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

gold income trigger

Status
Not open for further replies.
Level 3
Joined
Feb 28, 2009
Messages
31
hello i think this won't be hard question for any of you: atm i am making a map and when you destroy a building you get the same building at the same place but it belongs to you ( like you actually captured it ) i want to create a trigger that after you capture that building every second you get 1 gold. i tried with something like this but it doesn't work
dmtjjm.jpg
the problem is that in condition i selected a building that is on the map but during the gameplay i destroy it and that's why i don't get gold (building's name is brankovina)
 
Level 15
Joined
Oct 18, 2008
Messages
1,588
it should look like
  • Brankovina prihodi
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of Brankovina 0006 <gen>) Equal to (Player((Integer A)))
            • Then - Actions
              • Player - Add 1 to (Player((Integer A))) Current gold
            • Else - Actions
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Nope, it should be correct, but you don't need the loop if there's only one building.

You can just use Player - Add 1 to (Owner of Brankovina 0006 <gen>) Current gold.
The trigger will be much shorter to achieve the exact same goal (--> efficient).

(About the trigger failure, that's probably your fault: are you sure you did the exact same thing as kanadaj?)


Edit: Wait, I already figured out the problem.
You destroyed the building and created a new one, right?

Use variables.
Create a unit variable called "Brankovina" (or whatever) and every time you create the new tower, set the variable to last created unit.
Then, add 1 gold to the owner of Brankovina.

You're trying to give gold to someone who owns a building that doesn't exist anymore.
Sine nobody owns a tower that doesn't exist, nobody gets gold.
However, if you assign a variable to the new tower and give gold to the player who owns the building in that variable, he will get gold.

  • Gold Income
    • Events
      • Time - every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player - Add 1 to (Owner of Brankovina) Current gold
Don't forget to assign the variable to the newly created tower!

I really hope you understand variables, as you cannot make maps without them.


Another method, which is even more efficient, requires an integer variable instead of a unit variable.
If a player destroys the tower, set the variable to the player who destroyed it and give gold to the player with that player number.
It's easier for warcraft, although it doesn't matter that much.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Could you perhaps post whatever you tried here? (The trigger where the building dies and the trigger which gives gold)

By the way: above "events" you see the trigger name, right-click that and select "copy as text".
Write "[trigger][/trigger]" on the hive and then press ctrl + V in between the two tags.
You have now succesfully pasted a trigger on the hive (a lot easier for both you and us).
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Or instead of destroying the building, stop it at 1 hp and change ownership and heal it. And there you go, no need for variables because the building is always the same <gen>
Stopping at 1HP isn't the best idea: most units have over 1 damage, if the tower has 20HP left and is hit for 50 damage, it will be destroyed, forever.

Of course, says the smarter guy, but what if you change it at 51HP?
Well, how far can you push the boundaries with damage? How much damage can a unit in your map do?

And even if you have a set amount, let's say a unit can maximally damage the tower for 15% of its health, it would be completely unrealistic as the tower's ownership gets changed at anything below 15% (early in-game, you probably hit the tower for 1-2% damage and the tower doesn't even look destroyed when it's already yours).

Or you could create a dynamical HP-range, early in the game it will change ownership at 3% but later on it will change ownership at 18%, but... really, that requires a lot more work than just replacing the unit and assigning a variable.
 
Status
Not open for further replies.
Top