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

Go to the source code of this file.

Functions

 spawnfunc (target_viewlocation)
 spawnfunc (target_viewlocation_end)
 spawnfunc (target_viewlocation_start)
 spawnfunc (trigger_viewlocation)
bool trigger_viewloc_send (entity this, entity to, int sf)
void viewloc_init (entity this)
void viewloc_link (entity this)
bool viewloc_send (entity this, entity to, int sf)
void viewloc_think (entity this)

Variables

float angle

Function Documentation

◆ spawnfunc() [1/4]

spawnfunc ( target_viewlocation )

Definition at line 134 of file viewloc.qc.

135{
136 spawnfunc_target_viewlocation_start(this);
137}

◆ spawnfunc() [2/4]

spawnfunc ( target_viewlocation_end )

Definition at line 127 of file viewloc.qc.

128{
129 this.cnt = 2;
130 viewloc_link(this);
131}
float cnt
Definition powerups.qc:24
void viewloc_link(entity this)
Definition viewloc.qc:115

References cnt, and viewloc_link().

◆ spawnfunc() [3/4]

spawnfunc ( target_viewlocation_start )

Definition at line 122 of file viewloc.qc.

123{
124 this.cnt = 1;
125 viewloc_link(this);
126}

References cnt, and viewloc_link().

◆ spawnfunc() [4/4]

spawnfunc ( trigger_viewlocation )

Definition at line 92 of file viewloc.qc.

93{
94 // we won't check target2 here yet, as it may not even need to exist
95 if(this.target == "") { LOG_INFO("^1FAIL!"); delete(this); return; }
96
99}
const int INITPRIO_FINDTARGET
Definition constants.qh:96
#define LOG_INFO(...)
Definition log.qh:65
void viewloc_init(entity this)
Definition viewloc.qc:65
string target
Definition triggers.qh:55
void WarpZoneLib_ExactTrigger_Init(entity this, bool unsetmodel)
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209

References InitializeEntity(), INITPRIO_FINDTARGET, LOG_INFO, target, viewloc_init(), and WarpZoneLib_ExactTrigger_Init().

◆ trigger_viewloc_send()

bool trigger_viewloc_send ( entity this,
entity to,
int sf )

Definition at line 50 of file viewloc.qc.

51{
52 // CSQC doesn't need to know our origin (yet), as we're only available for referencing
53 WriteHeader(MSG_ENTITY, ENT_CLIENT_VIEWLOC_TRIGGER);
54
56
59
60 WriteVector(MSG_ENTITY, this.origin);
61
62 return true;
63}
int spawnflags
Definition ammo.qh:15
vector origin
const int MSG_ENTITY
Definition net.qh:115
#define WriteHeader(to, id)
Definition net.qh:221
entity goalentity
Definition viewloc.qh:16
void WriteEntity(entity data, float dest, float desto)
void WriteByte(float data, float dest, float desto)
entity enemy
Definition sv_ctf.qh:153

References enemy, entity(), goalentity, MSG_ENTITY, origin, spawnflags, WriteByte(), WriteEntity(), and WriteHeader.

Referenced by viewloc_init().

◆ viewloc_init()

void viewloc_init ( entity this)

Definition at line 65 of file viewloc.qc.

66{
67 entity e;
68 for(e = NULL; (e = find(e, targetname, this.target)); )
69 if(e.classname == "target_viewlocation_start")
70 {
71 this.enemy = e;
72 break;
73 }
74 for(e = NULL; (e = find(e, targetname, this.target2)); )
75 if(e.classname == "target_viewlocation_end")
76 {
77 this.goalentity = e;
78 break;
79 }
80
81 if(!this.enemy) { LOG_INFO("^1FAIL!"); delete(this); return; }
82
83 if(!this.goalentity)
84 this.goalentity = this.enemy; // make them match so CSQC knows what to do
85
86 Net_LinkEntity(this, false, 0, trigger_viewloc_send);
87
89 this.nextthink = time;
90}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float time
float nextthink
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
void viewloc_think(entity this)
Definition viewloc.qc:16
bool trigger_viewloc_send(entity this, entity to, int sf)
Definition viewloc.qc:50
entity find(entity start,.string field, string match)
#define NULL
Definition post.qh:14
#define setthink(e, f)
string target2
string targetname
Definition triggers.qh:56

References enemy, entity(), find(), goalentity, LOG_INFO, Net_LinkEntity(), nextthink, NULL, setthink, target, target2, targetname, time, trigger_viewloc_send(), and viewloc_think().

Referenced by spawnfunc().

◆ viewloc_link()

void viewloc_link ( entity this)

Definition at line 115 of file viewloc.qc.

116{
117 if(this.angle)
118 this.angles_y = this.angle;
119 Net_LinkEntity(this, false, 0, viewloc_send);
120}
angles_y
Definition ent_cs.qc:119
float angle
Definition viewloc.qc:114
bool viewloc_send(entity this, entity to, int sf)
Definition viewloc.qc:101

References angle, angles_y, entity(), Net_LinkEntity(), and viewloc_send().

Referenced by spawnfunc(), and spawnfunc().

◆ viewloc_send()

bool viewloc_send ( entity this,
entity to,
int sf )

Definition at line 101 of file viewloc.qc.

102{
103 WriteHeader(MSG_ENTITY, ENT_CLIENT_VIEWLOC);
104
105 WriteByte(MSG_ENTITY, this.cnt);
106
107 WriteVector(MSG_ENTITY, this.origin);
108
109 WriteAngleVector(MSG_ENTITY, this.angles);
110
111 return true;
112}
ent angles
Definition ent_cs.qc:121

References angles, cnt, entity(), MSG_ENTITY, origin, WriteByte(), and WriteHeader.

Referenced by viewloc_link().

◆ viewloc_think()

void viewloc_think ( entity this)

Definition at line 16 of file viewloc.qc.

17{
18 // we abuse this method, rather than using normal .touch, because touch isn't reliable with multiple clients inside the same trigger, and can't "untouch" entities
19
20 // set myself as current viewloc where possible
21#if 1
22 FOREACH_CLIENT(IS_PLAYER(it) && it.viewloc == this,
23 {
24 it.viewloc = NULL;
25 });
26#else
27 entity e;
28 for(e = NULL; (e = findentity(e, viewloc, this)); )
29 e.viewloc = NULL;
30#endif
31
32#if 1
33 FOREACH_CLIENT(!it.viewloc && IS_PLAYER(it),
34 {
35 if (WarpZoneLib_ExactTrigger_Touch(this, it, false))
36 it.viewloc = this;
37 });
38#else
39 for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain)
40 if(!e.viewloc)
41 if(IS_PLAYER(e)) // should we support non-player entities with this?
42 //if(!IS_DEAD(e)) // death view is handled separately, we can't override this just yet
43 if (WarpZoneLib_ExactTrigger_Touch(this, it, false))
44 e.viewloc = this;
45#endif
46
47 this.nextthink = time;
48}
#define IS_PLAYER(s)
Definition player.qh:243
vector absmax
vector absmin
bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher, bool touchfunc)
Definition common.qc:815
entity viewloc
Definition viewloc.qh:13
entity findentity(entity start,.entity field, entity match)
float vlen(vector v)
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References absmax, absmin, entity(), findentity(), FOREACH_CLIENT, IS_PLAYER, nextthink, NULL, time, viewloc, vlen(), and WarpZoneLib_ExactTrigger_Touch().

Referenced by viewloc_init().

Variable Documentation

◆ angle