public static Task HandleGameActionFightSpellCastMessage(Account account, GameActionFightSpellCastMessage message) => Task.Run(() => { account.Game.Fight.Update(message); account.Extensions.CharacterCreation.Update(message); //account.Logger.LogInfo(account.Game.Fight.GetFighter(message.SourceId).GetName(), $"a lancé {DataManager.Get<Spells>((int)message.SpellId).NameId}."); });
private void Spell_Casted(GameActionFightSpellCastMessage message) { if (message.SourceId == _account.Character.Id) { OnSpellCasted(true); } }
public void Update(GameActionFightSpellCastMessage message) { if (PlayedFighter?.ContextualId == message.SourceId) { var spell = DataManager.Get <Spells>((int)message.SpellId); var spellLevel = DataManager.Get <SpellLevels>(spell.SpellLevels[(int)message.SpellLevel - 1]); if (spellLevel.MinCastInterval > 0 && !_spellsIntervals.ContainsKey(spell.Id)) { _spellsIntervals.Add(spell.Id, spellLevel.MinCastInterval); } if (!_totalSpellLaunchs.ContainsKey(spell.Id)) { _totalSpellLaunchs.Add(spell.Id, 0); } _totalSpellLaunchs[spell.Id]++; if (_totalSpellLaunchsInCells.ContainsKey(spell.Id)) { if (!_totalSpellLaunchsInCells[spell.Id].ContainsKey(message.DestinationCellId)) { _totalSpellLaunchsInCells[spell.Id].Add(message.DestinationCellId, 0); } _totalSpellLaunchsInCells[spell.Id][message.DestinationCellId]++; } else { _totalSpellLaunchsInCells.Add(spell.Id, new Dictionary <int, int>() { { message.DestinationCellId, 1 } }); } } }
public override void Run() { m_inFight = false; m_fighters = new List <GameFightFighterInformations>(); m_castedSpell = null; counter = 0; base.Run(); }
public static void GameActionFightSpellCastMessageTreatment(Message message, byte[] packetDatas, AccountUC account) { GameActionFightSpellCastMessage msg = (GameActionFightSpellCastMessage)message; using (BigEndianReader reader = new BigEndianReader(packetDatas)) { msg.Deserialize(reader); } account.FightData.SetSpellCasted(msg.sourceId, msg.spellId, msg.destinationCellId); }
public void Update(GameActionFightSpellCastMessage message) { if (!IsDoingTutorial || message.SourceId != _account.Game.Character.Id) { return; } if (_currentStepNumber == 8) { ValidateCurrentStep(); } }
/// <summary> /// Notifies the spell that it has been cast on a given target /// </summary> public void CastAt(GameActionFightSpellCastMessage msg) { if (msg == null) { throw new ArgumentNullException("msg"); } Spell spell = GetSpell(msg.spellId); if (spell == null) { throw new ArgumentException(String.Format("Spell Id {0} do not exists in the SpellsBook of {1}, with {2} entries", msg.spellId, Character.Name, m_spells.Count)); } spell.CastAt(msg.targetId); //Character.SendMessage(string.Format("Spell {0} cast at actor Id {1}. Still available : {2}", spell, msg.targetId, spell.IsAvailable(msg.targetId))); }
public SpellCast(Fight fight, GameActionFightSpellCastMessage msg) { Caster = fight.GetFighter(msg.sourceId); if (Caster == null) { logger.Error("Fighter {0} not found as he casted spell {1}", msg.sourceId, msg.spellId); } Spell = ObjectDataManager.Instance.Get <Spell>(msg.spellId); SpellLevel = ObjectDataManager.Instance.Get <SpellLevel>((int)Spell.spellLevels[msg.spellLevel - 1]); Target = fight.Map.Cells[msg.destinationCellId]; RoundCast = fight.Round; Critical = (FightSpellCastCriticalEnum)msg.critical; SilentCast = msg.silentCast; TargetedFighter = fight.GetFighter(msg.targetId); }
public static void HandleGameActionFightSpellCastMessage(Bot bot, GameActionFightSpellCastMessage message) { if (bot == null || bot.Character == null || bot.Character.Fight == null) { logger.Error("Fight is not properly initialized."); return; // Can't handle the message } var fighter = bot.Character.Fight.GetFighter(message.sourceId); if (fighter == null) { logger.Error("Fighter {0} cast a spell but doesn't exist", message.sourceId); } else { fighter.NotifySpellCasted(new SpellCast(bot.Character.Fight, message)); if (bot.Character.Fighter != null && bot.Character.Fighter.Id == message.sourceId) { bot.Character.SpellsBook.CastAt(message); } } }
public override void Handle(Message message, string sender) { counter++; if (message is GameFightStartingMessage) { m_inFight = true; m_fighters.Clear(); } if (message is GameFightShowFighterMessage && m_inFight) { var msg = message as GameFightShowFighterMessage; m_fighters.Add(msg.informations); } if (message is GameActionFightSpellCastMessage && m_inFight) { m_castedSpell = message as GameActionFightSpellCastMessage; counter = 0; } if (message is GameActionFightLifePointsVariationMessage && m_inFight) { var msg = message as GameActionFightLifePointsVariationMessage; if (m_fighters != null && m_castedSpell != null && counter < 5) { if (msg.sourceId == m_castedSpell.sourceId && msg.sourceId < 0) { var fighter = m_fighters.Where(entry => entry.contextualId == msg.sourceId).FirstOrDefault() as GameFightMonsterInformations; if (fighter != null) { StoreResult(fighter.creatureGenericId, fighter.creatureGrade, m_castedSpell.spellId, m_castedSpell.spellLevel, Math.Abs(msg.delta)); } } } } if (message is GameFightEndMessage) { m_inFight = false; } }
private void HandleGameActionFightSpellCastMessage(IAccount account, GameActionFightSpellCastMessage message) { var fighter = (Fighter)GetFighter(message.SourceId); if (fighter == null || Fighter == null || fighter.Id != Fighter.Id) { return; } var spellLevel = -1; var spell = Account.Character.Spells.FirstOrDefault(s => s.SpellId == message.SpellId); if (spell != null) { spellLevel = spell.SpellLevel; } if (spellLevel == -1) { return; } var spellData = ObjectDataManager.Instance.Get <API.Datacenter.Spell>(message.SpellId); if (spellData == null) { return; } var spellLevelId = spellData.SpellLevels[spellLevel - 1]; var spellLevelData = ObjectDataManager.Instance.Get <SpellLevel>(spellLevelId); if (spellLevelData == null) { return; } if (spellLevelData.MinCastInterval > 0 && !LastTurnLaunchBySpell.ContainsKey(message.SpellId)) { LastTurnLaunchBySpell.Add(message.SpellId, (int)spellLevelData.MinCastInterval); } if (TotalLaunchBySpell.ContainsKey(message.SpellId)) { TotalLaunchBySpell[message.SpellId] += 1; } else { TotalLaunchBySpell.Add(message.SpellId, 1); } if (TotalLaunchByCellBySpell.ContainsKey(message.SpellId)) { if (TotalLaunchByCellBySpell[message.SpellId].ContainsKey(message.DestinationCellId)) { TotalLaunchByCellBySpell[message.SpellId][message.DestinationCellId] += 1; } else { TotalLaunchByCellBySpell[message.SpellId].Add(message.DestinationCellId, 1); } } else { var tempdico = new Dictionary <int, int> { { message.DestinationCellId, 1 } }; TotalLaunchByCellBySpell.Add(message.SpellId, tempdico); } }
public static void HandleGameActionFightSpellCastMessage(Bot bot, GameActionFightSpellCastMessage message) { }
private void HandleGameActionFightSpellCastMessage(IAccount account, GameActionFightSpellCastMessage message) { SpellCasted?.Invoke(message); }
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); } } } } } } }