OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: rOk on 12 Aug 2004, 09:31:46
-
Hi all
Another editing question I'm afraid. Here goes
I have 4 west loons in captive state. It's enough if you only save 1. Now what I want is that a variable becomes true if anyone (or all or anything in between) of them enters a specific trigger area.
They're each in their own group.
I know the variable part, I just don't know the syntax for the condition/s mentioned above.
Thanks
-
Three solutions comes to mind:
(The four units are named u0, u1, u2, u3)
1) Make a trigger with West Present, in the Condition field write:
this && ("_x in thislist" count [u0,u1,u2,u3]) > 0
2) Make four triggers, West Present, then group each one with one of the units. (non-scripted approach)
3) Make a trigger, 0 radius, (or have it spinning in a script (with @<condition>)), in the condition field write:
"_x distance safe_obj < 50" count [u0,u1,u2,u3] > 0
Where safe_obj is an object in the center of what you feel is safe-ground.
None of the syntax is guaranteed.
-
Thanks Mud_Spike
The first one works like a charm, had 4 triggers already but I'm trying to cut down on the numbers of them.
Now there's another problem
When the loon comes there variable turns to true, however in another trigger which has the condition this variable = true and someone not alive and end #1 there is no end.
Any thoughts?
Thanks
-
And it goes like this?
Condition:
variable == true && not alive unitX
Then it should work, if not, try to separate it further, have another trigger just checking 'not alive unitX', hint "":ing, setting a variable, and then use that variable in your trigger.. 'var==true&&isdead==true'.
If that works and the above doesnt, something is fishy.
-
Nope, no joy.
All of it has a problem with "==" it says "type any; expected number, string, object...
Separating them into 2 different + the ending trigger doesn't work also.
-
myVariable = true - assigns to the variable the value true
myVariable - what you put in a condition line if you want the trigger to fire when the variable is true
myVariable and (not alive loon1) - see above
myVariable == true - not used in OFP
-
Argh...
I feel so stupid. I should have known this. Anyway works great.
Thanks both of you
Just one quickie left:
This isn't MP ready right?
Where do I need to declare this a public variable?
-
Oops, sorry about that.
-
Hey rOk!
I am not a MP scripter, but I have seen publicVariable's declared in the init.sqs of some MP mission that I have unPBOed. Hope this helps!
Wadmann
-
I've heard its best to define every variable in the init.sqs, like
manv = false
captive = false
dude = true
You know, set the starting postion for the variable, true or false...
-
It is not always necessary to initialise every variable in init.sqs or elsewhere. The important thing is to realise that when the game meets an initialised (or undefined) variable it treats the whole expression (not just the variable) as false.
PublicVariable is for when you want the value of a variable to be sent to all computers in MP. You can use publicvariable whenever you like, it doesn't have to be in init.sqs.
-
Now now, let's not get too complicated.
If you want to know if ANYONE from a group is in a trigger radius, you GROUP the trigger to the group leader and after that select ANYONE from the trigger's activation options.
Trigger actions are run on all clients (if not told otherwise) so you don't have to worry about publicvariable. Everyone will know the mission is over if a trigger launches it.
So the whole thing would go:
/me reads the first post again
eh.. erm..
Ok, so I missed the part where you say they're all in their own groups. Scrap the rest but note the publicvariable thing. ;D
-
So basically what you're saying is, that if a variable status gets changed in the trigger there's no need to declare it as a PublicVariable? ???
@macguba or anyone who knows:
The important thing is to realise that when the game meets an initialised (or undefined) variable it treats the whole expression (not just the variable) as false.
But what if it's as simple as GuiltyRoachKillar said?
ie:
Dude=false
From what I understand this is the whole expression and if it is, what would change then?
Hope I'm making some sense here.
Thanks all
-
dude=false
does indeed define (or initialise) the variable "dude".
The point is that if dude has not been initialised the following expressions all return false:-
dude
not dude
dude or (not dude) or true
-
Trigger actions are run on all clients (if not told otherwise) so you don't have to worry about publicvariable. Everyone will know the mission is over if a trigger launches it.
Is the trigger Action or the trigger itself (i.e., Condition which then maybe fires the Action) being executed on all clients?
I think I read somewhere a long time ago that triggers are only triggered on the server, in that case, the client would have to use publicVariable for the trigger to fire, and everyone is brought up to date automagically.
-
Yes I ment the 'on activation' field specifically. If a condition becomes true on a client the activation is not launched. The condition must be true on server. :)