Moderator
M
Moderator
|
|
Init

Events


Map initialization

Conditions

Actions


Hashtable - Create a hashtable


Set AI_hash = (Last created hashtable)


-------- SETUP --------


Set AI_move[1] = 500.00


Set AI_move[2] = 300.00


Set AI_move[3] = 500.00


Set AI_order_return[1] = 1000.00


Set AI_order_return[2] = 1000.00


Set AI_order_return[3] = 1500.00


Set AI_order_return_instant[1] = 1200.00


Set AI_order_return_instant[2] = 1200.00


Set AI_order_return_instant[3] = 2000.00


Set AI_order_attack[1] = 800.00


Set AI_order_attack[2] = 500.00


Set AI_order_attack[3] = 1200.00
AI loop

Events


Time - Every 2.00 seconds of game time

Conditions

Actions


Unit Group - Pick every unit in AI_group and do (Actions)



Loop - Actions




Custom script: local integer h




Set t_unit = (Picked unit)




Custom script: set h = GetHandleId(udg_t_unit)




Custom script: set udg_Not_AI = LoadUnitHandle(udg_AI_hash, h, 4)




Custom script: set udg_AI_mode = LoadInteger(udg_AI_hash, h, 5)




Set t_loc_3 = (Position of Not_AI)




Set t_loc = (Position of t_unit)




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Distance between t_loc and t_loc_3) Greater than or equal to AI_order_return_instant[AI_mode]





Then - Actions






Unit - Move t_unit instantly to t_loc_3





Else - Actions






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








(Distance between t_loc and t_loc_3) Greater than or equal to AI_order_return[AI_mode]







Then - Actions








Unit - Order t_unit to Move To t_loc_3







Else - Actions




Custom script: set bj_wantDestroyGroup = true




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Issued order) Not equal to (Order(attack))





Then - Actions






Unit - Order t_unit to Attack (Random unit from (Units within AI_order_attack[AI_mode] of t_loc_3 matching ((((Matching unit) belongs to an enemy of (Owner of t_unit)) Equal to True) and ((((Matching unit) is alive) Equal to True) and ((Matching unit) Not equal to No unit)))))





Else - Actions




Custom script: set udg_t_loc_2 = LoadLocationHandle(udg_AI_hash, h, 1)




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






Or - Any (Conditions) are true







Conditions








(Current order of t_unit) Equal to (Order(<Empty String>))








(Distance between t_loc and t_loc_2) Less than or equal to 50.00





Then - Actions






Set t_loc_2 = (t_loc_3 offset by (Random real number between 1.00 and AI_move[AI_mode]) towards (Random real number between 1.00 and 360.00) degrees)






Custom script: call RemoveLocation(LoadLocationHandle(udg_AI_hash, h, 1))






Custom script: call SaveLocationHandle(udg_AI_hash, h, 1, udg_t_loc_2)






Unit - Order t_unit to Move To t_loc_2





Else - Actions




Custom script: call RemoveLocation(udg_t_loc)




Custom script: call RemoveLocation(udg_t_loc_3)
AI Attack back

Events


Game - damageEventTrigger becomes Equal to 1.00

Conditions


(source belongs to an enemy of (Owner of target)) Equal to True


target Equal to Not_AI


(target is in AI_group) Equal to True

Actions


Set AI_p[2] = (Position of target)


Unit Group - Pick every unit in AI_group and do (Actions)



Loop - Actions




Custom script: local integer h = GetHandleId(GetEnumUnit())




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Issued order) Not equal to (Order(attack))





Then - Actions






Set AI_p[1] = (Position of (Picked unit))






Custom script: set udg_AI_mode = LoadInteger(udg_AI_hash, h, 5)






Custom script: if DistanceBetweenPoints(udg_AI_p [1], udg_AI_p [2]) <= udg_AI_order_return [udg_AI_mode] then






Unit - Order (Picked unit) to Attack source






Custom script: endif






Custom script: call RemoveLocation(udg_AI_p[1])





Else - Actions


Custom script: call RemoveLocation(udg_AI_p[2])
AI Functions

Events

Conditions

Actions


Custom script: endfunction


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


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


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


Custom script: function AiPrepare takes unit u, unit master, location p returns nothing


Custom script: local integer h = GetHandleId(u)


Custom script: set udg_t_loc_2 = PolarProjectionBJ(p, GetRandomReal(1.00, 500.00), GetRandomReal(1.00, 360.00))


Custom script: call IssuePointOrderLoc(u, "move", udg_t_loc_2 )


Custom script: call SaveLocationHandle(udg_AI_hash, h, 1, udg_t_loc_2)


Custom script: call SaveUnitHandle(udg_AI_hash, h, 4, master)


Custom script: call SaveInteger(udg_AI_hash, h, 5, 1)


Custom script: call SaveBoolean(udg_AI_hash, h, 6, true)


Custom script: call GroupAddUnit(udg_AI_group, u)


