mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-17 04:52:26 +08:00
更新配置表
This commit is contained in:
99
gdconf/game_data_config/lua/common/V3_6/CodedLock.lua
Normal file
99
gdconf/game_data_config/lua/common/V3_6/CodedLock.lua
Normal file
@@ -0,0 +1,99 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
|
||||
--======================================================================================================================
|
||||
--|| Filename || CodedLock
|
||||
--|| RelVersion || V3_4
|
||||
--|| Owner || chao-jin
|
||||
--|| Description ||
|
||||
--|| LogName || ##[CodedLock]
|
||||
--|| Protection || 3.6版本的能量开关
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs
|
||||
--[[
|
||||
local defs = {
|
||||
opt_id = 91004,
|
||||
rotor_top = 91003,
|
||||
rotor_mid = 91002,
|
||||
rotor_bot = 91001,
|
||||
reminder_success = 400112,
|
||||
}
|
||||
local rotor_map = {
|
||||
[91001] = {init_state = 1, end_state = 3},
|
||||
[91002] = {init_state = 3, end_state = 2},
|
||||
[91003] = {init_state = 4, end_state = 4},
|
||||
}
|
||||
]]
|
||||
local CodedLock_Triggers = {
|
||||
[1] = { name = "group_load", config_id = 8001001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
|
||||
[2] = { name = "select_option", config_id = 8001002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
|
||||
[3] = { name = "gadget_state_change", config_id = 8001003, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
|
||||
|
||||
}
|
||||
|
||||
function CodedLock_Initialize()
|
||||
for k,v in pairs(CodedLock_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
|
||||
end
|
||||
--======================================================================================================================
|
||||
--Events
|
||||
function action_group_load(context, evt)
|
||||
if 0 ~= ScriptLib.GetGroupVariableValue(context, "Finished") then
|
||||
return 0
|
||||
end
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.opt_id, {811,812,813})
|
||||
for rotor_id,infos in pairs(rotor_map) do
|
||||
ScriptLib.SetGadgetStateByConfigId(context, rotor_id, (infos.init_state-1))
|
||||
for i=1,4 do
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface0"..i, 0)
|
||||
end
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface0"..infos.init_state, 1)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function action_select_option(context, evt)
|
||||
if evt.param2 == 811 then
|
||||
LF_RotateRotor(context, defs.rotor_top)
|
||||
end
|
||||
if evt.param2 == 812 then
|
||||
LF_RotateRotor(context, defs.rotor_mid)
|
||||
end
|
||||
if evt.param2 == 813 then
|
||||
LF_RotateRotor(context, defs.rotor_bot)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function action_gadget_state_change(context, evt)
|
||||
if rotor_map[defs.rotor_top].end_state-1 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.rotor_top) and
|
||||
rotor_map[defs.rotor_mid].end_state-1 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.rotor_mid) and
|
||||
rotor_map[defs.rotor_bot].end_state-1 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.rotor_bot) then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.opt_id, {})
|
||||
ScriptLib.ShowReminder(context, defs.reminder_success)
|
||||
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions
|
||||
--旋转转子
|
||||
function LF_RotateRotor(context, rotor_id)
|
||||
for i=1,4 do
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface0"..i, 0)
|
||||
end
|
||||
local rotor_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, rotor_id)
|
||||
if rotor_state < 3 then
|
||||
ScriptLib.SetGadgetStateByConfigId(context, rotor_id, rotor_state+1)
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface0"..(rotor_state+2), 1)
|
||||
else
|
||||
ScriptLib.SetGadgetStateByConfigId(context, rotor_id, 0)
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface01", 1)
|
||||
end
|
||||
end
|
||||
|
||||
CodedLock_Initialize()
|
||||
134
gdconf/game_data_config/lua/common/V3_6/DrumRegexp.lua
Normal file
134
gdconf/game_data_config/lua/common/V3_6/DrumRegexp.lua
Normal file
@@ -0,0 +1,134 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
|
||||
--======================================================================================================================
|
||||
--|| Filename || DrumRegexp
|
||||
--|| RelVersion || V3_4
|
||||
--|| Owner || chao-jin
|
||||
--|| Description ||
|
||||
--|| LogName || ##[DrumRegexp]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs
|
||||
local defs = {
|
||||
drum = 800001,
|
||||
reminder_success = 400112,
|
||||
reminder_fail = 400113,
|
||||
}
|
||||
|
||||
--local music_list = {"100110100101","110101011101","101010011101"}
|
||||
local music_list = {"11001","11101"}
|
||||
local music_len = 5
|
||||
|
||||
--======================================================================================================================
|
||||
--Events
|
||||
local DrumRegexp_Triggers = {
|
||||
[1] = { name = "group_load", config_id = 8002001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
|
||||
}
|
||||
|
||||
function DrumRegexp_Initialize()
|
||||
for k,v in pairs(DrumRegexp_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
end
|
||||
|
||||
DrumRegexp_Initialize()
|
||||
|
||||
--加载Group时的操作
|
||||
function action_group_load(context, evt)
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:加载敲鼓玩法Group")
|
||||
LF_ResetBeatMark(context)
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions
|
||||
--玩家攻击敲鼓的SLC
|
||||
function SLC_DrumPercussReg(context, beat_time)
|
||||
--[[
|
||||
if 0 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.drum) then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]: 已经完成了")
|
||||
return 0
|
||||
end
|
||||
]]
|
||||
if beat_time > 1 then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:在一个区间内敲击了多次,直接失败")
|
||||
LF_RegexpPlayFail(context)
|
||||
return 0
|
||||
end
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:敲鼓SLC,敲鼓次数"..beat_time)
|
||||
local reg_dec = ScriptLib.GetGroupTempValue(context, "RegDec", {})
|
||||
local reg_bin = LF_DecToBinStr(reg_dec)
|
||||
reg_bin = reg_bin..(math.ceil(beat_time))
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:当前谱"..reg_bin)
|
||||
if string.len(reg_bin) == 5 then
|
||||
for i=1,2 do
|
||||
if music_list[i] == reg_bin then
|
||||
LF_RegexpPlaySuccess(context)
|
||||
return 0
|
||||
end
|
||||
end
|
||||
LF_RegexpPlayFail(context)
|
||||
return 0
|
||||
end
|
||||
ScriptLib.SetGroupTempValue(context, "RegDec", LF_BinStrToDec(reg_bin), {})
|
||||
return 0
|
||||
end
|
||||
|
||||
--玩家长时间未敲鼓的SLC
|
||||
function SLC_DrumPercussRegEnd(context)
|
||||
--[[
|
||||
if 0 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.drum) then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]: 已经完成了")
|
||||
return 0
|
||||
end
|
||||
]]
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:超时未敲鼓,失败")
|
||||
LF_RegexpPlayFail(context)
|
||||
return 0
|
||||
end
|
||||
|
||||
--初始化鼓的敲击标记
|
||||
function LF_ResetBeatMark(context)
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:初始化节拍监听变量")
|
||||
ScriptLib.SetGroupTempValue(context, "RegDec", 1, {}) --记录当前匹配到的列表
|
||||
end
|
||||
|
||||
--演奏成功
|
||||
function LF_RegexpPlaySuccess(context)
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:演奏成功")
|
||||
LF_ResetBeatMark(context)
|
||||
ScriptLib.SetGadgetStateByConfigId(context, defs.drum, 201)
|
||||
ScriptLib.ShowReminder(context, defs.reminder_success)
|
||||
end
|
||||
|
||||
--演奏失败
|
||||
function LF_RegexpPlayFail(context)
|
||||
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:演奏失败")
|
||||
LF_ResetBeatMark(context)
|
||||
ScriptLib.ShowReminder(context, defs.reminder_fail)
|
||||
end
|
||||
|
||||
--把信息从十进制转成二进制的字符串
|
||||
function LF_DecToBinStr(dec_num)
|
||||
--转进制,字符的长度做一定的限制
|
||||
local bin_str = ""
|
||||
dec_num = math.ceil(dec_num)
|
||||
for i=1,16 do
|
||||
if dec_num ~= 0 then
|
||||
bin_str = bin_str..(dec_num%2)
|
||||
dec_num = math.floor(dec_num/2)
|
||||
else
|
||||
return string.reverse(bin_str)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--把二进制字符串变成十进制
|
||||
function LF_BinStrToDec(bin_str)
|
||||
local len = string.len(bin_str)
|
||||
local dec_num = 0
|
||||
for i=1,len do
|
||||
dec_num = dec_num + (2^(len-i))*tonumber(string.sub(bin_str,i,i))
|
||||
end
|
||||
return dec_num
|
||||
end
|
||||
197
gdconf/game_data_config/lua/common/V3_6/DrumSingle.lua
Normal file
197
gdconf/game_data_config/lua/common/V3_6/DrumSingle.lua
Normal file
@@ -0,0 +1,197 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
|
||||
--======================================================================================================================
|
||||
--|| Filename || DrumSingle
|
||||
--|| RelVersion || V3_4
|
||||
--|| Owner || chao-jin
|
||||
--|| Description || 对应Gadget 70900431
|
||||
--|| LogName || ##[DrumSingle]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--[[Defs & Miscs
|
||||
local defs = {
|
||||
drum = 77001, --鼓的ConfigID
|
||||
interval = 2, --敲鼓的节奏间隔
|
||||
reminder_success = 400112,
|
||||
reminder_fail = 400113,
|
||||
}
|
||||
--敲鼓的节奏, 0空 1普攻 2下落 70900431鼓ID
|
||||
local music_staff = {0,1,0,1, 1,0,1,0, 0,1,0,1}
|
||||
]]
|
||||
local OPTION = {
|
||||
SINGLE = 809,
|
||||
REGEXP = 810,
|
||||
}
|
||||
|
||||
--======================================================================================================================
|
||||
--Events
|
||||
local DrumSingle_Triggers = {
|
||||
[1] = { name = "group_load", config_id = 8001001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_single_group_load", trigger_count = 0},
|
||||
[2] = { name = "select_option", config_id = 8001002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_single_select_option", trigger_count = 0},
|
||||
[3] = { name = "time_axis_pass", config_id = 8001003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_single_time_axis_pass", trigger_count = 0},
|
||||
[4] = { name = "enter_region", config_id = 8001004, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0},
|
||||
[5] = { name = "leave_region", config_id = 8001005, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0},
|
||||
|
||||
}
|
||||
|
||||
function DrumSingle_Initialize()
|
||||
for k,v in pairs(DrumSingle_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
|
||||
end
|
||||
|
||||
DrumSingle_Initialize()
|
||||
|
||||
--加载Group时的操作
|
||||
function action_single_group_load(context, evt)
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:加载敲鼓玩法Group")
|
||||
LF_ResetBeatMark(context)
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.drum, {OPTION.SINGLE})
|
||||
return 0
|
||||
end
|
||||
|
||||
function action_enter_region(context,evt)
|
||||
return 0
|
||||
end
|
||||
|
||||
function action_leave_region(context,evt)
|
||||
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_Drum_Play_Start", 0)
|
||||
return 0
|
||||
end
|
||||
--玩家交互开始敲鼓玩法
|
||||
function action_single_select_option(context, evt)
|
||||
--单曲模式
|
||||
if evt.param2 == OPTION.SINGLE then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:敲鼓玩法,单曲演奏模式")
|
||||
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_Drum_Play_Start", 1)
|
||||
ScriptLib.SetGroupTempValue(context, "PlayMode", OPTION.SINGLE, {})
|
||||
if music_staff[1] ~= nil then
|
||||
--同步每个区间是否可以敲击
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:更新鼓状态,可以敲击")
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.drum, "SGV_DrumAxis", 1)
|
||||
end
|
||||
ScriptLib.InitTimeAxis(context, "MusicPlay", {defs.interval}, true)
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.drum, {})
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--检测敲击的时间轴
|
||||
function action_single_time_axis_pass(context, evt)
|
||||
if evt.source_name == "MusicPlay" then
|
||||
--处理单曲模式
|
||||
-- if OPTION.SINGLE == ScriptLib.GetGroupTempValue(context, "PlayMode", {}) then
|
||||
local pre_beat_index = ScriptLib.GetGroupTempValue(context, "BeatIndex", {})
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:上一个节拍"..pre_beat_index)
|
||||
--处理上一个节拍是否错过,如果错过了就直接处理失败
|
||||
if music_staff[pre_beat_index] ~= nil then
|
||||
if music_staff[pre_beat_index] ~= ScriptLib.GetGroupTempValue(context, "LastBeatType", {}) then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]: 上一个节拍 MISS")
|
||||
LF_SinglePlayFail(context)
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
--初始化下一个时间段内的记录变量,更新鼓的状态
|
||||
ScriptLib.SetGroupTempValue(context, "BeatPercussed", 0, {})
|
||||
ScriptLib.SetGroupTempValue(context, "LastBeatType", 0, {})
|
||||
if music_staff[pre_beat_index+1] ~= nil then
|
||||
--同步下一个区间可以敲击
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:更新鼓状态,可以敲击")
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.drum, "SGV_DrumAxis", pre_beat_index+1)
|
||||
else
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:没有下一个节拍了,成功")
|
||||
LF_SinglePlaySuccess(context)
|
||||
end
|
||||
|
||||
-- end
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:节拍+1")
|
||||
ScriptLib.ChangeGroupTempValue(context, "BeatIndex", 1, {})
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions
|
||||
--玩家攻击敲鼓的SLC
|
||||
function SLC_DrumPercussSingle(context, beat_timing, beat_type)
|
||||
local play_mode = ScriptLib.GetGroupTempValue(context, "PlayMode", {})
|
||||
if play_mode == 0 then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:演奏未开始,不处理敲击事件")
|
||||
return 0
|
||||
end
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:[SLC]敲鼓")
|
||||
|
||||
--获取是否进行过敲击
|
||||
local has_percussed = ScriptLib.GetGroupTempValue(context, "BeatPercussed", {})
|
||||
if 0 ~= ScriptLib.GetGroupTempValue(context, "BeatPercussed", {}) then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:当前节拍重复敲击,失败")
|
||||
LF_SinglePlayFail(context)
|
||||
return 0
|
||||
end
|
||||
ScriptLib.SetGroupTempValue(context, "LastBeatType", beat_type, {})
|
||||
--获取当前的敲击序列
|
||||
local staff_index = ScriptLib.GetGroupTempValue(context, "BeatIndex", {})
|
||||
--单曲模式校验
|
||||
if play_mode == OPTION.SINGLE then
|
||||
if music_staff[staff_index] ~= 0 then
|
||||
if beat_timing == 0 then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:未在敲击区间内敲击,失败")
|
||||
LF_SinglePlayFail(context)
|
||||
return 0
|
||||
else
|
||||
if music_staff[staff_index] ~= beat_type then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:敲击方式错误,失败"..beat_type)
|
||||
LF_SinglePlayFail(context)
|
||||
return 0
|
||||
end
|
||||
--最后一个节拍敲完
|
||||
if staff_index >= #music_staff then
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:全部节拍完成")
|
||||
LF_SinglePlaySuccess(context)
|
||||
return 0
|
||||
end
|
||||
end
|
||||
else
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:在非敲击节拍上进行敲击,失败处理")
|
||||
LF_SinglePlayFail(context)
|
||||
return 0
|
||||
end
|
||||
end
|
||||
--标记进行过敲击
|
||||
ScriptLib.SetGroupTempValue(context, "BeatPercussed", 1, {})
|
||||
return 0
|
||||
end
|
||||
|
||||
--初始化鼓的敲击标记
|
||||
function LF_ResetBeatMark(context)
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:初始化节拍监听变量")
|
||||
ScriptLib.SetGroupTempValue(context, "BeatIndex", 1, {}) --记录当前需要查询的节拍
|
||||
ScriptLib.SetGroupTempValue(context, "BeatPercussed", 0, {}) --当前节拍是否敲击过(同一个节拍只能敲击一次)
|
||||
ScriptLib.SetGroupTempValue(context, "PlayMode", 0, {}) --当前的敲击模式是哪一种
|
||||
ScriptLib.SetGroupTempValue(context, "LastBeatType", 0, {})
|
||||
--设置鼓的SGV
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.drum, "SGV_DrumAxis", 0)
|
||||
end
|
||||
|
||||
--演奏成功
|
||||
function LF_SinglePlaySuccess(context)
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:演奏成功")
|
||||
ScriptLib.EndTimeAxis(context, "MusicPlay")
|
||||
LF_ResetBeatMark(context)
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.drum, {OPTION.SINGLE})
|
||||
ScriptLib.ShowReminder(context, defs.reminder_success)
|
||||
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
|
||||
end
|
||||
|
||||
--演奏失败
|
||||
function LF_SinglePlayFail(context)
|
||||
ScriptLib.PrintContextLog(context, "##[DrumSingle]:演奏失败")
|
||||
ScriptLib.EndTimeAxis(context, "MusicPlay")
|
||||
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_Drum_Play_Start", 0)
|
||||
LF_ResetBeatMark(context)
|
||||
--失败则初始化操作台
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.drum, {OPTION.SINGLE})
|
||||
ScriptLib.ShowReminder(context, defs.reminder_fail)
|
||||
end
|
||||
205
gdconf/game_data_config/lua/common/V3_6/EnergyPillar.lua
Normal file
205
gdconf/game_data_config/lua/common/V3_6/EnergyPillar.lua
Normal file
@@ -0,0 +1,205 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
|
||||
--======================================================================================================================
|
||||
--|| Filename || EnergyPillar
|
||||
--|| RelVersion || V3_4
|
||||
--|| Owner || chao-jin
|
||||
--|| Description ||
|
||||
--|| LogName || ##[EnergyPillar]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs
|
||||
local defs = {
|
||||
pillar_top = 90003,
|
||||
pillar_mid = 90002,
|
||||
pillar_bot = 90001,
|
||||
operator_1 = 90004,
|
||||
operator_2 = 90005,
|
||||
operator_3 = 90006,
|
||||
}
|
||||
|
||||
local pillar_decals = {
|
||||
[90001] = {"E","F","F"},
|
||||
[90002] = {"C","D","C"},
|
||||
[90003] = {"A","B","A"},
|
||||
}
|
||||
|
||||
local pillar_answers = {
|
||||
[1] = "FCA",
|
||||
[2] = "ECB",
|
||||
[3] = "FDA",
|
||||
}
|
||||
|
||||
local pillar_state_map = {
|
||||
[90004] ={ {state = 0, sgv = "SGV_Surface01"}, {state = 1, sgv = "SGV_Surface02"},{state = 2, sgv = "SGV_Surface03"}},
|
||||
[90005] ={ {state = 0, sgv = "SGV_Surface02"}, {state = 1, sgv = "SGV_Surface03"},{state = 2, sgv = "SGV_Surface01"}},
|
||||
[90006] ={ {state = 0, sgv = "SGV_Surface03"}, {state = 1, sgv = "SGV_Surface01"},{state = 2, sgv = "SGV_Surface02"}},
|
||||
}
|
||||
|
||||
local OPTION = {
|
||||
TOP = 811,
|
||||
MID = 812,
|
||||
BOT = 813,
|
||||
}
|
||||
--======================================================================================================================
|
||||
local EP_Triggers = {
|
||||
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
|
||||
{ name = "select_option", config_id = 8000102, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
|
||||
}
|
||||
--Events
|
||||
function action_group_load(context, evt)
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.operator_1, {811,812,813})
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.operator_2, {811,812,813})
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.operator_3, {811,812,813})
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
function action_select_option(context, evt)
|
||||
--处理电源的开关
|
||||
if evt.param2 == OPTION.TOP then
|
||||
LF_TurnPillar(context, defs.pillar_top)
|
||||
LF_CheckCombine(context)
|
||||
end
|
||||
if evt.param2 == OPTION.MID then
|
||||
LF_TurnPillar(context, defs.pillar_mid)
|
||||
LF_CheckCombine(context)
|
||||
end
|
||||
if evt.param2 == OPTION.BOT then
|
||||
LF_TurnPillar(context, defs.pillar_bot)
|
||||
LF_CheckCombine(context)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function action_gadget_state_change(context, evt)
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions
|
||||
function LF_TurnPillar(context, pillar_id)
|
||||
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, pillar_id)
|
||||
if gadget_state == 0 then
|
||||
ScriptLib.SetGadgetStateByConfigId(context, pillar_id, 1)
|
||||
return 0
|
||||
end
|
||||
if gadget_state == 1 then
|
||||
ScriptLib.SetGadgetStateByConfigId(context, pillar_id, 2)
|
||||
return 0
|
||||
end
|
||||
if gadget_state == 2 then
|
||||
ScriptLib.SetGadgetStateByConfigId(context, pillar_id, 0)
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
--通过gadgetstate来拿一个转子的排列顺序,以State0的初始方向为基准
|
||||
function LF_GetPillarDecalSeq(context, pillar_id)
|
||||
local state_pillar = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, pillar_id)
|
||||
if state_pillar == 0 then
|
||||
return {
|
||||
{decal = pillar_decals[pillar_id][1], sgv_key = "SGV_Surface01", p_id = pillar_id},
|
||||
{decal = pillar_decals[pillar_id][2], sgv_key = "SGV_Surface02", p_id = pillar_id},
|
||||
{decal = pillar_decals[pillar_id][3], sgv_key = "SGV_Surface03", p_id = pillar_id},
|
||||
}
|
||||
end
|
||||
if state_pillar == 1 then
|
||||
return {
|
||||
{decal = pillar_decals[pillar_id][2], sgv_key = "SGV_Surface02", p_id = pillar_id},
|
||||
{decal = pillar_decals[pillar_id][3], sgv_key = "SGV_Surface03", p_id = pillar_id},
|
||||
{decal = pillar_decals[pillar_id][1], sgv_key = "SGV_Surface01", p_id = pillar_id},
|
||||
}
|
||||
end
|
||||
if state_pillar == 2 then
|
||||
return {
|
||||
{decal = pillar_decals[pillar_id][3], sgv_key = "SGV_Surface03", p_id = pillar_id},
|
||||
{decal = pillar_decals[pillar_id][1], sgv_key = "SGV_Surface01", p_id = pillar_id},
|
||||
{decal = pillar_decals[pillar_id][2], sgv_key = "SGV_Surface02", p_id = pillar_id},
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function LF_CheckCombine(context)
|
||||
--先把所有的面全部重置为0
|
||||
for pillar_id,v in pairs(pillar_decals) do
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface01", 0)
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface02", 0)
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface03", 0)
|
||||
end
|
||||
--拿到每个转子的状态
|
||||
local pillar_map = {}
|
||||
|
||||
for pillar_id, decal_str in pairs(pillar_decals) do
|
||||
table.insert( pillar_map, LF_GetPillarDecalSeq(context, pillar_id))
|
||||
end
|
||||
--[[
|
||||
local pillar_map = {
|
||||
[1] = { --转子1
|
||||
{decal = a, sgv_key = 1, p_id = 1},
|
||||
{decal = b, sgv_key = 2, p_id = 1},
|
||||
{decal = a, sgv_key = 3, p_id = 1},
|
||||
},
|
||||
[2] = { --转子2
|
||||
{decal = c, sgv_key = 1, p_id = 2},
|
||||
{decal = d, sgv_key = 2, p_id = 2},
|
||||
{decal = c, sgv_key = 3, p_id = 2},
|
||||
},
|
||||
[3] = { --转子3
|
||||
{decal = e, sgv_key = 1, p_id = 3},
|
||||
{decal = f, sgv_key = 2, p_id = 3},
|
||||
{decal = f, sgv_key = 3, p_id = 3},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
]]
|
||||
--把三个转子的纵向面连接起来,做一个StringList
|
||||
local pillar_combines = {}
|
||||
for i=1,3 do
|
||||
pillar_combines[i] = pillar_map[1][i].decal..pillar_map[2][i].decal..pillar_map[3][i].decal
|
||||
end
|
||||
local right_indexs = {}
|
||||
|
||||
--每个StringList去和解做比较,符合解就把这组压到答案组里
|
||||
for i=1,3 do
|
||||
for j=1,3 do
|
||||
if pillar_combines[i] == pillar_answers[j] then
|
||||
table.insert(right_indexs, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
--没有匹配的返回
|
||||
if #right_indexs == 0 then
|
||||
return 0
|
||||
else
|
||||
--有匹配的就会去找对应的面
|
||||
if #right_indexs < 3 then
|
||||
for i=1,#right_indexs do
|
||||
local idx = right_indexs[i]
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_map[1][idx].p_id, pillar_map[1][idx].sgv_key, 1)
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_map[2][idx].p_id, pillar_map[2][idx].sgv_key, 1)
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_map[3][idx].p_id, pillar_map[3][idx].sgv_key, 1)
|
||||
end
|
||||
end
|
||||
if #right_indexs == 3 then
|
||||
for pillar_id,v in pairs(pillar_decals) do
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface01", 1)
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface02", 1)
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface03", 1)
|
||||
end
|
||||
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--初始化
|
||||
function EP_Initialize()
|
||||
for k,v in pairs(EP_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
|
||||
end
|
||||
|
||||
EP_Initialize()
|
||||
825
gdconf/game_data_config/lua/common/V3_6/EnergyTransform.lua
Normal file
825
gdconf/game_data_config/lua/common/V3_6/EnergyTransform.lua
Normal file
@@ -0,0 +1,825 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
|
||||
--======================================================================================================================
|
||||
--|| Filename || EnergyTransform
|
||||
--|| RelVersion || V3_4
|
||||
--|| Owner || chao-jin
|
||||
--|| Description || 重构的能量传递Require
|
||||
--|| LogName || ##[EnergyTrans]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs
|
||||
--[[
|
||||
local DIR = {Up = 0,Right = 1,Down = 2,Left = 3,None = 4,}
|
||||
--转换器的列表,1表示可移动
|
||||
local defs = {
|
||||
pointarray_id = 110200028, --点阵ID
|
||||
graph_num = 1,
|
||||
len_x = 7, --长度
|
||||
len_z = 9, --高度
|
||||
rot_y = 0, --偏转角
|
||||
reminder_push_warning = 400095, --无法推动的reminder
|
||||
}
|
||||
local converter_infos = {[71017] = 2,[71022] = 1,[71039] = 1,[71040] = 1}
|
||||
--0->断路 |-1 电源| 1-> 可停留节点| 1.5 -> 可能存在结晶的节点| 2 -> 电线 | 2.5-> 结晶块 |
|
||||
--3-> 接收器 | 4 -> 中继器 | 4.5 -> 对位中继器输入
|
||||
|
||||
local connected_graph = {
|
||||
[9] = { 1, 2, 2, 2, 1, 2, 1},
|
||||
[8] = { 0, 0, 0, 0, 0, 0, 2},
|
||||
[7] = { 1, 2, 3, 0, -1, 0, 1},
|
||||
[6] = { 2, 0, 0, 0, 2, 0, 2},
|
||||
[5] = { 1, 2, 1, 2, 1, 2, 1},
|
||||
[4] = { 0, 0, 2, 0, 0, 0, 2},
|
||||
[3] = { 1, 2, 1, 2,2.5, 2, 1},
|
||||
[2] = { 2, 0, 0, 0, 0, 0, 2},
|
||||
[1] = { 3, 0, 0, 0, 0, 0,-1},
|
||||
}
|
||||
|
||||
--与节点图一一对应,点阵中 点的位置
|
||||
local waypoint_graph = {
|
||||
[9] = {10, 0, 0, 0, 6, 0, 5},
|
||||
[8] = { 0, 0, 0, 0, 0, 0, 0},
|
||||
[7] = {11, 0, 0, 0, 0, 0, 4},
|
||||
[6] = { 0, 0, 0, 0, 0, 0, 0},
|
||||
[5] = {12, 0, 9, 0, 7, 0, 3},
|
||||
[4] = { 0, 0, 0, 0, 0, 0, 0},
|
||||
[3] = {13, 0, 8, 0, 5, 0, 2},
|
||||
[2] = { 0, 0, 0, 0, 0, 0, 0},
|
||||
[1] = { 0, 0, 0, 0, 0, 0, 1},
|
||||
}
|
||||
|
||||
local gadget_graph ={
|
||||
[9] = { 71035, 71024, 71024, 71024, 71028, 71006, 71027},
|
||||
[8] = { 0, 0, 0, 0, 0, 0, 71005},
|
||||
[7] = { 71029, 71013, 71019, 0, 71021, 0, 71036},
|
||||
[6] = { 71014, 0, 0, 0, 71020, 0, 71004},
|
||||
[5] = { 71030, 71012, 71031, 71011, 71034, 71010, 71026},
|
||||
[4] = { 0, 0, 71023, 0, 0, 0, 71003},
|
||||
[3] = { 71033, 71015, 71032, 71008, 71009, 71007, 71025},
|
||||
[2] = { 71016, 0, 0, 0, 0, 0, 71002},
|
||||
[1] = { 71018, 0, 0, 0, 0, 0, 71001},
|
||||
}
|
||||
|
||||
--点阵和每个点的POS,用来在恢复的时候创建Gadget
|
||||
local waypoint_pos = {
|
||||
[1] = {x=1996.51245, y=197.46463, z=-1265.03467},
|
||||
[2] = {x=2000.27747, y=197.637466, z=-1269.03479},
|
||||
[3] = {x=2004.44043, y=197.682251, z=-1273.08423},
|
||||
[4] = {x=2008.35669, y=198.132111, z=-1276.61426},
|
||||
[5] = {x=2011.79822, y=198.469543, z=-1280.75232},
|
||||
[6] = {x=2016.40918, y=198.902481, z=-1275.91077},
|
||||
[7] = {x=2008.25366, y=198.260834, z=-1268.04431},
|
||||
[8] = {x=2008.5968, y=198.515762, z=-1260.09985},
|
||||
[9] = {x=2012.65173, y=198.5158, z=-1264.41284},
|
||||
[10] = {x=2025.0188, y=199.691757, z=-1267.24316},
|
||||
[11] = {x=2020.85693, y=198.902466, z=-1263.183},
|
||||
[12] = {x=2017.17883, y=198.681519, z=-1260.414},
|
||||
[13] = {x=2013.269, y=198.889435, z=-1255.92017},
|
||||
}
|
||||
|
||||
--定义左下角原点、X轴、Z轴正方向的点,通过向量计算位置关系
|
||||
local axis_O = {x = 2009, z = -1252}
|
||||
local axis_Z = {x = 2013, z = -1256}
|
||||
local axis_X = {x = 2003, z = -1258}
|
||||
|
||||
|
||||
--发射器的位置以及朝向,发射器的状态
|
||||
local emitter_infos = {
|
||||
[71001] = {z = 1, x = 7, dir = DIR.Up},
|
||||
[71021] = {z = 7, x = 5, dir = DIR.Down},
|
||||
}
|
||||
|
||||
local receiver_infos = {
|
||||
[71018] = {r_type = "Rec", connect_gadget = {71037} },
|
||||
[71019] = {r_type = "Rec", connect_gadget = {71038} },
|
||||
}
|
||||
]]
|
||||
--======================================================================================================================
|
||||
--全局变量,不需要LD处理,仅在Require内部使用
|
||||
local _G_pipe_route = {} --电路的流向合集
|
||||
local _G_pipe_state= {}
|
||||
local _G_ec_dir = 0 --电流的方向,每次递归计算的时候会用
|
||||
local _G_recur_counter = 0 --递归计数器
|
||||
local _G_cvt_graph = {} --在递归时建立的临时表,减少遍历次数
|
||||
local OPTION = {ROTATE = 31,START = 7,STOP = 72,PUSH = 193,}
|
||||
--0->断路 |-1 电源| 1-> 可停留节点| 1.5 -> 可能存在结晶的节点| 2 -> 电线 | 2.5-> 结晶块 |
|
||||
--3-> 接收器 | 4 -> 中继器 | 4.5 -> 对位中继器输入
|
||||
local NODE = {Off = 0,Power = -1,N_Node = 1,C_Node = 1.5, N_Pipe = 2, Crystal = 2.5, N_Rec = 3,C_Rec = 3.5,Sy_P_Node = 4,Sy_R_Node = 4.5}
|
||||
--======================================================================================================================
|
||||
--Events
|
||||
local ET_Triggers = {
|
||||
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
|
||||
{ name = "select_option", config_id = 8000102, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
|
||||
{ name = "time_axis_pass", config_id = 8000103, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
|
||||
{ name = "platform_reach",config_id = 8000104, event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_platform_arrival", trigger_count = 0 },
|
||||
}
|
||||
|
||||
--初始化
|
||||
function ET_Initialize()
|
||||
for k,v in pairs(ET_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
end
|
||||
--Events
|
||||
function action_group_load(context, evt)
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:Group 加载完毕")
|
||||
--确认每个电源的状态,修改按键信息,1代表物件结晶化,物件需要在加载完成的时候同步一次状态
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:打开电源操作台操作")
|
||||
for emitter_id,infos in pairs(emitter_infos) do
|
||||
--物件没有结晶化,给选项
|
||||
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, emitter_id, "GV_TMHY_CRYSTAL") then
|
||||
if 0 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, emitter_id) then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, emitter_id, {OPTION.STOP})
|
||||
ScriptLib.SetGroupTempValue(context, "GenState"..emitter_id, 1, {base_info.group_id})
|
||||
end
|
||||
if 201 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, emitter_id) then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, emitter_id, {OPTION.START})
|
||||
ScriptLib.SetGroupTempValue(context, "GenState"..emitter_id, 0, {base_info.group_id})
|
||||
end
|
||||
else
|
||||
--物件结晶化了,选项关掉
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, emitter_id, {})
|
||||
ScriptLib.SetGroupTempValue(context, "GenState"..emitter_id, 0, {base_info.group_id})
|
||||
end
|
||||
end
|
||||
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:开始创建转换器")
|
||||
local _cvt_graph = LF_RefreshGlobalConverterList(context)
|
||||
for cvt_id,cvt_info in pairs(_cvt_graph) do
|
||||
local waypoint = waypoint_graph[cvt_info.z][cvt_info.x]
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:转换器"..cvt_id.."对应路点"..waypoint)
|
||||
--创建转换器,设置方向
|
||||
ScriptLib.CreateGadgetByConfigIdByPos(context, cvt_id, waypoint_pos[waypoint], {x = 0, y = defs.rot_y, z = 0})
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:创建转换器"..cvt_id)
|
||||
ScriptLib.SetGadgetStateByConfigId(context, cvt_id, cvt_info.dir)
|
||||
--可移动的转换器
|
||||
if cvt_info.cvt_type == 1 then
|
||||
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, cvt_id, "GV_TMHY_CRYSTAL") then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {OPTION.ROTATE, OPTION.PUSH})
|
||||
end
|
||||
end
|
||||
--不可移动的转换器
|
||||
if cvt_info.cvt_type == 2 then
|
||||
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, cvt_id, "GV_TMHY_CRYSTAL") then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {OPTION.ROTATE})
|
||||
end
|
||||
end
|
||||
end
|
||||
LF_CheckConnection(context)
|
||||
return 0
|
||||
end
|
||||
|
||||
function action_select_option(context, evt)
|
||||
--处理电源的开关
|
||||
if emitter_infos[evt.param1] ~= nil and evt.param2 == OPTION.START then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:打开电源")
|
||||
-- ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_PowerOn", 1)
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, evt.param1, {OPTION.STOP})
|
||||
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 201)
|
||||
ScriptLib.SetGroupTempValue(context, "GenState"..evt.param1, 1, {base_info.group_id})
|
||||
LF_CheckConnection(context)
|
||||
end
|
||||
if emitter_infos[evt.param1] ~= nil and evt.param2 == OPTION.STOP then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:关闭电源")
|
||||
-- ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_PowerOn", 0)
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, evt.param1, {OPTION.START})
|
||||
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 0)
|
||||
ScriptLib.SetGroupTempValue(context, "GenState"..evt.param1, 0, {base_info.group_id})
|
||||
LF_CheckConnection(context)
|
||||
end
|
||||
|
||||
--处理中继器的旋转
|
||||
if converter_infos[evt.param1] ~= nil and evt.param2 == OPTION.ROTATE then
|
||||
--判断结晶化
|
||||
if 1 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, evt.param1, "GV_TMHY_CRYSTAL") then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:电桩结晶化了,不能旋转")
|
||||
ScriptLib.ShowReminder(context, defs.reminder_push_warning)
|
||||
end
|
||||
local rotate_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, evt.param1)
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:旋转中继器,旋转前方向"..rotate_state)
|
||||
if rotate_state == 3 then
|
||||
rotate_state = 0
|
||||
else
|
||||
rotate_state = rotate_state + 1
|
||||
end
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:旋转中继器,更新方向"..rotate_state)
|
||||
--更新当前电桩的朝向
|
||||
LF_LockConverterOperations(context, true)
|
||||
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, rotate_state)
|
||||
LF_SetConverterData(context, evt.param1, "Gadget_State", rotate_state)
|
||||
ScriptLib.InitTimeAxis(context, tostring(evt.param1), {1}, false)
|
||||
end
|
||||
|
||||
--处理推动电桩,只有类型1的电桩才会推动
|
||||
if converter_infos[evt.param1] ~= nil and converter_infos[evt.param1] == 1 and evt.param2 == OPTION.PUSH then
|
||||
if 1 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, evt.param1, "GV_TMHY_CRYSTAL") then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:电桩结晶化了,不能移动")
|
||||
ScriptLib.ShowReminder(context, defs.reminder_push_warning)
|
||||
end
|
||||
--按照玩家和电桩的相对位置推动电桩
|
||||
local push_dir = LF_CalcDirection(context, context.uid, evt.param1)
|
||||
local path = LF_GetMovePath(context, evt.param1, push_dir)
|
||||
if path ~= 0 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:推动中继器"..path[1].."to"..path[2])
|
||||
ScriptLib.SetPlatformPointArray(context, evt.param1, defs.pointarray_id, path, { route_type = 0})
|
||||
else
|
||||
ScriptLib.ShowReminder(context, defs.reminder_push_warning)
|
||||
end
|
||||
LF_LockConverterOperations(context, true)
|
||||
ScriptLib.InitTimeAxis(context, tostring(evt.param1), {1}, false)
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
--电桩旋转过程完成,检测电路连通和恢复电桩操作
|
||||
function action_time_axis_pass(context, evt)
|
||||
LF_CheckConnection(context)
|
||||
LF_LockConverterOperations(context, false)
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:操作时点完成,TimeAxis结束")
|
||||
return 0
|
||||
end
|
||||
|
||||
--电桩到达目标位置
|
||||
function action_platform_arrival( context, evt)
|
||||
--到达的柱子是这组Group里的
|
||||
if nil == converter_infos[evt.param1] then
|
||||
return -1
|
||||
end
|
||||
--到的不是目标点
|
||||
if evt.param3 ~= ScriptLib.GetGroupTempValue(context, "Move_Target_Point", {}) then
|
||||
return -1
|
||||
end
|
||||
local pos = LF_GetWaypointPos(evt.param3)
|
||||
--更新当前电桩的信息
|
||||
LF_SetConverterData( context, evt.param1, "Gadget_Pos", {pos_z = pos[1] ,pos_x = pos[2]})
|
||||
LF_CheckConnection(context)
|
||||
return 0
|
||||
end
|
||||
--======================================================================================================================
|
||||
--ServerLuaCalls
|
||||
--电桩从结晶化恢复时,通知Group恢复操作
|
||||
function SLC_CVTCrystallizeOff(context)
|
||||
local cvt_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
|
||||
if converter_infos[cvt_cfg_id] == 1 then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {OPTION.PUSH, OPTION.ROTATE})
|
||||
end
|
||||
if converter_infos[cvt_cfg_id] == 2 then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {OPTION.ROTATE})
|
||||
end
|
||||
LF_CheckConnection(context)
|
||||
return 0
|
||||
end
|
||||
|
||||
--电桩结晶化,通知Group关闭操作
|
||||
function SLC_CVTCrystallizeOn(context)
|
||||
local cvt_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {})
|
||||
LF_CheckConnection(context)
|
||||
return 0
|
||||
end
|
||||
|
||||
--电源结晶相关SLC
|
||||
function SLC_GeneratorCrystalStateChange(context, is_crystallized)
|
||||
local gen_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
|
||||
--结晶化时关掉开关的选项
|
||||
if 1 == is_crystallized then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电源SLC]电源结晶")
|
||||
ScriptLib.SetGroupTempValue(context, "GenState"..gen_cfg_id, 0, {base_info.group_id})
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gen_cfg_id, {})
|
||||
if 201 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, gen_cfg_id) then
|
||||
--相当于关闭电源,走一遍遍历
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电源SLC]关闭电路")
|
||||
LF_CheckConnection(context)
|
||||
end
|
||||
end
|
||||
if 0 == is_crystallized then
|
||||
--电源没打开,仍然是断路
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电源SLC]电源结晶解除")
|
||||
if 0 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, gen_cfg_id) then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gen_cfg_id, { OPTION.START })
|
||||
else
|
||||
--相当于电源打开了,重新连通
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电源SLC]打开电路")
|
||||
ScriptLib.SetGroupTempValue(context, "GenState"..gen_cfg_id, 1, {base_info.group_id})
|
||||
LF_CheckConnection(context)
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gen_cfg_id, { OPTION.STOP })
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--电桩结晶相关SLC
|
||||
function SLC_ConverterCrystalStateChange(context, is_crystallized)
|
||||
local cvt_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
|
||||
|
||||
--结晶化时关掉旋转的选项
|
||||
if 1 == is_crystallized then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[中继器]中继器结晶")
|
||||
LF_CheckConnection(context)
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {})
|
||||
end
|
||||
if 0 == is_crystallized then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[中继器]中继器解除结晶")
|
||||
LF_CheckConnection(context)
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {OPTION.ROTATE})
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--接收器相关SLC,结晶和结晶化解除时都要发
|
||||
function SLC_ReceiverCrystalStateChange(context, is_crystallized)
|
||||
--结晶化时关掉旋转的选项
|
||||
LF_CheckConnection(context)
|
||||
return 0
|
||||
end
|
||||
|
||||
--对位中继器相关SLC,结晶和结晶化解除时都要发
|
||||
function SLC_ReceiverCrystalStateChange(context, is_crystallized)
|
||||
local sync_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
|
||||
LF_CheckConnection(context)
|
||||
return 0
|
||||
end
|
||||
--======================================================================================================================
|
||||
--LevelFunctions
|
||||
--更新所有转换器的位置信息,使用一个全局表处理,每次使用时需要重置此表
|
||||
function LF_RefreshGlobalConverterList(context)
|
||||
local _cvt_graph = {}
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]创建电桩列表")
|
||||
for config_id,cvt_type in pairs(converter_infos) do
|
||||
_cvt_graph[config_id] = LF_GetConverterData(context, config_id)
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:转换器"..config_id.."z".._cvt_graph[config_id].z.."x".._cvt_graph[config_id].x)
|
||||
end
|
||||
return _cvt_graph
|
||||
end
|
||||
|
||||
--开关全部的电桩选项
|
||||
function LF_LockConverterOperations(context, is_lock)
|
||||
if is_lock then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]关闭全部中转器操作")
|
||||
for cvt_id,info in pairs(converter_infos) do
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {})
|
||||
end
|
||||
else
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]打开全部中转器操作")
|
||||
for cvt_id,info in pairs(converter_infos) do
|
||||
--校验结晶化
|
||||
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, cvt_id, "GV_TMHY_CRYSTAL") then
|
||||
if info == 1 then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {OPTION.ROTATE, OPTION.PUSH})
|
||||
end
|
||||
if info == 2 then
|
||||
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {OPTION.ROTATE})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--======================================================================================================================
|
||||
--电桩移动相关
|
||||
--获取电桩的移动路点列表
|
||||
function LF_GetMovePath(context, cvt_id, push_dir)
|
||||
local _cvt_graph = LF_RefreshGlobalConverterList(context)
|
||||
local pos_z = _cvt_graph[cvt_id].z
|
||||
local pos_x = _cvt_graph[cvt_id].x
|
||||
local cur_point = waypoint_graph[pos_z][pos_x]
|
||||
--走到下一个可以停留的点为止
|
||||
for i=1,defs.len_x do
|
||||
if push_dir == DIR.Up then
|
||||
pos_z = pos_z + 1
|
||||
end
|
||||
if push_dir == DIR.Down then
|
||||
pos_z = pos_z - 1
|
||||
end
|
||||
if push_dir == DIR.Left then
|
||||
pos_x = pos_x - 1
|
||||
end
|
||||
if push_dir == DIR.Right then
|
||||
pos_x = pos_x + 1
|
||||
end
|
||||
--检查是否越界,越界则直接返回
|
||||
if pos_z < 1 or pos_z > defs.len_z then
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]Z坐标越界")
|
||||
return 0
|
||||
end
|
||||
if pos_x < 1 or pos_x > defs.len_x then
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]X坐标越界")
|
||||
return 0
|
||||
end
|
||||
--找到下一个去的点信息
|
||||
if connected_graph[pos_z][pos_x] == NODE.Off or connected_graph[pos_z][pos_x] == NODE.Power or
|
||||
connected_graph[pos_z][pos_x] == NODE.N_Rec or connected_graph[pos_z][pos_x] == NODE.C_Rec or
|
||||
connected_graph[pos_z][pos_x] == NODE.Sy_P_Node or connected_graph[pos_z][pos_x] == NODE.Sy_R_Node then
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]前方是短路/终点/起点,停止检查")
|
||||
return 0
|
||||
end
|
||||
if connected_graph[pos_z][pos_x] == NODE.N_Pipe then
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]可以移动到中间点".."Z_"..pos_z.."X_"..pos_x)
|
||||
end
|
||||
if connected_graph[pos_z][pos_x] == NODE.Crystal then
|
||||
if LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]检查中间有结晶挡住")
|
||||
return 0
|
||||
else
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]检查中间没有结晶挡住")
|
||||
end
|
||||
end
|
||||
--节点检测
|
||||
if connected_graph[pos_z][pos_x] == NODE.C_Node or connected_graph[pos_z][pos_x] == NODE.N_Node then
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]可以移动到停留点".."Z_"..pos_z.."X_"..pos_x)
|
||||
if not LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
|
||||
for k,v in pairs(_cvt_graph) do
|
||||
if v.z == pos_z and v.x == pos_x then
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]目标点有一个电桩了,不移动")
|
||||
return 0
|
||||
end
|
||||
end
|
||||
--记录一下目标点
|
||||
ScriptLib.SetGroupTempValue(context, "Move_Target_Point", waypoint_graph[pos_z][pos_x], {})
|
||||
return {cur_point, waypoint_graph[pos_z][pos_x]}
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--根据点的位置获取xz坐标
|
||||
function LF_GetWaypointPos(point_id)
|
||||
for z = 1,defs.len_z do
|
||||
for x = 1,defs.len_x do
|
||||
if waypoint_graph[z][x] == point_id then
|
||||
return {z,x}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--全量检查当前电路的连接情况
|
||||
function LF_CheckConnection(context)
|
||||
--每个电源都走一个递归检测逻辑
|
||||
--递归次数清零
|
||||
local _cvt_graph = LF_RefreshGlobalConverterList(context)
|
||||
--建立一个每个电线的状态表,记为0 关闭
|
||||
for z = 1, defs.len_z do
|
||||
_G_pipe_state[z] = {}
|
||||
for x = 1, defs.len_x do
|
||||
_G_pipe_state[z][x] = 0
|
||||
end
|
||||
end
|
||||
|
||||
for emt_id,emt_pos in pairs(emitter_infos) do
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]检查电路连通,起点"..emt_id)
|
||||
--更新电流方向
|
||||
_G_ec_dir = emt_pos.dir
|
||||
_G_recur_counter = 0
|
||||
--检测一下电源的状态,
|
||||
if LF_IsGeneratorOn(context, emt_id) then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]开始打开电线")
|
||||
LF_RunEC(context, emt_pos, true, _cvt_graph)
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]检查完成")
|
||||
else
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]开始关闭电线")
|
||||
LF_RunEC(context, emt_pos, false, _cvt_graph)
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]检查完成")
|
||||
end
|
||||
end
|
||||
|
||||
--刷新所有电线状态
|
||||
for z=1,defs.len_z do
|
||||
for x=1,defs.len_x do
|
||||
if gadget_graph[z][x] ~= 0 then
|
||||
if connected_graph[z][x] == NODE.N_Pipe or connected_graph[z][x] == NODE.N_Node then
|
||||
if _G_pipe_state[z][x] > 0 then
|
||||
ScriptLib.SetGadgetStateByConfigId(context, gadget_graph[z][x], 201)
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]刷新物件状态"..gadget_graph[z][x])
|
||||
else
|
||||
ScriptLib.SetGadgetStateByConfigId(context, gadget_graph[z][x], 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--从一个点出发,更新电流信息,递归处理
|
||||
function LF_RunEC(context, ec_pos, is_on, _cvt_graph)
|
||||
_G_recur_counter = _G_recur_counter + 1
|
||||
if _G_recur_counter >= defs.len_x*defs.len_z then
|
||||
return false
|
||||
end
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]步长".._G_recur_counter.."电流方向".._G_ec_dir.."当前位置z"..ec_pos.z.."当前位置x"..ec_pos.x)
|
||||
for cfg_id,cvt_pos in pairs(_cvt_graph) do
|
||||
--找有没有对应的转接器
|
||||
if cvt_pos.x == ec_pos.x and cvt_pos.z == ec_pos.z then
|
||||
--判断电桩有没有结晶化
|
||||
if 0 ~= ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, cfg_id, "GV_TMHY_CRYSTAL") then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]走到了一个结晶化的电桩")
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, cfg_id, "SGV_PowerOn", 0)
|
||||
return false
|
||||
end
|
||||
--更新一下电流方向
|
||||
_G_ec_dir = cvt_pos.dir
|
||||
--更新电桩状态
|
||||
if is_on then
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, cfg_id, "SGV_PowerOn", 1)
|
||||
else
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, cfg_id, "SGV_PowerOn", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
--获取电流的所在节点
|
||||
local pos_x = ec_pos.x
|
||||
local pos_z = ec_pos.z
|
||||
--根据方向流动电流
|
||||
if _G_ec_dir == DIR.Up then
|
||||
pos_z = pos_z + 1
|
||||
end
|
||||
if _G_ec_dir == DIR.Down then
|
||||
pos_z = pos_z - 1
|
||||
end
|
||||
if _G_ec_dir == DIR.Left then
|
||||
pos_x = pos_x - 1
|
||||
end
|
||||
if _G_ec_dir == DIR.Right then
|
||||
pos_x = pos_x + 1
|
||||
end
|
||||
--检查是否越界,越界检查尝试转弯
|
||||
if pos_z < 1 or pos_z > defs.len_z or pos_x < 1 or pos_x > defs.len_x then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]走到了尽头,尝试拐弯")
|
||||
local try_turn_ec = LF_TurnEcDir(context, ec_pos)
|
||||
if try_turn_ec.dir == DIR.None then
|
||||
return false
|
||||
else
|
||||
_G_ec_dir = try_turn_ec.dir
|
||||
return LF_RunEC(context, ec_pos, is_on, _cvt_graph)
|
||||
end
|
||||
end
|
||||
--下一个点的信息判断
|
||||
if connected_graph[pos_z][pos_x] == NODE.Off then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]走到了断路,尝试拐弯")
|
||||
local try_turn_ec = LF_TurnEcDir(context, ec_pos)
|
||||
if try_turn_ec.dir == DIR.None then
|
||||
return false
|
||||
else
|
||||
_G_ec_dir = try_turn_ec.dir
|
||||
return LF_RunEC(context, ec_pos, is_on, _cvt_graph)
|
||||
end
|
||||
end
|
||||
|
||||
if connected_graph[pos_z][pos_x] == NODE.Power then
|
||||
return false
|
||||
end
|
||||
|
||||
if connected_graph[pos_z][pos_x] == NODE.N_Pipe then
|
||||
if is_on then
|
||||
_G_pipe_state[pos_z][pos_x] = _G_pipe_state[pos_z][pos_x] + 1
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]记录电线打开"..gadget_graph[pos_z][pos_x])
|
||||
end
|
||||
return LF_RunEC(context, {z = pos_z,x = pos_x}, is_on, _cvt_graph)
|
||||
end
|
||||
|
||||
if connected_graph[pos_z][pos_x] == NODE.C_Node or connected_graph[pos_z][pos_x] == NODE.N_Node then
|
||||
--确认节点有没有结晶化
|
||||
if LF_IsGadgetCrystal(context,gadget_graph[pos_z][pos_x]) then
|
||||
--如果是打开,就给这个位置的标记+1
|
||||
if is_on then
|
||||
_G_pipe_state[pos_z][pos_x] = _G_pipe_state[pos_z][pos_x] + 1
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]记录节点打开")
|
||||
end
|
||||
end
|
||||
return LF_RunEC(context, {z = pos_z,x = pos_x}, is_on, _cvt_graph)
|
||||
end
|
||||
|
||||
if connected_graph[pos_z][pos_x] == NODE.Crystal then
|
||||
if LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]走到了结晶")
|
||||
return false
|
||||
else
|
||||
LF_RunEC(context, {z = pos_z,x = pos_x}, is_on, _cvt_graph)
|
||||
end
|
||||
end
|
||||
--到达了接收器
|
||||
if connected_graph[pos_z][pos_x] == NODE.N_Rec or connected_graph[pos_z][pos_x] == NODE.C_Rec then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]到达终点")
|
||||
if LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]到达终点,终点被结晶化,连接失败")
|
||||
return false
|
||||
else
|
||||
if is_on then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]接收器打开")
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, gadget_graph[pos_z][pos_x], "SGV_PowerOn", 1)
|
||||
ScriptLib.SetGadgetStateByConfigId(context, gadget_graph[pos_z][pos_x], 201)
|
||||
else
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]接收器关闭")
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, gadget_graph[pos_z][pos_x], "SGV_PowerOn", 0)
|
||||
ScriptLib.SetGadgetStateByConfigId(context, gadget_graph[pos_z][pos_x], 0)
|
||||
end
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]连接完毕")
|
||||
return true
|
||||
end
|
||||
end
|
||||
if connected_graph[pos_z][pos_x] == NODE.Sy_P_Node or connected_graph[pos_z][pos_x] == NODE.Sy_C_Node then
|
||||
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]到达终点")
|
||||
if LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]到达终点,终点被结晶化,连接失败")
|
||||
return false
|
||||
else
|
||||
if is_on then
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, gadget_graph[pos_z][pos_x], "SGV_PowerOn", 1)
|
||||
else
|
||||
ScriptLib.SetEntityServerGlobalValueByConfigId(context, gadget_graph[pos_z][pos_x], "SGV_PowerOn", 0)
|
||||
end
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电路]连接完毕")
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--电流在走到头时自动检测是否转向
|
||||
function LF_TurnEcDir(context, cur_pos)
|
||||
--原来的电流是上下的,尝试左右移动
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]尝试扭转电流")
|
||||
local can_turn_dir = 0
|
||||
if _G_ec_dir == DIR.Up or _G_ec_dir == DIR.Down then
|
||||
--尝试向右转动电流
|
||||
if (cur_pos.x + 1) <= defs.len_x and (cur_pos.x + 1) >= 1 then
|
||||
if connected_graph[cur_pos.z][cur_pos.x + 1] >= 1 then
|
||||
can_turn_dir = can_turn_dir + 1
|
||||
end
|
||||
end
|
||||
--尝试向左转动电流
|
||||
if (cur_pos.x - 1) >= 1 and (cur_pos.x - 1) <= defs.len_x then
|
||||
if connected_graph[cur_pos.z][cur_pos.x - 1] >= 1 then
|
||||
can_turn_dir = can_turn_dir + 10
|
||||
end
|
||||
end
|
||||
--电流上下都没法转或者都能转
|
||||
if can_turn_dir == 11 or can_turn_dir == 0 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]不转")
|
||||
return {dir = DIR.None,z = cur_pos.z, x = cur_pos.x}
|
||||
else
|
||||
if can_turn_dir == 1 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]右转")
|
||||
return {dir = DIR.Right,z = cur_pos.z,x = cur_pos.x + 1}
|
||||
end
|
||||
if can_turn_dir == 10 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]左转")
|
||||
return {dir = DIR.Left,z = cur_pos.z,x = cur_pos.x - 1}
|
||||
end
|
||||
end
|
||||
end
|
||||
if _G_ec_dir == DIR.Left or _G_ec_dir == DIR.Right then
|
||||
--尝试向上转动电流
|
||||
if (cur_pos.z + 1) <= defs.len_z and (cur_pos.z + 1) >= 1 then
|
||||
if connected_graph[cur_pos.z+1][cur_pos.x] >= 1 then
|
||||
can_turn_dir = can_turn_dir + 1
|
||||
end
|
||||
end
|
||||
--尝试向下转动电流
|
||||
if (cur_pos.z - 1) >= 1 and (cur_pos.z - 1) <= defs.len_z then
|
||||
if connected_graph[cur_pos.z-1][cur_pos.x] >= 1 then
|
||||
can_turn_dir = can_turn_dir + 10
|
||||
end
|
||||
end
|
||||
--电流上下都没法转或者都能转
|
||||
if can_turn_dir == 11 or can_turn_dir == 0 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]不转")
|
||||
return {dir = DIR.None, z = cur_pos.z, x = cur_pos.x }
|
||||
else
|
||||
if can_turn_dir == 1 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]上转")
|
||||
return {dir = DIR.Up,z = cur_pos.z + 1,x = cur_pos.x }
|
||||
end
|
||||
if can_turn_dir == 10 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]下转")
|
||||
return {dir = DIR.Down,z = cur_pos.z - 1,x = cur_pos.x }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--判断一个节点或者电源是否被结晶化
|
||||
function LF_IsGadgetCrystal(context, gadget_cid)
|
||||
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, gadget_cid, "GV_TMHY_CRYSTAL") then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--判断电源是否通电,201为电源打开,GV为0时非结晶化
|
||||
function LF_IsGeneratorOn(context, gen_id)
|
||||
if 0 == ScriptLib.GetGroupTempValue(context, "GenState"..gen_id, {base_info.group_id}) then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
--======================================================================================================================
|
||||
|
||||
--======================================================================================================================
|
||||
--计算玩家和电桩的相对位置
|
||||
--根据玩家和电桩的坐标获取对应的夹角,计算出电桩移动的位置
|
||||
function LF_CalcDirection(context, uid, cvt_id)
|
||||
local avatar_pos = LF_GetEntityPos(context, context.uid, 0)
|
||||
local conver_pos = LF_GetEntityPos(context, 0, cvt_id)
|
||||
local vec_axis_OZ = {x = (axis_Z.x - axis_O.x), z = (axis_Z.z - axis_O.z)}
|
||||
local vec_axis_OX = {x = (axis_X.x - axis_O.x), z = (axis_X.z - axis_O.z)}
|
||||
local vec_cvt2avt = {x = (avatar_pos.x - conver_pos.x), z = (avatar_pos.z - conver_pos.z)}
|
||||
local deg_avt2OZ = LF_ClacAngle(vec_axis_OZ, vec_cvt2avt)
|
||||
local deg_avt2OX = LF_ClacAngle(vec_axis_OX, vec_cvt2avt)
|
||||
if 0 <= deg_avt2OZ and deg_avt2OZ <= 45 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:向后推动")
|
||||
return DIR.Down
|
||||
end
|
||||
if 45 < deg_avt2OZ and deg_avt2OZ < 135 then
|
||||
if 0 <= deg_avt2OX and deg_avt2OX <= 45 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:向左推动")
|
||||
return DIR.Left
|
||||
end
|
||||
if 135 <= deg_avt2OX and deg_avt2OX <= 180 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:向右推动")
|
||||
return DIR.Right
|
||||
end
|
||||
end
|
||||
if 135 <= deg_avt2OZ and deg_avt2OZ <= 180 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:向前推动")
|
||||
return DIR.Up
|
||||
end
|
||||
end
|
||||
|
||||
--计算向量夹角
|
||||
function LF_ClacAngle(vec1, vec2)
|
||||
local vec_cos = (vec1.x*vec2.x + vec1.z*vec2.z)/(math.sqrt( vec1.x^2 + vec1.z^2 )*math.sqrt( vec2.x^2 + vec2.z^2))
|
||||
return (math.acos(vec_cos)/math.pi*180)
|
||||
end
|
||||
|
||||
--拿到实体位置
|
||||
function LF_GetEntityPos(context, uid, cid)
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:获取坐标")
|
||||
local _eid = 0
|
||||
--转译entityId
|
||||
if uid ~= 0 then
|
||||
_eid = ScriptLib.GetAvatarEntityIdByUid(context, uid)
|
||||
elseif cid ~= 0 then
|
||||
_eid = ScriptLib.GetEntityIdByConfigId(context, cid)
|
||||
end
|
||||
--返回安全值,印象中直接返回_array时table里不干净
|
||||
local _array = ScriptLib.GetPosByEntityId(context, _eid)
|
||||
local _res = {}
|
||||
if _array.x == 0 and _array.y == 0 and _array.z == 0 then
|
||||
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:获取坐标失败,报错")
|
||||
_res.error = 1
|
||||
return _res
|
||||
end
|
||||
_res.x = _array.x
|
||||
_res.y = _array.y
|
||||
_res.z = _array.z
|
||||
return _res
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--切分和储存电桩数据
|
||||
--|移动类型 1位|GadgetState 1位|Pos_Z 2位|Pos_X 2位|
|
||||
--|1移动 2固定|State 0 1 2 3代表朝向
|
||||
--切分储存的数据
|
||||
function LF_GetConverterData(context, config_id)
|
||||
local cvt_archive_int = ScriptLib.GetGroupVariableValue(context, "converter_"..tostring(config_id))
|
||||
local cvt_archive_str = tostring(math.ceil(cvt_archive_int))
|
||||
return { cvt_type = tonumber(string.sub(cvt_archive_str,1,1)),
|
||||
dir = tonumber(string.sub(cvt_archive_str,2,2)),
|
||||
z = tonumber(string.sub(cvt_archive_str,3,4)),
|
||||
x = tonumber(string.sub(cvt_archive_str,5,6))}
|
||||
end
|
||||
|
||||
--数据储存
|
||||
function LF_SetConverterData( context, config_id, data_type, data_info)
|
||||
local cvt_archive_int = ScriptLib.GetGroupVariableValue(context, "converter_"..tostring(config_id))
|
||||
local cvt_archive_str = tostring(math.ceil(cvt_archive_int))
|
||||
local cvt_new_archive_str = ""
|
||||
if data_type == "Gadget_State" then
|
||||
cvt_new_archive_str = table.concat({string.sub(cvt_archive_str,1,1), tostring(data_info), string.sub(cvt_archive_str,3,6)})
|
||||
ScriptLib.SetGroupVariableValue(context, "converter_"..config_id, math.ceil( tonumber(cvt_new_archive_str)) )
|
||||
end
|
||||
if data_type == "Gadget_Pos" then
|
||||
local cvt_pos_new_z = ""
|
||||
local cvt_pos_new_x = ""
|
||||
if data_info.pos_z < 10 then
|
||||
cvt_pos_new_z = "0"..tostring(data_info.pos_z)
|
||||
else
|
||||
cvt_pos_new_z = tostring(data_info.pos_z)
|
||||
end
|
||||
if data_info.pos_x < 10 then
|
||||
cvt_pos_new_x = "0"..tostring(data_info.pos_x)
|
||||
else
|
||||
cvt_pos_new_x = tostring(data_info.pos_x)
|
||||
end
|
||||
cvt_new_archive_str = table.concat({string.sub(cvt_archive_str,1,2), cvt_pos_new_z, cvt_pos_new_x})
|
||||
ScriptLib.SetGroupVariableValue(context, "converter_"..config_id, math.ceil( tonumber(cvt_new_archive_str)) )
|
||||
end
|
||||
end
|
||||
--======================================================================================================================
|
||||
ET_Initialize()
|
||||
110
gdconf/game_data_config/lua/common/V3_6/PB_ChaseFeather.lua
Normal file
110
gdconf/game_data_config/lua/common/V3_6/PB_ChaseFeather.lua
Normal file
@@ -0,0 +1,110 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
|
||||
--======================================================================================================================
|
||||
--|| Filename || PB_ChaseFeather
|
||||
--|| RelVersion || V3_6
|
||||
--|| Owner || chao-jin
|
||||
--|| Description || 追逐草神羽毛的玩法
|
||||
--|| LogName || ##[PB_ChaseFeather]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs || 需要LD配置的内容
|
||||
|
||||
local defs = {
|
||||
feather = 108001, --草神羽毛的ID
|
||||
pointarray_id = 110200030, --草神羽毛移动的点阵ID
|
||||
target_pos = 6, --最后的目标点
|
||||
end_suite = 2, --
|
||||
}
|
||||
|
||||
--======================================================================================================================
|
||||
--Events || Group内EVENT事件,记得初始化和return 0
|
||||
local CF_Triggers = {
|
||||
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
|
||||
{ name = "platform_arrival", config_id = 8000102, event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_platform_arrival", trigger_count = 0 },
|
||||
{ name = "any_gadget_die", config_id = 8000103, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0 },
|
||||
|
||||
}
|
||||
|
||||
function CF_Initialize()
|
||||
for k,v in pairs(CF_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
end
|
||||
|
||||
CF_Initialize()
|
||||
|
||||
function action_group_load(context, evt)
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:追逐羽毛Group加载,初始化")
|
||||
ScriptLib.SetGroupTempValue(context, "CurrentPos", 1, {base_info.group_id})
|
||||
ScriptLib.SetGroupTempValue(context, "TargetPos", 2, {base_info.group_id})
|
||||
ScriptLib.SetGroupTempValue(context, "ChaseStarted", 0, {base_info.group_id})
|
||||
return 0
|
||||
end
|
||||
|
||||
--羽毛到达目标点
|
||||
function action_platform_arrival(context, evt)
|
||||
if evt.param1 ~= defs.feather then
|
||||
return 0
|
||||
end
|
||||
if evt.param3 ~= ScriptLib.GetGroupTempValue(context, "TargetPos", {base_info.group_id}) then
|
||||
return 0
|
||||
end
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:羽毛到达目标点,更新位置信息"..evt.param3)
|
||||
if evt.param3 == defs.target_pos then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:羽毛到达目标点,更新羽毛状态为可以拾取")
|
||||
ScriptLib.SetGadgetStateByConfigId(context, defs.feather, 201)
|
||||
return 0
|
||||
end
|
||||
ScriptLib.SetGroupTempValue(context, "CurrentPos", evt.param3, {base_info.group_id})
|
||||
ScriptLib.SetGroupTempValue(context, "ChaseStarted", 0, {base_info.group_id})
|
||||
return 0
|
||||
end
|
||||
|
||||
--羽毛从201状态死亡,完成玩法
|
||||
function action_any_gadget_die(context, evt)
|
||||
if evt.param1 == defs.feather then
|
||||
ScriptLib.ShowReminder(context, 400112)
|
||||
-- ScriptLib.GoToGroupSuite(context, base_info.group_id, defs.end_suite)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--ServerLuaCalls || 物件SLC,记得return 0
|
||||
--羽毛被追逐
|
||||
function SLC_BeChased(context)
|
||||
if 0 ~= ScriptLib.GetGroupTempValue(context, "ChaseStarted", {base_info.group_id}) then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:羽毛正在移动")
|
||||
return 0
|
||||
end
|
||||
if 0 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.feather) then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:羽毛移动完成")
|
||||
return 0
|
||||
end
|
||||
|
||||
local cur_pos = ScriptLib.GetGroupTempValue(context, "CurrentPos", {base_info.group_id})
|
||||
if cur_pos == 1 then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:追逐开始,闪现到目标点")
|
||||
ScriptLib.SetGroupTempValue(context, "CurrentPos", 2, {base_info.group_id})
|
||||
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.feather)
|
||||
|
||||
local _ret,R_pos,R_rot = ScriptLib.GetPlatformArrayInfoByPointId(context, defs.pointarray_id, 2)
|
||||
local blink_pos = {x = R_pos.x, y = R_pos.y, z = R_pos.z}
|
||||
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.feather, blink_pos, {x = 0, y = 0, z = 0})
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:闪现结束".._ret)
|
||||
return 0
|
||||
end
|
||||
ScriptLib.SetGroupTempValue(context, "ChaseStarted", 1, {base_info.group_id})
|
||||
ScriptLib.SetGroupTempValue(context, "TargetPos", cur_pos+1, {base_info.group_id})
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:追逐开始"..cur_pos.."to"..(cur_pos+1))
|
||||
ScriptLib.SetPlatformPointArray(context, defs.feather, defs.pointarray_id, {cur_pos, cur_pos+1}, {route_type = 0})
|
||||
ScriptLib.StartPlatform(context, defs.feather)
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions || 自定义函数
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
|
||||
--======================================================================================================================
|
||||
--|| Filename || PB_CollectFeatherOrb
|
||||
--|| RelVersion || V3_6
|
||||
--|| Owner || chao-jin
|
||||
--|| Description || 3.6 收集草神羽毛碎片的玩法
|
||||
--|| LogName || ##[PB_CollectFeatherOrb]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs || 需要LD配置的内容
|
||||
--Suite1 配置羽毛 Suite2 配置微粒
|
||||
--[[
|
||||
local defs = {
|
||||
time_limit = 20,
|
||||
feather = 106001, --羽毛的ConfigID
|
||||
orb_gadget_id = 70290729,
|
||||
orb_nums = 5,
|
||||
end_suite = 3,
|
||||
}
|
||||
]]
|
||||
--======================================================================================================================
|
||||
--Events || Group内EVENT事件,记得初始化和return 0
|
||||
local CFO_Triggers = {
|
||||
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
|
||||
{ name = "time_axis_pass", config_id = 8000102, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
|
||||
{ name = "any_gadget_die", config_id = 8000103, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0 },
|
||||
}
|
||||
|
||||
function CFO_Initialize()
|
||||
for k,v in pairs(CFO_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
end
|
||||
|
||||
CFO_Initialize()
|
||||
|
||||
--Group加载的时候初始化值
|
||||
function action_group_load(context, evt)
|
||||
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:Group加载记录死亡的微粒数量")
|
||||
ScriptLib.SetGroupTempValue(context, "OrbsCollectNums", 0, {base_info.group_id})
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
--收集微粒的时间轴
|
||||
function action_time_axis_pass(context, evt)
|
||||
--时间轴期间没有收集完毕微粒,玩法重置
|
||||
if evt.source_name == "CollectOrbs" then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:时间限制内没有收集完成全部微粒,玩法重置")
|
||||
ScriptLib.SetGroupTempValue(context, "OrbsCollectNums", 0, {base_info.group_id})
|
||||
ScriptLib.ShowReminder(context, 400113)
|
||||
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 1})
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--检测微粒死亡
|
||||
function action_any_gadget_die(context, evt)
|
||||
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:草神羽毛微粒死亡,计数+1")
|
||||
local orb_killed_num = ScriptLib.GetGroupTempValue(context, "OrbsCollectNums", {base_info.group_id})
|
||||
ScriptLib.ChangeGroupTempValue(context, "OrbsCollectNums", 1, {base_info.group_id})
|
||||
if orb_killed_num + 1 == defs.orb_nums then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:草神羽毛全部死亡,完成玩法")
|
||||
-- ScriptLib.GoToGroupSuite(context, base_info.group_id, defs.end_suite)
|
||||
ScriptLib.ShowReminder(context, 400112)
|
||||
ScriptLib.EndTimeAxis(context, "CollectOrbs")
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--ServerLuaCalls || 物件SLC,记得return 0
|
||||
--靠近羽毛之后,羽毛散开,创生需要收集的结晶
|
||||
function SLC_CollectStart(context)
|
||||
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:靠近草神羽毛,玩法开始")
|
||||
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
|
||||
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.feather)
|
||||
ScriptLib.InitTimeAxis(context, "CollectOrbs", {defs.time_limit}, false)
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions || 自定义函数
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
|
||||
--======================================================================================================================
|
||||
--|| Filename || PB_CrystalMonster
|
||||
--|| RelVersion || V3_6
|
||||
--|| Owner || chao-jin
|
||||
--|| Description ||
|
||||
--|| LogName || ##[PB_CrystalMonster]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs || 需要LD配置的内容
|
||||
--[[
|
||||
local crystal_to_monster = {
|
||||
[126002] = 126001,
|
||||
[126003] = 126004,
|
||||
}
|
||||
]]
|
||||
--======================================================================================================================
|
||||
--Events || Group内EVENT事件,记得初始化和return 0
|
||||
local CM_Triggers ={
|
||||
{ name = "gadget_state_change", config_id = 8000102, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
|
||||
}
|
||||
|
||||
function CM_Initialize()
|
||||
for k,v in pairs(CM_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
-- table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
|
||||
end
|
||||
|
||||
CM_Initialize()
|
||||
|
||||
function action_gadget_state_change(context, evt)
|
||||
if crystal_to_monster[evt.param2] ~= nil then
|
||||
if evt.param1 == 201 then
|
||||
ScriptLib.CreateMonster(context, { config_id = crystal_to_monster[evt.param2], delay_time = 0 })
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--ServerLuaCalls || 物件SLC,记得return 0
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions || 自定义函数
|
||||
|
||||
|
||||
|
||||
78
gdconf/game_data_config/lua/common/V3_6/PB_ElfFlower.lua
Normal file
78
gdconf/game_data_config/lua/common/V3_6/PB_ElfFlower.lua
Normal file
@@ -0,0 +1,78 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
|
||||
--======================================================================================================================
|
||||
--|| Filename || PB_ElfFlower
|
||||
--|| RelVersion || V3_6
|
||||
--|| Owner || chao-jin
|
||||
--|| Description || 精灵花朵收集玩法
|
||||
--|| LogName || ##[PB_ElfFlower]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs || 需要LD配置的内容
|
||||
--[[
|
||||
local defs = {
|
||||
flower_gadget_id = 70290733,
|
||||
}
|
||||
local elf_flowers = {}
|
||||
]]
|
||||
--======================================================================================================================
|
||||
--Events || Group内EVENT事件,记得初始化和return 0
|
||||
local EF_Triggers ={
|
||||
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
|
||||
{ name = "gadget_state_change", config_id = 8000102, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
|
||||
{ name = "time_axis_pass", config_id = 8000103, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
|
||||
}
|
||||
|
||||
function EF_Initialize()
|
||||
for k,v in pairs(EF_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
|
||||
end
|
||||
|
||||
EF_Initialize()
|
||||
|
||||
function action_group_load(context, evt)
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ElfFlower]:精灵花朵玩法加载")
|
||||
ScriptLib.SetGroupTempValue(context, "FlowerBloomed", 0, {base_info.group_id})
|
||||
return 0
|
||||
end
|
||||
|
||||
--监听花朵状态
|
||||
function action_gadget_state_change(context, evt)
|
||||
if gadgets[evt.param2].gadget_id == 70290733 and evt.param1 == 201 then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ElfFlower]: 精灵花朵状态变化")
|
||||
if #elf_flowers == ScriptLib.GetGroupTempValue(context, "FlowerBloomed", {base_info.group_id}) then
|
||||
ScriptLib.EndTimeAxis(context, "FlowerBloomTrail")
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ElfFlower]:挑战完成")
|
||||
for i=1,#elf_flowers do
|
||||
ScriptLib.SetGadgetStateByConfigId(context, elf_flowers[i], 202)
|
||||
end
|
||||
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
|
||||
return 0
|
||||
end
|
||||
ScriptLib.EndTimeAxis(context, "FlowerBloomTrail")
|
||||
ScriptLib.InitTimeAxis(context, "FlowerBloomTrail", {defs.time_limit}, false)
|
||||
ScriptLib.ChangeGroupTempValue(context, "FlowerBloomed", 1, {base_info.group_id})
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function action_time_axis_pass(context, evt)
|
||||
if evt.source_name == "FlowerBloomTrail" then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_ElfFlower]:时间结束,重置Group")
|
||||
ScriptLib.SetGroupTempValue(context, "FlowerBloomed", 0, {base_info.group_id})
|
||||
for i=1,#elf_flowers do
|
||||
ScriptLib.SetGadgetStateByConfigId(context, elf_flowers[i], 0)
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
--======================================================================================================================
|
||||
--ServerLuaCalls || 物件SLC,记得return 0
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions || 自定义函数
|
||||
|
||||
|
||||
|
||||
85
gdconf/game_data_config/lua/common/V3_6/PB_FireTrail.lua
Normal file
85
gdconf/game_data_config/lua/common/V3_6/PB_FireTrail.lua
Normal file
@@ -0,0 +1,85 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
|
||||
--======================================================================================================================
|
||||
--|| Filename || PB_FireTrail
|
||||
--|| RelVersion || V3_6
|
||||
--|| Owner || chao-jin
|
||||
--|| Description ||
|
||||
--|| LogName || ##[PB_FireTrail]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs || 需要LD配置的内容
|
||||
--[[
|
||||
local defs = {
|
||||
fire_seed = 110001,
|
||||
time_limit = 5,
|
||||
}
|
||||
|
||||
local pillars = {110002,110003,110004,110005,110006}
|
||||
]]
|
||||
--======================================================================================================================
|
||||
--Events || Group内EVENT事件,记得初始化和return 0
|
||||
local FT_Triggers ={
|
||||
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
|
||||
{ name = "gadget_state_change", config_id = 8000102, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
|
||||
{ name = "time_axis_pass", config_id = 8000103, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
|
||||
}
|
||||
|
||||
function FT_Initialize()
|
||||
for k,v in pairs(FT_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
|
||||
end
|
||||
|
||||
FT_Initialize()
|
||||
|
||||
function action_group_load(context, evt)
|
||||
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:火传导加载")
|
||||
ScriptLib.SetGroupTempValue(context, "PillarChanged", 0, {base_info.group_id})
|
||||
return 0
|
||||
end
|
||||
|
||||
function action_gadget_state_change(context, evt)
|
||||
if evt.param2 == defs.fire_seed and evt.param1 == 201 then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:火种状态变化,开启时间轴")
|
||||
ScriptLib.InitTimeAxis(context, "FireTrail", {defs.time_limit}, false)
|
||||
return 0
|
||||
else
|
||||
if gadgets[evt.param2].gadget_id == 70800422 and evt.param1 == 201 then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:传导柱状态变化,更新数量")
|
||||
if #pillars == ScriptLib.GetGroupTempValue(context, "PillarChanged", {base_info.group_id}) then
|
||||
ScriptLib.EndTimeAxis(context, "FireTrail")
|
||||
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:挑战完成")
|
||||
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
|
||||
return 0
|
||||
end
|
||||
ScriptLib.EndTimeAxis(context, "FireTrail")
|
||||
ScriptLib.InitTimeAxis(context, "FireTrail", {defs.time_limit}, false)
|
||||
ScriptLib.ChangeGroupTempValue(context, "PillarChanged", 1, {base_info.group_id})
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function action_time_axis_pass(context, evt)
|
||||
if evt.source_name == "FireTrail" then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:火种监听的时间结束,重置Group")
|
||||
ScriptLib.SetGroupTempValue(context, "PillarChanged", 0, {base_info.group_id})
|
||||
ScriptLib.SetGadgetStateByConfigId(context, defs.fire_seed, 0)
|
||||
for i=1,#pillars do
|
||||
ScriptLib.SetGadgetStateByConfigId(context, pillars[i], 0)
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
--======================================================================================================================
|
||||
--ServerLuaCalls || 物件SLC,记得return 0
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions || 自定义函数
|
||||
|
||||
|
||||
|
||||
70
gdconf/game_data_config/lua/common/V3_6/PB_FlowerInStone.lua
Normal file
70
gdconf/game_data_config/lua/common/V3_6/PB_FlowerInStone.lua
Normal file
@@ -0,0 +1,70 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
|
||||
--======================================================================================================================
|
||||
--|| Filename || PB_FlowerInStone
|
||||
--|| RelVersion || V3_6
|
||||
--|| Owner || chao-jin
|
||||
--|| Description ||
|
||||
--|| LogName || ##[PB_FlowerInStone]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs || 需要LD配置的内容
|
||||
--[[
|
||||
local defs = {
|
||||
bloom_time = 10,
|
||||
}
|
||||
|
||||
local flower_core = {
|
||||
[flower_cfg_id] = core_cfg_id,
|
||||
}
|
||||
]]
|
||||
--======================================================================================================================
|
||||
--Events || Group内EVENT事件,记得初始化和return 0
|
||||
local FIS_Triggers = {
|
||||
{ name = "gadget_state_change", config_id = 8000101, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
|
||||
{ name = "time_axis_pass", config_id = 8000102, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
|
||||
}
|
||||
|
||||
function FIS_Initialize()
|
||||
for k,v in pairs(FIS_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
end
|
||||
|
||||
FIS_Initialize()
|
||||
|
||||
--石中花的状态变化,创建和移除采集物
|
||||
function action_gadget_state_change(context, evt)
|
||||
if flower_core[evt.param2] ~= nil then
|
||||
if evt.param1 == 0 then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_FlowerInStone.lua]:石中花关闭,移除采集物")
|
||||
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, flower_core[evt.param2])
|
||||
return 0
|
||||
end
|
||||
if evt.param1 == 201 then
|
||||
ScriptLib.PrintContextLog(context, "##[PB_FlowerInStone.lua]:石中花打开,创建采集物")
|
||||
ScriptLib.CreateGadget(context, {config_id = flower_core[evt.param2]})
|
||||
ScriptLib.InitTimeAxis(context, tostring(evt.param2), {defs.bloom_time}, false)
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--开花后一段时间闭合
|
||||
function action_time_axis_pass(context, evt)
|
||||
local flower_id = tonumber(evt.source_name)
|
||||
if flower_id ~= nil then
|
||||
ScriptLib.SetGadgetStateByConfigId(context, flower_id, 0)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--ServerLuaCalls || 物件SLC,记得return 0
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions || 自定义函数
|
||||
|
||||
|
||||
|
||||
36
gdconf/game_data_config/lua/common/V3_6/PB_LeafPlatform.lua
Normal file
36
gdconf/game_data_config/lua/common/V3_6/PB_LeafPlatform.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
|
||||
--======================================================================================================================
|
||||
--|| Filename || PB_LeafPlatform
|
||||
--|| RelVersion || V3_6
|
||||
--|| Owner || chao-jin
|
||||
--|| Description || 叶片平台,用于在状态改变时创生钩锁点
|
||||
--|| LogName || ##[PB_LeafPlatform]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs || 需要LD配置的内容
|
||||
--[[
|
||||
local hook_map = {
|
||||
[] = ,
|
||||
}
|
||||
]]
|
||||
--======================================================================================================================
|
||||
--ServerLuaCalls || 物件SLC,记得return 0
|
||||
--平台关闭
|
||||
function SLC_PlatformOff(context)
|
||||
local config_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
|
||||
if hook_map[config_id] ~= nil then
|
||||
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, hook_map[config_id])
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--平台打开
|
||||
function SLC_PlatformOn(context)
|
||||
local config_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
|
||||
if hook_map[config_id] ~= nil then
|
||||
ScriptLib.CreateGadget(context, {config_id = hook_map[config_id] })
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
86
gdconf/game_data_config/lua/common/V3_6/ResidualBright.lua
Normal file
86
gdconf/game_data_config/lua/common/V3_6/ResidualBright.lua
Normal file
@@ -0,0 +1,86 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
|
||||
--======================================================================================================================
|
||||
--|| Filename || ResidualBright
|
||||
--|| RelVersion || V3_4
|
||||
--|| Owner || chao-jin
|
||||
--|| Description ||
|
||||
--|| LogName || ##[ResidualBright]
|
||||
--|| Protection ||
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs
|
||||
--[[
|
||||
local defs = {
|
||||
reset_region = 82001,
|
||||
gadget_id_bright = 70310498,
|
||||
}
|
||||
]]
|
||||
|
||||
--======================================================================================================================
|
||||
--Triggers&Init
|
||||
|
||||
local BrightTriggers={
|
||||
{ config_id = 8000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
|
||||
{ config_id = 8000002,name = "leave_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_reset_region", forbid_guest = false, trigger_count = 0 },
|
||||
-- { config_id = 8000003, name = "gadget_state_change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
|
||||
}
|
||||
|
||||
function LF_Initialize_Group(triggers, suites)
|
||||
for i=1,#BrightTriggers do
|
||||
table.insert(triggers, BrightTriggers[i])
|
||||
table.insert(suites[init_config.suite].triggers,BrightTriggers[i].name)
|
||||
end
|
||||
table.insert(variables,{ config_id = 50000001, name = "successed", value = 0, no_refresh = true})
|
||||
--初始化
|
||||
end
|
||||
|
||||
LF_Initialize_Group(triggers, suites)
|
||||
|
||||
--======================================================================================================================
|
||||
--Events
|
||||
|
||||
|
||||
--加载判定物件状态
|
||||
function action_group_load(context, evt)
|
||||
if ScriptLib.GetGroupVariableValue(context, "successed")==1 then
|
||||
LF_RemoveAllRepeater(context)
|
||||
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 3)
|
||||
for i=1,#gadgets do
|
||||
if gadgets[i].gadget_id == defs.gadget_id_bright then
|
||||
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, gadgets[i].config_id, 901)
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
--退出区域关闭挑战
|
||||
function action_leave_reset_region(context, evt)
|
||||
if evt.param1 ~= defs.reset_region then
|
||||
return 0
|
||||
end
|
||||
if ScriptLib.GetGroupVariableValue(context, "successed")==1 then
|
||||
LF_RemoveAllRepeater(context)
|
||||
return 0
|
||||
end
|
||||
ScriptLib.RefreshGroup(context,{group_id=base_info.group_id,suite=1})
|
||||
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions
|
||||
|
||||
function LF_RemoveAllRepeater(context)
|
||||
ScriptLib.PrintContextLog(context, "##[ResidualBright]:移除所有的残念")
|
||||
for i=1,#gadgets do
|
||||
if gadgets[i].gadget_id == defs.gadget_id_bright then
|
||||
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, gadgets[i].config_id)
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
213
gdconf/game_data_config/lua/common/V3_6/WQ_ElfFollow.lua
Normal file
213
gdconf/game_data_config/lua/common/V3_6/WQ_ElfFollow.lua
Normal file
@@ -0,0 +1,213 @@
|
||||
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
|
||||
--======================================================================================================================
|
||||
--|| Filename || WQ_ElfFollow
|
||||
--|| RelVersion || V3_6
|
||||
--|| Owner || chao-jin
|
||||
--|| Description || 用来给WQ任务中,小精灵伴飞的Require处理
|
||||
--|| LogName || ##[WQ_ElfFollow]
|
||||
--|| Protection || 玩法失败refresh到suite1,中间不存档
|
||||
--======================================================================================================================
|
||||
--Defs & Miscs || 需要LD配置的内容
|
||||
--[[
|
||||
local defs = {
|
||||
elf_config_id = 75001,
|
||||
pointarray_id = 110200031, --使用的点阵ID
|
||||
dis_fail_limit = 15, --跟随的最大距离限制
|
||||
dis_warning_limit = 6, --超出报警的距离
|
||||
time_fail_limit = 8, --超出最大距离限制判的上限时间
|
||||
time_warning_cd = 5, --提示玩家跟随的CD
|
||||
slusha_type = 3, --司露莎载具状态
|
||||
reminder_follow = 400094, --提示跟随
|
||||
reminder_fail = 400113,
|
||||
reminder_success = 400112,
|
||||
point_target = 15, --最终到达的终点ID
|
||||
end_suite = 2
|
||||
}
|
||||
--小精灵到达对应的Point时短暂停留,播放动画,播的动画ID
|
||||
local elf_actions = {
|
||||
[1] = {wait_time = 0,action_id = 0, next_point = 4}, --目标点在点阵内的PointID 到达点阵时播放的动画ID,没有则填0
|
||||
[4] = {wait_time = 2,action_id = 0, next_point = 8},
|
||||
[8] = {wait_time = 2,action_id = 0, next_point = 12},
|
||||
[12] = {wait_time = 2,action_id = 0, next_point = 15},
|
||||
[15] = {wait_time = 2,action_id = 0, next_point = 0},
|
||||
}
|
||||
]]
|
||||
--======================================================================================================================
|
||||
--Events || Group内EVENT事件,记得初始化和return 0
|
||||
local ElfFollow_Triggers = {
|
||||
{ name = "gadget_state_change", config_id = 8000101, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
|
||||
{ name = "time_axis_pass", config_id = 8000102, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
|
||||
{ name = "platform_arrival", config_id = 8000103, event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_platform_arrival", trigger_count = 0 }
|
||||
}
|
||||
|
||||
function ElfFollow_Initialize()
|
||||
for k,v in pairs(ElfFollow_Triggers) do
|
||||
table.insert(triggers, v)
|
||||
table.insert(suites[1].triggers, v.name)
|
||||
end
|
||||
end
|
||||
|
||||
ElfFollow_Initialize()
|
||||
|
||||
--监听小精灵Gadget的状态,切到201的时候开始玩法
|
||||
function action_gadget_state_change(context, evt)
|
||||
if evt.param2 == defs.elf_config_id and evt.param1 == 201 then
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:小精灵状态改变,开始飞行玩法")
|
||||
LF_StartFollowPlay(context)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--定时检测距离
|
||||
function action_time_axis_pass(context, evt)
|
||||
-- ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:触发TimeAxis")
|
||||
--提示跟随
|
||||
if evt.source_name == "WARNING_CD" then
|
||||
ScriptLib.SetGroupTempValue(context, "IS_WARNING_CD", 0, {})
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:提示CD结束")
|
||||
end
|
||||
--检查玩家和小精灵距离
|
||||
if evt.source_name == "CHECK_DISTANCE" then
|
||||
LF_CalcDist(context)
|
||||
end
|
||||
--检查玩家是否上了载具
|
||||
if evt.source_name == "CHECK_PLAYER_VEHICLE" then
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:检查玩家是否上载具")
|
||||
local _host_uid = ScriptLib.GetSceneOwnerUid(context)
|
||||
if defs.slusha_type ~= ScriptLib.GetPlayerVehicleType(context, _host_uid) then
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:玩家没有上载具")
|
||||
LF_FollowPlayFail(context)
|
||||
end
|
||||
end
|
||||
--小精灵继续飞行
|
||||
if evt.source_name == "ELF_FLY_AFTER_WAIT" then
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:小精灵继续飞行")
|
||||
ScriptLib.SetPlatformPointArray(context, defs.elf_config_id, defs.pointarray_id, LF_GetFlyPath(context), {route_type = 0,turn_mode = false})
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--到达停留点
|
||||
function action_platform_arrival( context, evt)
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:小精灵到达点"..evt.param3)
|
||||
--到达终点
|
||||
if evt.param3 == defs.point_target then
|
||||
LF_FollowPlaySuccess(context)
|
||||
return 0
|
||||
end
|
||||
if elf_actions[evt.param3] ~= nil then
|
||||
--小精灵播动画
|
||||
if elf_actions[evt.param3].action_id ~= 0 then
|
||||
ScriptLib.SetGadgetStateByConfigId(context, defs.elf_config_id, elf_actions[evt.param3].action_id)
|
||||
end
|
||||
--更新当前的点
|
||||
if evt.param3 ~= ScriptLib.GetGroupTempValue(context, "ELF_CUR_POINT", {base_info.group_id}) then
|
||||
ScriptLib.SetGroupTempValue(context, "ELF_CUR_POINT", evt.param3, {})
|
||||
end
|
||||
--等待一段时间后继续飞行
|
||||
if elf_actions[evt.param3].wait_time ~= 0 then
|
||||
ScriptLib.InitTimeAxis(context, "ELF_FLY_AFTER_WAIT", {elf_actions[evt.param3].wait_time}, false)
|
||||
else
|
||||
ScriptLib.SetPlatformPointArray(context, defs.elf_config_id, defs.pointarray_id, LF_GetFlyPath(context), {route_type = 0,turn_mode = false})
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
--======================================================================================================================
|
||||
--LevelFunctions || 自定义函数
|
||||
--开始小精灵跟随玩法
|
||||
function LF_StartFollowPlay(context)
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:跟随玩法开始")
|
||||
--记录离开距离过远的次数
|
||||
ScriptLib.SetGroupTempValue(context, "TIME_TOO_FAR", 0, {})
|
||||
--记录是否在提示冷却中
|
||||
ScriptLib.SetGroupTempValue(context, "IS_WARNING_CD", 0, {})
|
||||
--记录小精灵移动平台当前在哪个点
|
||||
ScriptLib.SetGroupTempValue(context, "ELF_CUR_POINT", 1, {})
|
||||
--创建一个时间轴,检查规定时间内是否处于载具状态
|
||||
ScriptLib.InitTimeAxis(context, "CHECK_PLAYER_VEHICLE", {8}, false)
|
||||
--创建一个时间轴,定期计算玩家和小精灵的距离
|
||||
ScriptLib.InitTimeAxis(context, "CHECK_DISTANCE", {1}, true)
|
||||
ScriptLib.SetPlatformPointArray(context, defs.elf_config_id, defs.pointarray_id, LF_GetFlyPath(context), {route_type = 0,turn_mode = false})
|
||||
end
|
||||
|
||||
--检查玩家和小精灵的距离
|
||||
function LF_CalcDist(context)
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:处理玩家和小精灵之间的距离")
|
||||
--计算玩家和小精灵的距离
|
||||
local dis_h2e = 100
|
||||
local uid_list = ScriptLib.GetSceneUidList(context)
|
||||
if uid_list ~= nil then
|
||||
local _host_uid = ScriptLib.GetSceneOwnerUid(context)
|
||||
local _avatar_eid = ScriptLib.GetAvatarEntityIdByUid(context, _host_uid)
|
||||
local _avatar_pos = ScriptLib.GetPosByEntityId(context, _avatar_eid)
|
||||
|
||||
local _elf_eid = ScriptLib.GetEntityIdByConfigId(context, defs.elf_config_id)
|
||||
local _elf_pos = ScriptLib.GetPosByEntityId(context, _elf_eid)
|
||||
dis_h2e = math.sqrt( (_avatar_pos.x - _elf_pos.x)^2 + (_avatar_pos.y - _elf_pos.y)^2 +(_avatar_pos.z - _elf_pos.z)^2 )
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:距离"..dis_h2e)
|
||||
end
|
||||
|
||||
--超出提示距离
|
||||
if dis_h2e > defs.dis_warning_limit then
|
||||
if 0 == ScriptLib.GetGroupTempValue(context, "IS_WARNING_CD", {}) then
|
||||
ScriptLib.ShowReminder(context, defs.reminder_follow)
|
||||
ScriptLib.SetGroupTempValue(context, "IS_WARNING_CD", 1, {})
|
||||
ScriptLib.InitTimeAxis(context, "WARNING_CD", {defs.time_waring_cd}, false)
|
||||
end
|
||||
end
|
||||
--处理超出限制距离
|
||||
if dis_h2e > defs.dis_fail_limit then
|
||||
--更新超出距离的次数
|
||||
ScriptLib.ChangeGroupTempValue(context, "TIME_TOO_FAR", 1, {})
|
||||
--计算一下
|
||||
if defs.time_fail_limit < ScriptLib.GetGroupTempValue(context, "TIME_TOO_FAR", {}) then
|
||||
LF_FollowPlayFail(context)
|
||||
return 0
|
||||
end
|
||||
else
|
||||
--靠近后累计时间清零
|
||||
ScriptLib.SetGroupTempValue(context, "TIME_TOO_FAR", 0, {})
|
||||
end
|
||||
end
|
||||
|
||||
--关闭所有时间轴
|
||||
function LF_EndAllTimeAxis(context)
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:停止所有时间轴")
|
||||
ScriptLib.EndTimeAxis(context, "IS_WARNING_CD")
|
||||
ScriptLib.EndTimeAxis(context, "CHECK_PLAYER_VEHICLE")
|
||||
ScriptLib.EndTimeAxis(context, "CHECK_DISTANCE")
|
||||
end
|
||||
|
||||
--跟随玩法失败
|
||||
function LF_FollowPlayFail(context)
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:玩法失败")
|
||||
LF_EndAllTimeAxis(context)
|
||||
ScriptLib.ShowReminder(context, defs.reminder_fail)
|
||||
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite=1})
|
||||
end
|
||||
|
||||
--跟随玩法成功
|
||||
function LF_FollowPlaySuccess(context)
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:玩法成功")
|
||||
ScriptLib.ShowReminder(context, defs.reminder_success)
|
||||
LF_EndAllTimeAxis(context)
|
||||
ScriptLib.GoToGroupSuite(context, base_info.group_id, defs.end_suite)
|
||||
end
|
||||
|
||||
--根据当前点生成飞行的路径
|
||||
function LF_GetFlyPath(context)
|
||||
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:生成飞行路径")
|
||||
local cur_point = ScriptLib.GetGroupTempValue(context, "ELF_CUR_POINT", {})
|
||||
local fly_path = {}
|
||||
if cur_point < defs.point_target then
|
||||
local target_point = elf_actions[cur_point].next_point
|
||||
for i=cur_point,target_point do
|
||||
table.insert(fly_path, i)
|
||||
-- ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:路径"..i)
|
||||
end
|
||||
end
|
||||
return fly_path
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user