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