예제 #1
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);
                            }
                        }
                    }
                }
            }
        }
예제 #2
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);
                                }
                            }
                        }
                    }
                }
            }
        }