예제 #1
0
        public override bool DoSpell(Point target)
        {
            Player  player  = Game.Dungeon.Player;
            Dungeon dungeon = Game.Dungeon;

            //Check the target is within FOV

            //Get the FOV from Dungeon (this also updates the map creature FOV state)
            CreatureFOV currentFOV = Game.Dungeon.CalculateCreatureFOV(player);

            //Is the target in FOV
            if (!currentFOV.CheckTileFOV(target.x, target.y))
            {
                LogFile.Log.LogEntryDebug("Target out of FOV", LogDebugLevel.Medium);
                Game.MessageQueue.AddMessage("Target is out of sight.");

                return(false);
            }

            //Check there is a monster at target
            SquareContents squareContents = dungeon.MapSquareContents(player.LocationLevel, target);

            //Is there no monster here? If so, then slow it
            if (squareContents.monster != null)
            {
                Monster targetM = squareContents.monster;


                LogFile.Log.LogEntryDebug("Slowing " + targetM.SingleDescription, LogDebugLevel.Medium);
                Game.MessageQueue.AddMessage("Slow Monster!");

                //Check magic resistance
                bool monsterResisted = CheckMagicResistance(targetM);
                if (monsterResisted)
                {
                    return(true);
                }

                //Add the slow monster effect
                int duration = 5 * Creature.turnTicks + Game.Random.Next(10 * Creature.turnTicks);
                targetM.AddEffect(new MonsterEffects.SlowDown(duration, targetM.Speed / 2));

                return(true);
            }

            Game.MessageQueue.AddMessage("No target for slow monster.");
            LogFile.Log.LogEntryDebug("No monster to target for Slow Monster", LogDebugLevel.Medium);
            return(false);
        }
