Home   Help Search Login Register  

Author Topic: Triggers and addAction, or Nearest trigger  (Read 1148 times)

0 Members and 1 Guest are viewing this topic.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Triggers and addAction, or Nearest trigger
« on: 16 Feb 2005, 20:54:39 »
I have a problem that I can think of two possible solutions for, but I can't seem to get them to work, in fact I am beginning to wonder if what I want is technically possible.  My two solutions are:

1: Add an Action to a trigger and in the script that is run by the action use _this select 0 to get the name of the trigger  (I really want its location and I want then to delete it) eg:
getPos _this select 0
deleteVehicle _this select 0

I can't even get an action added to the trigger!!

2. Add an Action to an object (at least I can manage that!).  In the script the action runs I can get the location of the object.  What I also want to do is to get the name of a trigger that is located at the same x,y coordinates as the object.  The intent here again is to delete the trigger.

Hah - the power of writing down your problems to help find a solution!  As I was writing this I realised that as I know the names of all the triggers in 2 I can simply loop through them checking their location until I find a match.  It is inelegant - but better than my current solution!  Any more elegant solutions, particularly any way to do 1. would be gratefully received.
« Last Edit: 18 Feb 2005, 00:19:14 by THobson »

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Triggers and addAction, or Nearest trigger
« Reply #1 on: 16 Feb 2005, 22:00:34 »
no ideas to offer, but i can identify with thinking up a solution as (or just after) you post ... :P

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Triggers and addAction, or Nearest trigger
« Reply #2 on: 17 Feb 2005, 02:35:30 »
Ditto.

I would be surprised if it was possible to add an action to a trigger.     It's just not how OFP works.

To improve 2., associate the objects and triggers at the start.   That way you don't need to cycle through them when you want to delete the trigger, you just know.

One of the problems of abhorring inelegance (generally an admirable quality) is that sometimes - particularly in OFP - it makes it harder to get to the best solution.     Good OFP code is not always elegant, even at its best.

In addition, there is a subtlety to discovering elegance which is not appreciated by many scripters.     If it takes more work to discover the elegant solution than the inelegant solution involves in the first place, then the apparently elegant solution is in fact inelegant.
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Triggers and addAction, or Nearest trigger
« Reply #3 on: 17 Feb 2005, 08:37:27 »
Quote
I would be surprised if it was possible to add an action to a trigger.    It's just not how OFP works.
I don't yet have that sort of feel for the game.  Triggers can be moved, deleted, targetted by a camera, distances can be measured from them, but they can't be created and seemingly they can't have actions added to them.  I will keep looking, there must be a pattern.

Quote
To improve 2., associate the objects and triggers at the start.
I started here, but to reduce the number of objects and names I changed it so the objects are only created when I need them, and they are created without names.  Anway what I have now works and instead of needing one script to deactivate each mine I only need one for all of them.

Quote
If it takes more work to discover the elegant solution than the inelegant solution involves in the first place, then the apparently elegant solution is in fact inelegant.
We could debate this for a long time.  Let me just put an alternative view:  an elegant solution is likely to be simple and so easy to understand easy to de-bug; finding an elegant solution could give insights that would make future elegance easier.  Is minimising mission builder time really the objective?  For me part of the fun is doing it neatly.  I bet Leonardo (d V not d C) and the unfortunately misnamed Luwig might also have different views. :)
« Last Edit: 17 Feb 2005, 08:54:09 by THobson »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Triggers and addAction, or Nearest trigger
« Reply #4 on: 17 Feb 2005, 22:28:21 »
exactly why do you want to delete a trigger in the first place?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Triggers and addAction, or Nearest trigger
« Reply #5 on: 17 Feb 2005, 22:53:33 »
Because it camcreates an explosion representing either an AP or AV mine.  I want to delete it when either the mine is disabled or is detonated.  Deleting the trigger is no problem.  Finding the correct trigger to delete when disabling the mine was what I was having problems with.

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:Triggers and addAction, or Nearest trigger
« Reply #6 on: 17 Feb 2005, 23:41:19 »
Having an idea what you're trying to do . . .

The triggers must be Anybody Present as you need to catch both East and West. So, why not have activation of the trigger call a script which would then:

If its a vehicle - boom - no questions!

If it's E or W on foot and AP - boom!

If it's the player on foot and not running - disable the mine and maybe generate action/script to recover it and put the trigger back to its holding area (also acts as a little reminder of whwere you're treading)

It would be nice if the 'this' returned by the activated trigger included the trigger name, but as you're predefining the triggers you can pass the names to the script.  Might be worth clarifying that I'm thinking of a single mine activation script which would be sent the parameters of say, triggername and type (AP/AV).

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Triggers and addAction, or Nearest trigger
« Reply #7 on: 18 Feb 2005, 00:16:08 »
What I have is the player decides when placing a mine whether it is an ap mine (grenade anybody present; this and "land" counttype thislist > 0 ) or an av mine (bigger explosion anybody present; this and "landVehicle" counttype thislist > 0 )

Having placed the mine if the player get too close, or lets any of his squad get too close, or if civilians get too close, then - well a mine is a mine - it doesn't know who or what set it off.

When the mine is placed a mine casing is camcreated and a disable action is added to it.  I wanted to add the action to the trigger which would have been really neat, but I can't.  When the player initiates the disable action the script needs to find the correct trigger to delete (no the player does not get another chance to place this mine).  Because I know the names of all the triggers the script can cycle through them checking their location to see if it matches the location of the mine case.  It works.  If I could have added the action to the trigger itself then I would not need to cycle through all the triggers to find the correct one.

When I started this thread I needed a script to disable each mine, I now have one script that can be used to disable all mines.  A reduction of 29 scripts!  Not a bad result.

Quote
It would be nice if the 'this' returned by the activated trigger included the trigger name
This sumarises my problem perfectly.
« Last Edit: 18 Feb 2005, 00:38:27 by THobson »

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Triggers and addAction, or Nearest trigger
« Reply #8 on: 18 Feb 2005, 22:17:51 »
I've used this idea for various other things as well:

one big trigger, anybody present
use that to get a list of everyone

then, when a mine is placed run 1 of 2 scripts(ap or av)

each will have basically the same function:
1)camcreate a gl
2)give it an action that will just delete the gl/end the script (have an alive check in the script that will check - or isnull)
3)check the trigger list for the appropriate types of units within the appropriate distance of the gl
4)KABOOM/delete gl

that way, the gl gets deleted whenever a mine is disabled/exploded
problem solved?
« Last Edit: 18 Feb 2005, 22:19:09 by Triggerhappy »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Triggers and addAction, or Nearest trigger
« Reply #9 on: 18 Feb 2005, 22:38:09 »
I hadn't thought of that.  So Instead of using a trigger to detonate each mine you have a gl with a script running checking distances from the gl, and as you can add an action to a gl, bit not to a trigger...  Neat.  

I have it working now by adding an action to the mine case.  But yours is an interesting idea.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Triggers and addAction, or Nearest trigger
« Reply #10 on: 19 Feb 2005, 05:15:42 »
all it really is is a simulated trigger. it can be quite effective in some cases

i didn't know you were using a mine case. its basically the same though