protected virtual void OnMonsterAttacksGeneric(Object p_sender, AttacksEventArgs p_args, Boolean p_isRanged) { PlayerEntityView playerEntity = FXHelper.GetPlayerEntity(); Vector3 p_slotOriginPosition; Vector3 p_slotForward; Vector3 p_slotLeft; Vector3 p_slotTargetPosition; ViewManager.GetSlotDatas(MyController.Position, LegacyLogic.Instance.WorldManager.Party.Position, out p_slotOriginPosition, out p_slotForward, out p_slotLeft, out p_slotTargetPosition); Boolean flag = false; GameObject gameObject = null; List <Action> callbacks = new List <Action>(p_args.Attacks.Count); EResultType eresultType = EResultType.HIT; Int32 num = 0; List <Character> targets = new List <Character>(); AttacksEventArgs.AttackedTarget attack; foreach (AttacksEventArgs.AttackedTarget attack2 in p_args.Attacks) { attack = attack2; num++; if (attack.AttackTarget is Character) { Character chara = (Character)attack.AttackTarget; AttackResult result = attack.AttackResult; targets.Add(chara); if (playerEntity != null) { gameObject = playerEntity.GetMemberGameObject(chara.Index); } if (gameObject == null) { Debug.LogError("Could not find target character! Char-Index: " + chara.Index); } else { flag |= attack.IsCriticalAttack; callbacks.Add(delegate { if (p_sender is Monster && ((Monster)p_sender).AbilityHandler.HasEntriesForPhase(EExecutionPhase.BEFORE_MONSTER_ATTACK)) { ((Monster)p_sender).AbilityHandler.FlushActionLog(EExecutionPhase.BEFORE_MONSTER_ATTACK); chara.ConditionHandler.FlushActionLog(); } if (((Monster)p_sender).AbilityHandler.HasEntriesForPhase(EExecutionPhase.AFTER_DAMAGE_CALCULATION)) { ((Monster)p_sender).AbilityHandler.FlushActionLog(EExecutionPhase.AFTER_DAMAGE_CALCULATION); } CombatEntryEventArgs p_args2 = new CombatEntryEventArgs(p_sender, chara, result, attack.BloodMagicEventArgs); LegacyLogic.Instance.ActionLog.PushEntry(p_args2); if (LegacyLogic.Instance.WorldManager.Party.Buffs.HasBuff(EPartyBuffs.SHADOW_CLOAK) && result.Result == EResultType.EVADE) { LegacyLogic.Instance.WorldManager.Party.Buffs.RemoveBuff(EPartyBuffs.SHADOW_CLOAK); } if (LegacyLogic.Instance.WorldManager.Party.Buffs.HasBuff(EPartyBuffs.CELESTIAL_ARMOR)) { if (LegacyLogic.Instance.WorldManager.Party.Buffs.GetBuff(EPartyBuffs.CELESTIAL_ARMOR).IsExpired()) { LegacyLogic.Instance.WorldManager.Party.Buffs.RemoveBuff(EPartyBuffs.CELESTIAL_ARMOR); } LegacyLogic.Instance.WorldManager.Party.Buffs.FlushActionLog(); } chara.FightHandler.FlushCounterAttackActionLog(); LegacyLogic.Instance.WorldManager.Party.Buffs.FlushActionLog(); if (p_sender is Monster && ((Monster)p_sender).AbilityHandler.HasEntriesForPhase(EExecutionPhase.AFTER_MONSTER_ATTACK)) { ((Monster)p_sender).AbilityHandler.FlushActionLog(EExecutionPhase.AFTER_MONSTER_ATTACK); chara.ConditionHandler.FlushActionLog(); } }); if (attack.AttackResult.Result == EResultType.BLOCK) { eresultType = EResultType.BLOCK; } else if (eresultType != EResultType.BLOCK && attack.AttackResult.Result == EResultType.EVADE) { eresultType = EResultType.EVADE; } } } } Action action = delegate { DelayedEventManager.InvokeEvent(EDelayType.ON_FX_HIT, (!p_isRanged) ? EEventType.MONSTER_ATTACKS : EEventType.MONSTER_ATTACKS_RANGED, p_sender, p_args); if (!p_isRanged) { foreach (AttacksEventArgs.AttackedTarget attackedTarget in p_args.Attacks) { ((Monster)MyController).CombatHandler.TriggerCounterAttacks(attackedTarget.AttackTarget, attackedTarget.AttackResult); } } foreach (Action action2 in callbacks) { action2(); } foreach (Character character in targets) { character.ConditionHandler.FlushDelayedActionLog(); } }; if (gameObject == null) { gameObject = playerEntity.GetMemberGameObject(UnityEngine.Random.Range(0, 4)); if (gameObject == null) { Debug.LogError("No target character could be found! Will skip whole FX! Num of Attacks = " + p_args.Attacks.Count); action(); return; } } FXArgs p_fxArgs = new FXArgs(this.gameObject, gameObject, this.gameObject, gameObject, p_slotOriginPosition, p_slotForward, p_slotLeft, p_slotTargetPosition); if (p_isRanged) { AttackRanged(p_fxArgs, action, (!flag) ? eresultType : EResultType.CRITICAL_HIT); } else if (flag) { AttackCritical(p_fxArgs, action); } else { Attack(p_fxArgs, action); } }
private void OnTakeHitAttackGeneric(Object p_sender, EventArgs p_args, EEventType p_eventType) { Boolean flag = true; Boolean flag2 = false; if (p_args is AttacksEventArgs) { AttacksEventArgs attacksEventArgs = (AttacksEventArgs)p_args; foreach (AttacksEventArgs.AttackedTarget attackedTarget in attacksEventArgs.Attacks) { if (attackedTarget.AttackTarget == MyController) { AttackResult attackResult = attackedTarget.AttackResult; if (!flag2 && attacksEventArgs.PushToParty) { flag2 = true; m_MainView.PushEntityToPosition(); } foreach (AttacksEventArgs.AttackedTarget attackedTarget2 in attacksEventArgs.Attacks) { if (attackedTarget2.AttackTarget != null && attackedTarget2.AttackTarget == MyController) { Monster monster = (Monster)MyController; FlushMonsterLogEntries(); monster.CombatHandler.CheckCounterAttack((Character)p_sender); List <CombatEntryEventArgs> counterLogEntries = monster.CombatHandler.CounterLogEntries; if (counterLogEntries.Count > 0) { foreach (CombatEntryEventArgs p_args2 in counterLogEntries) { LegacyLogic.Instance.ActionLog.PushEntry(p_args2); if (LegacyLogic.Instance.WorldManager.Party.Buffs.HasBuff(EPartyBuffs.CELESTIAL_ARMOR)) { if (LegacyLogic.Instance.WorldManager.Party.Buffs.GetBuff(EPartyBuffs.CELESTIAL_ARMOR).IsExpired()) { LegacyLogic.Instance.WorldManager.Party.Buffs.RemoveBuff(EPartyBuffs.CELESTIAL_ARMOR); } LegacyLogic.Instance.WorldManager.Party.Buffs.FlushActionLog(); } ((Character)p_sender).ConditionHandler.FlushActionLog(); ((Character)p_sender).ConditionHandler.FlushDelayedActionLog(); } } counterLogEntries.Clear(); if (monster.AiHandler is MamushiAIHandler) { ((Character)p_sender).FightHandler.FlushActionLog(); ((Character)p_sender).FightHandler.FlushDelayedActionLog(); ((Character)p_sender).FlushNormalActionLog(); } } } if (attackResult.ReflectedDamage != null && attackResult.ReflectedDamage.Damages.Count > 0 && MyController is Monster) { Monster p_attacker = MyController as Monster; AttackResult attackResult2 = ((Character)p_sender).FightHandler.AttackEntity(attackResult.ReflectedDamage, true, EDamageType.PHYSICAL, true, 0, false); ((Character)p_sender).ApplyDamages(attackResult2, p_attacker); Object p_source = (attackResult2.ReflectedDamageSource != null) ? attackResult2.ReflectedDamageSource : MyController; CombatEntryEventArgs p_args3 = new CombatEntryEventArgs(p_source, p_sender, attackResult2, null); LegacyLogic.Instance.ActionLog.PushEntry(p_args3); AttacksEventArgs attacksEventArgs2 = new AttacksEventArgs(false); attacksEventArgs2.Attacks.Add(new AttacksEventArgs.AttackedTarget(p_sender, attackResult2)); DelayedEventManager.InvokeEvent(EDelayType.ON_FX_FINISH, EEventType.REFLECTED_MAGIC_DAMAGE, p_sender, attacksEventArgs2); } if (flag) { flag = false; m_CommandQueue.Enqueue(delegate { ((Monster)MyController).HitAnimationDone.Trigger(); DelayedEventManager.InvokeEvent(EDelayType.ON_FX_FINISH, p_eventType, p_sender, p_args); }); PlayTakeHitSound(p_sender, attackResult, p_eventType == EEventType.CHARACTER_ATTACKS_RANGED); } TakeHit(attackedTarget.AttackResult, false); } } } else if (p_args is SpellEventArgs) { SpellEventArgs spellEventArgs = (SpellEventArgs)p_args; foreach (AttackedTarget attackedTarget3 in spellEventArgs.SpellTargetsOfType <AttackedTarget>()) { if (attackedTarget3.Target == MyController) { if (p_sender is Summon) { ((Summon)p_sender).FlushActionLog(); } FlushMonsterLogEntries(); if (flag) { flag = false; m_CommandQueue.Enqueue(delegate { ((Monster)MyController).HitAnimationDone.Trigger(); if (!(p_sender is Summon)) { DelayedEventManager.InvokeEvent(EDelayType.ON_FX_FINISH, EEventType.CHARACTER_CAST_SPELL, p_sender, p_args); } }); } TakeHit(attackedTarget3.Result, spellEventArgs.DamageType != EDamageType.PHYSICAL); } } foreach (PushedTarget pushedTarget in spellEventArgs.SpellTargetsOfType <PushedTarget>()) { if (pushedTarget.Target == MyController) { m_MainView.PushEntityToPosition(); } } } }
private void TakeHit(Object p_sender, EventArgs p_args, Boolean p_isRanged) { Int32 tagHash = m_animator.GetCurrentAnimatorStateInfo(0).tagHash; Int32 tagHash2 = m_animator.GetNextAnimatorStateInfo(0).tagHash; Int32 num = Animator.StringToHash("ATTACK"); Int32 num2 = Animator.StringToHash("DIE"); Boolean flag = true; Boolean flag2 = false; if (p_args is AttacksEventArgs) { AttacksEventArgs attacksEventArgs = (AttacksEventArgs)p_args; foreach (AttacksEventArgs.AttackedTarget attackedTarget in attacksEventArgs.Attacks) { if (attackedTarget.AttackTarget == MyController) { AttackResult attackResult = attackedTarget.AttackResult; if (flag) { flag = false; ((Monster)MyController).HitAnimationDone.Trigger(); FlushMonsterLogEntries(); DelayedEventManager.InvokeEvent(EDelayType.ON_FX_FINISH, (!p_isRanged) ? EEventType.CHARACTER_ATTACKS : EEventType.CHARACTER_ATTACKS_RANGED, p_sender, p_args); if (attackedTarget.AttackResult.DamageDone > 0 && num2 != tagHash && num2 != tagHash2 && num != tagHash && num != tagHash2) { m_animatorControl.Hit(); } PlayTakeHitSound(p_sender, attackResult, p_isRanged); } if (!flag2 && attacksEventArgs.PushToParty) { flag2 = true; m_MainView.PushEntityToPosition(); } foreach (AttacksEventArgs.AttackedTarget attackedTarget2 in attacksEventArgs.Attacks) { if (attackedTarget2.AttackTarget != null && attackedTarget2.AttackTarget == MyController) { Monster monster = (Monster)MyController; monster.CombatHandler.CheckCounterAttack((Character)p_sender); List <CombatEntryEventArgs> counterLogEntries = monster.CombatHandler.CounterLogEntries; if (counterLogEntries.Count > 0) { foreach (CombatEntryEventArgs p_args2 in counterLogEntries) { LegacyLogic.Instance.ActionLog.PushEntry(p_args2); if (LegacyLogic.Instance.WorldManager.Party.Buffs.HasBuff(EPartyBuffs.CELESTIAL_ARMOR)) { if (LegacyLogic.Instance.WorldManager.Party.Buffs.GetBuff(EPartyBuffs.CELESTIAL_ARMOR).IsExpired()) { LegacyLogic.Instance.WorldManager.Party.Buffs.RemoveBuff(EPartyBuffs.CELESTIAL_ARMOR); } LegacyLogic.Instance.WorldManager.Party.Buffs.FlushActionLog(); } ((Character)p_sender).ConditionHandler.FlushActionLog(); ((Character)p_sender).ConditionHandler.FlushDelayedActionLog(); } } counterLogEntries.Clear(); } } if (attackResult.ReflectedDamage != null && attackResult.ReflectedDamage.Damages.Count > 0 && MyController is Monster && (!p_isRanged || (p_isRanged && ((Monster)MyController).DistanceToParty < 1.1f))) { ((Monster)MyController).AbilityHandler.FlushActionLog(EExecutionPhase.ON_CHARACTER_ATTACKS_MONSTER_AFTER_DAMAGE_REDUCTION); AttackResult attackResult2 = ((Character)p_sender).FightHandler.AttackEntity(attackResult.ReflectedDamage, true, EDamageType.PHYSICAL, true, 0, false); ((Character)p_sender).ApplyDamages(attackResult2, (Monster)MyController); Object p_source = (attackResult2.ReflectedDamageSource != null) ? attackResult2.ReflectedDamageSource : MyController; CombatEntryEventArgs p_args3 = new CombatEntryEventArgs(p_source, p_sender, attackResult2, null); LegacyLogic.Instance.ActionLog.PushEntry(p_args3); DelayedEventManager.InvokeEvent(EDelayType.ON_FX_FINISH, EEventType.REFLECTED_MAGIC_DAMAGE, p_sender, new AttacksEventArgs(false) { Attacks = { new AttacksEventArgs.AttackedTarget(p_sender, attackResult2) } }); } this.SendEvent("OnReceivedAttacks", new AttacksUnityEventArgs(this, attackResult, false)); } } } else if (p_args is SpellEventArgs) { SpellEventArgs spellEventArgs = (SpellEventArgs)p_args; foreach (AttackedTarget attackedTarget3 in spellEventArgs.SpellTargetsOfType <AttackedTarget>()) { if (attackedTarget3.Target == MyController) { if (flag) { flag = false; TakeHitDoFinishBySpell(p_sender, p_args); if (attackedTarget3.Result.DamageDone > 0 && num2 != tagHash && num2 != tagHash2 && num != tagHash && num != tagHash2) { m_animatorControl.Hit(); } } if (attackedTarget3.Result.ReflectedDamage != null && attackedTarget3.Result.ReflectedDamage.Damages.Count > 0 && MyController is Monster && (!p_isRanged || (p_isRanged && ((Monster)MyController).DistanceToParty < 1.1f))) { ((Monster)MyController).AbilityHandler.FlushActionLog(EExecutionPhase.ON_CHARACTER_ATTACKS_MONSTER_AFTER_DAMAGE_REDUCTION); AttackResult attackResult3 = ((Character)p_sender).FightHandler.AttackEntity(attackedTarget3.Result.ReflectedDamage, true, EDamageType.PHYSICAL, true, 0, false); ((Character)p_sender).ApplyDamages(attackResult3, (Monster)MyController); Object p_source2 = (attackResult3.ReflectedDamageSource != null) ? attackResult3.ReflectedDamageSource : MyController; CombatEntryEventArgs p_args4 = new CombatEntryEventArgs(p_source2, p_sender, attackResult3, null); LegacyLogic.Instance.ActionLog.PushEntry(p_args4); DelayedEventManager.InvokeEvent(EDelayType.ON_FX_FINISH, EEventType.REFLECTED_MAGIC_DAMAGE, p_sender, new AttacksEventArgs(false) { Attacks = { new AttacksEventArgs.AttackedTarget(p_sender, attackResult3) } }); } this.SendEvent("OnReceivedAttacks", new AttacksUnityEventArgs(this, attackedTarget3.Result, spellEventArgs.DamageType != EDamageType.PHYSICAL)); } } foreach (PushedTarget pushedTarget in spellEventArgs.SpellTargetsOfType <PushedTarget>()) { if (pushedTarget.Target == MyController) { m_MainView.PushEntityToPosition(); } } foreach (MonsterBuffTarget monsterBuffTarget in spellEventArgs.SpellTargetsOfType <MonsterBuffTarget>()) { if (flag && monsterBuffTarget.Target == MyController) { flag = false; TakeHitDoFinishBySpell(p_sender, p_args); } } } }