Bridge Commander Central
BC Forums => BC Scripting => Topic started by: DKealt on August 18, 2009, 01:17:43 PM
-
I'm in desperation here. After seeing numerous mods and various ways of doing it...how do you create a phased torpedo?
I'm working within all the standard KM1.0 Technologies and I just can't make a good one, or one that works.
Also if there are multiple ways of doing this, anyone got a preferred scripting method?
-
From personal experiece, use the FoundationTechnologies way.
It should be included in KM, and there should be a readme on FTech included with KM, and that should include instruction for changing a projectile to phase through shields.
-
This is my Phased Torpedo Script, copy it into one of your own Torpedo scripts and you shoud be good to go. Rename it to what ever you want, you will need FTECH for it to work.
###############################################################################
# Filename: PoleronTorp.py
# By: Andy
###############################################################################
# This torpedo uses the FTA mod...
#
# it actually passes through shields and damages whatever subsystem it was
# targeted at
#
# please refer to the bottom of this file for details on changing effects
###############################################################################
import App
pWeaponLock = {}
###############################################################################
# Args: pTorp - the torpedo, ready to be filled-in
#
# Return: zero
###############################################################################
def Create(pTorp):
kCoreColor = App.TGColorA()
kCoreColor.SetRGBA(222.0 / 255.0, 222.0 / 255.0, 253.0 / 255.0, 1.000000)
kGlowColor = App.TGColorA()
kGlowColor.SetRGBA(61.0 / 201.0, 98.0 / 255.0, 239.0 / 255.0, 1.000000)
pTorp.CreateTorpedoModel(
"data/Textures/Tactical/TorpedoFlares.tga",
kCoreColor,
0.1,
0.8,
"data/Textures/Tactical/TorpedoCore.tga",
kCoreColor,
0.1,
0.2,
0.1,
"data/Textures/Tactical/TorpedoCore.tga",
kGlowColor,
400,
0.3,
0.05)
pTorp.SetDamage( GetDamage() )
pTorp.SetDamageRadiusFactor(0.50)
pTorp.SetGuidanceLifetime( GetGuidanceLifetime() )
pTorp.SetMaxAngularAccel( GetMaxAngularAccel() )
# Multiplayer specific stuff. Please, if you create a new torp
# type. modify the SpeciesToTorp.py file to add the new type.
import Multiplayer.SpeciesToTorp
pTorp.SetNetType (Multiplayer.SpeciesToTorp.QUANTUM)
return(0)
def GetLaunchSpeed():
return(32.0)
def GetLaunchSound():
return("ZZ_Shockwave")
def GetPowerCost():
return(33.0)
def GetName():
return("Phased")
def GetDamage():
return 0.00001
# Sets the minimum damage the torpedo will do
def GetMinDamage():
return 170
# Sets the percentage of damage the torpedo will do
def GetPercentage():
return 0.25
def GetGuidanceLifetime():
return 9.0
def GetMaxAngularAccel():
return 0.10
def TargetHit(pObject, pEvent):
global pWeaponLock
pTorp=App.Torpedo_Cast(pEvent.GetSource())
pShip=App.ShipClass_Cast(pEvent.GetDestination())
if (pTorp==None) or (pShip==None):
return
try:
id=pTorp.GetObjID()
pSubsystem=pWeaponLock[id]
del pWeaponLock[id]
except:
pSubsystem=pShip.GetHull()
if (pSubsystem==None):
return
Dmg=pSubsystem.GetMaxCondition()*GetPercentage()
if (Dmg<GetMinDamage()):
Dmg=GetMinDamage()
if (pSubsystem.GetCondition()>Dmg):
pSubsystem.SetCondition(pSubsystem.GetCondition()-Dmg)
else:
pShip.DestroySystem(pSubsystem)
return
def WeaponFired(pObject, pEvent):
global pWeaponLock
pTorp=App.Torpedo_Cast(pEvent.GetSource())
pTube=App.TorpedoTube_Cast(pEvent.GetDestination())
if (pTorp==None) or (pTube==None):
return
pShip=pTube.GetParentShip()
if (pShip==None):
return
try:
pWeaponLock[pTorp.GetObjID()]=pShip.GetTargetSubsystem()
except:
return
return
-
Thanks a bunch.
I think I just needed a working example to fully understand how it worked
-
Thanks a bunch.
I think I just needed a working example to fully understand how it worked
Yep, a working model is always good.
-
Really? FTech for it to work?
Seems like its something else... Kinda like... FTA perhaps? :P
-
Seems like its something else... Kinda like... FTA perhaps? :P
That would be why i could not get it to work. It seams Kobayashi Maru 1.0 removed that part of FTA.
-
I tried applying the script modifications with FTech.
Just didn't work not sure why tho, i added what it said in the Readme and I came up with this, anyone see why it didn't work?
import App
def Create(pTorp):
kCoreColor = App.TGColorA()
kCoreColor.SetRGBA(255.0 / 255.0, 250.0 / 255.0, 100.0 / 255.0, 1.000000)
kGlowColor = App.TGColorA()
kGlowColor.SetRGBA(230.0 / 255.0, 230.0 / 255.0, 10.0 / 255.0, 1.000000)
pTorp.CreateTorpedoModel(
"data/Textures/Tactical/TransphasicCore.tga",
kCoreColor,
0.1,
6.0,
"data/Textures/Tactical/TransphasicGlow.tga",
kGlowColor,
1.0,
0.25,
0.3,
"data/Textures/Tactical/TorpedoFlares.tga",
kGlowColor,
12,
0.15,
0.1)
pTorp.SetDamage( GetDamage() )
pTorp.SetDamageRadiusFactor(10.0)
pTorp.SetGuidanceLifetime( GetGuidanceLifetime() )
pTorp.SetMaxAngularAccel( GetMaxAngularAccel() )
import Multiplayer.SpeciesToTorp
pTorp.SetNetType (Multiplayer.SpeciesToTorp.PHOTON)
return(0)
def GetLaunchSpeed():
return(30.0)
def GetLaunchSound():
return("Transphasic Torpedo")
def GetPowerCost():
return(25.0)
def GetName():
return("Transphasic")
def GetDamage():
return 500000.0
def GetGuidanceLifetime():
return 2.0
def GetMaxAngularAccel():
return 0.3
def GetLifetime():
return 12.0
try:
sYieldName = ?Phased Torpedo?
import FoundationTech
try:
oYield = FoundationTech.oTechs[sYieldName]
FoundationTech.dYields[__name__] = oYield
except:
pass
except:
pass
-
The first example is FTA (I think), the last is FoundationTechnologies.
And here is the fixed version:
import App
def Create(pTorp):
kCoreColor = App.TGColorA()
kCoreColor.SetRGBA(255.0 / 255.0, 250.0 / 255.0, 100.0 / 255.0, 1.000000)
kGlowColor = App.TGColorA()
kGlowColor.SetRGBA(230.0 / 255.0, 230.0 / 255.0, 10.0 / 255.0, 1.000000)
pTorp.CreateTorpedoModel(
"data/Textures/Tactical/TransphasicCore.tga",
kCoreColor,
0.1,
6.0,
"data/Textures/Tactical/TransphasicGlow.tga",
kGlowColor,
1.0,
0.25,
0.3,
"data/Textures/Tactical/TorpedoFlares.tga",
kGlowColor,
12,
0.15,
0.1)
pTorp.SetDamage( GetDamage() )
pTorp.SetDamageRadiusFactor(10.0)
pTorp.SetGuidanceLifetime( GetGuidanceLifetime() )
pTorp.SetMaxAngularAccel( GetMaxAngularAccel() )
import Multiplayer.SpeciesToTorp
pTorp.SetNetType (Multiplayer.SpeciesToTorp.PHOTON)
return(0)
def GetLaunchSpeed():
return(30.0)
def GetLaunchSound():
return("Transphasic Torpedo")
def GetPowerCost():
return(25.0)
def GetName():
return("Transphasic")
def GetDamage():
return 500000.0
def GetGuidanceLifetime():
return 2.0
def GetMaxAngularAccel():
return 0.3
def GetLifetime():
return 12.0
try:
sYieldName = 'Phased Torpedo'
import FoundationTech
try:
oYield = FoundationTech.oTechs[sYieldName]
FoundationTech.dYields[__name__] = oYield
except:
pass
except:
pass
Notice the '' around Phased Torpedo, instead of the fancy ones.
And the indendation before the last pass.
-
Okay cool thanks,
That script loads, but it doesn't work. The torp doesn't pass through the shields and it just completely drains the vector it hits.
Second shot will destroy the ship,
Any idea why that is?
-
Cos the damage is so flipping powerful. :P
def GetDamage():
return 500000.0
It's still not phasing but its exceedingly powerful.
-
OK so the problem is then that the script still won't actually phase.
Im using this on a KM1.0 install, anyone know if this tech should work on it.
I've located the phasing strip etc, and it seems that it should work?
P.s. It's for a custom transphasic torp script so it needs to take down Cubes, hence the super power
-
Could you try this version of the projectile (mind the damage, I didn't change it):
[code]import App
def Create(pTorp):
kCoreColor = App.TGColorA()
kCoreColor.SetRGBA(255.0 / 255.0, 250.0 / 255.0, 100.0 / 255.0, 1.000000)
kGlowColor = App.TGColorA()
kGlowColor.SetRGBA(230.0 / 255.0, 230.0 / 255.0, 10.0 / 255.0, 1.000000)
pTorp.CreateTorpedoModel(
"data/Textures/Tactical/TransphasicCore.tga",
kCoreColor,
0.1,
6.0,
"data/Textures/Tactical/TransphasicGlow.tga",
kGlowColor,
1.0,
0.25,
0.3,
"data/Textures/Tactical/TorpedoFlares.tga",
kGlowColor,
12,
0.15,
0.1)
pTorp.SetDamage( GetDamage() )
pTorp.SetDamageRadiusFactor(10.0)
pTorp.SetGuidanceLifetime( GetGuidanceLifetime() )
pTorp.SetMaxAngularAccel( GetMaxAngularAccel() )
import Multiplayer.SpeciesToTorp
pTorp.SetNetType (Multiplayer.SpeciesToTorp.PHOTON)
return(0)
def GetLaunchSpeed():
return(30.0)
def GetLaunchSound():
return("Transphasic Torpedo")
def GetPowerCost():
return(25.0)
def GetName():
return("Transphasic")
def GetDamage():
return 500000.0
def GetGuidanceLifetime():
return 2.0
def GetMaxAngularAccel():
return 0.3
def GetLifetime():
return 12.0
try:
sYieldName = 'Phased Torpedo'
import FoundationTech
try:
oYield = FoundationTech.oTechs[sYieldName]
FoundationTech.dYields[__name__] = oYield
except:
print "Sorry, no Phased Torpedo Tech installed"
pass
except:
pass
And have you checked that you have a scripts/Custom/Techs/PhasedTorp.py and it's pyc counterpart?[/code]
-
MLeo, i think there might be a problem with
[/quote]
And have you checked that you have a scripts/Custom/Techs/PhasedTorp.py and it's pyc counterpart?being in the script :P
-
Got it.
Took a hunch that there was a line of code missing from the readme.
After the line...
import FoundationTechThere should have been another line after that...
import Custom.Techs.PhasedTorpAnd that's why it didn't work!!!
-
Phased Torpedoes should automatically load whenever the mutators are loaded.
Could you attach scripts/Custom/Autoload/LoadFoundationTech.py
-
Really? FTech for it to work?
Seems like its something else... Kinda like... FTA perhaps? :P
Sorry, my bad!
-
This is the "LoadFoundationsTech.py" that I have on my install...
import Foundation
import FoundationTech
import ftb.Tech
import ftb.Tech.ATPFunctions
mode = FoundationTech.mode
Foundation.SoundDef('Custom/FTB/Sfx/Weapons/RomPlasmaBurst.wav', 'FTB Plasma', 1.0, { 'modes': [ mode ] })
#oIPhasers = Foundation.OverrideDef('Inaccurate Phasers', 'TacticalControlHandlers.FireWeapons', 'FoundationTech.FireWeapons', { 'modes': [ mode ] } )
Foundation.LoadExtraPlugins("scripts\\Custom\\Techs")
#Foundation.LoadExtraPlugins("scripts\\ftb\\Tech")
#Include standard techs to initialize them
from ftb.Tech import AblativeArmour,DamperWeapon,DisablerYields,Shields,BreenDrainer,TachyonProjectile,FedAblativeArmor
Foundation.ERA_ENT = 1
Foundation.ERA_TOS = 2
Foundation.ERA_TMP = 4
Foundation.ERA_PRETNG = 8
Foundation.ERA_TNG = 16
Foundation.ERA_DS9 = 32
Foundation.ERA_NEMESIS = 64
-
In which case I think it should already have been loaded.
Oh well, if this works.
-
Just to check, the phased torp script is located in...
scripts/Custom/Techs folder,
Does the line in the script ...
Foundation.LoadExtraPlugins("scripts\\Custom\\Techs")
actually load the contents? (I don't know how the double backslash works)
-
Yeah, it does.
Windows uses the backslash to separate directories.
But in nearly all programming languages the backslash is used to "escape" a certain "control" character. But most \<character>s are not control characters (such as newline/linefeed which is \n). So to escape the \ you prepend it with another \
It's a tick of mine to turn backslashes into forward slashes (/), mostly because the browser also does that, and it makes more sense (for me) at that.