Home   Help Search Login Register  

Author Topic: PASSING TO A SCRIPT  (Read 2026 times)

0 Members and 1 Guest are viewing this topic.

mikeb

  • Guest
PASSING TO A SCRIPT
« on: 27 Aug 2002, 17:18:57 »
Hey all,

I have a trigger that activates when my player is detected by the other side.  When that happens I want to be able to pass a parameter to a script that activates on the trigger.

What I want is that the name of the AI unit that discovered the player (and hence set of the trigger) to be passed to the script.

I've tried using [this] exec... in the trigger but it doesn't seem to work in passing the "activator's" name..


Any idea what to do?

Bremmer

  • Guest
Re:PASSING TO A SCRIPT
« Reply #1 on: 27 Aug 2002, 17:58:21 »
I'm guessing the trigger is a 'spotted by east' or 'spotted by west' type?

If it is then try

[thislist select 0] exec "script.sqs"

thislist is a list of all units in the trigger that meet the triggers conditions (ie that have spotted you), and select 0  selects the first unit that meets that condition.

Check it out - should work OK

 :)

Demoniac

  • Guest
Re:PASSING TO A SCRIPT
« Reply #2 on: 27 Aug 2002, 22:58:49 »
You could also try "[_x] exec "script.sqs"" ForEach Units ThisList when you want to put the script to more than one unit...

mikeb

  • Guest
Re:PASSING TO A SCRIPT
« Reply #3 on: 28 Aug 2002, 14:18:58 »
So with "[thislist select 0]...", if I set the trigger to activate repeatedly, would that work each time someone spots me?  More importantly would it work seperately for a new person who spots me a few seconds after someone else already has (or would that new unit fall under select 1).

In my mission, I can avoid the spotters raising the general alarm if I kill them quickly enough - then everything turns back to normal and I remain undiscovered.  If I do this , does the trigger reset so that if another unit triggers it later on, the trigger would recognise him as "thislist select 0" or would the "detected by" trigger always be on from them on.

I don't think I'm making the greatest of sense.  Need to get my computer working again (so many problems!) before I can actually check it myself.

Cheers for the help.

M

Bremmer

  • Guest
Re:PASSING TO A SCRIPT
« Reply #4 on: 28 Aug 2002, 14:49:00 »
I think I follow what you are saying.

Here's my guess - I would need to do some checking to confirm this, but I think it's right :-

A repeating trigger does not go off every time the condition is true. The condition must first become false, resetting the trigger, before it can be set off again. This bit I'm sure of.

What does this mean for your example. Well for a start thislist for the trigger should in theory only contain one unit - the one that first spotted you. The reason I used thislist select 0 was because I'm not sure what happens if you are spotted by a group. The next implication is that all units in thislist must no longer know about you before the trigger is reset. If this is achieved then the trigger can go off again and thislist select 0 will be the new unit that has spotted you.

In practice what this means is that if you eliminate the unit that spots you then the trigger should be reset, but if the unit is not killed then the trigger will not go off again.

I think I'll give this a try when I get home from work.

Cheers

mikeb

  • Guest
Re:PASSING TO A SCRIPT
« Reply #5 on: 28 Aug 2002, 14:59:50 »
That makes a lot of sense.  My computer is minutes away from being fixed so I'll give it a go!!!

Thanks again for all your help.  God I love this forum!

M

Offline KTottE

  • Former Staff
  • ****
Re:PASSING TO A SCRIPT
« Reply #6 on: 28 Aug 2002, 15:03:29 »
You could also do something like an awareness system.
e1 spots you, but you run away out of his sight. He can't see you anymore. He will do something that you want him to (Call for support, investigate on his own, blahblah).
But let's say that you manage to stay out of his sight for more than 2 minutes, then the script is cancelled and e1 returns to his post.
Or if you manage to get more than 500 meters away from him, then the script cancels as well.
That would make for a cool mission, don't you think =)
"Life is not a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming 'WOW What a Ride!'"

mikeb

  • Guest
Re:PASSING TO A SCRIPT
« Reply #7 on: 28 Aug 2002, 16:03:24 »
Damn!!

