]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_buffs.qc
Fix some cases of division by 0
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_buffs.qc
index 12c3e4febb5e8d5661a49bce7ed453b9f55605b1..bafa28c9c88dbc86cfbf24718ea4e8be018eb66a 100644 (file)
@@ -46,7 +46,7 @@ float buff_Waypoint_visible_for_player(entity plr)
 
 void buff_Waypoint_Spawn(entity e)
 {
-    WaypointSprite_Spawn(Buff_PrettyName(e.buffs), 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs_z, world, e.team, e, buff_waypoint, TRUE, RADARICON_POWERUP, e.glowmod);
+    WaypointSprite_Spawn(Buff_Sprite(e.buffs), 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs_z, world, e.team, e, buff_waypoint, TRUE, RADARICON_POWERUP, e.glowmod);
     WaypointSprite_UpdateTeamRadar(e.buff_waypoint, RADARICON_POWERUP, e.glowmod);
     e.buff_waypoint.waypointsprite_visible_for_player = buff_Waypoint_visible_for_player;
 }
@@ -456,7 +456,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerPhysics)
 MUTATOR_HOOKFUNCTION(buffs_PlayerJump)
 {
        if(self.buffs & BUFF_JUMP)
-               player_jumpheight = autocvar_g_buffs_jump_height;
+               player_jumpheight = max(autocvar_g_buffs_jump_height, player_jumpheight);
 
        return FALSE;
 }
@@ -518,6 +518,19 @@ MUTATOR_HOOKFUNCTION(buffs_RemovePlayer)
        return FALSE;
 }
 
+MUTATOR_HOOKFUNCTION(buffs_CustomizeWaypoint)
+{
+       entity e = WaypointSprite_getviewentity(other);
+
+       // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
+       // but only apply this to real players, not to spectators
+       if((self.owner.flags & FL_CLIENT) && (self.owner.buffs & BUFF_INVISIBLE) && (e == other))
+       if(DIFF_TEAM(self.owner, e))
+               return TRUE;
+
+       return FALSE;
+}
+
 MUTATOR_HOOKFUNCTION(buffs_OnEntityPreSpawn)
 {
        if(autocvar_g_buffs_replace_powerups)
@@ -537,9 +550,11 @@ MUTATOR_HOOKFUNCTION(buffs_OnEntityPreSpawn)
 MUTATOR_HOOKFUNCTION(buffs_WeaponRate)
 {
        if(self.buffs & BUFF_SPEED)
+       if(autocvar_g_buffs_speed_rate > 0)
                weapon_rate *= autocvar_g_buffs_speed_rate;
                
        if(time < self.buff_disability_time)
+       if(autocvar_g_buffs_disability_rate > 0)
                weapon_rate *= autocvar_g_buffs_disability_rate;
        
        return FALSE;
@@ -753,7 +768,7 @@ void buffs_Initialize()
 MUTATOR_DEFINITION(mutator_buffs)
 {
        MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, buffs_PlayerDamage_SplitHealthArmor, CBC_ORDER_ANY);
-       MUTATOR_HOOK(PlayerDamage_Calculate, buffs_PlayerDamage_Calculate, CBC_ORDER_LAST);
+       MUTATOR_HOOK(PlayerDamage_Calculate, buffs_PlayerDamage_Calculate, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerSpawn, buffs_PlayerSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPhysics, buffs_PlayerPhysics, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerJump, buffs_PlayerJump, CBC_ORDER_ANY);
@@ -767,6 +782,7 @@ MUTATOR_DEFINITION(mutator_buffs)
        MUTATOR_HOOK(MakePlayerObserver, buffs_RemovePlayer, CBC_ORDER_ANY);
        MUTATOR_HOOK(ClientDisconnect, buffs_RemovePlayer, CBC_ORDER_ANY);
        MUTATOR_HOOK(OnEntityPreSpawn, buffs_OnEntityPreSpawn, CBC_ORDER_ANY);
+       MUTATOR_HOOK(CustomizeWaypoint, buffs_CustomizeWaypoint, CBC_ORDER_ANY);
        MUTATOR_HOOK(WeaponRateFactor, buffs_WeaponRate, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPreThink, buffs_PlayerThink, CBC_ORDER_ANY);
        MUTATOR_HOOK(GetCvars, buffs_GetCvars, CBC_ORDER_ANY);