Xonotic
server.qc File Reference
#include "server.qh"
#include "common.qh"
+ Include dependency graph for server.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WarpZone_StoreProjectileData(e_)
 

Functions

float WarpZone_Projectile_Touch (entity this, entity toucher)
 
float WarpZone_Teleport (entity wz, entity player, float f0, float f1)
 
void WarpZone_TeleportPlayer (entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
 
void WarpZone_Touch (entity this, entity toucher)
 

Variables

vector warpzone_oldangles
 
vector warpzone_oldorigin
 
vector warpzone_oldvelocity
 
vector warpzone_save_angles
 
vector warpzone_save_eangles
 
vector warpzone_save_eorigin
 
vector warpzone_save_origin
 
float warpzone_teleport_finishtime
 
float warpzone_teleport_time
 
entity warpzone_teleport_zone
 

Macro Definition Documentation

◆ WarpZone_StoreProjectileData

#define WarpZone_StoreProjectileData (   e_)
Value:
MACRO_BEGIN \
entity e = e_; \
e.warpzone_oldorigin = e.origin; \
e.warpzone_oldvelocity = e.velocity; \
e.warpzone_oldangles = e.angles; \
MACRO_END

Definition at line 38 of file server.qc.

Referenced by WarpZone_Projectile_Touch(), and WarpZone_Teleport().

Function Documentation

◆ WarpZone_Projectile_Touch()

float WarpZone_Projectile_Touch ( entity  this,
entity  toucher 
)

Definition at line 382 of file server.qc.

References aiment, angles, BITSET_ASSIGN, checkpvs(), cross, CS(), EF_NODEPTHTEST, effects, enemy, entity(), error(), find(), FOREACH_CLIENT, g_projectiles, g_warpzones, IL_EACH, IL_PUSH(), IS_CLIENT, IS_OBSERVER, IS_PLAYER, IS_REAL_CLIENT, killtarget, LOG_INFO, maxs, mins, model, modelscale, nextthink, normalize(), NULL, origin, ping, random(), scale, setorigin(), setSendEntity, setthink, Simple_TeleportPlayer(), solid, SOLID_BSP, SOLID_NOT, spawnflags, spawnfunc(), string_null, target, targetname, Teleport_Find(), time, trace_allsolid, trace_dphitcontents, trace_dphitq3surfaceflags, trace_dphittexturename, trace_dpstartcontents, trace_endpos, trace_ent, trace_fraction, trace_inopen, trace_inwater, trace_plane_dist, trace_plane_normal, trace_startsolid, use, v_angle, vdist, vectoangles(), vector(), vlen(), vtos(), warpzone_angles, WarpZone_Camera_SetUp(), warpzone_cameras_exist, WarpZone_Find(), warpzone_origin, WarpZone_PlaneDist(), WarpZone_PostInitialize_Callback(), WarpZone_Projectile_Touch_ImpactFilter_Callback(), warpzone_save_angles, warpzone_save_eangles, warpzone_save_eorigin, warpzone_save_origin, WarpZone_SetUp(), WarpZone_StoreProjectileData, WarpZone_Teleport(), warpzone_teleport_time, warpzone_teleport_zone, WarpZone_Touch(), WarpZone_TransformVAngles(), warpzone_warpzones_exist, WarpZoneLib_ExactTrigger_Init(), and WarpZoneLib_ExactTrigger_Touch().

383 {
384  if(toucher.classname == "trigger_warpzone")
385  return true;
386 
387  // no further impacts if we teleported this frame!
388  // this is because even if we did teleport, the engine still may raise
389  // touch events for the previous location
390  // engine now aborts moves on teleport, so this SHOULD not happen any more
391  // but if this is called from TouchAreaGrid of the projectile moving,
392  // then this won't do
393  if(time == this.warpzone_teleport_time)
394  return true;
395 
396 #ifdef SVQC
397 #ifdef WARPZONELIB_KEEPDEBUG
398  // this SEEMS to not happen at the moment, but if it did, it would be more reliable
399  {
400  float save_dpstartcontents;
401  float save_dphitcontents;
402  float save_dphitq3surfaceflags;
403  string save_dphittexturename;
404  float save_allsolid;
405  float save_startsolid;
406  float save_fraction;
407  vector save_endpos;
408  vector save_plane_normal;
409  float save_plane_dist;
410  entity save_ent;
411  float save_inopen;
412  float save_inwater;
413  save_dpstartcontents = trace_dpstartcontents;
414  save_dphitcontents = trace_dphitcontents;
415  save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
416  save_dphittexturename = trace_dphittexturename;
417  save_allsolid = trace_allsolid;
418  save_startsolid = trace_startsolid;
419  save_fraction = trace_fraction;
420  save_endpos = trace_endpos;
421  save_plane_normal = trace_plane_normal;
422  save_plane_dist = trace_plane_dist;
423  save_ent = trace_ent;
424  save_inopen = trace_inopen;
425  save_inwater = trace_inwater;
426  float f = WarpZone_CheckProjectileImpact(this);
427  if (f) return (f > 0);
428  trace_dpstartcontents = save_dpstartcontents;
429  trace_dphitcontents = save_dphitcontents;
430  trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
431  trace_dphittexturename = save_dphittexturename;
432  trace_allsolid = save_allsolid;
433  trace_startsolid = save_startsolid;
434  trace_fraction = save_fraction;
435  trace_endpos = save_endpos;
436  trace_plane_normal = save_plane_normal;
437  trace_plane_dist = save_plane_dist;
438  trace_ent = save_ent;
439  trace_inopen = save_inopen;
440  trace_inwater = save_inwater;
441  }
442 #endif
443 
445  return true;
446 #endif
447 
448  return false;
449 }
float trace_plane_dist
Definition: csprogsdefs.qc:39
float trace_dphitq3surfaceflags
float trace_dphitcontents
entity() spawn
bool WarpZone_Projectile_Touch_ImpactFilter_Callback(entity this, entity toucher)
Definition: common.qc:150
entity trace_ent
Definition: csprogsdefs.qc:40
string trace_dphittexturename
float trace_inopen
Definition: csprogsdefs.qc:41
float warpzone_teleport_time
Definition: server.qc:34
float trace_dpstartcontents
vector trace_endpos
Definition: csprogsdefs.qc:37
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float trace_inwater
Definition: csprogsdefs.qc:42
vector trace_plane_normal
Definition: csprogsdefs.qc:38
float trace_startsolid
Definition: csprogsdefs.qc:35
float trace_allsolid
Definition: csprogsdefs.qc:34
float time
Definition: csprogsdefs.qc:16
float trace_fraction
Definition: csprogsdefs.qc:36
+ Here is the call graph for this function:

◆ WarpZone_Teleport()

float WarpZone_Teleport ( entity  wz,
entity  player,
float  f0,
float  f1 
)

Definition at line 82 of file server.qc.

References EF_NODEPTHTEST, entity(), frametime, IS_NOT_A_CLIENT, IS_PLAYER, IS_VEHICLE, LOG_INFO, max(), MOVE_NOMONSTERS, MOVE_NORMAL, MOVE_WORLDONLY, NULL, setmodel, setorigin(), setSendEntity, setthink, time, trace_endpos, trace_startsolid, vector(), VF_CL_VIEWANGLES, vlen(), WarpZone_RefSys_Add(), WarpZone_StoreProjectileData, WarpZone_TargetPlaneDist(), WarpZone_TeleportPlayer(), WarpZone_TransformAngles(), WarpZone_TransformOrigin(), WarpZone_TransformVAngles(), WarpZone_TransformVelocity(), and WarpZoneLib_MoveOutOfSolid().

Referenced by WarpZone_Projectile_Touch(), and WarpZone_Touch().

83 {
84  vector o0, a0, v0, o1, a1, v1, o10;
85 
86  o0 = player.origin + player.view_ofs;
87  v0 = player.velocity;
88  a0 = player.angles;
89 
90  o10 = o1 = WarpZone_TransformOrigin(wz, o0);
91  v1 = WarpZone_TransformVelocity(wz, v0);
92  if (!IS_NOT_A_CLIENT(player))
93  a1 = WarpZone_TransformVAngles(wz, PHYS_INPUT_ANGLES(player));
94  else
95  a1 = WarpZone_TransformAngles(wz, a0);
96 
97  if(f0 != 0 || f1 != 0)
98  {
99  // retry last move but behind the warpzone!
100  // we must first go back as far as we can, then forward again, to not cause double touch events!
101 
102  tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
103  {
104  entity own;
105  own = player.owner;
106  player.owner = NULL;
107  tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
108  player.owner = own;
109  }
110  o1 = trace_endpos + player.view_ofs;
111 
112  float d, dv, md;
113  md = max(vlen(player.mins), vlen(player.maxs));
114  d = WarpZone_TargetPlaneDist(wz, o1);
115  dv = WarpZone_TargetPlaneDist(wz, v1);
116  if(d < 0)
117  o1 = o1 - v1 * (d / dv);
118  }
119 
120  // put him out of solid
121  tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
122  if(trace_startsolid)
123  {
124  setorigin(player, o1 - player.view_ofs);
125  if(WarpZoneLib_MoveOutOfSolid(player))
126  {
127  o1 = player.origin + player.view_ofs;
128  setorigin(player, o0 - player.view_ofs);
129  }
130  else
131  {
132  LOG_INFO("would have to put player in solid, won't do that");
133  setorigin(player, o0 - player.view_ofs);
134  return 0;
135  }
136  }
137 
138  // do the teleport
139  WarpZone_RefSys_Add(player, wz);
140  WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
142  player.warpzone_teleport_time = time;
143  player.warpzone_teleport_finishtime = time;
144  player.warpzone_teleport_zone = wz;
145 
146 #ifdef SVQC
147  // prevent further teleports back
148  float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
149  if(dt < PHYS_INPUT_FRAMETIME)
150  player.warpzone_teleport_finishtime += PHYS_INPUT_FRAMETIME - dt;
151 #endif
152 
153 #ifndef WARPZONE_USE_FIXANGLE
154  #ifdef SVQC
155  if(IS_VEHICLE(player) && player.owner)
156  player = player.owner; // hax
157  if(IS_PLAYER(player))
158  {
159  // instead of fixangle, send the transform to the client for smoother operation
160  player.fixangle = false;
161 
162  entity ts = new(warpzone_teleported);
163  setmodel(ts, MDL_Null);
164  setSendEntity(ts, WarpZone_Teleported_Send);
165  ts.SendFlags = 0xFFFFFF;
166  ts.drawonlytoclient = player;
167  setthink(ts, SUB_Remove);
168  ts.nextthink = time + 1;
169  ts.owner = player;
170  ts.enemy = wz;
171  ts.effects = EF_NODEPTHTEST;
172  ts.angles = wz.warpzone_transform;
173  }
174  #elif defined(CSQC)
175  setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(wz, getpropertyvec(VF_CL_VIEWANGLES)));
176  //if(checkextension("DP_CSQC_ROTATEMOVES"))
177  //CL_RotateMoves(wz.warpzone_transform);
178  #endif
179 #endif
180 
181  return 1;
182 }
const float VF_CL_VIEWANGLES
Definition: csprogsdefs.qc:194
bool WarpZoneLib_MoveOutOfSolid(entity e)
Definition: common.qc:826
entity() spawn
vector WarpZone_TransformOrigin(entity wz, vector v)
Definition: common.qc:499
const float MOVE_NORMAL
Definition: csprogsdefs.qc:252
#define WarpZone_StoreProjectileData(e_)
Definition: server.qc:38
const float EF_NODEPTHTEST
Definition: csprogsdefs.qc:304
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1
Definition: all.inc:654
#define setmodel(this, m)
Definition: model.qh:26
void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
Definition: server.qc:45
const float MOVE_NOMONSTERS
Definition: csprogsdefs.qc:253
vector WarpZone_TransformAngles(entity wz, vector v)
Definition: common.qc:509
vector WarpZone_TransformVAngles(entity wz, vector ang)
Definition: common.qc:514
void WarpZone_RefSys_Add(entity me, entity wz)
Definition: common.qc:714
#define setSendEntity(e, f)
Definition: self.qh:97
#define NULL
Definition: post.qh:17
float frametime
Definition: csprogsdefs.qc:17
#define LOG_INFO(...)
Definition: log.qh:70
float WarpZone_TargetPlaneDist(entity wz, vector v)
Definition: common.qc:494
vector trace_endpos
Definition: csprogsdefs.qc:37
#define IS_NOT_A_CLIENT(v)
was: (clienttype(v) == CLIENTTYPE_NOTACLIENT)
Definition: utils.qh:19
vector WarpZone_TransformVelocity(entity wz, vector v)
Definition: common.qc:504
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define IS_VEHICLE(v)
Definition: utils.qh:22
setorigin(ent, v)
#define setthink(e, f)
float trace_startsolid
Definition: csprogsdefs.qc:35
float MOVE_WORLDONLY
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WarpZone_TeleportPlayer()

