I'll do it! I'll do it!Requiemfang wrote:This is what I initially thought you would do after the alpha test you wanted me and a few others did in the final version.
[Script] Litcube's Bounce V1.7: Player Owned Autopilot Fix
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
Requiemfang
- Posts: 3206
- Joined: Thu, 16. Jul 09, 12:24

-
Litcube
- Posts: 4254
- Joined: Fri, 20. Oct 06, 19:02

Thanks, buddy.
I just finished implementing the signal. Seriously, it was 2 lines of code. Plus one more in the toggle hot-key. I'm going to throw flour all over my face before I exit the kitchen holding a cake I bought at the grocery store.
There's one last thing I want to check before I release it. I'm worried that Bounce will switch to non-idle mode if an enemy suddenly appears when the player's ship is in, or intersects, a solid object, thus destroying it.
That one last thing, and I'll throw 1.3 up. You and apricot will have your perpetual Bounce.
I just finished implementing the signal. Seriously, it was 2 lines of code. Plus one more in the toggle hot-key. I'm going to throw flour all over my face before I exit the kitchen holding a cake I bought at the grocery store.
There's one last thing I want to check before I release it. I'm worried that Bounce will switch to non-idle mode if an enemy suddenly appears when the player's ship is in, or intersects, a solid object, thus destroying it.
That one last thing, and I'll throw 1.3 up. You and apricot will have your perpetual Bounce.
-
HotSake
- Posts: 472
- Joined: Sun, 3. Jan 10, 22:15

Can I ask you to break down what's happening in the transpose subroutine? I get that you're figuring out the orientation of the ship and where to center the nodes. I'm having a hard time working out the process in my head, and the fact that scripts reference angles in 65,536 unit increments (and apparently return sin and cos in that range) due to being restricted to integers is messing with me. I guess it doesn't help that I'm not used to doing 3D geometry and don't really understand the rotation values.
Basically, if you could explain the reasoning behind the following formulas that would really help me understand working with positions and headings.
This is called twice with $z representing a distance along the ship's axis from the center toward the front, and then the back, correct? It uses the ship's rotation data to create a reference point along the ship's axis. Gamma is referenced first because it represents roll about the axis and therefore determines how the planes of the other two rotation values (pitch and yaw) are oriented. The end result is two sets of 3D coordinates making two points used below, each 80% of the ship's length from its center, or 30% of the ship's length past each end:
"Slope" is a bit of a misnomer, since they really represent the distance along a single axis between the two reference points, scaled down to generate the proper spacing, correct? This is why the reference points are placed where they are. Because 160% of the ship's total length, divided by 10 is 16% of the ship's length, which is approximately how far apart each node needs to be if there are 5 of them.
And finally:
From the ship's center point, take the increments determined above for each axis and add a decreasing number of steps to place the nodes so that they are spaced along the ship's axis from front to back forming a rough approximation of a cylinder, correct?
What I most need help with is understanding the first code chunk. Why that algorithm, why those operations in that order? I'm sure it would be obvious if I better understood 3D math. I get that the goal is to create reference points ahead of and behind the ship along its axis, but I'm having a hard time figuring out what's going on with the operations performed on $sin, $cos, $x,$y, $z, and $i. You're basically building triangles here, right? And $i is a temp variable used as a stand-in for when one of the other coordinates needs to be moved? I know I'm basically asking for a math lesson here, but I feel like I'm really close to getting it and just need a little help.
Basically, if you could explain the reasoning behind the following formulas that would really help me understand working with positions and headings.
Code: Select all
$G = [THIS]->get rot gamma
$sin = fixed sin $G
$cos = fixed cos $G
$i = ( $cos * $x - $sin * $y ) / 65535
$y = ( $cos * $y + $sin * $x ) / 65535
$x = $i
$B = [THIS]->get rot beta
$sin = fixed sin $B
$cos = fixed cos $B
$i = ( $sin * $z + $cos * $y ) / 65535
$z = ( $cos * $z - $sin * $y ) / 65535
$y = $i
$A = [THIS]->get rot alpha
$sin = fixed sin $A
$cos = fixed cos $A
$i = ( -$sin * $z + $cos * $x ) / 65535
$z = ( $cos * $z + $sin * $x ) / 65535
$x = $iCode: Select all
$SlopeX = ( $x1 - $x2 ) / ( $NodeCount * 2 )
$SlopeY = ( $y1 - $y2 ) / ( $NodeCount * 2 )
$SlopeZ = ( $z1 - $z2 ) / ( $NodeCount * 2 )And finally:
Code: Select all
$x1 = [THIS]->get x position
$y1 = [THIS]->get y position
$z1 = [THIS]->get z position
$Count = $NodeCount
while $Count
dec $Count =
$x = $x1 + $SlopeX * ( $Count - ( $NodeCount / 2 ) )
$y = $y1 + $SlopeY * ( $Count - ( $NodeCount / 2 ) )
$z = $z1 + $SlopeZ * ( $Count - ( $NodeCount / 2 ) )
$Point = array alloc: size=3
$Point[0] = $x
$Point[1] = $y
$Point[2] = $z
$Nodes[$Count] = $Point
endWhat I most need help with is understanding the first code chunk. Why that algorithm, why those operations in that order? I'm sure it would be obvious if I better understood 3D math. I get that the goal is to create reference points ahead of and behind the ship along its axis, but I'm having a hard time figuring out what's going on with the operations performed on $sin, $cos, $x,$y, $z, and $i. You're basically building triangles here, right? And $i is a temp variable used as a stand-in for when one of the other coordinates needs to be moved? I know I'm basically asking for a math lesson here, but I feel like I'm really close to getting it and just need a little help.
-
Litcube
- Posts: 4254
- Joined: Fri, 20. Oct 06, 19:02

