## Install Cloak
##
## By JB2005 & Tethys
##
## v0.2
##
## Change Log:
##
## - Replaced Button Script (QBautostart must be installed for this script to work, Ambiguity relies on QBReplacement being installed!)
## - Added a Check:
## - If a Cloaking Device is installed, the button fails and hides itself
## - When the Player Ship Changes, it checks if it has a cloaking device and hides / reveals the button
## - Added some comments to show what we've done (for the benefit of uploading this file to BCC!
##
## v0.2.1
##
## Change Log:
## - Changed PrependChild to AddChild (Moves to the Bottom of Brex's Screen)
## - Added Countdown Timer (def Countdown1 + def Countdown2) - each is called after 1 second and drops 1 second from a global property.
## Once pCounter reaches 0, it adds a Cloaking Device!
## v0.2.2
##
## Change Log:
## - Changed pCounter from 10 (seconds) to a multiplied value for installation time based upon subsystem max condition and repair complexity.
## - Moved def AddWarpCore to keep the file organized. (It's going to get a lot longer before its finished)
## v0.2.3
##
## Change Log:
## - Added imports for Tactical menu so we can get our Infiltration Team coded, so we can steal subsystems
## - Added some defs for the Infiltration Team
## ToDo:
## * Add imports for subsystems
## * Link GetMaxCondition and GetRepairComplexity to their own descriptors
## * Rewrite pCounter again with above imports
## * Change name of pCounter to pCloakCounter as we will probably be adding more unique globals for p(Subsystem)Counter for each subsystem
## * Begin writing additional defs for additional subsystems to install
## * Change (pTargetattr.GetShields().GetCurShields(App.ShieldClass.FRONT_SHIELDS) < 800000): back to < 800
## * Change (pMission.GetFriendlyGroup().IsNameInGroup(pTarget.GetName())): back to #GetEnemyGroup
import App
import MissionLib
import Libs.LibEngineering
import Lib.LibEngineering
import Bridge.BridgeUtils
from Libs.LibQBautostart import *
# Mod Info Block. Used for MP loading.
MODINFO = { "Author": "JB2005 & Tethys",
"Version": "0.2.1",
"License": "GPL",
"Description": "Install Cloaking Device",
"needBridge": 0
}
#pXOMenu = Lib.LibEngineering.GetBridgeMenu("XO")
pBrexMenu = Lib.LibEngineering.GetBridgeMenu("Engineering")
pFelixMenu = Lib.LibEngineering.GetBridgeMenu("Tactical")
GOTO_ENGINEERING = App.Mission_GetNextEventType()
pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pMission = pEpisode.GetCurrentMission()
pPlayer = pGame.GetPlayer()
pTarget = pPlayer.GetTarget()
pCoreCounter = None
pCounter = None
pInfiCounter = None
pEngButton = None
pEngButton1 = None
pReset = None
pTacButton = None
pTacButton1 = None
pCloakData = None
def init():
global pEngButton, pEngButton1, pReset, pTacButton, pCloakData
pMenu = App.STMenu_CreateW(App.TGString("Fabrications")) #WIP, will contain subsystem blueprint data stolen from other ships
pBrexMenu.AddChild(pMenu)
pTacMenu = App.STMenu_CreateW(App.TGString("Away Team")) #WIP
pFelixMenu.AddChild(pTacMenu)
pInfiMenu = App.STMenu_CreateW(App.TGString("Infiltrate")) #WIP
pTacMenu.AddChild(pInfiMenu)
pSubsMenu = App.STMenu_CreateW(App.TGString("Available Data")) #WIP, will contain available subsystem data to steal from other ships
pInfiMenu.AddChild(pSubsMenu)
# pReset = Lib.LibEngineering.CreateMenuButton("Reset List", "Engineering", __name__ + ".ResetList", ToButton = pMenu)
pEngButton = Lib.LibEngineering.CreateMenuButton("Cloaking Device", "Engineering", __name__ + ".ButtonTimer", ToButton = pMenu) #add an install simulation timer
pEngButton1 = Lib.LibEngineering.CreateMenuButton("Warp Core", "Engineering", __name__ + ".CoreTimer", ToButton = pMenu) #add an install simulation timer
pTacButton = Lib.LibEngineering.CreateMenuButton("Send Team", "Tactical", __name__ + ".CheckPossible", ToButton = pInfiMenu) #send the away team
pTacButton1 = Lib.LibEngineering.CreateMenuButton("Recall Team", "Tactical", __name__ + ".RecallTeam", ToButton = pTacMenu) #recall the away team
pCloakData = Lib.LibEngineering.CreateMenuButton("Cloak Data", "Tactical", __name__ + ".CloakData", ToButton = pSubsMenu) #recall the away team
pTacButton1.SetDisabled()
pCloakData.SetNotVisible()
pEngButton.SetNotVisible()
pEngButton1.SetNotVisible()
App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_SET_PLAYER, pMission, __name__ + ".CheckShip")
App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_OBJECT_EXPLODING, pMission, __name__ + ".ShipExploding")
def CheckPossible(pObject, pEvent):
# Need some checks here for target so we can allow or disallow the transport
pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pMission = pEpisode.GetCurrentMission()
pPlayer = pGame.GetPlayer()
pTarget = pPlayer.GetTarget()
pTargetCast = App.ShipClass_Cast(pPlayer.GetTarget())
pTargetattr = App.ShipClass_Cast(pTarget)
# pCloakingDevice = pPlayer.GetCloakingSubsystem()
# pWarpCore = pPlayer.GetPowerSubsystem()
if not (pTarget): #No target, get us out of here
pSound = App.TGSound_Create("sfx/Maelstrom/Episode 7/Mission 2/E7M2L067.mp3", "NoLock", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("NoLock")
return
if (Distance(pTarget) > 300): #Test Distance
pSound = App.TGSound_Create("sfx/Maelstrom/Episode 7/Mission 2/E7M2L0672.mp3", "TooFar", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("TooFar")
print("Target is too far away: can't Transport")
return # try to find an offline Shield
if (pMission.GetFriendlyGroup().IsNameInGroup(pTarget.GetName())): #GetEnemyGroup
if (pTargetattr.GetShields() != None):
if (pTargetattr.GetShields().GetCurShields(App.ShieldClass.FRONT_SHIELDS) < 800000):
print ("Front Shield is Offline...beaming")
elif (pTargetattr.GetShields().GetCurShields(App.ShieldClass.REAR_SHIELDS) < 800000):
print ("After Shield is Offline...beaming")
elif (pTargetattr.GetShields().GetCurShields(App.ShieldClass.TOP_SHIELDS) < 800000):
print ("Top Shield is Offline...beaming")
elif (pTargetattr.GetShields().GetCurShields(App.ShieldClass.BOTTOM_SHIELDS) < 800000):
print ("Bottom Shield is Offline...beaming")
elif (pTargetattr.GetShields().GetCurShields(App.ShieldClass.LEFT_SHIELDS) < 800000):
print ("Left Shield is Offline...beaming")
elif (pTargetattr.GetShields().GetCurShields(App.ShieldClass.RIGHT_SHIELDS) < 800000):
print ("Right Shield is Offline...beaming")
else:
print ("No offline Shield...sorry")
pSound = App.TGSound_Create("sfx/Maelstrom/Episode 7/Mission 2/E7M2L0673.mp3", "CantLock", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("CantLock")
return
# We have disabled their shield generator. Transport over
pSound = App.TGSound_Create("sfx/Bridge/Crew/Tactical/gt018.mp3", "Locked", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("Locked")
pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".InfiltrationTeam", App.g_kUtopiaModule.GetGameTime() + 2, 0, 0)
def InfiltrationTeam(pObject, pEvent):
global pInfiCounter
# Lets give our team 30 seconds to come up with the blueprints for the system
pInfiCounter = 30
MissionLib.TextBanner(None, App.TGString("Infiltrating: " + str(pInfiCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 14, 1, 0)
pSound = App.TGSound_Create("sfx/Bridge/Crew/Engineering/LoweringShields.mp3", "Lowering", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("Lowering")
#Send Team disabled, cant send another team
pTacButton.SetDisabled() #Send Team
pBeamingTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BeamingSFX", App.g_kUtopiaModule.GetGameTime() + 1.5, 0, 0)
pInfiTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".InfiCountdown1", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
def BeamingSFX(pObject, pEvent):
pSound = App.TGSound_Create("sfx/Interface/new_game3.wav", "Beaming", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("Beaming")
def InfiCountdown1(pObject,pEvent):
if pInfiCounter == 0:
AddStealableSystems()
# pEngButton.SetEnabled()
# pEngButton1.SetEnabled()
return 0
else:
global pInfiCounter
pInfiCounter = pInfiCounter - 1
MissionLib.TextBanner(None, App.TGString("Infiltrating: " + str(pInfiCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 14, 1, 0)
pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".InfiCountdown2", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
def InfiCountdown2(pObject,pEvent):
if pInfiCounter == 0:
AddStealableSystems()
# pEngButton.SetEnabled()
# pEngButton1.SetEnabled()
return 0
else:
global pInfiCounter
pInfiCounter = pInfiCounter - 1
MissionLib.TextBanner(None, App.TGString("Infiltrating: " + str(pInfiCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 14, 1, 0)
pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".InfiCountdown1", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
def AddStealableSystems():
pPlayer = MissionLib.GetPlayer()
pTarget = pPlayer.GetTarget()
pTargetCast = App.ShipClass_Cast(pPlayer.GetTarget())
pTargetattr = App.ShipClass_Cast(pTarget)
pSound = App.TGSound_Create("sfx/Maelstrom/Episode 5/Mission 4/E5M4FelixComm2.mp3", "StandingBy", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("StandingBy")
# Found out this stuff here resets the entire ship including all the shield and hull values. No good :( we wanna keep those for a linear gameplay
# pShip = pGame.GetPlayer()
# pGame.SetPlayer(pShip)
#This stuff got moved into the if statements below
# pCloakData.SetVisible()
# pOtherData.SetVisible() #Reserved for future features
if not (pTargetattr.GetCloakingSubsystem() != None): #it must not have one
pCloakData.SetNotVisible() #No Mr.Data :(
pTacButton1.SetEnabled() #Allow Recall Team
# pOtherData.SetNotVisible()
# pSubsMenu.ResizeToContents()
return
elif (pTargetattr.GetCloakingSubsystem() != None): #if target has cloaking subsystem
pCloakData.SetVisible() #Mr.Data
# pOtherData.SetVisible()
# pSubsMenu.ResizeToContents()
return
def CloakData(pObject, pEvent):
pSound = App.TGSound_Create("sfx/Maelstrom/Episode 6/Mission 1/E6M1SavoyHail1.mp3", "IncomingHail", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("IncomingHail")
pDataTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".CloakData1", App.g_kUtopiaModule.GetGameTime() + 5, 0, 0)
# pSubsMenu.ResizeToContents()
def CloakData1(pObject, pEvent):
pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pMission = pEpisode.GetCurrentMission()
pPlayer = pGame.GetPlayer()
pCloakingDevice = pPlayer.GetCloakingSubsystem()
pSound = App.TGSound_Create("sfx/Maelstrom/Episode 7/Mission 6/E7M6L048.mp3", "Aboard", 0) #E7M6L048
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("Aboard")
pCloakData.SetNotVisible()
pBeamingTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BeamingSFX", App.g_kUtopiaModule.GetGameTime() + 1.5, 0, 0)
if pCloakingDevice: #If we have a cloak, disallow cloak data and allow us to beam back
pEngButton.SetNotVisible() #We already have a cloaking device, no reason to install another
pTacButton1.SetEnabled() #Allow us to transport back
# pSubsMenu.ResizeToContents()
return #end
if not pCloakingDevice: #We don't have a cloaking device, make the button so we can install one
pEngButton.SetVisible() #Engineering you get to work now
# pSubsMenu.ResizeToContents()
return #end
def RecallTeam(pObject, pEvent):
pSound = App.TGSound_Create("sfx/Maelstrom/Episode 7/Mission 6/E7M6L048.mp3", "Aboard", 0) #E7M6L048
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("Aboard")
pTacButton1.SetDisabled()
# pCloakData.SetNotVisible()
# pSubsMenu.ResizeToContents() #These break the subroutine :( idk why right now
# pMenu.ResizeToContents()
pBeamingTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BeamingSFX", App.g_kUtopiaModule.GetGameTime() + 1.5, 0, 0)
# Get the Distance between the Player and pObject
def Distance(pObject):
debug(__name__ + ", Distance")
# pPlayer = App.Game_GetCurrentGame().GetPlayer()
vDifference = pObject.GetWorldLocation()
vDifference.Subtract(pPlayer.GetWorldLocation())
return vDifference.Length()
def ButtonTimer(pObject, pEvent):
global pCounter
#pCounter = 10 #Can we make this dependent on subsystem max health * subsystem repair complexity?
pCounter = (0.01 * 3000.000000 * 7.000000) #(For now we add the static value of the stock cloaking device rather than import it; we can do that later)
# #pCounter must be fractional since MaxCond * RepairComp will produce insanely high numbers causing realistic install
# #times (we need to multiply by fractions of 1 for ease of gameplay)
# #If MaxCond = 3000.000000
# #If RepairComp = 7.000000
# #For example if: pCounter = (0.01 * GetMaxCondition * GetRepairComplexity)
# #pCounter = 210 #(3.5 minutes)
# #For example if: pCounter = (0.02 * GetMaxCondition * GetRepairComplexity)
# #pCounter = 420 #(7 minutes) A far more realistic install time in relation to cooldown times of countless mods :)
# #For example if: pCounter = (0.03 * GetMaxCondition * GetRepairComplexity)
# #pCounter = 630 #(10.5 minutes) #You could go up to 0.05 but it makes a 17 minute install time.
MissionLib.TextBanner(None, App.TGString("Installating Cloaking Device " + str(pCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 14, 1, 0)
pSound = App.TGSound_Create("sfx/Bridge/Crew/Engineering/ge151.mp3", "EngTeamGo", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("EngTeamGo")
# Disable all the buttons, we only have so many engineers...
pEngButton.SetDisabled()
pEngButton1.SetDisabled()
pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".Countdown1", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
def Countdown1(pObject,pEvent):
if pCounter == 0:
AddCloakingDevice()
pEngButton.SetEnabled()
pEngButton1.SetEnabled()
return 0
else:
global pCounter
pCounter = pCounter - 1
MissionLib.TextBanner(None, App.TGString("Installating Cloaking Device " + str(pCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 14, 1, 0)
pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".Countdown2", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
def Countdown2(pObject,pEvent):
if pCounter == 0:
AddCloakingDevice()
pEngButton.SetEnabled()
pEngButton1.SetEnabled()
return 0
else:
global pCounter
pCounter = pCounter - 1
MissionLib.TextBanner(None, App.TGString("Installating Cloaking Device " + str(pCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 14, 1, 0)
pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".Countdown1", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
def AddCloakingDevice():
pSound = App.TGSound_Create("sfx/Bridge/Crew/Engineering/ge111.mp3", "EngTeamDone", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("EngTeamDone")
#Loads our new Hardpoint on top of the existing hardpoint - use once only!
pCloakingDevice = pPlayer.GetCloakingSubsystem()
if pCloakingDevice:
pEngButton.SetNotVisible()
pBrexMenu.SetVisible()
return
else:
pPropertySet = pPlayer.GetPropertySet()
mod = __import__('Custom.QBautostart.CloakingDevice')
mod.LoadPropertySet(pPropertySet)
pPlayer.SetupProperties()
#Reload the Player Ship - fully integrates the new component!
pShip = pGame.GetPlayer()
pGame.SetPlayer(pShip)
pEngButton.SetNotVisible()
pBrexMenu.SetVisible()
def CoreTimer(pObject, pEvent):
global pCoreCounter
#pCounter = 10 #Can we make this dependent on subsystem max health * subsystem repair complexity?
pCoreCounter = (0.001 * 5000.000000 * 2.200000) #(For now we add the static value of the stock cloaking device rather than import it; we can do that later)
# #pCounter must be fractional since MaxCond * RepairComp will produce insanely high numbers causing realistic install
# #times (we need to multiply by fractions of 1 for ease of gameplay)
# #If MaxCond = 3000.000000
# #If RepairComp = 7.000000
# #For example if: pCounter = (0.01 * GetMaxCondition * GetRepairComplexity)
# #pCounter = 210 #(3.5 minutes)
# #For example if: pCounter = (0.02 * GetMaxCondition * GetRepairComplexity)
# #pCounter = 420 #(7 minutes) A far more realistic install time in relation to cooldown times of countless mods :)
# #For example if: pCounter = (0.03 * GetMaxCondition * GetRepairComplexity)
# #pCounter = 630 #(10.5 minutes) #You could go up to 0.05 but it makes a 17 minute install time.
MissionLib.TextBanner(None, App.TGString("Installating Warp Core " + str(pCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 14, 1, 0)
pSound = App.TGSound_Create("sfx/Bridge/Crew/Engineering/ge151.mp3", "EngTeamGo", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("EngTeamGo")
# Disable all the buttons, we only have so many engineers...
pEngButton.SetDisabled()
pEngButton1.SetDisabled()
pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".CoreCount1", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
def CoreCount1(pObject,pEvent):
if pCoreCounter == 0:
AddWarpCore()
pEngButton.SetEnabled()
pEngButton1.SetEnabled()
return 0
else:
global pCoreCounter
pCoreCounter = pCoreCounter - 1
MissionLib.TextBanner(None, App.TGString("Installating Warp Core " + str(pCoreCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 14, 1, 0)
pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".CoreCount2", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
def CoreCount2(pObject,pEvent):
if pCoreCounter == 0:
AddWarpCore()
pEngButton.SetEnabled()
pEngButton1.SetEnabled()
return 0
else:
global pCoreCounter
pCoreCounter = pCoreCounter - 1
MissionLib.TextBanner(None, App.TGString("Installating Warp Core " + str(pCoreCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 14, 1, 0)
pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".CoreCount1", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
def AddWarpCore():
pSound = App.TGSound_Create("sfx/Bridge/Crew/Engineering/ge111.mp3", "EngTeamDone", 0)
pSound.SetSFX(0)
pSound.SetInterface(1)
App.g_kSoundManager.PlaySound("EngTeamDone")
#Loads our new Hardpoint on top of the existing hardpoint - use once only!
pWarpCore = pPlayer.GetPowerSubsystem()
if pWarpCore:
pEngButton1.SetNotVisible()
pBrexMenu.SetVisible()
return
else:
pPropertySet = pPlayer.GetPropertySet()
mod = __import__('Custom.QBautostart.WarpCore')
mod.LoadPropertySet(pPropertySet)
pPlayer.SetupProperties()
#Reload the Player Ship - fully integrates the new component!
pShip = pGame.GetPlayer()
pGame.SetPlayer(pShip)
pEngButton1.SetNotVisible()
pBrexMenu.SetVisible()
def CheckShip(pObject, pEvent):
# This little bit of scripting checks when the player ship changes if a cloaking device is present - and if it is, gets rid of the button
# If there isn't one, it makes / keeps the button visible
pCloakingDevice = pPlayer.GetCloakingSubsystem()
pWarpCore = pPlayer.GetPowerSubsystem()
if pCloakingDevice:
pEngButton.SetNotVisible()
pBrexMenu.SetNotVisible()
return
if pWarpCore:
pEngButton1.SetNotVisible()
pBrexMenu.SetNotVisible()
return
if pWarpCore.IsOn():
pEngButton1.SetNotVisible()
pBrexMenu.SetNotVisible()
return
if not pWarpCore.IsDisabled():
pEngButton1.SetNotVisible()
pBrexMenu.SetNotVisible()
return
else:
pEngButton.SetVisible()
pEngButton1.SetVisible()
pBrexMenu.SetVisible()
#pBrexMenu.SetNotVisible()
def ResetList(pObject, pEvent):
# This little bit of scripting checks when the player ship changes if a cloaking device is present - and if it is, gets rid of the button
# If there isn't one, it makes / keeps the button visible
# The code now also checks for subsystem presence on the target ship, and only allows us to install one if the target has one -Tethys
# Code needed for chance for success/failure, to tie in to Marines (Infiltration Teams) -Tethys
# This def may become obsolete soon... Button is disabled via init def
pGame = App.Game_GetCurrentGame()
pPlayer = pGame.GetPlayer()
pPlayerName = pPlayer.GetName()
pTarget = pPlayer.GetTarget()
pTargetCast = App.ShipClass_Cast(pPlayer.GetTarget())
pTargetattr = App.ShipClass_Cast(pTarget)
pCloakingDevice = pPlayer.GetCloakingSubsystem()
pWarpCore = pPlayer.GetPowerSubsystem()
# if not pTarget: #No target, get us out of here
# return
# if pTarget: #target confirmed, do stuff, and then continue on
# pTargetSubsystem = pTargetattr.GetCloakingSubsystem()
# if not pTargetSubsystem: #There is no cloaking device here, get us out of here
# pEngButton.SetNotVisible()
# pMenu.ResizeToContents()
# return
# if pTargetSubsystem: #Subsystem present, do our thing
# pCloakingDevice = pPlayer.GetCloakingSubsystem()
# if not pCloakingDevice: #We don't have a cloaking device, make the button so we can install one
# pEngButton.SetVisible()
# pBrexMenu.SetVisible()
# pMenu.ResizeToContents()
# return
# if not pCloakingDevice:
# pEngButton.SetVisible()
# pBrexMenu.SetVisible()
# return
if not pWarpCore:
pEngButton1.SetVisible()
pBrexMenu.SetVisible()
return
if not pWarpCore.IsOn():
pEngButton1.SetVisible()
pBrexMenu.SetVisible()
return
if pWarpCore.IsDisabled():
pEngButton1.SetVisible()
pBrexMenu.SetVisible()
return
else:
pEngButton.SetNotVisible()
pEngButton1.SetNotVisible()
pBrexMenu.SetVisible()
#pBrexMenu.SetNotVisible()
def ShipExploding(pObject, pEvent):
pPlayer = App.Game_GetCurrentGame().GetPlayer()
# Get the ship that is exploding.
pShip = App.ShipClass_Cast(pEvent.GetDestination())
if (pShip != None):
iShipID = pShip.GetObjID()
if pPlayer and pShip.GetName() == pPlayer.GetName():
# It's us. Reset.
# BoostReset(None, None)
InstallCloakReset(None, None)
def InstallCloakReset(pObject, pEvent):
global CheckCounter
pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pMission = pEpisode.GetCurrentMission()
# delete enable button timer
# try:
# App.g_kTimerManager.DeleteTimer(EnableTimer.GetObjID())
# App.g_kRealtimeTimerManager.DeleteTimer(EnableTimer.GetObjID())
# EnableTimer = None
# except:
# pass
# reenable buttons
pTacButton.SetEnabled()
CheckCounter(None, None)
# reset our end combat handelers
pSaffiQB = GetMenuButton("Commander", "End Combat")
pSaffiQBR = GetQBRMenuButton("Commander", "Configure")
pSIQB = GetMenuButton("Science", "Special Options")
pSIQBR = GetQBRMenuButton("Science", "Special Options")
if pSaffiQB:
pSaffiQB.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".InstallCloakReset")
if pSIQB:
pSIQB.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".InstallCloakReset")
if pSaffiQBR:
pSaffiQBR.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".InstallCloakReset")
if pSIQBR:
pSIQBR.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".InstallCloakReset")
App.g_kEventManager.RemoveBroadcastHandler(App.ET_OBJECT_EXPLODING, pMission, __name__ + ".ShipExploding")
App.g_kEventManager.RemoveBroadcastHandler(App.ET_SET_PLAYER, pMission, __name__ + ".InstallCloakReset")
def CheckCounter(pObject, pEvent):
global pCounter
pCounter = 0
pTop = App.TopWindow_GetTopWindow()
pSubtitle = pTop.FindMainWindow(App.MWT_SUBTITLE)
pSubtitle.SetNotVisible()