Hello can you help me how to create better AI system which can buy items, retreating when hp is low, can select random hero from before the game begin, uses skill item like teleport, and chase low hp enemy
Advance thanks
Advance thanks
Buying Item
- Untitled Trigger 001
- Events
- Unit - A unit comes within 256.00 of Shop
- Conditions
- ((Triggering unit) is in AIGroup) Equal to True
- Actions
- Player - Add -1000 to (Owner of (Triggering unit)) Current gold
- Hero - Create Kelen's Dagger of Escape and give it to (Triggering unit)
Retreating Low HP
- Untitled Trigger 002
- Events
- Unit - A unit Dies
- Conditions
- ((Triggering unit) is in AIGroup) Equal to True
- (Percentage life of (Triggering unit)) Less than or equal to 30.00
- Actions
- Set AI_TempPoint = (Player 1 (Red) start location)
- Unit - Order (Triggering unit) to Move To AI_TempPoint
- Custom script: call RemoveLocation( udg_AI_TempPoint)
Picking Random Hero
- Setup All Heroes
- Untitled Trigger 003
- Events
- Map initialization
- Conditions
- Actions
- Set AI_Heroes[1] = Paladin
- Set AI_Heroes[2] = Archmage
- Set AI_HeroesCount = 2
- Custom script: call DestroyTrigger( GetTriggeringTrigger())
- Pick Random Hero
- Untitled Trigger 004
- Events
- Time - Elapsed game time is 5.00 seconds
- Conditions
- Actions
- For each (Integer A) from 1 to 12, do (Actions)
- Loop - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- ((Player((Integer A))) is in AI_PlayerGroup) Equal to True
- Then - Actions
- Set AI_TempPoint = ((Player((Integer A))) start location)
- Unit - Create 1 AI_Heroes[(Random integer number between 1 and AI_HeroesCount)] for Player[Integer A] at AI_TempPoint facing Default building facing degrees
- Unit Group - Add (Last created unit) to AIGroup
- Custom script: call RemoveLocation( udg_AI_TempPoint)
- Else - Actions
Smell Low HP Unit
- Untitled Trigger 005
- Events
- Time - Every 1.00 seconds of game time
- Conditions
- Actions
- Unit Group - Pick every unit in AIGroup and do (Actions)
- Loop - Actions
- Set AI_TempUnit = (Picked unit)
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- ((Picked unit) is alive) Equal to True
- Then - Actions
- Custom script: set bj_wantDestroyGroup=true
- Unit Group - Pick every unit in (Units within 400.00 of (Position of AI_TempUnit)) and do (Actions)
- Loop - Actions
- Set AI_TempUnit2 = (Picked unit)
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Percentage life of (Picked unit)) Less than or equal to 10.00
- ((Picked unit) is alive) Equal to True
- Then - Actions
- Unit - Order AI_TempUnit to Attack AI_TempUnit2
- Else - Actions
- Else - Actions
In the example it leaks location, and the unit variables should be used instead of "Picked unit", but why there are malfunctions?The last trigger will cause malfunctions, you can't have a "pick every unit" function inside one.
What do you think this trigger triggers:In the example it leaks location, and the unit variables should be used instead of "Picked unit", but why there are malfunctions?
In "Buying Item" trigger you should check if triggering unit is a hero.
In "Retreating Low HP" trigger, your event A Unit Dies doesnt make much sense. Also the condition if HP is lower than 30 doesnt make much sense if unit is dead already.
Also this point could be set once in init trigger and never be destroyed, as you always use the same point over and over again.
In "Pick Random Hero" trigger:
You create a hero for Player 1 each time. You forget to it to Player[LoopInteger]
- Unit - Create 1 AI_Heroes[(Random integer number between 1 and AI_HeroesCount)] for Player 1 (Red) at AI_TempPoint facing Default building facing degrees
What do you think this trigger triggers:
It will only explode the units of player 2, and it should explode the units of player 1, causing malfunction.
- Pick
- Events
- Time - Elapsed game time is 5.00 seconds
- Conditions
- Actions
- Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
- Loop - Actions
- Unit Group - Pick every unit in (Units owned by Player 2 (Blue)) and do (Actions)
- Loop - Actions
- Unit - Explode (Picked unit)