Skip to content

Commit ac134ab

Browse files
committed
added LocomotorWorksWhenDisabled
added flags for HeightDieUpdate
1 parent 2750c07 commit ac134ab

7 files changed

Lines changed: 51 additions & 8 deletions

File tree

GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ class LocomotorTemplate : public Overridable
200200
Real m_ultraAccurateSlideIntoPlaceFactor; ///< how much we can fudge turning when ultra-accurate
201201

202202
Bool m_locomotorWorksWhenDead; ///< should locomotor continue working even when object is "dead"?
203+
Bool m_locomotorWorksWhenDisabled; ///< should locomotor continue working even when object is disabled?
203204
Bool m_allowMotiveForceWhileAirborne; ///< can we apply motive when airborne?
204205
Bool m_apply2DFrictionWhenAirborne; // apply "2d friction" even when airborne... useful for realistic-looking movement
205206
Bool m_downhillOnly; // pinewood derby, moves only by gravity pulling downhill
@@ -287,6 +288,7 @@ class Locomotor : public MemoryPoolObject, public Snapshot
287288
Bool getAllowMotiveForceWhileAirborne() const { return m_template->m_allowMotiveForceWhileAirborne; }
288289
Int getAirborneTargetingHeight() const { return m_template->m_airborneTargetingHeight; }
289290
Bool getLocomotorWorksWhenDead() const { return m_template->m_locomotorWorksWhenDead; }
291+
Bool getLocomotorWorksWhenDisabled() const { return m_template->m_locomotorWorksWhenDisabled; }
290292
Bool getStickToGround() const { return m_template->m_stickToGround; }
291293
Real getCloseEnoughDist() const { return m_closeEnoughDist; }
292294
Bool isCloseEnoughDist3D() const { return getFlag(IS_CLOSE_ENOUGH_DIST_3D); }

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,10 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface
315315
virtual AIUpdateInterface* getAIUpdateInterface() { return this; }
316316

317317
// Disabled conditions to process (AI will still process held status)
318-
virtual DisabledMaskType getDisabledTypesToProcess() const { return MAKE_DISABLED_MASK( DISABLED_HELD ); }
318+
//virtual DisabledMaskType getDisabledTypesToProcess() const { return MAKE_DISABLED_MASK( DISABLED_HELD ); }
319+
320+
// We need to process all disabled types to allow Locomotor working while disabled
321+
virtual DisabledMaskType getDisabledTypesToProcess() const { return DISABLEDMASK_ALL; }
319322

320323
// Some very specific, complex behaviors are used by more than one AIUpdate. Here are their interfaces.
321324
virtual DozerAIInterface* getDozerAIInterface() { return NULL; }

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/HeightDieUpdate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ class HeightDieUpdateModuleData: public UpdateModuleData
4444
static void buildFieldParse(MultiIniFieldParse& p);
4545

4646
Real m_targetHeightAboveTerrain; ///< die at this height above terrain
47+
Bool m_dieAboveTargetHeight; ///< inverted case. Die if above the given height
4748
Bool m_targetHeightIncludesStructures; ///< target height considers terrain AND structure height underneath us
4849
Bool m_onlyWhenMovingDown; ///< don't detonate unless moving in downward z dir
50+
Bool m_onlyWhenMovingUp; ///< don't detonate unless moving in upwards z dir
4951
Real m_destroyAttachedParticlesAtHeight; ///< HACK, destroy any attached particle system of object when below this height
5052
Bool m_snapToGroundOnDeath; ///< snap to the ground when killed
5153
UnsignedInt m_initialDelay; ///< Don't explode before this time

