- Joined
- Jul 20, 2013
- Messages
- 9
What i want: I was trying to create an autotraining system for buildings, something simmilar to Castle Fight, but with one important condition: Every building can have only limited ammount of alive units at a time. I.e. Barracks#1 trains units until the established limit of units (let's say it is 3) is reached, than it stops; meanwhile Barracks#2 and Forge#1 do the same thing. But when one of the trained units dies, a building that trained dying unit automatically trains a replacement until the limit is reached again. Hope it makes sense
What is done: I setted up autotraining with 3 simple triggers:
The problem: my continuous attempts to make it work failed. I would imagine hashtables are the way to go but since my trigger skills are mediocre and my hashtable/game cache knowledge is close to non-existent, I gave up after several hours of trial and error. I was trying to save training unit (building) and trained unit to hashtable and then load them whenever i need but it seems like i don't know know how to save/load units properly. My abomination of a trigger with a hashtable forced my buildings to train units in weird and unpredictable patterns, it was even funny. Unfortunately I deleted all my non-working triggers in a moment of despair so i don't have them to show you and make you laugh
One more thing: I'm planning to use the same unit limit for all of my buildings, but if it is possible to set different cap for each building type without major changes to trigger structure - let me know how.
Anyway, I hope someone will bother to reply
P.S. Sorry for occasional misspells, typos and grammar errors, my English is work in progress
What is done: I setted up autotraining with 3 simple triggers:
-
Barracks Initialization
-
Events
- Time - Elapsed game time is 0.20 seconds
- Conditions
-
Actions
- Set NumberOfBuilding = (NumberOfBuilding + 1)
- Set BarrackType[NumberOfBuilding] = |cFF8A4500Basic Barracks|r Lvl 1
- Set UnitType[NumberOfBuilding] = Militia Lvl 1
- -------- - --------
- Set NumberOfBuilding = (NumberOfBuilding + 1)
- Set BarrackType[NumberOfBuilding] = |cFF8A4500Basic Barracks|r Lvl 2
- Set UnitType[NumberOfBuilding] = Militia Lvl 2
- -------- - --------
- Set NumberOfBuilding = (NumberOfBuilding + 1)
- Set BarrackType[NumberOfBuilding] = |cFF8A4500Basic Barracks|r Lvl 3
- Set UnitType[NumberOfBuilding] = Militia Lvl 3
- -------- - --------
-
Events
-
Train First
-
Events
- Unit - A unit Finishes construction
- Conditions
-
Actions
- Unit group - Add (Triggering unit) to Barracks
-
For each (Integer loop) from 1 to NumberOfBuilding, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Condition
- (Unit-type of (Constructed structure)) Equal to BarrackType[loop]
-
Then - Actions
- Unit - Order (Constructed structure) to train/upgrade to a UnitType[loop]
- Else - Actions
-
If - Condition
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Events
-
Train Loop
-
Events
- Unit - A unit Finishes training a unit
- Conditions
-
Actions
- Unit - Set the custom value of (Triggering unit) to ((Custom value of (Triggering unit)) + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Custom value of (Triggering unit)) less than 3
-
Then - Actions
- Unit - Order (Triggering unit) to train/upgrade to a (Unit-type of (Trained unit))
-
Else - Actions
- Custom script: call IssueImmediateOrderById( GetTriggerUnit(), 851976 )
-
If - Conditions
-
Events
The problem: my continuous attempts to make it work failed. I would imagine hashtables are the way to go but since my trigger skills are mediocre and my hashtable/game cache knowledge is close to non-existent, I gave up after several hours of trial and error. I was trying to save training unit (building) and trained unit to hashtable and then load them whenever i need but it seems like i don't know know how to save/load units properly. My abomination of a trigger with a hashtable forced my buildings to train units in weird and unpredictable patterns, it was even funny. Unfortunately I deleted all my non-working triggers in a moment of despair so i don't have them to show you and make you laugh
One more thing: I'm planning to use the same unit limit for all of my buildings, but if it is possible to set different cap for each building type without major changes to trigger structure - let me know how.
Anyway, I hope someone will bother to reply
P.S. Sorry for occasional misspells, typos and grammar errors, my English is work in progress