5 /* spawnflags */ ATTRIB(EWheel, spawnflags, int, TUR_FLAG_PLAYER | TUR_FLAG_MOVE | TUR_FLAG_ROAM);
6 /* mins */ ATTRIB(EWheel, mins, vector, '-32 -32 0');
7 /* maxs */ ATTRIB(EWheel, maxs, vector, '32 32 48');
8 /* modelname */ ATTRIB(EWheel, mdl, string, "ewheel-base2.md3");
9 /* model */ ATTRIB(EWheel, model, string, strzone(strcat("models/turrets/", this.mdl)));
10 /* head_model */ ATTRIB(EWheel, head_model, string, strzone(strcat("models/turrets/", "ewheel-gun1.md3")));
11 /* netname */ ATTRIB(EWheel, netname, string, "ewheel");
12 /* fullname */ ATTRIB(EWheel, turret_name, string, _("eWheel Turret"));
15 REGISTER_TURRET(EWHEEL, NEW(EWheel));
21 float autocvar_g_turrets_unit_ewheel_speed_fast;
22 float autocvar_g_turrets_unit_ewheel_speed_slow;
23 float autocvar_g_turrets_unit_ewheel_speed_slower;
24 float autocvar_g_turrets_unit_ewheel_speed_stop;
25 float autocvar_g_turrets_unit_ewheel_turnrate;
27 const float ewheel_anim_stop = 0;
28 const float ewheel_anim_fwd_slow = 1;
29 const float ewheel_anim_fwd_fast = 2;
30 const float ewheel_anim_bck_slow = 3;
31 const float ewheel_anim_bck_fast = 4;
33 //#define EWHEEL_FANCYPATH
34 void ewheel_move_path()
36 #ifdef EWHEEL_FANCYPATH
37 // Are we close enougth to a path node to switch to the next?
38 if (vlen(self.origin - self.pathcurrent.origin) < 64)
39 if (self.pathcurrent.path_next == world)
41 // Path endpoint reached
42 pathlib_deletepath(self.pathcurrent.owner);
43 self.pathcurrent = world;
47 if (self.pathgoal.use)
50 if (self.pathgoal.enemy)
52 self.pathcurrent = pathlib_astar(self.pathgoal.origin,self.pathgoal.enemy.origin);
53 self.pathgoal = self.pathgoal.enemy;
57 self.pathgoal = world;
60 self.pathcurrent = self.pathcurrent.path_next;
63 if (vlen(self.origin - self.pathcurrent.origin) < 64)
64 self.pathcurrent = self.pathcurrent.enemy;
70 self.moveto = self.pathcurrent.origin;
71 self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95);
73 movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4);
77 void ewheel_move_enemy()
81 self.steerto = steerlib_arrive(self.enemy.origin,self.target_range_optimal);
83 self.moveto = self.origin + self.steerto * 128;
85 if (self.tur_dist_enemy > self.target_range_optimal)
87 if ( self.tur_head.spawnshieldtime < 1 )
89 newframe = ewheel_anim_fwd_fast;
90 movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4);
92 else if (self.tur_head.spawnshieldtime < 2)
95 newframe = ewheel_anim_fwd_slow;
96 movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4);
100 newframe = ewheel_anim_fwd_slow;
101 movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slower), 0.4);
104 else if (self.tur_dist_enemy < self.target_range_optimal * 0.5)
106 newframe = ewheel_anim_bck_slow;
107 movelib_move_simple(v_forward * -1, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4);
111 newframe = ewheel_anim_stop;
112 movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
115 turrets_setframe(newframe, false);
118 void ewheel_move_idle()
122 self.SendFlags |= TNSF_ANIM;
123 self.anim_start_time = time;
127 if (vlen(self.velocity))
128 movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
131 void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL.m_id)) remove(self); }
133 METHOD(EWheel, tr_attack, bool(EWheel thistur))
139 for (i = 0; i < 1; ++i)
141 turret_do_updates(self);
143 _mis = turret_projectile(SND(LASERGUN_FIRE), 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, TRUE, TRUE);
144 _mis.missile_flags = MIF_SPLASH;
146 Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
148 self.tur_head.frame += 2;
150 if (self.tur_head.frame > 3)
151 self.tur_head.frame = 0;
156 METHOD(EWheel, tr_think, bool(EWheel thistur))
160 vector wish_angle, real_angle;
162 vz = self.velocity_z;
164 self.angles_x = anglemods(self.angles_x);
165 self.angles_y = anglemods(self.angles_y);
167 fixedmakevectors(self.angles);
169 wish_angle = normalize(self.steerto);
170 wish_angle = vectoangles(wish_angle);
171 real_angle = wish_angle - self.angles;
172 real_angle = shortangle_vxy(real_angle, self.tur_head.angles);
174 self.tur_head.spawnshieldtime = fabs(real_angle_y);
175 real_angle_y = bound(-self.tur_head.aim_speed, real_angle_y, self.tur_head.aim_speed);
176 self.angles_y = (self.angles_y + real_angle_y);
180 else if(self.pathcurrent)
185 self.velocity_z = vz;
187 if(vlen(self.velocity))
188 self.SendFlags |= TNSF_MOVE;
192 METHOD(EWheel, tr_death, bool(EWheel thistur))
195 self.velocity = '0 0 0';
197 #ifdef EWHEEL_FANCYPATH
198 if (self.pathcurrent)
199 pathlib_deletepath(self.pathcurrent.owner);
201 self.pathcurrent = world;
205 METHOD(EWheel, tr_setup, bool(EWheel thistur))
210 if(self.movetype == MOVETYPE_WALK)
212 self.velocity = '0 0 0';
215 setorigin(self, self.pos1);
217 if (self.target != "")
219 e = find(world, targetname, self.target);
222 LOG_TRACE("Initital waypoint for ewheel does NOT exsist, fix your map!\n");
226 if (e.classname != "turret_checkpoint")
227 LOG_TRACE("Warning: not a turrret path\n");
231 #ifdef EWHEEL_FANCYPATH
232 self.pathcurrent = WALKER_PATH(self.origin,e.origin);
235 self.pathcurrent = e;
241 self.iscreature = true;
242 self.teleportable = TELEPORT_NORMAL;
243 self.damagedbycontents = true;
244 self.movetype = MOVETYPE_WALK;
245 self.solid = SOLID_SLIDEBOX;
246 self.takedamage = DAMAGE_AIM;
247 self.idle_aim = '0 0 0';
248 self.pos1 = self.origin;
249 self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
250 self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
251 self.frame = self.tur_head.frame = 1;
252 self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
254 // Convert from dgr / sec to dgr / tic
255 self.tur_head.aim_speed = (autocvar_g_turrets_unit_ewheel_turnrate);
256 self.tur_head.aim_speed = self.tur_head.aim_speed / (1 / self.ticrate);
260 METHOD(EWheel, tr_precache, bool(EWheel thistur))
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 METHOD(EWheel, tr_setup, bool(EWheel thistur))
291 self.movetype = MOVETYPE_BOUNCE;
292 self.move_movetype = MOVETYPE_BOUNCE;
293 self.move_origin = self.origin;
294 self.move_time = time;
295 self.draw = ewheel_draw;
299 METHOD(EWheel, tr_precache, bool(EWheel thistur))
305 #endif // REGISTER_TURRET