예제 #2
0
파일: FireLance.cs 프로젝트: vrum/roguelike
        public override bool DoSpell(Point target)
        {
            Player  player  = Game.Dungeon.Player;
            Dungeon dungeon = Game.Dungeon;


            //Check the target is within FOV

            //Get the FOV from Dungeon (this also updates the map creature FOV state)
            CreatureFOV currentFOV = Game.Dungeon.CalculateCreatureFOV(player);

            //Is the target in FOV
            if (!currentFOV.CheckTileFOV(target.x, target.y))
            {
                LogFile.Log.LogEntryDebug("Target out of FOV", LogDebugLevel.Medium);
                Game.MessageQueue.AddMessage("Target is out of sight.");

                return(false);
            }

            //Keep hitting monsters until we hit a wall

            Point targetSquare = target;

            int deltaX = targetSquare.x - player.LocationMap.x;
            int deltaY = targetSquare.y - player.LocationMap.y;

            if (deltaX == 0 && deltaY == 0)
            {
                LogFile.Log.LogEntryDebug("No target for fireland", LogDebugLevel.Medium);
                Game.MessageQueue.AddMessage("No target for Fire Lance.");

                return(false);
            }

            /*
             * int unitX = 0;
             * int unitY = 0;
             *
             * if (deltaX < 0 && deltaY < 0)
             * {
             *  unitX = -1;
             *  unitY = -1;
             * }
             * else if (deltaX < 0 && deltaY > 0)
             * {
             *  unitX = -1;
             *  unitY = 1;
             * }
             * else if (deltaX > 0 && deltaY < 0)
             * {
             *  unitX = 1;
             *  unitY = -1;
             * }
             * else if (deltaX > 0 && deltaY > 0)
             * {
             *  unitX = 1;
             *  unitY = 1;
             * }
             * else if (deltaX == 0 && deltaY > 0)
             * {
             *  unitX = 0;
             *  unitY = 1;
             * }
             * else if (deltaX == 0 && deltaY < 0)
             * {
             *  unitX = 0;
             *  unitY = -1;
             * }
             * else if (deltaY == 0 && deltaX < 0)
             * {
             *  unitX = -1;
             *  unitY = 0;
             * }
             * else if (deltaY == 0 && deltaX > 0)
             * {
             *  unitX = 1;
             *  unitY = 0;
             * }*/
            /*
             * //Extend this line until it hits an edge
             * int finalX = player.LocationMap.x;
             * int finalY = player.LocationMap.y;
             *
             * while(finalX < dungeon.Levels[player.LocationLevel].width &&
             *  finalY < dungeon.Levels[player.LocationLevel].height && finalX >0 && finalY > 0) {
             *  finalX += deltaX;
             *  finalY += deltaY;
             * }
             *
             * //int currentX = targetSquare.x;
             * // int currentY = targetSquare.y;
             *
             * int lastX = targetSquare.x;
             * int lastY = targetSquare.y;
             *
             * bool finishedLine = false;
             *
             * //This one is always cast, even without a target
             *
             * Game.MessageQueue.AddMessage("Fire Lance!");
             *
             * //Cast in 2 stages. The first stage from us to target 1. The next stage from target 1 to the end of the map
             *
             * TCODLineDrawing.InitLine(player.LocationMap.x, player.LocationMap.y, finalX, finalY);
             * int firstXStep = 0;
             * int firstYStep = 0;
             *
             * TCODLineDrawing.StepLine(ref firstXStep, ref firstYStep);
             *
             * int currentX = firstXStep;
             * int currentY = firstYStep;
             *
             * //Cast a line between the start and end
             * TCODLineDrawing.InitLine(currentX, currentY, targetSquare.x, targetSquare.y);
             *
             * do
             * {
             *
             *  LogFile.Log.LogEntryDebug("FireLance: Attacking square: x: " + currentX + " y:" + currentY, LogDebugLevel.Medium);
             *
             *  //Finish conditions - run out of line or hit wall (should always happen)
             *
             *  if (!dungeon.MapSquareIsWalkable(player.LocationLevel, new Point(currentX, currentY)))
             *  {
             *
             *      //Finish
             *      LogFile.Log.LogEntryDebug("hit wall Finished line 1 at: x: " + currentX + " y:" + currentY, LogDebugLevel.Medium);
             *      break;
             *  }
             *
             *  if (Dungeon.GetDistanceBetween(player.LocationMap, new Point(currentX, currentY)) > fireRange)
             *  {
             *      //Finish - range
             *      LogFile.Log.LogEntryDebug("(range) Finished line 1 at: x: " + currentX + " y:" + currentY, LogDebugLevel.Medium);
             *      break;
             *  }
             *
             *  //Is there a monster here? If so, then attack it
             *
             *  SquareContents squareContents = dungeon.MapSquareContents(player.LocationLevel, new Point(currentX, currentY));
             *
             *  if (squareContents.monster != null)
             *  {
             *      HitMonster(player, squareContents.monster);
             *  }
             *
             *  lastX = currentX; lastY = currentY;
             *
             *  finishedLine = TCODLineDrawing.StepLine(ref currentX, ref currentY);
             *
             *  if (finishedLine)
             *  {
             *      LogFile.Log.LogEntryDebug("Finished line 1 at: x: " + currentX + " y:" + currentY, LogDebugLevel.Low);
             *  }
             * } while (finishedLine == false);
             *
             *
             * //The second stage from one square away from target 1 to the end
             *
             * TCODLineDrawing.InitLine(targetSquare.x, targetSquare.y, finalX, finalY);
             * TCODLineDrawing.StepLine(ref currentX, ref currentY);
             *
             * //Cast a line between the start and end
             * TCODLineDrawing.InitLine(currentX, currentY, finalX, finalY);
             *
             * do
             * {
             *
             *  LogFile.Log.LogEntryDebug("FireLance: Attacking square: x: " + currentX + " y:" + currentY, LogDebugLevel.Low);
             *
             *  //Finish conditions - run out of line or hit wall (should always happen)
             *
             *  if (!dungeon.MapSquareIsWalkable(player.LocationLevel, new Point(currentX, currentY)))
             *  {
             *
             *      //Finish
             *      LogFile.Log.LogEntryDebug("Finished line 2 at: x: " + currentX + " y:" + currentY, LogDebugLevel.Medium);
             *      break;
             *  }
             *
             *  if (Dungeon.GetDistanceBetween(player.LocationMap, new Point(currentX, currentY)) > fireRange)
             *  {
             *      //Finish - range
             *      LogFile.Log.LogEntryDebug("(range) Finished line 1 at: x: " + currentX + " y:" + currentY, LogDebugLevel.Medium);
             *      break;
             *  }
             *
             *  //Is there a monster here? If so, then attack it
             *
             *  SquareContents squareContents = dungeon.MapSquareContents(player.LocationLevel, new Point(currentX, currentY));
             *
             *  if (squareContents.monster != null)
             *  {
             *      HitMonster(player, squareContents.monster);
             *  }
             *
             *  lastX = currentX; lastY = currentY;
             *
             *  finishedLine = TCODLineDrawing.StepLine(ref currentX, ref currentY);
             *
             *  if (finishedLine)
             *  {
             *      LogFile.Log.LogEntryDebug("Finished line 2 at: x: " + currentX + " y:" + currentY, LogDebugLevel.Low);
             *  }
             * } while (finishedLine == false);
             *
             * //Find the first square away from us
             * //Cast the ray from here
             *
             *
             * Screen.Instance.DrawFlashLine(new Point(player.LocationMap.x, player.LocationMap.y), new Point(lastX, lastY), ColorPresets.Yellow);
             */
            return(true);
        }
