read BreenDrainer.py
class BreenDrainerWeaponDef(MultipleDisableDef):
def IsDrainYield(self):
debug(__name__ + ", IsDrainYield")
return 1
def OnYield(self, pShip, pInstance, pEvent, pTorp):
debug(__name__ + ", OnYield")
if FoundationTech.EffectsLib:
FoundationTech.EffectsLib.CreateSpecialFXSeq(pShip, pEvent, 'Damper')
pShipID = pShip.GetObjID()
pShip = App.ShipClass_Cast(App.TGObject_GetTGObjectPtr(pShipID))
# useless against stations
if not pShip or pShip.GetShipProperty().IsStationary():
return
pPlayer = MissionLib.GetPlayer()
if pPlayer.GetObjID() == pShip.GetObjID():
pVoice = App.g_kSoundManager.GetSound("PowerDisabled")
if pVoice:
pVoice.Play()
pSound = App.g_kSoundManager.GetSound("BreenDraining")
if not pSound:
pSound = App.TGSound_Create("sfx/BreenDraining.wav", "BreenDraining", 0)
if pSound:
pSound.Play()
if FoundationTech.BridgeFX:
FoundationTech.BridgeFX.CreateDrainEffect()
# disable glow on ship
if not pShip.IsDead(): # possible crash work around
pShip.DisableGlowAlphaMaps()
# clients shouldn't do anything here
if App.g_kUtopiaModule.IsMultiplayer() and not App.g_kUtopiaModule.IsHost():
return
pPower = pShip.GetPowerSubsystem()
if pPower:
IonSubSystem(pPower)
#pProp = pPower.GetProperty()
#pProp.SetPowerOutput(0.0)
#pProp.SetMainConduitCapacity(0.000001)
#pProp.SetBackupConduitCapacity(0.000001)
pShields = pShip.GetShields()
if pShields:
IonSubSystem(pShields)
pCloak = pShip.GetCloakingSubsystem()
if pCloak:
IonSubSystem(pCloak)
pImpulse = pShip.GetImpulseEngineSubsystem()
if pImpulse:
IonSubSystem(pImpulse)
pWarp = pShip.GetWarpEngineSubsystem()
if pWarp:
IonSubSystem(pWarp)
pWeaponSys = pShip.GetTorpedoSystem()
if pWeaponSys:
IonSubSystem(pWeaponSys)
pWeaponSys = pShip.GetPhaserSystem()
if pWeaponSys:
IonSubSystem(pWeaponSys)
pWeaponSys = pShip.GetPulseWeaponSystem()
if pWeaponSys:
IonSubSystem(pWeaponSys)
OnYield gets activated when FTech detects a BreenDrainer torpedo has hit something... FTech goes check WHAT actually hit WHAT, and if it's a torpedo, then it fires the OnTorpDefense function, which takes you to the OnYield function here.
... to sum things up: study these kind of scripts and you will learn how to create the reaction you need for a given input.
like I said, FTech is always checking specific events, yours included... you don't need to write another handler for an event that's already being watched by a larger framework... just add your effect to the queue of effects to be fired when the trigger goes off.