From 4cb881c88f5e1879e89ab2c830a622a2edfb0f82 Mon Sep 17 00:00:00 2001 From: mekolat Date: Thu, 10 Sep 2015 22:30:23 -0400 Subject: do not bind trigger detection to map cells --- src/map/map.t.hpp | 2 -- src/map/npc-parse.cpp | 30 ------------------------------ src/map/npc.cpp | 4 ++-- src/map/pc.cpp | 8 ++------ src/map/script-fun.cpp | 7 ++++++- 5 files changed, 10 insertions(+), 41 deletions(-) diff --git a/src/map/map.t.hpp b/src/map/map.t.hpp index 89b9a87..ea7ead5 100644 --- a/src/map/map.t.hpp +++ b/src/map/map.t.hpp @@ -185,8 +185,6 @@ enum class MapCell : uint8_t UNWALKABLE = 0x01, // not in tmwa data _range = 0x04, - // set in code, not imported - NPC_NEAR = 0x80, }; ENUM_BITWISE_OPERATORS(MapCell) } diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp index edfe4c9..e30225a 100644 --- a/src/map/npc-parse.cpp +++ b/src/map/npc-parse.cpp @@ -166,21 +166,6 @@ bool npc_load_warp(ast::npc::Warp& warp) nd->warp.xs = xs; nd->warp.ys = ys; - for (int i = 0; i < ys; i++) - { - for (int j = 0; j < xs; j++) - { - int x_lo = x - xs / 2; - int y_lo = y - ys / 2; - int xc = x_lo + j; - int yc = y_lo + i; - MapCell t = map_getcell(m, xc, yc); - if (bool(t & MapCell::UNWALKABLE)) - continue; - map_setcell(m, xc, yc, t | MapCell::NPC_NEAR); - } - } - npc_warp++; nd->bl_type = BL::NPC; nd->npc_subtype = NpcSubtype::WARP; @@ -554,21 +539,6 @@ bool npc_load_script_map(ast::script::ScriptBody& body, ast::npc::ScriptMap& scr int xs = script_map.xs.data, ys = script_map.ys.data; { - for (int i = 0; i < ys; i++) - { - for (int j = 0; j < xs; j++) - { - int x_lo = x - xs / 2; - int y_lo = y - ys / 2; - int xc = x_lo + j; - int yc = y_lo + i; - MapCell t = map_getcell(m, xc, yc); - if (bool(t & MapCell::UNWALKABLE)) - continue; - map_setcell(m, xc, yc, t | MapCell::NPC_NEAR); - } - } - nd->scr.xs = xs; nd->scr.ys = ys; nd->scr.event_needs_map = true; diff --git a/src/map/npc.cpp b/src/map/npc.cpp index c55dbbf..b7fb9ca 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -713,12 +713,12 @@ int npc_touch_areanpc(dumb_ptr sd, Borrowed m, int aname.label = stringish("OnTouch"_s); if (sd->areanpc_id == m->npc[i]->bl_id) - return 1; + return 2; sd->areanpc_id = m->npc[i]->bl_id; if (npc_event(sd, aname, 0) > 0) npc_click(sd, m->npc[i]->bl_id); - break; + return 2; } } return 0; diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 7940812..1440454 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -2457,9 +2457,7 @@ void pc_walk(TimerData *, tick_t tick, BlockId id, unsigned char data) } } - if (bool(map_getcell(sd->bl_m, x, y) & MapCell::NPC_NEAR)) - npc_touch_areanpc(sd, sd->bl_m, x, y); - else + if (npc_touch_areanpc(sd, sd->bl_m, x, y) != 2) sd->areanpc_id = BlockId(); } interval_t i = calc_next_walk_step(sd); @@ -2563,9 +2561,7 @@ int pc_stop_walking(dumb_ptr sd, int type) void pc_touch_all_relevant_npcs(dumb_ptr sd) { - if (bool(map_getcell(sd->bl_m, sd->bl_x, sd->bl_y) & MapCell::NPC_NEAR)) - npc_touch_areanpc(sd, sd->bl_m, sd->bl_x, sd->bl_y); - else + if (npc_touch_areanpc(sd, sd->bl_m, sd->bl_x, sd->bl_y) != 2) sd->areanpc_id = BlockId(); } diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 7e55565..f8c81c4 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -894,6 +894,11 @@ void builtin_puppet(ScriptState *st) nd->bl_m = m; nd->bl_x = x; nd->bl_y = y; + if (HARG(5) && HARG(6)) + { + nd->scr.xs = ((conv_num(st, &AARG(5)) * 2) + 1); // do the same equation as in AST + nd->scr.ys = ((conv_num(st, &AARG(6)) * 2) + 1); + } nd->bl_id = npc_get_new_npc_id(); nd->scr.parent = parent_nd->bl_id; nd->dir = DIR::S; @@ -4312,7 +4317,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(isdead, ""_s, 'i'), BUILTIN(aggravate, "Mxyxyi"_s, '\0'), BUILTIN(fakenpcname, "ssi"_s, '\0'), - BUILTIN(puppet, "mxysi"_s, 'i'), + BUILTIN(puppet, "mxysi??"_s, 'i'), BUILTIN(destroy, "?"_s, '\0'), BUILTIN(getx, ""_s, 'i'), BUILTIN(gety, ""_s, 'i'), -- cgit v1.2.3-70-g09d2