Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(gameengine): spotter sight, beyond-vision acquire and blind scatter

Olcay Seygan7ea20cded902
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h b/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h
index 8715a4ec1..0ce223057 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h
@@ -432,6 +432,10 @@ public:
// Only Object can ask this. Everyone else should ask the Object. In fact, you really should ask the Object everything.
Real friend_calcVisionRange() const { return m_visionRange; } ///< get vision range
Real friend_calcShroudClearingRange() const { return m_shroudClearingRange; } ///< get vision range for Shroud ONLY (Design requested split)
+ /// AcquiresBeyondVision: idle, it takes targets out to its weapon's reach that its player sees, not just its own eyes'
+ Bool acquiresBeyondVision() const { return m_acquiresBeyondVision; }
+ /// SpotterSight: it keeps its whole ShroudClearingRange however short its weapon is (Object::look)
+ Bool hasSpotterSight() const { return m_spotterSight; }
//This one is okay to check directly... because it doesn't get effected by bonuses.
Real getShroudRevealToAllRange() const { return m_shroudRevealToAllRange; }
@@ -744,6 +748,8 @@ private:
Real m_fenceXOffset; ///< Fence X offset for fence type objects.
Real m_visionRange; ///< object "sees" this far around itself
Real m_shroudClearingRange; ///< Since So many things got added to "Seeing" functionality, we need to split this part out.
+ Bool m_acquiresBeyondVision; ///< Turkey's artillery: idle auto-acquire reaches its weapon range through a spotter's eyes
+ Bool m_spotterSight; ///< Turkey's spotters: sight not capped at half as far again as the weapon reaches
Real m_shroudRevealToAllRange; ///< When > zero, the shroud gets revealed to all players.
Real m_placementViewAngle; ///< when placing buildings this will be the angle of the building when "floating" at the mouse
Real m_factoryExitWidth; ///< when placing buildings this will be the width of the reserved exit area on the right side.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WeaponSetUpgrade.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WeaponSetUpgrade.h
index d73612c99..bc205a439 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WeaponSetUpgrade.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/WeaponSetUpgrade.h
@@ -34,18 +34,31 @@
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
#include "GameLogic/Module/UpgradeModule.h"
+#include "GameLogic/WeaponSetType.h"
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
class Thing;
//-------------------------------------------------------------------------------------------------
-/** The default die module */
+/** WeaponSetFlag names the flag the upgrade raises, PLAYER_UPGRADE when it is left out. EA's data
+ has one weapon set upgrade a unit; Turkey's artillery has two (Extended Range and Precision
+ Guidance), so the second raises CRATEUPGRADE_ONE, which no Turkey unit gets from a crate. */
+//-------------------------------------------------------------------------------------------------
+class WeaponSetUpgradeModuleData : public UpgradeModuleData
+{
+public:
+ WeaponSetUpgradeModuleData( void ) : m_weaponSetFlag( WEAPONSET_PLAYER_UPGRADE ) { }
+ static void buildFieldParse( MultiIniFieldParse& p );
+
+ WeaponSetType m_weaponSetFlag;
+};
+
//-------------------------------------------------------------------------------------------------
class WeaponSetUpgrade : public UpgradeModule
{
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( WeaponSetUpgrade, "WeaponSetUpgrade" )
- MAKE_STANDARD_MODULE_MACRO( WeaponSetUpgrade );
+ MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( WeaponSetUpgrade, WeaponSetUpgradeModuleData );
public:
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
index ac7850871..5cb019baa 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
@@ -510,6 +510,7 @@ private:
Real m_requestAssistRange; ///< My object will look this far around to get people to join in the attack.
Real m_aimDelta; ///< when aiming, consider yourself "aimed" if you are within +/- this much of an angle
Real m_scatterRadius; ///< Radius of area actual fire point will be in, default is zero for no deviation
+ Real m_blindScatterRadius; ///< added to the scatter when the firer's player cannot see where the shot is going
Real m_scatterTargetScalar; ///< Radius of area covered by the coordinates in the scatterTarget table
std::vector<Coord2D> m_scatterTargets; ///< instead of pure randomness, this is the list of places I will randomly choose from to attack
DamageType m_damageType; ///< damage type enum
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp
index a877a532a..2ac56974c 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp
@@ -126,6 +126,8 @@ const FieldParse ThingTemplate::s_objectFieldParseTable[] =
{ "WeaponSet", ThingTemplate::parseWeaponTemplateSet,NULL, 0},
{ "VisionRange", INI::parseReal, NULL, offsetof( ThingTemplate, m_visionRange ) },
{ "ShroudClearingRange", INI::parseReal, NULL, offsetof( ThingTemplate, m_shroudClearingRange ) },
+ { "AcquiresBeyondVision", INI::parseBool, NULL, offsetof( ThingTemplate, m_acquiresBeyondVision ) },
+ { "SpotterSight", INI::parseBool, NULL, offsetof( ThingTemplate, m_spotterSight ) },
{ "ShroudRevealToAllRange", INI::parseReal, NULL, offsetof( ThingTemplate, m_shroudRevealToAllRange ) },
{ "PlacementViewAngle", INI::parseAngleReal, NULL, offsetof( ThingTemplate, m_placementViewAngle ) },
@@ -687,7 +689,9 @@ void ThingTemplate::parsePrerequisites( INI* ini, void *instance, void *store, c
{ 0, 0, 0, 0 }
};
- if (ini->getLoadType() == INI_LOAD_CREATE_OVERRIDES)
+ // a patch file (MULTIFILE, TurkeyReforged.ini) states the whole list too, not an addition to the
+ // list its reskin source left behind
+ if (ini->getLoadType() == INI_LOAD_CREATE_OVERRIDES || ini->getLoadType() == INI_LOAD_MULTIFILE)
{
self->m_prereqInfo.clear();
}
@@ -1083,6 +1087,8 @@ ThingTemplate::ThingTemplate() :
m_fenceXOffset = 0;
m_visionRange = 0.0f;
m_shroudClearingRange = -1.0f;
+ m_acquiresBeyondVision = FALSE;
+ m_spotterSight = FALSE;
m_shroudRevealToAllRange = -1.0f;
m_buildCost = 0;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
index 1d8421e7e..fce48c071 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
@@ -5424,9 +5424,10 @@ void Object::look()
// applied here and not in getShroudClearingRange, so the sight bonuses that multiply the
// stored range and later divide it back out never bake the weapon cap into it. A dozer or
// a worker carries a mine-clearing weapon a few feet long, and capped by it the builder
- // was blind: it keeps its template's sight
+ // was blind: it keeps its template's sight. So does a spotter, whose sight is its job and
+ // whose carbine is for show
Real shroudClearingRange = getShroudClearingRange();
- if( !isKindOf( KINDOF_STRUCTURE ) && !isKindOf( KINDOF_DOZER ) )
+ if( !isKindOf( KINDOF_STRUCTURE ) && !isKindOf( KINDOF_DOZER ) && !getTemplate()->hasSpotterSight() )
shroudClearingRange = Object_armedShroudClearingRange( shroudClearingRange, getLargestWeaponRange() );
if( shroudClearingRange > 0.0f )
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index 7a819a300..3216c0d6d 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -6903,6 +6903,12 @@ Object* AIUpdateInterface::getNextMoodTarget( Bool calledByAI, Bool calledDuring
rangeToFindWithin = weaponRange * (requireWithinWeaponRange ? 1.0f : ATTACK_MOVE_SEARCH_SCALE);
}
+ // Turkey's artillery sees 100 and shoots 600: it takes what a spotter shows its player, out to its
+ // weapon's reach. The fog filter below is what keeps that to targets the team actually sees.
+ const Bool beyondVision = obj->getTemplate()->acquiresBeyondVision();
+ if (beyondVision)
+ rangeToFindWithin = max(rangeToFindWithin, obj->getLargestWeaponRange());
+
if (rangeToFindWithin <= 0.0f)
return NULL;
@@ -6982,7 +6988,7 @@ Object* AIUpdateInterface::getNextMoodTarget( Bool calledByAI, Bool calledDuring
// members and base defence turrets all route through here - so the exemption covered every one
// of them. The AI now sees what a player sees, which is also what makes stealth work against it.
//
- if( calledByAI && obj->getControllingPlayer() )
+ if( (calledByAI || beyondVision) && obj->getControllingPlayer() )
{
flags |= AI::UNFOGGED;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/WeaponSetUpgrade.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/WeaponSetUpgrade.cpp
index 07076cfc4..0d6c5ce0e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/WeaponSetUpgrade.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/WeaponSetUpgrade.cpp
@@ -33,6 +33,20 @@
#include "Common/Xfer.h"
#include "GameLogic/Object.h"
#include "GameLogic/Module/WeaponSetUpgrade.h"
+#include "GameLogic/WeaponSetFlags.h"
+
+//-------------------------------------------------------------------------------------------------
+void WeaponSetUpgradeModuleData::buildFieldParse( MultiIniFieldParse& p )
+{
+ UpgradeModuleData::buildFieldParse( p );
+
+ static const FieldParse dataFieldParse[] =
+ {
+ { "WeaponSetFlag", INI::parseIndexList, WeaponSetFlags::getBitNames(), offsetof( WeaponSetUpgradeModuleData, m_weaponSetFlag ) },
+ { 0, 0, 0, 0 }
+ };
+ p.add( dataFieldParse );
+}
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
@@ -53,7 +67,7 @@ void WeaponSetUpgrade::upgradeImplementation( )
// Very simple; just need to flag the Object as having the player upgrade, and the WeaponSet chooser
// will do the work of picking the right one from ini. This comment is as long as the code.
Object *obj = getObject();
- obj->setWeaponSetFlag( WEAPONSET_PLAYER_UPGRADE );
+ obj->setWeaponSetFlag( getWeaponSetUpgradeModuleData()->m_weaponSetFlag );
}
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
index a9ebafc19..c25365e10 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
@@ -221,6 +221,7 @@ const FieldParse WeaponTemplate::TheWeaponTemplateFieldParseTable[] =
{ "RequestAssistRange", INI::parseReal, NULL, offsetof(WeaponTemplate, m_requestAssistRange) },
{ "AcceptableAimDelta", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_aimDelta) },
{ "ScatterRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_scatterRadius) },
+ { "BlindScatterRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_blindScatterRadius) },
{ "ScatterTargetScalar", INI::parseReal, NULL, offsetof(WeaponTemplate, m_scatterTargetScalar) },
{ "ScatterRadiusVsInfantry", INI::parseReal, NULL, offsetof( WeaponTemplate, m_infantryInaccuracyDist ) },
{ "DamageType", DamageTypeFlags::parseSingleBitFromINI, NULL, offsetof(WeaponTemplate, m_damageType) },
@@ -308,6 +309,7 @@ WeaponTemplate::WeaponTemplate() : m_nextTemplate(NULL)
m_requestAssistRange = 0.0f;
m_aimDelta = 0.0f;
m_scatterRadius = 0.0f;
+ m_blindScatterRadius = 0.0f;
m_scatterTargetScalar = 0.0f;
m_shockWaveAmount = 0.0f;
m_shockWaveRadius = 0.0f;
@@ -1020,11 +1022,18 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate
Coord3D projectileDestination = *victimPos; //Need to copy this, as we have a pointer to their actual position
Real scatterRadius = 0.0f;
- if( m_scatterRadius > 0.0f || m_infantryInaccuracyDist > 0.0f && victimObj && victimObj->isKindOf( KINDOF_INFANTRY ) )
+ /* Turkey's artillery fires past its own sight and leans on a spotter. A shot at ground its
+ player does not see (a force fire into the fog, a target the spotter lost) spreads by
+ BlindScatterRadius on top. The shroud is logic state, the same every machine reads. */
+ Real blindScatter = 0.0f;
+ if( m_blindScatterRadius > 0.0f && sourceObj && sourceObj->getControllingPlayer() &&
+ ThePartitionManager->getShroudStatusForPlayer( sourceObj->getControllingPlayer()->getPlayerIndex(), victimPos ) != CELLSHROUD_CLEAR )
+ blindScatter = m_blindScatterRadius;
+ if( m_scatterRadius > 0.0f || blindScatter > 0.0f || m_infantryInaccuracyDist > 0.0f && victimObj && victimObj->isKindOf( KINDOF_INFANTRY ) )
{
// This weapon scatters, so clear the victimObj, as we are no longer shooting it directly,
// and find a random point within the radius to shoot at as victimPos
- scatterRadius = m_scatterRadius;
+ scatterRadius = m_scatterRadius + blindScatter;
// if it's an object, aim at the center, not the ground part (srj)
PathfindLayerEnum targetLayer = LAYER_GROUND;