Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make auto-repair work all the time, not just when droids are stopped.

Droids no longer start to retreat and then stop in the middle of the battlefield doing nothing, while getting shot
at.
  • Loading branch information...
commit 8c83693ba6b96b1810853448370d62e7023a62a7 1 parent 2402562
@Cyp Cyp authored
Showing with 28 additions and 48 deletions.
  1. +0 −6 src/action.cpp
  2. +0 −6 src/ai.cpp
  3. +28 −33 src/droid.cpp
  4. +0 −3  src/droid.h
View
6 src/action.cpp
@@ -868,12 +868,6 @@ void actionUpdateDroid(DROID *psDroid)
}
}
}
- // Still not doing anything? See if we need to self repair.
- if ((psDroid->action == DACTION_NONE || psDroid->action == DACTION_WAITFORREPAIR)
- && selfRepairEnabled(psDroid->player))
- {
- droidSelfRepair(psDroid);
- }
break;
case DACTION_WAITDURINGREPAIR:
// Check that repair facility still exists
View
6 src/ai.cpp
@@ -1054,12 +1054,6 @@ void aiUpdateDroid(DROID *psDroid)
{
lookForTarget = false;
}
- // except when self-repairing
- if (psDroid->action == DACTION_DROIDREPAIR &&
- psDroid->psActionTarget[0] == (BASE_OBJECT *)psDroid)
- {
- lookForTarget = true;
- }
// don't look for a target if sulking
if (psDroid->action == DACTION_SULK)
{
View
61 src/droid.cpp
@@ -104,9 +104,11 @@ extern DROID_TEMPLATE sDefaultDesignTemplate;
DROID *psLastDroidHit;
//determines the best IMD to draw for the droid - A TEMP MEASURE!
-void groupConsoleInformOfSelection( UDWORD groupNumber );
-void groupConsoleInformOfCreation( UDWORD groupNumber );
-void groupConsoleInformOfCentering( UDWORD groupNumber );
+static void groupConsoleInformOfSelection(UDWORD groupNumber);
+static void groupConsoleInformOfCreation(UDWORD groupNumber);
+static void groupConsoleInformOfCentering(UDWORD groupNumber);
+
+static void droidUpdateDroidSelfRepair(DROID *psRepairDroid);
void cancelBuild(DROID *psDroid)
{
@@ -826,6 +828,12 @@ void droidUpdate(DROID *psDroid)
}
// -----------------
+ // See if we can and need to self repair.
+ if (!isVtolDroid(psDroid) && psDroid->body < psDroid->originalBody && psDroid->asBits[COMP_REPAIRUNIT].nStat != 0 && selfRepairEnabled(psDroid->player))
+ {
+ droidUpdateDroidSelfRepair(psDroid);
+ }
+
/* Update the fire damage data */
if (psDroid->burnStart != 0 && psDroid->burnStart != gameTime - deltaGameTime) // -deltaGameTime, since projectiles are updated after droids.
{
@@ -1176,29 +1184,6 @@ bool droidStartDroidRepair( DROID *psDroid )
return true;
}
-/*checks a droids current body points to see if need to self repair*/
-void droidSelfRepair(DROID *psDroid)
-{
- CHECK_DROID(psDroid);
-
- if (!isVtolDroid(psDroid))
- {
- if (psDroid->body < psDroid->originalBody)
- {
- if (psDroid->asBits[COMP_REPAIRUNIT].nStat != 0)
- {
- psDroid->action = DACTION_DROIDREPAIR;
- setDroidActionTarget(psDroid, (BASE_OBJECT *)psDroid, 0);
- psDroid->actionStarted = gameTime;
- psDroid->actionPoints = 0;
- }
- }
- }
-
- CHECK_DROID(psDroid);
-}
-
-
/*Start a EW weapon droid working on a low resistance structure*/
bool droidStartRestore( DROID *psDroid )
{
@@ -1314,16 +1299,10 @@ bool droidUpdateRepair( DROID *psDroid )
}
/*Updates a Repair Droid working on a damaged droid*/
-bool droidUpdateDroidRepair(DROID *psRepairDroid)
+static bool droidUpdateDroidRepairBase(DROID *psRepairDroid, DROID *psDroidToRepair)
{
CHECK_DROID(psRepairDroid);
- ASSERT_OR_RETURN(false, psRepairDroid->action == DACTION_DROIDREPAIR, "Unit does not have unit repair order");
- ASSERT_OR_RETURN(false, psRepairDroid->asBits[COMP_REPAIRUNIT].nStat != 0, "Unit does not have a repair turret");
-
- DROID *psDroidToRepair = (DROID *)psRepairDroid->psActionTarget[0];
- ASSERT_OR_RETURN(false, psDroidToRepair->type == OBJ_DROID, "Target is not a unit");
-
int iRepairRateNumerator = repairPoints(asRepairStats + psRepairDroid->asBits[COMP_REPAIRUNIT].nStat, psRepairDroid->player);
int iRepairRateDenominator = 1;
@@ -1353,6 +1332,22 @@ bool droidUpdateDroidRepair(DROID *psRepairDroid)
return psDroidToRepair->body < psDroidToRepair->originalBody;
}
+bool droidUpdateDroidRepair(DROID *psRepairDroid)
+{
+ ASSERT_OR_RETURN(false, psRepairDroid->action == DACTION_DROIDREPAIR, "Unit does not have unit repair order");
+ ASSERT_OR_RETURN(false, psRepairDroid->asBits[COMP_REPAIRUNIT].nStat != 0, "Unit does not have a repair turret");
+
+ DROID *psDroidToRepair = (DROID *)psRepairDroid->psActionTarget[0];
+ ASSERT_OR_RETURN(false, psDroidToRepair->type == OBJ_DROID, "Target is not a unit");
+
+ return droidUpdateDroidRepairBase(psRepairDroid, psDroidToRepair);
+}
+
+static void droidUpdateDroidSelfRepair(DROID *psRepairDroid)
+{
+ droidUpdateDroidRepairBase(psRepairDroid, psRepairDroid);
+}
+
// return whether a droid is IDF
bool idfDroid(DROID *psDroid)
{
View
3  src/droid.h
@@ -157,9 +157,6 @@ extern bool droidStartDroidRepair( DROID *psDroid );
/*Updates a Repair Droid working on a damaged droid - returns true whilst repairing*/
extern bool droidUpdateDroidRepair(DROID *psRepairDroid);
-/*checks a droids current body points to see if need to self repair*/
-extern void droidSelfRepair(DROID *psDroid);
-
/* Update a construction droid while it is building
returns true while building continues */
extern bool droidUpdateBuild(DROID *psDroid);

1 comment on commit 8c83693

@dak180

@Cyp as I answered when you asked on irc there are two reasons why droids only repair when stopped: the story reason and the balance one, which I will enumerate here.

The balance one is of course that they become much harder to kill (I have not done tests to be able to say how much harder though); I would be most worried some especially high HP combos becoming more or less unkillable.

The story explanation is rather simple, since these are military vehicles there is the smallest possible margins for everything, including on-board power budget; this means that any later upgrades need to fit that budget; which in this case means that while they are repairing they cannot move or fire (or in some cases, produce more rounds to reload with), the two other most energy intensive operations they can perform.

All that said, I would not object to a droid still keeping a radar watch and continuing it's retreat when threatened; in fact I think that would cover most, if not all of the issues that people have with the current behavior.

Please sign in to comment.
Something went wrong with that request. Please try again.