Permalink
Browse files

Better rearming logic for campaign.

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 e6eeebe0d1ad9e1c30ae6b4d3de0ba7c2b19df69
Showing with 11 additions and 9 deletions.
  1. +11 −9 data/base/script/campaign/libcampaign.js
@@ -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)
{

0 comments on commit e6eeebe

Please sign in to comment.