summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-12-29 08:12:03 -0300
committerJesusaves <cpntb1@ymail.com>2021-12-29 08:12:03 -0300
commit9443a0d2124b05adc96aadc45a2c0de2f863bbec (patch)
tree1ecffda50ee7ed6f0975cca3a8ace9a556cd7e8f
parentf348a04be46b9b19b59cc9937f3f7ee7aa55472f (diff)
downloadevol-hercules-9443a0d2124b05adc96aadc45a2c0de2f863bbec.tar.gz
evol-hercules-9443a0d2124b05adc96aadc45a2c0de2f863bbec.tar.bz2
evol-hercules-9443a0d2124b05adc96aadc45a2c0de2f863bbec.tar.xz
evol-hercules-9443a0d2124b05adc96aadc45a2c0de2f863bbec.zip
Allow source to be specified in harm() - for more precise calculations
-rw-r--r--src/emap/init.c2
-rw-r--r--src/emap/script_buildins.c27
2 files changed, 16 insertions, 13 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index d92c48d..a50c5ef 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -240,7 +240,7 @@ HPExport void plugin_init (void)
addScriptCommand("instanceowner", "i", InstanceOwner);
addScriptCommand("aggravate", "i", aggravate);
addScriptCommand("calcdmg", "iii", calcdmg);
- addScriptCommand("harm", "ii??", harm);
+ addScriptCommand("harm", "ii???", harm);
addScriptCommand("resetrng", "", resetrng);
addScriptCommand("getskillname", "i", getskillname);
addScriptCommand("bgnew", "siiss", bgnew);
diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c
index 3bd6d8e..4ebab40 100644
--- a/src/emap/script_buildins.c
+++ b/src/emap/script_buildins.c
@@ -3409,13 +3409,12 @@ BUILDIN(calcdmg)
// Like heal() but works against anything (casts battle funcs)
// types: 1- physical; 2- magic.
// Any other number: misc (no calculation)
-// harm(guid, raw_damage, {type{, element}})
+// harm(guid, raw_damage, {type{, element{, source}}})
BUILDIN(harm)
{
struct block_list *src;
struct block_list *bl;
struct status_data *tstatus;
- struct map_session_data *sd = NULL;
int attack_type = BF_MISC;
short elemental = ELE_NEUTRAL;
@@ -3430,6 +3429,20 @@ BUILDIN(harm)
if (script_hasdata(st,5)) {
elemental = script_getnum(st,5);
}
+ // Source (sd), might be null
+ if (script_hasdata(st,6)) {
+ src = map->id2bl(script_getnum(st, 6));
+ } else if (st->rid != 0 && map->id2sd(st->rid) != NULL) {
+ struct map_session_data *sd = script->rid2sd(st);
+ // Default source to self if needed
+ if (sd == NULL) {
+ src = bl;
+ } else {
+ src = &sd->bl;
+ }
+ } else {
+ src = bl;
+ }
// Nullity checks
if (bl == NULL) {
@@ -3442,16 +3455,6 @@ BUILDIN(harm)
if( dmg == INT_MIN ) dmg++;
if( dmg == INT_MAX ) dmg--;
- // Source (sd), might be null
- if(st->rid != 0 && map->id2sd(st->rid) != NULL)
- sd = script->rid2sd(st);
-
- // Default source to self if needed
- if (sd == NULL) {
- src = bl;
- } else {
- src = &sd->bl;
- }
// Calculate defese (unaffected if not BF_WEAPON nor BF_MAGIC)
switch(attack_type) {