Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → grappling hooks
12
grappling hooks
2004-11-19, 3:25 AM #41
I have compiled the project into a zip. It's not %100 but the swinging is nice. :)

http://www.hellraiser64.com/Files/grapplehook.zip

Any questions just post them here.

[It's late, so read the comments or ask ZeqMacaw. I must get up and work for The Man in 6 hours so I'll post a more detailed outline of the whole thing later.]
-Hell Raiser
2004-11-22, 1:42 PM #42
this is cool, definitely different than what i've seen. but you can't really swing very high can you? he tends to swing back and forth forever without stopping. either that or i haven't tried it long enough. anyway, i hope to see the progress of this mod... if HR is still going to finish it...
2004-12-07, 8:47 PM #43
Really big bump...
Ferr1s b3ull3r, j00 r my h3r0!
2004-12-07, 9:28 PM #44
I kinda tipped the hat of development in ZeqMacaw's direction. (if that makes any sense, I'm sleep depping...)

He's looking over all the hook codes and trying to come up with a good mix of logic. (From what I understand :) )
-Hell Raiser
2004-12-08, 11:16 AM #45
Okay, I have looked at some of the grappling hook cogs (including the ones posted in this thread by Hell Raiser), trying to make sense of them.

Most of the hook cogs use some variant of 'pushing' the player toward the hook once it attaches, and not much else.

Quib Mask's cogs are also worthy of mention, but I am focusing on the swinging physics, for now.

HR's cogs seem to be the first real attempt at simulating swinging. (Yay!) HR's method disables the engine's physics for the player and simulates the swinging physics all in the cog.

Impressive as the swinging code is, I am hoping to figure out something more general that will allow easier integration of other physics effects. I have a theory that uses the engine's calculations of gravity and air resistance to our advantage, potentially shrinking the code and providing a very accurate simulation of real-world physics of swinging. I have not tested the theory in code yet, but I should be testing it by this weekend.

Here is the theory:
1. After hook has attached and player is in a position that will cause him to swing...
2. within a fast pulse
3. let the engine drop the player
4. move the player horizontally to the correct position (because engine moves player straight down, but player should be moving along an arc)
5. at the equilibrium point (under the hook), push player up with the speed the engine was giving the player when he reached the point
6. on the way up, just move player horizontally as when going down
7. continue until player stops.

Assumptions:
A. Engine calculates gravity and air resistance effects well enough.
B. Repositioning the player will not affect the engine's handling of the player's velocity.
C. This will make other effects easier to implement.

(If I remember the tests for my space station physics correctly, A and B are valid.)

Of course, if my theory fails the tests, then I will continue to build off of what Hell Raiser and Quib Mask have begun. ;)

Looking forward to SpiderMan mods,
:)

[Edit: one -> ones]
2004-12-08, 4:40 PM #46
Quote:
Originally posted by ZeqMacaw
5. at the equilibrium point (under the hook), push player up with the speed the engine was giving the player when he reached the point


I remember trying to determine the player's speed (not for the hook mod), but all the verbs were returning 0 as his speed and force. Are you having the same problem or did I just do something wrong?
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-12-08, 5:22 PM #47
VectorLen(GetThingVel(Player)); should return how many JKU's a second the player is moving. (unless my memory is THAT foggy :o )
-Hell Raiser
2004-12-08, 5:33 PM #48
Quote:
Originally posted by Hell Raiser
VectorLen(GetThingVel(Player)); should return how many JKU's a second the player is moving. (unless my memory is THAT foggy :o )

Nope, that's it
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2004-12-08, 7:16 PM #49
Quote:
Originally posted by Hell Raiser
VectorLen(GetThingVel(Player)); should return how many JKU's a second the player is moving. (unless my memory is THAT foggy :o )


Wait a tick... That's probably it! I think I just printed an integer value for getthingvel(player), DOH!

(for those new to cogging, the problem was that if you print a vector quantity as an integer it only displays '0')
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-12-15, 8:43 AM #50
Oops! I forgot to post a few days ago.

I am still working on implementing my theory, and I have good news: my initial tests have succeeded. My code handles the "downswing" to the equilibrium point as expected by the theory. The remaining parts will have to wait until this weekend. If the remaining implementation works as well as this first part, then it will be considerably shorter and more general than Hell Raiser's code. (Thanks go to HR for helping me with some of the vector calculations.)

(As a side note, I needed to use the square root function to implement the proper code. So, I implemented a working square root function that can be used in other cogs. I will probably also implement cos and sin functions and include them all in a "Special Functions" cog. BTW, these functions would return approximations, but will be good enough precision for our purposes.)

