Region trigger work - Pretty complicated.

Baltazhar

Active Member
Reaction score
55
I have a given ability that summons a unit, and has the unit walk around for the duration of the spell.
I first tried with having the unit move to a new point every 3 seconds, but that didn't look all too good. Then I figured that having a region, would make it look better. Since the unit would vary between short and long straight lines, instead of just changing every 3 seconds.

So I've tried quite a few things. First I made a Region-Variable[Array] that got set at unit spawn, and the unit was ordered to move there. Since u can't make Region variables appear in events generally, I added it by using a trigger at Map Initialization. However, it never moved beyond the first region.

Then I read somewhere that the Region used in the event, can't be moved during the actions of the given trigger. That would cause an error and something would screw up. That was my problem indeed, so on to plan 2.
I made the Region-Variable have 2 arrays for each player, so Player 1 would have Array 1 and 11.
Then I redid the trigger so the unit would initially move to Region[1] and having the 2nd trigger respond to Unit enters region Region[1] and Region[11]. However, this did not work either.

Then I thought, perhaps I need some 'physical' regions created in the Region Palette, and just bound to the Region-Variable at MapIni. Redid the initial order trigger, to move to Region1, and made the 2nd trigger respond to unit entering Region1 and Region11 (Not by using triggers).

This is as far as I've come. I've made some test so when I type "1" it pans cam to Region1 and "2" to Region11, so I can check if they've moved. The Region1 moves fine, but the Region11 doesn't. The 2nd trigger never goes off (put in text msgs here and there to see how far it comes).

So what I want to know is: Is there something that makes Region - Move or Set Region-variable unuseable in events? I have tried just about anythin (i can think of), and i'm getting desperate. Everytime I get that "Hey! I haven't tried that yet!" thought, it gets wiped darn fast >.<

Hope someone can bear with me and read through this entire text crap, I can post map (more or less unwillingly, would spoil the surprise :p) or post the triggers if that would help.

Rep award for anything that helps :D

- Balt

EDIT: Bolded the main question, for those who don't wanna know all the details ;)
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
You want the unit to move randomly or with fixed points?

Edit:
Is there something that makes Region - Move or Set Region-variable unuseable in events?

The bolded part I kinda don't understand at all.
 

Baltazhar

Active Member
Reaction score
55
It's supposed to be random points in a given range.

So it's basically:
Set Region1 -> Move there

EVENT: Unit enters Region1
Set Region11 to random point -> Move there

EVENT: Unit enters Region11
Set Region11 to random point -> Move there

If u catch my drift. Have an integer to make sure the 2 always change from Region1 to Region11, if the problem was that the same Region couldn't be moved under actions, when used in the event.

EDIT: Adding some code.

Code:
Death March
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Death March 
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                [Removed]
            Then - Actions
                [Removed]
            Else - Actions
                [Unimportant lines removed]
                Set Temp_Point = (Position of (Casting unit))
                Unit - Create 1 Death March for (Owner of (Casting unit)) at Temp_Point facing (Facing of (Casting unit)) degrees
                Custom script:   call RemoveLocation (udg_Temp_Point)
                Set DeathMarchLeader[(Player number of (Owner of (Casting unit)))] = (Last created unit)
                Unit - Turn collision for (Last created unit) Off
                Set Temp_Point = (Position of (Casting unit))
                Unit - Create 1 Death March Effect for (Owner of (Casting unit)) at Temp_Point facing Default building facing degrees
                Game - Display to (All players) the text: Dummy Unit created
                Custom script:   call RemoveLocation (udg_Temp_Point)
                Unit - Add a ((Real(((Owner of (Casting unit)) Current lumber))) x 2.00) second Generic expiration timer to (Last created unit)
                Player - Set (Owner of (Casting unit)) Current lumber to 0
                Set Temp_Group = (Units owned by (Owner of (Casting unit)) of type Death March)
                Unit Group - Pick every unit in Temp_Group and do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Owner of (Picked unit)) is an ally of Player 1 (Red)) Equal to True
                            Then - Actions
                                Set Temp_Point = (Random point in Seal Spawn Area <gen>)
                                Game - Display to (All players) the text: Seal Spawn point set
                            Else - Actions
                                Set Temp_Point = (Random point in Penguin Spawn Area <gen>)
                                Game - Display to (All players) the text: Penguin Spawn point...
                Set DeathMarchRegionCounter[(Player number of (Owner of (Casting unit)))] = (Player number of (Owner of (Casting unit)))
                Region - Center DeathMarchRegion[DeathMarchRegionCounter[(Player number of (Owner of (Casting unit)))]] on Temp_Point
                Unit - Order DeathMarchLeader[(Player number of (Owner of (Casting unit)))] to Move To (Center of DeathMarchRegion[DeathMarchRegionCounter[(Player number of (Owner of (Casting unit)))]])
                Game - Display to (All players) the text: Region moved and un...
                Custom script:   call DestroyGroup (udg_Temp_Group)
                Custom script:   call RemoveLocation (udg_Temp_Point)
