v = this.owner.destvec + this.owner.movedir * v_forward_y;
if(this.owner.classname == "func_bobbing") // don't brake stuff if the func_bobbing was killtarget'ed
// * 10 so it will arrive in 0.1 sec
- this.owner.velocity = (v - this.owner.SUB_ORIGIN) * 10;
+ this.owner.velocity = (v - this.owner.origin) * 10;
}
/*QUAKED spawnfunc_func_bobbing (0 .5 .8) ? X_AXIS Y_AXIS
controller.owner = this;
controller.nextthink = time + 1;
setthink(controller, func_bobbing_controller_think);
- this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
- SUB_THINK(this, SUB_NullThink);
+ this.nextthink = this.ltime + 999999999;
+ setthink(this, SUB_NullThink);
// Savage: Reduce bandwith, critical on e.g. nexdm02
this.effects |= EF_LOWPRECISION;
void button_wait(entity this)
{
this.state = STATE_TOP;
- this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
- SUB_THINK(this, button_return);
+ this.nextthink = this.ltime + this.wait;
+ setthink(this, button_return);
SUB_UseTargets(this, this.enemy, NULL);
this.frame = 1; // use alternate textures
}
return; // don't come down automatically
if (this.classname == "door")
{
- SUB_THINK(this, door_go_down);
+ setthink(this, door_go_down);
} else
{
- SUB_THINK(this, door_rotating_go_down);
+ setthink(this, door_rotating_go_down);
}
- this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+ this.nextthink = this.ltime + this.wait;
}
void door_hit_bottom(entity this)
if (this.state == STATE_TOP)
{ // reset top wait time
- this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+ this.nextthink = this.ltime + this.wait;
return;
}
this.state = STATE_TOP;
if (this.spawnflags & DOOR_TOGGLE)
return; // don't come down automatically
- SUB_THINK(this, door_rotating_go_down);
- this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+ setthink(this, door_rotating_go_down);
+ this.nextthink = this.ltime + this.wait;
}
void door_rotating_hit_bottom(entity this)
if (this.state == STATE_TOP)
{ // reset top wait time
- this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+ this.nextthink = this.ltime + this.wait;
return;
}
if (this.noise2 != "")
WriteShort(MSG_ENTITY, this.speed);
WriteByte(MSG_ENTITY, this.lip);
WriteByte(MSG_ENTITY, this.state);
- WriteCoord(MSG_ENTITY, this.SUB_LTIME);
+ WriteCoord(MSG_ENTITY, this.ltime);
}
if(sf & SF_TRIGGER_RESET)
void door_init_startopen(entity this)
{
- SUB_SETORIGIN(this, this.pos2);
+ setorigin(this, this.pos2);
this.pos2 = this.pos1;
this.pos1 = this.origin;
void door_reset(entity this)
{
- SUB_SETORIGIN(this, this.pos1);
- this.SUB_VELOCITY = '0 0 0';
+ setorigin(this, this.pos1);
+ this.velocity = '0 0 0';
this.state = STATE_BOTTOM;
- SUB_THINK(this, func_null);
- this.SUB_NEXTTHINK = 0;
+ setthink(this, func_null);
+ this.nextthink = 0;
#ifdef SVQC
this.SendFlags |= SF_TRIGGER_RESET;
if (!this.lip)
this.lip = 8;
- this.pos1 = this.SUB_ORIGIN;
+ this.pos1 = this.origin;
this.pos2 = this.pos1 + this.movedir*(fabs(this.movedir*this.size) - this.lip);
if(this.spawnflags & DOOR_NONSOLID)
this.speed = ReadShort();
this.lip = ReadByte();
this.state = ReadByte();
- this.SUB_LTIME = ReadCoord();
+ this.ltime = ReadCoord();
this.solid = SOLID_BSP;
set_movetype(this, MOVETYPE_PUSH);
if (this.noise1 != "")
_sound(this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM);
- this.SUB_NEXTTHINK = this.SUB_LTIME + 0.1;
+ this.nextthink = this.ltime + 0.1;
temp = 1 - (this.spawnflags & SECRET_1ST_LEFT); // 1 or -1
makevectors(this.mangle);
// Wait after first movement...
void fd_secret_move1(entity this)
{
- this.SUB_NEXTTHINK = this.SUB_LTIME + 1.0;
+ this.nextthink = this.ltime + 1.0;
setthink(this, fd_secret_move2);
if (this.noise3 != "")
_sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
_sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
if (!(this.spawnflags & SECRET_OPEN_ONCE))
{
- this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+ this.nextthink = this.ltime + this.wait;
setthink(this, fd_secret_move4);
}
}
// Wait 1 second...
void fd_secret_move5(entity this)
{
- this.SUB_NEXTTHINK = this.SUB_LTIME + 1.0;
+ this.nextthink = this.ltime + 1.0;
setthink(this, fd_secret_move6);
if (this.noise3 != "")
_sound(this, CH_TRIGGER_SINGLE, this.noise3, VOL_BASE, ATTEN_NORM);
}
setorigin(this, this.oldorigin);
setthink(this, func_null);
- this.SUB_NEXTTHINK = 0;
+ this.nextthink = 0;
}
/*QUAKED spawnfunc_func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
controller.owner = this;
controller.nextthink = time + 1;
setthink(controller, func_fourier_controller_think);
- this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
- SUB_THINK(this, SUB_NullThink); // for PushMove
+ this.nextthink = this.ltime + 999999999;
+ setthink(this, SUB_NullThink); // for PushMove
// Savage: Reduce bandwith, critical on e.g. nexdm02
this.effects |= EF_LOWPRECISION;
controller.owner = this;
controller.nextthink = time + 1;
setthink(controller, func_pendulum_controller_think);
- this.nextthink = this.SUB_LTIME + 999999999;
- SUB_THINK(this, SUB_NullThink); // for PushMove
+ this.nextthink = this.ltime + 999999999;
+ setthink(this, SUB_NullThink); // for PushMove
//this.effects |= EF_LOWPRECISION;
setblocked(this, generic_plat_blocked);
// wait for targets to spawn
- this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
- SUB_THINK(this, SUB_NullThink); // for PushMove
+ this.nextthink = this.ltime + 999999999;
+ setthink(this, SUB_NullThink); // for PushMove
// TODO make a reset function for this one
}
ang_x = -ang_x; // flip up / down orientation
if(this.wait > 0) // slow turning
- SUB_CalcAngleMove(this, ang, TSPEED_TIME, this.SUB_LTIME - time + this.wait, train_wait);
+ SUB_CalcAngleMove(this, ang, TSPEED_TIME, this.ltime - time + this.wait, train_wait);
else // instant turning
SUB_CalcAngleMove(this, ang, TSPEED_TIME, 0.0000001, train_wait);
this.train_wait_turning = true;
if(tg.spawnflags & 4)
{
this.use = train_use;
- SUB_THINK(this, func_null);
- this.SUB_NEXTTHINK = 0;
+ setthink(this, func_null);
+ this.nextthink = 0;
}
else
#endif
}
else
{
- SUB_THINK(this, train_next);
- this.SUB_NEXTTHINK = this.SUB_LTIME + this.wait;
+ setthink(this, train_next);
+ this.nextthink = this.ltime + this.wait;
}
}
void train_use(entity this, entity actor, entity trigger)
{
- this.SUB_NEXTTHINK = this.SUB_LTIME + 1;
- SUB_THINK(this, train_next);
+ this.nextthink = this.ltime + 1;
+ setthink(this, train_next);
this.use = func_null; // not again
if(trigger.target2 && trigger.target2 != "")
this.future_target = find(NULL, targetname, trigger.target2);
this.future_target = train_next_find(targ);
if (this.target == "")
objerror(this, "func_train_find: no next target");
- SUB_SETORIGIN(this, targ.origin - this.view_ofs);
+ setorigin(this, targ.origin - this.view_ofs);
if(!(this.spawnflags & 4))
{
- this.SUB_NEXTTHINK = this.SUB_LTIME + 1;
- SUB_THINK(this, train_next);
+ this.nextthink = this.ltime + 1;
+ setthink(this, train_next);
}
train_link(this);
return;
// wait for targets to spawn
- this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
- SUB_THINK(this, SUB_NullThink); // for PushMove
+ this.nextthink = this.ltime + 999999999;
+ setthink(this, SUB_NullThink); // for PushMove
// Savage: Reduce bandwith, critical on e.g. nexdm02
this.effects |= EF_LOWPRECISION;
_sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM);
this.state = 1;
- SUB_THINK(this, plat_go_down);
- this.SUB_NEXTTHINK = this.SUB_LTIME + 3;
+ setthink(this, plat_go_down);
+ this.nextthink = this.ltime + 3;
}
void plat_hit_bottom(entity this)
if (this.enemy.state == 2) {
plat_go_up(this.enemy);
} else if (this.enemy.state == 1)
- this.enemy.SUB_NEXTTHINK = this.enemy.SUB_LTIME + 1;
+ this.enemy.nextthink = this.enemy.ltime + 1;
}
void plat_outside_touch(entity this, entity toucher)
.float friction;
void SUB_Friction (entity this)
{
- this.SUB_NEXTTHINK = time;
+ this.nextthink = time;
if(IS_ONGROUND(this))
- this.SUB_VELOCITY = this.SUB_VELOCITY * (1 - frametime * this.friction);
+ this.velocity = this.velocity * (1 - frametime * this.friction);
}
/*
{
if(this.alpha == 0)
this.alpha = 1;
- SUB_THINK(this, SUB_SetFade_Think);
- this.SUB_NEXTTHINK = time;
+ setthink(this, SUB_SetFade_Think);
+ this.nextthink = time;
this.alpha -= frametime * this.fade_rate;
if (this.alpha < 0.01)
SUB_VanishOrRemove(this);
else
- this.SUB_NEXTTHINK = time;
+ this.nextthink = time;
}
/*
void SUB_SetFade (entity ent, float when, float fading_time)
{
ent.fade_rate = 1/fading_time;
- SUB_THINK(ent, SUB_SetFade_Think);
- ent.SUB_NEXTTHINK = when;
+ setthink(ent, SUB_SetFade_Think);
+ ent.nextthink = when;
}
/*
=============
SUB_CalcMove
-calculate this.SUB_VELOCITY and this.SUB_NEXTTHINK to reach dest from
-this.SUB_ORIGIN traveling at speed
+calculate this.velocity and this.nextthink to reach dest from
+this.origin traveling at speed
===============
*/
void SUB_CalcMoveDone(entity this)
{
// After moving, set origin to exact final destination
- SUB_SETORIGIN (this, this.finaldest);
- this.SUB_VELOCITY = '0 0 0';
- this.SUB_NEXTTHINK = -1;
+ setorigin (this, this.finaldest);
+ this.velocity = '0 0 0';
+ this.nextthink = -1;
if (this.think1 && this.think1 != SUB_CalcMoveDone)
this.think1 (this);
}
destangle_x = -destangle_x; // flip up / down orientation
// take the shortest distance for the angles
- vector v = SUB_ANGLES(this.owner);
+ vector v = this.owner.angles;
v.x -= 360 * floor((v.x - destangle_x) / 360 + 0.5);
v.y -= 360 * floor((v.y - destangle_y) / 360 + 0.5);
v.z -= 360 * floor((v.z - destangle_z) / 360 + 0.5);
- SUB_ANGLES(this.owner) = v;
- angloc = destangle - SUB_ANGLES(this.owner);
+ this.owner.angles = v;
+ angloc = destangle - this.owner.angles;
angloc = angloc * (1 / PHYS_INPUT_FRAMETIME); // so it arrives for the next frame
- this.owner.SUB_AVELOCITY = angloc;
+ this.owner.avelocity = angloc;
}
if(nexttick < this.animstate_endtime)
- veloc = nextpos - this.owner.SUB_ORIGIN;
+ veloc = nextpos - this.owner.origin;
else
- veloc = this.finaldest - this.owner.SUB_ORIGIN;
+ veloc = this.finaldest - this.owner.origin;
veloc = veloc * (1 / PHYS_INPUT_FRAMETIME); // so it arrives for the next frame
- this.owner.SUB_VELOCITY = veloc;
+ this.owner.velocity = veloc;
this.nextthink = nexttick;
}
else
{
// derivative: delta + 2 * delta2 (e.g. for angle positioning)
entity own = this.owner;
- SUB_THINK(own, this.think1);
+ setthink(own, this.think1);
delete(this);
- SUB_THUNK(own)(own);
+ getthink(own)(own);
}
}
this.think1 = func;
this.finaldest = tdest;
- SUB_THINK(this, SUB_CalcMoveDone);
+ setthink(this, SUB_CalcMoveDone);
switch(tspeedtype)
{
default:
case TSPEED_START:
- traveltime = 2 * vlen(tcontrol - this.SUB_ORIGIN) / tspeed;
+ traveltime = 2 * vlen(tcontrol - this.origin) / tspeed;
break;
case TSPEED_END:
traveltime = 2 * vlen(tcontrol - tdest) / tspeed;
break;
case TSPEED_LINEAR:
- traveltime = vlen(tdest - this.SUB_ORIGIN) / tspeed;
+ traveltime = vlen(tdest - this.origin) / tspeed;
break;
case TSPEED_TIME:
traveltime = tspeed;
if (traveltime < 0.1) // useless anim
{
- this.SUB_VELOCITY = '0 0 0';
- this.SUB_NEXTTHINK = this.SUB_LTIME + 0.1;
+ this.velocity = '0 0 0';
+ this.nextthink = this.ltime + 0.1;
return;
}
controller.platmovetype = this.platmovetype;
controller.platmovetype_start = this.platmovetype_start;
controller.platmovetype_end = this.platmovetype_end;
- SUB_CalcMove_controller_setbezier(controller, this.SUB_ORIGIN, tcontrol, tdest);
+ SUB_CalcMove_controller_setbezier(controller, this.origin, tcontrol, tdest);
controller.finaldest = (tdest + '0 0 0.125'); // where do we want to end? Offset to overshoot a bit.
controller.animstate_starttime = time;
controller.animstate_endtime = time + traveltime;
setthink(controller, SUB_CalcMove_controller_think);
- controller.think1 = SUB_THUNK(this);
+ controller.think1 = getthink(this);
// the thinking is now done by the controller
- SUB_THINK(this, SUB_NullThink); // for PushMove
- this.SUB_NEXTTHINK = this.SUB_LTIME + traveltime;
+ setthink(this, SUB_NullThink); // for PushMove
+ this.nextthink = this.ltime + traveltime;
// invoke controller
getthink(controller)(controller);
this.think1 = func;
this.finaldest = tdest;
- SUB_THINK(this, SUB_CalcMoveDone);
+ setthink(this, SUB_CalcMoveDone);
- if (tdest == this.SUB_ORIGIN)
+ if (tdest == this.origin)
{
- this.SUB_VELOCITY = '0 0 0';
- this.SUB_NEXTTHINK = this.SUB_LTIME + 0.1;
+ this.velocity = '0 0 0';
+ this.nextthink = this.ltime + 0.1;
return;
}
- delta = tdest - this.SUB_ORIGIN;
+ delta = tdest - this.origin;
switch(tspeedtype)
{
// 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.SUB_VELOCITY = delta * (1/traveltime); // QuakeC doesn't allow vector/float division
- this.SUB_NEXTTHINK = this.SUB_LTIME + traveltime;
+ this.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division
+ this.nextthink = this.ltime + traveltime;
return;
}
// now just run like a bezier curve...
- SUB_CalcMove_Bezier(this, (this.SUB_ORIGIN + tdest) * 0.5, tdest, tspeedtype, tspeed, func);
+ SUB_CalcMove_Bezier(this, (this.origin + tdest) * 0.5, tdest, tspeedtype, tspeed, func);
}
void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
=============
SUB_CalcAngleMove
-calculate this.SUB_AVELOCITY and this.SUB_NEXTTHINK to reach destangle from
+calculate this.avelocity and this.nextthink to reach destangle from
this.angles rotating
-The calling function should make sure this.SUB_THINK is valid
+The calling function should make sure this.setthink is valid
===============
*/
void SUB_CalcAngleMoveDone(entity this)
{
// After rotating, set angle to exact final angle
this.angles = this.finalangle;
- this.SUB_AVELOCITY = '0 0 0';
- this.SUB_NEXTTHINK = -1;
+ this.avelocity = '0 0 0';
+ this.nextthink = -1;
if (this.think1 && this.think1 != SUB_CalcAngleMoveDone) // avoid endless loops
this.think1 (this);
}
this.angles_x -= 360 * floor((this.angles_x - destangle_x) / 360 + 0.5);
this.angles_y -= 360 * floor((this.angles_y - destangle_y) / 360 + 0.5);
this.angles_z -= 360 * floor((this.angles_z - destangle_z) / 360 + 0.5);
- delta = destangle - this.angles;
+ vector delta = destangle - this.angles;
switch(tspeedtype)
{
this.think1 = func;
this.finalangle = destangle;
- SUB_THINK(this, SUB_CalcAngleMoveDone);
+ setthink(this, SUB_CalcAngleMoveDone);
if (traveltime < 0.1)
{
- this.SUB_AVELOCITY = '0 0 0';
- this.SUB_NEXTTHINK = this.SUB_LTIME + 0.1;
+ this.avelocity = '0 0 0';
+ this.nextthink = this.ltime + 0.1;
return;
}
- this.SUB_AVELOCITY = delta * (1 / traveltime);
- this.SUB_NEXTTHINK = this.SUB_LTIME + traveltime;
+ this.avelocity = delta * (1 / traveltime);
+ this.nextthink = this.ltime + traveltime;
}
void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void(entity this) func)
#pragma once
-#define SUB_ANGLES(s) (s).angles
-#define SUB_VELOCITY velocity
-#define SUB_AVELOCITY avelocity
-#define SUB_ORIGIN origin
-#define SUB_SETORIGIN(s,v) setorigin((s), (v))
-#define SUB_NEXTTHINK nextthink
-#define SUB_THINK(e, f) setthink(e, f)
-#define SUB_THUNK(e) getthink(e)
-#define SUB_LTIME ltime
-
-
void SUB_SetFade (entity ent, float when, float fading_time);
void SUB_VanishOrRemove (entity ent);