summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2018-07-02 12:30:05 -0300
committerJesusaves <cpntb1@ymail.com>2018-07-02 12:30:05 -0300
commit25c9d8e106868499bc487aa5df7e074d5555f183 (patch)
tree9d35ab3fade4c4a71d802928632a901474ae6053
parent435ace0cb46b9e636c423d3eaf07d9ebf419a7f8 (diff)
downloadserverdata-jesusalva/shovel.tar.gz
serverdata-jesusalva/shovel.tar.bz2
serverdata-jesusalva/shovel.tar.xz
serverdata-jesusalva/shovel.zip
Update shovel code.jesusalva/shovel
It will use drag'n'drop feature. It'll also have protection so you don't bury items too difficult to obtain, items which are bound, and your own shovel (ofc). PS. Legacy code was NOT updated to meet with @gumi standards, only new one. The code was tested.
-rw-r--r--npc/items/shovel.txt28
1 files changed, 20 insertions, 8 deletions
diff --git a/npc/items/shovel.txt b/npc/items/shovel.txt
index f01a0fcb..c6bc8224 100644
--- a/npc/items/shovel.txt
+++ b/npc/items/shovel.txt
@@ -1,5 +1,6 @@
// Evol scripts.
// Author:
+// Jesusalva
// Travolta
// Description:
// NPC to use shovel (dig, bury etc)
@@ -84,19 +85,30 @@
function Bury {
narrator S_FIRST_BLANK_LINE | S_LAST_BLANK_LINE, l("What would you like to bury?");
.@items$ = "";
- getinventorylist;
- for (.@i = 0; .@i < @inventorylist_count; .@i++)
+
+ mes("##B" + l("Drag and drop an item from your inventory.") + "##b");
+
+ .@id = requestitem();
+
+ // You cannot bury: Items you don't have, your shovel, Bound Items, and items which are not dropped by any mobs.
+ // The "item not dropped by any mob" is temporary, and should be replaced by "items with trade restrictions" later.
+ if (.@id < 1 || countitem(.@id) < 1 || .@id == IronShovel || checkbound(.@id) || !getiteminfo(.@id, ITEMINFO_MAXCHANCE))
{
- .@items$ = .@items$ + getitemname(@inventorylist_id[.@i]) + ":";
- debugmes getitemname(@inventorylist_id[.@i]);
+ @ShovelLastUsed = 0;
+ if (.@id == IronShovel || checkbound(.@id))
+ mes(col(l("You cannot bury this item!")));
+ else if (!getiteminfo(.@id, ITEMINFO_MAXCHANCE))
+ mes(col(l("This item is too precious, you cannot part with it!")));
+ else
+ mes(col(l("You give up.")));
+ return;
}
- .@idx = select(.@items$) - 1;
- .@id = @inventorylist_id[.@idx];
+
.@amount = 1;
- if (@inventorylist_amount[.@idx] > 1)
+ if (countitem(.@id) > 1)
{
narrator S_FIRST_BLANK_LINE | S_LAST_BLANK_LINE, l("Amount?");
- input .@amount, 1, @inventorylist_amount[.@idx];
+ input .@amount, 1, countitem(.@id);
}
getmapxy(.@map$, .@x, .@y, 0);