summaryrefslogtreecommitdiff
path: root/src/map/script-fun.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script-fun.cpp')
-rw-r--r--src/map/script-fun.cpp183
1 files changed, 152 insertions, 31 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 919bf90..3b814aa 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -1538,25 +1538,6 @@ void builtin_killmonster(ScriptState *st)
BL::MOB);
}
-static
-void builtin_killmonsterall_sub(dumb_ptr<block_list> bl)
-{
- mob_delete(bl->is_mob());
-}
-
-static
-void builtin_killmonsterall(ScriptState *st)
-{
- MapName mapname = stringish<MapName>(ZString(conv_str(st, &AARG(0))));
-
- P<map_local> m = TRY_UNWRAP(map_mapname2mapid(mapname), return);
- map_foreachinarea(builtin_killmonsterall_sub,
- m,
- 0, 0,
- m->xs, m->ys,
- BL::MOB);
-}
-
/*==========================================
* NPC主体イベント実行
*------------------------------------------
@@ -2159,6 +2140,37 @@ void builtin_pvpoff(ScriptState *st)
}
}
+static
+void builtin_setpvpchannel(ScriptState *st)
+{
+ dumb_ptr<map_session_data> sd = script_rid2sd(st);
+ int flag;
+ flag = conv_num(st, &AARG(0));
+ if (flag < 1)
+ flag = 0;
+
+ sd->state.pvpchannel = flag;
+}
+
+static
+void builtin_getpvpflag(ScriptState *st)
+{
+ dumb_ptr<map_session_data> sd = script_rid2sd(st);
+ int num = conv_num(st, &AARG(0));
+ int flag = 0;
+
+ switch (num){
+ case 0:
+ flag = sd->state.pvpchannel;
+ break;
+ case 1:
+ flag = bool(sd->status.option & Opt0::HIDE);
+ break;
+ }
+
+ push_int<ScriptDataInt>(st->stack, flag);
+}
+
/*==========================================
* NPCエモーション
*------------------------------------------
@@ -2169,7 +2181,7 @@ void builtin_emotion(ScriptState *st)
{
int type;
type = conv_num(st, &AARG(0));
- if (type < 0 || type > 100)
+ if (type < 0 || type > 200)
return;
clif_emotion(map_id2bl(st->oid), type);
}
@@ -2198,15 +2210,6 @@ void builtin_mapwarp(ScriptState *st) // Added by RoVeRT
}
static
-void builtin_cmdothernpc(ScriptState *st) // Added by RoVeRT
-{
- NpcName npc = stringish<NpcName>(ZString(conv_str(st, &AARG(0))));
- ZString command = ZString(conv_str(st, &AARG(1)));
-
- npc_command(map_id2sd(st->rid), npc, command);
-}
-
-static
void builtin_mobcount_sub(dumb_ptr<block_list> bl, NpcEvent event, int *c)
{
if (event == bl->is_mob()->npc_event)
@@ -2295,6 +2298,31 @@ void builtin_getitemname(ScriptState *st)
}
static
+void builtin_getitemlink(ScriptState *st)
+{
+ struct script_data *data;
+ AString buf;
+ data = &AARG(0);
+ ZString name = conv_str(st, data);
+
+ ItemNameId item_id;
+ Option<P<struct item_data>> item_data_ = itemdb_searchname(name);
+ OMATCH_BEGIN (item_data_)
+ {
+ OMATCH_CASE_SOME (item_data)
+ {
+ buf = STRPRINTF("[@@%d|%s@@]"_fmt, item_data->nameid, item_data->jname);
+ }
+ OMATCH_CASE_NONE ()
+ {
+ buf = STRPRINTF("Unknown Item: %s"_fmt, name);
+ }
+ }
+ OMATCH_END ();
+ push_str<ScriptDataStr>(st->stack, buf);
+}
+
+static
void builtin_getspellinvocation(ScriptState *st)
{
RString name = conv_str(st, &AARG(0));
@@ -2968,6 +2996,95 @@ void builtin_getmap(ScriptState *st)
push_str<ScriptDataStr>(st->stack, sd->bl_m->name_);
}
+/*
+ * Get the NPC's info
+ */
+static
+void builtin_strnpcinfo(ScriptState *st)
+{
+ int num = conv_num(st, &AARG(0));
+ RString name;
+ dumb_ptr<npc_data> nd;
+
+ if(HARG(1)){
+ NpcName npc = stringish<NpcName>(ZString(conv_str(st, &AARG(1))));
+ nd = npc_name2id(npc);
+ if (!nd)
+ {
+ PRINTF("builtin_strnpcinfo: no such npc: %s\n"_fmt, npc);
+ return;
+ }
+ } else {
+ nd = map_id_is_npc(st->oid);
+ }
+
+ switch(num)
+ {
+ case 0:
+ name = nd->name;
+ break;
+ case 1:
+ name = nd->name.xislice_h(std::find(nd->name.begin(), nd->name.end(), '#'));
+ break;
+ case 2:
+ name = nd->name.xislice_t(std::find(nd->name.begin(), nd->name.end(), '#'));
+ break;
+ case 3:
+ name = nd->bl_m->name_;
+ break;
+ }
+
+ push_str<ScriptDataStr>(st->stack, name);
+}
+
+/*============================
+ * Gets the NPC's x pos
+ *----------------------------
+ */
+static
+void builtin_getnpcx(ScriptState *st)
+{
+ dumb_ptr<npc_data> nd;
+
+ if(HARG(0)){
+ NpcName name = stringish<NpcName>(ZString(conv_str(st, &AARG(0))));
+ nd = npc_name2id(name);
+ if (!nd)
+ {
+ PRINTF("builtin_getnpcx: no such npc: %s\n"_fmt, name);
+ return;
+ }
+ } else {
+ nd = map_id_is_npc(st->oid);
+ }
+
+ push_int<ScriptDataInt>(st->stack, nd->bl_x);
+}
+
+/*============================
+ * Gets the NPC's y pos
+ *----------------------------
+ */
+static
+void builtin_getnpcy(ScriptState *st)
+{
+ dumb_ptr<npc_data> nd;
+
+ if(HARG(0)){
+ NpcName name = stringish<NpcName>(ZString(conv_str(st, &AARG(0))));
+ nd = npc_name2id(name);
+ if (!nd)
+ {
+ PRINTF("builtin_getnpcy: no such npc: %s\n"_fmt, name);
+ return;
+ }
+ } else {
+ nd = map_id_is_npc(st->oid);
+ }
+
+ push_int<ScriptDataInt>(st->stack, nd->bl_y);
+}
+
static
void builtin_mapexit(ScriptState *)
{
@@ -3030,7 +3147,6 @@ BuiltinFunction builtin_functions[] =
BUILTIN(monster, "Mxysmi?"_s, '\0'),
BUILTIN(areamonster, "Mxyxysmi?"_s, '\0'),
BUILTIN(killmonster, "ME"_s, '\0'),
- BUILTIN(killmonsterall, "M"_s, '\0'),
BUILTIN(donpcevent, "E"_s, '\0'),
BUILTIN(addtimer, "tE"_s, '\0'),
BUILTIN(initnpctimer, ""_s, '\0'),
@@ -3060,13 +3176,15 @@ BuiltinFunction builtin_functions[] =
BUILTIN(getmapflag, "Mi"_s, 'i'),
BUILTIN(pvpon, "M"_s, '\0'),
BUILTIN(pvpoff, "M"_s, '\0'),
+ BUILTIN(setpvpchannel, "i"_s, '\0'),
+ BUILTIN(getpvpflag, "i"_s, 'i'),
BUILTIN(emotion, "i"_s, '\0'),
BUILTIN(mapwarp, "MMxy"_s, '\0'),
- BUILTIN(cmdothernpc, "ss"_s, '\0'),
BUILTIN(mobcount, "ME"_s, 'i'),
BUILTIN(marriage, "P"_s, 'i'),
BUILTIN(divorce, ""_s, 'i'),
BUILTIN(getitemname, "I"_s, 's'),
+ BUILTIN(getitemlink, "I"_s, 's'),
BUILTIN(getspellinvocation, "s"_s, 's'),
BUILTIN(getpartnerid2, ""_s, 'i'),
BUILTIN(getinventorylist, ""_s, '\0'),
@@ -3094,6 +3212,9 @@ BuiltinFunction builtin_functions[] =
BUILTIN(fakenpcname, "ssi"_s, '\0'),
BUILTIN(getx, ""_s, 'i'),
BUILTIN(gety, ""_s, 'i'),
+ BUILTIN(getnpcx, "?"_s, 'i'),
+ BUILTIN(getnpcy, "?"_s, 'i'),
+ BUILTIN(strnpcinfo, "i?"_s, 's'),
BUILTIN(getmap, ""_s, 's'),
BUILTIN(mapexit, ""_s, '\0'),
BUILTIN(freeloop, "i"_s, '\0'),