• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Units Enters Region

Status
Not open for further replies.
Level 3
Joined
May 10, 2014
Messages
41
Hello!

I make a trigger: unit use spell, that creates region with size 300x300 at his position and stores it to variable. (rect)
The event 'unit enters region variable' added to trigger, that kills entering unit.

It works good for the first time.
If spell is used several times - units dying when they enter the ''old'' regions.

It would be cool to delete event from trigger, but that's impossible.

Is there any way to clean region variable?

Or remove (destroy) "old" region from the game before creating new, so units don't die even if they enter?

Or, may be creating and destroying triggers... i never did it before...
Does it slows the game or cause bugs?

If it's not, how to create a trigger? I need JASS or it's possible with custom script and GUI? And how to destroy it?

Thanks for any help! :as:
 
Level 25
Joined
Sep 26, 2009
Messages
2,383
the whole problem has nothing to do with variables as they are pointers (they only *tell* your computer which region to use, they're not the region itself).

Creating and destroying triggers is usable only in jass afaik.

As you cannot remove events, you may end up having to use either a point (location) or a region and periodically checking if any unit is within range of point or inside the region. That way will be quite taxing though as you would need to check every unit in map.
 
Level 25
Joined
Sep 26, 2009
Messages
2,383
That doesn't matter afaik (at least in GUI it doesn't) - once you add region to an event "unit enters region", it takes the coordinates of the region and uses them - even if you later move the region somewhere else.

For example you register the event "unit enters region" for region at coords [1,5]. Even if you move the region somewhere - for example to coords [2,3], the event will still fire when units enters [1,5].
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
That doesn't matter afaik (at least in GUI it doesn't) - once you add region to an event "unit enters region", it takes the coordinates of the region and uses them - even if you later move the region somewhere else.

For example you register the event "unit enters region" for region at coords [1,5]. Even if you move the region somewhere - for example to coords [2,3], the event will still fire when units enters [1,5].

This is true but you should mention why and how this happens.

Events in WC3 are registered when they are created. These are registered specifically at map init.

So that region event gets registered where the region is at map init. So moving the region does nothing since the event is already registered.

The only way to move the region and the event is to destroy the old trigger. Then create a new trigger. Then register the event to the new trigger. (All of this can be done in GUI.)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Is there any way to clean region variable?
Yes it is possible. Clear the old rect from the region before adding it in the new position.

JASS:
native RegionAddRect takes region whichRegion,rect r returns nothing
native RegionClearRect takes region whichRegion,rect r returns nothing

What should happen is the same event then corresponds to a different area on the map and all works fine as the event is linked to the region. However seeing how stupid WC3 is at times you might be forced to destroy the trigger and remake it with a new enter region event (maybe the event only attaches to the actual area and not even the region?). I have never tried this or seen the results of it so I can only speculate the result.
 
Status
Not open for further replies.
Top