@@ -33,6 +33,8 @@ DroneCarrierContainModuleData::DroneCarrierContainModuleData() : TransportContai
3333 m_deathTypeToContained = DEATH_DETONATED ;
3434 m_enterPositionOffsets.clear ();
3535 m_keepSlotAssignment = false ;
36+ m_numLaunchBones = 0 ;
37+ m_launchBone.clear ();
3638}
3739
3840void DroneCarrierContainModuleData::buildFieldParse (MultiIniFieldParse& p)
@@ -45,6 +47,8 @@ void DroneCarrierContainModuleData::buildFieldParse(MultiIniFieldParse& p)
4547 { " LaunchVelocityBoost" , INI ::parseReal, NULL , offsetof (DroneCarrierContainModuleData, m_launchVelocityBoost) },
4648 { " EnterPositionOffset" , DroneCarrierContainModuleData::parseEnterPositionOffset, NULL , 0 },
4749 { " KeepSlotAssignment" , INI ::parseBool, NULL , offsetof (DroneCarrierContainModuleData, m_keepSlotAssignment)},
50+ { " LaunchBone" , INI ::parseAsciiString, NULL , offsetof (DroneCarrierContainModuleData, m_launchBone)},
51+ { " NumLaunchBones" , INI ::parseInt, NULL , offsetof (DroneCarrierContainModuleData, m_numLaunchBones)},
4852 { 0 , 0 , 0 , 0 }
4953 };
5054 p.add (dataFieldParse);
@@ -138,8 +142,31 @@ void DroneCarrierContain::onRemoving(Object* rider)
138142 rider_draw->enableAmbientSound (true );
139143 }
140144
145+ if (!d->m_launchBone .isEmpty () && d->m_numLaunchBones > 0 )
146+ {
147+ Drawable* draw = getObject ()->getDrawable ();
148+ if (draw)
149+ {
150+ Coord3D bonePos;
151+ Matrix3D boneMat;
152+
153+ Int slot = m_containList.size ();
154+ if (slot >= 0 ) {
155+ Int boneId = slot % d->m_numLaunchBones ;
156+ Int foundBones = draw->getPristineBonePositions (d->m_launchBone .str (), boneId + 1 , &bonePos, &boneMat, 1 );
157+
158+ if (foundBones > 0 ) {
159+ Coord3D worldPos;
160+ Matrix3D worldMat;
161+ getObject ()->convertBonePosToWorldPos (&bonePos, &boneMat, &worldPos, &worldMat);
162+ rider->setPosition (&worldPos);
163+ rider->setTransformMatrix (&worldMat);
164+ }
165+ }
166+ }
167+ }
141168 // If we have a bone and no exit paths, put each rider at the numbered bone position
142- if (!d->m_exitBone .isEmpty () && d->m_numberOfExitPaths <= 0 )
169+ else if (!d->m_exitBone .isEmpty () && d->m_numberOfExitPaths <= 0 )
143170 {
144171 Drawable* draw = getObject ()->getDrawable ();
145172 if (draw)
@@ -346,9 +373,29 @@ void DroneCarrierContain::onDie(const DamageInfo* damageInfo)
346373
347374short DroneCarrierContain::getRiderSlot (ObjectID riderID) const
348375{
349- for (size_t i = 0 ; i < m_contained_units.size (); i++) {
350- if (std::get<0 >(m_contained_units[i]) == riderID) {
351- return i;
376+ const DroneCarrierContainModuleData* data = getDroneCarrierContainModuleData ();
377+ if (data->m_keepSlotAssignment ) {
378+ for (size_t i = 0 ; i < m_contained_units.size (); i++) {
379+ if (std::get<0 >(m_contained_units[i]) == riderID) {
380+ return i;
381+ }
382+ }
383+ }
384+ else {
385+ // use the list
386+ auto it = m_containList.begin ();
387+ short index = 0 ;
388+
389+ while (it != m_containList.end ())
390+ {
391+ Object* object = *it;
392+ DEBUG_ASSERTCRASH (object, (" Contain list must not contain NULL element" ));
393+ if (object->getID () == riderID) {
394+ return index;
395+ }
396+
397+ ++index;
398+ ++it;
352399 }
353400 }
354401 return -1 ;
0 commit comments