40747ff0569b08a69ec0580027c7b38f3abdd1b3
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / midair / sv_midair.qc
1 #include "sv_midair.qh"
2
3 float autocvar_g_midair_shieldtime;
4
5 REGISTER_MUTATOR(midair, cvar("g_midair"));
6
7 .float midair_shieldtime;
8
9 MUTATOR_HOOKFUNCTION(midair, PlayerDamage_Calculate)
10 {
11         entity frag_attacker = M_ARGV(1, entity);
12         entity frag_target = M_ARGV(2, entity);
13
14         if(IS_PLAYER(frag_attacker))
15         if(IS_PLAYER(frag_target))
16         if(time < frag_target.midair_shieldtime)
17                 M_ARGV(4, float) = 0;
18 }
19
20 MUTATOR_HOOKFUNCTION(midair, PlayerPowerups)
21 {
22         entity player = M_ARGV(0, entity);
23
24         if(time >= game_starttime)
25         if(IS_ONGROUND(player))
26         {
27                 player.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
28                 player.midair_shieldtime = max(player.midair_shieldtime, time + autocvar_g_midair_shieldtime);
29         }
30 }
31
32 MUTATOR_HOOKFUNCTION(midair, PlayerSpawn)
33 {
34         entity player = M_ARGV(0, entity);
35
36         if(IS_BOT_CLIENT(player))
37                 player.bot_moveskill = 0; // disable bunnyhopping
38 }
39
40 MUTATOR_HOOKFUNCTION(midair, BuildMutatorsString)
41 {
42         M_ARGV(0, string) = strcat(M_ARGV(0, string), ":midair");
43 }
44
45 MUTATOR_HOOKFUNCTION(midair, BuildMutatorsPrettyString)
46 {
47         M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Midair");
48 }