public void ResolveCombatEffects(AttackResult p_result, EEquipSlots p_attackHand, Monster p_target) { if (p_result.Result == EResultType.CRITICAL_HIT) { BaseItem itemAt = m_character.Equipment.GetItemAt(p_attackHand); List <SkillEffectStaticData> requiredSkillEffects = GetRequiredSkillEffects(itemAt); foreach (SkillEffectStaticData skillEffectStaticData in requiredSkillEffects) { if (skillEffectStaticData.Condition == ESkillEffectCondition.CRITICAL_HIT) { if (skillEffectStaticData.Type == ESkillEffectType.STUN_MONSTER) { MonsterBuffMaceStun p_buff = (MonsterBuffMaceStun)BuffFactory.CreateMonsterBuff(EMonsterBuffType.MACE_STUN, 0f); p_target.AddBuff(p_buff); m_character.FightHandler.FeedActionLog(skillEffectStaticData); } } else if (skillEffectStaticData.Condition == ESkillEffectCondition.FIRST_CRITICAL_HIT && skillEffectStaticData.Type == ESkillEffectType.APPLY_GASH && !m_criticalStrikeCounter.Contains(skillEffectStaticData.Type)) { MonsterBuffGash p_buff2 = (MonsterBuffGash)BuffFactory.CreateMonsterBuff(EMonsterBuffType.GASH, p_result.DamageDone); p_target.AddBuff(p_buff2); m_character.FightHandler.FeedActionLog(skillEffectStaticData); m_criticalStrikeCounter.Add(skillEffectStaticData.Type); } } } }
public void ImbibeTest() { // Test that Buffs can be added and have intended effects Monster monster = MonsterManager.GetMonsterByName("LegEater"); Assert.AreEqual(0, monster.GetBuffStacks(Buff.Imbibe)); Assert.AreEqual(4, monster.Strength); int baseStr = monster.Strength; // Ensure stacks have intended effects (+10 str per stack) monster.AddBuff(Buff.Imbibe, 1); Assert.AreEqual(baseStr + 10, monster.Strength); monster.AddBuff(Buff.Imbibe, 2); Assert.AreEqual(baseStr + (3 * 10), monster.Strength); monster.RemoveBuff(Buff.Imbibe); Assert.AreEqual(baseStr, monster.Strength); // Ensure Str + Buff doesn't exceed 255 monster.Strength = 10; // Temp increase LegEater's base str to execute test monster.AddBuff(Buff.Imbibe, 16); monster.AddBuff(Buff.Imbibe, 9); // 25 * 10 = 250 Buff Bonus Assert.AreEqual(255, monster.Strength); // min(255, str+(buff%256)) monster.Strength = baseStr; // Check Buff Overflow monster.AddBuff(Buff.Imbibe, 1); // 26 * 10 = 260 Buff Bonus Assert.AreEqual(8, monster.Strength); // str + (buff % 256) }
public void BerserkTest() { // Test that Buffs can be added and have intended effects Monster monster = MonsterManager.GetMonsterByName("LegEater"); // Ensure stacks are additive and removes properly Assert.AreEqual(4, monster.Strength); Assert.AreEqual(0, monster.HasBuff(Buff.Berserk)); monster.AddBuff(Buff.Berserk, 1); // 1 stack total, + 5 buff Assert.AreEqual(1, monster.HasBuff(Buff.Berserk)); Assert.AreEqual(9, monster.Strength); monster.AddBuff(Buff.Berserk, 2); // 3 stacks total, + 15 buff Assert.AreEqual(3, monster.HasBuff(Buff.Berserk)); Assert.AreEqual(19, monster.Strength); monster.RemoveBuff(Buff.Berserk); Assert.AreEqual(4, monster.Strength); Assert.AreEqual(0, monster.HasBuff(Buff.Berserk)); // Ensure Str + Buff doesn't exceed 255 monster.AddBuff(Buff.Berserk, 51); // 51 * 5 = 255 Buff Bonus Assert.AreEqual(255, monster.Strength); // min(255, str+(buff%256)) // Check Buff Overflow monster.AddBuff(Buff.Berserk, 1); // 52 * 5 = 260 Buff Bonus. Assert.AreEqual(8, monster.Strength); // str + (buff % 256) }
public void GeneralBuffTest() { // Setup Monster monster = new Monster(); // Test invalid arguments Assert.ThrowsException <ArgumentOutOfRangeException>(() => monster.AddBuff(Buff.Aura, -1)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => monster.AddBuff(Buff.Aura, 17)); // Spirit and Intelligence are currently irrelevant to monsters and should be ignored Assert.IsFalse(monster.AddBuff(Buff.Spirit, 1)); Assert.IsFalse(monster.AddBuff(Buff.Intelligence, 1)); }
public override void DoEffect(Monster p_monster, Character p_target, SpellEventArgs p_spellArgs) { if (p_monster != null && !p_monster.BuffHandler.HasBuff(EMonsterBuffType.FLICKERING_LIGHT)) { p_monster.AddBuff(BuffFactory.CreateMonsterBuff(EMonsterBuffType.FLICKERING_LIGHT, p_monster.MagicPower, m_level)); m_cooldown = 3; } }
/// <summary> /// Helper. Adds and removes one buff stack from the monster. /// </summary> /// <param name="monster"></param> /// <param name="buff"></param> private void AddRemoveBuff(Monster monster, Buff buff) { // Test that buff can be added and removed monster.AddBuff(buff, 1); Assert.AreEqual(1, monster.GetBuffStacks(buff)); monster.RemoveBuff(buff); Assert.AreEqual(0, monster.GetBuffStacks(buff)); }
public void AuraStacksTest() { // Setup Monster actor = new Monster(); Monster target = new Monster(); // Test Aura Buff damage bonus foreach (int i in Enum.GetValues(typeof(MonsterFamily))) { MonsterFamily fam = (MonsterFamily)i; int minDmg = actor.Strength; int maxDmg = actor.Strength * 3; target.Families.Add(fam); testDamageRange(actor, target, minDmg, maxDmg); actor.AddBuff(Buff.Aura, i + 1); // NES Bug. Aura buff ignores undead, and therefore applies no bonus damage. // Check this, flip the flag, then ensure it works properly if fixed Globals.BUG_FIXES = false; if (!Globals.BUG_FIXES && fam == MonsterFamily.Undead) { testDamageRange(actor, target, minDmg, maxDmg); Globals.BUG_FIXES = true; } testDamageRange(actor, target, minDmg + 20, maxDmg + 60); target.Families.Remove(fam); testDamageRange(actor, target, minDmg, maxDmg); actor.RemoveBuff(Buff.Aura); } // Ensure Aura bonus damage doesn't stack target.Families.Add(MonsterFamily.Air); target.Families.Add(MonsterFamily.Dragon); target.Families.Add(MonsterFamily.Earth); testDamageRange(actor, target, actor.Strength, actor.Strength * 3); actor.AddBuff(Buff.Aura, 1); testDamageRange(actor, target, actor.Strength + 20, (actor.Strength * 3) + 60); actor.AddBuff(Buff.Aura, 7); testDamageRange(actor, target, actor.Strength + 20, (actor.Strength * 3) + 60); target.Families.Clear(); actor.RemoveBuff(Buff.Aura); }
public void BerserkTest() { // Ensure normal base stats Monster monster = MonsterManager.GetMonsterByName("LegEater"); Assert.AreEqual(0, monster.GetBuffStacks(Buff.Berserk)); Assert.AreEqual(4, monster.Strength); int baseStr = monster.Strength; // Ensure stacks have intended effect (+5 str per stack) monster.AddBuff(Buff.Berserk, 1); Assert.AreEqual(baseStr + 5, monster.Strength); monster.AddBuff(Buff.Berserk, 2); Assert.AreEqual(baseStr + (3 * 5), monster.Strength); monster.RemoveBuff(Buff.Berserk); Assert.AreEqual(baseStr, monster.Strength); // Ensure Str + Buff doesn't exceed 255 monster.AddBuff(Buff.Berserk, 16); monster.AddBuff(Buff.Berserk, 16); monster.AddBuff(Buff.Berserk, 16); monster.AddBuff(Buff.Berserk, 3); // 51 * 5 = 255 Buff Bonus Assert.AreEqual(255, monster.Strength); // min(255, str+(buff%256)) // Check Buff Overflow monster.AddBuff(Buff.Berserk, 1); // 52 * 5 = 260 Buff Bonus Assert.AreEqual(8, monster.Strength); // str + (buff % 256) }
public void HasteTest() { // Ensure normal base stats Monster monster = MonsterManager.GetMonsterByName("LegEater"); Assert.AreEqual(0, monster.GetBuffStacks(Buff.Haste)); Assert.AreEqual(1, monster.Hits); int baseHits = monster.Hits; // Ensure stacks have intended effect (+1 hit per stack) monster.AddBuff(Buff.Haste, 1); Assert.AreEqual(baseHits + 1, monster.Hits); monster.AddBuff(Buff.Haste, 5); Assert.AreEqual(baseHits + 5, monster.Hits); monster.AddBuff(Buff.Haste, 1); // Ensure lower-level Haste doesn't change hits Assert.AreEqual(baseHits + 5, monster.Hits); monster.RemoveBuff(Buff.Haste); Assert.AreEqual(1, monster.Hits); }
public void BarrierTest() { // Ensure normal base stats Monster monster = new Monster(); Assert.AreEqual(0, monster.GetBuffStacks(Buff.Barrier)); Queue <Element> resistQueue = new Queue <Element>(); Queue <Element> noResistQueue = new Queue <Element>(new[] { Element.Dimension, Element.Fire, Element.Mind, Element.Lightning, Element.Death, Element.Poison, Element.Body, Element.Ice }); foreach (Element e in resistQueue) { Assert.IsTrue(monster.IsResistantTo(e)); } foreach (Element e in noResistQueue) { Assert.IsFalse(monster.IsResistantTo(e)); } System.Diagnostics.Debug.WriteLine(String.Join(",", resistQueue)); System.Diagnostics.Debug.WriteLine(String.Join(",", noResistQueue)); System.Diagnostics.Debug.WriteLine("---"); // Ensure stacks have intended effect: Elemental resistance baaed on stack level for (int i = 0; i < 7; i++) { monster.AddBuff(Buff.Barrier, i + 1); resistQueue.Enqueue(noResistQueue.Dequeue()); foreach (Element e in resistQueue) { Assert.IsTrue(monster.IsResistantTo(e)); } foreach (Element e in noResistQueue) { Assert.IsFalse(monster.IsResistantTo(e)); } } // Check for the 8th stack, Ice, and ensure it doesn't work unless BUG_FIX monster.AddBuff(Buff.Barrier, 8); Globals.BUG_FIXES = false; Assert.IsFalse(monster.IsResistantTo(Element.Ice)); Globals.BUG_FIXES = true; Assert.IsTrue(monster.IsResistantTo(Element.Ice)); }
/// <summary> /// Helper. Add and remove highest-stacking buffs and check maxStack is enforced /// </summary> /// <param name="monster"></param> /// <param name="buff"></param> /// <param name="maxStack">How high the buff can stack</param> private void AddRemoveHighestStackBuff(Monster monster, Buff buff, int maxStack) { // Ensure only the highest stack value is active Assert.AreEqual(0, monster.GetBuffStacks(buff)); monster.AddBuff(buff, 1); Assert.AreEqual(1, monster.GetBuffStacks(buff)); monster.AddBuff(buff, 1); Assert.AreEqual(1, monster.GetBuffStacks(buff)); monster.AddBuff(buff, 5); Assert.AreEqual(5, monster.GetBuffStacks(buff)); monster.AddBuff(buff, 1); Assert.AreEqual(5, monster.GetBuffStacks(buff)); monster.RemoveBuff(buff); Assert.AreEqual(0, monster.GetBuffStacks(buff)); // Ensure buff cannot exceed max stacks monster.AddBuff(buff, 16); Assert.AreEqual(maxStack, monster.GetBuffStacks(buff)); }
public override void HandleAttacks(List <Attack> p_attackList, Monster p_monster, Character p_character, Boolean p_isMagic) { if (!p_monster.BuffHandler.HasBuff(EMonsterBuffType.SHADOW_CLOAK)) { MonsterBuffShadowCloak p_buff = (MonsterBuffShadowCloak)BuffFactory.CreateMonsterBuff(EMonsterBuffType.SHADOW_CLOAK, 1f, m_level); p_monster.AddBuff(p_buff); AbilityTriggeredEventArgs p_args = new AbilityTriggeredEventArgs(p_monster, this); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ENTITY_ABILITY_ADDED, new AbilityEventArgs(p_monster, this)); p_monster.AbilityHandler.AddEntry(m_executionPhase, p_args); } }
/// <summary> /// Helper. Add and removes stacks from cumulative buffs /// </summary> /// <param name="monster"></param> /// <param name="buff"></param> private void AddRemoveStackingBuff(Monster monster, Buff buff) { // Ensure buff stacks are cumulative and remove properly Assert.AreEqual(0, monster.GetBuffStacks(buff)); monster.AddBuff(buff, 1); Assert.AreEqual(1, monster.GetBuffStacks(buff)); monster.AddBuff(buff, 1); Assert.AreEqual(2, monster.GetBuffStacks(buff)); monster.AddBuff(buff, 2); Assert.AreEqual(4, monster.GetBuffStacks(buff)); monster.RemoveBuff(buff); Assert.AreEqual(0, monster.GetBuffStacks(buff)); // Overflow check: Cannot exceed 255 for (int i = 0; i < 15; i++) { monster.AddBuff(buff, 16); } Assert.AreEqual(240, monster.GetBuffStacks(buff)); monster.AddBuff(buff, 16); Assert.AreEqual(0, monster.GetBuffStacks(buff)); }
protected override void OnTriggerEnter2D(Collider2D collision) { if (!collision.gameObject.activeSelf) { return; } if (collision.tag == "Monster" && collision.transform == targetTrans) { Monster monster = collision.GetComponent <Monster>(); monster.AddBuff(new SlowDownBuff(monster, BuffType.SlowDownBuff, towerLevel * 0.7f, towerLevel * 0.4f)); } base.OnTriggerEnter2D(collision); }
public void ShellTest() { // Ensure normal base stats Monster monster = MonsterManager.GetMonsterByName("LegEater"); Assert.AreEqual(0, monster.GetBuffStacks(Buff.Shell)); Assert.AreEqual(1, monster.MagicBlocks); int baseBlocks = monster.MagicBlocks; // Ensure stacks have intended effect (+1 mBlock per stack) monster.AddBuff(Buff.Shell, 1); Assert.AreEqual(baseBlocks + 1, monster.MagicBlocks); monster.AddBuff(Buff.Shell, 2); Assert.AreEqual(baseBlocks + 3, monster.MagicBlocks); monster.RemoveBuff(Buff.Shell); Assert.AreEqual(baseBlocks, monster.MagicBlocks); // Ensure Stat + Buff doesn't exceed 255 monster.MagicBlocks = 250; // Temp stat adjustment Assert.AreEqual(250, monster.MagicBlocks); monster.AddBuff(Buff.Shell, 16); // 266 total (250 + 16) Assert.AreEqual(255, monster.MagicBlocks); }
public void AddMonsterBuff(Monster p_target, EMonsterBuffType p_monsterBuff, Single p_magicFactor) { if (p_target != null) { Character selectedCharacter = LegacyLogic.Instance.WorldManager.Party.SelectedCharacter; MonsterBuff monsterBuff = BuffFactory.CreateMonsterBuff(p_monsterBuff, p_magicFactor); monsterBuff.Causer = selectedCharacter; p_target.AddBuff(monsterBuff); if (SINGLE_TARGET_BUFFS.Contains(p_monsterBuff)) { SingleTargetBuff(monsterBuff, p_target); } } }
public override void DoEffect(Monster p_monster, Character p_target, SpellEventArgs p_spellArgs) { GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(p_monster.Position); IList <MovingEntity> entities = slot.Entities; for (Int32 i = 0; i < entities.Count; i++) { if (entities[i] is Monster) { Monster monster = (Monster)entities[i]; monster.AddBuff(BuffFactory.CreateMonsterBuff(EMonsterBuffType.BATTLESPIRIT, p_monster.MagicPower, m_level)); } } m_cooldown = 3; }
private void AfflictDebuff(Monster p_target, EMonsterBuffType p_buff, SuffixStaticData p_suffix, Boolean p_buffEndDelayed) { if (p_suffix.MagicSchool != EDamageType.NONE && p_target.CombatHandler.TestEvadeSpell(p_suffix.MagicSchool, 0)) { return; } MonsterBuff monsterBuff = BuffFactory.CreateMonsterBuff(p_buff, p_suffix.GetValueForLevel(m_equipment.SuffixLevel, m_equipment.ItemSlot == EItemSlot.ITEM_SLOT_2_HAND)); monsterBuff.Causer = m_character; monsterBuff.DontTriggerOnFirstDamage = true; if (p_buffEndDelayed) { monsterBuff.Duration++; } p_target.AddBuff(monsterBuff); LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ITEM_SUFFIX_APPLY_BUFF, new ItemSuffixApplyBuffEventArgs(p_target, p_suffix.Description, p_buff)); MonsterBuffEntryEventArgs item = new MonsterBuffEntryEventArgs(p_target, monsterBuff, p_target.BuffHandler.HasBuff(monsterBuff)); m_logEntries.Add(item); }
public override void DoEffect(Monster p_monster, Character p_target, SpellEventArgs p_spellArgs) { GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(p_monster.Position); IList <MovingEntity> entities = slot.Entities; m_targetBuffer.Clear(); foreach (MovingEntity movingEntity in entities) { Monster monster = movingEntity as Monster; if (monster != null && !monster.BuffHandler.HasBuff(EMonsterBuffType.LIQUIDMEMBRANE)) { m_targetBuffer.Add(monster); } } Int32 index = Random.Range(0, m_targetBuffer.Count); if (m_targetBuffer.Count != 0) { Monster monster2 = m_targetBuffer[index]; monster2.AddBuff(BuffFactory.CreateMonsterBuff(EMonsterBuffType.LIQUIDMEMBRANE, p_monster.MagicPower, m_level)); } m_cooldown = 3; }
protected Boolean Attack(List <Object> attackBuffer) { if (Controller.StaticID == 5) { GetAllTargetsInRange(attackBuffer, false, true); } else { GetAttackTargets(attackBuffer); } if (attackBuffer.Count > 0) { Damage[] array = new Damage[Brain.Data.DamageData.Length]; for (Int32 i = 0; i < Brain.Data.DamageData.Length; i++) { DamageData p_data = DamageData.Scale(Brain.Data.DamageData[i], Brain.MagicFactor); array[i] = Damage.Create(p_data, 0f); } Attack p_attack = new Attack(0f, 0f, array); Boolean flag = false; SummonSpellEventArgs summonSpellEventArgs = new SummonSpellEventArgs(); foreach (Object obj in attackBuffer) { BaseCombatHandler baseCombatHandler; if (obj is Character) { flag = true; Character character = (Character)obj; baseCombatHandler = character.FightHandler; } else { if (!(obj is Monster)) { continue; } flag = true; Monster monster = (Monster)obj; baseCombatHandler = monster.CombatHandler; if (Controller.StaticID == 3 && monster.AbilityHandler.HasAbility(EMonsterAbilityType.UNDEAD)) { AttackResult attackResult = new AttackResult(); attackResult.Result = EResultType.IMMUNE; summonSpellEventArgs.SpellTargets.Add(new AttackedTarget(obj, attackResult)); continue; } } if (Controller.StaticData.DamageMod != EDamageMod.NONE && Controller.StaticData.DamageMod == EDamageMod.MultiplyByTargets) { List <Damage> list = new List <Damage>(); foreach (Damage item in array) { var damage = item; damage.Value *= attackBuffer.Count; list.Add(damage); } p_attack = new Attack(0f, 0f, list); } AttackResult attackResult2 = baseCombatHandler.AttackEntity(p_attack, false, Brain.DamageType, Controller.StaticID == 6, Brain.IgnoreResistance, false); summonSpellEventArgs.SpellTargets.Add(new AttackedTarget(obj, attackResult2)); if (attackResult2.Result != EResultType.EVADE) { if (obj is Character) { Character character2 = (Character)obj; character2.ApplyDamages(attackResult2, null); } else if (obj is Monster) { Monster monster2 = (Monster)obj; monster2.ApplyDamages(attackResult2, Controller); } if (Controller.StaticData.MonsterBuffs[0] != EMonsterBuffType.NONE && obj is Monster) { Monster monster3 = (Monster)obj; foreach (EMonsterBuffType p_type in Controller.StaticData.MonsterBuffs) { MonsterBuff p_buff = BuffFactory.CreateMonsterBuff(p_type, Brain.MagicFactor); monster3.AddBuff(p_buff); } } if (Controller.StaticData.PartyBuffs[0] != EPartyBuffs.NONE && obj is Character) { foreach (EPartyBuffs p_buffId in Controller.StaticData.PartyBuffs) { LegacyLogic.Instance.WorldManager.Party.Buffs.AddBuff(p_buffId, 1f); } } if (Controller.StaticData.RemovedConditions[0] != ECondition.NONE && obj is Character) { Character character3 = (Character)obj; foreach (ECondition p_condition in Controller.StaticData.RemovedConditions) { character3.ConditionHandler.RemoveCondition(p_condition); } } } } summonSpellEventArgs.Result = ((!flag) ? ESpellResult.NO_TARGET_FOUND : ESpellResult.OK); Controller.FeedActionLog(summonSpellEventArgs); LegacyLogic.Instance.EventManager.InvokeEvent(Controller, EEventType.SUMMON_CAST_SPELL, summonSpellEventArgs); return(flag); } return(false); }
public override void DoEffect(Monster p_monster, Character p_target, SpellEventArgs p_spellArgs) { p_monster.AddBuff(BuffFactory.CreateMonsterBuff(EMonsterBuffType.CRYSTAL_SHELL, p_monster.MagicPower, m_level)); m_cooldown = 3; }