예제 #3
0
        public override bool DoSpell(Point target)
        {
            Player  player  = Game.Dungeon.Player;
            Dungeon dungeon = Game.Dungeon;

            //Check the target is within FOV

            //Get the FOV from Dungeon (this also updates the map creature FOV state)
            CreatureFOV currentFOV = Game.Dungeon.CalculateCreatureFOV(player);

            //Is the target in FOV
            if (!currentFOV.CheckTileFOV(target.x, target.y))
            {
                LogFile.Log.LogEntryDebug("Target out of FOV", LogDebugLevel.Medium);
                Game.MessageQueue.AddMessage("Target is out of sight.");

                return(false);
            }

            //Check there is a monster at target
            SquareContents squareContents = dungeon.MapSquareContents(player.LocationLevel, target);

            //Is there no monster here? If so, then attack it
            if (squareContents.monster != null)
            {
                LogFile.Log.LogEntryDebug("Firing magic missile", LogDebugLevel.Medium);
                Game.MessageQueue.AddMessage("Magic Missile!");

                Monster monster = squareContents.monster;

                //Check magic resistance
                bool monsterResisted = CheckMagicResistance(squareContents.monster);

                //Draw attack
                CombatResults results = CombatResults.DefenderDamaged;
                if (monsterResisted)
                {
                    results = CombatResults.DefenderUnhurt;
                }

                Screen.Instance.DrawMissileAttack(player, monster, results, ColorPresets.Violet);

                //If monster resisted no damage
                if (monsterResisted)
                {
                    return(true);
                }

                //Damage base

                int damageBase;

                if (player.MagicStat > 120)
                {
                    damageBase = 8;
                }
                else if (player.MagicStat > 60)
                {
                    damageBase = 6;
                }
                else if (player.MagicStat > 30)
                {
                    damageBase = 5;
                }
                else
                {
                    damageBase = 4;
                }

                //Damage done is just the base

                int damage = Utility.DamageRoll(damageBase);

                string combatResultsMsg = "PvM Magic Missile: Dam: 1d" + damageBase + " -> " + damage;
                LogFile.Log.LogEntryDebug(combatResultsMsg, LogDebugLevel.Medium);

                //Apply damage
                player.ApplyDamageToMonster(squareContents.monster, damage, true, false);


                //Graphical effect

                /*
                 * TCODLineDrawing.InitLine(player.LocationMap.x, player.LocationMap.y, target.x, target.y);
                 * int firstXStep = 0;
                 * int firstYStep = 0;
                 *
                 * TCODLineDrawing.StepLine(ref firstXStep, ref firstYStep);*/

                return(true);
            }

            Game.MessageQueue.AddMessage("No target for magic missile.");
            LogFile.Log.LogEntryDebug("No monster to target for Magic Missile", LogDebugLevel.Medium);
            return(false);
        }
