self.th_jump; [ Oh , this is a hack ! ]
Moderator: InsideQC Admins
12 posts
• Page 1 of 1
self.th_jump; [ Oh , this is a hack ! ]
For a while now I thought a jump animation on the player would be a nice enhancement. I think I hit it on the head today finally, using the stock player model and some basic QC. Here goes:
1) Add a new .void def :
2) Define the new function in client.qc in the [ PutClientInServer () ] function...near the self.th_die; for example :
3) Paste the new animation macro set in an appropriate location.
If you paste at the top of player.qc , you will need to re-declare the player_jump function someplace higher up in the code such as defs.qc by entering :
....so that it can be compiled and executed.
4) Lastly, place the call to the new macro reference in client.qc in the [ PlayerJump() ] function:
4a) Optional - add also to CheckWaterJump ()
Thats it !
Video of it in action here:
http://youtu.be/aH0b737M-sM
1) Add a new .void def :
- Code: Select all
.void () th_jump; // in defs.qc in an appropriate location.
2) Define the new function in client.qc in the [ PutClientInServer () ] function...near the self.th_die; for example :
- Code: Select all
self.th_die = PlayerDie;
self.th_jump = player_jump; // << here
3) Paste the new animation macro set in an appropriate location.
- Code: Select all
void () player_jump = [ 85, player_jump1 ]
{
};
void () player_jump1 = [ 86, player_jump2 ]
{
};
void () player_jump2 = [ 87, player_jump3 ]
{
};
void () player_jump3 = [ 66, player_jump4 ]
{
setsize (self, VEC_HULL_MIN, (VEC_HULL_MAX - '1 0 32')); // Adjust hitbox size - optional.
};
void () player_jump4 = [ 66, player_jump5 ]
{
};
void () player_jump5 = [ 86, player_jump6 ]
{
setsize (self, VEC_HULL_MIN, VEC_HULL_MAX); // Reset hitbox size
};
void () player_jump6= [ 85, player_run ] // << was player_stand 1 previously .... change as per leileilol and Frag.machine, looks better
{
};
If you paste at the top of player.qc , you will need to re-declare the player_jump function someplace higher up in the code such as defs.qc by entering :
- Code: Select all
void () player_jump;
....so that it can be compiled and executed.
4) Lastly, place the call to the new macro reference in client.qc in the [ PlayerJump() ] function:
- Code: Select all
self.flags = (self.flags - FL_ONGROUND);
self.th_jump (); // <<< here
4a) Optional - add also to CheckWaterJump ()
- Code: Select all
self.velocity_z = 225;
self.th_jump (); // <<< here
Thats it !
Video of it in action here:
http://youtu.be/aH0b737M-sM
Last edited by Cobalt on Mon Mar 03, 2014 4:30 am, edited 7 times in total.
-

Cobalt - Posts: 445
- Joined: Wed Jun 10, 2009 2:58 am
- Location: New England, USA
Re: self.th_jump; [ Oh , this is a hack ! ]
I like it! I think im going to throw it in my current project : )
-

gnounc - Posts: 424
- Joined: Mon Apr 06, 2009 6:26 am
Re: self.th_jump; [ Oh , this is a hack ! ]
Very nice Cobalt.
Sometimes it only needs small tweaks to get great result.
Things like these should also go into the tutorials section of main page.
http://inside3d.com/tutorials.php
Sometimes it only needs small tweaks to get great result.
Things like these should also go into the tutorials section of main page.
http://inside3d.com/tutorials.php
- Seven
- Posts: 301
- Joined: Sat Oct 06, 2007 8:49 pm
- Location: Germany
Re: self.th_jump; [ Oh , this is a hack ! ]
Thanks, glad u guys like it.
Noticed today the youtube vid got flagged for 3rd party content. The music track is from an old David Bowie Album....they got the artist and title correct, however, I wrote back to them saying its great you know that, but it should not matter unless you are an authorized agent of that artist to take any actions on his behalf. I have seen this topic bought up over and over, and if a complaint gets filed with anyone with a youtube account, its as if the actual artist is filing the complaint...which is a crock. I also mentioned the Quake team at ID software, and said credit ought to be given to them as well, and I have no problem mentioning all the people involved who wrote the software or supplied music etc. Actually , I think crediting everyone involved makes sense because you are acknowledging their work, and they can only benefit when they see something they did a long time ago still being promoted in a good light. True the decision is ultimately theirs and if they dont like your use of their work, they can request it not be posted, and you should take it down....but thats not for some dweeb at Google to decide - its up to the original artists to make that call.
Noticed today the youtube vid got flagged for 3rd party content. The music track is from an old David Bowie Album....they got the artist and title correct, however, I wrote back to them saying its great you know that, but it should not matter unless you are an authorized agent of that artist to take any actions on his behalf. I have seen this topic bought up over and over, and if a complaint gets filed with anyone with a youtube account, its as if the actual artist is filing the complaint...which is a crock. I also mentioned the Quake team at ID software, and said credit ought to be given to them as well, and I have no problem mentioning all the people involved who wrote the software or supplied music etc. Actually , I think crediting everyone involved makes sense because you are acknowledging their work, and they can only benefit when they see something they did a long time ago still being promoted in a good light. True the decision is ultimately theirs and if they dont like your use of their work, they can request it not be posted, and you should take it down....but thats not for some dweeb at Google to decide - its up to the original artists to make that call.
-

