From bd1ba3b8748305069a59fd26d6022a0b7b4983bd Mon Sep 17 00:00:00 2001 From: Penguinum Date: Thu, 23 Apr 2015 15:03:15 +0300 Subject: [PATCH] Antiwall works, need to modify triggers --- qcsrc/client/antiwall.qc | 20 +++++- qcsrc/client/main.qc | 2 + qcsrc/server/antiwall.qc | 129 +++++++++++++++++++++++++++++++++++++++ qcsrc/server/defs.qh | 3 + qcsrc/server/progs.src | 1 + 5 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 qcsrc/server/antiwall.qc diff --git a/qcsrc/client/antiwall.qc b/qcsrc/client/antiwall.qc index 87300b75c..e333eef64 100644 --- a/qcsrc/client/antiwall.qc +++ b/qcsrc/client/antiwall.qc @@ -90,7 +90,7 @@ void Ent_Antiwall_Remove() void Ent_Antiwall() { - int f; + float f; var .vector fld; InterpolateOrigin_Undo(); @@ -148,7 +148,6 @@ void Ent_Antiwall() self.loddistance1 = 0; self.loddistance2 = 0; } - self.solid = ReadByte(); self.scale = ReadShort() / 256.0; if(f & 0x20) { @@ -187,14 +186,29 @@ void Ent_Antiwall() self.movedir_z = ReadCoord(); self.lip = ReadByte() / 255.0; } + + self.fade_start = ReadShort(); + self.fade_end = ReadShort(); + self.alpha_max = ReadShort(); + self.inactive = ReadShort(); + self.solid = ReadByte(); + if (!self.fade_start) { + self.fade_start = 50; + } + if (!self.fade_end) { + self.fade_end = 150; + } + if (!self.alpha_max) { + self.alpha_max = 1; + } BGMScript_InitEntity(self); } - InterpolateOrigin_Note(); self.saved = self.fld; self.entremove = Ent_Antiwall_Remove; self.draw = Ent_Antiwall_Draw; + self.predraw = Ent_Antiwall_PreDraw; } diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 36ec4f7b8..b09724c80 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -7,6 +7,7 @@ #include "tturrets.qh" #include "tuba.qh" #include "wall.qh" +#include "antiwall.qh" #include "waypointsprites.qh" #include "vehicles/vehicles.qh" @@ -822,6 +823,7 @@ void CSQC_Ent_Update(float bIsNewEntity) case ENT_CLIENT_CLIENTDATA: Ent_ClientData(); break; case ENT_CLIENT_RANDOMSEED: Ent_RandomSeed(); break; case ENT_CLIENT_WALL: Ent_Wall(); break; + case ENT_CLIENT_ANTIWALL: Ent_Antiwall(); break; case ENT_CLIENT_MODELEFFECT: Ent_ModelEffect(bIsNewEntity); break; case ENT_CLIENT_TUBANOTE: Ent_TubaNote(bIsNewEntity); break; case ENT_CLIENT_WARPZONE: WarpZone_Read(bIsNewEntity); break; diff --git a/qcsrc/server/antiwall.qc b/qcsrc/server/antiwall.qc new file mode 100644 index 000000000..2153cf2f4 --- /dev/null +++ b/qcsrc/server/antiwall.qc @@ -0,0 +1,129 @@ +#if defined(CSQC) +#elif defined(MENUQC) +#elif defined(SVQC) + #include "../dpdefs/progsdefs.qh" + #include "../dpdefs/dpextensions.qh" + #include "../common/constants.qh" + #include "autocvars.qh" + #include "constants.qh" + #include "defs.qh" + #include "../csqcmodellib/sv_model.qh" +#endif + +void antiwall_setcolormaptoactivator (void) +{ + g_model_setcolormaptoactivator(); + self.SendFlags |= 9; +} + +void antiwall_dropbyspawnflags() +{ + vector o0; + o0 = self.origin; + g_model_dropbyspawnflags(); + if(self.origin != o0) + self.SendFlags |= 2; +} + +float antiwall_genericsendentity (entity to, float sf) +{ + sf = sf & 0x0F; + if(self.angles != '0 0 0') + sf |= 0x10; + if(self.solid && (self.mins != '0 0 0' || self.maxs != '0 0 0')) + sf |= 0x20; + if(self.colormap != 0) + sf |= 0x40; + if(self.lodmodelindex1) + sf |= 0x80; + + WriteByte(MSG_ENTITY, ENT_CLIENT_ANTIWALL); + WriteByte(MSG_ENTITY, sf); + + if (self.inactive) { + self.solid = SOLID_NOT; + } else { + self.solid = SOLID_BSP; + } + + if(sf & 1) + { + if(sf & 0x40) + WriteShort(MSG_ENTITY, self.colormap); + } + + if(sf & 2) + { + WriteCoord(MSG_ENTITY, self.origin_x); + WriteCoord(MSG_ENTITY, self.origin_y); + WriteCoord(MSG_ENTITY, self.origin_z); + } + + if(sf & 4) + { + if(sf & 0x10) + { + WriteAngle(MSG_ENTITY, self.angles_x); + WriteAngle(MSG_ENTITY, self.angles_y); + WriteAngle(MSG_ENTITY, self.angles_z); + } + } + + if(sf & 8) + { + if(sf & 0x80) + { + WriteShort(MSG_ENTITY, self.lodmodelindex0); + WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535)); + WriteShort(MSG_ENTITY, self.lodmodelindex1); + WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535)); + WriteShort(MSG_ENTITY, self.lodmodelindex2); + } else { + WriteShort(MSG_ENTITY, self.modelindex); + } + WriteShort(MSG_ENTITY, floor(self.scale * 256)); + if(sf & 0x20) + { + WriteCoord(MSG_ENTITY, self.mins_x); + WriteCoord(MSG_ENTITY, self.mins_y); + WriteCoord(MSG_ENTITY, self.mins_z); + WriteCoord(MSG_ENTITY, self.maxs_x); + WriteCoord(MSG_ENTITY, self.maxs_y); + WriteCoord(MSG_ENTITY, self.maxs_z); + } + WriteString(MSG_ENTITY, self.bgmscript); + if(self.bgmscript != "") + { + WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64)); + WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64)); + WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255)); + WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64)); + WriteCoord(MSG_ENTITY, self.movedir_x); + WriteCoord(MSG_ENTITY, self.movedir_y); + WriteCoord(MSG_ENTITY, self.movedir_z); + WriteByte(MSG_ENTITY, floor(self.lip * 255)); + } + WriteShort(MSG_ENTITY, self.fade_start); + WriteShort(MSG_ENTITY, self.fade_end); + WriteShort(MSG_ENTITY, self.alpha_max); + WriteShort(MSG_ENTITY, self.inactive); + WriteByte(MSG_ENTITY, self.solid); + /*printf("called\n");*/ + } + + return TRUE; +} + +#define ANTIWALL_INIT(sol) \ + if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \ + if(!self.scale) self.scale = self.modelscale; \ + SetBrushEntityModel(); \ + self.use = antiwall_setcolormaptoactivator; \ + InitializeEntity(self, antiwall_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \ + if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \ + if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \ + Net_LinkEntity(self, TRUE, 0, antiwall_genericsendentity); + +void spawnfunc_func_antiwall() { ANTIWALL_INIT(SOLID_BSP) } // Solid dynamic entity +void spawnfunc_func_antiillusion() { ANTIWALL_INIT(SOLID_NOT) } // Non-solid dynamic entity +void spawnfunc_aw() { ANTIWALL_INIT(SOLID_BSP) } // Solid dynamic entity diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 7c26399af..2802a9569 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -627,4 +627,7 @@ const int MIF_GUIDED_TAG = 128; .float init_for_player_needed; .void(entity) init_for_player; +.float fade_start, fade_end; +.float inactive, alpha_max; + #endif diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index 85e75cda9..2f01d82e1 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -59,6 +59,7 @@ t_quake.qc t_swamp.qc t_teleporters.qc waypointsprites.qc +antiwall.qc bot/bot.qc -- 2.39.2