Home   Help Search Login Register  

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

0 Members and 1 Guest are viewing this topic.

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