64 if (this.
alpha < 0.01)
81 ent.fade_rate = 1/fading_time;
83 ent.nextthink = vanish_time;
120 nexttick =
time + PHYS_INPUT_FRAMETIME;
125 nextpos = this.
origin + (delta * phasepos) + (delta2 * phasepos * phasepos);
128 if(this.
owner.platmovetype_turn)
131 destangle = delta + 2 * delta2 * phasepos;
133 destangle_x = -destangle_x;
137 v.x -= 360 *
floor((v.x - destangle_x) / 360 + 0.5);
138 v.y -= 360 *
floor((v.y - destangle_y) / 360 + 0.5);
139 v.z -= 360 *
floor((v.z - destangle_z) / 360 + 0.5);
141 angloc = destangle - this.
owner.angles;
142 angloc = angloc * (1 / PHYS_INPUT_FRAMETIME);
143 this.
owner.avelocity = angloc;
146 veloc = nextpos - this.
owner.origin;
149 veloc = veloc * (1 / PHYS_INPUT_FRAMETIME);
151 this.
owner.velocity = veloc;
160 own.move_controller =
NULL;
176 controller.destvec = 2 * control;
177 controller.destvec2 = destin - 2 * control;
190 controller.destvec = destin;
191 controller.destvec2 =
'0 0 0';
200 objerror (
this,
"No speed is defined!");
210 traveltime = 2 *
vlen(tcontrol - this.
origin) / tspeed;
213 traveltime = 2 *
vlen(tcontrol - tdest) / tspeed;
216 traveltime =
vlen(tdest - this.
origin) / tspeed;
223 if (traveltime < 0.1)
235 controller =
new_pure(SUB_CalcMove_controller);
236 controller.owner =
this;
242 controller.finaldest = (tdest +
'0 0 0.125');
243 controller.animstate_starttime =
time;
244 controller.animstate_endtime =
time + traveltime;
262 objerror (
this,
"No speed is defined!");
275 delta = tdest - this.
origin;
283 traveltime =
vlen (delta) / tspeed;
296 this.
velocity = delta * (1/traveltime);
334 objerror (
this,
"No speed is defined!");
337 this.angles_x -= 360 *
floor((this.angles_x - destangle_x) / 360 + 0.5);
338 this.angles_y -= 360 *
floor((this.angles_y - destangle_y) / 360 + 0.5);
339 this.angles_z -= 360 *
floor((this.angles_z - destangle_z) / 360 + 0.5);
349 traveltime =
vlen (delta) / tspeed;
360 if (traveltime < 0.1)
367 this.
avelocity = delta * (1 / traveltime);
377 void ApplyMinMaxScaleAngles(
entity e)
379 if(e.angles.x != 0 || e.angles.z != 0 || e.avelocity.x != 0 || e.avelocity.z != 0)
381 e.maxs =
'1 1 1' *
vlen(
382 '1 0 0' *
max(-e.mins.x, e.maxs.x) +
383 '0 1 0' *
max(-e.mins.y, e.maxs.y) +
384 '0 0 1' *
max(-e.mins.z, e.maxs.z)
388 else if(e.angles.y != 0 || e.avelocity.y != 0)
391 '1 0 0' *
max(-e.mins.x, e.maxs.x) +
392 '0 1 0' *
max(-e.mins.y, e.maxs.y)
395 e.mins_x = -e.maxs.x;
396 e.mins_y = -e.maxs.x;
399 setsize(e, e.mins * e.scale, e.maxs * e.scale);
401 setsize(e, e.mins, e.maxs);
404 void SetBrushEntityModel(
entity this,
bool with_lod)
408 precache_model(this.
model);
409 if(this.
mins !=
'0 0 0' || this.
maxs !=
'0 0 0')
413 _setmodel(
this, this.
model);
414 setsize(
this, mi, ma);
417 _setmodel(
this, this.
model);
422 this.angles_y =
anglemods(this.angles_y - 180);
425 ApplyMinMaxScaleAngles(
this);
430 if(autocvar_loddebug)
432 int d = autocvar_loddebug;
443 vector near_point = NearestPointOnBox(
this, client.origin);
444 if(
vdist(near_point - client.origin, <,
this.loddistance1))
454 void LOD_uncustomize(
entity this)
459 void LODmodel_attach(
entity this)
463 if(!this.loddistance1)
464 this.loddistance1 = 1000;
465 if(!this.loddistance2)
466 this.loddistance2 = 2000;
469 if(this.lodtarget1 !=
"")
474 this.lodmodel1 = e.model;
478 if(this.lodtarget2 !=
"")
483 this.lodmodel2 = e.model;
488 if(autocvar_loddebug < 0)
490 this.lodmodel1 = this.lodmodel2 =
"";
493 if(this.lodmodel1 !=
"")
499 precache_model(this.lodmodel1);
500 _setmodel(
this, this.lodmodel1);
503 if(this.lodmodel2 !=
"")
505 precache_model(this.lodmodel2);
506 _setmodel(
this, this.lodmodel2);
511 setsize(
this, mi, ma);
516 SetCustomizer(
this, LOD_customize, LOD_uncustomize);
525 void SetMovedir(
entity this)
538 void InitTrigger(
entity this)
544 SetBrushEntityModel(
this,
false);
550 void InitSolidBSPTrigger(
entity this)
556 SetBrushEntityModel(
this,
false);
562 bool InitMovingBrushTrigger(
entity this)
567 SetBrushEntityModel(
this,
true);
571 objerror(
this,
"InitMovingBrushTrigger: no brushes found!");
void SUB_CalcAngleMoveEnt(entity ent, vector destangle, float tspeedtype, float tspeed, void(entity this) func)
void SUB_CalcMove_controller_setlinear(entity controller, vector org, vector destin)
ERASEABLE float anglemods(float v)
void SUB_VanishOrRemove(entity ent)
void SUB_Friction(entity this)
spawnfunc(info_player_attacker)
void SUB_CalcAngleMoveDone(entity this)
void SUB_CalcMove(entity this, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
void SUB_SetFade_Think(entity this)
void SUB_CalcMoveDone(entity this)
ERASEABLE float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd)
void SUB_CalcMove_controller_think(entity this)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void SUB_NullThink(entity this)
void InitializeEntity(entity e, void(entity this) func, int order)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
float animstate_starttime
const float SOLID_TRIGGER
#define new_pure(class)
purely logical entities (.origin doesn't work)
void SUB_CalcAngleMove(entity this, vector destangle, float tspeedtype, float tspeed, void(entity this) func)
void SUB_SetFade(entity ent, float vanish_time, float fading_time)
void SUB_CalcMove_controller_setbezier(entity controller, vector org, vector control, vector destin)
void SUB_CalcMove_Bezier(entity this, vector tcontrol, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
void set_movetype(entity this, int mt)
void SUB_CalcMoveEnt(entity ent, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
#define endsWith(this, suffix)