Home   Help Search Login Register  

Author Topic: Checking if unit in list has been injured?  (Read 5708 times)

0 Members and 1 Guest are viewing this topic.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Checking if unit in list has been injured?
« on: 06 Sep 2002, 23:10:31 »
LATEST QUESTION AT BOTTOM OF PAGE  ;)

after looking through a mission by BIS - they make editor music play by using (in scripts):

playmusic "res7"

or summit like that

now - i wanna do the same but make a voice sound...

the reason being is i have an atmospheric script that basically (well in the end) will check any1 who gets injured on side west and then makes that guy who gets injured say one of the MEDIC!!!! or HELP!!! etc.

now - i need to place that in a script and make a guy say it - so i have to know how to acces these voices using a snytax...

oh - and on the same subject - how can i make a trigger check for any1 on west side who is injured - and then on activation it will make that person exec a script - could be any1 in the list (another trigger that makes a list of all west)

cheers :thumbsup:
« Last Edit: 07 Sep 2002, 10:59:29 by Messiah »
Proud Member of the Volunteer Commando Battalion

Kaliyuga

  • Guest
Re:editor voices
« Reply #1 on: 06 Sep 2002, 23:34:21 »
Well if you want to play a sound through the playmusic command, why not either record, or find a suitable .wav file of the sound you want (probably could find something from a movie on-line I'd bet ;) ) convert to .ogg and play it like you would a song

I'm not at home at the moment otherwise I'd post what the description.ext would look like.. but I'm guessing you know how to do that already anyways... ;D

Not sure bout the other thing, but something along the lines of a countside in conjunction with a getdammage would be my best guess

:cheers: :toocool:
« Last Edit: 06 Sep 2002, 23:35:11 by Kaliyuga »

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:editor voices
« Reply #2 on: 06 Sep 2002, 23:40:45 »
no, no, no

i wanna use the ones already in the editor - and play them using a similiar method to that - im sure it must be possible.
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:editor voices
« Reply #3 on: 07 Sep 2002, 00:06:38 »
The editor sounds like the russian ones are:

player say "rus1"
player say "rus2"
....
player say "eng1"
player say "eng2"


And so on...

 8)PEACE

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:editor voices
« Reply #4 on: 07 Sep 2002, 01:02:48 »
so are the eng1 are west?

i need to select the medic ones - but this is cool - its possible.

 ;)
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:editor voices
« Reply #5 on: 07 Sep 2002, 01:11:51 »
Yes, the english ones are west. Go into the effects menu in the trigger and count down the list in the voices bit to find the sound you want.

 8)PEACE

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:editor voices
« Reply #6 on: 07 Sep 2002, 01:26:21 »
h0000t...

gamer, u are a freakin legend again my man :thumbsup:

now, the last thing (gurus please)

i have this script now, and basically (with the help of good old gamer) it creates a random thing for the guy to say.

now...

LATEST QUESTION HERE :thumbsup:

how do i make a trigger check a list of side west for ANYONE who gets injured and then in the onactivation take that guy and make him exec a script, along with another array variable?

thats all i need.... and its all done (i hope)

cheers.

(jeeeze Gamer - fancy teaming up on this one? youve done most the work so far  ;) )
« Last Edit: 07 Sep 2002, 11:01:22 by Messiah »
Proud Member of the Volunteer Commando Battalion

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:editor voices
« Reply #7 on: 07 Sep 2002, 04:38:37 »
You can also grab the voice name from the mission.sqm, if
you search for sensors and scroll down to that trigger.

You could run one-timer scripts for each soldier, waiting for
him to become injured.

~S~ CD
« Last Edit: 07 Sep 2002, 04:42:18 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:editor voices
« Reply #8 on: 07 Sep 2002, 10:38:24 »
hmmm i could, but for all of the 100 or so soldiers?

i know there must be a way to do this - does any1 know?
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #9 on: 07 Sep 2002, 11:46:46 »
Hmm...Tricky one. Try making another script and in it:

Code: [Select]
_unitarray= [sold1,sold2,sold3,sold4,sold5]

_tmp=1
#loop1
? (getdammage (_unitarray select _tmp)) > 0:[(_unitarray select _tmp)] exec "somescript.sqs"
_tmp = _tmp + 1
?_tmp>5:_tmp=0
~0.05
goto "loop1"

What you do is you add the name of each soldier into the array (Sorry, but you have to name them. Although you could pass everyone to a script with thislist....  ::)). So you put each soldier's name into the script. Then in this line:

?_tmp>5:_tmp=0

Make sure you change the five to the amoount of people in the script.

Now, i predict problems, so just ask...

Quote
jeeeze Gamer - fancy teaming up on this one? youve done most the work so far  ;)

Em...Joke or not? Not?  :-\

Cheers

Gameer

 8)PEACE

