Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_bloodloss.qc
1 #include "../_all.qh"
2
3 #include "mutator.qh"
4
5 .float bloodloss_timer;
6
7 MUTATOR_HOOKFUNCTION(bloodloss_PlayerThink)
8 {
9         if(IS_PLAYER(self))
10         if(self.health <= autocvar_g_bloodloss && self.deadflag == DEAD_NO)
11         {
12                 self.BUTTON_CROUCH = true;
13
14                 if(time >= self.bloodloss_timer)
15                 {
16                         if(self.vehicle)
17                                 vehicles_exit(VHEF_RELEASE);
18                         if(self.event_damage)
19                                 self.event_damage(self, self, 1, DEATH_ROT, self.origin, '0 0 0');
20                         self.bloodloss_timer = time + 0.5 + random() * 0.5;
21                 }
22         }
23
24         return false;
25 }
26
27 MUTATOR_HOOKFUNCTION(bloodloss_PlayerJump)
28 {
29         if(self.health <= autocvar_g_bloodloss)
30                 return true;
31
32         return false;
33 }
34
35 MUTATOR_HOOKFUNCTION(bloodloss_BuildMutatorsString)
36 {
37         ret_string = strcat(ret_string, ":bloodloss");
38         return false;
39 }
40
41 MUTATOR_HOOKFUNCTION(bloodloss_BuildMutatorsPrettyString)
42 {
43         ret_string = strcat(ret_string, ", Blood loss");
44         return false;
45 }
46
47 MUTATOR_DEFINITION(mutator_bloodloss)
48 {
49         MUTATOR_HOOK(PlayerPreThink, bloodloss_PlayerThink, CBC_ORDER_ANY);
50         MUTATOR_HOOK(PlayerJump, bloodloss_PlayerJump, CBC_ORDER_ANY);
51         MUTATOR_HOOK(BuildMutatorsString, bloodloss_BuildMutatorsString, CBC_ORDER_ANY);
52         MUTATOR_HOOK(BuildMutatorsPrettyString, bloodloss_BuildMutatorsPrettyString, CBC_ORDER_ANY);
53
54         return false;
55 }