diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/pc.cpp | 3 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 43 |
2 files changed, 28 insertions, 18 deletions
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<block_list> 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); diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 0b1e7e6..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<block_list> caster = map_id2bl(st->rid); + dumb_ptr<block_list> sd; bl_num = conv_num(st, &AARG(0)); MapName mapname = stringish<MapName>(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<BlockId>(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, @@ -2640,11 +2649,23 @@ void builtin_donpcevent(ScriptState *st) static void builtin_addtimer(ScriptState *st) { + dumb_ptr<map_session_data> sd; interval_t tick = static_cast<interval_t>(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<BlockId>(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); } /*========================================== @@ -3222,17 +3243,10 @@ void builtin_resetstatus(ScriptState *st) static void builtin_attachrid(ScriptState *st) { - dumb_ptr<map_session_data> sd = map_id2sd(st->rid); - BlockId newid = wrap<BlockId>(conv_num(st, &AARG(0))); - - if (sd && newid != st->rid) - sd->npc_id = BlockId(); - - st->rid = newid; + st->rid = wrap<BlockId>(conv_num(st, &AARG(0))); push_int<ScriptDataInt>(st->stack, (map_id2sd(st->rid) != nullptr)); } - /*========================================== * RIDのデタッチ *------------------------------------------ @@ -3240,9 +3254,6 @@ void builtin_attachrid(ScriptState *st) static void builtin_detachrid(ScriptState *st) { - dumb_ptr<map_session_data> sd = map_id2sd(st->rid); - if (sd) - sd->npc_id = BlockId(); st->rid = BlockId(); } @@ -4746,7 +4757,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'), @@ -4813,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'), |