Skip to content

Commit dbdcd89

Browse files
authored
tweak(module): Add 'TransferSelection' field to CreateObjectDie INI module to allow transfer selection on object creation (#1665)
This change allows to configure the GLA Sneak Attack in INI to remain selected after it transitioned to the fully emerged object. Object GLASneakAttackTunnelNetworkStart Behavior = CreateObjectDie ModuleTag ... TransferSelection = Yes ; The tunnel remains selected after emerging End End
1 parent 893a557 commit dbdcd89

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class CreateObjectDieModuleData : public DieModuleData
4848

4949
const ObjectCreationList* m_ocl; ///< object creaton list to make
5050
Bool m_transferPreviousHealth; ///< Transfers previous health before death to the new object created.
51+
Bool m_transferSelection; ///< Transfers selection state before death to the new object created.
5152

5253
CreateObjectDieModuleData();
5354

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "GameLogic/Object.h"
3939
#include "GameLogic/ObjectCreationList.h"
4040
#include "GameLogic/Module/BodyModule.h"
41-
41+
#include "GameClient/InGameUI.h"
4242

4343
// ------------------------------------------------------------------------------------------------
4444
// ------------------------------------------------------------------------------------------------
@@ -47,7 +47,7 @@ CreateObjectDieModuleData::CreateObjectDieModuleData()
4747

4848
m_ocl = NULL;
4949
m_transferPreviousHealth = FALSE;
50-
50+
m_transferSelection = FALSE;
5151
}
5252

5353
// ------------------------------------------------------------------------------------------------
@@ -60,6 +60,7 @@ CreateObjectDieModuleData::CreateObjectDieModuleData()
6060
{
6161
{ "CreationList", INI::parseObjectCreationList, NULL, offsetof( CreateObjectDieModuleData, m_ocl ) },
6262
{ "TransferPreviousHealth", INI::parseBool, NULL ,offsetof( CreateObjectDieModuleData, m_transferPreviousHealth ) },
63+
{ "TransferSelection", INI::parseBool, NULL, offsetof( CreateObjectDieModuleData, m_transferSelection ) },
6364
{ 0, 0, 0, 0 }
6465
};
6566
p.add(dataFieldParse);
@@ -95,11 +96,13 @@ void CreateObjectDie::onDie( const DamageInfo * damageInfo )
9596
Object *damageDealer = TheGameLogic->findObjectByID( damageInfo->in.m_sourceID );
9697

9798
Object *newObject = ObjectCreationList::create( data->m_ocl, getObject(), damageDealer );
99+
if (!newObject)
100+
return;
98101

99102
//If we're transferring previous health, we're transfering the last known
100103
//health before we died. In the case of the sneak attack tunnel network, it
101104
//is killed after the lifetime update expires.
102-
if( newObject && data->m_transferPreviousHealth )
105+
if( data->m_transferPreviousHealth )
103106
{
104107
//Convert old health to new health.
105108
Object *oldObject = getObject();
@@ -140,7 +143,22 @@ void CreateObjectDie::onDie( const DamageInfo * damageInfo )
140143
}
141144
}
142145

146+
// TheSuperHackers @bugfix Stubbjax 02/10/2025 If the old object was selected, select the new one.
147+
// This is important for the Sneak Attack, which is spawned via a CreateObjectDie module.
148+
if (data->m_transferSelection)
149+
{
150+
Object* oldObject = getObject();
151+
Drawable* selectedDrawable = TheInGameUI->getFirstSelectedDrawable();
152+
Bool oldObjectSelected = selectedDrawable && selectedDrawable->getID() == oldObject->getDrawable()->getID();
143153

154+
if (oldObjectSelected)
155+
{
156+
GameMessage* msg = TheMessageStream->appendMessage(GameMessage::MSG_CREATE_SELECTED_GROUP_NO_SOUND);
157+
msg->appendBooleanArgument(TRUE);
158+
msg->appendObjectIDArgument(newObject->getID());
159+
TheInGameUI->selectDrawable(newObject->getDrawable());
160+
}
161+
}
144162
}
145163

146164
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)