]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/generator.qc
Merge branch 'master' into Mario/ons_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / generator.qc
1 #include "generator.qh"
2
3 bool generator_send(entity to, int sf)
4 {
5         WriteByte(MSG_ENTITY, ENT_CLIENT_GENERATOR);
6         WriteByte(MSG_ENTITY, sf);
7         if(sf & GSF_SETUP)
8         {
9                 WriteCoord(MSG_ENTITY, self.origin_x);
10                 WriteCoord(MSG_ENTITY, self.origin_y);
11                 WriteCoord(MSG_ENTITY, self.origin_z);
12
13                 WriteByte(MSG_ENTITY, self.health);
14                 WriteByte(MSG_ENTITY, self.max_health);
15                 WriteByte(MSG_ENTITY, self.count);
16                 WriteByte(MSG_ENTITY, self.team);
17         }
18
19         if(sf & GSF_STATUS)
20         {
21                 WriteByte(MSG_ENTITY, self.team);
22
23                 if(self.health <= 0)
24                         WriteByte(MSG_ENTITY, 0);
25                 else
26                         WriteByte(MSG_ENTITY, ceil((self.health / self.max_health) * 255));
27         }
28
29         return true;
30 }
31
32 void generator_link(void() spawnproc)
33 {
34         Net_LinkEntity(self, true, 0, generator_send);
35         self.think              = spawnproc;
36         self.nextthink  = time;
37 }