Author Topic: Looking for help with a red alert mod.  (Read 1285 times)

Offline joshua101

  • Posts: 5
  • Cookies: 0
Looking for help with a red alert mod.
« 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 :)

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Looking for help with a red alert mod.
« Reply #1 on: April 25, 2010, 02:32:48 PM »
There might still be some problems as I haven't tested it thoroughly.

Code: [Select]
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)


               

Offline joshua101

  • Posts: 5
  • Cookies: 0
Re: Looking for help with a red alert mod.
« Reply #2 on: April 25, 2010, 02:47:17 PM »
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

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Looking for help with a red alert mod.
« Reply #3 on: April 25, 2010, 04:17:38 PM »
Quote
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

Offline joshua101

  • Posts: 5
  • Cookies: 0
Re: Looking for help with a red alert mod.
« Reply #4 on: April 25, 2010, 05:21:47 PM »
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?

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Looking for help with a red alert mod.
« Reply #5 on: April 25, 2010, 05:26:48 PM »
Is the qbautostart mutator on?

Offline joshua101

  • Posts: 5
  • Cookies: 0
Re: Looking for help with a red alert mod.
« Reply #6 on: April 25, 2010, 05:29:54 PM »
qb autostart is in the custom missions section rather than the mutators section should i re-install qb autostart?

Offline joshua101

  • Posts: 5
  • Cookies: 0
Re: Looking for help with a red alert mod.
« Reply #7 on: April 25, 2010, 05:34:11 PM »
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 :)

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Looking for help with a red alert mod.
« Reply #8 on: April 25, 2010, 06:18:55 PM »
Just found a small mistake.

In
Code: [Select]
               if (sType == App.CharacterClass.EST_ALERT_GREEN):
                        LoadSound()
                        pSound = App.g_kSoundManager.GetSound("RedAlertSound")

"RedAlertSound" needs to be replaced with "GreenAlertSound".

Offline JimmyB76

  • Posts: 6423
  • Cookies: 421
Re: Looking for help with a red alert mod.
« Reply #9 on: April 28, 2010, 03:12:21 PM »
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...

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Looking for help with a red alert mod.
« Reply #10 on: April 29, 2010, 08:37:23 AM »
I completely forgot about custom bridges. I'll look into it.

Offline FekLeyr Targ

  • DS9FX Team
  • Posts: 490
  • Cookies: 537
Re: Looking for help with a red alert mod.
« Reply #11 on: April 30, 2010, 05:17:52 PM »
I completely forgot about custom bridges. I'll look into it.
Good luck. I know that you can do it, guys. :)
TaH pagh, Tah be.

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Looking for help with a red alert mod.
« Reply #12 on: May 01, 2010, 06:59:29 PM »
This should do it. I've also added a mutator.

Offline FekLeyr Targ

  • DS9FX Team
  • Posts: 490
  • Cookies: 537
Re: Looking for help with a red alert mod.
« Reply #13 on: May 01, 2010, 07:02:16 PM »
This should do it. I've also added a mutator.
Downloaded.
I'll look into it ASAP.
TaH pagh, Tah be.

Offline Lurok91

  • Posts: 1309
  • Cookies: 2062
  • SPMod Developer (Retired)
    • Lurok91 Mods
Re: Looking for help with a red alert mod.
« Reply #14 on: May 28, 2010, 03:22:51 PM »
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.  

Offline JimmyB76

  • Posts: 6423
  • Cookies: 421
Re: Looking for help with a red alert mod.
« Reply #15 on: May 28, 2010, 06:12:39 PM »
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...

Offline Villain

  • Posts: 1480
  • Cookies: 71
  • The artist formerly known as Prime
Re: Looking for help with a red alert mod.
« Reply #16 on: May 29, 2010, 02:38:26 PM »
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


"The design is clearly ancient... Launched hundreds of thousands of years ago."

Quote from: JimmyB76
der-ner-ner-ner-ner ..... der-ner-ner-ner-ner .....
---
Quote from: Rick Sternbach, on the topic of the Galor Class' length
...Probably not, but the number I get(379.6m) could be considered ?original intent,? a term that I think I will be using from now on, and ?canon? be damned.

Offline flarespire

  • The one who breaks the cycle.
  • Posts: 1230
  • Cookies: 47
  • God Green God Dammit!
Re: Looking for help with a red alert mod.
« Reply #17 on: June 24, 2010, 05:34:03 PM »
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.