예제 #4
0
        public override bool DoSpell(Point target)
        {
            Player  player  = Game.Dungeon.Player;
            Dungeon dungeon = Game.Dungeon;

            //Check the target is within FOV

            //Get the FOV from Dungeon (this also updates the map creature FOV state)
            CreatureFOV currentFOV = Game.Dungeon.CalculateCreatureFOV(player);

            //Is the target in FOV
            if (!currentFOV.CheckTileFOV(target.x, target.y))
            {
                LogFile.Log.LogEntryDebug("Target out of FOV", LogDebugLevel.Medium);
                Game.MessageQueue.AddMessage("Target is out of sight.");

                return(false);
            }

            //Hit monsters around the target

            Point targetSquare = target;

            List <Point> splashSquares = new List <Point>();

            for (int i = targetSquare.x - spellRange; i < targetSquare.x + spellRange; i++)
            {
                for (int j = targetSquare.y - spellRange; j < targetSquare.y + spellRange; j++)
                {
                    if (Math.Pow(i - targetSquare.x, 2) + Math.Pow(j - targetSquare.y, 2) < Math.Pow(spellRange, 2))
                    {
                        splashSquares.Add(new Point(i, j));
                        LogFile.Log.LogEntryDebug("FireBall Added square x: " + i + " y: " + j, LogDebugLevel.Low);
                    }
                }
            }


            //This one is always cast, even without a target

            Game.MessageQueue.AddMessage("Fire Ball!");


            foreach (Point p in splashSquares)
            {
                //Is there a monster here? If so, then attack it

                SquareContents squareContents = dungeon.MapSquareContents(player.LocationLevel, new Point(p.x, p.y));

                if (squareContents.monster != null)
                {
                    HitMonster(player, squareContents.monster);
                }

                if (squareContents.player != null)
                {
                    HitPlayer();
                }
            }

            //Screen.Instance.DrawFlashSquares(splashSquares, ColorPresets.Red);

            return(true);
        }
예제 #5
0
        public override bool DoSpell(Point target)
        {
            Player  player  = Game.Dungeon.Player;
            Dungeon dungeon = Game.Dungeon;

            //Check the target is within FOV

            //Get the FOV from Dungeon (this also updates the map creature FOV state)
            CreatureFOV currentFOV = Game.Dungeon.CalculateCreatureFOV(player);

            //Is the target in FOV
            if (!currentFOV.CheckTileFOV(target.x, target.y))
            {
                LogFile.Log.LogEntryDebug("Target out of FOV", LogDebugLevel.Medium);
                Game.MessageQueue.AddMessage("Target is out of sight.");

                return(false);
            }

            //Check there is a monster at target
            SquareContents squareContents = dungeon.MapSquareContents(player.LocationLevel, target);

            //Is there no monster here? If so, then attack it
            if (squareContents.monster != null)
            {
                LogFile.Log.LogEntryDebug("Firing energy blast", LogDebugLevel.Medium);
                Game.MessageQueue.AddMessage("Energy Blast!");

                //Attack the monster

                //Check magic resistance
                bool monsterResisted = CheckMagicResistance(squareContents.monster);

                //Draw attack
                CombatResults results = CombatResults.DefenderDamaged;
                if (monsterResisted)
                {
                    results = CombatResults.DefenderUnhurt;
                }

                Screen.Instance.DrawMissileAttack(player, squareContents.monster, results, ColorPresets.Crimson);

                //If monster resisted no damage
                if (monsterResisted)
                {
                    return(true);
                }

                //Damage base

                int damageBase;

                if (player.MagicStat > 140)
                {
                    damageBase = 12;
                }

                if (player.MagicStat > 120)
                {
                    damageBase = 10;
                }

                if (player.MagicStat > 100)
                {
                    damageBase = 8;
                }
                else
                {
                    damageBase = 6;
                }

                //Damage done is just the base

                int damage = Utility.DamageRoll(damageBase) + Utility.DamageRoll(damageBase) + Utility.DamageRoll(damageBase);// +damageBase / 2;

                string combatResultsMsg = "PvM Energy Blast: Dam: 3d" + damageBase + " -> " + (damage);
                LogFile.Log.LogEntryDebug(combatResultsMsg, LogDebugLevel.Medium);

                //Apply damage
                player.ApplyDamageToMonster(squareContents.monster, damage, true, false);

                return(true);
            }

            Game.MessageQueue.AddMessage("No target for energy blast.");
            LogFile.Log.LogEntryDebug("No monster to target for Energy Blast", LogDebugLevel.Medium);
            return(false);
        }