Exemplo n.º 1
0
        public override void Initialize()
        {
            this.m_CurrentTarget = (IGameObject)null;
            this.m_RefreshTarget = 200;
            this.m_State         = SimpleAIStates.SEEK;
            SpectreGlobalData globalSpectreData = this.m_Game.Game.AssetDatabase.GlobalSpectreData;

            SpectreGlobalData.SpectreSize spectreSize = SpectreGlobalData.SpectreSize.Small;
            if (this.m_Game.Game.ScriptModules.Spectre != null)
            {
                if (this.m_Spector.DesignID == this.m_Game.Game.ScriptModules.Spectre.SmallDesignId)
                {
                    spectreSize = SpectreGlobalData.SpectreSize.Small;
                }
                else if (this.m_Spector.DesignID == this.m_Game.Game.ScriptModules.Spectre.MediumDesignId)
                {
                    spectreSize = SpectreGlobalData.SpectreSize.Medium;
                }
                else if (this.m_Spector.DesignID == this.m_Game.Game.ScriptModules.Spectre.BigDesignId)
                {
                    spectreSize = SpectreGlobalData.SpectreSize.Large;
                }
            }
            this.m_Spector.Maneuvering.PostSetProp("SetCombatAIDamage", (object)globalSpectreData.Damage[(int)spectreSize].Crew, (object)globalSpectreData.Damage[(int)spectreSize].Population, (object)globalSpectreData.Damage[(int)spectreSize].InfraDamage, (object)globalSpectreData.Damage[(int)spectreSize].TeraDamage);
        }
Exemplo n.º 2
0
 private void ThinkSeek()
 {
     if (this.m_Planets.Count <= 0)
     {
         return;
     }
     this.ObtainPositionAndFacing();
     this.m_Meteor.Maneuvering.PostAddGoal(this.m_TargetPosition, this.m_TargetFacing);
     this.m_State = SimpleAIStates.TRACK;
 }
Exemplo n.º 3
0
        public override void Initialize()
        {
            this.m_State = SimpleAIStates.SEEK;
            this.m_VictoryConditionsMet = false;
            this.m_Planets        = new List <StellarBody>();
            this.m_UpdateRate     = 0;
            this.m_Target         = (StellarBody)null;
            this.m_TargetFacing   = -Vector3.UnitZ;
            this.m_TargetPosition = Vector3.Zero;
            CometGlobalData globalCometData = this.m_Game.Game.AssetDatabase.GlobalCometData;

            this.m_Comet.Maneuvering.PostSetProp("SetCombatAIDamage", (object)globalCometData.Damage.Crew, (object)globalCometData.Damage.Population, (object)globalCometData.Damage.InfraDamage, (object)globalCometData.Damage.TeraDamage);
        }
Exemplo n.º 4
0
        public override void Initialize()
        {
            this.m_State = SimpleAIStates.SEEK;
            this.m_VictoryConditionsMet = false;
            this.m_FailureConditionMet  = false;
            this.m_Planets           = new List <StellarBody>();
            this.m_UpdateRate        = 0;
            this.m_Size              = MeteorCombatAIControl.GetMeteorSize(this.m_Game, this.m_Meteor.DesignID);
            this.m_CanSubDivide      = MeteorCombatAIControl.CanSubDivide(this.m_Size);
            this.m_CanApplyResources = true;
            this.m_Target            = (StellarBody)null;
            this.m_TargetFacing      = -Vector3.UnitZ;
            this.m_TargetPosition    = Vector3.Zero;
            MeteorShowerGlobalData meteorShowerData = this.m_Game.Game.AssetDatabase.GlobalMeteorShowerData;

            this.m_Meteor.Maneuvering.PostSetProp("SetCombatAIDamage", (object)meteorShowerData.Damage[(int)this.m_Size].Crew, (object)meteorShowerData.Damage[(int)this.m_Size].Population, (object)meteorShowerData.Damage[(int)this.m_Size].InfraDamage, (object)meteorShowerData.Damage[(int)this.m_Size].TeraDamage);
        }
