OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: 456820 on 09 Jun 2005, 18:05:49
-
hello everybody i have this small script that i have made wich checks the dammage of 2 Mi24's at seperate times and when the dammage is higher than 0.85 it sets the helicopters fuel to 0
but i have managed to tell my slef that i am using the code _dammage totally wrong and i cant test this that easy in the mission becuase i havent got it all set up right and there are so many markers and waypoints that i get confused
so im just checking if
a) the script is wright
b) am i using the code _dammage correctly
and
c) what other codes are there wich are like _dammage such as _height
here is the script
#check
? _dammage mi24a > 0.85 : mi24a setfuel 0
~1
? not (canmove mi24a) : goto "check2"
~1
goto "check"
#check2
vulcan dotarget mi24b
~1
vulcan dofire mi24b
#check3
? _dammage mi24b > 0.85 : mi24b setfuel 0
~1
? not (canmove mi24b) : goto "exit"
~1
goto "check3"
#exit
EXIT
-
i'm not sure you want the underscore (_) before 'dammage' - that makes it a local variable, not the command to reference damage of vehicles or units.
so it would be -
#check
? dammage mi24a > 0.85 : mi24a setfuel 0
~1
? not (canmove mi24a) : goto "check2"
~1
goto "check"
#check2
vulcan dotarget mi24b
~1
vulcan dofire mi24b
#check3
? dammage mi24b > 0.85 : mi24b setfuel 0
~1
? not (canmove mi24b) : goto "exit"
~1
goto "check3"
#exit
EXIT
-
so if i changed it to just dammage it should work ? or is it still missing something
-
oh yeah also is the > the right way around for dammage more than 0.85 actuall ill make it an equals aswell
=> is that right for dammage is or more than 0.85 ?
-
check the comref (http://www.ofpec.com/editors/comref.php?letter=num) ;)
-
you could probably use a trigger and in the condition field put
dammge helo1 > .85
and in activation field put
helo1 setfuel 0
and just make another one for the second helo
easier?
-
its abit different than a trigger becuase i have the vulcan opening and ceasing fire on the different targets at once instead of shooting at one then target the second whilst the first is still alive and so on so i included it in a script like that before that is just aload of radio conversation so that is meaningless from the part i posted
-
it turns out when i went to test it that it couldnt relise what the mi24a was as in unknows operator so would get dammage be correct ?
-
pardon? you speaky the english? :P
i think the line you want is
? (getdamage mi24a > 0.85) : mi24a setfuel 0
apologies for not spotting that earlier ;)
-
pardon? you speaky the english?
yep first language just type to fast to keep the words making sense. ;D
apologies for not spotting that earlier
no problem mate im just going to test it but it seems right
also if dammage was the wrong code than what does it do anyway also the same with things like
_height
and also what does the _ do for the code ?
thanks for your help aswell
-
Any variable with a '_' in front of it is a local variable.
Usually local to the script it is used in.
You cannot use local variables in global space.
Planck
-
okay well im making another one where ive used the same begining then i want to check the height of a uh60 named uh60 from the ground for example im using this script
player setcaptive true
titlecut ["", "black in", 3]
shilkag dotarget uh60
shilka dofire uh60
#check
? getdammage uh60 > 0.85 or getdammage uh60 == 0.85 : uh60 setfuel 0 && deletevehicle shilka && goto "done"
~1
goto "check"
#done
~2
shilka switchcamera "external"
#check2
now where it says check2 i want it to check the height of the chopper and when it is around 30metres i want to setpos it to a game logic called set1 how do i check the height of a helicopter also when i set pos it does that mean it will be at ground level ?
-
height is contained in the positional array as select 2. so if you want to check the height of something, do it thus:
_objheight = getpos obj select 2
once you have that value, you already know how to check if it's below/above another value.
similarly, when you setpos something, there's space to put the height value, such as
obj setpos [x,y,z]
-
player setcaptive true
titlecut ["", "black in", 3]
shilka switchcamera "gunner"
shilka setpos getpos maybe_2
shilkag dotarget uh60
shilka dofire uh60
#check
? getdammage uh60 > 0.85 or getdammage uh60 == 0.85 : uh60 setfuel 0 && deletevehicle shilka
~1
goto "check"
~2
shilka switchcamera "external"
#check2
uh60 _height < 60 or == 60 : uh60 setpos getpos set1 uh60p action ["eject",uh60]
uh60 _height < 30 or == 30 : uh60 setpos getpos set1 && goto "finish"
~1
goto "check2"
#finish
uh60 setdammage 0.95
uh60p setpos getpos set_1
[] exec "obj3.sqs"
player setcaptive false
titlecut ["", "white out", 1]
player switchcamera "INTERNAL"
shilkascript = true
~1
titlecut ["", "black in", 1]
~1
exit
i dont really understand that well i think i do but i wouldnt be able to include it into this script when i was having a few experiments so is this nearly right and what do i do to get it right ?
thanks
-
player setcaptive true
titlecut ["", "black in", 3]
shilka switchcamera "gunner"
shilka setpos getpos maybe_2
shilkag dotarget uh60
shilka dofire uh60
#check
? (getdammage uh60 >= 0.85) : uh60 setfuel 0; deletevehicle shilka
~1
goto "check"
~2
shilka switchcamera "external"
#check2
_height = getpos uh60 select 2
? _height >=60 : uh60 setpos getpos set1; uh60p action ["eject",uh60]
? _height <=30 : uh60 setpos getpos set1; goto "finish"
~1
goto "check2"
#finish
uh60 setdammage 0.95
uh60p setpos getpos set1
[] exec "obj3.sqs"
player setcaptive false
titlecut ["", "white out", 1]
player switchcamera "INTERNAL"
shilkascript = true
~1
titlecut ["", "black in", 1]
~1
exit
-
thanks alot it works with no errors but the set pos leaves it on the ground how do i setpos getpos set1 and still have the black hawk at the height it was at before the set pos ? then ill be donr perfect
-
_preheight = getpos uh60 select 2
uh60p setpos [getpos set1 select 0, getpos set1 select 1, _preheight]
-
wouldnt that run in with
_height = getpos uh60 select 2
becuase its both select 2
i tried this anyway
#check2
_preheight = getpos uh60 select 2
_height = getpos uh60 select 2
? _height >=60 : uh60p setpos [getpos set1 select 0, getpos set1 select 1, _preheight]; uh60p action ["eject",uh60]
? _height <=30 : uh60 setpos getpos set1; goto "finish"
~1
and it didnt work the chopper stayed on the ground
-
at the moment, the script stays in #check anyways...
i'm not sure what it is you want this script to do.
i want it to check the height of the chopper and when it is around 30metres i want to setpos it to a game logic called set1
and you want it at the same height as it was before it was setpos'd.
#check2
_height = getpos uh60 select 2
? _height <=30 : uh60 setpos [getpos set1 select 0, getpos set1 select 1, _height] ; goto "finish"
~1
goto "check2"
will do that. what the ejecting is all about isn't clear...
-
okay thanks ill try that and ill explain about the script
it basiccaly shows a shilkas gunners optics and fires at a black hawk then when the black hawks dammage is around 0.85 it stops firing the black hawk loses its fuel comes crashing down to earth and when the uh60' around 65m the pilot ejects then when the black hawk is around 30 metres it goes to the end of the script and just does a few things to make all other units attack and so on hope thats clear enough
anyway thanks ill have a go with that
-
aha perfect works great. thanks alot but do you know how you have things like
if you call a m2machine gun 'M2' for instance you can use M2g to talk about the gunner what is it for a pilot becuase uh60p doesnt seem to work so he doesnt eject and just crahes
-
call him 'uh60d' - pilots are drivers ;)
-
okay ive changed it slightly because the action eject wasnt working so i thought i would cam create a parachute an move the pilot in it to give the illusion that he bailed out but now the script just shows the chopper on the ground.
here are the scripts
script1 wich is what ive been working on
titlecut ["", "black in", 3]
shilka switchcamera "gunner"
shilka setpos getpos maybe_2
shilka dotarget uh60
shilka dofire uh60
#check
? (getdammage uh60 >= 0.80) : uh60 setfuel 0; goto "done"; shilka dofire objnull; shilka dotarget objnull
~0.01
goto "check"
#done
[] exec "camloop.sqs"
#check2
_height = getpos uh60 select 2
? _height <=80 : uh60 setpos [getpos set1 select 0, getpos set1 select 1, _height]; parachute = "parachuteWest" camCreate [0,0,80]; uh60d moveindriver parachute
? _height <=5: uh60 setpos [getpos set1 select 0, getpos set1 select 1, _height]; goto "finish"
uh60d setdammage 0
~0.01
goto "check2"
#finish
uh60 setpos getpos set1
uh60p setdamage 0
uh60 setdammage 0.99
;uh60p setpos getpos set_1
trig1 setpos getpos uh60d
[] exec "obj3.sqs"
player setcaptive false
titlecut ["", "white out", 1]
player switchcamera "INTERNAL"
shilkascript = true
~1
obj5 = true
titlecut ["", "black in", 1]
~1
player switchcamera "INTERNAL"
exit
script 2 wich is a cam follow script
_camera = "camera" camcreate [0,0,0]
titlecut [" ", "black in", 0.75]
#loop
_camera cameraeffect ["internal", "back"]
_camera camsettarget uh60
_camera camsetrelpos [2,10,1.5]
_camera camcommit 0
~0
? obj5 : goto "rest"
goto "loop"
#rest
_camera camsettarget uh60p
_camera camcommit 2
~2
titlecut [" ","BLACK OUT",0.75]
~0.75
_camera cameraeffect ["terminate", "back"]
camdestroy _camera
player switchcamera "internal"
titlecut [" ","BLACK in",0.75]
exit
if you can see any mistakes in either of these 2 scripts please can you either tell me or correct them