Bridge Commander Central

BC Forums => BC Scripting => Topic started by: JB2005 on September 26, 2021, 04:51:19 PM

Title: Auto-Eject Warp Core
Post by: JB2005 on September 26, 2021, 04:51:19 PM
Hi All!

Long time no speak! With GOG re-releasing BC, I've been playing through the game again, and earlier this afternoon had an idea for a little script to protect the ship, before a Core Breach can destroy the ship:

Code: [Select]
###############################################################################
# Filename: CoreEjectAuto.py
#
# Neither Confidential nor Proprietary, Apologies to Totally Games!
#
# Gives Brex Agency to eject the Warp Core if the damage level reaches
# 95%
#
# Created: 26/09/21 - JB2005
###############################################################################

import Lib.LibEngineering
import Custom.Sneaker.CoreEject.SneakerCoreMenuHandlers
import App
import MissionLib

pButton = None

def init():

        global pButton
        pButton = Lib.LibEngineering.CreateMenuButton("Eject Core", "Engineer", __name__ + ".Eject")
        pButton.SetChoosable(1)
        App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_WEAPON_HIT, MissionLib.GetMission(), __name__ + ".EjectAuto")
       

def Eject(pObject, pEvent):

        global pButton

        print pButton.IsChosen()

        if pButton.IsChosen() == 0:
            pButton.SetChosen(1)
            return 0

        if pButton.IsChosen() == 1:
            pButton.SetChosen(0)
            return 0

def EjectAuto(pObject, pEvent):

pGame = App.Game_GetCurrentGame()
pPlayer = pGame.GetPlayer()
        pPlayerPower = pPlayer.GetPowerSubsystem()
        pLevel = pPlayerPower.GetCondition() / pPlayerPower.GetMaxCondition()

        print(pLevel)

        if pLevel > 0.05:
            return

        if pButton.IsChosen() == 0:
            return
       
        Custom.Sneaker.CoreEject.SneakerCoreMenuHandlers.CoreEject(pObject, pEvent)

It requires Sneaker 98's Core Eject Mod to work, and the file just drops into the QBAutostart folder!
Title: Re: Auto-Eject Warp Core
Post by: JimmyB76 on September 26, 2021, 07:04:29 PM
How very cool!!
Good to see ya around here again  😁
Title: Re: Auto-Eject Warp Core
Post by: Blackrook32 on September 26, 2021, 09:31:15 PM
How very cool!!
Good to see ya around here again  😁

Agreed! Very interesting script, JB. Definitely adding this to my install! :D

Assimilated and cookied :thumbsup:
Title: Re: Auto-Eject Warp Core
Post by: Nebula on September 27, 2021, 12:33:11 AM
oooh Welcome back and with such a nice addition to boot!
Title: Re: Auto-Eject Warp Core
Post by: ACES_HIGH on September 27, 2021, 03:10:17 PM
it should have like a 75% chance of the ejection system being offline.  :wink:
Title: Re: Auto-Eject Warp Core
Post by: JB2005 on September 27, 2021, 03:45:29 PM
Thanks for the feedback :)

Another one, along the same lines:

Code: [Select]
###############################################################################
# Filename: AbandonShipAuto.py
#
# Neither Confidential nor Proprietary, Apologies to Totally Games!
#
# Gives Saffi agency to evacuate the ship if the Hull Damage Level reaches
# 95%
#
# Created: 26/09/21 - JB2005
###############################################################################

import Lib.LibEngineering
import Custom.Sneaker.CoreEject.SneakerCoreMenuHandlers
import App
import MissionLib

pButton = None

def init():

        global pButton
        pButton = Lib.LibEngineering.CreateMenuButton("Auto Abandon Ship", "XO", __name__ + ".Abandon")
        pButton.SetChoosable(1)
        App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_WEAPON_HIT, MissionLib.GetMission(), __name__ + ".AbandonAuto")
       

def Abandon(pObject, pEvent):

        global pButton

        print pButton.IsChosen()

        if pButton.IsChosen() == 0:
            pButton.SetChosen(1)
            return 0

        if pButton.IsChosen() == 1:
            pButton.SetChosen(0)
            return 0

def AbandonAuto(pObject, pEvent):

pGame = App.Game_GetCurrentGame()
pPlayer = pGame.GetPlayer()
        pHullLevel = pPlayer.GetHull()
        pLevel = pHullLevel.GetCondition() / pHullLevel.GetMaxCondition()

        Abandon_Ship = __import__("Abandon Ship")

        print(pLevel)

        if pLevel > 0.05:
            return

        if pButton.IsChosen() == 0:
            return
       
        Abandon_Ship.StartAbandonShip(pObject, pEvent)

Triggers the Abandon Ship Mod if the hull reaches 95% damage.

I tested this one by loading a quick battle game and just sat stationary with the shields off whilst another ship attacked me - luckily I had the Auto-Eject button on, because the AI decided to target the Warp Core!
Title: Re: Auto-Eject Warp Core
Post by: Haxxor1337 on October 01, 2021, 02:13:33 AM
Thank you :) Welcome back  :yay: