diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-12-26 04:24:26 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-12-26 04:24:26 +0000 |
commit | dc60309beafb22e34d91593417b09d84e9442089 (patch) | |
tree | ebe5253297db76b0d9f6db3acef7f54bf6a18908 | |
parent | e4faa247edaf389d4d52e3a3129af540bb19a0ac (diff) | |
download | NorthstarMods-dc60309beafb22e34d91593417b09d84e9442089.tar.gz NorthstarMods-dc60309beafb22e34d91593417b09d84e9442089.zip |
evac, dropship, bleedout, flyout, private lobby, fastball and server browser fixes
8 files changed, 292 insertions, 28 deletions
diff --git a/Northstar.Client/mod/resource/ui/menus/server_browser.menu b/Northstar.Client/mod/resource/ui/menus/server_browser.menu index 90785e46..213f46e9 100644 --- a/Northstar.Client/mod/resource/ui/menus/server_browser.menu +++ b/Northstar.Client/mod/resource/ui/menus/server_browser.menu @@ -249,7 +249,7 @@ resource/ui/menus/mods_browse.menu LabelDetails { ControlName RuiPanel - xpos 900 + xpos 675 ypos 160 tall 800 wide 950 diff --git a/Northstar.Client/mod/scripts/vscripts/client/cl_flyout.gnut b/Northstar.Client/mod/scripts/vscripts/client/cl_flyout.gnut new file mode 100644 index 00000000..e077ab68 --- /dev/null +++ b/Northstar.Client/mod/scripts/vscripts/client/cl_flyout.gnut @@ -0,0 +1,255 @@ + +global function ClWeaponFlyout_Init + +global function WeaponFlyoutThink +global function ShouldShowWeaponFlyout +global function WeaponFlyoutRefresh +global function IsWeaponFlyoutVisible +global function DestroyWeaponFlyout +global function GetWeaponFlyoutAliveTime +global function GetWeaponFlyoutAliveTimeLeft +global function SetWeaponFlyoutRemainingTime + +global function WeaponFlyout_SetLevelEnabled + +const float FLYOUT_DURATION = 4.0 +const float FLYOUT_DURATION_SHORT = 1.0 +const vector FLYOUT_COLOR = <0.851, 0.976, 1.0> + +struct +{ + var weaponRUI + string weaponClassName + float flyoutShowTime = -99.0 + float lastFlyoutDuration = FLYOUT_DURATION + + bool flyoutLevelEnabled = true + + table<string, asset> modImages +} file + +void function ClWeaponFlyout_Init() +{ + AddOnDeathCallback( "player", WeaponFlyout_OnDeathCallback ) + AddCallback_OnSelectedWeaponChanged( OnSelectedWeaponChanged ) + + var dataTable = GetDataTable( $"datatable/pilot_weapon_mods_common.rpak" ) + int numRows = GetDatatableRowCount( dataTable ) + + for ( int i = 0; i < numRows; i++ ) + { + string modRef = GetDataTableString( dataTable, i, PILOT_WEAPON_MOD_COMMON_COLUMN ) + asset modImage = GetDataTableAsset( dataTable, i, PILOT_WEAPON_MOD_COMMON_IMAGE_COLUMN ) + file.modImages[ modRef ] <- modImage + } +} + +void function WeaponFlyout_OnDeathCallback( entity player ) +{ + if ( player == GetLocalViewPlayer() ) + DestroyWeaponFlyout() +} + +void function WeaponFlyoutShow( entity weapon, string weaponClassName ) +{ + if ( IsWatchingReplay() ) + return + + file.weaponClassName = weaponClassName + + entity player = GetLocalViewPlayer() + if ( !IsValid( player ) ) + return + + entity viewModel = player.GetViewModelEntity() + if ( !IsValid( viewModel ) ) + return + + if ( GetConVarInt( "hud_setting_showWeaponFlyouts" ) == 0 ) + return + + //file.weaponRUI = RuiCreate( $"ui/weapon_flyout.rpak", clGlobal.topoFullScreen, RUI_DRAW_HUD, 0 ) + file.weaponRUI = CreateCockpitRui( $"ui/weapon_flyout.rpak" ) + file.flyoutShowTime = Time() + + float flyoutDuration = IsPickupFlyoutValid() ? FLYOUT_DURATION_SHORT : FLYOUT_DURATION + file.lastFlyoutDuration = flyoutDuration + + RuiSetGameTime( file.weaponRUI, "startTime", file.flyoutShowTime ) + RuiSetFloat( file.weaponRUI, "duration", file.lastFlyoutDuration ) + + if ( IsMultiplayer() && file.flyoutLevelEnabled ) + WeaponFlyoutRefresh() + + if ( weapon.GetWeaponSettingBool( eWeaponVar.is_burn_mod ) ) + RuiSetFloat3( file.weaponRUI, "color", BURN_CARD_WEAPON_HUD_COLOR_VECTOR ) + + string weaponPrintName = Localize( expect string( weapon.GetWeaponInfoFileKeyField( "shortprintname" ) ) ) + string weaponDescription = weapon.GetWeaponDescription() + " " + RuiSetString( file.weaponRUI, "titleText", weaponPrintName ) + RuiSetString( file.weaponRUI, "descriptionText", weaponDescription ) + + int modNum = 1 + array<string> weaponMods = weapon.GetMods() + foreach ( mod in weaponMods ) + { + if ( modNum >= 5 ) // setting mod5 in the rui crashes client + break + + if ( mod in file.modImages ) + RuiSetImage( file.weaponRUI, "mod" + modNum++, file.modImages[ mod ] ) + } + + RuiSetFloat( file.weaponRUI, "underlineHeight", 4.0 ) + RuiSetFloat( file.weaponRUI, "underlineWidth", 4.0 ) + + int attachment = viewModel.LookupAttachment( "flyout" ) + if ( attachment <= 0 ) + attachment = viewModel.LookupAttachment( "shell" ) + + RuiTrackFloat3( file.weaponRUI, "pos", viewModel, RUI_TRACK_POINT_FOLLOW, attachment ) + + HidePickupFlyout( file.lastFlyoutDuration ) + + #if SP + ScriptCallback_UpdateOnscreenHint() + #endif +} + +void function WeaponFlyoutRefresh() +{ + entity player = GetLocalViewPlayer() + if ( !IsValid( player ) ) + return + + if ( file.weaponRUI == null ) + return + + if ( file.flyoutShowTime + ( file.lastFlyoutDuration - 0.2 ) <= Time() ) + return + +#if MP + if ( !ShouldTrackXPForWeapon( file.weaponClassName ) ) + return + + string persistenceVar = GetItemPersistenceStruct( file.weaponClassName ) + ".weaponXP" + int currentXP = player.GetPersistentVarAsInt( persistenceVar ) + + RuiSetInt( file.weaponRUI, "numPips", WeaponGetNumPipsForXP( file.weaponClassName, currentXP ) ) + RuiSetInt( file.weaponRUI, "numFilledPips", WeaponGetFilledPipsForXP( file.weaponClassName, currentXP ) ) + RuiSetString( file.weaponRUI, "currentLevel", WeaponGetDisplayGenAndLevelForXP( file.weaponClassName, currentXP ) ) + RuiSetBool( file.weaponRUI, "showWeaponXP", true ) +#endif +} + +void function WeaponFlyoutThink( entity player ) +{ + if ( !WEAPON_FLYOUTS_ENABLED ) + return + + entity currentWeapon = player.GetActiveWeapon() + + if ( !IsValid( currentWeapon ) ) + return + + string weaponClassName = currentWeapon.GetWeaponClassName() + + if ( currentWeapon == player.p.previousWeapon ) + return + + if ( !ShouldShowWeaponFlyout( player, currentWeapon, weaponClassName ) ) + return + + player.p.previousWeapon = currentWeapon + + WeaponFlyoutShow( currentWeapon, weaponClassName ) +} + +bool function ShouldShowWeaponFlyout( entity player, entity weapon, string weaponClassName ) +{ + // Allow time for weapons to be disabled at level start + if ( Time() < 2.0 ) + return false + + // No weapon + if ( !IsValid( weapon ) ) + return false + + // MP can be dead with new weapon + if ( !IsAlive( player ) ) + return false + + if ( weapon.IsWeaponOffhand() ) + return false + + if ( GetWeaponInfoFileKeyField_Global( weaponClassName, "flyoutEnabled" ) == 0 ) + return false + + if ( player.IsWeaponDisabled() ) + return false + + if ( player.IsInThirdPersonReplay() ) + return false + + if ( GetGameState() < eGameState.Playing ) + return false + + if ( player.IsTitan() && GameRules_GetGameMode() == FD ) + return false + + if( !player.GetPlayerNetBool( "shouldShowWeaponFlyout" ) ) + return false + + return true +} + +void function OnSelectedWeaponChanged( entity selectedWeapon ) +{ + DestroyWeaponFlyout() +} + +void function DestroyWeaponFlyout() +{ + if ( file.weaponRUI != null ) + { + RuiDestroyIfAlive( file.weaponRUI ) + file.weaponRUI = null + file.flyoutShowTime = -99.0 + } + + #if SP + ScriptCallback_UpdateOnscreenHint() + #endif +} + +float function GetWeaponFlyoutAliveTime() +{ + return Time() - file.flyoutShowTime +} + +float function GetWeaponFlyoutAliveTimeLeft() +{ + return file.flyoutShowTime + file.lastFlyoutDuration - Time() +} + +bool function IsWeaponFlyoutVisible() +{ + return ( file.weaponRUI != null && ( file.flyoutShowTime + file.lastFlyoutDuration > Time() ) ) +} + +void function WeaponFlyout_SetLevelEnabled( bool state ) +{ + file.flyoutLevelEnabled = state +} + +void function SetWeaponFlyoutRemainingTime( float time ) +{ + if ( file.weaponRUI == null ) + return + + file.flyoutShowTime = Time() + file.lastFlyoutDuration = time + + RuiSetGameTime( file.weaponRUI, "startTime", file.flyoutShowTime ) + RuiSetFloat( file.weaponRUI, "duration", file.lastFlyoutDuration ) +}
\ No newline at end of file diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut index 03009764..19a544cc 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -6,6 +6,7 @@ const int BUTTONS_PER_PAGE = 15 struct { int page = 0 int lastSelectedServer = 0 + bool serverListRequestFailed = false } file void function AddNorthstarServerBrowserMenu() @@ -52,6 +53,7 @@ void function RefreshServers( var button ) return file.page = 0 + file.serverListRequestFailed = false NSClearRecievedServerList() NSRequestServerList() @@ -101,7 +103,8 @@ void function WaitForServerListRequest() while ( NSIsRequestingServerList() ) WaitFrame() - if ( !NSMasterServerConnectionSuccessful() ) + file.serverListRequestFailed = !NSMasterServerConnectionSuccessful() + if ( file.serverListRequestFailed ) SetButtonRuiText( serverButtons[ 0 ], "#NS_SERVERBROWSER_CONNECTIONFAILED" ) else UpdateShownPage() @@ -152,7 +155,7 @@ void function UpdateShownPage() void function OnServerFocused( var button ) { - if ( NSIsRequestingServerList() || !NSMasterServerConnectionSuccessful() || NSGetServerCount() == 0 ) + if ( NSIsRequestingServerList() || NSGetServerCount() == 0 || file.serverListRequestFailed ) return var menu = GetMenu( "ServerBrowserMenu" ) @@ -201,7 +204,7 @@ string function FormatServerDescription( int server ) void function OnServerSelected( var button ) { - if ( NSIsRequestingServerList() || !NSMasterServerConnectionSuccessful() || NSGetServerCount() == 0 ) + if ( NSIsRequestingServerList() || NSGetServerCount() == 0 || file.serverListRequestFailed ) return int serverIndex = file.page * BUTTONS_PER_PAGE + int ( Hud_GetScriptID( button ) ) diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_fastball_intro.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_fastball_intro.gnut index b4e5ef2b..5f2e6adc 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_fastball_intro.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_fastball_intro.gnut @@ -127,10 +127,7 @@ void function FastballPlayer( entity player ) player.EndSignal( "OnDeath" ) - // do this here so it's in OnThreadEnd - var oldVisibility = player.kv.VisibilityFlags - - OnThreadEnd( function() : ( player, oldVisibility ) + OnThreadEnd( function() : ( player ) { if ( IsValid( player ) ) { @@ -140,7 +137,7 @@ void function FastballPlayer( entity player ) player.DeployWeapon() player.PlayerCone_Disable() player.ClearInvulnerable() - player.kv.VisibilityFlags = oldVisibility // restore visibility + player.kv.VisibilityFlags = ENTITY_VISIBLE_TO_EVERYONE // restore visibility } }) diff --git a/Northstar.Custom/mod/scripts/vscripts/sh_bleedout_damage.gnut b/Northstar.Custom/mod/scripts/vscripts/sh_bleedout_damage.gnut index 3306d1bd..c94e5ff0 100644 --- a/Northstar.Custom/mod/scripts/vscripts/sh_bleedout_damage.gnut +++ b/Northstar.Custom/mod/scripts/vscripts/sh_bleedout_damage.gnut @@ -12,6 +12,12 @@ struct { void function BleedoutDamage_PreInit() { AddCallback_OnRegisteringCustomNetworkVars( Bleedout_RegisterRemoteFunctions ) + + #if CLIENT + // because playlist var overrides fucking suck, they aren't actually updated by this point + // client bleedout can be inited late enough that we can just init it on local player spawn + AddCallback_LocalClientPlayerSpawned( InitClientBleedoutForLocalPlayer ) + #endif } void function Bleedout_RegisterRemoteFunctions() @@ -43,9 +49,9 @@ void function BleedoutDamage_Init() AddPrivateMatchModeSettingArbitrary( "#MODE_SETTING_CATEGORY_BLEEDOUT", "player_bleedout_aiBleedingPlayerMissChance", DEFAULT_AI_BLEEDING_PLAYER_MISS_CHANCE.tostring() ) #if CLIENT - // because playlist var overrides fucking suck, they aren't actually updated by this point - // client bleedout can be inited late enough that we can just init it on local player spawn - AddCallback_LocalClientPlayerSpawned( InitClientBleedoutForLocalPlayer ) + // manually register signals here: defensive fix so we don't crash + RegisterSignal( "Bleedout_OnRevive" ) + RegisterSignal( "Bleedout_StopFirstAid" ) #elseif SERVER // sh_riff_settings should set this correctly on server if ( !Riff_PlayerBleedout() ) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/lobby/_private_lobby.gnut b/Northstar.CustomServers/mod/scripts/vscripts/lobby/_private_lobby.gnut index b5c6ea32..dd3d5e0e 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/lobby/_private_lobby.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/lobby/_private_lobby.gnut @@ -39,10 +39,6 @@ bool function ClientCommandCallback_PrivateMatchLaunch( entity player, array<str { if ( file.startState == ePrivateMatchStartState.STARTING ) { - if ( GetConVarBool( "ns_private_match_only_host_can_start" ) ) - if ( !NSIsPlayerIndexLocalPlayer( player.GetPlayerIndex() ) ) - return true - // cancel start if we're already mid-countdown file.startState = ePrivateMatchStartState.READY SetUIVar( level, "privatematch_starting", ePrivateMatchStartState.READY ) @@ -50,6 +46,10 @@ bool function ClientCommandCallback_PrivateMatchLaunch( entity player, array<str } else { + if ( GetConVarBool( "ns_private_match_only_host_can_start" ) ) + if ( !NSIsPlayerIndexLocalPlayer( player.GetPlayerIndex() ) ) + return true + // start match file.startState = ePrivateMatchStartState.STARTING thread StartMatch() @@ -159,7 +159,7 @@ void function StartMatch() SetConVarString( "ns_private_match_last_map", file.map ) SetConVarString( "ns_private_match_last_mode", file.mode ) - SetConVarBool( "ns_should_return_to_lobby", true ) // potentially temp? + //SetConVarBool( "ns_should_return_to_lobby", true ) // potentially temp? string mode = file.mode if ( !( mode in GAMETYPE_TEXT ) ) 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 fdcc468c..7ca1246b 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 @@ -146,7 +146,7 @@ void function SpawnPlayerIntoDropship( entity player ) int playerDropshipIndex = -1 foreach ( IntroDropship dropship in teamDropships ) for ( int i = 0; i < dropship.players.len(); i++ ) - if ( dropship.players[ i ] == player ) + if ( dropship.players[ i ] == null ) { playerDropship = dropship playerDropshipIndex = i diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut index 562f65e5..6518b633 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_gamestate_mp.nut @@ -717,18 +717,21 @@ void function SetWinner( int team, string winningReason = "", string losingReaso else file.announceRoundWinnerLosingSubstr = GetStringID( losingReason ) - if ( IsRoundBased() ) - { - if ( team != TEAM_UNASSIGNED ) - { - GameRules_SetTeamScore( team, GameRules_GetTeamScore( team ) + 1 ) - GameRules_SetTeamScore2( team, GameRules_GetTeamScore2( team ) + 1 ) + if ( GamePlayingOrSuddenDeath() ) + { + if ( IsRoundBased() ) + { + if ( team != TEAM_UNASSIGNED ) + { + GameRules_SetTeamScore( team, GameRules_GetTeamScore( team ) + 1 ) + GameRules_SetTeamScore2( team, GameRules_GetTeamScore2( team ) + 1 ) + } + + SetGameState( eGameState.WinnerDetermined ) } - - SetGameState( eGameState.WinnerDetermined ) + else + SetGameState( eGameState.WinnerDetermined ) } - else - SetGameState( eGameState.WinnerDetermined ) } void function AddTeamScore( int team, int amount ) |