Home   Help Search Login Register  

Author Topic: donut-shape trigger. anyone knows how?  (Read 1094 times)

0 Members and 2 Guests are viewing this topic.

scorpi0x

  • Guest
donut-shape trigger. anyone knows how?
« on: 03 Mar 2005, 10:52:18 »


i need to do this trigger in the picture i sketched
whereby it adds an action for the player when player is inside the grey zone. and remove the action when at the white area.

i know about addAction ["newAction", "newAction.sqs"] and removeAction here. but apparently i cannot do it by just overlapping a small circle (to remove action) over a big circle (to add action)

not sure the difficulty of this but i'll just ask in here anyway  ::)

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:donut-shape trigger. anyone knows how?
« Reply #1 on: 03 Mar 2005, 11:01:36 »
the problem (i think) with just overlapping the triggers is that when you're inside the wee one, you're still inside the big one too.

what you want to do is create a global variable - let's call it mmmdonuts - and set it to true in the 'on activation' field of the larger trigger, false in the wee one. then in the condition fields of each, check which value mmmdonuts has before performing any add/remove action.

that should do it.

mmmmmmmmdonuts....

scorpi0x

  • Guest
Re:donut-shape trigger. anyone knows how?
« Reply #2 on: 03 Mar 2005, 11:36:56 »
sorry guess i am just too new...
if i can't perform the add/remove action in the 'on activation' field, where do i perform the add/remove action then?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:donut-shape trigger. anyone knows how?
« Reply #3 on: 03 Mar 2005, 11:39:28 »
Try:

Inner trigger:
Repeating
on activation: Inner = true; remove the action
on deactivation Inner = false

Outer Tigger:
Repeating
condition: this and not Inner
on activiation: add the action
on deactivation: remove the action

Note you must set Inner = false at the start of the mission, either in init.sqs or in a trigger with condition set to true

I have not tested it but the above should ensure the action is onthe loon when he is in the grey area but not if he is in the inner trigger or outside the outer trigger

EDIT:
Thinking about it bedges is the same as your method?  I didn't think so when I started writing.
« Last Edit: 03 Mar 2005, 11:58:44 by THobson »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:donut-shape trigger. anyone knows how?
« Reply #4 on: 03 Mar 2005, 11:50:34 »
m'kay, just tested and this works. set up your mmmmdonut like this -

large trigger:
repeated
condition: this and mmmdonut
on activation: mmmdonut = true; your addaction code
on deactivation: mmmdonut = false;  your removeaction code

smaller trigger:
repeated
on activation: mmmdonut = false; your removeaction code
on deactivation: mmmdonut = true

you may want to stick a couple of hints in after the add/removeaction codes to see (and hear) it working. just separate them from the rest of the code by using another semicolon ( ; )

EDIT - heheheh, touché monsieur T'obson
« Last Edit: 03 Mar 2005, 12:06:51 by bedges »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:donut-shape trigger. anyone knows how?
« Reply #5 on: 03 Mar 2005, 12:00:30 »
Great minds. Bye the way: How does mmmdonut get set to be true without first visiting the inner trigger?

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:donut-shape trigger. anyone knows how?
« Reply #6 on: 03 Mar 2005, 12:03:54 »
by reading your post and putting it in the init file, of course  ::)

errr... no, hang on :hmm:
« Last Edit: 03 Mar 2005, 12:06:09 by bedges »

scorpi0x

  • Guest
Re:donut-shape trigger. anyone knows how?
« Reply #7 on: 03 Mar 2005, 12:39:15 »
alright i finally figure it out.
thank you all  ;D
a small error i corrected for all others info. ;)

large trigger:
repeated
condition: this and mmmdonut
on activation: your addaction code
on deactivation: your removeaction code

smaller trigger:
repeated
on activation: mmmdonut = false; your removeaction code
on deactivation: mmmdonut = true

forgot to mention i set mmmdonut to true in init.sqs
and made it a publicvariable.
:)
« Last Edit: 03 Mar 2005, 16:22:41 by scorpi0x »

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:donut-shape trigger. anyone knows how?
« Reply #8 on: 03 Mar 2005, 21:00:28 »
Or instead of all that trigger business you could do a .sqs file. Example:

Code: [Select]
_pos = getpos donut

#reset
@((player distance _pos > 30)&&(player distance _pos < 40))
donut = player addaction ["Eat the donut!","donut.sqs"]
@((player distance _pos < 30)or(player distance _pos > 40))
player removeaction donut
hint"Dang! I lost my donut!"
goto"reset"

All you have to do is put a gamelogic where ever and name it donut, or you could do _this select 0 for mulitple donuts.
I like your approach, lets see your departure.
Download the New Flashlight Script!

scorpi0x

  • Guest
Re:donut-shape trigger. anyone knows how?
« Reply #9 on: 04 Mar 2005, 04:17:00 »
kinda like ur idea and i tried ur method rujik
but i got this error at start. :(
'((player distance _pos > |#|30)&&(player distance _pos < 40))': Error distance: Type Array, expected Object

guess i'll stick to the triggers for now :)

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:donut-shape trigger. anyone knows how?
« Reply #10 on: 04 Mar 2005, 04:23:05 »
yep, it's because _pos is the position, not an object, which is what distance is looking for to compare.

the script is a fair concept in principle, but i'm not really convinced of the efficacy of using a looping script when two simple triggers will do the same job. especially a script with no pause in it.

that said, i'm no expert. ask the general, he'll be able to tell you on the scripting side of things.

nitenite  :)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:donut-shape trigger. anyone knows how?
« Reply #11 on: 04 Mar 2005, 08:18:49 »
It is a case of 'horses for courses'

Triggers are easy to implement, but consume CPU (the condition is checked many times a second).  Slow(ish) looping scripts can reduce CPU load, but generally do take more thinking about.  They are also intrinsically slower as they are not compiled in the way the code for a trigger is, so I try for a loop of several seconds where I can.

So if it is a small mission triggers are fine.  For a large mission I use looping scripts when I can unless the action is time or spatially critical, and even then I find I can avoid a lot of instances where I used to use triggers by using Event Handlers instead.
« Last Edit: 04 Mar 2005, 08:42:24 by THobson »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:donut-shape trigger. anyone knows how?
« Reply #12 on: 04 Mar 2005, 09:58:45 »
that's an interesting point. i had read (in a trigger tutorial i believe) about the number of times per second triggers are polled, compared to the @ command, or looping scripts. the figures being discussed were fractions of seconds and i didn't give it much thought - couldn't be that important could it...

but then, create a mission full of conditional triggers and a whole heap o' loons with waypoints and the lag soon builds up.

bedges looks at his previous mission with a more critical eye...
the mission squeaks nervously in alarm.

heheh, cheers sir, that's something i'm going to take a look at.  :)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:donut-shape trigger. anyone knows how?
« Reply #13 on: 04 Mar 2005, 11:10:56 »
There is a limit to how much you can go back and rework.  I have missions that play quite well that had a squads of loons parachuting from choppers, and each loon had their own trigger!!  I am embarassed to think about it now.  My previous mission I think is quite good - but even there I was detecting the death of individuals using triggers instead of event handlers.  Building a large mission, which as you know I am now doing, really forced me to think about what I was doing, how I was doing it and why, and then when I had an answer to all that, then think: is there a better way?

I know if I so much as look at one of my old missions I will end up re-making it.  "And a good thing too" I hear some of you say!
« Last Edit: 04 Mar 2005, 11:12:58 by THobson »