Home   Help Search Login Register  

Author Topic: Finding the intruders  (Read 2220 times)

0 Members and 2 Guests are viewing this topic.

funkster

  • Guest
Finding the intruders
« on: 13 Aug 2005, 23:45:45 »
Hi all, having looked at other threads, particularly the one about who set the trigger off, I still have an unresolved issue.

I have a trigger, the 'yellow zone' within the West base. The condition is that when East is detected by West within the trigger then it goes off - so far so good.
The purpose is, that it sets off 'yellow alert', and unitd a couple of Ks away move at full speed to where the trigger was set off - defeding the base against intruders.

So, in the 'on activation' field, I call my script:


_pos1 = getPos (thislist select 0)
Wdefenders move pos1
Wdefenders setSpeedMode "FULL"
Wdefenders setBehaviour "COMBAT"

Wreserve move pos1
Wreserve setSpeedMode "FULL"
Wreserve setBehaviour "COMBAT"


pos1 is supposed to be the position of whoever set off the trigger (this select 0) - i dont know if the person setting off the trigger is the West unit who 'sees' the enemy, or if it is the enemy itself, but it doesnt matter, as long as the defenders go to the vicinity.

Anyway, when I test the script, I always seem to get a message something along the lines of "this select 0, type unit, expected array".

Can anyone make this script work for me please....?

Thanks.

Dubieman

  • Guest
Re:Finding the intruders
« Reply #1 on: 14 Aug 2005, 03:33:40 »
As I see it, give the west units a guard waypoint. Well the important responding ones and make a trigger around your yellow area and use one of the drop down menus (cant remember which) and select "guarded by west". That way the west units respond to other units' sightings of the enemy and occasionally move about in the trigger area since you defined it as a sensitive area.

funkster

  • Guest
Re:Finding the intruders
« Reply #2 on: 14 Aug 2005, 04:49:58 »
ok thanks for that, I appreciate it. I will use that for the yellow zone, however, using one of the menus isnt flexible enough for everthing, because I want to do a similar thing elswhere.

Is there a script I can write, that will send units from anywhere in the map to the position of whoever set a trigger....I would really like to be able to do it this way....?

Thanks... :)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Finding the intruders
« Reply #3 on: 14 Aug 2005, 08:57:28 »
What you have written is the script you need but with one correction.  In the first line you have _pos1

and later you have:

pos1


You should be using the same throughout.  Also _pos1 will generate an error if used in the activation field of a trigger.

So either use pos1 in the trigger or use _pos1 in a script.  My preference would be for the latter.
« Last Edit: 14 Aug 2005, 08:58:25 by THobson »

funkster

  • Guest
Re:Finding the intruders
« Reply #4 on: 14 Aug 2005, 23:19:45 »
Thanks for that Thobbo,

What I am actually trying to do was inspired by your work, a very preliminary Alpha will be posted for testing and ideas before long.

I am calling it  'dynamic battles' - an island with battles constantly raging back and forth without need for any interference from the player - this can then by used later as a setting to base missions in which would be really cool - playing missions with a war constantly raging non stop.

Anyway, Ill try those suggestions. Thanks.
----------------------------------------------------------------------------------------------
EDIT:

I have tried the new way, I am using this script:
(Copied all exactly from notepad:)
-------------

; First, checks to see if the red triggers have been set off, exits
; if they have. Otherwise
; wYellow.sqs - this will detect who set the trigger off, and send the response
; group their position by. (hopefully)

? Wred = 1 : exit

pos1 = getPos (thislist select 0)
Wdefenders move pos1
Wdefenders setSpeedMode "FULL"
Wdefenders setBehaviour "COMBAT"

Wreserve move pos1
Wreserve setSpeedMode "FULL"
Wreserve setBehaviour "COMBAT"

--------------

When the script is called, I get the following error message:

"error move pos1; type any, expected Object, Group"

Anyone got any idea what is going wrong or what I can do?
« Last Edit: 14 Aug 2005, 23:44:00 by funkster »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Finding the intruders
« Reply #5 on: 15 Aug 2005, 07:59:49 »
Quote
What I am actually trying to do was inspired by your work
I am happy that my mission has inspired you.  That is great praise.

