Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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
8
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
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
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;
96}
97
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 {
113 }
114 else
115 {
116 if(this.noise && this.noise != "")
117 {
119 }
120 }
121}
122
124{
125 if (this.noise && this.noise != "" && this.active == ACTIVE_ACTIVE && IS_REAL_CLIENT(player))
126 {
127 msg_entity = player;
129 }
130}
131
132spawnfunc(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)
153
154 if(this.target2normal)
156
157 if(this.target3normal)
159
160 if(this.target4normal)
162
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
187 this.init_for_player = func_vectormamamam_init_for_player;
188
190}
191#endif
float dmg
Definition breakable.qc:12
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
string message
Definition powerups.qc:19
entity owner
Definition main.qh:87
const int INITPRIO_FINDTARGET
Definition constants.qh:96
float effects
float time
float nextthink
vector origin
const int ACTIVE_TOGGLE
Definition defs.qh:40
const int ACTIVE_NOT
Definition defs.qh:36
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
float EF_LOWPRECISION
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float MSG_ONE
Definition menudefs.qc:56
entity find(entity start,.string field, string match)
string precache_sound(string sample)
vector normalize(vector v)
float ltime
Definition net.qc:10
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
void generic_plat_blocked(entity this, entity blocker)
Definition platforms.qc:3
float dmgtime
Definition platforms.qh:7
float dmgtime2
Definition platforms.qh:8
#define NULL
Definition post.qh:14
#define objerror
Definition pre.qh:8
entity msg_entity
Definition progsdefs.qc:63
#define setthink(e, f)
vector
Definition self.qh:92
#define setblocked(e, f)
IntrusiveList g_initforplayer
Definition client.qh:370
const int CH_TRIGGER_SINGLE
Definition sound.qh:13
const float VOL_BASE
Definition sound.qh:36
#define _sound(e, c, s, v, a)
Definition sound.qh:43
const float ATTEN_IDLE
Definition sound.qh:32
void stopsound(entity e, int chan)
Definition all.qc:109
void soundto(int _dest, entity e, int chan, string samp, float vol, float _atten, float _pitch)
Definition all.qc:74
#define spawnfunc(id)
Definition spawnfunc.qh:96
bool InitMovingBrushTrigger(entity this)
Definition subs.qc:577
void SUB_NullThink(entity this)
Definition subs.qc:3
vector destvec
Definition subs.qh:35
string noise
Definition subs.qh:83
string target4
Definition subs.qh:55
string target3
Definition subs.qh:54
string target2
string message2
Definition triggers.qh:19
string targetname
Definition triggers.qh:56
string target
Definition triggers.qh:55
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
void func_vectormamamam_init_for_player(entity this, entity player)
float target3factor
entity wp01
void func_vectormamamam_findtarget(entity this)
vector func_vectormamamam_origin(entity o, float timestep)
void func_vectormamamam_controller_think(entity this)
float target4factor
void func_vectormamamam_setactive(entity this, int astate)
entity wp03
vector target4normal
entity wp02
entity wp00
vector targetnormal
float target2factor
vector target2normal
vector target3normal
float targetfactor
const int PROJECT_ON_TARGETNORMAL
const int PROJECT_ON_TARGET2NORMAL
const float VECTORMAMAMAM_TIMESTEP
const int PROJECT_ON_TARGET3NORMAL
const int PROJECT_ON_TARGET4NORMAL
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209