X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_subs.qc;h=22c8931bef8813bc43536ab950b281b1a7def223;hb=6f94b6750eadebc8d9929bcdb14e37ac5a8514a0;hp=180dee305a320d98771e93824db928aca539e6e1;hpb=49205b35c27f6f7bb9e476aa7759dbb6661a23b6;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index 180dee305..22c8931be 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -188,7 +188,7 @@ void SUB_CalcMove_controller_think (void) vector nextpos; if(time < self.animstate_endtime) { delta = self.destvec; - nexttick = time + 0.1; + nexttick = time + sys_frametime; if(nexttick < self.animstate_endtime) { traveltime = self.animstate_endtime - self.animstate_starttime; @@ -200,12 +200,11 @@ void SUB_CalcMove_controller_think (void) nextpos = self.origin + (delta * phasepos); veloc = nextpos - self.owner.origin; - veloc = veloc * 10; // so it arrives in 0.1 seconds + veloc = veloc * (1 / sys_frametime); // so it arrives for the next frame } else { veloc = self.finaldest - self.owner.origin; - veloc = veloc * 10; // so it arrives in 0.1 seconds - self.nextthink = self.animstate_endtime; + veloc = veloc * (1 / sys_frametime); // so it arrives for the next frame } self.owner.velocity = veloc; self.nextthink = nexttick; @@ -248,9 +247,11 @@ void SUB_CalcMove (vector tdest, float tspeed, void() func) return; } - // the controller only thinks every 0.1 seconds, so very short - // animations should just use the traditional movement - if (traveltime < 0.3) + // Very short animations don't really show off the effect + // of controlled animation, so let's just use linear movement. + // Alternatively entities can choose to specify non-controlled movement. + // The only currently implemented alternative movement is linear (value 1) + if (traveltime < 0.15 || self.platmovetype == 1) { self.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division self.nextthink = self.ltime + traveltime; @@ -261,7 +262,7 @@ void SUB_CalcMove (vector tdest, float tspeed, void() func) controller.classname = "SUB_CalcMove_controller"; controller.owner = self; controller.origin = self.origin; // starting point - controller.finaldest = tdest; // where do we want to end? + controller.finaldest = (tdest + '0 0 0.125'); // where do we want to end? Offset to overshoot a bit. controller.destvec = delta; controller.animstate_starttime = time; controller.animstate_endtime = time + traveltime; @@ -431,13 +432,13 @@ void traceline_antilag_force (entity source, vector v1, vector v2, float nomonst } void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag) { - if (cvar("g_antilag") != 2 || source.cvar_cl_noantilag) + if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag) lag = 0; traceline_antilag_force(source, v1, v2, nomonst, forent, lag); } void tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag) { - if (cvar("g_antilag") != 2 || source.cvar_cl_noantilag) + if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag) lag = 0; tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, FALSE); } @@ -447,13 +448,13 @@ void WarpZone_traceline_antilag_force (entity source, vector v1, vector v2, floa } void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag) { - if (cvar("g_antilag") != 2 || source.cvar_cl_noantilag) + if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag) lag = 0; WarpZone_traceline_antilag_force(source, v1, v2, nomonst, forent, lag); } void WarpZone_tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag) { - if (cvar("g_antilag") != 2 || source.cvar_cl_noantilag) + if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag) lag = 0; tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, TRUE); } @@ -676,9 +677,9 @@ float LOD_customize() { float d; - if(cvar("loddebug")) + if(autocvar_loddebug) { - d = cvar("loddebug"); + d = autocvar_loddebug; if(d == 1) self.modelindex = self.lodmodelindex0; else if(d == 2 || !self.lodmodelindex2) @@ -734,7 +735,7 @@ void LODmodel_attach() } } - if(cvar("loddebug") < 0) + if(autocvar_loddebug < 0) { self.lodmodel1 = self.lodmodel2 = ""; // don't even initialize } @@ -765,6 +766,33 @@ void LODmodel_attach() SetCustomizer(self, LOD_customize, LOD_uncustomize); } +void ApplyMinMaxScaleAngles(entity e) +{ + if(e.angles_x != 0 || e.angles_z != 0 || self.avelocity_x != 0 || self.avelocity_z != 0) // "weird" rotation + { + e.maxs = '1 1 1' * vlen( + '1 0 0' * max(-e.mins_x, e.maxs_x) + + '0 1 0' * max(-e.mins_y, e.maxs_y) + + '0 0 1' * max(-e.mins_z, e.maxs_z) + ); + e.mins = -e.maxs; + } + else if(e.angles_y != 0 || self.avelocity_y != 0) // yaw only is a bit better + { + e.maxs_x = vlen( + '1 0 0' * max(-e.mins_x, e.maxs_x) + + '0 1 0' * max(-e.mins_y, e.maxs_y) + ); + e.maxs_y = e.maxs_x; + e.mins_x = -e.maxs_x; + e.mins_y = -e.maxs_x; + } + if(e.scale) + setsize(e, e.mins * e.scale, e.maxs * e.scale); + else + setsize(e, e.mins, e.maxs); +} + void SetBrushEntityModel() { if(self.model != "") @@ -774,10 +802,7 @@ void SetBrushEntityModel() InitializeEntity(self, LODmodel_attach, INITPRIO_FINDTARGET); } setorigin(self, self.origin); - if(self.scale) - setsize(self, self.mins * self.scale, self.maxs * self.scale); - else - setsize(self, self.mins, self.maxs); + ApplyMinMaxScaleAngles(self); } void SetBrushEntityModelNoLOD() @@ -788,10 +813,7 @@ void SetBrushEntityModelNoLOD() setmodel(self, self.model); // no precision needed } setorigin(self, self.origin); - if(self.scale) - setsize(self, self.mins * self.scale, self.maxs * self.scale); - else - setsize(self, self.mins, self.maxs); + ApplyMinMaxScaleAngles(self); } /* @@ -817,9 +839,7 @@ void InitTrigger() { // trigger angles are used for one-way touches. An angle of 0 is assumed // to mean no restrictions, so use a yaw of 360 instead. - if (self.movedir == '0 0 0') - if (self.angles != '0 0 0') - SetMovedir (); + SetMovedir (); self.solid = SOLID_TRIGGER; SetBrushEntityModel(); self.movetype = MOVETYPE_NONE; @@ -831,9 +851,7 @@ void InitSolidBSPTrigger() { // trigger angles are used for one-way touches. An angle of 0 is assumed // to mean no restrictions, so use a yaw of 360 instead. - if (self.movedir == '0 0 0') - if (self.angles != '0 0 0') - SetMovedir (); + SetMovedir (); self.solid = SOLID_BSP; SetBrushEntityModel(); self.movetype = MOVETYPE_NONE; // why was this PUSH? -div0