X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fg_subs.qc;h=e9f9b3454e18ef0151812464e7ce7aabecabf6b9;hb=7c8995e3ccc4a2504891c7c52359e7817ebc25ea;hp=e3c2e1225bf18257ccc5a6f7ca869395a15775fe;hpb=ccff2fe4cfc13a8f7d1413f5c39261bb42b82c9d;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index e3c2e1225..e9f9b3454 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -1,4 +1,4 @@ -void SUB_Null() {}; +void SUB_Null() {} float SUB_True() { return 1; } float SUB_False() { return 0; } @@ -16,6 +16,9 @@ void spawnfunc_info_null (void) void setanim(entity e, vector anim, float looping, float override, float restart) { + if (!anim) + return; // no animation was given to us! We can't use this. + if (anim_x == e.animstate_startframe) if (anim_y == e.animstate_numframes) if (anim_z == e.animstate_framerate) @@ -38,7 +41,7 @@ void setanim(entity e, vector anim, float looping, float override, float restart e.animstate_override = override; e.frame = e.animstate_startframe; e.frame1time = servertime; -}; +} void updateanim(entity e) { @@ -53,31 +56,20 @@ void updateanim(entity e) } e.frame = e.animstate_startframe + bound(0, (time - e.animstate_starttime) * e.animstate_framerate, e.animstate_numframes - 1); //print(ftos(time), " -> ", ftos(e.frame), "\n"); -}; - -float animparseerror; -vector animparseline(float animfile) -{ - local string line; - local float c; - local vector anim; - if (animfile < 0) - return '0 1 2'; - line = fgets(animfile); - c = tokenize_console(line); - if (c < 3) +} + +vector animfixfps(entity e, vector a) +{ + // multi-frame anim: keep as-is + if(a_y == 1) { - animparseerror = TRUE; - return '0 1 2'; + float dur; + dur = frameduration(e.modelindex, a_x); + if(dur > 0) + a_z = 1.0 / dur; } - anim_x = stof(argv(0)); - anim_y = stof(argv(1)); - anim_z = stof(argv(2)); - // don't allow completely bogus values - if (anim_x < 0 || anim_y < 1 || anim_z < 0.001) - anim = '0 1 2'; - return anim; -}; + return a; +} /* ================== @@ -247,9 +239,11 @@ void SUB_CalcMove (vector tdest, float tspeed, void() func) return; } - // very short animations don't really show off the effect - // of controlled animation, so let's just use linear movement - if (traveltime < 0.15) + // 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; @@ -260,7 +254,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 + '0 0 1'); // where do we want to end? Offset to overshoot a bit. + 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; @@ -376,8 +370,8 @@ Additionally it moves players back into the past before the trace and restores t */ void tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag, float wz) { - local entity player; - local float oldsolid; + entity player; + float oldsolid; // check whether antilagged traces are enabled if (lag < 0.001) @@ -430,13 +424,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); } @@ -446,13 +440,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); } @@ -675,9 +669,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) @@ -733,7 +727,7 @@ void LODmodel_attach() } } - if(cvar("loddebug") < 0) + if(autocvar_loddebug < 0) { self.lodmodel1 = self.lodmodel2 = ""; // don't even initialize } @@ -764,6 +758,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 != "") @@ -773,10 +794,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() @@ -787,10 +805,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); } /* @@ -810,35 +825,31 @@ void SetMovedir() } self.angles = '0 0 0'; -}; +} 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; self.modelindex = 0; self.model = ""; -}; +} 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 // self.modelindex = 0; self.model = ""; -}; +} float InitMovingBrushTrigger() { @@ -853,4 +864,4 @@ float InitMovingBrushTrigger() return 0; } return 1; -}; +}