This is the initial trigger that spawns the unit, and sends it to the first region. It may look messy, but the more ideas I tried and failed at, the more complicated it god :D

Code:
Death March Player1
    Events
        Unit - A unit enters DeathMarch1 <gen>
        Unit - A unit enters DeathMarch11 <gen>
    Conditions
        And - All (Conditions) are true
            Conditions
                (Unit-type of (Entering unit)) Equal to Death March
                (Owner of (Entering unit)) Equal to Player 1 (Red)
    Actions
        Game - Display to (All players) the text: Death March Player ...
        Set Temp_Point = (Random point in Seal Spawn Area <gen>)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))] Equal to (Player number of (Owner of (Entering unit)))
            Then - Actions
                Set DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))] = ((Player number of (Owner of (Entering unit))) + 10)
            Else - Actions
                Set DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))] = (Player number of (Owner of (Entering unit)))
        Region - Center DeathMarchRegion[DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))]] on Temp_Point
        Unit - Order DeathMarchLeader[(Player number of (Owner of (Entering unit)))] to Move To (Center of DeathMarchRegion[DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))]])
        Custom script:   call RemoveLocation (udg_Temp_Point)
The 2nd trigger that should trigger when the unit enters the first region, and send it off to the 2nd. However, it never triggers.

Code:
Set DeathMarchRegion[1] = DeathMarch1 <gen>
Set DeathMarchRegion[11] = DeathMarch11 <gen>
I got this under map ini. At map ini they are both in the bottom corner of the map. The first moves up to Random Point in SealSpawnArea, and the second does nothing, as the second trigger never triggers.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Then try something like

Events
A unit starts the effect of an ability

Conditions
Ability being cast equal to <your ability>

Actions
Create 1 <your unit> for Owner of (triggering unit) at <desired location> facing <whatever> degrees
Set YourUnit = last created unit
Set CasterLocation = Position of (triggering unit)
Set MoveCount = 0
Set TempRegion = Region centered at CasterLocation with width X and heigth X
Turn on Unit Move <gen>
-------------------------------------------------------------------
Unit Move (initially off)

Events
Every X.XX seconds of game time

Conditions

Actions
If - If all contidions are true then do (then actions) else do (else actions)
If - MoveCount Less Than X (desired amount of moves)
Then do actions
Set TempLoc = Random point in TempRegion
Set UnitMove = Region Centered at TempLoc with width X and heigth X
Set UnitMovePoint = Center of UnitMove
Order YourUnit to move to UnitMovePoint
Set MoveCount = MoveCount + 1
Else do actions
Turn off <this trigger>
--------------------------------------------------------------------------

Hasn't tried it, don't know if it works, and it leaks as hell but I assume you know how to remove the leaks.

