Home   Help Search Login Register  

Author Topic: ThisList + other trigger issues  (Read 639 times)

0 Members and 1 Guest are viewing this topic.

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
ThisList + other trigger issues
« on: 28 May 2003, 17:46:36 »
Hi, need some help, can't figure out whether it's an OpF or MaBrain-problem...  :P

What i try to do :

Placed an empty flagcarrier object (a flag) and a trigger over it, set to 'Repeating' and 'Anybody'.  Therefore it calls a script everytime a person/vehicle from either side enters it, giving 'ThisList' to the script.

My script should get the whole array 'ThisList' from the trigger - it includes all objects that are within the triggerarea, right ?
Now depending on all objects in the array i want to determine what side they're on / which flagtexture i should set on the flagcarrier.
(I can refer to the flagobject via "flagcarrier" nearestObject (pos of 1st object in array)).

I want to do this because it would only require 1 trigger for 1 flag, rather than several. Also, i don't need to name the flag or the trigger because i want to use nearestObject.

Can it be done at all ?

Anyway, my outcomes are:
It works when i as the player go into the trigger: even if there are some AI buddies with me there's only 1 thing in ThisList. But i can change the flagtexture because nearestObject() gives me the flagobject.

It doesn't work when i send 1 or more computer mates into the trigger. There's still only 1 thing in ThisList, but nearestObject won't find a flagcarrier object ! As if it isn't there.

Does this mean, objects in ThisList are only valid when i go into the trigger myself ? I don't get it ...

Anyone could cast some light on this ?  ???

Offline Doolittle

  • Contributing Member
  • **
  • _this select 0
Re:ThisList + other trigger issues
« Reply #1 on: 28 May 2003, 19:39:25 »
Maybe the flagpole is in thisList and so it sets off the trigger when the game starts??  Do OnCondition: this and count (thisList - flagpole) > 0
You have to name the flagpole of course.

Doolittle

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:ThisList + other trigger issues
« Reply #2 on: 29 May 2003, 12:01:18 »
No, an emtpy flag ("flagcarrier" btw) doesn't activate an 'anybody' trigger, i tested that. The 1st entry in 'ThisList' is the unit that comes into the trigger area.

Btw: i found some info to this problem in the AdvancedEditing/CommandeerThis! Thread (http://www.ofpec.com/yabbse/index.php?board=8;action=display;threadid=9437;start=0)

Knowing, that NearestObject only works up to about 55m i found a mistake in my script: my nearestObject searched around the player pos, not the pos of the object that activated the trigger. So when an AI walked into the trigger and i was more than 55m away from the flag, nearestObject couldn't find the flag. Stupid mistake.

The answer brings me to the next question: what is the 1st enty in ThisList ? An object ? A pos ?

EDIT: No, it's an array containing all objects within the triggerarea. Got everything working, only requirement is that the trigger radius isn't greater than 55m, otherwise the nearestObject won't work.

Here's my script:
Quote
;CheckFlag 1.0
;=======================================================================================

; ThisList from Trigger
_allarray = _this

; All objects in the TriggerArea
_group = _allarray select 0

; 1st object that activated the trigger
_activator = _group select 0

_flag = nearestObject [(_activator), "flagcarrier"]
? (side _activator == west):_flag setflagtexture "usa_vlajka.pac"

hint format ["Objects near flag:%1",(_group)]

EXIT
;=====================================END OF SCRIPT=====================================

It works great. You won't need to name the flag, nor the trigger. Plus you only need 1 trigger to change the status of the flag instead of 2 or more. What needs to be included now is a loop that checks each object in _group:
- is it west or east ? if it's a vehicle, is it manned ? (i don't want empty vehicles to 'block' a flag from being conquered)

After all objects are checked, the flag should be set to appropiate texture (west,east,uncontrolled).

Here's my example map that works with the test script:
« Last Edit: 29 May 2003, 12:49:59 by DrStrangelove »