diff options
author | Joseph Botosh <rumly111@gmail.com> | 2015-09-24 13:57:57 +0300 |
---|---|---|
committer | Joseph Botosh <rumly111@gmail.com> | 2015-09-24 13:57:57 +0300 |
commit | 03f18337b0733fb964e1d239f0f6a29efd11675b (patch) | |
tree | 3d18b655bf2682641b5cea526104b7483f04a83f | |
parent | 9635df8475f479f416d933edb7d473232d794545 (diff) | |
download | serverdata-03f18337b0733fb964e1d239f0f6a29efd11675b.tar.gz serverdata-03f18337b0733fb964e1d239f0f6a29efd11675b.tar.bz2 serverdata-03f18337b0733fb964e1d239f0f6a29efd11675b.tar.xz serverdata-03f18337b0733fb964e1d239f0f6a29efd11675b.zip |
add constrains to shovel usage (rectangular areas)
-rw-r--r-- | npc/items/shovel.txt | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/npc/items/shovel.txt b/npc/items/shovel.txt index b6302d9f..c4fcd8fa 100644 --- a/npc/items/shovel.txt +++ b/npc/items/shovel.txt @@ -7,6 +7,42 @@ - script Shovel -1,{ + function CheckDigLocation { + getmapxy(.@map$, .@x, .@y, 0); + for (.@i = 0; .@i < getarraysize(.WorldDigRect_Map$); .@i++) + { + if (!strcmp(.WorldDigRect_Map$[.@i], .@map$) && + .WorldDigRect_x1[.@i] <= .@x && + .WorldDigRect_x2[.@i] >= .@x && + .WorldDigRect_y1[.@i] <= .@y && + .WorldDigRect_y2[.@i] >= .@y) + { + return 1; + } + } + return 0; + } + + function AddDigRect { + if (getargcount() < 5) + { + debugmes "usage: AddDigRect(map$,x1,y1,x2,y2)"; + return 0; + } + .@map$ = str(getarg(0)); + .@x1 = getarg(1); + .@y1 = getarg(2); + .@x2 = getarg(3); + .@y2 = getarg(4); + .@size = getarraysize(.WorldDigRect_Map$); + .WorldDigRect_Map$[.@size] = .@map$; + .WorldDigRect_x1[.@size] = .@x1; + .WorldDigRect_y1[.@size] = .@y1; + .WorldDigRect_x2[.@size] = .@x2; + .WorldDigRect_y2[.@size] = .@y2; + return 1; + } + function Dig { getmapxy(.@map$, .@x, .@y, 0); for (.@i = 0; .@i < getarraysize($WorldBuriedTreasures_id); .@i++) @@ -62,6 +98,13 @@ } OnUse: + if (!CheckDigLocation()) + { + narrator 0, + l("You can't use the shovel here."); + close; + } + narrator 0, l("You hold the shovel in your hangs."), l("What are you going to do?"); @@ -85,6 +128,8 @@ OnUse: } close; - +OnInit: + AddDigRect("001-1", 172, 26, 200, 48); + end; } |