From afea3530d872f6b50fe6be5a04bbe54c1551aa31 Mon Sep 17 00:00:00 2001 From: DBmaoha <56738369+DBmaoha@users.noreply.github.com> Date: Tue, 28 Feb 2023 05:58:48 +0800 Subject: [FW] Enable Turrets By Default (#587) * turrets are enabled by default, with some formatting * update indentation * add commentaries for turret highlight --- .../scripts/vscripts/gamemodes/_gamemode_fw.nut | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'Northstar.Custom/mod/scripts/vscripts') diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_fw.nut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_fw.nut index 7a5b0ee5f..b025ff0a1 100644 --- a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_fw.nut +++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_fw.nut @@ -125,7 +125,7 @@ void function GamemodeFW_Init() AddCallback_GameStateEnter( eGameState.Playing, OnFWGamePlaying ) AddSpawnCallback( "item_powerup", FWAddPowerUpIcon ) - AddSpawnCallback( "npc_turret_mega", FWTurretHighlight ) + AddSpawnCallback( "npc_turret_mega", OnFWTurretSpawned ) AddCallback_OnClientConnected( OnFWPlayerConnected ) AddCallback_PlayerClassChanged( OnFWPlayerClassChanged ) @@ -582,9 +582,6 @@ void function LoadEntities() // create turret, spawn with no team and set it after game starts entity turret = CreateNPC( "npc_turret_mega", TEAM_UNASSIGNED, info_target.GetOrigin(), info_target.GetAngles() ) SetSpawnOption_AISettings( turret, "npc_turret_mega_fortwar" ) - SetDefaultMPEnemyHighlight( turret ) // for sonar highlights to work - Highlight_SetFriendlyHighlight( turret, "fw_friendly" ) - AddEntityCallback_OnDamaged( turret, OnMegaTurretDamaged ) DispatchSpawn( turret ) turretsite.turret = turret @@ -1384,19 +1381,23 @@ void function FWAreaThreatLevelThink_Threaded() ///// TURRET FUNCTIONS ///// //////////////////////////// -void function FWTurretHighlight( entity turret ) +void function OnFWTurretSpawned( entity turret ) { - thread FWTurretHighlightThink( turret ) + turret.EnableTurret() // always enabled + SetDefaultMPEnemyHighlight( turret ) // for sonar highlights to work + AddEntityCallback_OnDamaged( turret, OnMegaTurretDamaged ) + thread FWTurretHighlightThink( turret ) } // this will clear turret's highlight upon their death, for notifying players to fix them void function FWTurretHighlightThink( entity turret ) { - turret.EndSignal( "OnDestroy" ) - Highlight_SetFriendlyHighlight( turret, "fw_friendly" ) + turret.EndSignal( "OnDestroy" ) + WaitFrame() // wait a frame for other turret spawn options to set up + Highlight_SetFriendlyHighlight( turret, "fw_friendly" ) // initialize the highlight, they will show upon player's next respawn - turret.WaitSignal( "OnDeath" ) - Highlight_ClearFriendlyHighlight( turret ) + turret.WaitSignal( "OnDeath" ) + Highlight_ClearFriendlyHighlight( turret ) } // for battery_port, replace the turret with new one @@ -1407,8 +1408,6 @@ entity function FW_ReplaceMegaTurret( entity perviousTurret ) entity turret = CreateNPC( "npc_turret_mega", perviousTurret.GetTeam(), perviousTurret.GetOrigin(), perviousTurret.GetAngles() ) SetSpawnOption_AISettings( turret, "npc_turret_mega_fortwar" ) - SetDefaultMPEnemyHighlight( turret ) // for sonar highlights to work - AddEntityCallback_OnDamaged( turret, OnMegaTurretDamaged ) DispatchSpawn( turret ) // apply settings to new turret, must up on date -- cgit v1.2.3