summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--npc/functions/array.txt14
1 files changed, 13 insertions, 1 deletions
diff --git a/npc/functions/array.txt b/npc/functions/array.txt
index 161cedd0b..74a38a466 100644
--- a/npc/functions/array.txt
+++ b/npc/functions/array.txt
@@ -420,16 +420,28 @@ function script array_highest {
.@size = getarraysize(getarg(0));
.@win=0;
.@idx=0;
+ .@dw=false;
freeloop(true);
for (.@i = getarrayindex(getarg(0)); .@i < .@size; ++.@i) {
if (getelementofarray(getarg(0), .@i) > .@win) {
.@win=getelementofarray(getarg(0), .@i);
.@idx=.@i;
+ if (.@dw) {
+ deletearray .@draw;
+ .@dw=false;
+ }
+ } else if (getelementofarray(getarg(0), .@i) == .@win) {
+ array_push(.@draw, .@i);
+ .@dw=true;
}
}
+ // Will we return .@idx or do we need to draw a loot?
freeloop(false);
- return .@idx;
+ if (.@dw)
+ return any_of(.@draw);
+ else
+ return .@idx;
}