diff options
-rw-r--r-- | npc/items/shovel.txt | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/npc/items/shovel.txt b/npc/items/shovel.txt index 2fced1af..7580f217 100644 --- a/npc/items/shovel.txt +++ b/npc/items/shovel.txt @@ -59,13 +59,15 @@ getmapxy(.@map$, .@x, .@y, 0); for (.@i = 0; .@i < getarraysize($WorldBuriedTreasures_id); .@i++) { - if ($WorldBuriedTreasures_x[.@i] == .@x && + if (!strcmp($WorldBuriedTreasures_map$[.@i], .@map$) && + $WorldBuriedTreasures_x[.@i] == .@x && $WorldBuriedTreasures_y[.@i] == .@y) { .@id = $WorldBuriedTreasures_id[.@i]; .@amount = $WorldBuriedTreasures_amount[.@i]; deletearray $WorldBuriedTreasures_id[.@i], 1; deletearray $WorldBuriedTreasures_amount[.@i], 1; + deletearray $WorldBuriedTreasures_map$[.@i], 1; deletearray $WorldBuriedTreasures_x[.@i], 1; deletearray $WorldBuriedTreasures_y[.@i], 1; getitem .@id, .@amount; @@ -102,6 +104,7 @@ .@wtc = getarraysize($WorldBuriedTreasures_id); $WorldBuriedTreasures_id[.@wtc] = .@id; $WorldBuriedTreasures_amount[.@wtc] = .@amount; + $WorldBuriedTreasures_map$[.@wtc] = .@map$; $WorldBuriedTreasures_x[.@wtc] = .@x; $WorldBuriedTreasures_y[.@wtc] = .@y; narrator l("You buried @@ @@.", .@amount, getitemname(.@id)); @@ -109,6 +112,26 @@ return 0; } + function ShovelQuests { + getmapxy(.@map$, .@x, .@y, 0); + for (.@i = 0; .@i < getarraysize(ShovelQuests_func$); .@i++) + { + if (!strcmp(ShovelQuests_map$[.@i], .@map$) && + ShovelQuests_x[.@i] == .@x && + ShovelQuests_y[.@i] == .@y) + { + .@func$ = ShovelQuests_func$[.@i]; + deletearray ShovelQuests_func$[.@i], 1; + deletearray ShovelQuests_map$[.@i], 1; + deletearray ShovelQuests_x[.@i], 1; + deletearray ShovelQuests_y[.@i], 1; + callfunc(.@func$); + return 1; + } + } + return 0; + } + OnUse: if (!CheckDigLocation()) { @@ -131,7 +154,8 @@ OnUse: case 1: if (PlayerIsTired()) close; - Dig(); + if (!ShovelQuests()) + Dig(); break; case 2: if (PlayerIsTired()) @@ -155,3 +179,43 @@ OnInit: end; } + + +function script shovel_addquest { + if (getargcount() < 4) + { + debugmes "usage: shovel_addquest(map$,x,y,func$)"; + return 0; + } + .@map$ = str(getarg(0)); + .@x = getarg(1); + .@y = getarg(2); + .@func$ = str(getarg(3)); + .@size = getarraysize(ShovelQuests_func$); + ShovelQuests_func$[.@size] = .@func$; + ShovelQuests_map$[.@size] = .@map$; + ShovelQuests_x[.@size] = .@x; + ShovelQuests_y[.@size] = .@y; + return 1; +} + + +function script shovel_adddigrect { + if (getargcount() < 5) + { + debugmes "usage: shovel_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(getvariableofnpc(.WorldDigRect_Map$, strnpcinfo(3))); + set getvariableofnpc(.WorldDigRect_Map$[.@size], strnpcinfo(3)), .@map$; + set getvariableofnpc(.WorldDigRect_x1[.@size], strnpcinfo(3)), .@x1; + set getvariableofnpc(.WorldDigRect_y1[.@size], strnpcinfo(3)), .@y1; + set getvariableofnpc(.WorldDigRect_x2[.@size], strnpcinfo(3)), .@x2; + set getvariableofnpc(.WorldDigRect_y2[.@size], strnpcinfo(3)), .@y2; + return 1; +} |