Bridge Commander Central

BC Forums => BC Scripting => Topic started by: DKealt on August 21, 2008, 12:56:48 PM

Title: Splitting Projectiles
Post by: DKealt on August 21, 2008, 12:56:48 PM
Hi Im desperately trying to get a few more canon actions working on the upcoming Stargate pack, and thru wanderring around some of the already existing tech out there i came across the splitting projectiles mod as part of foundation technologies.

If im right the multi target splitting projectiles would be perfect for the Horizon platform (A multi launching - multi targetting Nuke platform) and this could help.

Also it may be the answer to making the Drone weapons appear more cluster like after they have been fired.

The instructions with the FTech is pretty straight forward i think, but im not exactly most comfortable when it comes to scripting, so basically does anyone know how to implement this tech, an example script etc. would be perfect, or even if anyone knows if it is indeed possible to achieve what i would like via this method.

Any help would be much appreciated

DKealt
Title: Re: Splitting Projectiles
Post by: MLeo on August 21, 2008, 01:19:30 PM
The readme contains examples, including one for splitting I believe. Even 2 of them.
Title: Re: Splitting Projectiles
Post by: El on August 21, 2008, 02:24:22 PM
I think you will struggle to get the swarming effect your after however the Horizon effect is do able although it obviously doesn't use solid models.
Title: Re: Splitting Projectiles
Post by: DKealt on August 22, 2008, 08:08:01 AM
Yeh the solid models isnt a prob, i just figure that the horizon launches one projectile from it that splits, and as for the drone swarm, it is hard, very hard, i just want to reduce the current effect of one straight line of drones, that too be fair can look a bit disapointing.

As for the examples. iv seen them, read them and tried to apply them with no success, the readme is fantastic, im just not too sure if something, perhaps very simple to most scripters hasnt been mentioned that i need to do
Title: Re: Splitting Projectiles
Post by: MLeo on August 22, 2008, 08:11:25 AM
If you don't know something specific, then you can of course ask.
But I as the writer of the readme can't think of anything that I missed.
I used descriptive names on purpose.
Title: Re: Splitting Projectiles
Post by: DKealt on August 22, 2008, 08:27:30 AM
Yeh of course, i think im just missing something thats spelled out right in front of me, here's the script iv tried to add to the bottom of the script...

Code: [Select]
sYieldName = ?Horizon?
try:

    import FoundationTech
    import ftb.Tech.TimedTorpedoes

    oFire = ftb.Tech.TimedTorpedoes.MIRVMultiTargetTorpedo(
    ?Horizon?, {
?spreadNumber?: 6,
?spreadDensity?: 6.5,
?warheadModule?: ?Tactical.Projectiles.Mark9Tactical?,
?shellLive?: 0,
    })
    FoundationTech.dOnFires[__name__] = oFire
    oYield = FoundationTech.oTechs[Horizon]
    FoundationTech.dYields[__name__] = oYield
except:
    pass

Please help me find whats wrong with it, it is a script worth using (P.s. i added the script to an identical script renamed Mark9TacticalA).
Title: Re: Splitting Projectiles
Post by: MLeo on August 22, 2008, 08:39:01 AM
I added code tags to your post, and I noticed that you didn't have any indendation.
Is this the case in the source file as well? If so, copy the above back into the projectile file and try again.
Title: Re: Splitting Projectiles
Post by: DKealt on August 22, 2008, 10:48:40 AM
Still no joy so far... for reference this is the entire script...

Code: [Select]
import App
import LJTorpLib.LibTorp

sDamage = 100000

def Create(pTorp):
kCoreColor = App.TGColorA()
kCoreColor.SetRGBA(255.0 / 255.0, 255.0 / 255.0, 128.0 / 255.0, 1.000000)
kGlowColor = App.TGColorA()
kGlowColor.SetRGBA(255.0 / 255.0, 128.0 / 255.0, 0.0 / 255.0, 1.000000)
kFlareColor = App.TGColorA()
kFlareColor.SetRGBA(255.0 / 255.0, 128.0 / 255.0, 0.0 / 255.0, 1.000000)

pTorp.CreateTorpedoModel(
"data/Textures/Tactical/TorpedoCore.tga",
kCoreColor,
0.04,
0.05,
"data/Textures/Tactical/TorpedoGlow.tga",
kGlowColor,
0.2,
0.04,
0.025,
"data/Textures/Tactical/TorpedoFlares.tga",
kFlareColor,
0,
0.01,
0.01)


#pTorp.SetDamage( GetDamage(pTorp) )
pTorp.SetDamageRadiusFactor(5.0)
pTorp.SetGuidanceLifetime( GetGuidanceLifetime() )
pTorp.SetMaxAngularAccel( GetMaxAngularAccel() )

