Skip to content

Commit

Permalink
Fix Hold order immediately reverting for military droids.
Browse files Browse the repository at this point in the history
Should fix some other cases where Hold does not hold, as
well.
  • Loading branch information
perim committed Nov 9, 2017
1 parent e449140 commit 27460ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/action.cpp
Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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))
{
Expand All @@ -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;
Expand All @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/order.cpp
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 27460ef

Please sign in to comment.