• 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.

Simple Resource Generator System v1.2 [GUI]

  • Like
Reactions: tayfinch and Kam
- This system will allow your building to auto generate resource.
- You can adjust the income and the interval between receiving income.
- It is GUI-friendly :)


External Instructions
- Open World Editor - File - Preferences... - General Tab - Tick the Automatically create unknown variables while pasting trigger data
- Copy the Simple Resource Generator System folder.
- Further instructions inside the RG Setup Trigger.

Internal Instructions
There are 4 types of configurables;
RG_Building - Which building you want ?
RG_Income - What amount of income do you want from the building ?
RG_DurationInterval - What is the interval in-between receiving income from the building ?
RG_ResourceType - What kind of resource do you want that building to supply ?
- ResourceTypeFood
- ResourceTypeLumber
- ResourceTypeGold


  • RG Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_RG_Hashtable = InitHashtable()
      • -------- Do not touch this if you don't know what you are doing --------
      • Set RG_ResourceTypeFood = 1
      • Set RG_ResourceTypeLumber = 2
      • Set RG_ResourceTypeGold = 3
      • Set RG_MaxResource = 3
      • -------- RG_Building sets the building you want data to be saved --------
      • -------- RG_Income sets the value per interval for that building type --------
      • -------- RG_DurationInterval sets the interval per income --------
      • -------- RG_ResourceType sets what kind of Resource is available for that building --------
      • -------- You can choose between: --------
      • -------- 1. ResourceTypeFood --------
      • -------- 2. ResourceTypeLumber --------
      • -------- 3. ResourceTypeGold --------
      • -------- DATA CONFIGURABLES --------
      • Set RG_Building = Meathouse
      • Set RG_Income = 2
      • Set RG_DurationInterval = 2.00
      • Set RG_ResourceType = RG_ResourceTypeFood
      • Trigger - Run RG Save <gen> (ignoring conditions)
      • -------- 2ND BUILDING --------
      • Set RG_Building = Lumber Mill
      • Set RG_Income = 10
      • Set RG_DurationInterval = 10.00
      • Set RG_ResourceType = RG_ResourceTypeLumber
      • Trigger - Run RG Save <gen> (ignoring conditions)
      • -------- 3RD BUILDING --------
      • Set RG_Building = Marketplace
      • Set RG_Income = 20
      • Set RG_DurationInterval = 5.00
      • Set RG_ResourceType = RG_ResourceTypeGold
      • Trigger - Run RG Save <gen> (ignoring conditions)
      • -------- END OF CONFIGURABLES --------
      • -------- ---------- --------
      • -------- CONSTANTS CONFIGURABLES --------
      • Set RG_Triggers[1] = RG Food <gen>
      • Set ResourceColor[1] = |CFFFF0000
      • Set RG_Triggers[2] = RG Lumber <gen>
      • Set ResourceColor[2] = |CFF00FF00
      • Set RG_Triggers[3] = RG Gold <gen>
      • Set ResourceColor[3] = |CFFFFD700
      • -------- ---------- --------
      • -------- FLOATING TEXT CONFIGURABLES --------
      • -------- RG_FloatingTextSpeed sets the speed of the Floating Text to move out of the building --------
      • -------- RG_FloatingTextLifeSpan sets the duration of Floating Text --------
      • -------- RG_FloatingTextFadeTime sets the duration of fading time for the Floating Text - it is suggested that this value should be the half of RG_FloatingTextLifeSpan --------
      • -------- ---------- --------
      • Set RG_FloatingTextSpeed = 64.00
      • Set RG_FloatingTextLifeSpan = 5.00
      • Set RG_FloatingTextFadeTime = 2.50
      • -------- END OF CONFIGURABLES --------
      • Set RG_Interval = 0.03
      • Trigger - Add to RG Loop <gen> the event (Time - Every RG_Interval seconds of game time)
  • RG Save
    • Events
    • Conditions
    • Actions
      • Set RG_BooleanResourceBuilding = True
      • Custom script: set udg_RG_Key = udg_RG_Building
      • Hashtable - Save RG_Income as 0 of RG_Key in RG_Hashtable
      • Hashtable - Save RG_DurationInterval as 1 of RG_Key in RG_Hashtable
      • Hashtable - Save RG_ResourceType as 2 of RG_Key in RG_Hashtable
      • Hashtable - Save RG_BooleanResourceBuilding as 3 of RG_Key in RG_Hashtable
  • RG Event
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempUnitType = (Unit-type of TempUnit)
      • Custom script: set udg_RG_Key = udg_TempUnitType
      • Set RG_BooleanResourceBuilding = (Load 3 of RG_Key from RG_Hashtable)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RG_BooleanResourceBuilding Equal to True
        • Then - Actions
          • Unit Group - Add TempUnit to RG_Group
          • Set RG_DurationInterval = (Load 1 of RG_Key from RG_Hashtable)
          • Custom script: set udg_RG_Key = GetHandleId(udg_TempUnit)
          • Hashtable - Save RG_DurationInterval as 1 of RG_Key in RG_Hashtable
          • Trigger - Turn on RG Loop <gen>
        • Else - Actions
  • RG Loop
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (RG_Group is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit Group - Pick every unit in RG_Group and do (Actions)
            • Loop - Actions
              • Set TempUnit = (Picked unit)
              • Custom script: set udg_RG_Key = GetHandleId(udg_TempUnit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempUnit is alive) Equal to True
                • Then - Actions
                  • Set RG_DurationInterval = (Load 1 of RG_Key from RG_Hashtable)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • RG_DurationInterval Greater than 0.00
                    • Then - Actions
                      • Hashtable - Save (RG_DurationInterval - RG_Interval) as 1 of RG_Key in RG_Hashtable
                    • Else - Actions
                      • Set TempUnitType = (Unit-type of TempUnit)
                      • Custom script: set udg_RG_Key = udg_TempUnitType
                      • Set RG_DurationInterval = (Load 1 of RG_Key from RG_Hashtable)
                      • Set RG_ResourceType = (Load 2 of RG_Key from RG_Hashtable)
                      • Set RG_Income = (Load 0 of RG_Key from RG_Hashtable)
                      • Custom script: set udg_RG_Key = GetHandleId(udg_TempUnit)
                      • Hashtable - Save RG_DurationInterval as 1 of RG_Key in RG_Hashtable
                      • Trigger - Run RG_Triggers[RG_ResourceType] (ignoring conditions)
                • Else - Actions
                  • Unit Group - Remove TempUnit from RG_Group
                  • Hashtable - Clear all child hashtables of child RG_Key in RG_Hashtable
  • RG Food
    • Events
    • Conditions
    • Actions
      • Set TempPlayerGroup = (Player group((Owner of TempUnit)))
      • Player - Add RG_Income to (Owner of TempUnit) Food cap
      • Floating Text - Create floating text that reads (ResourceColor[1] + ((String(RG_Income)) + |r)) above TempUnit with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Set TempFloatingText = (Last created floating text)
      • Floating Text - Hide TempFloatingText for (All players)
      • Floating Text - Show TempFloatingText for TempPlayerGroup
      • Floating Text - Set the velocity of TempFloatingText to RG_FloatingTextSpeed towards 90.00 degrees
      • Floating Text - Change TempFloatingText: Disable permanence
      • Floating Text - Change the lifespan of TempFloatingText to RG_FloatingTextLifeSpan seconds
      • Floating Text - Change the fading age of TempFloatingText to RG_FloatingTextFadeTime seconds
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
  • RG Lumber
    • Events
    • Conditions
    • Actions
      • Set TempPlayerGroup = (Player group((Owner of TempUnit)))
      • Player - Add RG_Income to (Owner of TempUnit) Current lumber
      • Floating Text - Create floating text that reads (ResourceColor[2] + ((String(RG_Income)) + |r)) above TempUnit with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Set TempFloatingText = (Last created floating text)
      • Floating Text - Hide TempFloatingText for (All players)
      • Floating Text - Show TempFloatingText for TempPlayerGroup
      • Floating Text - Set the velocity of TempFloatingText to RG_FloatingTextSpeed towards 90.00 degrees
      • Floating Text - Change TempFloatingText: Disable permanence
      • Floating Text - Change the lifespan of TempFloatingText to RG_FloatingTextLifeSpan seconds
      • Floating Text - Change the fading age of TempFloatingText to RG_FloatingTextFadeTime seconds
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
  • RG Gold
    • Events
    • Conditions
    • Actions
      • Set TempPlayerGroup = (Player group((Owner of TempUnit)))
      • Player - Add RG_Income to (Owner of TempUnit) Current gold
      • Floating Text - Create floating text that reads (ResourceColor[3] + ((String(RG_Income)) + |r)) above TempUnit with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Set TempFloatingText = (Last created floating text)
      • Floating Text - Hide TempFloatingText for (All players)
      • Floating Text - Show TempFloatingText for TempPlayerGroup
      • Floating Text - Set the velocity of TempFloatingText to RG_FloatingTextSpeed towards 90.00 degrees
      • Floating Text - Change TempFloatingText: Disable permanence
      • Floating Text - Change the lifespan of TempFloatingText to RG_FloatingTextLifeSpan seconds
      • Floating Text - Change the fading age of TempFloatingText to RG_FloatingTextFadeTime seconds
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
Inspired by a game called Command - Conquer: Generals
Magtheridon96 - Suggestions/code optimization


v1.0
- Initial release

v1.1
- Changed some instructions and comments
- Included somewhat, documentation-friendly-like-text
- Code optimized a bit (removed O(n) search)
- Changed some variable name

v1.2
- Resource Gain is shown only to the Player owning the building
- Floating Text attributes are now configurables


Keywords:
simple, resource, generator, system, defskull, hashtable, gold, food, lumber, money, builder, income.
Contents

Just another Warcraft III map (Map)

Reviews
01:47, 16th Jul 2012 Magtheridon96: Approved. This is an excellent system. There are some speed quirks that could be taken into consideration, but I find it hard to care. :P Good job. This is an ideal system that does no extra operations...

Moderator

M

Moderator

01:47, 16th Jul 2012
Magtheridon96: Approved.
This is an excellent system.
There are some speed quirks that could be taken into consideration, but I find it hard to care. :p

Good job. This is an ideal system that does no extra operations (algorithmically speaking)

Well, it does it's job pretty well. Just a few tips:

  • When a unit is constructed, you don't need to loop to determine
    whether you should add him to the group or not, you can save a
    boolean into the hashtable to determine whether the structure would
    produce a resource or not and load that instead.
  • There needs to be an easier way to add resources to the system.

Something like the below trigger would suffice:

  • Init
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • -------- Resource Types --------
      • Set ResourceTypeFood = 1
      • Set ResourceTypeLumber = 2
      • Set ResourceTypeGold = 3
      • Set ResourceTypeLaz0rs = 4
      • -------- --- --------
      • Set Resource_Building = Meathouse
      • Set Resource_Type = ResourceTypeFood
      • Set Resource_Income = 60
      • Run ResourceSetup <gen> (ignoring conditions)
      • -------- --- --------
      • Set Resource_Building = GoldMine
      • Set Resource_Type = ResourceTypeGold
      • Set Resource_Income = 15
      • Run ResourceSetup <gen> (ignoring conditions)
This would be much better. The ResourceSetup trigger would save
the values into your hashtable, making this resource much easier for
the user to ... use.
 
Level 9
Joined
Aug 7, 2009
Messages
380
Def-Kool :p (Definitely cool) :p
okey, i can see no-leaks, it's a GUI-friendliness and easy-configurable
Could be useful with GUIers
Rated for 4/5 :p Nice

Edit: This can be even better if having something more advance like: Playing building (unit) animations during the income time. And a special effects with the income time expiration
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Def-Kool :p (Definitely cool) :p
okey, i can see no-leaks, it's a GUI-friendliness and easy-configurable
Could be useful with GUIers
Rated for 4/5 :p Nice
Thanks :)

