Bridge Commander Central
BC Forums => BC Scripting => Topic started by: teleguy on June 04, 2009, 01:51:11 PM
-
Is it possible to make shields glow on their own constantly for a certain amount of time?
-
In theory, the glow decay should partially control that, but I believe it doesn't do anything. The only other viable method is through an invisible torpedo positioned just outside a shield vector, pointing inwards, that can only hit the ship in question and (eventually) doesn't do any damage. Terribly hackish, but it's the only method I could come up with (last time it was asked).
-
Sounds extremely complicated. There has to be a torpedo for every shield arc. How exactly would I do that?
-
Like I said, it has been asked before, there may even be some code floating about.
First you define 6 vectors (for the 6 shield arcs), which denote a "normal" for a shield arc. For each vector, you create, position and prepare a torpedo, and let it go. The impact of that torpedo can be nullified through a simple FoundationTech yield.
Positioning is by scaling that arcs vector by the radius of the ship times 1.1, preparation is making sure it can only be hit by the ship itself (is fairly easy to do, EnableCollisionsWith) and that it is relative to the ship (AttachObject), and that it faces the ship (which is the opposite vector for that arc).
-
I've found the thread you mentioned. http://bc-central.net/forums/index.php/topic,4534.0.html
I'll take a closer look later.
Meanwhile I tried the glow decay but apperently it has no effect, there are no console errors either.
for pShield in range(App.ShieldClass.NUM_SHIELDS):
maxshield = pShields.GetMaxShields
(pShield)
rate = pShields.GetProperty
().GetShieldChargePerSecond(pShield)
glow = pShields.GetShieldGlowDecay()
pShields.GetProperty().SetShieldGlowDecay
(1000000)
pShields.SetCurShields(pShield, maxshield)
-
Would it perhaps be possible to attach a Nanofx atmosphere to a ship?
-
That's a sphere, shields are not (neccesairly). And it's static, always the same.
-
A Nanofx atmosphere is more than a sphere...
It's a couple of Sun and Planet objects.
What you want exactly? Just to make a ship "glow" a little?
-
Yes, something like this or this...
-
Hmmm ok.
I asked because I know a easy way to make a "glow" in a ship, but it still would be a sphere.
It works by creating a torpedo which only purpose is to glow, and attach it to the center of the ship you want. I made something like this in GravityFX. It can be easily modified to use a torpedo with the size, color, textures and flares as you want (and actually color and size are already).
So the restrictions you would had in the effect would be those of a torpedo... Like the fact it is a sphere.
It might work for pulses as well, but I never tried it.
-
That sounds promising. Is it possible to make the glow semi transparent? I tried to do that with a gravity torpedo (GladSingularity) but no matter how I set the alpha in the plugin there was no visible effect.
-
Could'nt just load a glowing sphere model, scale it and attach it to the ship?
-
Yeah, technically you should be able to make it semi-transparent changing the alpha component of all colors (core color, glow color and flare color). But still depending on size of core and glow, and the flares, the semi-transparent effect might not be easily visible... So you just gotta mess around with the values in the good old trial and error lol
LJ, that would require modeling skills I don't have lol
Since a semi-transparent sphere would be needed, and as far as I know, making such models for BC isn't exactly easy.
Plus, it would require more system resources than a simple, flare-less torpedo wouldn't it?
And finally, with the torpedo we can also easily control size, color and glow (pulse rate and size) :P
-
Won't work. If you encapsulate a transparent object over another object, that other object will be invisible, even if you put it outside the transparent model, but behind it, you won't see it.
-
could you attach it in the following order:
ship -> glowing thing -> ship
I dare say the render tree doesn't do cycle checking - it might work :-)
-
I don't think that has anything to do with it, when transparent, they should render the background over the ship.
-
Won't work. If you encapsulate a transparent object over another object, that other object will be invisible, even if you put it outside the transparent model, but behind it, you won't see it.
hmm..
I don't think that has anything to do with it, when transparent, they should render the background over the ship.
I wouldn't be surprised if BC uses a object based implementation of the painters algorithm. It couldn't hurt to try subverting the render queue tho :-p Its better than punishing the physics engine with a torpedo. :P
-
if you reverse the vertex order of the sphere, the side opposite the camera will render, and the ship will render over that.
No problem.
-
I've found the thread you mentioned. http://bc-central.net/forums/index.php/topic,4534.0.html
I tried to give that a go however I've run into some problems.
This is my function:
def pShieldGlow(pObject, pEvent):
pPlayer = MissionLib.GetPlayer()
pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pShip = App.Game_GetCurrentPlayer()
pShipID = App.NULL_ID
idTarget = pShipID
pHull = pPlayer.GetHull()
radius = pHull.GetRadius()*1.5
kPoint = App.TGPoint3()
kPoint.SetXYZ(0, radius, 0)
kVector = App.TGPoint3()
kVector.SetXYZ(0, -radius, 0)
pTorp = ftb.Tech.ATPFunctions.FireTorpFromPointWithVector(kPoint,
kVector, "Blood Photon", idTarget, pShipID, 50, TGOffset = None)
pShip.AttachObject(pTorp)
And that's what the console says:
EDIT: Figured it out. However when a fire the torpedo the game crashes. How do I add the torpedo script? I tried Tactical.Projectiles.PhotonTorpedo, PhotonTorpedo and the name that shows up ingame.
EDIT2: Ok, firing torpedoes works but they are neither interacting with the ships hull nor the shields.
-
When you pass the ID of the target (idTarget) to the FireTorpFromPointWithVector function, it expects that it is a valid ID (meaning the ID of a ship that exists).
And quoting your code:
pShipID = App.NULL_ID
idTarget = pShipIDSo yeah, it'll never work like that lol. You gotta pass a valid ID (like pTargetShip.GetObjID(), assuming pTargetShip to be a ShipClass obj).
The same applies to the parameter pShipID you're passing, tho if I remember correctly it might not be as necessary as the target ID.
Also, why are you doing this:
pPlayer = MissionLib.GetPlayer()
# ...
pShip = App.Game_GetCurrentPlayer()???
pPlayer and pShip will be the same object: the player ship.
About the pcTorpScriptName parameter (which in your code is "Blood Photon"), it should be the torpedo script (module) string, like "Tactical.Projectiles.<script name>".
EDIT: lol just now saw your edits :P
Anyway... How do you mean they're not interacting with the hulls/shields? You want your torp to "hit" the shields to show the shield effect?
If that's the case, try these 2 things: make that the ship isn't the torp's parent but the target, also try to make it without attaching the torpedo to the ship (i've tried that before and the torpedo never detonated).
-
Thanks.
If I don't attach the torpedo to the ship the torpedoes just start flying from a random location.
How do I make the ship not the parent but the target?
-
Target and parent can be App.NULL_ID
They won't affect the player if the parent is the player.
@Frontier: The wrong projectile name didn't crash BC (and worked) probably because of DiamondBC_Projectiles. ;)
-
So this is my function
def pShieldGlow(pObject, pEvent):
pPlayer = MissionLib.GetPlayer()
pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pShip = App.Game_GetCurrentPlayer()
pShipID = pShip.GetObjID()
idTarget = pShip.GetObjID()
#pHull = pPlayer.GetHull()
radius = pShip.GetRadius()*1.1
kPoint = App.TGPoint3()
kPoint.SetXYZ(0, radius, 0)
kVector = App.TGPoint3()
kVector.SetXYZ(0, -radius, 0)
pTorp = ftb.Tech.ATPFunctions.FireTorpFromPointWithVector(kPoint,
kVector, "Tactical.Projectiles.Quantum", idTarget, pShipID, 20, TGOffset =
None)
pShip.AttachObject(pTorp)
#pShip.EnableCollisionsWith(pTorp, 1)
#pTorp.EnableCollisionsWith(pShip, 1)
and the movie shows what happens when I fire the torpedo.
-
Mleo,
Target can be NULL_ID only if you have a version of FTech/ATPFunctions.py I don't have lol
I tho the one in KM1 was the latest?
From the ATPFunctions.py, FireTorpFromPointWithVector function (right at the beggining):
pTarget = App.ShipClass_Cast(App.TGObject_GetTGObjectPtr(idTarget))
pSet = pTarget.GetContainingSet()If the target is NULL_ID, pTarget = None, and "None" has no attribute GetContainingSet() :P And that part of code isn't in a "try/catch" block lol
The parent/ship ID can be NULL tho yea...
Dunno if he has the DiamondBC scripts so it's best to assume he hasn't :P
Heck that reminds me I have to get them lol
teleguy,
If you not attach the torp to the ship, it's position (as you set) will be in "space" coords, and not the "local" coords of the ship, that's why they appear off position. You just gotta compensate for that: start the torp's location vector from the target's world location, then add the appropriate offset (like you're doing) to make it appear a bit to the side of ship and hit her.
OR your problem is like Mleo said: they won't affect the player if the parent is the player.
Which I believe can be generalized to: the torp you fire won't affect the ship X if it's parent is ship X :P
EDIT:
Saw your post now, you made the torp's parent and target the same (like Mleo said). Set the parent as NULL_ID, and see if that works.
-
pShipID = App.NULL_ID??
If I do that I get a crash to desktop.
-
Mleo,
Target can be NULL_ID only if you have a version of FTech/ATPFunctions.py I don't have lol
I tho the one in KM1 was the latest?
Ok, point taken, you need a target. But no parent.
And it's the parent that's important, if a torp from a parent could hit said parent, then it would never leave the hull.
I can't even remember if I ever changed it, so it's the latest.
-
I managed to get the torpedoes to do damage but for some reason attaching the torpedo to the ship no longer works.
def pShieldGlow(pObject, pEvent):
pPlayer = MissionLib.GetPlayer()
pGame = App.Game_GetCurrentGame()
pEpisode = pGame.GetCurrentEpisode()
pShip = App.Game_GetCurrentPlayer()
pShipID = App.NULL_ID
idTarget = pShip.GetObjID()
pHull = pPlayer.GetHull()
idTargetSubsystem = pHull.GetObjID()
radius = pShip.GetRadius()*1.3
kPoint = App.TGPoint3()
kPoint.SetXYZ(0, radius, 0)
kVector = App.TGPoint3()
kVector.SetXYZ(0, -radius, 0)
#pTorp = ftb.Tech.ATPFunctions.FireTorpFromPointWithVector(kPoint, kVector, "Tactical.Projectiles.QuantumTorpedo", idTarget, pShipID, 20, TGOffset = None)
pTorp = MissionLib.FireTorpFromPoint(None, kPoint, "Tactical.Projectiles.QuantumTorpedo", idTarget, idTargetSubsystem, 20, None)
pShip.AttachObject(pTorp)
-
That's because the MissionLib function returns 0, and not the torpedo object...
-
:D :dance :dance
(http://bc-central.net/forums/index.php?action=dlattach;topic=5869.0;attach=30028;image)
(http://bc-central.net/forums/index.php?action=dlattach;topic=5869.0;attach=30030;image)
Thank you Mleo and USS Frontier, you rule!
I still have one question though. Would the onYield function remove those small puffs of smoke and the shield impact sounds?
-
So is it possible to remove the explosions and the impact sounds? And how can I find out the setname of the ship set?
-
Still thinking about the puffs, they seem awfully randomly placed. You did set the lifetime to 0 in the OnYield, right? So the shield doesn't drain?
About the set, from any ship (and nearly any object that you can see) you can call "GetContainingSet" and it will give you the actual set (not just the set name).
-
You did set the lifetime to 0 in the OnYield, right? So the shield doesn't drain?
No I set the damage in the torpedo script to 0.0001.
About the set, from any ship (and nearly any object that you can see) you can call "GetContainingSet" and it will give you the actual set (not just the set name).
I'm using ATPFunctions.FireTorpFromPoint and that rerquires pcSetName. So far I set it to none.
Still thinking about the puffs, they seem awfully randomly placed.
Yes, that's the problem. I think that's because the function uses world coordinates to orient the torpedo toward the target and those are srewed up when I move the torpedo into the ship set. Anyhow the torpedoes fly in strange diagonal circles around the ship.
-
You did set the lifetime to 0 in the OnYield, right? So the shield doesn't drain?
No I set the damage in the torpedo script to 0.0001.
If you call pTorp.SetLifetime(0) then you still get the shield effect (possibly also the explosion, not sure) but it won't do any damage at all.
About the set, from any ship (and nearly any object that you can see) you can call "GetContainingSet" and it will give you the actual set (not just the set name).
I'm using ATPFunctions.FireTorpFromPoint and that rerquires pcSetName. So far I set it to none.
After you get the set, call GetName() to get the pcSetName.
Still thinking about the puffs, they seem awfully randomly placed.
Yes, that's the problem. I think that's because the function uses world coordinates to orient the torpedo toward the target and those are srewed up when I move the torpedo into the ship set. Anyhow the torpedoes fly in strange diagonal circles around the ship.
As soon as you attach the torpedo to the ship, then it's "origin" (coordinate 0, 0, 0) is then the ship itself, instead of the set.
The system won't suddenly change just because you have a different origin.
-
As soon as you attach the torpedo to the ship, then it's "origin" (coordinate 0, 0, 0) is then the ship itself, instead of the set.
The system won't suddenly change just because you have a different origin.
So why are the torpedoes flying in tilted circles if the torpedo is attached?
-
Perhaps the torp's orientation (forward vector) is wrong. Like it should (from any point around the ship) be pointing at the ship, but isn't. Since torps move forward, they go in a line which won't hit the ship and thus start turning to actually hit the ship.
And with that you get the feeling they circling the ship :P
You could try changing the torp's attributes like speed, max angular accel and guidance lifetime, to see if it's really a problem with the orientation. If you make the torp have god-like maneuvering, he'll be able to hit the ship with a erroneous orientation and seem like line trajectory (or at least a lot closer to a line trajectory than you're currently having).
And just as a kinda offtopic idea: what if you set the torps to actually damage the ship?
It would be a cool offensive tech lol
-
You could try changing the torp's attributes like speed, max angular accel and guidance lifetime, to see if it's really a problem with the orientation. If you make the torp have god-like maneuvering, he'll be able to hit the ship with a erroneous orientation and seem like line trajectory (or at least a lot closer to a line trajectory than you're currently having).
Guidance Lifetime and AngularAcceleration are already pretty high (30 and 50). I tried with 30 and 200 and it didn't help much.
Perhaps the torp's orientation (forward vector) is wrong. Like it should (from any point around the ship) be pointing at the ship, but isn't.
Since the vector is created by the function based on the relative positions between torpedo and ship, don't I get the wrong vector if a different set is used? I noticed that the direction of the torpedoes changes as the position of the ship shifts.
Does anybody know why setting pShipID = App.NULL_ID in FireTorpFromPointWithVector crashes the game?
-
Probably because you didn't specify the offset (TGOffset in the code).
-
Ok, I'm now trying to use the Ftech yield however I don't have any success.
And just as a kinda offtopic idea: what if you set the torps to actually damage the ship?
It would be a cool offensive tech lol
I've thought about this too.
-
In that second script, the one I believe is the tech, don't put everything inside a try block. Because what you put in there is essentially the whole script, and if any errors happen within it, because of the except "pass" block, you'll never know what happened... So in this case the console dump is kinda useless because there was no way for anything to appear in it due to that try/except in your script :?
And about the first script, the torpedo: if your idea is to use the FTech tech only to make the torpedo not do any damage (using the SetLifetime(0)), then you'll only need the onYield method. In your torpedo script, you add the torp to FTech both in the onYield as in the onFire, which in this case is kinda pointless lol
Probably won't change much, but why bother doing something useless right :P
-
import App
try:
import Foundation
import FoundationTech
except:
print "FTech not found"
class ShieldflareTorpedo(FoundationTech.TechDef):
def __init__(self, name, dict = {}):
FoundationTech.TechDef.__init__(self, name,
FoundationTech.dMode)
self.lYields = []
self.__dict__.update(dict)
self.lFired = []
def OnYield(self, pShip, pInstance, pEvent, pTorp):
pTorp.SetLifetime(0)
-
You have inconsistent identation (sp).
import App
try:
import Foundation
import FoundationTech
except:
print "FTech not found"
class ShieldflareTorpedo(FoundationTech.TechDef):
def __init__(self, name, dict = {}):
FoundationTech.TechDef.__init__(self, name, FoundationTech.dMode)
self.lYields = []
self.__dict__.update(dict)
self.lFired = []
def OnYield(self, pShip, pInstance, pEvent, pTorp):
pTorp.SetLifetime(0)
-
Fixed it. However it's still doing shield damage and explosions.
-
I assume you mean with "damage" that the shield still drains?
Is the tech applied to your torpedo?
-
The second attachment in my last post is the torpedo script.
-
Maybe there's something wrong with my install. I noticed Phased Torpedoes are also doing shield damage.
-
Could you please describe what you mean with "shield damage"?
I mean, SetLifetime has worked since, forever.
-
I mean the torpedoes are draining the shield.
Did you check if my torpedo script is correct?
-
It looks correct. Please try the following in the console (and get a console report afterwards) when you are in game.
print App.Torpedo.SetLifetime
-
Here is it. And thank you for your patience.
-
Does that tell you anything?
-
I was hoping to find something there.
If you look in scripts/Custom/Techs/PhasedTorp.py, you can see I use the same thing, and I know it works there.