What I have newly added is a SystemEventHandler in the Systems folder. There I set different scripts that are to be started automatically, a spaceship enters a certain set. Currently this script does nothing more than play an automatic welcome message. I simply removed a few speaches from the missions and moved them into this script.
So when you enter certain systems, Kiska automatically says, "We have achieved XY." Unfortunately, the programmers of the game have not deposited such a voice message for all sets. But with some systems like Vesuvi, Tevron, Starbase12 or Serris it works.
from bcdebug import debug
import App
import MissionLib
import loadspacehelper
import Bridge.BridgeUtils
import Bridge.HelmMenuHandlers
import Bridge.Characters.Graff
###############################################################################
# SetupEventHandlers()
#
# Set up event handlers used by the Starbase 12 set.
#
# Args: pSet - The Starbase 12 set.
#
# Return: none
###############################################################################
def SetupEventHandlers():
debug(__name__ + ", SetupEventHandlers")
try:
pGame = App.Game_GetCurrentGame()
if pGame:
pEpisode = pGame.GetCurrentEpisode()
pPlayer = MissionLib.GetPlayer()
if pPlayer:
pSet = pPlayer.GetContainingSet()
# Ship entrance event
App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_ENTERED_SET, pSet, __name__ + ".EnterSet")
# Ship exit event
App.g_kEventManager.AddBroadcastPythonFuncHandler(App.ET_EXITED_SET, pSet, __name__ + ".ExitSet")
except:
pass
###############################################################################
# EnterSet(pObject, pEvent)
#
# Event handler for player's ship entering this set.
# Create the Starbase 12 Control Room Set when the player enters.
#
# Args:
#
# Return:
###############################################################################
def EnterSet(pObject, pEvent):
debug(__name__ + ", EnterSet")
pMission = MissionLib.GetMission()
pBridge = App.g_kSetManager.GetSet("bridge")
pHelm = App.CharacterClass_GetObject(pBridge, "Helm")
pSequence = App.TGSequence_Create()
pPreLoad = App.TGScriptAction_Create("MissionLib", "PreloadSequenceLines")
try:
# Get ship entering set.
pShip = App.ShipClass_Cast(pEvent.GetDestination())
pName = pShip.GetName()
pID = pShip.GetObjID()
# Get player.
pPlayer = MissionLib.GetPlayer()
except AttributeError:
# Ship or Player is None. Nothing to do here.
return
if pPlayer and (pID == pPlayer.GetObjID()):
if pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Starbase12":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E1M1ArriveStarbase1", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 1/E1M1.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
MissionLib.SetupGraffSet()
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Beol4":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E2M1PlayerInBeol1a", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 2/E2M1.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Biranu2":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E2M6ArriveBiranu1", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 2/E2M6.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Savoy1":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E3M1L058", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 3/E3M1.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Savoy3":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E3M1ArrivedSavoy3", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 3/E3M1.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Serris2":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E2M2ArriveSerris2-1", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 2/E2M2.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Serris3":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E2M2ArriveSerris3-1", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 2/E2M2.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Tevron2":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E2M0ArriveTevron1", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 2/E2M0.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Vesuvi4":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E3M2ShouldHail", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 3/E3M2.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Vesuvi5":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E2M1ArriveGeki1", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 2/E2M1.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
elif pShip.GetContainingSet() and pShip.GetContainingSet().GetName() == "Vesuvi6":
pKiskaArrive = App.CharacterAction_Create(pHelm, App.CharacterAction.AT_SAY_LINE, "E1M2ArriveHaven1", "Captain", 1, pMission.SetDatabase("data/TGL/Maelstrom/Episode 1/E1M2.tgl"))
pSequence.AppendAction(pKiskaArrive)
pSequence.Play()
App.TGActionManager_RegisterAction(pSequence, "Generic")
else:
return
else:
SetupAIHandler(pShip)
###############################################################################
# ExitSet(pObject, pEvent)
#
# Event handler for player's ship exiting this set.
# Delete the Starbase 12 Control Room Set when the player enters.
#
# Args:
#
# Return:
###############################################################################
def ExitSet(pObject, pEvent):
debug(__name__ + ", ExitSet")
try:
# Get ship exiting set.
pShip = App.ShipClass_Cast(pEvent.GetDestination())
# Get player.
pPlayer = App.Game_GetCurrentPlayer()
if pShip.GetObjID() != pPlayer.GetObjID():
# This ship isn't the player's ship. We're done.
return
except AttributeError:
# Ship or Player is None. Nothing to do here.
return
# The player's ship is exiting a set. Check if it's exiting
# the Starbase 12 set...
if pEvent.GetCString() == "Starbase12":
# Delete the Starbase 12 Control Room Set.
pStarbaseControlSet = App.g_kSetManager.GetSet("FedOutpostSet_Graff")
if pStarbaseControlSet:
App.g_kSetManager.DeleteSet("FedOutpostSet_Graff")
Bridge.Characters.Graff.RemoveEventHandlers()
# Disable dock button.
pButton = Bridge.BridgeUtils.GetDockButton()
if(pButton):
pButton.SetDisabled()
###############################################################################
# SetupAIHandler(pShip)
#
# Event handler for AI ship entering this set.
#
# Args:
#
# Return:
###############################################################################
def SetupAIHandler(pShip):
debug(__name__ + ", SetupAIHandler")
if pShip:
MissionLib.AddCommandableShip(pShip.GetName())
print pShip.GetObjID(), pShip.GetName(), "is not player - no arrive message for: ", pShip.GetContainingSet().GetName()
return
###############################################################################
# IsPlayerInsideStarbase12
#
# Check if the player's ship is inside the Starbase12 starbase.
#
# Args: None
#
# Return: True if the player is in the starbase, false if not.
###############################################################################
def IsPlayerInsideStarbase12():
# Check if the player and starbase 12 are in the Starbase12 set...
debug(__name__ + ", IsPlayerInsideStarbase12")
pPlayer = App.Game_GetCurrentPlayer()
if not pPlayer:
return 0
pSet = pPlayer.GetContainingSet()
if not pSet:
return 0
if pSet.GetName() != "Starbase12":
return 0
pStarbase = App.ShipClass_GetObject(pSet, "Starbase 12")
if not pStarbase:
return 0
# Both are. Check if the player is inside the starbase.
import AI.Compound.DockWithStarbase
return AI.Compound.DockWithStarbase.IsInViewOfInsidePoints(pPlayer, pStarbase)
###############################################################################
# HailStarbase12
#
# Hail Starbase 12.
#
# Args: pAction - The action triggering this function.
#
# Return: 0 or 1.
###############################################################################
def HailStarbase12(pAction):
# Get Player
debug(__name__ + ", HailStarbase12")
pPlayer = MissionLib.GetPlayer()
if pPlayer is None:
return 0
# Setup a sequence for Graff's stuff.
pSequence = App.TGSequence_Create()
# Set the viewscreen to watch Graff.
pSequence.AppendAction(App.TGScriptAction_Create("MissionLib", "ViewscreenOn", "FedOutpostSet_Graff", "Graff"))
# Have Graff say his greeting.
pSequence.AppendAction(App.TGScriptAction_Create("Bridge.Characters.Graff", "SayGreeting"))
# Turn off the viewscreen.
pSequence.AppendAction(App.TGScriptAction_Create("MissionLib", "ViewscreenOff"))
# pAction is done when pSequence is done.
pDoneEvent = App.TGObjPtrEvent_Create()
pDoneEvent.SetEventType(App.ET_ACTION_COMPLETED)
pDoneEvent.SetDestination(App.g_kTGActionManager)
pDoneEvent.SetObjPtr(pAction)
pSequence.AddCompletedEvent(pDoneEvent)
MissionLib.QueueActionToPlay(pSequence)
return 1
###############################################################################
# DockStarbase12(pAction)
#
# Similar to HailStarbase12 script action, but used for when the
# player docks with the starbase, rather than just hailing it.
#
# Args: pAction - The action calling this function.
# pGraffAction - If this isn't None, this action will be played
# in place of Graff's usual greeting action.
# bNoRepair - If true, no repairing will be done, only reloading.
#
# Return: none
###############################################################################
def DockStarbase12(pAction, pGraffAction = None, bNoRepair = 0, bFadeEnd = 1):
debug(__name__ + ", DockStarbase12")
# Get Player
pPlayer = MissionLib.GetPlayer()
if pPlayer is None:
return 0
# Take down Helm menu and turn character back.
pBridgeSet = App.BridgeSet_Cast(App.g_kSetManager.GetSet("bridge"))
pHelm = App.CharacterClass_GetObject (pBridgeSet, "Helm")
if pHelm is None:
return 0
pHelm.MenuDown()
pHelm.TurnBack()
# Setup a sequence for Graff's stuff.
pSequence = App.TGSequence_Create()
# Make sure the rendered set is the Bridge.
sOldSet = App.g_kSetManager.GetRenderedSet().GetName()
pSequence.AppendAction(App.TGScriptAction_Create("Actions.CameraScriptActions", "ChangeRenderedSet", "bridge"))
# Set the viewscreen to watch Graff.
pSequence.AppendAction(App.TGScriptAction_Create("MissionLib", "ViewscreenOn", "FedOutpostSet_Graff", "Graff"))
# Have Graff say his greeting.
if pGraffAction is None:
pSequence.AppendAction(App.TGScriptAction_Create("Bridge.Characters.Graff", "SayGreeting"))
else:
# debug("Triggering custom Graff action.")
pSequence.AppendAction(pGraffAction)
# Automatically reload & repair the player's ship.
if not bNoRepair:
pSequence.AppendAction(App.TGScriptAction_Create("Actions.ShipScriptActions", "RepairShipFully", pPlayer.GetObjID()))
pSequence.AppendAction(App.TGScriptAction_Create("Actions.ShipScriptActions", "ReloadShip", pPlayer.GetObjID()))
# Fade out... Something else will fade us back in later.
if bFadeEnd:
pSequence.AppendAction( App.TGScriptAction_Create("MissionLib", "FadeOut") )
# Turn off the viewscreen.
pSequence.AppendAction(App.TGScriptAction_Create("MissionLib", "ViewscreenOff"))
# Change the rendered set back to whatever it used to be.
pSequence.AppendAction(App.TGScriptAction_Create("Actions.CameraScriptActions", "ChangeRenderedSet", sOldSet), 0.5)
# pAction is done when pSequence is done.
pDoneEvent = App.TGObjPtrEvent_Create()
pDoneEvent.SetEventType(App.ET_ACTION_COMPLETED)
pDoneEvent.SetDestination(App.g_kTGActionManager)
pDoneEvent.SetObjPtr(pAction)
pSequence.AddCompletedEvent(pDoneEvent)
pSequence.Play()
return 1