Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
portals.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

vector Portal_ApplyTransformToPlayerAngle (vector transform, vector vangle)
void Portal_ClearAll (entity own)
void Portal_ClearAll_PortalsOnly (entity own)
void Portal_ClearAllLater (entity own)
void Portal_ClearWithID (entity own, float id)
float Portal_SpawnInPortalAtTrace (entity own, vector dir, float id)
float Portal_SpawnOutPortalAtTrace (entity own, vector dir, float id)
void Portal_Think (entity this)

Variables

float autocvar_g_balance_portal_health
float autocvar_g_balance_portal_lifetime
float portal_id
entity portal_in
entity portal_out

Function Documentation

◆ Portal_ApplyTransformToPlayerAngle()

vector Portal_ApplyTransformToPlayerAngle ( vector transform,
vector vangle )

Definition at line 47 of file portals.qc.

48{
49 vector old_forward, old_up;
50 vector old_yawforward;
51 vector new_forward, new_up;
52 vector new_yawforward;
53
54 vector ang;
55 ang = vangle;
56 /*
57 ang_x = bound(-89, mod(-ang_x + 180, 360) - 180, 89);
58 ang = AnglesTransform_ApplyToVAngles(transform, ang);
59 */
60
61 // PLAYERS use different math
62#if !(POSITIVE_PITCH_IS_DOWN)
63 ang.x = -ang.x;
64#endif
65
66 //print("reference: ", vtos(AnglesTransform_ApplyToVAngles(transform, ang)), "\n");
67
69 old_forward = v_forward;
70 old_up = v_up;
71 fixedmakevectors(ang.y * '0 1 0');
72 old_yawforward = v_forward;
73
74 // their aiming directions are portalled...
75 new_forward = AnglesTransform_Apply(transform, old_forward);
76 new_up = AnglesTransform_Apply(transform, old_up);
77 new_yawforward = AnglesTransform_Apply(transform, old_yawforward);
78
79 // but now find a new sense of direction
80 // this is NOT easy!
81 // assume new_forward points straight up.
82 // What is our yaw?
83 //
84 // new_up could now point forward OR backward... which direction to choose?
85
86 if(new_forward.z > 0.7 || new_forward.z < -0.7) // far up; in this case, the "up" vector points backwards
87 {
88 // new_yawforward and new_yawup define the new aiming half-circle
89 // we "just" need to find out whether new_up or -new_up is in that half circle
90 ang = fixedvectoangles(new_forward); // this still gets us a nice pitch value...
91 if(new_up * new_yawforward < 0)
92 new_up = -1 * new_up;
93 ang.y = vectoyaw(new_up); // this vector is the yaw we want
94 //print("UP/DOWN path: ", vtos(ang), "\n");
95 }
96 else
97 {
98 // good angles; here, "forward" suffices
99 ang = fixedvectoangles(new_forward);
100 //print("GOOD path: ", vtos(ang), "\n");
101 }
102
103#if !(POSITIVE_PITCH_IS_DOWN)
104 ang.x = -ang.x;
105#endif
106 ang.z = vangle.z;
107 return ang;
108}
vector AnglesTransform_Apply(vector transform, vector v)
void fixedmakevectors(vector a)
#define fixedvectoangles
vector v_up
vector v_forward
float vectoyaw(vector v)
vector
Definition self.qh:92
vector vector ang
Definition self.qh:92

References ang, AnglesTransform_Apply(), fixedmakevectors(), fixedvectoangles, v_forward, v_up, vector, and vectoyaw().

Referenced by Portal_TeleportPlayer().

◆ Portal_ClearAll()

void Portal_ClearAll ( entity own)

Definition at line 588 of file portals.qc.

589{
591 W_Porto_Remove(own);
592}
void Portal_ClearAll_PortalsOnly(entity own)
Definition portals.qc:581
void W_Porto_Remove(entity p)
Definition porto.qc:146

References entity(), Portal_ClearAll_PortalsOnly(), and W_Porto_Remove().

Referenced by checkpoint_passed(), ClientDisconnect(), and PutObserverInServer().

◆ Portal_ClearAll_PortalsOnly()

void Portal_ClearAll_PortalsOnly ( entity own)

Definition at line 581 of file portals.qc.

582{
583 if(own.portal_in)
584 Portal_Remove(own.portal_in, 0);
585 if(own.portal_out)
586 Portal_Remove(own.portal_out, 0);
587}
void Portal_Remove(entity portal, float killed)
Definition portals.qc:410

References entity(), and Portal_Remove().

Referenced by Portal_ClearAll(), and W_Porto_Touch().

◆ Portal_ClearAllLater()

void Portal_ClearAllLater ( entity own)

Definition at line 611 of file portals.qc.

612{
614 W_Porto_Remove(own);
615}
void Portal_ClearAllLater_PortalsOnly(entity own)
Definition portals.qc:604

References entity(), Portal_ClearAllLater_PortalsOnly(), and W_Porto_Remove().

Referenced by PlayerDamage().

◆ Portal_ClearWithID()

void Portal_ClearWithID ( entity own,
float id )

Definition at line 616 of file portals.qc.

617{
618 if(own.portal_in)
619 if(own.portal_in.portal_id == id)
620 {
621 if(own.portal_out)
622 Portal_Disconnect(own.portal_in, own.portal_out);
623 Portal_Remove(own.portal_in, 0);
624 }
625 if(own.portal_out)
626 if(own.portal_out.portal_id == id)
627 {
628 if(own.portal_in)
629 Portal_Disconnect(own.portal_in, own.portal_out);
630 Portal_Remove(own.portal_out, 0);
631 }
632}
void Portal_Disconnect(entity teleporter, entity destination)
Definition portals.qc:381

