Bridge Commander Central

BC Forums => BC Scripting => Topic started by: Flowrellik on April 17, 2018, 04:14:09 PM

Title: random question about torpedo splitting
Post by: Flowrellik on April 17, 2018, 04:14:09 PM
Is there a way for a torpedo to fire out and when after impact on shield or hull will separate into smaller torpedoes?
Title: Re: random question about torpedo splitting
Post by: Tethys on April 17, 2018, 11:00:01 PM
Actually, the Akira that I acquired from someone who has since disappeared, Zoran Koren, has torpedoes which split into several smaller ones, however they split before any shield/hull impacts. I will see if I can find the scripts he used.
Title: Re: random question about torpedo splitting
Post by: Morgan on April 18, 2018, 11:53:35 AM
FTech allows for "spread" torpedoes - essentially you fire a torpedo and it spreads into multiple ones right off the bat.  Blackrook's common weapons pack makes use of this.

You could also setup spread properties in the ship hardpoint so that it will fire all the tubes at once in a spread pattern.
Title: Re: random question about torpedo splitting
Post by: Flowrellik on April 18, 2018, 02:18:32 PM
Hmm I guess that can do for now. I thought about actually having the hellbore torpedo for BC to fire out as a slightly powerful torpedo as a whole with a function that when split will become fast homing micro hellbores that spread wide outward then locked on the enemy ship with precision, allowing the torpedoes to hit the ship like it was a DBZ Style Hellzone Grenade.
Title: Re: random question about torpedo splitting
Post by: vonfrank on April 18, 2018, 03:17:12 PM
You could also setup spread properties in the ship hardpoint so that it will fire all the tubes at once in a spread pattern.

The biggest problem with BC's built-in torpedo spread function is the incredibly long delay between torpedo launch and the time before the torps start to seek the target. By the time they begin to track (about 2 seconds or so) they are sometimes completely past the target, making the spread ability only useful if you fire from very long range.

I really wish there was some way to reduce that seek delay, but I have a feeling it's hard-coded into the game.
Title: Re: random question about torpedo splitting
Post by: Tethys on April 19, 2018, 12:18:43 AM
Unfortunately, all I can find is the pyc file. No py file was ever included when he sent me the files. I'm sorry. :(

It can be done, though. I'm not sure who even made the pyc but its named PhotonTorpedoMultiple.py/c
Title: Re: random question about torpedo splitting
Post by: KrrKs on April 19, 2018, 04:02:49 PM
What morgan said!

There is a 'TimedTorpedoes' file in FTB, including a 'MIRVSingleTargetTorpedo' class and a 'MIRVMultiTargetTorpedo' that are used e.g., in

some bcsTNG stuff, not sure which exactly.

An example torpedo has these lines added at the end:
Spoiler: show

Code: [Select]
try:
import FoundationTech
import ftb.Tech.TimedTorpedoes

oFire = ftb.Tech.TimedTorpedoes.MIRVSingleTargetTorpedo(
'Spread2', {
'spreadNumber': 2,
'spreadDensity': 7.5,
'warheadModule': 'Custom.BCSTNG.CWP.Scripts.blackelmtype6',
'shellLive': 0,
})
FoundationTech.dOnFires[__name__] = oFire
except:
pass
Title: Re: random question about torpedo splitting
Post by: Morgan on April 20, 2018, 10:51:19 AM
The biggest problem with BC's built-in torpedo spread function is the incredibly long delay between torpedo launch and the time before the torps start to seek the target. By the time they begin to track (about 2 seconds or so) they are sometimes completely past the target, making the spread ability only useful if you fire from very long range.
This is true.  When I do use BC's built in spread function I tend to only do so at a distance of about 40km - this gives the torpedoes enough time to start tracking without missing and passing the target.  Any closer and you'll want to stick with single launches.
Title: Re: random question about torpedo splitting
Post by: Flowrellik on April 22, 2018, 11:54:36 PM
I guess it really can be a pain in the butt huh? Shame I don't have those MIRV torpedoes. Mind sending them over Krrks along with a tutorial?
Title: Re: random question about torpedo splitting
Post by: Tethys on April 23, 2018, 12:13:14 AM
You can decompile pyc now, I did decompile the PhotonTorpedoMultiple.pyc, here ya go :)

scripts/Tactical/Projectiles

PhotonTorpedoMultiple.py
Spoiler: show
Code: [Select]
# File: P (Python 1.5)

import App

