if (handicap_lvl != 0)
{
sbt_field_icon_extra1 = "gfx/scoreboard/player_handicap";
- sbt_field_icon_extra1_rgb = '1 0 0' + '0 1 1' * ((255 - handicap_lvl) / 254);
- // goes from white to red over level 1 to 255
+ sbt_field_icon_extra1_rgb = '1 0 0' + '0 1 1' * ((16 - handicap_lvl) / 15);
+ // goes from white to red over level 1 to 16
}
return entcs_GetName(pl.sv_entnum);
}
/// \copyright GNU GPLv2 or any later version.
#include <common/state.qh>
-#include <common/ent_cs.qh> // for .handicap_total
+#include <common/ent_cs.qh> // for .handicap_level
#include <lib/replicate.qh> // for REPLICATE_APPLYCHANGE
#include <server/client.qh>
void Handicap_UpdateHandicapLevel(entity player)
{
- float handicap_total = Handicap_GetTotalHandicap(player, true) *
- Handicap_GetTotalHandicap(player, false);
+ float handicap_total = (Handicap_GetTotalHandicap(player, true) +
+ Handicap_GetTotalHandicap(player, false)) / 2;
if (handicap_total <= 1)
player.handicap_level = 0;
else
- player.handicap_level = map_bound_ranges(handicap_total, 1, 5, 1, 255);
+ player.handicap_level = floor(map_bound_ranges(handicap_total, 1, HANDICAP_MAX_LEVEL_EQUIVALENT, 1, 16));
}
REPLICATE_APPLYCHANGE("cl_handicap_damage_given", { Handicap_UpdateHandicapLevel(this); });
/// \param[in] player Player to check.
void Handicap_UpdateHandicapLevel(entity player);
+#define HANDICAP_MAX_LEVEL_EQUIVALENT 2.0
+
.int handicap_level;
-// This int ranges 0 to 255, 0 meaning no handicap, 1-255 representing handicap "levels"
-// ... mapped from 1.0 to 5.0, using given * taken (i.e. both-ways handicap)
-// It is networked to the client
+// This int ranges 0 to 16, 0 meaning no handicap, 1 to 16 representing handicap "levels" mapped
+// from 1.0 to HANDICAP_MAX_LEVEL_EQUIVALENT, using (given + taken)/2 (i.e. both-ways handicap).
+// It is networked to the client.
+// The levels are mostly meaningless, just used to determine the player_handicap icon color.
+