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

Slave Wagon v1.4

A system made at the request of the Naga Fans group (Specifically Misha) To act a remake of the Slave Miner from C&C RA2 YR and acts as automatic lumber miner which will seek out the closest trees on the map in proximity to the wagon

Basic system explaination:
1. Slave Wagon is trained
2. Slave Wagon find the closest tree and go towards it and stops nearby
3. Slave Wagon Produces Mur'gul slaves who will mine the targeted tree
4. When the tree is cut the Slave Wagon finds the next closest tree and retargets
5. Slaves Follow Wagon around
6. Overriding Comands for the automation
7. When a Slave dies the Wagon replaces the slave after a given interval
8. When the Slave Wagon dies all the Slaves die too


Information
Speeding up Import (Import order)
Trouble Shooting
Basic Modification Explaination
Examples of more complex modification



WaitTime: Multiply the Value of this setting by 0.09 and that is how many seconds will be between the production of each slave
AmountProducedAtATime: This is how many Slaves will be produced at each interval (WaitTime)
OrderRange: How far away the Wagon must be before it moves closer to the tree it is harvesting
DistanceRange: How close the Wagon will move to the tree it is harvesting (if it's further away than OrderRange)
MurgulDistance: How far away from the Wagon the Mur'gul will move when issued a move command in formation (150 minimum)
SearchRangeGrowth: How fast the search range for trees will grow (divide by 0.09 for how much range per second it grows)
MurgulMax: Number of Mur'gul Slaves



  • Setup
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • -------- Creates a hashtable --------
      • Hashtable - Create a hashtable
      • -------- Sets the variable to the last created hashtable --------
      • Set WagonHash = (Last created hashtable)
      • -------- Adds pre-placed Wagons to the group --------
      • Set SlaveWagons = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Slave Wagon))
      • -------- Configurables --------
      • -------- Wait time between production (WaitTime * 0.09 seconds) --------
      • Set WaitTime = 50
      • -------- Production at a time --------
      • Set AmountProducedAtATime = 1
      • -------- Move Order Issue Range --------
      • Set OrderRange = 600.00
      • -------- Move Distance Range --------
      • Set DistanceRange = 500.00
      • -------- Mur'gul Distance --------
      • Set MurgulDistance = 200.00
      • -------- Search Range Growth Speed --------
      • Set SearchRangeGrowthSpeed = 30.00
      • -------- Mur'gul Count --------
      • Set MurgulMax = 4
      • Set TempPoint1 = (Point(0.00, 0.00))
      • Unit - Create 1 Peasant for Neutral Passive at TempPoint1 facing Default building facing degrees
      • Set TreeChecker = (Last created unit)
      • Unit - Hide TreeChecker
      • Unit - Make TreeChecker Invulnerable
      • Custom script: call RemoveLocation (udg_TempPoint1)
  • Activation
    • Events
      • Unit - A unit enters (Playable map area)
      • Unit - A unit Dies
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Entering unit)) Equal to Slave Wagon
        • Then - Actions
          • Set Unit = (Entering unit)
          • Unit Group - Add Unit to SlaveWagons
          • Trigger - Turn on System Operation <gen>
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Dying unit)) Equal to Slave Wagon
            • Then - Actions
              • Set PickedUnit = (Key (Triggering unit))
              • Set Unit = (Triggering unit)
              • For each (Integer Debug) from 20 to (MurgulMax + 19), do (Actions)
                • Loop - Actions
                  • Unit - Kill (Load Debug of PickedUnit in WagonHash)
              • Hashtable - Clear all child hashtables of child PickedUnit in WagonHash
              • Unit Group - Remove Unit from SlaveWagons
              • If ((Number of units in SlaveWagons) Equal to 0) then do (Trigger - Turn off System Operation <gen>) else do (Do nothing)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Ability being cast) Equal to Select Tree
                • Then - Actions
                  • Set PickedUnit = (Key (Triggering unit))
                  • Set Unit = (Triggering unit)
                  • Hashtable - Save Handle Of(Target destructible of ability being cast) as 10 of PickedUnit in WagonHash
                  • Hashtable - Save 0.00 as 7 of PickedUnit in WagonHash
                  • Set TempPoint1 = (Position of (Target destructible of ability being cast))
                  • Set TempPoint2 = (Position of Unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between TempPoint2 and TempPoint1) Greater than OrderRange
                    • Then - Actions
                      • Unit - Order Unit to Move To TempPoint1
                    • Else - Actions
                  • Custom script: call RemoveLocation (udg_TempPoint2)
                  • Custom script: call RemoveLocation (udg_TempPoint1)
                  • For each (Integer Debug) from 20 to (MurgulMax + 19), do (Actions)
                    • Loop - Actions
                      • Unit - Order (Load Debug of PickedUnit in WagonHash) to Right-Click (Target destructible of ability being cast)
                • Else - Actions
  • System Operation
    • Events
      • Time - Every 0.09 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SlaveWagons and do (Actions)
        • Loop - Actions
          • Set Unit = (Picked unit)
          • Set PickedUnit = (Key (Picked unit))
          • Set TempPoint1 = (Position of Unit)
          • Hashtable - Save ((Load 6 of PickedUnit from WagonHash) + 1) as 6 of PickedUnit in WagonHash
          • For each (Integer Debug) from 20 to (MurgulMax + 19), do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Load Debug of PickedUnit in WagonHash) is alive) Equal to False
                • Then - Actions
                  • Custom script: call RemoveSavedHandle(udg_WagonHash, udg_PickedUnit, udg_Debug)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Current order of (Load Debug of PickedUnit in WagonHash)) Not equal to (Order(resumeharvesting))
                      • (Current order of (Load Debug of PickedUnit in WagonHash)) Not equal to (Order(harvest))
                      • (Current order of (Load Debug of PickedUnit in WagonHash)) Not equal to (Order(smart))
                      • (Current order of (Load Debug of PickedUnit in WagonHash)) Not equal to (Order(move))
                      • (Current order of (Load Debug of PickedUnit in WagonHash)) Not equal to (Order(attack))
                    • Then - Actions
                      • Unit - Order (Load Debug of PickedUnit in WagonHash) to Right-Click (Load 10 of PickedUnit in WagonHash)
                    • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Current order of Unit) Equal to (Order(move))
                  • (Current order of Unit) Equal to (Order(smart))
            • Then - Actions
              • Set Circle = 45.00
              • For each (Integer Debug) from 20 to (MurgulMax + 19), do (Actions)
                • Loop - Actions
                  • Set Circle = (Circle + (360.00 / (Real(MurgulMax))))
                  • Set TempPoint2 = (TempPoint1 offset by MurgulDistance towards Circle degrees)
                  • Unit - Order (Load Debug of PickedUnit in WagonHash) to Move To TempPoint2
                  • Custom script: call RemoveLocation (udg_TempPoint2)
            • Else - Actions
          • If (((Load 10 of PickedUnit in WagonHash) is dead) Equal to True) then do (Hashtable - Save ((Load 7 of PickedUnit from WagonHash) + SearchRangeGrowthSpeed) as 7 of PickedUnit in WagonHash) else do (Do nothing)
          • Destructible - Pick every destructible within (Load 7 of PickedUnit from WagonHash) of TempPoint1 and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked destructible) is alive) Equal to True
                  • ((Load 10 of PickedUnit in WagonHash) is dead) Equal to True
                • Then - Actions
                  • Unit - Order TreeChecker to Harvest (Picked destructible)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Current order of TreeChecker) Equal to (Order(harvest))
                    • Then - Actions
                      • Unit - Order TreeChecker to Stop
                      • Unit - Order Unit to Night Elf Huntress - Sentinel (Picked destructible)
                    • Else - Actions
                • Else - Actions
          • Destructible - Pick every destructible within DistanceRange of TempPoint1 and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Picked destructible) Equal to (Load 10 of PickedUnit in WagonHash)
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Current order of Unit) Equal to (Order(move))
                • Then - Actions
                  • Unit - Order Unit to Stop
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load 6 of PickedUnit from WagonHash) Greater than or equal to WaitTime
            • Then - Actions
              • Hashtable - Save 0 as 6 of PickedUnit in WagonHash
              • Hashtable - Save AmountProducedAtATime as 9 of PickedUnit in WagonHash
              • For each (Integer Debug) from 20 to (MurgulMax + 19), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Load Debug of PickedUnit in WagonHash) is dead) Equal to True
                      • (Load 9 of PickedUnit from WagonHash) Greater than 0
                    • Then - Actions
                      • Hashtable - Save ((Load 9 of PickedUnit from WagonHash) - 1) as 9 of PickedUnit in WagonHash
                      • Unit - Create 1 Mur'gul Slave for (Owner of Unit) at TempPoint1 facing Default building facing degrees
                      • Set Unit = (Last created unit)
                      • Hashtable - Save Handle OfUnit as Debug of PickedUnit in WagonHash
                      • Unit - Order Unit to Harvest (Load 10 of PickedUnit in WagonHash)
                    • Else - Actions
            • Else - Actions
          • Custom script: call RemoveLocation (udg_TempPoint1)



