From c98d734b22e0fa9d3f72693531414efa7657eb23 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Tue, 7 Sep 2021 04:20:39 -0300 Subject: Track criticals, misses, dodges and undefended damage --- src/emap/battle.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/emap/battle.c b/src/emap/battle.c index 1b311b7..66097ca 100644 --- a/src/emap/battle.c +++ b/src/emap/battle.c @@ -97,6 +97,18 @@ struct Damage ebattle_calc_weapon_attack_post(struct Damage retVal, if (src == NULL) return retVal; + /* Player Variable updates (target) */ + if (target->type == BL_PC) { + struct map_session_data *tsd = BL_CAST(BL_PC, target); + pc->setreg(tsd, script->add_variable("@weaponDef"), pc->readreg(tsd,script->add_variable("@weaponDef"))+retVal.damage); + + if (retVal.type == BDT_PDODGE) + pc->setreg(tsd, script->add_variable("@weaponDodge"), pc->readreg(tsd,script->add_variable("@weaponDodge"))+10); + + if (retVal.dmg_lv == ATK_FLEE) + pc->setreg(tsd, script->add_variable("@weaponDodge"), pc->readreg(tsd,script->add_variable("@weaponDodge"))+1); + } + struct map_session_data *sd = BL_CAST(BL_PC, src); if (sd == NULL) return retVal; @@ -131,7 +143,18 @@ struct Damage ebattle_calc_weapon_attack_post(struct Damage retVal, } retVal.damage = apply_percentrate64(retVal.damage, mod, 10000); retVal.damage2 = apply_percentrate64(retVal.damage2, mod, 10000); - pc->setreg(sd, script->add_variable("@weaponAtk"), pc->readreg(sd,script->add_variable("@weaponAtk"))+1); + + /* Player Variable updates (source) */ + if (src->type == BL_PC) { + pc->setreg(sd, script->add_variable("@weaponAtk"), pc->readreg(sd,script->add_variable("@weaponAtk"))+1); + + if (retVal.type == BDT_CRIT) + pc->setreg(sd, script->add_variable("@weaponCrit"), pc->readreg(sd,script->add_variable("@weaponCrit"))+1); + + if (retVal.dmg_lv == ATK_FLEE) + pc->setreg(sd, script->add_variable("@weaponMiss"), pc->readreg(sd,script->add_variable("@weaponMiss"))+1); + } + return retVal; } -- cgit v1.2.3-70-g09d2