summaryrefslogtreecommitdiff
path: root/npc/items
diff options
context:
space:
mode:
Diffstat (limited to 'npc/items')
-rw-r--r--npc/items/shovel.txt29
1 files changed, 21 insertions, 8 deletions
diff --git a/npc/items/shovel.txt b/npc/items/shovel.txt
index c116c83f8..3c6e23b88 100644
--- a/npc/items/shovel.txt
+++ b/npc/items/shovel.txt
@@ -40,14 +40,27 @@ function script shovel_scatter {
.@x2=getarg(3);
.@y2=getarg(4);
.@amount=getarg(5,1);
-
- freeloop(true); // DANGEROUS
- for (.@i = 0; .@i < .@amount; .@i++)
- shovel_scriptItem(.@map$, rand(.@x1,.@x2), rand(.@y1,.@y2), getarg(rand(getargcount()-6)+6));
- freeloop(false);
-
- .@wtc = getarraysize($@WBT_Random_id);
- debugmes "Scattered "+.@amount+" items on "+.@map$+". Currently scattered: "+.@wtc;
+ .@dbgamm=.@amount; // debug message
+
+ .@wta = getarraysize($@WBT_Random_id); // wta - original
+ .@wtb = .@wta+.@amount; // wtb - future
+ .@tries=3;
+ do {
+ freeloop(true); // DANGEROUS
+ for (.@i = 0; .@i < .@amount; .@i++)
+ shovel_scriptItem(.@map$, rand(.@x1,.@x2), rand(.@y1,.@y2), getarg(rand(getargcount()-6)+6));
+ freeloop(false);
+
+ .@wtc = getarraysize($@WBT_Random_id); // wtc - current
+ .@amount=.@wtb-.@wtc;
+
+ //debugmes "WTA %d WTB %d. WTC %d, tries %d, amount %d and dbg %d", .@wta, .@wtb, .@wtc, .@tries, .@amount, .@dbgamm;
+ if (.@wtc >= .@wtb)
+ .@tries=0;
+ else
+ .@tries-=1;
+ } while (.@tries > 0);
+ debugmes "Scattered "+.@dbgamm+" items on "+.@map$+". Currently scattered: "+.@wtc;
return;
}