import Multiplayer.SpeciesToTorp
pTorp.SetNetType (Multiplayer.SpeciesToTorp.PHOTON)


        LJTorpLib.LibTorp.AddCreationHandler(pTorp, __name__ + ".AttachSmoke")
return(0)

def AttachSmoke(self, pEvent = None):

    pTorpedo = App.Torpedo_Cast(pEvent.GetDestination())
    if not pTorpedo:
        return (1)

    LJTorpLib.LibTorp.SetupSmokeTrail(pTorpedo)

    SetDamage(pTorpedo)

    return (0)

def SetDamage(self, pEvent = None):
    global sDamage

    pTorpedo = self
    if not pTorpedo:
        return (1)

    pTargetId = pTorpedo.GetTargetID()

    pSet = pTorpedo.GetContainingSet()

    lObjects = pSet.GetClassObjectList(App.CT_OBJECT)
    for sObject in lObjects:
sOBjectID = sObject.GetObjID()

if (sOBjectID == pTargetId):
import Foundation
import string
                if sObject.GetScript():
                        pShip = string.split(sObject.GetScript(), '.')[-1]

if Foundation.shipList.has_key(pShip):
pFoundationShip = Foundation.shipList[pShip]
if pFoundationShip and hasattr(pFoundationShip, "fTorpedoID"):
pTorpedoeID = pFoundationShip.fTorpedoID
if (pTorpedoeID == "Not-Target"):
Rand = App.g_kSystemWrapper.GetRandomNumber(100)

if (Rand <= 10):
pTorpedo.SetDamage(int(sDamage))

else:
pTorpedo.SetDamage(0.01)
                                else:
                                        pTorpedo.SetDamage(int(sDamage))

def GetLaunchSpeed():
return(20.0)

def GetLaunchSound():
return("MissileFire")

def GetPowerCost():
return(30.0)

def GetName():
return("Mark 9 Tactical")

def GetDamage():
        global sDamage
return int(sDamage)

def GetGuidanceLifetime():
return 8.0

def GetMaxAngularAccel():
return 2.0

sYieldName = ?Horizon?
try:

    import FoundationTech
    import ftb.Tech.TimedTorpedoes

    oFire = ftb.Tech.TimedTorpedoes.MIRVMultiTargetTorpedo(
    ?Horizon?, {
?spreadNumber?: 6,
?spreadDensity?: 6.5,
?warheadModule?: ?Tactical.Projectiles.Mark9TacticalA?,
?shellLive?: 0,
    })
    FoundationTech.dOnFires[__name__] = oFire
    oYield = FoundationTech.oTechs[Horizon]
    FoundationTech.dYields[__name__] = oYield
except:
    pass

Ive also tried adding the script to an simple torp script with no success, the one thing that confusses me is the naming of the tech, i put horizon as i assume that the name need not be specific, and also im unsure as to where to insert this name as it only specifies one place in the readme.
Title: Re: Splitting Projectiles
Post by: MLeo on August 22, 2008, 01:02:39 PM
In this case the yieldname isn't needed, since you define a new torpedo tech instead of referencing (through the name) it.

But what exactly is the problem here?
Title: Re: Splitting Projectiles
Post by: DKealt on August 22, 2008, 02:18:13 PM
Simply the torpdeo/missile script doesnt load, as if the script file is missing.

If i try and fire the missile with the splitting tech the game crashes. Something with the below code is wrong and the game crashes,

Im finding it really frustrating as i just cant figure out where its gone wrong
Title: Re: Splitting Projectiles
Post by: MLeo on August 22, 2008, 02:25:29 PM
Have you tried importing the projectile (in the console) and see what happens?
Title: Re: Splitting Projectiles
Post by: DKealt on August 22, 2008, 02:45:03 PM
Ive got a really basic level of knowledge when it comes to scripting im afraid, including console usage.

I thought there maybe something very apparent in the script that was wrong and that's why it didnt work,

Im just getting really stuck for ideas on getting it working now
Title: Re: Splitting Projectiles
Post by: MLeo on August 22, 2008, 03:22:56 PM
Like I said, just do this in the console:
Code: [Select]
import Tactical.Projectiles.Mark9Tactical Assuming that's the name of course.
Title: Re: Splitting Projectiles
Post by: DKealt on August 23, 2008, 09:50:27 AM
Yay a step in the right direction, the console informed me of a Syntax error, basically all the ' symbols needed changing to ".

Now everything loads fine in the console "TimedTorpedoes Loaded"

But now when the missiles fire they just fire as they did before and they dont split, here's how the code looks now...