Cobalt - Posts: 445
- Joined: Wed Jun 10, 2009 2:58 am
- Location: New England, USA
Re: self.th_jump; [ Oh , this is a hack ! ]
Original artists were always screwed by the record industry executives, new and old songs alike - they can't make that call, even for those that did want to share their music to the world with the freedom of expression. The only music i've used in my videos were tracker music from the scene and I never had a problem with that.
Also, why go back to the stand1 animation after the jump? No one should do a standing pose when they fall. Even Quake2 knows that.
Also, why go back to the stand1 animation after the jump? No one should do a standing pose when they fall. Even Quake2 knows that.
i should not be here
- leileilol
- Posts: 2783
- Joined: Fri Oct 15, 2004 3:23 am
Re: self.th_jump; [ Oh , this is a hack ! ]
Not a q2 fan at all, but originally I had SUB_Null in there, but it locked up the animation. I am pretty sure you have to put something in there that resumes the players animaiton sequence...maybe its engine related, I dont know for sure. I suppose you could tweak the code from there to see if the player is standing still or running/moving. If standing still during a jump, then stand would eventually be a legit sequense...but if moving, maybe player_run could be substituted. Falling isnt the same as jumping, but they are related....which is a good point.
At first I wanted to repeat the same first 2 or 3 frames backwards from frame 66 to make it more fluid...so it would appear more like what you described....but on short distance jumps that seemed to look not always what would happen. On jumps from a larger height, that may look legit. Also I had at one point activated the sequence when the player was not on ground (just moved off a ledge) - and held it at frame 66 all the way through...which looked neat when in mid air and falling - but in order to really perfect it, you need to traceline to ground until about a players height or about 56 units from the ground, then continue the animaiton. Thats more work - might give that a try as well one day, who knows.
At first I wanted to repeat the same first 2 or 3 frames backwards from frame 66 to make it more fluid...so it would appear more like what you described....but on short distance jumps that seemed to look not always what would happen. On jumps from a larger height, that may look legit. Also I had at one point activated the sequence when the player was not on ground (just moved off a ledge) - and held it at frame 66 all the way through...which looked neat when in mid air and falling - but in order to really perfect it, you need to traceline to ground until about a players height or about 56 units from the ground, then continue the animaiton. Thats more work - might give that a try as well one day, who knows.
leileilol wrote:Also, why go back to the stand1 animation after the jump? No one should do a standing pose when they fall. Even Quake2 knows that.
-

Cobalt - Posts: 445
- Joined: Wed Jun 10, 2009 2:58 am
- Location: New England, USA
Re: self.th_jump; [ Oh , this is a hack ! ]
@Cobalt: just use player_run instead, if the player has no velocity applied it will switch automatically to the stand animation, otherwise it won't look like is sliding on ice.
But I agree,making a jump animation that looks correctly in Quake is far more complex than one can imagine at first.
But I agree,making a jump animation that looks correctly in Quake is far more complex than one can imagine at first.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Re: self.th_jump; [ Oh , this is a hack ! ]
Ok Frag machine....I edited the code above to reflect your improvement.
-

