5 /* function */ t_ewheel,
6 /* spawnflags */ TUR_FLAG_PLAYER | TUR_FLAG_MOVE | TUR_FLAG_ROAM,
7 /* mins,maxs */ '-32 -32 0', '32 32 48',
8 /* model */ "ewheel-base2.md3",
9 /* head_model */ "ewheel-gun1.md3",
10 /* netname */ "ewheel",
11 /* fullname */ _("eWheel Turret")
17 float autocvar_g_turrets_unit_ewheel_speed_fast;
18 float autocvar_g_turrets_unit_ewheel_speed_slow;
19 float autocvar_g_turrets_unit_ewheel_speed_slower;
20 float autocvar_g_turrets_unit_ewheel_speed_stop;
21 float autocvar_g_turrets_unit_ewheel_turnrate;
23 const float ewheel_anim_stop = 0;
24 const float ewheel_anim_fwd_slow = 1;
25 const float ewheel_anim_fwd_fast = 2;
26 const float ewheel_anim_bck_slow = 3;
27 const float ewheel_anim_bck_fast = 4;
29 //#define EWHEEL_FANCYPATH
30 void ewheel_move_path()
32 #ifdef EWHEEL_FANCYPATH
33 // Are we close enougth to a path node to switch to the next?
34 if (vlen(self.origin - self.pathcurrent.origin) < 64)
35 if (self.pathcurrent.path_next == world)
37 // Path endpoint reached
38 pathlib_deletepath(self.pathcurrent.owner);
39 self.pathcurrent = world;
43 if (self.pathgoal.use)
46 if (self.pathgoal.enemy)
48 self.pathcurrent = pathlib_astar(self.pathgoal.origin,self.pathgoal.enemy.origin);
49 self.pathgoal = self.pathgoal.enemy;
53 self.pathgoal = world;
56 self.pathcurrent = self.pathcurrent.path_next;
59 if (vlen(self.origin - self.pathcurrent.origin) < 64)
60 self.pathcurrent = self.pathcurrent.enemy;
66 self.moveto = self.pathcurrent.origin;
67 self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95);
69 movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4);
73 void ewheel_move_enemy()
77 self.steerto = steerlib_arrive(self.enemy.origin,self.target_range_optimal);
79 self.moveto = self.origin + self.steerto * 128;
81 if (self.tur_dist_enemy > self.target_range_optimal)
83 if ( self.tur_head.spawnshieldtime < 1 )
85 newframe = ewheel_anim_fwd_fast;
86 movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4);
88 else if (self.tur_head.spawnshieldtime < 2)
91 newframe = ewheel_anim_fwd_slow;
92 movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4);
96 newframe = ewheel_anim_fwd_slow;
97 movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slower), 0.4);
100 else if (self.tur_dist_enemy < self.target_range_optimal * 0.5)
102 newframe = ewheel_anim_bck_slow;
103 movelib_move_simple(v_forward * -1, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4);
107 newframe = ewheel_anim_stop;
108 movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
111 turrets_setframe(newframe, false);
114 void ewheel_move_idle()
118 self.SendFlags |= TNSF_ANIM;
119 self.anim_start_time = time;
123 if (vlen(self.velocity))
124 movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
127 void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL.m_id)) remove(self); }
129 float t_ewheel(float req)
138 for (i = 0; i < 1; ++i)
140 turret_do_updates(self);
142 _mis = turret_projectile(SND(LASERGUN_FIRE), 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, TRUE, TRUE);
143 _mis.missile_flags = MIF_SPLASH;
145 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
147 self.tur_head.frame += 2;
149 if (self.tur_head.frame > 3)
150 self.tur_head.frame = 0;
158 vector wish_angle, real_angle;
160 vz = self.velocity_z;
162 self.angles_x = anglemods(self.angles_x);
163 self.angles_y = anglemods(self.angles_y);
165 fixedmakevectors(self.angles);
167 wish_angle = normalize(self.steerto);
168 wish_angle = vectoangles(wish_angle);
169 real_angle = wish_angle - self.angles;
170 real_angle = shortangle_vxy(real_angle, self.tur_head.angles);
172 self.tur_head.spawnshieldtime = fabs(real_angle_y);
173 real_angle_y = bound(-self.tur_head.aim_speed, real_angle_y, self.tur_head.aim_speed);
174 self.angles_y = (self.angles_y + real_angle_y);
178 else if(self.pathcurrent)
183 self.velocity_z = vz;
185 if(vlen(self.velocity))
186 self.SendFlags |= TNSF_MOVE;
192 self.velocity = '0 0 0';
194 #ifdef EWHEEL_FANCYPATH
195 if (self.pathcurrent)
196 pathlib_deletepath(self.pathcurrent.owner);
198 self.pathcurrent = world;
206 if(self.movetype == MOVETYPE_WALK)
208 self.velocity = '0 0 0';
211 setorigin(self, self.pos1);
213 if (self.target != "")
215 e = find(world, targetname, self.target);
218 LOG_TRACE("Initital waypoint for ewheel does NOT exsist, fix your map!\n");
222 if (e.classname != "turret_checkpoint")
223 LOG_TRACE("Warning: not a turrret path\n");
227 #ifdef EWHEEL_FANCYPATH
228 self.pathcurrent = WALKER_PATH(self.origin,e.origin);
231 self.pathcurrent = e;
237 self.iscreature = true;
238 self.teleportable = TELEPORT_NORMAL;
239 self.damagedbycontents = true;
240 self.movetype = MOVETYPE_WALK;
241 self.solid = SOLID_SLIDEBOX;
242 self.takedamage = DAMAGE_AIM;
243 self.idle_aim = '0 0 0';
244 self.pos1 = self.origin;
245 self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
246 self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
247 self.frame = self.tur_head.frame = 1;
248 self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
250 // Convert from dgr / sec to dgr / tic
251 self.tur_head.aim_speed = (autocvar_g_turrets_unit_ewheel_turnrate);
252 self.tur_head.aim_speed = self.tur_head.aim_speed / (1 / self.ticrate);
272 dt = time - self.move_time;
273 self.move_time = time;
277 fixedmakevectors(self.angles);
278 setorigin(self, self.origin + self.velocity * dt);
279 self.tur_head.angles += dt * self.tur_head.move_avelocity;
280 self.angles_y = self.move_angles_y;
282 if (self.health < 127)
284 te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
287 float t_ewheel(float req)
294 self.movetype = MOVETYPE_BOUNCE;
295 self.move_movetype = MOVETYPE_BOUNCE;
296 self.move_origin = self.origin;
297 self.move_time = time;
298 self.draw = ewheel_draw;
312 #endif // REGISTER_TURRET