Author Topic: Install Cloaking Device  (Read 1121 times)

Offline JB2005

  • Scripter, Lawyer, Soldier, Spy
  • Posts: 197
  • Cookies: 58
    • Captain's Orders Blog
Install Cloaking Device
« on: April 30, 2018, 04:00:56 PM »
Hi, long time no see!

For those who don't remember me I was a little bit active on these boards up to about 2013. I recently re-installed BC and started playing about with a few ideas I've had. I'd like to present something I'm quite proud of:



This is a small script which adds a cloaking device to any player ship (which doesn't already have one - if you have one, it will crash the game!)

It's rather simple and hopefully elegant. It loads a second hardpoint script over the top of the existing hardpoint, to add the new components and is made up of two scripts, as follows:

Script 1:

Code: [Select]

import App
import MissionLib
import Bridge.BridgeUtils
import Lib.Ambiguity
import QuickBattle.QuickBattle

pBridge = App.g_kSetManager.GetSet('bridge')
BridgeType = App.BridgeSet_Cast(pBridge).GetConfig()
g_pBrex = App.CharacterClass_GetObject(pBridge, 'Engineer')
pBrexMenu = Bridge.BridgeUtils.GetBridgeMenu('Engineer')
GOTO_ENGINEERING = App.Mission_GetNextEventType()

pGame = App.Game_GetCurrentGame()

pPlayer = pGame.GetPlayer()

def init():

        # Create the Button (Bit of an elongated way of doing it, but I'm a sucker for nostalgia!

        if (pBrexMenu != None):
            event = Lib.Ambiguity.getEvent(GOTO_ENGINEERING)
            g_pBrex.AddPythonFuncHandlerForInstance(event, __name__ + ".AddCloakingDevice")
            pButton = QuickBattle.QuickBattle.CreateBridgeMenuButton(App.TGString('Install Cloaking Device'), event, 0, g_pBrex)

        #BCS:TNG Solved this issue a long time ago with The Beginning. This is my own solution, like theirs it adds the button below Brex's Menu
            pBrexMenu.AddChild(pButton)

def AddCloakingDevice(pObject,pEvent):

        #Loads our new Hardpoint on top of the existing hardpoint - use once only!

        pPropertySet = pPlayer.GetPropertySet()
        mod = __import__('Custom.QBautostart.CloakingDevice')
        mod.LoadPropertySet(pPropertySet)

        pPlayer.SetupProperties()

        #Reload the Player Ship - fully integrates the new component!

        pGame.SetPlayer(pPlayer)



Script 2: (The New Hardpoint)

Code: [Select]

import App
import GlobalPropertyTemplates

#################################################
CloakingDevice = App.CloakingSubsystemProperty_Create("Cloaking Device")

CloakingDevice.SetMaxCondition(3000.000000)
CloakingDevice.SetCritical(0)
CloakingDevice.SetTargetable(1)
CloakingDevice.SetPrimary(1)
CloakingDevice.SetPosition(0.000000, -2.947170, 1.100000)
CloakingDevice.SetPosition2D(64.000000, 92.000000)
CloakingDevice.SetRepairComplexity(7.000000)
CloakingDevice.SetDisabledPercentage(0.750000)
CloakingDevice.SetRadius(0.550000)
CloakingDevice.SetNormalPowerPerSecond(1000.000000)
CloakingDevice.SetCloakStrength(100.000000)
App.g_kModelPropertyManager.RegisterLocalTemplate(CloakingDevice)
################################################

def LoadPropertySet(pObj):

        prop = App.g_kModelPropertyManager.FindByName("Cloaking Device", App.TGModelPropertyManager.LOCAL_TEMPLATES)
        if (prop != None):
                pObj.AddToSet("Scene Root", prop)



I'm conscious that last time I just left suddenly (change in circumstances etc. etc.) and I don't want the community to miss out again - so please feel free to use / adapt this to your hearts content (just give credit!) I'm currently planning a small script which will simulate a commando raid on an enemy ship to 'steal' a cloaking device for your own - watch this space!
http://captainsordersdevelopmentblog.blogspot.com/2011/12/preview-no-1.html- Captains Orders Development Blog - Last Updated 10/12/2011

Offline Morgan

  • Moderator
  • Posts: 1340
  • Cookies: 65535
Re: Install Cloaking Device
« Reply #1 on: April 30, 2018, 04:30:23 PM »
Very cool concept!  I don't see in your description where one would install these things, though.  Does script 1 go into the autoload folder and script 2 into the hardpoints folder for example?

Offline JB2005

  • Scripter, Lawyer, Soldier, Spy
  • Posts: 197
  • Cookies: 58
    • Captain's Orders Blog
Re: Install Cloaking Device
« Reply #2 on: April 30, 2018, 04:47:09 PM »
Sorry should have made that clear! Both go in QBautostart (simple reason being the file path was at the top of Script 1 when I was writing it!

I've updated the Code a little bit and removed 'Ambiguity.py' as a requirement.


http://captainsordersdevelopmentblog.blogspot.com/2011/12/preview-no-1.html- Captains Orders Development Blog - Last Updated 10/12/2011

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Install Cloaking Device
« Reply #3 on: April 30, 2018, 05:01:04 PM »
I am particularly interested in your Commando Team; I can think of many things to steal from enemy ships in addition to a cloaking device ;)

Do you plan to add a chance for failure/success to the script?

I would recommend some kind of subsystem installation complexity as well per race, if stealing as Borg the installation complexity would be minimal (obviously) with a high chance of theft success, if stealing as Ferengi (because we can't all be a Pakled) installation complexity would be high with a low chance of success. This would be your discretion sir of course, but if you do release updated codes... I will inevitably use and modify them extensively.

Also, welcome back. I don't think we ever met.

Offline JB2005

  • Scripter, Lawyer, Soldier, Spy
  • Posts: 197
  • Cookies: 58
    • Captain's Orders Blog
Re: Install Cloaking Device
« Reply #4 on: May 08, 2018, 04:34:18 PM »
Thanks!

Commando Team would be a bit of a 'text based adventure' I think.

I'm envisaging a little GUI which opens with Saffi's Console and updates you to the status "Away Team have reached Engineering...etc"

Just a bit of a Sideline, I trialled this with Sovvie's Slipstream Framework, works like a Gem (ignore "Add Torpedo - I forgot to rename the button!")

http://captainsordersdevelopmentblog.blogspot.com/2011/12/preview-no-1.html- Captains Orders Development Blog - Last Updated 10/12/2011

Offline FekLeyr Targ

  • DS9FX Team
  • Posts: 490
  • Cookies: 537
Re: Install Cloaking Device
« Reply #5 on: May 08, 2018, 05:30:39 PM »
A belated welcome back. It's good to see you again. :)

All of this looks/sounds great.
Perhabs the commando team could be a fitting extension to the life support feature of DS9FX.
TaH pagh, Tah be.

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Install Cloaking Device
« Reply #6 on: May 08, 2018, 10:10:02 PM »
I have been thinking, does this apply to warp cores? Instead of how Core Eject automatically reinstalls the warp core when tractor beam hits, I think I may change this behavior and require engineering to reinstall the core. This only makes sense, and I could then add a random number timer + static timer to emulate the reinstallation process.

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2186
  • Cookies: 1706
  • Life is life
Re: Install Cloaking Device
« Reply #7 on: May 09, 2018, 01:37:21 PM »
A belated welcome back. It's good to see you again. :)

All of this looks/sounds great.
Perhabs the commando team could be a fitting extension to the life support feature of DS9FX.

I was thinking the same thing :).
Acta, non verba.
aka USS Sovereign

Offline JimmyB76

  • Posts: 6423
  • Cookies: 421
Re: Install Cloaking Device
« Reply #8 on: May 10, 2018, 10:29:51 AM »
heya JB!
we have awesome initials, yeah?  :D
cool script you got there!  :thumbsup:

Offline JB2005

  • Scripter, Lawyer, Soldier, Spy
  • Posts: 197
  • Cookies: 58
    • Captain's Orders Blog
Re: Install Cloaking Device
« Reply #9 on: May 10, 2018, 04:47:15 PM »
Thanks Jimmy! (For both!)

Warp Cores are a good one - it's not shown in any of the videos I've made, but I have a little script running which checks if the Warp Core has been damaged/ejected and if it has turns off the ship's lights.

I'm also working on a Side-Project which is rebuild destroyed systems (ironically rebuilding the scripts from scratch, as the ones i was working on 5 years ago died with a previous laptop!) and a lot of that code would easily adapt to reinstalling a Warp Core.

The DS9FX Crew would be something I'd love to integrate into this - but it will be a long way down the road. So far I've got a GUI working and a bit of a text window going - it scans an ship, reports the name and whether it has a cloaking device - bit of a way to get yet!

http://captainsordersdevelopmentblog.blogspot.com/2011/12/preview-no-1.html- Captains Orders Development Blog - Last Updated 10/12/2011

Offline Rob Archer

  • Posts: 163
  • Cookies: 545
  • New Frontier MKVI
Re: Install Cloaking Device
« Reply #10 on: May 13, 2018, 09:57:10 AM »
Warp cores might be a bit troublesome as the Engineering UI is dependant on the primary power generator.

Rebuilding destroyed systems takes me back a bit

Offline JB2005

  • Scripter, Lawyer, Soldier, Spy
  • Posts: 197
  • Cookies: 58
    • Captain's Orders Blog
Re: Install Cloaking Device
« Reply #11 on: May 13, 2018, 10:19:14 AM »
Yeah - to clarify, there's no issue with rebuilding the Warp Core after it's been ejected (since from the perspective of the game it's the same subsystem)

If you try to add another system which is already on the Hardpoint (Cloaking Device, Torpedo System are the two I've tried so far) you get a fatal error and the game crashes!

I had a working prototype for a Rebuild Destroyed Systems (a few years after the New Frontier version - and I'm showing my age there!) but unfortunately it was on an old Laptop which subsequently fried! I'd like to recreate it though:

http://captainsordersdevelopmentblog.blogspot.com/2011/12/preview-no-1.html- Captains Orders Development Blog - Last Updated 10/12/2011

Offline Rob Archer

  • Posts: 163
  • Cookies: 545
  • New Frontier MKVI
Re: Install Cloaking Device
« Reply #12 on: May 14, 2018, 12:05:13 PM »
Yeah I still have the old scripts lying around somewhere, it's a relatively straight forward script if I remember. I think at one point I had auxiliary power systems tied into the existing power system. As I wanted to do fusion reactors as warp backups, again can't remember how I implemented it

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Install Cloaking Device
« Reply #13 on: January 07, 2020, 03:43:37 PM »
Hey JB, so I added on to the Cloaking.py you initially created, and added some away team functions that you may be able to apply to you Away Mission mod GUI. What the code does is checks for a target, and if it has a target it checks if the target is close enough for transport, if it is then it checks for offline shields (right now for easy testing is set up for FriendliesGroup and bypasses target shields). After these things are checked and true, the Infiltration Team beams over to steal Blueprint/Data (right now only checks for cloaking device). The team has 30 seconds to download the data. Eventually I want to add a chance for data download failure or away team capture, both of which would end with the same result; no Data. After 30 seconds it checks the Target for cloaking device presence and if present, it adds the Data to the queue. Clicking the Data there is a 5 second delay as the Data arrives to Engineering Fabrications submenu (and it does populate the menu, but I am having trouble getting the ResizeToContents feature to work here, so you have to click the menu a few times for it to show up). Shortly after there is a transporter sound and your button becomes enabled again. Several check are included throughout to make sure you dont get Cloak Data if you already have a cloak, or if there is no cloak data available. Will post the code in a following post.

Additionally, if we're using:

        # pShip = pGame.GetPlayer()
        # pGame.SetPlayer(pShip)

then we need to import all current shield hull parent and child systems globally and reload them after using SetPlayer. Otherwise, we unrealistically get free shield recharge and hull fix. Not good for linear gameplay :(


Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Install Cloaking Device
« Reply #14 on: January 07, 2020, 03:44:39 PM »
Warning: Alpha code, may contain bugs or unfinished features.

Quote
Outdated, only added spoiler tags

Spoiler: show
Code: [Select]
## 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()

Offline FekLeyr Targ

  • DS9FX Team
  • Posts: 490
  • Cookies: 537
Re: Install Cloaking Device
« Reply #15 on: January 08, 2020, 04:38:34 AM »
Well done.
Have you by any chance watched "The Enterprise Incident" recently? I had to think of that episode when I saw your video. ;)
TaH pagh, Tah be.

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Install Cloaking Device
« Reply #16 on: January 09, 2020, 02:43:08 AM »
Yes I remember that episode.

Updated code, still alpha, code untested

Code: [Select]
## 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
##         - pCounter is now based on the MaxCondition and RepairComplexity of the ship from which it was stolen
##         - Removed (def Countdown2) and other duplicate counters and adjusted the calls accordingly (changed some names for easier searching);
##           Only one Countdown def is needed to loop back to itself until *Counter = 0
##         -
##         -
##         -
## 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.3",
                "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

pCloakButton = None
pWarpButton = None
pReset = None
pSendButton = None
pRecallButton = None
pCloakData = None

def init():

        global pCloakButton, pWarpButton, pReset, pSendButton, pRecallButton, 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)
        pCloakButton = Lib.LibEngineering.CreateMenuButton("Cloaking Device", "Engineering", __name__ + ".ButtonTimer", ToButton = pMenu) #add an install simulation timer
        pWarpButton = Lib.LibEngineering.CreateMenuButton("Warp Core", "Engineering", __name__ + ".CoreTimer", ToButton = pMenu) #add an install simulation timer

        pSendButton = Lib.LibEngineering.CreateMenuButton("Send Team", "Tactical", __name__ + ".CheckPossible", ToButton = pInfiMenu) #send the away team
        pRecallButton = 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) #data button for target cloaking device
        # pShieldData = Lib.LibEngineering.CreateMenuButton("Shield Data", "Tactical", __name__ + ".ShieldData", ToButton = pSubsMenu) #data button for target shield generator
        # pTractorData = Lib.LibEngineering.CreateMenuButton("Tractor Data", "Tactical", __name__ + ".TractorData", ToButton = pSubsMenu) #data button for target tractor beams
        # pWeaponData = Lib.LibEngineering.CreateMenuButton("Weapon Data", "Tactical", __name__ + ".WeaponData", ToButton = pSubsMenu) #data button for target weapons
        # pEngineData = Lib.LibEngineering.CreateMenuButton("Engine Data", "Tactical", __name__ + ".EngineData", ToButton = pSubsMenu) #data button for target engines
        # pCoreData = Lib.LibEngineering.CreateMenuButton("Core Data", "Tactical", __name__ + ".CoreData", ToButton = pSubsMenu) #data button for target power core (we probably wont use this one)

        # pShieldData.SetNotVisible()
        # pTractorData.SetNotVisible()
        # pWeaponData.SetNotVisible()
        # pEngineData.SetNotVisible()
        # pCoreData.SetNotVisible()
        pRecallButton.SetDisabled()
        pCloakData.SetNotVisible()
        pCloakButton.SetNotVisible()
        pWarpButton.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, pTargetName

        pPlayer = MissionLib.GetPlayer()
        pTarget = pPlayer.GetTarget()
        pTargetattr = App.ShipClass_Cast(pTarget)
        pTargetName = pTargetattr.GetName() #Use the name of the target to make things look better :P

# Lets give our team 30 seconds to come up with the blueprints for the system
# We could base this counter on something like Sensor subsystem GetCondition (this way you can reduce your InfiTime by damaging the Sensor subsystem) or something similar -Tethys
        pInfiCounter = 30

        MissionLib.TextBanner(None, App.TGString("Infiltrating " + str(pTargetName) + ":  " + str(pInfiCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 12, 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
        pSendButton.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__ + ".InfiCounter", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)

def InfiCounter(pObject,pEvent):

        if pInfiCounter == 0:

            AddStealableSystems()

            return 0 #End this def here. This is why we only need the one countdown def -Tethys

        else:

            global pInfiCounter

            pInfiCounter = pInfiCounter - 1

            MissionLib.TextBanner(None, App.TGString("Infiltrating " + str(pTargetName) + ":  " + str(pInfiCounter) + " Seconds Remaining"), 0.35, 0.1, 0.9, 12, 1, 0)

            # Call this def again, until pInfiCounter = 0, then AddStealableSystems and end the loop -Tethys
            pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".InfiCounter", 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 -Tethys
        # pShip = pGame.GetPlayer()
        # pGame.SetPlayer(pShip)

        if not (pTargetattr.GetCloakingSubsystem() != None): #it must not have one
            pCloakData.SetNotVisible() #No Mr.Data :(
            pRecallButton.SetEnabled() #Allow Recall Team
            # pOtherData.SetNotVisible()
            # pSubsMenu.ResizeToContents()
            return
        elif (pTargetattr.GetCloakingSubsystem() != None): #if target has cloaking subsystem
            pCloakData.SetVisible() #Mr.Data
            pSubsMenu.ResizeToContents()
            # pOtherData.SetVisible()
            # pTacMenu.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)
        # pBeepTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BeepSounds2", App.g_kUtopiaModule.GetGameTime() + 3.5, 0, 0)
        # pBeepTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BeepSounds2", App.g_kUtopiaModule.GetGameTime() + 3.5, 0, 0)
        pCloakData.SetNotVisible()
        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 5/Mission 4/E5M4FelixComm2.mp3", "StandingBy", 0)
        pSound.SetSFX(0)
        pSound.SetInterface(1)
        App.g_kSoundManager.PlaySound("StandingBy")

        if pCloakingDevice: #If we have a cloak, disallow cloak data and allow us to beam back
            pCloakButton.SetNotVisible() #We already have a cloaking device, no reason to install another
            pRecallButton.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
            pCloakButton.SetVisible() #Engineering you get to work now
            pRecallButton.SetEnabled() #Allow us to transport back
            # pSubsMenu.SetVisible()
            # pSubsMenu.ResizeToContents()
            return #end

def RecallTeam(pObject, pEvent):

        # We could get fancy here and require the target shields to remain down to beam back, or we can simply say that Felix downloaded the
        # shield frequency and bypassed the shields for transport. Regardless, we will probably need to be within 50 km... so we need our Distance...
       
        pBeepTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BeepSounds", App.g_kUtopiaModule.GetGameTime() + 0, 0, 0)
        pBeepTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BeepSounds1", App.g_kUtopiaModule.GetGameTime() + 1.5, 0, 0)
        pRecallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".RecallActions", App.g_kUtopiaModule.GetGameTime() + 2.5, 0, 0)

def RecallActions(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")
        pRecallButton.SetDisabled()
        pSendButton.SetEnabled()
        pBeamingTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BeamingSFX", App.g_kUtopiaModule.GetGameTime() + 1.5, 0, 0)

def ButtonTimer(pObject, pEvent):

        global pCounter

        # Begin importing stuff for pCounter dynamic value; based on pTarget cloaking device subsystem
        pPlayer = MissionLib.GetPlayer()
        pTarget = pPlayer.GetTarget()
        pTargetCast = App.ShipClass_Cast(pPlayer.GetTarget())
        pTargetattr = App.ShipClass_Cast(pTarget)
        pTCloak = pTargetattr.GetCloakingSubsystem()
        MaxCond = pTCloak.GetMaxCondition()
        RepairComp = pTCloak.GetRepairComplexity()

        #pCounter = 10 #Can we make this dependent on subsystem max health * subsystem repair complexity?
        pCounter = (0.01 * MaxCond * RepairComp) #Bob the Builder said Yes We Can!

        #   #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
        #   #If Fractional = 0.01

        #   #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, 12, 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...
        pCloakButton.SetDisabled()
        pWarpButton.SetDisabled()
        pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".CloakCounter", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)

def CloakCounter(pObject,pEvent):

        # if pCounter == 1:

            # Get the current states of all our subsystems...
            # PlayerCurrentValues()

        if pCounter == 0:

            AddCloakingDevice()
            pCloakButton.SetEnabled()
            pWarpButton.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, 12, 1, 0)

            pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".CloakCounter", 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:
                pCloakButton.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! (but also kills gameplay, we need to fix the subsystems)
                pShip = pGame.GetPlayer()
                pGame.SetPlayer(pShip)
                pCloakButton.SetNotVisible()
                pBrexMenu.SetVisible()

# Put all our subsystem values back to what they were before we got reset (WIP)
                # FixPlayerSubsystems()

"""def FixPlayerSubsystems(pObject, pEvent):

       

def PlayerCurrentValues(pObject, pEvent):

        global
       
        pGame = App.Game_GetCurrentGame()
        pEpisode = pGame.GetCurrentEpisode()
        pMission = pEpisode.GetCurrentMission()
        pPlayer = pGame.GetPlayer()"""

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, 12, 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...
        pCloakButton.SetDisabled()
        pWarpButton.SetDisabled()
        pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".CoreCounter", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)

def CoreCounter(pObject,pEvent):

        if pCoreCounter == 0:

            AddWarpCore()
            pCloakButton.SetEnabled()
            pWarpButton.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, 12, 1, 0)

            pInstallTimer = MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".CoreCounter", 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:
                pWarpButton.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)
                pWarpButton.SetNotVisible()
                pBrexMenu.SetVisible()