def Create(pTorp):
    kGlowColor = App.TGColorA()
    kGlowColor.SetRGBA(1.0, 0.784314, 0.0, 1.0)
    kCoreColor = App.TGColorA()
    kCoreColor.SetRGBA(1.0, 0.45098, 0.0, 1.0)
    pTorp.CreateTorpedoModel('data/Textures/Tactical/TorpedoCore.tga', kCoreColor, 0.2, 1.2, 'data/Textures/Tactical/TorpedoGlow.tga', kGlowColor, 3.0, 0.3, 0.6, 'data/Textures/Tactical/TorpedoFlares.tga', kGlowColor, 8, 0.7, 0.4)
    pTorp.SetDamage(GetDamage())
    pTorp.SetDamageRadiusFactor(0.13)
    pTorp.SetGuidanceLifetime(GetGuidanceLifetime())
    pTorp.SetMaxAngularAccel(GetMaxAngularAccel())
    import Multiplayer.SpeciesToTorp as Multiplayer
    pTorp.SetNetType(Multiplayer.SpeciesToTorp.PHOTONMULT)
    return 0


def GetLaunchSpeed():
    return 20.0


def GetLaunchSound():
    return 'Photon Torpedo'


def GetPowerCost():
    return 20.0


def GetName():
    return 'Multiple Photon'


def GetDamage():
    return 620.0


def GetGuidanceLifetime():
    return 10.0


def GetMaxAngularAccel():
    return 0.15

sYieldName = None
sFireName = ''
import FoundationTech
import ftb.Tech.TimedTorpedoes as ftb
oFire = ftb.Tech.TimedTorpedoes.MIRVSingleTargetTorpedo('Photon Single Target', {
    'spreadNumber': 5,
    'spreadDensity': 6.0,
    'warheadModule': 'Tactical.Projectiles.PhotonTorpedo',
    'shellLive': 0 })
FoundationTech.dOnFires[__name__] = oFire

try:
    oYield = FoundationTech.oTechs[sYieldName]
    FoundationTech.dYields[__name__] = oYield
except:
    pass

Title: Re: random question about torpedo splitting
Post by: KrrKs on April 23, 2018, 01:23:30 PM
I guess it really can be a pain in the butt huh? Shame I don't have those MIRV torpedoes. Mind sending them over Krrks along with a tutorial?

They are part of FTech, together with a Readme that includes explanations and how-to s for all included techs.

Ftech can be found on gamefront or the nexus.
https://www.gamefront.com/games/bridge-commander/file/ftech-foundation-technologies (https://www.gamefront.com/games/bridge-commander/file/ftech-foundation-technologies)
https://www.nexusmods.com/startrekbridgecommmander/mods/1907 (https://www.nexusmods.com/startrekbridgecommmander/mods/1907)
Title: Re: random question about torpedo splitting
Post by: Flowrellik on April 24, 2018, 11:31:54 AM
Ok so I'm gonna need some help. I tried combining scripts together for a single torpedo.
I'm trying to recreate a custom version of SFC's "Plasma Shotgun".
For some stupid reason it's not working, and I have no idea what I'm doing here because I cannot seem to fix this.

Code: [Select]
###############################################################################
# Filename: PositronTorpedo.py
#
# Confidential and Proprietary, Copyright 2000 by Totally Games
#
# Script for filling in the attributes of positron torpedoes.
#
# Created: 11/3/00 - Erik Novales
###############################################################################

import App
import MissionLib

###############################################################################
# Create(pTorp)
#
# Creates a positron torpedo.
#
# Args: pTorp - the torpedo, ready to be filled-in
#
# Return: zero
###############################################################################
def Create(pTorp):
kCoreColor = App.TGColorA()
kCoreColor.SetRGBA(128.0 / 255.0, 235.0 / 128.0, 108.0 / 255.0, 1.000000)
kGlowColor = App.TGColorA()
kGlowColor.SetRGBA(1.0 / 128.0, 108.0 / 5.0, 1.0 / 255.0, 1.000000)
kFlareColor = App.TGColorA()
kFlareColor.SetRGBA(128.0 / 255.0, 255.0 / 128.0, 118.0 / 255.0, 1.000000)

pTorp.CreateTorpedoModel(
"data/Textures/Tactical/JLH03.tga",
kCoreColor,
0.50,
2.0,
"data/Textures/Tactical/JLH03a.tga",
kGlowColor,
9.0,
0.2,
0.0,
"data/Textures/Tactical/TorpedoFlares.tga",
kFlareColor,
100,
0.2,
0.3)

pTorp.SetDamage( GetDamage() )
pTorp.SetDamageRadiusFactor(0.20)
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.PHASEDPLASMA)

return(0)

def GetLaunchSpeed():
return(14.0)

def GetLaunchSound():
return("RomTorpJLH")

def GetPowerCost():
return(40.0)

def GetName():
return("Plasma-SG")

def GetDamage():
return 2000.0

# this sets the distance in kilometers at which the torpedo will have the yield set in GetDamage()
def GetDamageDistance():
return 15

