Author Topic: Ingame Subsystem adding  (Read 6200 times)

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Ingame Subsystem adding
« on: July 16, 2008, 07:43:48 AM »
Hello to all,
I'm new here and need help with a script. I wanted to make a kind of "special Beam" like
the Galaxy's Deflector pulse or the Warbirds Shield Drain weapon from ST Armada.
For the Effect I tried to add a Phasersubsystem to the ship i used while playing, meaning the script should be able to add a phaser (or whatever) with predefined values,  at a predefined location on the ship, when clicking on a button.
In the App there is a "AddChildSubsystem" command, but I don't know how to use it.
Thanks for help, and sorry for this monster text in my bad english ;)

Offline Nighthawk

  • |______[o]_|
  • Posts: 750
  • Cookies: 18
Re: Ingame Subsystem adding
« Reply #1 on: July 16, 2008, 09:21:23 AM »
you'd better ask Rob at BCS. I think he managed to master dynamic hardpoints. at least, he was working on that. or Frontier, or Sovereign also there.
for what I know, it's like picking the hardpoint, copying it, adding the property you need, making it a new hardpoint and changing the one on the ship.

www.bcs-tng.com/forums/index.php



Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Ingame Subsystem adding
« Reply #2 on: July 16, 2008, 10:10:13 AM »
Thanks! I'll ask them!

Offline cnotsch

  • Posts: 85
  • Cookies: 3
Re: Ingame Subsystem adding
« Reply #3 on: July 16, 2008, 02:38:37 PM »
nice idea i started that a few weeks ago and hey! it works i have to look into my libary somewhere must be that bit of text adding a deflector beam to a ship....
... ahh there it is as far as i know that works fine last time i tried i fried a cube with one shot  :lol: :lol: :lol:

Code: [Select]
def CreatePhaser(pShip, fDamage):
Position = [0, 0, 0]
Radius = 0.05
SSS = pShip.GetSensorSubsystem()
if SSS:
pos = SSS.GetPositionTG()
if pos:
Position = [pos.GetX(), pos.GetY(), pos.GetZ()]
rad = SSS.GetRadius()
if rad:
Radius = rad
App.g_kModelPropertyManager.ClearLocalTemplates()
PhasedPoleronBeam = App.PhaserProperty_Create("Phased Poleron Beam")