Edit: This can be even better if having something more advance like: Playing building (unit) animations during the income time. And a special effects with the income time expiration
I'm trying to make a lagless system as I can, well, maybe it's okay to have SFX created for just 10 buildings or less, but if the players have built 20 buildings per player (12 * 20 = 240) SFX create per income interval (maybe some of them has different timer) but still, it would create a lag if it's done all at once.

For playing the unit's animation would not create as much lag as SFX but, some of the animation has about more than 10 seconds of animation to complete, it could possibly overrides the duration of income interval and would play a not-complete-animation of the building thus could ruin the concept there.

I'm more focusing towards functionality rather than visually.
 
Ah I remember doing something like this a while ago obviously, not released, personally I always think these systems are too map-specific (since everybody has to manually put in all the structures they want and blah) Triggering itself looks pretty good, I'm /assuming/ there's a big long instructions manual in the actual map itself, it's useful, Although I still think you should move onto using dynamic indexing for these kind of systems - they really are a waste when they're only holding a couple of variables and less efficient, there are quite a lot of tutorials on it, I suggest you go have a look at them, it'd make it cleaner and easier to understand for other people.
 
Level 7
Joined
Aug 11, 2009
Messages
194
Digging this up a bit - I'm wondering about 2 things:
- Can multiple buildings be chosen for a single resource? (E.g. graveyard 1, graveyard 2, farm 1, farm 2 all producing gold?)
- Can I have more than 3 buildings in the setup?

If not, could anyone redirect me to a system that allows the things mentioned above?
 
Top