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!
You are using an out of date browser. It may not display this or other websites correctly. You should upgrade or use an alternative browser.
Triggers
TribeSystem.w3x
Variables
Tribe System
Hash Init
Add to group
Remove from group
Create group
Remove group
Train Units
Training Starts
Training Finishes
Test
Initialization
Enter map-specific custom script code below. This text will be included in the map script after variables are declared and before any trigger code except Custom Script Item. Custom Script Item will merge into map script after globals variables declaration with the list order in trigger view.
Name
Type
is_array
initial_value
BusyStructures
group
No
HomelessPlayer
player
No
TribeBuilding
unitcode
Yes
TribeMaxId
integer
No
TribePlayers
force
No
TribesHash
hashtable
No
TribeUnit
unitcode
Yes
Sets the Variables at Initialization
TribeBuilding[0] trains TribeUnit[0].
TribeBuilding[1] trains TribeUnit[1].
TribeMaxId is the maximum Id. For Peon (Id 0) and Grunt (Id 1) we set it to 1.
Children of Unit = Unit Group of Trained units by that building Unit
MaxTrain of String(UnitType) = How many units can that building sustain at a time
Homeless player should be Enemy with all players. Like Neutral Hostile, except doesn't grant gold. If you want to have neutral hostile that grants gold in your map use it like this. if not set it to neutral hostile and disable gold for neutral kills.
TribePlayers = Player Group of players that use the system
Hash Init
Events
Map initialization
Conditions
Actions
Hashtable - Create a hashtable
Set Variable Set TribesHash = (Last created hashtable)
Set Variable Set HomelessPlayer = Player 21 (Coal)
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Picked player) Not equal to HomelessPlayer
(Picked player) Not equal to Neutral Hostile
(Picked player) Not equal to Neutral Victim
(Picked player) Not equal to Neutral Extra
(Picked player) Not equal to Neutral Passive
Then - Actions
Player - Make (Picked player) treat HomelessPlayer as an Enemy
Player - Make HomelessPlayer treat (Picked player) as an Enemy
Player Group - Add (Picked player) to TribePlayers
Else - Actions
-------- Units and Buildings --------
Set Variable Set TribeUnit[0] = "opeo"
Set Variable Set TribeBuilding[0] = "npgf"
Hashtable - Save 3 as (Key MaxTrain.) of (Key (String(TribeBuilding[0])).) in TribesHash .
Set Variable Set TribeUnit[1] = "ogru"
Set Variable Set TribeBuilding[1] = "obar"
Hashtable - Save 5 as (Key MaxTrain.) of (Key (String(Barracks)).) in (Last created hashtable) .
Set Variable Set TribeMaxId = "1"
For each (Integer A) from 0 to TribeMaxId , do (Actions)
Loop - Actions
-------- Disable all auto-trainable units --------
Player Group - Pick every player in TribePlayers and do (Actions)
Loop - Actions
Player - Make TribeUnit[(Integer A)] Unavailable for training/construction by (Picked player)
-------- Create the groups for each already placed building --------
Unit Group - Pick every unit in (Units of type TribeBuilding[(Integer A)]) and do (Actions)
Loop - Actions
Hashtable - Save Handle Of (Units in No region) as (Key Children.) of (Key (Picked unit).) in TribesHash .
When TribeUnit is trained, it is added to TribeBuilding's group.
Add to group
Events
Unit - A unit Finishes training a unit
Conditions
Actions
For each (Integer A) from 0 to TribeMaxId , do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Trained unit)) Equal to TribeUnit[(Integer A)]
Then - Actions
Unit Group - Add (Trained unit) to (Load (Key Children.) of (Key (Triggering unit).) in TribesHash.)
Else - Actions
When TribeUnit is killed, it is removed from TribeBuilding's group.
Remove from group
Events
Unit - A unit Dies
Conditions
Actions
For each (Integer A) from 0 to TribeMaxId , do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Dying unit)) Equal to TribeUnit[(Integer A)]
Then - Actions
Unit Group - Pick every unit in (Units of type TribeBuilding[(Integer A)]) and do (Actions)
Loop - Actions
Unit Group - Remove (Dying unit) from (Load (Key Children.) of (Key (Picked unit).) in TribesHash.) .
Else - Actions
Create the unit group when the TribeBuilding is constructed.
Create group
Events
Unit - A unit Finishes construction
Conditions
Actions
For each (Integer A) from 0 to TribeMaxId , do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Constructed structure)) Equal to TribeBuilding[(Integer A)]
Then - Actions
Hashtable - Save Handle Of (Units in No region) as (Key Children.) of (Key (Constructed structure).) in TribesHash .
Else - Actions
Remove the unit group when the TribeBuilding is destroyed. Also TribeUnits sustained by the building will become Homeless and will attack anyone. Peons and other workers need to get their 'Worker/Peon-type unit' classification removed so they will attack nearby enemies.
If making Homeless units hostile is not your style, you can kill them or replace them with less powerful versions of themselves.
Remove group
Events
Unit - A unit Dies
Conditions
Actions
For each (Integer A) from 0 to TribeMaxId , do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Dying unit)) Equal to TribeBuilding[(Integer A)]
Then - Actions
Unit Group - Pick every unit in (Load (Key Children.) of (Key (Dying unit).) in TribesHash.) and do (Actions)
Loop - Actions
Unit - Change ownership of (Picked unit) to Player 21 (Coal) and Change color
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Integer A) Equal to 0
Then - Actions
Unit - Remove classification of A peon-type unit from (Picked unit)
Else - Actions
Unit Group - Remove all units from (Load (Key Children.) of (Key (Dying unit).) in TribesHash.) .
Else - Actions
If TribeBuilding's group hasn't reached its MaxTrain value, train another TribeUnit from that it.
Train Units
Events
Time - Every 2 seconds of game time
Conditions
Actions
For each (Integer A) from 0 to TribeMaxId , do (Actions)
Loop - Actions
Unit Group - Pick every unit in (Units of type TribeBuilding[(Integer A)]) and do (Actions)
Loop - Actions
Game - Display to (All players) for 30 seconds the text: (String((Number of units in (Load (Key Children.) of (Key (Picked unit).) in TribesHash.))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in (Load (Key Children.) of (Key (Picked unit).) in TribesHash.)) Less than (Load (Key MaxTrain.) of (Key (String(TribeBuilding[(Integer A)])).) from TribesHash.)
((Picked unit) is in BusyStructures.) Equal to False
Then - Actions
Player - Make TribeUnit[(Integer A)] Available for training/construction by (Owner of (Picked unit))
Unit - Order (Picked unit) to train/upgrade to a TribeUnit[(Integer A)]
Else - Actions
Player Group - Pick every player in TribePlayers and do (Actions)
Loop - Actions
Player - Make TribeUnit[(Integer A)] Unavailable for training/construction by Player 1 (Red)
Tags the building as a BusyStructure so it doesn't train multiple units at a time.
Training Starts
Events
Unit - A unit Begins training a unit
Conditions
Actions
Unit Group - Add (Triggering unit) to BusyStructures
Removes the BusyStructures tag.
Training Finishes
Events
Unit - A unit Cancels training a unit
Unit - A unit Finishes training a unit
Conditions
Actions
Unit Group - Remove (Triggering unit) from BusyStructures .
Used for the test.
You can see here how to add units to a building's group.
Initialization
Events
Map initialization
Conditions
Actions
Melee Game - Use melee time of day (for all players)
Player - Set Player 1 (Red) . Current gold to 999999
Player - Set Player 1 (Red) . Current lumber to 999999
Unit Group - Add Peon 0002 <gen> to (Load (Key Children.) of (Key (Random unit from (Units in (Playable map area) matching ((Matching unit) Equal to Pig Farm 0005 <gen>))).) in TribesHash.)
Unit Group - Add Peon 0003 <gen> to (Load (Key Children.) of (Key (Random unit from (Units in (Playable map area) matching ((Matching unit) Equal to Pig Farm 0005 <gen>))).) in TribesHash.)
Unit Group - Add Peon 0004 <gen> to (Load (Key Children.) of (Key (Random unit from (Units in (Playable map area) matching ((Matching unit) Equal to Pig Farm 0005 <gen>))).) in TribesHash.)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.