# 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()

# Organize our sound effects...
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 BeepSounds(pObject, pEvent):

        pSound = App.TGSound_Create("sfx/KM/computerbeep_33.wav", "Beeps", 0)
        pSound.SetSFX(0)
        pSound.SetInterface(1)
        App.g_kSoundManager.PlaySound("Beeps")

def BeepSounds1(pObject, pEvent):

        pSound = App.TGSound_Create("sfx/KM/computerbeep_7.mp3", "Beeps1", 0)
        pSound.SetSFX(0)
        pSound.SetInterface(1)
        App.g_kSoundManager.PlaySound("Beeps1")

def BeepSounds2(pObject, pEvent):

        pSound = App.TGSound_Create("sfx/KM/computer_activate.mp3", "Beeps2", 0)
        pSound.SetSFX(0)
        pSound.SetInterface(1)
        App.g_kSoundManager.PlaySound("Beeps2")
        pSound = App.TGSound_Create("sfx/KM/computer_activate.mp3", "Beeps2a", 0)
        pSound.SetSFX(0)
        pSound.SetInterface(1)
        App.g_kSoundManager.PlaySound("Beeps2a")

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
                # pCloakButton.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
                    # pCloakButton.SetVisible()
                    # pBrexMenu.SetVisible()
                    # pMenu.ResizeToContents()
                    # return
        # if not pCloakingDevice:
                # pCloakButton.SetVisible()
                # pBrexMenu.SetVisible()
                # return
        if not pWarpCore:
                pWarpButton.SetVisible()
                pBrexMenu.SetVisible()
                return
        if not pWarpCore.IsOn():
                pWarpButton.SetVisible()
                pBrexMenu.SetVisible()
                return
        if pWarpCore.IsDisabled():
                pWarpButton.SetVisible()
                pBrexMenu.SetVisible()
                return
        else:
                pCloakButton.SetNotVisible()
                pWarpButton.SetNotVisible()
                pBrexMenu.SetVisible()
                #pBrexMenu.SetNotVisible()
       
