diff options
Diffstat (limited to 'src/map/script-fun.cpp')
-rw-r--r-- | src/map/script-fun.cpp | 182 |
1 files changed, 61 insertions, 121 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 3b814aa..3291cfc 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -108,7 +108,7 @@ void builtin_goto(ScriptState *st) { if (!AARG(0).is<ScriptDataPos>()) { - PRINTF("script: goto: not label !\n"_fmt); + PRINTF("script: goto: that's not a label!\n"_fmt); st->state = ScriptEndState::END; return; } @@ -149,7 +149,7 @@ void builtin_callfunc(ScriptState *st) } OMATCH_CASE_NONE () { - PRINTF("script:callfunc: function not found! [%s]\n"_fmt, str); + PRINTF("script: callfunc: function not found! [%s]\n"_fmt, str); st->state = ScriptEndState::END; } } @@ -338,22 +338,10 @@ void builtin_warp(ScriptState *st) { int x, y; dumb_ptr<map_session_data> sd = script_rid2sd(st); - MapName str = stringish<MapName>(ZString(conv_str(st, &AARG(0)))); x = conv_num(st, &AARG(1)); y = conv_num(st, &AARG(2)); - if (str == "Random"_s) - pc_randomwarp(sd, BeingRemoveWhy::WARPED); - else if (str == "SavePoint"_s or str == "Save"_s) - { - if (sd->bl_m->flag.get(MapFlag::NORETURN)) - return; - - pc_setpos(sd, sd->status.save_point.map_, sd->status.save_point.x, sd->status.save_point.y, - BeingRemoveWhy::WARPED); - } - else - pc_setpos(sd, str, x, y, BeingRemoveWhy::GONE); + pc_setpos(sd, str, x, y, BeingRemoveWhy::GONE); } /*========================================== @@ -364,10 +352,7 @@ static void builtin_areawarp_sub(dumb_ptr<block_list> bl, MapName mapname, int x, int y) { dumb_ptr<map_session_data> sd = bl->is_player(); - if (mapname == "Random"_s) - pc_randomwarp(sd, BeingRemoveWhy::WARPED); - else - pc_setpos(sd, mapname, x, y, BeingRemoveWhy::GONE); + pc_setpos(sd, mapname, x, y, BeingRemoveWhy::GONE); } static @@ -553,7 +538,7 @@ void builtin_setarray(ScriptState *st) if (prefix != '$' && prefix != '@') { - PRINTF("builtin_setarray: illegal scope !\n"_fmt); + PRINTF("builtin_setarray: illegal scope!\n"_fmt); return; } if (prefix != '$') @@ -584,7 +569,7 @@ void builtin_cleararray(ScriptState *st) if (prefix != '$' && prefix != '@') { - PRINTF("builtin_cleararray: illegal scope !\n"_fmt); + PRINTF("builtin_cleararray: illegal scope!\n"_fmt); return; } if (prefix != '$') @@ -641,7 +626,7 @@ void builtin_getarraysize(ScriptState *st) if (prefix != '$' && prefix != '@') { - PRINTF("builtin_copyarray: illegal scope !\n"_fmt); + PRINTF("builtin_copyarray: illegal scope!\n"_fmt); return; } @@ -660,7 +645,7 @@ void builtin_getelementofarray(ScriptState *st) int i = conv_num(st, &AARG(1)); if (i > 255 || i < 0) { - PRINTF("script: getelementofarray (operator[]): param2 illegal number %d\n"_fmt, + PRINTF("script: getelementofarray (operator[]): param2 illegal number: %d\n"_fmt, i); push_int<ScriptDataInt>(st->stack, 0); } @@ -672,11 +657,29 @@ void builtin_getelementofarray(ScriptState *st) } else { - PRINTF("script: getelementofarray (operator[]): param1 not name !\n"_fmt); + PRINTF("script: getelementofarray (operator[]): param1 not named!\n"_fmt); push_int<ScriptDataInt>(st->stack, 0); } } +static +void builtin_wgm(ScriptState *st) +{ + ZString message = ZString(conv_str(st, &AARG(0))); + + intif_wis_message_to_gm(WISP_SERVER_NAME, + battle_config.hack_info_GM_level, + STRPRINTF("[GM] %s"_fmt, message)); +} + +static +void builtin_gmlog(ScriptState *st) +{ + dumb_ptr<map_session_data> sd = script_rid2sd(st); + ZString message = ZString(conv_str(st, &AARG(0))); + log_atcommand(sd, STRPRINTF("{SCRIPT} %s"_fmt, message)); +} + /*========================================== * *------------------------------------------ @@ -732,7 +735,7 @@ void builtin_countitem(ScriptState *st) else { if (battle_config.error_log) - PRINTF("wrong item ID : countitem (%i)\n"_fmt, nameid); + PRINTF("wrong item ID: countitem (%i)\n"_fmt, nameid); } push_int<ScriptDataInt>(st->stack, count); @@ -770,7 +773,7 @@ void builtin_checkweight(ScriptState *st) amount = conv_num(st, &AARG(1)); if (amount <= 0 || !nameid) { - //if get wrong item ID or amount<=0, don't count weight of non existing items + //If it gets the wrong item ID or the amount<=0, don't count its weight (assume it's a non-existent item) push_int<ScriptDataInt>(st->stack, 0); return; } @@ -922,7 +925,7 @@ void builtin_delitem(ScriptState *st) if (!nameid || amount <= 0) { - //by Lupus. Don't run FOR if u got wrong item ID or amount<=0 + //By Lupus. Don't run FOR if you've got the wrong item ID or amount<=0 return; } @@ -949,31 +952,6 @@ void builtin_delitem(ScriptState *st) } /*========================================== - *キャラ関係のパラメータ取得 - *------------------------------------------ - */ -static -void builtin_readparam(ScriptState *st) -{ - dumb_ptr<map_session_data> sd; - - SP type = SP(conv_num(st, &AARG(0))); - if (HARG(1)) - sd = map_nick2sd(stringish<CharName>(ZString(conv_str(st, &AARG(1))))); - else - sd = script_rid2sd(st); - - if (sd == nullptr) - { - push_int<ScriptDataInt>(st->stack, -1); - return; - } - - push_int<ScriptDataInt>(st->stack, pc_readparam(sd, type)); - -} - -/*========================================== *キャラ関係のID取得 *------------------------------------------ */ @@ -1165,20 +1143,6 @@ void builtin_getequipname(ScriptState *st) } /*========================================== - * - *------------------------------------------ - */ -static -void builtin_statusup2(ScriptState *st) -{ - SP type = SP(conv_num(st, &AARG(0))); - int val = conv_num(st, &AARG(1)); - dumb_ptr<map_session_data> sd = script_rid2sd(st); - pc_statusup2(sd, type, val); - -} - -/*========================================== * 装備品による能力値ボーナス *------------------------------------------ */ @@ -1970,7 +1934,7 @@ static void builtin_debugmes(ScriptState *st) { RString mes = conv_str(st, &AARG(0)); - PRINTF("script debug : %d %d : %s\n"_fmt, + PRINTF("script debug: %d %d: '%s'\n"_fmt, st->rid, st->oid, mes); } @@ -1987,20 +1951,6 @@ void builtin_resetstatus(ScriptState *st) } /*========================================== - * 性別変換 - *------------------------------------------ - */ -static -void builtin_changesex(ScriptState *st) -{ - dumb_ptr<map_session_data> sd = nullptr; - sd = script_rid2sd(st); - - chrif_char_ask_name(AccountId(), sd->status_key.name, 5, HumanTimeDiff()); // type: 5 - changesex - chrif_save(sd); -} - -/*========================================== * RIDのアタッチ *------------------------------------------ */ @@ -2179,11 +2129,22 @@ void builtin_getpvpflag(ScriptState *st) static void builtin_emotion(ScriptState *st) { - int type; - type = conv_num(st, &AARG(0)); + ZString str; + dumb_ptr<map_session_data> pl_sd = nullptr; + int type = conv_num(st, &AARG(0)); + if (HARG(1)) { + str = ZString(conv_str(st, &AARG(1))); + CharName player = stringish<CharName>(str); + pl_sd = map_nick2sd(player); + } if (type < 0 || type > 200) return; - clif_emotion(map_id2bl(st->oid), type); + if (pl_sd != nullptr) + clif_emotion_towards(map_id2bl(st->oid), pl_sd, type); + else if (st->rid && str == "self"_s) + clif_emotion(map_id2sd(st->rid), type); + else + clif_emotion(map_id2bl(st->oid), type); } static @@ -2311,11 +2272,11 @@ void builtin_getitemlink(ScriptState *st) { OMATCH_CASE_SOME (item_data) { - buf = STRPRINTF("[@@%d|%s@@]"_fmt, item_data->nameid, item_data->jname); + buf = STRPRINTF("@@%d|@@"_fmt, item_data->nameid); } OMATCH_CASE_NONE () { - buf = STRPRINTF("Unknown Item: %s"_fmt, name); + buf = "Unknown Item"_s; } } OMATCH_END (); @@ -2592,25 +2553,6 @@ void builtin_unequipbyid(ScriptState *st) } /*========================================== - * gmcommand [MouseJstr] - * - * suggested on the forums... - *------------------------------------------ - */ - -static -void builtin_gmcommand(ScriptState *st) -{ - dumb_ptr<map_session_data> sd; - - sd = script_rid2sd(st); - RString cmd = conv_str(st, &AARG(0)); - - is_atcommand(sd->sess, sd, cmd, GmLevel::from(-1U)); - -} - -/*========================================== * npcwarp [remoitnane] * Move NPC to a new position on the same map. *------------------------------------------ @@ -2628,7 +2570,7 @@ void builtin_npcwarp(ScriptState *st) if (!nd) { - PRINTF("builtin_npcwarp: no such npc: %s\n"_fmt, npc); + PRINTF("builtin_npcwarp: no such npc: '%s'\n"_fmt, npc); return; } @@ -2671,7 +2613,7 @@ void builtin_npcareawarp(ScriptState *st) if (!nd) { - PRINTF("builtin_npcareawarp: no such npc: %s\n"_fmt, npc); + PRINTF("builtin_npcareawarp: no such npc: '%s'\n"_fmt, npc); return; } @@ -2916,7 +2858,7 @@ void builtin_shop(ScriptState *st) nd = npc_name2id(name); if (!nd) { - PRINTF("builtin_shop: no such npc: %s\n"_fmt, name); + PRINTF("builtin_shop: no such npc: '%s'\n"_fmt, name); return; } @@ -2949,7 +2891,7 @@ void builtin_fakenpcname(ScriptState *st) dumb_ptr<npc_data> nd = npc_name2id(name); if (!nd) { - PRINTF("builtin_fakenpcname: no such npc: %s\n"_fmt, name); + PRINTF("builtin_fakenpcname: no such npc: '%s'\n"_fmt, name); return; } nd->name = newname; @@ -3011,7 +2953,7 @@ void builtin_strnpcinfo(ScriptState *st) nd = npc_name2id(npc); if (!nd) { - PRINTF("builtin_strnpcinfo: no such npc: %s\n"_fmt, npc); + PRINTF("builtin_strnpcinfo: no such npc: '%s'\n"_fmt, npc); return; } } else { @@ -3051,7 +2993,7 @@ void builtin_getnpcx(ScriptState *st) nd = npc_name2id(name); if (!nd) { - PRINTF("builtin_getnpcx: no such npc: %s\n"_fmt, name); + PRINTF("builtin_getnpcx: no such npc: '%s'\n"_fmt, name); return; } } else { @@ -3075,7 +3017,7 @@ void builtin_getnpcy(ScriptState *st) nd = npc_name2id(name); if (!nd) { - PRINTF("builtin_getnpcy: no such npc: %s\n"_fmt, name); + PRINTF("builtin_getnpcy: no such npc: '%s'\n"_fmt, name); return; } } else { @@ -3124,12 +3066,10 @@ BuiltinFunction builtin_functions[] = BUILTIN(getitem, "Ii??"_s, '\0'), BUILTIN(makeitem, "IiMxy"_s, '\0'), BUILTIN(delitem, "Ii"_s, '\0'), - BUILTIN(readparam, "i?"_s, 'i'), BUILTIN(getcharid, "i?"_s, 'i'), BUILTIN(strcharinfo, "i"_s, 's'), BUILTIN(getequipid, "i"_s, 'i'), BUILTIN(getequipname, "i"_s, 's'), - BUILTIN(statusup2, "ii"_s, '\0'), BUILTIN(bonus, "ii"_s, '\0'), BUILTIN(bonus2, "iii"_s, '\0'), BUILTIN(skill, "ii?"_s, '\0'), @@ -3149,11 +3089,11 @@ BuiltinFunction builtin_functions[] = BUILTIN(killmonster, "ME"_s, '\0'), BUILTIN(donpcevent, "E"_s, '\0'), BUILTIN(addtimer, "tE"_s, '\0'), - BUILTIN(initnpctimer, ""_s, '\0'), + BUILTIN(initnpctimer, "?"_s, '\0'), BUILTIN(startnpctimer, "?"_s, '\0'), - BUILTIN(stopnpctimer, ""_s, '\0'), - BUILTIN(getnpctimer, "i"_s, 'i'), - BUILTIN(setnpctimer, "i"_s, '\0'), + BUILTIN(stopnpctimer, "?"_s, '\0'), + BUILTIN(getnpctimer, "i?"_s, 'i'), + BUILTIN(setnpctimer, "i?"_s, '\0'), BUILTIN(announce, "si"_s, '\0'), BUILTIN(mapannounce, "Msi"_s, '\0'), BUILTIN(getusers, "i"_s, 'i'), @@ -3166,8 +3106,9 @@ BuiltinFunction builtin_functions[] = BUILTIN(sc_end, "i"_s, '\0'), BUILTIN(sc_check, "i"_s, 'i'), BUILTIN(debugmes, "s"_s, '\0'), + BUILTIN(wgm, "s"_s, '\0'), + BUILTIN(gmlog, "s"_s, '\0'), BUILTIN(resetstatus, ""_s, '\0'), - BUILTIN(changesex, ""_s, '\0'), BUILTIN(attachrid, "i"_s, 'i'), BUILTIN(detachrid, ""_s, '\0'), BUILTIN(isloggedin, "i"_s, 'i'), @@ -3178,7 +3119,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(pvpoff, "M"_s, '\0'), BUILTIN(setpvpchannel, "i"_s, '\0'), BUILTIN(getpvpflag, "i"_s, 'i'), - BUILTIN(emotion, "i"_s, '\0'), + BUILTIN(emotion, "i?"_s, '\0'), BUILTIN(mapwarp, "MMxy"_s, '\0'), BUILTIN(mobcount, "ME"_s, 'i'), BUILTIN(marriage, "P"_s, 'i'), @@ -3197,7 +3138,6 @@ BuiltinFunction builtin_functions[] = BUILTIN(specialeffect2, "i"_s, '\0'), BUILTIN(nude, ""_s, '\0'), BUILTIN(unequipbyid, "i"_s, '\0'), - BUILTIN(gmcommand, "s"_s, '\0'), BUILTIN(npcwarp, "xys"_s, '\0'), BUILTIN(npcareawarp, "xyxyis"_s, '\0'), BUILTIN(message, "Ps"_s, '\0'), |