Edit:
Needs a lot of improvement, working on some minor details now.
 

Baltazhar

Active Member
Reaction score
55
I know how to remove leaks :)

What u suggested is what I've tried before. It worked fine, however I thought it looked too sloppy that the unit got a new target every X.XX seconds. That's why I wanted to give it a new target, once it reached the first target. Thus, using regions to determine when it reached the target it was supposed to go to, and then created a new and have it move there. -And then loop it, so it kept reaching target and being sent to a new one.

EDIT: +rep alrdy btw, for at least trying to help :)
 
Reaction score
107
Couldn't you just give the unit the wander ability, then have a trigger to order it to move back to the centre if it tries to leave penguin/seal spawn?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Events
A unit starts the effect of an ability

Conditions
Ability being cast equal to <your ability>

Actions
Set CasterPosition = Position of (triggering unit)
Set TempRegion = region centered at CasterPoint with size (X,X)
Add to this trigger the event a unit enters TempRegion
Create 1 <unit> for Owner of triggering unit at <desired location> facing <Whatever> degrees
Set TempUnit = last created unit
Set TempLoc = Random point in TempRegion
Set UnitMoveRegion = Region centered at TempLoc with size (X,X)
Set UnitMove = Center of TempLoc
Order TempUnit to Move to UnitMove
-----------------------------------------------------------------------
Kinda got stuck here, I don't know if you can add shitloads of events into a trigger, in that case you can keep adding events such as "A unit enters UnitMoveRegion", then remove that region, recreate the points/regions to get a new random point and keep doing that. Otherwise you can make a trigger for each region enterred. Make a region array variable, make a integer variable to count the regions and make a trigger "A unit enters UnitMovePoint[RegionCounter].
 

Baltazhar

Active Member
Reaction score
55
baka-ranger: Ofc I could, that would be very easy. However, I'm such a bi*ch, and want it perfect :D The unit is supposed to be marching, not wandaring, so I couldn't live with myself that way :p

Larcenist: I've tried all ur suggestions. The basic problem is this: Unit enters Region event does not work if one of the following are true - Event has been added by a trigger (Region variable /w & /wo Array), Region has been moved by a trigger.

Perhaps I'm sharing too much information, perhaps the only needed is the basic problem discribed above.

EDIT: Larcenist, now that ur trying to make the trigger in ur own WE, try this:
Code:
Trigger 1:
Create Unit
Set RegionVariable[1] to random point
Order Unit to move to RegionVariable[1]

Trigger 2:
When unit enters RegionVariable[1]
Set Region Variable[2] to random point
Order unit to move to RegionVariable[2]
That's the only thing I need to know can be done :)

EDIT 2.0:
I tried making the most basic triggering possible, looking like this:

Code:
Trigger 1
    Events
        Unit - A unit Finishes casting an ability
    Conditions
    Actions
        Unit - Create 1 Footman for Player 1 (Red) at (Position of (Casting unit)) facing Default building facing degrees
        Region - Center DeathMarch1 <gen> on (Random point in Seal Spawn Area <gen>)
        Unit - Order (Last created unit) to Move To (Center of DeathMarch1 <gen>)

Code:
Trigger 2
    Events
        Unit - A unit enters DeathMarch1 <gen>
    Conditions
    Actions
        Game - Display to (All players) the text: Test "Enters Region...

Still doesn't work, the Game Text doesn't get displayed... I really can't figure this one out >.<
The footman gets created, and moves to the random point, but nothing happens then. He just stops.
 
