1 #include "sv_powerups.qh"
3 MUTATOR_HOOKFUNCTION(powerups, W_PlayStrengthSound)
5 entity player = M_ARGV(0, entity);
6 entity store = IS_PLAYER(player) ? PS(player) : player; // because non-player entities can fire weapons
8 if(StatusEffects_active(STATUSEFFECT_Strength, player)
9 && ((time > store.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam
10 || (time > store.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold)))
12 sound(player, CH_TRIGGER, SND_STRENGTH_FIRE, VOL_BASE, ATTEN_NORM);
13 store.prevstrengthsound = time;
15 store.prevstrengthsoundattempt = time;
18 MUTATOR_HOOKFUNCTION(powerups, LogDeath_AppendItemCodes)
20 entity player = M_ARGV(0, entity);
22 if(StatusEffects_active(STATUSEFFECT_Strength, player))
23 M_ARGV(1, string) = strcat(M_ARGV(1, string), "S");
25 if(StatusEffects_active(STATUSEFFECT_Shield, player))
26 M_ARGV(1, string) = strcat(M_ARGV(1, string), "I");
28 // TODO: item codes for other powerups?
31 MUTATOR_HOOKFUNCTION(powerups, Damage_Calculate)
33 entity attacker = M_ARGV(1, entity);
34 entity targ = M_ARGV(2, entity);
36 // apply strength multiplier
37 if(StatusEffects_active(STATUSEFFECT_Strength, attacker))
41 M_ARGV(4, float) = M_ARGV(4, float) * autocvar_g_balance_powerup_strength_selfdamage;
42 M_ARGV(6, vector) = M_ARGV(6, vector) * autocvar_g_balance_powerup_strength_selfforce;
46 M_ARGV(4, float) = M_ARGV(4, float) * autocvar_g_balance_powerup_strength_damage;
47 M_ARGV(6, vector) = M_ARGV(6, vector) * autocvar_g_balance_powerup_strength_force;
51 // apply shield multiplier
52 if(StatusEffects_active(STATUSEFFECT_Shield, targ))
54 M_ARGV(4, float) = M_ARGV(4, float) * autocvar_g_balance_powerup_invincible_takedamage;
57 M_ARGV(6, vector) = M_ARGV(6, vector) * autocvar_g_balance_powerup_invincible_takeforce;
62 MUTATOR_HOOKFUNCTION(powerups, CustomizeWaypoint)
64 entity wp = M_ARGV(0, entity);
65 entity player = M_ARGV(1, entity);
67 entity e = WaypointSprite_getviewentity(player);
69 // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
70 // but only apply this to real players, not to spectators
71 if(IS_CLIENT(wp.owner) && (e == player) && DIFF_TEAM(wp.owner, e) && StatusEffects_active(STATUSEFFECT_Invisibility, wp.owner))
75 MUTATOR_HOOKFUNCTION(powerups, MonsterValidTarget)
77 entity targ = M_ARGV(1, entity);
78 return StatusEffects_active(STATUSEFFECT_Invisibility, targ);
81 MUTATOR_HOOKFUNCTION(powerups, PlayerPhysics_UpdateStats)
83 entity player = M_ARGV(0, entity);
84 // these automatically reset, no need to worry
86 if(StatusEffects_active(STATUSEFFECT_Speed, player))
87 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_balance_powerup_speed_highspeed;
90 MUTATOR_HOOKFUNCTION(powerups, WeaponSpeedFactor)
92 entity player = M_ARGV(1, entity);
94 if(StatusEffects_active(STATUSEFFECT_Speed, player))
95 M_ARGV(0, float) *= autocvar_g_balance_powerup_speed_weaponspeed;
98 MUTATOR_HOOKFUNCTION(powerups, WeaponRateFactor)
100 entity player = M_ARGV(1, entity);
102 if(StatusEffects_active(STATUSEFFECT_Speed, player))
103 M_ARGV(0, float) *= autocvar_g_balance_powerup_speed_attackrate;
106 MUTATOR_HOOKFUNCTION(powerups, BuildMutatorsPrettyString)
108 if(autocvar_g_powerups == 0)
109 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", No powerups");
110 if(autocvar_g_powerups > 0)
111 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Powerups");
114 MUTATOR_HOOKFUNCTION(powerups, BotShouldAttack)
116 entity targ = M_ARGV(1, entity);
118 if(StatusEffects_active(STATUSEFFECT_Invisibility, targ))
122 MUTATOR_HOOKFUNCTION(powerups, BuildMutatorsString)
124 if(autocvar_g_powerups == 0)
125 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":no_powerups");
126 if(autocvar_g_powerups > 0)
127 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":powerups");