Aiming code

Freeform discussion about anything related to modding Transcendence.
Post Reply
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Looking for opinions on this ticket:
http://wiki.neurohack.com/transcendence/trac/ticket/334

I just realized that sysCreateWeaponFire has a hidden feature: If you enter Nil for the direction (but still supply a target) then sysCreateWeaponFire will automatically aim the shot at the target (compensating for motion, etc.)

Is that enough to solve the ticket?

I can also add a new function:

(sysCalcFireSolution targetPos targetVel missileSpeed) -> angle to fire

[Where targetPos and targetVel are vectors relative to the firing platform.]
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

The hidden feature is very cool...

Personally I would not mind having access to a function that gave me the angle directly, but would not miss it much either
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

alterecco wrote:Personally I would not mind having access to a function that gave me the angle directly, but would not miss it much either
It was easy to add, so it will be in the next release.
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Unfortunately this gives the vector from the firing ship and my mod requires the vector from a shot object because I'm simulating not a turret but fragmentation.

I may be able to set the shot as the firer, but I expect this will lose the player blame or credit for any damage. I have an idea for a possible workaround, but it's very kludgy.
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Atarlost wrote:Unfortunately this gives the vector from the firing ship...
I think I can fix this by using the position vector passed in to sysCreateWeaponFire instead of the position of the source object (that's definitely a bug). [Please check me on that.]

But regardless, I hope you can also use the new sysCalcFireSolution function.

[p.s.: Long-term I agree that we need floating-point manipulation functions, but this is easier and computationally faster.]
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

george moromisato wrote:I think I can fix this by using the position vector passed in to sysCreateWeaponFire...
Nevermind, this won't totally work because there is no way to pass in the relative velocity of the target.

I think I will have to use the position passed in, but take the source velocity from the object.
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

If "blame" gets passed I could pass the shot object whose fragmentation I'm simulating in the second argument I think.

I suppose I should check that it's not before going any further.

Nope, that creates wildly unpredictable behavior and makes the shots fratricide.

Hmm. I see why the behavior has gone erratic. I'm moving the shot. I don't remember why.

Okay, sort of working. They're still fratriciding, but at least the survivor works right. You don't get blame for killing friendlies with it though.

Okay, I've got a workaround moving gSource around. http://xelerus.de/index.php?s=mod&id=706
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

george moromisato wrote:I can also add a new function:

(sysCalcFireSolution targetPos targetVel missileSpeed) -> angle to fire

[Where targetPos and targetVel are vectors relative to the firing platform.]
Doesn't it also need to take the firing platform?

(sysCalcFireSolution source targetPos targetVel missileSpeed)

To my mind, though, it would be most sensible if the firing platform and target are the same "kind" of thing.

Either
(sysCalcFireSolution source target missileSpeed)
where source and target are space objects

or
(sysCalcFireSolution sourcePos sourceVel targetPos targetVel missileSpeed)
with source and target as mere vector pairs.

In the latter case it's slightly more work to use where the source and target are preexisting space objects. In the former it's more work where they are locations with no objects, but temporary objects can be created and deleted for such situations, which should be rare. I therefore prefer the former.
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Atarlost wrote:Doesn't it also need to take the firing platform?
You can use sysVectorSubtract to convert to vectors relative to the firing platform:

Code: Select all

(sysCalcFireSolution
   (sysVectorSubtract targetPos sourcePos)
   (sysVectorSubtract targetVel sourceVel)
   missileSpeed)
The new build is up there with sysCalcFireSolution, so you can try it and see.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

I would go for (sysCalcFireSolution source target missilespeed)
Seems the simplest solution, and would provide all we need, ass far as I can see
Post Reply