Home   Help Search Login Register  

Author Topic: Finding the intruders  (Read 1915 times)

0 Members and 1 Guest 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.

funkster

  • Guest
Re:Finding the intruders
« Reply #15 on: 16 Aug 2005, 09:15:35 »
Great, thanks again.

(So much simpler, I didnt know they automatically changed back to SAFE!   ::)  )

Your a staff member now! When did this happen? Today? Congrats!

...Off to the labs for me, see what I can cook up...

funkster

  • Guest
Re:Finding the intruders
« Reply #16 on: 17 Aug 2005, 12:44:09 »
Ok, done some testing /changing. Found out I was doing all kinds of things wrong.

Wdefenders, Wreserve, Edefenders etc are all arrays of groups I have created. They are all defined in a script "definitions.sqs" which is called by a 'true' trigger at the start like so

Code: [Select]
;define the defending, advanced, and reserve groups:

Wdefenders = [Wdefender1, Wdefender2, Wdefender3, Wdefender4, WSU1]
Edefenders = [Edefender1, Edefender2, Edefender3, Edefender4, Edefender5, Edefender6, ESU1]

Wreserve = [Wreserve1, Wreserve2, Wreserve3, Wreserve4, Wreserve5]
Ereserve = [Ereserve1, Ereserve2, Ereserve3, Ereserve4, Ereserve5]

Wadvanced = [Wadvanced1, Wadvanced2, Wadvanced3, Wadvanced4]
Eadvanced = [Eadvanced1, Eadvanced2, Eadvanced3, Eadvanced4]

Wall = [Wdefender1, Wdefender2, Wdefender3, Wdefender4, WSU1, Wreserve1, Wreserve2, Wreserve3, Wreserve4, Wreserve5, Wadvanced1, Wadvanced2, Wadvanced3, Wadvanced4]
Eall = [Edefender1, Edefender2, Edefender3, Edefender4, Edefender5, Edefender6, ESU1, Ereserve1, Ereserve2, Ereserve3, Ereserve4, Ereserve5, Eadvanced1, Eadvanced2, Eadvanced3, Eadvanced4]

Ok, so far, so good.

Because they are arrays, I changed my other scripts to look like this (eYellow - yellow alert, causes appropriate units to go to where enemy has been seen intruding);

Code: [Select]
; First, checks to see if the red triggers have been set off, exits
; if they have. Otherwise
; eYellow.sqs - this will detect who set the trigger off, and send the response
; group their position by setting a waypoint at the position. (hopefully)

if ealertr then {exit}

_unit = _this select 0
_pos = getPos _unit

[move _pos] forEach Edefenders
[setSpeedMode "FULL"] forEach Edefenders

[move _pos] forEach Ereserve
[setSpeedMode "FULL"] forEach Ereserve

now, when called in the game, i get an error:

"[setSpeedMode "FULL"] forEach Edefenders" error, unknown operator...


Im lost, any ideas anyone?

Thanks.
« Last Edit: 18 Aug 2005, 04:00:20 by funkster »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Finding the intruders
« Reply #17 on: 17 Aug 2005, 13:51:42 »
Instead of

Code: [Select]
[setSpeedMode "FULL"] forEach Ereserve
try:

Code: [Select]
{_x setSpeedMode "FULL"} forEach Ereserve
Also instead of:

Code: [Select]
[move _pos] forEach Ereserve
Use:

{_x move _pos} forEach Ereserve
« Last Edit: 17 Aug 2005, 13:52:52 by THobson »

funkster

  • Guest
Re:Finding the intruders
« Reply #18 on: 17 Aug 2005, 22:54:07 »
Great, thanks heaps.Ill go and check if it works.

(I think this thread could keep going on and on and on and on....)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Finding the intruders
« Reply #19 on: 17 Aug 2005, 23:27:54 »
Better to solve it when the first few ideas are done, then start a new one when you have a new question
« Last Edit: 18 Aug 2005, 10:05:38 by THobson »

funkster

  • Guest
Re:Finding the intruders
« Reply #20 on: 18 Aug 2005, 00:34:18 »
Oh, ok. I thought I was being polite by not hogging too many threads, but ok, if I have a new prob after this Ill post new thread.... :)

Ok, I have im implemented your suggestions, thanx, they seem fine.

However, there is a major problem, I thought the scripts were working,  because tanks racing around and battling. But, they are not! I think it was just those set on guard were going around by themselves.

I have tested the triggers I have for certain conditions, eg "red alert" - enemy detected right near the base, "yellow alert" - enemy detected in or territory, and the triggers work (i created messages in the on activation field). So the trigger side of things is fine.

However, the scripts that they call, are now no longer displaying error messages, but when I test under controlled conditions, they are not doing anything! Not one unit on the map goes back to base when red alert, or to where an enemy is spotted when in yellow alert! Why? I have no idea.
I wont post all the scrpit up again, as its up above here, I dont know why they wont move.

They are all groups, they are being ordered to a location with the MOVE command as u know, some are set to a GUARD waypoint, all armour is set to SAFE.

Any help pls....??

Thanks.
« Last Edit: 18 Aug 2005, 03:59:13 by funkster »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Finding the intruders
« Reply #21 on: 18 Aug 2005, 10:08:47 »
Well they should respond to a move command, but sometimes things are strange.  Try using doMove instead of move.  Other things to try are:
- move their waypoints
- use a switch trigger to send them to a new waypoint.

This is all part of the 'cooking' you need to do to make a mission sometimes.

funkster

  • Guest
Re:Finding the intruders
« Reply #22 on: 18 Aug 2005, 13:09:00 »
Ok, cheers, thats interesting. So sometimes it works,sometimes it doesnt huh? :-\ , interesting....

Ill be back no doubt, lol...

funkster

  • Guest
Re:Finding the intruders
« Reply #23 on: 31 Aug 2005, 09:57:27 »
Ok ok ok, things were not working, so i have given up on this mission, I think the rotteness goes to its core, so Im working on something much more interesting now which has given me more scripting experience and allowed me to see where I was making most of my mistakes anyway  8)

So, although this is not solved, I will mark it as solved, so it doesnt float away lost into the void...