public void Process_SrcUnit() { damage = Random.Range(srcUnit.GetDamageMin(), srcUnit.GetDamageMax()); float critChance = srcUnit.GetCritChance(); if (Random.Range(0f, 1f) < critChance) { critical = true; damage *= srcUnit.GetCritMultiplier(); } float dmgModifier = DamageTable.GetModifier(tgtUnit.armorType, srcUnit.damageType); damage *= dmgModifier; stunned = srcUnit.GetStun().IsApplicable(); slowed = srcUnit.GetSlow().IsValid(); dotted = srcUnit.GetDot().GetTotalDamage() > 0; if (stunned) { stun = srcUnit.GetStun().Clone(); } if (slowed) { slow = srcUnit.GetSlow().Clone(); } if (dotted) { dot = srcUnit.GetDot().Clone(); } }
public AttackInfo(Ability ability, Unit tUnit, bool useAOE = true) { tgtUnit = tUnit; damageMin = ability.GetDamageMin(); damageMax = ability.GetDamageMax(); aoeRange = useAOE ? ability.GetAOERange() : 0; critChance = ability.GetCrit(); critMultiplier = tUnit.GetImmunedToCrit() ? 0 : ability.GetCritMultiplier(); //~ useEffect=ability.UseEffectOnHit(); //~ if(useEffect) effect=ability.GetEffectOnHit().Clone(); if (Random.value < ability.GetEffectOnHitChance()) { effect = ability.GetEffectOnHit(); } critical = Random.value < critChance; damage = Mathf.Round(Random.Range(damageMin, damageMax)) * (critical ? critMultiplier : 1); damage *= DamageTable.GetModifier(tgtUnit.GetArmorType(), ability.GetDamageType()); damage *= (1 - tUnit.GetDmgReduction()); if (Random.value < ability.GetHit() - tgtUnit.GetDodge()) { hit = true; } }
public AttackInfo(Unit sUnit, Unit tUnit, bool useAOE = true) { srcUnit = sUnit; tgtUnit = tUnit; damageMin = srcUnit.GetDamageMin(); damageMax = srcUnit.GetDamageMax(); aoeRange = useAOE ? srcUnit.GetAOERange() : 0; critChance = srcUnit.GetCritChance(); critMultiplier = tUnit.GetImmunedToCrit() ? 0 : srcUnit.GetCritMultiplier(); //~ useEffect=srcUnit.UseEffectOnHit(); //~ if(useEffect) effect=srcUnit.GetEffectOnHit().Clone(); if (Random.value < srcUnit.GetEffectOnHitChance()) { effect = srcUnit.GetEffectOnHit(); } critical = Random.value < critChance; damage = Mathf.Round(Random.Range(damageMin, damageMax)) * (critical ? critMultiplier : 1); //Debug.Log(damageMin+" "+damageMax+" "+damage); damage *= DamageTable.GetModifier(tgtUnit.GetArmorType(), srcUnit.GetDamageType()); damage *= (1 - tUnit.GetDmgReduction()); if (Random.value < srcUnit.GetHit() - tgtUnit.GetDodge()) { hit = true; } }
//stats processing for attack from fps-weapon public void Process_SrcWeapon() { if (srcWeapon.GetInstantKill().IsApplicable(tgtUnit.HP, tgtUnit.fullHP)) { damage = tgtUnit.HP; damageHP = tgtUnit.HP; instantKill = true; destroy = true; return; } damage = Random.Range(srcWeapon.GetDamageMin(), srcWeapon.GetDamageMax()); damage /= (float)srcWeapon.GetShootPointCount(); //divide the damage by number of shootPoint float critChance = srcWeapon.GetCritChance(); if (tgtUnit.immuneToCrit) { critChance = -1f; } if (Random.Range(0f, 1f) < critChance) { critical = true; damage *= srcWeapon.GetCritMultiplier(); //new TextOverlay(impactPoint, "Critical", new Color(1f, .6f, 0f, 1f)); } float dmgModifier = DamageTable.GetModifier(tgtUnit.armorType, srcWeapon.damageType); damage *= dmgModifier; if (damage >= tgtUnit.shield) { damageShield = tgtUnit.shield; damageHP = damage - tgtUnit.shield; } else { damageShield = damage; damageHP = 0; } if (Random.Range(0f, 1f) < srcWeapon.GetShieldPierce() && damageShield > 0) { damageHP += damageShield; damageShield = 0; pierceShield = true; //new TextOverlay(impactPoint,"Shield Pierced", new Color(0f, 1f, 1f, 1f)); } if (srcWeapon.DamageShieldOnly()) { damageHP = 0; } if (damageHP >= tgtUnit.HP) { destroy = true; return; } if (Random.Range(0f, 1f) < srcWeapon.GetShieldBreak() && tgtUnit.fullShield > 0) { breakShield = true; } stunned = srcWeapon.GetStun().IsApplicable(); if (tgtUnit.immuneToStun) { stunned = false; } slowed = srcWeapon.GetSlow().IsValid(); if (tgtUnit.immuneToSlow) { slowed = false; } if (srcWeapon.GetDot().GetTotalDamage() > 0) { dotted = true; } if (stunned) { stun = srcWeapon.GetStun().Clone(); } if (slowed) { slow = srcWeapon.GetSlow().Clone(); } if (dotted) { dot = srcWeapon.GetDot().Clone(); } }
//stats processing for attack from unit (tower/creep) public void Process_SrcUnit() { if (srcUnit.GetHit() <= 0) { Debug.LogWarning("Attacking unit (" + srcUnit.unitName + ") has default hitChance of 0%, is this intended?", srcUnit); } float hitChance = Mathf.Clamp(srcUnit.GetHit() - tgtUnit.GetDodge(), 0, 1); if (Random.Range(0f, 1f) > hitChance) { missed = true; return; } if (srcUnit.GetInstantKill().IsApplicable(tgtUnit.HP, tgtUnit.GetFullHP())) { damage = tgtUnit.HP; damageHP = tgtUnit.HP; instantKill = true; destroy = true; return; } damage = Random.Range(srcUnit.GetDamageMin(), srcUnit.GetDamageMax()); damage /= (float)srcUnit.GetShootPointCount(); //divide the damage by number of shootPoint float critChance = srcUnit.GetCritChance(); if (tgtUnit.immuneToCrit) { critChance = -1f; } if (Random.Range(0f, 1f) < critChance) { critical = true; damage *= srcUnit.GetCritMultiplier(); //new TextOverlay(impactPoint, "Critical", new Color(1f, .6f, 0f, 1f)); } float dmgModifier = DamageTable.GetModifier(tgtUnit.armorType, srcUnit.damageType); damage *= dmgModifier; if (damage >= tgtUnit.shield) { damageShield = tgtUnit.shield; damageHP = damage - tgtUnit.shield; } else { damageShield = damage; damageHP = 0; } if (Random.Range(0f, 1f) < srcUnit.GetShieldPierce() && damageShield > 0) { damageHP += damageShield; damageShield = 0; pierceShield = true; //new TextOverlay(impactPoint,"Shield Pierced", new Color(0f, 1f, 1f, 1f)); } if (srcUnit.DamageShieldOnly()) { damageHP = 0; } if (damageHP >= tgtUnit.HP) { destroy = true; return; } if (Random.Range(0f, 1f) < srcUnit.GetShieldBreak() && tgtUnit.defaultShield > 0) { breakShield = true; } stunned = srcUnit.GetStun().IsApplicable(); if (tgtUnit.immuneToStun) { stunned = false; } slowed = srcUnit.GetSlow().IsValid(); if (tgtUnit.immuneToSlow) { slowed = false; } if (srcUnit.GetDot().GetTotalDamage() > 0) { dotted = true; } if (stunned) { stun = srcUnit.GetStun().Clone(); } if (slowed) { slow = srcUnit.GetSlow().Clone(); } if (dotted) { dot = srcUnit.GetDot().Clone(); } }
public void UpdateActiveEffect() { activeEffectMod = new Effect(); activeEffectMod.SetAsModifier(); activeEffectMul = new Effect(); activeEffectMul.SetAsMultiplier(); for (int i = 0; i < allEffectList.Count; i++) { activeEffectMod.stun |= allEffectList[i].stun; if (!allEffectList[i].IsMultiplier()) { activeEffectMod.stats.hp += allEffectList[i].stats.hp; activeEffectMod.stats.sh += allEffectList[i].stats.sh; activeEffectMod.stats.hpRate += allEffectList[i].stats.hpRate * DamageTable.GetModifier(GetArmorType(), allEffectList[i].stats.damageType); activeEffectMod.stats.shRate += allEffectList[i].stats.shRate; activeEffectMod.stats.speed += allEffectList[i].stats.speed; activeEffectMod.stats.damageMin += allEffectList[i].stats.damageMin; activeEffectMod.stats.damageMax += allEffectList[i].stats.damageMax; activeEffectMod.stats.attackRange += allEffectList[i].stats.attackRange; activeEffectMod.stats.aoeRange += allEffectList[i].stats.aoeRange; activeEffectMod.stats.cooldown += allEffectList[i].stats.cooldown; activeEffectMod.stats.hit += allEffectList[i].stats.hit; activeEffectMod.stats.dodge += allEffectList[i].stats.dodge; activeEffectMod.stats.critChance += allEffectList[i].stats.critChance; activeEffectMod.stats.critMultiplier += allEffectList[i].stats.critMultiplier; activeEffectMod.stats.dmgReduc += allEffectList[i].stats.dmgReduc; activeEffectMod.stats.critReduc += allEffectList[i].stats.critReduc; activeEffectMod.stats.effectOnHitChance += allEffectList[i].stats.effectOnHitChance; for (int n = 0; n < activeEffectMod.stats.rscGain.Count; n++) { activeEffectMod.stats.rscGain[n] += allEffectList[i].stats.rscGain[n]; } } else { activeEffectMul.stats.hp *= allEffectList[i].stats.hp; activeEffectMul.stats.sh *= allEffectList[i].stats.sh; activeEffectMul.stats.hpRate *= allEffectList[i].stats.hpRate; activeEffectMul.stats.shRate *= allEffectList[i].stats.shRate; activeEffectMul.stats.speed *= allEffectList[i].stats.speed; activeEffectMul.stats.damageMin *= allEffectList[i].stats.damageMin; activeEffectMul.stats.damageMax *= allEffectList[i].stats.damageMax; activeEffectMul.stats.attackRange *= allEffectList[i].stats.attackRange; activeEffectMul.stats.aoeRange *= allEffectList[i].stats.aoeRange; activeEffectMul.stats.cooldown *= allEffectList[i].stats.cooldown; activeEffectMul.stats.hit *= allEffectList[i].stats.hit; activeEffectMul.stats.dodge *= allEffectList[i].stats.dodge; activeEffectMul.stats.critChance *= allEffectList[i].stats.critChance; activeEffectMul.stats.critMultiplier *= allEffectList[i].stats.critMultiplier; activeEffectMul.stats.dmgReduc *= allEffectList[i].stats.dmgReduc; activeEffectMul.stats.critReduc *= allEffectList[i].stats.critReduc; activeEffectMul.stats.effectOnHitChance *= allEffectList[i].stats.effectOnHitChance; for (int n = 0; n < activeEffectMul.stats.rscGain.Count; n++) { activeEffectMul.stats.rscGain[n] *= allEffectList[i].stats.rscGain[n]; } } } }