Skip to content

Commit

Permalink
Merge pull request #498 from GoogleFrog/decloakLosOption
Browse files Browse the repository at this point in the history
Added the modrule decloakRequiresLineOfSight
  • Loading branch information
gajop committed Mar 23, 2020
2 parents a942be9 + 5ddef55 commit cb54625
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions rts/Sim/Misc/ModInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void CModInfo::ResetState()

requireSonarUnderWater = true;
alwaysVisibleOverridesCloaked = false;
decloakRequiresLineOfSight = false;
separateJammers = true;
}
{
Expand Down Expand Up @@ -252,6 +253,7 @@ void CModInfo::Init(const std::string& modFileName)

requireSonarUnderWater = sensors.GetBool("requireSonarUnderWater", requireSonarUnderWater);
alwaysVisibleOverridesCloaked = sensors.GetBool("alwaysVisibleOverridesCloaked", alwaysVisibleOverridesCloaked);
decloakRequiresLineOfSight = sensors.GetBool("decloakRequiresLineOfSight", decloakRequiresLineOfSight);
separateJammers = sensors.GetBool("separateJammers", separateJammers);

// losMipLevel is used as index to readMap->mipHeightmaps,
Expand Down
4 changes: 3 additions & 1 deletion rts/Sim/Misc/ModInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ class CModInfo

/// when underwater, units are not in LOS unless also in sonar
bool requireSonarUnderWater;
///
/// when unit->alwaysVisible is true, it is visible even when cloaked
bool alwaysVisibleOverridesCloaked;
/// ignore enemies when checking decloak if they are further than their spherical sight range
bool decloakRequiresLineOfSight;
/// should _all_ allyteams share the same jammermap
bool separateJammers;

Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Units/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2395,7 +2395,7 @@ bool CUnit::GetNewCloakState(bool stunCheck) {
const CUnit* closestEnemy = this;

if (!stunCheck)
closestEnemy = CGameHelper::GetClosestEnemyUnitNoLosTest(this, midPos, decloakDistance, allyteam, unitDef->decloakSpherical, false);
closestEnemy = CGameHelper::GetClosestEnemyUnitNoLosTest(this, midPos, decloakDistance, allyteam, unitDef->decloakSpherical, modInfo.decloakRequiresLineOfSight);

return (eventHandler.AllowUnitCloak(this, closestEnemy));
}
Expand Down

0 comments on commit cb54625

Please sign in to comment.