#undef TRY
}
+bool turret_closetotarget(entity this, vector targ)
+{
+ vector path_extra_size = '64 64 64';
+ return boxesoverlap(targ - path_extra_size, targ + path_extra_size, this.absmin - path_extra_size, this.absmax + path_extra_size);
+}
+
void turret_findtarget(entity this)
{
entity e = find(NULL, classname, "turret_manager");
bool turret_initialize(entity this, Turret tur);
+// returns true when box overlaps with a given location
+bool turret_closetotarget(entity this, vector targ);
+
/// Function to use for target evaluation. usualy turret_targetscore_generic
.float(entity _turret, entity _target) turret_score_target;
void ewheel_move_path(entity this)
{
// Are we close enough to a path node to switch to the next?
- if(vdist(this.origin - this.pathcurrent.origin, <, 64))
+ if(turret_closetotarget(this, this.pathcurrent.origin))
{
#ifdef EWHEEL_FANCYPATH
if (this.pathcurrent.path_next == NULL)
if (this.pathcurrent)
{
-
this.moveto = this.pathcurrent.origin;
this.steerto = steerlib_attract2(this, this.moveto, 0.5, 500, 0.95);
{
#ifdef WALKER_FANCYPATHING
// Are we close enougth to a path node to switch to the next?
- if(vdist(this.origin - this.pathcurrent.origin, <, 64))
+ if(turret_closetotarget(this, this.pathcurrent.origin))
+ {
if (this.pathcurrent.path_next == NULL)
{
// Path endpoint reached
}
else
this.pathcurrent = this.pathcurrent.path_next;
+ }
this.moveto = this.pathcurrent.origin;
this.steerto = steerlib_attract2(this, this.moveto,0.5,500,0.95);
walker_move_to(this, this.moveto, 0);
#else
- if(vdist(this.origin - this.pathcurrent.origin, <, 64))
+ if(turret_closetotarget(this, this.pathcurrent.origin))
this.pathcurrent = this.pathcurrent.enemy;
if(!this.pathcurrent)