Skip to content

Commit d1adee2

Browse files
committed
Add exhaust for DumbProjectileBehavior
Add fix for FXList groundHeight
1 parent cd69854 commit d1adee2

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "WWMath/matrix3d.h"
4040

4141
class ParticleSystem;
42+
enum ParticleSystemID CPP_11(: Int);
4243
class FXList;
4344

4445

@@ -120,11 +121,16 @@ class DumbProjectileBehavior : public UpdateModule, public ProjectileUpdateInter
120121
Int m_currentFlightPathStep; ///< Our current index in the flight path vector. Quicker than popping off.
121122
WeaponBonusConditionFlags m_extraBonusFlags;
122123

124+
const ParticleSystemTemplate* m_exhaustSysTmpl;
125+
ParticleSystemID m_exhaustID;
126+
123127
Bool m_hasDetonated; ///<
124128

125129
Bool calcFlightPath(Bool recalcNumSegments);
126130
#if defined(RTS_DEBUG)
127131
void displayFlightPath(); ///< Uses little debug icons in worldspace to show the path chosen when it is decided upon
128132
#endif
129133

134+
void tossExhaust();
135+
130136
};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,15 @@ class ParticleSystemFXNugget : public FXNugget
827827
if (!isValidSurface(primary, &info))
828828
continue;
829829

830-
refHeight = needWaterCheck ? info.m_waterHeight : info.m_groundHeight;
830+
refHeight = surfaceInfo->m_isWater ? info.m_waterHeight : info.m_groundHeight;
831831
}
832832

833833
if (m_createAtGroundHeight) {
834834
if (needExactCheck) {
835835
newPos.z = refHeight + offset.z + m_height.getValue();
836836
}
837837
else {
838-
refHeight = needWaterCheck ? surfaceInfo->m_waterHeight : surfaceInfo->m_groundHeight;
838+
refHeight = surfaceInfo->m_isWater ? surfaceInfo->m_waterHeight : surfaceInfo->m_groundHeight;
839839
newPos.z = refHeight + offset.z + m_height.getValue();
840840
}
841841
}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "Common/RandomValue.h"
3737
#include "Common/Xfer.h"
3838
#include "GameClient/Drawable.h"
39+
#include "GameClient/ParticleSys.h"
3940
#include "GameClient/FXList.h"
4041
#include "GameLogic/GameLogic.h"
4142
#include "GameLogic/Object.h"
@@ -126,13 +127,16 @@ DumbProjectileBehavior::DumbProjectileBehavior( Thing *thing, const ModuleData*
126127
m_flightPathEnd.zero();
127128
m_currentFlightPathStep = 0;
128129
m_extraBonusFlags = 0;
130+
m_exhaustSysTmpl = nullptr;
131+
m_exhaustID = INVALID_PARTICLE_SYSTEM_ID;
129132

130133
m_hasDetonated = FALSE;
131134
}
132135

133136
//-------------------------------------------------------------------------------------------------
134137
DumbProjectileBehavior::~DumbProjectileBehavior()
135138
{
139+
tossExhaust();
136140
}
137141

138142
//-------------------------------------------------------------------------------------------------
@@ -324,6 +328,16 @@ static Bool calcTrajectory(
324328

325329
#endif // NOT_IN_USE
326330

331+
//-------------------------------------------------------------------------------------------------
332+
void DumbProjectileBehavior::tossExhaust()
333+
{
334+
if (m_exhaustID != INVALID_PARTICLE_SYSTEM_ID)
335+
{
336+
TheParticleSystemManager->destroyParticleSystemByID(m_exhaustID);
337+
m_exhaustID = INVALID_PARTICLE_SYSTEM_ID;
338+
}
339+
}
340+
327341
//-------------------------------------------------------------------------------------------------
328342
// Prepares the missile for launch via proper weapon-system channels.
329343
//-------------------------------------------------------------------------------------------------
@@ -407,6 +421,12 @@ void DumbProjectileBehavior::projectileFireAtObjectOrPosition( const Object *vic
407421
return;
408422
}
409423
m_currentFlightPathStep = 0;// We are at the first point, because the launching put us there
424+
425+
m_exhaustSysTmpl = exhaustSysOverride;
426+
if (m_exhaustSysTmpl != nullptr)
427+
{
428+
m_exhaustID = TheParticleSystemManager->createAttachedParticleSystemID(m_exhaustSysTmpl, getObject());
429+
}
410430
}
411431

412432
//-------------------------------------------------------------------------------------------------
@@ -845,6 +865,18 @@ void DumbProjectileBehavior::xfer( Xfer *xfer )
845865

846866
}
847867

868+
AsciiString exhaustName;
869+
if (m_exhaustSysTmpl)
870+
{
871+
exhaustName = m_exhaustSysTmpl->getName();
872+
}
873+
xfer->xferAsciiString(&exhaustName);
874+
if (exhaustName.isNotEmpty() && m_exhaustSysTmpl == nullptr)
875+
{
876+
m_exhaustSysTmpl = TheParticleSystemManager->findTemplate(exhaustName);
877+
}
878+
879+
848880
// lifespan frame
849881
xfer->xferUnsignedInt( &m_lifespanFrame );
850882

0 commit comments

Comments
 (0)