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