]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/powerups/sv_powerups.qc
Numerous enhancements to the new status effects system, split powerups into a dedicat...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / powerups / sv_powerups.qc
1 #include "sv_powerups.qh"
2
3 MUTATOR_HOOKFUNCTION(powerups, W_PlayStrengthSound)
4 {
5         entity player = M_ARGV(0, entity);
6         entity store = IS_PLAYER(player) ? PS(player) : player; // because non-player entities can fire weapons
7
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)))
11                 {
12                         sound(player, CH_TRIGGER, SND_STRENGTH_FIRE, VOL_BASE, ATTEN_NORM);
13                         store.prevstrengthsound = time;
14                 }
15         store.prevstrengthsoundattempt = time;
16 }
17
18 MUTATOR_HOOKFUNCTION(powerups, LogDeath_AppendItemCodes)
19 {
20         entity player = M_ARGV(0, entity);
21
22         if(StatusEffects_active(STATUSEFFECT_Strength, player))
23                 M_ARGV(1, string) = strcat(M_ARGV(1, string), "S");
24
25         if(StatusEffects_active(STATUSEFFECT_Shield, player))
26                 M_ARGV(1, string) = strcat(M_ARGV(1, string), "I");
27
28         // TODO: item codes for other powerups?
29 }
30
31 MUTATOR_HOOKFUNCTION(powerups, Damage_Calculate)
32 {
33         entity attacker = M_ARGV(1, entity);
34         entity targ = M_ARGV(2, entity);
35
36         // apply strength multiplier
37         if(StatusEffects_active(STATUSEFFECT_Strength, attacker))
38         {
39                 if(targ == attacker)
40                 {
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;
43                 }
44                 else
45                 {
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;
48                 }
49         }
50
51         // apply shield multiplier
52         if(StatusEffects_active(STATUSEFFECT_Shield, targ))
53         {
54                 M_ARGV(4, float) = M_ARGV(4, float) * autocvar_g_balance_powerup_invincible_takedamage;
55                 if (targ != attacker)
56                 {
57                         M_ARGV(6, vector) = M_ARGV(6, vector) * autocvar_g_balance_powerup_invincible_takeforce;
58                 }
59         }
60 }
61
62 MUTATOR_HOOKFUNCTION(powerups, CustomizeWaypoint)
63 {
64         entity wp = M_ARGV(0, entity);
65         entity player = M_ARGV(1, entity);
66
67         entity e = WaypointSprite_getviewentity(player);
68
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))
72                 return true;
73 }
74
75 MUTATOR_HOOKFUNCTION(powerups, MonsterValidTarget)
76 {
77         entity targ = M_ARGV(1, entity);
78         return StatusEffects_active(STATUSEFFECT_Invisibility, targ);
79 }
80
81 MUTATOR_HOOKFUNCTION(powerups, PlayerPhysics_UpdateStats)
82 {
83         entity player = M_ARGV(0, entity);
84         // these automatically reset, no need to worry
85
86         if(StatusEffects_active(STATUSEFFECT_Speed, player))
87                 STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_balance_powerup_speed_highspeed;
88 }
89
90 MUTATOR_HOOKFUNCTION(powerups, WeaponSpeedFactor)
91 {
92         entity player = M_ARGV(1, entity);
93
94         if(StatusEffects_active(STATUSEFFECT_Speed, player))
95                 M_ARGV(0, float) *= autocvar_g_balance_powerup_speed_weaponspeed;
96 }
97
98 MUTATOR_HOOKFUNCTION(powerups, WeaponRateFactor)
99 {
100         entity player = M_ARGV(1, entity);
101
102         if(StatusEffects_active(STATUSEFFECT_Speed, player))
103                 M_ARGV(0, float) *= autocvar_g_balance_powerup_speed_attackrate;
104 }
105
106 MUTATOR_HOOKFUNCTION(powerups, BuildMutatorsPrettyString)
107 {
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");
112 }
113
114 MUTATOR_HOOKFUNCTION(powerups, BotShouldAttack)
115 {
116         entity targ = M_ARGV(1, entity);
117
118         if(StatusEffects_active(STATUSEFFECT_Invisibility, targ))
119                 return true;
120 }
121
122 MUTATOR_HOOKFUNCTION(powerups, BuildMutatorsString)
123 {
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");
128 }