26#define PORTALS_ARE_NOT_SOLID
40 ((v.x < 0) ? p.mins.x : p.maxs.x),
41 ((v.y < 0) ? p.mins.y : p.maxs.y),
42 ((v.z < 0) ? p.mins.z : p.maxs.z));
49 vector old_forward, old_up;
51 vector new_forward, new_up;
62#if !(POSITIVE_PITCH_IS_DOWN)
86 if(new_forward.z > 0.7 || new_forward.z < -0.7)
91 if(new_up * new_yawforward < 0)
103#if !(POSITIVE_PITCH_IS_DOWN)
113 vector from, to, safe, step, transform,
ang, newvel;
114 float planeshift, s, t;
116 if (!teleporter.enemy)
118 backtrace(
"Portal_TeleportPlayer called without other portal being set. Stop.");
122 from = teleporter.origin;
123 transform = teleporter.portal_transform;
125 to = teleporter.enemy.origin;
143 s = (to - teleporter.enemy.origin) *
v_right;
144 t = (to - teleporter.enemy.origin) *
v_up;
145 s =
bound(-48, s, 48);
146 t =
bound(-48, t, 48);
147 to = teleporter.enemy.origin
152 safe = teleporter.enemy.portal_safe_origin;
157 LOG_INFO(
"'safe' teleport location is not safe!");
165 LOG_INFO(
"trace_endpos in solid, this can't be!");
183 if (!teleporter.enemy)
185 backtrace(
"Portal_TeleportPlayer ended up without other portal being set BEFORE TeleportPlayer. Stop.");
194 if(
time < teleporter.teleport_time + 1)
199 player.pusher = portal_owner;
204 if (!teleporter.enemy)
206 backtrace(
"Portal_TeleportPlayer ended up without other portal being set AFTER TeleportPlayer. Stop.");
211 teleporter.portal_wants_to_vanish = 0;
234 portal.portal_safe_origin = portal.origin;
235 setorigin(portal, o);
241 float dist, distpersec, delta;
244 dist = (eorg - porg) * pnorm;
245 dist +=
min(emins.x * pnorm.x, emaxs.x * pnorm.x);
246 dist +=
min(emins.y * pnorm.y, emaxs.y * pnorm.y);
247 dist +=
min(emins.z * pnorm.z, emaxs.z * pnorm.z);
250#ifdef PORTALS_ARE_NOT_SOLID
251 distpersec = evel * pnorm;
255 delta = dist / distpersec;
256 v = eorg - evel * delta - porg;
257 v = v - pnorm * (pnorm * v);
258 return vlen(v) < psize;
268#ifdef PORTALS_ARE_NOT_SOLID
277 if(
toucher.classname ==
"item_flag_team")
280 if(
toucher.classname ==
"grapplinghook")
288 error(
"Portal_Touch called for a broken portal\n");
290#ifdef PORTALS_ARE_NOT_SOLID
298 if(
toucher.classname ==
"porto")
300 if(
toucher.portal_id ==
this.portal_id)
313 if(
toucher.aiment !=
this.aiment)
332 if(
toucher.classname ==
"porto")
344 portal.nextthink = 0;
355 portal.nextthink = 0;
366 portal.nextthink =
time;
377 portal.nextthink = 0;
383 teleporter.enemy =
NULL;
384 destination.enemy =
NULL;
393 teleporter.enemy = destination;
394 destination.enemy = teleporter;
398 destination.fade_time = teleporter.fade_time;
399 teleporter.portal_wants_to_vanish = 0;
400 destination.portal_wants_to_vanish = 0;
401 teleporter.teleport_time =
time;
402#ifdef PORTALS_ARE_NOT_SOLID
407 setorigin(teleporter, teleporter.origin);
421 if(portal == portal.aiment.portal_in)
422 portal.aiment.portal_in =
NULL;
423 if(portal == portal.aiment.portal_out)
424 portal.aiment.portal_out =
NULL;
445 if(deathtype == DEATH_TELEFRAG.m_id)
447 if(attacker != this.
aiment)
472#ifdef PORTALS_ARE_NOT_SOLID
478 error(
"Portal_Think called for a broken portal\n");
499 if(it.(weaponentity).hook)
516 client = client.enemy;
557 own.portal_in = portal;
560 own.portal_out.portal_id = portal.portal_id;
573 own.portal_out = portal;
576 own.portal_in.portal_id = portal.portal_id;
602 portal.nextthink =
time;
619 if(own.portal_in.portal_id ==
id)
626 if(own.portal_out.portal_id ==
id)
642 portal =
new(portal);
644 setorigin(portal,
org);
647 portal.angles_x = -portal.angles.x;
649 portal.nextthink = 0;
650 portal.portal_activatetime =
time + 0.1;
656 portal.savemodelindex = portal.modelindex;
665 setsize(portal,
'-48 -48 -48',
'48 48 48');
685 portal.portal_id = portal_id_val;
705 portal.portal_id = portal_id_val;
#define MUTATOR_CALLHOOK(id,...)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
#define setmodel(this, m)
#define PHYS_INPUT_BUTTON_CHAT(s)
#define autocvar_sv_gravity
float CheckWireframeBox(entity forent, vector v0, vector dvx, vector dvy, vector dvz)
const vector PL_MIN_CONST
const vector PL_MAX_CONST
const float MOVE_NOMONSTERS
const float SOLID_TRIGGER
vector trace_plane_normal
float autocvar_g_maxpushtime
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
#define move_out_of_solid(e)
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
vector portal_safe_origin
vector Portal_ApplyTransformToPlayerAngle(vector transform, vector vangle)
void Portal_Think(entity this)
float Portal_WillHitPlane(vector eorg, vector emins, vector emaxs, vector evel, vector porg, vector pnorm, float psize)
void Portal_Remove(entity portal, float killed)
float Portal_TeleportPlayer(entity teleporter, entity player, entity portal_owner)
float Portal_SetInPortal(entity own, entity portal)
float portal_wants_to_vanish
void Portal_ClearAllLater(entity own)
entity Portal_Spawn(entity own, vector org, vector ang)
void Portal_Disconnect(entity teleporter, entity destination)
void Portal_MakeOutPortal(entity portal)
float Portal_SpawnOutPortalAtTrace(entity own, vector dir, float portal_id_val)
float Portal_FindSafeOrigin(entity portal)
float PlayerEdgeDistance(entity p, vector v)
void Portal_ClearAll(entity own)
void Portal_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void Portal_MakeInPortal(entity portal)
void Portal_ClearWithID(entity own, float id)
void Portal_Think_TryTeleportPlayer(entity this, entity e, vector g, entity portal_owner)
float portal_activatetime
void Portal_MakeWaitingPortal(entity portal)
void Portal_Connect(entity teleporter, entity destination)
void Portal_ClearAll_PortalsOnly(entity own)
float Portal_SpawnInPortalAtTrace(entity own, vector dir, float portal_id_val)
bool Portal_Customize(entity this, entity client)
void Portal_MakeBrokenPortal(entity portal)
void Portal_RemoveLater(entity portal, float kill)
void Portal_ClearAllLater_PortalsOnly(entity own)
void Portal_RemoveLater_Think(entity this)
void Portal_Touch(entity this, entity toucher)
float Portal_SetOutPortal(entity own, entity portal)
float autocvar_g_balance_portal_health
float autocvar_g_balance_portal_lifetime
void W_Porto_Remove(entity p)
#define IS_INDEPENDENT_PLAYER(e)
#define sound(e, c, s, v, a)
void SUB_SetFade(entity ent, float vanish_time, float fading_time)
float autocvar_g_vehicles_teleportable
void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
#define TELEPORT_FLAGS_PORTAL
#define FOREACH_CLIENT(cond, body)
const int MAX_WEAPONSLOTS
entity weaponentities[MAX_WEAPONSLOTS]