- Joined
- Jan 23, 2020
- Messages
- 3
I am making an AI for a hero.
Im using knowledge i've learned from this tutorial.
The AI has two parts. Attack and defend. The AI will decide wether or not to attack depending on wether or not it is defending.
The hero will defend when ever a unit of the same team is getting attacked.
I am using a seperate trigger to detect when a unit is getting attacked (when hero needs to defend). Checking when a unit on the same team is attacked is not a problem, the problem is when it isn't attacked anymore.
Main state:
Im using knowledge i've learned from this tutorial.
The AI has two parts. Attack and defend. The AI will decide wether or not to attack depending on wether or not it is defending.
The hero will defend when ever a unit of the same team is getting attacked.
I am using a seperate trigger to detect when a unit is getting attacked (when hero needs to defend). Checking when a unit on the same team is attacked is not a problem, the problem is when it isn't attacked anymore.
Main state:
-
AI Mainstate
-
Events
-
Time - Every 1.00 seconds of game time
-
-
Conditions
-
Actions
-
Set VariableSet AIUnitGroup = (Units owned by Player 2 (Blue) matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Hero 1)).)
-
Unit Group - Pick every unit in AIUnitGroup and do (Actions)
-
Loop - Actions
-
-------- Defend --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
AIDefend Equal to True
-
-
Then - Actions
-
Trigger - Run AI Defend <gen> (checking conditions)
-
-
Else - Actions
-
-
-------- Charge --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
AIDefend Not equal to True
-
AIAttack Not equal to True
-
-
Then - Actions
-
Trigger - Run AI Attack <gen> (checking conditions)
-
-
Else - Actions
-
-
-------- Back to Charge --------
-
-
-
Custom script: call DestroyGroup(udg_AIUnitGroup)
-
-
-
AI Attack
-
Events
-
Conditions
-
Actions
-
Set VariableSet AIDefend = False
-
Set VariableSet AIAttack = True
-
Set VariableSet AI_Loc = (Center of Town 2 Claim <gen>)
-
Unit - Order (Picked unit) to Move To AI_Loc
-
Custom script: call RemoveLocation(udg_AI_Loc)
-
-
-
AI Defend
-
Events
-
Conditions
-
Actions
-
Set VariableSet AIAttack = False
-
Set VariableSet AIUnitGroupGrunts = (Units within 512.00 of (Position of (Picked unit)).)
-
Unit - Order (Picked unit) to Attack-Move To AI_Loc
-
Unit Group - Order AIUnitGroupGrunts to Attack-Move To AI_Loc
-
Custom script: call DestroyGroup(udg_AIUnitGroupGrunts)
-
Custom script: call RemoveLocation(udg_AI_Loc)
-
-
-
AI Attacked state
-
Events
-
Unit - A unit owned by Player 2 (Blue) Is attacked
-
-
Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
AIDefend Not equal to True
-
-
Then - Actions
-
Set VariableSet AIDefend = True
-
Set VariableSet AI_Loc = (Position of (Attacked unit))
-
-
Else - Actions
-
Wait 20.00 seconds
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
AIDefend Equal to True
-
((Region centered at (Position of (Attacked unit)) with size (700.00, 700.00)) contains (Attacking unit)) Equal to False
-
-
Then - Actions
-
Trigger - Run AI Attack <gen> (checking conditions)
-
-
Else - Actions
-
-
-
-
-