[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Spells


Reply
 
Thread Tools
The Hive Workshop Spells:
Simple Resource Generator System v1.2 [GUI]
Images
Highslide JS
Details
Uploaded:17:32, 9th Jul 2012
Last Updated:02:06, 26th Aug 2012
Keywords:simple, resource, generator, system, defskull, hashtable, gold, food, lumber, money, builder, income.
Type:System
Category:GUI / Triggers

INTRODUCTIONS
- 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 :)


HOW TO USE
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


TRIGGERS
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 &lt;gen&gt;
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)


CREDITS
Inspired by a game called Command - Conquer: Generals
Magtheridon96 - Suggestions/code optimization


CHANGELOGS
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
Rating - 4.50 (2 votes)
(Hover and click)
Moderator Comments
Useful
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)

Old reviews
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:

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

This spell is approved and works properly.


Download Simple Resource Generator System v1.2.w3x
(18.46 KB, 234 Downloads)

Old 07-09-2012, 05:33 PM   #2 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
Reserved.
defskull is offline   Reply With Quote
Old 07-10-2012, 03:54 AM   #3 (permalink)
Registered User Striker21
Dota's Fan
 
Striker21's Avatar
 
Join Date: Aug 2009
Posts: 362
Striker21 has little to show at this moment (31)Striker21 has little to show at this moment (31)Striker21 has little to show at this moment (31)Striker21 has little to show at this moment (31)
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
__________________
Wanna see DotA heroes on paper? ===> Click to visit <===
Nothing is IMPOSSIBLE but Nothing is EASY
Striker21 is offline   Reply With Quote
Old 07-10-2012, 04:25 AM   #4 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
Quote:
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 :)

Quote:
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.
defskull is offline   Reply With Quote
Old 07-10-2012, 07:53 AM   #5 (permalink)
Registered User snowman990
Abducted by Minecraft
 
snowman990's Avatar
 
Join Date: Aug 2010
Posts: 620
snowman990 has a spectacular aura about (135)snowman990 has a spectacular aura about (135)snowman990 has a spectacular aura about (135)snowman990 has a spectacular aura about (135)
Nice system, although I didn't need this for now. Why not add a unit generation system too? An example if you don't know what I mean.
A barrack create 1 footman for each 5 seconds. Max 10 footman
__________________
snowman990 is offline   Reply With Quote
Old 07-10-2012, 07:55 AM   #6 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
I am planning to do that system for separate use.
This one is for resources and that one is for units.
defskull is offline   Reply With Quote
Old 07-10-2012, 09:18 AM   #7 (permalink)
Forum Moderator -Kobas-
★ SotP Project Leader ★
 
-Kobas-'s Avatar
Resource Moderator
 
Join Date: Jan 2010
Posts: 5,869
-Kobas- has a reputation beyond repute (2079)-Kobas- has a reputation beyond repute (2079)-Kobas- has a reputation beyond repute (2079)-Kobas- has a reputation beyond repute (2079)-Kobas- has a reputation beyond repute (2079)-Kobas- has a reputation beyond repute (2079)
Hero Contest #6 - Winner: Alora, the Priestess of Moonlight was found to be the most succesful defender against the Armies of the Burning Legion! A hero by -Kobas-. Hero Contest #5 - Winner: Stormbringer was -Kobas-'s entry, who incorporated lightnings as the power of future weaponry. Despite the instability of lightnings, this entry was stable enough to be approved by judges and public. A hero by -Kobas-. Mini-Game Mapping Contest #4: -Kobas- has won the fourth edition of The Hive Workshop's Mini-Game Mapping Contest with his entry: "Hunted". Check out the Arena if you want to participate on competitions as well! 
There was thread in WE HZ
Thread: how can i create a resource system based on units owned
Post: «N/A»
01-03-2012 12:52 PM

(link won't work anymore). And user needed something like this.
I posted this as solution: http://www.hiveworkshop.com/forums/a...ts-owned-x.w3x

I don't say that you steal my resource, in fact I just want to see this improved even more.
__________________

New version is out!
Shadows of the Past v0.9.3.0
Monday, March 25 2013 22:20
Check it out -> ★ Shadows of the Past ★
------------------------------------------------------
We got our Writer, please, welcome Noxx-
-Kobas- is offline   Reply With Quote
Old 07-10-2012, 10:18 AM   #8 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
It is up to you whether to think of it as stealing or whatever, you can check in the CREDITS from what game does this system inspires me.

Also;
Quote:
I don't say that you steal my resource, in fact I just want to see this improved even more.
I believed that (your system) is better than me.
defskull is offline   Reply With Quote
Old 07-12-2012, 01:04 AM   #9 (permalink)
Registered User Tank-Commander
Most spells/systems
 
Tank-Commander's Avatar
 
Join Date: May 2009
Posts: 1,197
Tank-Commander is a glorious beacon of light (445)Tank-Commander is a glorious beacon of light (445)Tank-Commander is a glorious beacon of light (445)Tank-Commander is a glorious beacon of light (445)Tank-Commander is a glorious beacon of light (445)Tank-Commander is a glorious beacon of light (445)
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.
__________________
Tank-Commander is offline   Reply With Quote
Old 07-27-2012, 07:25 PM   #10 (permalink)
Registered User defskull
ϟƘƦƖ|ןΣ✘
 
defskull's Avatar
 
Join Date: Mar 2008
Posts: 7,533
defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)defskull has a brilliant future (1284)
Zephyr Contest #9 - Winner: Stringed Shuriken: An assassin is always working like a trickster. This entry proves the theory, as defskull managed to integrate the fictional lore of the human legacy into a single, virtual ability. Strike fast, die instantly! 
Updated to v1.1
defskull is offline   Reply With Quote
Old 09-11-2012, 12:34 PM   #11 (permalink)
Registered User Ken-E
Judgment Time
 
Ken-E's Avatar
 
Join Date: Apr 2009
Posts: 563
Ken-E is just really nice (412)Ken-E is just really nice (412)Ken-E is just really nice (412)Ken-E is just really nice (412)Ken-E is just really nice (412)
Just the thing I need for my map, thanks alot.
Also, this works perfectly!
Ken-E is online now   Reply With Quote
Old 05-03-2013, 11:03 AM   #12 (permalink)
Registered User MasterTrainer
MT@Hiveworkshop.com
 
MasterTrainer's Avatar
 
Join Date: Apr 2012
Posts: 1,665
MasterTrainer is just really nice (322)MasterTrainer is just really nice (322)
It's simple and easy to use. Great job on making this defskull! I hope you make more systems like these (in terms of awesomeness)!
__________________
My Current Project Promising Project Hive Arena
MasterTrainer is online now   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 11:42 AM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle