OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: DarkAngel on 15 Jul 2003, 12:57:56
-
Hey guys,
I'm devising a mission where your chopper has been shot down and one of your men has been seriously injured. I've already got a loop in which his condition gradually worsens, what I want to do now is set it up so that he "speaks" (using SideChat) one of a number of pre-selected phrases each time his SetDammage is increased.
At the moment the routine looks like:
#complaintloop
; insert different phrases so it gets interesting.
_chatArray = ["SIR, I'M BLEEDING HERE","DAMN, THIS HURTS.","SIR, AM I GOING TO MAKE IT"]
_chat = random 3
_woundedguy sidechat _ChatArray select _chat
goto "loop"
("loop" being the main loop where his condition worsens)
Doesn't seem to work, though. Does anyone know why this is?
Thanks,
DarkAngel
-
random returns a number between 0 and the number specified.
I can't remember how array things are counted, does it start from 0 for the first one or 1, not sure.
In either case, you still have a problem. random 3 could return
0 (which won't work if the counting starts at 1)
1.29837 (dunno what happens there)
3 (which won't work if the counting starts at 0)
You need to discover what the counting system is. You probably also need to convert your random number to a whole number. There is a handy little item in the FAQ which explains how to do this.
-
Try this :
_chatArray = ["SIR, I'M BLEEDING HERE","d**n, THIS HURTS.","SIR, AM I GOING TO MAKE IT"]
_rand=random ((count _chatArray)-1)+0.5
_rand=_rand - (_rand % 1)
_woundedguy sidechat (_chatArray select _rand)