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

[General] Making a "Gold Producer" Building or Unit

Status
Not open for further replies.
Level 5
Joined
Apr 3, 2015
Messages
104
I Summon you! Oh masters of the editor! to response this simple mortal question!

The title says everything, i want to create a unit or building who gives "X" gold per "X" time.

I would prefer to dont have triggers involved...only if possible
 
Level 15
Joined
Jul 9, 2008
Messages
1,552
im afraid ull have to triggers this it would look somthing like this

  • gold
    • Events
      • Time - Every x seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to GOLD UNIT)) and do (Actions)
        • Loop - Actions
          • Player - Add x to (Owner of (Picked unit)) Current gold
Note: this example leaks a unit group Variable
 
Level 6
Joined
May 20, 2014
Messages
228
And even then that's not really enough, because the trigger will also check any unconstructed gold producers and thus can be 'spammed' with low construction time in that it will count.

The better way would do is to make 3 triggers: one that checks an unit finishing construction, then add it to the group, one that checks if an unit dies and it is that gold producer, then remove the unit from the group. The third would be basically above, but instead counting the amount of gold producers in the group and multiplying that with x.
 
Level 18
Joined
Jun 15, 2012
Messages
498
Using triggers is the easiest and most efficent way in this case (made many tests myself in the past with object editor workarounds)

The triggers Alright suggested are pretty easy and short
 
Level 20
Joined
Feb 23, 2014
Messages
1,264
Perhaps, but it uses a Periodic timer; I was always taught to avoid those like the plague, that they eat up lots of processing power or summat...
I think periodic events are fine if you don't overdo them - i.e. if you have a small number of simpler and non-leaking triggers that run every few seconds, it shouldn't really hurt.

As for the request, I think that triggers are the best way to go.
 
Last edited:

Kyrbi0

Arena Moderator
Level 45
Joined
Jul 29, 2008
Messages
9,502
I think periodic events are fine if you don't overdo them - i.e. if you have a small number of simpler and non-leaking triggers that run every few seconds, it shouldn't really hurt.
Hm. Well that would be wonderful, because I've had loads of ideas involving periodic timers... But the issue is, "how many is a 'small number'?"
 
Level 20
Joined
Feb 23, 2014
Messages
1,264
Well, I'm no expert here, so don't really take my word for it, but I've tried playing with them and I had a couple (3-4) of pretty simple, basic and non-leaking ones that didn't fire that often and I didn't experience any issues whatsoever.

Perhaps you should just go ahead and try? :)
 
Level 4
Joined
Aug 6, 2014
Messages
87
That's the one I use, simple and easy to understand.

Every second ingame it takes the amount of exisitng buidlings/units you want and multiplies it with 2 (2 gold for each unit) and adds it to the player gold.
  • goldmines
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • Player - Add ((Number of living Goldmine units owned by (Picked player)) x 2) to (Picked player) Current gold
 
Level 6
Joined
May 20, 2014
Messages
228
> Every second ingame it takes the amount of exisitng buidlings/units you want and multiplies it with 2 (2 gold for each unit) and adds it to the player gold.

See my post above. It will take unfinished buildings into account which skews the gameplay. You're going to have to get a bit complicated than that.
 

Kyrbi0

Arena Moderator
Level 45
Joined
Jul 29, 2008
Messages
9,502
Well, I'm no expert here, so don't really take my word for it, but I've tried playing with them and I had a couple (3-4) of pretty simple, basic and non-leaking ones that didn't fire that often and I didn't experience any issues whatsoever.

Perhaps you should just go ahead and try? :)

Hm, perhaps. It might be nice... Would solve a lot of problems for me. Though mine would have to be firing relatively often (every ~0.03 sec), to make sure no errors result. (Maybe *that* was my issue...)


That's the one I use, simple and easy to understand.

Every second ingame it takes the amount of exisitng buidlings/units you want and multiplies it with 2 (2 gold for each unit) and adds it to the player gold.
  • goldmines
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • Player - Add ((Number of living Goldmine units owned by (Picked player)) x 2) to (Picked player) Current gold
Not to be pedantic, but doesn't that leak a Player Group?
 
Level 6
Joined
May 20, 2014
Messages
228
> Not to be pedantic, but doesn't that leak a Player Group?

(All players) group doesn't leak. In fact you should never destroy it.
 
Level 4
Joined
Aug 6, 2014
Messages
87
Just make your builder undead then, auto-finishes the building.

Ain't put more effort into this because I'm busy with my own map atm and need it like that, I posted it in here because it took me 10 seconds and thought it might would help.
 
Level 6
Joined
May 20, 2014
Messages
228
> Just make your builder undead then, auto-finishes the building.

That doesn't mean it's not still finished constructing... it just means it doesn't need someone to repair/construct the building as it will build on its own, but it will still count in that trigger since it's not a fully constructed building...

The triggers doesn't even take that much to create either.
 
Level 4
Joined
Aug 6, 2014
Messages
87
I`ve done it like this now, didn't test it ingame yet:
I have a manual unit remove from unit group because I don't know if they remove theirself on death.

Like this it should also be fixed with the "not yet constructed" abuse issue. @Alright
(Took me a while to understand what you mean by that "abuse", but I've watched a vampirism fire video recently where exactly that got abused.)

  • goldmines 1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • Player - Add ((Number of units in Group_Unit_Goldmine_1[(Player number of (Picked player))]) x 2) to (Picked player) Current gold
  • add group gold production 1
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Goldmine
    • Actions
      • Unit Group - Add (Constructed structure) to Group_Unit_Goldmine_1[(Player number of (Owner of (Constructed structure)))]
  • remove group gold production 1
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Goldmine
    • Actions
      • Unit Group - Remove (Dying unit) from Group_Unit_Goldmine_1[(Player number of (Owner of (Dying unit)))]
 
Status
Not open for further replies.
Top