Home   Help Search Login Register  

Author Topic: Jump  (Read 502 times)

0 Members and 1 Guest are viewing this topic.

Loup-Garou

  • Guest
Jump
« on: 05 Jun 2004, 22:32:02 »
On BIS forum I've found the two following scripts, that allow to jump. The only problem is that the jump is TOO big, and fatal after a few tries  :-\. However, I think that only a FEW modifications are needed in order to obtain a realistic jump (let's say about 1 m hight and 3 m long  :P). So if anyone can help...I'm not very good in scripting...but it might be a question of mathematics... :P.

;jump.sqs
;first script

jup = 1
jdn = 5
_ux = 0

_xdir = getdir player
_xsin = sin (_xdir) * 100
_xcos = cos (_xdir) * 100
_xposX = (getpos player select 0)
_xposY = (getpos player select 1)
_xposz = (getpos player select 2)

_xXpos = (_xposX)+(_xsin)
_xYpos = (_xposY)+(_xcos)

#loop1
player setpos [_xXpos,_xYpos,_xposz + 75]
jup = jup + 1
_dx = _dx + 1
~0.01
? (_dx < 75): goto "loop1"

_xdir = getdir player
_xsin = sin (_xdir)
_xcos = cos (_xdir)
_xposX = (getpos player select 0)
_xposY = (getpos player select 1)
_xposz = (getpos player select 2)

_xXpos = (_xposX)+(_xsin)
_xYpos = (_xposY)+(_xcos)

#loop2
player setpos [_xXpos,_xYpos,_xposz - jdn]
jdn = jdn + 5
_ux = _ux + 5
~0.05
? (_ux < 70): goto "loop2"

;addjump.sqs
;second script
pj = player addaction ["Jump","jump.sqs"]

;Put in player's init field : [] exec "addjump.sqs"
« Last Edit: 06 Jun 2004, 09:09:11 by Loup-Garou »

Dubieman

  • Guest
Re:Jump
« Reply #1 on: 06 Jun 2004, 02:16:01 »
Maybe I'm wrong but can't you just decrease all numbers that +1 or whatever to +0.5 and toy with it?
« Last Edit: 06 Jun 2004, 02:16:28 by GuiltyRoachKilla »

Uldics

  • Guest
Re:Jump
« Reply #2 on: 06 Jun 2004, 08:07:56 »
Why can't you use setvelocity command - could get rid of the second loop? As I know you can not use setvelocity on units, but only when standing on ground (touching; height 0). But It could be worth a try to setpos in the beginning only to detach from ground - 1 time. Then setvelocity in a desired direction, as I can see you understand sin cos and so on. Then the game engine would make the trajectory and the ballistic curve instead of you + you would decrease some lag, and it would probably look more natural.

Loup-Garou

  • Guest
Re:Jump
« Reply #3 on: 06 Jun 2004, 09:12:50 »
Someone suggested me this solution...but sadly I don't know how to use it  :-\...I'M NO GOOD IN SCRIPTING  :'( !

_me=_this select 0
_v= velocity _me
_me setvelocity [_v select 0, _v select 1, (_v select 2)+50]

exit
« Last Edit: 06 Jun 2004, 09:13:05 by Loup-Garou »

DBR_ONIX

  • Guest
Re:Jump
« Reply #4 on: 06 Jun 2004, 11:12:04 »
Uh, theres already a thread about jumping.. I think I posted it ::) (Atleast replied to it)

I made up the script that I've attached to this thread

To setvelocity a unit, you have to use the setpos command on him (unit setpos getpos unit - I think, might be setpos unit, though)

Anyway, to change the height you jump (In my code atleast), just change the line "_howmuch = 5"
to something else, 1 will be a tiny jump, 10 is around the highest you can jump without getting killed (I guess)
5 is a okay height, you can jump over the sandbag wall things perfectly..

Also, if your running, and jump, you jump in that direction, and speed up a bit :)

Last thing, I've disabled the bug that let you jump repeatedly (So you can go flying into the air :P)

It's a lot simpler than that other script (I hardly undersand half of it), also I've commented it all, so it's simpler to understand/edit

If you want anything added etc, lemme know and I'll give you the code

Hope this helps :)
- Ben
« Last Edit: 06 Jun 2004, 11:20:14 by DBR_ONIX »

Loup-Garou

  • Guest
Re:Jump
« Reply #5 on: 06 Jun 2004, 11:25:21 »
Ok. I've found it : http://www.ofpec.com/yabbse/index.php?board=10;action=display;threadid=14793;start=0. Thanks  :D !

I've begun to examinate your script. When it'll be successfully tested, I'll post the code here  :).

Loup-Garou

  • Guest
Re:Jump
« Reply #6 on: 06 Jun 2004, 11:49:31 »
Ok ! I've tested it ! It works fine, I've no problem.

In my opinion, jumping has a practical use in the game : it would be useful to jump over fences of a garden in order to quickly take cover in a house (instead of going round the house until you find the entrance while being under enemy fire... :P).

Code (jump.sqs) :

_Nameofunit = _this select 0

; How high the person jumps, max 10, min 3, approx.

_howmuch = 5

; If the person jumps higher the more you jump

_jumpinc = 1
_wherex = getpos _Nameofunit select 0
_wherey = getpos _Nameofunit select 1
_wherez = getpos _Nameofunit select 2
_fastx = velocity _Nameofunit select 0
_fasty = velocity _Nameofunit select 1
_fastz = velocity _Nameofunit select 2
_newfastz = _fastz + 5

_Nameofunit setpos [_wherex,_wherey,_wherez]
_Nameofunit setvelocity [_fastx, _fasty, _newfastz]

; Stop the person jumping repeatadly, 3 should be enough of a delay
; It remove the jump acction, waits 3 seconds, and add's it again

_Nameofunit removeaction jumpacc

~3

jumpacc = _Nameofunit addAction ["Jump","jump.sqs"]

;and add to the player jumpacc = this addAction ["Jump","jump.sqs"]

exit

TOPIC SOLVED !  :D
« Last Edit: 06 Jun 2004, 14:40:32 by Loup-Garou »