PhasedPoleronBeam.SetMaxCondition(1500.000000)
PhasedPoleronBeam.SetCritical(0)
PhasedPoleronBeam.SetTargetable(1)
PhasedPoleronBeam.SetPrimary(1)
PhasedPoleronBeam.SetPosition(Position[0], Position[1], Position[2])
PhasedPoleronBeam.SetPosition2D(64.000000, 62.304001)
PhasedPoleronBeam.SetRepairComplexity(1.000000)
PhasedPoleronBeam.SetDisabledPercentage(0.250000)
PhasedPoleronBeam.SetRadius(0.200000)
PhasedPoleronBeam.SetDumbfire(0)
PhasedPoleronBeam.SetWeaponID(1)
PhasedPoleronBeam.SetGroups(0)
PhasedPoleronBeam.SetDamageRadiusFactor(0.180000)
PhasedPoleronBeam.SetIconNum(364)
PhasedPoleronBeam.SetIconPositionX(66.000000)
PhasedPoleronBeam.SetIconPositionY(17.000000)
PhasedPoleronBeam.SetIconAboveShip(0)
PhasedPoleronBeam.SetFireSound("Kessok Phaser")
PhasedPoleronBeam.SetMaxCharge(10.00000)
PhasedPoleronBeam.SetMaxDamage(fDamage)
PhasedPoleronBeam.SetMaxDamageDistance(30.000000)
PhasedPoleronBeam.SetMinFiringCharge(10.00000)
PhasedPoleronBeam.SetNormalDischargeRate(0.500000)
PhasedPoleronBeam.SetRechargeRate(0.300000)
PhasedPoleronBeam.SetIndicatorIconNum(510)
PhasedPoleronBeam.SetIndicatorIconPositionX(59.000000)
PhasedPoleronBeam.SetIndicatorIconPositionY(27.000000)
PhasedPoleronBeamForward = App.TGPoint3()
PhasedPoleronBeamForward.SetXYZ(0.000000, 1.000000, 0.000000)
PhasedPoleronBeamUp = App.TGPoint3()
PhasedPoleronBeamUp.SetXYZ(0.000000, 0.000000, 1.000000)
PhasedPoleronBeam.SetOrientation(PhasedPoleronBeamForward, PhasedPoleronBeamUp)
PhasedPoleronBeam.SetWidth(0.010000)
PhasedPoleronBeam.SetLength(0.001000)
PhasedPoleronBeam.SetArcWidthAngles(-0.785398, 0.785398)
PhasedPoleronBeam.SetArcHeightAngles(-0.785398, 0.785398)
PhasedPoleronBeam.SetPhaserTextureStart(16)
PhasedPoleronBeam.SetPhaserTextureEnd(23)
PhasedPoleronBeam.SetPhaserWidth(0.300000)
kColor = App.TGColorA()
kColor.SetRGBA(0.000000, 0.000000, 1.000000, 1.000000)
PhasedPoleronBeam.SetOuterShellColor(kColor)
kColor.SetRGBA(0.000000, 0.501961, 1.000000, 1.000000)
PhasedPoleronBeam.SetInnerShellColor(kColor)
kColor.SetRGBA(0.000000, 0.937255, 1.000000, 1.000000)
PhasedPoleronBeam.SetOuterCoreColor(kColor)
kColor.SetRGBA(0.074510, 1.000000, 1.000000, 1.000000)
PhasedPoleronBeam.SetInnerCoreColor(kColor)
PhasedPoleronBeam.SetNumSides(12)
PhasedPoleronBeam.SetMainRadius(Radius)
PhasedPoleronBeam.SetTaperRadius(Radius * 0.7)
PhasedPoleronBeam.SetCoreScale(0.500000)
PhasedPoleronBeam.SetTaperRatio(0.250000)
PhasedPoleronBeam.SetTaperMinLength(5.000000)
PhasedPoleronBeam.SetTaperMaxLength(30.000000)
PhasedPoleronBeam.SetLengthTextureTilePerUnit(0.050000)
PhasedPoleronBeam.SetPerimeterTile(1.000000)
PhasedPoleronBeam.SetTextureSpeed(2.500000)
PhasedPoleronBeam.SetTextureName("data/eldominionpolaron1.tga")
App.g_kModelPropertyManager.RegisterLocalTemplate(PhasedPoleronBeam)
prop = App.g_kModelPropertyManager.FindByName("Phased Poleron Beam", App.TGModelPropertyManager.LOCAL_TEMPLATES)
if (prop != None):
pShip.GetPropertySet().AddToSet("Scene Root", prop)
pShip.SetupProperties()

the arguments: pShip the App.ShipClass object, fDamage (pretty hard to guess) the damage the phaser does.

running that piece of code adds a blue phaser with the size of your deflector and the position of your defl. to your ship (or any other ship)

but i recommend disablind advanced power control since it can't handle new subsystems wich are added after a ship was created, don't worry i think it only causes some errors in the console you can still have fun, maybe we can/may develop a fix for advanced power control... let's see

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Ingame Subsystem adding
« Reply #4 on: July 16, 2008, 06:36:13 PM »
*sniff* :'(
And no-one thought of asking me?

AddChildSubsystem can add a phaser bank to the phaser "master" system (top level, what you see directly under the ship menu in the targets list).

In the ship class there is a corresponding AddSubsystem.

It also is so that any system can be "just" made and then filled in. Which can then be added to the ship, but don't try to add a phaser bank (atleast, not a "Weapon" type, yes, there is a real Weapon type in BC) as a direct subsystem for ship (through AddSubsystem).

You will have to do trial and error of course, since nearly no-one has done this before.

No offense, but it seems a bit over the top to emulate the entire hardpoint system just to add a single system to a ship.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline cnotsch

  • Posts: 85
  • Cookies: 3
Re: Ingame Subsystem adding
« Reply #5 on: July 17, 2008, 03:46:38 AM »
originally that was just fooling around, i never looked for a perfect way.
i just thaught if it works while creating a ship, will it also work ingame?  8)
but i could give it a try, if i find time for that during renewing 2 other mods.

Offline Rob Archer

  • Posts: 163
  • Cookies: 545
  • New Frontier MKVI