Reaction score
107
Code:
Death March Player1
    Events
        Unit - A unit enters DeathMarch1 <gen>
        Unit - A unit enters DeathMarch11 <gen>
    Conditions
        And - All (Conditions) are true
            Conditions
                (Unit-type of (Entering unit)) Equal to Death March
                (Owner of (Entering unit)) Equal to Player 1 (Red)
    Actions
        Game - Display to (All players) the text: Death March Player ...
        Set Temp_Point = (Random point in Seal Spawn Area <gen>)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))] Equal to (Player number of (Owner of (Entering unit)))
            Then - Actions
                Set DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))] = ((Player number of (Owner of (Entering unit))) + 10)
            Else - Actions
                Set DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))] = (Player number of (Owner of (Entering unit)))
        Region - Center DeathMarchRegion[DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))]] on Temp_Point
        Unit - Order DeathMarchLeader[(Player number of (Owner of (Entering unit)))] to Move To (Center of DeathMarchRegion[DeathMarchRegionCounter[(Player number of (Owner of (Entering unit)))]])
        Custom script:   call RemoveLocation (udg_Temp_Point)

Instead of having a common trigger for the 2 regions, why not split them up and have it so that region 1 points to region 11, and region 11 points back to region 1?

In your conditions, you dont need the "and" since all conditions are automatically and.

"March" or not, it seems like wandering to me :p

EDIT::
When you display the text message, add a "unit - create" line, and create a unit at the centre of deathmarch1 and see where it creates.
 

Baltazhar

Active Member
Reaction score
55
baka-ranger:
Since I need 1 trigger (doing it this way) for every player, and all other abilities only use 1 even if all 10 players use it at the same time, I thought that would be a lot. If it's needed ofc, I would make 2 triggers for each player. Would be a lot easier to look at as well :)

Didn't know that conditions are automatically considered "and", thx for the tip :D

Concerning the text message, i've have had the camera pan to the point, so I could see where it was, so I know it's moved. But if the text message doesn't even appear, then the trigger is obviously not working, thus adding a "Unit - Create" line wouldn't be needed ;)

I think i'll try the Wander thing, perhaps it's a lot better than I actually think :D
 
Reaction score
107
Hmm... This is curious.. I've never tried moving regions before. When I get home, Ill try it out and get back to you. I'm at work atm :p
 

Iwan_Krissov

New Member
Reaction score
18
I can explain you why your triggers dont work like you want them to work.
But I cant give you a solution for your problem unfortunately.

At first you have:

Code:
Set DeathMarchRegion[1] = DeathMarch1 <gen>

Than you create your unit and order it to go to "DeathMarchRegion[1]".
But:
Code:
Region - Center DeathMarchRegion[DeathMarchRegionCounter[(Player number of (Owner of (Casting unit)))]] on Temp_Point
"DeathMarchRegion[1/11]" is anywhere else, as you want it to be...

Now you want the unit to go to the next region, ordering it so with your second trigger.
But your second trigger will never set off, if you have not extreme luck...
Code:
Death March Player1
    Events
        Unit - A unit enters DeathMarch1 <gen>
        Unit - A unit enters DeathMarch11 <gen>
....

"DeathMarch1/11 <gen>" is still, were it was at the beginning. You only have moved "DeathMarchRegion[1/11]". The problem is you cant move real regions, just variable-region. but you cant use variable-regions for "unit enters region"-event, just real regions ...
So if youre very lucky, your new region is where the old was and the trigger may go off...but Im sure thats not what you want...
 

Baltazhar

Active Member
Reaction score
55
baka-ranger: Hahaha, slacking off at work? =) I'd be glad if u'd look at the trigger once u get home <3

Iwan_Krissov: I can see where ur going with this. Using [1/11] are just for player 1, for my personal testing. When I find something that works, I'll make the rest for players 2-10.
About me just moving the variable, and not the 'real' region. I did a test about the region moving, since u can't see them in game. Just to know if it moved or not.

I set the DeathMarch1 <gen> at point A on the map in the editor, made a trigger to move it to point B. Then I made a trigger, to pan the camera to DeathMarch1 <gen> when I typed "1" as an exact match. The camera panned to point B, so I see no other possibility than the region itself, indeed did move.
I know u can't set variable regions in the event normally, but if u use the action "Trigger - Add new event", u can choose the region variable as well. However, as u say, it can't be triggered as an actual event.

