Skip to content

Commit fa9bb64

Browse files
authored
bugfix(module): Consistently yield experience for direct poison kills (#1527)
1 parent 1bab18e commit fa9bb64

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

Generals/Code/GameEngine/Include/GameLogic/Module/PoisonedBehavior.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class PoisonedBehavior : public UpdateModule,
9292
UnsignedInt m_poisonDamageFrame;
9393
UnsignedInt m_poisonOverallStopFrame;
9494
Real m_poisonDamageAmount;
95+
ObjectID m_poisonSource;
9596
DeathType m_deathType;
9697

9798
};

Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PoisonedBehavior.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ PoisonedBehavior::PoisonedBehavior( Thing *thing, const ModuleData* moduleData )
7070
m_poisonDamageFrame = 0;
7171
m_poisonOverallStopFrame = 0;
7272
m_poisonDamageAmount = 0.0f;
73+
m_poisonSource = INVALID_ID;
7374
m_deathType = DEATH_POISONED;
7475
setWakeFrame(getObject(), UPDATE_SLEEP_FOREVER);
7576
}
@@ -117,7 +118,7 @@ UpdateSleepTime PoisonedBehavior::update()
117118
// If it is time to do damage, then do it and reset the damage timer
118119
DamageInfo damage;
119120
damage.in.m_amount = m_poisonDamageAmount;
120-
damage.in.m_sourceID = INVALID_ID;
121+
damage.in.m_sourceID = m_poisonSource;
121122
damage.in.m_damageType = DAMAGE_UNRESISTABLE; // Not poison, as that will infect us again
122123
damage.in.m_deathType = m_deathType;
123124
getObject()->attemptDamage( &damage );
@@ -157,6 +158,10 @@ void PoisonedBehavior::startPoisonedEffects( const DamageInfo *damageInfo )
157158

158159
// We are going to take the damage dealt by the original poisoner every so often for a while.
159160
m_poisonDamageAmount = damageInfo->out.m_actualDamageDealt;
161+
#if !RETAIL_COMPATIBLE_CRC
162+
// TheSuperHackers @bugfix Stubbjax 03/09/2025 Allow poison damage to award xp to the poison source.
163+
m_poisonSource = damageInfo->in.m_sourceID;
164+
#endif
160165

161166
m_poisonOverallStopFrame = now + d->m_poisonDurationData;
162167

@@ -182,6 +187,7 @@ void PoisonedBehavior::stopPoisonedEffects()
182187
m_poisonDamageFrame = 0;
183188
m_poisonOverallStopFrame = 0;
184189
m_poisonDamageAmount = 0.0f;
190+
m_poisonSource = INVALID_ID;
185191

186192
Drawable *myDrawable = getObject()->getDrawable();
187193
if( myDrawable )
@@ -208,7 +214,11 @@ void PoisonedBehavior::xfer( Xfer *xfer )
208214
{
209215

210216
// version
217+
#if RETAIL_COMPATIBLE_XFER_SAVE
211218
const XferVersion currentVersion = 2;
219+
#else
220+
const XferVersion currentVersion = 3;
221+
#endif
212222
XferVersion version = currentVersion;
213223
xfer->xferVersion( &version, currentVersion );
214224

@@ -229,6 +239,12 @@ void PoisonedBehavior::xfer( Xfer *xfer )
229239
xfer->xferUser(&m_deathType, sizeof(m_deathType));
230240
}
231241

242+
#if !RETAIL_COMPATIBLE_XFER_SAVE
243+
if (version >= 3)
244+
{
245+
xfer->xferObjectID(&m_poisonSource);
246+
}
247+
#endif
232248
}
233249

234250
// ------------------------------------------------------------------------------------------------

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class PoisonedBehavior : public UpdateModule,
9292
UnsignedInt m_poisonDamageFrame;
9393
UnsignedInt m_poisonOverallStopFrame;
9494
Real m_poisonDamageAmount;
95+
ObjectID m_poisonSource;
9596
DeathType m_deathType;
9697

9798
};

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ PoisonedBehavior::PoisonedBehavior( Thing *thing, const ModuleData* moduleData )
7070
m_poisonDamageFrame = 0;
7171
m_poisonOverallStopFrame = 0;
7272
m_poisonDamageAmount = 0.0f;
73+
m_poisonSource = INVALID_ID;
7374
m_deathType = DEATH_POISONED;
7475
setWakeFrame(getObject(), UPDATE_SLEEP_FOREVER);
7576
}
@@ -117,7 +118,7 @@ UpdateSleepTime PoisonedBehavior::update()
117118
// If it is time to do damage, then do it and reset the damage timer
118119
DamageInfo damage;
119120
damage.in.m_amount = m_poisonDamageAmount;
120-
damage.in.m_sourceID = INVALID_ID;
121+
damage.in.m_sourceID = m_poisonSource;
121122
damage.in.m_damageType = DAMAGE_UNRESISTABLE; // Not poison, as that will infect us again
122123
damage.in.m_damageFXOverride = DAMAGE_POISON; // but this will ensure that the right effect is played
123124
damage.in.m_deathType = m_deathType;
@@ -158,6 +159,10 @@ void PoisonedBehavior::startPoisonedEffects( const DamageInfo *damageInfo )
158159

159160
// We are going to take the damage dealt by the original poisoner every so often for a while.
160161
m_poisonDamageAmount = damageInfo->out.m_actualDamageDealt;
162+
#if !RETAIL_COMPATIBLE_CRC
163+
// TheSuperHackers @bugfix Stubbjax 03/09/2025 Allow poison damage to award xp to the poison source.
164+
m_poisonSource = damageInfo->in.m_sourceID;
165+
#endif
161166

162167
m_poisonOverallStopFrame = now + d->m_poisonDurationData;
163168

@@ -183,6 +188,7 @@ void PoisonedBehavior::stopPoisonedEffects()
183188
m_poisonDamageFrame = 0;
184189
m_poisonOverallStopFrame = 0;
185190
m_poisonDamageAmount = 0.0f;
191+
m_poisonSource = INVALID_ID;
186192

187193
Drawable *myDrawable = getObject()->getDrawable();
188194
if( myDrawable )
@@ -209,7 +215,11 @@ void PoisonedBehavior::xfer( Xfer *xfer )
209215
{
210216

211217
// version
218+
#if RETAIL_COMPATIBLE_XFER_SAVE
212219
const XferVersion currentVersion = 2;
220+
#else
221+
const XferVersion currentVersion = 3;
222+
#endif
213223
XferVersion version = currentVersion;
214224
xfer->xferVersion( &version, currentVersion );
215225

@@ -230,6 +240,12 @@ void PoisonedBehavior::xfer( Xfer *xfer )
230240
xfer->xferUser(&m_deathType, sizeof(m_deathType));
231241
}
232242

243+
#if !RETAIL_COMPATIBLE_XFER_SAVE
244+
if (version >= 3)
245+
{
246+
xfer->xferObjectID(&m_poisonSource);
247+
}
248+
#endif
233249
}
234250

235251
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)