diff options
Diffstat (limited to 'src/emap/battle.c')
-rw-r--r-- | src/emap/battle.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/src/emap/battle.c b/src/emap/battle.c index e0b7942..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,6 +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); + + /* 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; } @@ -149,9 +173,20 @@ enum damage_lv ebattle_weapon_attack_pre(struct block_list **srcPtr, if (sd == NULL) return ATK_NONE; - const int weaponIndex = sd->equip_index[EQI_HAND_L]; - if (weaponIndex < 0) + const int weaponIndex = sd->equip_index[EQI_HAND_R]; + if (weaponIndex < 0) { + const int oldWeapon = pc->readreg(sd, script->add_variable("@weaponId")); + if (oldWeapon < 1) + { + pc->setreg(sd, script->add_variable("@weaponId"), 1); + } + else if (1 != oldWeapon) + { + pc->setreg(sd, script->add_variable("@weaponId"), 1); + pc->setreg(sd, script->add_variable("@weaponNew"), 1); + } return ATK_NONE; + } struct ItemdExt *data = itemd_get(sd->inventory_data[weaponIndex]); if (!data) @@ -162,5 +197,16 @@ enum damage_lv ebattle_weapon_attack_pre(struct block_list **srcPtr, hookStop(); return ATK_NONE; } + + const int oldWeapon = pc->readreg(sd,script->add_variable("@weaponId")); + if (oldWeapon < 1) + { + pc->setreg(sd, script->add_variable("@weaponId"), sd->inventory_data[weaponIndex]->nameid); + } + else if (sd->inventory_data[weaponIndex]->nameid != oldWeapon) + { + pc->setreg(sd, script->add_variable("@weaponId"), sd->inventory_data[weaponIndex]->nameid); + pc->setreg(sd, script->add_variable("@weaponNew"), 1); + } return ATK_NONE; } |