Rewrite Bane and Elemental Dmg stuff and GetWeaponDamage (client version)

This commit is contained in:
Michael Cook (mackal)
2016-01-16 18:29:17 -05:00
parent ad1c91f204
commit 600866f573
3 changed files with 234 additions and 189 deletions
+167 -1
View File
@@ -5689,4 +5689,170 @@ int32 Mob::GetMeleeMitigation() {
mitigation += itembonuses.MeleeMitigationEffect;
mitigation += aabonuses.MeleeMitigationEffect;
return mitigation;
}
}
/* this is the mob being attacked.
* Pass in the weapon's ItemInst
*/
int Mob::ResistElementalWeaponDmg(const ItemInst *item)
{
if (!item)
return 0;
int magic = 0, fire = 0, cold = 0, poison = 0, disease = 0, chromatic = 0, prismatic = 0, physical = 0,
corruption = 0;
int resist = 0;
int roll = 0;
/* this is how the client does the resist rolls for these.
* Given the difficulty of parsing out these resists, I'll trust the client
*/
if (item->GetItemElementalDamage(magic, fire, cold, poison, disease, chromatic, prismatic, physical, corruption, true)) {
if (magic) {
resist = GetMR();
if (resist >= 201) {
magic = 0;
} else {
roll = zone->random.Int(0, 200) - resist;
if (roll < 1)
magic = 0;
else if (roll < 100)
magic = magic * roll / 100;
}
}
if (fire) {
resist = GetFR();
if (resist >= 201) {
fire = 0;
} else {
roll = zone->random.Int(0, 200) - resist;
if (roll < 1)
fire = 0;
else if (roll < 100)
fire = fire * roll / 100;
}
}
if (cold) {
resist = GetCR();
if (resist >= 201) {
cold = 0;
} else {
roll = zone->random.Int(0, 200) - resist;
if (roll < 1)
cold = 0;
else if (roll < 100)
cold = cold * roll / 100;
}
}
if (poison) {
resist = GetPR();
if (resist >= 201) {
poison = 0;
} else {
roll = zone->random.Int(0, 200) - resist;
if (roll < 1)
poison = 0;
else if (roll < 100)
poison = poison * roll / 100;
}
}
if (disease) {
resist = GetDR();
if (resist >= 201) {
disease = 0;
} else {
roll = zone->random.Int(0, 200) - resist;
if (roll < 1)
disease = 0;
else if (roll < 100)
disease = disease * roll / 100;
}
}
if (corruption) {
resist = GetCorrup();
if (resist >= 201) {
corruption = 0;
} else {
roll = zone->random.Int(0, 200) - resist;
if (roll < 1)
corruption = 0;
else if (roll < 100)
corruption = corruption * roll / 100;
}
}
if (chromatic) {
resist = GetFR();
int temp = GetCR();
if (temp < resist)
resist = temp;
temp = GetMR();
if (temp < resist)
resist = temp;
temp = GetDR();
if (temp < resist)
resist = temp;
temp = GetPR();
if (temp < resist)
resist = temp;
if (resist >= 201) {
chromatic = 0;
} else {
roll = zone->random.Int(0, 200) - resist;
if (roll < 1)
chromatic = 0;
else if (roll < 100)
chromatic = chromatic * roll / 100;
}
}
if (prismatic) {
resist = (GetFR() + GetCR() + GetMR() + GetDR() + GetPR()) / 5;
if (resist >= 201) {
prismatic = 0;
} else {
roll = zone->random.Int(0, 200) - resist;
if (roll < 1)
prismatic = 0;
else if (roll < 100)
prismatic = prismatic * roll / 100;
}
}
if (physical) {
resist = GetPhR();
if (resist >= 201) {
physical = 0;
} else {
roll = zone->random.Int(0, 200) - resist;
if (roll < 1)
physical = 0;
else if (roll < 100)
physical = physical * roll / 100;
}
}
}
return magic + fire + cold + poison + disease + chromatic + prismatic + physical + corruption;
}
/* this is the mob being attacked.
* Pass in the weapon's ItemInst
*/
int Mob::CheckBaneDamage(const ItemInst *item)
{
if (!item)
return 0;
int damage = item->GetItemBaneDamageBody(GetBodyType(), true);
damage += item->GetItemBaneDamageRace(GetRace(), true);
return damage;
}