-
Are you planning to upload your awesome spell or system to Hive? Please review the rules here.Dismiss Notice
-
Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.Dismiss Notice
-
A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!Dismiss Notice
-
Check out the Staff job openings thread.Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.
Faction System
Submitted by
streetpunk
- Tags:
- System, GUI / Triggers
- Filesize:
- 48.53 KB
- Rating:
-
(1 vote)
- Downloads:
- 471
- Uploaded:
- Mar 17, 2017
- Updated:
- Jun 16, 2017
- Resources:
- 1
- Author(s):
- streetpunk
- State:
- Approved

This bundle is marked as approved. It works and satisfies the submission rules.
GUI Faction system, useful for many styles of maps.
Requirements:
° Unit Indexer (already included on the map);
° UNITDATA Hashtable with all melee player races' unit's attack range stored (You need to add new data of your units to the hashtable)
So this system consists of creating many groups of units owned by the same player and make them threat each other as ally/enemy. For example I have a mercenary camp creeps and a murloc camp creeps, they're both neutral hostile, but I want to make them threat each other as enemies, we set the mercenary camp creeps into one faction, called "Mercenary Camp" and the murloc camp creeps into other faction "Murloc Camp", when they meet each other they will attack themselves as they triggered set to be enemies. This has a great use for huge RPG maps on which have many cities and the user wants one city to be at war with another and yet don't want to spend 2 player slots for them, instead you put all units of one city into a faction, let's say "City #1" and the units from another city into a different faction "City #2".
On this test map we have 4 unit groups and 2 factions: Group1 (Humans) belongs to "The Alliance", Group2 (Night Elves) also belongs to "The Alliance", Group3 (Orcs) and Group4 (Undead) belongs to "The Horde", therefore Group1 and Group2 are enemies of Group3 and Group4 because their factions are enemies. All units are owned by the same player (Player 1). To demonstrate the system, on your map you can make them Neutral Passive or Hostile to save player slots instead of using a Computer Player, for example with this system, on dota we could add 1 player to each team making it 6v6 instead of 5v5 as we would simulate the Sentinel and the Scourge inside Neutral Passive, as the minions and bases could be Neutral Passive and still interact as ally/enemies with players and each other.
How to add unit data to the UNITDATA Hashtable:
This will save 90 as the Peasant's attack range on our hashtable.
Pros:
° Nice for working with RPG maps and other projects that needs many factions;
° Number of factions are limited by your imagination;
° Simulates basic unit behavior, (will threat units on other groups as enemies);
° Supports:
* Attack order;
* Attack-Move order;
* Patrol order;
* Hold Position order;
* Stop order;
* Move order.
° Easy to implement, just use the function:
Where "My Faction" is replaced by the name of the faction you wish to add the unit to.
Cons:
° No buffs or abilities can be used on it's current state as the factions some times belongs to the same player (abilities won't be able to cast and buffs will also affect units on the enemy group);
° Units can only patrol between 2 points.
Credits:
° @Bribe for he's "Unit Indexer" system.
° @BloodSoul for helping providing the following line of code, on which this system would not be possible:
Credits: Bribe (Unit Indexer)
Requirements:
° Unit Indexer (already included on the map);
° UNITDATA Hashtable with all melee player races' unit's attack range stored (You need to add new data of your units to the hashtable)
So this system consists of creating many groups of units owned by the same player and make them threat each other as ally/enemy. For example I have a mercenary camp creeps and a murloc camp creeps, they're both neutral hostile, but I want to make them threat each other as enemies, we set the mercenary camp creeps into one faction, called "Mercenary Camp" and the murloc camp creeps into other faction "Murloc Camp", when they meet each other they will attack themselves as they triggered set to be enemies. This has a great use for huge RPG maps on which have many cities and the user wants one city to be at war with another and yet don't want to spend 2 player slots for them, instead you put all units of one city into a faction, let's say "City #1" and the units from another city into a different faction "City #2".
On this test map we have 4 unit groups and 2 factions: Group1 (Humans) belongs to "The Alliance", Group2 (Night Elves) also belongs to "The Alliance", Group3 (Orcs) and Group4 (Undead) belongs to "The Horde", therefore Group1 and Group2 are enemies of Group3 and Group4 because their factions are enemies. All units are owned by the same player (Player 1). To demonstrate the system, on your map you can make them Neutral Passive or Hostile to save player slots instead of using a Computer Player, for example with this system, on dota we could add 1 player to each team making it 6v6 instead of 5v5 as we would simulate the Sentinel and the Scourge inside Neutral Passive, as the minions and bases could be Neutral Passive and still interact as ally/enemies with players and each other.
How to add unit data to the UNITDATA Hashtable:
-
UNITDATA Hashtable Values
-
Events
-
Conditions
-
Actions
-
-------- PEASANT --------
-
Set UNITDATA_UnitType = Peasant
-
Custom script: set udg_UNITDATA_UnitTypeInteger = udg_UNITDATA_UnitType
-
Hashtable - Save 90 as UNITDATA_ATTACKRANGE of UNITDATA_UnitTypeInteger in UNITDATA_Hash
-
-
This will save 90 as the Peasant's attack range on our hashtable.
Pros:
° Nice for working with RPG maps and other projects that needs many factions;
° Number of factions are limited by your imagination;
° Simulates basic unit behavior, (will threat units on other groups as enemies);
° Supports:
* Attack order;
* Attack-Move order;
* Patrol order;
* Hold Position order;
* Stop order;
* Move order.
° Easy to implement, just use the function:
-
Set FACSYS_FactionName[(Custom value of (Triggering unit))] = My Faction
-
Unit Group - Add (Your Unit) to FACSYS_AssignedGroup
Where "My Faction" is replaced by the name of the faction you wish to add the unit to.
Cons:
° No buffs or abilities can be used on it's current state as the factions some times belongs to the same player (abilities won't be able to cast and buffs will also affect units on the enemy group);
° Units can only patrol between 2 points.
Credits:
° @Bribe for he's "Unit Indexer" system.
° @BloodSoul for helping providing the following line of code, on which this system would not be possible:
-
-------- ------------------------- --------
-
-------- We need to use this custom script because there is no "Order unit to patrol unit" function in GUI --------
-
Custom script: call IssueTargetOrderById(udg_FACSYS_Unit[1], 851990, udg_FACSYS_PatrolTarget[udg_FACSYS_TempInteger[1]])
-
-------- ------------------------- --------
Readme
-
Readme
-
Events
-
Conditions
-
Actions
-
-------- Hello this is my faction system --------
-
-------- ---------------------------------------- --------
-
-------- First you need to add custom and neutral units that you're going to use into the UNITDATA Hashtable (the trigger is at the "Requirements" folder) --------
-
-------- It is necessary that you use the following functions to add the unit's attack range value into the UNITDATA Hashtable --------
-
-------- Example: --------
-
-------- PEASANT --------
-
Set UNITDATA_UnitType = Peasant
-
Custom script: set udg_UNITDATA_UnitTypeInteger = udg_UNITDATA_UnitType
-
Hashtable - Save 90 as UNITDATA_ATTACKRANGE of UNITDATA_UnitTypeInteger in UNITDATA_Hash
-
-------- This will save 90 as the Peasant's attack range on our hashtable. --------
-
-------- We need this value so that orders like "Hold Position", for example, work correctly. --------
-
-------- ---------------------------------------- --------
-
-------- In order to add a unit to a faction you just need to set the string variable FACSYS_FactionName[Custom value of Unit] = "name of faction" --------
-
-------- Something like this: --------
-
Set FACSYS_FactionName[(Custom value of (Triggering unit))] = My Faction
-
-------- ------- --------
-
-------- But for memory saving reasons we usually do it like this: --------
-
Set FACSYS_Unit[1] = (Triggering unit)
-
Set FACSYS_TempInteger[1] = (Custom value of FACSYS_Unit[1])
-
Set FACSYS_FactionName[FACSYS_TempInteger[1]] = My Faction
-
-------- ------- --------
-
-------- ---------------------------------------- --------
-
-------- Now follows an explanation of the setup and how it works --------
-
-------- After configuring the Object Editor data, you just need to set the FACSYS_GroupInteger of an unit to the value corresponding to the faction you want the unit to join --------
-
-------- For example: --------
-
Set FACSYS_FactionName[FACSYS_TempInteger[1]] = The Alliance
-
-------- This will make (Picked unit) join Faction with the name (The Alliance for example) --------
-
-------- If I would set it to (The Horde) for example, then it would be joining The Horde --------
-
-------- --------------------- --------
-
-------- If a unit from one faction meets one from the opposing faction they will behave like normal enemy units would --------
-
-------- But you can set a unit's faction to "Passive" if you wish that unit to have no faction, making them a passive unit --------
-
-------- --------------------- --------
-
-------- First you need to decide what will make a unit join a faction, if it's race, it's owner etc --------
-
-------- Then you set FACSYS_FactionName[Custom value of Your Unit] = The namer of the faction you want the unit to join --------
-
-------- Example: If I want all human units in the map to be part of the alliance I will do the following actions: --------
-
-------- Pick all human units in playable map area --------
-
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Race of (Picked unit)) Equal to Human
-
-
Then - Actions
-
-------- -------------------------------------------------------------- --------
-
-------- Here we set the name of the faction the unit belongs to --------
-
Set FACSYS_FactionName[FACSYS_TempInteger[1]] = The Alliance
-
-------- In this case it's the alliance as it's number is set to "The Alliance" --------
-
-
Else - Actions
-
-
-
-
-------- -------------------------------------------------------------- --------
-
-------- If we want the unit to belong to a specific group inside the faction we just add the unit to the group --------
-
-------- For example: Now we want all human units to join the Human group inside The Alliance --------
-
-------- Again we pick the desired units --------
-
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Race of (Picked unit)) Equal to Human
-
-
Then - Actions
-
-------- And then add them to the Human group --------
-
Unit Group - Add (Picked unit) to FACSYS_GroupHumans
-
-
Else - Actions
-
-
-
-
-------- This way if we wish, we can remove all humans from the alliance or make them join another faction --------
-
-------- Like this: --------
-
Unit Group - Pick every unit in FACSYS_GroupHumans and do (Actions)
-
Loop - Actions
-
-------- Clear the unit's faction --------
-
Set FACSYS_FactionName[FACSYS_TempInteger[1]] = Passive
-
-------- Or make them join another --------
-
Set FACSYS_FactionName[FACSYS_TempInteger[1]] = The Horde
-
-
-
-------- --------------------- --------
-
-------- You can create new factions, you just need to assign them with a name of your wish --------
-
-------- Same goes for groups, you can create new ones to help identify units belonging to a race, a region (a village or town) or by owning player etc. --------
-
-------- --------------------- --------
-
-------- I think this is all the user should know before getting started, thank you and let me know if you face any issues! --------
-
-
Code
-
FACSYS Pre Setup
-
Events
-
Game - UnitIndexEvent becomes Equal to 3.00
-
-
Conditions
-
Actions
-
Set FACSYS_OrderAttack = (Order(attack))
-
Set FACSYS_OrderHold = (Order(holdposition))
-
Set FACSYS_OrderMove = (Order(move))
-
Set FACSYS_OrderSmart = (Order(smart))
-
Set FACSYS_OrderStop = (Order(stop))
-
Set FACSYS_OrderPatrol = (Order(patrol))
-
Set FACSYS_PERIODIC_TIMEOUT = 0.33
-
Set FACSYS_TRIG_Region = FACSYS Region Actions <gen>
-
Set FACSYS_TRIG_Periodic = FACSYS Periodic Checking <gen>
-
Trigger - Add to FACSYS_TRIG_Periodic the event (Time - Every FACSYS_PERIODIC_TIMEOUT seconds of game time)
-
-
-
FACSYS Periodic Checking
-
Events
-
Conditions
-
Actions
-
-------- CHECK FOR NEARBY ENEMIES AND CURRENT ORDERS --------
-
-------- We pick the units on the previously set group so it saves us time and memory --------
-
Unit Group - Pick every unit in FACSYS_AssignedGroup and do (Actions)
-
Loop - Actions
-
Set FACSYS_Unit[1] = (Picked unit)
-
Set FACSYS_TempInteger[1] = (Custom value of FACSYS_Unit[1])
-
Set FACSYS_Loc[1] = (Position of FACSYS_Unit[1])
-
Set FACSYS_TempOrder = (Current order of FACSYS_Unit[1])
-
Set FACSYS_TempBool[1] = (FACSYS_Target[FACSYS_TempInteger[1]] is dead)
-
-------- --------------------------------------------- --------
-
-------- UNITDATA Hashtable Functions --------
-
-------- --------------------------------------------- --------
-
Set UNITDATA_UnitType = (Unit-type of FACSYS_Unit[1])
-
Custom script: set udg_UNITDATA_UnitTypeInteger = udg_UNITDATA_UnitType
-
Set FACSYS_TempReal[1] = (Real((Load UNITDATA_ATTACKRANGE of UNITDATA_UnitTypeInteger from UNITDATA_Hash)))
-
-------- --------------------------------------------- --------
-
-------- First we clear unit's target if needed --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempBool[1] Equal to True
-
-
Then - Actions
-
Set FACSYS_Target[FACSYS_TempInteger[1]] = No unit
-
Set FACSYS_IsEngaged[FACSYS_TempInteger[1]] = False
-
-
Else - Actions
-
-------- Here we order it to attack it's target if it's alive and the unit isn't attacking, just to make sure. --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempBool[1] Equal to False
-
FACSYS_TempOrder Not equal to FACSYS_OrderAttack
-
-
Then - Actions
-
Unit - Order FACSYS_Unit[1] to Attack FACSYS_Target[FACSYS_TempInteger[1]]
-
-
Else - Actions
-
-
-
-
-------- Then we check If unit's current order is hold position this function will prevent it from following the target after it leaves it's attack range --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_Target[FACSYS_TempInteger[1]] Not equal to No unit
-
-
Then - Actions
-
Set FACSYS_Loc[2] = (Position of FACSYS_Target[FACSYS_TempInteger[1]])
-
Set FACSYS_TempReal[2] = (Distance between FACSYS_Loc[1] and FACSYS_Loc[2])
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempReal[2] Greater than FACSYS_TempReal[1]
-
FACSYS_HoldPosition[FACSYS_TempInteger[1]] Equal to True
-
-
Then - Actions
-
Set FACSYS_Target[FACSYS_TempInteger[1]] = No unit
-
Set FACSYS_IsEngaged[FACSYS_TempInteger[1]] = False
-
Unit - Order FACSYS_Unit[1] to Hold Position
-
-
Else - Actions
-
-
Custom script: call RemoveLocation(udg_FACSYS_Loc[2])
-
-
Else - Actions
-
-
-------- -------------------------------------------------------------- --------
-
-------- Here we can check if the unit is stopped and if a enemy is nearby then we order them to fight --------
-
-------- We always check for orders to ensure they are not interrupted --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_IsEngaged[FACSYS_TempInteger[1]] Equal to False
-
FACSYS_TempOrder Not equal to FACSYS_OrderSmart
-
FACSYS_TempOrder Not equal to FACSYS_OrderMove
-
-
Then - Actions
-
-------- -------------------------------------------------------------- --------
-
-------- Checking units whithin range --------
-
Set FACSYS_TempReal[3] = (Current acquisition range of FACSYS_Unit[1])
-
Set FACSYS_TempReal[4] = (X of FACSYS_Loc[1])
-
Set FACSYS_TempReal[5] = (Y of FACSYS_Loc[1])
-
Custom script: call GroupEnumUnitsInRange(udg_FACSYS_TempGroup, (udg_FACSYS_TempReal[4]), (udg_FACSYS_TempReal[5]), (udg_FACSYS_TempReal[3]), null)
-
Unit Group - Pick every unit in FACSYS_TempGroup and do (Actions)
-
Loop - Actions
-
Set FACSYS_Unit[2] = (Picked unit)
-
Set FACSYS_TempBool[2] = (FACSYS_Unit[2] is alive)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempBool[2] Equal to True
-
-
Then - Actions
-
Set FACSYS_TempInteger[2] = (Custom value of FACSYS_Unit[2])
-
Set FACSYS_Loc[2] = (Position of FACSYS_Unit[2])
-
-------- If the faction number (GroupInteger) differs from one unit to another, they will attack each other --------
-
-------- The exception is for GroupInteger number 0, which menas the unit is passive and has no faction --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_FactionName[FACSYS_TempInteger[1]] Not equal to FACSYS_FactionName[FACSYS_TempInteger[2]]
-
FACSYS_FactionName[FACSYS_TempInteger[1]] Not equal to Passive
-
FACSYS_FactionName[FACSYS_TempInteger[2]] Not equal to Passive
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_HoldPosition[FACSYS_TempInteger[1]] Equal to False
-
-
Then - Actions
-
Unit - Order FACSYS_Unit[1] to Attack FACSYS_Unit[2]
-
-------- Here we need to set IsEngaged to true so the unit won't be ordered to attack every 0.33 seconds --------
-
Set FACSYS_IsEngaged[FACSYS_TempInteger[1]] = True
-
-------- -------------------------------------------------------------- --------
-
-------- Defining a specific target --------
-
Set FACSYS_Target[FACSYS_TempInteger[1]] = FACSYS_Unit[2]
-
-------- -------------------------------------------------------------- --------
-
-
Else - Actions
-
Set FACSYS_TempReal[2] = (Distance between FACSYS_Loc[1] and FACSYS_Loc[2])
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_HoldPosition[FACSYS_TempInteger[1]] Equal to True
-
FACSYS_TempReal[2] Less than or equal to FACSYS_TempReal[1]
-
-
Then - Actions
-
Unit - Order FACSYS_Unit[1] to Attack FACSYS_Unit[2]
-
-------- Here we need to set IsEngaged to true so the unit won't be ordered to attack every 0.33 seconds --------
-
Set FACSYS_IsEngaged[FACSYS_TempInteger[1]] = True
-
-------- -------------------------------------------------------------- --------
-
-------- Defining a specific target --------
-
Set FACSYS_Target[FACSYS_TempInteger[1]] = FACSYS_Unit[2]
-
-------- -------------------------------------------------------------- --------
-
-
Else - Actions
-
-
-
-
-
Else - Actions
-
-
Custom script: call RemoveLocation(udg_FACSYS_Loc[2])
-
-
Else - Actions
-
-
-
-
-
Else - Actions
-
-
-------- ------------------------- --------
-
-------- Then, next we will check for unit stored orders and move on with them if needed --------
-
-------- ------------------------- --------
-
-------- Attack-Move order --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempOrder Not equal to FACSYS_OrderAttack
-
FACSYS_TempOrder Not equal to FACSYS_OrderPatrol
-
FACSYS_IsEngaged[FACSYS_TempInteger[1]] Equal to False
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_StoredOrder[FACSYS_TempInteger[1]] Equal to FACSYS_OrderAttack
-
-
Then - Actions
-
-------- ------------------------- --------
-
-------- Here we order the unit to Attack-Move to it's stored location --------
-
Unit - Order FACSYS_Unit[1] to Attack-Move To FACSYS_Loc1[FACSYS_TempInteger[1]]
-
-------- ------------------------- --------
-
-
Else - Actions
-
-------- Here we will deal with patrol orders --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_StoredOrder[FACSYS_TempInteger[1]] Equal to FACSYS_OrderPatrol
-
-
Then - Actions
-
Set FACSYS_OrderPatrolling[FACSYS_TempInteger[1]] = True
-
-------- Here we check if unit's patrol orders are towards a friendly unit or a location point --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_PatrolTarget[FACSYS_TempInteger[1]] Not equal to No unit
-
-
Then - Actions
-
-------- ------------------------- --------
-
-------- We need to use this custom script because there is no "Order unit to patrol unit" function in GUI --------
-
Custom script: call IssueTargetOrderById(udg_FACSYS_Unit[1], 851990, udg_FACSYS_PatrolTarget[udg_FACSYS_TempInteger[1]])
-
-------- ------------------------- --------
-
-
Else - Actions
-
-------- ------------------------- --------
-
-------- Here we check for the nearest Patrol point and order unit to patrol there --------
-
-------- ------------------------- --------
-
Set FACSYS_TempReal[6] = (Distance between FACSYS_Loc[1] and FACSYS_Loc[FACSYS_TempInteger[1]])
-
Set FACSYS_TempReal[7] = (Distance between FACSYS_Loc[1] and FACSYS_Loc1[FACSYS_TempInteger[1]])
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempReal[6] Greater than FACSYS_TempReal[7]
-
-
Then - Actions
-
Unit - Order FACSYS_Unit[1] to Attack-Move To FACSYS_Loc[FACSYS_TempInteger[1]]
-
-
Else - Actions
-
Unit - Order FACSYS_Unit[1] to Attack-Move To FACSYS_Loc1[FACSYS_TempInteger[1]]
-
-
-
-------- ------------------------- --------
-
-------- ------------------------- --------
-
-
-
-
Else - Actions
-
-
-
-
-
Else - Actions
-
-
-------- ------------------------- --------
-
-------- ------------------------- --------
-
-------- ------------------------- --------
-
-------- -------------------------------------------------------------- --------
-
-------- Here we clear location leak --------
-
Custom script: call RemoveLocation(udg_FACSYS_Loc[1])
-
-
-
-------- -------------------------- --------
-
-------- -------------------------- --------
-
-
-
FACSYS Order Handling
-
Events
-
Unit - A unit Is issued an order targeting an object
-
Unit - A unit Is issued an order targeting a point
-
Unit - A unit Is issued an order with no target
-
-
Conditions
-
Actions
-
-------- ------------------------------------------------------------------------------------ --------
-
-------- ------------------------------------------------------------------------------------ --------
-
-------- On this trigger we clear the "fighting state" of a unit so it can obbey orders like move/smart without interference --------
-
-------- ------------------------------------------------------------------------------------ --------
-
-------- ------------------------------------------------------------------------------------ --------
-
Set FACSYS_TempOrder = (Issued order)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
FACSYS_TempOrder Equal to FACSYS_OrderAttack
-
FACSYS_TempOrder Equal to FACSYS_OrderHold
-
FACSYS_TempOrder Equal to FACSYS_OrderMove
-
FACSYS_TempOrder Equal to FACSYS_OrderPatrol
-
FACSYS_TempOrder Equal to FACSYS_OrderSmart
-
FACSYS_TempOrder Equal to FACSYS_OrderStop
-
-
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
Set FACSYS_Unit[1] = (Triggering unit)
-
Set FACSYS_TempInteger[1] = (Custom value of FACSYS_Unit[1])
-
Set FACSYS_Unit[2] = (Target unit of issued order)
-
Set FACSYS_TempInteger[2] = (Custom value of FACSYS_Unit[2])
-
Set FACSYS_Loc[1] = (Position of FACSYS_Unit[1])
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- Here we check for units being the target of the order or not --------
-
-------- If they are, we set them as the unit's current target --------
-
-------- If not we clear it's target --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_Unit[2] Equal to No unit
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- Putting unit out of fighting state --------
-
-------- ---------------------------------- --------
-
Set FACSYS_Target[FACSYS_TempInteger[1]] = No unit
-
Set FACSYS_IsEngaged[FACSYS_TempInteger[1]] = False
-
-------- ---------------------------------- --------
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_FactionName[FACSYS_TempInteger[1]] Not equal to FACSYS_FactionName[FACSYS_TempInteger[2]]
-
FACSYS_FactionName[FACSYS_TempInteger[1]] Not equal to Passive
-
FACSYS_FactionName[FACSYS_TempInteger[2]] Not equal to Passive
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- If the target of the order is a unit then we set it as the unit's target --------
-
-------- ---------------------------------- --------
-
Set FACSYS_Target[FACSYS_TempInteger[1]] = (Target unit of issued order)
-
Set FACSYS_IsEngaged[FACSYS_TempInteger[1]] = True
-
-------- ------------------------------------- --------
-
-
Else - Actions
-
-
-
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- Next we will deal with Hold Position Order --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempOrder Equal to FACSYS_OrderHold
-
-
Then - Actions
-
Set FACSYS_HoldPosition[FACSYS_TempInteger[1]] = True
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_HoldPosition[FACSYS_TempInteger[1]] Equal to True
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_IsEngaged[FACSYS_TempInteger[1]] Equal to False
-
-
Then - Actions
-
Set FACSYS_HoldPosition[FACSYS_TempInteger[1]] = False
-
-
Else - Actions
-
-
-
Else - Actions
-
-
-
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- Here we will handle Attack-Move and Patrol orders accordindly --------
-
-------- This system simulates patrols through attack-move orders from one point to the other --------
-
-------- So in order to make it work correctly we will need to set a boolean to define if a Attack-Move comes from a patrol order or if it is a legit Attack-Move order --------
-
-------- First we check to see if the current order of the unit is attack and if it's not patrolling --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
FACSYS_TempOrder Equal to FACSYS_OrderAttack
-
FACSYS_TempOrder Equal to FACSYS_OrderPatrol
-
-
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempOrder Equal to FACSYS_OrderAttack
-
FACSYS_OrderPatrolling[FACSYS_TempInteger[1]] Equal to False
-
FACSYS_Unit[2] Equal to No unit
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- We need to set the Stored order so we can relate to it properly on the periodic trigger --------
-
-------- ---------------------------------- --------
-
Set FACSYS_StoredOrder[FACSYS_TempInteger[1]] = FACSYS_TempOrder
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- Here we set the attack-move order position --------
-
-------- ---------------------------------- --------
-
Set FACSYS_Loc1[FACSYS_TempInteger[1]] = (Target point of issued order)
-
-------- ---------------------------------- --------
-
-------- Then we create ar region on which when the unit enters the orders and leaks are removed --------
-
-------- ---------------------------------- --------
-
Set FACSYS_TempRegion[FACSYS_TempInteger[1]] = (Region centered at FACSYS_Loc1[FACSYS_TempInteger[1]] with size (512.00, 512.00))
-
-------- ---------------------------------- --------
-
-------- Add the region to a event on the Region trigger --------
-
-------- ---------------------------------- --------
-
Trigger - Add to FACSYS_TRIG_Region the event (Unit - A unit enters FACSYS_TempRegion[FACSYS_TempInteger[1]])
-
-------- ---------------------------------- --------
-
-
Else - Actions
-
-------- Here we check for Patrol order --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempOrder Equal to FACSYS_OrderPatrol
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- We need to set the Stored order so we can relate to it properly on the periodic trigger --------
-
-------- ---------------------------------- --------
-
Set FACSYS_StoredOrder[FACSYS_TempInteger[1]] = FACSYS_TempOrder
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- Defining the points on which the unit will patrol --------
-
-------- ---------------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_Unit[2] Equal to No unit
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- If the target of the patrol order is a location point we set 2 location on which the unit will patrol --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
Set FACSYS_Loc[FACSYS_TempInteger[1]] = (Position of FACSYS_Unit[1])
-
Set FACSYS_Loc1[FACSYS_TempInteger[1]] = (Target point of issued order)
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-
Else - Actions
-
-------- ---------------------------------- --------
-
-------- Here we will check, if the target is a friendly unit then we will set it as the PatrolTarget --------
-
-------- ---------------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
FACSYS_FactionName[FACSYS_TempInteger[1]] Equal to FACSYS_FactionName[FACSYS_TempInteger[2]]
-
FACSYS_FactionName[FACSYS_TempInteger[1]] Equal to Passive
-
FACSYS_FactionName[FACSYS_TempInteger[2]] Equal to Passive
-
-
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
Set FACSYS_PatrolTarget[FACSYS_TempInteger[1]] = FACSYS_Unit[2]
-
-------- ---------------------------------- --------
-
-
Else - Actions
-
-------- ---------------------------------- --------
-
-------- If the unit is a enemy we set the patrol point to the position of the unit --------
-
-------- ---------------------------------- --------
-
Set FACSYS_Loc1[FACSYS_TempInteger[1]] = (Position of (Target unit of issued order))
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-
-
-------- ---------------------------------- --------
-
-------- Creating regions to detect when the unit has reached one point of it's patrol so it is then ordered to Attack-Move to the other point --------
-
-------- ---------------------------------- --------
-
Set FACSYS_TempRegion[FACSYS_TempInteger[1]] = (Region centered at FACSYS_Loc[FACSYS_TempInteger[1]] with size (512.00, 512.00))
-
Set FACSYS_TempRegion1[FACSYS_TempInteger[1]] = (Region centered at FACSYS_Loc1[FACSYS_TempInteger[FACSYS_TempInteger[1]]] with size (512.00, 512.00))
-
-------- ---------------------------------- --------
-
-------- We set the patrolling boolean to true so we can differ from Attack-Move and simulated Patrol --------
-
-------- ---------------------------------- --------
-
Set FACSYS_OrderPatrolling[FACSYS_TempInteger[1]] = True
-
-------- ---------------------------------- --------
-
-------- Add the regions to a event on the Region trigger --------
-
-------- ---------------------------------- --------
-
Trigger - Add to FACSYS_TRIG_Region the event (Unit - A unit enters FACSYS_TempRegion[FACSYS_TempInteger[1]])
-
Trigger - Add to FACSYS_TRIG_Region the event (Unit - A unit enters FACSYS_TempRegion1[FACSYS_TempInteger[1]])
-
-------- ---------------------------------- --------
-
-
Else - Actions
-
-
-
-
-
Else - Actions
-
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- On the next stage of this trigger we will be running cleaning actions --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- First we check for possible movment and guard orders --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
FACSYS_TempOrder Equal to FACSYS_OrderHold
-
FACSYS_TempOrder Equal to FACSYS_OrderMove
-
FACSYS_TempOrder Equal to FACSYS_OrderSmart
-
FACSYS_TempOrder Equal to FACSYS_OrderStop
-
And - All (Conditions) are true
-
Conditions
-
FACSYS_TempOrder Equal to FACSYS_OrderAttack
-
FACSYS_Unit[2] Not equal to No unit
-
FACSYS_TempOrder Equal to FACSYS_OrderOutside[FACSYS_TempInteger[1]]
-
-
-
-
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempOrder Equal to FACSYS_OrderSmart
-
FACSYS_Unit[2] Not equal to No unit
-
-
Then - Actions
-
-------- ---------------------------------------------------- --------
-
-------- Here we check for right clicks of a unit from one faction to another --------
-
-------- ---------------------------------------------------- --------
-
Set FACSYS_Unit[1] = (Triggering unit)
-
Set FACSYS_TempInteger[1] = (Custom value of FACSYS_Unit[1])
-
Set FACSYS_TempInteger[2] = (Custom value of FACSYS_Unit[2])
-
-------- ---------------------------------------------------- --------
-
-------- ---------------------------------------------------- --------
-
-------- Faction Checking --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_FactionName[FACSYS_TempInteger[1]] Not equal to FACSYS_FactionName[FACSYS_TempInteger[2]]
-
FACSYS_FactionName[FACSYS_TempInteger[1]] Not equal to Passive
-
FACSYS_FactionName[FACSYS_TempInteger[2]] Not equal to Passive
-
-
Then - Actions
-
-------- We turn the "smart" order into "attack" --------
-
Set FACSYS_HoldPosition[FACSYS_TempInteger[1]] = False
-
Unit - Order FACSYS_Unit[1] to Attack FACSYS_Unit[2]
-
-------- ---------------------------------------------------- --------
-
-------- Setting variables so after we can perform target cleaning --------
-
-------- FACSYS_Target means the current target of the unit --------
-
Set FACSYS_Target[FACSYS_TempInteger[1]] = FACSYS_Unit[2]
-
-------- FACSYS_IsEngaged menas that the unit is in combat --------
-
Set FACSYS_IsEngaged[FACSYS_TempInteger[1]] = True
-
-------- ---------------------------------------------------- --------
-
-
Else - Actions
-
-
-------- ---------------------------------------------------- --------
-
-------- ---------------------------------------------------- --------
-
-
Else - Actions
-
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- Here we clean the attack-move specific order if the unit is ordered to attack --------
-
-------- We will use a Order variable called OrderOutside, which means it's an order given by the user --------
-
-------- All attack unit orders triggered by the user should be stored on OrderOutside so we can know if the order was given by the user --------
-
-------- Because if it's not a order given by the user then the system should't be interrupted --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-------- Then we null all actions and variables reffering to attack-move and patrol --------
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
Set FACSYS_TempString = <Empty String>
-
Set FACSYS_StoredOrder[FACSYS_TempInteger[1]] = (Order(FACSYS_TempString))
-
Set FACSYS_PatrolTarget[FACSYS_TempInteger[1]] = No unit
-
Custom script: call RemoveLocation (udg_FACSYS_Loc[udg_FACSYS_TempInteger[1]])
-
Custom script: call RemoveLocation (udg_FACSYS_Loc1[udg_FACSYS_TempInteger[1]])
-
Custom script: call RemoveRect(udg_FACSYS_TempRegion[udg_FACSYS_TempInteger[1]])
-
Custom script: call RemoveRect(udg_FACSYS_TempRegion1[udg_FACSYS_TempInteger[1]])
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-
Else - Actions
-
-
Custom script: call RemoveLocation (udg_FACSYS_Loc[1])
-
-------- Removing Leaks --------
-
-
Else - Actions
-
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
-
-
FACSYS Region Actions
-
Events
-
Conditions
-
Actions
-
-------- ---------------------------------- --------
-
-------- On this trigger we will be dealing with actions reffering to the regions created by Attack-Move and Patrol orders --------
-
-------- ---------------------------------- --------
-
Set FACSYS_Unit[1] = (Triggering unit)
-
Set FACSYS_TempInteger[1] = (Custom value of FACSYS_Unit[1])
-
Set FACSYS_Loc[1] = (Position of FACSYS_Unit[1])
-
-------- ---------------------------------- --------
-
-------- ---------------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_StoredOrder[FACSYS_TempInteger[1]] Equal to FACSYS_OrderAttack
-
FACSYS_OrderPatrolling[FACSYS_TempInteger[1]] Equal to False
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- Here we clear the location and order of Attack-Move when the unit gets to the targeted location --------
-
-------- ---------------------------------- --------
-
Set FACSYS_TempString = <Empty String>
-
Custom script: set udg_FACSYS_TempString = null
-
Set FACSYS_StoredOrder[FACSYS_TempInteger[1]] = (Order(FACSYS_TempString))
-
Custom script: call RemoveLocation (udg_FACSYS_Loc1[udg_FACSYS_TempInteger[1]])
-
-------- ---------------------------------- --------
-
-
Else - Actions
-
-------- ---------------------------------- --------
-
-------- Next we deal with Patrol order and Location handling --------
-
-------- ---------------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_StoredOrder[FACSYS_TempInteger[1]] Equal to FACSYS_OrderPatrol
-
FACSYS_OrderPatrolling[FACSYS_TempInteger[1]] Equal to True
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- Unit got to first Patrol location --------
-
-------- ---------------------------------- --------
-
Set FACSYS_TempBool[1] = (FACSYS_TempRegion[FACSYS_TempInteger[1]] contains FACSYS_Loc[1])
-
Set FACSYS_TempBool[2] = (FACSYS_TempRegion1[FACSYS_TempInteger[1]] contains FACSYS_Loc[1])
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempBool[1] Equal to True
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- Order it to "Patrol" to the second location --------
-
-------- ---------------------------------- --------
-
Unit - Order FACSYS_Unit[1] to Attack-Move To FACSYS_Loc1[FACSYS_TempInteger[1]]
-
-------- ---------------------------------- --------
-
-
Else - Actions
-
-------- ---------------------------------- --------
-
-------- Unit got to second Patrol location --------
-
-------- ---------------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempBool[2] Equal to True
-
-
Then - Actions
-
-------- ---------------------------------- --------
-
-------- Order it to "Patrol" to the first location --------
-
-------- ---------------------------------- --------
-
Unit - Order FACSYS_Unit[1] to Attack-Move To FACSYS_Loc[FACSYS_TempInteger[1]]
-
-------- ---------------------------------- --------
-
-
Else - Actions
-
-
-
-
-
Else - Actions
-
-
-
-
Custom script: call RemoveLocation(udg_FACSYS_Loc[1])
-
-
Demo Setup used on the map
-
FACSYS Demo Setup
-
Events
-
Game - UnitIndexEvent becomes Equal to 1.00
-
-
Conditions
-
Actions
-
-------- This is a demo trigger on how to set up a unit's faciton --------
-
Set FACSYS_Unit[1] = UDexUnits[UDex]
-
Set FACSYS_TempInteger[1] = (Custom value of FACSYS_Unit[1])
-
Set FACSYS_TempRace[1] = (Race of FACSYS_Unit[1])
-
-------- -------------------------------------------------------------- --------
-
-------- Here we set a boolean to later check if unit has already been assigned to a faction or not, so we don't spend memory picking the same unit --------
-
-------- Add to a overall specific group so we won't have to get units in playable map area as it will cost us memory --------
-
Unit Group - Add FACSYS_Unit[1] to FACSYS_AssignedGroup
-
-------- -------------------------------------------------------------- --------
-
-------- Creating groups and factions --------
-
-------- You can always change the criteria on how the unit will be handled and which faction and group will it join, in this case I choose the race --------
-
-------- Set up for the allaince --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
FACSYS_TempRace[1] Equal to Human
-
FACSYS_TempRace[1] Equal to Night Elf
-
-
-
-
Then - Actions
-
-------- -------------------------------------------------------------- --------
-
-------- Here we set the number of the faction the unit belongs to --------
-
Set FACSYS_FactionName[FACSYS_TempInteger[1]] = The Alliance
-
-------- -------------------------------------------------------------- --------
-
-------- Adding unit to specific group inside faction --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempRace[1] Equal to Human
-
-
Then - Actions
-
Unit Group - Add FACSYS_Unit[1] to FACSYS_GroupHumans
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempRace[1] Equal to Night Elf
-
-
Then - Actions
-
Unit Group - Add FACSYS_Unit[1] to FACSYS_GroupNightElfs
-
-
Else - Actions
-
-
-
-
Unit - Change color of FACSYS_Unit[1] to Blue
-
-
Else - Actions
-
-
-------- -------------------------------------------------------------- --------
-
-------- Set up for the horde --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
FACSYS_TempRace[1] Equal to Orc
-
FACSYS_TempRace[1] Equal to Undead
-
-
-
-
Then - Actions
-
-------- -------------------------------------------------------------- --------
-
-------- Here we set the number of the faction the unit belongs to --------
-
Set FACSYS_FactionName[FACSYS_TempInteger[1]] = The Horde
-
-------- -------------------------------------------------------------- --------
-
-------- Adding unit to specific group inside faction --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempRace[1] Equal to Orc
-
-
Then - Actions
-
Unit Group - Add FACSYS_Unit[1] to FACSYS_GroupOrcs
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FACSYS_TempRace[1] Equal to Undead
-
-
Then - Actions
-
Unit Group - Add FACSYS_Unit[1] to FACSYS_GroupUndead
-
-
Else - Actions
-
-
-
-
Unit - Change color of FACSYS_Unit[1] to Red
-
-------- -------------------------- --------
-
-
Else - Actions
-
-
-------- Add to Event Handle the event "unit comes whithin acquisition range of picked unit" --------
-
-------- This event will let us know when the units acquires their targets so we can properly handle it --------
-
-------- -------------------------- --------
-
-
Credits: Bribe (Unit Indexer)
Contents
Page 1 of 3