-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to send sound alerts data to allies #1169
Merged
Iridar
merged 9 commits into
X2CommunityCore:master
from
RedDoby:ConsiderAlliesforSoundAlerts2
Aug 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
84809cc
Add option to send sound alerts data to allies
RedDoby f7078be
Changed from function to variable
RedDoby 929a9e7
Updated to latest highlander XComGame file
RedDoby b2b4a6f
Merge branch 'master' into ConsiderAlliesforSoundAlerts2
RedDoby f3d8a15
Update XComGame.ini
RedDoby 737e444
Update XComGame.ini
RedDoby 0844dd8
Change OutEnemies to OutUnits
RedDoby aa13e10
Merge branch 'ConsiderAlliesforSoundAlerts2' of https://github.com/Re…
RedDoby a32640b
Some docs fixes.
ps2guides File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9667,7 +9667,24 @@ function EventListenerReturn OnAbilityActivated(Object EventData, Object EventSo | |
GetKeystoneVisibilityLocation(SoundTileLocation); | ||
} | ||
|
||
GetEnemiesInRange(SoundTileLocation, SoundRange, Enemies); | ||
/// HL-Docs: feature:ConsiderAlliesforSoundAlerts; issue:620; tags:tactical | ||
/// if enabled then use our private function GetUnitsInRange | ||
/// Gather the units in sound range of this weapon to include sound from allied weapon fire. | ||
/// By default the base game code only checks for sound from enemy units | ||
/// But it makes sense that sound can be heard from anyone firing a weapon, not just enemies | ||
/// Note that this will not have any affect unless a mod has turned on | ||
/// yellow alerts in ShouldEnemyFactionsTriggerAlertsOutsidePlayerVision in XComGameState_AIUnitData | ||
/// Since by default alert data is not recorded for sound outside of XCom's vision | ||
// start issue #620 | ||
if( class'CHHelpers'.static.ConsiderAlliesforSoundAlerts() ) | ||
{ | ||
GetUnitsInRange(SoundTileLocation, SoundRange, Enemies); | ||
} | ||
else | ||
{ // Default behavior | ||
GetEnemiesInRange(SoundTileLocation, SoundRange, Enemies); | ||
} | ||
// end issue #620 | ||
|
||
`LogAI("Weapon sound @ Tile("$SoundTileLocation.X$","@SoundTileLocation.Y$","@SoundTileLocation.Z$") - Found"@Enemies.Length@"enemies in range ("$SoundRange$" meters)"); | ||
foreach Enemies(EnemyRef) | ||
|
@@ -10861,6 +10878,47 @@ function GetUnitsInRangeOnTeam(ETeam Team, TTile kLocation, int nMeters, out arr | |
} | ||
// End Issue #510 | ||
|
||
/// HL-Docs: ref:ConsiderAlliesforSoundAlerts | ||
// start issue #620 | ||
// Copied from XComGameState_Unit::GetEnemiesInRange, except will include all units within | ||
// the specified range. | ||
private function GetUnitsInRange(TTile kLocation, int nMeters, out array<StateObjectReference> OutEnemies) | ||
{ | ||
local vector vCenter, vLoc; | ||
local float fDistSq; | ||
local XComGameState_Unit kUnit; | ||
local XComGameStateHistory History; | ||
local eTeam Team; | ||
local float AudioDistanceRadius, UnitHearingRadius, RadiiSumSquared; | ||
|
||
History = `XCOMHISTORY; | ||
vCenter = `XWORLD.GetPositionFromTileCoordinates(kLocation); | ||
AudioDistanceRadius = `METERSTOUNITS(nMeters); | ||
fDistSq = Square(AudioDistanceRadius); | ||
|
||
foreach History.IterateByClassType(class'XComGameState_Unit', kUnit) | ||
{ | ||
Team = kUnit.GetTeam(); | ||
if( Team != eTeam_Neutral && kUnit.IsAlive() ) | ||
{ | ||
vLoc = `XWORLD.GetPositionFromTileCoordinates(kUnit.TileLocation); | ||
UnitHearingRadius = kUnit.GetCurrentStat(eStat_HearingRadius); | ||
|
||
RadiiSumSquared = fDistSq; | ||
if( UnitHearingRadius != 0 ) | ||
{ | ||
RadiiSumSquared = Square(AudioDistanceRadius + UnitHearingRadius); | ||
} | ||
|
||
if( VSizeSq(vLoc - vCenter) < RadiiSumSquared ) | ||
{ | ||
OutEnemies.AddItem(kUnit.GetReference()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you're collecting units, not enemies, would make sense for the array to be called OutUnits rather than OutEnemies. |
||
} | ||
} | ||
} | ||
} | ||
// end issue #620 | ||
|
||
native function float GetConcealmentDetectionDistance(const ref XComGameState_Unit DetectorUnit); | ||
|
||
simulated function bool CanFlank(bool bAllowMelee = false) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there are a particular reason you created a function to check the value of a config variable?
You could just do
class'CHHelpers'.default.bConsiderAlliesforSoundAlerts
wherever you need to check this.But even if using a function, it can be simplified to:
Also, your function has no return value for when
default.bConsiderAlliesforSoundAlerts
isfalse
. It will still returnfalse
as that is the default value forbool
values, but it's not a proper way to do things.