13
« Last post by Mark McWire on January 10, 2026, 09:32:54 AM »
import App # imports API to game engine
# Example entry for weapon launch sound.
# This text should be defined either in StaticDefs.py or in a script file in Custom/Autoload/.
import Foundation # imports Foundation API
Foundation.SoundDef( "sfx/Weapons/ion_cannon.wav", "Ion Cannon", 1.0, { 'modes': [ Foundation.MutatorDef.StockSounds ] } )
def Create(pTorp):
kCoreColor = App.TGColorA() # Creating a core color object
kCoreColor.SetRGBA(240.0 / 255.0, 60.0 / 255.0, 10.0 / 255.0, 1.000000) # Core color as RGB-Code
kGlowColor = App.TGColorA() # Creating a glow color object
kGlowColor.SetRGBA(180.0 / 255.0, 40.0 / 255.0, 40.0 / 255.0, 1.000000) # Glow color as RGB-Code
kFlareColor = App.TGColorA() # Creating a flare color object
kFlareColor.SetRGBA(80.0 / 255.0, 120.0 / 255.0, 70.0 / 255.0, 1.000000) # Flare color as RGB-Code
pTorp.CreateTorpedoModel( # Creating the torpedo object itself
"data/Textures/Tactical/TorpedoCore.tga", # Relative path to the texture file
kCoreColor, # Reference to the core color object
0.2, # The scale of the core in relation the the rest of the torpedo.
1.0, # The rate at which the torpedo rotates ingame. This affects flares and how fast the rotate (Larger = Faster)
"data/Textures/Tactical/TorpedoGlow.tga", # Relative path to the texture file
kGlowColor, # Reference to the glow color object
4.0, # Specifies the rate at which the glow will pulsate. (Larger = Faster Pulse)
0.2, # The minimum size of the glow.
0.7, # The maximum size of the glow. (Determines how much the glow will increase from the minimum size to the large size)
"data/Textures/Tactical/TorpedoFlares.tga", # Relative path to the texture file
kFlareColor, # Reference to the core color object
6, # The maximum number of flares that spawn from the core.
0.7, # The length of the individual flares.
0.4 # The amount of time that the flares will last until they spawn again elsewhere. (Larger = Longer Existence)
)
pTorp.SetDamage( GetDamage() ) # Setting the maximum damage the torpedo could do on shields, hull or subsystem
pTorp.SetDamageRadiusFactor( GetDamageRadius() ) # Setting the maximum visible radius, the torpedo would damage on impact
pTorp.SetGuidanceLifetime( GetGuidanceLifetime() ) # The length of time; the torpedo is actively controlled towars its target
pTorp.SetMaxAngularAccel( GetMaxAngularAccel() ) # The maximum angular velocity at which a torpedo is steered towards its target.
pTorp.SetLifetime( GetLifetime() ) # The maximum lifespan of the torpedo before it is deleted by the game engine.
import Multiplayer.SpeciesToTorp # Multiplayer specific stuff. Please, if you create a new torp type. modify the SpeciesToTorp.py file to add the new type.
pTorp.SetNetType (Multiplayer.SpeciesToTorp.ANTIMATTERTORP) # Each new torpedo requires an entry in this script with a new ID in order to be used in multiplayer.
return(0) # Function returns 0 after creating the torpedo object
def GetName(): # Name displayed in the torpedo's selection field.
return("Antiproton") # Should be a maximum of 16 to 32 characters, depending on the resolution.
def GetDamage(): # Damage is outsourced as a separate function.
return 1000.0 # Damage in relative game units
def GetDamageRadius(): # The radius of the damage is outsourced as a separate function.
return 0.1 # This function is not in the original script. I added it for practical reasons.
def GetLaunchSound(): # The sound a torpedo makes when fired.
return("Ion Cannon") # See also Foundation sound example above.
def GetLaunchSpeed(): # Speed in game units per second at which the torpedo is fired.
return 100.0 # 100 is approximately 70000 km/h in the game.
def GetMaxAngularAccel(): # Angular velocity at which the torpedo can maneuver.
return 10.0 # 10 means approximately 700 km/h/s in the game.
def GetGuidanceLifetime(): # Time that the torpedo is actively steered.
return 0.1 # Time in Seconds
def GetPowerCost(): # This value comes from the original SDK, but is not used by the API. This value affects the AI's torpedo selection in the preprocessor.py located in the AI folder.
return 10.0 # It does not affect the spaceship's power management or the energy consumption of the torpedo launchers.
def GetLifetime(): # The lifespan of the torpedo object in the game. After that lifespan, it is deleted by the game engine.
return 10.0 # This also allows you to calculate the maximum torpedo range using formnula GetLifetime * GetLaunchSpeed.