-#ifndef TURRET_EWHEEL_H
-#define TURRET_EWHEEL_H
-
-//#define EWHEEL_FANCYPATH
-
-#include "ewheel_weapon.qh"
-
-CLASS(EWheel, Turret)
-/* spawnflags */ ATTRIB(EWheel, spawnflags, int, TUR_FLAG_PLAYER | TUR_FLAG_MOVE | TUR_FLAG_ROAM);
-/* mins */ ATTRIB(EWheel, mins, vector, '-32 -32 0');
-/* maxs */ ATTRIB(EWheel, maxs, vector, '32 32 48');
-/* modelname */ ATTRIB(EWheel, mdl, string, "ewheel-base2.md3");
-/* model */ ATTRIB_STRZONE(EWheel, model, string, strcat("models/turrets/", this.mdl));
-/* head_model */ ATTRIB_STRZONE(EWheel, head_model, string, strcat("models/turrets/", "ewheel-gun1.md3"));
-/* netname */ ATTRIB(EWheel, netname, string, "ewheel");
-/* fullname */ ATTRIB(EWheel, turret_name, string, _("eWheel Turret"));
- ATTRIB(EWheel, m_weapon, Weapon, WEP_EWHEEL);
-ENDCLASS(EWheel)
-REGISTER_TURRET(EWHEEL, NEW(EWheel));
-
-#endif
-
-#ifdef IMPLEMENTATION
+#include "ewheel.qh"
#ifdef SVQC
float autocvar_g_turrets_unit_ewheel_speed_stop;
float autocvar_g_turrets_unit_ewheel_turnrate;
-const float ewheel_anim_stop = 0;
-const float ewheel_anim_fwd_slow = 1;
-const float ewheel_anim_fwd_fast = 2;
-const float ewheel_anim_bck_slow = 3;
-const float ewheel_anim_bck_fast = 4;
+const int ewheel_anim_stop = 0;
+const int ewheel_anim_fwd_slow = 1;
+const int ewheel_anim_fwd_fast = 2;
+const int ewheel_anim_bck_slow = 3;
+const int ewheel_anim_bck_fast = 4;
void ewheel_move_path(entity this)
{
+ // Are we close enough to a path node to switch to the next?
+ if(turret_closetotarget(this, this.pathcurrent.origin))
+ {
#ifdef EWHEEL_FANCYPATH
- // Are we close enougth to a path node to switch to the next?
- if(vdist(this.origin - this.pathcurrent.origin, <, 64))
if (this.pathcurrent.path_next == NULL)
{
// Path endpoint reached
}
else
this.pathcurrent = this.pathcurrent.path_next;
-
#else
- if(vdist(this.origin - this.pathcurrent.origin, <, 64))
this.pathcurrent = this.pathcurrent.enemy;
#endif
+ }
if (this.pathcurrent)
{
-
this.moveto = this.pathcurrent.origin;
this.steerto = steerlib_attract2(this, this.moveto, 0.5, 500, 0.95);
void ewheel_move_enemy(entity this)
{
- float newframe;
+ int newframe;
this.steerto = steerlib_arrive(this, this.enemy.origin,this.target_range_optimal);
- this.moveto = this.origin + this.steerto * 128;
+ this.moveto = this.origin + this.steerto * 128;
if (this.tur_dist_enemy > this.target_range_optimal)
{
movelib_brake_simple(this, (autocvar_g_turrets_unit_ewheel_speed_stop));
}
-spawnfunc(turret_ewheel) { if(!turret_initialize(this, TUR_EWHEEL)) remove(this); }
+void ewheel_findtarget(entity this)
+{
+ entity e = find(NULL, targetname, this.target);
+ if (!e)
+ {
+ LOG_TRACE("Initital waypoint for ewheel does NOT exist, fix your map!");
+ this.target = "";
+ }
+
+ if (e.classname != "turret_checkpoint")
+ LOG_TRACE("Warning: not a turret path");
+ else
+ {
+
+#ifdef EWHEEL_FANCYPATH
+ this.pathcurrent = pathlib_astar(this, this.origin, e.origin);
+ this.pathgoal = e;
+#else
+ this.pathcurrent = e;
+#endif
+ }
+}
+
+spawnfunc(turret_ewheel) { if(!turret_initialize(this, TUR_EWHEEL)) delete(this); }
METHOD(EWheel, tr_think, void(EWheel thistur, entity it))
{
- float vz;
vector wish_angle, real_angle;
- vz = it.velocity_z;
+ float vz = it.velocity_z;
it.angles_x = anglemods(it.angles_x);
it.angles_y = anglemods(it.angles_y);
METHOD(EWheel, tr_setup, void(EWheel this, entity it))
{
- entity e;
-
if(it.move_movetype == MOVETYPE_WALK)
{
it.velocity = '0 0 0';
setorigin(it, it.pos1);
if (it.target != "")
- {
- e = find(NULL, targetname, it.target);
- if (!e)
- {
- LOG_TRACE("Initital waypoint for ewheel does NOT exsist, fix your map!\n");
- it.target = "";
- }
-
- if (e.classname != "turret_checkpoint")
- LOG_TRACE("Warning: not a turrret path\n");
- else
- {
-
-#ifdef EWHEEL_FANCYPATH
- it.pathcurrent = WALKER_PATH(it, it.origin, e.origin);
- it.pathgoal = e;
-#else
- it.pathcurrent = e;
-#endif
- }
- }
+ InitializeEntity(it, ewheel_findtarget, INITPRIO_FINDTARGET);
}
it.iscreature = true;
it.teleportable = TELEPORT_NORMAL;
- it.damagedbycontents = true;
+ if(!it.damagedbycontents)
+ IL_PUSH(g_damagedbycontents, it);
+ it.damagedbycontents = true;
set_movetype(it, MOVETYPE_WALK);
it.solid = SOLID_SLIDEBOX;
it.takedamage = DAMAGE_AIM;
setorigin(this, this.origin + this.velocity * dt);
this.tur_head.angles += dt * this.tur_head.avelocity;
- if (this.health < 127)
+ if(GetResourceAmount(this, RES_HEALTH) < 127)
if(random() < 0.05)
te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
}
- METHOD(EWheel, tr_setup, void(EWheel this, entity it))
- {
- it.gravity = 1;
- it.move_movetype = MOVETYPE_BOUNCE;
- it.move_time = time;
- it.draw = ewheel_draw;
- }
+METHOD(EWheel, tr_setup, void(EWheel this, entity it))
+{
+ it.gravity = 1;
+ set_movetype(it, MOVETYPE_BOUNCE);
+ it.move_time = time;
+ it.draw = ewheel_draw;
+}
#endif // CSQC
-#endif