Code: [Select]
sYieldName = "Horizon"
try:

    import FoundationTech
    import ftb.Tech.TimedTorpedoes

    oFire = ftb.Tech.TimedTorpedoes.MIRVMultiTargetTorpedo({"Horizon"
"spreadNumber": 6,
"spreadDensity": 6.5,
"warheadModule": "Tactical.Projectiles.Mark9TacticalA",
"shellLive": 0,
    })
    FoundationTech.dOnFires[__name__] = oFire
    oYield = FoundationTech.oTechs[Horizon]
    FoundationTech.dYields[__name__] = oYield
except:
    pass
Title: Re: Splitting Projectiles
Post by: DKealt on August 23, 2008, 12:18:36 PM
Oh and BTW, u mentioned before about not needing to use a name code, in this instance Horizon,

I havnt yet removed that part, would this still cause a problem?
Title: Re: Splitting Projectiles
Post by: DKealt on August 23, 2008, 12:27:58 PM
Finally!!!!

Crisis averted, i finally have a multi targetting Horizon platform!!!!

Thanks so much for ur consistent help guiding my newb skills through this!!!
Title: Re: Splitting Projectiles
Post by: MLeo on August 23, 2008, 12:54:47 PM
So what was it?
Title: Re: Splitting Projectiles
Post by: DKealt on August 23, 2008, 01:03:16 PM
Basically after figuring out that i was using the wrong characters in the code i replaced them, forgetting that i had since tried to change/remove the need to have the "sYieldName" present, so all i needed to do was reinsert the original code that was less tampered with and edit the syntax on that version.

The effect is really satisfying now, if there are 6 targets it ends in 6 kills, unlike the prev. version where these 6 killer nukes would all fire on 1 target.

Thanks again, couldn't have made it happen without ur help!!!
Title: Re: Splitting Projectiles
Post by: El on August 23, 2008, 04:00:19 PM
Just had a though for your swarm effect that may or may not work.
Use the same splitting technique you used for the horizon, so multiple projectiles fire at once, use a very low spread delay to make it seem like they are launching en mass.
Keep the spread density low since you want them to track very closely to each other.
Adjust the spread number until you get the right number of drones to give the swarm the right 'thickness'

Also, In the file for the split projectile, under 'Get Guidance Lifetime' try setting it to a high number, since we know Drones rarely if ever miss, you may need to tinker with the angular acceleration value as well.
Title: Re: Splitting Projectiles
Post by: DKealt on August 24, 2008, 09:08:17 PM
Yeh iv hit a bit of a wall with that at the moment. I tend to be that because of the high angular acceleration value of the Drones, when they split they virtually converge back on each other and u just get 3 drones all in the same place, making it look like a very bright drone.

Im also unsure how to change the delay between the splitting? Do u know where to change that value as im not sure if that attribute is in the projectile file?
Title: Re: Splitting Projectiles
Post by: El on August 25, 2008, 06:25:54 AM
You mean the delay before your initial projectile splits into multiples?
I can't remember the field name of the top of my head, it should be something like 'SpreadDelay' or similar.

Also, in order to avoid the drones re-merging, try giving them different targets.
Title: Re: Splitting Projectiles
Post by: DKealt on August 25, 2008, 06:55:51 AM
cool ill hav a look for that, but do u know if tht varible is in the tech file for timed torps?

also the probs with multi target drones is tht it reduces firepower, as in if u fight against wo hives and u hav only enough drones to take out one it could get quite annoing.
Title: Re: Splitting Projectiles
Post by: El on August 25, 2008, 01:52:16 PM
It should be in the split torp script, as I remember there's a section on torpedo behaviour its in there somewhere.
Its a long time since I've looked at those scripts, so honestly can't remember the specifics, Mleo may have more info.
Title: Re: Splitting Projectiles
Post by: MLeo on August 25, 2008, 02:08:04 PM
Anything that can be configured can be done in the projectile script.

Title: Re: Splitting Projectiles
Post by: DKealt on August 25, 2008, 02:31:01 PM
really? as in the areas mentioned in the readme are the only areas modifiable,

or do u mean that u cn add additional script lines to modify the behaviour that aren't currently present?
Title: Re: Splitting Projectiles
Post by: MLeo on August 25, 2008, 03:26:02 PM
I meant that any configuration that you can do can be done in the projectile script itself.

The 4 things you can define are: spreadNumber, spreadDensity, warheadModule and shellLive.
Title: Re: Splitting Projectiles
Post by: El on August 25, 2008, 03:29:24 PM
I thought there was more than that, I could be thinking of the ATP scripts though. Hmm, I thought Ftech was the same?
Title: Re: Splitting Projectiles
Post by: MLeo on August 25, 2008, 03:38:41 PM
Dasher copied some helper functions (and idea's) from ATP.

You could be right though. But those are the variables I have found in the script.

I think you will need something far more elaborate to create a proper effect. Such as using Boids AI (flocking) but that's really hard to do, especially since Torpedoes don't have AI. (I'll keep this in mind for Excalibur!)