Xonotic
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.

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

Referenced by Portal_TeleportPlayer().

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 
68  fixedmakevectors(ang);
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 }
#define fixedvectoangles(a)
vector v_up
Definition: csprogsdefs.qc:31
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector AnglesTransform_Apply(vector transform, vector v)
#define fixedmakevectors
vector v_forward
Definition: csprogsdefs.qc:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Portal_ClearAll()

void Portal_ClearAll ( entity  own)

Definition at line 587 of file portals.qc.

References Portal_ClearAll_PortalsOnly().

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

588 {
590  W_Porto_Remove(own);
591 }
void Portal_ClearAll_PortalsOnly(entity own)
Definition: portals.qc:580
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Portal_ClearAll_PortalsOnly()

void Portal_ClearAll_PortalsOnly ( entity  own)

Definition at line 580 of file portals.qc.

References Portal_Remove().

Referenced by Portal_ClearAll().

581 {
582  if(own.portal_in)
583  Portal_Remove(own.portal_in, 0);
584  if(own.portal_out)
585  Portal_Remove(own.portal_out, 0);
586 }
void Portal_Remove(entity portal, float killed)
Definition: portals.qc:409
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Portal_ClearAllLater()

void Portal_ClearAllLater ( entity  own)

Definition at line 610 of file portals.qc.

References Portal_ClearAllLater_PortalsOnly().

Referenced by PlayerDamage().

611 {
613  W_Porto_Remove(own);
614 }
void Portal_ClearAllLater_PortalsOnly(entity own)
Definition: portals.qc:603
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Portal_ClearWithID()

void Portal_ClearWithID ( entity  own,
float  id 
)

Definition at line 615 of file portals.qc.

References Portal_Disconnect(), and Portal_Remove().

616 {
617  if(own.portal_in)
618  if(own.portal_in.portal_id == id)
619  {
620  if(own.portal_out)
621  Portal_Disconnect(own.portal_in, own.portal_out);
622  Portal_Remove(own.portal_in, 0);
623  }
624  if(own.portal_out)
625  if(own.portal_out.portal_id == id)
626  {
627  if(own.portal_in)
628  Portal_Disconnect(own.portal_in, own.portal_out);
629  Portal_Remove(own.portal_out, 0);
630  }
631 }
void Portal_Disconnect(entity teleporter, entity destination)
Definition: portals.qc:381
void Portal_Remove(entity portal, float killed)
Definition: portals.qc:409
+ Here is the call graph for this function:

◆ Portal_SpawnInPortalAtTrace()

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

Definition at line 670 of file portals.qc.

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

671 {
672  entity portal;
673  vector ang;
674  vector org;
675 
676  org = trace_endpos;
678  fixedmakevectors(ang);
679 
680  portal = Portal_Spawn(own, org, ang);
681  if(!portal)
682  return 0;
683 
684  portal.portal_id = portal_id_val;
685  Portal_SetInPortal(own, portal);
686 
687  return 1;
688 }
entity() spawn
vector trace_endpos
Definition: csprogsdefs.qc:37
entity Portal_Spawn(entity own, vector org, vector ang)
Definition: portals.qc:633
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float Portal_SetInPortal(entity own, entity portal)
Definition: portals.qc:548
vector trace_plane_normal
Definition: csprogsdefs.qc:38
int dir
Definition: impulse.qc:89
#define fixedmakevectors
#define fixedvectoangles2(a, b)
+ Here is the call graph for this function:

◆ Portal_SpawnOutPortalAtTrace()

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

Definition at line 690 of file portals.qc.

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

691 {
692  entity portal;
693  vector ang;
694  vector org;
695 
696  org = trace_endpos;
698  fixedmakevectors(ang);
699 
700  portal = Portal_Spawn(own, org, ang);
701  if(!portal)
702  return 0;
703 
704  portal.portal_id = portal_id_val;
705  Portal_SetOutPortal(own, portal);
706 
707  return 1;
708 }
entity() spawn
vector trace_endpos
Definition: csprogsdefs.qc:37
float Portal_SetOutPortal(entity own, entity portal)
Definition: portals.qc:564
entity Portal_Spawn(entity own, vector org, vector ang)
Definition: portals.qc:633
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector trace_plane_normal
Definition: csprogsdefs.qc:38
int dir
Definition: impulse.qc:89
#define fixedmakevectors
#define fixedvectoangles2(a, b)
+ Here is the call graph for this function:

◆ Portal_Think()

void Portal_Think ( entity  this)

Definition at line 466 of file portals.qc.

References aiment, 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().

467 {
468  entity o;
469  vector g;
470 
471 #ifdef PORTALS_ARE_NOT_SOLID
472  // portal is being removed?
473  if(this.solid != SOLID_TRIGGER)
474  return; // possibly engine bug
475 
476  if(!this.enemy)
477  error("Portal_Think called for a broken portal\n");
478 
479  o = this.aiment;
480  this.solid = SOLID_BBOX;
481  this.aiment = NULL;
482 
483  g = frametime * '0 0 -1' * autocvar_sv_gravity;
484 
485  fixedmakevectors(this.mangle);
486 
488  if(it != o)
490  continue; // cannot go through someone else's portal
491 
492  if(it != o || time >= this.portal_activatetime)
493  Portal_Think_TryTeleportPlayer(this, it, g, o);
494 
495  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
496  {
497  .entity weaponentity = weaponentities[slot];
498  if(it.(weaponentity).hook)
499  Portal_Think_TryTeleportPlayer(this, it.(weaponentity).hook, g, o);
500  }
501  });
502  this.solid = SOLID_TRIGGER;
503  this.aiment = o;
504 #endif
505 
506  this.nextthink = time;
507 
508  if(this.fade_time && time > this.fade_time)
509  Portal_Remove(this, 0);
510 }
#define IS_INDEPENDENT_PLAYER(e)
Definition: client.qh:314
entity() spawn
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
void Portal_Think_TryTeleportPlayer(entity this, entity e, vector g, entity portal_owner)
Definition: portals.qc:454
void Portal_Remove(entity portal, float killed)
Definition: portals.qc:409
entity enemy
Definition: sv_ctf.qh:143
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
#define NULL
Definition: post.qh:17
float frametime
Definition: csprogsdefs.qc:17
float nextthink
Definition: csprogsdefs.qc:121
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float fade_time
Definition: common.qh:22
const float SOLID_TRIGGER
Definition: csprogsdefs.qc:245
entity aiment
Definition: movetypes.qh:90
const float SOLID_BBOX
Definition: csprogsdefs.qc:246
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
vector mangle
Definition: subs.qh:51
float time
Definition: csprogsdefs.qc:16
float portal_activatetime
Definition: portals.qc:34
#define fixedmakevectors
#define IS_PLAYER(v)
Definition: utils.qh:9
float solid
Definition: csprogsdefs.qc:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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.

◆ 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.