summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2018-07-01 00:18:41 -0300
committerJesusaves <cpntb1@ymail.com>2018-07-01 00:18:41 -0300
commitbe188ef5c1e3ea995e2248901e2613ec35ec5817 (patch)
treeacd8511e1198347ddc3bb038c7246c30185d7e04 /npc
parent0f8c0a64e2f13e480708dc0079f247475f7edd61 (diff)
downloadserverdata-be188ef5c1e3ea995e2248901e2613ec35ec5817.tar.gz
serverdata-be188ef5c1e3ea995e2248901e2613ec35ec5817.tar.bz2
serverdata-be188ef5c1e3ea995e2248901e2613ec35ec5817.tar.xz
serverdata-be188ef5c1e3ea995e2248901e2613ec35ec5817.zip
Finish Shovel script and helpers. You can now use [Iron Shovel] @Saulc
Only on mines, and there is RANDOM TREASURE waiting to be found :o
Diffstat (limited to 'npc')
-rw-r--r--npc/items/shovel.txt94
1 files changed, 89 insertions, 5 deletions
diff --git a/npc/items/shovel.txt b/npc/items/shovel.txt
index fd74ed262..bbefc3274 100644
--- a/npc/items/shovel.txt
+++ b/npc/items/shovel.txt
@@ -58,6 +58,7 @@
}
function Dig {
+ // First check: Did some player burried a TREASURE? O.o
getmapxy(.@map$, .@x, .@y, 0);
for (.@i = 0; .@i < getarraysize($WorldBuriedTreasures_id); .@i++)
{
@@ -67,6 +68,9 @@
{
.@id = $WorldBuriedTreasures_id[.@i];
.@amount = $WorldBuriedTreasures_amount[.@i];
+
+ inventoryplace .@id, .@amount;
+
deletearray $WorldBuriedTreasures_id[.@i], 1;
deletearray $WorldBuriedTreasures_amount[.@i], 1;
deletearray $WorldBuriedTreasures_map$[.@i], 1;
@@ -79,6 +83,30 @@
return 1;
}
}
+ // Second check: Perhaps here is a rare, random ore?
+ for (.@i = 0; .@i < getarraysize($@WBT_Random_id); .@i++)
+ {
+ if (!strcmp($@WBT_Random_map$[.@i], .@map$) &&
+ $@WBT_Random_x[.@i] == .@x &&
+ $@WBT_Random_y[.@i] == .@y)
+ {
+ .@id = $@WBT_Random_id[.@i];
+ .@amount = $@WBT_Random_amount[.@i];
+
+ inventoryplace .@id, .@amount;
+
+ deletearray $@WBT_Random_id[.@i], 1;
+ deletearray $@WBT_Random_amount[.@i], 1;
+ deletearray $@WBT_Random_map$[.@i], 1;
+ deletearray $@WBT_Random_x[.@i], 1;
+ deletearray $@WBT_Random_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;
}
@@ -169,22 +197,45 @@ OnUse:
Bury();
break;
case 3:
- narrator S_FIRST_BLANK_LINE, l("You hide your shovel.");
+ narrator S_FIRST_BLANK_LINE, l("You withdraw your shovel.");
break;
}
close;
-OnHour00:
- if (playerattached())
- @ShovelLastUsed = 0;
- end;
OnInit:
+ // Define constants
.PlayerTiredTime = 25;
+
// You can bury & dig on all mines
AddDigRect("007-1", 20, 20, 180, 180);
AddDigRect("011-1", 20, 20, 180, 180);
AddDigRect("015-1", 20, 20, 180, 180);
+
+OnHour00:
+ // Clear random treasure
+ deletearray $@WBT_Random_id;
+ deletearray $@WBT_Random_amount;
+ deletearray $@WBT_Random_map$;
+ deletearray $@WBT_Random_x/
+ deletearray $@WBT_Random_y;
+
+ // Current treasures list
+ // Food, misc, ores, gems, "rares"
+ setarray .@Treasure,Bread,Candy,BugLeg,Cheese,Acorn,
+ ScorpionStinger,CoinBag,RustyKnife,TreasureKey,CasinoCoins,SulfurPowder,
+ Coal,IronOre,CopperOre,LeadOre,TinOre,SilverOre,GoldOre,PlatinumOre,IridiumOre,TitaniumOre,
+ Diamond,Ruby,Emerald,Sapphire,Topaz,Amethyst,
+ BoneArrow;
+
+ // Scatter Treasure.
+ // There are 25600 possible cells, and over half of them are collisions.
+ // As we don't prevent treasure from falling on collision, it is pretty high.
+ // If two treasures fall on same place, the previous treasure will be deleted.
+ // Theoretical chance of treasure is 0.12% to 0.70%
+ shovel_scatter("007-1", 20, 20, 180, 180, .@Treasure, rand(30,180));
+ shovel_scatter("011-1", 20, 20, 180, 180, .@Treasure, rand(30,180));
+ shovel_scatter("015-1", 20, 20, 180, 180, .@Treasure, rand(30,180));
end;
}
@@ -226,3 +277,36 @@ function script shovel_adddigrect {
set getvariableofnpc(.WorldDigRect_y2[.@size], strnpcinfo(3)), .@y2;
return 1;
}
+
+// shovel_scriptItem( map, x, y, item, {amount} )
+function script shovel_scriptItem {
+ .@map$=getarg(0);
+ .@x=getarg(1);
+ .@y=getarg(2);
+ .@id=getarg(3);
+ .@amount=getarg(4,1);
+
+ .@wtc = getarraysize($@WBT_Random_id);
+ $@WBT_Random_id[.@wtc] = .@id;
+ $@WBT_Random_amount[.@wtc] = .@amount;
+ $@WBT_Random_map$[.@wtc] = .@map$;
+ $@WBT_Random_x[.@wtc] = .@x;
+ $@WBT_Random_y[.@wtc] = .@y;
+ debugmes "Buried"+.@amount+" "+getitemname(.@id);
+}
+
+// shovel_scatter( map, x1, y1, x2, y2, items_array, {amount} )
+function script shovel_scatter {
+ .@map$=getarg(0);
+ .@x1=getarg(1);
+ .@y1=getarg(2);
+ .@x2=getarg(3);
+ .@y2=getarg(4);
+ .@id=getarg(5);
+ .@amount=getarg(6,1);
+
+ for (.@i = 0; .@i < .@amount; .@i++)
+ shovel_scriptItem(.@map$, rand(.@x1,.@x2), rand(.@y1,.@y2), any_of(.@id));
+
+}
+