Under the hood, with HotSake.
The first blurb is trig. It takes the three rotations, and a point. The point is supplied as though the object were aligned with the 0,0,0 axis. So -1000,0,0, would be 1km to the left of a ship (regardless of it's direction). sin and cos are trig functions. Yes, I'm making triangles. To understand how they work, lookup trigonometry in wiki. To get angles in 3D space, you need to pretend that there's triangles everywhere, and use sin, cos, and other trig functions to be able to gather the relation between object. This is way out of scope of this thread, which isn't a trig course (and I'm definitely no prof in trig
).
I believe you understand what's happening in the code. I'm changing some of it for the next release, which should be in about an hour or so.
The first blurb is trig. It takes the three rotations, and a point. The point is supplied as though the object were aligned with the 0,0,0 axis. So -1000,0,0, would be 1km to the left of a ship (regardless of it's direction). sin and cos are trig functions. Yes, I'm making triangles. To understand how they work, lookup trigonometry in wiki. To get angles in 3D space, you need to pretend that there's triangles everywhere, and use sin, cos, and other trig functions to be able to gather the relation between object. This is way out of scope of this thread, which isn't a trig course (and I'm definitely no prof in trig
Correct.HotSake wrote:This is called twice with $z representing a distance along the ship's axis from the center toward the front, and then the back, correct?
Slope isn't a misnomer, but the rest of your statement is correct.HotSake wrote:"Slope" is a bit of a misnomer, since they really represent the distance along a single axis between the two reference points, scaled down to generate the proper spacing, correct?
That's correct. But it's not really a cylinder; it's more like this, but with larger spheres.HotSake wrote:From the ship's center point, take the increments determined above for each axis and add a decreasing number of steps to place the nodes so that they are spaced along the ship's axis from front to back forming a rough approximation of a cylinder, correct?
I believe you understand what's happening in the code. I'm changing some of it for the next release, which should be in about an hour or so.
-
HotSake
- Posts: 472
- Joined: Sun, 3. Jan 10, 22:15

Yeah, I was paper checking the code with some numbers from the default wall file to see if there were any gaps where a ship's hull could extend beyond a node's surface. Looks like there are no possible gaps in coverage. I understand basic trig, so I'll just have to sit down with some scratch paper and work through the steps in the code to see exactly how those values yield a 3D point.
-
MadMan983
- Posts: 447
- Joined: Fri, 10. Jul 09, 13:03

-
Litcube
- Posts: 4254
- Joined: Fri, 20. Oct 06, 19:02

[ external image ]MadMan983 wrote: but will it work with XTC or X-tra ship pack?
-
Litcube
- Posts: 4254
- Joined: Fri, 20. Oct 06, 19:02

Update!
1.3:
- Bounce now only requires a toggle, and is on perpetually afterword, until turned off. Regardless of new ships in sector, or if playership changes sector. You will have to setup your toggle hotkey again. Essentially, it's turn on and forget, but you can turn it off at any time.
- setup.Bounce.UnregisterOldKeys script included to unregister the 1.2 and prior hotkeys. Once you save your game after the keys have been removed, you can delete this script.
- Optimized collision detection significantly
- There was a bad speed check that was causing partial error collision losses (3 - 5 in a fleet of about 300), but this has been eliminated.
- Optimized node code to improve performance
- Included check for idle mode intersections, avoids ships popping due to being within an object when collision detection is suddenly resumed.
- Wall file generation has been optimized. My test ran at 2:37 minutes.
1.3:
- Bounce now only requires a toggle, and is on perpetually afterword, until turned off. Regardless of new ships in sector, or if playership changes sector. You will have to setup your toggle hotkey again. Essentially, it's turn on and forget, but you can turn it off at any time.
- setup.Bounce.UnregisterOldKeys script included to unregister the 1.2 and prior hotkeys. Once you save your game after the keys have been removed, you can delete this script.
- Optimized collision detection significantly
- There was a bad speed check that was causing partial error collision losses (3 - 5 in a fleet of about 300), but this has been eliminated.
- Optimized node code to improve performance
- Included check for idle mode intersections, avoids ships popping due to being within an object when collision detection is suddenly resumed.
- Wall file generation has been optimized. My test ran at 2:37 minutes.
-
HotSake
- Posts: 472
- Joined: Sun, 3. Jan 10, 22:15

What's the point of this:
Does the set position command put the object in the nearest available space if the arguments would cause it to collide with something? Otherwise, I don't see how this accomplishes anything.
Code: Select all
MoveOutSideOfObject:
$x = [THIS]->get x position
$y = [THIS]->get y position
$z = [THIS]->get z position
[THIS]->set position: x=$x y=$y z=$z
endsub-
Litcube
- Posts: 4254
- Joined: Fri, 20. Oct 06, 19:02

It moves the object outside of an object if it's within another object. It's why I didn't name the function "AcomplishNothing:".
Dude, why are you asking me all these questions and picking apart my code? Honestly, I don't mind at all, even though it sounds like I do. I like to make jokes. It keeps me from being bored. If you're trying to find faults with my work, it's a good thing. It helps us all improve, and hopefully people can learn.
Aside from that, though, I'm still curious. Do you work for the FBI?
Dude, why are you asking me all these questions and picking apart my code? Honestly, I don't mind at all, even though it sounds like I do. I like to make jokes. It keeps me from being bored. If you're trying to find faults with my work, it's a good thing. It helps us all improve, and hopefully people can learn.
Aside from that, though, I'm still curious. Do you work for the FBI?
-
HotSake
- Posts: 472
- Joined: Sun, 3. Jan 10, 22:15

-
HotSake
- Posts: 472
- Joined: Sun, 3. Jan 10, 22:15

I specifically started picking apart your Bounce script because I already had design notes for something similar, so it seemed like a good candidate to learn from. I've got a lot of stuff I'm designing, down to the pseudocode level, but implementation is going to be lots of trial and error as I figure out what I can really do with the language (thank god for Exscriptor).
-
Black147
- Posts: 94
- Joined: Sun, 23. Jan 11, 14:45

I may have run into an issue with your script:
Using TC v3.0 with XTC v1.1, Lucike´s scripts+XTC update and MARS. Bounce 1.3.
This is what happens: bounce seems to run on my playership as well which leads to all kinds of weirdness, specifically after I *just* undocked I sometimes get teleported several km away from said docking clamp for no reason. Additionally with bounce turned on, it appears collision check is turned off *on playership* after a sector change. While nice and cheaty am I right to assume bounce should never run on the playership in the first place?
A quick look into your code led me to the "Sig.Bounce.SectorChange" script and adding the lines
seems to alleviate this so far. I´ll keep testing. Any ideas?
EDIT:
Ikaruga
Using TC v3.0 with XTC v1.1, Lucike´s scripts+XTC update and MARS. Bounce 1.3.
This is what happens: bounce seems to run on my playership as well which leads to all kinds of weirdness, specifically after I *just* undocked I sometimes get teleported several km away from said docking clamp for no reason. Additionally with bounce turned on, it appears collision check is turned off *on playership* after a sector change. While nice and cheaty am I right to assume bounce should never run on the playership in the first place?
A quick look into your code led me to the "Sig.Bounce.SectorChange" script and adding the lines
Code: Select all
0004 skip if not [THIS] == [PLAYERSHIP]
0005 return nullEDIT:
Ikaruga
Good idea, but it´s turned off and I´m fairly certain this issue started after installing bounce not before.XTC, which has an AL plugin called "Safe undocking"
Last edited by Black147 on Thu, 3. Feb 11, 14:35, edited 3 times in total.
-
Ikaruga
- Posts: 376
- Joined: Fri, 30. Jan 04, 14:26

-
Bléral
- Posts: 697
- Joined: Wed, 31. Mar 04, 00:37

I think I'm getting a little glitch about that, although I'm using the latest version. Collisions deactivated after I switched ships in-sector: that seems to make some sense, and is easily fixable by deactivating/reactivating bounce (realized it as I tried to fly through a gate, and just went through it without warping). More weird: loaded a game, undocked, flew around a few minutes; spotted a bunch of Xenons, engaged "attack all" with my Drake and my wingmen, and I just watched. Quickly realized my own ship was invulnerable, as ennemy shots went through it. Scratched my head for a while; toggled Bounce, all went fine. Toggled it back on, everything seemed normal again with my playership.
Glitch? Bug with the new system?
Anyway, great script, by the way. My Asps love it!
Glitch? Bug with the new system?
Anyway, great script, by the way. My Asps love it!
L'hypertrophie de louveteau se palpe.
Tiens, mais ne serait-ce pas une fonction de Recherche ?
Tiens, mais ne serait-ce pas une fonction de Recherche ?
