Jump to content
The Dark Mod Forums

Grappling Hook (donation/help Required)


Metal

Recommended Posts

Hey guys, I've decided to come over here and post about my grapple hook mod that I'm working on (originally posted at doom3world.org) because well I've decided to go a different route with modding and I won't need a grapple hook in my new project. However I still want to get this working while my new idea is being formulated and planned out. You guys had mentioned some interest in this for your own game and I know Domarius has already implemented a Rope Arrow. So if you guys would like I will gladly donate my code and time for your use (I'd love to see something I helped create actually be used, rather than sit on my harddrive). The catch is I'm stuck in a rut and I need some help myself :rolleyes:

 

I've been doing all my working via scripts now use of the sdk (yet) and the method I've used to get the grapple hook (or as Domarius I believe called this early version the "chameleon's tongue") is to create an entity 'func_mover' and then bind that entity to $player1. I can then use moveToPos( vector pos ) to move the func_mover entity where ever the grapple's hook landed and pull the player along with it. And it works great however, at the end of moving the player I need to release him so that he can move around normally again. So I've looked around and found out I could do use $player1.unbind(); however, no matter where I place this code in my script it seems to unbind the player from the mover before the move and ruins the grapple effect :angry: I've been working on this for 3 days straight now trying several different methods and I just know that the solution is going to be something small and easy that I'm overlooking.

 

Does any of your team or any1 here have any idea how this could be accomplished?

 

After I get the basic idea of a grapple that can pull the player to a location done I plan on enhancing the way it acts and continuing to develop it to a more realistic hook that interacts with physics and realistically grabs onto the environment. And allowing different methods of movement on the rope (ie. swing, climb, run along walls). Which I believe would be a really cool feature in your guy's game. :D

Link to comment
Share on other sites

I can then use moveToPos( vector pos ) to move the func_mover entity where ever the grapple's hook landed and pull the player along with it. And it works great however, at the end of moving the player I need to release him so that he can move around normally again. So I've looked around and found out I could do use $player1.unbind(); however, no matter where I place this code in my script it seems to unbind the player from the mover before the move and ruins the grapple effect :angry:

How do you decide when the move is over and the player is near the grappling hook?

Gerhard

Link to comment
Share on other sites

I used the following code (bits borrowed from clusternade mod and a rope arrow):

 

   vector lastPos;
  while(projectile.getProjectileState() != PROJECTILE_EXPLODED && projectile.getProjectileState() != 0) {
     lastPos = projectile.getWorldOrigin();
     sys.waitFrame();
  }
  if(lastPos != '0 0 0') {
     //added by metal for grapple hook effect
     mover = sys.spawn( "func_mover" );
     mover.setAngles( getAngles() ); // I think this prob useless
     mover.setOrigin( getWorldOrigin() );

     //bind the player to the mover (can only get it to work in this fashion)
     $player1.bind(mover);

     // set the mover's speed
     mover.speed (120);
     // move to the desired position
     // change this next line to check all directions (maybe mod moveToPos to check)
     lastPos_x += 20; //to keep us from sticking in the wall
     mover.moveToPos( lastPos );

     // wait until we get there
     sys.waitFor(mover);
  }

 

the line sys.waitFor(mover); should cause doom3 to not do anything until we have completed the move...not totally sure that it does especially now that I'm really thinking about it.

Link to comment
Share on other sites

It could be that sys.waitFor just waits for the mover to finish one "Think()" cycle, ie one update, but that's probably not enough time for the whole move to take place.

 

Maybe you could calculate the amount of frames it's going to take for the mover to drag the player over, and then call waitFrames (not sure that's the exact name) for that number of frames before detaching the player. A frame is 1/60th of a second (has nothing to do with visual framerate), so if you know how many doom units separate the player and the impact point, and how many doom units per second the mover is moving at, you should be able to calculate the number of frames to wait before detaching the player. Also, there might be a script function that waits for a given time instead of a given frame number... I don't know that much about script functions.

 

Also, you might ask Domarius about some of the arrow scripting, because that handles pulling the arrow back out of the wall like you want to pull the player out of the wall in this example (by adding to lastPos.. actually what you want to do is subtract a vector away from the collision normal of whatever surface it hits, but ask Domarius about that :) ).

Link to comment
Share on other sites

Well I just took a quick glance through the SDK to see if I could figure out what exactly waitFor( mover ) does, but the code was a bit to complex for me to follow right now. I'm to tired and I've been swamped with stuff all day, and tomorrow I'm driving back up to Orlando from South Florida so I don't know how much time I'll have to look it over, but thanks for the new ideas :D