Custom script: call SaveLocationHandle(udg_AI_hash, h, 1, udg_t_loc_2)


Custom script: endfunction


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


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


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


Custom script: function AiRemove takes unit u returns nothing


Custom script: local integer h = GetHandleId(u)


Custom script: call GroupRemoveUnit(udg_AI_group, u)


Custom script: call RemoveLocation(LoadLocationHandle(udg_AI_hash, h, 1))


Custom script: call FlushChildHashtable(udg_AI_hash, h)
AI Remove

Events


Unit - A unit Dies

Conditions


((Triggering unit) is in AI_group) Equal to True

Actions


Custom script: call AiRemove(GetTriggerUnit())
Demo init AI

Events


Map initialization

Conditions

Actions


Set Not_AI = Paladin 0000 <gen>


Set AI_units[1] = Footman 0001 <gen>


Set AI_units[2] = Footman 0002 <gen>


Set AI_units[3] = Footman 0003 <gen>


Set t_loc = (Position of Not_AI)


Set AI_max = 3


For each (Integer A) from 1 to AI_max, do (Actions)



Loop - Actions




Custom script: call AiPrepare(udg_AI_units [bj_forLoopAIndex], udg_Not_AI, udg_t_loc)


Custom script: call RemoveLocation(udg_t_loc)
Item summon AI demo

Events


Unit - A unit Uses an item

Conditions


(Item-type of (Item being manipulated)) Equal to Baba

Actions


Custom script: local integer h


Set TempLoc = (Position of (Hero manipulating item))


Unit - Create 1 Peasant for Player 1 (Red) at TempLoc facing Default building facing degrees


Unit - Add a 60.00 second Generic expiration timer to (Last created unit)


Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Orc\HealingWave\HealingWaveTarget.mdl


Special Effect - Destroy (Last created special effect)


Custom script: call AiPrepare(bj_lastCreatedUnit, GetManipulatingUnit(), udg_TempLoc)


Custom script: call RemoveLocation(udg_TempLoc)
Companion Passive Mode

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Passive Mode

Actions


Unit Group - Pick every unit in AI_group and do (Actions)



Loop - Actions




Custom script: local integer h = GetHandleId(GetEnumUnit())




Set AI_mode = 2




Custom script: call SaveInteger(udg_AI_hash, h, 5, udg_AI_mode)
Companion Passive Mode Target

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Passive Mode Target

Actions


Custom script: local integer h = GetHandleId(GetTriggerUnit())


Set AI_mode = 2


Custom script: call SaveInteger(udg_AI_hash, h, 5, udg_AI_mode)
Normal Mode

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Normal Mode

Actions


Unit Group - Pick every unit in AI_group and do (Actions)



Loop - Actions




Custom script: local integer h = GetHandleId(GetEnumUnit())




Set AI_mode = 1




Custom script: call SaveInteger(udg_AI_hash, h, 5, udg_AI_mode)
Normal Mode Target

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Normal Mode Target

Actions


Custom script: local integer h = GetHandleId(GetTriggerUnit())


Set AI_mode = 1


Custom script: call SaveInteger(udg_AI_hash, h, 5, udg_AI_mode)
Agressive Mode

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Agressive Mode

Actions


Unit Group - Pick every unit in AI_group and do (Actions)



Loop - Actions




Custom script: local integer h = GetHandleId(GetEnumUnit())




Set AI_mode = 3




Custom script: call SaveInteger(udg_AI_hash, h, 5, udg_AI_mode)
Agressive Mode Target

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Agressive Mode Target

Actions


Custom script: local integer h = GetHandleId(GetTriggerUnit())


Set AI_mode = 3


Custom script: call SaveInteger(udg_AI_hash, h, 5, udg_AI_mode)
Companion Enable AI Target

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Enable/Disable AI Target

Actions


Custom script: local integer h


Set AI_temp_unit = (Target unit of ability being cast)


Custom script: set h = GetHandleId(udg_AI_temp_unit)


Custom script: set udg_AI_check_target = LoadBoolean(udg_AI_hash, h, 6)


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




AI_check_target Equal to True



Then - Actions




Unit Group - Remove AI_temp_unit from AI_group




Set AI_check_target = False



Else - Actions




Unit Group - Add AI_temp_unit to AI_group




Set AI_check_target = True


Custom script: call SaveBoolean(udg_AI_hash, h, 6, udg_AI_check_target)
Command

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Command

Actions


Custom script: local integer h = GetHandleId(GetSpellTargetUnit())


Set Not_AI = (Triggering unit)


Custom script: call SaveUnitHandle(udg_AI_hash, h, 4, GetTriggerUnit())
Untitled Trigger 001

Events


Player - Player 1 (Red) Selects a unit

Conditions


(Unit-type of (Triggering unit)) Equal to (Restore Panel)

Actions


Selection - Select Game Panel 0018 <gen> for Player 1 (Red)