#Controllable tower

1 messages · Page 1 of 1 (latest)

dry pagoda
#

Hello everyone, I was trying to write an ability that will put the tower under the control of the player for a certain period of time (1 screenshot) and an ability that will set the way of movement (2 screenshots). I don't know why, but the console gives an error: Client tried to execute invalid order (31). Order invalid for units with movement capability DOTA_UNIT_CAP_MOVE_NONE.I suspect that the error is related to the tower.
I specifically added a timer after the modifier disappears so that the tower can teleport even with the DOTA_UNIT_CAP_MOVE_NONE class, but it doesn't work.
Who knows why this happens?

#

In short: The tower is moving, but for some reason it still considers the movement class as DATA_UNIT_CAP_MOVE_GROUND, which is why teleportation does not occur.

dry pagoda
#
LinkLuaModifier("modifier_npc_tower_check_move", "abilities/npc_tower_check_move", LUA_MODIFIER_MOTION_NONE)
npc_tower_check_move = class({})

function npc_tower_check_move:GetIntrinsicModifierName()
    return "modifier_npc_tower_check_move"
end
modifier_npc_tower_check_move = class({})

function modifier_npc_tower_check_move:OnCreated()
    self:StartIntervalThink(0.1)
end

function modifier_npc_tower_check_move:OnIntervalThink()
    local parent = self:GetParent()
    local controllableModif = parent:FindModifierByName("modifier_npc_treant_controllable")

    if controllableModif then
        parent:SetMoveCapability(DOTA_UNIT_CAP_MOVE_GROUND)
    end
    if controllableModif == nil then
        Timers:CreateTimer(0.7, function()
            parent:SetMoveCapability(DOTA_UNIT_CAP_MOVE_NONE)
        end)
    end
end

No more errors are caused, but for some reason the tower is still not moving.

ashen mural
#

I don't exactly understand what you're trying to do. On the one hand you keep saying "teleportation" but on the other end you're saying the tower is not moving.

#

Can you explain what you're trying to do exactly?

#

Why not make the tower always have DOTA_UNIT_CAP_MOVE_GROUND capabilities but make it rooted when it's not supposed to be moving?

#

That's much easier than having to change Move Capabilities imo

dry pagoda
ashen mural
#

Easiest way to do it is make it change teams to your team then. When 30 seconds elapse, it changes teams back to neutral and teleports to starting position

#

Ah, the ability is on the tower, sorry. Thought it is on the hero

#

Well in that case you can make it rooted like I said, when you use the ability you lift the root and let it move

dry pagoda
#

If the tower always has DOTA_UNIT_CAP_MOVE_GROUND in KV, then the tower will run after the hero by itself, even if it is not controlled by the player.

dry pagoda
#

I created a modifier and linked it using addon_init

modifier_tower_root = class({})

function modifier_tower_root:CheckState()
    return
    {
        [MODIFIER_STATE_ROOTED] = true,
    }
end

In KV I write

DOTA_UNIT_CAP_MOVE_GROUND
if target:GetUnitName() == "npc_dota_custom_tower_long_1" and target:GetTeamNumber() == DOTA_TEAM_GOODGUYS then
            target:AddNewModifier(self:GetCaster(), self, "modifier_npc_treant_controllable", {duration = self:GetSpecialValueFor("duration")})
            local caster = self:GetCaster()
            local id = caster:GetPlayerID()
            target:SetBaseMoveSpeed(300)
            target:SetOwner(caster)
            target:SetControllableByPlayer(id, true)
            target:RemoveModifierByName("modifier_tower_root")
            local point_g_l_1 = Entities:FindByName(nil, "tower_long_good_1")
            Timers:CreateTimer(self:GetSpecialValueFor("duration"), function()
                if not target:IsNull() then
                    target:SetOwner(nil)
                    target:SetBaseMoveSpeed(0)
                    target:SetControllableByPlayer(-1, false)
                    FindClearSpaceForUnit(target, point_g_l_1:GetAbsOrigin(), true)
                    target:AddNewModifier(nil, nil, "modifier_tower_root", {duration = -1})
                end
            end)
        end 

But the tower doesn't teleport on start position. The console does not provide information

#

OK, I found the problem.

#

FindClearSpaceForUnit does not work on towers

#

SetAbsOrigin

#

Now I use

ashen mural
#

You'd rather use SetAbsOrigin because FindClearSpaceForUnit would make the tower not be placed exactly where you'd want (if it worked)

#

you need to make sure to find all units in the tower's radius after you do SetAbsOrigin and do FindClearSpaceForUnit on them though, otherwise they could get stuck inside the tower

worthy cairnBOT
#

Found 1 function for resolve

🇸 ResolveNPCPositions(location: Vector, radius: float): nil
Check and fix units that have been assigned a position inside collision radius of other NPCs.

strange mountain
#

this is better