void WarpZone_TeleportPlayer ( entity  teleporter,
entity  player,
vector  to,
vector  to_angles,
vector  to_velocity 
)

Definition at line 45 of file server.qc.

References angles, BITCLR_ASSIGN, BITXOR_ASSIGN, bot_aim_reset(), EF_TELEPORT_BIT, entity(), FL_ONGROUND, IS_BOT_CLIENT, IS_PLAYER, setorigin(), time, to, and WarpZone_PostTeleportPlayer_Callback().

Referenced by WarpZone_Teleport().

46 {
47 #ifdef SVQC
48  player.lastteleport_origin = player.origin;
49  player.lastteleporttime = time;
50 #endif
51  setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch
52  player.angles = to_angles;
53 #ifdef SVQC
54  player.oldorigin = to; // for DP's unsticking
55  player.fixangle = true;
56  if (IS_BOT_CLIENT(player))
57  {
58  // FIXME find a way to smooth view's angles change for bots too
59  player.v_angle = player.angles;
60  bot_aim_reset(player);
61  }
62 #endif
63  player.velocity = to_velocity;
64 
65  BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
66 
67  if(IS_PLAYER(player))
68  BITCLR_ASSIGN(player.flags, FL_ONGROUND);
69 
71 }
void bot_aim_reset(entity this)
Definition: aim.qc:170
float FL_ONGROUND
Definition: progsdefs.qc:240
entity to
Definition: self.qh:96
const int EF_TELEPORT_BIT
#define BITCLR_ASSIGN(a, b)
Definition: common.qh:101
void WarpZone_PostTeleportPlayer_Callback(entity pl)
Definition: teleporters.qc:294
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition: utils.qh:15
setorigin(ent, v)
#define BITXOR_ASSIGN(a, b)
Definition: common.qh:107
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WarpZone_Touch()

