Сначала всё работало, но теперь перестало и юнит "не видит" моего героя, чтобы скастовать в него скилл
Вот что пишет сервер
Game code (account 0) tried to execute invalid order (26). Target can't be seen by the unit's team.
function Spawn( entityKeyValues )
thisEntity:SetContextThink( "AIThink", AIThink, 0.5 )
if not IsServer() then
return
end
if thisEntity == nil then
return
end
creature_heal = thisEntity:FindAbilityByName( "dota_ability_creature_heal" )
creature_damage = thisEntity:FindAbilityByName( "dota_ability_creature_damage" )
creature_heal_damage = thisEntity:FindAbilityByName( "dota_ability_creature_heal_damage" )
end
function AIThink()
if ( not thisEntity:IsAlive() ) then
return -1
end
if GameRules:IsGamePaused() == true then
return 1
end
local enemies = FindUnitsInRadius(thisEntity:GetTeamNumber(), thisEntity:GetAbsOrigin(), nil, 99999, DOTA_UNIT_TARGET_TEAM_ENEMY, DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES, FIND_CLOSEST, false )
if enemies == 0 then
return
end
if #enemies > 0 then
if creature_heal_damage:IsFullyCastable() and creature_heal_damage ~= nil then
return CastHealToEnemy( enemies [1] )
end
if thisEntity:GetHealth() < ( thisEntity:GetMaxHealth() * 0.5 ) then
if creature_heal:IsFullyCastable() and creature_heal ~= nil then
return CastHeal()
end
end
if creature_damage ~= nil and creature_damage:IsFullyCastable() then
for i=1, #enemies do
if enemies:GetHealth() < ( enemies:GetMaxHealth() * 0.1 ) then
return CastDmg( enemies [1] )
end
end
end
end
return 0.5
end
------------------------------------------ABILITY CASTS------------------------------------
function CastHeal()
ExecuteOrderFromTable({
UnitIndex = thisEntity:entindex(),
OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
TargetIndex = thisEntity:entindex(),
AbilityIndex = creature_heal:entindex(),
Queue = false,
})
return 0.5
end
function CastHealToEnemy( enemy )
if enemy == 0 then
return
end
ExecuteOrderFromTable({
UnitIndex = thisEntity:entindex(),
OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
TargetIndex = enemy:entindex(),
AbilityIndex = creature_heal_damage:entindex(),
Queue = false,
})
return 0.5
end
function CastDmg( enemy )
ExecuteOrderFromTable({
UnitIndex = thisEntity:entindex(),
OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
TargetIndex = enemy:entindex(),
AbilityIndex = creature_damage:entindex(),
Queue = false,
})
return 0.5
end
thisEntity:SetContextThink( "AIThink", AIThink, 0.5 )
if not IsServer() then
return
end
if thisEntity == nil then
return
end
creature_heal = thisEntity:FindAbilityByName( "dota_ability_creature_heal" )
creature_damage = thisEntity:FindAbilityByName( "dota_ability_creature_damage" )
creature_heal_damage = thisEntity:FindAbilityByName( "dota_ability_creature_heal_damage" )
end
function AIThink()
if ( not thisEntity:IsAlive() ) then
return -1
end
if GameRules:IsGamePaused() == true then
return 1
end
local enemies = FindUnitsInRadius(thisEntity:GetTeamNumber(), thisEntity:GetAbsOrigin(), nil, 99999, DOTA_UNIT_TARGET_TEAM_ENEMY, DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES, FIND_CLOSEST, false )
if enemies == 0 then
return
end
if #enemies > 0 then
if creature_heal_damage:IsFullyCastable() and creature_heal_damage ~= nil then
return CastHealToEnemy( enemies [1] )
end
if thisEntity:GetHealth() < ( thisEntity:GetMaxHealth() * 0.5 ) then
if creature_heal:IsFullyCastable() and creature_heal ~= nil then
return CastHeal()
end
end
if creature_damage ~= nil and creature_damage:IsFullyCastable() then
for i=1, #enemies do
if enemies:GetHealth() < ( enemies:GetMaxHealth() * 0.1 ) then
return CastDmg( enemies [1] )
end
end
end
end
return 0.5
end
------------------------------------------ABILITY CASTS------------------------------------
function CastHeal()
ExecuteOrderFromTable({
UnitIndex = thisEntity:entindex(),
OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
TargetIndex = thisEntity:entindex(),
AbilityIndex = creature_heal:entindex(),
Queue = false,
})
return 0.5
end
function CastHealToEnemy( enemy )
if enemy == 0 then
return
end
ExecuteOrderFromTable({
UnitIndex = thisEntity:entindex(),
OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
TargetIndex = enemy:entindex(),
AbilityIndex = creature_heal_damage:entindex(),
Queue = false,
})
return 0.5
end
function CastDmg( enemy )
ExecuteOrderFromTable({
UnitIndex = thisEntity:entindex(),
OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
TargetIndex = enemy:entindex(),
AbilityIndex = creature_damage:entindex(),
Queue = false,
})
return 0.5
end
Game code (account 0) tried to execute invalid order (26). Target can't be seen by the unit's team.