Some thing I wonder. Why did Blizzard make the "Trigger - Add new event" if some of the possibilities herein doesn't work. And second, why does "Unit - A unit enters DeathMarch1 <gen>" not work, after the region has been moved by a trigger? Perhaps i'll make another test, making DeathMarch1 <gen> move to DeathMarch11 <gen>, have a unit go there, and have 2 different triggers. One spawning a Footman if unit enters DM1 and the other spawning a Grunt if unit enters DM11. Just to check if my map is just fu**ed up, or if the 100% normal DM11 would work.

It's really nice that u guys are willing to help so much, I really appreciate it <3
Rep rep and awaaaaaay.... ;)

=======EDIT:=======
Okay, I've tested things out.
First off, I made a trigger to pan the camera to DeathMarch1 <gen> (hereafter known as DM1), and a trigger to pan it to DeathMarch11 <gen> (hereafter known as DM11).
Then I made 3 simple triggers.
Code:
Spawning the unit
    Events
        Unit - A unit Finishes casting an ability
    Conditions
    Actions
        Unit - Create 1 Footman for Player 1 (Red) at (Position of (Casting unit)) facing Default building facing degrees
        Region - Center DeathMarch1 <gen> on (Center of DeathMarch11 <gen>)
        Unit - Order (Last created unit) to Move To (Center of DeathMarch1 <gen>)
Simply to spawn the unit, move the region, and make it run.

Code:
DeathMarch1
    Events
        Unit - A unit enters DeathMarch1 <gen>
    Conditions
    Actions
        Game - Display to (All players) the text: DeathMarch1 worked!
        Unit - Create 1 Footman for Player 1 (Red) at (Center of DeathMarch11 <gen>) facing Default building facing degrees
To test if DM1 region would be triggered after it's moved.

Code:
DeathMarch11
    Events
        Unit - A unit enters DeathMarch11 <gen>
    Conditions
    Actions
        Game - Display to (All players) the text: DeathMarch11 worked!
        Unit - Create 1 Grunt for Player 1 (Red) at (Center of DeathMarch11 <gen>) facing Default building facing degrees
And to check DM11 to see if the region that hadn't been moved, would trigger.

The results were. DM1 and DM11 was at different places at map ini, tested with the 2 triggers. After spellcast, they were at the same place. The spawned Footman ran to the DM1/11 regions, and only the Grunt from DM11 was created, and the text "DM11 worked!".

Thereby the evidence of this whole investigation is probably, and sadly:
-Variable-regions can't be used to trigger events.
-Regions that has been moved by triggers, can't be used to trigger events. (makes u wonder why blizzard would make the action "Region - Move", since it works for absolutely nothing, apparently).

So now, as I see it, I have 2 options.
Option A: Find some Jass geek and hope that Jass can produce the code needed, cuz God knows that I suck at Jass :D
Option B: Use the 'Wander' ability for the unit.
(Option C: Hope that someone with really wicked WE-GUI skillz has the head to crack this nutty problem)

Still, hope to hear from u guys :)
 

Baltazhar

Active Member
Reaction score
55
Okay, I just HAD to post this, made it in a seperate topic, just to keep things clear.

I tried giving my DeathMarch unit 'wander'. It also has 'locust', to make it unselectable by the player, making to move on random without influence. Furthermore, I made it a flying unit, cuz it's a ghost-thingie, meant to fly 'through' enemies. I put it on the map, and booted up the test.

Here's what happened. It starts wondering around, nice long straight lines, which was what I was looking for actually. However, it flew over the cliff meant to border the player area, and into, and beyond, the playable map area. Made map boundries to seal off any blink attempts and such, but this sucker just kept flying around in the dark map boundry xD
I thought that boundry was there to stop anything from going out there, but apparently the 'locust' ability kinda screws that rule over :D

