1 #include "sv_powerups.qh"
3 MUTATOR_HOOKFUNCTION(powerups, W_PlayStrengthSound)
5 entity player = M_ARGV(0, entity);
7 if(StatusEffects_active(STATUSEFFECT_Strength, player)
8 && ((time > player.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam
9 || (time > player.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold)))
11 sound(player, CH_TRIGGER, SND_STRENGTH_FIRE, VOL_BASE, ATTEN_NORM);
12 player.prevstrengthsound = time;
14 player.prevstrengthsoundattempt = time;
17 MUTATOR_HOOKFUNCTION(powerups, LogDeath_AppendItemCodes)
19 entity player = M_ARGV(0, entity);
21 if(StatusEffects_active(STATUSEFFECT_Strength, player))
22 M_ARGV(1, string) = strcat(M_ARGV(1, string), "S");
24 if(StatusEffects_active(STATUSEFFECT_Shield, player))
25 M_ARGV(1, string) = strcat(M_ARGV(1, string), "I");
27 // TODO: item codes for other powerups?
30 MUTATOR_HOOKFUNCTION(powerups, Damage_Calculate)
32 entity attacker = M_ARGV(1, entity);
33 entity targ = M_ARGV(2, entity);
35 // apply strength multiplier
36 if(StatusEffects_active(STATUSEFFECT_Strength, attacker))
40 M_ARGV(4, float) = M_ARGV(4, float) * autocvar_g_balance_powerup_strength_selfdamage;
41 M_ARGV(6, vector) = M_ARGV(6, vector) * autocvar_g_balance_powerup_strength_selfforce;
45 M_ARGV(4, float) = M_ARGV(4, float) * autocvar_g_balance_powerup_strength_damage;
46 M_ARGV(6, vector) = M_ARGV(6, vector) * autocvar_g_balance_powerup_strength_force;
50 // apply shield multiplier
51 if(StatusEffects_active(STATUSEFFECT_Shield, targ))
53 M_ARGV(4, float) = M_ARGV(4, float) * autocvar_g_balance_powerup_invincible_takedamage;
56 M_ARGV(6, vector) = M_ARGV(6, vector) * autocvar_g_balance_powerup_invincible_takeforce;
61 MUTATOR_HOOKFUNCTION(powerups, CustomizeWaypoint)
63 entity wp = M_ARGV(0, entity);
64 entity player = M_ARGV(1, entity);
66 entity e = WaypointSprite_getviewentity(player);
68 // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
69 // but only apply this to real players, not to spectators
70 if(IS_CLIENT(wp.owner) && (e == player) && DIFF_TEAM(wp.owner, e) && StatusEffects_active(STATUSEFFECT_Invisibility, wp.owner))
74 MUTATOR_HOOKFUNCTION(powerups, MonsterValidTarget)
76 entity targ = M_ARGV(1, entity);
77 return StatusEffects_active(STATUSEFFECT_Invisibility, targ);
80 void powerups_DropItem(entity this, StatusEffects effect)
82 entity item = Item_DefinitionFromInternalName(effect.netname);
83 float timeleft = StatusEffects_gettime(effect, this);
84 if((timeleft - time) <= 0 || !item)
87 // TODO: items cannot hold their "item field" yet, so we need to list all the powerups here!
90 case ITEM_Strength: e.strength_finished = timeleft; break;
91 case ITEM_Shield: e.invincible_finished = timeleft; break;
92 case ITEM_Invisibility: e.invisibility_finished = timeleft; break;
93 case ITEM_Speed: e.speed_finished = timeleft; break;
95 Item_InitializeLoot(e, item.m_canonical_spawnfunc, this.origin + '0 0 32', randomvec() * 175 + '0 0 175', min(timeleft - time, 10));
96 Item_SetExpiring(e, true);
99 MUTATOR_HOOKFUNCTION(powerups, PlayerDies)
101 if(!autocvar_g_powerups_dropondeath)
104 entity frag_target = M_ARGV(2, entity);
106 FOREACH(StatusEffect, it.instanceOfPowerups,
108 if(StatusEffects_active(it, frag_target))
109 powerups_DropItem(frag_target, it);
113 MUTATOR_HOOKFUNCTION(powerups, PlayerPhysics_UpdateStats)
115 entity player = M_ARGV(0, entity);
116 // these automatically reset, no need to worry
118 if(StatusEffects_active(STATUSEFFECT_Speed, player))
119 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_balance_powerup_speed_highspeed;
122 MUTATOR_HOOKFUNCTION(powerups, WeaponRateFactor)
124 entity player = M_ARGV(1, entity);
126 if(StatusEffects_active(STATUSEFFECT_Speed, player))
127 M_ARGV(0, float) *= autocvar_g_balance_powerup_speed_attackrate;
130 MUTATOR_HOOKFUNCTION(powerups, BuildMutatorsPrettyString)
132 if(autocvar_g_powerups == 0)
133 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", No powerups");
134 if(autocvar_g_powerups > 0)
135 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Powerups");
138 MUTATOR_HOOKFUNCTION(powerups, BotShouldAttack)
140 entity targ = M_ARGV(1, entity);
142 if(StatusEffects_active(STATUSEFFECT_Invisibility, targ))
146 MUTATOR_HOOKFUNCTION(powerups, BuildMutatorsString)
148 if(autocvar_g_powerups == 0)
149 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":no_powerups");
150 if(autocvar_g_powerups > 0)
151 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":powerups");