First of all change all pos1  to _pos1 unless you really do want them to be global variables.

You didn't say which line gave the error but I suspect the following is the line that is causing the problem:

Code: [Select]
pos1 = getPos (thislist select 0)thislist is not a defined variable in the script.  If you want to refer to the list created by a trigger use:

list triggername
« Last Edit: 15 Aug 2005, 08:03:46 by THobson »

funkster

  • Guest
Re:Finding the intruders
« Reply #6 on: 15 Aug 2005, 08:28:42 »
Thanks again for that mate, :)

Actually, to be honest, I dont really know exactly what I am doing, hence the errors, I have only begginger scripting experience.
I dont even know what 'thislist' is - I am just trying to figure out and piece together my script, and things like that are taken from other help posts.

So, I dont really know what to do here if I am on the wrong track.

What script will create a position (_pos) that is the position of whoever set off the trigger, and then send my groups (Wdefenders) to that position? (The script is called in the 'on activation field of the trigger).

All help is greatly appreciated...

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Finding the intruders
« Reply #7 on: 15 Aug 2005, 09:01:15 »
thislist is an array.    It is created by a trigger and is local to that trigger.    It is an array of all the units in the trigger area that satisfy the first element in the Activation box.

In other words, if you have a trigger with East not present, then thislist is an array of all the East units in the trigger area.   It is continually updated.    However, you can only use "thislist" within the trigger itself.   If you want to use this array anywhere else (for example in a script or another trigger) you must use list triggerName, remembering of course to call the trigger triggerName (or whatever you like.)   This array is also updated dynamically.

Now, in this particular case what you care about is the unit that fired the trigger.   (East detected by west:  the east unit must be in the trigger area but the west unit may be outside it.)

On activation:   [thislist select 0] exec "myScript.sqs"

In the script:

_unit = _this select 0
_pos = getPos _unit
Wdefenders move _pos

etc.

Hope that helps.  Syntax etc not guaranteed.





Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Finding the intruders
« Reply #8 on: 15 Aug 2005, 09:22:25 »
Just a small change:

Quote
In other words, if you have a trigger with East not present, then thislist is an array of all the East units in the trigger area.
Actually thislist is probably the same for east present and east not present.  I have not checked that.

It is a bit like groping in the dark at first, don't worry.  Keep at it and it will all become clear.

I suggest you read (and re-read) the comref:
http://www.ofpec.com/editors/comref.php
It will give you a lot of ideas.
« Last Edit: 15 Aug 2005, 09:24:41 by THobson »

funkster

  • Guest
Re:Finding the intruders
« Reply #9 on: 15 Aug 2005, 09:49:47 »
Great, that all helps alot actually  8),

Ill give it a go. There is one more q I want to ask, but Ill see if these probs are fixed yet first.

Cheers.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Finding the intruders
« Reply #10 on: 15 Aug 2005, 09:56:37 »
Quote
Actually thislist is probably the same for east present and east not present.
It is.
Plenty of reviewed ArmA missions for you to play

funkster

  • Guest
Re:Finding the intruders
« Reply #11 on: 16 Aug 2005, 04:56:11 »

On activation:   [thislist select 0] exec "myScript.sqs"

In the script:

_unit = _this select 0
_pos = getPos _unit
Wdefenders move _pos

etc.

Hope that helps.  Syntax etc not guaranteed.







Thanks mac,
that does help, however I am confused as to why it is nessasary.

What is the difference between calling the script in the 'on activation' field of a trigger like so: " [] exec wYellow.sqs "

and the way you reccommend:

" [ this select 0] exec wYellow.sqs" ?




One more issue:

I am trying to create a script that, for every group on the field, will check the distance to the nearest enemy, and then set them to "safe" if the enemy is a reasonable distance away (to stop tanks trying to do a bit of rock - climing as some of them are).

Is there any command along the lines of "nearest enemy"?
Ive looked all through the comref, cant see anything except "distance", which would mean i would have to name every unit to every unit, which is ridiculous.....!

Any ideas?

Thanks alot....

-----------------------------------------------------------------------------
EDIT:

what am I doing wrong here?::

" if (ealert = true) then EXIT "

where "ealert" is a trigger???

