Home   Help Search Login Register  

Author Topic: Trigger Problem (Boolean Operators!)  (Read 651 times)

0 Members and 1 Guest are viewing this topic.

Aneurysm

  • Guest
Trigger Problem (Boolean Operators!)
« on: 16 Jan 2003, 15:42:41 »
Ok, I'll need to explain to you what it is I'm trying to do in my mission:

~~One of the objectives is to steal some vehicles from the enemy. There is a max. of four vehicles for you to steal. You don't have to steal ALL four for the objective to be completed, but you must steal AT LEAST one.

~~The vehicles are called v1, v2, v3 and v4. At the mission exit point I've set up four triggers, one for each vehicle, I've linked each of the triggers to each of the vehicles using the group function.
Now each trigger is set up so when 'v1' (for example) is present, 'vp1=true' Same again for v2, 'vp2=true' etc

~~I've set up another trigger with the condition "vp1 OR vp2 OR vp3 OR vp4" and this activates "2" objStatus "DONE". So in theory when either v1 or v2 or v3 or v4 enter the trigger areas obj 2 will be completed. But it doesn't work!

Strangely enough, if I replace 'OR' with 'AND' then it can function, providing of course all the vehicles are in the trigger area. But I don't want that! It would be unrealistic to fail your mission simply because you 'only' stole 3 vehicles! I need my 'OR' gate to work!

Anyone know what I've done wrong? Or can anyone think of a better way of achieving the same thing in a different way?

Thanks very much.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Trigger Problem (Boolean Operators!)
« Reply #1 on: 16 Jan 2003, 18:41:30 »
Why don't you set only one boolean to true, instead of
using 4 of them?

I mean:

v1 in area = vp1=true
v2 in area = vp1=true
etc.

And in your last trigger you would only have to check for
vp1 then.

Or do it other way:

Make only one trigger for the vehicles to be taken to.

Activation: anybody/present
condition:
v1 in this list OR v2 in thislist OR v3 in thislist OR v4 in thislist

onActivation: vp1=true

OK, this is all not the right answer to your question, but a way
around. I'm not sure, if you can link booleans with the OR
statement (haven't tested it yet, or not needed it).

~S~ CD
« Last Edit: 16 Jan 2003, 18:44:56 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 Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:Trigger Problem (Boolean Operators!)
« Reply #2 on: 16 Jan 2003, 19:07:51 »
OFP uses a three-valued logic: True, False and Contingent (Undefined).
Any condition involving a contingent boolean will result FALSE
so in the case:
(!Seabattletomorrow || Seabattletomorrow)
if Seabattletomorrow is neither TRUE nor FALSE, OFP will always give the result of FALSE
This holds for combinations too, so:
(!Seabattletomorrow || Seabattletomorrow) || TRUE
will also be FALSE

To avoid this, initialize your variables to FALSE at the start of the mission.

Dinger/Cfit

Offline Ranger

  • Members
  • *
  • Hoo-ah!
Re:Trigger Problem (Boolean Operators!)
« Reply #3 on: 16 Jan 2003, 19:23:56 »
Strangely enough, if I replace 'OR' with 'AND' then it can function, providing of course all the vehicles are in the trigger area. But I don't want that! It would be unrealistic to fail your mission simply because you 'only' stole 3 vehicles! I need my 'OR' gate to work!

Anyone know what I've done wrong? Or can anyone think of a better way of achieving the same thing in a different way?

To answer your question directly, the problem with "or" condition is that you have to define a starting value for the boolean variables, otherwise the "or" condition won't work.

To do so, in your init.sqs script, set all of their values to false.

vp1 = false
vp2 = false
vp3 = false
vp4 = false

This should work.
Ranger

Aneurysm

  • Guest
Re:Trigger Problem (Boolean Operators!)
« Reply #4 on: 16 Jan 2003, 21:50:28 »
Ok, thanks guys!

I got it working by adding another trigger with...

vp1 = false
vp2 = false
vp3 = false
vp4 = false

...as Ranger said.

I might try some of the other things you guys mentioned, as they seem easier than the long winded way I've done it, but i'm not that much of an expert with the editor. I''l see anyway.

Thanks for the help!

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Trigger Problem (Boolean Operators!)
« Reply #5 on: 17 Jan 2003, 03:44:35 »
Hmm...

Good to hear you got it sorted, Aneurysm

I'm not sure if you want my input or not, so if you feel this is out of place, or you don't need anymore help please feel free to completely ignore me ;D

Instead of having several triggers, why not have just one:

Trigger

Radius: Covering exit area
Condition: Anybody Present
Condition field: "_x in thislist" count [v1,v2,v3,v4] > 0
OnActivation field: "2" objstatus "done"

That one trigger will go off if any of your four vehicles (v1-v4) enters it's radius.
What it's doing is checking the array of units within the trigger (thislist) and checking if any of them are in the count array ([ v1,v2,v3,v4 ]). If so, the trigger activates, and objective "2" is met.

Like I said, if you prefer your way, then please ignore my ramblings ;)