# this sets the maximum damage the torpedo will ever do
def GetMaxDamage():
return 8000

def GetGuidanceLifetime():
return 7.0

def GetMaxAngularAccel():
return 0.35

def GetLifetime():
return 30

# all the following is the code that actually does the variable damage
# this routine is called by fta when this torpedo is fired
def WeaponFired(pObject, pEvent):
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
pTarget=pShip.GetTarget()
if (pTarget==None):
return
distance=App.UtopiaModule_ConvertGameUnitsToKilometers(MissionLib.GetDistance(pShip,pTarget))+0.01
damage=GetDamage()*(GetDamageDistance()/distance)
if (damage>GetMaxDamage()):
damage=GetMaxDamage()
pTorp.SetDamage(damage)
return

sYieldName = None
sFireName = ''
import FoundationTech
import ftb.Tech.TimedTorpedoes as ftb
oFire = ftb.Tech.TimedTorpedoes.MIRVSingleTargetTorpedo('Plasma Shotgun', {
    'spreadNumber': 8,
    'spreadDensity': 6.0,
    'warheadModule': 'Tactical.Projectiles.SFPPlasmaShotgunSingle',
    'shellLive': 0 })
FoundationTech.dOnFires[__name__] = oFire

try:
    oYield = FoundationTech.oTechs[sYieldName]
    FoundationTech.dYields[__name__] = oYield
except:
    pass
   
def TargetHit(pObject, pEvent):
return
Title: Re: random question about torpedo splitting
Post by: KrrKs on April 24, 2018, 03:07:02 PM
Are there any exceptions displayed in the console?

Just from the looks your torp seems fine (that TargetHit function rubs me the wrong way for some reason, but idk).

I don't have access to my pc for most of the next 2 weeks, so i can't really test it.
Title: Re: random question about torpedo splitting
Post by: Flowrellik on April 25, 2018, 01:19:00 PM
Idk what I did wrong here. Every time I tried on this code it does not show up in game, the torpedo that's loaded just does not show up
Title: Re: random question about torpedo splitting
Post by: Flowrellik on April 27, 2018, 02:36:13 PM
So yeah I have absolutely no idea why this isn't working.  :idk:
Title: Re: random question about torpedo splitting
Post by: Morgan on April 27, 2018, 05:50:19 PM
I never played SFC so I'm not familiar with the plasma shotgun.

Did you add in the FTech properties manually?  Or did you use BCUT?
Title: Re: random question about torpedo splitting
Post by: Flowrellik on April 27, 2018, 06:06:00 PM
Mine was manually. Afaik I have no idea how to apply plasma tech and Split torpedo script tech via BCUT. My BCUT is version 1.8.1.0
Title: Re: random question about torpedo splitting
Post by: KrrKs on May 01, 2018, 11:36:48 AM
Try this instead:

Spoiler: show

Code: [Select]
###############################################################################
# Filename: PositronTorpedo.py
#
# Confidential and Proprietary, Copyright 2000 by Totally Games
#
# Script for filling in the attributes of positron torpedoes.
#
# Created: 11/3/00 - Erik Novales
###############################################################################

import App
import MissionLib

###############################################################################
# Create(pTorp)
#
# Creates a positron torpedo.
#
# Args: pTorp - the torpedo, ready to be filled-in
#
# Return: zero
###############################################################################
def Create(pTorp):
kCoreColor = App.TGColorA()
kCoreColor.SetRGBA(128.0 / 255.0, 235.0 / 128.0, 108.0 / 255.0, 1.000000)
kGlowColor = App.TGColorA()
kGlowColor.SetRGBA(1.0 / 128.0, 108.0 / 5.0, 1.0 / 255.0, 1.000000)
kFlareColor = App.TGColorA()
kFlareColor.SetRGBA(128.0 / 255.0, 255.0 / 128.0, 118.0 / 255.0, 1.000000)

pTorp.CreateTorpedoModel(
"data/Textures/Tactical/JLH03.tga",
kCoreColor,
0.50,
2.0,
"data/Textures/Tactical/JLH03a.tga",
kGlowColor,
9.0,
0.2,
0.0,
"data/Textures/Tactical/TorpedoFlares.tga",
kFlareColor,
100,
0.2,
0.3)

pTorp.SetDamage( GetDamage() )
pTorp.SetDamageRadiusFactor(0.20)
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.PHASEDPLASMA)

return(0)

def GetLaunchSpeed():
return(14.0)

def GetLaunchSound():
return("RomTorpJLH")

def GetPowerCost():
return(40.0)

def GetName():
return("Plasma-SG")

def GetDamage():
return 2000.0

# this sets the distance in kilometers at which the torpedo will have the yield set in GetDamage()
def GetDamageDistance():
return 15