void WarpZone_Touch ( entity  this,
entity  toucher 
)

Definition at line 184 of file server.qc.

References BIT, BITSET_ASSIGN, bound(), enemy, entity(), frametime, IS_NOT_A_CLIENT, LOG_INFO, LOG_TRACE, max(), maxs, mins, modelindex, MOVETYPE_FOLLOW, MOVETYPE_NONE, origin, scale, sendflags, setorigin(), SUB_UseTargets_SkipTargets(), time, to, vector(), vlen(), vtos(), warpzone_angles, warpzone_fadeend, warpzone_fadestart, WarpZone_Find(), warpzone_isboxy, warpzone_origin, WarpZone_PlaneDist(), warpzone_targetangles, warpzone_targetorigin, WarpZone_Teleport(), WarpZoneLib_ExactTrigger_Touch(), WriteByte(), WriteCoord(), and WriteShort().

Referenced by WarpZone_Fade_PreDraw(), and WarpZone_Projectile_Touch().

185 {
186  if(toucher.classname == "trigger_warpzone")
187  return;
188 
189  if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
190  return;
191 
192  // FIXME needs a better check to know what is safe to teleport and what not
193  if(toucher.move_movetype == MOVETYPE_NONE || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity)
194  return;
195 
196  if(WarpZoneLib_ExactTrigger_Touch(this, toucher))
197  return;
198 
199  if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
200  return;
201 
202  float f;
203  // number of frames we need to go back:
204  // dist = 16*sqrt(2) qu
205  // dist ~ 24 qu
206  // 24 qu = v*t
207  // 24 qu = v*frametime*n
208  // n = 24 qu/(v*frametime)
209  // for clients go only one frame though, may be too irritating otherwise
210  // but max 0.25 sec = 0.25/frametime frames
211  // 24/(0.25/frametime)
212  // 96*frametime
213  float d;
214  d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
215  if(IS_NOT_A_CLIENT(toucher))
216  f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
217  else
218  f = -1;
219  if(WarpZone_Teleport(this, toucher, f, 0))
220  {
221 #ifdef SVQC
222  SUB_UseTargets_SkipTargets(this, toucher, toucher, BIT(1) | BIT(3)); // use toucher too?
223  SUB_UseTargets_SkipTargets(this.enemy, toucher, toucher, BIT(1) | BIT(2)); // use toucher too?
224 #endif
225  }
226  else
227  {
228  LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
229  }
230 }
float MOVETYPE_NONE
Definition: progsdefs.qc:246
float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
Definition: server.qc:82
bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
Definition: common.qc:798
void SUB_UseTargets_SkipTargets(entity this, entity actor, entity trigger, int skiptargets)
Definition: triggers.qc:368
float WarpZone_PlaneDist(entity wz, vector v)
Definition: common.qc:489
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
entity enemy
Definition: sv_ctf.qh:143
float frametime
Definition: csprogsdefs.qc:17
#define IS_NOT_A_CLIENT(v)
was: (clienttype(v) == CLIENTTYPE_NOTACLIENT)
Definition: utils.qh:19
float MOVETYPE_FOLLOW
#define LOG_TRACE(...)
Definition: log.qh:81
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ warpzone_oldangles

