• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Moving regions and its related problems

Status
Not open for further replies.
I am making a system which require moving regions. I use it in JASS with a MoveRectTo function. But I need that region to detect when units enter. But I encounter some bugs here. I heard that trigger events are registered only at the start of the game, so moving a region/rect has no effect on this and it treats the region as where was at the start of the game. So is there any way to re-register these events when I move the region? Or else how to fix this problem? Any non vJass solution is welcome. Anyone who read until here may alternatively suggest me how to do weather effects in circle instead of rect.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I am making a system which require moving regions. I use it in JASS with a MoveRectTo function. But I need that region to detect when units enter. But I encounter some bugs here.
I would assume that it would not bug that easily... but yea I am not surprised it doesn't :D After what I have been through ;D

I heard that trigger events are registered only at the start of the game, so moving a region/rect has no effect on this and it treats the region as where was at the start of the game. So is there any way to re-register these events when I move the region? Or else how to fix this problem?
That is not true. However that is a very recommended way to add events.
If you take a look at every Damage Detection System, you see that they add one event for every unit that is created.
What you need is to create a new event when a region moves.
The problem is with removing the old events.
You should either use an Event Handler System (Though I have no idea if that even exists) or you have to put all your regions in a list of regions and remove all events and add all events when one region moves.

Anyone who read until here may alternatively suggest me how to do weather effects in circle instead of rect.
With that... I cannot help.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The events you put in the events block in GUI are created at the start of the game. You can recreate the event everytime but it's rather ineffective and to get rid of the old event, you would have to scrap the trigger, too. You are already using jass. Do not use the TriggerRegisterEnterRectSimple-bj but the TriggerRegisterEnterRegion event directly. You have to build a region for it, which you can then modify and since the event is tied to the region, it is affected as well. However, what you should not forget is that moving the region around and brushing over units does not fire enter/leave events by itself.

Weather effects can only be constructed on rects. You may approximate a circle but I do not know if this will look good if you split it up.
 
When you register a "unit enters rect" event, the jass function creates a region (regions in jass are different from regions in GUI, which in jass are called rects), then it uses a native called RegionAddRect() to make them equivalent. Finally, it connects the region to the event.

If you do this manually, and create your own region as a global, you can use these natives:

JASS:
RegionAddRect()
RegionClearRect()

To add and remove rects from the region, just like WaterKnight suggested. But your method of grouping the units in the rect will also work, just don't use a too high frequency (checking one time per second is enough).

An interesting thing about regions is that they don't have to be square. They can consist of any number of cells from different places across the map. You just create a region and add rects to it. Then, you can use IsPointInRegion or IsLocInRegion to check if a point intersects it, which is really, REALLY useful for checking stuff such as wether a unit is indoors, in a forest, etc without using several different rects.
 
Status
Not open for further replies.
Top