private bool isCrit = false; /// <value> Flag for if eventDescription will mention the attack dealt a critical hit/heal </value> /// <summary> /// Initializes with basic information using a given partyMember /// </summary> /// <param name="pm"> partyMember object </param> public void Init(PartyMember pm) { this.pm = pm; activeCandles = new ItemDisplay[3]; // due to object intialization orders, if this isnt dont here, it'll just be null if (PartyManager.instance.GetClassCount(pm.className) == 0) // don't show alternate colour scheme if its the first partyMember to be added { partyMemberSprite = Resources.Load <Sprite>("Sprites/Classes/" + char.ToUpper(pm.className[0]) + pm.className.Substring(1) + "Icon"); if (pm.className == ClassConstants.WARRIOR) { partyMemberColour = new Color32(189, 29, 0, 255); } else if (pm.className == ClassConstants.MAGE || pm.className == ClassConstants.FROSTGOLEM) { partyMemberColour = new Color32(0, 152, 220, 255); } else if (pm.className == ClassConstants.ARCHER) { partyMemberColour = new Color32(90, 197, 79, 255); } else if (pm.className == ClassConstants.ROGUE) { partyMemberColour = new Color32(255, 205, 2, 255); } } else { partyMemberSprite = Resources.Load <Sprite>("Sprites/Classes/" + char.ToUpper(pm.className[0]) + pm.className.Substring(1) + "IconAlt"); if (pm.className == ClassConstants.WARRIOR) { partyMemberColour = new Color32(236, 100, 75, 255); } else if (pm.className == ClassConstants.MAGE || pm.className == ClassConstants.FROSTGOLEM) { partyMemberColour = new Color32(0, 111, 135, 255); } else if (pm.className == ClassConstants.ARCHER) { partyMemberColour = new Color32(0, 156, 65, 255); } else if (pm.className == ClassConstants.ROGUE) { partyMemberColour = new Color32(133, 122, 61, 255); } } for (int i = 0; i < pm.skills.Length; i++) { if (pm.skills[i] != null) // temporary until all 12 skills for each class get filled out { skillSprites[i] = Resources.Load <Sprite>("Sprites/Skills/" + pm.className + "/" + pm.skills[i].name); } } }
/// <summary> /// Updates the value of the statusEffect and then updates the display /// </summary> public void UpdateValue() { if (name == StatusEffectConstant.BURN) { value = preValue; if (afflicted.GetStatusEffect(StatusEffectConstant.BOSS) != -1) { value = (int)(value * 0.5f); } if (afflicted.GetStatusEffect(StatusEffectConstant.ROOT) != -1) { value *= 2; } value -= afflicted.MDEF; } if (name == StatusEffectConstant.FROSTBITE) { value = preValue; if (afflicted.GetStatusEffect(StatusEffectConstant.BOSS) != -1) { value = (int)(value * 0.5f); } if (afflicted.GetStatusEffect(StatusEffectConstant.FREEZE) != -1) { value *= 2; } value -= afflicted.MDEF; } else if (name == StatusEffectConstant.POISON) // right now poison damage only needs to update for partyMembers { PartyMember pm = afflicted as PartyMember; if (pm != null) { if (pm.className == ClassConstants.ARCHER && pm.skills[(int)SkillConstants.ArcherSkills.SURVIVALIST].skillEnabled == true) { value = 0; } else // skill reducing poison damage was toggled off { value = preValue; } } } else if (name == StatusEffectConstant.BLEED) { PartyMember pm = afflicted as PartyMember; if (pm != null && pm.className == ClassConstants.ARCHER && pm.skills[(int)SkillConstants.ArcherSkills.SURVIVALIST].skillEnabled == true) { value = 0; } else if (afflicted.GetStatusEffect(StatusEffectConstant.BOSS) != -1) // if not a partyMember, bleed damage can also be halved from being a boss { value = (int)(preValue * 0.5f) - afflicted.PDEF; } else { value = preValue - afflicted.PDEF; } } if (value < 0) { value = 0; } sed.UpdateValue(); }
/// <summary> /// Sets the value for a status effect (e.g. damage, defense buff amount) /// </summary> /// <param name="afflicter"> Character that caused the status effect </param> /// <param name="afflicted"> Character being affected by the status effect </param> public void SetValue(Character afflicter, Character afflicted) { this.afflicted = afflicted; if (name == StatusEffectConstant.BURN) { if (afflicter.burnPlus == true) { plus = true; preValue = (int)(afflicter.MATK * 0.5f); } else { preValue = (int)(afflicter.MATK * 0.3f); } value = preValue; if (afflicted.GetStatusEffect(StatusEffectConstant.BOSS) != -1) { value = (int)(value * 0.5f); } if (afflicted.GetStatusEffect(StatusEffectConstant.ROOT) != -1) { value *= 2; } value -= afflicted.MDEF; } if (name == StatusEffectConstant.FROSTBITE) { preValue = (int)(afflicter.PATK * 0.3f); value = preValue; if (afflicted.GetStatusEffect(StatusEffectConstant.BOSS) != -1) { value = (int)(value * 0.5f); } if (afflicted.GetStatusEffect(StatusEffectConstant.FREEZE) != -1) { value *= 2; } value -= afflicted.MDEF; } else if (name == StatusEffectConstant.POISON) { if (afflicter != null && afflicter.poisonPlus == true) { plus = true; preValue = (int)(afflicted.HP * 0.15f); } else { preValue = (int)(afflicted.HP * 0.1f); } PartyMember pm = afflicted as PartyMember; if (pm != null && pm.className == ClassConstants.ARCHER && pm.skills[(int)SkillConstants.ArcherSkills.SURVIVALIST].skillEnabled == true) { value = 0; } else { if (afflicted.GetStatusEffect(StatusEffectConstant.BOSS) != -1) { value = (int)(preValue * 0.5f); } else { value = preValue; } } } else if (name == StatusEffectConstant.TAUNT || name == StatusEffectConstant.MARIONETTE) { this.afflicter = afflicter; } else if (name == StatusEffectConstant.BLEED) { this.afflicter = afflicter; if (afflicter.bleedPlus == true) { plus = true; preValue = (int)(afflicter.PATK * 0.6f); } else { preValue = (int)(afflicter.PATK * 0.4f); } PartyMember pm = afflicted as PartyMember; if (pm != null && pm.className == ClassConstants.ARCHER && pm.skills[(int)SkillConstants.ArcherSkills.SURVIVALIST].skillEnabled == true) { value = 0; } else { if (afflicted.GetStatusEffect(StatusEffectConstant.BOSS) != -1) { value = (int)(preValue * 0.5f) - afflicted.PDEF; } else { value = preValue - afflicted.PDEF; } } } else if (name == StatusEffectConstant.REGENERATE) { preValue = (int)(Mathf.Ceil((float)afflicted.HP * 0.05f)); value = preValue; } else if (name == StatusEffectConstant.CHAMPIONHP) { preValue = (int)(Mathf.Ceil((float)(afflicted.HP * 1.66) * 0.05f)); // the bonus hp is not calculated in initially for champion HP value = preValue; } else if (name == StatusEffectConstant.FATALWOUND) { preValue = (int)(afflicted.HP * 0.33f); value = preValue; } if (value < 0) { value = 0; } }
/// <summary> /// Handles the calculations involved when attack hits this monster /// </summary> /// <param name="a"> Attack used on this character </param> /// <param name="c"> Character attacking this </param> /// <returns></returns> public IEnumerator GetAttacked(Attack a, Character c) { bool attackHit = CalculateAttackHit(c); PartyMember pmc = (PartyMember)c; if (attackHit) { int damage = CalculateAttackDamage(a); bool isCrit = CalculateAttackCrit(c); bool isStatus = CalculateAttackStatus(a, c); if (isCrit) { damage = CalculateAttackDamageCrit(damage, c); damage = CalculateAttackReductions(damage, a); md.SetCrit(); } else { damage = CalculateAttackReductions(damage, a); } yield return(StartCoroutine(LoseHP(damage, a.animationClipName))); // side effects from partyMember skills if (pmc.className == ClassConstants.WARRIOR) { if (pmc.skills[(int)SkillConstants.WarriorSkills.MANABLADE].skillEnabled == true) { if (a.type == AttackConstants.PHYSICAL) { pmc.AddMP((int)(damage * 0.25f)); } } } if (isStatus == true && CheckDeath() == false) { AddStatusEffect(a.seName, a.seDuration, c); } // side effects from partyMember on hit effects for (int i = 0; i < c.onHitChances.Length; i++) { if (c.onHitChances[i] != 0) { if (CalculateOnHitHit(i, c) == true) { if (i == 0) { AddStatusEffect(StatusEffectConstant.POISON, 2, c); } else if (i == 1) { AddStatusEffect(StatusEffectConstant.WEAKNESS, 2, c); } else if (i == 2) { AddStatusEffect(StatusEffectConstant.BLEED, 2, c); } else if (i == 3) { AddStatusEffect(StatusEffectConstant.ROOT, 2, c); } else if (i == 4) { AddStatusEffect(StatusEffectConstant.SHOCK, 2, c); } } } } } else { yield return(StartCoroutine(DodgeAttack(a.animationClipName))); } }