Cobalt - Posts: 445
- Joined: Wed Jun 10, 2009 2:58 am
- Location: New England, USA
Re: self.th_jump; [ Oh , this is a hack ! ]
Added another (2) updates.
1) Noticed this new sequence looks pretty good if its ran while the players FL_WATERJUMP is active from CheckWaterJump ().
2) Seems to be ok to also adjust the players hitbox / max_z size when we are frame 66 in the new jump sequence.... so lets put it out there and try it. The only thing I noticed where this could be trouble is if a solid entity happens to land on our head or already be on our head while we are jumping and are frame 66. Darkplaces didnt seem to mind much, but other engines I am not so sure.
UPDATE:
I noticed if you try these 2 changes, an issue will happen if you are in first person view during a waterjump and the hitbox is being altered. On a map like end for example, the wall you are against while jumping will disappear and if you float to the bottom while still touching the wall, you can see the rest of the map as if you are noclip. So I adjusted the max_x size of the hitbox one quake unit smaller than normal in addition to the _z change, and it seems to have resolved this anomaly. See updated code.
1) Noticed this new sequence looks pretty good if its ran while the players FL_WATERJUMP is active from CheckWaterJump ().
2) Seems to be ok to also adjust the players hitbox / max_z size when we are frame 66 in the new jump sequence.... so lets put it out there and try it. The only thing I noticed where this could be trouble is if a solid entity happens to land on our head or already be on our head while we are jumping and are frame 66. Darkplaces didnt seem to mind much, but other engines I am not so sure.
UPDATE:
I noticed if you try these 2 changes, an issue will happen if you are in first person view during a waterjump and the hitbox is being altered. On a map like end for example, the wall you are against while jumping will disappear and if you float to the bottom while still touching the wall, you can see the rest of the map as if you are noclip. So I adjusted the max_x size of the hitbox one quake unit smaller than normal in addition to the _z change, and it seems to have resolved this anomaly. See updated code.
-

Cobalt - Posts: 445
- Joined: Wed Jun 10, 2009 2:58 am
- Location: New England, USA
Re: self.th_jump; [ Oh , this is a hack ! ]
I noticed that you tried to use SUB_Null in the animation, so I think you should know what [] really does...
void () player_jump2 = [ 87, player_jump3 ] {};
void () player_jump3 = [ 66, player_jump4 ] {};
is the same as:
void () player_jump2 =
{
self.frame = 87;
self.think = player_jump3;
self.nextthink = time + 0.1;
};
void () player_jump3 =
{
self.frame = 66;
self.think = player_jump4;
self.nextthink = time + 0.1;
};
A result of this is that players' .think fields are always being updated for animation, so don't use them.
If you want to pause the animation, I think you can add a "self.nextthink = time + 0.2" (for two frames worth) in the function to override the []'s automatic one. In your case, I think you might need a think function that calls itself until the player touches ground.
void () player_jump2 = [ 87, player_jump3 ] {};
void () player_jump3 = [ 66, player_jump4 ] {};
is the same as:
void () player_jump2 =
{
self.frame = 87;
self.think = player_jump3;
self.nextthink = time + 0.1;
};
void () player_jump3 =
{
self.frame = 66;
self.think = player_jump4;
self.nextthink = time + 0.1;
};
A result of this is that players' .think fields are always being updated for animation, so don't use them.
If you want to pause the animation, I think you can add a "self.nextthink = time + 0.2" (for two frames worth) in the function to override the []'s automatic one. In your case, I think you might need a think function that calls itself until the player touches ground.
- Zop
- Posts: 5
- Joined: Mon Apr 21, 2014 10:41 pm
Re: self.th_jump; [ Oh , this is a hack ! ]
Zop thanks for that tip. I went ahead and put your code in as a test with all the same frames. Had to paste them in reverse because they call on each other from the bottom up, as opposed to the other code which works the other way.
Not any noticable difference so far....the animation looks the same , and if we start an atttack during that sequence, we jump out of it and go into the attack frames just like before, so I guess that would work too.
I have also updated this code alot since my last post, I have a landing sequence when the jump is at a decent height, also Im using frame No. 73 as a "diving" frame when jumpuig off a ledge, but not when the ledge is nearby a decent depth of water. For the case where the ledge is right near the water, I made the jump sequence activate, but with no upward velocity_z , so it makes him look like he didnt just fall into empty air. You may have seen it in action too when you played on my server last week.
I will try to post all the code here when time permits, but its more complicated because we are hijacking playerprethink () now, and new floats need to be added along with some others....
Not any noticable difference so far....the animation looks the same , and if we start an atttack during that sequence, we jump out of it and go into the attack frames just like before, so I guess that would work too.
I have also updated this code alot since my last post, I have a landing sequence when the jump is at a decent height, also Im using frame No. 73 as a "diving" frame when jumpuig off a ledge, but not when the ledge is nearby a decent depth of water. For the case where the ledge is right near the water, I made the jump sequence activate, but with no upward velocity_z , so it makes him look like he didnt just fall into empty air. You may have seen it in action too when you played on my server last week.
I will try to post all the code here when time permits, but its more complicated because we are hijacking playerprethink () now, and new floats need to be added along with some others....
-

Cobalt - Posts: 445
- Joined: Wed Jun 10, 2009 2:58 am
- Location: New England, USA
12 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest