Home   Help Search Login Register  

Author Topic: a small script  (Read 1547 times)

0 Members and 1 Guest are viewing this topic.

Offline 456820

  • Contributing Member
  • **
a small script
« 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

Code: [Select]
#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

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:a small script
« Reply #1 on: 09 Jun 2005, 18:23:36 »
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 -

Code: [Select]
#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
« Last Edit: 09 Jun 2005, 18:27:09 by bedges »

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #2 on: 09 Jun 2005, 18:24:35 »
so if i changed it to just dammage it should work ? or is it still missing something

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #3 on: 09 Jun 2005, 18:29:19 »
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 ?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:a small script
« Reply #4 on: 09 Jun 2005, 18:42:22 »
check the comref ;)

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:a small script
« Reply #5 on: 09 Jun 2005, 18:52:31 »
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?

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #6 on: 09 Jun 2005, 19:02:32 »
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

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #7 on: 10 Jun 2005, 16:39:13 »
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 ?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:a small script
« Reply #8 on: 10 Jun 2005, 18:31:53 »
pardon? you speaky the english? :P

i think the line you want is

Code: [Select]
? (getdamage mi24a > 0.85) : mi24a setfuel 0
apologies for not spotting that earlier ;)

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #9 on: 10 Jun 2005, 18:49:00 »
Quote
pardon? you speaky the english?
yep first language just type to fast to keep the words making sense.  ;D

Quote
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

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:a small script
« Reply #10 on: 10 Jun 2005, 20:08:26 »
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
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #11 on: 12 Jun 2005, 16:17:59 »
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

Code: [Select]
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 ?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:a small script
« Reply #12 on: 12 Jun 2005, 16:38:12 »
height is contained in the positional array as select 2. so if you want to check the height of something, do it thus:

Code: [Select]
_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

Code: [Select]
obj setpos [x,y,z]


Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #13 on: 12 Jun 2005, 16:41:13 »
Code: [Select]
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

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:a small script
« Reply #14 on: 12 Jun 2005, 16:44:57 »
Code: [Select]
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

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #15 on: 12 Jun 2005, 17:18:24 »
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

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:a small script
« Reply #16 on: 12 Jun 2005, 17:32:42 »
Code: [Select]
_preheight = getpos uh60 select 2
uh60p setpos [getpos set1 select 0, getpos set1 select 1, _preheight]

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #17 on: 12 Jun 2005, 17:40:55 »
wouldnt that run in with

Code: [Select]
_height = getpos uh60 select 2
becuase its both select 2
i tried this anyway

Code: [Select]
#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

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:a small script
« Reply #18 on: 12 Jun 2005, 17:57:11 »
at the moment, the script stays in #check anyways...

i'm not sure what it is you want this script to do.

Quote
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.

Code: [Select]
#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...

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #19 on: 12 Jun 2005, 18:00:41 »
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

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #20 on: 12 Jun 2005, 18:05:31 »
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

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:a small script
« Reply #21 on: 12 Jun 2005, 18:18:08 »
call him 'uh60d' - pilots are drivers ;)

Offline 456820

  • Contributing Member
  • **
Re:a small script
« Reply #22 on: 12 Jun 2005, 19:06:13 »
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

Code: [Select]
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

Code: [Select]
_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