summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-07-29 20:06:41 -0300
committerJesusaves <cpntb1@ymail.com>2019-07-29 20:06:41 -0300
commit2347ce5b6c84a62be386643aa9b4773a1c3bb9d0 (patch)
tree8e2a8b2b0517f266c7be7d37268561a1e4d5d265
parentce7cbf358967493350caccc61124395f44ad040e (diff)
downloadserverdata-2347ce5b6c84a62be386643aa9b4773a1c3bb9d0.tar.gz
serverdata-2347ce5b6c84a62be386643aa9b4773a1c3bb9d0.tar.bz2
serverdata-2347ce5b6c84a62be386643aa9b4773a1c3bb9d0.tar.xz
serverdata-2347ce5b6c84a62be386643aa9b4773a1c3bb9d0.zip
New logic for siege difficulty calculator - it now use flags.
Previous implementation was bad.
-rw-r--r--npc/functions/siege.txt29
1 files changed, 20 insertions, 9 deletions
diff --git a/npc/functions/siege.txt b/npc/functions/siege.txt
index 95d16ebc2..baca59a63 100644
--- a/npc/functions/siege.txt
+++ b/npc/functions/siege.txt
@@ -18,22 +18,31 @@ function script siege_spawn {
}
// Calculate player average level
-// if highest is set, it will return highest player level, with minimum the value
-// passed. (A level "0" is clearly not valid, of course)
-// siege_calcdiff ( map{, highest_lvl} )
+// flag 1 - Don't count dead players
+// flag 2 - Return highest player level, instead of average.
+// flag 4 - Return the total sum of levels instead.
+// siege_calcdiff ( map{, flags} )
function script siege_calcdiff {
.@bsum=0;
- .@highest=getarg(1, false);
+ if (getarg(1,0) & 1)
+ .@deadcount=true;
+ if (getarg(1,0) & 2)
+ .@onlyhighest=true;
+ if (getarg(1,0) & 4)
+ .@onlytotal=true;
.@c = getunits(BL_PC, .@players, false, getarg(0));
.@skip=0;
// There is at least one player, do things properly
for (.@i = 0; .@i < .@c; .@i++) {
- /*
// Dead players are not counted
- if (ispcdead(strcharinfo(0, "", .@players[.@i])))
- continue;
- */
+ if (.@deadcount) {
+ if (ispcdead(strcharinfo(0, "", .@players[.@i]))) {
+ .@skip+=1;
+ continue;
+ }
+ }
+
.@b=readparam(BaseLevel, .@players[.@i]);
// GMs are not counted
@@ -53,8 +62,10 @@ function script siege_calcdiff {
//debugmes "calcdiff: Total %d Average %d Highest %d", .@bsum, (.@bsum/.@c), .@highest;
- if (getarg(1,false))
+ if (.@onlyhighest)
return .@highest;
+ else if (.@onlytotal)
+ return .@bsum;
else
return (.@bsum/.@c);
}