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.txt361
1 files changed, 0 insertions, 361 deletions
diff --git a/npc/items/shovel.txt b/npc/items/shovel.txt
deleted file mode 100644
index b4a5a968..00000000
--- a/npc/items/shovel.txt
+++ /dev/null
@@ -1,361 +0,0 @@
-// Evol scripts.
-// Author:
-// Travolta
-// Jesusalva
-// Description:
-// NPC to use shovel (dig, bury etc)
-
-- script Shovel -1,{
-
- function CheckDigLocation {
- getmapxy(.@map$, .@x, .@y, 0);
-
- if (.@map$ != "001-1") {
- if (getunits(BL_NPC, .@units, 1, .@map$, .@x - 1, .@y, .@x + 1, .@y + 1))
- {
- dispbottom(l("You cannot bury under a NPC!"));
- return false;
- }
- }
-
- // TODO: we should have a way to check for GROUNDTOP collisions too
-
- 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 true;
- }
- }
-
- dispbottom(l("You can't use the shovel here."));
- return false;
- }
-
- function AddDigRect {
- if (getargcount() < 5)
- {
- consolemes(CONSOLEMES_ERROR, "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 AddMapDigRect {
- .@m$=getarg(0);
- .@x=getmapinfo(MAPINFO_SIZE_X, .@m$)-20;
- .@y=getmapinfo(MAPINFO_SIZE_Y, .@m$)-20;
- return AddDigRect(.@m$, 20, 20, .@x, .@y);
- }
-
- function PlayerIsTired {
- if (is_evtc())
- return false; // event coordinators are never tired
-
- .@tick = gettimetick(1);
- .@playertick = .PlayerTiredTime - readparam(bStr);
- if (@ShovelLastUsed + max(4, .@playertick) > .@tick)
- {
- narrator S_FIRST_BLANK_LINE,
- l("You are exhausted, you should rest a bit.");
- return true;
- }
- @ShovelLastUsed = .@tick;
- return false;
- }
-
- function Dig {
- getmapxy(.@map$, .@x, .@y, 0);
- for (.@i = 0; .@i < getarraysize($WorldBuriedTreasures_id); .@i++)
- {
- 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;
- narrator S_FIRST_BLANK_LINE,
- l("You found something!"),
- l("It's @@ @@.", .@amount, getitemname(.@id));
- return 1;
- }
- }
- narrator S_FIRST_BLANK_LINE, l("Sadly, you found nothing but dirt.");
- return 0;
- }
-
- function Bury {
- narrator S_FIRST_BLANK_LINE | S_LAST_BLANK_LINE, l("What would you like to bury?");
- .@items$ = "";
-
- mes "##B" + l("Drag and drop an item from your inventory.") + "##b";
-
- .@id = requestitem();
-
- // If ID is invalid, there's not enough items, it is an Iron Shovel, it is bound = Cannot bury
- // NOBODY bypass notrade check. (ITR_NONE is 0)
- if (.@id < 1) close;
- if (.@id < 1 || countitem(.@id) < 1 || .@id == IronShovel || checkbound(.@id) ||
- (!getiteminfo(.@id, ITEMINFO_TRADE))
- ) {
- @ShovelLastUsed = 0;
- if (.@id == IronShovel || .@id == SteelShovel || checkbound(.@id))
- mesc l("You cannot bury this item!");
- else if (!getiteminfo(.@id, ITEMINFO_TRADE))
- mesc l("This item is too precious, you cannot part with it!");
- else
- mesc l("You give up.");
- close;
- return;
- }
-
- .@amount = 1;
- if (countitem(.@id) > 1)
- {
- narrator S_FIRST_BLANK_LINE | S_LAST_BLANK_LINE, l("Amount?");
- input .@amount, 1, countitem(.@id);
- }
-
- getmapxy(.@map$, .@x, .@y, 0);
-
- delitem .@id, .@amount;
- .@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 S_FIRST_BLANK_LINE, l("You buried @@ @@.", .@amount, getitemname(.@id));
-
- return true;
- }
-
- 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())
- end;
-
- narrator S_LAST_BLANK_LINE,
- l("You hold the shovel in your hands."),
- l("What are you going to do?");
-
- .@action = select(
- l("Dig."),
- l("Bury."),
- l("Nothing."));
-
- 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 hide your shovel.");
- break;
- }
- close;
-
-OnHour00:
- if (playerattached())
- @ShovelLastUsed = 0;
- end;
-
-OnInit:
- .PlayerTiredTime = 20;
-
- // Partial maps
- AddDigRect("001-1", 172, 26, 200, 48);
- AddDigRect("001-1", 198, 60, 201, 63);
- AddDigRect("008-1-1", 32, 42, 46, 88);
- AddDigRect("008-1-2", 40, 52, 114, 146);
- AddDigRect("012-1", 44, 21, 139, 47);
-
- // Whole maps
- AddMapDigRect("008-1");
- AddMapDigRect("008-3-5");
- AddMapDigRect("012-3-1");
- end;
-
-}
-
-function script shovel_addquest {
- if (getargcount() < 4)
- {
- consolemes(CONSOLEMES_ERROR, "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)
- {
- consolemes(CONSOLEMES_ERROR, "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;
-}
-
-// [Treasure Map] functions
-
-function script shovel_getcity {
- .@a$=getarg(0);
-
- // else is not required (return prevails)
- if (.@a$ == "001-1")
- return l("Artis East Beach");
- if (.@a$ == "008-1")
- return l("East Woodlands");
- if (.@a$ == "008-1-1")
- return l("West Woodland Beach");
- if (.@a$ == "008-1-2")
- return l("Swamps");
- if (.@a$ == "008-3-5")
- return l("Hurnscald Bandit Cave");
- if (.@a$ == "012-1")
- return l("Candor North");
- if (.@a$ == "012-3-1")
- return l("Candor Main Cave");
-
- return .@a$;
-}
-
-function script shovel_randomtreasure {
- .@id=any(TreasureKey,CoinBag,CoinBag,CoinBag,Coal,
- Diamond,Ruby,Emerald,Sapphire,Topaz,Amethyst,
- CrudeDiamond,CrudeRuby,CrudeEmerald,
- CrudeSapphire,CrudeTopaz,CrudeAmethyst,
- MaggotSlimePotion, LargeMana, LargeHealing);
- delitem TreasureMap, 1;
- .@amount=any(1,1,2);
- // Very Commons
- if (.@id == CoinBag || .@id == MaggotSlimePotion || .@id == TreasureKey)
- .@amount+=any(0,1,0,1,2);
- // Super commons
- if (.@id == LargeMana || .@id == LargeHealing)
- .@amount+=rand2(0,8);
- // Rares
- if (.@id == Coal)
- .@amount=1;
- getitem .@id, .@amount;
- ShovelQuests_AssignedMAP$="";
- ShovelQuests_AssignedX=0;
- ShovelQuests_AssignedY=0;
-
- mesn strcharinfo(0);
- mesc l("You found something!");
- mesc l("It's %d %s.", .@amount, getitemlink(.@id));
- next;
- closeclientdialog;
- return;
-}
-
-function script shovel_genrandtreasure {
- .@m$=any("008-1", "008-1-1", "008-1-2", "008-3-5",
- "012-1", "012-3-1");
-
- // Prepare good defaults
- .@x1=.@y1=20;
- .@x2=getmapinfo(MAPINFO_SIZE_X, .@m$)-20;
- .@y2=getmapinfo(MAPINFO_SIZE_Y, .@m$)-20;
-
- // Default overrides
- if (.@m$ == "008-1-1") {
- // West Woodland Beach
- .@x1=32; .@y1=42;
- .@x2=46; .@y2=88;
- } else if (.@m$ == "008-1-2") {
- // Swamps
- .@x1=40; .@y1=52;
- .@x2=114; .@y2=146;
- } else if (.@m$ == "012-1") {
- // Candor North
- .@x1=44; .@y1=139;
- .@x2=21; .@y2=47;
- }
-
- // Dangerous, but I never had issues with this
- do {
- .@x=rand2(.@x1, .@x2);
- .@y=rand2(.@y1, .@y2);
- } while (!checkcell(.@m$, .@x, .@y, cell_chkpass));
-
- // Success
- if (checkcell(.@m$, .@x, .@y, cell_chkpass)) {
- shovel_addquest(.@m$, .@x, .@y, "shovel_randomtreasure");
- ShovelQuests_AssignedMAP$=shovel_getcity(.@m$);
- ShovelQuests_AssignedX=.@x;
- ShovelQuests_AssignedY=.@y;
- }
- return;
-}
-
-