-=V1.0=-
- Initial Upload
-=V1.1=-
- Modified Adding unit to unit groups
- Cleared hashtables on death
-=V1.2=-
- Changed PickedUnit into an Integer
- Added Tree Checking using a peasant
- Strung along If statements in Activation
-=V1.3=-
- Changed Config Variable to non-arrayed presets with appropriate names
- TempPoint variable non-arrayed/changed to seperate variables
-=V1.4=-
- Reduced amount of Location Variables and removed redunancies
- Increased Interval Timer to 0.09 (changed to this to maintain accuracy)
- Corrected a line to use WagonHash instead of Last created hashtable
- Corrected a non-working line to null a hashtable value
- Corrected a few errors in the help on the map and in the description


if you find any errors in the script or if it is not functioning as described please contact me via PM so that it can be corrected.

Keywords:
Command, Conquer, Red, Alert, 2, Yuri's, Revenge, Yuri, Naga, Dragon, Turtle, Mur'gul, Slave, Automatic, Harvesting, Lumber, Seeking, Slave, Wagon.
Contents

Slave Wagon v.1.4 (Map)

Reviews
Approved. Neat system, I like it. -0.03 seconds is too low for this system -Use less point variables -Last created hash:Unit - Order (Load Debug of PickedUnit in (Last created hashtable)) to Right-Click (Load 10 of PickedUnit in WagonHash)...

