Bridge Commander Central
BC Forums => BC Bridge Modding => Topic started by: joshua101 on April 24, 2010, 08:04:50 PM
-
Hello,
I am fluent in VB code and C but mod-ing BC has completely stumped me.
Basically i would like to mod bc so that the red alert sound loops when at red alert, this would make the game more true to that you see in the tv shows and films. When you get legends such as kirk yelling shut that noise off .....
I thought that a button could be added to first officer menu allowing for siren to be muted should it become annoying.
Hoping somebody will offer help.
P.S. you guys keep me enthused with BC, thanks for all the mods you've already created :)
-
There might still be some problems as I haven't tested it thoroughly.
import App
import MissionLib
import Libs.LibEngineering
import Foundation
import Bridge.BridgeUtils
def init():
pGame = App.Game_GetCurrentGame()
#pEpisode = pGame.GetCurrentEpisode()
#pMission = pEpisode.GetCurrentMission()
pXOMenu = Bridge.BridgeUtils.GetBridgeMenu("XO")
Libs.LibEngineering.CreateMenuButton("Mute Alert Sound", "XO", __name__ + ".MuteSound")
pXOMenu.AddPythonFuncHandlerForInstance(App.ET_SET_ALERT_LEVEL, __name__ + ".AlertLevel")
def LoadSound():
pGame = App.Game_GetCurrentGame()
pBridgeRegion = App.TGSoundRegion_GetRegion("bridge")
pBridgeRegion.SetFilter(App.TGSoundRegion.FT_NONE)
for sFile, sSound, fVolume in (
("sfx/redalert.wav", "RedAlertSound", 1.0),
("sfx/yellowalert.wav", "YellowAlertSound", 1.0),
("sfx/greenalert.wav", "GreenAlertSound", 1.0)
):
pSound = pGame.LoadSoundInGroup(sFile, sSound, "BridgeGeneric")
pBridgeRegion.AddSound(pSound)
pSound.SetVolume(1.0)
def AlertLevel(pObject, pEvent):
sType = pEvent.GetInt()
pGame = App.Game_GetCurrentGame()
pPlayer = App.ShipClass_Cast(pGame.GetPlayer())
if (App.IsNull(pPlayer)):
pObject.CallNextHandler(pEvent)
return
sLevel = 0
if (sType == App.CharacterClass.EST_ALERT_GREEN):
sLevel = pPlayer.GREEN_ALERT
if (sType == App.CharacterClass.EST_ALERT_YELLOW):
sLevel = pPlayer.YELLOW_ALERT
if (sType == App.CharacterClass.EST_ALERT_RED):
sLevel = pPlayer.RED_ALERT
if (sLevel != pPlayer.GetAlertLevel()):
if (sType == App.CharacterClass.EST_ALERT_GREEN):
LoadSound()
pSound = App.g_kSoundManager.GetSound("RedAlertSound")
if (pSound != None):
pSound.SetLooping(0)
pSound.SetPriority(1.0)
pSound.Play()
print "green alert"
MuteSound(pObject, pEvent)
if (sType == App.CharacterClass.EST_ALERT_YELLOW):
LoadSound()
pSound = App.g_kSoundManager.GetSound("YellowAlertSound")
if (pSound != None):
pSound.SetLooping(0)
pSound.SetPriority(1.0)
pSound.Play()
print "yellow alert"
MuteSound(pObject, pEvent)
if (sType == App.CharacterClass.EST_ALERT_RED):
print "red alert"
LoadSound()
pSound = App.g_kSoundManager.GetSound("RedAlertSound")
if (pSound != None):
pSound.SetLooping(1)
pSound.SetPriority(1.0)
pSound.Play()
pAlertEvent = App.TGIntEvent_Create()
pAlertEvent.SetSource(pObject)
pAlertEvent.SetDestination(pPlayer)
pAlertEvent.SetEventType(App.ET_SET_ALERT_LEVEL)
pAlertEvent.SetInt(sLevel)
App.g_kEventManager.AddEvent(pAlertEvent)
pObject.CallNextHandler(pEvent)
def MuteSound(pObject, pEvent):
try:
App.g_kSoundManager.StopSound("RedAlertSound")
except:
pass
pObject.CallNextHandler(pEvent)
-
Wow Thanks hugely for your reply, i was beginning to think nobody would be able to help :D
don't suppose you could do me one more favour and suggest where i should install this in-order to make it take effect.
Once again thanks for replying, I know its a small thing in the game but I have been trying to do it for quite sometime and its the most frustrating thing ever, as I always end-up hitting an irreversible BSOD and having to uninstall and reinstall my game.
Josh
-
don't suppose you could do me one more favour and suggest where i should install this in-order to make it take effect.
scripts\Custom\qbautostart
-
i created a .py file called alertstatus and placed the code inside the qbautosatart file but when i launch into bc quickbattle it takes no effect. Am i going wrong here?
-
Is the qbautostart mutator on?
-
qb autostart is in the custom missions section rather than the mutators section should i re-install qb autostart?
-
ahh cool now it works thanks :D
Now to conqour the single player mode :P I must have a dig around i think
Thanks for everything :)
-
Just found a small mistake.
In
if (sType == App.CharacterClass.EST_ALERT_GREEN):
LoadSound()
pSound = App.g_kSoundManager.GetSound("RedAlertSound")
"RedAlertSound" needs to be replaced with "GreenAlertSound".
-
an interesting script...
i wonder if it is possible that it could be made to recognize BP Core? at the moment, it only recognizes the default alert.wav's in the sfx folder, rather than the different alert sounds per bridge...
-
I completely forgot about custom bridges. I'll look into it.
-
I completely forgot about custom bridges. I'll look into it.
Good luck. I know that you can do it, guys. :)
-
This should do it. I've also added a mutator.
-
This should do it. I've also added a mutator.
Downloaded.
I'll look into it ASAP.
-
Very useful script. *Cookie* Just wondering: how does BC know how long to play the standard red alert for? Is it length of wav? Or defined in script somewhere? I want to experiment with extending length of red alert, but not looping.
-
Is it length of wav?
yep
altho sometimes in BC, weapons fire and such will cut off the red alert wav, no matter how long you have it recorded to run...
-
yep
altho sometimes in BC, weapons fire and such will cut off the red alert wav, no matter how long you have it recorded to run...
That'd be weapons systems drawing power from the lights. :funny
-
That'd be weapons systems drawing power from the lights. :funny
LOL :funny and this may come in handy if we can make it so weapons fire doesnt interfere with it.