:)
2004-12-15, 9:03 AM #51
Yea, yours will compensate for gravity and whatnot, while I had to simulate it with scalers. :) Can't wait to see our combined efforts in action. :D
-Hell Raiser
2004-12-15, 4:03 PM #52
Well, for a square root function, you could use
Code:
sqrt:
for(a=0; rootme-a*a>=0; a=a+1)
{}
if(rootme-a*a>rootme-(a-1)*(a-1))
a=a-1;
b=rootme-a*a;
answer=(a+(b/(2*a)))-(((b/(2*a))*(b/(2*a)))/(2*(a+(b/(2*a)))));
printflex(answer);
return;

or you could just use
Code:
pow(rootme, 1/2);


Not 100% sure pow works in JK (all my tests were in MOTS). The first code block will get the square root within at least 4 decimals.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-12-15, 4:19 PM #53
The second doesn't work, as I remember with a couple edge-grapple concept mods my team worked on. It was always very poorly calculated.
ᵗʰᵉᵇˢᵍ๒ᵍᵐᵃᶥᶫ∙ᶜᵒᵐ
ᴸᶥᵛᵉ ᴼᵑ ᴬᵈᵃᵐ
2004-12-15, 5:58 PM #54
This is my version of the square root function:
Code:
    root = square * 0.5;
    i = 0;
    do
    {
        i = i + 1;
        root = (root + (square / root)) * 0.5;
        check = root * root - square;
        if (check < 0)
        {
            check = -check;
        }
    }
    while (check > 0.000001 && i < 10);

I need to check how many times the loop needs to run; I think it can be fewer than 10 for the 6 decimal places that JK uses.

:)
2004-12-15, 6:56 PM #55
Back when I posted this a while ago, I didn't get any responses save CavEmaN telling me to use a 1/2 power.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-12-15, 7:19 PM #56
Yeah, I thought I had seen the square root mentioned a few times in the forums, but I have given up using the search on Massassi's forums. :(

I only looked up how to code the square root function because I needed it. I would have posted it in SG-fan's thread had I figured it out back then. ;)

Because of how easy it was to code the square root function, I looked up how to code the sin and cos functions. The algorithms for them seem only slightly harder to code than the square root function.

I normally avoid such complicated math, but cogging such cool features is fun.

:)
2004-12-16, 6:09 PM #57
pow does not work for JK. It may for MOTS, but it doesn't for JK. Just tested. Though Zeq's looks useful. (And somewhat familiar, lol). I've long been annoyed by the lack of power functions for JK.
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2005-01-02, 6:50 AM #58
*sigh*

The bad news:
My theory did not work in JK for two reasons. One, SetThingVel (for the upswing) did not seem to use air drag, so the player kept swinging. Two, moving the player via teleport (for the steps 4 and 6 in the theory), could often place the player inside a wall or 3do. So, I abandoned that theory.

I then tried another idea until I realized I was re-implementing the idea that was used by TIE_14 and HR in the thread I linked to earlier in this thread. Lol. That idea's problem is the player looks like he is on a bungee cord bouncing up and down as he swings. (This might be useful for other purposes though.)

The good news:
I tried a third idea. This one is really a variant of HR's method. Instead of arbitrarily using "step" amounts for figuring out where to move next in the swing, I use what I think is a more accurate math model for the next move. The idea is to calculate which direction and how fast the player should be swinging in each pulse.

The idea works in general, but still needs some tweaking. It seems to handle horizontal swinging and moving the player while on the swing, 'automatically'. The initial down-swing and the following up-swing seems to work well, except at the end of the up-swing it slows little by little for much too long. I might have 'fixed' that part, but then when it comes back, (in my tests) the player would bump the platform he jumped from (which was fine in this case), but the calculations don't adjust for the bumping before the end of the swing, so it goes wacky after that. (This is possibly what HR meant about needing to handle 'bumping into stuff' in his version.) To handle that, I started placing the needed code for using the TSDS and ETM-P cogs. I didn't finish this part.

Conslusion:
I have run out of interest in this mod for now. I hope it is a simple matter of finishing the 'bumping'. I have zipped the files for others to use or experiment with, or even better, to finish.

:)
2005-01-02, 6:09 PM #59
Well, I got my hook to work. Unfortunately, it only works in slowmo :(

I don't know why, but I think the engine changes it's physics calculations when in slowmo. Either that, or I'm asking too much of the cog at regular speeds, but in slowmo it has the time to process the data... If you want I'll post the cog later.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
12

↑ Up to the top!