GeneralsMD/Code/GameEngine/Source/GameClient/FXList.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static bool getSurfaceInfo(const Coord3D* primary, FXSurfaceInfo* surfaceInfo, B
159159
}
160160
else { // compute missing water info
161161
surfaceInfo->m_waterHeight = TheTerrainLogic->getWaterZ(primary->x, primary->y);
162+
surfaceInfo->m_isWater = surfaceInfo->m_waterHeight > surfaceInfo->m_groundHeight;
162163
surfaceInfo->m_isWaterChecked = true;
163164
return true;
164165
}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ LocomotorTemplate::LocomotorTemplate()
330330
m_downhillOnly = false;
331331
m_allowMotiveForceWhileAirborne = false;
332332
m_locomotorWorksWhenDead = false;
333+
m_locomotorWorksWhenDisabled = false;
333334
m_airborneTargetingHeight = INT_MAX;
334335
m_stickToGround = false;
335336
m_canMoveBackward = false;
@@ -489,6 +490,7 @@ const FieldParse* LocomotorTemplate::getFieldParse() const
489490
{ "DownhillOnly", INI::parseBool, NULL, offsetof(LocomotorTemplate, m_downhillOnly) },
490491
{ "AllowAirborneMotiveForce", INI::parseBool, NULL, offsetof(LocomotorTemplate, m_allowMotiveForceWhileAirborne) },
491492
{ "LocomotorWorksWhenDead", INI::parseBool, NULL, offsetof(LocomotorTemplate, m_locomotorWorksWhenDead) },
493+
{ "LocomotorWorksWhenDisabled", INI::parseBool, NULL, offsetof(LocomotorTemplate, m_locomotorWorksWhenDisabled) },
492494
{ "AirborneTargetingHeight", INI::parseInt, NULL, offsetof( LocomotorTemplate, m_airborneTargetingHeight ) },
493495
{ "StickToGround", INI::parseBool, NULL, offsetof(LocomotorTemplate, m_stickToGround) },
494496
{ "CanMoveBackwards", INI::parseBool, NULL, offsetof(LocomotorTemplate, m_canMoveBackward) },
@@ -1157,7 +1159,8 @@ void Locomotor::locoUpdate_moveTowardsPosition(Object* obj, const Coord3D& goalP
11571159
moveTowardsPositionTreads(obj, physics, goalPos, onPathDistToGoal, desiredSpeed);
11581160
break;
11591161
case LOCO_SHIP:
1160-
moveTowardsPositionTreads(obj, physics, goalPos, onPathDistToGoal, desiredSpeed);
1162+
moveTowardsPositionHover(obj, physics, goalPos, onPathDistToGoal, desiredSpeed);
1163+
//moveTowardsPositionTreads(obj, physics, goalPos, onPathDistToGoal, desiredSpeed);
11611164
break;
11621165
case LOCO_HOVER:
11631166
moveTowardsPositionHover(obj, physics, goalPos, onPathDistToGoal, desiredSpeed);

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,11 +1226,12 @@ UpdateSleepTime AIUpdateInterface::update( void )
12261226
Object *obj = getObject();
12271227

12281228
if (! obj->isEffectivelyDead() &&
1229-
! obj->isDisabledByType( DISABLED_PARALYZED ) &&
1230-
! obj->isDisabledByType( DISABLED_UNMANNED ) &&
1231-
! obj->isDisabledByType( DISABLED_EMP ) &&
1232-
! obj->isDisabledByType( DISABLED_SUBDUED ) &&
1233-
! obj->isDisabledByType( DISABLED_HACKED ) )
1229+
//! obj->isDisabledByType( DISABLED_PARALYZED ) &&
1230+
//! obj->isDisabledByType( DISABLED_UNMANNED ) &&
1231+
//! obj->isDisabledByType( DISABLED_EMP ) &&
1232+
//! obj->isDisabledByType( DISABLED_SUBDUED ) &&
1233+
//! obj->isDisabledByType( DISABLED_HACKED ) )
1234+
! (obj->isDisabled() && !obj->isDisabledByType(DISABLED_HELD )))
12341235
{
12351236
// If we are dead, don't let the turrets do anything anymore, or else they will keep attacking
12361237
for (int i = 0; i < MAX_TURRETS; ++i)
@@ -2275,6 +2276,18 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )
22752276

