• 🏆 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!

Dynamic Region Trigger

Status
Not open for further replies.
Level 14
Joined
Dec 29, 2009
Messages
931
Hey, so I have this part of a trigger I'm using. Loads on map initialization. I don't think this is the problem though.

  • For each (Integer A) from 0 to 23, do (Actions)
    • Loop - Actions
      • Set tempLoc = (Center of heroSelectionRegion[(Integer A)])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Integer A) Greater than or equal to 0) and ((Integer A) Less than or equal to 5)
        • Then - Actions
          • Unit - Create 1 heroSelectionType[(Integer A)] for Neutral Passive at tempLoc facing 270.00 degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Integer A) Greater than or equal to 6) and ((Integer A) Less than or equal to 8)
        • Then - Actions
          • Unit - Create 1 heroSelectionType[(Integer A)] for Neutral Passive at tempLoc facing 180.00 degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Integer A) Greater than or equal to 9) and ((Integer A) Less than or equal to 14)
        • Then - Actions
          • Unit - Create 1 heroSelectionType[(Integer A)] for Neutral Passive at tempLoc facing 270.00 degrees
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Integer A) Greater than or equal to 15) and ((Integer A) Less than or equal to 17)
        • Then - Actions
          • Unit - Create 1 heroSelectionType[(Integer A)] for Neutral Passive at tempLoc facing 270.00 degrees
        • Else - Actions
      • Custom script: call RemoveLocation( udg_tempLoc )
      • Trigger - Add to Selection <gen> the event (Unit - A unit enters heroSelectionRegion[(Integer A)])
This however, is a problem.

  • Selection
    • Events
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Soul
    • Actions
      • For each (Integer A) from 0 to 23, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (heroSelectionRegion[(Integer A)] contains (Triggering unit)) Equal to True
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 1.00 seconds the text: ((Soul owned by + ((Name of (Owner of (Triggering unit))) + is located in region )) + ((String((Integer A))) + .))
            • Else - Actions
Obviously this is just something I made to test, but you get the idea. Basically, instead of making 24 different triggers for creating each hero I want to create one and use if/then/else to check and see which hero it is.
The heroes are chosen by moving the "Soul" into a circle of power.

To summarize, I need to be able to check to see which region is being entered. WE doesn't feature a generic "region-entered" event, nor the condition to determine if the region-entered is equal to a specific region.

What I have currently will *sometimes* display the text. I don't quite understand why.

Advice appreciated. Thanks in advance. :)
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
In the Selection trigger, you don't have any event.

WE doesn't feature a generic "region-entered" event
  • Unit - A unit enters (your region)
You need to have 24 events there ;)

Another way is by periodically checking whether each region is empty or not using this event:
  • trig
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (your region)) and do (Actions)
        • Loop - Actions
If a valid unit has detected (Soul), remove that unit and create the hero for owner of (Picked Unit), in your case:
  • trig
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 23, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in region[(Integer A)] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to Soul
                • Then - Actions
                  • Unit - Remove (Picked unit) from the game
                  • Unit - Create 1 HeroType[Integer A] for (Owner of (Picked unit)) at (somewhere) facing Default building facing degrees
                • Else - Actions
 
Level 14
Joined
Dec 29, 2009
Messages
931
I don't need an event, I use this for my initialization triggers.
  • Initialize
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Trigger - Run Players Init <gen> (ignoring conditions)
      • Trigger - Run Units Init <gen> (ignoring conditions)
      • Trigger - Run HeroSelection Init <gen> (ignoring conditions)
      • Trigger - Run Visibility Init <gen> (ignoring conditions)
I also only posted a portion of the trigger for initializing the Hero Selection system, the rest of it doesn't really apply to the issue.
I assure you, the event for entering the region is added to the trigger.

The If/Then/Else there is referring to the regionId's I have.
eb6eVq0.jpg

In the picture above, I show you the regions, each of which is initialized into a region array which is referenced in the loop for creating the heroes.

EDIT: Well you edited your post so now nothing that I just said applies.
In the Selection trigger, you don't have any event.

There are 24 events there, they are simply loaded when the HeroSelection Init trigger runs.
This way I didn't have to copy and paste them all and change it 24 times.. It simply uses a loop to add them all automatically.

EDIT2: You edited your post again.

If I end up having to use a periodic event, I would rather make seperate triggers for each region. I would rather keep the lag to a minimum.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
The problem is that when "Unit enters a region" triggers, then "A unit is in region" check can fail. I believe the first one uses collision size and the second one the center of the unit. Or something like that.

You can use a system, look here: http://www.hiveworkshop.com/forums/triggers-scripts-269/just-am-very-simple-region-trigger-232027/

You can save the integer
  • Custom script: call SaveInteger(udg_RectHash , GetHandleId(r), 0, bj_forLoopAIndex)
And load it
  • Custom script: set udg_Int = LoadInteger(udg_RectHash , GetHandleId(GetTriggeringRegion()) , 0)
 
Status
Not open for further replies.
Top