- Joined
- Oct 9, 2015
- Messages
- 721
1.0 Version Released
Last edited:
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
Set FACSYS_FactionName[(Custom value of (Triggering unit))] = My Faction
Unit Group - Add (Your Unit) to FACSYS_AssignedGroup
-------- ------------------------- --------
-------- 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

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! --------
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])
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 --------


-------- -------------------------- --------