薛之猫大王
2026-02-22 3b98d982bed635e986ab09f8185cfa9b9b2c33bb
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
local CONST     = require 'config.const'
local Balance   = require 'config.balance'
 
local M = {}
 
-- ---------------------------------------------------------
-- 开始换装(对尸体换衣)
-- ---------------------------------------------------------
function M.start_disguise(player_unit, corpse_unit)
    if not corpse_unit:has_tag('corpse') then return false end
    if not player_unit:is_in_radius(corpse_unit, 2.0) then return false end
    if player_unit:storage_get('is_disguising') then return false end
 
    player_unit:storage_set('is_disguising', true)
    player_unit:add_state(CONST.STATE_IMMOBILE)
    player_unit:play_animation('channel', 1.0, 0, -1, false, true)
 
    local prof = player_unit:storage_get('profession')
    local dur  = (prof == 'mimic') and Balance.DISGUISE_TIME_MIMIC or Balance.DISGUISE_TIME
 
    clicli.timer.wait(dur, function()
        if not player_unit:is_alive() then
            player_unit:storage_set('is_disguising', false)
            return
        end
 
        local Suspicion = require 'systems.suspicion'
 
        local old_model = player_unit:storage_get('current_model')
        player_unit:storage_set('previous_model', old_model)
 
        local new_model = corpse_unit:storage_get('model_key')
 
        if new_model then
            player_unit:replace_model(new_model)
        end
        player_unit:storage_set('current_model', new_model)
 
        Suspicion.set(player_unit, 0)
 
        player_unit:remove_state(CONST.STATE_IMMOBILE)
        player_unit:stop_cur_animation()
        player_unit:storage_set('is_disguising', false)
 
        -- 尸体换成旧外观(留下的"证据")
        if old_model then
            corpse_unit:replace_model(old_model)
            corpse_unit:storage_set('model_key', old_model)
        end
    end)
 
    return true
end
 
-- ---------------------------------------------------------
-- 玩家互动点降低怀疑值
-- ---------------------------------------------------------
function M.try_player_interact(player_unit)
    local Suspicion = require 'systems.suspicion'
    local pos = player_unit:get_point()
 
    local interact_tags = {
        { tag = 'interact_bench',  anim = 'sit',   sus_reduce = -10, time_min = 8,  time_max = 15 },
        { tag = 'interact_board',  anim = 'look',  sus_reduce = -8,  time_min = 5,  time_max = 10 },
        { tag = 'interact_well',   anim = 'wash',  sus_reduce = -6,  time_min = 5,  time_max = 8  },
        { tag = 'interact_vendor', anim = 'trade', sus_reduce = -8,  time_min = 6,  time_max = 12 },
    }
 
    for _, cfg in ipairs(interact_tags) do
        local areas = clicli.area.get_circle_areas_by_tag(cfg.tag)
        for _, area in ipairs(areas) do
            if area:is_point_in_area(pos) then
                player_unit:stop()
                player_unit:play_animation(cfg.anim, 1.0, 0, -1, true, false)
                Suspicion.add(player_unit, cfg.sus_reduce)
                player_unit:storage_set('interacting', true)
 
                local wait = math.random(cfg.time_min, cfg.time_max)
                clicli.timer.wait(wait, function()
                    player_unit:stop_cur_animation()
                    player_unit:storage_set('interacting', false)
                end)
                return true
            end
        end
    end
 
    return false
end
 
return M