• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! đź“… Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! đź”— Click here to enter!

Squared grid movement - Trigger Editor

Level 3
Joined
Mar 11, 2024
Messages
9
Hello Hiveworkshop community đź‘‹,

I am working on a turn based game on a map with a squared grid 15x15 regions. (225 regions)
The player's character shall enter max. 3 regions in one turn.
I have already created a trigger with 225 events for entering each region:
  • Unit - A unit enters 1 <gen>
...
  • Unit - A unit enters 225 <gen>

I don't know how to continue with this, can you help me out?
After that I would like to add, if the character walks the same regions backwards - he can reset the entered regions.
So he can always choose a new path if necessary.

In short:
max. steps = 3
retrace steps = reset max. steps count

Thanks in advance
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,724
I'm not sure I fully understand but I think this is what you want.

NOTE: These triggers may not even work! This is just an idea to get you started in the right direction.

You can keep track of the unit's previous region in a variable. Then whenever it enters a region you can compare that region with the previous region variable:
  • Events
    • Unit - A unit enters 1 <gen>
  • Conditions
  • Actions
    • Set Variable Unit = (Triggering unit)
    • Set Variable PN = (Player number of (Owner of Unit))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (1 <gen> Equal to Unit_Previous_Region[PN])
      • Then - Actions
        • -------- It entered the previous region --------
      • Else - Actions
        • -------- It entered a new region --------
        • Set Variable Unit_Steps[PN] = (Unit_Steps[PN] - 1)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Unit_Steps[PN] Equal to 0)
          • Then - Actions
            • -------- It ran out of steps --------
            • Unit - Pause Unit
          • Else - Actions
            • -------- It still has one or more steps left --------
  • Events
    • Unit - A unit leaves 1 <gen>
  • Conditions
  • Actions
    • Set Variable Unit = (Triggering unit)
    • Set Variable PN = (Player number of (Owner of Unit))
    • Set Variable Unit_Previous_Region[PN] = 1 <gen>
I assumed that each Player only has 1 character (unit) so I'm using Player Indexing to track the Steps / Regions. Note that I highly recommend using a more advanced system for tracking all of this, you should be able to have one or two triggers work for all 225 regions.

Additionally, you will likely want to "fix" your regions. I show how to do this in my first post in this thread:

Lastly, if you're making a more traditional turn based game then you shouldn't even need regions. Instead, you could break the map up into a grid using some kind of Array/Hashtable data structure and use x/y coordinates to create the grid nodes as well as determine which grid node you're trying to move to. A grid can easily be created with two nested For Loops, one for the X rows and another for the Y columns.
 
Last edited:
Level 3
Joined
Mar 11, 2024
Messages
9
Hey Uncle,

Thank you for the great Help. I just started with the world editor two days ago. Thats why I only understand half of it haha. But I will try to learn everything you explained tomorrow and try to make it work.

Not sure If it is a traditional turn based game. But my Idea is all written down.

I have the map, the UI, the characters already.

Still need abilities, movement system, Action Point system.

So a lot to learn still. :)
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,724
Hey Uncle,

Thank you for the great Help. I just started with the world editor two days ago. Thats why I only understand half of it haha. But I will try to learn everything you explained tomorrow and try to make it work.

Not sure If it is a traditional turn based game. But my Idea is all written down.

I have the map, the UI, the characters already.

Still need abilities, movement system, Action Point system.

So a lot to learn still. :)
I mean traditional like FF Tactics, Fire Emblem, Advance Wars, with a grid that usually has strict orthogonal movement and you only take 1 action at a time and need to wait for that action to complete before moving on to the next action.

Or does it rely on the Warcraft 3 engine where units can move freely but are limited to "steps" which you define based on your own preferences. For example, maybe your unit could position themselves anywhere within a 256x256 sized region, so they aren't locked to the very center of it. Sort of similar to the freedom you get in a game like Worms World Party.

Maybe something in the middle? I don't know, I can only guess based on your limited description.

But I assume you want something traditional, in which case 225 Regions is very unnecessary. Also, a word of warning, if you are unfamiliar with the editor and have little game dev experience then you're going to struggle with a map like this. Not to say it's impossible, but you may end up biting off more than you can currently chew.
 
Last edited:
Level 3
Joined
Mar 11, 2024
Messages
9
Oh okay sure I can give more Information.

At the beginning of the game people choose their character..
The character is being spawned at a random squared region on the map.
The turns are played out simultaneously.

From this point I want them to have 3 Action points each turn they can spend to do something.

the actions are:
move: 1st use = 3 steps / 2nd use = 2 steps / 3rd use = 1 step
explore: interact with neutrals or objects
ability: cast one of your abilities


But for now I want to work on the movement system there.
  • So I figured the first thing I need to implement for it is to have the unit move maximum 3 regions.
  • also that it can walk backwards to define a new path.
  • and that the movement can be re-used by using an action point. What shall result in a penalty though as explained in move (the more action points you use in move the slower you get) .
  • inside one region they can always move freely
