eventArea<LABEL>() and resetArea() questions

For AI and campaign script related discussions and questions
Post Reply
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

eventArea<LABEL>() and resetArea() questions

Post by aubergine »

Ability to unsetArea()?

Would it be possible to get some way to disable an area (eg. disableArea() or an extra param on resetArea())?

For example, I might only want certain areas to trigger events if some other area has been triggered beforehand. This would allow AIs to make more erudite decisions based on enemy unit movements around the map as they could enable/disable area events based on how the enemy is moving around the map.

Example: I might have areas defined at two ends of a valley, and in the middle, but only want the middle area to trigger an event if the northern area was entered beforehand.

Also, looking at the C++ code, does resetArea() reset that area for all script environments or just the environment associated with "me"? In other words, if eventAreaFOO() is triggered and player 1 resets that area but player 2 doesn't, the next time a droid enters will player 2 still get the event notification because player 1 had reset that area? It looks like the trigger states (l.id) are currently stored centrally and shared for all environments...?

eventArea<LABEL>

Would it be possible to pass in the label name as a parameter? That way it will be easier to use a single function for all area events and have them reset, etc.

Example:

Code: Select all

areaHandler = function(droid, labelname) {
  // reset trigger
  resetArea(labelname);
  // call some other function that processes the event
  if (!allianceExistsBetween(me, droid.player) {
    dealWithEnemyEnteringArea(droid, labelname);
  }
}

// now use that function to handle three different area events...
this.eventAreaFOO = areaHandler;
this.eventAreaBAR = areaHandler;
this.eventAreaBAZ = areaHandler;
Actually, thinking about it, when considering that an area event will get disabled once it's been entered then is there any benefit to having the label in the event name? When the area event was first discussed, the impact of it's auto-deactivation wasn't fully formed in my mind. Having had time to think about it more, does it really matter if there's some slight overhead the first time areas are entered -- if a central handler isn't interested in them it just won't reset them and they'll never get called again.

Maybe it would be better to just have eventEntered(areaName, droid)?
(sorry for only realising this just now and not back when the event naming was first proposed)
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: eventArea<LABEL>() and resetArea() questions

Post by Per »

You can set an area to be inactive by default in labels.ini by setting triggered = 1. Does that cover your use cases?

Yes, label data is shared between all script contexts. They are intended to be used by rules.js-like scripts, not AIs.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: eventArea<LABEL>() and resetArea() questions

Post by aubergine »

Ah, in that case they won't be useable by AIs, only campaigns and challenges.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Post Reply