OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: penguinman on 03 Jun 2005, 18:19:54
-
Hello,
im trying to make a script that waits untill a parachute has landed, then switchmoves the driver into a animation
Ive tried many different things but i cant get it to work, could sombody help me by making it,
thanks
-
well could you say some ways that youve tried so we dont suggest the same thing
-
You need a loop checking the para's height, and when he lands then play the anim.
I've got this to work for another project already, so heres the way the code should look either incorporated into the eject script or activated by it... (it would help to know what method you are using to have the unit(s?) eject)
#altcheck
~1
_pos=getpos paranamehere
_alt=_pos select 2
?(_alt>.5): goto "altcheck"
~1
paranamehere playmove(or switchmove) "animationnamehere"
-Grendel
-
ok here is the script im using, it dosent need an eject part because the parachute starts in the air
_unit = _this select 0
_para = vehicle _unit
#loop
~1
_height = (getpos _unit select 2)
?_height < 1: goto"update"
goto "loop"
#update
_unit action ["EJECT",_para]
#loop2
_unit setpos getpos _para
?(getpos _unit select 2) < 1: goto "update2"
~.01
goto "loop2"
#update2
~1
_unit switchmove"paraland"
exit
-
I also tried just ejecting him and then doing it like so
_unit = _this select 0
_para = vehicle _unit
#loop
~1
_height = (getpos _unit select 2)
?_height < 1: goto"update"
goto "loop"
#update
_unit action ["EJECT",_para]
~1
_unit switchmove"paraland"
exit
the reason im ejecting him from his parachute is that normaly when it lands the man plays an animation already, right after the parachute disapeers
-
what about
#loop
~1
;detects if paratrooper is 0 or less than 0 metres underground
? _height <= 0 : goto "anim"
~1
goto "loop"
#anim
;an extra test to make sure hes at ground level
? !_height >= 0 : goto "loop"
<put the rest of the script here eg play move anim name and so on>
Syntax not guranteed
-
correct me if i'm wrong, but isn't the default animation the unit plays when it lands, "paraland" or are you trying to play a custom animation...
-grendel
-
no, its an animation i made :)
-
oh, its close,
w/ your script it does the animation after he does the default one, i also found out that he can play my animation while he is still in the parachute, so if you can find a way to keep the parachute from being deleted.
-
whos script is this that almost works if mine try deleting the parachute when hes about 1 or less metres from the ground then he will fall without hurting himself then perform the animation
-
how would i delete the parachute without deleting the unit, and eject wont work because it makes him play another default anim.
-
the only way to do that is move the player into a parachute so if there already in a chopper and then disembarks then it wont work but try
playerp
like
bmpd for the driver of a bmp that might talk about the parachute but if the player starts at a certain height you have to move him in a parachute by creating the soldier and create a parachute then you can name the parachute.
then to delete it would be
deletevechille parachute_name
-
ok il try it :)
deletevechille parachute_name
I think you mean deletevehicle ;)
thanks
-
erm probaly i can never seem to spell it no matter how hard i try thats whyi have to copy and paste it so its reconised as a command lol.
also i think i know a way this can work but it will cause alot of lag well might depending on the mission until youve landed ill put it down anyway
#loop
;detects if paratrooper is 0.1 or less than 0.1 metres from the ground
? _height <= 0.1 : goto "anim"
~0.1
goto "loop"
#anim
;an extra test to make sure hes at ground level
? !_height >= 0.1 : goto "loop"
<put the rest of the script here eg play move anim name and so on>
? _height == 0 : goto "exit"
#exit
exit
have a go with that you can change the loop time and height and so on until it works but it depends on how you did the paradrop if you moved him in the parachute instead of that script use this
#loop
;detects if paratrooper is 0.1 or less than 0.1 metres from the ground
? _height <= 0.1 : goto "delete"
~0.1
goto "loop"
#delete
;an extra test to make sure hes at ground level
? !_height >= 0.1 : goto "loop"
deletevechile paracute_name
~0.5
player playmove <anim name>
?_height == 0 : goto "exit"
#exit
exitthat should instead of play the anim delete the parachute and then play the anim wich might be a bit more smoother than the first but anyway just have a play around with either of these two scripts
good luck
-
Not sure this method is what your after, but you can avoid loops using eventhandlers.
In this case I'm adding the para chute myself. But the trouble is, it looks like you have to use CamCreate rather than CreateVehicle for the chute, so I'm not sure how it will work in MP. But if your guy is jumping out of a plane, then it should not be a problem, aslong as you modify the scripts to use another GetOut event on the aircraft.
_Man=_This Select 0
_Chute=ObjNull
_Pos=GetPos _Man
_Chute="ParachuteWest" CamCreate [_Pos Select 0,_Pos Select 1,100]
_Man AssignAsDriver _Chute
_Man MoveInDriver _Chute
@!(IsNull (Driver _Chute))
_Chute AddEventHandler ["GetOut",{_This Exec "GetOut.sqs"}]
GetOut.sqs:
_Driver=Driver (_This Select 2)
_Driver SwitchMove "Stand"
UnassignVehicle _Driver
As soon as he hits the ground he will use the Stand anim, you will probably have to add more code depending on what your anim is. As the guy still moves around because of the getout action, you might have to secure him in place with SetPos or something?
-
It works!
but now I have the unit in switchmove"crouchToCombat" and he gets stuck, how do I have him him not be stuck in an animation and be able to walk around again.
-
He should'nt be locked from a CrouchToCombat Switchmove.
Might be better to post the entire script or a test mision. Sometimes, depending how you move AI in and out of vehicles, can cause it to loose it's ability to follow orders. I had that problem Setpos'ing AI out of vehicles. Had to use actions instead.
-
erm try
player_name switchmove "null"
i think thats right
-
nm i fixed it myself, thanks but UNN you said about having them jump out of planes, you had to add another EH.
'
well i do want them to jump out of planes so how do I run the script on them, i tried but all that happens is the units jump out and then another parachute is created near them but they stay in the one they are in and then dont play the anim when they land,
-
Add a getout event to the plane that checks for guys leaving the cargo positions, and grab the chute, OFP creates by default:
_Aircraft AddEventHandler ["getout",{_This Exec "CargoEject.sqs"}]
CargoEject.sqs:
_Pos=_This Select 1
_Man=_This Select 2
If (_Pos!="cargo") Then {goto "Exit"}
@((Vehicle _Man)!=_Man)
_Chute=Vehicle _Man
_Chute AddEventHandler ["GetOut",{_This Exec "GetOut.sqs"}]
#Exit
-
thanks it works, you can find it in scripting beta testing/