예제 #1
0
파일: FightData.cs 프로젝트: Teles1/Cookie
 private void HandleGameActionFightDeathMessage(IAccount account, GameActionFightDeathMessage message)
 {
     lock (CheckLock)
     {
         if (Fighter.Id == message.TargetId)
         {
             Logger.Default.Log("Bot mort");
             Fighters.Remove(Fighters.Find(f => f.Id == message.TargetId));
         }
         if (Monsters.Exists(m => m.Id == message.TargetId))
         {
             Logger.Default.Log($"Monstre[{message.TargetId}] est mort");
             Monsters.Remove(Monsters.Find(m => m.Id == message.TargetId));
             Logger.Default.Log($"Signalig FighterDiedAutoReset", LogMessageType.Divers);
             FighterDiedAutoReset.Set();
         }
     }
 }
예제 #2
0
        private void ExecuteSpell(IASpell spell, IFighter target)
        {
            Logger.Default.Log($"ExecuteSpell {spell.Name}");
            try
            {
                if (spell.HandToHand && !_account.Character.Fight.IsHandToHand())
                {
                    if (Fighter.MovementPoints > 0 && MoveToHit(target, spell, true) == MovementEnum.Success)
                    {
                        if (MovementAutoReset.WaitOne(TimeOut)) // Waiting some time for MovementAnswer finished. If true then call recursively
                        {
                            Logger.Default.Log($"Movement succeeded and Bot is HandToHand to cast {spell.Name}.", LogMessageType.FightLog);
                            ExecuteSpell(spell, target);//in theory it should be HandToHand
                        }// if movement fails let it return let it returns;
                        else
                        {
                            Logger.Default.Log($"Movement Failed. Bot couldn't not get HandToHand to cast {spell.Name}.", LogMessageType.FightLog);
                        }
                    }
                    else
                    {
                        Logger.Default.Log($"Movement cannot be performed to cast {spell.Name}.", LogMessageType.FightLog);
                    }
                }
                else
                {
                    if (target == null)
                    {
                        return;
                    }
                    SpellInabilityReason reason = _account.Character.Fight.CanLaunchSpellOn(spell.SpellId, Fighter.CellId, target.CellId);
                    switch (reason)
                    {
                    case SpellInabilityReason.ActionPoints:
                    case SpellInabilityReason.RequiredState:
                    case SpellInabilityReason.TooManyLaunch:
                    case SpellInabilityReason.TooManyLaunchOnCell:
                    case SpellInabilityReason.Unknown:
                    case SpellInabilityReason.UnknownSpell:
                        // any of those conditions we can't do anything other then going to the next spell. so, let it return;
                        break;

                    case SpellInabilityReason.None:
                        CastSpell(target, spell);
                        if (_account.Character.Fight.SpellResetEvent.WaitOne(TimeOut))
                        {
                            Logger.Default.Log($"Successfully launched {spell.Name}", LogMessageType.FightLog);
                        }
                        else
                        {
                            Logger.Default.Log($"Could not cast {spell.Name} at {target.CellId} ", LogMessageType.FightLog);
                        }
                        break;

                    default:
                        if (Fighter.MovementPoints > 0 && MoveToHit(target, spell, false) == MovementEnum.Success)
                        {
                            if (MovementAutoReset.WaitOne(TimeOut))     // If movement was a success then we call recursively
                            {
                                ExecuteSpell(spell, target);
                            }
                        }
                        break;
                    }
                }
                if (!FighterDiedAutoReset.WaitOne(Delay))
                {
                    return;                                       // Wait to see if mob died. If true then we Task.Await
                }
                Task.Delay(Delay / 2).Wait();
                return;
            }
            catch (Exception)
            {
            }
        }