Ejemplo n.º 1
0
        public BehaviourTreeBuilder Build(BehaviourTreeBuilder builder, params object[] args)
        {
            return(builder.Do("AggroTargetBySight", t =>
            {
                NWCreature self = (NWCreature)args[0];

                if (self.IsInCombat)
                {
                    return BehaviourTreeStatus.Failure;
                }

                float aggroRange = self.GetLocalFloat("AGGRO_RANGE");
                if (aggroRange <= 0.0f)
                {
                    aggroRange = 10.0f;
                }
                Location targetLocation = _.Location(
                    self.Area.Object,
                    _biowarePos.GetChangedPosition(self.Position, aggroRange, self.Facing),
                    self.Facing + 180.0f);

                NWCreature creature = NWCreature.Wrap(_.GetFirstObjectInShape(NWScript.SHAPE_SPELLCYLINDER, aggroRange, targetLocation, NWScript.TRUE, NWScript.OBJECT_TYPE_CREATURE, self.Position));
                while (creature.IsValid)
                {
                    if (_.GetIsEnemy(creature.Object, self.Object) == NWScript.TRUE &&
                        !_enmity.IsOnEnmityTable(self, creature) &&
                        _.GetDistanceBetween(self.Object, creature.Object) <= aggroRange &&
                        !creature.HasAnyEffect(NWScript.EFFECT_TYPE_INVISIBILITY, NWScript.EFFECT_TYPE_SANCTUARY))
                    {
                        _enmity.AdjustEnmity(self, creature, 0, 1);
                    }

                    creature = NWCreature.Wrap(_.GetNextObjectInShape(NWScript.SHAPE_SPELLCYLINDER, aggroRange, targetLocation, NWScript.TRUE, NWScript.OBJECT_TYPE_CREATURE, self.Position));
                }

                return BehaviourTreeStatus.Running;
            }));
        }
Ejemplo n.º 2
0
        public BehaviourTreeBuilder Build(BehaviourTreeBuilder builder, params object[] args)
        {
            return(builder.Do("AggroTargetBySound", t =>
            {
                NWCreature self = (NWCreature)args[0];

                if (self.IsInCombat)
                {
                    return BehaviourTreeStatus.Failure;
                }

                float aggroRange = self.GetLocalFloat("AGGRO_RANGE");
                if (aggroRange <= 0.0f)
                {
                    aggroRange = 5.0f;
                }

                int nth = 1;
                NWCreature creature = NWCreature.Wrap(_.GetNearestObject(NWScript.OBJECT_TYPE_CREATURE, self.Object, nth));
                while (creature.IsValid)
                {
                    if (_.GetIsEnemy(creature.Object, self.Object) == NWScript.TRUE &&
                        !_enmity.IsOnEnmityTable(self, creature) &&
                        !creature.HasAnyEffect(NWScript.EFFECT_TYPE_SANCTUARY) &&
                        _.GetDistanceBetween(self.Object, creature.Object) <= aggroRange &&
                        _.LineOfSightObject(self.Object, creature.Object) == NWScript.TRUE)
                    {
                        _enmity.AdjustEnmity(self, creature, 0, 1);
                    }

                    nth++;
                    creature = NWCreature.Wrap(_.GetNearestObject(NWScript.OBJECT_TYPE_CREATURE, self.Object, nth));
                }


                return BehaviourTreeStatus.Running;
            }));
        }
Ejemplo n.º 3
0
        public bool Run(object[] args)
        {
            NWCreature self = (NWCreature)args[0];

            if (self.IsInCombat)
            {
                return(false);
            }

            float aggroRange = self.GetLocalFloat("AGGRO_RANGE");

            if (aggroRange <= 0.0f)
            {
                aggroRange = 10.0f;
            }
            Location targetLocation = _.Location(
                self.Area.Object,
                _biowarePos.GetChangedPosition(self.Position, aggroRange, self.Facing),
                self.Facing + 180.0f);

            NWCreature creature = _.GetFirstObjectInShape(SHAPE_SPELLCYLINDER, aggroRange, targetLocation, TRUE, OBJECT_TYPE_CREATURE, self.Position);

            while (creature.IsValid)
            {
                if (_.GetIsEnemy(creature.Object, self.Object) == TRUE &&
                    !_enmity.IsOnEnmityTable(self, creature) &&
                    _.GetDistanceBetween(self.Object, creature.Object) <= aggroRange &&
                    !creature.HasAnyEffect(EFFECT_TYPE_INVISIBILITY, EFFECT_TYPE_SANCTUARY))
                {
                    _enmity.AdjustEnmity(self, creature, 0, 1);
                }

                creature = _.GetNextObjectInShape(SHAPE_SPELLCYLINDER, aggroRange, targetLocation, TRUE, OBJECT_TYPE_CREATURE, self.Position);
            }

            return(true);
        }
