Advertisement
Guest User

CargoBays

a guest
Jan 18th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 71.01 KB | None | 0 0
  1. ## Cargo Bays by Tethys
  2. ## Supported accompanying code RepairSystem by Rob Archer aka sfc3fan
  3. ##
  4. ## v0.1
  5. ##
  6. ## Change Log:
  7. ##
  8. ##          - Begin button creation
  9. ##          - Scripted the menus (based on Library.py by Defiant)
  10. ##          - Incorporated RepairSystem by Rob Archer
  11. ##          - Text added for parts maximum capacity (eye candy only at the moment)
  12. ##          - Disabled all cargo bay selection buttons when transferring parts; until Confirm is clicked
  13. ##
  14. ##
  15. ## ToDo:
  16. ##          * Set up a def for each cargo bay to react independently, meaning parts will be drawn from
  17. ##            and added to the currently selected cargo bay rather than having them split between all
  18. ##            available cargo bays.
  19. ##          * Implement code for maximum parts capacity, so cargo bays don't have infinite inventory space...
  20. ##          * Set up button dis/enablers for the repair menu (cooldowns).
  21. ##          * Remove the repair menu updater function and make the menu static (so it doesn't reset when
  22. ##            clicking on one of the cargo bays). Also need to change the way total parts updates, because
  23. ##            it is tied into the repair menu...
  24. ##          * Add text for repair teams to make the window more interactive.
  25. ##          * Add text for replicator status.
  26. ##          * Decide whether or not to use Add Quantity: (additional coding).
  27. ##
  28. ############################################################################################
  29. # Introduction:
  30. #
  31. # This mod adds a window button for Brex that allows you to carry spare parts. These parts can be used to
  32. # rebuild systems which have been completely destroyed in battle. The number of cargo bays your ship can have
  33. # is based on the ship's rotational inertia (not a very elegant way to get the bay count, but efficient). A
  34. # ship with less than 2001 rotational inertia value does not get a cargo bay (it is probably a shuttle). The
  35. # number of parts that can be held in each cargo bay varies and is based upon you ship's radius. This number
  36. # is multiplied by a base number of 10 to achieve a respectable number of spare parts.
  37. #
  38. #############################################################################################
  39. #                                                                                           #
  40. #  This Section Handles the Num Of Available Spare Parts This Ship Has Available            #
  41. #                                                                                           #
  42. #                                                                                           #
  43. #                                                                                           #
  44. #############################################################################################
  45. # Information:
  46. #
  47. # In This version you can set the number of spare parts the ship currently has available simply change
  48. # the number 10 to  higher or lower number please note though for the sake of balace it is best left at 10
  49. # In the Next version you will not be able to set this figure it will be automatically calculated by using
  50. # the ships hull, However you will be able to 'Borrrow Some Parts from an enemy ship using the Transporter
  51. # It should also be possible to replicate a limited number of replacements using Main Power And a new replicator
  52. # system which should be added in a latter edition of New Frontier until then enjoy.
  53. #
  54.  
  55. Bay1Parts = 0 #*pPlayer.GetRadius()
  56. Bay2Parts = 0
  57. Bay3Parts = 0
  58. Bay4Parts = 0
  59. Bay5Parts = 0
  60. Bay6Parts = 0
  61. Bay7Parts = 0
  62. BayParts = 0
  63. TotalParts = Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts+Bay6Parts+Bay7Parts
  64.  
  65.  
  66. import App
  67. import MissionLib
  68. import Libs.LibEngineering
  69. import Lib.LibEngineering
  70. import Bridge.BridgeUtils
  71. import Foundation
  72. import loadspacehelper
  73. import Bridge.EngineerMenuHandlers
  74. import BridgeHandlers
  75. import Actions.MissionScriptActions
  76. import Bridge.BridgeMenus
  77. from Libs.LibQBautostart import *
  78.  
  79. # Mod Info Block.  Used for MP loading.
  80. MODINFO = {     "Author": "Tethys",
  81.                 "Version": "0.1",
  82.                 "License": "GPL",
  83.                 "Description": "Cargo Bays for spare parts/systems",
  84.                 "needBridge": 0
  85.             }
  86.  
  87. pMain = None
  88. pAvailablePartsButton = None
  89. AvailPartsTimer = None
  90. # BayParts = BayParts
  91. g_pMissionDatabase  = None
  92. g_pGeneralDatabase  = None
  93. g_pDatabase     = None
  94. g_bSequenceRunning  = None
  95.  
  96. pBrexMenu   = Lib.LibEngineering.GetBridgeMenu("Engineering")
  97. GOTO_ENGINEERING = App.Mission_GetNextEventType()
  98. ET_CLOSE = None
  99. ET_CATEGORY = None
  100. ET_TOPIC = None
  101. ET_SCROLLUP = None
  102. ET_GET_SUPPLIES = None
  103. ET_SEND_SUPPLIES = None
  104. ET_REPLICATE_SUPPLIES = None
  105. # ET_SET_PLAYER = None
  106. # ET_OBJECT_EXPLODING = None
  107. ET_ADD_QTY = None
  108. ET_CONFIRM = None
  109. # ET_CHARACTER_MENU = None
  110. sBayName = "Cargo Bays"
  111. sInfoName = "Inventory"
  112. pInventoryMenu = None
  113. pBodyMenu = None
  114. CargoBayNum = 0
  115. SuppliesNum = 0
  116. QtyType = 0
  117. CargoCapacity = 0
  118.  
  119. pGame = App.Game_GetCurrentGame()
  120. pEpisode = pGame.GetCurrentEpisode()
  121. pMission = pEpisode.GetCurrentMission()
  122.  
  123. pPlayer = pGame.GetPlayer()
  124. pTarget = pPlayer.GetTarget()
  125.  
  126. # Spare parts
  127. pLargeParts = None
  128. pMediumParts = None
  129. pSmallParts = None
  130.  
  131. def init():
  132.     global ET_CLOSE, ET_TOPIC, ET_CATEGORY, ET_GET_SUPPLIES, ET_SEND_SUPPLIES, ET_REPLICATE_SUPPLIES, ET_ADD_QTY
  133.     global ET_CONFIRM, ET_SET_PLAYER, ET_OBJECT_EXPLODING, ET_LARGE_PARTS, ET_MEDIUM_PARTS, ET_SMALL_PARTS, pBayButtons
  134.    
  135.     # Hey, we have a mutator now!
  136.     # if not Lib.LibEngineering.CheckActiveMutator("Cargo Bays"):
  137.         # return
  138.  
  139.     pMission = MissionLib.GetMission()
  140.     pBrexMenu   = Lib.LibEngineering.GetBridgeMenu("Engineering")
  141.     pBridge = App.g_kSetManager.GetSet('bridge')
  142.     pEngineer = App.CharacterClass_GetObject(pBridge, "Engineer")
  143.     ET_CLOSE = Lib.LibEngineering.GetEngineeringNextEventType()
  144.     ET_CATEGORY = Lib.LibEngineering.GetEngineeringNextEventType()
  145.     ET_TOPIC = Lib.LibEngineering.GetEngineeringNextEventType()
  146.     ET_GET_SUPPLIES = Lib.LibEngineering.GetEngineeringNextEventType()
  147.     ET_SEND_SUPPLIES = Lib.LibEngineering.GetEngineeringNextEventType()
  148.     ET_REPLICATE_SUPPLIES = Lib.LibEngineering.GetEngineeringNextEventType()
  149.     # ET_SET_PLAYER = Lib.LibEngineering.GetEngineeringNextEventType()
  150.     # ET_OBJECT_EXPLODING = Lib.LibEngineering.GetEngineeringNextEventType()
  151.     # ET_CHARACTER_MENU = Lib.LibEngineering.GetEngineeringNextEventType()
  152.     ET_ADD_QTY = Lib.LibEngineering.GetEngineeringNextEventType()
  153.     ET_CONFIRM = Lib.LibEngineering.GetEngineeringNextEventType()
  154.  
  155.     # Start with the menu.
  156.     pBayButtons = Lib.LibEngineering.CreateMenuButton(sBayName, "Engineering", __name__ + ".WindowOpenClose")
  157.     App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_CLOSE, pMission, __name__ + ".WindowOpenClose")
  158.     App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_GET_SUPPLIES, pMission, __name__ + ".TransferSupplies")
  159.     App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_SEND_SUPPLIES, pMission, __name__ + ".TransferSupplies")
  160.     App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_REPLICATE_SUPPLIES, pMission, __name__ + ".TransferSupplies")
  161.     App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_ADD_QTY, pMission, __name__ + ".AddQty")
  162.     App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_CONFIRM, pMission, __name__ + ".UpdateQty")
  163.     App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_SET_PLAYER, pMission, __name__ + ".CheckShip")
  164.     App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_OBJECT_EXPLODING, pMission, __name__ + ".ShipExploding")
  165.     if pEngineer:
  166.         pEngineer.AddPythonFuncHandlerForInstance(App.ET_CHARACTER_MENU, __name__ + ".WindowClose")
  167.         # App.g_kEventManager.AddBroadcastPythonFuncHandler(ET_CHARACTER_MENU, pMission, __name__ + ".WindowOpenClose")
  168.  
  169. # handle mouse clicks in empty space
  170. def PassMouse(pWindow, pEvent):
  171.         debug(__name__ + ", PassMouse")
  172.         pWindow.CallNextHandler(pEvent)
  173.  
  174.         if pEvent.EventHandled() == 0:
  175.                 pEvent.SetHandled()
  176.    
  177. def WindowOpenClose(pObject, pEvent):
  178.         debug(__name__ + ", WindowOpenClose")
  179.         pCargoBayWindow = GetCargoBayWindow()
  180.         if not pCargoBayWindow:
  181.                 pCargoBayWindow = CreateBayGUI(None, None)
  182.                
  183.         # pInfoWindow = GetInfoWindow()
  184.         # if not pInfoWindow:
  185.                 # pInfoWindow = CreateInfoWindow(None, None)
  186.  
  187.         pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
  188.         if pCargoBayWindow.IsVisible(): # and pInfoWindow.IsVisible()
  189.                 pTacticalControlWindow.MoveToBack(pCargoBayWindow)
  190.                 pCargoBayWindow.SetNotVisible()
  191.                 # pCargoBayWindow.KillChildren()
  192.                 # pTacticalControlWindow.MoveToBack(pInfoWindow)
  193.                 # pInfoWindow.SetNotVisible()
  194.         else:
  195.                 pCargoBayWindow.SetVisible()
  196.                 pTacticalControlWindow.MoveToFront(pCargoBayWindow)
  197.                 # Not so agressiv to the front - only give us problems!
  198.                 pTacticalControlWindow.MoveTowardsBack(pCargoBayWindow)
  199.                 # pCargoBayWindow.KillChildren()
  200.                 # CreateWindows(pCargoBayWindow)
  201.                 # pInfoWindow.SetVisible()
  202.                 # pTacticalControlWindow.MoveToFront(pInfoWindow)
  203.                 # Not so agressiv to the front - only give us problems!
  204.                 # pTacticalControlWindow.MoveTowardsBack(pInfoWindow)
  205.  
  206. def WindowClose(pObject, pEvent):
  207.         debug(__name__ + ", WindowClose")
  208.         pCargoBayWindow = GetCargoBayWindow()
  209.         # pInfoWindow = GetInfoWindow()
  210.         if pCargoBayWindow:
  211.                 pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
  212.                 if pCargoBayWindow.IsVisible():
  213.                         pTacticalControlWindow.MoveToBack(pCargoBayWindow)
  214.                         pCargoBayWindow.SetNotVisible()
  215.                         pCargoBayWindow.KillChildren()
  216.                         # pTacticalControlWindow.MoveToBack(pInfoWindow)
  217.                         # pInfoWindow.SetNotVisible()
  218.        
  219.         pCargoBayWindow.SetNotVisible()
  220.         pObject.CallNextHandler(pEvent)
  221.  
  222. def WindowOpen(pObject, pEvent):
  223.         debug(__name__ + ", WindowOpen")
  224.         pCargoBayWindow = GetCargoBayWindow()
  225.         # pInfoWindow = GetInfoWindow()
  226.         if not pCargoBayWindow:
  227.                 pCargoBayWindow = CreateBayGUI(None, None)
  228.                 pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
  229.                 if not pCargoBayWindow.IsVisible():
  230.                         pTacticalControlWindow.MoveToFront(pCargoBayWindow)
  231.                         pCargoBayWindow.SetVisible()
  232.                         pTacticalControlWindow.MoveTowardsBack(pCargoBayWindow)
  233.                         # pCargoBayWindow.KillChildren()
  234.                         # pTacticalControlWindow.MoveToBack(pInfoWindow)
  235.                         # pInfoWindow.SetNotVisible()
  236.        
  237.         pCargoBayWindow.SetNotVisible()
  238.         pObject.CallNextHandler(pEvent)
  239.  
  240. # Begin building the outer window and border/text
  241. def GetCargoBayWindow():
  242.         debug(__name__ + ", GetCargoBayWindow")
  243.         pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
  244.  
  245.         # cycle all
  246.         curChild = pTacticalControlWindow.GetFirstChild()
  247.         while curChild:
  248.                 curWindow = App.STStylizedWindow_Cast(curChild)
  249.                 if curWindow:
  250.                         kString = curWindow.GetName()
  251.                         if (kString.GetCString() == sBayName):
  252.                                 return curWindow
  253.                 curChild = pTacticalControlWindow.GetNextChild(curChild)
  254.  
  255. def CreateBayGUI(pObject, pEvent):
  256.         global pCargoBayWindow
  257.         debug(__name__ + ", CreateBayGUI")
  258.         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
  259.         pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
  260.         pTacticalControlWindow.AddChild(pCargoBayWindow, 0.085, 0.005) #Window X, Y
  261.  
  262.         pCargoBayWindow.AddPythonFuncHandlerForInstance(App.ET_MOUSE, __name__ + ".PassMouse")
  263.         pCargoBayWindow.SetNotVisible()
  264.        
  265.         pCargoBayWindow.AddPythonFuncHandlerForInstance(ET_CATEGORY, __name__ + ".SelectCategory")
  266.         pCargoBayWindow.AddPythonFuncHandlerForInstance(ET_TOPIC, __name__ + ".SelectTopic")
  267.        
  268.         CreateWindows(pCargoBayWindow)
  269.        
  270.         return pCargoBayWindow
  271.  
  272. """def GetInfoWindow():
  273.        debug(__name__ + ", GetInfoWindow")
  274.        pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
  275.  
  276.        # cycle all
  277.        curChild = pTacticalControlWindow.GetFirstChild()
  278.        while curChild:
  279.                curWindow = App.STStylizedWindow_Cast(curChild)
  280.                if curWindow:
  281.                        kString = curWindow.GetName()
  282.                        if (kString.GetCString() == sInfoName):
  283.                                return curWindow
  284.                curChild = pTacticalControlWindow.GetNextChild(curChild)"""
  285.  
  286. """def CreateInfoWindow(pObject, pEvent):
  287.        debug(__name__ + ", CreateInfoWindow")
  288.        pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
  289.        pInfoWindow = App.STStylizedWindow_CreateW("StylizedWindow", "NoMinimize", App.TGString(sInfoName), 0.0, 0.0, None, 1, 0.35, 0.65, App.g_kMainMenuBorderMainColor)
  290.        pTacticalControlWindow.AddChild(pInfoWindow, 0.45, 0.05)
  291.  
  292.        pInfoWindow.SetNotVisible()
  293.  
  294.        pInfoWindow.AddPythonFuncHandlerForInstance(App.ET_MOUSE, __name__ + ".PassMouse")
  295.        pInfoWindow.SetNotVisible()
  296.        pInfoWindow.AddPythonFuncHandlerForInstance(ET_SCROLLUP, __name__ + ".ScrollUp")
  297.        
  298.        CreateWindowInterior1(pInfoWindow)
  299.        return pInfoWindow"""
  300.        
  301. # Create the interior windows of our GUI, also handle the number of cargo bays the ship will receive based on it's Rotational Inertia
  302. def CreateWindows(pCargoBayWindow):
  303.         debug(__name__ + ", CreateWindows")
  304.         global BayParts, TotalParts, pRadius, pGetSuppliesButton, pSendSuppliesButton, pReplicateButton
  305.         global Bay1Parts, Bay2Parts, Bay3Parts, Bay4Parts, Bay5Parts, Bay6Parts, Bay7Parts, SetNumBays
  306.         Bay1Parts = 14 #*pPlayer.GetRadius()
  307.         Bay2Parts = 14
  308.         Bay3Parts = 14
  309.         Bay4Parts = 14
  310.         Bay5Parts = 14
  311.         Bay6Parts = 14
  312.         Bay7Parts = 14
  313.         BayParts = 0
  314.         TotalParts = 0
  315.         # TotalParts = Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts+Bay6Parts+Bay7Parts
  316.  
  317.         # This ship gets how many Cargo Bays? GetRotationalInertia ;)
  318.  
  319.         pPlayer = MissionLib.GetPlayer()
  320.         # pCargo = pPlayer.GetProperty("Cargo Bay Control") #Unable to retrieve hull property at this time
  321.         # pRotational = pCargo.GetMaxCondition()
  322.         pRotational = pPlayer.GetRotationalInertia()
  323.         pHull = pPlayer.GetHull()
  324.         pRadius = pHull.GetRadius()
  325.  
  326.         if pRotational <= 2000: # Ship is too small for a cargo bay
  327.             SetNumBays = 0
  328.             CreateNullMenu(pCargoBayWindow)
  329.             TotalParts = TotalParts #0
  330.             BayParts = BayParts #0
  331.  
  332.             pMission = MissionLib.GetMission()
  333.             pEvent = App.TGIntEvent_Create()
  334.             pEvent.SetEventType(ET_CLOSE)
  335.             pEvent.SetDestination(pMission)
  336.             pEvent.SetInt(0)
  337.             pCloseButton = App.STRoundedButton_CreateW(App.TGString("Close"), pEvent, 0.1, 0.02)
  338.             pCloseButton.SetNormalColor(App.g_kMainMenuButtonColor)
  339.             pCargoBayWindow.AddChild(pCloseButton, 0.01, 0.2, 0)
  340.        
  341.             pCargoBayWindow.InteriorChangedSize()
  342.             pCargoBayWindow.Layout()
  343.             return #End, get us out of here!
  344.  
  345.         if pRotational > 2000: # Create 1 cargo bay for now, until I can fix the display
  346.             SetNumBays = 1
  347.             CreateBayMenu(pCargoBayWindow) #Add a cargo bay
  348.             TotalParts = (Bay1Parts)*pRadius
  349.             BayParts = (TotalParts/SetNumBays)#*pRadius
  350.             # return
  351.  
  352.         if pRotational > 30000: # 2
  353.             SetNumBays = 2
  354.             # CreateBayMenu(pCargoBayWindow) #Lets condense this code a little bit :)
  355.             CreateBayMenu1(pCargoBayWindow) #Second bay now
  356.             TotalParts = (Bay1Parts+Bay2Parts)*pRadius
  357.             BayParts = (TotalParts/SetNumBays)#*pRadius
  358.             # return
  359.  
  360.         if pRotational > 70000: # 3
  361.             SetNumBays = 3
  362.             CreateBayMenu2(pCargoBayWindow) #Third now
  363.             TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts)*pRadius
  364.             BayParts = (TotalParts/SetNumBays)#*pRadius
  365.             # return
  366.  
  367.         if pRotational > 150000: # 4
  368.             SetNumBays = 4
  369.             CreateBayMenu3(pCargoBayWindow)
  370.             TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts)*pRadius
  371.             BayParts = (TotalParts/SetNumBays)#*pRadius
  372.             # return
  373.  
  374.         if pRotational > 310000: # 5
  375.             SetNumBays = 5
  376.             CreateBayMenu4(pCargoBayWindow)
  377.             TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts)*pRadius
  378.             BayParts = (TotalParts/SetNumBays)#*pRadius
  379.             # return
  380.  
  381.         if pRotational > 700000: # 6
  382.             SetNumBays = 6
  383.             CreateBayMenu5(pCargoBayWindow)
  384.             TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts+Bay6Parts)*pRadius
  385.             BayParts = (TotalParts/SetNumBays)#*pRadius
  386.             # return
  387.  
  388.         if pRotational > 2000000: # 7
  389.             SetNumBays = 7
  390.             CreateBayMenu6(pCargoBayWindow)
  391.             TotalParts = (Bay1Parts+Bay2Parts+Bay3Parts+Bay4Parts+Bay5Parts+Bay6Parts+Bay7Parts)*pRadius
  392.             BayParts = (TotalParts/SetNumBays)#*pRadius
  393.             # return
  394.  
  395.         # Create these here, they now give us correct starting part number
  396.         CreateInventoryMenu(pCargoBayWindow)
  397.         CreateBodyMenu(pCargoBayWindow)
  398.         CreatePartsTotalText(pCargoBayWindow)
  399.         SpareParts(pCargoBayWindow)
  400.  
  401.         pMission = MissionLib.GetMission()
  402.  
  403.         pEvent = App.TGIntEvent_Create()
  404.         pEvent.SetEventType(ET_CLOSE)
  405.         pEvent.SetDestination(pMission)
  406.         pEvent.SetInt(0)
  407.         pCloseButton = App.STRoundedButton_CreateW(App.TGString("Close"), pEvent, 0.1, 0.02) # W, H ?
  408.         pCloseButton.SetNormalColor(App.g_kMainMenuButtonColor)
  409.         pCargoBayWindow.AddChild(pCloseButton, 0.01, 0.225, 0) # X, Y, ?
  410.  
  411.         pEvent = App.TGIntEvent_Create()
  412.         pEvent.SetEventType(ET_SEND_SUPPLIES) #SendSupplies
  413.         pEvent.SetDestination(pMission)
  414.         pEvent.SetInt(8)
  415.         pSendSuppliesButton = App.STRoundedButton_CreateW(App.TGString("Send Supplies"), pEvent, 0.1, 0.02)
  416.         pSendSuppliesButton.SetNormalColor(App.g_kMainMenuButtonColor)
  417.         pCargoBayWindow.AddChild(pSendSuppliesButton, 0.01, 0.2, 0)
  418.  
  419.         pEvent = App.TGIntEvent_Create()
  420.         pEvent.SetEventType(ET_GET_SUPPLIES) #GetSupplies
  421.         pEvent.SetDestination(pMission)
  422.         pEvent.SetInt(9)
  423.         pGetSuppliesButton = App.STRoundedButton_CreateW(App.TGString("Get Supplies"), pEvent, 0.1, 0.02)
  424.         pGetSuppliesButton.SetNormalColor(App.g_kMainMenuButtonColor)
  425.         pCargoBayWindow.AddChild(pGetSuppliesButton, 0.01, 0.175, 0)
  426.  
  427.         pEvent = App.TGIntEvent_Create()
  428.         pEvent.SetEventType(ET_REPLICATE_SUPPLIES) #ReplicateSupplies
  429.         pEvent.SetDestination(pMission)
  430.         pEvent.SetInt(10)
  431.         pReplicateButton = App.STRoundedButton_CreateW(App.TGString("Replicate Supplies"), pEvent, 0.1, 0.02)
  432.         pReplicateButton.SetNormalColor(App.g_kMainMenuButtonColor)
  433.         pCargoBayWindow.AddChild(pReplicateButton, 0.01, 0.15, 0)
  434.        
  435.         pCargoBayWindow.InteriorChangedSize()
  436.         pCargoBayWindow.Layout()
  437.                
  438. """# Get the Distance between the Player and pObject
  439. def Distance(pObject):
  440.     debug(__name__ + ", Distance")
  441.     pPlayer = App.Game_GetCurrentGame().GetPlayer()
  442.     vDifference = pObject.GetWorldLocation()
  443.     vDifference.Subtract(pPlayer.GetWorldLocation())
  444.  
  445.     return vDifference.Length()"""
  446.  
  447. """# Setup the checks for if we can send supplies to our target
  448. def SendSupplies(pObject, pEvent):
  449.        debug(__name__ + ", SendSupplies")
  450.        pGame = App.Game_GetCurrentGame()
  451.        pEpisode = pGame.GetCurrentEpisode()
  452.        pMission = pEpisode.GetCurrentMission()
  453.        pPlayer = MissionLib.GetPlayer()
  454.        pTarget = pPlayer.GetTarget()
  455.        pTargetCast = App.ShipClass_Cast(pPlayer.GetTarget())
  456.        pTargetattr = App.ShipClass_Cast(pTarget)
  457.        pFriendlies = pMission.GetFriendlyGroup()
  458.        pEnemies = pMission.GetEnemyGroup()
  459.  
  460.        # Test Distance
  461.        if (Distance(pTarget) > 300):
  462.            pSound = App.TGSound_Create("sfx/Maelstrom/Episode 7/Mission 2/E7M2L0672.mp3", "TooFar", 0)
  463.            pSound.SetSFX(0)
  464.            pSound.SetInterface(1)
  465.            App.g_kSoundManager.PlaySound("TooFar")
  466.            print("Target is too far away: can't Transport")
  467.            return
  468.        
  469.            if App.g_kUtopiaModule.IsMultiplayer() and pTargetattr.GetNetPlayerID() >= 0:
  470.                print("This is a Player, don't Transport") #For now
  471.                return
  472.        
  473.        # Test if our Target is friendly
  474.        if (pFriendlies.IsNameInGroup(pTarget.GetName()) != 1):
  475.            print("Target is not friendly...testing Shields")
  476.            # but maybe neutral:
  477.                if pMission.GetEnemyGroup().IsNameInGroup(pTarget.GetName()):
  478.                    print("Neither neutral :(")
  479.                    return
  480.  
  481.        pSound = App.TGSound_Create("sfx/Interface/new_game3.mp3", "Beaming", 0)
  482.        pSound.SetSFX(0)
  483.        pSound.SetInterface(1)
  484.        App.g_kSoundManager.PlaySound("Beaming")"""
  485.  
  486. """# Setup the checks for if we can send supplies to our target
  487. def SendSupplies(pObject, pEvent):
  488.        debug(__name__ + ", SendSupplies")
  489.        pSound = App.TGSound_Create("sfx/Interface/new_game3.mp3", "Beaming", 0)
  490.        pSound.SetSFX(0)
  491.        pSound.SetInterface(1)
  492.        App.g_kSoundManager.PlaySound("Beaming")
  493.  
  494. # Setup the checks for if we can get supplies from our target
  495. def GetSupplies(pObject, pEvent):
  496.        debug(__name__ + ", GetSupplies")
  497.        pSound = App.TGSound_Create("sfx/Interface/new_game2.mp3", "Warping", 0)
  498.        pSound.SetSFX(0)
  499.        pSound.SetInterface(1)
  500.        App.g_kSoundManager.PlaySound("Warping")"""
  501.  
  502. # Get the relevant Event Int
  503. def TransferSupplies(pObject, pEvent):
  504.         debug(__name__ + ", TransferSupplies")
  505.         pGame = App.Game_GetCurrentGame()
  506.         pEpisode = pGame.GetCurrentEpisode()
  507.         pMission = pEpisode.GetCurrentMission()
  508.         pPlayer = MissionLib.GetPlayer()
  509.         pTarget = pPlayer.GetTarget()
  510.         # pTargetCast = App.ShipClass_Cast(pPlayer.GetTarget())
  511.         # pTargetattr = App.ShipClass_Cast(pTarget)
  512.         # pFriendlies = pMission.GetFriendlyGroup()
  513.         # pEnemies = pMission.GetEnemyGroup()
  514.         global SuppliesNum
  515.         SuppliesNum = pEvent.GetInt()
  516.         # Bay2Inventory(pInventoryMenu)
  517.         pSendSuppliesButton.SetDisabled() #we must disable them all, otherwise we might end the cycle prematurely...
  518.         pGetSuppliesButton.SetDisabled() #^
  519.         pReplicateButton.SetDisabled() #^
  520.         if SuppliesNum == 8:
  521.             pBay1Text = App.TGParagraph_Create("\nSending supplies...")
  522.             pInventoryMenu.AddChild(pBay1Text)
  523.             pSendSuppliesTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".SentSupplies", App.g_kUtopiaModule.GetGameTime() + 5, 0, 0)
  524.  
  525.             # pSound = App.TGSound_Create("sfx/Interface/new_game3.mp3", "Beaming", 0)
  526.             # pSound.SetSFX(0)
  527.             # pSound.SetInterface(1)
  528.             # App.g_kSoundManager.PlaySound("Beaming")
  529.         elif SuppliesNum == 9:
  530.             pBay2Text = App.TGParagraph_Create("\nGetting supplies...")
  531.             pInventoryMenu.AddChild(pBay2Text)
  532.             pGetSuppliesTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailSupplies", App.g_kUtopiaModule.GetGameTime() + 5, 0, 0)
  533.  
  534.             # pSound = App.TGSound_Create("sfx/Interface/new_game3.mp3", "Beaming", 0)
  535.             # pSound.SetSFX(0)
  536.             # pSound.SetInterface(1)
  537.             # App.g_kSoundManager.PlaySound("Beaming")
  538.         elif SuppliesNum == 10:
  539.             pPower = pPlayer.GetPowerSubsystem()
  540.             PowerOut        = pPower.GetPowerOutput()
  541.             MainConduit     = pPower.GetMainConduitCapacity()
  542.             MainBatteryPower = pPower.GetMainBatteryPower()
  543.             MainBatteryLimit = pPower.GetMainBatteryLimit()
  544.             ReserveConduit      = pPower.GetBackupConduitCapacity()
  545.             ReserveBatteryPower = pPower.GetBackupBatteryPower()
  546.             ReserveBatteryLimit = pPower.GetBackupBatteryLimit()   
  547.             Transferenergy = MainBatteryLimit*0.1
  548.        
  549.             if MainBatteryPower <= 0.2:
  550.                 Bay2Inventory(pInventoryMenu)
  551.                 pInventoryMenu.ResizeToContents()
  552.                 return
  553.        
  554.             if MainBatteryPower > 0.2:
  555.                 pPower.SetMainBatteryPower(MainBatteryPower - Transferenergy)
  556.                 pBay2Text = App.TGParagraph_Create("\nReplicating supplies...")
  557.                 pInventoryMenu.AddChild(pBay2Text)
  558.             pReplicateSuppliesTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".ReplicateSupplies", App.g_kUtopiaModule.GetGameTime() + 15, 0, 0)
  559.  
  560.  
  561. """        # Test Distance
  562.        if (Distance(pTarget) > 300):
  563.            pSound = App.TGSound_Create("sfx/Maelstrom/Episode 7/Mission 2/E7M2L0672.mp3", "TooFar", 0)
  564.            pSound.SetSFX(0)
  565.            pSound.SetInterface(1)
  566.            App.g_kSoundManager.PlaySound("TooFar")
  567.            print("Target is too far away: can't Transport")
  568.            return
  569.        
  570.            if App.g_kUtopiaModule.IsMultiplayer() and pTargetattr.GetNetPlayerID() >= 0:
  571.                print("This is a Player, don't Transport") #For now
  572.                return
  573.        
  574.        # Test if our Target is friendly
  575.        if (pFriendlies.IsNameInGroup(pTarget.GetName()) != 1):
  576.            print("Target is not friendly...testing Shields")
  577.            # but maybe neutral:
  578.                if pMission.GetEnemyGroup().IsNameInGroup(pTarget.GetName()):
  579.                    print("Neither neutral :(")
  580.                    return"""
  581.        
  582.  
  583. def CreateNullMenu(pCargoBayWindow):
  584.         debug(__name__ + ", CreateNullMenu")
  585.         WIDTH = 0.1
  586.         HEIGHT = 0.3
  587.         X_POS = 0.01
  588.         Y_POS = 0.01
  589.        
  590.         pBayMenu = App.STSubPane_Create(WIDTH, HEIGHT)
  591.  
  592.         pBay1Text = App.TGParagraph_Create("This vessel has no available storage bays.")
  593.         pBayMenu.AddChild(pBay1Text)
  594.  
  595.     pBayMenu.ResizeToContents()
  596.        
  597.         pCargoBayWindow.AddChild(pBayMenu, X_POS, Y_POS)
  598.        
  599. def CreateBayMenu(pCargoBayWindow):
  600.         debug(__name__ + ", CreateBayMenu")
  601.         # global CargoCapacity
  602.         global BayParts, TotalParts
  603.         WIDTH = 0.1
  604.         HEIGHT = 0.3
  605.         X_POS = 0.01
  606.         Y_POS = 0.01
  607.        
  608.         pBayMenu = App.STSubPane_Create(WIDTH, HEIGHT)
  609.  
  610.         pEvent = App.TGIntEvent_Create()
  611.         pEvent.SetEventType(ET_CATEGORY)
  612.         pEvent.SetDestination(pCargoBayWindow)
  613.         pEvent.SetInt(1)
  614.         pBay1Button = App.STCharacterMenu_Create("Cargo Bay 1")
  615.         pBay1Button.SetActivationEvent(pEvent)
  616.         pBay1Button.SetNotOpenable()
  617.         pBayMenu.AddChild(pBay1Button)
  618.  
  619.     pBayMenu.ResizeToContents()
  620.        
  621.         pCargoBayWindow.AddChild(pBayMenu, X_POS, Y_POS)
  622.            
  623.  
  624. def CreateBayMenu1(pCargoBayWindow):
  625.         debug(__name__ + ", CreateBayMenu1")
  626.         WIDTH = 0.1
  627.         HEIGHT = 0.3
  628.         X_POS = 0.01
  629.         Y_POS = 0.03
  630.        
  631.         pBayMenu1 = App.STSubPane_Create(WIDTH, HEIGHT)
  632.        
  633.         pEvent = App.TGIntEvent_Create()
  634.         pEvent.SetEventType(ET_CATEGORY)
  635.         pEvent.SetDestination(pCargoBayWindow)
  636.         pEvent.SetInt(2)
  637.         pBay2Button = App.STCharacterMenu_Create("Cargo Bay 2")
  638.         pBay2Button.SetActivationEvent(pEvent)
  639.         pBay2Button.SetNotOpenable()
  640.         pBayMenu1.AddChild(pBay2Button)
  641.  
  642.     pBayMenu1.ResizeToContents()
  643.        
  644.         pCargoBayWindow.AddChild(pBayMenu1, X_POS, Y_POS)
  645.                
  646. def CreateBayMenu2(pCargoBayWindow):
  647.         debug(__name__ + ", CreateBayMenu2")
  648.         WIDTH = 0.1
  649.         HEIGHT = 0.3
  650.         X_POS = 0.01
  651.         Y_POS = 0.049
  652.        
  653.         pBayMenu2 = App.STSubPane_Create(WIDTH, HEIGHT)
  654.        
  655.         pEvent = App.TGIntEvent_Create()
  656.         pEvent.SetEventType(ET_CATEGORY)
  657.         pEvent.SetDestination(pCargoBayWindow)
  658.         pEvent.SetInt(3)
  659.         pBay3Button = App.STCharacterMenu_Create("Cargo Bay 3")
  660.         pBay3Button.SetActivationEvent(pEvent)
  661.         pBay3Button.SetNotOpenable()
  662.         pBayMenu2.AddChild(pBay3Button)
  663.  
  664.     pBayMenu2.ResizeToContents()
  665.        
  666.         pCargoBayWindow.AddChild(pBayMenu2, X_POS, Y_POS)
  667.                
  668. def CreateBayMenu3(pCargoBayWindow):
  669.         debug(__name__ + ", CreateBayMenu3")
  670.         WIDTH = 0.1
  671.         HEIGHT = 0.3
  672.         X_POS = 0.01
  673.         Y_POS = 0.0685
  674.        
  675.         pBayMenu3 = App.STSubPane_Create(WIDTH, HEIGHT)
  676.        
  677.         pEvent = App.TGIntEvent_Create()
  678.         pEvent.SetEventType(ET_CATEGORY)
  679.         pEvent.SetDestination(pCargoBayWindow)
  680.         pEvent.SetInt(4)
  681.         pBay4Button = App.STCharacterMenu_Create("Cargo Bay 4")
  682.         pBay4Button.SetActivationEvent(pEvent)
  683.         pBay4Button.SetNotOpenable()
  684.         pBayMenu3.AddChild(pBay4Button)
  685.  
  686.     pBayMenu3.ResizeToContents()
  687.        
  688.         pCargoBayWindow.AddChild(pBayMenu3, X_POS, Y_POS)
  689.                
  690. def CreateBayMenu4(pCargoBayWindow):
  691.         debug(__name__ + ", CreateBayMenu4")
  692.         WIDTH = 0.1
  693.         HEIGHT = 0.3
  694.         X_POS = 0.01
  695.         Y_POS = 0.088
  696.        
  697.         pBayMenu4 = App.STSubPane_Create(WIDTH, HEIGHT)
  698.        
  699.         pEvent = App.TGIntEvent_Create()
  700.         pEvent.SetEventType(ET_CATEGORY)
  701.         pEvent.SetDestination(pCargoBayWindow)
  702.         pEvent.SetInt(5)
  703.         pBay5Button = App.STCharacterMenu_Create("Cargo Bay 5")
  704.         pBay5Button.SetActivationEvent(pEvent)
  705.         pBay5Button.SetNotOpenable()
  706.         pBayMenu4.AddChild(pBay5Button)
  707.  
  708.     pBayMenu4.ResizeToContents()
  709.        
  710.         pCargoBayWindow.AddChild(pBayMenu4, X_POS, Y_POS)
  711.                
  712. def CreateBayMenu5(pCargoBayWindow):
  713.         debug(__name__ + ", CreateBayMenu5")
  714.         WIDTH = 0.1
  715.         HEIGHT = 0.3
  716.         X_POS = 0.01
  717.         Y_POS = 0.107
  718.        
  719.         pBayMenu5 = App.STSubPane_Create(WIDTH, HEIGHT)
  720.        
  721.         pEvent = App.TGIntEvent_Create()
  722.         pEvent.SetEventType(ET_CATEGORY)
  723.         pEvent.SetDestination(pCargoBayWindow)
  724.         pEvent.SetInt(6)
  725.         pBay6Button = App.STCharacterMenu_Create("Cargo Bay 6")
  726.         pBay6Button.SetActivationEvent(pEvent)
  727.         pBay6Button.SetNotOpenable()
  728.         pBayMenu5.AddChild(pBay6Button)
  729.  
  730.     pBayMenu5.ResizeToContents()
  731.        
  732.         pCargoBayWindow.AddChild(pBayMenu5, X_POS, Y_POS)
  733.                
  734. def CreateBayMenu6(pCargoBayWindow):
  735.         debug(__name__ + ", CreateBayMenu6")
  736.         WIDTH = 0.1
  737.         HEIGHT = 0.3
  738.         X_POS = 0.01
  739.         Y_POS = 0.127
  740.        
  741.         pBayMenu6 = App.STSubPane_Create(WIDTH, HEIGHT)
  742.        
  743.         pEvent = App.TGIntEvent_Create()
  744.         pEvent.SetEventType(ET_CATEGORY)
  745.         pEvent.SetDestination(pCargoBayWindow)
  746.         pEvent.SetInt(7)
  747.         pBay7Button = App.STCharacterMenu_Create("Cargo Bay 7")
  748.         pBay7Button.SetActivationEvent(pEvent)
  749.         pBay7Button.SetNotOpenable()
  750.         pBayMenu6.AddChild(pBay7Button)
  751.  
  752.     pBayMenu6.ResizeToContents()
  753.        
  754.         pCargoBayWindow.AddChild(pBayMenu6, X_POS, Y_POS)
  755.  
  756. def CreateInventoryMenu(pCargoBayWindow):
  757.         debug(__name__ + ", CreateInventoryMenu")
  758.         global pInventoryMenu
  759.         WIDTH = 0.2
  760.         HEIGHT = 0.25
  761.         X_POS = 0.13
  762.         Y_POS = 0.01
  763.        
  764.         pInventoryMenu = App.STSubPane_Create(WIDTH, HEIGHT)
  765.         pCargoBayWindow.AddChild(pInventoryMenu, X_POS, Y_POS)
  766.         pHeader = App.TGParagraph_Create("Inventory Menu")
  767.         pInventoryMenu.AddChild(pHeader)
  768.         pHeader1 = App.TGParagraph_Create("\nParts Total: " + str(TotalParts)) #Total count
  769.         pInventoryMenu.AddChild(pHeader1)
  770.  
  771. def CreateBodyMenu(pCargoBayWindow):
  772.         debug(__name__ + ", CreateBodyMenu")
  773.         global pBodyMenu, pButton1, pButton2, pButton3, pButton4, pButton5, pButton6, pButtonD1, pPartsText
  774.         WIDTH = 0.2
  775.         HEIGHT = 0.35
  776.         X_POS = 0.25
  777.         Y_POS = 0.01
  778.  
  779.         pBrexMenu   = Lib.LibEngineering.GetBridgeMenu("Engineering")
  780.        
  781.         pBodyMenu = App.STSubPane_Create(WIDTH, HEIGHT)
  782.         pCargoBayWindow.AddChild(pBodyMenu, X_POS, Y_POS)
  783.  
  784.         pMain = App.STMenu_CreateW(App.TGString("Rebuild Destroyed Systems"))
  785.         pBodyMenu.AddChild(pMain)
  786.         pMain.Open()
  787.         pMain.SetNotCloseable()
  788.  
  789.         # pButton6 = Lib.LibEngineering.CreateMenuButton("Request Spare Parts Resupply", "Engineering", __name__ + ".AddTimer", 0, pMain)
  790.         # pAvailablePartsButton = Lib.LibEngineering.CreateMenuButton("Parts Count: " + str(BayParts), "Engineering", __name__ + ".Nothing", 0, pBodyMenu)
  791.         pButtonD1 = Lib.LibEngineering.CreateMenuButton("Destroy Systems Test", "Engineering", __name__ + ".BlowSystems", 0, pMain)
  792.         pButton5 = Lib.LibEngineering.CreateMenuButton("Impulse Engines: 10 Parts", "Engineering", __name__ + ".Impulse", 0, pMain)
  793.         pButton4 = Lib.LibEngineering.CreateMenuButton("Shield Generator: 5 Parts", "Engineering", __name__ + ".Shields", 0, pMain)
  794.         pButton3 = Lib.LibEngineering.CreateMenuButton("Sensor Array: 10 Parts", "Engineering", __name__ + ".Sensors", 0, pMain)
  795.         pButton2 = Lib.LibEngineering.CreateMenuButton("Warp Engines: 20 Parts", "Engineering", __name__ + ".WarpE", 0, pMain)
  796.         pButton1 = Lib.LibEngineering.CreateMenuButton("Warp Core: 10 Parts", "Engineering", __name__ + ".Core", 0, pMain)
  797.  
  798. def CreatePartsTotalText(pCargoBayWindow):
  799.         debug(__name__ + ", CreatePartsTotalText")
  800.         pPartsText = App.TGParagraph_Create("\nParts Total: " + str(TotalParts))
  801.         pBodyMenu.AddChild(pPartsText)
  802.         # SpareParts(pCargoBayWindow)
  803.  
  804. def CreatePartsInBayText(pCargoBayWindow):
  805.         debug(__name__ + ", CreatePartsInBayText")
  806.         pPartsInBayText = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n\n")
  807.         pBodyMenu.AddChild(pPartsInBayText)
  808.  
  809. def SelectCategory(pObject, pEvent): #ET_CATEGORY
  810.         debug(__name__ + ", SelectCategory")
  811.         global CargoBayNum, pPartsInBay1, pPartsInBay2, pPartsInBay3, pPartsInBay4, pPartsInBay5, pPartsInBay6, pPartsInBay7
  812.         CargoBayNum = pEvent.GetInt()
  813.         if CargoBayNum and pInventoryMenu:
  814.                 pInventoryMenu.KillChildren()
  815.                 pBodyMenu.KillChildren()
  816.                 if CargoBayNum == 1:
  817.                         pBay1Text = App.TGParagraph_Create("Inventory: Cargo Bay 1")
  818.                         pInventoryMenu.AddChild(pBay1Text)
  819.                        
  820.                         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
  821.                         pInventoryMenu.AddChild(pPartsInBay1)
  822.                        
  823.                         # Bay1Inventory(pInventoryMenu) #Need to remove this from here and link it to our Get/Send Supplies button (we can't)
  824.                         # CreateBodyMenu(pCargoBayWindow)
  825.                 elif CargoBayNum == 2:
  826.                         pBay2Text = App.TGParagraph_Create("Inventory: Cargo Bay 2")
  827.                         pInventoryMenu.AddChild(pBay2Text)
  828.                        
  829.                         pPartsInBay2 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
  830.                         pInventoryMenu.AddChild(pPartsInBay2)
  831.                        
  832.                         # Bay2Inventory(pInventoryMenu)#
  833.                         # CreateBodyMenu(pCargoBayWindow)
  834.                 elif CargoBayNum == 3:
  835.                         pBay3Text = App.TGParagraph_Create("Inventory: Cargo Bay 3")
  836.                         pInventoryMenu.AddChild(pBay3Text)
  837.                        
  838.                         pPartsInBay3 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
  839.                         pInventoryMenu.AddChild(pPartsInBay3)
  840.                        
  841.                         # Bay2Inventory(pInventoryMenu)#
  842.                         # CreateBodyMenu(pCargoBayWindow)
  843.                 elif CargoBayNum == 4:
  844.                         pBay4Text = App.TGParagraph_Create("Inventory: Cargo Bay 4")
  845.                         pInventoryMenu.AddChild(pBay4Text)
  846.                        
  847.                         pPartsInBay4 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
  848.                         pInventoryMenu.AddChild(pPartsInBay4)
  849.                        
  850.                         # Bay2Inventory(pInventoryMenu)#
  851.                         # CreateBodyMenu(pCargoBayWindow)
  852.                 elif CargoBayNum == 5:
  853.                         pBay5Text = App.TGParagraph_Create("Inventory: Cargo Bay 5")
  854.                         pInventoryMenu.AddChild(pBay5Text)
  855.                        
  856.                         pPartsInBay5 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
  857.                         pInventoryMenu.AddChild(pPartsInBay5)
  858.                        
  859.                         # Bay2Inventory(pInventoryMenu)#
  860.                         # CreateBodyMenu(pCargoBayWindow)
  861.                 elif CargoBayNum == 6:
  862.                         pBay6Text = App.TGParagraph_Create("Inventory: Cargo Bay 6")
  863.                         pInventoryMenu.AddChild(pBay6Text)
  864.                        
  865.                         pPartsInBay6 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
  866.                         pInventoryMenu.AddChild(pPartsInBay6)
  867.                        
  868.                         # Bay2Inventory(pInventoryMenu)#
  869.                         # CreateBodyMenu(pCargoBayWindow)
  870.                 elif CargoBayNum == 7:
  871.                         pBay7Text = App.TGParagraph_Create("Inventory: Cargo Bay 7")
  872.                         pInventoryMenu.AddChild(pBay7Text)
  873.                        
  874.                         pPartsInBay7 = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
  875.                         pInventoryMenu.AddChild(pPartsInBay7)
  876.                        
  877.                         # Bay2Inventory(pInventoryMenu)#
  878.                         # CreateBodyMenu(pCargoBayWindow)
  879.                 else:
  880.                         CreateBodyMenu(pCargoBayWindow)
  881.                         CreatePartsTotalText(pCargoBayWindow)
  882.                         SpareParts(pCargoBayWindow)
  883.                 CreateBodyMenu(pCargoBayWindow)
  884.                 CreatePartsTotalText(pCargoBayWindow)
  885.                 SpareParts(pCargoBayWindow)
  886.                 # Bay2Inventory(pInventoryMenu)
  887.                 pInventoryMenu.ResizeToContents()
  888.  
  889. def UpdateQty(pObject, pEvent): #
  890.         debug(__name__ + ", UpdateQty")
  891.         global QtyType, pPartsInBay1, pPartsInBay2, pPartsInBay3, pPartsInBay4, pPartsInBay5, pPartsInBay6, pPartsInBay7, TotalParts, pPartsInBay
  892.         # Bay2Inventory(pInventoryMenu)
  893.         QtyType = pEvent.GetInt()
  894.         if QtyType and pInventoryMenu:
  895.                 pInventoryMenu.KillChildren()
  896.                 pBodyMenu.KillChildren() #We might not need this if we call CreateBodyMenu(pCargoBayWindow) early on or in a different menu...
  897.                 if QtyType == 30: #Add
  898.                         return
  899.                 if QtyType == 31: #Confirm
  900.                         pPartsInBay = App.TGParagraph_Create("\nParts In Bay: " + str(TotalParts/SetNumBays) + "\n\n\n\n\n\n\n\n")
  901.                         pInventoryMenu.AddChild(pPartsInBay)
  902.                         pSendSuppliesButton.SetEnabled()
  903.                         pGetSuppliesButton.SetEnabled()
  904.                         pReplicateButton.SetEnabled()
  905.  
  906.                         CreateBodyMenu(pCargoBayWindow)
  907.                         CreatePartsTotalText(pCargoBayWindow) #Create parts added to each bay text instead
  908.                         SpareParts(pCargoBayWindow)
  909.                         # Bay2Inventory(pInventoryMenu)
  910.  
  911. def Bay1Inventory(pInventoryMenu):
  912.         debug(__name__ + ", Bay1Inventory")
  913.         global pConfirm
  914.         pCargoBayWindow = GetCargoBayWindow()
  915.  
  916.         pEvent = App.TGIntEvent_Create()
  917.         pEvent.SetEventType(ET_ADD_QTY)
  918.         pEvent.SetDestination(pInventoryMenu)
  919.         pEvent.SetInt(30)
  920.         pAddQty = App.STRoundedButton_CreateW(App.TGString("Add Quantity:"), pEvent, 0.05, 0.02) # W, H ?
  921.         pAddQty.SetNormalColor(App.g_kMainMenuButtonColor)
  922.         pInventoryMenu.AddChild(pAddQty, 0.25, 0.2, 0) # X, Y, ?
  923.  
  924.         pEvent = App.TGIntEvent_Create()
  925.         pEvent.SetEventType(ET_CONFIRM)
  926.         pEvent.SetDestination(pInventoryMenu)
  927.         pEvent.SetInt(31)
  928.         pConfirm = App.STRoundedButton_CreateW(App.TGString("Confirm"), pEvent, 0.05, 0.02) # W, H ?
  929.         pConfirm.SetNormalColor(App.g_kMainMenuButtonColor)
  930.         pInventoryMenu.AddChild(pConfirm, 0.175, 0.2, 0) # X, Y, ?
  931.  
  932. def Bay2Inventory(pInventoryMenu):
  933.         debug(__name__ + ", Bay2Inventory")
  934.         pCargoBayWindow = GetCargoBayWindow()
  935.  
  936.         pEvent = App.TGIntEvent_Create()
  937.         pEvent.SetEventType(ET_ADD_QTY)
  938.         pEvent.SetDestination(pInventoryMenu)
  939.         pEvent.SetInt(30)
  940.         pAddQty = App.STRoundedButton_CreateW(App.TGString("Add Quantity:"), pEvent, 0.05, 0.02) # W, H ?
  941.         pAddQty.SetNormalColor(App.g_kMainMenuButtonColor)
  942.         pInventoryMenu.AddChild(pAddQty, 0.25, 0.2, 0) # X, Y, ?
  943.  
  944.         pEvent = App.TGIntEvent_Create()
  945.         pEvent.SetEventType(ET_CONFIRM)
  946.         pEvent.SetDestination(pInventoryMenu)
  947.         pEvent.SetInt(31)
  948.         pConfirm = App.STRoundedButton_CreateW(App.TGString("Confirm"), pEvent, 0.05, 0.02) # W, H ?
  949.         pConfirm.SetNormalColor(App.g_kMainMenuButtonColor)
  950.         pInventoryMenu.AddChild(pConfirm, 0.175, 0.2, 0) # X, Y, ?
  951.  
  952. #############################################################################################
  953. #                                                                                           #
  954. #  This Section Handles Repairs to the Destroyed Warp Core,                                 #
  955. #                                                                                           #
  956. #                                                                                           #
  957. #                                                                                           #
  958. #############################################################################################
  959.  
  960. def Core(pObject, pEvent):
  961.  
  962.         global BayParts, AvailPartsTimer #, BayParts
  963.  
  964.         if BayParts < 10:
  965.             pButton1.SetDisabled()
  966.  
  967.         pPlayer          = MissionLib.GetPlayer()
  968.  
  969.     pPowerSys = pPlayer.GetPowerSubsystem()
  970.  
  971.     if pPowerSys:
  972.         pPowerHealth = pPowerSys.GetCondition()
  973.  
  974.         if  (pPowerHealth > 0):
  975.              return
  976.  
  977.         AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailCoreParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
  978.  
  979.         pPlayer          = MissionLib.GetPlayer()
  980.     pShipSet = pPlayer.GetPropertySet()
  981.     pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
  982.  
  983.     iNumItems = pShipList.TGGetNumItems()
  984.         pShipList.TGBeginIteration()
  985.         for i in range(iNumItems):
  986.         pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
  987.         pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
  988.  
  989.         pPower = pPlayer.GetPowerSubsystem()
  990.         pPower.SetCondition(pSubsystem.GetMaxCondition())
  991.         pPower.SetCondition(1)
  992.  
  993. def AvailCoreParts(pObject, pEvent):
  994.         global BayParts, TotalParts, pAvailablePartsButton #, BayParts
  995.  
  996.  
  997.         BayParts = BayParts - 10
  998.         TotalParts = TotalParts - 10
  999.  
  1000.         # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
  1001.         # pBodyMenu.DeleteChild(pPartsText)
  1002.         # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
  1003.         # pBodyMenu.AddChild(pPartsText)
  1004.         pInventoryMenu.KillChildren()
  1005.         # pBodyMenu.KillChildren()
  1006.         # CreateBodyMenu(pCargoBayWindow) #recreate buttons
  1007.         CreatePartsTotalText(pCargoBayWindow) #update part total
  1008.         SpareParts(pCargoBayWindow)
  1009.         SelectCategory()
  1010.         # CreateInventoryMenu(pCargoBayWindow)
  1011.     return 0   
  1012.    
  1013.  
  1014.  
  1015. #############################################################################################
  1016. #                                                                                           #
  1017. #  This Section Handles Repairs to the Destroyed Shield Generators,                         #
  1018. #                                                                                           #
  1019. #                                                                                           #
  1020. #                                                                                           #
  1021. #############################################################################################
  1022. def Shields(pObject, pEvent):
  1023.        
  1024.         if BayParts < 5:
  1025.             pButton4.SetDisabled()
  1026.  
  1027.         pPlayer = MissionLib.GetPlayer()
  1028.  
  1029.     pShieldSys = pPlayer.GetShields()
  1030.  
  1031.     if pShieldSys:
  1032.         pShieldHealth = pShieldSys.GetCondition()
  1033.  
  1034.         if  (pShieldHealth > 0):
  1035.              return
  1036.  
  1037.         AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailShieldParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
  1038.     pShipSet = pPlayer.GetPropertySet()
  1039.     pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
  1040.  
  1041.     iNumItems = pShipList.TGGetNumItems()
  1042.         pShipList.TGBeginIteration()
  1043.         for i in range(iNumItems):
  1044.         pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
  1045.         pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
  1046.  
  1047.         pShield = pPlayer.GetShields()
  1048.         pShield.SetCondition(1)
  1049.  
  1050.  
  1051. def AvailShieldParts(pObject, pEvent):
  1052.         global BayParts, TotalParts, pAvailablePartsButton, pPartsText #, BayParts
  1053.  
  1054.         BayParts = BayParts - 5
  1055.         TotalParts = TotalParts - 5
  1056.  
  1057.         # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
  1058.         # pBodyMenu.DeleteChild(pPartsText)
  1059.         # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
  1060.         # pBodyMenu.AddChild(pPartsText)
  1061.         pInventoryMenu.KillChildren()
  1062.         # pBodyMenu.KillChildren()
  1063.         # CreateBodyMenu(pCargoBayWindow)
  1064.         CreatePartsTotalText(pCargoBayWindow) #update part total
  1065.         SpareParts(pCargoBayWindow)
  1066.         SelectCategory()
  1067.         # CreateInventoryMenu(pCargoBayWindow)
  1068.     return 0   
  1069.      
  1070.  
  1071. #############################################################################################
  1072. #                                                                                           #
  1073. #  This Section Handles Repairs to the Destroyed Sensor Array,                              #
  1074. #                                                                                           #
  1075. #                                                                                           #
  1076. #                                                                                           #
  1077. #############################################################################################
  1078.  
  1079. def Sensors(pObject, pEvent):
  1080.         global BayParts, AvailPartsTimer #, BayParts
  1081.  
  1082.  
  1083.         if BayParts < 10:
  1084.             pButton3.SetDisabled()
  1085.  
  1086.         pPlayer = MissionLib.GetPlayer()
  1087.  
  1088.     pSensors = pPlayer.GetSensorSubsystem()
  1089.  
  1090.     if pSensors:
  1091.         pSensorHealth = pSensors.GetCondition()
  1092.  
  1093.         if  (pSensorHealth > 0):
  1094.              return
  1095.  
  1096.         AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailSensorParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
  1097.     pShipSet = pPlayer.GetPropertySet()
  1098.     pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
  1099.  
  1100.     iNumItems = pShipList.TGGetNumItems()
  1101.         pShipList.TGBeginIteration()
  1102.         for i in range(iNumItems):
  1103.         pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
  1104.         pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
  1105.  
  1106.         pSensors.SetCondition(pSubsystem.GetMaxCondition())
  1107.         pSensors.SetCondition(1)
  1108.  
  1109. def AvailSensorParts(pObject, pEvent):
  1110.         global BayParts, TotalParts, pAvailablePartsButton #, BayParts
  1111.  
  1112.         BayParts = BayParts - 5
  1113.         TotalParts = TotalParts - 5
  1114.  
  1115.         # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
  1116.         # pBodyMenu.DeleteChild(pPartsText)
  1117.         # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
  1118.         # pBodyMenu.AddChild(pPartsText)
  1119.         pInventoryMenu.KillChildren()
  1120.         # pBodyMenu.KillChildren()
  1121.         # CreateBodyMenu(pCargoBayWindow)
  1122.         CreatePartsTotalText(pCargoBayWindow)
  1123.         SpareParts(pCargoBayWindow)
  1124.         SelectCategory()
  1125.         # CreateInventoryMenu(pCargoBayWindow)
  1126.     return 0   
  1127.      
  1128.  
  1129.  
  1130. #############################################################################################
  1131. #                                                                                           #
  1132. #  This Section Handles Repairs to the Destroyed Warp Engines,                              #
  1133. #                                                                                           #
  1134. #                                                                                           #
  1135. #                                                                                           #
  1136. #############################################################################################
  1137.  
  1138. def Impulse(pObject, pEvent):
  1139.         global BayParts, AvailPartsTimer #, BayParts
  1140.  
  1141.         if BayParts < 20:
  1142.             pButton5.SetDisabled()
  1143.  
  1144.         pPlayer          = MissionLib.GetPlayer()
  1145.  
  1146.     pImpulseSys = pPlayer.GetImpulseEngineSubsystem()
  1147.  
  1148.     if pImpulseSys:
  1149.         iNumImpulse = pImpulseSys.GetNumChildSubsystems()
  1150.         for iEng in range(iNumImpulse):
  1151.             pImpulseChild = pImpulseSys.GetChildSubsystem(iEng)
  1152.             if pImpulseChild:
  1153.                 pImpulseChildCondition = pImpulseChild.GetCondition()
  1154.                 pImpulseChildMaxCondition = pImpulseChild.GetMaxCondition()
  1155.                 if (pImpulseChildCondition > 0):
  1156.                     return
  1157.  
  1158.  
  1159.         AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailImpulseParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
  1160.      
  1161.     pShipSet = pPlayer.GetPropertySet()
  1162.  
  1163.     pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
  1164.  
  1165.     iNumItems = pShipList.TGGetNumItems()
  1166.         pShipList.TGBeginIteration()
  1167.         for i in range(iNumItems):
  1168.         pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
  1169.         pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
  1170.  
  1171.         pImpulseSys = pPlayer.GetImpulseEngineSubsystem()
  1172.         if pImpulseSys:
  1173.             iNumImpulse = pImpulseSys.GetNumChildSubsystems()
  1174.             for iEng in range(iNumImpulse):
  1175.                         pImpulseChild = pImpulseSys.GetChildSubsystem(iEng)
  1176.                     pImpulseChild.SetCondition(1)
  1177.                
  1178. def AvailImpulseParts(pObject, pEvent):
  1179.         global BayParts, TotalParts, pAvailablePartsButton #, BayParts
  1180.  
  1181.         BayParts = BayParts - 10
  1182.         TotalParts = TotalParts - 10
  1183.  
  1184.         # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
  1185.         # pBodyMenu.DeleteChild(pPartsText)
  1186.         # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
  1187.         # pBodyMenu.AddChild(pPartsText)
  1188.         pInventoryMenu.KillChildren()
  1189.         # pBodyMenu.KillChildren()
  1190.         # CreateBodyMenu(pCargoBayWindow)
  1191.         CreatePartsTotalText(pCargoBayWindow)
  1192.         SpareParts(pCargoBayWindow)
  1193.         SelectCategory()
  1194.         # CreateInventoryMenu(pCargoBayWindow)
  1195.     return 0   
  1196.  
  1197. #############################################################################################
  1198. #                                                                                           #
  1199. #  This Section Handles Repairs to the Destroyed Impulse Engines,                           #
  1200. #                                                                                           #
  1201. #                                                                                           #
  1202. #                                                                                           #
  1203. #############################################################################################
  1204. #
  1205.  
  1206. def WarpE(pObject, pEvent):
  1207.  
  1208.         if BayParts < 20:
  1209.             pButton2.SetDisabled()
  1210.  
  1211.         pPlayer          = MissionLib.GetPlayer()
  1212.  
  1213.     pWarpSys = pPlayer.GetWarpEngineSubsystem()
  1214.  
  1215.     if pWarpSys:
  1216.         iNumWarp = pWarpSys.GetNumChildSubsystems()
  1217.         for iEng in range(iNumWarp):
  1218.             pWarpChild = pWarpSys.GetChildSubsystem(iEng)
  1219.             if pWarpChild:
  1220.                 pWarpChildCondition = pWarpChild.GetCondition()
  1221.                 pWarpChildMaxCondition = pWarpChild.GetMaxCondition()
  1222.                 if (pWarpChildCondition > 0):
  1223.                     return
  1224.  
  1225.  
  1226.         AvailPartsTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailWCoilsParts", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
  1227.      
  1228.     pShipSet = pPlayer.GetPropertySet()
  1229.  
  1230.     pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
  1231.  
  1232.     iNumItems = pShipList.TGGetNumItems()
  1233.         pShipList.TGBeginIteration()
  1234.         for i in range(iNumItems):
  1235.         pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
  1236.         pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
  1237.  
  1238.         pWarpSys = pPlayer.GetWarpEngineSubsystem()
  1239.         if pWarpSys:
  1240.             iNumWarp = pWarpSys.GetNumChildSubsystems()
  1241.             for iEng in range(iNumWarp):
  1242.                         pWarpChild = pWarpSys.GetChildSubsystem(iEng)
  1243.                     pWarpChild.SetCondition(1)
  1244.        
  1245. def AvailWCoilsParts(pObject, pEvent):
  1246.         global BayParts, TotalParts, pAvailablePartsButton #, BayParts
  1247.  
  1248.         BayParts = BayParts - 20
  1249.         TotalParts = TotalParts - 20
  1250.  
  1251.         # pAvailablePartsButton.SetName(App.TGString("Parts Total: " + str(BayParts)))
  1252.         # pBodyMenu.DeleteChild(pPartsText)
  1253.         # pPartsText = App.TGParagraph_Create("\nParts Total: " + str(BayParts))
  1254.         # pBodyMenu.AddChild(pPartsText)
  1255.         pInventoryMenu.KillChildren()
  1256.         # pBodyMenu.KillChildren()
  1257.         # CreateBodyMenu(pCargoBayWindow)
  1258.         CreatePartsTotalText(pCargoBayWindow)
  1259.         SpareParts(pCargoBayWindow)
  1260.         SelectCategory()
  1261.         # CreateInventoryMenu(pCargoBayWindow)
  1262.     return 0   
  1263.  
  1264. #############################################################################################
  1265. #                                                                                           #
  1266. #  This Section Destroys The Systems This is Purely For Testing Purposes,                   #
  1267. #  I have Kept these controls in incase you would like to test this mod the quick way       #
  1268. #                                                                                           #
  1269. #                                                                                           #
  1270. #############################################################################################
  1271.  
  1272. def BlowSystems(pObject, pEvent):
  1273.  
  1274.         pPlayer          = MissionLib.GetPlayer()
  1275.  
  1276.     pShipSet = pPlayer.GetPropertySet()
  1277.  
  1278.     pShipList = pShipSet.GetPropertiesByType(App.CT_SUBSYSTEM_PROPERTY)
  1279.  
  1280.     iNumItems = pShipList.TGGetNumItems()
  1281.         pShipList.TGBeginIteration()
  1282.         for i in range(iNumItems):
  1283.         pShipProperty = App.SubsystemProperty_Cast(pShipList.TGGetNext().GetProperty())
  1284.         pSubsystem = pPlayer.GetSubsystemByProperty(pShipProperty)
  1285.  
  1286.         pPower = pPlayer.GetPowerSubsystem()
  1287.         pPower.SetCondition(0)
  1288.  
  1289.         pShields = pPlayer.GetShields()
  1290.         pShields.SetCondition(0)
  1291.  
  1292.         pSensors = pPlayer.GetSensorSubsystem()
  1293.         pSensors.SetCondition(0)
  1294.  
  1295.         pWarpSys = pPlayer.GetWarpEngineSubsystem()
  1296.         if pWarpSys:
  1297.             iNumWarp = pWarpSys.GetNumChildSubsystems()
  1298.             for iEng in range(iNumWarp):
  1299.                         pWarpChild = pWarpSys.GetChildSubsystem(iEng)
  1300.                     pWarpChild.SetCondition(0)
  1301.        
  1302.         pImpulseSys = pPlayer.GetImpulseEngineSubsystem()
  1303.         if pImpulseSys:
  1304.             iNumImpulse = pImpulseSys.GetNumChildSubsystems()
  1305.             for iEng in range(iNumImpulse):
  1306.                         pImpulseChild = pImpulseSys.GetChildSubsystem(iEng)
  1307.                     pImpulseChild.SetCondition(0)
  1308.  
  1309. ##########################################################################################
  1310. #                                                                                        #
  1311. #                                                                                        #
  1312. #    Everything Below This Point simply handles the Media and veiwscreens DO NOT EDIT    # 
  1313. #                                                                                        #
  1314. #                                                                                        #
  1315. ##########################################################################################
  1316. def AddTimer (pObject, pEvent):
  1317.  
  1318.     # Play the sound
  1319.     pSound = App.TGSound_Create("sfx/Custom/RepairSystem/IncomingMsgLuiOS.wav", "Lui_OS", 2)
  1320.     pSound.SetSFX(0)
  1321.     pSound.SetInterface(1)
  1322.     App.g_kSoundManager.PlaySound("Lui_OS")
  1323.  
  1324.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".Briefing", App.g_kUtopiaModule.GetGameTime() + 3, 0, 0)
  1325.  
  1326. def Briefing (pObject, pEvent):
  1327.  
  1328.     pLiuSet = MissionLib.SetupBridgeSet("LiuSet", "data/Models/Sets/StarbaseControl/starbasecontrolRM.nif", -40, 65, -1.55)
  1329.     pLiu = App.CharacterClass_GetObject(pLiuSet, "Liu")
  1330.     if not (pLiu):
  1331.         pLiu = MissionLib.SetupCharacter("Bridge.Characters.Admiral_Liu", "LiuSet", 0, 0, 5)
  1332.  
  1333.     pSeq = MissionLib.NewDialogueSequence()
  1334.     pAction = App.TGScriptAction_Create("MissionLib", "ViewscreenOn", "LiuSet", "Liu", 200)
  1335.     pSeq.AppendAction(pAction)
  1336.     MissionLib.QueueActionToPlay(pSeq)
  1337.  
  1338.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".PlayLuiCommuniq", App.g_kUtopiaModule.GetGameTime() + 2, 0, 0)
  1339.  
  1340. def PlayLuiCommuniq (pObject, pEvent):
  1341.  
  1342.     pSound1 = App.TGSound_Create("sfx/Custom/RepairSystem/IncomingMsgLuiOS2a.wav", "Lui_OS2", 2)
  1343.     pSound1.SetSFX(0)
  1344.     pSound1.SetInterface(1)
  1345.     pAction = App.g_kSoundManager.PlaySound("Lui_OS2")
  1346.  
  1347.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".EndLuiComuniq", App.g_kUtopiaModule.GetGameTime() + 12, 0, 0)
  1348.  
  1349. def EndLuiComuniq (pObject, pEvent):
  1350.  
  1351.     pSeq = MissionLib.NewDialogueSequence()
  1352.     pAction = App.TGScriptAction_Create("MissionLib", "ViewscreenOff")
  1353.     pSeq.AppendAction(pAction)
  1354.     MissionLib.QueueActionToPlay(pSeq)
  1355.  
  1356.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".DamReport", App.g_kUtopiaModule.GetGameTime() + 2, 0, 0)
  1357.  
  1358. def DamReport (pObject, pEvent):
  1359.  
  1360.     pSound1 = App.TGSound_Create("sfx/Custom/RepairSystem/Damage.wav", "Lui_OS2", 2)
  1361.     pSound1.SetSFX(0)
  1362.     pSound1.SetInterface(1)
  1363.     pAction = App.g_kSoundManager.PlaySound("Lui_OS2")
  1364.  
  1365.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".WarpIn", App.g_kUtopiaModule.GetGameTime() + 180
  1366. , 0, 0)
  1367.  
  1368.  
  1369. def WarpIn (pObject, pEvent):
  1370.  
  1371.     global AddshipTimer
  1372.     pPlayer     = MissionLib.GetPlayer()
  1373.     pEnemyGroup     = MissionLib.GetEnemyGroup()
  1374.     pSet        = pPlayer.GetContainingSet()
  1375.  
  1376.  
  1377.     pTransportX = loadspacehelper.CreateShip("Transport", pSet, "SS Calgary", "", 300 )
  1378.     pTransportX.SetInvincible(1)
  1379.  
  1380.     vImpPoint = App.TGPoint3()
  1381.     vImpPoint.SetXYZ(0, 1, 0)
  1382.  
  1383.     pTransportX.SetImpulse(.1, vImpPoint, App.ShipClass.DIRECTION_MODEL_SPACE)
  1384.  
  1385.     global pFriendlies
  1386.     pMission = MissionLib.GetMission()
  1387.     pFriendlies = pMission.GetFriendlyGroup()
  1388.     pFriendlies.AddName("SS Calgary")
  1389.  
  1390.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".SotoOnScreen", App.g_kUtopiaModule.GetGameTime() + 10, 0, 0)
  1391.  
  1392.  
  1393.  
  1394. def SotoOnScreen (pObject, pEvent):
  1395.  
  1396.  
  1397.     pEBridgeSet = MissionLib.SetupBridgeSet("EBridgeSet", "data/Models/Sets/EBridge/EBridge.nif", 0, 0, 0)
  1398.     pSoto = App.CharacterClass_GetObject(pEBridgeSet, "Soto")
  1399.     if not (pSoto):
  1400.         pSoto = MissionLib.SetupCharacter("Bridge.Characters.Soto", "EBridgeSet", 0, 0, 0)
  1401.  
  1402.  
  1403.     pSeq = MissionLib.NewDialogueSequence()
  1404.     pAction = App.TGScriptAction_Create("MissionLib", "ViewscreenOn", "EBridgeSet", "Soto", -0, 0, 0)
  1405.     pSeq.AppendAction(pAction)
  1406.     MissionLib.QueueActionToPlay(pSeq)
  1407.  
  1408.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".GraffCall", App.g_kUtopiaModule.GetGameTime() + 2, 0, 0)
  1409.  
  1410.  
  1411. def GraffCall (pObject, pEvent):
  1412.  
  1413.     pSound1 = App.TGSound_Create("sfx/Custom/RepairSystem/Graffhail1.wav", "Graff_OS1", 2)
  1414.     pSound1.SetSFX(0)
  1415.     pSound1.SetInterface(1)
  1416.     pAction = App.g_kSoundManager.PlaySound("Graff_OS1")
  1417.  
  1418.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".EndGraffComuniq", App.g_kUtopiaModule.GetGameTime() + 12, 0, 0)
  1419.  
  1420.  
  1421. def EndGraffComuniq (pObject, pEvent):
  1422.  
  1423.     pSeq = MissionLib.NewDialogueSequence()
  1424.     pAction = App.TGScriptAction_Create("MissionLib", "ViewscreenOff")
  1425.     pSeq.AppendAction(pAction)
  1426.     MissionLib.QueueActionToPlay(pSeq)
  1427.  
  1428.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".BrexReady", App.g_kUtopiaModule.GetGameTime() + 1, 0, 0)
  1429.  
  1430.  
  1431. def BrexReady (pObject, pEvent):
  1432.  
  1433.     pSound1 = App.TGSound_Create("sfx/Custom/RepairSystem/ReadyForSupplies.wav", "Graff_OSX", 2)
  1434.     pSound1.SetSFX(0)
  1435.     pSound1.SetInterface(1)
  1436.     pAction = App.g_kSoundManager.PlaySound("Graff_OSX")
  1437.  
  1438.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".LowerShields", App.g_kUtopiaModule.GetGameTime() + 6, 0, 0)
  1439.  
  1440. def LowerShields (pObject, pEvent):
  1441.  
  1442.         pPlayer = MissionLib.GetPlayer()
  1443.         pShields = pPlayer.GetShields()
  1444.  
  1445.         if (pShields.IsOn() and not pShields.IsDisabled()):  
  1446.             pGame = App.Game_GetCurrentGame()
  1447.             pEpisode = pGame.GetCurrentEpisode()
  1448.             pMission = pEpisode.GetCurrentMission()
  1449.             Database = pMission.SetDatabase("data/TGL/Bridge Crew General.tgl")
  1450.  
  1451.             pSequence = App.TGSequence_Create()
  1452.             pSet = App.g_kSetManager.GetSet("bridge")
  1453.             pEngineer = App.CharacterClass_GetObject(pSet, "Engineer")
  1454.             pSequence.AppendAction(App.CharacterAction_Create(pEngineer, App.CharacterAction.AT_SAY_LINE, "LoweringShields", None, 0, Database))
  1455.             pSequence.AppendAction(App.TGScriptAction_Create("Actions.ShipScriptActions", "FlickerShields", 0, 10))
  1456.             pSequence.Play()
  1457.  
  1458.         # play the transport sound no matter if shields are online or not
  1459.        
  1460.         Sound = App.TGSound_Create("sfx/Custom/RepairSystem/Transport.wav", "Transport", 0)
  1461.     Sound.SetSFX(0)
  1462.     Sound.SetInterface(1)
  1463.     App.g_kSoundManager.PlaySound("Transport")
  1464.  
  1465.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".IncreaseParts", App.g_kUtopiaModule.GetGameTime() + 12, 0, 0)
  1466.  
  1467.  
  1468. def IncreaseParts (pObject, pEvent):
  1469.  
  1470.         Sound = App.TGSound_Create("sfx/Custom/RepairSystem/TransferSupplies.wav", "Transport8", 0)
  1471.     Sound.SetSFX(0)
  1472.     Sound.SetInterface(1)
  1473.     App.g_kSoundManager.PlaySound("Transport8")
  1474.  
  1475.  
  1476.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".WarpOut", App.g_kUtopiaModule.GetGameTime() + 5, 0, 0)
  1477.  
  1478.  
  1479. def WarpOut(pObject, pEvent):      
  1480.     pGame   = App.Game_GetCurrentGame()
  1481.     pEpisode    = pGame.GetCurrentEpisode()
  1482.     pMission    = pEpisode.GetCurrentMission()
  1483.     pPlayer = MissionLib.GetPlayer()
  1484.     pSet = pPlayer.GetContainingSet()
  1485.     pTransortX = App.ShipClass_GetObject(pSet, "SS Calgary")
  1486.  
  1487.    
  1488.     import AI.PlainAI.WarpAI
  1489.  
  1490.     pTransortX.SetAI(AI.PlainAI.WarpAI.CreateAI(pTransortX))
  1491.    
  1492.         AddshipTimer = MissionLib.CreateTimer(Lib.LibEngineering.GetEngineeringNextEventType(), __name__ + ".AvailSupplies", App.g_kUtopiaModule.GetGameTime() + 2, 0, 0)
  1493.  
  1494.  
  1495. def AvailSupplies(pObject, pEvent):
  1496.         global BayParts, pAvailablePartsButton, TotalParts
  1497.  
  1498.         BayParts = BayParts + 10
  1499.         TotalParts = TotalParts + 10
  1500.         # pGetSuppliesButton.SetEnabled()
  1501.         Bay2Inventory(pInventoryMenu)
  1502.         pInventoryMenu.ResizeToContents()
  1503.  
  1504.         # pAvailablePartsButton.SetName(App.TGString("Parts Count: " + str(BayParts)))
  1505.     return 0   
  1506.  
  1507. def SentSupplies(pObject, pEvent):
  1508.         global BayParts, pAvailablePartsButton, TotalParts
  1509.  
  1510.         BayParts = BayParts - 10
  1511.         TotalParts = TotalParts - 10
  1512.         # pSendSuppliesButton.SetEnabled()
  1513.         Bay2Inventory(pInventoryMenu)
  1514.         pInventoryMenu.ResizeToContents()
  1515.  
  1516.         # pAvailablePartsButton.SetName(App.TGString("Parts Count: " + str(BayParts)))
  1517.     return 0   
  1518.  
  1519. def ReplicateSupplies(pObject, pEvent):
  1520.         global BayParts, pAvailablePartsButton, TotalParts
  1521.  
  1522.         pPlayer = MissionLib.GetPlayer()
  1523.         pPower = pPlayer.GetPowerSubsystem()
  1524.         PowerOut        = pPower.GetPowerOutput()
  1525.         MainConduit     = pPower.GetMainConduitCapacity()
  1526.         MainBatteryPower = pPower.GetMainBatteryPower()
  1527.         MainBatteryLimit = pPower.GetMainBatteryLimit()
  1528.         ReserveConduit      = pPower.GetBackupConduitCapacity()
  1529.         ReserveBatteryPower = pPower.GetBackupBatteryPower()
  1530.         ReserveBatteryLimit = pPower.GetBackupBatteryLimit()   
  1531.         Transferenergy = MainBatteryLimit*0.1
  1532.        
  1533.         if MainBatteryPower <= 0.2:
  1534.             Bay2Inventory(pInventoryMenu)
  1535.             pInventoryMenu.ResizeToContents()
  1536.             return
  1537.        
  1538.         if MainBatteryPower > 0.2:
  1539.             pPower.SetMainBatteryPower(MainBatteryPower - Transferenergy)
  1540.        
  1541.         BayParts = BayParts + 5
  1542.         TotalParts = TotalParts + 5
  1543.         # pSendSuppliesButton.SetEnabled()
  1544.         Bay2Inventory(pInventoryMenu)
  1545.         pInventoryMenu.ResizeToContents()
  1546.  
  1547.         # pAvailablePartsButton.SetName(App.TGString("Parts Count: " + str(BayParts)))
  1548.     return 0   
  1549.  
  1550. def RecycleSupplies(pObject, pEvent):
  1551.         global BayParts, pAvailablePartsButton, TotalParts
  1552.  
  1553.         BayParts = BayParts - 5
  1554.         TotalParts = TotalParts - 5
  1555.         # pSendSuppliesButton.SetEnabled()
  1556.         Bay2Inventory(pInventoryMenu)
  1557.         pInventoryMenu.ResizeToContents()
  1558.  
  1559.         # pAvailablePartsButton.SetName(App.TGString("Parts Count: " + str(BayParts)))
  1560.     return 0   
  1561.    
  1562. # 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
  1563. # It seems I always have problems with this *sigh*
  1564.  
  1565. def CheckShip(pObject, pEvent): #ET_SET_PLAYER
  1566.  
  1567. # This little bit of scripting checks when the player ship changes
  1568.  
  1569.         pGame = App.Game_GetCurrentGame()
  1570.         pPlayer = pGame.GetPlayer()
  1571.         pPlayerName = pPlayer.GetName()
  1572.         pCargoBayWindow = GetCargoBayWindow()
  1573.         pWarpCore = pPlayer.GetPowerSubsystem()
  1574.         if pCargoBayWindow:
  1575.                 pBayButtons.SetVisible()
  1576.                 pCargoBayWindow.SetNotVisible()
  1577.                 ResetBayCount(None, None)
  1578.                 return
  1579.         else:
  1580.                 pBayButtons.SetVisible()
  1581.                 pCargoBayWindow.SetNotVisible()
  1582.                 ResetBayCount(None, None)
  1583.  
  1584. def ShipExploding(pObject, pEvent):
  1585. #                global CheckDef, pButtonSI, pSpecial
  1586.                 pPlayer = App.Game_GetCurrentGame().GetPlayer()
  1587.                 pCargoBayWindow = GetCargoBayWindow()
  1588.  
  1589.                 # Get the ship that is exploding.
  1590.                 pShip = App.ShipClass_Cast(pEvent.GetDestination())
  1591.                 if (pShip != None):
  1592.                         iShipID = pShip.GetObjID()
  1593.                         if pPlayer and pShip.GetName() == pPlayer.GetName():
  1594.                                 # It's us.  Reset.
  1595.                                 WindowClose(None, None) #close this crap, otherwise bad thing :[
  1596.  
  1597. def ResetBayCount(pObject, pEvent):
  1598.         debug(__name__ + ", ResetBayCount")
  1599.         # global CreateBayGUI, CreateWindows
  1600.         pGame = App.Game_GetCurrentGame()
  1601.         pEpisode = pGame.GetCurrentEpisode()
  1602.         pMission = pEpisode.GetCurrentMission()
  1603.         pCargoBayWindow = GetCargoBayWindow()
  1604.  
  1605.         # delete enable button timer
  1606.         try:
  1607.                 App.g_kTimerManager.DeleteTimer(pSendSuppliesTimer.GetObjID())
  1608.                 App.g_kRealtimeTimerManager.DeleteTimer(pSendSuppliesTimer.GetObjID())
  1609.                 pSendSuppliesTimer = None
  1610.                 App.g_kTimerManager.DeleteTimer(pGetSuppliesTimer.GetObjID())
  1611.                 App.g_kRealtimeTimerManager.DeleteTimer(pGetSuppliesTimer.GetObjID())
  1612.                 pGetSuppliesTimer = None
  1613.                 App.g_kTimerManager.DeleteTimer(pReplicateSuppliesTimer.GetObjID())
  1614.                 App.g_kRealtimeTimerManager.DeleteTimer(pReplicateSuppliesTimer.GetObjID())
  1615.                 pReplicateSuppliesTimer = None
  1616.  
  1617.         except:
  1618.                 pass
  1619.  
  1620.         # reenable the stuff we need (this seems to be all we need yay!)
  1621.         pCargoBayWindow.KillChildren()
  1622.         CreateWindows(pCargoBayWindow)
  1623.  
  1624.         # reset our end combat handelers
  1625.  
  1626.         pSaffiQB = GetMenuButton("Commander", "End Combat")
  1627.         pSaffiQBR = GetQBRMenuButton("Commander", "Configure")
  1628.         pSIQB = GetMenuButton("Science", "Special Options")
  1629.         pSIQBR = GetQBRMenuButton("Science", "Special Options")
  1630.        
  1631.         if pSaffiQB:
  1632.                 pSaffiQB.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".ResetBayCount")
  1633.                    
  1634.         if pSIQB:
  1635.                 pSIQB.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".ResetBayCount")
  1636.  
  1637.         if pSaffiQBR:
  1638.                 pSaffiQBR.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".ResetBayCount")
  1639.                    
  1640.         if pSIQBR:
  1641.                 pSIQBR.RemoveHandlerForInstance(App.ET_ST_BUTTON_CLICKED, __name__ + ".ResetBayCount")
  1642.            
  1643.         App.g_kEventManager.RemoveBroadcastHandler(App.ET_OBJECT_EXPLODING, pMission, __name__ + ".ShipExploding")
  1644.         App.g_kEventManager.RemoveBroadcastHandler(App.ET_SET_PLAYER, pMission, __name__ + ".ResetBayCount")
  1645.  
  1646. def SpareParts(pCargoBayWindow):
  1647.         global CargoCapacity
  1648.         pPlayer = MissionLib.GetPlayer()
  1649.         pHull = pPlayer.GetHull()
  1650.         pHullMaxHP = pHull.GetMaxCondition()
  1651.         CargoCapacity = 0
  1652.  
  1653.         if pHullMaxHP <= 7500:
  1654.             CargoCapacity = 150
  1655.  
  1656.         elif pHullMaxHP > 7500:
  1657.             CargoCapacity = 200
  1658.  
  1659.         # WIDTH = 0.3
  1660.         # HEIGHT = 0.3
  1661.         # X_POS = 0.21
  1662.         # Y_POS = 0.21
  1663.        
  1664.         # pPartsMenu = App.STSubPane_Create(WIDTH, HEIGHT)
  1665.  
  1666.         pCapacityInfo = App.TGParagraph_CreateW(App.TGString("Capacity:  " + str(CargoCapacity))) #+ " space remaining"
  1667.         pBodyMenu.AddChild(pCapacityInfo)
  1668.  
  1669.     pBodyMenu.ResizeToContents()
  1670.        
  1671.         # pBodyMenu.AddChild(pPartsMenu, X_POS, Y_POS)
  1672.  
  1673.         # pCapacityInfo = App.TGParagraph_CreateW(App.TGString("Capacity:  " + str(CargoCapacity) + " space remaining"))
  1674.         # pCargoBayWindow.AddChild(pCapacityInfo, 0.3, 0.3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement