1 #define ewheel_amin_stop 0
2 #define ewheel_amin_fwd_slow 1
3 #define ewheel_amin_fwd_fast 2
4 #define ewheel_amin_bck_slow 3
5 #define ewheel_amin_bck_fast 4
7 void turret_ewheel_projectile_explode()
12 d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_EWHEEL, world);
13 self.owner.tur_dbg_dmg_t_h = self.owner.tur_dbg_dmg_t_h + d;
14 self.owner.tur_dbg_dmg_t_f = self.owner.tur_dbg_dmg_t_f + self.owner.shot_dmg;
16 RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, world, self.owner.shot_force, DEATH_TURRET_EWHEEL, world);
28 for (i = 0; i < 1; ++i)
30 turret_do_updates(self);
32 sound (self, CHAN_WEAPON, "weapons/lasergun_fire.wav", VOL_BASE, ATTN_NORM);
33 pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
36 setorigin(proj, self.tur_shotorg);
37 proj.classname = "ewheel bolt";
39 proj.bot_dodge = FALSE;
40 proj.bot_dodgerating = self.shot_dmg;
41 proj.think = turret_ewheel_projectile_explode;
42 proj.nextthink = time + 9;
43 //proj.solid = SOLID_TRIGGER;
44 proj.movetype = MOVETYPE_FLYMISSILE;
45 proj.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
46 proj.touch = turret_ewheel_projectile_explode;
47 proj.enemy = self.enemy;
48 proj.flags = FL_PROJECTILE | FL_NOTARGET;
49 PROJECTILE_MAKETRIGGER(proj);
51 CSQCProjectile(proj, TRUE, PROJECTILE_LASER, TRUE);
53 self.tur_head.frame += 2;
55 if (self.tur_head.frame > 3)
56 self.tur_head.frame = 0;
61 void ewheel_move_path()
64 // Are we close enougth to a path node to switch to the next?
65 if (vlen(self.origin - self.pathcurrent.origin) < 64)
66 if (self.pathcurrent.path_next == world)
68 // Path endpoint reached
69 pathlib_deletepath(self.pathcurrent.owner);
70 self.pathcurrent = world;
74 if (self.pathgoal.use)
77 if (self.pathgoal.enemy)
79 self.pathcurrent = pathlib_astar(self.pathgoal.origin,self.pathgoal.enemy.origin);
80 self.pathgoal = self.pathgoal.enemy;
84 self.pathgoal = world;
87 self.pathcurrent = self.pathcurrent.path_next;
94 self.moveto = self.pathcurrent.origin;
95 self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95);
97 movelib_move_simple(v_forward, autocvar_g_turrets_unit_ewheel_speed_fast, 0.4);
103 void ewheel_move_enemy()
108 self.steerto = steerlib_arrive(self.enemy.origin,self.target_range_optimal);
110 //self.steerto = steerlib_standoff(self.enemy.origin,self.target_range_optimal);
111 //self.steerto = steerlib_beamsteer(self.steerto,1024,64,68,256);
112 self.moveto = self.origin + self.steerto * 128;
114 if (self.tur_dist_enemy > self.target_range_optimal)
116 if ( self.tur_head.spawnshieldtime < 1 )
118 newframe = ewheel_amin_fwd_fast;
119 movelib_move_simple(v_forward, autocvar_g_turrets_unit_ewheel_speed_fast, 0.4);
121 else if (self.tur_head.spawnshieldtime < 2)
124 newframe = ewheel_amin_fwd_slow;
125 movelib_move_simple(v_forward, autocvar_g_turrets_unit_ewheel_speed_slow, 0.4);
129 newframe = ewheel_amin_fwd_slow;
130 movelib_move_simple(v_forward, autocvar_g_turrets_unit_ewheel_speed_slower, 0.4);
133 else if (self.tur_dist_enemy < self.target_range_optimal * 0.5)
135 newframe = ewheel_amin_bck_slow;
136 movelib_move_simple(v_forward * -1, autocvar_g_turrets_unit_ewheel_speed_slow, 0.4);
140 newframe = ewheel_amin_stop;
141 movelib_beak_simple(autocvar_g_turrets_unit_ewheel_speed_stop);
144 if(self.frame != newframe)
146 self.frame = newframe;
147 self.SendFlags |= TNSF_ANIM;
148 self.anim_start_time = time;
153 void ewheel_move_idle()
157 self.SendFlags |= TNSF_ANIM;
158 self.anim_start_time = time;
162 if (vlen(self.velocity))
163 movelib_beak_simple(autocvar_g_turrets_unit_ewheel_speed_stop);
166 void ewheel_postthink()
169 vector wish_angle, real_angle;
171 vz = self.velocity_z;
173 self.angles_x = anglemods(self.angles_x);
174 self.angles_y = anglemods(self.angles_y);
176 fixedmakevectors(self.angles);
178 wish_angle = normalize(self.steerto);
179 wish_angle = vectoangles(wish_angle);
180 real_angle = wish_angle - self.angles;
181 real_angle = shortangle_vxy(real_angle, self.tur_head.angles);
183 self.tur_head.spawnshieldtime = fabs(real_angle_y);
184 real_angle_y = bound(-self.tur_head.aim_speed, real_angle_y, self.tur_head.aim_speed);
185 self.angles_y = (self.angles_y + real_angle_y);
189 else if(self.pathcurrent)
195 self.velocity_z = vz;
197 if(vlen(self.velocity))
198 self.SendFlags |= TNSF_MOVE;
201 void ewheel_respawnhook()
205 // Respawn is called & first spawn to, to set team. need to make sure we do not move the initial spawn.
206 if(self.movetype != MOVETYPE_WALK)
209 self.velocity = '0 0 0';
212 setorigin(self, self.pos1);
214 if (self.target != "")
216 e = find(world,targetname,self.target);
219 dprint("Initital waypoint for ewheel does NOT exsist, fix your map!\n");
223 if (e.classname != "turret_checkpoint")
224 dprint("Warning: not a turrret path\n");
227 self.pathcurrent = WALKER_PATH(self.origin,e.origin);
233 void ewheel_diehook()
235 self.velocity = '0 0 0';
237 if (self.pathcurrent)
238 pathlib_deletepath(self.pathcurrent.owner);
240 self.pathcurrent = world;
243 void turret_ewheel_dinit()
247 if (self.netname == "")
248 self.netname = "eWheel Turret";
250 if (self.target != "")
252 e = find(world,targetname,self.target);
255 bprint("Warning! initital waypoint for ewheel does NOT exsist!\n");
259 if (e.classname != "turret_checkpoint")
260 dprint("Warning: not a turrret path\n");
262 self.goalcurrent = e;
265 self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIVE;
266 self.turrcaps_flags = TFL_TURRCAPS_PLAYERKILL | TFL_TURRCAPS_MOVE | TFL_TURRCAPS_ROAM ;
267 self.turret_respawnhook = ewheel_respawnhook;
269 self.turret_diehook = ewheel_diehook;
271 if (turret_stdproc_init("ewheel_std", "models/turrets/ewheel-base2.md3", "models/turrets/ewheel-gun1.md3", TID_EWHEEL) == 0)
277 self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
278 self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
280 self.damage_flags |= TFL_DMG_DEATH_NOGIBS;
282 self.iscreature = TRUE;
283 self.movetype = MOVETYPE_WALK;
284 self.solid = SOLID_SLIDEBOX;
285 self.takedamage = DAMAGE_AIM;
287 setsize(self, '-32 -32 0', '32 32 48');
288 self.idle_aim = '0 0 0';
290 self.pos1 = self.origin;
293 self.turret_firefunc = ewheel_attack;
294 self.turret_postthink = ewheel_postthink;
295 self.tur_head.frame = 1;
297 // Convert from dgr / sec to dgr / tic
298 self.tur_head.aim_speed = autocvar_g_turrets_unit_ewheel_turnrate;
299 self.tur_head.aim_speed = self.tur_head.aim_speed / (1 / self.ticrate);
301 //setorigin(self,self.origin + '0 0 128');
302 if (self.target != "")
304 e = find(world,targetname,self.target);
307 dprint("Initital waypoint for ewheel does NOT exsist, fix your map!\n");
311 if (e.classname != "turret_checkpoint")
312 dprint("Warning: not a turrret path\n");
315 self.pathcurrent = WALKER_PATH(self.origin, e.origin);
321 void spawnfunc_turret_ewheel()
323 g_turrets_common_precash();
325 precache_model ("models/turrets/ewheel-base2.md3");
326 precache_model ("models/turrets/ewheel-gun1.md3");
328 self.think = turret_ewheel_dinit;
329 self.nextthink = time + 0.5;