20#ifdef WARPZONELIB_KEEPDEBUG
21 #define WARPZONELIB_REMOVEHACK
36#define WarpZone_StoreProjectileData(e_) MACRO_BEGIN \
38 e.warpzone_oldorigin = e.origin; \
39 e.warpzone_oldvelocity = e.velocity; \
40 e.warpzone_oldangles = e.angles; \
46 player.lastteleport_origin = player.origin;
47 player.lastteleporttime =
time;
49 setorigin(player, to);
50 player.angles = to_angles;
52 player.oldorigin = to;
53 player.fixangle =
true;
57 player.v_angle = player.angles;
61 player.velocity = to_velocity;
82 vector o0, a0, v0, o1, a1, v1, o10;
84 o0 = player.origin + player.view_ofs;
95 if (f0 != 0 ||
f1 != 0)
102 entity own = player.owner;
118 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs,
MOVE_NOMONSTERS, player);
121 setorigin(player, o1 - player.view_ofs);
124 o1 = player.origin + player.view_ofs;
125 setorigin(player, o0 - player.view_ofs);
129 LOG_INFO(
"would have to put player in solid, won't do that");
130 setorigin(player, o0 - player.view_ofs);
139 player.warpzone_teleport_time =
time;
140 player.warpzone_teleport_finishtime =
time;
141 player.warpzone_teleport_zone = wz;
145 float dt = (v1 !=
'0 0 0') ? (o1 - o10) * v1 * (1 / (v1 * v1)) : 0;
150#ifndef WARPZONE_USE_FIXANGLE
153 player = player.owner;
157 player.fixangle =
false;
159 entity ts =
new(warpzone_teleported);
162 ts.SendFlags = 0xFFFFFF;
163 ts.drawonlytoclient = player;
165 ts.nextthink =
time + 1;
169 ts.angles = wz.warpzone_transform;
183 if (
toucher.classname ==
"trigger_warpzone")
236 if (this.
origin !=
'0 0 0')
271 if (this.
origin !=
'0 0 0')
297#ifdef WARPZONELIB_KEEPDEBUG
298float WarpZone_CheckProjectileImpact(
entity player)
300 vector o0 = player.origin + player.view_ofs;
301 vector v0 = player.velocity;
304 if (
time <= player.warpzone_teleport_finishtime + 0.1)
312#ifdef WARPZONELIB_REMOVEHACK
313 LOG_INFO(
"impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now");
315 LOG_INFO(
"impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again");
317 LOG_INFO(
"Entity type: ", player.classname);
321#ifdef WARPZONELIB_REMOVEHACK
325 setorigin(player, player.warpzone_oldorigin);
326 player.velocity = player.warpzone_oldvelocity;
334 setorigin(player, o0 - player.view_ofs);
335 player.velocity = v0;
346 if (
toucher.classname ==
"trigger_warpzone")
359#ifdef WARPZONELIB_KEEPDEBUG
362 float save_dpstartcontents;
363 float save_dphitcontents;
364 float save_dphitq3surfaceflags;
365 string save_dphittexturename;
367 float save_startsolid;
371 float save_plane_dist;
388 float f = WarpZone_CheckProjectileImpact(
this);
389 if (f)
return (f > 0);
422 error(
"Warp zone with nonexisting killtarget");
433 error(
"Warp zone position with no target");
439 error(
"Warp zone position with nonexisting target");
442 if (this.
enemy.aiment)
445 error(
"Warp zone position targeting already oriented warpzone");
448 this.
enemy.aiment =
this;
456 ||
this.warpzone_save_eangles !=
this.enemy.angles)
473 error(
"Camera with no target");
482 error(
"Camera with nonexisting target");
509 norm = point =
'0 0 0';
511 for (i_s = 0; ; ++i_s)
513 tex = getsurfacetexture(
this, i_s);
516 if (tex ==
"textures/common/trigger" || tex ==
"trigger")
518 n_t = getsurfacenumtriangles(
this, i_s);
519 for (i_t = 0; i_t < n_t; ++i_t)
521 tri = getsurfacetriangle(
this, i_s, i_t);
522 a = getsurfacepoint(
this, i_s, tri.x);
523 b = getsurfacepoint(
this, i_s, tri.y);
524 c = getsurfacepoint(
this, i_s, tri.z);
525 n =
cross(c - a, b - a);
528 point +=
vlen(n) * (a + b + c);
534 point *= 1 / (3 * area);
535 if (
vdist(norm, <, 0.99))
537 LOG_INFO(
"trigger_warpzone near ",
vtos(this.
aiment.origin),
" is nonplanar. BEWARE.");
550 org -= ((
org - point) * norm) * norm;
551 vector forward, right, up;
553 if (norm * forward < 0)
555 LOG_INFO(
"Position target of trigger_warpzone near ",
vtos(this.
aiment.origin),
" points into trigger_warpzone. BEWARE.");
558 ang = vectoangles2(norm, up);
560 if (norm * forward < 0.99)
573 error(
"cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
601 if (e.classname ==
this.classname)
607 error(
"Warpzone with non-existing target");
620 error(
"Invalid warp zone detected. Killed.");
650 spawnfunc_misc_warpzone_position(
this);
683 if (this.
model !=
"")
685 precache_model(this.
model);
686 _setmodel(
this, this.
model);
688 setorigin(
this, this.
origin);
690 setsize(
this, this.
mins * this.
scale, this.
maxs * this.scale);
692 setsize(
this, this.
mins, this.
maxs);
695 else if (this.
solid < 0)
719 ||
this.warpzone_save_eangles !=
this.enemy.angles)
792 e.warpzone_reconnecting = ((
this.target ==
"" || e.target ==
this.target) && !((
this.spawnflags & 1) &&
visible_to_some_client(e)));
794 if (e.warpzone_reconnecting)
797 if (e.warpzone_reconnecting)
800 if (e.warpzone_reconnecting)
803 if (e.warpzone_reconnecting || e.enemy.warpzone_reconnecting)
814 spawnfunc_trigger_warpzone_reconnect(
this);
819#ifndef WARPZONE_DONT_FIX_VANGLE
825 this.v_angle_z += 720;
void bot_aim_reset(entity this)
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define setmodel(this, m)
#define IS_NOT_A_CLIENT(s)
#define PHYS_INPUT_FRAMETIME
#define PHYS_INPUT_ANGLES(s)
const float MOVE_NOMONSTERS
float trace_dphitcontents
const float VF_CL_VIEWANGLES
float trace_dpstartcontents
string trace_dphittexturename
float checkpvs(vector viewpos, entity viewee)
float trace_dphitq3surfaceflags
const float EF_NODEPTHTEST
vector trace_plane_normal
const int EF_TELEPORT_BIT
void SUB_Remove(entity this)
Remove entity.
#define MAKE_VECTORS(angles, forward, right, up)
Same as the makevectors builtin but uses the provided locals instead of the v_* globals.
WriteByte(chan, ent.angles.y/DEC_FACTOR)
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define IL_EACH(this, cond, body)
#define WriteHeader(to, id)
void WarpZone_Touch(entity this, entity toucher)
void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, vector other_ang)
void WarpZone_RefSys_Add(entity me, entity wz)
entity WarpZone_Find(vector mi, vector ma)
bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher, bool touchfunc)
float WarpZone_PlaneDist(entity wz, vector v)
void WarpZone_Camera_SetUp(entity e, vector my_org, vector my_ang)
vector WarpZone_TransformVAngles(entity wz, vector ang)
vector WarpZone_TransformVelocity(entity wz, vector v)
vector WarpZone_TransformAngles(entity wz, vector v)
vector WarpZone_TransformOrigin(entity wz, vector v)
float WarpZone_TargetPlaneDist(entity wz, vector v)
int WarpZoneLib_MoveOutOfSolid(entity e)
#define EXACTTRIGGER_TOUCH(e, t)
#define BITSET_ASSIGN(a, b)
float warpzone_cameras_exist
vector warpzone_targetorigin
#define BITCLR_ASSIGN(a, b)
vector warpzone_targetangles
IntrusiveList g_warpzones
float warpzone_warpzones_exist
#define BITXOR_ASSIGN(a, b)
const int MOVETYPE_FOLLOW
#define setSendEntity(e, f)
IntrusiveList g_projectiles
float warpzone_initialized
void WarpZone_Think(entity this)
void WarpZone_InitStep_FindOriginTarget(entity this)
vector warpzone_oldvelocity
vector warpzone_save_eangles
void WarpZone_StartFrame()
bool WarpZone_Camera_Send(entity this, entity to, int sf)
bool WarpZone_Teleported_Send(entity this, entity to, int sf)
entity warpzone_teleport_zone
void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
float WarpZone_Projectile_Touch(entity this, entity toucher)
vector warpzone_oldangles
entity warpzone_position_first
entity warpzone_camera_first
vector warpzone_save_origin
float warpzone_teleport_time
float warpzone_teleport_finishtime
vector warpzone_save_angles
void WarpZoneCamera_InitStep_FindTarget(entity this)
vector warpzone_save_eorigin
void WarpZones_Reconnect()
void WarpZoneCamera_Think(entity this)
bool visible_to_some_client(entity ent)
#define WarpZone_StoreProjectileData(e_)
float warpzone_reconnecting
void WarpZone_InitStep_FindTarget(entity this)
void WarpZone_InitStep_UpdateTransform(entity this)
float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
void WarpZone_InitStep_ClearTarget(entity this)
void WarpZonePosition_InitStep_FindTarget(entity this)
bool autocvar_sv_warpzone_allow_selftarget
void WarpZone_PlayerPhysics_FixVAngle(entity this)
vector warpzone_oldorigin
void WarpZone_InitStep_FinalizeTransform(entity this)
void WarpZone_Touch(entity this, entity toucher)
void trigger_warpzone_reconnect_use(entity this, entity actor, entity trigger)
bool WarpZone_Send(entity this, entity to, int sf)
bool WarpZone_Projectile_Touch_ImpactFilter_Callback(entity this, entity toucher)
void WarpZone_PostInitialize_Callback()
ClientState CS(Client this)
entity Simple_TeleportPlayer(entity teleporter, entity player)
void WarpZone_PostTeleportPlayer_Callback(entity pl)
entity Teleport_Find(vector mi, vector ma)
void SUB_UseTargets_SkipTargets(entity this, entity actor, entity trigger, int skiptargets)
void WarpZoneLib_ExactTrigger_Init(entity this, bool unsetmodel)
#define IS_REAL_CLIENT(v)
#define FOREACH_CLIENT(cond, body)
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt().