diff --git a/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_mortar_spectres.gnut b/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_mortar_spectres.gnut index c63d9dd22..2c1aa4bbb 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_mortar_spectres.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_mortar_spectres.gnut @@ -34,19 +34,17 @@ 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 - entity squadMarker = CreatePropScript( $"models/dev/empty_model.mdl", expect StationaryAIPosition( mortarPosition ).origin + < 0, 0, 150 >, < 0, 1, 0 > ) + entity squadMarker = CreatePropScript( $"models/dev/empty_model.mdl", mortarPosition.origin + < 0, 0, 150 >, < 0, 1, 0 > ) SetTargetName( squadMarker, "mortarPosition" ) squadMarker.SetShieldHealthMax( MORTAR_SPECTRE_TRACKER_SHIELD_MAX ) squadMarker.Minimap_SetCustomState( eMinimapObject_prop_script.FD_MORTAR_POSITION ) @@ -57,7 +55,7 @@ void function MortarSpectreSquadThink( array< entity > spectres, entity harveste int i = 0 foreach( entity spectre in spectres ) { - thread MortarSpectreMoveToMortarPosition( spectre, squadMarker, OriginToGround( expect StationaryAIPosition( mortarPosition ).origin + MORTAR_SPECTRE_POSITION_OFFSETS[i] + < 0, 0, 100 > ) ) + thread MortarSpectreMoveToMortarPosition( spectre, squadMarker, OriginToGround( mortarPosition.origin + MORTAR_SPECTRE_POSITION_OFFSETS[i] + < 0, 0, 100 > ) ) if ( i++ >= MORTAR_SPECTRE_POSITION_OFFSETS.len() ) { diff --git a/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_mortar_titans.gnut b/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_mortar_titans.gnut index f23c05f90..c9a02a726 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_mortar_titans.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_mortar_titans.gnut @@ -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 ) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_sniper_titans.gnut b/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_sniper_titans.gnut index b1ff4fa29..f2b0ded61 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_sniper_titans.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_sniper_titans.gnut @@ -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 ) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_stationary_firing_positions.gnut b/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_stationary_firing_positions.gnut index 430de58a7..ba5a2081d 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_stationary_firing_positions.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_stationary_firing_positions.gnut @@ -6,6 +6,7 @@ global function GetClosestAvailableStationaryPosition global function ClaimStationaryAIPosition global function ReleaseStationaryAIPosition global function DebugDrawStationaryAiPositions +global function AnyStationaryPositionsAvailable global enum eStationaryAIPositionTypes { @@ -137,6 +138,19 @@ void function ValidateAndFinalizePendingStationaryPositions() } } +bool function AnyStationaryPositionsAvailable( int type ) +{ + array positions = file.stationaryPositions[type] + + foreach ( position in positions ) + { + if ( !position.inUse ) + return true + } + + return false +} + StationaryAIPosition function GetClosestAvailableStationaryPosition( vector origin, float maxDist, int type ) {