summaryrefslogtreecommitdiff
path: root/src/map/script-fun.cpp
diff options
context:
space:
mode:
authormekolat <mekolat@users.noreply.github.com>2016-05-01 20:31:04 -0400
committermekolat <mekolat@users.noreply.github.com>2016-05-01 20:31:04 -0400
commit360614b270acb47643fcf6216dd32b10dfab81dd (patch)
treefec10771d65d17a111a09ed28ca1837b4eb07917 /src/map/script-fun.cpp
parent9661c46ab0c9bcb1cc582396b4816e057cec570d (diff)
parent552b06a0205b2179da6017d876c2117fdebbb514 (diff)
downloadtmwa-360614b270acb47643fcf6216dd32b10dfab81dd.tar.gz
tmwa-360614b270acb47643fcf6216dd32b10dfab81dd.tar.bz2
tmwa-360614b270acb47643fcf6216dd32b10dfab81dd.tar.xz
tmwa-360614b270acb47643fcf6216dd32b10dfab81dd.zip
Merge pull request #216 from mekolat/aggravate
simplify `aggravate` builtin
Diffstat (limited to 'src/map/script-fun.cpp')
-rw-r--r--src/map/script-fun.cpp34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 898eec0..0b1e7e6 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -2976,35 +2976,17 @@ void builtin_getmapusers(ScriptState *st)
}
static
-void builtin_aggravate_sub(dumb_ptr<block_list> bl, dumb_ptr<block_list> target, int effect)
-{
- dumb_ptr<mob_data> md = bl->is_mob();
-
- if (mob_aggravate(md, target))
- clif_misceffect(bl, effect);
-}
-
-static
void builtin_aggravate(ScriptState *st)
{
- dumb_ptr<block_list> target = map_id2bl(st->rid);
- MapName str = stringish<MapName>(ZString(conv_str(st, &AARG(0))));
- int x0 = conv_num(st, &AARG(1));
- int y0 = conv_num(st, &AARG(2));
- int x1 = conv_num(st, &AARG(3));
- int y1 = conv_num(st, &AARG(4));
- int effect = conv_num(st, &AARG(5));
- P<map_local> m = TRY_UNWRAP(map_mapname2mapid(str),
+ dumb_ptr<mob_data> md = map_id_is_mob(wrap<BlockId>(conv_num(st, &AARG(0))));
+ if (md)
{
- push_int<ScriptDataInt>(st->stack, -1);
- return;
- });
+ dumb_ptr<block_list> target = script_rid2sd(st);
+ if (HARG(1))
+ target = map_id2bl(wrap<BlockId>(conv_num(st, &AARG(1))));
- map_foreachinarea(std::bind(builtin_aggravate_sub, ph::_1, target, effect),
- m,
- x0, y0,
- x1, y1,
- BL::MOB);
+ mob_aggravate(md, target);
+ }
}
/*==========================================
@@ -4836,7 +4818,7 @@ BuiltinFunction builtin_functions[] =
BUILTIN(iscollision, "Mxy"_s, 'i'),
BUILTIN(shop, "s"_s, '\0'),
BUILTIN(isdead, ""_s, 'i'),
- BUILTIN(aggravate, "Mxyxyi"_s, '\0'),
+ BUILTIN(aggravate, "i?"_s, '\0'),
BUILTIN(fakenpcname, "ssi"_s, '\0'),
BUILTIN(puppet, "mxysi??"_s, 'i'),
BUILTIN(destroy, "?"_s, '\0'),