Ejemplo n.º 4
0
        protected void AggroTargetInRange(NWCreature self, NWCreature nearby)
        {
            float aggroRange = GetAggroRange(self);

            // Check distance
            if (GetDistanceBetween(self, nearby) > aggroRange)
            {
                return;
            }

            // Is creature dead?
            if (nearby.IsDead)
            {
                return;
            }

            // Does the nearby creature have line of sight to the creature being attacked?
            if (LineOfSightObject(self, nearby) == FALSE)
            {
                return;
            }

            // Is the nearby creature not an enemy?
            if (GetIsEnemy(nearby, self.Object) == FALSE)
            {
                return;
            }

            // Does the nearby creature have sanctuary?
            if (nearby.HasAnyEffect(EFFECT_TYPE_SANCTUARY))
            {
                return;
            }

            // Success. Increase enmity on the nearby target.
            EnmityService.AdjustEnmity(self, nearby, 0, 1);
        }
Ejemplo n.º 5
0
        public bool Run(object[] args)
        {
            NWCreature self = (NWCreature)args[0];

            if (self.IsInCombat)
            {
                return(false);
            }

            float aggroRange = self.GetLocalFloat("AGGRO_RANGE");

            if (aggroRange <= 0.0f)
            {
                aggroRange = 10.0f;
            }

            int        nth      = 1;
            NWCreature creature = _.GetNearestObject(OBJECT_TYPE_CREATURE, self.Object, nth);

            while (creature.IsValid)
            {
                if (_.GetIsEnemy(creature.Object, self.Object) == TRUE &&
                    !_enmity.IsOnEnmityTable(self, creature) &&
                    !creature.HasAnyEffect(EFFECT_TYPE_SANCTUARY) &&
                    _.GetDistanceBetween(self.Object, creature.Object) <= aggroRange &&
                    _.LineOfSightObject(self.Object, creature.Object) == TRUE)
                {
                    _enmity.AdjustEnmity(self, creature, 0, 1);
                }

                nth++;
                creature = _.GetNearestObject(OBJECT_TYPE_CREATURE, self.Object, nth);
            }


            return(true);
        }
Ejemplo n.º 6
0
        public bool Run(object[] args)
        {
            NWCreature self = (NWCreature)args[0];

            if (_enmity.IsEnmityTableEmpty(self) ||
                _.GetMovementRate(self.Object) == 1 ||  // 1 = Immobile
                self.HasAnyEffect(EFFECT_TYPE_DAZED) || // Dazed
                self.RightHand.CustomItemType == CustomItemType.BlasterRifle ||
                self.RightHand.CustomItemType == CustomItemType.BlasterPistol)
            {
                if (self.Data.ContainsKey("WarpToTargetIfStuck_Position"))
                {
                    self.Data.Remove("WarpToTargetIfStuck_Position");
                }
                if (self.Data.ContainsKey("WarpToTargetIfStuck_CyclesStuckInPlace"))
                {
                    self.Data.Remove("WarpToTargetIfStuck_CyclesStuckInPlace");
                }

                return(false);
            }


            Vector previousPosition = new Vector();

            if (self.Data.ContainsKey("WarpToTargetIfStuck_Position"))
            {
                previousPosition = (Vector)self.Data["WarpToTargetIfStuck_Position"];
            }

            Vector currentPosition = self.Position;

            if (previousPosition.m_X == currentPosition.m_X &&
                previousPosition.m_Y == currentPosition.m_Y &&
                previousPosition.m_Z == currentPosition.m_Z)
            {
                var cyclesStuck = 0;
                if (self.Data.ContainsKey("WarpToTargetIfStuck_CyclesStuckInPlace"))
                {
                    cyclesStuck = (int)self.Data["WarpToTargetIfStuck_CyclesStuckInPlace"];
                }
                cyclesStuck++;

                if (cyclesStuck >= 12) // Stuck for 12 seconds - warp to the target if still in the area.
                {
                    EnmityTable table     = _enmity.GetEnmityTable(self);
                    var         topTarget = table.Values.OrderByDescending(o => o.TotalAmount).FirstOrDefault();
                    if (topTarget != null && topTarget.TargetObject.IsValid)
                    {
                        var location = topTarget.TargetObject.Location;
                        _.AssignCommand(self.Object, () => _.JumpToLocation(location));
                    }

                    cyclesStuck = 0;
                }

                self.Data["WarpToTargetIfStuck_CyclesStuckInPlace"] = cyclesStuck;
            }
            else
            {
                self.Data["WarpToTargetIfStuck_CyclesStuckInPlace"] = 0;
            }

            self.Data["WarpToTargetIfStuck_Position"] = currentPosition;

            return(true);
        }