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