thanks.
« Last Edit: 16 Aug 2005, 06:23:43 by funkster »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Finding the intruders
« Reply #12 on: 16 Aug 2005, 08:12:34 »
Code: [Select]
if (ealert = true) then EXIT Should be

Code: [Select]
if ealert then {exit}

1. ealert is a boolean so you don't need to compare it with anything (it is already either true or false)
2. = is not a comparison it is an assignment.  To check for equality you need to use ==
3. You need {} around the set of code after the then.

I assume that when you say ealert is a trigger what you mean is that in the activation field of a trigger you have the line:
ealert = true
If not and ealert is the name given to a trigger then:

4. put ealert = true in the activation field of the trigger and change the trigger's name

Apart from that it was okay!

Quote
I am trying to create a script that, for every group on the field, will check the distance to the nearest enemy, and then set them to "safe" if the enemy is a reasonable distance away (to stop tanks trying to do a bit of rock - climing as some of them are).
I would try a different solution.  Setting them to Safe will not stop them chasing the enemy.  If you really want to continue with it then set up triggers that cover the map to give you a list of all the units on each side,  Then cycle through each unit from one side and check the distance to each of the enemy units.  As I said - I would go a different route.


Mac actually recommended:
Code: [Select]
[ thislist select 0] exec "wYellow.sqs"  (You used this instead of thislist)

This will pass into the script the unit that is first on the trigger's list.
To access that unit in the script you would need the line:

_unit = _this select 0

If you want to use:

Code: [Select]
[] exec "wYellow.sqs" You need to be able to tell the script about the units that the trigger has detected.  To do this you would need to give the trigger a name and then in the script itself extract the unit from the trigger's list using:

_unit = list triggername select 0

The problem with this method is that the script will always use the same trigger.  In mac's solution the script can be used successfully from any number of triggers.

Just because a script is run from a trigger's activation field do not assume that that script knows anything about the trigger. It doesn't.
« Last Edit: 16 Aug 2005, 09:00:40 by THobson »

funkster

  • Guest
Re:Finding the intruders
« Reply #13 on: 16 Aug 2005, 08:39:17 »
Once again, that is very informative and helpful - posting and reading here is a great way of furthering my OFP education!  ;D

The explanation you give of unit triggername, and thislist select 0 actually makes sense to me now, so thanx!

As for the script i want to create, there is a reason I want it the way I do, its because I still want units to go to the location of wherever on the frontline a  battle is taking place, which they do. However, pretty much all the relevant units are constantly set on COMBAT, thus, they are attempting to traverse from the North side of the frontline on Kolgujev to the South side and vice versa, which makes for some really spectacular mountaiside tank battles, but also means tanks attepting to climb hills they cant manage and becoming stuck. Same happening in forests.
If I could contstantly set those who arent engaged in combat, or near enemies to SAFE, they would go via the road, which would look alot more realistic, and save them getting stuck in corners.

On that note, does the AI automatically change to COMBAT from SAFE when engaged? If so, I could have a trigger that goes off every five minutes or so and changes everyone on the whole map to SAFE, those in battle would fix themselves...

One last thing. I think I have created the laggiest scripts in the whole world, - twice as bad as your masterpiece AA. I dont know why, there are around 5 triggers, some of which call small scripts. - Could the problem be armour? I susect too much armour lags big time right? I have around 50 armoured units on the map, probably the total number of all units would be around 150! might have something to do with it right  :P ?


Thanks amillion once again!

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Finding the intruders
« Reply #14 on: 16 Aug 2005, 09:10:45 »
Quote
On that note, does the AI automatically change to COMBAT from SAFE when engaged?
Yes.

Quote
If so, I could have a trigger that goes off every five minutes or so and changes everyone on the whole map to SAFE, those in battle would fix themselves...
You could try it but I think it would look ugly.  Why not just have them all set to SAFE, they will go to COMBAT when they need to and they will then go back to SAFE when there are no enemies around.


Quote
I have around 50 armoured units on the map, probably the total number of all units would be around 150
!
That is probably your problem.  In Abandoned Armies I have 34 crewed armour units and 6 empty ones, any collection of more than a handfull generates horrible lag.  I have around 650 loons (solders and civilians) but I think most of the lag comes from the armour.