]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mapobjects/subs.qc
Use gender-neutral pronouns when referring to the player
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapobjects / subs.qc
index f9e50dcf8f19d819509c9c6a460050da0a120954..9c8eda61bb45f5232cd9fa6b50ca5904b8ba6678 100644 (file)
@@ -1,4 +1,5 @@
 #include "subs.qh"
+
 void SUB_NullThink(entity this) { }
 
 void SUB_CalcMoveDone(entity this);
@@ -8,7 +9,7 @@ void SUB_CalcAngleMoveDone(entity this);
 spawnfunc(info_null)
 {
        delete(this);
-       // if anything breaks, tell the mapper to fix his map! info_null is meant to remove itself immediately.
+       // if anything breaks, tell the mapper to fix their map! info_null is meant to remove itself immediately.
 }
 #endif
 
@@ -70,14 +71,16 @@ void SUB_SetFade_Think (entity this)
 ==================
 SUB_SetFade
 
-Fade 'ent' out when time >= 'when'
+Fade ent out when time >= vanish_time
 ==================
 */
-void SUB_SetFade (entity ent, float when, float fading_time)
+void SUB_SetFade(entity ent, float vanish_time, float fading_time)
 {
+       if (fading_time <= 0)
+               fading_time = 0.01;
        ent.fade_rate = 1/fading_time;
        setthink(ent, SUB_SetFade_Think);
-       ent.nextthink = when;
+       ent.nextthink = vanish_time;
 }
 
 /*
@@ -99,6 +102,12 @@ void SUB_CalcMoveDone(entity this)
                this.think1 (this);
 }
 
+void SUB_CalcMovePause(entity this)
+{
+       this.move_controller.animstate_starttime += frametime;
+       this.move_controller.animstate_endtime += frametime;
+}
+
 .float platmovetype_turn;
 void SUB_CalcMove_controller_think (entity this)
 {
@@ -166,7 +175,8 @@ void SUB_CalcMove_controller_setbezier (entity controller, vector org, vector co
        // 2 * control * t - 2 * control * t * t + destin * t * t
        // 2 * control * t + (destin - 2 * control) * t * t
 
-       setorigin(controller, org);
+       //setorigin(controller, org); // don't link to the world
+       controller.origin = org;
        control -= org;
        destin -= org;
 
@@ -181,7 +191,8 @@ void SUB_CalcMove_controller_setlinear (entity controller, vector org, vector de
        // 2 * control * t - 2 * control * t * t + destin * t * t
        // 2 * control * t + (destin - 2 * control) * t * t
 
-       setorigin(controller, org);
+       //setorigin(controller, org); // don't link to the world
+       controller.origin = org;
        destin -= org;
 
        controller.destvec = destin; // end point
@@ -229,7 +240,8 @@ void SUB_CalcMove_Bezier (entity this, vector tcontrol, vector tdest, float tspe
        {
                delete(this.move_controller);
        }
-       controller = new(SUB_CalcMove_controller);
+       controller = new_pure(SUB_CalcMove_controller);
+       set_movetype(controller, MOVETYPE_NONE); // mark the entity as physics driven so that thinking is handled by QC
        controller.owner = this;
        this.move_controller = controller;
        controller.platmovetype = this.platmovetype;
@@ -287,7 +299,7 @@ void SUB_CalcMove (entity this, vector tdest, float tspeedtype, float tspeed, vo
        // 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)
+       // The only currently implemented alternative movement is linear (value 1)
        if (traveltime < 0.15 || (this.platmovetype_start == 1 && this.platmovetype_end == 1)) // is this correct?
        {
                this.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division
@@ -393,16 +405,16 @@ void ApplyMinMaxScaleAngles(entity e)
                e.mins_y = -e.maxs.x;
        }
        if(e.scale)
-               setsize(e, e.mins * e.scale, e.maxs * e.scale);
+               setsize(e, RoundPerfectVector(e.mins * e.scale), RoundPerfectVector(e.maxs * e.scale));
        else
                setsize(e, e.mins, e.maxs);
 }
 
-void SetBrushEntityModel(entity this)
+void SetBrushEntityModel(entity this, bool with_lod)
 {
-       if(this.model != "")
-       {
-               precache_model(this.model);
+       if(this.model != "")
+       {
+               precache_model(this.model);
                if(this.mins != '0 0 0' || this.maxs != '0 0 0')
                {
                        vector mi = this.mins;
@@ -412,27 +424,12 @@ void SetBrushEntityModel(entity this)
                }
                else
                        _setmodel(this, this.model); // no precision needed
-               InitializeEntity(this, LODmodel_attach, INITPRIO_FINDTARGET);
-       }
-       setorigin(this, this.origin);
-       ApplyMinMaxScaleAngles(this);
-}
+               if(with_lod)
+                       InitializeEntity(this, LODmodel_attach, INITPRIO_FINDTARGET);
 
-void SetBrushEntityModelNoLOD(entity this)
-{
-       if(this.model != "")
-       {
-               precache_model(this.model);
-               if(this.mins != '0 0 0' || this.maxs != '0 0 0')
-               {
-                       vector mi = this.mins;
-                       vector ma = this.maxs;
-                       _setmodel(this, this.model); // no precision needed
-                       setsize(this, mi, ma);
-               }
-               else
-                       _setmodel(this, this.model); // no precision needed
-       }
+               if(endsWith(this.model, ".obj")) // WORKAROUND: darkplaces currently rotates .obj models on entities incorrectly, we need to add 180 degrees to the Y axis
+                       this.angles_y = anglemods(this.angles_y - 180);
+       }
        setorigin(this, this.origin);
        ApplyMinMaxScaleAngles(this);
 }
@@ -553,7 +550,7 @@ void InitTrigger(entity this)
 // to mean no restrictions, so use a yaw of 360 instead.
        SetMovedir(this);
        this.solid = SOLID_TRIGGER;
-       SetBrushEntityModelNoLOD(this);
+       SetBrushEntityModel(this, false);
        set_movetype(this, MOVETYPE_NONE);
        this.modelindex = 0;
        this.model = "";
@@ -565,7 +562,7 @@ void InitSolidBSPTrigger(entity this)
 // to mean no restrictions, so use a yaw of 360 instead.
        SetMovedir(this);
        this.solid = SOLID_BSP;
-       SetBrushEntityModelNoLOD(this);
+       SetBrushEntityModel(this, false);
        set_movetype(this, MOVETYPE_NONE); // why was this PUSH? -div0
 //     this.modelindex = 0;
        this.model = "";
@@ -576,7 +573,7 @@ bool InitMovingBrushTrigger(entity this)
 // 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.
        this.solid = SOLID_BSP;
-       SetBrushEntityModel(this);
+       SetBrushEntityModel(this, true);
        set_movetype(this, MOVETYPE_PUSH);
        if(this.modelindex == 0)
        {