Bremmer

  • Guest
Re:Checking if unit in list has been injured?
« Reply #10 on: 07 Sep 2002, 12:58:17 »
That script looks like a good start Gameer, but once injured the unit will execute the script on every loop.

A slight modification to remove the unit from the array, and change the value that controls the looping would sort that out:


_unitarray= [sold1,sold2,sold3,sold4,sold5]

#start
_tmp=0
_count = count _unitarray
#loop1
_unit = _unitarray select _tmp
? getdammage _unit > 0:[_unit] exec "somescript.sqs"; _unitarray = _unitarray - _unit; goto "start"
_tmp = _tmp + 1
?_tmp > _count : _tmp=0
~0.05
goto "loop1"


Should work OK.

 :)

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #11 on: 07 Sep 2002, 13:19:12 »
Good point Bremmer. My Excuse: I was "tired"   ;D

But, a slight modification:

Code: [Select]
_unitarray= [sold1,sold2,sold3,sold4,sold5]

#start1
_tmp=0
_count = count _unitarray
#loop1
_unit = _unitarray select _tmp
? getdammage _unit > 0:[_unit] exec "somescript.sqs";_unitarray = unitarray - unit;goto "start1"
_tmp = _tmp + 1
?_tmp > _count : _tmp=0
~0.05
goto "loop1"

Before it was doing the whole "unknown operator" thing with the "_unitarray = _unitarray - _unit" bit.  :)

 8)PEACE

Bremmer

  • Guest
Re:Checking if unit in list has been injured?
« Reply #12 on: 07 Sep 2002, 13:28:35 »
Opps sorry!

My bad  :-[

_unit needs to be in array format before you can remove it from the array

ie. _unitarray = _unitarray - [_unit]

I was also thinking that its possible to get around the problem without removing the unit from that array. This means the unit will execute the script each time he is hurt (after being healed). I havent tried this yet, so it may be buggy:


_unitarray= [sold1,sold2,sold3,sold4,sold5]
_hurt = []
_count = count _unitarray

#start
_tmp=0

#loop1
_unit = _unitarray select _tmp
? _unit in _hurt : goto "check"
? getdammage _unit > 0:[_unit] exec "somescript.sqs"; _hurt = _hurt + [_unit]

#cycle
_tmp = _tmp + 1
?_tmp > _count : _tmp=0
~0.05
goto "loop1"

#check
? getdammage _unit == 0: _hurt = _hurt - [_unit]
goto "cycle"


[edit]Just tested it out - everything seems OK  :)[/edit]
« Last Edit: 07 Sep 2002, 13:59:35 by Bremmer »

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #13 on: 07 Sep 2002, 14:08:16 »
Nice idea, Bremmer!  :)

Now, where is Messiah  ::)

 8)PEACE


Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #14 on: 07 Sep 2002, 16:54:47 »
here.... scared... ummm... those scripts mean nuthing to me...

how do i execute them? remember its for the whole of side west under a list trigger.... so.... ummm... yeah, im cofused  :-\

Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #15 on: 07 Sep 2002, 17:58:55 »
The methods Bremmer and I are detailing need you to name each and every unit and add his name to the _unitname array.

Although I think you could make a trigger, and pass all the people on, then using the WEST command see if he is on the west side, if he is then add him to the array. Bremmer, any ideas as to how this could be executed?  :-\

 8)PEACE

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #16 on: 07 Sep 2002, 18:43:58 »
yes.... because i have something like 60 men on the battle field - not so good for arrays like that...
Proud Member of the Volunteer Commando Battalion

Bremmer

  • Guest
Re:Checking if unit in list has been injured?
« Reply #17 on: 07 Sep 2002, 19:44:38 »
The easiest method of getting your men into a list is using a west present trigger. Make its size big enough to cover all your men, leave the condition as this, and have on activation as [thislist] exec "injured.sqs".

In the script (injured.sqs) replace the line _unitarray= [sold1,sold2,sold3,sold4,sold5] with

_unitarray = _this select 0

everything else can be left exactly as written before, but you might want to add the lines

? (vehicle _unit != _unit) : goto "cycle"
? ("man" CountType [_unit] == 0) : goto "cycle"

directly after the line that selects the _unit (_unit = _unitarray select _tmp).
These check that the unit is actually a soldier on foot, and will stop your tanks crying out in pain when you shoot them  ;)

If your still having trouble I could make up a sample mission for you. Just let me know.

Good luck



Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #18 on: 07 Sep 2002, 20:56:36 »
So you only need to use a 'west present' trigger?  :-\

Ooh, did'nt realise it was that easy.  :)

Ah well...

 8)PEACE

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #19 on: 08 Sep 2002, 01:16:12 »
aaah, great stuff.... cheers.

:thumbsup:

