Skip to content

Commit ae315b4

Browse files
committed
fix ScatterOnImpact and add angle limitations for ScatterShotUpdate
1 parent a26292a commit ae315b4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ScatterShotUpdateModuleData : public UpdateModuleData
5353
Bool m_preferNearestTargets;
5454
Real m_noTargetsScatterRadius;
5555
Real m_noTargetsScatterMinRadius;
56+
Real m_noTargetsScatterMaxAngle;
5657
Bool m_attackGroundWhenNoTargets;
5758

5859
Real m_triggerDistanceToTarget;

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ScatterShotUpdate.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ ScatterShotUpdateModuleData::ScatterShotUpdateModuleData()
8989
{ "PreferNearestTargets", INI::parseBool, NULL, offsetof(ScatterShotUpdateModuleData, m_preferNearestTargets) },
9090
{ "NoTargetsScatterRadius", INI::parseReal, NULL, offsetof(ScatterShotUpdateModuleData, m_noTargetsScatterRadius) },
9191
{ "NoTargetsScatterMinRadius", INI::parseReal, NULL, offsetof(ScatterShotUpdateModuleData, m_noTargetsScatterMinRadius) },
92+
{ "NoTargetsScatterMaxAngle", INI::parseAngleReal, NULL, offsetof(ScatterShotUpdateModuleData, m_noTargetsScatterMaxAngle) },
9293
{ "AttackGroundWhenNoTargets", INI::parseBool, NULL, offsetof(ScatterShotUpdateModuleData, m_attackGroundWhenNoTargets) },
9394

9495
{ "TriggerDistanceToTarget", INI::parseReal, NULL, offsetof(ScatterShotUpdateModuleData, m_triggerDistanceToTarget) },
@@ -403,7 +404,16 @@ void ScatterShotUpdate::triggerScatterShot(void)
403404
targetPos.y = pos->y;
404405

405406
Real scatterRadius = GameLogicRandomValueReal(MAX(data->m_noTargetsScatterMinRadius, data->m_targetMinRadius), data->m_noTargetsScatterRadius);
406-
Real scatterAngleRadian = GameLogicRandomValueReal(0, 2 * PI);
407+
408+
Real scatterAngleRadian;
409+
if (data->m_noTargetsScatterMaxAngle > 0) {
410+
Real orientation = getObject()->getOrientation();
411+
scatterAngleRadian = normalizeAngle(GameLogicRandomValueReal(orientation - data->m_noTargetsScatterMaxAngle, orientation + data->m_noTargetsScatterMaxAngle));
412+
}
413+
else
414+
{
415+
scatterAngleRadian = GameLogicRandomValueReal(0, 2 * PI);
416+
}
407417

408418
Coord3D firingOffset;
409419
firingOffset.zero();

0 commit comments

Comments
 (0)