From 53d5fc609a537456ba36ef4a5bcc7228b016bb65 Mon Sep 17 00:00:00 2001 From: Atemo Date: Sat, 22 Oct 2022 12:57:46 +0200 Subject: [PATCH] Updated damagetaken (#7372) Save damagetaken in mob_data for mob controller --- doc/script_commands.txt | 1 + src/map/battle.cpp | 4 ++-- src/map/mob.hpp | 1 + src/map/script.cpp | 2 ++ src/map/script.hpp | 1 + src/map/script_constants.hpp | 1 + src/map/status.cpp | 1 + 7 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 938d755bfb..2696bd786f 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -8584,6 +8584,7 @@ Parameters (indexes) for monsters are: UMOB_IGNORE_CELL_STACK_LIMIT UMOB_RES UMOB_MRES + UMOB_DAMAGETAKEN ----- diff --git a/src/map/battle.cpp b/src/map/battle.cpp index d803b71c5d..b2b6dd9e3b 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -1845,8 +1845,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if (bl->type == BL_MOB) { // Reduces damage received for Green Aura MVP mob_data *md = BL_CAST(BL_MOB, bl); - if (md && md->db->damagetaken != 100) - damage = i64max(damage * md->db->damagetaken / 100, 1); + if (md && md->damagetaken != 100) + damage = i64max(damage * md->damagetaken / 100, 1); } return damage; diff --git a/src/map/mob.hpp b/src/map/mob.hpp index c1e5200ff0..865f6d9665 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -380,6 +380,7 @@ struct mob_data { * MvP Tombstone NPC ID **/ int tomb_nid; + uint16 damagetaken; e_mob_bosstype get_bosstype(); }; diff --git a/src/map/script.cpp b/src/map/script.cpp index 631fd3a64f..1d2b88e6a2 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -18741,6 +18741,7 @@ BUILDIN_FUNC(getunitdata) getunitdata_sub(UMOB_IGNORE_CELL_STACK_LIMIT, md->ud.state.ignore_cell_stack_limit); getunitdata_sub(UMOB_RES, md->status.res); getunitdata_sub(UMOB_MRES, md->status.mres); + getunitdata_sub(UMOB_DAMAGETAKEN, md->damagetaken); break; case BL_HOM: @@ -19148,6 +19149,7 @@ BUILDIN_FUNC(setunitdata) case UMOB_IGNORE_CELL_STACK_LIMIT: md->ud.state.ignore_cell_stack_limit = value > 0; break; case UMOB_RES: md->base_status->res = (short)value; calc_status = true; break; case UMOB_MRES: md->base_status->mres = (short)value; calc_status = true; break; + case UMOB_DAMAGETAKEN: md->damagetaken = (unsigned short)value; break; default: ShowError("buildin_setunitdata: Unknown data identifier %d for BL_MOB.\n", type); return SCRIPT_CMD_FAILURE; diff --git a/src/map/script.hpp b/src/map/script.hpp index 17eedd4621..b8081a51a3 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -494,6 +494,7 @@ enum unitdata_mobtypes { UMOB_IGNORE_CELL_STACK_LIMIT, UMOB_RES, UMOB_MRES, + UMOB_DAMAGETAKEN, }; enum unitdata_homuntypes { diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp index 7f7b7c3e12..aebab6faf1 100644 --- a/src/map/script_constants.hpp +++ b/src/map/script_constants.hpp @@ -4685,6 +4685,7 @@ export_constant(UMOB_IGNORE_CELL_STACK_LIMIT); export_constant(UMOB_RES); export_constant(UMOB_MRES); + export_constant(UMOB_DAMAGETAKEN); /* unit control - homunculus */ export_constant(UHOM_SIZE); diff --git a/src/map/status.cpp b/src/map/status.cpp index 2d77a48913..cc58d6aafb 100644 --- a/src/map/status.cpp +++ b/src/map/status.cpp @@ -2602,6 +2602,7 @@ int status_calc_mob_(struct mob_data* md, uint8 opt) ; else md->level = md->db->lv; + md->damagetaken = md->db->damagetaken; } // Check if we need custom base-status