From 7cac56cb9bcaabed9562a7b46718f5c5de3400b8 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Fri, 17 Dec 2021 21:53:06 +0000 Subject: wargames intro and many fixes --- .../mod/scripts/vscripts/mp/_classic_mp.nut | 3 +- .../vscripts/mp/_classic_mp_dropship_intro.gnut | 5 +- .../mod/scripts/vscripts/mp/_gamestate_mp.nut | 53 +-- .../vscripts/mp/levels/_lf_maps_shared.gnut | 2 +- .../mod/scripts/vscripts/mp/levels/mp_lf_deck.nut | 1 + .../mod/scripts/vscripts/mp/levels/mp_wargames.nut | 423 ++++++++++++++++++++- .../mod/scripts/vscripts/mp/spawn.nut | 10 +- 7 files changed, 446 insertions(+), 51 deletions(-) (limited to 'Northstar.CustomServers/mod/scripts/vscripts/mp') diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_classic_mp.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_classic_mp.nut index 66bb3d6a4..2baf119c4 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_classic_mp.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_classic_mp.nut @@ -30,6 +30,7 @@ struct { float customIntroLength bool epilogueForceDisabled = false + bool shouldRunEpilogueInRoundBasedMode = false void functionref() epilogueSetupFunc } file @@ -117,5 +118,5 @@ bool function GetClassicMPMode() bool function ClassicMP_ShouldRunEpilogue() { // note: there is a run_evac playlist var, but it's unused, and default 0, so use a new one - return !file.epilogueForceDisabled && GetClassicMPMode() && !IsRoundBased() && GetCurrentPlaylistVarInt( "run_epilogue", 1 ) == 1 + return !file.epilogueForceDisabled && GetClassicMPMode() && GetCurrentPlaylistVarInt( "run_epilogue", 1 ) == 1 } \ No newline at end of file diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_classic_mp_dropship_intro.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_classic_mp_dropship_intro.gnut index 02c312be3..b6b0aa100 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_classic_mp_dropship_intro.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_classic_mp_dropship_intro.gnut @@ -221,7 +221,7 @@ void function SpawnPlayerIntoDropship( entity player ) ClassicMP_OnIntroFinished() // set intro as finished // wait for intro timer to be fully done - wait( Time() - ( file.introStartTime + DROPSHIP_INTRO_LENGTH ) ) + wait ( file.introStartTime + DROPSHIP_INTRO_LENGTH ) - Time() player.MovementDisable() // disable all movement but let them look around still player.ConsumeDoubleJump() // movementdisable doesn't prevent double jumps @@ -234,6 +234,5 @@ void function SpawnPlayerIntoDropship( entity player ) player.EnableWeaponViewModel() RemoveCinematicFlag( player, CE_FLAG_CLASSIC_MP_SPAWNING ) - if ( GetServerVar( "switchedSides" ) != 1 ) - TryGameModeAnnouncement( player ) + TryGameModeAnnouncement( player ) } \ No newline at end of file diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut index 0eef7f005..bf21b492b 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut @@ -63,7 +63,6 @@ void function PIN_GameStart() AddCallback_GameStateEnter( eGameState.WaitingForCustomStart, GameStateEnter_WaitingForCustomStart ) AddCallback_GameStateEnter( eGameState.WaitingForPlayers, GameStateEnter_WaitingForPlayers ) AddCallback_OnClientConnected( WaitingForPlayers_ClientConnected ) - AddCallback_OnClientDisconnected( WaitingForPlayers_ClientDisconnected ) AddCallback_GameStateEnter( eGameState.PickLoadout, GameStateEnter_PickLoadout ) AddCallback_GameStateEnter( eGameState.Prematch, GameStateEnter_Prematch ) @@ -120,27 +119,20 @@ void function GameStateEnter_WaitingForPlayers() foreach ( entity player in GetPlayerArray() ) WaitingForPlayers_ClientConnected( player ) - thread WaitForPlayers( GetPendingClientsCount() + file.numPlayersFullyConnected ) // like 90% sure there should be a way to get number of loading clients on server but idk it + thread WaitForPlayers() // like 90% sure there should be a way to get number of loading clients on server but idk it } -void function WaitForPlayers( int wantedNum ) +void function WaitForPlayers( ) { // note: atm if someone disconnects as this happens the game will just wait forever - print( "WaitForPlayers(): " + wantedNum + " players" ) - float endTime = Time() + 120.0 + float endTime = Time() + 30.0 - while ( endTime > Time() ) - { - if ( file.numPlayersFullyConnected >= wantedNum ) - break - + while ( GetPendingClientsCount() != 0 && endTime > Time() ) WaitFrame() - } print( "done waiting!" ) wait 1.0 // bit nicer - if ( file.usePickLoadoutScreen ) SetGameState( eGameState.PickLoadout ) else @@ -151,16 +143,8 @@ void function WaitingForPlayers_ClientConnected( entity player ) { if ( GetGameState() == eGameState.WaitingForPlayers ) ScreenFadeToBlackForever( player, 0.0 ) - - file.numPlayersFullyConnected++ } -void function WaitingForPlayers_ClientDisconnected( entity player ) -{ - file.numPlayersFullyConnected-- -} - - // eGameState.PickLoadout void function GameStateEnter_PickLoadout() { @@ -238,7 +222,10 @@ void function GameStateEnter_Playing_Threaded() if ( file.timeoutWinnerDecisionFunc != null ) winningTeam = file.timeoutWinnerDecisionFunc() else - winningTeam = GameScore_GetWinningTeam() + winningTeam = GetWinningTeam() + + if ( winningTeam == -1 ) + winningTeam = TEAM_UNASSIGNED if ( file.switchSidesBased && !file.hasSwitchedSides && !IsRoundBased() ) // in roundbased modes, we handle this in setwinner SetGameState( eGameState.SwitchingSides ) @@ -269,6 +256,8 @@ void function GameStateEnter_WinnerDetermined_Threaded() { // do win announcement int winningTeam = GetWinningTeam() + if ( winningTeam == -1 ) + winningTeam = TEAM_UNASSIGNED foreach ( entity player in GetPlayerArray() ) { @@ -277,15 +266,15 @@ void function GameStateEnter_WinnerDetermined_Threaded() announcementSubstr = player.GetTeam() == winningTeam ? file.announceRoundWinnerWinningSubstr : file.announceRoundWinnerLosingSubstr if ( IsRoundBased() ) - Remote_CallFunction_NonReplay( player, "ServerCallback_AnnounceRoundWinner", GetWinningTeam(), announcementSubstr, ROUND_WINNING_KILL_REPLAY_SCREEN_FADE_TIME, GameRules_GetTeamScore2( TEAM_MILITIA ), GameRules_GetTeamScore2( TEAM_IMC ) ) + Remote_CallFunction_NonReplay( player, "ServerCallback_AnnounceRoundWinner", winningTeam, announcementSubstr, ROUND_WINNING_KILL_REPLAY_SCREEN_FADE_TIME, GameRules_GetTeamScore2( TEAM_MILITIA ), GameRules_GetTeamScore2( TEAM_IMC ) ) else - Remote_CallFunction_NonReplay( player, "ServerCallback_AnnounceWinner", GetWinningTeam(), announcementSubstr, ROUND_WINNING_KILL_REPLAY_SCREEN_FADE_TIME ) + Remote_CallFunction_NonReplay( player, "ServerCallback_AnnounceWinner", winningTeam, announcementSubstr, ROUND_WINNING_KILL_REPLAY_SCREEN_FADE_TIME ) } WaitFrame() // wait a frame so other scripts can setup killreplay stuff entity replayAttacker = file.roundWinningKillReplayAttacker - bool doReplay = Replay_IsEnabled() && !ClassicMP_ShouldRunEpilogue() && IsRoundWinningKillReplayEnabled() && IsValid( replayAttacker ) + bool doReplay = Replay_IsEnabled() && IsRoundWinningKillReplayEnabled() && IsValid( replayAttacker ) && Time() - file.roundWinningKillReplayTime <= ROUND_WINNING_KILL_REPLAY_LENGTH_OF_REPLAY float replayLength = 2.0 // extra delay if no replay @@ -336,11 +325,23 @@ void function GameStateEnter_WinnerDetermined_Threaded() int roundsPlayed = expect int ( GetServerVar( "roundsPlayed" ) ) SetServerVar( "roundsPlayed", roundsPlayed + 1 ) - float highestScore = max( GameRules_GetTeamScore( TEAM_IMC ), GameRules_GetTeamScore( TEAM_MILITIA ) ) + int winningTeam = GetWinningTeam() + if ( winningTeam == -1 ) + winningTeam = TEAM_UNASSIGNED + + int highestScore = GameRules_GetTeamScore( winningTeam ) int roundScoreLimit = GameMode_GetRoundScoreLimit( GAMETYPE ) if ( highestScore >= roundScoreLimit ) - SetGameState( eGameState.Postmatch ) + { + if ( ClassicMP_ShouldRunEpilogue() ) + { + ClassicMP_SetupEpilogue() + SetGameState( eGameState.Epilogue ) + } + else + SetGameState( eGameState.Postmatch ) + } else if ( file.switchSidesBased && !file.hasSwitchedSides && highestScore >= ( roundScoreLimit.tofloat() / 2.0 ) ) // round up SetGameState( eGameState.SwitchingSides ) // note: switchingsides will handle setting to pickloadout and prematch by itself else if ( file.usePickLoadoutScreen ) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/_lf_maps_shared.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/_lf_maps_shared.gnut index 695f096db..91b178404 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/_lf_maps_shared.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/_lf_maps_shared.gnut @@ -5,5 +5,5 @@ void function SetupLiveFireMaps() { Riff_ForceTitanAvailability( eTitanAvailability.Never ) ClassicMP_SetLevelIntro( ClassicMP_DefaultNoIntro_Setup, ClassicMP_DefaultNoIntro_GetLength() ) - ClassicMP_ForceDisableEpilogue( true ) + // ClassicMP_ForceDisableEpilogue( true ) // don't do this because evac handles this now } \ No newline at end of file diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_lf_deck.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_lf_deck.nut index 398b2fc55..dca30fe9c 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_lf_deck.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_lf_deck.nut @@ -2,5 +2,6 @@ global function CodeCallback_MapInit void function CodeCallback_MapInit() { + FlagClear( "Disable_Marvins" ) SetupLiveFireMaps() } \ No newline at end of file diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_wargames.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_wargames.nut index 3a46eba84..58a4be024 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_wargames.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_wargames.nut @@ -2,7 +2,12 @@ untyped global function CodeCallback_MapInit struct { - bool introStartTime + float introStartTime + entity militiaPod + entity imcPod + + vector militiaPodFXEyePos + vector imcPodFXEyePos } file void function CodeCallback_MapInit() @@ -14,32 +19,426 @@ void function CodeCallback_MapInit() SetEvacSpaceNode( GetEnt( "end_spacenode" ) ) - // currently disabled: intro - // if ( !IsFFAGame() ) - // ClassicMP_SetLevelIntro( WargamesIntroSetup, 25.0 ) + // dissolve effects + AddDeathCallback( "player", WargamesDissolveDeadEntity ) + AddDeathCallback( "npc_soldier", WargamesDissolveDeadEntity ) + AddDeathCallback( "npc_spectre", WargamesDissolveDeadEntity ) + AddDeathCallback( "npc_pilot_elite", WargamesDissolveDeadEntity ) + AddDeathCallback( "npc_marvin", WargamesDissolveDeadEntity ) + + FlagClear( "Disable_Marvins" ) + + // currently disabled until finished: intro + if ( !IsFFAGame() ) + ClassicMP_SetLevelIntro( WargamesIntroSetup, 20.0 ) } -// intro stuff +// dissolve effects +void function WargamesDissolveDeadEntity( entity deadEnt, var damageInfo ) +{ + if ( deadEnt.IsPlayer() || GamePlayingOrSuddenDeath() || GetGameState() == eGameState.Epilogue ) + { + deadEnt.Dissolve( ENTITY_DISSOLVE_CHAR, < 0, 0, 0 >, 0 ) + EmitSoundAtPosition( TEAM_UNASSIGNED, deadEnt.GetOrigin(), "Object_Dissolve" ) + } +} + +// intro stuff: void function WargamesIntroSetup() { - AddCallback_OnClientConnected( WargamesIntro_OnClientConnected ) - AddCallback_OnClientDisconnected( WargamesIntro_OnClientDisconnected ) + PrecacheParticleSystem( FX_POD_SCREEN_IN ) + PrecacheParticleSystem( $"P_pod_scan_laser_FP" ) + PrecacheParticleSystem( $"P_pod_Dlight_console1" ) + PrecacheParticleSystem( $"P_pod_Dlight_console2" ) + PrecacheParticleSystem( $"P_pod_door_glow_FP" ) + PrecacheModel( $"models/titans/ogre/ogreposeopen.mdl" ) + + file.militiaPod = GetEnt( "training_pod" ) + file.imcPod = GetEnt( "training_pod_imc" ) + + AddCallback_OnClientConnected( WargamesIntro_AddPlayer ) AddCallback_GameStateEnter( eGameState.Prematch, OnPrematchStart ) } -void function WargamesIntro_OnClientConnected( entity player ) +void function WargamesIntro_AddPlayer( entity player ) { + if ( GetGameState() != eGameState.Prematch ) + return + + thread PlayerWatchesWargamesIntro( player ) +} +void function OnPrematchStart() +{ + ClassicMP_OnIntroStarted() + file.introStartTime = Time() + + // set up shared objects + // this breaks glowlights, not sure why + //file.imcPod.RenderWithViewModels( true ) + //file.militiaPod.RenderWithViewModels( true ) + + PodFXLights( file.imcPod ) + PodFXLights( file.militiaPod ) + + FirstPersonSequenceStruct openPodSequence + openPodSequence.thirdPersonAnimIdle = "trainingpod_doors_open_idle" + thread FirstPersonSequence( openPodSequence, file.imcPod ) + thread FirstPersonSequence( openPodSequence, file.militiaPod ) + + // militia titans/marvins + entity militiaOgre = CreatePropDynamic( $"models/titans/ogre/ogreposeopen.mdl", < -2060, 2856, -1412.5 >, < 0, 0, 0 > ) + + entity militiaOgreMarvin1 = CreateMarvin( TEAM_UNASSIGNED, < -2113, 2911, -1412 >, < 0, 20, 0 > ) + DispatchSpawn( militiaOgreMarvin1 ) + thread PlayAnim( militiaOgreMarvin1, "mv_idle_weld" ) + + entity militiaOgreMarvin2 = CreateMarvin( TEAM_UNASSIGNED, < -2040, 2788, -1412 >, < 0, 140, 0 > ) + DispatchSpawn( militiaOgreMarvin2 ) + thread PlayAnim( militiaOgreMarvin2, "mv_idle_weld" ) + + entity militiaOgreMarvin3 = CreateMarvin( TEAM_UNASSIGNED, < -2116, 2868, -1458 >, < 0, 127, 0 > ) + DispatchSpawn( militiaOgreMarvin3 ) + thread PlayAnim( militiaOgreMarvin3, "mv_turret_repair_A_idle" ) + + entity militiaIon = CreatePropDynamic( $"models/titans/medium/titan_medium_ajax.mdl", < -1809.98, 2790.39, -1409 >, < 0, 80, 0 > ) + thread PlayAnim( militiaIon, "at_titan_activation_wargames_intro" ) + + entity militiaPilot = CreateElitePilot( TEAM_UNASSIGNED, < 0, 0, 0 >, < 0, 0, 0 > ) + DispatchSpawn( militiaPilot ) + militiaPilot.SetParent( militiaIon, "HIJACK" ) + militiaPilot.MarkAsNonMovingAttachment() + militiaPilot.Anim_ScriptedPlay( "pt_titan_activation_pilot" ) + militiaPilot.Anim_EnableUseAnimatedRefAttachmentInsteadOfRootMotion() + + entity militiaMarvinChillin = CreateMarvin( TEAM_UNASSIGNED, < -1786, 3060, -1412 >, < 0, -120, 0 > ) + DispatchSpawn( militiaMarvinChillin ) + thread PlayAnim( militiaMarvinChillin, "mv_idle_unarmed" ) + + + // imc grunts + entity imcGrunt1 = CreatePropDynamic( $"models/humans/grunts/imc_grunt_rifle.mdl", < -2915, 2867, -1788 >, < 0, -137, 0 > ) + thread PlayAnim( imcGrunt1, "pt_console_idle" ) + + entity imcGrunt2 = CreatePropDynamic( $"models/humans/grunts/imc_grunt_rifle.mdl", < -2870, 2746, -1786 >, < 0, -167, 0 > ) + thread PlayAnim( imcGrunt2, "pt_console_idle" ) + imcGrunt2.Anim_SetInitialTime( 2.0 ) + + entity imcGrunt3 = CreatePropDynamic( $"models/humans/grunts/imc_grunt_rifle.mdl", < -3037, 2909, -1786 >, < 0, -60, 0 > ) + thread PlayAnim( imcGrunt3, "pt_console_idle" ) + imcGrunt3.Anim_SetInitialTime( 4.0 ) + + entity imcGrunt4 = CreatePropDynamic( $"models/humans/grunts/imc_grunt_rifle.mdl", < -3281, 2941, -1790 >, < 0, 138, 0 > ) + thread PlayAnim( imcGrunt4, "pt_console_idle" ) + imcGrunt4.Anim_SetInitialTime( 6.0 ) + + // launch players into intro + foreach ( entity player in GetPlayerArray() ) + thread PlayerWatchesWargamesIntro( player ) + + // 7 seconds of nothing until we start the pod sequence + wait 7.0 + + FirstPersonSequenceStruct podCloseSequence + podCloseSequence.thirdPersonAnim = "trainingpod_doors_close" + podCloseSequence.thirdPersonAnimIdle = "trainingpod_doors_close_idle" + thread FirstPersonSequence( podCloseSequence, file.imcPod ) + thread FirstPersonSequence( podCloseSequence, file.militiaPod ) + + wait 7.0 + thread PodBootFXThread( file.imcPod ) + thread PodBootFXThread( file.militiaPod ) + + wait 6.0 + ClassicMP_OnIntroFinished() + + // make sure we stop using viewmodels for these otherwise everyone can see them in the floor 24/7 + file.imcPod.RenderWithViewModels( false ) + file.militiaPod.RenderWithViewModels( false ) + + //PodFXCleanup( file.imcPod ) + //PodFXCleanup( file.militiaPod ) + + // cleanup intro objects + militiaOgre.Destroy() + militiaIon.Destroy() + militiaPilot.Destroy() + militiaOgreMarvin1.Destroy() + militiaOgreMarvin2.Destroy() + militiaOgreMarvin3.Destroy() + militiaMarvinChillin.Destroy() + + imcGrunt1.Destroy() + imcGrunt2.Destroy() + imcGrunt3.Destroy() + imcGrunt4.Destroy() } -void function WargamesIntro_OnClientDisconnected( entity player ) +void function PlayerWatchesWargamesIntro( entity player ) { + if ( IsAlive( player ) ) + player.Die() + OnThreadEnd( function() : ( player ) + { + if ( IsValid( player ) ) + { + RemoveCinematicFlag( player, CE_FLAG_CLASSIC_MP_SPAWNING ) + player.kv.VisibilityFlags = ENTITY_VISIBLE_TO_EVERYONE + ClearPlayerAnimViewEntity( player ) + player.EnableWeaponViewModel() + player.ClearParent() + player.UnforceStand() + player.MovementEnable() + Remote_CallFunction_NonReplay( player, "ServerCallback_ClearFactionLeaderIntro" ) + } + }) + + // we need to wait a frame if we killed ourselves to spawn into this, so just easier to do it all the time to remove any weirdness + WaitFrame() + + player.EndSignal( "OnDestroy" ) + player.EndSignal( "OnDeath" ) + + int factionTeam = ConvertPlayerFactionToIMCOrMilitiaTeam( player ) + entity playerPod + if ( factionTeam == TEAM_IMC ) + playerPod = file.imcPod + else + playerPod = file.militiaPod + + // setup player + int podAttachId = playerPod.LookupAttachment( "REF" ) + player.SetOrigin( playerPod.GetAttachmentOrigin( podAttachId ) ) + player.SetAngles( playerPod.GetAttachmentAngles( podAttachId ) ) + player.RespawnPlayer( null ) + player.SetParent( playerPod, "REF" ) + player.ForceStand() + + if ( !HasAnimEvent( player.GetFirstPersonProxy(), "PlaySound_SimPod_DoorShut" ) ) + AddAnimEvent( player.GetFirstPersonProxy(), "PlaySound_SimPod_DoorShut", PlaySound_SimPod_DoorShut ) + + AddCinematicFlag( player, CE_FLAG_CLASSIC_MP_SPAWNING ) + player.kv.VisibilityFlags = ENTITY_VISIBLE_TO_OWNER + TrainingPod_ViewConeLock_PodClosed( player ) + player.DisableWeaponViewModel() + player.MovementDisable() + + // spawn faction leader + // no clue why client subtracts 4.5 from the time we give this, so just add it here instead + if ( factionTeam == TEAM_IMC ) + Remote_CallFunction_NonReplay( player, "ServerCallback_SpawnIMCFactionLeaderForIntro", file.introStartTime + 4.5, playerPod.GetEncodedEHandle() ) + else + Remote_CallFunction_NonReplay( player, "ServerCallback_SpawnMilitiaFactionLeaderForIntro", file.introStartTime + 4.5, playerPod.GetEncodedEHandle() ) + + // idle pod sequence + FirstPersonSequenceStruct podIdleSequence + podIdleSequence.firstPersonAnimIdle = "ptpov_trainingpod_idle" + podIdleSequence.renderWithViewModels = true + podIdleSequence.attachment = "REF" + thread FirstPersonSequence( podIdleSequence, player, playerPod ) + + ScreenFadeFromBlack( player, max( 0.0, ( file.introStartTime + 0.5 ) - Time() ), max( 0.0, ( file.introStartTime + 0.5 ) - Time() ) ) + + // also get eye positions for fx here + if ( file.imcPodFXEyePos == < 0, 0, 0 > && factionTeam == TEAM_IMC ) + file.imcPodFXEyePos = player.EyePosition() + else if ( file.militiaPodFXEyePos == < 0, 0, 0 > && factionTeam == TEAM_MILITIA ) + file.militiaPodFXEyePos = player.EyePosition() + + // 7 seconds of nothing before we start the pod sequence + wait ( file.introStartTime + 7.0 ) - Time() + + FirstPersonSequenceStruct podCloseSequence + podCloseSequence.firstPersonAnim = "ptpov_trainingpod_doors_close" + podCloseSequence.renderWithViewModels = true + podCloseSequence.attachment = "REF" + podCloseSequence.viewConeFunction = TrainingPod_ViewConeLock_SemiStrict + podCloseSequence.setInitialTime = Time() - ( file.introStartTime + 7.0 ) + waitthread FirstPersonSequence( podCloseSequence, player, playerPod ) + + // boot sequence + EmitSoundOnEntityOnlyToPlayer( player, player, "NPE_Scr_SimPod_PowerUp" ) + TrainingPod_ViewConeLock_PodClosed( player ) + + // 10 seconds of starting pod before we run effects and spawn players + // note, this is cool because it waits for a specific time, so we can have a blocking call directly before it just fine + wait ( file.introStartTime + 15.5 ) - Time() + Remote_CallFunction_NonReplay( player, "ServerCallback_PlayPodTransitionScreenFX" ) + + // need to wait no matter what the delay is here so fx will sync up + wait 3.5 + + entity spawnpoint = FindSpawnPoint( player, false, true ) + spawnpoint.s.lastUsedTime = Time() + player.SetOrigin( spawnpoint.GetOrigin() ) + player.SetAngles( spawnpoint.GetAngles() ) + + thread DelayedGamemodeAnnouncement( player ) } -void function OnPrematchStart() +void function DelayedGamemodeAnnouncement( entity player ) { - ClassicMP_OnIntroStarted() - file.introStartTime = Time() + wait 1.0 + TryGameModeAnnouncement( player ) +} + +void function PlaySound_SimPod_DoorShut( entity playerFirstPersonProxy ) // stolen from sp_training +{ + entity player = playerFirstPersonProxy.GetOwner() + if ( !IsValid( player ) ) + return + + EmitSoundOnEntityOnlyToPlayer( player, player, "NPE_Scr_SimPod_DoorShut" ) +} + +// intro viewcones +void function TrainingPod_ViewConeLock_PodOpen( entity player ) +{ + player.PlayerCone_FromAnim() + player.PlayerCone_SetMinYaw( -25 ) + player.PlayerCone_SetMaxYaw( 25 ) + player.PlayerCone_SetMinPitch( -30 ) + player.PlayerCone_SetMaxPitch( 35 ) +} + +void function TrainingPod_ViewConeLock_PodClosed( entity player ) +{ + player.PlayerCone_FromAnim() + player.PlayerCone_SetMinYaw( -25 ) + player.PlayerCone_SetMaxYaw( 25 ) + player.PlayerCone_SetMinPitch( -30 ) + player.PlayerCone_SetMaxPitch( 30 ) +} + +void function TrainingPod_ViewConeLock_SemiStrict( entity player ) +{ + player.PlayerCone_FromAnim() + player.PlayerCone_SetMinYaw( -10 ) + player.PlayerCone_SetMaxYaw( 10 ) + player.PlayerCone_SetMinPitch( -10 ) + player.PlayerCone_SetMaxPitch( 10 ) +} + +// intro pod fx +// here be dragons etc hell code probably +void function PodFXLights( entity pod ) +{ + // dlights + pod.s.podLightFXHandles <- [] + pod.s.podLightFXHandles.append( PlayLoopFXOnEntity( $"P_pod_Dlight_console1", pod, "light_console1" ) ) + pod.s.podLightFXHandles.append( PlayLoopFXOnEntity( $"P_pod_Dlight_console2", pod, "light_console2" ) ) +} + +void function PodFXLasers( entity pod ) +{ + entity leftEmitter = CreateScriptMover( pod.GetOrigin() ) + pod.s.leftLaserEmitter <- leftEmitter + entity rightEmitter = CreateScriptMover( pod.GetOrigin() ) + pod.s.rightLaserEmitter <- rightEmitter + + thread PodFXLaserSweep( leftEmitter, pod, pod == file.imcPod ? file.imcPodFXEyePos : file.militiaPodFXEyePos, "fx_laser_L" ) + thread PodFXLaserSweep( rightEmitter, pod, pod == file.imcPod ? file.imcPodFXEyePos : file.militiaPodFXEyePos, "fx_laser_R" ) +} + +void function PodFXLaserSweep( entity emitter, entity pod, vector eyePos, string attachment ) +{ + // setup emitter attachments + emitter.SetOrigin( < 5, 5, 5 > ) + emitter.SetParent( pod, attachment ) + + float sweepTime = RandomFloatRange( 2.9, 3.15 ) + + vector centerAng = VectorToAngles( ( eyePos + < 0, 0, 7 > ) - emitter.GetOrigin() ) + vector topAng = centerAng + < -270, 0, 0 > + vector bottomAng = centerAng + < -90, 0, 0 > + + emitter.s.fxHandle <- PlayLoopFXOnEntity( $"P_pod_scan_laser_FP", emitter ) + + float finalCenterTime = sweepTime * 0.15 + float bigSweepTime = ( sweepTime - finalCenterTime ) / 2 + + emitter.SetAbsAngles( topAng ) + emitter.NonPhysicsRotateTo( topAng, bigSweepTime, 0.0, bigSweepTime * 0.2 ) + wait bigSweepTime - 0.1 + + emitter.NonPhysicsRotateTo( bottomAng, bigSweepTime, 0.0, bigSweepTime * 0.2 ) + wait bigSweepTime + + emitter.NonPhysicsRotateTo( centerAng, finalCenterTime, 0.0, finalCenterTime * 0.2 ) +} + +void function PodFXGlowLights( entity pod ) +{ + // see sp_training:5533 (TrainingPod_GlowLightsArraySetup) + array< array< string > > glowLightGroups = [ + [ "fx_glow_L_door012", "fx_glow_R_door014" ], + [ "fx_glow_L_door013", "fx_glow_R_door013" ], + [ "fx_glow_L_door014", "fx_glow_R_door012" ], + [ "fx_glow_L_door011", "fx_glow_R_door011" ], + [ "fx_glow_L_door09", "fx_glow_R_door09" ], + [ "fx_glow_L_door010", "fx_glow_R_door010" ], + [ "fx_glow_L_door07", "fx_glow_R_door07" ], + [ "fx_glow_L_door08", "fx_glow_R_door08" ], + [ "fx_glow_L_door05", "fx_glow_R_door05" ], + [ "fx_glow_L_door06", "fx_glow_R_door06" ], + [ "fx_glow_L_door03", "fx_glow_R_door03" ], + [ "fx_glow_L_door04", "fx_glow_R_door04" ], + [ "fx_glow_L_door01", "fx_glow_R_door01" ], + [ "fx_glow_L_door02", "fx_glow_R_door02" ] + ] + + pod.s.podGlowLightFXHandles <- [] + + foreach ( array group in glowLightGroups ) + { + foreach ( string attachName in group ) + pod.s.podGlowLightFXHandles.append( PlayLoopFXOnEntity( $"P_pod_door_glow_FP", pod, attachName ) ) + + wait 0.1 + } +} + +void function PodBootFXThread( entity pod ) +{ + PodFXGlowLights( pod ) + PodFXLasers( pod ) +} + +void function PodFXCleanup( entity pod ) +{ + foreach ( entity handle in pod.s.podLightFXHandles ) + { + if ( IsValid_ThisFrame( handle ) ) + { + handle.SetStopType( "DestroyImmediately" ) + handle.ClearParent() + handle.Destroy() + } + } + + pod.s.podLightFXHandles = [] + + foreach ( entity handle in pod.s.podGlowLightFXHandles ) + { + if ( IsValid_ThisFrame( handle ) ) + { + handle.SetStopType( "DestroyImmediately" ) + handle.ClearParent() + handle.Destroy() + } + } + + pod.s.podGlowLightFXHandles = [] + + pod.s.leftLaserEmitter.s.fxHandle.SetStopType( "DestroyImmediately" ) + pod.s.leftLaserEmitter.s.fxHandle.ClearParent() + pod.s.leftLaserEmitter.s.fxHandle.Destroy() + pod.s.leftLaserEmitter.Destroy() + + pod.s.rightLaserEmitter.s.fxHandle.SetStopType( "DestroyImmediately" ) + pod.s.rightLaserEmitter.s.fxHandle.ClearParent() + pod.s.rightLaserEmitter.s.fxHandle.Destroy() + pod.s.rightLaserEmitter.Destroy() } \ No newline at end of file diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut index 18026f178..88f1e04ce 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/spawn.nut @@ -302,15 +302,9 @@ bool function IsSpawnpointValid( entity spawnpoint, int team ) void function RateSpawnpoints_Generic( int checkClass, array spawnpoints, int team, entity player ) { - // generic spawns v2 - array startSpawns = checkClass == TD_TITAN ? SpawnPoints_GetTitanStart( team ) : SpawnPoints_GetPilotStart( team ) + // i'm not a fan of this func, but i really don't have a better way to do this rn, and it's surprisingly good with los checks implemented now - // realistically, this should spawn people fairly spread out across the map, preferring being closer to their startspawns - // should spawn like, near fights, but not in them - - - // using old func for tests rq - // calculate ratings for preferred nodes + // calculate ratings for preferred nodes // this tries to prefer nodes with more teammates, then activity on them // todo: in the future it might be good to have this prefer nodes with enemies up to a limit of some sort // especially in ffa modes i could deffo see this falling apart a bit rn -- cgit v1.2.3