]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/g_casings.qc
Move test to /lib
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_casings.qc
1 #include "_all.qh"
2
3 #include "../common/util.qh"
4
5 float Casing_SendEntity(entity to, int sf)
6 {
7         WriteByte(MSG_ENTITY, ENT_CLIENT_CASING);
8         WriteByte(MSG_ENTITY, self.state); // actually type
9         WriteCoord(MSG_ENTITY, self.origin.x);
10         WriteCoord(MSG_ENTITY, self.origin.y);
11         WriteCoord(MSG_ENTITY, self.origin.z);
12         WriteShort(MSG_ENTITY, self.oldorigin.x); // acrually compressed velocity
13         WriteByte(MSG_ENTITY, self.angles.x * 256 / 360);
14         WriteByte(MSG_ENTITY, self.angles.y * 256 / 360);
15         WriteByte(MSG_ENTITY, self.angles.z * 256 / 360);
16         return true;
17 }
18
19 void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner)
20 {
21         entity e;
22         vector org;
23
24         org = self.origin + self.view_ofs + self.weaponentity.spawnorigin.x * v_forward - self.weaponentity.spawnorigin.y * v_right + self.weaponentity.spawnorigin.z * v_up;
25
26         if(!sound_allowed(MSG_BROADCAST, casingowner))
27                 casingtype |= 0x80;
28
29         e = spawn();
30         e.state = casingtype;
31         setorigin(e, org);
32         e.velocity = vel;
33         e.angles = ang;
34         e.oldorigin_x = compressShortVector(e.velocity);
35
36         Net_LinkEntity(e, true, 0.2, Casing_SendEntity);
37                 // 0.2s should be enough time for all clients to receive this ent once, do the gibbage and be done with it
38 }