• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Managing Regions - Advice / Alternatives

Level 4
Joined
Jul 27, 2015
Messages
33
Hi everyone,

The map I'm developing has a dungeon in it. By 'dungeon' really I just mean an area that a number of players can try to fight their way through, and if they fail it 'resets' itself and they can try again.

I'm achieving this by placing a bunch of regions as the locations for where the various enemies or traps will be placed when the dungeon is populated.

So far I've placed 28 regions for what I consider a relatively small one and I'm quickly becoming nervous that this will become and unmanageable huge list of regions I have to scroll through when setting up triggers and such (or perhaps I even hit some kind of region limit!) In the region editor itself, it's already quite cumbersome.

So my question is really two questions:

a. Does anyone have any advice or tips on managing regions within the editor. Perhaps there are even tools or plugins that let you create a hierarchy, I don't know something to make them more than just a big list of words.

b. Is my methodology flawed to begin with? Are there cleaner or cleverer ways to achieve what I'm aiming for here? I'm open to learning to use bits of LUA in the editor, though I find that really hard because it's just a plain text file and when scripting I'm used to the computer... helping me a bit lol

Thanks for your time, hope someone more experienced can help guide me a little. :grin:
 
Level 30
Joined
Sep 26, 2009
Messages
2,617
Simply put, what you want is a respawn system.
Complexity of such system can vary from map to map (for example: are traps units or destructibles, how much logic/triggers are tied to creeps in the dungeon, etc.)

A very basic solution would be to have a single regions that encompasses the entire dungeon (and only the dungeon). It's possible with more regions as well, just a bit more complex. Then a bunch of array variables to keep track of respawnable creeps: units array, unit-type array, point array and real array for angle + a non-array integer variable to store number of tracked creeps. With that information you can move units back to their spawn points or create fresh units at that spawn point.
At map initialization you would just pick all units in the dungeon region and track each unit:
  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in DungeonRegion <gen> owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set VariableSet DungeonCreep_Index = (DungeonCreep_Index + 1)
          • Set VariableSet DungeonCreep_Units[DungeonCreep_Index] = (Picked unit)
          • Set VariableSet DungeonCreep_UnitTypes[DungeonCreep_Index] = (Unit-type of (Picked unit))
          • Set VariableSet DungeonCreep_Angles[DungeonCreep_Index] = (Facing of (Picked unit))
          • Set VariableSet DungeonCreep_Points[DungeonCreep_Index] = (Position of (Picked unit))
The above assumes that dungeon creeps are owned by Neutral Hostile.
Then you will need some trigger to reset/respawn creeps:
  • Reset Dungeon
    • Actions
      • For each (Integer loopIdx) from 1 to DungeonCreep_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • DungeonCreep_Units[loopIdx] Equal to No unit
                  • (DungeonCreep_Units[loopIdx] is dead) Equal to True
                  • (Owner of DungeonCreep_Units[loopIdx]) Not equal to Neutral Hostile
            • Then - Actions
              • -------- Creep was killed and/or possibly completely decayed or charmed/revived by player, so new creep will be created --------
              • Unit - Create 1 DungeonCreep_UnitTypes[loopIdx] for Neutral Hostile at DungeonCreep_Points[loopIdx] facing DungeonCreep_Angles[loopIdx] degrees
              • Set VariableSet DungeonCreep_Units[loopIdx] = (Last created unit)
            • Else - Actions
              • -------- Creep is alive, possibly hurt and not at its original location, so we just reset it --------
              • Unit - Move DungeonCreep_Units[loopIdx] instantly to DungeonCreep_Points[loopIdx], facing DungeonCreep_Angles[loopIdx] degrees
              • Unit - Set life of DungeonCreep_Units[loopIdx] to 100.00%
              • Unit - Set mana of DungeonCreep_Units[loopIdx] to 100.00%
              • Unit - Reset ability cooldowns for DungeonCreep_Units[loopIdx].
It will iterate over each creep that we've tracked at map initialization and checks if that creep is alive/exists and belongs to Neutral Hostile. If yes, it just moves the creep back at the position it had during map initialization; if not, it will create a new creep where the original one was during map initialization.

When you run the reset trigger is up to you, so I have not included any trigger events/conditions
 
Level 4
Joined
Jul 27, 2015
Messages
33
Wow thank you, this is exactly what I was hoping for really - someone just thinking about the problem differently.

I'll give this approach a go tonight. My dungeon doesn't cleanly fit into one region so I'm just going to do a loop for each region one after the other I think that ought to work.

I've read before that it's important to destroy locations once you're done using them to prevent memory leaks and I think that created a bit of a blind spot that I could just have an array of locations for where they respawn - I presume they don't actually take up that much memory, it's just that leaked locations add up fast?

Will update tonight anyway.
 
Level 30
Joined
Sep 26, 2009
Messages
2,617
I've read before that it's important to destroy locations once you're done using them to prevent memory leaks and I think that created a bit of a blind spot that I could just have an array of locations for where they respawn - I presume they don't actually take up that much memory, it's just that leaked locations add up fast?
Yes. The key difference here is that you are not done with those locations, since you are re-using them to respawn creeps, so there's no reason to destroy them.
As long as you can reference the object (location in this case) and you have use for it, then it is not a memory leak. You could clear all those locations if you get to a point where creeps in that dungeon would no longer respawn (i.e. dungeon was completely cleared and you will never ever want to reset it after in that gameplay).
Even if you do not clear it, I don't think it would be much of an issue. I assume your dungeon has a max of 100 respawnable creeps? Each location does not take that much memory, so having 100 memory leaks is not an issue.
What would be an issue would be to have a trigger that runs every 0.03 seconds and creates a bunch of locations and not cleaning them up - those would pile up in the memory and later on would start affecting performance.
 
Top