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
|