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 t)
21 p = e.origin + t * e.velocity;
23 v = v + (p * o.targetnormal) * o.targetnormal * o.targetfactor;
25 v = v + (p - (p * o.targetnormal) * o.targetnormal) * o.targetfactor;
31 p = e.origin + t * e.velocity;
33 v = v + (p * o.target2normal) * o.target2normal * o.target2factor;
35 v = v + (p - (p * o.target2normal) * o.target2normal) * o.target2factor;
41 p = e.origin + t * e.velocity;
43 v = v + (p * o.target3normal) * o.target3normal * o.target3factor;
45 v = v + (p - (p * o.target3normal) * o.target3normal) * o.target3factor;
51 p = e.origin + t * e.velocity;
53 v = v + (p * o.target4normal) * o.target4normal * o.target4factor;
55 v = v + (p - (p * o.target4normal) * o.target4normal) * o.target4factor;
61 void func_vectormamamam_controller_think(entity this)
63 this.nextthink = time + 0.1;
65 if(this.owner.active != ACTIVE_ACTIVE)
67 this.owner.velocity = '0 0 0';
71 if(this.owner.classname == "func_vectormamamam") // don't brake stuff if the func_vectormamamam was killtarget'ed
72 this.owner.velocity = (this.owner.destvec + func_vectormamamam_origin(this.owner, 0.1) - this.owner.origin) * 10;
75 void func_vectormamamam_findtarget(entity this)
78 this.wp00 = find(NULL, targetname, this.target);
80 if(this.target2 != "")
81 this.wp01 = find(NULL, targetname, this.target2);
83 if(this.target3 != "")
84 this.wp02 = find(NULL, targetname, this.target3);
86 if(this.target4 != "")
87 this.wp03 = find(NULL, targetname, this.target4);
89 if(!this.wp00 && !this.wp01 && !this.wp02 && !this.wp03)
90 objerror(this, "No reference entity found, so there is nothing to move. Aborting.");
92 this.destvec = this.origin - func_vectormamamam_origin(this, 0);
95 controller = new(func_vectormamamam_controller);
96 controller.owner = this;
97 controller.nextthink = time + 1;
98 setthink(controller, func_vectormamamam_controller_think);
101 spawnfunc(func_vectormamamam)
103 if (this.noise != "")
105 precache_sound(this.noise);
106 soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
109 if(!this.targetfactor)
110 this.targetfactor = 1;
112 if(!this.target2factor)
113 this.target2factor = 1;
115 if(!this.target3factor)
116 this.target3factor = 1;
118 if(!this.target4factor)
119 this.target4factor = 1;
121 if(this.targetnormal)
122 this.targetnormal = normalize(this.targetnormal);
124 if(this.target2normal)
125 this.target2normal = normalize(this.target2normal);
127 if(this.target3normal)
128 this.target3normal = normalize(this.target3normal);
130 if(this.target4normal)
131 this.target4normal = normalize(this.target4normal);
133 setblocked(this, generic_plat_blocked);
134 if(this.dmg && (this.message == ""))
135 this.message = " was squished";
136 if(this.dmg && (this.message == ""))
137 this.message2 = "was squished by";
138 if(this.dmg && (!this.dmgtime))
140 this.dmgtime2 = time;
142 if(this.netname == "")
143 this.netname = "1 0 0 0 1";
145 if (!InitMovingBrushTrigger(this))
148 // wait for targets to spawn
149 this.nextthink = this.ltime + 999999999;
150 setthink(this, SUB_NullThink); // for PushMove
152 // Savage: Reduce bandwith, critical on e.g. nexdm02
153 this.effects |= EF_LOWPRECISION;
155 this.active = ACTIVE_ACTIVE;
157 InitializeEntity(this, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);