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