22762277
chooseGoodLocomotorFromCurrentSet();
22772278

2279+
// Disabled check
2280+
Bool disabled = getObject()->isDisabled() && !getObject()->isDisabledByType(DISABLED_HELD);
2281+
if (disabled && m_curLocomotor != NULL)
2282+
{
2283+
if (!m_curLocomotor->getLocomotorWorksWhenDisabled()) {
2284+
return UPDATE_SLEEP_FOREVER;
2285+
}
2286+
if (m_curLocomotor->locoUpdate_maintainCurrentPosition(getObject()))
2287+
return UPDATE_SLEEP_NONE;
2288+
return UPDATE_SLEEP_FOREVER;
2289+
}
2290+
22782291
if (m_isBlocked)
22792292
{
22802293
++m_blockedFrames;

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HeightDieUpdate.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ HeightDieUpdateModuleData::HeightDieUpdateModuleData( void )
4949
{
5050

5151
m_targetHeightAboveTerrain = 0.0f;
52+
m_dieAboveTargetHeight = FALSE;
5253
m_targetHeightIncludesStructures = FALSE;
5354
m_onlyWhenMovingDown = FALSE;
55+
m_onlyWhenMovingUp = FALSE;
5456
m_destroyAttachedParticlesAtHeight = -1.0f;
5557
m_snapToGroundOnDeath = FALSE;
5658
m_initialDelay = 0;
@@ -68,7 +70,9 @@ void HeightDieUpdateModuleData::buildFieldParse(MultiIniFieldParse& p)
6870
{
6971
{ "TargetHeight", INI::parseReal, NULL, offsetof( HeightDieUpdateModuleData, m_targetHeightAboveTerrain ) },
7072
{ "TargetHeightIncludesStructures", INI::parseBool, NULL, offsetof( HeightDieUpdateModuleData, m_targetHeightIncludesStructures ) },
73+
{ "DieAboveTargetHeight", INI::parseBool, NULL, offsetof( HeightDieUpdateModuleData, m_dieAboveTargetHeight) },
7174
{ "OnlyWhenMovingDown", INI::parseBool, NULL, offsetof( HeightDieUpdateModuleData, m_onlyWhenMovingDown ) },
75+
{ "OnlyWhenMovingUp", INI::parseBool, NULL, offsetof( HeightDieUpdateModuleData, m_onlyWhenMovingUp ) },
7276
{ "DestroyAttachedParticlesAtHeight", INI::parseReal, NULL, offsetof( HeightDieUpdateModuleData, m_destroyAttachedParticlesAtHeight ) },
7377
{ "SnapToGroundOnDeath", INI::parseBool, NULL, offsetof( HeightDieUpdateModuleData, m_snapToGroundOnDeath ) },
7478
{ "InitialDelay", INI::parseDurationUnsignedInt, NULL, offsetof( HeightDieUpdateModuleData, m_initialDelay ) },
@@ -148,6 +152,14 @@ UpdateSleepTime HeightDieUpdate::update( void )
148152

149153
}
150154

155+
if (modData->m_onlyWhenMovingUp)
156+
{
157+
158+
if (pos->z <= m_lastPosition.z)
159+
directionOK = FALSE;
160+
161+
}
162+
151163
// get the terrain height
152164
Real terrainHeightAtPos = TheTerrainLogic->getGroundHeight( pos->x, pos->y );
153165

@@ -215,8 +227,15 @@ UpdateSleepTime HeightDieUpdate::update( void )
215227

216228
}
217229

230+
bool doTheKill = false;
231+
232+
if (modData->m_dieAboveTargetHeight)
233+
doTheKill = pos->z > targetHeight && directionOK;
234+
else
235+
doTheKill = pos->z < targetHeight && directionOK;
236+
218237
// if we are below the target height ... DIE!
219-
if( pos->z < targetHeight && directionOK )
238+
if(doTheKill)
220239
{
221240

222241
// if we're supposed to snap us to the ground on death do so

0 commit comments

Comments
 (0)