References entity(), Portal_Disconnect(), and Portal_Remove().

Referenced by W_Porto_Fail().

◆ Portal_SpawnInPortalAtTrace()

float Portal_SpawnInPortalAtTrace ( entity own,
vector dir,
float id )

Definition at line 671 of file portals.qc.

672{
673 entity portal;
674 vector ang;
675 vector org;
676
680
681 portal = Portal_Spawn(own, org, ang);
682 if(!portal)
683 return 0;
684
685 portal.portal_id = portal_id_val;
686 Portal_SetInPortal(own, portal);
687
688 return 1;
689}
#define fixedvectoangles2
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
vector trace_endpos
vector trace_plane_normal
float Portal_SetInPortal(entity own, entity portal)
Definition portals.qc:549
entity Portal_Spawn(entity own, vector org, vector ang)
Definition portals.qc:634
vector org
Definition self.qh:92
int dir
Definition impulse.qc:89

References ang, dir, entity(), fixedmakevectors(), fixedvectoangles2, org, Portal_SetInPortal(), Portal_Spawn(), trace_endpos, trace_plane_normal, and vector.

Referenced by W_Porto_Touch().

◆ Portal_SpawnOutPortalAtTrace()

float Portal_SpawnOutPortalAtTrace ( entity own,
vector dir,
float id )

Definition at line 691 of file portals.qc.

692{
693 entity portal;
694 vector ang;
695 vector org;
696
700
701 portal = Portal_Spawn(own, org, ang);
702 if(!portal)
703 return 0;
704
705 portal.portal_id = portal_id_val;
706 Portal_SetOutPortal(own, portal);
707
708 return 1;
709}
float Portal_SetOutPortal(entity own, entity portal)
Definition portals.qc:565

References ang, dir, entity(), fixedmakevectors(), fixedvectoangles2, org, Portal_SetOutPortal(), Portal_Spawn(), trace_endpos, trace_plane_normal, and vector.

Referenced by W_Porto_Touch().

◆ Portal_Think()

void Portal_Think ( entity this)

Definition at line 467 of file portals.qc.

468{
469 entity o;
470 vector g;
471
472#ifdef PORTALS_ARE_NOT_SOLID
473 // portal is being removed?
474 if(this.solid != SOLID_TRIGGER)
475 return; // possibly engine bug
476
477 if(!this.enemy)
478 error("Portal_Think called for a broken portal\n");
479
480 o = this.aiment;
481 this.solid = SOLID_BBOX;
482 this.aiment = NULL;
483
484 g = frametime * '0 0 -1' * autocvar_sv_gravity;
485
487
489 if(it != o)
491 continue; // cannot go through someone else's portal
492
493 if(it != o || time >= this.portal_activatetime)
494 Portal_Think_TryTeleportPlayer(this, it, g, o);
495
496 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
497 {
498 .entity weaponentity = weaponentities[slot];
499 if(it.(weaponentity).hook)
500 Portal_Think_TryTeleportPlayer(this, it.(weaponentity).hook, g, o);
501 }
502 });
503 this.solid = SOLID_TRIGGER;
504 this.aiment = o;
505#endif
506
507 this.nextthink = time;
508
509 if(this.fade_time && time > this.fade_time)
510 Portal_Remove(this, 0);
511}
#define IS_PLAYER(s)
Definition player.qh:243
#define autocvar_sv_gravity
Definition stats.qh:421
const float SOLID_TRIGGER
float frametime
const float SOLID_BBOX
float time
float nextthink
solid
Definition ent_cs.qc:165
entity aiment
Definition movetypes.qh:90
void Portal_Think_TryTeleportPlayer(entity this, entity e, vector g, entity portal_owner)
Definition portals.qc:455
float portal_activatetime
Definition portals.qc:34
#define NULL
Definition post.qh:14
#define error
Definition pre.qh:6
#define IS_INDEPENDENT_PLAYER(e)
Definition client.qh:312
float fade_time
Definition common.qh:23
vector mangle
Definition subs.qh:51
entity enemy
Definition sv_ctf.qh:153
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17

References aiment, autocvar_sv_gravity, enemy, entity(), error, fade_time, fixedmakevectors(), FOREACH_CLIENT, frametime, IS_INDEPENDENT_PLAYER, IS_PLAYER, mangle, MAX_WEAPONSLOTS, nextthink, NULL, portal_activatetime, Portal_Remove(), Portal_Think_TryTeleportPlayer(), solid, SOLID_BBOX, SOLID_TRIGGER, time, vector, and weaponentities.

Referenced by Portal_MakeInPortal(), and Portal_Spawn().

Variable Documentation

◆ autocvar_g_balance_portal_health

float autocvar_g_balance_portal_health

Definition at line 3 of file portals.qh.

Referenced by Portal_Spawn(), and Portal_TeleportPlayer().

◆ autocvar_g_balance_portal_lifetime

float autocvar_g_balance_portal_lifetime

Definition at line 4 of file portals.qh.

Referenced by Portal_Connect(), Portal_Spawn(), and Portal_TeleportPlayer().

◆ portal_id

float portal_id

Definition at line 6 of file portals.qh.

Referenced by W_Porto_Fail(), and W_Porto_Touch().

◆ portal_in

entity portal_in

Definition at line 7 of file portals.qh.

◆ portal_out

entity portal_out

Definition at line 7 of file portals.qh.