1 #include "vectormamamam.qh"
3 // reusing some fields havocbots declared
4 .entity wp00, wp01, wp02, wp03;
6 .float targetfactor, target2factor, target3factor, target4factor;
7 .vector targetnormal, target2normal, target3normal, target4normal;
9 vector func_vectormamamam_origin(entity o, float timestep)
13 int myflags = o.spawnflags;
19 p = e.origin + timestep * e.velocity;
20 if(myflags & PROJECT_ON_TARGETNORMAL)
21 v = v + (p * o.targetnormal) * o.targetnormal * o.targetfactor;
23 v = v + (p - (p * o.targetnormal) * o.targetnormal) * o.targetfactor;
29 p = e.origin + timestep * e.velocity;
30 if(myflags & PROJECT_ON_TARGET2NORMAL)
31 v = v + (p * o.target2normal) * o.target2normal * o.target2factor;
33 v = v + (p - (p * o.target2normal) * o.target2normal) * o.target2factor;
39 p = e.origin + timestep * e.velocity;
40 if(myflags & PROJECT_ON_TARGET3NORMAL)
41 v = v + (p * o.target3normal) * o.target3normal * o.target3factor;
43 v = v + (p - (p * o.target3normal) * o.target3normal) * o.target3factor;
49 p = e.origin + timestep * e.velocity;
50 if(myflags & PROJECT_ON_TARGET4NORMAL)
51 v = v + (p * o.target4normal) * o.target4normal * o.target4factor;
53 v = v + (p - (p * o.target4normal) * o.target4normal) * o.target4factor;
59 void func_vectormamamam_controller_think(entity this)
61 this.nextthink = time + VECTORMAMAMAM_TIMESTEP;
63 if(this.owner.active != ACTIVE_ACTIVE)
65 this.owner.velocity = '0 0 0';
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;
73 void func_vectormamamam_findtarget(entity this)
75 if(this.target && this.target != "")
76 this.wp00 = find(NULL, targetname, this.target);
78 if(this.target2 && this.target2 != "")
79 this.wp01 = find(NULL, targetname, this.target2);
81 if(this.target3 && this.target3 != "")
82 this.wp02 = find(NULL, targetname, this.target3);
84 if(this.target4 && this.target4 != "")
85 this.wp03 = find(NULL, targetname, this.target4);
87 if(!this.wp00 && !this.wp01 && !this.wp02 && !this.wp03)
88 objerror(this, "No reference entity found, so there is nothing to move. Aborting.");
90 this.destvec = this.origin - func_vectormamamam_origin(this, 0);
92 entity controller = new_pure(func_vectormamamam_controller);
93 controller.owner = this;
94 controller.nextthink = time + 1;
95 setthink(controller, func_vectormamamam_controller_think);
98 void func_vectormamamam_setactive(entity this, int astate)
100 if (astate == ACTIVE_TOGGLE)
102 if(this.active == ACTIVE_ACTIVE)
103 this.active = ACTIVE_NOT;
105 this.active = ACTIVE_ACTIVE;
108 this.active = astate;
110 if(this.active == ACTIVE_NOT)
112 stopsound(this, CH_TRIGGER_SINGLE);
116 if(this.noise && this.noise != "")
118 _sound(this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
123 void func_vectormamamam_init_for_player(entity this, entity player)
125 if (this.noise && this.noise != "" && this.active == ACTIVE_ACTIVE && IS_REAL_CLIENT(player))
128 soundto(MSG_ONE, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE, 0);
132 spawnfunc(func_vectormamamam)
134 if (this.noise != "")
136 precache_sound(this.noise);
139 if(!this.targetfactor)
140 this.targetfactor = 1;
142 if(!this.target2factor)
143 this.target2factor = 1;
145 if(!this.target3factor)
146 this.target3factor = 1;
148 if(!this.target4factor)
149 this.target4factor = 1;
151 if(this.targetnormal)
152 this.targetnormal = normalize(this.targetnormal);
154 if(this.target2normal)
155 this.target2normal = normalize(this.target2normal);
157 if(this.target3normal)
158 this.target3normal = normalize(this.target3normal);
160 if(this.target4normal)
161 this.target4normal = normalize(this.target4normal);
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))
170 this.dmgtime2 = time;
172 if (!InitMovingBrushTrigger(this))
175 // wait for targets to spawn
176 this.nextthink = this.ltime + 999999999;
177 setthink(this, SUB_NullThink); // for PushMove
179 // Savage: Reduce bandwith, critical on e.g. nexdm02
180 this.effects |= EF_LOWPRECISION;
182 this.setactive = func_vectormamamam_setactive;
183 this.setactive(this, ACTIVE_ACTIVE);
185 // maybe send sound to new players
186 IL_PUSH(g_initforplayer, this);
187 this.init_for_player = func_vectormamamam_init_for_player;
189 InitializeEntity(this, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);