Re: Ingame Subsystem adding
« Reply #6 on: July 17, 2008, 09:53:02 AM »
Is this t he kinda thing your hoping to achieve?


Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Ingame Subsystem adding
« Reply #7 on: July 17, 2008, 09:55:44 AM »
Thank you cnotsch! You really helped me out! That were exactly the codelines I was looking for! Do i have permission to post it on BCfiles when it's ready? I have never seen something like this there.

to MLeo: The AddSubsystem and AddChildSubsystem commands always ended in an error message like "expectet  _p_Shipsubsystem", which I don't understand (yet!??)

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Ingame Subsystem adding
« Reply #8 on: July 17, 2008, 09:59:25 AM »
to Rob Archer:
Yes something like that, But you should be able to Choose the location (subsystem) from where to shoot, and also the color and texture of the Beam. In addition (that part is alreade made) it damages a predefined subsystem on the tartetet ship (eg. Warpcore, Sensores, what you wish) with a predefined strength

Offline cnotsch

  • Posts: 85
  • Cookies: 3
Re: Ingame Subsystem adding
« Reply #9 on: July 17, 2008, 11:04:12 AM »
go ahead but bevore you release it make SURE there are no errors anymore!!! if you want i can test it when it is ready and maybe fix something. and of course it would be nice if you mention who gave you the hint  :P :P :P

Offline cnotsch

  • Posts: 85
  • Cookies: 3
Re: Ingame Subsystem adding
« Reply #10 on: July 17, 2008, 11:06:44 AM »
oh and rob what is wrong with your science menu looks kinda wrong  :lol: :lol:

Offline JimmyB76

  • Posts: 6423
  • Cookies: 421
Re: Ingame Subsystem adding
« Reply #11 on: July 17, 2008, 12:09:42 PM »
he has secret projects in the works ;)   (more info is at his forum at BCS)
tho i would love to see what is underneath those white boxes :P

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Ingame Subsystem adding
« Reply #12 on: July 17, 2008, 01:27:55 PM »
Thank you cnotsch! You really helped me out! That were exactly the codelines I was looking for! Do i have permission to post it on BCfiles when it's ready? I have never seen something like this there.

