薛之猫大王
2026-02-22 35593fff68c76413ce82a918e56f127355bf6c55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local CONST     = require 'config.const'
local Suspicion = require 'systems.suspicion'
local Base      = require 'profession.base'
 
local trap_count = {}
 
Base.register('surgeon', function(unit, ability)
    local pid = unit:get_owner():get_id()
    trap_count[pid] = trap_count[pid] or 0
    if trap_count[pid] >= 2 then return end
 
    local pos = unit:get_point()
    local trap_area = clicli.area.create_circle_area(pos, 1.5)
    trap_area:add_tag('trap')
    trap_count[pid] = trap_count[pid] + 1
 
    Suspicion.add(unit, 5)
 
    clicli.timer.loop(0.5, function(timer, count)
        if count > 180 then
            trap_area:remove()
            timer:remove()
            trap_count[pid] = math.max(0, (trap_count[pid] or 1) - 1)
            return
        end
 
        local trapped_units = trap_area:get_all_unit_in_area()
        for _, u in ipairs(trapped_units) do
            if u:has_tag('player_controlled') and u ~= unit and u:is_alive() then
                u:add_state(CONST.STATE_IMMOBILE)
                u:add_buff({ key = CONST.BUFF_TRAP_ROOT, time = 2.0 })
                clicli.timer.wait(2.0, function()
                    u:remove_state(CONST.STATE_IMMOBILE)
                end)
 
                trap_area:remove()
                timer:remove()
                trap_count[pid] = math.max(0, (trap_count[pid] or 1) - 1)
                return
            end
        end
    end, '陷阱检测')
end)
 
return Base