Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

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

Discussion in 'World Editor Help Zone' started by DragunovCh, Jun 17, 2016.

  1. DragunovCh

    DragunovCh

    Joined:
    Apr 3, 2015
    Messages:
    94
    Resources:
    0
    Resources:
    0
    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
     
  2. millzy

    millzy

    Joined:
    Jul 9, 2008
    Messages:
    1,540
    Resources:
    6
    Maps:
    5
    Spells:
    1
    Resources:
    6
    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
     
  3. Alright

    Alright

    Joined:
    May 20, 2014
    Messages:
    230
    Resources:
    0
    Resources:
    0
    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.
     
  4. Kyrbi0

    Kyrbi0

    Joined:
    Jul 29, 2008
    Messages:
    8,419
    Resources:
    2
    Models:
    1
    Maps:
    1
    Resources:
    2
    Isn't there an ability that can do this? "Haunted Gold Mine" or "Entangled Gold Mine" or something?
     
  5. Arrr

    Arrr

    Joined:
    Jun 15, 2012
    Messages:
    430
    Resources:
    20
    Maps:
    20
    Resources:
    20
    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
     
  6. Kyrbi0

    Kyrbi0

    Joined:
    Jul 29, 2008
    Messages:
    8,419
    Resources:
    2
    Models:
    1
    Maps:
    1
    Resources:
    2
    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...
     
  7. MasterBlaster

    MasterBlaster

    Joined:
    Feb 23, 2014
    Messages:
    1,039
    Resources:
    0
    Resources:
    0
    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: Jun 18, 2016
  8. Kyrbi0

    Kyrbi0

    Joined:
    Jul 29, 2008
    Messages:
    8,419
    Resources:
    2
    Models:
    1
    Maps:
    1
    Resources:
    2
    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'?"
     
  9. MasterBlaster

    MasterBlaster

    Joined:
    Feb 23, 2014
    Messages:
    1,039
    Resources:
    0
    Resources:
    0
    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? :)
     
  10. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    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
     
  11. Alright

    Alright

    Joined:
    May 20, 2014
    Messages:
    230
    Resources:
    0
    Resources:
    0
    > 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.
     
  12. Kyrbi0

    Kyrbi0

    Joined:
    Jul 29, 2008
    Messages:
    8,419
    Resources:
    2
    Models:
    1
    Maps:
    1
    Resources:
    2
    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...)


    Not to be pedantic, but doesn't that leak a Player Group?
     
  13. Alright

    Alright

    Joined:
    May 20, 2014
    Messages:
    230
    Resources:
    0
    Resources:
    0
    > 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.
     
  14. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    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.
     
  15. Alright

    Alright

    Joined:
    May 20, 2014
    Messages:
    230
    Resources:
    0
    Resources:
    0
    > 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.
     
  16. DragunovCh

    DragunovCh

    Joined:
    Apr 3, 2015
    Messages:
    94
    Resources:
    0
    Resources:
    0
    Thanks for the replies :D It's already done and well working
     
  17. The_Silent

    The_Silent

    Joined:
    Feb 4, 2008
    Messages:
    3,048
    Resources:
    164
    Models:
    53
    Icons:
    90
    Packs:
    8
    Skins:
    12
    Maps:
    1
    Resources:
    164
    Don't ever pick every unit in a the map. Just create a unit group of the buildings that produce gold, and add them to it whenever they finish construction.
     
  18. Freyky

    Freyky

    Joined:
    Aug 6, 2014
    Messages:
    87
    Resources:
    0
    Resources:
    0
    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)))]