Bridge Commander Central
BC Forums => BC Scripting => Topic started by: ChronowerX_GT on June 19, 2008, 12:33:18 PM
-
I've been trying various fleet shots using the "Edit ()" command but when I exit it and go back to normal QB all the ships fly off into different positions. To stop this i've been transporting to every ship and manually disableing the engines but with 20 ships in the map it takes quite a while. Is there any script avaliable that allows me to destroy every engine in the map, without visable damage, by just clicking on a button? Or how would I go about creating one? Thanks.
-
Stick this in a file you can easily remember (in scripts/):
import App
def disableAllEngines():
pPlayer = App.Game_GetCurrentPlayer()
pSet = pPlayer.GetContainingSet()
ObjTuple = pSet.GetClassObjectList(App.CT_SHIP)
if ObjTuple:
for pShip in ObjTuple:
if pShip:
pShip.ClearAI()
What this actually does, is making the ships not think (including the player), so they also won't fire weapons.
If you need that, then that's also possible through scripts.
Then, in the console:
from <<YourChosenNameHere>> import *And then you can do:
disableAllEngines()
Also, this script assumes the player ship is in the set which contains all the ships you want to disable engines for.
-
As for the button:
import App
# if you have scripts\Lib\LibEngineering.py(c)
import Lib.LibEngineering
def init():
Lib.LibEngineering.CreateMenuButton("The name of your button", "Tactical", __name__ + ".disableAllEngines")
# else (i dont' know if it is part of stock bc):
def init():
pTacticalControlWindow = App.TacticalControlWindow_GetTacticalControlWindow()
if not pTacticalControlWindow:
print "Error: No Tactical Control Window"
return None
pDatabase = App.g_kLocalizationManager.Load("data/TGL/Bridge Menus.tgl")
pMenu = pTacticalControlWindow.FindMenu(pDatabase.GetString("Tactical"))
App.g_kLocalizationManager.Unload(pDatabase)
ET_EVENT = App.Mission_GetNextEventType()
pMenu.AddPythonFuncHandlerForInstance(ET_EVENT, __name__ + ".disableAllEngines")
pEvent = App.TGIntEvent_Create()
pEvent.SetEventType(ET_EVENT)
pEvent.SetDestination(pMenu)
pEvent.SetInt(EventInt)
pButton = App.STButton_CreateW(App.TGString("The name of your button"), pEvent)
pMenu.PrependChild(pButton)
# in both cases:
def disableAllEngines(pObject, pEvent):
pPlayer = App.Game_GetCurrentPlayer()
pSet = pPlayer.GetContainingSet()
ObjTuple = pSet.GetClassObjectList(App.CT_SHIP)
if ObjTuple:
for pShip in ObjTuple:
if pShip:
pShip.ClearAI()
pObject.CallNextHandler(pEvent)
you do the same as MLeo said only that you type into the console
init()instead of
from <<YourChosenNameHere>> import *
If you have QBautostart installed place the script into scripts/Custom/QBautostart and the button wil be loaded automatically when you start QB.
NOTE: the code in the second init method is a copy of some code in LibEngineering so I'm not the autor, i only changed some variables!
-
Great, thanks a lot. I'll try them out as soon as I get on my desktop.
-
Thanks guys, the script worked great. Just what I wanted. Since the thread's served it purpouse i'll lock it.