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, void(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;
154 METHOD(EWheel, tr_think, bool(EWheel thistur))
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;
190 METHOD(EWheel, tr_death, bool(EWheel thistur))
193 self.velocity = '0 0 0';
195 #ifdef EWHEEL_FANCYPATH
196 if (self.pathcurrent)
197 pathlib_deletepath(self.pathcurrent.owner);
199 self.pathcurrent = world;
203 METHOD(EWheel, tr_setup, bool(EWheel thistur))
208 if(self.movetype == MOVETYPE_WALK)
210 self.velocity = '0 0 0';
213 setorigin(self, self.pos1);
215 if (self.target != "")
217 e = find(world, targetname, self.target);
220 LOG_TRACE("Initital waypoint for ewheel does NOT exsist, fix your map!\n");
224 if (e.classname != "turret_checkpoint")
225 LOG_TRACE("Warning: not a turrret path\n");
229 #ifdef EWHEEL_FANCYPATH
230 self.pathcurrent = WALKER_PATH(self.origin,e.origin);
233 self.pathcurrent = e;
239 self.iscreature = true;
240 self.teleportable = TELEPORT_NORMAL;
241 self.damagedbycontents = true;
242 self.movetype = MOVETYPE_WALK;
243 self.solid = SOLID_SLIDEBOX;
244 self.takedamage = DAMAGE_AIM;
245 self.idle_aim = '0 0 0';
246 self.pos1 = self.origin;
247 self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
248 self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS;
249 self.frame = self.tur_head.frame = 1;
250 self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE;
252 // Convert from dgr / sec to dgr / tic
253 self.tur_head.aim_speed = (autocvar_g_turrets_unit_ewheel_turnrate);
254 self.tur_head.aim_speed = self.tur_head.aim_speed / (1 / self.ticrate);
258 METHOD(EWheel, tr_precache, bool(EWheel thistur))
270 dt = time - self.move_time;
271 self.move_time = time;
275 fixedmakevectors(self.angles);
276 setorigin(self, self.origin + self.velocity * dt);
277 self.tur_head.angles += dt * self.tur_head.move_avelocity;
278 self.angles_y = self.move_angles_y;
280 if (self.health < 127)
282 te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
285 METHOD(EWheel, tr_setup, bool(EWheel thistur))
289 self.movetype = MOVETYPE_BOUNCE;
290 self.move_movetype = MOVETYPE_BOUNCE;
291 self.move_origin = self.origin;
292 self.move_time = time;
293 self.draw = ewheel_draw;
297 METHOD(EWheel, tr_precache, bool(EWheel thistur))
303 #endif // REGISTER_TURRET