Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Cargo Bays by Tethys
- ## Supported accompanying code RepairSystem by Rob Archer aka sfc3fan
- ##
- ## v0.1
- ##
- ## Change Log:
- ##
- ## - Begin button creation
- ## - Scripted the menus (based on Library.py by Defiant)
- ## - Incorporated RepairSystem by Rob Archer
- ## - Text added for parts maximum capacity (eye candy only at the moment)
- ## - Disabled all cargo bay selection buttons when transferring parts; until Confirm is clicked
- ##
- ##
- ## ToDo:
- ## * Set up a def for each cargo bay to react independently, meaning parts will be drawn from
- ## and added to the currently selected cargo bay rather than having them split between all
- ## available cargo bays.
- ## * Implement code for maximum parts capacity, so cargo bays don't have infinite inventory space...
- ## * Set up button dis/enablers for the repair menu (cooldowns).
- ## * Remove the repair menu updater function and make the menu static (so it doesn't reset when
- ## clicking on one of the cargo bays). Also need to change the way total parts updates, because
- ## it is tied into the repair menu...
- ## * Add text for repair teams to make the window more interactive.
- ## * Add text for replicator status.
- ## * Decide whether or not to use Add Quantity: (additional coding).
- ##
- ############################################################################################
- # Introduction:
- #
- # This mod adds a window button for Brex that allows you to carry spare parts. These parts can be used to
- # rebuild systems which have been completely destroyed in battle. The number of cargo bays your ship can have
- # is based on the ship's rotational inertia (not a very elegant way to get the bay count, but efficient). A
- # ship with less than 2001 rotational inertia value does not get a cargo bay (it is probably a shuttle). The
- # number of parts that can be held in each cargo bay varies and is based upon you ship's radius. This number
- # is multiplied by a base number of 10 to achieve a respectable number of spare parts.
- #
- #############################################################################################
- # #
- # This Section Handles the Num Of Available Spare Parts This Ship Has Available #
- # #
- # #
- # #
- #############################################################################################
- # Information:
- #
- # In This version you can set the number of spare parts the ship currently has available simply change
- # the number 10 to higher or lower number please note though for the sake of balace it is best left at 10
- # In the Next version you will not be able to set this figure it will be automatically calculated by using
- # the ships hull, However you will be able to 'Borrrow Some Parts from an enemy ship using the Transporter
- # It should also be possible to replicate a limited number of replacements using Main Power And a new replicator
- # system which should be added in a latter edition of New Frontier until then enjoy.
- #
- Bay1Parts = 0 #*pPlayer.GetRadius()
- Bay2Parts = 0
- Bay3Parts = 0
- Bay4Parts = 0
- Bay5Parts = 0
- Bay6Parts = 0
- Bay7Parts = 0
- BayParts = 0
- TotalParts = Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts+Bay6Parts+Bay7Parts
- import App
- import MissionLib
- import Libs.LibEngineering
- import Lib.LibEngineering
- import Bridge.BridgeUtils
- import Foundation
- import loadspacehelper
- import Bridge.EngineerMenuHandlers
- import BridgeHandlers
- import Actions.MissionScriptActions
- import Bridge.BridgeMenus
- from Libs.LibQBautostart import *
- # Mod Info Block. Used for MP loading.
- MODINFO = { "Author": "Tethys",
- "Version": "0.1",
- "License": "GPL",
- "Description": "Cargo Bays for spare parts/systems",
- "needBridge": 0
- }
- pMain = None
- pAvailablePartsButton = None
- AvailPartsTimer = None
- # BayParts = BayParts
- g_pMissionDatabase = None
- g_pGeneralDatabase = None
- g_pDatabase = None
- g_bSequenceRunning = None
- pBrexMenu = Lib.LibEngineering.GetBridgeMenu("Engineering")
- GOTO_ENGINEERING = App.Mission_GetNextEventType()
- ET_CLOSE = None
- ET_CATEGORY = None
- ET_TOPIC = None
- ET_SCROLLUP = None
- ET_GET_SUPPLIES = None
- ET_SEND_SUPPLIES = None
- ET_REPLICATE_SUPPLIES = None
- # ET_SET_PLAYER = None
- # ET_OBJECT_EXPLODING = None
- ET_ADD_QTY = None
- ET_CONFIRM = None
- # ET_CHARACTER_MENU = None
- sBayName = "Cargo Bays"
- sInfoName = "Inventory"
- pInventoryMenu = None
- pBodyMenu = None
- CargoBayNum = 0
- SuppliesNum = 0
- QtyType = 0
- CargoCapacity = 0
- pGame = App.Game_GetCurrentGame()
- pEpisode = pGame.GetCurrentEpisode()
- pMission = pEpisode.GetCurrentMission()
- pPlayer = pGame.GetPlayer()
- pTarget = pPlayer.GetTarget()
- # Spare parts
- pLargeParts = None
- pMediumParts = None
- pSmallParts = None
- def init():
- global ET_CLOSE, ET_TOPIC, ET_CATEGORY, ET_GET_SUPPLIES, ET_SEND_SUPPLIES, ET_REPLICATE_SUPPLIES, ET_ADD_QTY
- global ET_CONFIRM, ET_SET_PLAYER, ET_OBJECT_EXPLODING, ET_LARGE_PARTS, ET_MEDIUM_PARTS, ET_SMALL_PARTS, pBayButtons
- # Hey, we have a mutator now!
- # if not Lib.LibEngineering.CheckActiveMutator("Cargo Bays"):
- # return
- pMission = MissionLib.GetMission()
- pBrexMenu = Lib.LibEngineering.GetBridgeMenu("Engineering")
- pBridge = App.g_kSetManager.GetSet('bridge')
- pEngineer = App.CharacterClass_GetObject(pBridge, "Engineer")
- ET_CLOSE = Lib.LibEngineering.GetEngineeringNextEventType()
- ET_CATEGORY = Lib.LibEngineering.GetEngineeringNextEventType()
- ET_TOPIC = Lib.LibEngineering.GetEngineeringNextEventType()
- ET_GET_SUPPLIES = Lib.LibEngineering.GetEngineeringNextEventType()
- ET_SEND_SUPPLIES = Lib.LibEngineering.GetEngineeringNextEventType()
- ET_REPLICATE_SUPPLIES = Lib.LibEngineering.GetEngineeringNextEventType()
- # ET_SET_PLAYER = Lib.LibEngineering.GetEngineeringNextEventType()
- # ET_OBJECT_EXPLODING = Lib.LibEngineering.GetEngineeringNextEventType()
- # ET_CHARACTER_MENU = Lib.LibEngineering.GetEngineeringNextEventType()
- ET_ADD_QTY = Lib.LibEngineering.GetEngineeringNextEventType()
- ET_CONFIRM = Lib.LibEngineering.GetEngineeringNextEventType()
- # Start with the menu.
- pBayButtons = Lib.LibEngineering.CreateMenuButton(sBayName, "Engineering", __name__ + ".WindowOpenClose")
- App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_CLOSE, pMission, __name__ + ".WindowOpenClose")
- App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_GET_SUPPLIES, pMission, __name__ + ".TransferSupplies")
- App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_SEND_SUPPLIES, pMission, __name__ + ".TransferSupplies")
- App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_REPLICATE_SUPPLIES, pMission, __name__ + ".TransferSupplies")
- App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_ADD_QTY, pMission, __name__ + ".AddQty")
- App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_CONFIRM, pMission, __name__ + ".UpdateQty")
- App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_SET_PLAYER, pMission, __name__ + ".CheckShip")
- App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_OBJECT_EXPLODING, pMission, __name__ + ".ShipExploding")
- if pEngineer:
- pEngineer.AddPythonFuncHandlerForInstance(App.ET_CHARACTER_MENU, __name__ + ".WindowClose")
- # App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_CHARACTER_MENU, pMission, __name__ + ".WindowOpenClose")
- # handle mouse clicks in empty space
- def PassMouse(pWindow, pEvent):
- debug(__name__ + ", PassMouse")
- pWindow.CallNextHandler(pEvent)
- if pEvent.EventHandled() == 0:
- pEvent.SetHandled()
- def WindowOpenClose(pObject, pEvent):
- debug(__name__ + ", WindowOpenClose")
- pCargoBayWindow = GetCargoBayWindow()
- if not pCargoBayWindow:
- pCargoBayWindow = CreateBayGUI(None, None)
- # pInfoWindow = GetInfoWindow()
- # if not pInfoWindow:
- # pInfoWindow = CreateInfoWindow(None, None)
- pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
- if pCargoBayWindow.IsVisible(): # and pInfoWindow.IsVisible()
- pTacticalControlWindow.MoveToBack(pCargoBayWindow)
- pCargoBayWindow.SetNotVisible()
- # pCargoBayWindow.KillChildren()
- # pTacticalControlWindow.MoveToBack(pInfoWindow)
- # pInfoWindow.SetNotVisible()
- else:
- pCargoBayWindow.SetVisible()
- pTacticalControlWindow.MoveToFront(pCargoBayWindow)
- # Not so agressiv to the front - only give us problems!
- pTacticalControlWindow.MoveTowardsBack(pCargoBayWindow)
- # pCargoBayWindow.KillChildren()
- # CreateWindows(pCargoBayWindow)
- # pInfoWindow.SetVisible()
- # pTacticalControlWindow.MoveToFront(pInfoWindow)
- # Not so agressiv to the front - only give us problems!
- # pTacticalControlWindow.MoveTowardsBack(pInfoWindow)
- def WindowClose(pObject, pEvent):
- debug(__name__ + ", WindowClose")
- pCargoBayWindow = GetCargoBayWindow()
- # pInfoWindow = GetInfoWindow()
- if pCargoBayWindow:
- pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
- if pCargoBayWindow.IsVisible():
- pTacticalControlWindow.MoveToBack(pCargoBayWindow)
- pCargoBayWindow.SetNotVisible()
- pCargoBayWindow.KillChildren()
- # pTacticalControlWindow.MoveToBack(pInfoWindow)
- # pInfoWindow.SetNotVisible()
- pCargoBayWindow.SetNotVisible()
- pObject.CallNextHandler(pEvent)
- def WindowOpen(pObject, pEvent):
- debug(__name__ + ", WindowOpen")
- pCargoBayWindow = GetCargoBayWindow()
- # pInfoWindow = GetInfoWindow()
- if not pCargoBayWindow:
- pCargoBayWindow = CreateBayGUI(None, None)
- pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
- if not pCargoBayWindow.IsVisible():
- pTacticalControlWindow.MoveToFront(pCargoBayWindow)
- pCargoBayWindow.SetVisible()
- pTacticalControlWindow.MoveTowardsBack(pCargoBayWindow)
- # pCargoBayWindow.KillChildren()
- # pTacticalControlWindow.MoveToBack(pInfoWindow)
- # pInfoWindow.SetNotVisible()
- pCargoBayWindow.SetNotVisible()
- pObject.CallNextHandler(pEvent)
- # Begin building the outer window and border/text
- def GetCargoBayWindow():
- debug(__name__ + ", GetCargoBayWindow")
- pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
- # cycle all
- curChild = pTacticalControlWindow.GetFirstChild()
- while curChild:
- curWindow = App.STStylizedWindow_Cast(curChild)
- if curWindow:
- kString = curWindow.GetName()
- if (kString.GetCString() == sBayName):
- return curWindow
- curChild = pTacticalControlWindow.GetNextChild(curChild)
- def CreateBayGUI(pObject, pEvent):
- global pCargoBayWindow
- debug(__name__ + ", CreateBayGUI")
- pCargoBayWindow = App.STStylizedWindow_CreateW("StylizedWindow", "NoMinimize", App.TGString(sBayName), 0.0, 0.0, None, 1, 0.4, 0.275, App.g_kMainMenuBorderMainColor) #Window size W, H
- pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
- pTacticalControlWindow.AddChild(pCargoBayWindow, 0.085, 0.005) #Window X, Y
- pCargoBayWindow.AddPythonFuncHandlerForInstance(App.ET_MOUSE, __name__ + ".PassMouse")
- pCargoBayWindow.SetNotVisible()
- pCargoBayWindow.AddPythonFuncHandlerForInstance(ET_CATEGORY, __name__ + ".SelectCategory")
- pCargoBayWindow.AddPythonFuncHandlerForInstance(ET_TOPIC, __name__ + ".SelectTopic")
- CreateWindows(pCargoBayWindow)
- return pCargoBayWindow
- """def GetInfoWindow():
- debug(__name__ + ", GetInfoWindow")
- pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
- # cycle all
- curChild = pTacticalControlWindow.GetFirstChild()
- while curChild:
- curWindow = App.STStylizedWindow_Cast(curChild)
- if curWindow:
- kString = curWindow.GetName()
- if (kString.GetCString() == sInfoName):
- return curWindow
- curChild = pTacticalControlWindow.GetNextChild(curChild)"""
- """def CreateInfoWindow(pObject, pEvent):
- debug(__name__ + ", CreateInfoWindow")
- pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
- pInfoWindow = App.STStylizedWindow_CreateW("StylizedWindow", "NoMinimize", App.TGString(sInfoName), 0.0, 0.0, None, 1, 0.35, 0.65, App.g_kMainMenuBorderMainColor)
- pTacticalControlWindow.AddChild(pInfoWindow, 0.45, 0.05)
- pInfoWindow.SetNotVisible()
- pInfoWindow.AddPythonFuncHandlerForInstance(App.ET_MOUSE, __name__ + ".PassMouse")
- pInfoWindow.SetNotVisible()
- pInfoWindow.AddPythonFuncHandlerForInstance(ET_SCROLLUP, __name__ + ".ScrollUp")
- CreateWindowInterior1(pInfoWindow)
- return pInfoWindow"""
- # Create the interior windows of our GUI, also handle the number of cargo bays the ship will receive based on it's Rotational Inertia
- def CreateWindows(pCargoBayWindow):
- debug(__name__ + ", CreateWindows")
- global BayParts, TotalParts, pRadius, pGetSuppliesButton, pSendSuppliesButton, pReplicateButton
- global Bay1Parts, Bay2Parts, Bay3Parts, Bay4Parts, Bay5Parts, Bay6Parts, Bay7Parts, SetNumBays
- Bay1Parts = 14 #*pPlayer.GetRadius()
- Bay2Parts = 14
- Bay3Parts = 14
- Bay4Parts = 14
- Bay5Parts = 14
- Bay6Parts = 14
- Bay7Parts = 14
- BayParts = 0
- TotalParts = 0
- # TotalParts = Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts+Bay6Parts+Bay7Parts
- # This ship gets how many Cargo Bays? GetRotationalInertia ;)
- pPlayer = MissionLib.GetPlayer()
- # pCargo = pPlayer.GetProperty("Cargo Bay Control") #Unable to retrieve hull property at this time
- # pRotational = pCargo.GetMaxCondition()
- pRotational = pPlayer.GetRotationalInertia()
- pHull = pPlayer.GetHull()
- pRadius = pHull.GetRadius()
- if pRotational <= 2000: # Ship is too small for a cargo bay
- SetNumBays = 0
- CreateNullMenu(pCargoBayWindow)
- TotalParts = TotalParts #0
- BayParts = BayParts #0
- pMission = MissionLib.GetMission()
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CLOSE)
- pEvent.SetDestination(pMission)
- pEvent.SetInt(0)
- pCloseButton = App.STRoundedButton_CreateW(App.TGString("Close"), pEvent, 0.1, 0.02)
- pCloseButton.SetNormalColor(App.g_kMainMenuButtonColor)
- pCargoBayWindow.AddChild(pCloseButton, 0.01, 0.2, 0)
- pCargoBayWindow.InteriorChangedSize()
- pCargoBayWindow.Layout()
- return #End, get us out of here!
- if pRotational > 2000: # Create 1 cargo bay for now, until I can fix the display
- SetNumBays = 1
- CreateBayMenu(pCargoBayWindow) #Add a cargo bay
- TotalParts = (Bay1Parts)*pRadius
- BayParts = (TotalParts/SetNumBays)#*pRadius
- # return
- if pRotational > 30000: # 2
- SetNumBays = 2
- # CreateBayMenu(pCargoBayWindow) #Lets condense this code a little bit :)
- CreateBayMenu1(pCargoBayWindow) #Second bay now
- TotalParts = (Bay1Parts+Bay2Parts)*pRadius
- BayParts = (TotalParts/SetNumBays)#*pRadius
- # return
- if pRotational > 70000: # 3
- SetNumBays = 3
- CreateBayMenu2(pCargoBayWindow) #Third now
- TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts)*pRadius
- BayParts = (TotalParts/SetNumBays)#*pRadius
- # return
- if pRotational > 150000: # 4
- SetNumBays = 4
- CreateBayMenu3(pCargoBayWindow)
- TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts)*pRadius
- BayParts = (TotalParts/SetNumBays)#*pRadius
- # return
- if pRotational > 310000: # 5
- SetNumBays = 5
- CreateBayMenu4(pCargoBayWindow)
- TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts)*pRadius
- BayParts = (TotalParts/SetNumBays)#*pRadius
- # return
- if pRotational > 700000: # 6
- SetNumBays = 6
- CreateBayMenu5(pCargoBayWindow)
- TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts+Bay6Parts)*pRadius
- BayParts = (TotalParts/SetNumBays)#*pRadius
- # return
- if pRotational > 2000000: # 7
- SetNumBays = 7
- CreateBayMenu6(pCargoBayWindow)
- TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts+Bay6Parts+Bay7Parts)*pRadius
- BayParts = (TotalParts/SetNumBays)#*pRadius
- # return
- # Create these here, they now give us correct starting part number
- CreateInventoryMenu(pCargoBayWindow)
- CreateBodyMenu(pCargoBayWindow)
- CreatePartsTotalText(pCargoBayWindow)
- SpareParts(pCargoBayWindow)
- pMission = MissionLib.GetMission()
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CLOSE)
- pEvent.SetDestination(pMission)
- pEvent.SetInt(0)
- pCloseButton = App.STRoundedButton_CreateW(App.TGString("Close"), pEvent, 0.1, 0.02) # W, H ?
- pCloseButton.SetNormalColor(App.g_kMainMenuButtonColor)
- pCargoBayWindow.AddChild(pCloseButton, 0.01, 0.225, 0) # X, Y, ?
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_SEND_SUPPLIES) #SendSupplies
- pEvent.SetDestination(pMission)
- pEvent.SetInt(8)
- pSendSuppliesButton = App.STRoundedButton_CreateW(App.TGString("Send Supplies"), pEvent, 0.1, 0.02)
- pSendSuppliesButton.SetNormalColor(App.g_kMainMenuButtonColor)
- pCargoBayWindow.AddChild(pSendSuppliesButton, 0.01, 0.2, 0)
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_GET_SUPPLIES) #GetSupplies
- pEvent.SetDestination(pMission)
- pEvent.SetInt(9)
- pGetSuppliesButton = App.STRoundedButton_CreateW(App.TGString("Get Supplies"), pEvent, 0.1, 0.02)
- pGetSuppliesButton.SetNormalColor(App.g_kMainMenuButtonColor)
- pCargoBayWindow.AddChild(pGetSuppliesButton, 0.01, 0.175, 0)
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_REPLICATE_SUPPLIES) #ReplicateSupplies
- pEvent.SetDestination(pMission)
- pEvent.SetInt(10)
- pReplicateButton = App.STRoundedButton_CreateW(App.TGString("Replicate Supplies"), pEvent, 0.1, 0.02)
- pReplicateButton.SetNormalColor(App.g_kMainMenuButtonColor)
- pCargoBayWindow.AddChild(pReplicateButton, 0.01, 0.15, 0)
- pCargoBayWindow.InteriorChangedSize()
- pCargoBayWindow.Layout()
- """# 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()"""
- """# Setup the checks for if we can send supplies to our target
- def SendSupplies(pObject, pEvent):
- debug(__name__ + ", SendSupplies")
- pGame = App.Game_GetCurrentGame()
- pEpisode = pGame.GetCurrentEpisode()
- pMission = pEpisode.GetCurrentMission()
- pPlayer = MissionLib.GetPlayer()
- pTarget = pPlayer.GetTarget()
- pTargetCast = App.ShipClass_Cast(pPlayer.GetTarget())
- pTargetattr = App.ShipClass_Cast(pTarget)
- pFriendlies = pMission.GetFriendlyGroup()
- pEnemies = pMission.GetEnemyGroup()
- # Test Distance
- if (Distance(pTarget) > 300):
- 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
- if App.g_kUtopiaModule.IsMultiplayer() and pTargetattr.GetNetPlayerID() >= 0:
- print("This is a Player, don't Transport") #For now
- return
- # Test if our Target is friendly
- if (pFriendlies.IsNameInGroup(pTarget.GetName()) != 1):
- print("Target is not friendly...testing Shields")
- # but maybe neutral:
- if pMission.GetEnemyGroup().IsNameInGroup(pTarget.GetName()):
- print("Neither neutral :(")
- return
- pSound = App.TGSound_Create("sfx/Interface/new_game3.mp3", "Beaming", 0)
- pSound.SetSFX(0)
- pSound.SetInterface(1)
- App.g_kSoundManager.PlaySound("Beaming")"""
- """# Setup the checks for if we can send supplies to our target
- def SendSupplies(pObject, pEvent):
- debug(__name__ + ", SendSupplies")
- pSound = App.TGSound_Create("sfx/Interface/new_game3.mp3", "Beaming", 0)
- pSound.SetSFX(0)
- pSound.SetInterface(1)
- App.g_kSoundManager.PlaySound("Beaming")
- # Setup the checks for if we can get supplies from our target
- def GetSupplies(pObject, pEvent):
- debug(__name__ + ", GetSupplies")
- pSound = App.TGSound_Create("sfx/Interface/new_game2.mp3", "Warping", 0)
- pSound.SetSFX(0)
- pSound.SetInterface(1)
- App.g_kSoundManager.PlaySound("Warping")"""
- # Get the relevant Event Int
- def TransferSupplies(pObject, pEvent):
- debug(__name__ + ", TransferSupplies")
- pGame = App.Game_GetCurrentGame()
- pEpisode = pGame.GetCurrentEpisode()
- pMission = pEpisode.GetCurrentMission()
- pPlayer = MissionLib.GetPlayer()
- pTarget = pPlayer.GetTarget()
- # pTargetCast = App.ShipClass_Cast(pPlayer.GetTarget())
- # pTargetattr = App.ShipClass_Cast(pTarget)
- # pFriendlies = pMission.GetFriendlyGroup()
- # pEnemies = pMission.GetEnemyGroup()
- global SuppliesNum
- SuppliesNum = pEvent.GetInt()
- # Bay2Inventory(pInventoryMenu)
- pSendSuppliesButton.SetDisabled() #we must disable them all, otherwise we might end the cycle prematurely...
- pGetSuppliesButton.SetDisabled() #^
- pReplicateButton.SetDisabled() #^
- if SuppliesNum == 8:
- pBay1Text = App.TGParagraph_Create("\nSending supplies...")
- pInventoryMenu.AddChild(pBay1Text)
- pSendSuppliesTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".SentSupplies", App.g_kUtopiaModule.GetGameTime() + 5, 0, 0)
- # pSound = App.TGSound_Create("sfx/Interface/new_game3.mp3", "Beaming", 0)
- # pSound.SetSFX(0)
- # pSound.SetInterface(1)
- # App.g_kSoundManager.PlaySound("Beaming")
- elif SuppliesNum == 9:
- pBay2Text = App.TGParagraph_Create("\nGetting supplies...")
- pInventoryMenu.AddChild(pBay2Text)
- pGetSuppliesTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailSupplies", App.g_kUtopiaModule.GetGameTime() + 5, 0, 0)
- # pSound = App.TGSound_Create("sfx/Interface/new_game3.mp3", "Beaming", 0)
- # pSound.SetSFX(0)
- # pSound.SetInterface(1)
- # App.g_kSoundManager.PlaySound("Beaming")
- elif SuppliesNum == 10:
- pPower = pPlayer.GetPowerSubsystem()
- PowerOut = pPower.GetPowerOutput()
- MainConduit = pPower.GetMainConduitCapacity()
- MainBatteryPower = pPower.GetMainBatteryPower()
- MainBatteryLimit = pPower.GetMainBatteryLimit()
- ReserveConduit = pPower.GetBackupConduitCapacity()
- ReserveBatteryPower = pPower.GetBackupBatteryPower()
- ReserveBatteryLimit = pPower.GetBackupBatteryLimit()
- Transferenergy = MainBatteryLimit*0.1
- if MainBatteryPower <= 0.2:
- Bay2Inventory(pInventoryMenu)
- pInventoryMenu.ResizeToContents()
- return
- if MainBatteryPower > 0.2:
- pPower.SetMainBatteryPower(MainBatteryPower - Transferenergy)
- pBay2Text = App.TGParagraph_Create("\nReplicating supplies...")
- pInventoryMenu.AddChild(pBay2Text)
- pReplicateSuppliesTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".ReplicateSupplies", App.g_kUtopiaModule.GetGameTime() + 15, 0, 0)
- """ # Test Distance
- if (Distance(pTarget) > 300):
- 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
- if App.g_kUtopiaModule.IsMultiplayer() and pTargetattr.GetNetPlayerID() >= 0:
- print("This is a Player, don't Transport") #For now
- return
- # Test if our Target is friendly
- if (pFriendlies.IsNameInGroup(pTarget.GetName()) != 1):
- print("Target is not friendly...testing Shields")
- # but maybe neutral:
- if pMission.GetEnemyGroup().IsNameInGroup(pTarget.GetName()):
- print("Neither neutral :(")
- return"""
- def CreateNullMenu(pCargoBayWindow):
- debug(__name__ + ", CreateNullMenu")
- WIDTH = 0.1
- HEIGHT = 0.3
- X_POS = 0.01
- Y_POS = 0.01
- pBayMenu = App.STSubPane_Create(WIDTH, HEIGHT)
- pBay1Text = App.TGParagraph_Create("This vessel has no available storage bays.")
- pBayMenu.AddChild(pBay1Text)
- pBayMenu.ResizeToContents()
- pCargoBayWindow.AddChild(pBayMenu, X_POS, Y_POS)
- def CreateBayMenu(pCargoBayWindow):
- debug(__name__ + ", CreateBayMenu")
- # global CargoCapacity
- global BayParts, TotalParts
- WIDTH = 0.1
- HEIGHT = 0.3
- X_POS = 0.01
- Y_POS = 0.01
- pBayMenu = App.STSubPane_Create(WIDTH, HEIGHT)
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CATEGORY)
- pEvent.SetDestination(pCargoBayWindow)
- pEvent.SetInt(1)
- pBay1Button = App.STCharacterMenu_Create("Cargo Bay 1")
- pBay1Button.SetActivationEvent(pEvent)
- pBay1Button.SetNotOpenable()
- pBayMenu.AddChild(pBay1Button)
- pBayMenu.ResizeToContents()
- pCargoBayWindow.AddChild(pBayMenu, X_POS, Y_POS)
- def CreateBayMenu1(pCargoBayWindow):
- debug(__name__ + ", CreateBayMenu1")
- WIDTH = 0.1
- HEIGHT = 0.3
- X_POS = 0.01
- Y_POS = 0.03
- pBayMenu1 = App.STSubPane_Create(WIDTH, HEIGHT)
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CATEGORY)
- pEvent.SetDestination(pCargoBayWindow)
- pEvent.SetInt(2)
- pBay2Button = App.STCharacterMenu_Create("Cargo Bay 2")
- pBay2Button.SetActivationEvent(pEvent)
- pBay2Button.SetNotOpenable()
- pBayMenu1.AddChild(pBay2Button)
- pBayMenu1.ResizeToContents()
- pCargoBayWindow.AddChild(pBayMenu1, X_POS, Y_POS)
- def CreateBayMenu2(pCargoBayWindow):
- debug(__name__ + ", CreateBayMenu2")
- WIDTH = 0.1
- HEIGHT = 0.3
- X_POS = 0.01
- Y_POS = 0.049
- pBayMenu2 = App.STSubPane_Create(WIDTH, HEIGHT)
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CATEGORY)
- pEvent.SetDestination(pCargoBayWindow)
- pEvent.SetInt(3)
- pBay3Button = App.STCharacterMenu_Create("Cargo Bay 3")
- pBay3Button.SetActivationEvent(pEvent)
- pBay3Button.SetNotOpenable()
- pBayMenu2.AddChild(pBay3Button)
- pBayMenu2.ResizeToContents()
- pCargoBayWindow.AddChild(pBayMenu2, X_POS, Y_POS)
- def CreateBayMenu3(pCargoBayWindow):
- debug(__name__ + ", CreateBayMenu3")
- WIDTH = 0.1
- HEIGHT = 0.3
- X_POS = 0.01
- Y_POS = 0.0685
- pBayMenu3 = App.STSubPane_Create(WIDTH, HEIGHT)
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CATEGORY)
- pEvent.SetDestination(pCargoBayWindow)
- pEvent.SetInt(4)
- pBay4Button = App.STCharacterMenu_Create("Cargo Bay 4")
- pBay4Button.SetActivationEvent(pEvent)
- pBay4Button.SetNotOpenable()
- pBayMenu3.AddChild(pBay4Button)
- pBayMenu3.ResizeToContents()
- pCargoBayWindow.AddChild(pBayMenu3, X_POS, Y_POS)
- def CreateBayMenu4(pCargoBayWindow):
- debug(__name__ + ", CreateBayMenu4")
- WIDTH = 0.1
- HEIGHT = 0.3
- X_POS = 0.01
- Y_POS = 0.088
- pBayMenu4 = App.STSubPane_Create(WIDTH, HEIGHT)
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CATEGORY)
- pEvent.SetDestination(pCargoBayWindow)
- pEvent.SetInt(5)
- pBay5Button = App.STCharacterMenu_Create("Cargo Bay 5")
- pBay5Button.SetActivationEvent(pEvent)
- pBay5Button.SetNotOpenable()
- pBayMenu4.AddChild(pBay5Button)
- pBayMenu4.ResizeToContents()
- pCargoBayWindow.AddChild(pBayMenu4, X_POS, Y_POS)
- def CreateBayMenu5(pCargoBayWindow):
- debug(__name__ + ", CreateBayMenu5")
- WIDTH = 0.1
- HEIGHT = 0.3
- X_POS = 0.01
- Y_POS = 0.107
- pBayMenu5 = App.STSubPane_Create(WIDTH, HEIGHT)
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CATEGORY)
- pEvent.SetDestination(pCargoBayWindow)
- pEvent.SetInt(6)
- pBay6Button = App.STCharacterMenu_Create("Cargo Bay 6")
- pBay6Button.SetActivationEvent(pEvent)
- pBay6Button.SetNotOpenable()
- pBayMenu5.AddChild(pBay6Button)
- pBayMenu5.ResizeToContents()
- pCargoBayWindow.AddChild(pBayMenu5, X_POS, Y_POS)
- def CreateBayMenu6(pCargoBayWindow):
- debug(__name__ + ", CreateBayMenu6")
- WIDTH = 0.1
- HEIGHT = 0.3
- X_POS = 0.01
- Y_POS = 0.127
- pBayMenu6 = App.STSubPane_Create(WIDTH, HEIGHT)
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CATEGORY)
- pEvent.SetDestination(pCargoBayWindow)
- pEvent.SetInt(7)
- pBay7Button = App.STCharacterMenu_Create("Cargo Bay 7")
- pBay7Button.SetActivationEvent(pEvent)
- pBay7Button.SetNotOpenable()
- pBayMenu6.AddChild(pBay7Button)
- pBayMenu6.ResizeToContents()
- pCargoBayWindow.AddChild(pBayMenu6, X_POS, Y_POS)
- def CreateInventoryMenu(pCargoBayWindow):
- debug(__name__ + ", CreateInventoryMenu")
- global pInventoryMenu
- WIDTH = 0.2
- HEIGHT = 0.25
- X_POS = 0.13
- Y_POS = 0.01
- pInventoryMenu = App.STSubPane_Create(WIDTH, HEIGHT)
- pCargoBayWindow.AddChild(pInventoryMenu, X_POS, Y_POS)
- pHeader = App.TGParagraph_Create("Inventory Menu")
- pInventoryMenu.AddChild(pHeader)
- pHeader1 = App.TGParagraph_Create("\nParts Total: " + str(TotalParts)) #Total count
- pInventoryMenu.AddChild(pHeader1)
- def CreateBodyMenu(pCargoBayWindow):
- debug(__name__ + ", CreateBodyMenu")
- global pBodyMenu, pButton1, pButton2, pButton3, pButton4, pButton5, pButton6, pButtonD1, pPartsText
- WIDTH = 0.2
- HEIGHT = 0.35
- X_POS = 0.25
- Y_POS = 0.01
- pBrexMenu = Lib.LibEngineering.GetBridgeMenu("Engineering")
- pBodyMenu = App.STSubPane_Create(WIDTH, HEIGHT)
- pCargoBayWindow.AddChild(pBodyMenu, X_POS, Y_POS)
- pMain = App.STMenu_CreateW(App.TGString("Rebuild Destroyed Systems"))
- pBodyMenu.AddChild(pMain)
- pMain.Open()
- pMain.SetNotCloseable()
- # pButton6 = Lib.LibEngineering.CreateMenuButton("Request Spare Parts Resupply", "Engineering", __name__ + ".AddTimer", 0, pMain)
- # pAvailablePartsButton = Lib.LibEngineering.CreateMenuButton("Parts Count: " + str(BayParts), "Engineering", __name__ + ".Nothing", 0, pBodyMenu)
- pButtonD1 = Lib.LibEngineering.CreateMenuButton("Destroy Systems Test", "Engineering", __name__ + ".BlowSystems", 0, pMain)
- pButton5 = Lib.LibEngineering.CreateMenuButton("Impulse Engines: 10 Parts", "Engineering", __name__ + ".Impulse", 0, pMain)
- pButton4 = Lib.LibEngineering.CreateMenuButton("Shield Generator: 5 Parts", "Engineering", __name__ + ".Shields", 0, pMain)
- pButton3 = Lib.LibEngineering.CreateMenuButton("Sensor Array: 10 Parts", "Engineering", __name__ + ".Sensors", 0, pMain)
- pButton2 = Lib.LibEngineering.CreateMenuButton("Warp Engines: 20 Parts", "Engineering", __name__ + ".WarpE", 0, pMain)
- pButton1 = Lib.LibEngineering.CreateMenuButton("Warp Core: 10 Parts", "Engineering", __name__ + ".Core", 0, pMain)
- def CreatePartsTotalText(pCargoBayWindow):
- debug(__name__ + ", CreatePartsTotalText")
- pPartsText = App.TGParagraph_Create("\nParts Total: " + str(TotalParts))
- pBodyMenu.AddChild(pPartsText)
- # SpareParts(pCargoBayWindow)
- def CreatePartsInBayText(pCargoBayWindow):
- debug(__name__ + ", CreatePartsInBayText")
- pPartsInBayText = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n\n")
- pBodyMenu.AddChild(pPartsInBayText)
- def SelectCategory(pObject, pEvent): #ET_CATEGORY
- debug(__name__ + ", SelectCategory")
- global CargoBayNum, pPartsInBay1, pPartsInBay2, pPartsInBay3, pPartsInBay4, pPartsInBay5, pPartsInBay6, pPartsInBay7
- CargoBayNum = pEvent.GetInt()
- if CargoBayNum and pInventoryMenu:
- pInventoryMenu.KillChildren()
- pBodyMenu.KillChildren()
- if CargoBayNum == 1:
- pBay1Text = App.TGParagraph_Create("Inventory: Cargo Bay 1")
- pInventoryMenu.AddChild(pBay1Text)
- pPartsInBay1 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n") #dirty workaround to get the button near the bottom
- pInventoryMenu.AddChild(pPartsInBay1)
- # Bay1Inventory(pInventoryMenu) #Need to remove this from here and link it to our Get/Send Supplies button (we can't)
- # CreateBodyMenu(pCargoBayWindow)
- elif CargoBayNum == 2:
- pBay2Text = App.TGParagraph_Create("Inventory: Cargo Bay 2")
- pInventoryMenu.AddChild(pBay2Text)
- pPartsInBay2 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
- pInventoryMenu.AddChild(pPartsInBay2)
- # Bay2Inventory(pInventoryMenu)#
- # CreateBodyMenu(pCargoBayWindow)
- elif CargoBayNum == 3:
- pBay3Text = App.TGParagraph_Create("Inventory: Cargo Bay 3")
- pInventoryMenu.AddChild(pBay3Text)
- pPartsInBay3 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
- pInventoryMenu.AddChild(pPartsInBay3)
- # Bay2Inventory(pInventoryMenu)#
- # CreateBodyMenu(pCargoBayWindow)
- elif CargoBayNum == 4:
- pBay4Text = App.TGParagraph_Create("Inventory: Cargo Bay 4")
- pInventoryMenu.AddChild(pBay4Text)
- pPartsInBay4 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
- pInventoryMenu.AddChild(pPartsInBay4)
- # Bay2Inventory(pInventoryMenu)#
- # CreateBodyMenu(pCargoBayWindow)
- elif CargoBayNum == 5:
- pBay5Text = App.TGParagraph_Create("Inventory: Cargo Bay 5")
- pInventoryMenu.AddChild(pBay5Text)
- pPartsInBay5 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
- pInventoryMenu.AddChild(pPartsInBay5)
- # Bay2Inventory(pInventoryMenu)#
- # CreateBodyMenu(pCargoBayWindow)
- elif CargoBayNum == 6:
- pBay6Text = App.TGParagraph_Create("Inventory: Cargo Bay 6")
- pInventoryMenu.AddChild(pBay6Text)
- pPartsInBay6 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
- pInventoryMenu.AddChild(pPartsInBay6)
- # Bay2Inventory(pInventoryMenu)#
- # CreateBodyMenu(pCargoBayWindow)
- elif CargoBayNum == 7:
- pBay7Text = App.TGParagraph_Create("Inventory: Cargo Bay 7")
- pInventoryMenu.AddChild(pBay7Text)
- pPartsInBay7 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
- pInventoryMenu.AddChild(pPartsInBay7)
- # Bay2Inventory(pInventoryMenu)#
- # CreateBodyMenu(pCargoBayWindow)
- else:
- CreateBodyMenu(pCargoBayWindow)
- CreatePartsTotalText(pCargoBayWindow)
- SpareParts(pCargoBayWindow)
- CreateBodyMenu(pCargoBayWindow)
- CreatePartsTotalText(pCargoBayWindow)
- SpareParts(pCargoBayWindow)
- # Bay2Inventory(pInventoryMenu)
- pInventoryMenu.ResizeToContents()
- def UpdateQty(pObject, pEvent): #
- debug(__name__ + ", UpdateQty")
- global QtyType, pPartsInBay1, pPartsInBay2, pPartsInBay3, pPartsInBay4, pPartsInBay5, pPartsInBay6, pPartsInBay7, TotalParts, pPartsInBay
- # Bay2Inventory(pInventoryMenu)
- QtyType = pEvent.GetInt()
- if QtyType and pInventoryMenu:
- pInventoryMenu.KillChildren()
- pBodyMenu.KillChildren() #We might not need this if we call CreateBodyMenu(pCargoBayWindow) early on or in a different menu...
- if QtyType == 30: #Add
- return
- if QtyType == 31: #Confirm
- pPartsInBay = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
- pInventoryMenu.AddChild(pPartsInBay)
- pSendSuppliesButton.SetEnabled()
- pGetSuppliesButton.SetEnabled()
- pReplicateButton.SetEnabled()
- CreateBodyMenu(pCargoBayWindow)
- CreatePartsTotalText(pCargoBayWindow) #Create parts added to each bay text instead
- SpareParts(pCargoBayWindow)
- # Bay2Inventory(pInventoryMenu)
- def Bay1Inventory(pInventoryMenu):
- debug(__name__ + ", Bay1Inventory")
- global pConfirm
- pCargoBayWindow = GetCargoBayWindow()
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_ADD_QTY)
- pEvent.SetDestination(pInventoryMenu)
- pEvent.SetInt(30)
- pAddQty = App.STRoundedButton_CreateW(App.TGString("Add Quantity:"), pEvent, 0.05, 0.02) # W, H ?
- pAddQty.SetNormalColor(App.g_kMainMenuButtonColor)
- pInventoryMenu.AddChild(pAddQty, 0.25, 0.2, 0) # X, Y, ?
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CONFIRM)
- pEvent.SetDestination(pInventoryMenu)
- pEvent.SetInt(31)
- pConfirm = App.STRoundedButton_CreateW(App.TGString("Confirm"), pEvent, 0.05, 0.02) # W, H ?
- pConfirm.SetNormalColor(App.g_kMainMenuButtonColor)
- pInventoryMenu.AddChild(pConfirm, 0.175, 0.2, 0) # X, Y, ?
- def Bay2Inventory(pInventoryMenu):
- debug(__name__ + ", Bay2Inventory")
- pCargoBayWindow = GetCargoBayWindow()
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_ADD_QTY)
- pEvent.SetDestination(pInventoryMenu)
- pEvent.SetInt(30)
- pAddQty = App.STRoundedButton_CreateW(App.TGString("Add Quantity:"), pEvent, 0.05, 0.02) # W, H ?
- pAddQty.SetNormalColor(App.g_kMainMenuButtonColor)
- pInventoryMenu.AddChild(pAddQty, 0.25, 0.2, 0) # X, Y, ?
- pEvent = App.TGIntEvent_Create()
- pEvent.SetEventType(ET_CONFIRM)
- pEvent.SetDestination(pInventoryMenu)
- pEvent.SetInt(31)
- pConfirm = App.STRoundedButton_CreateW(App.TGString("Confirm"), pEvent, 0.05, 0.02) # W, H ?
- pConfirm.SetNormalColor(App.g_kMainMenuButtonColor)
- pInventoryMenu.AddChild(pConfirm, 0.175, 0.2, 0) # X, Y, ?
- #############################################################################################
- # #
- # This Section Handles Repairs to the Destroyed Warp Core, #
- # #
- # #
- # #
- #############################################################################################
- def Core(pObject, pEvent):
- global BayParts, AvailPartsTimer #, BayParts
- if BayParts < 10:
- pButton1.SetDisabled()
- pPlayer = MissionLib.GetPlayer()
- pPowerSys = pPlayer.GetPowerSubsystem()
- if pPowerSys:
- pPowerHealth = pPowerSys.GetCondition()
- if (pPowerHealth > 0):
- return
- AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailCoreParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
- pPlayer = MissionLib.GetPlayer()
- pShipSet = pPlayer.GetPropertySet()
- pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
- iNumItems = pShipList.TGGetNumItems()
- pShipList.TGBeginIteration()
- for i in range(iNumItems):
- pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
- pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
- pPower = pPlayer.GetPowerSubsystem()
- pPower.SetCondition(pSubsystem.GetMaxCondition())
- pPower.SetCondition(1)
- def AvailCoreParts(pObject, pEvent):
- global BayParts, TotalParts, pAvailablePartsButton #, BayParts
- BayParts = BayParts - 10
- TotalParts = TotalParts - 10
- # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
- # pBodyMenu.DeleteChild(pPartsText)
- # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
- # pBodyMenu.AddChild(pPartsText)
- pInventoryMenu.KillChildren()
- # pBodyMenu.KillChildren()
- # CreateBodyMenu(pCargoBayWindow) #recreate buttons
- CreatePartsTotalText(pCargoBayWindow) #update part total
- SpareParts(pCargoBayWindow)
- SelectCategory()
- # CreateInventoryMenu(pCargoBayWindow)
- return 0
- #############################################################################################
- # #
- # This Section Handles Repairs to the Destroyed Shield Generators, #
- # #
- # #
- # #
- #############################################################################################
- def Shields(pObject, pEvent):
- if BayParts < 5:
- pButton4.SetDisabled()
- pPlayer = MissionLib.GetPlayer()
- pShieldSys = pPlayer.GetShields()
- if pShieldSys:
- pShieldHealth = pShieldSys.GetCondition()
- if (pShieldHealth > 0):
- return
- AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailShieldParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
- pShipSet = pPlayer.GetPropertySet()
- pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
- iNumItems = pShipList.TGGetNumItems()
- pShipList.TGBeginIteration()
- for i in range(iNumItems):
- pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
- pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
- pShield = pPlayer.GetShields()
- pShield.SetCondition(1)
- def AvailShieldParts(pObject, pEvent):
- global BayParts, TotalParts, pAvailablePartsButton, pPartsText #, BayParts
- BayParts = BayParts - 5
- TotalParts = TotalParts - 5
- # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
- # pBodyMenu.DeleteChild(pPartsText)
- # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
- # pBodyMenu.AddChild(pPartsText)
- pInventoryMenu.KillChildren()
- # pBodyMenu.KillChildren()
- # CreateBodyMenu(pCargoBayWindow)
- CreatePartsTotalText(pCargoBayWindow) #update part total
- SpareParts(pCargoBayWindow)
- SelectCategory()
- # CreateInventoryMenu(pCargoBayWindow)
- return 0
- #############################################################################################
- # #
- # This Section Handles Repairs to the Destroyed Sensor Array, #
- # #
- # #
- # #
- #############################################################################################
- def Sensors(pObject, pEvent):
- global BayParts, AvailPartsTimer #, BayParts
- if BayParts < 10:
- pButton3.SetDisabled()
- pPlayer = MissionLib.GetPlayer()
- pSensors = pPlayer.GetSensorSubsystem()
- if pSensors:
- pSensorHealth = pSensors.GetCondition()
- if (pSensorHealth > 0):
- return
- AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailSensorParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
- pShipSet = pPlayer.GetPropertySet()
- pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
- iNumItems = pShipList.TGGetNumItems()
- pShipList.TGBeginIteration()
- for i in range(iNumItems):
- pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
- pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
- pSensors.SetCondition(pSubsystem.GetMaxCondition())
- pSensors.SetCondition(1)
- def AvailSensorParts(pObject, pEvent):
- global BayParts, TotalParts, pAvailablePartsButton #, BayParts
- BayParts = BayParts - 5
- TotalParts = TotalParts - 5
- # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
- # pBodyMenu.DeleteChild(pPartsText)
- # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
- # pBodyMenu.AddChild(pPartsText)
- pInventoryMenu.KillChildren()
- # pBodyMenu.KillChildren()
- # CreateBodyMenu(pCargoBayWindow)
- CreatePartsTotalText(pCargoBayWindow)
- SpareParts(pCargoBayWindow)
- SelectCategory()
- # CreateInventoryMenu(pCargoBayWindow)
- return 0
- #############################################################################################
- # #
- # This Section Handles Repairs to the Destroyed Warp Engines, #
- # #
- # #
- # #
- #############################################################################################
- def Impulse(pObject, pEvent):
- global BayParts, AvailPartsTimer #, BayParts
- if BayParts < 20:
- pButton5.SetDisabled()
- pPlayer = MissionLib.GetPlayer()
- pImpulseSys = pPlayer.GetImpulseEngineSubsystem()
- if pImpulseSys:
- iNumImpulse = pImpulseSys.GetNumChildSubsystems()
- for iEng in range(iNumImpulse):
- pImpulseChild = pImpulseSys.GetChildSubsystem(iEng)
- if pImpulseChild:
- pImpulseChildCondition = pImpulseChild.GetCondition()
- pImpulseChildMaxCondition = pImpulseChild.GetMaxCondition()
- if (pImpulseChildCondition > 0):
- return
- AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailImpulseParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
- pShipSet = pPlayer.GetPropertySet()
- pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
- iNumItems = pShipList.TGGetNumItems()
- pShipList.TGBeginIteration()
- for i in range(iNumItems):
- pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
- pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
- pImpulseSys = pPlayer.GetImpulseEngineSubsystem()
- if pImpulseSys:
- iNumImpulse = pImpulseSys.GetNumChildSubsystems()
- for iEng in range(iNumImpulse):
- pImpulseChild = pImpulseSys.GetChildSubsystem(iEng)
- pImpulseChild.SetCondition(1)
- def AvailImpulseParts(pObject, pEvent):
- global BayParts, TotalParts, pAvailablePartsButton #, BayParts
- BayParts = BayParts - 10
- TotalParts = TotalParts - 10
- # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
- # pBodyMenu.DeleteChild(pPartsText)
- # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
- # pBodyMenu.AddChild(pPartsText)
- pInventoryMenu.KillChildren()
- # pBodyMenu.KillChildren()
- # CreateBodyMenu(pCargoBayWindow)
- CreatePartsTotalText(pCargoBayWindow)
- SpareParts(pCargoBayWindow)
- SelectCategory()
- # CreateInventoryMenu(pCargoBayWindow)
- return 0
- #############################################################################################
- # #
- # This Section Handles Repairs to the Destroyed Impulse Engines, #
- # #
- # #
- # #
- #############################################################################################
- #
- def WarpE(pObject, pEvent):
- if BayParts < 20:
- pButton2.SetDisabled()
- pPlayer = MissionLib.GetPlayer()
- pWarpSys = pPlayer.GetWarpEngineSubsystem()
- if pWarpSys:
- iNumWarp = pWarpSys.GetNumChildSubsystems()
- for iEng in range(iNumWarp):
- pWarpChild = pWarpSys.GetChildSubsystem(iEng)
- if pWarpChild:
- pWarpChildCondition = pWarpChild.GetCondition()
- pWarpChildMaxCondition = pWarpChild.GetMaxCondition()
- if (pWarpChildCondition > 0):
- return
- AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailWCoilsParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
- pShipSet = pPlayer.GetPropertySet()
- pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
- iNumItems = pShipList.TGGetNumItems()
- pShipList.TGBeginIteration()
- for i in range(iNumItems):
- pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
- pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
- pWarpSys = pPlayer.GetWarpEngineSubsystem()
- if pWarpSys:
- iNumWarp = pWarpSys.GetNumChildSubsystems()
- for iEng in range(iNumWarp):
- pWarpChild = pWarpSys.GetChildSubsystem(iEng)
- pWarpChild.SetCondition(1)
- def AvailWCoilsParts(pObject, pEvent):
- global BayParts, TotalParts, pAvailablePartsButton #, BayParts
- BayParts = BayParts - 20
- TotalParts = TotalParts - 20
- # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
- # pBodyMenu.DeleteChild(pPartsText)
- # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
- # pBodyMenu.AddChild(pPartsText)
- pInventoryMenu.KillChildren()
- # pBodyMenu.KillChildren()
- # CreateBodyMenu(pCargoBayWindow)
- CreatePartsTotalText(pCargoBayWindow)
- SpareParts(pCargoBayWindow)
- SelectCategory()
- # CreateInventoryMenu(pCargoBayWindow)
- return 0
- #############################################################################################
- # #
- # This Section Destroys The Systems This is Purely For Testing Purposes, #
- # I have Kept these controls in incase you would like to test this mod the quick way #
- # #
- # #
- #############################################################################################
- def BlowSystems(pObject, pEvent):
- pPlayer = MissionLib.GetPlayer()
- pShipSet = pPlayer.GetPropertySet()
- pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
- iNumItems = pShipList.TGGetNumItems()
- pShipList.TGBeginIteration()
- for i in range(iNumItems):
- pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
- pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
- pPower = pPlayer.GetPowerSubsystem()
- pPower.SetCondition(0)
- pShields = pPlayer.GetShields()
- pShields.SetCondition(0)
- pSensors = pPlayer.GetSensorSubsystem()
- pSensors.SetCondition(0)
- pWarpSys = pPlayer.GetWarpEngineSubsystem()
- if pWarpSys:
- iNumWarp = pWarpSys.GetNumChildSubsystems()
- for iEng in range(iNumWarp):
- pWarpChild = pWarpSys.GetChildSubsystem(iEng)
- pWarpChild.SetCondition(0)
- pImpulseSys = pPlayer.GetImpulseEngineSubsystem()
- if pImpulseSys:
- iNumImpulse = pImpulseSys.GetNumChildSubsystems()
- for iEng in range(iNumImpulse):
- pImpulseChild = pImpulseSys.GetChildSubsystem(iEng)
- pImpulseChild.SetCondition(0)
- ##########################################################################################
- # #
- # #
- # Everything Below This Point simply handles the Media and veiwscreens DO NOT EDIT #
- # #
- # #
- ##########################################################################################
- def AddTimer (pObject, pEvent):
- # Play the sound
- pSound = App.TGSound_Create("sfx/Custom/RepairSystem/IncomingMsgLuiOS.wav", "Lui_OS", 2)
- pSound.SetSFX(0)
- pSound.SetInterface(1)
- App.g_kSoundManager.PlaySound("Lui_OS")
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".Briefing", App.g_kUtopiaModule.GetGameTime() + 3, 0, 0)
- def Briefing (pObject, pEvent):
- pLiuSet = MissionLib.SetupBridgeSet("LiuSet", "data/Models/Sets/StarbaseControl/starbasecontrolRM.nif", -40, 65, -1.55)
- pLiu = App.CharacterClass_GetObject(pLiuSet, "Liu")
- if not (pLiu):
- pLiu = MissionLib.SetupCharacter("Bridge.Characters.Admiral_Liu", "LiuSet", 0, 0, 5)
- pSeq = MissionLib.NewDialogueSequence()
- pAction = App.TGScriptAction_Create("MissionLib", "ViewscreenOn", "LiuSet", "Liu", 200)
- pSeq.AppendAction(pAction)
- MissionLib.QueueActionToPlay(pSeq)
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".PlayLuiCommuniq", App.g_kUtopiaModule.GetGameTime() + 2, 0, 0)
- def PlayLuiCommuniq (pObject, pEvent):
- pSound1 = App.TGSound_Create("sfx/Custom/RepairSystem/IncomingMsgLuiOS2a.wav", "Lui_OS2", 2)
- pSound1.SetSFX(0)
- pSound1.SetInterface(1)
- pAction = App.g_kSoundManager.PlaySound("Lui_OS2")
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".EndLuiComuniq", App.g_kUtopiaModule.GetGameTime() + 12, 0, 0)
- def EndLuiComuniq (pObject, pEvent):
- pSeq = MissionLib.NewDialogueSequence()
- pAction = App.TGScriptAction_Create("MissionLib", "ViewscreenOff")
- pSeq.AppendAction(pAction)
- MissionLib.QueueActionToPlay(pSeq)
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".DamReport", App.g_kUtopiaModule.GetGameTime() + 2, 0, 0)
- def DamReport (pObject, pEvent):
- pSound1 = App.TGSound_Create("sfx/Custom/RepairSystem/Damage.wav", "Lui_OS2", 2)
- pSound1.SetSFX(0)
- pSound1.SetInterface(1)
- pAction = App.g_kSoundManager.PlaySound("Lui_OS2")
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".WarpIn", App.g_kUtopiaModule.GetGameTime() + 180
- , 0, 0)
- def WarpIn (pObject, pEvent):
- global AddshipTimer
- pPlayer = MissionLib.GetPlayer()
- pEnemyGroup = MissionLib.GetEnemyGroup()
- pSet = pPlayer.GetContainingSet()
- pTransportX = loadspacehelper.CreateShip("Transport", pSet, "SS Calgary", "", 300 )
- pTransportX.SetInvincible(1)
- vImpPoint = App.TGPoint3()
- vImpPoint.SetXYZ(0, 1, 0)
- pTransportX.SetImpulse(.1, vImpPoint, App.ShipClass.DIRECTION_MODEL_SPACE)
- global pFriendlies
- pMission = MissionLib.GetMission()
- pFriendlies = pMission.GetFriendlyGroup()
- pFriendlies.AddName("SS Calgary")
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".SotoOnScreen", App.g_kUtopiaModule.GetGameTime() + 10, 0, 0)
- def SotoOnScreen (pObject, pEvent):
- pEBridgeSet = MissionLib.SetupBridgeSet("EBridgeSet", "data/Models/Sets/EBridge/EBridge.nif", 0, 0, 0)
- pSoto = App.CharacterClass_GetObject(pEBridgeSet, "Soto")
- if not (pSoto):
- pSoto = MissionLib.SetupCharacter("Bridge.Characters.Soto", "EBridgeSet", 0, 0, 0)
- pSeq = MissionLib.NewDialogueSequence()
- pAction = App.TGScriptAction_Create("MissionLib", "ViewscreenOn", "EBridgeSet", "Soto", -0, 0, 0)
- pSeq.AppendAction(pAction)
- MissionLib.QueueActionToPlay(pSeq)
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".GraffCall", App.g_kUtopiaModule.GetGameTime() + 2, 0, 0)
- def GraffCall (pObject, pEvent):
- pSound1 = App.TGSound_Create("sfx/Custom/RepairSystem/Graffhail1.wav", "Graff_OS1", 2)
- pSound1.SetSFX(0)
- pSound1.SetInterface(1)
- pAction = App.g_kSoundManager.PlaySound("Graff_OS1")
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".EndGraffComuniq", App.g_kUtopiaModule.GetGameTime() + 12, 0, 0)
- def EndGraffComuniq (pObject, pEvent):
- pSeq = MissionLib.NewDialogueSequence()
- pAction = App.TGScriptAction_Create("MissionLib", "ViewscreenOff")
- pSeq.AppendAction(pAction)
- MissionLib.QueueActionToPlay(pSeq)
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BrexReady", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
- def BrexReady (pObject, pEvent):
- pSound1 = App.TGSound_Create("sfx/Custom/RepairSystem/ReadyForSupplies.wav", "Graff_OSX", 2)
- pSound1.SetSFX(0)
- pSound1.SetInterface(1)
- pAction = App.g_kSoundManager.PlaySound("Graff_OSX")
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".LowerShields", App.g_kUtopiaModule.GetGameTime() + 6, 0, 0)
- def LowerShields (pObject, pEvent):
- pPlayer = MissionLib.GetPlayer()
- pShields = pPlayer.GetShields()
- if (pShields.IsOn() and not pShields.IsDisabled()):
- pGame = App.Game_GetCurrentGame()
- pEpisode = pGame.GetCurrentEpisode()
- pMission = pEpisode.GetCurrentMission()
- Database = pMission.SetDatabase("data/TGL/Bridge Crew General.tgl")
- pSequence = App.TGSequence_Create()
- pSet = App.g_kSetManager.GetSet("bridge")
- pEngineer = App.CharacterClass_GetObject(pSet, "Engineer")
- pSequence.AppendAction(App.CharacterAction_Create(pEngineer, App.CharacterAction.AT_SAY_LINE, "LoweringShields", None, 0, Database))
- pSequence.AppendAction(App.TGScriptAction_Create("Actions.ShipScriptActions", "FlickerShields", 0, 10))
- pSequence.Play()
- # play the transport sound no matter if shields are online or not
- Sound = App.TGSound_Create("sfx/Custom/RepairSystem/Transport.wav", "Transport", 0)
- Sound.SetSFX(0)
- Sound.SetInterface(1)
- App.g_kSoundManager.PlaySound("Transport")
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".IncreaseParts", App.g_kUtopiaModule.GetGameTime() + 12, 0, 0)
- def IncreaseParts (pObject, pEvent):
- Sound = App.TGSound_Create("sfx/Custom/RepairSystem/TransferSupplies.wav", "Transport8", 0)
- Sound.SetSFX(0)
- Sound.SetInterface(1)
- App.g_kSoundManager.PlaySound("Transport8")
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".WarpOut", App.g_kUtopiaModule.GetGameTime() + 5, 0, 0)
- def WarpOut(pObject, pEvent):
- pGame = App.Game_GetCurrentGame()
- pEpisode = pGame.GetCurrentEpisode()
- pMission = pEpisode.GetCurrentMission()
- pPlayer = MissionLib.GetPlayer()
- pSet = pPlayer.GetContainingSet()
- pTransortX = App.ShipClass_GetObject(pSet, "SS Calgary")
- import AI.PlainAI.WarpAI
- pTransortX.SetAI(AI.PlainAI.WarpAI.CreateAI(pTransortX))
- AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailSupplies", App.g_kUtopiaModule.GetGameTime() + 2, 0, 0)
- def AvailSupplies(pObject, pEvent):
- global BayParts, pAvailablePartsButton, TotalParts
- BayParts = BayParts + 10
- TotalParts = TotalParts + 10
- # pGetSuppliesButton.SetEnabled()
- Bay2Inventory(pInventoryMenu)
- pInventoryMenu.ResizeToContents()
- # pAvailablePartsButton.SetName(App.TGString("Parts Count: " + str(BayParts)))
- return 0
- def SentSupplies(pObject, pEvent):
- global BayParts, pAvailablePartsButton, TotalParts
- BayParts = BayParts - 10
- TotalParts = TotalParts - 10
- # pSendSuppliesButton.SetEnabled()
- Bay2Inventory(pInventoryMenu)
- pInventoryMenu.ResizeToContents()
- # pAvailablePartsButton.SetName(App.TGString("Parts Count: " + str(BayParts)))
- return 0
- def ReplicateSupplies(pObject, pEvent):
- global BayParts, pAvailablePartsButton, TotalParts
- pPlayer = MissionLib.GetPlayer()
- pPower = pPlayer.GetPowerSubsystem()
- PowerOut = pPower.GetPowerOutput()
- MainConduit = pPower.GetMainConduitCapacity()
- MainBatteryPower = pPower.GetMainBatteryPower()
- MainBatteryLimit = pPower.GetMainBatteryLimit()
- ReserveConduit = pPower.GetBackupConduitCapacity()
- ReserveBatteryPower = pPower.GetBackupBatteryPower()
- ReserveBatteryLimit = pPower.GetBackupBatteryLimit()
- Transferenergy = MainBatteryLimit*0.1
- if MainBatteryPower <= 0.2:
- Bay2Inventory(pInventoryMenu)
- pInventoryMenu.ResizeToContents()
- return
- if MainBatteryPower > 0.2:
- pPower.SetMainBatteryPower(MainBatteryPower - Transferenergy)
- BayParts = BayParts + 5
- TotalParts = TotalParts + 5
- # pSendSuppliesButton.SetEnabled()
- Bay2Inventory(pInventoryMenu)
- pInventoryMenu.ResizeToContents()
- # pAvailablePartsButton.SetName(App.TGString("Parts Count: " + str(BayParts)))
- return 0
- def RecycleSupplies(pObject, pEvent):
- global BayParts, pAvailablePartsButton, TotalParts
- BayParts = BayParts - 5
- TotalParts = TotalParts - 5
- # pSendSuppliesButton.SetEnabled()
- Bay2Inventory(pInventoryMenu)
- pInventoryMenu.ResizeToContents()
- # pAvailablePartsButton.SetName(App.TGString("Parts Count: " + str(BayParts)))
- return 0
- # IDK whats going on here, but I want the window to close when the ship explodes and reset our cargo bays when ET_SET_PLAYER is triggered
- # It seems I always have problems with this *sigh*
- def CheckShip(pObject, pEvent): #ET_SET_PLAYER
- # This little bit of scripting checks when the player ship changes
- pGame = App.Game_GetCurrentGame()
- pPlayer = pGame.GetPlayer()
- pPlayerName = pPlayer.GetName()
- pCargoBayWindow = GetCargoBayWindow()
- pWarpCore = pPlayer.GetPowerSubsystem()
- if pCargoBayWindow:
- pBayButtons.SetVisible()
- pCargoBayWindow.SetNotVisible()
- ResetBayCount(None, None)
- return
- else:
- pBayButtons.SetVisible()
- pCargoBayWindow.SetNotVisible()
- ResetBayCount(None, None)
- def ShipExploding(pObject, pEvent):
- # global CheckDef, pButtonSI, pSpecial
- pPlayer = App.Game_GetCurrentGame().GetPlayer()
- pCargoBayWindow = GetCargoBayWindow()
- # 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.
- WindowClose(None, None) #close this crap, otherwise bad thing :[
- def ResetBayCount(pObject, pEvent):
- debug(__name__ + ", ResetBayCount")
- # global CreateBayGUI, CreateWindows
- pGame = App.Game_GetCurrentGame()
- pEpisode = pGame.GetCurrentEpisode()
- pMission = pEpisode.GetCurrentMission()
- pCargoBayWindow = GetCargoBayWindow()
- # delete enable button timer
- try:
- App.g_kTimerManager.DeleteTimer(pSendSuppliesTimer.GetObjID())
- App.g_kRealtimeTimerManager.DeleteTimer(pSendSuppliesTimer.GetObjID())
- pSendSuppliesTimer = None
- App.g_kTimerManager.DeleteTimer(pGetSuppliesTimer.GetObjID())
- App.g_kRealtimeTimerManager.DeleteTimer(pGetSuppliesTimer.GetObjID())
- pGetSuppliesTimer = None
- App.g_kTimerManager.DeleteTimer(pReplicateSuppliesTimer.GetObjID())
- App.g_kRealtimeTimerManager.DeleteTimer(pReplicateSuppliesTimer.GetObjID())
- pReplicateSuppliesTimer = None
- except:
- pass
- # reenable the stuff we need (this seems to be all we need yay!)
- pCargoBayWindow.KillChildren()
- CreateWindows(pCargoBayWindow)
- # 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__ + ".ResetBayCount")
- if pSIQB:
- pSIQB.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".ResetBayCount")
- if pSaffiQBR:
- pSaffiQBR.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".ResetBayCount")
- if pSIQBR:
- pSIQBR.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".ResetBayCount")
- App.g_kEventManager.RemoveBroadcastHandler(App.ET_OBJECT_EXPLODING, pMission, __name__ + ".ShipExploding")
- App.g_kEventManager.RemoveBroadcastHandler(App.ET_SET_PLAYER, pMission, __name__ + ".ResetBayCount")
- def SpareParts(pCargoBayWindow):
- global CargoCapacity
- pPlayer = MissionLib.GetPlayer()
- pHull = pPlayer.GetHull()
- pHullMaxHP = pHull.GetMaxCondition()
- CargoCapacity = 0
- if pHullMaxHP <= 7500:
- CargoCapacity = 150
- elif pHullMaxHP > 7500:
- CargoCapacity = 200
- # WIDTH = 0.3
- # HEIGHT = 0.3
- # X_POS = 0.21
- # Y_POS = 0.21
- # pPartsMenu = App.STSubPane_Create(WIDTH, HEIGHT)
- pCapacityInfo = App.TGParagraph_CreateW(App.TGString("Capacity: " + str(CargoCapacity))) #+ " space remaining"
- pBodyMenu.AddChild(pCapacityInfo)
- pBodyMenu.ResizeToContents()
- # pBodyMenu.AddChild(pPartsMenu, X_POS, Y_POS)
- # pCapacityInfo = App.TGParagraph_CreateW(App.TGString("Capacity: " + str(CargoCapacity) + " space remaining"))
- # pCargoBayWindow.AddChild(pCapacityInfo, 0.3, 0.3)
Advertisement
Add Comment
Please, Sign In to add comment