From 8e60c58eddaaf08cdbe13eb075bbadfc422bb4e4 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 3 Mar 2019 11:20:27 -0300 Subject: This is Saulc patch, but done properly ^.^ (Actually no, but I like high talking distances >.>) --- npc/functions/main.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'npc/functions') diff --git a/npc/functions/main.txt b/npc/functions/main.txt index 4a6f89d80..f491c24fe 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -279,6 +279,26 @@ function script getmap { return .@mapName$; } +// isin( map, x1, y1, {[x2, y2][radius]} ) +function script isin { + if (getmapxy(.@mapName$, .@xpos, .@ypos, 0) != 0) + return false; + if (.@mapName$ != getarg(0)) + return false; + + if (getarg(4,-1) < 0) { + // Radius Based + if (.@xpos >= getarg(1)-getarg(3) && .@xpos <= getarg(1)+getarg(3) && .@ypos >= getarg(2)-getarg(3) && .@ypos <= getarg(2)+getarg(3)) + return true; + } else { + // Coordinate based + if (.@xpos >= getarg(1) && .@xpos <= getarg(3) && .@ypos >= getarg(2) && .@ypos <= getarg(4)) + return true; + } + return false; +} + +// isinrad( map, x1, y1, radius) function script isin { if (getmapxy(.@mapName$, .@xpos, .@ypos, 0) != 0) return false; -- cgit v1.2.3-60-g2f50