From 27fe76b6a48cf51aa87346094845fb0ed6333304 Mon Sep 17 00:00:00 2001 From: mekolat Date: Tue, 21 Apr 2015 00:30:19 -0400 Subject: make PCtoNPCRange smarter --- world/map/npc/functions/default_npc_checks.txt | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'world/map/npc/functions') diff --git a/world/map/npc/functions/default_npc_checks.txt b/world/map/npc/functions/default_npc_checks.txt index deb3ba64..d20ed187 100644 --- a/world/map/npc/functions/default_npc_checks.txt +++ b/world/map/npc/functions/default_npc_checks.txt @@ -1,13 +1,16 @@ // Default NPC Checks -// Author: Wushin +// Author: Wushin, mekolat // Range -// Map, X, Y, Distance in Tiles -// setarray @npc_loc, 24, 113, 4; +// Distance in Tiles +// set @npc_distance, 4; function|script|PCtoNPCRange { set @npc_check, 0; - set @Nmap$, getmap() + ""; + set @Nmap$, strnpcinfo(3); + if(!@npc_distance) set @npc_distance, 4; // <== default distance + cleararray @npc_loc, 0, 3; + setarray @npc_loc, getnpcx(), getnpcy(), @npc_distance; set @Nx1, (@npc_loc[0] - @npc_loc[2]); set @Ny1, (@npc_loc[1] - @npc_loc[2]); set @Nx2, (@npc_loc[0] + @npc_loc[2]); @@ -15,9 +18,22 @@ function|script|PCtoNPCRange if (isin(@Nmap$, @Nx1, @Ny1, @Nx2, @Ny2)) goto L_Return; set @npc_check, 1; + if(@distance_handler) goto L_Return; + set @dnpc_name$, strnpcinfo(1); + if(@dnpc_name$ != "") goto L_Named; + mes "You need to move closer to interact with this npc."; + close2; goto L_Return; +L_Named: + message strcharinfo(0), "##3"+@dnpc_name$+" : ##BPlease move closer."; + end; + L_Return: + set @dnpc_name$, ""; + set @distance_handler, 0; + set @npc_distance, 0; + cleararray @npc_loc, 0, 3; return; } -- cgit v1.2.3-60-g2f50