The trigger doesn't seem to reset when I kill the guy that spotted me.  Any way to make sure this happens?

mikeb

  • Guest
Re:PASSING TO A SCRIPT
« Reply #8 on: 28 Aug 2002, 16:11:32 »
I think my problem may have something to do with the deactivation box.  Does anyone know how this works?  And what about how it works for triggers activated on detection by east?

Gameer_77

  • Guest
Re:PASSING TO A SCRIPT
« Reply #9 on: 28 Aug 2002, 22:10:45 »
Try making an exact replica of the trigger and place it almost directly over the other one. then in the condition field add "not" to it. So it should say "not this".

I think thats what your wanting.  :-\

 8)PEACE

Bremmer

  • Guest
Re:PASSING TO A SCRIPT
« Reply #10 on: 28 Aug 2002, 22:50:52 »
After much fiddling I have found that I have told you a complete and utter lie mikeb  :-[

[thislist select 0] exec "script.sqs"

does not give the discovering unit, but rather the discovered unit. To make matters worse I don't know how to get the discovering unit using a trigger, and the only way I can think to get around the problem is some reasonably complex scripting.

I can't apologise enough. If you want I'll happily script a routine to carry out what you want to do (if you explain in detail), but I'll understand if you don't want to touch my 'advise' with a 10 foot barge pole.

Sorry  :-\

mikeb

  • Guest
Re:PASSING TO A SCRIPT
« Reply #11 on: 29 Aug 2002, 02:29:06 »
Thanks for the help anyway.  You were at work and still managed to at least attempt to help me.  For that I give you credit and apologies are unecessary.

I have constructed a complex script to do with the knows about command.  Actually it's not so complex as it is repetetive.  What it does is that if the enemy discovers me (and with a weapon) then the enemy will fire at me.  I have about 5 seconds until he gives the general alarm.  If after those 5 seconds he is still knows of my presence and that I'm bearing a weapon (or anybody else knows for that matter), then the general alarm is raised and I'm forever "setcaptive false".

It's a little messy at the moment and requires naming and (entering into the trigger) every possible enemy on screen.  So far it seems to work but I'm testing it at the moment.

It's just a shame that trigger doesn't work how I want it to.  It's also a shame you can't seem to enter an array of sorts for the knowsabout command.  Oh well.  I'm sure I'll have a flash of genius soon!

Offline WhisperOFP

  • Members
  • *
  • I'm a llama!
Re:PASSING TO A SCRIPT
« Reply #12 on: 09 Sep 2002, 16:06:11 »
Well, getting the list of discovering units is tough.

In your first trigger, in the activation field, put playerDetected=true.
In the deactivation field, put playerDetected=false (hope this one works, not sure).
U need to make a second trigger, trigerred by the detecting guys side, repeatedely, and in the condition field, put :
this && playerDetected.

Then I'm afraid u need to make a script to create a list of the detecting units :
create in your mission folder a listDetectors.sqs , edit it w/ notepad, put in it :
Code: [Select]
_nbUnits=count _this

_i=0

#Loop1
_u=_this select _i
?((_u knowsAbout player) >= 3):goto "onDetection"
#Back1

_i = _i + 1
?(_i < _nbUnits):goto "Loop1"

exit

#onDetection
;put here the actions taken when detected
_u globalChat "I know where you are!"

goto "Back1"

I can't think of easier solution :(

Whis'

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:PASSING TO A SCRIPT
« Reply #13 on: 10 Sep 2002, 08:20:02 »
In a couple of days when I get back from holiday, I'll have access to all my source code...

Then if this thread is still around I'll post up the detection routine I use...

It involves two (I think) triggers and a script... and cycles through each enemy unit in a 300m radius (you may need to change that... I use it at night) and checks their knowsabout variable...

The one who knows the most about any unit in the player's group becomes the 'detectee'. Then the group has about 30 seconds to neutralize the 'detectee' before the alarm is raised.

Anyway, it'll give you another idea on how you might go about accomplishing what you're after... if you can be bothered waiting two days ;)