Home   Help Search Login Register  

Author Topic: a small script  (Read 1548 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