summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/chrif.cpp5
-rw-r--r--src/map/clif.cpp33
-rw-r--r--src/map/npc-parse.cpp122
-rw-r--r--src/map/npc.cpp2
-rw-r--r--src/map/pc.cpp29
-rw-r--r--src/map/pc.hpp1
-rw-r--r--src/map/script-fun.cpp27
7 files changed, 39 insertions, 180 deletions
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 37efc4e..2606911 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -249,11 +249,6 @@ int chrif_connectack(Session *s, const Packet_Fixed<0x2af9>& fixed)
chrif_sendmap(s);
- PRINTF("chrif: OnCharIfInit event done. (%d events)\n"_fmt,
- npc_event_doall(stringish<ScriptLabel>("OnCharIfInit"_s)));
- PRINTF("chrif: OnInterIfInit event done. (%d events)\n"_fmt,
- npc_event_doall(stringish<ScriptLabel>("OnInterIfInit"_s)));
-
return 0;
}
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index e3cd55f..d327286 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -807,6 +807,8 @@ void clif_mob007b(dumb_ptr<mob_data> md, Buffer& buf)
fixed_7b.mob_class = md->mob_class;
// snip: stuff for monsters disguised as PCs
fixed_7b.tick_and_maybe_part_of_guild_emblem = gettick();
+ fixed_7b.max_hp = md->stats[mob_stat::MAX_HP];
+ fixed_7b.hp = md->hp;
fixed_7b.pos2.x0 = md->bl_x;
fixed_7b.pos2.y0 = md->bl_y;
@@ -819,7 +821,33 @@ void clif_mob007b(dumb_ptr<mob_data> md, Buffer& buf)
buf = create_fpacket<0x007b, 60>(fixed_7b);
}
+/*==========================================
+ * Packet to send server's mob walkpath data
+ *------------------------------------------
+ */
+static
+int clif_0225_being_move3(dumb_ptr<mob_data> md)
+{
+ Packet_Head<0x0225> head_225;
+ std::vector<Packet_Repeat<0x0225>> repeat_225;
+
+ head_225.magic_packet_length = md->walkpath.path_len + 14;
+ head_225.id = md->bl_id;
+ head_225.speed = battle_get_speed(md);
+ head_225.x_position = md->bl_x;
+ head_225.y_position = md->bl_y;
+ for (int i = 0; i < md->walkpath.path_len; i++)
+ {
+ Packet_Repeat<0x0225> move_225;
+ move_225.move = md->walkpath.path[i];
+ repeat_225.push_back(move_225);
+ }
+
+ Buffer buf = create_vpacket<0x0225, 14, 1>(head_225, repeat_225);
+ clif_send(buf, md, SendWho::AREA);
+ return 0;
+}
/*==========================================
*
*------------------------------------------
@@ -901,7 +929,7 @@ int clif_spawnnpc(dumb_ptr<npc_data> nd)
{
nullpo_retz(nd);
- if (nd->npc_class == NEGATIVE_SPECIES || nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS)
+ if (nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS)
return 0;
Packet_Fixed<0x007c> fixed_7c;
@@ -2320,7 +2348,7 @@ void clif_getareachar_npc(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd)
nullpo_retv(sd);
nullpo_retv(nd);
- if (nd->npc_class == NEGATIVE_SPECIES || nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS)
+ if (nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS)
return;
Buffer buf;
@@ -2339,6 +2367,7 @@ int clif_movemob(dumb_ptr<mob_data> md)
Buffer buf;
clif_mob007b(md, buf);
clif_send(buf, md, SendWho::AREA);
+ clif_0225_being_move3(md);
return 0;
}
diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp
index 9c9a22c..4d9fcbd 100644
--- a/src/map/npc-parse.cpp
+++ b/src/map/npc-parse.cpp
@@ -446,7 +446,7 @@ bool npc_load_script_none(ast::script::ScriptBody& body, ast::npc::ScriptNone& s
nd->bl_id = npc_get_new_npc_id();
nd->dir = DIR::S;
nd->flag = 0;
- nd->npc_class = NEGATIVE_SPECIES;
+ nd->npc_class = INVISIBLE_CLASS;
nd->speed = 200_ms;
nd->scr.script = std::move(script);
nd->option = Opt0::ZERO;
@@ -514,115 +514,6 @@ bool npc_load_script_none(ast::script::ScriptBody& body, ast::npc::ScriptNone& s
}
static
-bool npc_load_script_map_none(ast::script::ScriptBody& body, ast::npc::ScriptMapNone& script_map_none)
-{
- MapName mapname = script_map_none.m.data;
- int x = script_map_none.x.data, y = script_map_none.y.data;
- DIR dir = script_map_none.d.data;
- P<map_local> m = TRY_UNWRAP(map_mapname2mapid(mapname),
- {
- script_map_none.m.span.error("No such map"_s);
- return false;
- });
-
- std::unique_ptr<const ScriptBuffer> script = compile_script(STRPRINTF("script npc \"%s\""_fmt, script_map_none.name.data), body, false);
- if (script == nullptr)
- return false;
-
- dumb_ptr<npc_data_script> nd;
- nd.new_();
- nd->scr.event_needs_map = false;
-
- nd->name = script_map_none.name.data;
-
- nd->bl_prev = nd->bl_next = nullptr;
- nd->bl_m = m;
- nd->bl_x = x;
- nd->bl_y = y;
- nd->bl_id = npc_get_new_npc_id();
- nd->dir = dir;
- nd->flag = 0;
- nd->npc_class = NEGATIVE_SPECIES;
- nd->speed = 200_ms;
- nd->scr.script = std::move(script);
- nd->option = Opt0::ZERO;
- nd->opt1 = Opt1::ZERO;
- nd->opt2 = Opt2::ZERO;
- nd->opt3 = Opt3::ZERO;
-
- npc_script++;
- nd->bl_type = BL::NPC;
- nd->npc_subtype = NpcSubtype::SCRIPT;
-
- nd->n = map_addnpc(m, nd);
- map_addblock(nd);
-
- {
- struct event_data ev {};
- ev.nd = nd;
- ev.pos = 0;
- NpcEvent npcev;
- npcev.npc = nd->name;
- npcev.label = ScriptLabel();
- ev_db.insert(npcev, ev);
- }
-
- register_npc_name(nd);
-
- for (auto& pair : scriptlabel_db)
- npc_convertlabel_db(pair.first, pair.second, nd);
-
- for (npc_label_list& el : nd->scr.label_listv)
- {
- ScriptLabel lname = el.name;
- int pos = el.pos;
-
- if (lname.startswith("On"_s))
- {
- struct event_data ev {};
- ev.nd = nd;
- ev.pos = pos;
- NpcEvent buf;
- buf.npc = nd->name;
- buf.label = lname;
- ev_db.insert(buf, ev);
- }
- }
-
- for (npc_label_list& el : nd->scr.label_listv)
- {
- int t_ = 0;
- ScriptLabel lname = el.name;
- int pos = el.pos;
- if (lname.startswith("OnTimer"_s) && extract(lname.xslice_t(7), &t_) && t_ > 0)
- {
- interval_t t = static_cast<interval_t>(t_);
-
- npc_timerevent_list tel {};
- tel.timer = t;
- tel.pos = pos;
-
- auto it = std::lower_bound(nd->scr.timer_eventv.begin(), nd->scr.timer_eventv.end(), tel,
- [](const npc_timerevent_list& l, const npc_timerevent_list& r)
- {
- return l.timer < r.timer;
- }
- );
- assert (it == nd->scr.timer_eventv.end() || it->timer != tel.timer);
-
- nd->scr.timer_eventv.insert(it, std::move(tel));
- }
- }
- // The counter starts stopped with 0 ticks, which is the first event,
- // unless there is none, in which case begin == end.
- nd->scr.timer = interval_t::zero();
- nd->scr.next_event = nd->scr.timer_eventv.begin();
- // nd->scr.timerid = nullptr;
-
- return true;
-}
-
-static
bool npc_load_script_map(ast::script::ScriptBody& body, ast::npc::ScriptMap& script_map)
{
MapName mapname = script_map.m.data;
@@ -761,17 +652,6 @@ bool npc_load_script_any(ast::npc::Script *script)
{
return npc_load_script_none(script->body, script_none);
}
- MATCH_CASE (ast::npc::ScriptMapNone&, script_map_none)
- {
- auto& mapname = script_map_none.m;
- Option<P<map_local>> m = map_mapname2mapid(mapname.data);
- if (m.is_none())
- {
- mapname.span.error(STRPRINTF("Map not found: %s"_fmt, mapname.data));
- return false;
- }
- return npc_load_script_map_none(script->body, script_map_none);
- }
MATCH_CASE (ast::npc::ScriptMap&, script_map)
{
auto& mapname = script_map.m;
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index 56c33cc..4296432 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -583,7 +583,7 @@ int npc_checknear(dumb_ptr<map_session_data> sd, BlockId id)
if (nd->bl_type != BL::NPC)
return 1;
- if (nd->npc_class == NEGATIVE_SPECIES)
+ if (nd->npc_class == INVISIBLE_CLASS)
return 0;
// エリア判定
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index e8e526a..6fa35b0 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -2289,35 +2289,6 @@ int pc_setpos(dumb_ptr<map_session_data> sd,
}
/*==========================================
- * PCのランダムワープ
- *------------------------------------------
- */
-int pc_randomwarp(dumb_ptr<map_session_data> sd, BeingRemoveWhy type)
-{
- int x, y, i = 0;
-
- nullpo_retz(sd);
-
- P<map_local> m = sd->bl_m;
-
- if (sd->bl_m->flag.get(MapFlag::NOTELEPORT)) // テレポート禁止
- return 0;
-
- do
- {
- x = random_::in(1, m->xs - 2);
- y = random_::in(1, m->ys - 2);
- }
- while (bool(read_gatp(m, x, y) & MapCell::UNWALKABLE)
- && (i++) < 1000);
-
- if (i < 1000)
- pc_setpos(sd, m->name_, x, y, type);
-
- return 0;
-}
-
-/*==========================================
*
*------------------------------------------
*/
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index 6c0803f..d100938 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -92,7 +92,6 @@ int pc_walktoxy(dumb_ptr<map_session_data>, int, int);
int pc_stop_walking(dumb_ptr<map_session_data>, int);
int pc_setpos(dumb_ptr<map_session_data>, MapName, int, int, BeingRemoveWhy);
void pc_setsavepoint(dumb_ptr<map_session_data>, MapName, int, int);
-int pc_randomwarp(dumb_ptr<map_session_data> sd, BeingRemoveWhy type);
ADDITEM pc_checkadditem(dumb_ptr<map_session_data>, ItemNameId, int);
int pc_inventoryblank(dumb_ptr<map_session_data>);
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 6dc1510..4c20555 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -358,22 +358,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);
}
/*==========================================
@@ -384,10 +372,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
@@ -3132,11 +3117,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'),