# Reset our counters when our condition changes
def CheckCounter(pObject, pEvent):
    global pCounter

    pCounter = 0

    pTop = App.TopWindow_GetTopWindow()
    pSubtitle = pTop.FindMainWindow(App.MWT_SUBTITLE)
    pSubtitle.SetNotVisible()

def CheckInfiCounter(pObject, pEvent):
    global pInfiCounter

    pInfiCounter = 0

    pTop = App.TopWindow_GetTopWindow()
    pSubtitle = pTop.FindMainWindow(App.MWT_SUBTITLE)
    pSubtitle.SetNotVisible()

# Handle our functions
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

        pGame = App.Game_GetCurrentGame()
        pPlayer = pGame.GetPlayer()
        pPlayerName = pPlayer.GetName()
        pCloakingDevice = pPlayer.GetCloakingSubsystem()
        pWarpCore = pPlayer.GetPowerSubsystem()
        if pCloakingDevice:
                pCloakButton.SetNotVisible()
                InstallCloakReset(None, None)
                # pBrexMenu.SetNotVisible()
                return
        if pWarpCore:
                pWarpButton.SetNotVisible()
                # InstallCloakReset(None, None)
                # pBrexMenu.SetNotVisible()
                return
        if pWarpCore.IsOn():
                pWarpButton.SetNotVisible()
                InstallCloakReset(None, None)
                # pBrexMenu.SetNotVisible()
                return
        if not pWarpCore.IsDisabled():
                pWarpButton.SetNotVisible()
                InstallCloakReset(None, None)
                # pBrexMenu.SetNotVisible()
                return
        else:
                pCloakButton.SetVisible()
                pWarpButton.SetVisible()
                InstallCloakReset(None, None)
                # 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.
                                InstallCloakReset(None, None)

def InstallCloakReset(pObject, pEvent):
        global CheckCounter, CheckInfiCounter
        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
        pSendButton.SetEnabled()
        CheckCounter(None, None)
        CheckInfiCounter(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")   

Revised: Jan 9 2020