Bridge Commander Central
BC Forums => BC Scripting => Topic started by: KrrKs 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 ;)
-
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
-
Thanks! I'll ask them!
-
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:
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
-
*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.
-
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.
-
Is this t he kinda thing your hoping to achieve?
(http://img140.imageshack.us/img140/7669/deflectoractivesj3.png)
-
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!??)
-
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
-
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
-
oh and rob what is wrong with your science menu looks kinda wrong :lol: :lol:
-
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
-
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.
-
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
-
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.
-
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
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
-
Prepare a real Phaser (App.PhaserBank) (ie. setting up all the properties) and add that.
-
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:
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:
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
-
Instead of:
#pShip.GetPhaserSystem().AddChildSubsystem(App.PhaserProperty(SBWeapon)) #app error in line 9821, __init__
Try this:
pShip.GetPhaserSystem().AddChildSubsystem(App.PhaserProperty_Cast(SBWeapon)) #app error in line 9821, __init__or:
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.
-
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... :?
-
Well, the AddSubsystem and it's Remove counterpart need an actual shipsubsystem, not a shipsubsystemproperty (or that's what the error says).
-
The "App.PhaserProperty" is the only thing (I know of) which does NOT return the "expecting ...." message. But this returns that "init in line somewhere" in the App.
This messages now are really getting on my nerves.
Could I send the script to some of you, so that you can test yourself? (I know this is normaly a "donut ask" question, but I just can't figure out how to do these two things properly.
-
Have you tried putting a PhaserSystemProperty instance as the argument to App.PhaserSystem()?
-
Sorry, I don't get it right now. SBweapon is set up as a PhaserSystemProperty, so what do you mean??? Sorry again, it's now about 11pm here and I'm getting tired.
-
Use AddShipsubsystem like this:
AddShipSubsystem(App.PhaserSystem(SBWeapon))
-
Ouh, sorry sometimes I'm just as stupid as i look.
Yes I tried that. It returns the same beforementioned "__init__" error in the App, but in line 6448. :?
-
What exactly does it say?
__init__ error doesn't say a thing. It just tells us that an error occured in the function called __init__.
-
it's refering to this:
class PhaserSystem(WeaponSystem):
PP_LOW = Appc.PhaserSystem_PP_LOW
PP_MEDIUM = Appc.PhaserSystem_PP_MEDIUM
PP_HIGH = Appc.PhaserSystem_PP_HIGH
def __init__(self,*args):
self.this = apply(Appc.new_PhaserSystem,args) # line 6448 in which the error ocurs
self.thisown = 1
in the App. But as there *can't* be a failure in this script and i just dont know which failure I did, i'm :?
EDIT: Or should I give you a console printout?
-
I know that (I looked it up), but what is the error, what does it say?
-
It says this:
File ".\Scripts\Custom\QBAutostart\SpecialBeam.py", Line 406, in CreatePhaser
pShip.GetPhaserSystem().AddChildSubsystem(App.PhaserProperty(SBWeapon))
File".\Scripts\App.py", Line 9281, in __init__
Attribute Error: __int__
(No Failure, the error in init is named int)
BTW, wasn't there a way to save a complete printout direct out of BC somewhere?
-
Try this code:
pShip.GetPhaserSystem().AddChildSubsystem(App.PhaserSystem(SBWeapon))Note the use of PhaserSystem instead of PhaserProperty.
-
Just looked over the script again. I already tried this, it is returnig exctli the same error in line 6448 instead of line 9281.
-
Alright, try this one:
pShip.GetPhaserSystem().AddChildSubsystem(App.PhaserSystem(App.PhaserSystem.PP_LOW))
-
PP_LOW ????
However this line gets an extra large WHOW, as it is instantly kicking me out of the game!
(I tried twice with two different ships)
-
*sitting alone in the dark*
still anyone out there??
-
Do you want to know when you posted your last 2 posts?
1:22AM and 1:47AM. I'm asleep, hopefully, around those times. ;)
The reason I suggested the PP_LOW, is because it's a constant (actually for the phaser powerlevel) and that the error pointed to the __int__ method, which is used for allowing custom classes to convert themselves to an int(eger).
-
Ahh, got it. But since this failed, do you have any other suggestions?
Edit: Are the netherlands on our after Germany or did I just fail to read the Clock? :)
-
In the same timezone.
But your 2 previous posts were posted at 1:22 and 1:47 AM.
-
Damn, so I failed reading the clock. I thought it was already 2:15 am
-
Ugh, gobbledeegook. Good idea though.