Xonotic
vectormamamam.qc
Go to the documentation of this file.
1 #include "vectormamamam.qh"
2 #ifdef SVQC
3 // reusing some fields havocbots declared
4 .entity wp00, wp01, wp02, wp03;
5 
6 .float targetfactor, target2factor, target3factor, target4factor;
7 .vector targetnormal, target2normal, target3normal, target4normal;
8 
9 vector func_vectormamamam_origin(entity o, float timestep)
10 {
11  vector p;
12  entity e;
13  int myflags = o.spawnflags;
14  vector v = '0 0 0';
15 
16  e = o.wp00;
17  if(e)
18  {
19  p = e.origin + timestep * e.velocity;
20  if(myflags & PROJECT_ON_TARGETNORMAL)
21  v = v + (p * o.targetnormal) * o.targetnormal * o.targetfactor;
22  else
23  v = v + (p - (p * o.targetnormal) * o.targetnormal) * o.targetfactor;
24  }
25 
26  e = o.wp01;
27  if(e)
28  {
29  p = e.origin + timestep * e.velocity;
30  if(myflags & PROJECT_ON_TARGET2NORMAL)
31  v = v + (p * o.target2normal) * o.target2normal * o.target2factor;
32  else
33  v = v + (p - (p * o.target2normal) * o.target2normal) * o.target2factor;
34  }
35 
36  e = o.wp02;
37  if(e)
38  {
39  p = e.origin + timestep * e.velocity;
40  if(myflags & PROJECT_ON_TARGET3NORMAL)
41  v = v + (p * o.target3normal) * o.target3normal * o.target3factor;
42  else
43  v = v + (p - (p * o.target3normal) * o.target3normal) * o.target3factor;
44  }
45 
46  e = o.wp03;
47  if(e)
48  {
49  p = e.origin + timestep * e.velocity;
50  if(myflags & PROJECT_ON_TARGET4NORMAL)
51  v = v + (p * o.target4normal) * o.target4normal * o.target4factor;
52  else
53  v = v + (p - (p * o.target4normal) * o.target4normal) * o.target4factor;
54  }
55 
56  return v;
57 }
58 
59 void func_vectormamamam_controller_think(entity this)
60 {
62 
63  if(this.owner.active != ACTIVE_ACTIVE)
64  {
65  this.owner.velocity = '0 0 0';
66  return;
67  }
68 
69  if(this.owner.classname == "func_vectormamamam") // don't brake stuff if the func_vectormamamam was killtarget'ed
70  this.owner.velocity = (this.owner.destvec + func_vectormamamam_origin(this.owner, VECTORMAMAMAM_TIMESTEP) - this.owner.origin) * 10;
71 }
72 
73 void func_vectormamamam_findtarget(entity this)
74 {
75  if(this.target && this.target != "")
76  this.wp00 = find(NULL, targetname, this.target);
77 
78  if(this.target2 && this.target2 != "")
79  this.wp01 = find(NULL, targetname, this.target2);
80 
81  if(this.target3 && this.target3 != "")
82  this.wp02 = find(NULL, targetname, this.target3);
83 
84  if(this.target4 && this.target4 != "")
85  this.wp03 = find(NULL, targetname, this.target4);
86 
87  if(!this.wp00 && !this.wp01 && !this.wp02 && !this.wp03)
88  objerror(this, "No reference entity found, so there is nothing to move. Aborting.");
89 
90  this.destvec = this.origin - func_vectormamamam_origin(this, 0);
91 
92  entity controller = new_pure(func_vectormamamam_controller);
93  controller.owner = this;
94  controller.nextthink = time + 1;
95  setthink(controller, func_vectormamamam_controller_think);
96 }
97 
98 void func_vectormamamam_setactive(entity this, int astate)
99 {
100  if (astate == ACTIVE_TOGGLE)
101  {
102  if(this.active == ACTIVE_ACTIVE)
103  this.active = ACTIVE_NOT;
104  else
105  this.active = ACTIVE_ACTIVE;
106  }
107  else
108  this.active = astate;
109 
110  if(this.active == ACTIVE_NOT)
111  {
112  stopsound(this, CH_TRIGGER_SINGLE);
113  }
114  else
115  {
116  if(this.noise && this.noise != "")
117  {
119  }
120  }
121 }
122 
123 void func_vectormamamam_init_for_player(entity this, entity player)
124 {
125  if (this.noise && this.noise != "" && this.active == ACTIVE_ACTIVE && IS_REAL_CLIENT(player))
126  {
127  msg_entity = player;
128  soundto(MSG_ONE, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE, 0);
129  }
130 }
131 
132 spawnfunc(func_vectormamamam)
133 {
134  if (this.noise != "")
135  {
136  precache_sound(this.noise);
137  }
138 
139  if(!this.targetfactor)
140  this.targetfactor = 1;
141 
142  if(!this.target2factor)
143  this.target2factor = 1;
144 
145  if(!this.target3factor)
146  this.target3factor = 1;
147 
148  if(!this.target4factor)
149  this.target4factor = 1;
150 
151  if(this.targetnormal)
152  this.targetnormal = normalize(this.targetnormal);
153 
154  if(this.target2normal)
155  this.target2normal = normalize(this.target2normal);
156 
157  if(this.target3normal)
158  this.target3normal = normalize(this.target3normal);
159 
160  if(this.target4normal)
161  this.target4normal = normalize(this.target4normal);
162 
163  setblocked(this, generic_plat_blocked);
164  if(this.dmg && (!this.message || this.message == ""))
165  this.message = " was squished";
166  if(this.dmg && (!this.message2 || this.message2 == ""))
167  this.message2 = "was squished by";
168  if(this.dmg && (!this.dmgtime))
169  this.dmgtime = 0.25;
170  this.dmgtime2 = time;
171 
172  if (!InitMovingBrushTrigger(this))
173  return;
174 
175  // wait for targets to spawn
176  this.nextthink = this.ltime + 999999999;
177  setthink(this, SUB_NullThink); // for PushMove
178 
179  // Savage: Reduce bandwith, critical on e.g. nexdm02
180  this.effects |= EF_LOWPRECISION;
181 
182  this.setactive = func_vectormamamam_setactive;
183  this.setactive(this, ACTIVE_ACTIVE);
184 
185  // maybe send sound to new players
186  IL_PUSH(g_initforplayer, this);
187  this.init_for_player = func_vectormamamam_init_for_player;
188 
189  InitializeEntity(this, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
190 }
191 #endif
entity wp02
Definition: api.qh:56
string noise
Definition: progsdefs.qc:209
vector destvec
Definition: subs.qh:35
const int ACTIVE_TOGGLE
Definition: defs.qh:40
string target3
Definition: subs.qh:54
const float VECTORMAMAMAM_TIMESTEP
Definition: vectormamamam.qh:8
entity() spawn
entity wp00
Definition: api.qh:56
entity wp03
Definition: api.qh:56
float dmg
Definition: platforms.qh:6
const int PROJECT_ON_TARGET3NORMAL
Definition: vectormamamam.qh:5
spawnfunc(info_player_attacker)
Definition: sv_assault.qc:283
origin
Definition: ent_cs.qc:114
float ltime
Definition: progsdefs.qc:107
float effects
Definition: csprogsdefs.qc:111
entity owner
Definition: main.qh:73
IntrusiveList g_initforplayer
Definition: client.qh:373
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
entity msg_entity
Definition: progsdefs.qc:63
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
const int PROJECT_ON_TARGETNORMAL
Definition: vectormamamam.qh:3
const int ACTIVE_ACTIVE
Definition: defs.qh:37
string message
Definition: powerups.qc:19
#define NULL
Definition: post.qh:17
const float VOL_BASE
Definition: sound.qh:36
float nextthink
Definition: csprogsdefs.qc:121
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
string target2
Definition: sv_onslaught.qh:45
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void SUB_NullThink(entity this)
Definition: subs.qc:3
float dmgtime
Definition: platforms.qh:7
vector v
Definition: ent_cs.qc:116
void InitializeEntity(entity e, void(entity this) func, int order)
Definition: world.qc:2146
#define _sound(e, c, s, v, a)
Definition: sound.qh:50
string targetname
Definition: progsdefs.qc:194
float dmgtime2
Definition: platforms.qh:8
const int PROJECT_ON_TARGET2NORMAL
Definition: vectormamamam.qh:4
void generic_plat_blocked(entity this, entity blocker)
Definition: platforms.qc:3
int active
Definition: defs.qh:34
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
#define setthink(e, f)
entity wp01
Definition: api.qh:56
string target
Definition: progsdefs.qc:193
const int ACTIVE_NOT
Definition: defs.qh:36
float time
Definition: csprogsdefs.qc:16
const int PROJECT_ON_TARGET4NORMAL
Definition: vectormamamam.qh:6
float EF_LOWPRECISION
const float ATTEN_IDLE
Definition: sound.qh:32
string target4
Definition: subs.qh:55