From: Penguinum Date: Tue, 5 May 2015 17:10:31 +0000 (+0300) Subject: Antiwall is moved to clientwall and clientillusionary X-Git-Tag: xonotic-v0.8.1~40^2~10 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e0e8902fefa72caddacf87fcab5110a31ebc961d;p=xonotic%2Fxonotic-data.pk3dir.git Antiwall is moved to clientwall and clientillusionary --- diff --git a/qcsrc/client/antiwall.qc b/qcsrc/client/antiwall.qc deleted file mode 100644 index 71268b0b8..000000000 --- a/qcsrc/client/antiwall.qc +++ /dev/null @@ -1,151 +0,0 @@ -#include "antiwall.qh" - -void Ent_Antiwall_PreDraw() -{ - if (self.inactive) { - self.alpha = 0; - } else { - vector org; - org = getpropertyvec(VF_ORIGIN); - if(!checkpvs(org, self)) - self.alpha = 0; - else if(self.fade_start) { - self.alpha = self.alpha_max / 100.0 * bound(0, - (self.fade_end - vlen(org - self.origin - 0.5 * (self.mins + self.maxs))) - / (self.fade_end - self.fade_start), 1); - } else { - self.alpha = 1; - } - } - if(self.alpha <= 0) - self.drawmask = 0; - else - self.drawmask = MASK_NORMAL; -} - -void Ent_Antiwall_Draw() -{ - float f; - - if(self.lodmodelindex1) - { - if(autocvar_cl_modeldetailreduction <= 0) - { - if(self.lodmodelindex2 && autocvar_cl_modeldetailreduction <= -2) - self.modelindex = self.lodmodelindex2; - else if(autocvar_cl_modeldetailreduction <= -1) - self.modelindex = self.lodmodelindex1; - else - self.modelindex = self.lodmodelindex0; - } - else - { - float distance = vlen(NearestPointOnBox(self, view_origin) - view_origin); - f = (distance * current_viewzoom + 100.0) * autocvar_cl_modeldetailreduction; - f *= 1.0 / bound(0.01, view_quality, 1); - if(self.lodmodelindex2 && f > self.loddistance2) - self.modelindex = self.lodmodelindex2; - else if(f > self.loddistance1) - self.modelindex = self.lodmodelindex1; - else - self.modelindex = self.lodmodelindex0; - } - } - - InterpolateOrigin_Do(); -} - -void Ent_Antiwall_Remove() -{ -} - -void Ent_Antiwall() -{ - float f; - - InterpolateOrigin_Undo(); - self.iflags = IFLAG_ANGLES | IFLAG_ORIGIN; - - f = ReadByte(); - - if(f & 1) - { - if(f & 0x40) - self.colormap = ReadShort(); - else - self.colormap = 0; - } - - if(f & 2) - { - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); - setorigin(self, self.origin); - } - - if(f & 4) - { - if(f & 0x10) - { - self.angles_x = ReadAngle(); - self.angles_y = ReadAngle(); - self.angles_z = ReadAngle(); - } - else - self.angles = '0 0 0'; - } - - if(f & 8) - { - if(f & 0x80) - { - self.lodmodelindex0 = ReadShort(); - self.loddistance1 = ReadShort(); - self.lodmodelindex1 = ReadShort(); - self.loddistance2 = ReadShort(); - self.lodmodelindex2 = ReadShort(); - } - else - { - self.modelindex = ReadShort(); - self.loddistance1 = 0; - self.loddistance2 = 0; - } - self.scale = ReadShort() / 256.0; - if(f & 0x20) - { - self.mins_x = ReadCoord(); - self.mins_y = ReadCoord(); - self.mins_z = ReadCoord(); - self.maxs_x = ReadCoord(); - self.maxs_y = ReadCoord(); - self.maxs_z = ReadCoord(); - } - else - self.mins = self.maxs = '0 0 0'; - setsize(self, self.mins, self.maxs); - - self.fade_start = ReadShort(); - self.fade_end = ReadShort(); - self.alpha_max = ReadShort(); - self.inactive = ReadShort(); - self.solid = ReadByte(); - self.illusion = ReadShort(); - if (!self.fade_start) { - self.fade_start = 50; - } - if (!self.fade_end) { - self.fade_end = 150; - } - if (!self.alpha_max) { - self.alpha_max = 1; - } - } - InterpolateOrigin_Note(); - - self.entremove = Ent_Antiwall_Remove; - self.draw = Ent_Antiwall_Draw; - self.predraw = Ent_Antiwall_PreDraw; -} - diff --git a/qcsrc/client/antiwall.qh b/qcsrc/client/antiwall.qh deleted file mode 100644 index 5ae5641b7..000000000 --- a/qcsrc/client/antiwall.qh +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ANTIWALL_H -#define ANTIWALL_H - -.int lodmodelindex0, lodmodelindex1, lodmodelindex2; -.float loddistance1, loddistance2; -.float inactive, alpha_max; -.float fade_start, fade_end; -.float illusion; - -void Ent_Antiwall_Draw(); - -void Ent_Antiwall_Remove(); - -void Ent_Antiwall(); -#endif - diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index b09724c80..36ec4f7b8 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -7,7 +7,6 @@ #include "tturrets.qh" #include "tuba.qh" #include "wall.qh" -#include "antiwall.qh" #include "waypointsprites.qh" #include "vehicles/vehicles.qh" @@ -823,7 +822,6 @@ 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/client/progs.src b/qcsrc/client/progs.src index 535f5084c..f80da18d6 100644 --- a/qcsrc/client/progs.src +++ b/qcsrc/client/progs.src @@ -35,7 +35,6 @@ vehicles/vehicles.qc view.qc wall.qc waypointsprites.qc -antiwall.qc command/cl_cmd.qc diff --git a/qcsrc/client/wall.qc b/qcsrc/client/wall.qc index 1ae8fa85a..8ff162faa 100644 --- a/qcsrc/client/wall.qc +++ b/qcsrc/client/wall.qc @@ -1,5 +1,28 @@ #include "wall.qh" +void Ent_Wall_PreDraw() +{ + if (self.inactive) { + self.alpha = 0; + } else { + vector org; + org = getpropertyvec(VF_ORIGIN); + if(!checkpvs(org, self)) + self.alpha = 0; + else if(self.fade_start) { + self.alpha = self.alpha_max / 100.0 * bound(0, + (self.fade_end - vlen(org - self.origin - 0.5 * (self.mins + self.maxs))) + / (self.fade_end - self.fade_start), 1); + } else { + self.alpha = 1; + } + } + if(self.alpha <= 0) + self.drawmask = 0; + else + self.drawmask = MASK_NORMAL; +} + void Ent_Wall_Draw() { float f; @@ -164,6 +187,11 @@ void Ent_Wall() self.movedir_z = ReadCoord(); self.lip = ReadByte() / 255.0; } + self.fade_start = ReadShort(); + self.fade_end = ReadShort(); + self.alpha_max = ReadShort(); + self.alpha_min = ReadShort(); + self.inactive = ReadShort(); BGMScript_InitEntity(self); } @@ -173,4 +201,5 @@ void Ent_Wall() self.entremove = Ent_Wall_Remove; self.draw = Ent_Wall_Draw; + self.predraw = Ent_Wall_PreDraw; } diff --git a/qcsrc/client/wall.qh b/qcsrc/client/wall.qh index 984b54c88..85d025f81 100644 --- a/qcsrc/client/wall.qh +++ b/qcsrc/client/wall.qh @@ -7,6 +7,12 @@ .float loddistance1, loddistance2; .vector saved; +// Needed for dynamic clientwalls +.float inactive; // Clientwall disappears when inactive +.float alpha_max, alpha_min; +.float fade_start, fade_end; +.float default_solid; // Variable to store default self.solid for clientwalls + void Ent_Wall_Draw(); void Ent_Wall_Remove(); diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index d83e6262a..45a65abbe 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -78,7 +78,6 @@ const int ENT_CLIENT_ELIMINATEDPLAYERS = 39; const int ENT_CLIENT_TURRET = 40; const int ENT_CLIENT_AUXILIARYXHAIR = 50; const int ENT_CLIENT_VEHICLE = 60; -const int ENT_CLIENT_ANTIWALL = 61; const int ENT_CLIENT_HEALING_ORB = 80; diff --git a/qcsrc/server/antiwall.qc b/qcsrc/server/antiwall.qc deleted file mode 100644 index f0d9641d3..000000000 --- a/qcsrc/server/antiwall.qc +++ /dev/null @@ -1,126 +0,0 @@ -#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.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.illusion) { - if (self.inactive) { - self.solid = SOLID_NOT; - } else { - self.solid = SOLID_BSP; - } - } else { - self.solid = SOLID_NOT; - } - - 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); - } - 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); - WriteShort(MSG_ENTITY, self.illusion); - /*printf("called\n");*/ - } - - return TRUE; -} - -void spawnfunc_func_antiwall() { - 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.illusion) { - self.solid = SOLID_NOT; - } else { - self.solid = SOLID_BSP; - } - Net_LinkEntity(self, TRUE, 0, antiwall_genericsendentity); -} diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 2802a9569..f0a9d2f4e 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -81,6 +81,13 @@ float server_is_dedicated; .string platmovetype; .float platmovetype_start, platmovetype_end; + +// Needed for dynamic clientwalls +.float inactive; // Clientwall disappears when inactive +.float alpha_max, alpha_min; +.float fade_start, fade_end; +.float default_solid; // Variable to store default self.solid for clientwalls + .string killtarget; .vector pos1, pos2; @@ -627,7 +634,4 @@ 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/g_models.qc b/qcsrc/server/g_models.qc index 6e1c06d05..cd25c53ef 100644 --- a/qcsrc/server/g_models.qc +++ b/qcsrc/server/g_models.qc @@ -29,7 +29,12 @@ void g_model_setcolormaptoactivator (void) void g_clientmodel_setcolormaptoactivator (void) { g_model_setcolormaptoactivator(); - self.SendFlags |= 1; + self.SendFlags |= 9; +} + +void g_clientmodel_use(void) +{ + g_clientmodel_setcolormaptoactivator(); } void g_model_dropbyspawnflags() @@ -65,7 +70,7 @@ float g_clientmodel_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')) + if(self.mins != '0 0 0' || self.maxs != '0 0 0') sf |= 0x20; if(self.colormap != 0) sf |= 0x40; @@ -133,6 +138,11 @@ float g_clientmodel_genericsendentity (entity to, float sf) 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.alpha_min); + WriteShort(MSG_ENTITY, self.inactive); } return true; @@ -151,11 +161,12 @@ float g_clientmodel_genericsendentity (entity to, float sf) 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 = g_clientmodel_setcolormaptoactivator; \ + self.use = g_clientmodel_use; \ InitializeEntity(self, g_clientmodel_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, g_clientmodel_genericsendentity); + Net_LinkEntity(self, true, 0, g_clientmodel_genericsendentity); \ + self.default_solid = sol; // non-solid model entities: void spawnfunc_misc_gamemodel() { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // model entity diff --git a/qcsrc/server/g_triggers.qc b/qcsrc/server/g_triggers.qc index 101e17677..6851f2942 100644 --- a/qcsrc/server/g_triggers.qc +++ b/qcsrc/server/g_triggers.qc @@ -103,9 +103,9 @@ void SUB_UseTargets() } if (s != "") { - // Flag to set antiwall state + // Flag to set func_clientwall state // 1 == deactivate, 2 == activate, 0 == do nothing - float aw_inactive = self.antiwall_flag; + float aw_inactive = self.clientwall_flag; for(t = world; (t = find(t, targetname, s)); ) if(t.use) { @@ -115,19 +115,16 @@ void SUB_UseTargets() } else { - if (t.classname == "func_antiwall") { + if (t.classname == "func_clientwall" || t.classname == "func_clientillusionary") { if (aw_inactive == 1) { t.inactive = 1; - if (!t.illusion) { - t.solid = SOLID_BSP; - } } else if (aw_inactive == 2) { t.inactive = 0; - if (t.illusion) { - t.solid = SOLID_NOT; - } else { - t.solid = SOLID_BSP; - } + } + if (t.inactive) { + t.solid = SOLID_NOT; + } else { + t.solid = t.default_solid; } } self = t; diff --git a/qcsrc/server/g_triggers.qh b/qcsrc/server/g_triggers.qh index 300a87a81..12b57cbf4 100644 --- a/qcsrc/server/g_triggers.qh +++ b/qcsrc/server/g_triggers.qh @@ -386,9 +386,7 @@ void spawnfunc_target_changelevel_use(); void spawnfunc_target_changelevel(); -.float antiwall_flag; // Variable to define what to do with func_antiwall +.float clientwall_flag; // Variable to define what to do with func_clientwall // 0 == do nothing, 1 == deactivate, 2 == activate -.float illusion; // If not 0, func_antiwall will be non-solid - #endif diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index 2f01d82e1..85e75cda9 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -59,7 +59,6 @@ t_quake.qc t_swamp.qc t_teleporters.qc waypointsprites.qc -antiwall.qc bot/bot.qc