Change the player's jump height: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
setplayer has been able to take constants for a while now: the ZERO var is redundant.
LordMisfit (talk | contribs)
Adding some info on extending jump height (Lord Misfit edit)
Line 1: Line 1:
You can use the player member [[jumping_counter]] to limit the player's jump to less Olympic heights.
You can use the player member [[jumping_counter]] to limit the player's jump to less Olympic heights.


The [[jumping_counter]] increments from 0 (not jumping) to 1441 as follows:
The [[jumping_counter]] increments from 0 (not jumping) to 1441 (end of jump) in increments of 180, as follows:


  0
  0
Line 13: Line 13:
  1441
  1441


By manually setting the counter to 0 when the counter reaches one of these values, you can decrease the duration of the jump by effectively cancelling it mid-jump.
By manually setting the counter to 0 or a value above 1440 when the counter reaches one of these values, you can decrease the duration of the jump by effectively cancelling it mid-jump. Additionally, you can use a similar method to extend the jump height of the player.


You'll need a gamevar to hold the value of [[jumping_counter]].
You'll need a gamevar to hold the value of [[jumping_counter]].
Line 26: Line 26:
{
{
setplayer[THISACTOR].jumping_counter 0  
setplayer[THISACTOR].jumping_counter 0  
}</pre>
}
</pre>
 
If you want to increase jump height instead of lowering it, you can do this instead:
<pre>
getplayer[THISACTOR].jumping_counter temp
ifvare temp 1261
{
setplayer[THISACTOR].jumping_counter 362
}
</pre>
The above example increases the jump duration by 5 tics. The default jumping height is 9 tics without any changes in the code. The reason 1 is added to the counter when a jump is extended is to prevent an endless jumping loop from occuring. It is recommended to check for 128x when extending the jump to maximize jumping velocity(or [[poszv]]).


[[Category: Tutorials]]
[[Category: Tutorials]]

Revision as of 13:08, 13 July 2009

You can use the player member jumping_counter to limit the player's jump to less Olympic heights.

The jumping_counter increments from 0 (not jumping) to 1441 (end of jump) in increments of 180, as follows:

0
181
361
541
721
901
1081
1261
1441

By manually setting the counter to 0 or a value above 1440 when the counter reaches one of these values, you can decrease the duration of the jump by effectively cancelling it mid-jump. Additionally, you can use a similar method to extend the jump height of the player.

You'll need a gamevar to hold the value of jumping_counter.

gamevar temp 0 2

Inside the APLAYER actor, use the following code to cut the jump duration in half:

getplayer[THISACTOR].jumping_counter temp
ifvare temp 721 
{
	setplayer[THISACTOR].jumping_counter 0 
}

If you want to increase jump height instead of lowering it, you can do this instead:

getplayer[THISACTOR].jumping_counter temp
ifvare temp 1261 
{
	setplayer[THISACTOR].jumping_counter 362 
}

The above example increases the jump duration by 5 tics. The default jumping height is 9 tics without any changes in the code. The reason 1 is added to the counter when a jump is extended is to prevent an endless jumping loop from occuring. It is recommended to check for 128x when extending the jump to maximize jumping velocity(or poszv).