I'll do some more testing with keeping the testing unit within the area where I want it. I'll post back later :)
 
Reaction score
107
Make it a ground unit, and give it "ghost (visible)" as well.

Either that or turn off its collision when you create it in the trigger, although i think that lets it ignore pathing as well... =/
 

Baltazhar

Active Member
Reaction score
55
Ofc, didn't even cross my mind to make it ground xD
I must be falling apart here... I think giving it collision 0 / turning off it's collision will make it go through other units, but not ignore the pathing of terrain.

Never seen or heard of "ghost (visible)", what does that do? No pun intended about the 'never seeing the ghost' ;)

Got home from work yet baka? :D
 
Reaction score
107
Ghost visible basically removes collision size. so it can walk through units, and units can walk through it.
Most people say to just set collision size to 0, but i've tried it a few times and it seems flawed.. where ghost (visible) seemed to do the trick for me.

ANYways.. moving along
So i am home now, and i tried out the moving region function, and it works like this.
The region ACTUALLY does get moved to the new location, and therefore every reference to the region there after is actually correct.
However, the problem there arises, in that if you have a "pre-created" event saying "unit enters region whatever" the event only registers the regions ORIGINAL location.
BUT. If you add the event "unit enters region whatever" AFTER moving the region, THEN, the trigger will fire at the regions moved position.

So... basically for your application, you're basically stuck since you would need to re-add the events every time you move the region, which would lead to multiple firings of the trigger, unless you can remove events from a trigger [that of which i am not sure whether it can be done in JASS let alone GUI]...

My advice at this point? Just use wander. Its simple and trigger free.
Although since you give the "marcher" locust already, you don't really need to add other things, since locust removes collision normally.
 

Iwan_Krissov

New Member
Reaction score
18
Thereby the evidence of this whole investigation is probably, and sadly:
-Variable-regions can't be used to trigger events.
-Regions that has been moved by triggers, can't be used to trigger events. (makes u wonder why blizzard would make the action "Region - Move", since it works for absolutely nothing, apparently).

Thats exactly what i wanted to show you. Unfortunately my english seems not to be so good, that it can be understood from everyone :D

Edit:
No, wait!
--->-Regions that has been moved by triggers, can't be used to trigger events. (makes u wonder why blizzard would make the action "Region - Move", since it works for absolutely nothing, apparently).
You cannot move regions, you can just move variable-regions

Edit²:
If you still want to trigger the movement, you could think of 2 dummy units, set there position randomly and use the "unit comes within range of unit"-event... maybe you get something like this working...
 

Baltazhar

Active Member
Reaction score
55
Okay, thx for the replies everyone. Think I got the matter settled.

I will use wander and let my brain have some time off :D

Everyone has gotten rep, appreciate all the help a lot.

<3 @ thehelper.net

- Balt

EDIT: Okay, I've been testing a bit with the 'wander' ability. When set to 'Foot' movement type, the unit walks for 2 seconds, waits 1 second, and repeats. If the unit is set to 'Fly', it is in constant motion.
Therefore my final result is letting it be a flying unit, giving it locust and wander (think locust does cancel collision completely btw) and having a trigger that sends it to a random point in the region, when it leaves. To contain it, so it doesn't wander away from the playingfield :)

It looks awesome btw, imo at least.
The idea of the ability was to create a marching unit, with ghostly looks. Thereby the name Death March for the ability. It flies around random and deals passive aoe (permanent immo /w changed looks) and every unit that dies in her presence has a 25% chance to become a small ghost that follows her. If there alrdy is someone following her, it just grabs the tail of the unit furthest back in the chain, thus getting an effect like "Worm Wars", the Blizzard map if u ever played that. - Or snake, the old DOS classic. The Death March follower unit deals small AoE dmg as well, just reduced compared to the original Death March unit :)
- Just if u wanted to know what this whole craze about "I WANT IT TO WALK IN LONG STRAIGHT LINES" thing was :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top