edit | blame | history | raw
local CONST     = require 'config.const'
local Suspicion = require 'systems.suspicion'
local Base      = require 'profession.base'

Base.register('hound', function(unit, ability)
    local scan = clicli.area.create_circle_area(unit:get_point(), 8)
    local all  = scan:get_all_unit_in_area()
    scan:remove()

    local target = nil
    for _, u in ipairs(all) do
        if u ~= unit and u:is_alive() then
            target = u
            break
        end
    end
    if not target then return end

    target:add_buff({ key = CONST.BUFF_TRACKED, source = unit, time = 20.0 })

    clicli.timer.loop(1.0, function(timer, count)
        if count > 20 then
            timer:remove()
            return
        end
        if not target:is_alive() then
            timer:remove()
            return
        end

        if target:has_tag('npc') then
            target:remove_buffs_by_key(CONST.BUFF_TRACKED)
            timer:remove()
            local abi = unit:find_ability('英雄', CONST.ABI_BLOOD_TRACK)
            if abi then
                local remaining = abi:get_cd()
                abi:set_cd(remaining * 0.5)
            end
            return
        end

        -- 玩家目标:通过本地特效显示脚印(仅施法者可见)
        clicli.player.with_local(function(local_player)
            if local_player == unit:get_owner() then
                local tpos = target:get_point()
                clicli.particle.create({
                    type   = CONST.SFX_FOOTPRINT,
                    target = tpos,
                    time   = 2.0,
                    scale  = 1.0,
                    angle  = 0,
                })
            end
        end)
    end, '血迹追踪')

    Suspicion.add(unit, 8)
end)

return Base