Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "projectile.h"
#include "objmem.h"
#include "order.h"
#include "visibility.h"

/* Weights used for target selection code,
* target distance is used as 'common currency'
Expand All @@ -48,6 +49,7 @@
#define WEIGHT_HEALTH_STRUCT (WEIGHT_DIST_TILE * 7)

#define WEIGHT_NOT_VISIBLE_F 10 //We really don't like objects we can't see
#define WEIGHT_NOT_LOS_VISIBLE_F 4

#define WEIGHT_SERVICE_DROIDS (WEIGHT_DIST_TILE_DROID * 5) //We don't want them to be repairing droids or structures while we are after them
#define WEIGHT_WEAPON_DROIDS (WEIGHT_DIST_TILE_DROID * 4) //We prefer to go after anything that has a gun and can hurt us
Expand Down Expand Up @@ -487,6 +489,11 @@ static SDWORD targetAttackWeight(BASE_OBJECT *psTarget, BASE_OBJECT *psAttacker,
return 1;
}

if (bDirect && !lineOfFire(psAttacker, psTarget, weapon_slot, false))
{
attackWeight /= WEIGHT_NOT_LOS_VISIBLE_F; // Prefer objects not obstructed by terrain
}

/* We prefer objects we can see and can attack immediately */
if (!visibleObject((BASE_OBJECT *)psAttacker, psTarget, true))
{
Expand Down
Loading