Beispiel #1
0
        private void ReturnToSpawnPoint(NWCreature self)
        {
            if (self.IsInCombat || !EnmityService.IsEnmityTableEmpty(self))
            {
                return;
            }

            if (_.GetCurrentAction(self.Object) == _.ACTION_INVALID &&
                _.IsInConversation(self.Object) == _.FALSE &&
                _.GetCurrentAction(self.Object) != _.ACTION_RANDOMWALK)
            {
                var      flags         = GetAIFlags(self);
                Location spawnLocation = self.GetLocalLocation("AI_SPAWN_POINT");
                // If creature also has the RandomWalk flag, only send them back to the spawn point
                // if they go outside the range (15 meters)
                if ((flags & AIFlags.RandomWalk) != 0 &&
                    _.GetDistanceBetweenLocations(self.Location, spawnLocation) <= 15.0f)
                {
                    return;
                }

                self.AssignCommand(() => _.ActionMoveToLocation(spawnLocation));
            }
        }