diff options
Diffstat (limited to 'src/emap')
-rw-r--r-- | src/emap/init.c | 2 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 27 |
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) { |