Link to comment
Share on other sites

Alright I haven't found out what exactly waitFor(mover) actually waits for, but I called wait( time ) and that actually works! Now it's just a matter of correctly calculating the time it will take for me to move to the position and then calling that time in the wait function! Thanks for all the help guys, next step will be making the hook throw more realisitcally and attaching a rope to it (I have a modeler friend working on some stuff for me) :)

Link to comment
Share on other sites

And it works great however, at the end of moving the player I need to release him so that he can move around normally again. So I've looked around and found out I could do use $player1.unbind(); however, no matter where I place this code in my script it seems to unbind the player from the mover before the move and ruins the grapple effect.

Let's see, I'm a newbie at programing and have only learnt C++ at school. Anyway, if I would think in 'normal person way' instead of programers way, I think you should do something similar as this;

 

1. You shoot the grappler.

2. The grappler hits the wall.

3. By programing, make the hit of the grappler spawn a reference-object at the point where the grappler hit.

4. When the player collides with the reference-object, run the unbind-thingy.

 

If you choose for the player to be able to cancel the moving effect in mid-air, just make the reference-object disappear when clicking 'jump button' for example.

 

Or, you could choose to use that time-thingy you made. But, if you manage to do what I thought out, I think it would be more accurate. :)

Link to comment
Share on other sites

Everything with the grapple works, for now I don't have any way for the player to cancel the grapple, other than throwing another grapple in a different direction. And in order to keep the player from getting stuck in the wall I'm going to modify the moveToPos(vector) function in the SDK and create a moveToCheckPos( vector ) that basically will check if the moving entity has hit a wall and if so it will stop the move, there by keep the player out of the walls, ceiling, floor.

 

So for the rest of the day I'll probably work on that and also adding new move types, (haven't thought this completely through) type RopeSwing, RopeWall, RopeClimb are the types I was thinking...I might not even need three I might be able to do it with just one moveType Rope and then have the jump, strafe, forward/backword work to accomplish everything...have to take a look at how other movetypes work first.

 

If any of you guys are interested to see how it works so far, just let me know and I'll put up a working version for everyone to fool around with.

Link to comment
Share on other sites

Well, at the moment it's more like a CS hook, as I understand it. I don't think we'd want to use anything that didn't have half-way realistic physics.

Link to comment
Share on other sites

Ok guys you asked to see a working version so here you go.

 

Note that I used code from Domarius' weapon_broadhead that was posted on Doom3World.org, in order to use this jus rename it from .zip to .pk4 and load it up

 

You should spawn with broadheads, just use prev/next weapon to get to them, it will be a black image that looks like grenades (also note that I have left in my scripts for a fireball and added a light to the pistol, I was to lazy to go in and remove the code and since it has no effect on the grapple who cares :D )

 

EDIT: the link is back up, I fixed the corruption in the file should work now

Grapple Link!

 

The speed is still a little slow and it's still possible to get stuck in the floor and such so be careful :P and finally sorry about using geocities =x I just have no other webspace at the moment.

Edited by Metal
Link to comment
Share on other sites

Well I've spent the better part of the day meddling over code on paper, my head, and the sdk...and I have designed a method that I believe (may) work for the hook to realistically (to an extent) hook onto the level...I'm not 100% I will even be able to implement it and it seems like it might just be a kind of "hack"-ish way to do things...but before I can really dive into that part I need to get a working rope, so I have something to attach the player too.

 

So...new question, how/where do I go about creating a rope...should be an entity, an af, or what...Domarius have you implemented a rope yet? and does it interact properly physics wise? Maybe we could share code or something...seeing as my only real motivation to make this thing work realistically is now Dark Mod. I started it only hoping to achieve the 'pull to target' effect which I have effectively done, but I'm just so fasinated by the idea of a realistic grappling hook and seeing it actually used in a game. :)

Link to comment
Share on other sites

Basically, I'm implementing the rope arrow as it is in T2 (this was a team desicion) since that is what everyone really wants to see again and its quite easy to implement.

 

Compared with a full blown rope that actually can have physics applied to it. That would be a lot of work, and not nessecary to get the simple T2 rope behaviour.

So we are leaving that sort of thing till after the first milestone.

 

The "rope" in T2 is just a different kind of "ladder". And the wobbling you see it do in T2 is just an animation in response to being deployed or being climbed. You can't actually interact with it with real rope physics.

 

Hope I didn't dissapoint you - I think the other guys were hoping you actually knew how to do rope physics already. We chose not to get into that thing just yet, otherwise.

Edited by Domarius
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 1 reply
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...