]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Cleanse steerlib and movelib of self
authorMario <mario@smbclan.net>
Sat, 21 May 2016 23:10:40 +0000 (09:10 +1000)
committerMario <mario@smbclan.net>
Sat, 21 May 2016 23:10:40 +0000 (09:10 +1000)
qcsrc/common/physics/movelib.qc
qcsrc/common/physics/movelib.qh
qcsrc/common/turrets/turret/ewheel.qc
qcsrc/common/turrets/turret/walker.qc
qcsrc/server/mutators/events.qh
qcsrc/server/steerlib.qc
qcsrc/server/steerlib.qh
qcsrc/server/sv_main.qc
qcsrc/server/t_quake.qc

index a27b8666eedf0a716c4f5743dd844bdfd2593c76..cfdcbfd14700262db5e3911b95c83107e4427c45 100644 (file)
@@ -5,23 +5,23 @@
 
 /**
     Simulate drag
-    self.velocity = movelib_dragvec(self.velocity,0.02,0.5);
+    this.velocity = movelib_dragvec(this.velocity,0.02,0.5);
 **/
-vector movelib_dragvec(float drag, float exp_)
-{SELFPARAM();
+vector movelib_dragvec(entity this, float drag, float exp_)
+{
     float lspeed,ldrag;
 
-    lspeed = vlen(self.velocity);
+    lspeed = vlen(this.velocity);
     ldrag = lspeed * drag;
     ldrag = ldrag * (drag * exp_);
     ldrag = 1 - (ldrag / lspeed);
 
-    return self.velocity * ldrag;
+    return this.velocity * ldrag;
 }
 
 /**
     Simulate drag
-    self.velocity *= movelib_dragflt(somespeed,0.01,0.7);
+    this.velocity *= movelib_dragflt(somespeed,0.01,0.7);
 **/
 float movelib_dragflt(float fspeed,float drag,float exp_)
 {
@@ -37,70 +37,70 @@ float movelib_dragflt(float fspeed,float drag,float exp_)
 /**
     Do a inertia simulation based on velocity.
     Basicaly, this allows you to simulate loss of steering with higher speed.
-    self.velocity = movelib_inertmove_byspeed(self.velocity,newvel,1000,0.1,0.9);
+    this.velocity = movelib_inertmove_byspeed(this.velocity,newvel,1000,0.1,0.9);
 **/
-vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,float oldmax)
-{SELFPARAM();
+vector movelib_inertmove_byspeed(entity this, vector vel_new, float vel_max,float newmin,float oldmax)
+{
     float influense;
 
-    influense = vlen(self.velocity) * (1 / vel_max);
+    influense = vlen(this.velocity) * (1 / vel_max);
 
     influense = bound(newmin,influense,oldmax);
 
-    return (vel_new * (1 - influense)) + (self.velocity * influense);
+    return (vel_new * (1 - influense)) + (this.velocity * influense);
 }
 
-vector movelib_inertmove(vector new_vel,float new_bias)
-{SELFPARAM();
-    return new_vel * new_bias + self.velocity * (1-new_bias);
+vector movelib_inertmove(entity this, vector new_vel,float new_bias)
+{
+    return new_vel * new_bias + this.velocity * (1-new_bias);
 }
 
-void movelib_move(vector force,float max_velocity,float drag,float theMass,float breakforce)
-{SELFPARAM();
+void movelib_move(entity this, vector force,float max_velocity,float drag,float theMass,float breakforce)
+{
     float deltatime;
     float acceleration;
     float mspeed;
     vector breakvec;
 
-    deltatime = time - self.movelib_lastupdate;
+    deltatime = time - this.movelib_lastupdate;
     if (deltatime > 0.15) deltatime = 0;
-    self.movelib_lastupdate = time;
+    this.movelib_lastupdate = time;
     if (!deltatime) return;
 
-    mspeed = vlen(self.velocity);
+    mspeed = vlen(this.velocity);
 
     if (theMass)
         acceleration = vlen(force) / theMass;
     else
         acceleration = vlen(force);
 
-    if (IS_ONGROUND(self))
+    if (IS_ONGROUND(this))
     {
         if (breakforce)
         {
-            breakvec = (normalize(self.velocity) * (breakforce / theMass) * deltatime);
-            self.velocity = self.velocity - breakvec;
+            breakvec = (normalize(this.velocity) * (breakforce / theMass) * deltatime);
+            this.velocity = this.velocity - breakvec;
         }
 
-        self.velocity = self.velocity + force * (acceleration * deltatime);
+        this.velocity = this.velocity + force * (acceleration * deltatime);
     }
 
     if (drag)
-        self.velocity = movelib_dragvec(drag, 1);
+        this.velocity = movelib_dragvec(this, drag, 1);
 
-    if (self.waterlevel > 1)
+    if (this.waterlevel > 1)
     {
-        self.velocity = self.velocity + force * (acceleration * deltatime);
-        self.velocity = self.velocity + '0 0 0.05' * autocvar_sv_gravity * deltatime;
+        this.velocity = this.velocity + force * (acceleration * deltatime);
+        this.velocity = this.velocity + '0 0 0.05' * autocvar_sv_gravity * deltatime;
     }
     else
-        self.velocity = self.velocity + '0 0 -1' * autocvar_sv_gravity * deltatime;
+        this.velocity = this.velocity + '0 0 -1' * autocvar_sv_gravity * deltatime;
 
-    mspeed = vlen(self.velocity);
+    mspeed = vlen(this.velocity);
 
     if (max_velocity)
         if (mspeed > max_velocity)
-            self.velocity = normalize(self.velocity) * (mspeed - 50);//* max_velocity;
+            this.velocity = normalize(this.velocity) * (mspeed - 50);//* max_velocity;
 }
 
 /*
@@ -112,17 +112,17 @@ void movelib_move(vector force,float max_velocity,float drag,float theMass,float
 .float buoyancy;
 float movelib_deltatime;
 
-void movelib_startupdate()
+void movelib_startupdate(entity this)
 {
-    movelib_deltatime = time - self.movelib_lastupdate;
+    movelib_deltatime = time - this.movelib_lastupdate;
 
     if (movelib_deltatime > 0.5)
         movelib_deltatime = 0;
 
-    self.movelib_lastupdate = time;
+    this.movelib_lastupdate = time;
 }
 
-void movelib_update(vector dir,float force)
+void movelib_update(entity this, vector dir,float force)
 {
     vector acceleration;
     float old_speed;
@@ -135,30 +135,30 @@ void movelib_update(vector dir,float force)
 
     if(!movelib_deltatime)
         return;
-    v_z = self.velocity_z;
-    old_speed    = vlen(self.velocity);
-    old_dir      = normalize(self.velocity);
+    v_z = this.velocity_z;
+    old_speed    = vlen(this.velocity);
+    old_dir      = normalize(this.velocity);
 
-    //ggravity      =  (autocvar_sv_gravity / self.mass) * '0 0 100';
-    acceleration =  (force / self.mass) * dir;
-    //acceleration -= old_dir * (old_speed / self.mass);
+    //ggravity      =  (autocvar_sv_gravity / this.mass) * '0 0 100';
+    acceleration =  (force / this.mass) * dir;
+    //acceleration -= old_dir * (old_speed / this.mass);
     acceleration -= ggravity;
 
-    if(self.waterlevel > 1)
+    if(this.waterlevel > 1)
     {
-        ffriction = self.water_friction;
-        acceleration += self.buoyancy * '0 0 1';
+        ffriction = this.water_friction;
+        acceleration += this.buoyancy * '0 0 1';
     }
     else
-        if(IS_ONGROUND(self))
-            ffriction = self.ground_friction;
+        if(IS_ONGROUND(this))
+            ffriction = this.ground_friction;
         else
-            ffriction = self.air_friction;
+            ffriction = this.air_friction;
 
     acceleration *= ffriction;
-    //self.velocity = self.velocity * (ffriction * movelib_deltatime);
-    self.velocity += acceleration * movelib_deltatime;
-    self.velocity_z = v_z;
+    //this.velocity = this.velocity * (ffriction * movelib_deltatime);
+    this.velocity += acceleration * movelib_deltatime;
+    this.velocity_z = v_z;
 
 }
 */
index 90ea4b4160e12d79ce24e4b00e60fc9582c424f0..a64651b30e092dd2939cb513bcab941744d0ba35 100644 (file)
@@ -8,7 +8,7 @@
     Simulate drag
     self.velocity = movelib_dragvec(self.velocity,0.02,0.5);
 **/
-vector movelib_dragvec(float drag, float exp_);
+vector movelib_dragvec(entity this, float drag, float exp_);
 
 /**
     Simulate drag
@@ -21,12 +21,12 @@ float movelib_dragflt(float fspeed,float drag,float exp_);
     Basicaly, this allows you to simulate loss of steering with higher speed.
     self.velocity = movelib_inertmove_byspeed(self.velocity,newvel,1000,0.1,0.9);
 **/
-vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,float oldmax);
+vector movelib_inertmove_byspeed(entity this, vector vel_new, float vel_max, float newmin, float oldmax);
 
-vector movelib_inertmove(vector new_vel,float new_bias);
+vector movelib_inertmove(entity this, vector new_vel, float new_bias);
 
 .float  movelib_lastupdate;
-void movelib_move(vector force,float max_velocity,float drag,float theMass,float breakforce);
+void movelib_move(entity this, vector force, float max_velocity, float drag, float theMass, float breakforce);
 
 /*
 void movelib_move_simple(vector newdir,float velo,float blendrate)
index d11c0867b044696b651990ce5450360f2a62dc90..40603cca0defdf6a9aa3e8599a16434f83e3fda3 100644 (file)
@@ -83,7 +83,7 @@ void ewheel_move_enemy()
 {SELFPARAM();
     float newframe;
 
-    self.steerto = steerlib_arrive(self.enemy.origin,self.target_range_optimal);
+    self.steerto = steerlib_arrive(self, self.enemy.origin,self.target_range_optimal);
 
     self.moveto  = self.origin + self.steerto * 128;
 
index ebca240d0b6f9865a3de673cba0309f2d31042cb..afe85bf8ce5ca1c177181381762d072a76912c02 100644 (file)
@@ -161,7 +161,7 @@ void walker_rocket_think()
     if (self.enemy)
     {
         itime = max(edist / m_speed, 1);
-        newdir = steerlib_pull(self.enemy.origin + self.tur_shotorg);
+        newdir = steerlib_pull(self, self.enemy.origin + self.tur_shotorg);
     }
     else
         newdir  = normalize(self.velocity);
@@ -186,7 +186,7 @@ void walker_rocket_loop3()
         return;
     }
 
-    newdir = steerlib_pull(self.tur_shotorg);
+    newdir = steerlib_pull(self, self.tur_shotorg);
     WALKER_ROCKET_MOVE;
 
     self.angles = vectoangles(self.velocity);
@@ -211,7 +211,7 @@ void walker_rocket_loop2()
         return;
     }
 
-    newdir = steerlib_pull(self.tur_shotorg);
+    newdir = steerlib_pull(self, self.tur_shotorg);
     WALKER_ROCKET_MOVE;
 }
 
index fac7249c8b2d241ba57c3eee2fa7fee1a72891c1..ad97997e2f53c2f4c0d61900688d9a6416c6e84c 100644 (file)
@@ -195,7 +195,10 @@ bool ret_bool;
 MUTATOR_HOOKABLE(Turret_CheckFire, EV_Turret_CheckFire);
 
 /** return error to prevent entity spawn, or modify the entity */
-MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_NO_ARGS);
+#define EV_OnEntityPreSpawn(i, o) \
+    /** turret */ i(entity, __self) \
+    /**/
+MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_OnEntityPreSpawn);
 
 /** runs in the event loop for players; is called for ALL player entities, also bots, also the dead, or spectators */
 MUTATOR_HOOKABLE(PlayerPreThink, EV_NO_ARGS);
index 8491000918fb497be97e8849c71a29eabaf2bc16..0389efa37c47337f5236f6d3feebfcf09ed107cd 100644 (file)
@@ -7,44 +7,44 @@
 /**
     Uniform pull towards a point
 **/
-vector steerlib_pull(vector point)
-{SELFPARAM();
-    return normalize(point - self.origin);
+vector steerlib_pull(entity this, vector point)
+{
+    return normalize(point - this.origin);
 }
 
 /**
     Uniform push from a point
 **/
-#define steerlib_push(point) normalize(self.origin - point)
+#define steerlib_push(ent,point) normalize(ent.origin - point)
 /*
-vector steerlib_push(vector point)
+vector steerlib_push(entity this, vector point)
 {
-    return normalize(self.origin - point);
+    return normalize(this.origin - point);
 }
 */
 /**
     Pull toward a point, The further away, the stronger the pull.
 **/
-vector steerlib_arrive(vector point,float maximal_distance)
-{SELFPARAM();
+vector steerlib_arrive(entity this, vector point, float maximal_distance)
+{
     float distance;
     vector direction;
 
-    distance = bound(0.001,vlen(self.origin - point),maximal_distance);
-    direction = normalize(point - self.origin);
+    distance = bound(0.001,vlen(this.origin - point),maximal_distance);
+    direction = normalize(point - this.origin);
     return  direction * (distance / maximal_distance);
 }
 
 /**
     Pull toward a point increasing the pull the closer we get
 **/
-vector steerlib_attract(vector point, float maximal_distance)
-{SELFPARAM();
+vector steerlib_attract(entity this, vector point, float maximal_distance)
+{
     float distance;
     vector direction;
 
-    distance = bound(0.001,vlen(self.origin - point),maximal_distance);
-    direction = normalize(point - self.origin);
+    distance = bound(0.001,vlen(this.origin - point),maximal_distance);
+    direction = normalize(point - this.origin);
 
     return  direction * (1-(distance / maximal_distance));
 }
@@ -73,12 +73,12 @@ vector steerlib_attract2(vector point, float maximal_distance,float min_influens
     float i_target,i_current;
 
     if(!distance)
-        distance = vlen(self.origin - point);
+        distance = vlen(this.origin - point);
 
     distance = bound(0.001,distance,maximal_distance);
 
-    target_direction = normalize(point - self.origin);
-    current_direction = normalize(self.velocity);
+    target_direction = normalize(point - this.origin);
+    current_direction = normalize(this.velocity);
 
     i_target = bound(min_influense,(1-(distance / maximal_distance)),max_influense);
     i_current = 1 - i_target;
@@ -97,13 +97,13 @@ vector steerlib_attract2(vector point, float maximal_distance,float min_influens
 /**
     Move away from a point.
 **/
-vector steerlib_repell(vector point,float maximal_distance)
-{SELFPARAM();
+vector steerlib_repell(entity this, vector point,float maximal_distance)
+{
     float distance;
     vector direction;
 
-    distance = bound(0.001,vlen(self.origin - point),maximal_distance);
-    direction = normalize(self.origin - point);
+    distance = bound(0.001,vlen(this.origin - point),maximal_distance);
+    direction = normalize(this.origin - point);
 
     return  direction * (1-(distance / maximal_distance));
 }
@@ -111,21 +111,21 @@ vector steerlib_repell(vector point,float maximal_distance)
 /**
     Try to keep at ideal_distance away from point
 **/
-vector steerlib_standoff(vector point,float ideal_distance)
-{SELFPARAM();
+vector steerlib_standoff(entity this, vector point,float ideal_distance)
+{
     float distance;
     vector direction;
 
-    distance = vlen(self.origin - point);
+    distance = vlen(this.origin - point);
 
 
     if(distance < ideal_distance)
     {
-        direction = normalize(self.origin - point);
+        direction = normalize(this.origin - point);
         return direction * (distance / ideal_distance);
     }
 
-    direction = normalize(point - self.origin);
+    direction = normalize(point - this.origin);
     return direction * (ideal_distance / distance);
 
 }
@@ -134,12 +134,12 @@ vector steerlib_standoff(vector point,float ideal_distance)
     A random heading in a forward halfcicrle
 
     use like:
-    self.target = steerlib_wander(256,32,self.target)
+    this.target = steerlib_wander(256,32,this.target)
 
     where range is the cicrle radius and tresh is how close we need to be to pick a new heading.
 **/
-vector steerlib_wander(float range,float tresh,vector oldpoint)
-{SELFPARAM();
+vector steerlib_wander(entity this, float range, float tresh, vector oldpoint)
+{
     vector wander_point;
     wander_point = v_forward - oldpoint;
 
@@ -148,20 +148,20 @@ vector steerlib_wander(float range,float tresh,vector oldpoint)
 
     range = bound(0,range,1);
 
-    wander_point = self.origin + v_forward * 128;
+    wander_point = this.origin + v_forward * 128;
     wander_point = wander_point + randomvec() * (range * 128) - randomvec() * (range * 128);
 
-    return normalize(wander_point - self.origin);
+    return normalize(wander_point - this.origin);
 }
 
 /**
     Dodge a point. dont work to well.
 **/
-vector steerlib_dodge(vector point,vector dodge_dir,float min_distance)
-{SELFPARAM();
+vector steerlib_dodge(entity this, vector point, vector dodge_dir, float min_distance)
+{
     float distance;
 
-    distance = max(vlen(self.origin - point),min_distance);
+    distance = max(vlen(this.origin - point),min_distance);
     if (min_distance < distance)
         return '0 0 0';
 
@@ -173,21 +173,21 @@ vector steerlib_dodge(vector point,vector dodge_dir,float min_distance)
     Group will move towards the unified direction while keeping close to eachother.
 **/
 .float flock_id;
-vector steerlib_flock(float _radius, float standoff,float separation_force,float flock_force)
-{SELFPARAM();
+vector steerlib_flock(entity this, float _radius, float standoff,float separation_force,float flock_force)
+{
     entity flock_member;
     vector push = '0 0 0', pull = '0 0 0';
     float ccount = 0;
 
-    flock_member = findradius(self.origin, _radius);
+    flock_member = findradius(this.origin, _radius);
     while(flock_member)
     {
-        if(flock_member != self)
-        if(flock_member.flock_id == self.flock_id)
+        if(flock_member != this)
+        if(flock_member.flock_id == this.flock_id)
         {
             ++ccount;
-            push = push + (steerlib_repell(flock_member.origin,standoff) * separation_force);
-            pull = pull + (steerlib_arrive(flock_member.origin + flock_member.velocity, _radius) * flock_force);
+            push = push + (steerlib_repell(this, flock_member.origin,standoff) * separation_force);
+            pull = pull + (steerlib_arrive(this, flock_member.origin + flock_member.velocity, _radius) * flock_force);
         }
         flock_member = flock_member.chain;
     }
@@ -199,21 +199,21 @@ vector steerlib_flock(float _radius, float standoff,float separation_force,float
     Group will move towards the unified direction while keeping close to eachother.
     xy only version (for ground movers).
 **/
-vector steerlib_flock2d(float _radius, float standoff,float separation_force,float flock_force)
-{SELFPARAM();
+vector steerlib_flock2d(entity this, float _radius, float standoff,float separation_force,float flock_force)
+{
     entity flock_member;
     vector push = '0 0 0', pull = '0 0 0';
     float ccount = 0;
 
-    flock_member = findradius(self.origin,_radius);
+    flock_member = findradius(this.origin,_radius);
     while(flock_member)
     {
-        if(flock_member != self)
-        if(flock_member.flock_id == self.flock_id)
+        if(flock_member != this)
+        if(flock_member.flock_id == this.flock_id)
         {
             ++ccount;
-            push = push + (steerlib_repell(flock_member.origin, standoff) * separation_force);
-            pull = pull + (steerlib_arrive(flock_member.origin + flock_member.velocity, _radius) * flock_force);
+            push = push + (steerlib_repell(this, flock_member.origin, standoff) * separation_force);
+            pull = pull + (steerlib_arrive(this, flock_member.origin + flock_member.velocity, _radius) * flock_force);
         }
         flock_member = flock_member.chain;
     }
@@ -230,27 +230,27 @@ vector steerlib_flock2d(float _radius, float standoff,float separation_force,flo
 
     This results in a aligned movement (?!) much like flocking.
 **/
-vector steerlib_swarm(float _radius, float standoff,float separation_force,float swarm_force)
-{SELFPARAM();
+vector steerlib_swarm(entity this, float _radius, float standoff,float separation_force,float swarm_force)
+{
     entity swarm_member;
     vector force = '0 0 0', center = '0 0 0';
     float ccount = 0;
 
-    swarm_member = findradius(self.origin,_radius);
+    swarm_member = findradius(this.origin,_radius);
 
     while(swarm_member)
     {
-        if(swarm_member.flock_id == self.flock_id)
+        if(swarm_member.flock_id == this.flock_id)
         {
             ++ccount;
             center = center + swarm_member.origin;
-            force = force + (steerlib_repell(swarm_member.origin,standoff) * separation_force);
+            force = force + (steerlib_repell(this, swarm_member.origin,standoff) * separation_force);
         }
         swarm_member = swarm_member.chain;
     }
 
     center = center * (1 / ccount);
-    force = force + (steerlib_arrive(center,_radius) * swarm_force);
+    force = force + (steerlib_arrive(this, center,_radius) * swarm_force);
 
     return force;
 }
@@ -260,8 +260,8 @@ vector steerlib_swarm(float _radius, float standoff,float separation_force,float
     Run four tracelines in a forward funnel, bias each diretion negative if something is found there.
     You need to call makevectors() (or equivalent) before this function to set v_forward and v_right
 **/
-vector steerlib_traceavoid(float pitch,float length)
-{SELFPARAM();
+vector steerlib_traceavoid(entity this, float pitch,float length)
+{
     vector vup_left,vup_right,vdown_left,vdown_right;
     float fup_left,fup_right,fdown_left,fdown_right;
     vector upwish,downwish,leftwish,rightwish;
@@ -272,28 +272,28 @@ vector steerlib_traceavoid(float pitch,float length)
     v_down = v_up * -1;
 
     vup_left = (v_forward + (v_left * pitch + v_up * pitch)) * length;
-    traceline(self.origin, self.origin +  vup_left,MOVE_NOMONSTERS,self);
+    traceline(this.origin, this.origin +  vup_left,MOVE_NOMONSTERS,this);
     fup_left = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     vup_right = (v_forward + (v_right * pitch + v_up * pitch)) * length;
-    traceline(self.origin,self.origin + vup_right ,MOVE_NOMONSTERS,self);
+    traceline(this.origin,this.origin + vup_right ,MOVE_NOMONSTERS,this);
     fup_right = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     vdown_left = (v_forward + (v_left * pitch + v_down * pitch)) * length;
-    traceline(self.origin,self.origin + vdown_left,MOVE_NOMONSTERS,self);
+    traceline(this.origin,this.origin + vdown_left,MOVE_NOMONSTERS,this);
     fdown_left = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     vdown_right = (v_forward + (v_right * pitch + v_down * pitch)) * length;
-    traceline(self.origin,self.origin + vdown_right,MOVE_NOMONSTERS,self);
+    traceline(this.origin,this.origin + vdown_right,MOVE_NOMONSTERS,this);
     fdown_right = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
     upwish    = v_up    * (fup_left   + fup_right);
     downwish  = v_down  * (fdown_left + fdown_right);
     leftwish  = v_left  * (fup_left   + fdown_left);
@@ -307,8 +307,8 @@ vector steerlib_traceavoid(float pitch,float length)
     Steer towards the direction least obstructed.
     Run tracelines in a forward trident, bias each direction negative if something is found there.
 **/
-vector steerlib_traceavoid_flat(float pitch, float length, vector vofs)
-{SELFPARAM();
+vector steerlib_traceavoid_flat(entity this, float pitch, float length, vector vofs)
+{
     vector vt_left, vt_right,vt_front;
     float f_left, f_right,f_front;
     vector leftwish, rightwish,frontwish, v_left;
@@ -317,20 +317,20 @@ vector steerlib_traceavoid_flat(float pitch, float length, vector vofs)
 
 
     vt_front = v_forward * length;
-    traceline(self.origin + vofs, self.origin + vofs + vt_front,MOVE_NOMONSTERS,self);
+    traceline(this.origin + vofs, this.origin + vofs + vt_front,MOVE_NOMONSTERS,this);
     f_front = trace_fraction;
 
     vt_left = (v_forward + (v_left * pitch)) * length;
-    traceline(self.origin + vofs, self.origin + vofs + vt_left,MOVE_NOMONSTERS,self);
+    traceline(this.origin + vofs, this.origin + vofs + vt_left,MOVE_NOMONSTERS,this);
     f_left = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     vt_right = (v_forward + (v_right * pitch)) * length;
-    traceline(self.origin + vofs, self.origin + vofs + vt_right ,MOVE_NOMONSTERS,self);
+    traceline(this.origin + vofs, this.origin + vofs + vt_right ,MOVE_NOMONSTERS,this);
     f_right = trace_fraction;
 
-    //te_lightning1(world,self.origin, trace_endpos);
+    //te_lightning1(world,this.origin, trace_endpos);
 
     leftwish  = v_left    * f_left;
     rightwish = v_right   * f_right;
@@ -379,15 +379,15 @@ float beamsweep_badpoint(vector point,float waterok)
 }
 
 //#define BEAMSTEER_VISUAL
-float beamsweep(vector from, vector dir,float length, float step,float step_up, float step_down)
-{SELFPARAM();
+float beamsweep(entity this, vector from, vector dir,float length, float step,float step_up, float step_down)
+{
     float i;
     vector a,b,u,d;
 
     u = '0 0 1' * step_up;
     d = '0 0 1' * step_down;
 
-    traceline(from + u, from - d,MOVE_NORMAL,self);
+    traceline(from + u, from - d,MOVE_NORMAL,this);
     if(trace_fraction == 1.0)
         return 0;
 
@@ -399,11 +399,11 @@ float beamsweep(vector from, vector dir,float length, float step,float step_up,
     {
 
         b = a + dir * step;
-        tracebox(a + u,'-4 -4 -4','4 4 4', b + u,MOVE_NORMAL,self);
+        tracebox(a + u,'-4 -4 -4','4 4 4', b + u,MOVE_NORMAL,this);
         if(trace_fraction != 1.0)
             return i / length;
 
-        traceline(b + u, b - d,MOVE_NORMAL,self);
+        traceline(b + u, b - d,MOVE_NORMAL,this);
         if(trace_fraction == 1.0)
             return i / length;
 
@@ -419,8 +419,8 @@ float beamsweep(vector from, vector dir,float length, float step,float step_up,
     return 1;
 }
 
-vector steerlib_beamsteer(vector dir, float length, float step, float step_up, float step_down)
-{SELFPARAM();
+vector steerlib_beamsteer(entity this, vector dir, float length, float step, float step_up, float step_down)
+{
     float bm_forward, bm_right, bm_left,p;
     vector vr,vl;
 
@@ -428,31 +428,28 @@ vector steerlib_beamsteer(vector dir, float length, float step, float step_up, f
     vr = vectoangles(dir);
     //vr_x *= -1;
 
-    tracebox(self.origin + '0 0 1' * step_up, self.mins, self.maxs, ('0 0 1' * step_up) + self.origin +  (dir * length), MOVE_NOMONSTERS, self);
+    tracebox(this.origin + '0 0 1' * step_up, this.mins, this.maxs, ('0 0 1' * step_up) + this.origin +  (dir * length), MOVE_NOMONSTERS, this);
     if(trace_fraction == 1.0)
     {
-        //te_lightning1(self,self.origin,self.origin +  (dir * length));
+        //te_lightning1(this,this.origin,this.origin +  (dir * length));
         return dir;
     }
 
-
-
-
     makevectors(vr);
-    bm_forward = beamsweep(self.origin, v_forward, length, step, step_up, step_down);
+    bm_forward = beamsweep(this, this.origin, v_forward, length, step, step_up, step_down);
 
     vr = normalize(v_forward + v_right * 0.125);
     vl = normalize(v_forward - v_right * 0.125);
 
-    bm_right = beamsweep(self.origin, vr, length, step, step_up, step_down);
-    bm_left  = beamsweep(self.origin, vl, length, step, step_up, step_down);
+    bm_right = beamsweep(this, this.origin, vr, length, step, step_up, step_down);
+    bm_left  = beamsweep(this, this.origin, vl, length, step, step_up, step_down);
 
 
     p = bm_left + bm_right;
     if(p == 2)
     {
-        //te_lightning1(self,self.origin + '0 0 32',self.origin + '0 0 32' + vr * length);
-        //te_lightning1(self.tur_head,self.origin + '0 0 32',self.origin + '0 0 32' + vl * length);
+        //te_lightning1(this,this.origin + '0 0 32',this.origin + '0 0 32' + vr * length);
+        //te_lightning1(this.tur_head,this.origin + '0 0 32',this.origin + '0 0 32' + vl * length);
 
         return v_forward;
     }
@@ -461,8 +458,8 @@ vector steerlib_beamsteer(vector dir, float length, float step, float step_up, f
 
     vr = normalize(v_forward + v_right * p);
     vl = normalize(v_forward - v_right * p);
-    bm_right = beamsweep(self.origin, vr, length, step, step_up, step_down);
-    bm_left  = beamsweep(self.origin, vl, length, step, step_up, step_down);
+    bm_right = beamsweep(this, this.origin, vr, length, step, step_up, step_down);
+    bm_left  = beamsweep(this, this.origin, vl, length, step, step_up, step_down);
 
 
     if(bm_left + bm_right < 0.15)
@@ -470,12 +467,12 @@ vector steerlib_beamsteer(vector dir, float length, float step, float step_up, f
         vr = normalize((v_forward*-1) + v_right * 0.75);
         vl = normalize((v_forward*-1) - v_right * 0.75);
 
-        bm_right = beamsweep(self.origin, vr, length, step, step_up, step_down);
-        bm_left  = beamsweep(self.origin, vl, length, step, step_up, step_down);
+        bm_right = beamsweep(this, this.origin, vr, length, step, step_up, step_down);
+        bm_left  = beamsweep(this, this.origin, vl, length, step, step_up, step_down);
     }
 
-    //te_lightning1(self,self.origin + '0 0 32',self.origin + '0 0 32' + vr * length);
-    //te_lightning1(self.tur_head,self.origin + '0 0 32',self.origin + '0 0 32' + vl * length);
+    //te_lightning1(this,this.origin + '0 0 32',this.origin + '0 0 32' + vr * length);
+    //te_lightning1(this.tur_head,this.origin + '0 0 32',this.origin + '0 0 32' + vl * length);
 
     bm_forward *= bm_forward;
     bm_right   *= bm_right;
@@ -495,15 +492,15 @@ vector steerlib_beamsteer(vector dir, float length, float step, float step_up, f
 //////////////////////////////////////////////
 //#define TLIBS_TETSLIBS
 #ifdef TLIBS_TETSLIBS
-void flocker_die()
-{SELFPARAM();
-       Send_Effect(EFFECT_ROCKET_EXPLODE, self.origin, '0 0 0', 1);
+void flocker_die(entity this)
+{
+       Send_Effect(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1);
 
-    self.owner.cnt += 1;
-    self.owner = world;
+    this.owner.cnt += 1;
+    this.owner = world;
 
-    self.nextthink = time;
-    self.think = SUB_Remove;
+    this.nextthink = time;
+    this.think = SUB_Remove;
 }
 
 
@@ -512,50 +509,50 @@ void flocker_think()
     vector dodgemove,swarmmove;
     vector reprellmove,wandermove,newmove;
 
-    self.angles_x = self.angles.x * -1;
-    makevectors(self.angles);
-    self.angles_x = self.angles.x * -1;
+    this.angles_x = this.angles.x * -1;
+    makevectors(this.angles);
+    this.angles_x = this.angles.x * -1;
 
-    dodgemove   = steerlib_traceavoid(0.35,1000);
-    swarmmove   = steerlib_flock(500,75,700,500);
-    reprellmove = steerlib_repell(self.owner.enemy.origin+self.enemy.velocity,2000) * 700;
+    dodgemove   = steerlib_traceavoid(this, 0.35,1000);
+    swarmmove   = steerlib_flock(this, 500,75,700,500);
+    reprellmove = steerlib_repell(this, this.owner.enemy.origin+this.enemy.velocity,2000) * 700;
 
-    if(vlen(dodgemove) == 0)
+    if(dodgemove == '0 0 0')
     {
-        self.pos1 = steerlib_wander(0.5,0.1,self.pos1);
-        wandermove  = self.pos1 * 50;
+        this.pos1 = steerlib_wander(this, 0.5,0.1,this.pos1);
+        wandermove  = this.pos1 * 50;
     }
     else
-        self.pos1 = normalize(self.velocity);
+        this.pos1 = normalize(this.velocity);
 
-    dodgemove = dodgemove * vlen(self.velocity) * 5;
+    dodgemove = dodgemove * vlen(this.velocity) * 5;
 
     newmove = swarmmove + reprellmove + wandermove + dodgemove;
-    self.velocity = movelib_inertmove_byspeed(newmove,300,0.2,0.9);
-    //self.velocity  = movelib_inertmove(dodgemove,0.65);
+    this.velocity = movelib_inertmove_byspeed(this, newmove,300,0.2,0.9);
+    //this.velocity  = movelib_inertmove(this, dodgemove,0.65);
 
-    self.velocity = movelib_dragvec(0.01,0.6);
+    this.velocity = movelib_dragvec(this, 0.01,0.6);
 
-    self.angles = vectoangles(self.velocity);
+    this.angles = vectoangles(this.velocity);
 
-    if(self.health <= 0)
-        flocker_die();
+    if(this.health <= 0)
+        flocker_die(this);
     else
-        self.nextthink = time + 0.1;
+        this.nextthink = time + 0.1;
 }
 
 MODEL(FLOCKER, "models/turrets/rocket.md3");
 
-void spawn_flocker()
-{SELFPARAM();
+void spawn_flocker(entity this)
+{
     entity flocker = new(flocker);
 
-    setorigin(flocker, self.origin + '0 0 32');
+    setorigin(flocker, this.origin + '0 0 32');
     setmodel (flocker, MDL_FLOCKER);
     setsize (flocker, '-3 -3 -3', '3 3 3');
 
-    flocker.flock_id   = self.flock_id;
-    flocker.owner      = self;
+    flocker.flock_id   = this.flock_id;
+    flocker.owner      = this;
     flocker.think      = flocker_think;
     flocker.nextthink  = time + random() * 5;
     PROJECTILE_MAKETRIGGER(flocker);
@@ -566,18 +563,16 @@ void spawn_flocker()
     flocker.health     = 10;
     flocker.pos1      = normalize(flocker.velocity + randomvec() * 0.1);
 
-    self.cnt = self.cnt -1;
+    this.cnt = this.cnt -1;
 
 }
 
 void flockerspawn_think()
 {SELFPARAM();
+    if(this.cnt > 0)
+        spawn_flocker(this);
 
-
-    if(self.cnt > 0)
-        spawn_flocker();
-
-    self.nextthink = time + self.delay;
+    this.nextthink = time + this.delay;
 
 }
 
@@ -587,57 +582,57 @@ void flocker_hunter_think()
     entity e,ee;
     float d,bd;
 
-    self.angles_x = self.angles.x * -1;
-    makevectors(self.angles);
-    self.angles_x = self.angles.x * -1;
+    this.angles_x = this.angles.x * -1;
+    makevectors(this.angles);
+    this.angles_x = this.angles.x * -1;
 
-    if(self.enemy)
-    if(vdist(self.enemy.origin - self.origin, <, 64))
+    if(this.enemy)
+    if(vdist(this.enemy.origin - this.origin, <, 64))
     {
-        ee = self.enemy;
+        ee = this.enemy;
         ee.health = -1;
-        self.enemy = world;
+        this.enemy = world;
 
     }
 
-    if(!self.enemy)
+    if(!this.enemy)
     {
-        e = findchainfloat(flock_id,self.flock_id);
+        e = findchainfloat(flock_id,this.flock_id);
         while(e)
         {
-            d = vlen(self.origin - e.origin);
+            d = vlen(this.origin - e.origin);
 
-            if(e != self.owner)
+            if(e != this.owner)
             if(e != ee)
             if(d > bd)
             {
-                self.enemy = e;
+                this.enemy = e;
                 bd = d;
             }
             e = e.chain;
         }
     }
 
-    if(self.enemy)
-        attractmove = steerlib_attract(self.enemy.origin+self.enemy.velocity * 0.1,5000) * 1250;
+    if(this.enemy)
+        attractmove = steerlib_attract(this, this.enemy.origin+this.enemy.velocity * 0.1,5000) * 1250;
     else
-        attractmove = normalize(self.velocity) * 200;
+        attractmove = normalize(this.velocity) * 200;
 
-    dodgemove = steerlib_traceavoid(0.35,1500) * vlen(self.velocity);
+    dodgemove = steerlib_traceavoid(this, 0.35,1500) * vlen(this.velocity);
 
     newmove = dodgemove + attractmove;
-    self.velocity = movelib_inertmove_byspeed(newmove,1250,0.3,0.7);
-    self.velocity = movelib_dragvec(0.01,0.5);
+    this.velocity = movelib_inertmove_byspeed(this, newmove,1250,0.3,0.7);
+    this.velocity = movelib_dragvec(this, 0.01,0.5);
 
 
-    self.angles = vectoangles(self.velocity);
-    self.nextthink = time + 0.1;
+    this.angles = vectoangles(this.velocity);
+    this.nextthink = time + 0.1;
 }
 
 
 float globflockcnt;
 spawnfunc(flockerspawn)
-{SELFPARAM();
+{
     ++globflockcnt;
 
     if(!this.cnt)      this.cnt = 20;
index 32ac07c3cda37b75d951f8e00197beb0428d30ee..fa21610f042d29c794149cb2a28a0ec02a824569 100644 (file)
@@ -2,6 +2,6 @@
 
 .vector steerto;
 
-vector steerlib_arrive(vector point,float maximal_distance);
-vector steerlib_attract2(entity this, vector point, float min_influense,float max_distance,float max_influense);
-vector steerlib_pull(vector point);
+vector steerlib_arrive(entity this, vector point, float maximal_distance);
+vector steerlib_attract2(entity this, vector point, float min_influense, float max_distance, float max_influense);
+vector steerlib_pull(entity this, vector point);
index 44bd23c8c292712db9dc9cb3fff5f4a316ad1c0d..b33b96db1b2cb02cd24af7205b5e005d82ec406f 100644 (file)
@@ -240,20 +240,20 @@ bool DoesQ3ARemoveThisEntity(entity this);
 void SV_OnEntityPreSpawnFunction()
 {SELFPARAM();
        __spawnfunc_expect = this;
-       if (self)
-       if (self.gametypefilter != "")
-       if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, self.gametypefilter))
+       if (this)
+       if (this.gametypefilter != "")
+       if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, this.gametypefilter))
        {
-               remove(self);
+               remove(this);
                return;
        }
-       if(self.cvarfilter != "")
+       if(this.cvarfilter != "")
        {
                float n, i, o, inv;
                string s, k, v;
                inv = 0;
 
-               s = self.cvarfilter;
+               s = this.cvarfilter;
                if(substring(s, 0, 1) == "+")
                {
                        s = substring(s, 1, -1);
@@ -352,41 +352,41 @@ LABEL(cvar_fail)
                if (!inv)
                {
                        //print("cvarfilter fail\n");
-                       remove(self);
+                       remove(this);
                        return;
                }
        }
 
-       if(DoesQ3ARemoveThisEntity(self))
+       if(DoesQ3ARemoveThisEntity(this))
        {
-               remove(self);
+               remove(this);
                return;
        }
 
        // support special -1 and -2 angle from radiant
-       if (self.angles == '0 -1 0')
-               self.angles = '-90 0 0';
-       else if (self.angles == '0 -2 0')
-               self.angles = '+90 0 0';
-
-       if(self.originjitter.x != 0)
-               self.origin_x = self.origin.x + (random() * 2 - 1) * self.originjitter.x;
-       if(self.originjitter.y != 0)
-               self.origin_y = self.origin.y + (random() * 2 - 1) * self.originjitter.y;
-       if(self.originjitter.z != 0)
-               self.origin_z = self.origin.z + (random() * 2 - 1) * self.originjitter.z;
-       if(self.anglesjitter.x != 0)
-               self.angles_x = self.angles.x + (random() * 2 - 1) * self.anglesjitter.x;
-       if(self.anglesjitter.y != 0)
-               self.angles_y = self.angles.y + (random() * 2 - 1) * self.anglesjitter.y;
-       if(self.anglesjitter.z != 0)
-               self.angles_z = self.angles.z + (random() * 2 - 1) * self.anglesjitter.z;
-       if(self.anglejitter != 0)
-               self.angles_y = self.angles.y + (random() * 2 - 1) * self.anglejitter;
-
-       if(MUTATOR_CALLHOOK(OnEntityPreSpawn))
+       if (this.angles == '0 -1 0')
+               this.angles = '-90 0 0';
+       else if (this.angles == '0 -2 0')
+               this.angles = '+90 0 0';
+
+       if(this.originjitter.x != 0)
+               this.origin_x = this.origin.x + (random() * 2 - 1) * this.originjitter.x;
+       if(this.originjitter.y != 0)
+               this.origin_y = this.origin.y + (random() * 2 - 1) * this.originjitter.y;
+       if(this.originjitter.z != 0)
+               this.origin_z = this.origin.z + (random() * 2 - 1) * this.originjitter.z;
+       if(this.anglesjitter.x != 0)
+               this.angles_x = this.angles.x + (random() * 2 - 1) * this.anglesjitter.x;
+       if(this.anglesjitter.y != 0)
+               this.angles_y = this.angles.y + (random() * 2 - 1) * this.anglesjitter.y;
+       if(this.anglesjitter.z != 0)
+               this.angles_z = this.angles.z + (random() * 2 - 1) * this.anglesjitter.z;
+       if(this.anglejitter != 0)
+               this.angles_y = this.angles.y + (random() * 2 - 1) * this.anglejitter;
+
+       if(MUTATOR_CALLHOOK(OnEntityPreSpawn, this))
        {
-               remove(self);
+               remove(this);
                return;
        }
 }
index c41f8ccf8cd5c50b739e2f720337e7985bbb9f5e..9096acc23576aecce3d20fd93d0759c0622bbb76 100644 (file)
@@ -21,8 +21,8 @@ spawnfunc(weapon_supershotgun) {spawnfunc_weapon_machinegun(this);}
 spawnfunc(item_spikes) {spawnfunc_item_bullets(this);}
 //spawnfunc(item_armor1) {spawnfunc_item_armor_medium(this);}  // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
 spawnfunc(item_armor2) {spawnfunc_item_armor_large(this);}
-void item_armorInv() {SELFPARAM();spawnfunc_item_armor_large(self);}
-spawnfunc(item_health) {if (self.spawnflags & 2) spawnfunc_item_health_mega(this);else spawnfunc_item_health_medium(this);}
+void item_armorInv() {SELFPARAM();spawnfunc_item_armor_large(this);} // FIXME: we require spawnfunc_ prefix for functions to be map entities
+spawnfunc(item_health) {if (this.spawnflags & 2) spawnfunc_item_health_mega(this);else spawnfunc_item_health_medium(this);}
 
 //spawnfunc_item_spikes
 //spawnfunc_item_health