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

Unit enters ANY region event

Status
Not open for further replies.

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
It would not make much sense, since every region includes the region "entire map" which then again includes every region you could possibly make.
You are probably only talking about regions you made yourself. You need to add an enter region event for all these regions. They are global variables, but are not in an array, which makes it hard to add an event for all of them.

There is probably not an automatic way of doing so. If you have only very few regions, you can add them to an array by yourself or just create the events manually.
If you have a lot of regions, this would take too long. If that is the case you can open the map script, extract all variable names of the regions and use a text editor with search & replace functions to add all of them to an array.
 
Can I ask what exactly this is for?
You might have an advantaged from using an jass only feature (useable with custom script and an hash) called Region, the regions placed in world Editor are actually rects.
An Region is kind of an rectGroup and can be used as enter/leaves event.

An example

  • Initialisierung Preplaced Rects
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Create the region --------
      • Custom script: local region RectGroup = CreateRegion()
      • -------- Add the preplaced Rects to the region --------
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_000)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_001)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_002)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_003)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_004)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_005)
      • -------- Register the Region as event --------
      • Custom script: call TriggerRegisterEnterRegionSimple (gg_trg_Enters_Grass, RectGroup)
      • -------- Register the Region as event --------
      • Custom script: call TriggerRegisterLeaveRegionSimple (gg_trg_Leaves_Grass, RectGroup)
      • -------- you can skip the hash stuff, if you only want leave/enter events --------
      • -------- Create the hash --------
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
      • -------- Save the Region in the hash (in this case it would be unneeded, if you want an isInRegion your need the region save) --------
      • Custom script: call SaveRegionHandle(udg_Hash,0,0, RectGroup)
      • -------- Hero is only needed for the demo --------
      • Set Hero = Paladin 0000 <gen>
      • -------- clean the reference --------
      • Custom script: set RectGroup = null
  • Enters Grass
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Name of the current trigger)
  • Leaves Grass
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Name of the current trigger)
  • Paladin is On Grass
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local region RectGroup = LoadRegionHandle(udg_Hash,0,0)
      • Custom script: if IsUnitInRegion (RectGroup, udg_Hero) then
      • Game - Display to (All players) for 5.00 seconds the text: Hero stands on Grass
      • Custom script: endif
      • Custom script: set RectGroup = null


If this is about places with an specific terrain you can automize the rect adding.
 

Attachments

  • Region Multiple Rects as one.w3x
    18.2 KB · Views: 43
Level 21
Joined
Apr 8, 2017
Messages
1,530
Can I ask what exactly this is for?
You might have an advantaged from using an jass only feature (useable with custom script and an hash) called Region, the regions placed in world Editor are actually rects.
An Region is kind of an rectGroup and can be used as enter/leaves event.

An example

  • Initialisierung Preplaced Rects
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Create the region --------
      • Custom script: local region RectGroup = CreateRegion()
      • -------- Add the preplaced Rects to the region --------
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_000)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_001)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_002)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_003)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_004)
      • Custom script: call RegionAddRect (RectGroup, gg_rct_Gebiet_005)
      • -------- Register the Region as event --------
      • Custom script: call TriggerRegisterEnterRegionSimple (gg_trg_Enters_Grass, RectGroup)
      • -------- Register the Region as event --------
      • Custom script: call TriggerRegisterLeaveRegionSimple (gg_trg_Leaves_Grass, RectGroup)
      • -------- you can skip the hash stuff, if you only want leave/enter events --------
      • -------- Create the hash --------
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
      • -------- Save the Region in the hash (in this case it would be unneeded, if you want an isInRegion your need the region save) --------
      • Custom script: call SaveRegionHandle(udg_Hash,0,0, RectGroup)
      • -------- Hero is only needed for the demo --------
      • Set Hero = Paladin 0000 <gen>
      • -------- clean the reference --------
      • Custom script: set RectGroup = null
  • Enters Grass
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Name of the current trigger)
  • Leaves Grass
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Name of the current trigger)
  • Paladin is On Grass
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local region RectGroup = LoadRegionHandle(udg_Hash,0,0)
      • Custom script: if IsUnitInRegion (RectGroup, udg_Hero) then
      • Game - Display to (All players) for 5.00 seconds the text: Hero stands on Grass
      • Custom script: endif
      • Custom script: set RectGroup = null


If this is about places with an specific terrain you can automize the rect adding.
Sorry but i think adding all regions to same event is easier cuz these triggers does not work with each region :(, in case adding they its impossible cuz they are more than 100 regions. :(x10
 
Status
Not open for further replies.
Top