AMAI
AMAI copied to clipboard
Repeated teleport
https://github.com/SMUnlimited/AMAI/blob/2caeba791acb62ebc4d4fb315a8a62480e7fde1f/Jobs/TELEPORT.eai#L15
When running TeleportJob for the first time , if current order < 852008 or current order > 852013 , this indicates that the Teleport was not successful , It's really necessary TeleportCaptain
but If it's after the second time , the Teleport is complete, and current order always will change , TeleportCaptain will it cause duplicate Teleport at that time??
function TeleportJob takes unit hu returns nothing
local group g = null
local unit u = null
local integer current_order = GetUnitCurrentOrder(hu)
call DisplayToAllJobDebug("TELEPORT JOB Start")
if not UnitAlive(hu) or current_order < 852008 or current_order > 852013 then
if not UnitAlive(hu) then
call CaptainGoHome()
else
if teleporting then // running TeleportJob for the first time , if Teleport successful , this is false
call TeleportCaptain(GetLocationX(teleportloc), GetLocationY(teleportloc))
set teleporting = false
else
call AttackMoveXY(R2I(GetLocationX(teleportloc)), R2I(GetLocationY(teleportloc))) // The army that has not been teleported continues to attack
endif
endif
return
endif
set g = CreateGroup()
call GroupEnumUnitsInRange(g, GetUnitX(hu), GetUnitY(hu), 2 * teleport_radius, null)
call GroupRemoveUnit(g, hu)
set g = SelectByPlayer(g, ai_player, true)
set g = SelectUnittype(g, UNIT_TYPE_PEON, false)
set g = SelectByHidden(g, false)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if DistanceBetweenUnits(hu, u) > teleport_radius then
call IssuePointOrder(u, "move", GetUnitX(hu), GetUnitY(hu))
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
set g = null
set teleporting = false // Teleport was successful ,current order is use Teleport item
call TQAddUnitJob(1, TELEPORT, 0, hu)
endfunction
MICRO_HERO and the TeleportHome function controls when it begins to teleport.
TELEPORT function just tries to detect when teleport has happened and reset flags to teleports are allowed again. It doesn't itself trigger a teleport.
In China, the native functions of AI scripts are not fully understood by anyone It is basically a literal translation and has not undergone comprehensive testing
So it's natural for us to understand that TeleportCaptain() is a function for script call AI use teleport skills or item
What I really hope to solve is, after the teleport is completed, still have some unit will going to -- hero position before teleportation This is a queue up one by one to send experience to the enemy
so here use AttackMoveXY when teleport is completed , hope can let this unit go -- hero position after teleportation