]> icculus.org git repositories - divverent/nexuiz.git/blob - TeamNexuiz/game/gamec/medic.c
Added a Game C folder
[divverent/nexuiz.git] / TeamNexuiz / game / gamec / medic.c
1 void MedicSpecial()\r
2 {\r
3         sprint(self, "Not done yet\n");\r
4 }\r
5 \r
6 void MedicGrenade(float req)\r
7 {\r
8         float atk_delay;\r
9         atk_delay = cvar("g_balance_class_medic_grenade_delayattack");\r
10         if(req == WR_GRENADE1)\r
11         {\r
12                 if(W_ThrowGrenade(W_PoisonGrenade))\r
13                 {\r
14                         self.grenade_time = time + cvar("g_balance_grenade_poison_refire");\r
15                         // special: medic can't shoot for a while\r
16                         if(self.attack_finished < time + atk_delay)\r
17                                 self.attack_finished = time + atk_delay;\r
18                 }\r
19         }\r
20         else if(req == WR_GRENADE2)\r
21         {\r
22                 if(W_ThrowGrenade(W_ArmorGrenade))\r
23                 {\r
24                         self.grenade_time = time + cvar("g_balance_grenade_armor_refire");\r
25                         // special: medic can't shoot for a while\r
26                         if(self.attack_finished < time + atk_delay)\r
27                                 self.attack_finished = time + atk_delay;\r
28                 }\r
29         }\r
30 }\r
31 \r
32 void player_clearpoison(entity targ);\r
33 \r
34 void MedicPreThink()\r
35 {\r
36         entity head;\r
37         float maxhpratio, healamt, armoramt, reducestatus, didheal;\r
38 \r
39         if(self.special_time > time)\r
40                 return;\r
41         self.special_time = time + cvar("g_balance_medic_heal_pingrate");\r
42 \r
43         maxhpratio = cvar("g_balance_medic_heal_max");\r
44         healamt = cvar("g_balance_medic_heal_pingheal");\r
45         armoramt = cvar("g_balance_medic_heal_pingarmor");\r
46         reducestatus = cvar("g_balance_medic_heal_reducestatus");\r
47 \r
48         head = findradius(self.origin, cvar("g_balance_medic_heal_radius"));\r
49         while(head)\r
50         {\r
51                 if(head.team == self.team && head.class != CLASS_MEDIC)// && head != self)\r
52                 {\r
53                         if(head.classname == "player")\r
54                         {\r
55                                 didheal = 0;\r
56                                 if(head.health < head.max_health * maxhpratio)\r
57                                 {\r
58                                         //bprint(strcat("heal hp ", ftos(head.health)));\r
59                                         //bprint(strcat(" ", ftos(head.health + healamt)));\r
60                                         //bprint(strcat(" ", ftos(head.max_health * maxhpratio), "\n"));\r
61                                         head.health = bound(head.health,\r
62                                                 head.health + healamt,\r
63                                                 head.max_health * maxhpratio);\r
64                                         //head.health = head.health + healamt;\r
65                                         //if(head.health > head.max_health * maxhpratio)\r
66                                         //      head.health = head.max_health * maxhpratio;\r
67                                         DelayHealthRot(head);\r
68                                         didheal = 1;\r
69                                 }\r
70                                 if(head.armorvalue < head.max_armor * maxhpratio)\r
71                                 {\r
72                                         //bprint("heal ar\n");\r
73                                         head.armorvalue = bound(head.armorvalue,\r
74                                                 head.armorvalue + armoramt,\r
75                                                 head.max_armor * maxhpratio);\r
76                                         DelayArmorRot(head);\r
77                                         didheal = 1;\r
78                                 }\r
79                                 if(head.poison_damage)\r
80                                 {\r
81                                         //bprint("heal poison\n");\r
82                                         player_clearpoison(head);\r
83                                         didheal = 1;\r
84                                 }\r
85                                 if(head.onfire)\r
86                                 {\r
87                                         //bprint("heal fire\n");\r
88                                         head.onfire.wait = time + (head.onfire.wait - time)*reducestatus;\r
89                                         didheal = 1;\r
90                                 }\r
91                                 if(didheal)\r
92                                 {\r
93                                         // visual effect\r
94                                         te_teleport(head.origin);\r
95                                 }\r
96                         }\r
97                 }\r
98                 head = head.chain;\r
99         }\r
100 }\r
101 \r
102 void MedicPostThink()\r
103 {\r
104 }\r
105 \r
106 void BecomeMedic(float portion)\r
107 {\r
108         self.max_health = cvar("g_balance_class_medic_health") * portion;\r
109 \r
110         self.max_armor = cvar("g_balance_class_medic_armor") * portion;\r
111 \r
112         self.mass = cvar("g_balance_class_medic_mass");\r
113 \r
114         SetPlayerSpeed(self);\r
115 \r
116         self.items = IT_WEP1 | IT_WEP2 | IT_WEP3 | IT_WEP4;\r
117         self.switchweapon = WEP2;\r
118         self.ammo_shells = floor(20 * portion);\r
119         self.ammo_nails = floor(50 * portion);\r
120         self.ammo_rockets = floor(0 * portion);\r
121         self.ammo_cells = floor(0 * portion);\r
122         self.playerclass = 5;           // TF P.C.\r
123         SetMaxAmmoFor (16);\r
124 }\r