Skip to content

Commit

Permalink
Better rearming logic for campaign.
Browse files Browse the repository at this point in the history
Looks better and makes sure a VTOL has full ammo and health
before getting off the rearming pad.
  • Loading branch information
KJeff01 committed Jan 7, 2018
1 parent 7523d1a commit e6eeebe
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions data/base/script/campaign/libcampaign.js
Expand Up @@ -1730,17 +1730,19 @@ function __camTacticsTickForGroup(group)
continue;
}
}
var vt = (droid.type === DROID) && isVTOL(droid);
//Rearm vtols.
if (vt && ((Math.floor(droid.weapons[0].armed) < 1)
|| ((droid.order === DORDER_REARM)
&& (Math.ceil(droid.weapons[0].armed) < 100))))
if (droid.type === DROID && isVTOL(droid))
{
var pads = countStruct("A0VtolPad", droid.player);
if (pads && (droid.order !== DORDER_REARM))
orderDroid(droid, DORDER_REARM);
else
continue;
var arm = Math.floor(droid.weapons[0].armed);
var isRearming = droid.order === DORDER_REARM;
var health = Math.floor(droid.health);
if ((arm < 1) || (isRearming && (arm < 100 || health < 100)))
{
var pads = countStruct("A0VtolPad", droid.player);
if (pads && !isRearming)
orderDroid(droid, DORDER_REARM);
continue; //Rearming. Try not to attack stuff.
}
}
if (camDist(droid, target) >= __CAM_CLOSE_RADIUS)
{
Expand Down

0 comments on commit e6eeebe

Please sign in to comment.