From 0384d11f9b92d1368a87d5351db983a7b94b5042 Mon Sep 17 00:00:00 2001 From: mekolat Date: Sun, 1 May 2016 19:50:31 -0400 Subject: revert attachrid modification for now, will be deprecated soon enough --- src/map/script-fun.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src') diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 0b1e7e6..90eb557 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -3222,17 +3222,10 @@ void builtin_resetstatus(ScriptState *st) static void builtin_attachrid(ScriptState *st) { - dumb_ptr sd = map_id2sd(st->rid); - BlockId newid = wrap(conv_num(st, &AARG(0))); - - if (sd && newid != st->rid) - sd->npc_id = BlockId(); - - st->rid = newid; + st->rid = wrap(conv_num(st, &AARG(0))); push_int(st->stack, (map_id2sd(st->rid) != nullptr)); } - /*========================================== * RIDのデタッチ *------------------------------------------ @@ -3240,9 +3233,6 @@ void builtin_attachrid(ScriptState *st) static void builtin_detachrid(ScriptState *st) { - dumb_ptr sd = map_id2sd(st->rid); - if (sd) - sd->npc_id = BlockId(); st->rid = BlockId(); } -- cgit v1.2.3-70-g09d2 From 1aa0c7f8ed925a181809fb72ed531b0981435537 Mon Sep 17 00:00:00 2001 From: mekolat Date: Sun, 1 May 2016 20:27:30 -0400 Subject: allow addtimer to have a target --- src/map/script-fun.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 90eb557..849bffa 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2640,11 +2640,23 @@ void builtin_donpcevent(ScriptState *st) static void builtin_addtimer(ScriptState *st) { + dumb_ptr sd; interval_t tick = static_cast(conv_num(st, &AARG(0))); ZString event_ = ZString(conv_str(st, &AARG(1))); NpcEvent event; extract(event_, &event); - pc_addeventtimer(script_rid2sd(st), tick, event); + + if (HARG(2)) + sd = map_id_is_player(wrap(conv_num(st, &AARG(2)))); + else if (st->rid) + sd = script_rid2sd(st); + + if (sd == nullptr) + { + PRINTF("builtin_addtimer: player not attached.\n"_fmt); + } + + pc_addeventtimer(sd, tick, event); } /*========================================== @@ -4736,7 +4748,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(areamonster, "Mxyxysmi?"_s, '\0'), BUILTIN(killmonster, "ME"_s, '\0'), BUILTIN(donpcevent, "E"_s, '\0'), - BUILTIN(addtimer, "tE"_s, '\0'), + BUILTIN(addtimer, "tE?"_s, '\0'), BUILTIN(addnpctimer, "tE"_s, '\0'), BUILTIN(initnpctimer, "?"_s, '\0'), BUILTIN(startnpctimer, "?"_s, '\0'), -- cgit v1.2.3-70-g09d2 From c5a7ca5c82088546954bbf31ab12f0bab6c2093a Mon Sep 17 00:00:00 2001 From: mekolat Date: Sun, 1 May 2016 20:52:27 -0400 Subject: allow foreach to have a target --- src/map/script-fun.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 849bffa..98c07ed 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -1065,7 +1065,7 @@ void builtin_foreach(ScriptState *st) { int x0, y0, x1, y1, bl_num; - dumb_ptr caster = map_id2bl(st->rid); + dumb_ptr sd; bl_num = conv_num(st, &AARG(0)); MapName mapname = stringish(ZString(conv_str(st, &AARG(1)))); x0 = conv_num(st, &AARG(2)); @@ -1096,8 +1096,17 @@ void builtin_foreach(ScriptState *st) default: return; } + if (HARG(7)) + sd = map_id_is_player(wrap(conv_num(st, &AARG(7)))); + else if (st->rid) + sd = script_rid2sd(st); + + if (sd == nullptr) + { + PRINTF("builtin_foreach: player not attached.\n"_fmt); + } - map_foreachinarea(std::bind(builtin_foreach_sub, ph::_1, event, caster->bl_id), + map_foreachinarea(std::bind(builtin_foreach_sub, ph::_1, event, sd->bl_id), m, x0, y0, x1, y1, @@ -4815,7 +4824,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(getlook, "i"_s, 'i'), BUILTIN(getsavepoint, "i"_s, '.'), BUILTIN(areatimer, "MxyxytEi"_s, '\0'), - BUILTIN(foreach, "iMxyxyE"_s, '\0'), + BUILTIN(foreach, "iMxyxyE?"_s, '\0'), BUILTIN(isin, "Mxyxy"_s, 'i'), BUILTIN(iscollision, "Mxy"_s, 'i'), BUILTIN(shop, "s"_s, '\0'), -- cgit v1.2.3-70-g09d2 From b2599f6595558840632bbabf4f91692900536d65 Mon Sep 17 00:00:00 2001 From: mekolat Date: Sun, 1 May 2016 21:17:46 -0400 Subject: make SP::HP use pc_heal in pc_setparam --- src/map/pc.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 6057278..05f61ea 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -3710,8 +3710,7 @@ int pc_setparam(dumb_ptr bl, SP type, int val) case SP::HP: nullpo_retz(sd); // TODO: mob mutation - sd->status.hp = val; - clif_updatestatus(sd, type); + pc_heal(sd, (val - sd->status.hp), 0); break; case SP::MAXHP: nullpo_retz(sd); -- cgit v1.2.3-70-g09d2