Moderator

M

Moderator

Maker, Slave Wagon v1.4, 19th Oct 2011

Approved. Neat system, I like it.

Maker, Slave Wagon v1.3, 18th Oct 2011

-0.03 seconds is too low for this system
-Use less point variables
-Last created hash:
  • Unit - Order (Load Debug of PickedUnit in (Last created hashtable)) to Right-Click (Load 10 of PickedUnit in WagonHash)
-Does not work:
  • Hashtable - Save Handle OfNo unit as Debug of PickedUnit in WagonHash
Use
  • Custom script: call RemoveSavedHandle(udg_WagonHash, udg_PickedUnit, udg_Debug)
29 Aug 2011
Bribe: TempPoint and Config should not be arrays, they should be specific variables with specific names.

Config is also way too generic of a name it needs to be prefixed with
something relevant. It could clash with other systems.

Currently if someone has a variable named TempPoint and it is not an array then it will make this system explode when trying to import it.

01:40, 25th Aug 2011
Pharaoh_: http://www.hiveworkshop.com/forums/1991132-post3.html
You can view my comments here.
 
1) Use a destructable-detection system, instead of using that huge block: http://www.hiveworkshop.com/forums/1910913-post4.html

2) When a Wagon dies and you remove it from the Unit Group, clear every hashtable value.

3) In the activation trigger, you might want to use "GetTriggerEventId()", to check which event fired the trigger and by extension save the engine some checks.

4) What's the difference between these two variables?
  • Set PickedUnit = (Triggering unit)
  • Set Unit = (Triggering unit)
You have set them one under another.


5) You might want to use "Unit - A unit enters (Playable map area)" as an event, instead of the "Finishes training a unit". This way, reanimated units or resurrected ones will be taken into account.
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
The importing instructions do not mention that one must set the ability correctly in the triggers. I recommed you create a variable for the ability, so it only needs to be set in the init trigger.

Picked unit handle variable is pretty useless. Create an integer variable and use this:
  • Custom script: set udg_variable = GetHandleId(udg_Unit)
Use that integer instead of the handle variable.
 
In the game, the slaves will be "free" when the mine is destroyed. Maybe make it similiar? :p

it's for lumber :p slaves never get free

although in RA2YR slaves become tiny melees for the player who killed the unit that sends them to work, but that would be too complicated and .. really not usable..
 
Level 21
Joined
Jul 27, 2008
Messages
14,361
Well this is certainly interesting. Though would prefer if ability was activated by right clicking.

Though this will stop slaves for being repairmen and construction, but will cut back on pain of purchasing slaves. Guess Naga worker will do repairs and all constructions.
 
Level 9
Joined
May 23, 2009
Messages
1,741
It looks very nice, It does start to lag when you have a lot of them. but that could also be my wooden pc. and how does it react if there is an unreachable tree close by. "say on a unreachable cliff." And there is harvest able trees far away. what will it do? try to reach the unreachable or continue?
 
in that cercumstance you'd need to use the override to make it stop going for the unreachable, that's one of the reasons for it's existences as it's not really that feasable to make the unit check to see if it can actually get to the tree or not, I /would/ advise anyone using the system to not place inaccessible trees for that reason.

or turn off collision for all slaves in an attempt to reach the trees, lol

that would be funny..
 
Yes you can change the theme to any race - that's all object data so long as the names are the same, and it is possible to change it to other worker tasks, but that'd have to be done by you yourself as the system isn't made to support them as standard.

as far as which ones it can do: you can change it to mining/repairing as well as the lumber gathering but not building structures provided you have the know-how to check for toher things, for instance repairing you'd need to find the closest damaged structure, and for gold mining you'd have to find the closest gold mine (although both would be quite simple modifications really, but you'd need good knowledge on GUI if you wanted to do it yourself because you'd have to modify the hashtables to save the target structure/goldmine as well as modify/change the override ability.
 
Top