Xonotic
onslaught.qc
Go to the documentation of this file.
1 #include "onslaught.qh"
2 
4 
5 #ifdef GAMEQC
6 REGISTER_NET_LINKED(ENT_ONSCAMERA)
7 #endif
8 
9 #ifdef CSQC
10 
11 entity generator_camera;
12 NET_HANDLE(ENT_ONSCAMERA, bool isnew)
13 {
14  this.origin = ReadVector();
15  setorigin(this, this.origin);
16 
17  this.angles = ReadAngleVector();
18 
19  this.drawmask = MASK_NORMAL;
20  setmodel(this, MDL_Null); // give it a size for clientcamera
21  setsize(this, '-1 -1 -1', '1 1 1');
22 
23  generator_camera = this;
24  return true;
25 }
26 
27 REGISTER_MUTATOR(cl_ons, true);
28 
29 float ons_roundlost;
30 vector generator_origin;
31 vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
32 float autocvar_cl_eventchase_generator_distance = 400;
34 {
35  ons_roundlost = STAT(ROUNDLOST);
36  entity gen = NULL;
37  if(ons_roundlost)
38  {
39  IL_EACH(g_onsgenerators, GetResource(it, RES_HEALTH) <= 0,
40  {
41  gen = it;
42  break;
43  });
44  if(!gen)
45  ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
46  }
47 
48  if(ons_roundlost)
49  {
50  generator_origin = gen.origin;
51  return true;
52  }
53  return false;
54 }
55 
56 MUTATOR_HOOKFUNCTION(cl_ons, CustomizeEventchase)
57 {
58  if(ons_roundlost)
59  {
60  M_ARGV(0, vector) = generator_camera.origin;
61  M_ARGV(1, vector) = autocvar_cl_eventchase_generator_viewoffset;
62  M_ARGV(0, float) = autocvar_cl_eventchase_generator_distance;
63  return true;
64  }
65  return false;
66 }
67 
68 #endif
#define IL_EACH(this, cond, body)
#define REGISTER_NET_LINKED(id)
Definition: net.qh:67
#define REGISTER_MUTATOR(id, dependence)
Definition: base.qh:263
entity() spawn
int WantEventchase(entity this, bool want_vehiclechase)
Definition: view.qc:590
#define NET_HANDLE(id, param)
Definition: net.qh:12
origin
Definition: ent_cs.qc:114
#define setmodel(this, m)
Definition: model.qh:26
RES_HEALTH
Definition: ent_cs.qc:126
#define NULL
Definition: post.qh:17
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
#define M_ARGV(x, type)
Definition: events.qh:17
float drawmask
Definition: csprogsdefs.qc:95
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
setorigin(ent, v)
vector angles
Definition: csprogsdefs.qc:104
#define MUTATOR_HOOKFUNCTION(...)
Definition: base.qh:310