• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[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 28
Joined
Nov 18, 2012
Messages
2,007
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