Exemplo n.º 5
0
 private void ThinkSeek()
 {
     if (this.m_CurrentTarget == null)
     {
         return;
     }
     if (this.m_CurrentTarget is Ship)
     {
         this.m_Spector.SetShipTarget(this.m_CurrentTarget.ObjectID, (this.m_CurrentTarget as Ship).ShipSphere.center, true, 0);
     }
     else if (this.m_CurrentTarget is StellarBody)
     {
         this.m_Spector.SetShipTarget(this.m_CurrentTarget.ObjectID, Vector3.Zero, true, 0);
     }
     this.m_RefreshTarget = 200;
     this.m_State         = SimpleAIStates.TRACK;
 }
Exemplo n.º 6
0
        private void ChaseCreature(Creature newTarget)
        {
            //Confirm this as current target
            currentTarget = newTarget;

            //Go into pursuit mode
            AIState = SimpleAIStates.Pursuit;

            //Find location of next step on the path towards them
            Point nextStep = Game.Dungeon.GetPathTo(this, newTarget);

            bool moveIntoSquare = true;

            //If this is the same as the target creature's location, we are adjacent and can attack
            if (nextStep.x == newTarget.LocationMap.x && nextStep.y == newTarget.LocationMap.y)
            {
                //Attack the monster
                //Ugly select here
                CombatResults result;

                if (newTarget == Game.Dungeon.Player)
                {
                    result = AttackPlayer(newTarget as Player);
                }
                else
                {
                    //It's a normal creature
                    result = AttackMonster(newTarget as Monster);
                }


                //If we killed it, move into its square
                if (result != CombatResults.DefenderDied)
                {
                    moveIntoSquare = false;
                }
            }

            //Otherwise (or if the creature died), move towards it (or its corpse)
            if (moveIntoSquare)
            {
                LocationMap = nextStep;
            }
        }
Exemplo n.º 7
0
 private void ThinkTrack()
 {
     if (this.m_CurrentTarget == null)
     {
         this.m_State = SimpleAIStates.SEEK;
     }
     else
     {
         bool  flag = false;
         float num  = 0.0f;
         if (this.m_CurrentTarget is Ship)
         {
             Ship currentTarget = this.m_CurrentTarget as Ship;
             this.m_Spector.Maneuvering.PostAddGoal(currentTarget.Position, -Vector3.UnitZ);
             if (!Ship.IsActiveShip(currentTarget))
             {
                 this.m_CurrentTarget = (IGameObject)null;
             }
         }
         else if (this.m_CurrentTarget is StellarBody)
         {
             this.m_Spector.Maneuvering.PostAddGoal((this.m_CurrentTarget as StellarBody).Parameters.Position, -Vector3.UnitZ);
             flag = true;
         }
         if ((double)num <= 25000000.0 && !flag)
         {
             return;
         }
         --this.m_RefreshTarget;
         if (this.m_RefreshTarget > 0)
         {
             return;
         }
         this.m_CurrentTarget = (IGameObject)null;
     }
 }
