Ejemplo n.º 1
0
        /// <summary>
        /// Update the cellId of the specified fighter.
        /// </summary>
        public void UpdateFighterCell(int id, int cell)
        {
            BFighter fighter = GetFighter(id);

            if (fighter != null)
            {
                fighter.CellId = cell;
            }
        }
Ejemplo n.º 2
0
        public static void GameFightTurnEndMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameFightTurnEndMessage msg = (GameFightTurnEndMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            if (msg.id == account.CharacterBaseInformations.id)
            {
                int        num4 = 0;
                List <int> list = new List <int>();
                account.Fight.IsFighterTurn = false;
                account.Fight.TotalLaunchBySpell.Clear();       //Nettoyage des variables de vérification de lancement d'un sort
                account.Fight.TotalLaunchByCellBySpell.Clear(); //Nettoyage des variables de vérification de lancement d'un sort
                for (int i = 0; i < account.Fight.DurationByEffect.Keys.Count; i++)
                {
                    Dictionary <int, int> durationPerEffect = account.Fight.DurationByEffect;
                    num4 = Enumerable.ElementAtOrDefault <int>(account.Fight.DurationByEffect.Keys, i);
                    durationPerEffect[num4] = (durationPerEffect[num4] - 1);
                    if (account.Fight.DurationByEffect[Enumerable.ElementAtOrDefault <int>(account.Fight.DurationByEffect.Keys, i)] <= 0)
                    {
                        list.Add(Enumerable.ElementAtOrDefault <int>(account.Fight.DurationByEffect.Keys, i));
                    }
                }
                while (list.Count > 0)
                {
                    account.Fight.DurationByEffect.Remove(list[0]);
                    list.RemoveAt(0);
                }
                for (int i = 0; i < account.Fight.LastTurnLaunchBySpell.Keys.Count; i++)
                {
                    Dictionary <int, int> dictionary = account.Fight.LastTurnLaunchBySpell;
                    num4             = Enumerable.ElementAtOrDefault <int>(account.Fight.LastTurnLaunchBySpell.Keys, i);
                    dictionary[num4] = (dictionary[num4] - 1);
                    if (account.Fight.LastTurnLaunchBySpell[Enumerable.ElementAtOrDefault <int>(account.Fight.LastTurnLaunchBySpell.Keys, i)] <= 0)
                    {
                        list.Add(Enumerable.ElementAtOrDefault <int>(account.Fight.LastTurnLaunchBySpell.Keys, i));
                    }
                }
                while (list.Count > 0)
                {
                    account.Fight.LastTurnLaunchBySpell.Remove(list[0]);
                    list.RemoveAt(0);
                }
                account.Log(new BotTextInformation("Fin du tour"), 5);
            }
            BFighter fighter = (BFighter)account.Fight.GetFighter(msg.id);

            if (fighter != null)
            {
                fighter.ActionPoints   = fighter.GameFightMinimalStats.maxActionPoints;
                fighter.MovementPoints = fighter.GameFightMinimalStats.maxMovementPoints;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Set a spell casted by the player.
        /// </summary>
        public void SetSpellCasted(long id, int spellId, int destinationCellId)
        {
            BFighter fighter = GetFighter(id);

            if (fighter != null && fighter.Id == Fighter.Id)
            {
                int spellLevel = -1;
                BlueSheep.Common.Types.Spell spell = m_Account.Spells.FirstOrDefault(s => s.Id == spellId);
                if (spell != null)
                {
                    spellLevel = spell.Level;
                }
                if (spellLevel != -1)
                {
                    DataClass spellData = GameData.GetDataObject(D2oFileEnum.Spells, spellId);
                    if (spellData != null)
                    {
                        uint      spellLevelId   = (uint)((ArrayList)spellData.Fields["spellLevels"])[spellLevel - 1];
                        DataClass spellLevelData = GameData.GetDataObject(D2oFileEnum.SpellLevels, (int)spellLevelId);
                        if (spellLevelData != null)
                        {
                            if ((int)spellLevelData.Fields["minCastInterval"] > 0 && !(LastTurnLaunchBySpell.ContainsKey(spellId)))
                            {
                                LastTurnLaunchBySpell.Add(spellId, (int)spellLevelData.Fields["minCastInterval"]);
                            }
                            if (TotalLaunchBySpell.ContainsKey(spellId)) //Si on a déjà utilisé ce sort ce tour
                            {
                                TotalLaunchBySpell[spellId] += 1;
                            }
                            else
                            {
                                TotalLaunchBySpell.Add(spellId, 1);
                            }
                            if (TotalLaunchByCellBySpell.ContainsKey(spellId))                        //Si on a déjà utilisé ce sort ce tour
                            {
                                if (TotalLaunchByCellBySpell[spellId].ContainsKey(destinationCellId)) //Si on a déjà utilisé ce sort sur cette case
                                {
                                    TotalLaunchByCellBySpell[spellId][destinationCellId] += 1;
                                }
                                else
                                {
                                    TotalLaunchByCellBySpell[spellId].Add(destinationCellId, 1);
                                }
                            }
                            else
                            {
                                Dictionary <int, int> tempdico = new Dictionary <int, int>();
                                tempdico.Add(destinationCellId, 1);
                                TotalLaunchByCellBySpell.Add(spellId, tempdico);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns the distance between our player and the specified fighter. Default is the nearest monster.
        /// </summary>
        public int DistanceFrom(BFighter fighter = null)
        {
            if (fighter == null)
            {
                fighter = NearestMonster();
            }
            MapPoint CharacterPoint   = new MapPoint(Fighter.CellId);
            MapPoint TestFighterPoint = new MapPoint(fighter.CellId);
            int      dist             = new SimplePathfinder(m_Account.MapData).FindPath(fighter.CellId, TestFighterPoint.CellId).Cells.Count();

            dist += CharacterPoint.DistanceToCell(TestFighterPoint);
            return(dist);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Update the life points of the specified fighter.
        /// </summary>
        public void UpdateFighterLifePoints(long id, int delta)
        {
            BFighter fighter = GetFighter(id);

            if (fighter != null)
            {
                fighter.LifePoints += delta;
                if (fighter.Id == Fighter.Id)
                {
                    m_Account.ModifBar(2, m_Account.FightData.Fighter.MaxLifePoints, m_Account.FightData.Fighter.LifePoints, "Vitalité");
                }
                m_Account.Log(new ActionTextInformation(fighter.Name + ": " + delta + "PV."), 5);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Removes the fighter from the fighters and add it to the dead ennemies' list.
        /// </summary>
        public void SetFighterDeath(long id)
        {
            BFighter fighter = GetFighter(id);

            DeadEnnemies.Add(fighter);
            if (!IsDead && fighter.Id == Fighter.Id)
            {
                m_Account.Log(new ErrorTextInformation("Personnage mort :'("), 0);
                IsDead = true;
            }
            else if (fighter.CreatureGenericId != 0)
            {
                m_Account.Log(new ActionTextInformation(fighter.Name + " est mort !"), 5);
            }
            Fighters.Remove(fighter);
        }
Ejemplo n.º 7
0
        public static void GameActionFightTeleportOnSameMapMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameActionFightTeleportOnSameMapMessage msg = (GameActionFightTeleportOnSameMapMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            if (account.Fight != null)
            {
                BFighter fighter = (BFighter)account.Fight.GetFighter(msg.targetId);
                if (fighter != null)
                {
                    fighter.CellId = msg.cellId;
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Add the summoner and its summon.
        /// </summary>
        public void AddSummon(long sourceId, BFighter summon)
        {
            Fighters.Add(summon);
            List <BFighter> summoned = new List <BFighter>();

            if (m_Summons.ContainsKey(sourceId))
            {
                m_Summons.TryGetValue(sourceId, out summoned);
                summoned.Add(summon);
                m_Summons.Remove(sourceId);
                m_Summons.Add(sourceId, summoned);
            }
            else
            {
                summoned.Add(summon);
                m_Summons.Add(sourceId, summoned);
            }
        }
Ejemplo n.º 9
0
        public static void GameActionFightLifePointsLostMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameActionFightLifePointsLostMessage msg = (GameActionFightLifePointsLostMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            if (account.Fight != null && account.state == Status.Fighting)
            {
                BFighter fighter = account.Fight.GetFighter(msg.targetId);
                account.Fight.Fighters[account.Fight.Fighters.IndexOf(fighter)].LifePoints -= msg.loss;
                if (fighter.Id == account.Fight.Fighter.Id)
                {
                    account.ModifBar(2, account.Fight.Fighter.MaxLifePoints, account.Fight.Fighter.LifePoints, "Vitalité");
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// CanUseSpell() vérifie si le sort peut être utilisé.
        /// </summary>
        /// <param name="spell">Sort à lancé</param>
        /// <param name="target">Cible</param>
        /// <returns>False si non, true si oui. </returns>
        public bool CanUseSpell(BSpell spell, BFighter target)
        {
            // Principally AP
            if (CanLaunchSpell(spell.SpellId) != SpellInabilityReason.None)
            {
                return(false);
            }

            // Use without move
            if (CanLaunchSpell(spell.SpellId, Fighter.CellId, target.CellId) == SpellInabilityReason.None)
            {
                Account.Log(new BotTextInformation("No need to move maggle"), 5);
                return(true);
            }
            // Try with move
            int moveCell = -1;
            int distance = -1;

            foreach (int cell in GetReachableCells())
            {
                if (CanLaunchSpell(spell.SpellId, cell, target.CellId) == SpellInabilityReason.None)
                {
                    MapPoint characterPoint = new MapPoint(cell);
                    int      tempDistance   = characterPoint.DistanceToCell(new MapPoint(target.CellId));

                    if (tempDistance > distance || distance == -1)
                    {
                        distance = tempDistance;
                        moveCell = cell;
                    }
                }
            }

            if (moveCell != -1 && moveCell != Fighter.CellId)
            {
                MoveToCell(moveCell);
                Account.Log(new BotTextInformation("CanUseSpellWithMove!"), 5);
                return(true);
            }

            // Can't use
            Account.Log(new ErrorTextInformation("CantUseSpell"), 5);
            return(false);
        }
Ejemplo n.º 11
0
        public static void GameActionFightSlideMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameActionFightSlideMessage msg = (GameActionFightSlideMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            if (account.Fight != null)
            {
                BFighter fighter = account.Fight.GetFighter(msg.targetId);
                if (fighter != null)
                {
                    //account.Log(new BotTextInformation("Ancienne cellid of " + fighter.Id + " = " + fighter.CellId));
                    fighter.CellId = msg.endCellId;
                    //account.Log(new BotTextInformation("Nouvelle cellid of " + fighter.Id+ " = " + fighter.CellId));
                }
            }
        }
Ejemplo n.º 12
0
        public static void GameMapMovementMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameMapMovementMessage msg = (GameMapMovementMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            MovementPath clientMovement = MapMovementAdapter.GetClientMovement(msg.keyMovements.Select <short, uint>(k => (uint)k).ToList());

            if (account.state == Enums.Status.Fighting)
            {
                BFighter fighter = account.Fight.GetFighter(msg.actorId);
                if (fighter != null)
                {
                    //account.Log(new BotTextInformation("GameMap Ancienne cellid of " + fighter.Id + " = " + fighter.CellId));
                    fighter.CellId = clientMovement.CellEnd.CellId;
                    //account.Log(new BotTextInformation("GameMap Nouvelle cellid of " + fighter.Id + " = " + fighter.CellId));
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Affect the specified variation on the specified target.
        /// </summary>
        public void SetPointsVariation(long targetId, int actionId, int delta)
        {
            BFighter fighter = GetFighter(targetId);

            if (fighter != null)
            {
                switch (actionId)
                {
                case 101:
                case 102:
                case 120:
                    fighter.ActionPoints += delta;
                    break;

                case 78:
                case 127:
                case 129:
                    fighter.MovementPoints += delta;
                    break;
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Perform the correct move according to the tactic and end the turn.
        /// </summary>
        private void PerformMove()
        {
            BFighter NearMonster = m_Data.NearestMonster();

            if (NearMonster == null)
            {
                EndTurn();
                return;
            }
            TacticEnum tactic = m_AI.GetStrategy();

            // EndMove
            if (m_Data.Fighter.MovementPoints > 0 && tactic != TacticEnum.Immobile)
            {
                int distance = m_Data.DistanceFrom(NearMonster);
                if (tactic == TacticEnum.Fuyard)
                {
                    MoveToCell(m_Data.FurthestCellFrom(NearMonster));
                }
                else if (tactic == TacticEnum.Barbare)
                {
                    if (!m_Data.IsHandToHand())
                    {
                        MoveToCell(m_Data.NearestCellFrom(NearMonster));
                    }
                    else
                    {
                        EndTurn();
                    }
                }
                flag = -1;

                m_Account.Log(new BotTextInformation("EndMove"), 5);
            }
            else
            {
                EndTurn();
            }
        }
Ejemplo n.º 15
0
        public static void GameFightLeaveMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameFightLeaveMessage msg = (GameFightLeaveMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            if (msg.charId == account.CharacterBaseInformations.id)
            {
                account.Fight.IsFightStarted = false;
                account.Fight.WaitForReady   = false;
            }
            else
            {
                BFighter fighter = account.Fight.GetFighter(msg.charId);
                if (fighter != null)
                {
                    account.Fight.Fighters.Remove(fighter);
                }
            }
        }
Ejemplo n.º 16
0
        public static void GameActionFightLifePointsGainMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameActionFightLifePointsGainMessage msg = (GameActionFightLifePointsGainMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            /* Credit : Apokah */
            if (account.Fight != null && account.state == Status.Fighting)
            {
                BFighter fighter = account.Fight.GetFighter(msg.targetId);
                if (msg.actionId == 108) // HP Récupérés (delta = combien on a récupérés)
                {
                    account.Fight.Fighters[account.Fight.Fighters.IndexOf(fighter)].LifePoints += msg.delta;
                    if (fighter.Id == account.Fight.Fighter.Id)
                    {
                        account.ModifBar(2, account.Fight.Fighter.MaxLifePoints, account.Fight.Fighter.LifePoints, "Vitalité");
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public int ComputeDamage(int spellId, BFighter target)
        {
            DataClass spellData       = GameData.GetDataObject(D2oFileEnum.Spells, spellId);
            ArrayList ids             = (ArrayList)spellData.Fields["spellLevels"];
            int       level           = m_Account.Spells.FirstOrDefault(Spell => Spell.Id == spellId).Level;
            int       id              = Convert.ToInt32(ids[level - 1]);
            DataClass spellLevelsData = GameData.GetDataObject(D2oFileEnum.SpellLevels, id);
            ArrayList effects         = (ArrayList)spellLevelsData.Fields["effects"];
            int       minDam          = 0;
            int       maxDam          = 0;

            foreach (var effect in effects)
            {
                DataClass data = (DataClass)effect;
                minDam += (int)data.Fields["diceNum"];
                maxDam += (int)data.Fields["diceSide"];
                maxDam  = minDam >= maxDam ? minDam : maxDam;
            }
            int baseDam  = (maxDam + minDam) / 2;
            int totalDam = baseDam + (baseDam * m_Account.CharacterStats.permanentDamagePercent.@base) + m_Account.CharacterStats.allDamagesBonus;
            // TODO check is this is puissance.
            // totaux - res fixes  - (totaux * %res/100)
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Returns the nearest cell from the specified fighter. Default is the nearest monster.
        /// </summary>
        public int NearestCellFrom(BFighter fighter = null)
        {
            if (fighter == null)
            {
                fighter = NearestMonster();
            }
            List <int> ReachableCells = GetReachableCells();
            int        CellId         = -1;
            int        SavDistance    = -1;

            foreach (int ReachableCell in ReachableCells)
            {
                MapPoint ReachableCellPoint = new MapPoint(ReachableCell);
                int      Distance           = 0;
                Distance = (Distance + ReachableCellPoint.DistanceToCell(new MapPoint(fighter.CellId)));
                if (((SavDistance == -1) || (Distance < SavDistance)))
                {
                    CellId      = ReachableCell;
                    SavDistance = Distance;
                }
            }
            return(CellId);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Returns the nearest ally from our player.
        /// </summary>
        public BFighter NearestAlly()
        {
            BFighter Fighterr    = null;
            int      SavDistance = -1;

            foreach (BFighter TestFighter in Fighters)
            {
                if (TestFighter.TeamId != Fighter.TeamId || TestFighter.IsAlive == false)
                {
                    continue;
                }
                int dist = DistanceFrom(TestFighter);
                if (((dist < SavDistance) || (SavDistance == -1)) && TestFighter != Fighter)
                {
                    SavDistance = dist;
                    Fighterr    = TestFighter;
                }
            }
            if (Fighterr == null)
            {
                return(null);
            }
            return(Fighterr);
        }
Ejemplo n.º 20
0
        public BFighter GetTarget(TeamEnum teamEnum__1)
        {
            BFighter target = null;

            switch (teamEnum__1)
            {
            case TeamEnum.Ally:
                target = null;
                break;

            case TeamEnum.EmptyCase:
                target = new BFighter(0, NearCell(), 0, null, false, 0, 0, 0, 0, 0);
                break;

            case TeamEnum.Enemy:
                target = NearestMonster();
                break;

            case TeamEnum.Self:
                target = Fighter;
                break;
            }
            return(target);
        }
Ejemplo n.º 21
0
 public Fighter(BFighterId id, BFighter bean)
 {
     this.Id   = id;
     this.Bean = bean;
 }
Ejemplo n.º 22
0
        public bool CanUseSpell(BSpell spell, BFighter target)
        {
            // Principally AP
            if (CanLaunchSpell(spell.SpellId) != SpellInabilityReason.None)
            {
                return(false);
            }

            // Use without move
            if (CanLaunchSpell(spell.SpellId, Fighter.CellId, target.CellId) == SpellInabilityReason.None)
            {
                //if (spell.IsHandToHand && !IsHandToHand())
                //{
                //    MapPoint characterPoint = new MapPoint(Account.Game.Fight.Fighter.CellId);
                //    int tempDistance = characterPoint.DistanceToCell(new MapPoint(NearestMonster().CellId));
                //    if (tempDistance - 1 > Account.Game.Fight.Fighter.MovementPoints)
                //    {
                //        return false;
                //    }
                //}
                //else if (spell.IsHandToHand && IsHandToHand())
                //{
                //    Account.Log("No need to move maggle", LogType.DEBUG);
                //    return true;
                //}
                //else if (!spell.IsHandToHand)
                //{
                m_Account.Log(new BotTextInformation("No need to move maggle"), 5);
                return(true);
                //}
            }

            // Try with move
            int moveCell = -1;
            int distance = -1;

            foreach (int cell in GetReachableCells())
            {
                //if (spell.IsHandToHand)
                //{
                //    MapPoint characterPoint = new MapPoint(cell);
                //    int tempDistance = characterPoint.DistanceToCell(new MapPoint(target.CellId));

                //    if (IsHandToHand(cell) && (tempDistance < distance || distance == -1))
                //    {
                //        distance = tempDistance;
                //        moveCell = cell;
                //    }
                //}
                if (CanLaunchSpell(spell.SpellId, cell, target.CellId) == SpellInabilityReason.None)
                {
                    MapPoint characterPoint = new MapPoint(cell);
                    int      tempDistance   = characterPoint.DistanceToCell(new MapPoint(target.CellId));

                    if (tempDistance > distance || distance == -1)
                    {
                        distance = tempDistance;
                        moveCell = cell;
                    }
                }
            }

            if (moveCell != -1 && moveCell != Fighter.CellId)
            {
                MoveToCell(moveCell);
                m_Account.Log(new BotTextInformation("CanUseSpellWithMove!"), 5);
                return(true);
            }

            // Can't use
            m_Account.Log(new ErrorTextInformation("CantUseSpell"), 5);
            return(false);
        }
Ejemplo n.º 23
0
        public static void GameActionFightSpellCastMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            GameActionFightSpellCastMessage msg = (GameActionFightSpellCastMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                msg.Deserialize(reader);
            }
            if (account.Fight != null)
            {
                BFighter fighter = (BFighter)account.Fight.GetFighter(msg.targetId);
                if (fighter != null && account.Fight.Fighter != null && fighter.Id == account.Fight.Fighter.Id)
                {
                    int spellLevel = -1;
                    BlueSheep.Common.Types.Spell spell = account.Spells.FirstOrDefault(s => s.Id == msg.spellId);
                    if (spell != null)
                    {
                        spellLevel = spell.Level;
                    }
                    if (spellLevel != -1)
                    {
                        DataClass spellData = GameData.GetDataObject(D2oFileEnum.Spells, msg.spellId);
                        if (spellData != null)
                        {
                            uint      spellLevelId   = (uint)((ArrayList)spellData.Fields["spellLevels"])[spellLevel - 1];
                            DataClass spellLevelData = GameData.GetDataObject(D2oFileEnum.SpellLevels, (int)spellLevelId);
                            if (spellLevelData != null)
                            {
                                if ((int)spellLevelData.Fields["minCastInterval"] > 0 && !(account.Fight.LastTurnLaunchBySpell.ContainsKey(msg.spellId)))
                                {
                                    account.Fight.LastTurnLaunchBySpell.Add(msg.spellId, (int)spellLevelData.Fields["minCastInterval"]);
                                }
                                if (account.Fight.TotalLaunchBySpell.ContainsKey(msg.spellId)) //Si on a déjà utilisé ce sort ce tour
                                {
                                    account.Fight.TotalLaunchBySpell[msg.spellId] += 1;
                                }
                                else
                                {
                                    account.Fight.TotalLaunchBySpell.Add(msg.spellId, 1);
                                }
                                if (account.Fight.TotalLaunchByCellBySpell.ContainsKey(msg.spellId))                            //Si on a déjà utilisé ce sort ce tour
                                {
                                    if (account.Fight.TotalLaunchByCellBySpell[msg.spellId].ContainsKey(msg.destinationCellId)) //Si on a déjà utilisé ce sort sur cette case
                                    {
                                        account.Fight.TotalLaunchByCellBySpell[msg.spellId][msg.destinationCellId] += 1;
                                    }
                                    else
                                    {
                                        account.Fight.TotalLaunchByCellBySpell[msg.spellId].Add(msg.destinationCellId, 1);
                                    }
                                }
                                else
                                {
                                    Dictionary <int, int> tempdico = new Dictionary <int, int>();
                                    tempdico.Add(msg.destinationCellId, 1);
                                    account.Fight.TotalLaunchByCellBySpell.Add(msg.spellId, tempdico);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 24
0
        public bool PerformSpellsStack()
        {
            Relaunch--;              /* On baisse le relaunch */
            if (Relaunch == 0)       /* Si on l'a lancé le nombre de fois qu'il fallait, on passe au sort suivant */
            {
                spells.RemoveAt(0);
            }
            if (spells.Count() == 0)
            {                           /* Si il n'y a plus de sorts restants, on renvoie false pour terminer le tour. */
                PerformMove();
                return(false);
            }
            BFighter target = null;

            if (spells[0].TargetName == "Nom du monstre") /* On récup la cible */
            {
                target = GetTarget(spells[0].Target);
            }
            else
            {
                target = GetTarget(spells[0].TargetName);
            }

            //if (spells[0].SpellId == 413)
            //{
            //    if (target.LifePoints / target.MaxLifePoints * 100 <= spells[0].TargetLife && GetFighters(true).Count() < 2)
            //    {
            //        m_Account.Log(new BotTextInformation("It's time to capture ! POKEBALL GOOOOOOOOOO"), 5);
            //        LaunchSpell(spells[0].SpellId, Fighter.CellId);
            //        spells[0].LastTurn = TurnId;
            //        PerformAutoTimeoutFight(1000);
            //    }
            //}
            if (target != null && target.LifePoints / target.MaxLifePoints * 100 <= spells[0].TargetLife)
            {
                m_Account.Log(new BotTextInformation("Cible en vue à la cellule " + target.CellId + " !"), 5);
                if (m_Conf.Tactic == TacticEnum.Immobile)
                {
                    if (CanLaunchSpell(spells[0].SpellId) == SpellInabilityReason.None && CanLaunchSpell(spells[0].SpellId, Fighter.CellId, target.CellId) == SpellInabilityReason.None)
                    {
                        m_Account.Log(new BotTextInformation("CanLaunchSpell !"), 5);
                        LaunchSpell(spells[0].SpellId, target.CellId);
                        spells[0].LastTurn = TurnId;
                    }
                    else
                    {
                        Relaunch = 1;           /* Si on peut pas lancer ce sort, on passe au suivant en mettant le relaunch comme fini */
                        return(PerformSpellsStack());
                    }
                }
                else if (CanUseSpell(spells[0], target))
                {
                    m_Account.Log(new BotTextInformation("CanUseSpell ! "), 5);
                    LaunchSpell(spells[0].SpellId, target.CellId);
                    spells[0].LastTurn = TurnId;
                }
                else
                {
                    Relaunch = 1;              /* Si on peut pas lancer ce sort, on passe au suivant en mettant le relaunch comme fini */
                    return(PerformSpellsStack());
                }
            }
            else
            {
                Relaunch = 1;
                return(PerformSpellsStack());
            }


            if (Relaunch == 0)                /* Si on a réussi a lancé le sort et que le relaunch n'a pas été mis, on le définit. */
            {
                Relaunch = spells[0].Relaunch;
            }
            return(true);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Interface to manage fights
        /// </summary>
        private List <string> Fight()
        {
            bool launch   = IsSwitchOn("-launch");
            bool Lock     = IsSwitchOn("-lock");
            bool fighters = IsSwitchOn("-l");
            bool verbose  = IsSwitchOn("-v");
            bool turn     = IsSwitchOn("-t");
            bool me       = IsSwitchOn("-me");
            bool infinite = IsSwitchOn("-i");

            try
            {
                if (turn && account.state == Status.Fighting)
                {
                    result.Add("[TURN] " + account.FightData.TurnId);
                }
                if (fighters && account.state == Status.Fighting)
                {
                    foreach (BFighter f in account.FightData.Fighters)
                    {
                        if (verbose)
                        {
                            bool isAlly = f.TeamId == account.FightData.Fighter.TeamId;
                            result.Add(String.Format("[{1}] LP : {2}/{3} AP:{4} MP:{5} Cell: {6} Alive ? {7}",
                                                     isAlly ? "ALLY" : "ENNEMY", f.LifePoints, f.MaxLifePoints,
                                                     f.ActionPoints, f.MovementPoints, f.CellId, f.IsAlive));
                        }
                        else
                        {
                            bool isAlly = f.TeamId == account.FightData.Fighter.TeamId;
                            result.Add(String.Format("[{1}] LP : {2}/{3} Alive ? {4} ",
                                                     isAlly ? "ALLY" : "ENNEMY", f.LifePoints, f.MaxLifePoints, f.IsAlive));
                        }
                    }
                }
                if (me && account.state == Status.Fighting)
                {
                    BFighter m = account.FightData.Fighter;
                    if (verbose)
                    {
                        result.Add(String.Format("[ME] LP : {1}/{2} AP:{3} MP:{4} Cell: {5} Alive ? {6}", m.LifePoints, m.MaxLifePoints
                                                 , m.ActionPoints, m.MovementPoints, m.IsAlive));
                    }
                    else
                    {
                        result.Add(String.Format("[ME] LP : {1}/{2} Alive ? {3} \n", m.LifePoints, m.MaxLifePoints, m.IsAlive));
                    }
                }
                if (account.Fight != null && (launch || Lock))
                {
                    if (launch && account.state != Status.Fighting)
                    {
                        account.Fight.infinite = infinite;
                        account.Fight.SearchFight();
                        result.Add("Recherche d'un combat...");
                    }
                    if (Lock && account.FightData.WaitForReady)
                    {
                        account.Fight.LockFight();
                        result.Add("Fermeture du combat.");
                    }
                }
                else
                {
                    throw new Exception("L'utilisation de cette commande nécessite d'avoir une IA chargée.");
                }
            }
            catch (Exception ex)
            {
                result.Add("[ERROR] " + ex.Message + "\n");
                return(result);
            }
            if (!(result.Count > 0))
            {
                return(Usage("fight"));
            }
            else
            {
                return(result);
            }
        }