Yes perhaps you're right that I could be struggling due to my low game dev experience.
It's more the WorldEditor I struggle with because I don't find exactly what I need.
Since I understand the logic behind it.
Outside of the pc world I create board games and have experience with flow charts though.
I have the time though and no matter what it takes I wanna finish this. And maybe I come back to this map when I have more experience also :).
 
Last edited:

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,724
Okay, so it's not very traditional and relies on standard Warcraft 3 mechanics as part of it's gameplay. It sounds interesting.

If I understand everything correctly:

1) You move freely using the standard Warcraft 3 move ability -> Press M or Right click the ground or a target unit to move there. It's when you enter a Region (that you weren't previously on) that it consumes a Step.

2) Some special Regions don't consume a Step when entered.
inside one region they can always move freely

3) Each player controls a single character (a Hero I assume) and can move around and act freely, assuming that they have enough Actions/Steps to do so.

4) The exact moment a unit enters a new Region and uses it's last Step it stops moving. Even if it's on the edge of the Region (I don't see it working otherwise). Then their movement is impaired using some kind of mechanic like Ensnare, which would be removed if they spend an available Action to "Move" again.

5) The character's Move action is an instant ability requiring no target. All it does is add/refresh Steps (3 -> 2 -> 1). The character's Explore action is a unit-targeted ability with melee cast range or perhaps max cast range but requires you to be in the same Region as the target. The character's Ability action let's you cast a spell like Chain Lightning or Storm Bolt. I assume Summon abilities are off limits for now since those complicate things.

6) A turn ends when all character's have used their End Turn ability. That or after some time limit to prevent AFKers from spoiling the game, whichever comes first.

Oh and are you on the latest patch of Warcraft 3? (1.36)
 
Last edited:
Level 3
Joined
Mar 11, 2024
Messages
9
YES! you understand everything correctly. Thats about the idea. My game is up to date, I guess its the latest patch right.

Maybe I have 2 summon abilites planned but the concepts of the Heroes need review anyways.
One hero can send out a ghost for a few steps and if it finds a Hero in the same Region I want it to steal an Item.
And the other sommon ability is a landmine which is placed on a region and triggers death when a hero enters it.
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,724
YES! you understand everything correctly. Thats about the idea. My game is up to date, I guess its the latest patch right.

Maybe I have 2 summon abilites planned but the concepts of the Heroes need review anyways.
One hero can send out a ghost for a few steps and if it finds a Hero in the same Region I want it to steal an Item.
And the other sommon ability is a landmine which is placed on a region and triggers death when a hero enters it.
Here's an example map that showcases how you can setup your Grid and manage the "Step" movement. Hopefully this will help you get on the right track.

I'm using a lot of advanced techniques like Unit Indexing, nested For Loops to quickly determine which Region you've entered, and Jass code (see GridSetupHelper) to easily setup the different Region variables.

It'd be insane to have 225 Triggers (one for each Grid Region) in order to manage the different Region events. So I went with a different solution that relies on For Loops and the "Region contains Point" condition. That's where the complicated nested For Loop stuff comes to play, which would not even be necessary if Blizzard gave us a simple "Entered region" Event Response but unfortunately one does not exist.

Anyway, what I do is sample each Region in the map and check if your entering unit is inside of it. This would be very inefficient with 225 Grid Regions so I introduced new "Row Regions" to help reduce the complexity. The idea is that you have 15 Row Regions that each cover their own 15 Grid Regions. If a unit is in Row1 then we know that we only have to check Grid Regions 1 to 15 in our For Loop to determine where it is. Row2 covers regions 16 to 30, Row3 covers 31 - 45, and the pattern continues. In the best case scenario it'll only have to check 2 Regions and worst case it'll have to check 24 Regions. That's a big improvement over always checking all 225 Grid Regions every single time.
 

Attachments

  • Region_Grid_1.w3m
    29.5 KB · Views: 5
Last edited:
Level 3
Joined
Mar 11, 2024
Messages
9
wow big help! I am very grateful for this.
I had a quick look into it and it works exactly as needed.

Moving between region 1 and 2 resets the steps but moving between 2 and 3 does not.
But thats something I believe I can figure out myself :)

I think I'll have to learn some advanced techniques also before I continue with my game.
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,724
wow big help! I am very grateful for this.
I had a quick look into it and it works exactly as needed.

Moving between region 1 and 2 resets the steps but moving between 2 and 3 does not.
But thats something I believe I can figure out myself :)

I think I'll have to learn some advanced techniques also before I continue with my game.
The Steps will never reset unless you type "r" in the chat. Perhaps you're misunderstanding how it's designed or don't understand the Text Messages. The Step count is displayed as "Steps #", the other text messages refer to the index of the Region you entered (1 through 9).

Also, a Step won't be spent if you move to your previous region, but it's currently only setup to remember one previous region at a time. I'd have to introduce a Hashtable and add some extra Actions/Conditions to remember all of the Regions you've passed through so far.
 
Last edited:
Top