diff options
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/siege.txt | 29 |
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); } |