to MLeo: The AddSubsystem and AddChildSubsystem commands always ended in an error message like "expectet  _p_Shipsubsystem", which I don't understand (yet!??)
That's because it expects an object with a certain type, for instance, they except a ShipSubsystem of some sort.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Ingame Subsystem adding
« Reply #13 on: July 24, 2008, 08:10:01 AM »
Hello again, Problems (and so me) returned
I think i have now nearly 2/3rd of the main features working, but....
The "ClearLocalTemplates" Command (I think it's this) for some reason affects shields and sensors of a ship.
Meaning: The Brex Powermenu slide doesn't have any effect to the Shields anymore.
              If you power down you sensors, or if they are disabled /destroyed you still have the last targetet vessel in the list and BC tries periodicly to target it.
Is there a way to fix this?

Another thing is that the powerloss createt by the extra subsystem is a bigger problem than I thought. Even if the ship is totaly overpowered it beginns to drain the engines power.
Everything I tried to fix this, from setting the "NormalPowerperSecond" of the phasers to overpower the warpcore (output, batterylimits, batteryoutputs) did not work.
Now I try to completely remove the subsystem after using it, but the "App.g_kModelPropertyManager.RemoveTemplate" command requires 4 arguments:
I know three, the "remove", the ship and the ships subsystem. Anithing else I tried got the message "Error: __init__".
How can I fix these things?? :(
and again, thanx and sorry for the long text in my bad english

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Ingame Subsystem adding
« Reply #14 on: July 24, 2008, 08:55:10 AM »
It's basicly what I feared, using this will cause the hp of a ship to be "reset" (basicly).

And things like sliders will be disconnected from the actual subsystems.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Ingame Subsystem adding
« Reply #15 on: July 25, 2008, 09:33:36 AM »
Ok I retried the addchield subsystem [just the otherway round, now it looks like "pShip.GetPhaserSystem().AddChildSubsystem(App.PhaserProperty(SBWeapon))" ]. Now it returns an "Error: __init__" in the Appp.py in line 9280

Quote
class PhaserProperty(EnergyWeaponProperty):
    def __init__(self,*args):
        self.this = apply(Appc.new_PhaserProperty,args)
        self.thisown = 1

So, any Idea what I did wrong? This constellation was the only one not returning a "missing args", or "attr Error".

Or is there a way to reallign the sliders, MLeo?

again, thanks

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Ingame Subsystem adding
« Reply #16 on: July 25, 2008, 05:20:57 PM »
Prepare a real Phaser (App.PhaserBank) (ie. setting up all the properties) and add that.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Ingame Subsystem adding
« Reply #17 on: August 01, 2008, 09:09:18 AM »
So, the script is to ~ 90% ready. Sadly I had to leave the extra graphical "Blopp" part aside.
But there is still the error with the phaser. Anything i tried ended in Attribute or init Errors.
And the Remove Templates Command did much the same.
I have the script a bit cleaned up, so ...  if someone of you could take look over it and tell me how to use this right, that would be a great help. Now it looks like this:
Quote
def CreatePhaser(pShip):
   global PluginDict
   Position = [0, 0, 0]
   Radius = 0.05
   Sound = None
   SBSF = MissionLib.GetSubsystemByName(pShip, PluginDict['ShootFrom'])
   if SBSF:
      pos = SBSF.GetPositionTG()
      if pos:
         Position = [pos.GetX(), pos.GetY(), pos.GetZ()]
      #rad = SBSF.GetRadius()
      #if rad:
      #   Radius = rad

   OSC = PluginDict['OuterShellColor']
   ISC = PluginDict['InnerShellColor']
   OCC = PluginDict['OuterCoreColor']
   ICC = PluginDict['InnerCoreColor']
   Sound = PluginDict['PhaserSound']
   PhaserDamage = PluginDict['PhaserDamage']
   Radius = PluginDict['PhaserRadius']
   TCharge = PluginDict['FireTime']

   #App.g_kModelPropertyManager.ClearLocalTemplates()

   SBWeapon = App.PhaserProperty_Create("Special Beam Weapon")

   SBWeapon.SetMaxCondition(1500.000000)
   SBWeapon.SetCritical(0)
   SBWeapon.SetTargetable(0)
   SBWeapon.SetPrimary(1)
   SBWeapon.SetPosition(Position[0], Position[1], Position[2])
   SBWeapon.SetPosition2D(64.000000, 62.304001)
   SBWeapon.SetRepairComplexity(1.000000)
   SBWeapon.SetDisabledPercentage(1.000000)
   SBWeapon.SetRadius(0.200000)
   SBWeapon.SetDumbfire(0)
   SBWeapon.SetWeaponID(1)
   SBWeapon.SetGroups(0)
   SBWeapon.SetDamageRadiusFactor(Radius)
   SBWeapon.SetIconNum(364)
   SBWeapon.SetIconPositionX(66.000000)
   SBWeapon.SetIconPositionY(17.000000)
   SBWeapon.SetIconAboveShip(0)
   SBWeapon.SetFireSound(Sound)
   SBWeapon.SetMaxCharge(TCharge)
   SBWeapon.SetMaxDamage(PhaserDamage)
   SBWeapon.SetMaxDamageDistance(550.000000)
   SBWeapon.SetMinFiringCharge(TCharge)
   SBWeapon.SetNormalDischargeRate(0.100000)
   SBWeapon.SetRechargeRate(1.000000)
   SBWeapon.SetIndicatorIconNum(510)
   SBWeapon.SetIndicatorIconPositionX(59.000000)
   SBWeapon.SetIndicatorIconPositionY(27.000000)
   SBWeaponForward = App.TGPoint3()
   SBWeaponForward.SetXYZ(0.000000, 1.000000, 0.000000)
   SBWeaponUp = App.TGPoint3()
   SBWeaponUp.SetXYZ(0.000000, 0.000000, 1.000000)
   SBWeapon.SetOrientation(SBWeaponForward, SBWeaponUp)
   SBWeapon.SetWidth(0.010000)
   SBWeapon.SetLength(0.001000)
   SBWeapon.SetArcWidthAngles(-0.785398, 0.785398)
   SBWeapon.SetArcHeightAngles(-0.785398, 0.785398)
   SBWeapon.SetPhaserTextureStart(16)
   SBWeapon.SetPhaserTextureEnd(23)
   SBWeapon.SetPhaserWidth(0.300000)
   kColor = App.TGColorA()
   kColor.SetRGBA(OSC[0], OSC[1], OSC[2], OSC[3])
   SBWeapon.SetOuterShellColor(kColor)
   kColor.SetRGBA(ISC[0], ISC[1], ISC[2], ISC[3])
   SBWeapon.SetInnerShellColor(kColor)
   kColor.SetRGBA(OCC[0], OCC[1], OCC[2], OCC[3])
   SBWeapon.SetOuterCoreColor(kColor)
   kColor.SetRGBA(ICC[0], ICC[1], ICC[2], ICC[3])
   SBWeapon.SetInnerCoreColor(kColor)
   SBWeapon.SetNumSides(12)
   SBWeapon.SetMainRadius(Radius)
   SBWeapon.SetTaperRadius(Radius * 0.7)
   SBWeapon.SetCoreScale(0.500000)
   SBWeapon.SetTaperRatio(0.250000)
   SBWeapon.SetTaperMinLength(5.000000)
   SBWeapon.SetTaperMaxLength(30.000000)
   SBWeapon.SetLengthTextureTilePerUnit(0.050000)
   SBWeapon.SetPerimeterTile(1.000000)
   SBWeapon.SetTextureSpeed(2.500000)
   SBWeapon.SetTextureName("data/CACardassian.tga")

   App.g_kModelPropertyManager.RegisterLocalTemplate(SBWeapon)
   prop = App.g_kModelPropertyManager.FindByName("Special Beam Weapon", App.TGModelPropertyManager.LOCAL_TEMPLATES)
   if (prop != None):
      pShip.GetPropertySet().AddToSet("Scene Root", prop)


   pShip.SetupProperties()      #here is that D***ed error cause
      #pShip.GetPhaserSystem().AddChildSubsystem(App.PhaserProperty(SBWeapon))   #app error in line 9821, __init__

   #print "created Phaser"
   FireWeapons(pShip)

there are just a few of the notworking commands left and the "setup propertys"

the other difficult part is this:
Quote
def DestroySB(pObject, pEvent):

   global TimeIndex

   #print "Am I here?"
   pShip = App.Game_GetCurrentPlayer()

   SBWeapon = "Special Beam Weapon"
   SBWD = MissionLib.GetSubsystemByName(pShip, SBWeapon)

   pShip.DestroySystem(SBWD)

   #App.g_kModelPropertyManager.RemoveTemplate(pShip, SBWD) #req 4 args, 3 givn

   #App.g_kModelPropertyManager.GetProperty().RemoveTemplate(pShip, SBWD)
   #App.g_kModelPropertyManager.RemoveTemplate(pShip,App.ModelPropertyManager.LOCAL_TEMPLATES, SBWD)
   #App.g_kModelPropertyManager.LOCAL_TEMPLATES.RemoveTemplate(pShip, SBWD)
   #App.g_kModelPropertyManager.RemoveTemplate(pShip,App.g_kModelPropertyManager.LOCAL_TEMPLATES, SBWD)


   TimeIndex = 0

   LoadPhaser(pShip)

For both parts: The uncommentet commands do not work.
And again, thanks for help

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Ingame Subsystem adding
« Reply #18 on: August 01, 2008, 09:28:42 AM »
Instead of:
Code: [Select]
#pShip.GetPhaserSystem().AddChildSubsystem(App.PhaserProperty(SBWeapon))   #app error in line 9821, __init__
Try this:
Code: [Select]
pShip.GetPhaserSystem().AddChildSubsystem(App.PhaserProperty_Cast(SBWeapon))   #app error in line 9821, __init__or:
Code: [Select]
pShip.GetPhaserSystem().AddChildSubsystem(SBWeapon)   #app error in line 9821, __init__You were using the wrong function to cast the SBWeapon obj as a App.PhaserProperty instance.
Plus, SBWeapon is already a App.PhaserProperty object, so there's no need to cast it as a PhaserProperty again when passing it to the AddChildSubsystem method.
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Ingame Subsystem adding
« Reply #19 on: August 01, 2008, 10:37:35 AM »
Whithout saying again that this is a Phaser property the function returns normaly an "expecting __p__ShipSubsystem" Error. When I tried your code it returned an "attribute Error", and a combination of both got a also an "p_ShipSubsystem Error". So, not really... :?