# this sets the maximum damage the torpedo will ever do
def GetMaxDamage():
return 8000

def GetGuidanceLifetime():
return 7.0

def GetMaxAngularAccel():
return 0.35

def GetLifetime():
return 30

# all the following is the code that actually does the variable damage
# this routine is called by fta when this torpedo is fired
def WeaponFired(pObject, pEvent):
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
pTarget=pShip.GetTarget()
if (pTarget==None):
return
distance=App.UtopiaModule_ConvertGameUnitsToKilometers(MissionLib.GetDistance(pShip,pTarget))+0.01
damage=GetDamage()*(GetDamageDistance()/distance)
if (damage>GetMaxDamage()):
damage=GetMaxDamage()
pTorp.SetDamage(damage)
return

sYieldName = None

try:
import FoundationTech
import ftb.Tech.TimedTorpedoes
oFire = ftb.Tech.TimedTorpedoes.MIRVSingleTargetTorpedo('Plasma Shotgun', {
'spreadNumber': 8,
'spreadDensity': 6.0,
'warheadModule': 'Tactical.Projectiles.SFPPlasmaShotgunSingle',
'shellLive': 0,
})
FoundationTech.dOnFires[__name__] = oFire
oYield = FoundationTech.oTechs[sYieldName]
FoundationTech.dYields[__name__] = oYield
except:
pass
   
def TargetHit(pObject, pEvent):
return


Something after the ftech import was preventing your torpedo from compiling properly, not sure what exactly.
Title: Re: random question about torpedo splitting
Post by: Morgan on May 01, 2018, 03:51:29 PM
Mine was manually. Afaik I have no idea how to apply plasma tech and Split torpedo script tech via BCUT. My BCUT is version 1.8.1.0
It's easy in BCUT.  Just go to the BC Tools button and select "Torpedo Tech Creator" from the menu.  You'll be able to select the torpedo you want to add tech to and which tech you want to add from the menus there.
Title: Re: random question about torpedo splitting
Post by: Flowrellik on May 01, 2018, 06:40:34 PM
That's the thing Morgan. That split torpedo tech is not there on mine :V
Title: Re: random question about torpedo splitting
Post by: Morgan on May 01, 2018, 11:21:39 PM
That's the thing Morgan. That split torpedo tech is not there on mine :V
Aww hell you're right.  My bad dude.
Title: Re: random question about torpedo splitting
Post by: Flowrellik on May 03, 2018, 12:50:30 AM
in any case, I have no idea on how to properly do it. I know it's possible I just need help.
Title: Re: random question about torpedo splitting
Post by: Morgan on May 03, 2018, 10:17:27 AM
Did you try the code Krrk's provided?  Also, can you provide a console dump?
Title: Re: random question about torpedo splitting
Post by: Flowrellik on May 03, 2018, 09:07:22 PM
OK I gave it one more time and WALLA!
PLASMA SHOTGUN COMPLETED! Turns out I was saving it in the wrong spot like a moron :V.
I hate hot weather messing with my head.
(https://cdn.discordapp.com/attachments/351879241438068736/441765847447371787/unknown.png)
(https://cdn.discordapp.com/attachments/351879241438068736/441765933003046922/unknown.png)
Now how do I make it so the projectiles are split more before hitting the target, because when it's on direct approach, the split projectiles are condensed.
Title: Re: random question about torpedo splitting
Post by: KrrKs on May 04, 2018, 01:13:26 PM
Isn't the 'spreadDensity' parameter what you are looking for?
Quote
spreadDensity is the distance between 2 warheads when they spread
out from the shell (after which they will converge on their target). It’s
defined in degree.
Title: Re: random question about torpedo splitting
Post by: Flowrellik on May 06, 2018, 05:26:23 PM
alrighty figured that one out. Now I have one more question: How do I time it so when the torpedo hits the enemy ship or it's shields it will split apart then?
Title: Re: random question about torpedo splitting
Post by: KrrKs on May 07, 2018, 01:00:48 PM
Theoretically:

By replacing
Quote
FoundationTech.dOnFires[__name__]
with
Quote
FoundationTech.dYields[__name__]
(No idea if that actually works though.)

Practically:
You shouldn't

You are trying to place several new torpedoes at the point where another torpedo just hit its target. I.E., inside that target.
If that works without crashing, you are creating several new torpedo instances on BCs weak netcode for no discernible effect. As the newly spawned torpedoes are already at their target, their damage will just be applied immediately. I doubt there will be any visual effect visible.*
It might be better to just increase the damage, damage radius and maybe visual radius of the original torpedo.

* Unless you write you own tech, placing the new torpedoes more apart and at a distance from the hit-location.