Home   Help Search Login Register  

Author Topic: Detecting unit not in trigger.  (Read 1691 times)

0 Members and 1 Guest are viewing this topic.

Offline rhysduk

  • Former Staff
  • ****
Detecting unit not in trigger.
« on: 29 Jan 2005, 19:21:51 »
Hi,

I have been tryingto build a script that detects when a unit leaves a trigger, but have problems.

The script looks like this
Code: [Select]
#Start
_player_array = ["W1","W2","W3","W4","W5","W6","W7","W8"]
_list = (List dying)

?(_playerarray) in _list : Goto "NotInList"
~2
Goto "Start"

#NotInList
~1
Hint Format ["%1\n You are leaving the battle area.\n Please return or be punished", (name (this select 0))]
~4
_unit = ?(_playerarray) in _list
?(_playerarray) in _list : (_x setdammage 1) foreach _unit

Goto "Start"

_playerarray is the array of units i have on the map (8 in total, of names W1 through to W8)

_list = (List dying) is the trigger that i want to be used (called dying) Or in other words his is the trigger that i do not want the players to leave.

The purpose of the script is to detect players levaing an area, if they do they get a warning message, the script detects if they carry on leaving the area, if so they die, or return inside the trigger.

Hope someone can help me.

Thx
Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #1 on: 29 Jan 2005, 22:41:55 »
I have not looked at your script because I don't see why you need one.  

If you place a trigger, group it with the person you want to detect, set the Activation field to group leader and put in the 'On Deactivation' field whatever you want to happen when the person leaves the trigger area.
« Last Edit: 29 Jan 2005, 22:42:51 by THobson »

UNN

  • Guest
Re:Detecting unit not in trigger.
« Reply #2 on: 29 Jan 2005, 23:10:50 »
A couple of things I can think of:

Code: [Select]
_player_array = ["W1","W2","W3","W4","W5","W6","W7","W8"]
_Player_Array should be:

Code: [Select]
_player_array = [W1,W2,W3,W4,W5,W6,W7,W8]
You cant refer to units that way, using strings. They have to be the exact names you add to each units name, in the editor.

After that just do this:

Code: [Select]

#Loop

~7

;Unit array
_player_array = [W1,W2,W3,W4,W5,W6,W7,W8]

;Create a copy of List dying
_list = +(List dying)

;check against the player array
_Result=_player_array-_list

{[_x] Exec "Exit.sqs"} ForEach _Result

goto "Loop"


Exit.sqs:

Code: [Select]
_Man=_This Select 0
~1
If !(_Man In (List Dying)) Then {Hint Format ["%1\n You are leaving the battle area.\n Please return or be punished", name _Man]}
~4
If !(_Man In (List Dying)) Then {_Man setdammage 1}

Anything in the array _Result, is not in the trigger.
« Last Edit: 29 Jan 2005, 23:29:52 by UNN »

Offline rhysduk

  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #3 on: 30 Jan 2005, 02:42:24 »
Hello,

Thanks both for the replies, but neither solutions work.

I have tried and tested each one in the mission editor and in MP.

If you can get your solutions to work .. could u post a copy of each mission please?

Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #4 on: 30 Jan 2005, 11:30:30 »
This is a simple example on malden

Offline rhysduk

  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #5 on: 30 Jan 2005, 13:15:46 »
Hi THobson,

Thanks for that, it works perfectly.

Dont know hwy it didnt work for me in the beginning.

Any idea howi detect a unit not in the trigger through a piece of syntax? Know i have the trigger workng i need the script bit to work for the next part ..

Thanks
Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #6 on: 30 Jan 2005, 14:24:36 »
Give the trigger a name say  trig_one.  In the script put

if not (loon1 in list trig_one) then {hint"he is not in the trigger area"} else {hint"Oh yes he is"}


Offline rhysduk

  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #7 on: 30 Jan 2005, 14:35:10 »
Hi again,

Putting this in the script, placing a trigger called trig_one and a unit called loon1 gives the hint syaing  that he is not in the trigger area when he clearly is.

Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #8 on: 30 Jan 2005, 14:41:29 »
Use the radio to run the code.  Still Malden

Offline rhysduk

  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #9 on: 30 Jan 2005, 14:41:46 »
Fixed: I had the trigger set to None and Present so i changed it to West and Present and it works fine..

Thanks All!!

Topic left open till i know nothing left to ask on topic
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline rhysduk

  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #10 on: 30 Jan 2005, 21:49:47 »
Right i have a problem, using your (Thobson) way by using the ON DEACTIVE feild of the trigger i have done this

Trigger:

Name: dying1
Activation: Group Leader & Present & Repeatedly
On Deactivation: ["W3",dying3] exec "Check.sqs"

And the script "Check.sqs" is this:

Code: [Select]
_unit = _this select 0
_list = _this select 1

~0.7

If not (_unit in list _list) then {Hint Format ["%1 is leaving the battle feild.\n Return or be court martialed", name _unit]}

~7

If not (_unit in list _list) then {_unit setdammage 1} else {Hint Format ["%1 returned to the battle area", name _unit]}

Exit

I get numerous errors through this and i dont know why.. i just used the code you gave me, kept teh same format and just changed a few arguements/erpressions or whatever you wanna calll them.

Any help appreciated

Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #11 on: 30 Jan 2005, 22:16:31 »
Instead of:
["W3",dying3] exec "Check.sqs"

try
[W3,dying1] exec "Check.sqs"

« Last Edit: 30 Jan 2005, 22:21:38 by THobson »

Offline rhysduk

  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #12 on: 30 Jan 2005, 22:19:07 »
No different...

Its a pain in the arse!!!

Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #13 on: 30 Jan 2005, 22:22:14 »
How about:

[W3,thislist] exec "Check.sqs"

and take the list out of the script so it becomes

Code: [Select]
unit in _list
« Last Edit: 30 Jan 2005, 22:23:47 by THobson »

Offline rhysduk

  • Former Staff
  • ****
Re:Detecting unit not in trigger.
« Reply #14 on: 30 Jan 2005, 22:28:02 »
Hi THobson

I changed it to what you said. And that gave me an error of saying there was an error int his line of the script :

Code: [Select]
If not (_unit in list _list) then {Hint Format ["%1 is leaving the battle feild.\n Return or be court martialed", name _unit]}
So i took out list to make it
Code: [Select]
If not (_unit in _list) then {Hint Format ["%1 is leaving the battle feild.\n Return or be court martialed", name _unit]}
I think i was getting an error becuase i was contradicting/calling/referencing the list of the trigger twice...

But anyhow.. all works like i want...

Thanks again THobson..

Looks out for the mission in the Mission Mepot in about 2 week.. you'll be in the credits ;)

Rhys
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)