vector warpzone_oldangles

Definition at line 33 of file server.qc.

◆ warpzone_oldorigin

vector warpzone_oldorigin

Definition at line 33 of file server.qc.

◆ warpzone_oldvelocity

vector warpzone_oldvelocity

Definition at line 33 of file server.qc.

◆ warpzone_save_angles

vector warpzone_save_angles

Definition at line 28 of file server.qc.

Referenced by WarpZone_Projectile_Touch().

◆ warpzone_save_eangles

vector warpzone_save_eangles

Definition at line 30 of file server.qc.

Referenced by WarpZone_Projectile_Touch().

◆ warpzone_save_eorigin

vector warpzone_save_eorigin

Definition at line 29 of file server.qc.

Referenced by WarpZone_Projectile_Touch().

◆ warpzone_save_origin

vector warpzone_save_origin

Definition at line 27 of file server.qc.

Referenced by WarpZone_Projectile_Touch().

◆ warpzone_teleport_finishtime

float warpzone_teleport_finishtime

Definition at line 35 of file server.qc.

◆ warpzone_teleport_time

float warpzone_teleport_time

Definition at line 34 of file server.qc.

Referenced by WarpZone_Projectile_Touch().

◆ warpzone_teleport_zone

entity warpzone_teleport_zone

Definition at line 36 of file server.qc.

Referenced by WarpZone_Projectile_Touch().