]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/antiwall.qc
Antiwall works, need to modify triggers
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / antiwall.qc
1 #if defined(CSQC)
2 #elif defined(MENUQC)
3 #elif defined(SVQC)
4         #include "../dpdefs/progsdefs.qh"
5     #include "../dpdefs/dpextensions.qh"
6     #include "../common/constants.qh"
7     #include "autocvars.qh"
8     #include "constants.qh"
9     #include "defs.qh"
10     #include "../csqcmodellib/sv_model.qh"
11 #endif
12
13 void antiwall_setcolormaptoactivator (void)
14 {
15         g_model_setcolormaptoactivator();
16         self.SendFlags |= 9;
17 }
18
19 void antiwall_dropbyspawnflags()
20 {
21         vector o0;
22         o0 = self.origin;
23         g_model_dropbyspawnflags();
24         if(self.origin != o0)
25                 self.SendFlags |= 2;
26 }
27
28 float antiwall_genericsendentity (entity to, float sf)
29 {
30         sf = sf & 0x0F;
31         if(self.angles != '0 0 0')
32                 sf |= 0x10;
33         if(self.solid && (self.mins != '0 0 0' || self.maxs != '0 0 0'))
34                 sf |= 0x20;
35         if(self.colormap != 0)
36                 sf |= 0x40;
37         if(self.lodmodelindex1)
38                 sf |= 0x80;
39
40         WriteByte(MSG_ENTITY, ENT_CLIENT_ANTIWALL);
41         WriteByte(MSG_ENTITY, sf);
42
43     if (self.inactive) {
44         self.solid = SOLID_NOT;
45     } else {
46         self.solid = SOLID_BSP;
47     }
48
49         if(sf & 1)
50         {
51                 if(sf & 0x40)
52                         WriteShort(MSG_ENTITY, self.colormap);
53         }
54
55         if(sf & 2)
56         {
57                 WriteCoord(MSG_ENTITY, self.origin_x);
58                 WriteCoord(MSG_ENTITY, self.origin_y);
59                 WriteCoord(MSG_ENTITY, self.origin_z);
60         }
61
62         if(sf & 4)
63         {
64                 if(sf & 0x10)
65                 {
66                         WriteAngle(MSG_ENTITY, self.angles_x);
67                         WriteAngle(MSG_ENTITY, self.angles_y);
68                         WriteAngle(MSG_ENTITY, self.angles_z);
69                 }
70         }
71
72         if(sf & 8)
73         {
74                 if(sf & 0x80)
75                 {
76                         WriteShort(MSG_ENTITY, self.lodmodelindex0);
77                         WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535));
78                         WriteShort(MSG_ENTITY, self.lodmodelindex1);
79                         WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535));
80                         WriteShort(MSG_ENTITY, self.lodmodelindex2);
81                 } else {
82                         WriteShort(MSG_ENTITY, self.modelindex);
83         }
84                 WriteShort(MSG_ENTITY, floor(self.scale * 256));
85                 if(sf & 0x20)
86                 {
87                         WriteCoord(MSG_ENTITY, self.mins_x);
88                         WriteCoord(MSG_ENTITY, self.mins_y);
89                         WriteCoord(MSG_ENTITY, self.mins_z);
90                         WriteCoord(MSG_ENTITY, self.maxs_x);
91                         WriteCoord(MSG_ENTITY, self.maxs_y);
92                         WriteCoord(MSG_ENTITY, self.maxs_z);
93                 }
94                 WriteString(MSG_ENTITY, self.bgmscript);
95                 if(self.bgmscript != "")
96                 {
97                         WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
98                         WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
99                         WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
100                         WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
101                         WriteCoord(MSG_ENTITY, self.movedir_x);
102                         WriteCoord(MSG_ENTITY, self.movedir_y);
103                         WriteCoord(MSG_ENTITY, self.movedir_z);
104                         WriteByte(MSG_ENTITY, floor(self.lip * 255));
105                 }
106         WriteShort(MSG_ENTITY, self.fade_start);
107         WriteShort(MSG_ENTITY, self.fade_end);
108         WriteShort(MSG_ENTITY, self.alpha_max);
109         WriteShort(MSG_ENTITY, self.inactive);
110         WriteByte(MSG_ENTITY, self.solid);
111         /*printf("called\n");*/
112         }
113
114         return TRUE;
115 }
116
117 #define ANTIWALL_INIT(sol) \
118         if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
119         if(!self.scale) self.scale = self.modelscale; \
120         SetBrushEntityModel(); \
121         self.use = antiwall_setcolormaptoactivator; \
122         InitializeEntity(self, antiwall_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
123         if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \
124         if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \
125         Net_LinkEntity(self, TRUE, 0, antiwall_genericsendentity);
126
127 void spawnfunc_func_antiwall() { ANTIWALL_INIT(SOLID_BSP) } // Solid dynamic entity
128 void spawnfunc_func_antiillusion() { ANTIWALL_INIT(SOLID_NOT) } // Non-solid dynamic entity
129 void spawnfunc_aw() { ANTIWALL_INIT(SOLID_BSP) } // Solid dynamic entity