Pathfinder Fix

Bug #1447671 reported by Andre Novellino Gouvêa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stratagus
Won't Fix
Undecided
Unassigned

Bug Description

Currently, we have the following code in astar.cpp (CostMoveToCallBack_Default function):

     // for non moving unit Always Fail unless goal is unit, or unit can attack the target
     if (&unit != goal) {
      if (goal->Player->IsEnemy(unit) && unit.IsAgressive() && CanTarget(*unit.Type, *goal->Type)
       && goal->Variable[UNHOLYARMOR_INDEX].Value == 0 && goal->IsVisibleAsGoal(*unit.Player)) {
        cost += 2 * AStarMovingUnitCrossingCost;
      } else {
      // FIXME: Need support for moving a fixed unit to add cost
       return -1;
      }
      //cost += AStarFixedUnitCrossingCost;
     }

The problem is that this makes melee units (or ranged units if the goal is outside range) keep trying to get to a target even if there is something blocking the way.

Modifying that code to this instead solves the issue:

     // for non moving unit Always Fail unless goal is unit, or unit can attack the target
     if (&unit != goal) {
      if (goal->Player->IsEnemy(unit) && unit.IsAgressive() && CanTarget(*unit.Type, *goal->Type)
       && unit.MapDistanceTo(*goal) <= unit.Variable[ATTACKRANGE_INDEX].Max
       && goal->Variable[UNHOLYARMOR_INDEX].Value == 0 && goal->IsVisibleAsGoal(*unit.Player)) {
        cost += 2 * AStarMovingUnitCrossingCost;
      } else {
      // FIXME: Need support for moving a fixed unit to add cost
       return -1;
      }
      //cost += AStarFixedUnitCrossingCost;
     }

Revision history for this message
timfelgentreff (timfelgentreff) wrote : Moving to GitHub

This project was moved to https://github.com/Wargus/stratagus. All issues were migrated there.

Changed in stratagus:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.