]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/g_violence.qc
a9111a03bc7f3ef231b3e4445df5d32f4a9e0abc
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_violence.qc
1 #include "g_violence.qh"
2 #include "_all.qh"
3
4 float Violence_GibSplash_SendEntity(entity to, int sf)
5 {SELFPARAM();
6         WriteByte(MSG_ENTITY, ENT_CLIENT_GIBSPLASH);
7         WriteByte(MSG_ENTITY, self.state); // actually type
8         WriteByte(MSG_ENTITY, bound(1, self.cnt * 16, 255)); // gibbage amount multiplier
9         WriteShort(MSG_ENTITY, floor(self.origin.x / 4)); // not using a coord here, as gibs don't need this accuracy
10         WriteShort(MSG_ENTITY, floor(self.origin.y / 4)); // not using a coord here, as gibs don't need this accuracy
11         WriteShort(MSG_ENTITY, floor(self.origin.z / 4)); // not using a coord here, as gibs don't need this accuracy
12         WriteShort(MSG_ENTITY, self.oldorigin.x); // acrually compressed velocity
13         return true;
14 }
15
16 // TODO maybe convert this to a TE?
17 void Violence_GibSplash_At(vector org, vector dir, float type, float amount, entity gibowner, entity attacker)
18 {SELFPARAM();
19         if(g_cts) // no gibs in CTS
20                 return;
21
22         entity e;
23
24         e = spawn();
25         e.classname = "gibsplash";
26         e.cnt = amount;
27         e.state = type; // should stay smaller than 15
28         if(!sound_allowed(MSG_BROADCAST, gibowner) || !sound_allowed(MSG_BROADCAST, attacker))
29                 e.state |= 0x40; // "silence" bit
30         e.state |= 8 * self.species; // gib type, ranges from 0 to 15
31
32         // if this is a copied dead body, send the num of its player instead
33         // TODO: remove this field, read from model txt files
34         if(self.classname == "body")
35                 e.team = num_for_edict(self.enemy);
36         else
37                 e.team = num_for_edict(self);
38
39         setorigin(e, org);
40         e.velocity = dir;
41
42         e.oldorigin_x = compressShortVector(e.velocity);
43
44         Net_LinkEntity(e, false, 0.2, Violence_GibSplash_SendEntity);
45 }
46
47 void Violence_GibSplash(entity source, float type, float amount, entity attacker)
48 {
49         Violence_GibSplash_At(source.origin + source.view_ofs, source.velocity, type, amount, source, attacker);
50 }