Author Topic: Shieldflare  (Read 7341 times)

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #20 on: June 18, 2009, 01:12:23 PM »
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?

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Shieldflare
« Reply #21 on: June 18, 2009, 04:49:07 PM »
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. ;)
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 teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #22 on: June 18, 2009, 06:14:19 PM »
So this is my function

Code: [Select]
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.

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Shieldflare
« Reply #23 on: June 18, 2009, 06:23:05 PM »
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):
Code: [Select]
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.
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #24 on: June 18, 2009, 06:29:16 PM »
Code: [Select]
pShipID = App.NULL_ID??

If I do that I get a crash to desktop.

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Shieldflare
« Reply #25 on: June 18, 2009, 07:48:21 PM »
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 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 teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #26 on: June 19, 2009, 05:45:41 AM »
I managed to get the torpedoes to do damage but for some reason attaching the torpedo to the ship no longer works.

Code: [Select]
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)


Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Shieldflare
« Reply #27 on: June 19, 2009, 12:59:59 PM »
That's because the MissionLib function returns 0, and not the torpedo object...
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline teleguy

  • Posts: 363
  • Cookies: 53
Oh yea!!!
« Reply #28 on: June 19, 2009, 04:50:52 PM »
 :D  :dance :dance



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?


Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #29 on: June 20, 2009, 09:18:43 AM »
So is it possible to remove the explosions and the impact sounds? And how can I find out the setname of the ship set?

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Shieldflare
« Reply #30 on: June 20, 2009, 09:26:45 AM »
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).
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 teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #31 on: June 20, 2009, 09:56:07 AM »
Quote
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.
Quote
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.

Quote
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.











Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Shieldflare
« Reply #32 on: June 20, 2009, 12:59:08 PM »
Quote
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.

Quote
Quote
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.

Quote
Quote
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.
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 teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #33 on: June 20, 2009, 01:07:26 PM »
Quote
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?

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Shieldflare
« Reply #34 on: June 20, 2009, 01:47:48 PM »
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
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #35 on: June 20, 2009, 03:08:17 PM »
Quote
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.

Quote
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?







Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Shieldflare
« Reply #36 on: June 20, 2009, 06:01:49 PM »
Probably because you didn't specify the offset (TGOffset in the code).
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 teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #37 on: June 20, 2009, 08:15:50 PM »
Ok, I'm now trying to use the Ftech yield however I don't have any success.


Quote
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.

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: Shieldflare
« Reply #38 on: June 21, 2009, 02:04:19 AM »
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
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Shieldflare
« Reply #39 on: June 21, 2009, 08:36:44 AM »
Code: [Select]
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)