summaryrefslogtreecommitdiff
path: root/src/emap/script_buildins.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emap/script_buildins.c')
-rw-r--r--src/emap/script_buildins.c27
1 files changed, 15 insertions, 12 deletions
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) {