From 7e2871d65406c81da0b4b2feb748fabf3f25f25a Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 13 Jul 2012 17:30:32 +0200 Subject: [PATCH] also add DistributeEvenly_GetRandomized for randomized rounding --- qcsrc/server/miscfunctions.qc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 25b42821e..70523892a 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -67,6 +67,16 @@ float DistributeEvenly_Get(float weight) DistributeEvenly_amount -= f; return f; } +float DistributeEvenly_GetRandomized(float weight) +{ + float f; + if (weight <= 0) + return 0; + f = floor(random() + DistributeEvenly_amount * weight / DistributeEvenly_totalweight); + DistributeEvenly_totalweight -= weight; + DistributeEvenly_amount -= f; + return f; +} #define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e) -- 2.39.2