]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/vehicles/vehicles.qc
Merge remote branch 'refs/remotes/origin/tzork/vehicles1'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / vehicles / vehicles.qc
1 void vehicle_stdproc_enter()
2 {
3 }
4
5 void vehicle_stdproc_exit(float eject)
6 {
7 }
8
9 void vehicle_stdproc_shiledregen(float rmax, float dt)
10 {
11     if(self.vehicle_shield < rmax)
12     if(self.dmg_time + CCVAR("_shield_regen_dmgpause") < time)
13     {
14         self.vehicle_shield = min(self.vehicle_shield + CCVAR("_shield_regen") * dt, rmax);
15
16         if(self.owner)
17             self.owner.vehicle_shield = self.vehicle_shield / rmax;
18     }
19 }
20
21 void vehicle_stdproc_healthregen(float rmax, float dt)
22 {
23
24     if(self.dmg_time + CCVAR("_health_regen_dmgpause") < time)
25     if(self.vehicle_health < rmax)
26     {
27         self.vehicle_health = min(self.vehicle_health + CCVAR("_health_regen") * dt, rmax);
28
29         if(self.owner)
30             self.owner.vehicle_health = self.vehicle_health / rmax;
31     }
32 }
33
34 void vehicle_stdproc_energyregen(float rmax, float dt)
35 {
36     if(self.vehicle_energy < rmax)
37     {
38         self.vehicle_energy = min(self.vehicle_energy + CCVAR("_energy_regen") * dt, rmax);
39
40         if(self.owner)
41             self.owner.vehicle_energy = self.vehicle_energy / rmax;
42     }
43 }
44
45 void shieldhit_think()
46 {
47     self.alpha = self.alpha - 0.2;
48     if (self.alpha <= 0)
49     {
50         setmodel(self,"");
51         self.alpha = -1;
52     }
53     else
54     {
55         self.nextthink = time + 0.1;
56     }
57 }
58
59 void vehicle_stdproc_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
60 {
61
62     float ddmg_take;
63
64     self.dmg_time = time;
65
66     if((self.vehicle_flags & VHF_HASSHIELD) && (self.vehicle_shield > 0))
67     {
68
69         
70         if (wasfreed(self.tur_head.enemy) || self.tur_head.enemy == world)
71         {
72             self.tur_head.enemy = spawn();
73             self.tur_head.enemy.effects = EF_LOWPRECISION;
74         }
75
76         setmodel(self.tur_head.enemy, "models/vhshield.md3");
77         setattachment(self.tur_head.enemy, self, "");
78
79         self.tur_head.enemy.colormod = '1 1 1';
80         self.tur_head.enemy.alpha = 0.45;
81         self.tur_head.enemy.scale  = (256 / vlen(self.maxs - self.mins));
82         self.tur_head.enemy.angles = vectoangles(normalize(hitloc - self.origin)) - self.angles;
83         self.tur_head.enemy.think = shieldhit_think;
84         self.tur_head.enemy.nextthink = time;
85
86         self.vehicle_shield -= damage;
87         if(self.vehicle_shield < 0)
88         {
89             self.tur_head.enemy.colormod = '10 0 -1';
90             ddmg_take = fabs(self.vehicle_shield);
91             self.vehicle_shield = 0;
92             self.tur_head.enemy.alpha = 0.75;
93             self.vehicle_health -= ddmg_take;
94         }
95     }
96     else
97         self.vehicle_health -= damage;
98
99     if(self.owner)
100     {
101         self.owner.vehicle_health = self.vehicle_health / CCVAR("_health");
102
103         if(self.vehicle_flags & VHF_HASSHIELD)
104             self.owner.vehicle_shield = self.vehicle_shield / cvar(strcat(self.cvar_basename,"_shield"));
105
106     }
107
108     if(self.vehicle_health <= 0)
109     {
110         if(self.owner)
111             if(self.vehicle_flags & VHF_DEATHEJECT)
112                 self.vehicle_exit(VHEF_EJECT);
113
114         self.vehicle_die();
115     }
116
117
118 }
119
120 void bugmenot()
121 {
122     self.vehicle_exit       = self.vehicle_exit;
123     self.vehicle_enter      = self.vehicle_exit;
124     self.vehicle_die        = self.vehicle_exit;
125     self.vehicle_spawn      = self.vehicle_exit;
126     //self.vehicle_message    = self.vehicle_exit;
127 }