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

How to get gold back after finish building a unit?

Status
Not open for further replies.
Level 4
Joined
Mar 20, 2010
Messages
107
Hi!
My question is simple. I got a building that can build a unit of the type structure (A structure building a castle that increases spawns), and it costs 5000 gold to make it. Now I need some kind of trigger that gives me the 5000 gold back when I finish the construction of the unit/structure.

I tried some simple triggering, but unfortunatly without success. I might not be so good with explaining, but if you wonder anything just ask :)

Thanks for your time and patience,
+REP will ofcourse be given to the one that helps me :)
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Is this what you were looking for?
  • FinishConstruction
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Town Hall
    • Actions
      • Player - Add 5000 to (Owner of (Triggering unit)) Current gold
Note that Triggering unit refers to the unit that has finished construction.
 
Level 4
Joined
Mar 20, 2010
Messages
107
I think that was what I tried myself. But, I will try again just incase. Imma newbie so I might have done something different :p

EDIT: It doesnt seem to work. Nothing happens at all really.. :p Btw, the best thing would be if you could make a trigger about the unit thats constructed, and not the structure thats constructing it. If you understand what I mean.. I want to be able to make several different buildings from one main building, all gives different amount of gold back.

Hope its not too much of a problem for you :/
 
Level 4
Joined
Mar 20, 2010
Messages
107
Maybe you used training a unit?
try - Event - unit finished training a unit

the posted trigger should work....

The thing is that the trained unit is not a unit, its a structure. Dont know if it matters.

EDIT: Tried all of the combinations now, none seem to work. I think the problem is that im "training" a unit that is infact a structure. I know tihs is much to ask, but could any of you try it on a new map and post it if possible?
 
Level 4
Joined
Mar 20, 2010
Messages
107
GoblinShoD, tell me what do you want to achieve again. Building a structure has nothing to do with Training a unit. So, you want everytime you build a building to return the gold it costed, when its construction finishes?

Once again you're here to help me :p
To answer your question: Almost. I want that everytime my structure trains a unit of type structure, it returns the gold to me when its construction finishes :p Do you understand what I mean?
I want a castle to train a barrack for 5000 gold, when the construction/training is finished, it should return the 5000 gold again :)
 
The trigger:
  • Melee Initialization
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ((Trained unit) is A structure) Equal to True
    • Actions
      • Animation - Play (Trained unit)'s stand animation
      • Player - Add 5000 to (Owner of (Triggering unit)) Current gold
The map:
View attachment Train Structure.w3x

Forgot to add gold to Player 1 (Red). Use greedisgood to train the Ziggurat.
 
Level 4
Joined
Mar 20, 2010
Messages
107
The trigger:
  • Melee Initialization
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ((Trained unit) is A structure) Equal to True
    • Actions
      • Animation - Play (Trained unit)'s stand animation
      • Player - Add 5000 to (Owner of (Triggering unit)) Current gold
The map:
View attachment 80094

Forgot to add gold to Player 1 (Red). Use greedisgood to train the Ziggurat.

Does that work with different structures aswell? I mean, if I build barrack(1) for 5000 gold, and barrack(2) for 7000 gold? Or cant that trigger see the difference between the structures it is training?
 
This trigger, no, it can't. You need to set array variables for this. Use 2 variables with array, one will be Unit-type and the other Integer. Then:
  • Trigger
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set Units[1] = Barracks (1)
    • Set Units[2] = Barracks (2)
    • Set Units[3] = Apothecary
    • Set GoldCost[1] = 2000
    • Set GoldCost[2] = 5000
    • Set GoldCost[3] = 6500
  • One
  • Events
    • Unit - A unit Finishes training a unit
  • Conditions
    • ((Trained unit) is A structure) Equal to True
  • Actions
    • Animation - Play (Trained unit)'s stand animation
    • For each (Integer A) from 1 to 3, do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Unit-type of (Trained unit)) Equal to Units[(IntegerA)]
          • Then - Actions
            • Player - Add GoldCost[(IntegerA)] to (Owner of (Triggering unit)) Current gold
          • Else - Actions
 
Level 4
Joined
Mar 20, 2010
Messages
107
This trigger, no, it can't. You need to set array variables for this. Use 2 variables with array, one will be Unit-type and the other Integer. Then:
  • Trigger
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set Units[1] = Barracks (1)
    • Set Units[2] = Barracks (2)
    • Set Units[3] = Apothecary
    • Set GoldCost[1] = 2000
    • Set GoldCost[2] = 5000
    • Set GoldCost[3] = 6500
  • One
  • Events
    • Unit - A unit Finishes training a unit
  • Conditions
    • ((Trained unit) is A structure) Equal to True
  • Actions
    • Animation - Play (Trained unit)'s stand animation
    • For each (Integer A) from 1 to 3, do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Unit-type of (Trained unit)) Equal to Units[(IntegerA)]
          • Then - Actions
            • Player - Add GoldCost[(IntegerA)] to (Owner of (Triggering unit)) Current gold
          • Else - Actions

Perfect! And it works like a charm :D Only tried it on one building and with one Player yet, but I daubt I will find any problem with other teams ^^ Once again you do it Pharaoh_! Will +rep you as soon the "you need to spread your reputation"-thing passes :p
 
Status
Not open for further replies.
Top