Exemplo n.º 8
0
 public MonsterSimpleAI()
 {
     AIState       = SimpleAIStates.Patrol;
     currentTarget = null;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Run the Simple AI actions
        /// </summary>
        public override void ProcessTurn()
        {
            //If in pursuit state, continue to pursue enemy until it is dead (or creature itself is killed) [no FOV used after initial target selected]

            //If in randomWalk state, look for new enemies in FOV.
            //Closest enemy becomes new target

            //If no targets, move randomly

            Random rand = Game.Random;


            if (AIState == SimpleAIStates.Pursuit)
            {
                //Pursuit state, continue chasing and attacking target

                //Is target yet living?
                if (currentTarget.Alive == false)
                {
                    //If not, go to non-chase state
                    AIState = SimpleAIStates.RandomWalk;
                }
                //Is target on another level (i.e. has escaped down the stairs)
                else if (currentTarget.LocationLevel != this.LocationLevel)
                {
                    AIState = SimpleAIStates.RandomWalk;
                }
                else
                {
                    //Otherwise continue to chase

                    ChaseCreature(currentTarget);
                }
            }

            if (AIState == SimpleAIStates.RandomWalk)
            {
                //RandomWalk state

                //Search an area of sightRadius on either side for creatures and check they are in the FOV

                Map currentMap = Game.Dungeon.Levels[LocationLevel];

                //Get the FOV from Dungeon (this also updates the map creature FOV state)
                TCODFov currentFOV = Game.Dungeon.CalculateCreatureFOV(this);
                //currentFOV.CalculateFOV(LocationMap.x, LocationMap.y, SightRadius);

                //Check for other creatures within this creature's FOV

                int xl = LocationMap.x - SightRadius;
                int xr = LocationMap.x + SightRadius;

                int yt = LocationMap.y - SightRadius;
                int yb = LocationMap.y + SightRadius;

                //If sight is infinite, check all the map
                if (SightRadius == 0)
                {
                    xl = 0;
                    xr = currentMap.width;
                    yt = 0;
                    yb = currentMap.height;
                }

                if (xl < 0)
                {
                    xl = 0;
                }
                if (xr >= currentMap.width)
                {
                    xr = currentMap.width - 1;
                }
                if (yt < 0)
                {
                    yt = 0;
                }
                if (yb >= currentMap.height)
                {
                    yb = currentMap.height - 1;
                }

                //List will contain monsters & player
                List <Creature> creaturesInFOV = new List <Creature>();

                foreach (Monster monster in Game.Dungeon.Monsters)
                {
                    //Same monster
                    if (monster == this)
                    {
                        continue;
                    }

                    //Not on the same level
                    if (monster.LocationLevel != this.LocationLevel)
                    {
                        continue;
                    }

                    //Not in FOV
                    if (!currentFOV.CheckTileFOV(monster.LocationMap.x, monster.LocationMap.y))
                    {
                        continue;
                    }

                    //Otherwise add to list of possible targets
                    creaturesInFOV.Add(monster);

                    LogFile.Log.LogEntryDebug(this.Representation + " spots " + monster.Representation, LogDebugLevel.Medium);
                }

                //Check PC
                if (Game.Dungeon.Player.LocationLevel == this.LocationLevel)
                {
                    if (currentFOV.CheckTileFOV(Game.Dungeon.Player.LocationMap.x, Game.Dungeon.Player.LocationMap.y))
                    {
                        creaturesInFOV.Add(Game.Dungeon.Player);
                        LogFile.Log.LogEntryDebug(this.Representation + " spots " + Game.Dungeon.Player.Representation, LogDebugLevel.Medium);
                    }
                }

                //If there are possible targets, find the closest and chase it
                //Otherwise continue to move randomly

                if (creaturesInFOV.Count > 0)
                {
                    //Find the closest creature
                    Creature closestCreature = null;
                    double   closestDistance = Double.MaxValue; //a long way

                    foreach (Creature creature in creaturesInFOV)
                    {
                        double distanceSq = Math.Pow(creature.LocationMap.x - this.LocationMap.x, 2) +
                                            Math.Pow(creature.LocationMap.y - this.LocationMap.y, 2);

                        double distance = Math.Sqrt(distanceSq);

                        if (distance < closestDistance)
                        {
                            closestDistance = distance;
                            closestCreature = creature;
                        }
                    }

                    //Start chasing this creature
                    LogFile.Log.LogEntryDebug(this.Representation + " chases " + closestCreature.Representation, LogDebugLevel.Medium);
                    ChaseCreature(closestCreature);
                }
                else
                {
                    //Move randomly. If we walk into something attack it, but it does not become a new target

                    int direction = rand.Next(9);

                    int moveX = 0;
                    int moveY = 0;

                    moveX = direction / 3 - 1;
                    moveY = direction % 3 - 1;

                    //If we're not moving quit at this point, otherwise the target square will be the one we're in
                    if (moveX == 0 && moveY == 0)
                    {
                        return;
                    }

                    //Check this is a valid move
                    bool  validMove   = false;
                    Point newLocation = new Point(LocationMap.x + moveX, LocationMap.y + moveY);

                    validMove = Game.Dungeon.MapSquareCanBeEntered(LocationLevel, newLocation);

                    //Give up if this is not a valid move
                    if (!validMove)
                    {
                        return;
                    }

                    //Check if the square is occupied by a PC or monster
                    SquareContents contents           = Game.Dungeon.MapSquareContents(LocationLevel, newLocation);
                    bool           okToMoveIntoSquare = false;

                    if (contents.empty)
                    {
                        okToMoveIntoSquare = true;
                    }

                    if (contents.player != null)
                    {
                        //Attack the player
                        CombatResults result = AttackPlayer(contents.player);

                        if (result == CombatResults.DefenderDied)
                        {
                            //Bad news for the player here!
                            okToMoveIntoSquare = true;
                        }
                    }

                    if (contents.monster != null)
                    {
                        //Attack the monster
                        CombatResults result = AttackMonster(contents.monster);

                        if (result == CombatResults.DefenderDied)
                        {
                            okToMoveIntoSquare = true;
                        }
                    }

                    //Move if allowed
                    if (okToMoveIntoSquare)
                    {
                        LocationMap = newLocation;
                    }
                }
            }
        }
Exemplo n.º 10
0
 public MonsterSimpleAI()
 {
     AIState = SimpleAIStates.RandomWalk;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Run the Simple AI actions
        /// </summary>
        public override void ProcessTurn()
        {
            //If in pursuit state, continue to pursue enemy until it is dead (or creature itself is killed) [no FOV used after initial target selected]

            //If in randomWalk state, look for new enemies in FOV.
            //Closest enemy becomes new target

            //If no targets, move randomly

            Random rand = Game.Random;

            if (AIState == SimpleAIStates.Pursuit)
            {
                //Pursuit state, continue chasing and attacking target

                //Is target yet living?
                if (currentTarget.Alive == false)
                {
                    //If not, go to non-chase state
                    AIState = SimpleAIStates.RandomWalk;
                }
                //Is target on another level (i.e. has escaped down the stairs)
                else if (currentTarget.LocationLevel != this.LocationLevel)
                {
                    AIState = SimpleAIStates.RandomWalk;
                }
                else
                {
                    //Otherwise continue to chase

                    ChaseCreature(currentTarget);
                }
            }

            if(AIState == SimpleAIStates.RandomWalk) {
                //RandomWalk state

                //Search an area of sightRadius on either side for creatures and check they are in the FOV

                Map currentMap = Game.Dungeon.Levels[LocationLevel];

                //Get the FOV from Dungeon (this also updates the map creature FOV state)
                TCODFov currentFOV = Game.Dungeon.CalculateCreatureFOV(this);
                //currentFOV.CalculateFOV(LocationMap.x, LocationMap.y, SightRadius);

                //Check for other creatures within this creature's FOV

                int xl = LocationMap.x - SightRadius;
                int xr = LocationMap.x + SightRadius;

                int yt = LocationMap.y - SightRadius;
                int yb = LocationMap.y + SightRadius;

                //If sight is infinite, check all the map
                if (SightRadius == 0)
                {
                    xl = 0;
                    xr = currentMap.width;
                    yt = 0;
                    yb = currentMap.height;
                }

                if (xl < 0)
                    xl = 0;
                if(xr >= currentMap.width)
                    xr = currentMap.width - 1;
                if (yt < 0)
                    yt = 0;
                if (yb >= currentMap.height)
                    yb = currentMap.height - 1;

                //List will contain monsters & player
                List<Creature> creaturesInFOV = new List<Creature>();

                foreach (Monster monster in Game.Dungeon.Monsters)
                {
                    //Same monster
                    if (monster == this)
                        continue;

                    //Not on the same level
                    if (monster.LocationLevel != this.LocationLevel)
                        continue;

                    //Not in FOV
                    if (!currentFOV.CheckTileFOV(monster.LocationMap.x, monster.LocationMap.y))
                        continue;

                    //Otherwise add to list of possible targets
                    creaturesInFOV.Add(monster);

                    LogFile.Log.LogEntryDebug(this.Representation + " spots " + monster.Representation, LogDebugLevel.Medium);
                }

                //Check PC
                if (Game.Dungeon.Player.LocationLevel == this.LocationLevel)
                {
                    if (currentFOV.CheckTileFOV(Game.Dungeon.Player.LocationMap.x, Game.Dungeon.Player.LocationMap.y))
                    {
                        creaturesInFOV.Add(Game.Dungeon.Player);
                        LogFile.Log.LogEntryDebug(this.Representation + " spots " + Game.Dungeon.Player.Representation, LogDebugLevel.Medium);
                    }
                }

                //If there are possible targets, find the closest and chase it
                //Otherwise continue to move randomly

                if (creaturesInFOV.Count > 0)
                {
                    //Find the closest creature
                    Creature closestCreature = null;
                    double closestDistance = Double.MaxValue; //a long way

                    foreach (Creature creature in creaturesInFOV)
                    {
                        double distanceSq = Math.Pow(creature.LocationMap.x - this.LocationMap.x, 2) +
                            Math.Pow(creature.LocationMap.y - this.LocationMap.y, 2);

                        double distance = Math.Sqrt(distanceSq);

                        if (distance < closestDistance)
                        {
                            closestDistance = distance;
                            closestCreature = creature;
                        }
                    }

                    //Start chasing this creature
                    LogFile.Log.LogEntryDebug(this.Representation + " chases " + closestCreature.Representation, LogDebugLevel.Medium);
                    ChaseCreature(closestCreature);
                }
                else
                {
                    //Move randomly. If we walk into something attack it, but it does not become a new target

                    int direction = rand.Next(9);

                    int moveX = 0;
                    int moveY = 0;

                    moveX = direction / 3 - 1;
                    moveY = direction % 3 - 1;

                    //If we're not moving quit at this point, otherwise the target square will be the one we're in
                    if (moveX == 0 && moveY == 0)
                    {
                        return;
                    }

                    //Check this is a valid move
                    bool validMove = false;
                    Point newLocation = new Point(LocationMap.x + moveX, LocationMap.y + moveY);

                    validMove = Game.Dungeon.MapSquareCanBeEntered(LocationLevel, newLocation);

                    //Give up if this is not a valid move
                    if (!validMove)
                        return;

                    //Check if the square is occupied by a PC or monster
                    SquareContents contents = Game.Dungeon.MapSquareContents(LocationLevel, newLocation);
                    bool okToMoveIntoSquare = false;

                    if (contents.empty)
                    {
                        okToMoveIntoSquare = true;
                    }

                    if (contents.player != null)
                    {
                        //Attack the player
                        CombatResults result = AttackPlayer(contents.player);

                        if (result == CombatResults.DefenderDied)
                        {
                            //Bad news for the player here!
                            okToMoveIntoSquare = true;
                        }
                    }

                    if (contents.monster != null)
                    {
                        //Attack the monster
                        CombatResults result = AttackMonster(contents.monster);

                        if (result == CombatResults.DefenderDied)
                        {
                            okToMoveIntoSquare = true;
                        }
                    }

                    //Move if allowed
                    if (okToMoveIntoSquare)
                    {
                        LocationMap = newLocation;
                    }
                }
            }
        }
Exemplo n.º 12
0
 public MonsterSimpleAI()
 {
     AIState = SimpleAIStates.RandomWalk;
 }
Exemplo n.º 13
0
        private void ChaseCreature(Creature newTarget)
        {
            //Confirm this as current target
            currentTarget = newTarget;

            //Go into pursuit mode
            AIState = SimpleAIStates.Pursuit;

            //Find location of next step on the path towards them
            Point nextStep = Game.Dungeon.GetPathTo(this, newTarget);

            bool moveIntoSquare = true;

            //If this is the same as the target creature's location, we are adjacent and can attack
            if (nextStep.x == newTarget.LocationMap.x && nextStep.y == newTarget.LocationMap.y)
            {
                //Attack the monster
                //Ugly select here
                CombatResults result;

                if (newTarget == Game.Dungeon.Player)
                {
                    result = AttackPlayer(newTarget as Player);
                }
                else
                {
                    //It's a normal creature
                    result = AttackMonster(newTarget as Monster);
                }

                //If we killed it, move into its square
                if (result != CombatResults.DefenderDied)
                {
                    moveIntoSquare = false;
                }
            }

            //Otherwise (or if the creature died), move towards it (or its corpse)
            if (moveIntoSquare)
            {
                LocationMap = nextStep;
            }
        }