Bridge Commander Central
BC Forums => BC Scripting => Topic started by: Nighthawk on January 31, 2007, 08:33:43 AM
-
Some months ago, USS Sovereign from BCS did a mod pack which included Thalaron Radiation, Deflector Pulse and Self-Meinheim
what I'm doing now, as a script training, is trying to improve that Deflector Pulse mod. although it was never released on bcfiles, he said he made it to use a tractor beam to get the effect. I'm planning to tweak it a bit using phasers (more like Elminster's BOBW Galaxy) and ...... well, using any addition I discover while working on it.....
In case you wonder, no, I didn't get Deflector Pulse Beta by Sovereign and I never will, thread is outdated, and so are the links....
I'm building this preety much looking at other scripter's works (ACO, BCSTB, EO, RDS, PW), although some lines were build completely from scratch.
here is what I got so far. suggestions/critics/head-ups are welcomed.
import App
import MissionLib
import Libs.LibEngineering
import Foundation
import string
def init():
global pPlayer
global Stat
global Load
global pPower
global pSensors
Stat = 0
pPower = 0.1
pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pMission = pEpisode.GetCurrentMission()
App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_SET_PLAYER, pMission, __name__ + ".LoadPlugin")
def LoadPlugin(pObject, pEvent):
global pPlugin, pPlayer
pPlayer = MissionLib.GetPlayer()
pPlugin = None
pPlugin = GetShipName(pPlayer)
try:
# Attempt to load the plugin
pModule = __import__("Custom.Tech.DeflectorBeam." + pPlugin)
if hasattr(pModule, "SHIP_NAME"):
# All is ok, retrieve the value
HPName = pModule.SHIP_NAME()
if pPlugin == HPName:
# OK, build the interface
CreateButtons()
# Give a console printout of an unsuccessfull Plugin Loading
else:
print "Deflector Beam Plugin for ", HPName, " failed. Please notify BCS:TNG"
else:
#Failure to locate key / plugin has no key
print "Plugin is invalid. Please contact BCS:TNG"
# No plugins we won't do anything
except:
return
#^^Thanks BCSTNG for this procedure :D
def GetShipName(pShip):
if pShip.GetScript():
return string.split(pShip.GetScript(), '.')[-1]
return None
def CreateButtons():
global pMenu, pMenu2, pFire, pModify, pOverload, Stat
# Grabbing menues and appending sub-menues
pBridge = App.g_kSetManager.GetSet('bridge')
pTacticalMenu = Libs.LibEngineering.GetBridgeMenu("Tactical")
pEngineerMenu = Libs.LibEngineering.GetBridgeMenu("Engineer")
pMenu = App.STMenu_CreateW(App.TGString("Deflector Control"))
pTacticalMenu.PrependChild(pMenu)
pMenu2 = App.STMenu_CreateW(App.TGString("Deflector Control"))
pEngineerMenu.PrependChild(pMenu2)
# Setup buttons
pModify = Libs.LibEngineering.CreateMenuButton("Modify Structure", "Engineer", __name__ + ".Modify", 0, pMenu2)
pFire = Libs.LibEngineering.CreateMenuButton("Fire", "Tactical", __name__ + ".Fire", 0, pMenu)
pOverload = Libs.LibEngineering.CreateMenuButton("Overload Deflector", "Tactical", __name__ + ".Overload", 0, pMenu)
# Disable some options
pModify.SetEnabled()
Stat = 1
pOverload.SetDisabled()
pFire.SetDisabled()
def Modify(pObject, pEvent):
global Stat, pSensors, pPower, pSensorPower
if Stat:
#Grabbing Sensor System and its values
pSensors = pPlayer.GetSensorSubsystem()
if (pSensors.GetCondition() > pSensors.GetDisabledPercentage()):
#Only modify if sensors are operational
pSensorPower = pSensors.GetProperty().GetNormalPowerPerSecond()
pSensorLevel = pSensors.GetNormalPowerPercentage()
pSensorRange = pSensors.GetProperty().GetBaseSensorRange()
#Cutting Sensors down because of the modification work
pSensors.GetProperty().SetNormalPowerPerSecond(pSensorPower * 0.2) #Lower the power consumption....
pSensors.SetPowerPercentageWanted(pPower) #... and also cut power to the sensors. Sensors now cause barely no drain to the warpcore...
pSensors.SetBaseSensorRange(pSensorRange * 0.01) #... thus reducing the range.
RepairTime = int(pSensors.GetMaxCondition() * 0.4 / 2)
MissionLib.CreateTimer(Libs.LibEngineering.GetEngineeringNextEventType(), __name__ + ".EnableDeflectorForLoad", App.g_kUtopiaModule.GetGameTime() + RepairTime, 0, 0)
pModify.SetName(App.TGString("Setting up.."))
pModify.SetDisabled()
Sound = App.TGSound_Create("sfx/Custom/DeflectorBeam/ACK.mp3", "ACK", 0)
Sound.SetSFX(0)
Sound.SetInterface(1)
App.g_kSoundManager.PlaySound("ACK")
App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_SUBSYSTEM_POWER_CHANGED, pMission, __name__ + ".ControlSensors")
else:
print "Sensors disabled"
pass
else:
print "Stat = 0"
pass
def EnableDeflectorForLoad(pObject, pEvent):
global Stat, pModify, pOverload, pPower, pSensorPower
#Deflector has been modified. Show the status and enable Overload
Stat = 0
pPower = 0.05 #Lower the power level way lower. Preparing for the big bang....
pModify.SetName(App.TGString("Deflector Ready"))
pModify.SetEnabled()
pOverload.SetEnabled()
pSensors.GetProperty().SetNormalPowerPerSecond(pSensorPower * 2.5) #Setting the overall power, not the current power. Current power remains, this far, in 5%
DisableScienceMenu() #Since we don't have sensors, disable anything related with them
def Overload(pObject, pEvent):
#Still have to figure out how to overload slowly, kinda progress bar scrolling. Timer/Loop needed.
return
def ControlSensors(pObject, pEvent):
global pSensors, pPower
pSensors.SetPowerPercentageWanted(pPower)
def DisableScienceMenu(pObject, pEvent):
#From KM's CheckDockButton and stock handlers. *hopes this works*
pDatabase = App.g_kLocalizationManager.Load("data/TGL/Bridge Menus.tgl")
BScanArea = pDatabase.GetString("Scan Area")
BScanTarget = pDatabase.GetString("Scan Target")
BLaunchProbe = pDatabase.GetString("Launch Probe")
App.g_kLocalizationManager.Unload(pDatabase)
pMenu = Lib.LibEngineering.GetBridgeMenu("Science")
try:
pSubmenu = pMenu.GetSubmenu("Phalantium Wave") #
BCharge = pSubmenu.GetButton("Charge") #
BFire = pSubmenu.GetButton("Fire") #Tried to optimize and improvised. Not sure
BCharge.SetDisabled() #
BFire.SetDisabled() #
except:
print "PhalWave not present. skipping"
Lib.LibEngineering.GetButton(BScanArea.GetCString(), pMenu).SetDisabled()
Lib.LibEngineering.GetButton(BScanTarget.GetCString(), pMenu).SetDisabled()
Lib.LibEngineering.GetButton(BLaunchProbe.GetCString(), pMenu).SetDisabled()
Download (http://files.filefront.com/Deflectorwmv/;6661377;;/fileinfo.html) video preview of the overload sequence
-
so, the overloading sequence and a good part of the restart procedure is done. now I'm having a hard issue here, so if anyone can help me to sort this out, will be greatly thanked.
I need to build a sequence based mostly in audio and animations (turn to captain and push buttons, just that.), what should I use? a TGL for the dialogues and sound and build the animation sequence via code or build everything via code?
MissionLib has "SubtitledLine()" that seems to play a dialogue line given database and line ID, but I didn't see it in third-party scripts, is it worth it?
-
i normally use TGLs they are used in the missions and seem to work fairly well,
Code From NF Distress Calls:
pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pMission = pEpisode.GetCurrentMission()
gp_Database = pMission.SetDatabase("data/TGL/NewFrontier/General.tgl")
pSequence = App.TGSequence_Create()
pBridge = App.g_kSetManager.GetSet("bridge")
pKiska = App.CharacterClass_GetObject(pBridge, "Helm")
pSaffi = App.CharacterClass_GetObject(pBridge, "XO")
pISID1 = pSequence.AppendAction(App.CharacterAction_Create(pKiska, App.CharacterAction.AT_SAY_LINE, "IncomingSID1", None, 0, gp_Database))
pISID2 = pSequence.AppendAction(App.CharacterAction_Create(pKiska, App.CharacterAction.AT_SAY_LINE, "IncomingSID2", None, 0, gp_Database))
pISID3 = pSequence.AppendAction(App.CharacterAction_Create(pKiska, App.CharacterAction.AT_SAY_LINE, "IncomingSID3", None, 0, gp_Database))
pSID = pSequence.AppendAction(App.CharacterAction_Create(pKiska, App.CharacterAction.AT_SAY_LINE, "GenericDistress", None, 0, gp_Database))
pORD = pSequence.AppendAction(App.CharacterAction_Create(pSaffi, App.CharacterAction.AT_SAY_LINE, "Orders", None, 0, gp_Database))
pSequence.AppendAction(pISID1)
pSequence.AppendAction(pISID2)
pSequence.AppendAction(pISID3)
pSequence.AppendAction(pORD)
pSequence.Play()
-
ok, that would work if I had to use characters to play lines, actually I do, but I want to add an instruction so the sequence can play a sound which is made by the computer.
the sequence is:
Brex-Saffi-Computer-Brex-Computer
I tried adding the sound to the sequence and also playing them outside the sequence. nothing worked.
I'm adding the code you posted to the script *crosses fingers*
EDIT: just had a vague tought: "App.TGSoundAction_Create()" they used it in MissionLib, I think.