Skip to content

Commit

Permalink
wait for a stationary position to become available before getting one
Browse files Browse the repository at this point in the history
  • Loading branch information
ASpoonPlaysGames committed Oct 3, 2023
1 parent 9c13170 commit b47c58b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ void function MortarSpectreSquadThink( array< entity > spectres, entity harveste
if ( spectres.len() == 0)
return

// get the closest available stationary position for mortar spectres
StationaryAIPosition ornull mortarPosition = GetClosestAvailableStationaryPosition( /* spectres[0] isnt ideal but the spectres all spawn in the same position atm */ spectres[0].GetOrigin(), MORTAR_SPECTRE_POSITION_SEARCH_RANGE, eStationaryAIPositionTypes.MORTAR_SPECTRE )
while ( mortarPosition == null )
{
// in case all stationary spectre positions are in use wait for one to become available
// incase all stationary mortar positions are in use wait for one to become available
while ( !AnyStationaryPositionsAvailable( eStationaryAIPositionTypes.MORTAR_SPECTRE ) )
wait 5
// should change this to use an average position or the start position or something but for now this is fine
mortarPosition = GetClosestAvailableStationaryPosition( spectres[0].GetOrigin(), MORTAR_SPECTRE_POSITION_SEARCH_RANGE, eStationaryAIPositionTypes.MORTAR_SPECTRE )
}

// should change this to use an average position or the start position or something but for now this is fine
StationaryAIPosition mortarPosition = GetClosestAvailableStationaryPosition( spectres[0].GetOrigin(), MORTAR_SPECTRE_POSITION_SEARCH_RANGE, eStationaryAIPositionTypes.MORTAR_SPECTRE )

// create the entity responsible for managing this squad of spectres
// note: client shows the ui thing for this entity if the y angle is not 0
// it also shows the set up time thing based on the shield frac of the entity? weird
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,12 @@ void function MortarTitanThink( entity titan, entity generator )
WaitTillHotDropComplete( titan )

float minEngagementDuration = 5
StationaryAIPosition ornull mortarPosition = GetClosestAvailableStationaryPosition( titan.GetOrigin(), MORTAR_TITAN_POSITION_SEARCH_RANGE, eStationaryAIPositionTypes.MORTAR_TITAN )
while ( mortarPosition == null )
{
// incase all stationary titan positions are in use wait for one to become available

// incase all stationary titan positions are in use wait for one to become available
while ( !AnyStationaryPositionsAvailable( eStationaryAIPositionTypes.MORTAR_TITAN ) )
wait 5
mortarPosition = GetClosestAvailableStationaryPosition( titan.GetOrigin(), MORTAR_TITAN_POSITION_SEARCH_RANGE, eStationaryAIPositionTypes.MORTAR_TITAN )
}

expect StationaryAIPosition( mortarPosition )
StationaryAIPosition mortarPosition = GetClosestAvailableStationaryPosition( titan.GetOrigin(), MORTAR_TITAN_POSITION_SEARCH_RANGE, eStationaryAIPositionTypes.MORTAR_TITAN )

ClaimStationaryAIPosition( mortarPosition )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,12 @@ void function SniperTitanThink( entity titan, entity generator)
WaitTillHotDropComplete( titan )

float minEngagementDuration = 5
StationaryAIPosition ornull sniperPosition = GetClosestAvailableStationaryPosition( titan.GetOrigin(), SNIPER_TITAN_POSITION_SEARCH_RANGE, eStationaryAIPositionTypes.SNIPER_TITAN )
while ( sniperPosition == null )
{
// incase all stationary titan positions are in use wait for one to become available

// incase all stationary titan positions are in use wait for one to become available
while ( !AnyStationaryPositionsAvailable( eStationaryAIPositionTypes.SNIPER_TITAN ) )
wait 5
sniperPosition = GetClosestAvailableStationaryPosition( titan.GetOrigin(), SNIPER_TITAN_POSITION_SEARCH_RANGE, eStationaryAIPositionTypes.SNIPER_TITAN )
}

expect StationaryAIPosition( sniperPosition )
StationaryAIPosition sniperPosition = GetClosestAvailableStationaryPosition( titan.GetOrigin(), SNIPER_TITAN_POSITION_SEARCH_RANGE, eStationaryAIPositionTypes.SNIPER_TITAN )

ClaimStationaryAIPosition( sniperPosition )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ global function GetClosestAvailableStationaryPosition
global function ClaimStationaryAIPosition
global function ReleaseStationaryAIPosition
global function DebugDrawStationaryAiPositions
global function AnyStationaryPositionsAvailable

global enum eStationaryAIPositionTypes
{
Expand Down Expand Up @@ -137,6 +138,19 @@ void function ValidateAndFinalizePendingStationaryPositions()
}
}

bool function AnyStationaryPositionsAvailable( int type )
{
array<StationaryAIPosition> positions = file.stationaryPositions[type]

foreach ( position in positions )
{
if ( !position.inUse )
return true
}

return false
}

StationaryAIPosition function GetClosestAvailableStationaryPosition( vector origin, float maxDist, int type )
{

Expand Down

0 comments on commit b47c58b

Please sign in to comment.