Permalink
Browse files

Fix Hold order immediately reverting for military droids.

Should fix some other cases where Hold does not hold, as
well.
  • Loading branch information...
perim committed Nov 9, 2017
1 parent e449140 commit 27460ef00625c9c2d8594892bd5263896f1afcfb
Showing with 11 additions and 11 deletions.
  1. +5 −5 src/action.cpp
  2. +6 −6 src/order.cpp
View
@@ -1243,7 +1243,7 @@ void actionUpdateDroid(DROID *psDroid)
if (actionInsideMinRange(psDroid, psDroid->psActionTarget[0], psWeapStats))
{
if (proj_Direct(psWeapStats))
if (proj_Direct(psWeapStats) && order->type != DORDER_HOLD)
{
SDWORD pbx, pby;
@@ -1265,7 +1265,7 @@ void actionUpdateDroid(DROID *psDroid)
}
}
}
else // too far away
else if (order->type != DORDER_HOLD) // approach closer?
{
// try to close the range
moveDroidTo(psDroid, psDroid->psActionTarget[0]->pos.x, psDroid->psActionTarget[0]->pos.y);
@@ -1955,7 +1955,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
{
psDroid->action = DACTION_ATTACK; // holding, try attack straightaway
}
else if (actionInsideMinRange(psDroid, psAction->psObj, psWeapStats))
else if (actionInsideMinRange(psDroid, psAction->psObj, psWeapStats)) // too close?
{
if (!proj_Direct(psWeapStats))
{
@@ -1969,7 +1969,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
moveTurnDroid(psDroid, psDroid->psActionTarget[0]->pos.x, psDroid->psActionTarget[0]->pos.y);
}
}
else
else if (order->type != DORDER_HOLD)
{
/* direct fire - try and extend the range */
psDroid->action = DACTION_MOVETOATTACK;
@@ -1980,7 +1980,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
turnOffMultiMsg(false);
}
}
else
else if (order->type != DORDER_HOLD) // approach closer?
{
psDroid->action = DACTION_MOVETOATTACK;
turnOffMultiMsg(true);
View
@@ -366,8 +366,8 @@ void orderUpdateDroid(DROID *psDroid)
break;
}
// if you are in a command group, default to guarding the commander
else if (hasCommander(psDroid) &&
psDroid->order.psStats != structGetDemolishStat()) // stop the constructor auto repairing when it is about to demolish
else if (hasCommander(psDroid) && psDroid->order.type != DORDER_HOLD
&& psDroid->order.psStats != structGetDemolishStat()) // stop the constructor auto repairing when it is about to demolish
{
orderDroidObj(psDroid, DORDER_GUARD, psDroid->psGroup->psCommander, ModeImmediate);
}
@@ -386,11 +386,11 @@ void orderUpdateDroid(DROID *psDroid)
}
}
}
else if (tryDoRepairlikeAction(psDroid))
{
}
// default to guarding
else if (psDroid->order.psStats != structGetDemolishStat() && !isVtolDroid(psDroid))
else if (!tryDoRepairlikeAction(psDroid)
&& psDroid->order.type != DORDER_HOLD
&& psDroid->order.psStats != structGetDemolishStat()
&& !isVtolDroid(psDroid))
{
orderDroidLoc(psDroid, DORDER_GUARD, psDroid->pos.x, psDroid->pos.y, ModeImmediate);
}

0 comments on commit 27460ef

Please sign in to comment.