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

[Solved] When unit enters in a region, remove that unit and add +1 to a counter

Status
Not open for further replies.

Eae

Eae

Level 1
Joined
Jan 31, 2022
Messages
3
Hi! This is my first post here. I think this is a very simple question, but I can't manage to solve it by myself.
I just want to create a little thing (maybe a counter? A multiboard? I don't know the correct name), a little window in the upside of the screen, that says 'Units passed' and '0'. Then, when a unit enters in a region, I want to remove that triggering unit and add a '+1' at that '0' value, making it a '1'. When another unit enters in the same region, it has to become '2', then '3', et cetera.

Now, I know how to set a region and how to create a trigger that remove a unit that enters in that region. But I don't know how to create that simple counter, if that is its name.

Pratically, I wish to create a map in which you have to move civilians to safe places, where they can run to the main city and be safe. But I don't know how to keep the number of civilians saved!
This mechanic could be used even in a map in which you have to defend a mountain pass from invaders, and enemy units that reach a specific zone vanish and become a +1 on that counter.
I hope I've explained myself and I thank you all for help!
 
Last edited:

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,890
You need to create an integer variable, the yellow-orangish X on top of the screen in trigger editor.
Name it whatever.
Afterwards you simply create an action "set variable", use the variable name, and use a function called Arithmetic, there you can make the most basic operations.
 
  • Like
Reactions: Eae

Eae

Eae

Level 1
Joined
Jan 31, 2022
Messages
3
Thank you very much! It works! I've created an integer variable (''Counter'') and then I've made this simple trigger:

Event - Unit - A unit enters '(Region X)'
Action - Unit - Remove (triggering unit) from the game
Action - Set Variable - Set Counter = (Counter + 1)

I know that it works because I've also created a test trigger to check:

Event - Player - Player 1 (Red) types a chat message containing 'Test' as An exact match
Action - Unit - Create Counter Peasant for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees

And it works. It creates a number of peasants equal to the value of 'Counter', just to check. I know that it's a trifle for you, but it means a lot for me. Thank you again! Now I only have to figure out how to create the window that shows that value! =D
How can I reward you for your answer? Just by push the 'Like' button?
 

Eae

Eae

Level 1
Joined
Jan 31, 2022
Messages
3
And done! I've just managed to create a leaderboard studying the tft undead campaign first mission and a very useful tutorial here on Hiveworkshop (this one: Leaderboards ). My mistake was running the trigger from another trigger, and not by a game-time timer event... Thank you again! =)
 
Status
Not open for further replies.
Top