p.s. i'll be back to solve it - dont worry - just gonna looksie a bit  ;)
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #20 on: 08 Sep 2002, 14:30:48 »
So is that you almost done with your mission the Messiah?  :)

 8)PEACE

SEAL84

  • Guest
Re:Checking if unit in list has been injured?
« Reply #21 on: 09 Sep 2002, 00:09:50 »
I have a question for you guys...

I took this script here because I figured I could really use this thing for a little project of mine.  Now, once this script runs though, what's the setup for the next one?

We've determined who's activating the script, how do you pass that info on to make that guy now do something?  (this is different from Mezzy's idea...I now want the injured guys to be assigned into a dustoff chopper.)

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #22 on: 09 Sep 2002, 00:23:51 »
? getdammage _unit > 0:[_unit] exec "somescript.sqs"; _hurt = _hurt + [_unit]


In the above bit of code taken from the script, change the [_unit] exec "somescript.sqs" to whatever you want. The injured unit is contained inside the _unit variable.

 8)PEACE

SEAL84

  • Guest
Re:Checking if unit in list has been injured?
« Reply #23 on: 09 Sep 2002, 00:30:22 »
Okay, I got that part...guess I worded it badly...

So if in the next script I want the injured guy to do something, I just need to call him _unit?

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Checking if unit in list has been injured?
« Reply #24 on: 09 Sep 2002, 01:26:45 »
You have to handle the guy in the next script, like
you would do, if you would exec the script out of the
game.

*hint: _this or _this select 0*

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #25 on: 09 Sep 2002, 11:25:10 »
Yeh, so basically, just put _unit= _this select 0 at the top, then use _unit.

 8)PEACE

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #26 on: 15 Sep 2002, 22:22:31 »
hmmmm

been working on the mission and just tried the script (been playing mafia)

well, this error pops up when some1 gets injured:

'_unit = _unitarray select _tmp |#|': Error Zero Divisor

any clues?
« Last Edit: 15 Sep 2002, 22:23:41 by Messiah »
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #27 on: 15 Sep 2002, 22:29:45 »
Lol, yet another oversight. When one of the units is injured, it is removed from the array so the number in the variable _count is less than the value of _tmp. Make sense?  :-\

Because Bremmer made the script, i don't know if this would work, but try doing this:

In the line that says this:

? getdammage _unit > 0:[_unit] exec "somescript.sqs"; _hurt = _hurt + [_unit]

Add this onto the end:

_tmp= _tmp - 1

So it should look like this:

? getdammage _unit > 0:[_unit] exec "somescript.sqs"; _hurt = _hurt + [_unit];_tmp= _tmp - 1

I dunno if this'll work. You may also need to do the same at the bottom with the:

? getdammage _unit == 0: _hurt = _hurt - [_unit]

 :-\

 8)PEACE

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #28 on: 15 Sep 2002, 22:53:47 »
ok - that solved that - but.... i feel like im playing 'spot all ofp errors' game  ;)

heres a new error line - god i wish i knew what the damn thing meant....

Randomnum = random (_this select 0) |#|: type object, expected number

now, i think this is from this script below, so its my mistake but what?

Code: [Select]
Randomnum = random (_this select 0)
_pain = _this select 1


? Randomnum <1 : goto "say1"
? Randomnum <2 : goto "say2"
? Randomnum <3 : goto "say3"
? Randomnum <4 : goto "say4"
? Randomnum <5 : goto "say5"
? Randomnum <6 : goto "say6"
? Randomnum <7 : goto "say7"
? Randomnum <8 : goto "say8"

#say1

_pain say "eng22"

goto "exit"

#say2

_pain say "eng23"

goto "exit"

#say3

_pain say "eng29"

goto "exit"

#say4

_pain say "eng30"

goto "exit"

#say5

_pain say "eng31"

goto "exit"

#say6

_pain say "eng32"

goto "exit"

#say7

_pain say "eng33"

goto "exit"

#say8

_pain say "eng34"

goto "exit"

#exit

exit

cheers - oh and gammer - the mission is a while off yet - its actually gonna be a mini campaign (3 missions)
Proud Member of the Volunteer Commando Battalion

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #29 on: 15 Sep 2002, 23:00:10 »
ok - ive spotted the mistake here

now, thats the script that the other script activates, and i think i know the rpoblem....

let me check  ;)


------------------------------------------------------------

ok, checked - now there is no error now BUT i dont hear the man who gets injured say the editor sounds...

ummmm

is it because they are not loud enuff or is it my fault again?
Proud Member of the Volunteer Commando Battalion

Bremmer

  • Guest
Re:Checking if unit in list has been injured?
« Reply #30 on: 15 Sep 2002, 23:56:12 »
Try activating it with [8,player] exec "script.sqs"
If you still can't hear anything then your script isn't working.

ps Messiah - In situations like this arrays are your friend. They can really cut down the amount of code you need. eg:



