summaryrefslogtreecommitdiff
path: root/npc/items/shovel.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/items/shovel.txt')
-rw-r--r--npc/items/shovel.txt176
1 files changed, 80 insertions, 96 deletions
diff --git a/npc/items/shovel.txt b/npc/items/shovel.txt
index b0a45b4f1..f8a110f94 100644
--- a/npc/items/shovel.txt
+++ b/npc/items/shovel.txt
@@ -52,69 +52,12 @@ function script shovel_scatter {
}
+// Here we begin
- script Shovel -1,{
+ function CheckDigLocation;
+ function AddDigRect;
+ function PlayerIsTired;
- 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 PlayerIsTired {
- // GMs can do this in an unrestricted way
- if (is_gm())
- return 0;
-
- .@tick = gettimetick(1);
- .@playertick = .PlayerTiredTime - (readparam(bStr)/5) - (readparam(bVit)/10);
-
- // Dig and Bury more with Steel Shovel
- if (countitem(SteelShovel)) {
- .@playertick-=(.PlayerTiredTime*2)/3;
- }
-
- if (@ShovelLastUsed + max(5, .@playertick) > .@tick) {
- if (!GSET_SHOVEL_AUTODIG) {
- mes "";
- mesc lg("You are exhausted, you should rest a bit.");
- } else {
- dispbottom lg("You are exhausted, you should rest a bit.");
- }
- return 1;
- }
- @ShovelLastUsed = .@tick;
- return 0;
- }
function Dig {
// First check: Did some player burried a TREASURE? O.o
@@ -139,6 +82,8 @@ function script shovel_scatter {
narrator S_FIRST_BLANK_LINE,
l("You found something!"),
l("It's @@ @@.", .@amount, getitemname(.@id));
+ next;
+ closeclientdialog;
return 1;
}
}
@@ -163,10 +108,12 @@ function script shovel_scatter {
narrator S_FIRST_BLANK_LINE,
l("You found something!"),
l("It's @@ @@.", .@amount, getitemname(.@id));
+ next;
+ closeclientdialog;
return 1;
}
}
- narrator S_FIRST_BLANK_LINE, l("Sadly, you found nothing but dirt.");
+ dispbottom l("Sadly, you found nothing but dirt.");
return 0;
}
@@ -191,6 +138,7 @@ function script shovel_scatter {
mesc l("This item is too precious, you cannot part with it!");
else
mesc l("You give up.");
+ close;
return;
}
@@ -199,8 +147,10 @@ function script shovel_scatter {
narrator S_FIRST_BLANK_LINE | S_LAST_BLANK_LINE, l("Amount?");
input .@amount, 0, countitem(.@id);
}
- if (.@amount == 0 || .@amount > countitem(.@id))
+ if (.@amount == 0 || .@amount > countitem(.@id)) {
+ close;
return;
+ }
getmapxy(.@map$, .@x, .@y, 0);
delitem .@id, .@amount;
@@ -211,7 +161,7 @@ function script shovel_scatter {
$WorldBuriedTreasures_x[.@wtc] = .@x;
$WorldBuriedTreasures_y[.@wtc] = .@y;
narrator S_FIRST_BLANK_LINE, l("You buried @@ @@.", .@amount, getitemname(.@id));
-
+ close;
return 0;
}
@@ -235,48 +185,82 @@ function script shovel_scatter {
return 0;
}
-OnUse:
+OnDig:
if (!CheckDigLocation()) {
- message strcharinfo(0), l("I can't use the shovel here.");
- close;
+ dispbottom l("I can't use the shovel here.");
+ end;
}
+ if (PlayerIsTired())
+ end;
+ if (!ShovelQuests())
+ Dig();
+ end;
- // SHOVEL_AUTODIG - Skip menu and outright try to dig
- if (GSET_SHOVEL_AUTODIG) {
- if (PlayerIsTired())
- end;
- if (!ShovelQuests())
- Dig();
+OnBury:
+ if (!CheckDigLocation()) {
+ dispbottom l("I can't use the shovel here.");
end;
}
+ if (PlayerIsTired())
+ end;
+ Bury();
+ end;
- narrator S_LAST_BLANK_LINE,
- l("You hold the shovel in your hands. What are you going to do?");
+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;
+}
- .@action = select(
- l("Dig."),
- l("Bury."),
- l("Nothing."));
+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;
+}
- switch(.@action)
- {
- case 1:
- if (PlayerIsTired())
- close;
- if (!ShovelQuests())
- Dig();
- break;
- case 2:
- if (PlayerIsTired())
- close;
- Bury();
- break;
- case 3:
- narrator S_FIRST_BLANK_LINE, l("You withdraw your shovel.");
- break;
+function PlayerIsTired {
+ // GMs can do this in an unrestricted way
+ if (is_gm())
+ return 0;
+
+ .@tick = gettimetick(1);
+ .@playertick = .PlayerTiredTime - (readparam(bStr)/5) - (readparam(bVit)/10);
+
+ // Dig and Bury more with Steel Shovel
+ if (countitem(SteelShovel)) {
+ .@playertick-=(.PlayerTiredTime*2)/3;
}
- close;
+ if (@ShovelLastUsed + max(5, .@playertick) > .@tick) {
+ dispbottom lg("You are exhausted, you should rest a bit.");
+ return 1;
+ }
+ @ShovelLastUsed = .@tick;
+ return 0;
+}
OnInit:
// Define constants