_num = _this select 0
_pain = _this select 1

_say = ["eng22","eng23","eng29","eng30","eng31","eng32","eng33","eng34"]

_rand = random _num
_rand = _rand - _rand % 1

_pain say (_say select _rand)

exit


@Gameer
I don't think the Error Zero Divisor problem lies with units being removed from the unitarray when they are hurt - The first script I wrote does this, but the second does not. Unit array SHOULD stay the same size at all times, but in practice I have encountered this error as well. I think it might arise when units get into or out of vehicles. The sure-fire way around this problem is to get rid of:

? _tmp > _count : _tmp = 0

and replace it with

? _tmp > count unitarray : _tmp = 0

There is another method that Rubble_Maker came up with that requires fewer uses of the count command (and is therefore marginally quicker) but this method is fine unless you are experiencing serious speed problems.

Cheers
« Last Edit: 15 Sep 2002, 23:58:47 by Bremmer »

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #31 on: 16 Sep 2002, 00:14:25 »
Can't argue with that  :)

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #32 on: 16 Sep 2002, 22:41:03 »
hmmmm....

ok - well - i checked my script and added a titletext in each of them 'say' parts - it works...

but no sound - umm - does any1 have a clue whats up?

i could get around this by using 8 triggers which say the sounds and teleport them to the guy and activate them - but thats a very long way around it.

any help is appreciated - again  ;)
Proud Member of the Volunteer Commando Battalion

Gameer_77

  • Guest
Re:Checking if unit in list has been injured?
« Reply #33 on: 17 Sep 2002, 00:16:36 »
Did it work before the array? Try just putting player say "eng1" orsomething and see if you can haer that. If so then theres a problem with using that array.

How are you calling the script?

 8)PEACE

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #34 on: 17 Sep 2002, 00:48:51 »
no, no, no...  ;)

havnt used the array... and it didnt work before then...

what i'll do is check if the player say 'eng#' works (like u just said...

if not, then i'll use my workaround.
Proud Member of the Volunteer Commando Battalion

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #35 on: 17 Sep 2002, 00:57:34 »
ok - say "eng32" works in a trigger...

Bremmer - when i removed that gamer said and added your line, the error zero divisor came back up on the same line..

this is what it looks like atm

Code: [Select]
;The easiest method of getting your men into a list is using a west present ;trigger. Make its size big enough to cover all your men, leave the condition as ;this, and have on activation as [thislist] exec "injured.sqs".

_unitarray = _this select 0
_hurt = []
_count = count _unitarray

#start
_tmp=0

#loop1
_unit = _unitarray select _tmp
? (vehicle _unit != _unit) : goto "cycle"
? ("man" CountType [_unit] == 0) : goto "cycle"
? _unit in _hurt : goto "check"
? getdammage _unit > 0:[_unit, 8] exec "randomscream.sqs"; _hurt = _hurt + [_unit]


#cycle
_tmp = _tmp + 1
? _tmp > count unitarray : _tmp = 0
~0.05
goto "loop1"

#check
? getdammage _unit == 0: _hurt = _hurt - [_unit]
goto "cycle"

gamer - my random scream script is activated by that script. _unit is the inuured unit (hopefully) and 8 is the random number generator thing.

this is my random scream script atm:

Code: [Select]
_pain = _this select 0
Randomnum = random (_this select 1)

? Randomnum <1 : goto "say1"
? Randomnum <2 : goto "say2"
? Randomnum <3 : goto "say3"
? Randomnum <4 : goto "say4"
? Randomnum <5 : goto "say5"
? Randomnum <6 : goto "say6"
? Randomnum <7 : goto "say7"
? Randomnum <8 : goto "say8"

#say1

_pain say "eng22"

goto "exit"

#say2

_pain say "eng23"

goto "exit"

#say3

_pain say "eng29"

goto "exit"

#say4

_pain say "eng30"

goto "exit"

#say5

_pain say "eng31"

goto "exit"

#say6

_pain say "eng32"

goto "exit"

#say7

_pain say "eng33"

goto "exit"

#say8

_pain say "eng34"

goto "exit"

#exit

exit

hope u can see the problem - on both accounts - cheers
Proud Member of the Volunteer Commando Battalion

Bremmer

  • Guest
Re:Checking if unit in list has been injured?
« Reply #36 on: 17 Sep 2002, 01:00:02 »


[attachment deleted by admin]
« Last Edit: 17 Sep 2002, 01:15:13 by Bremmer »

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Checking if unit in list has been injured?
« Reply #37 on: 17 Sep 2002, 01:25:02 »
aaaah  - that all works a treat now - shame that over the gun fire i cant hear the damn thing....

oh well - no way to sort that.

cheers lads :thumbsup:
Proud Member of the Volunteer Commando Battalion