添加配置表

This commit is contained in:
flswld
2022-11-30 00:00:20 +08:00
parent f70a890338
commit d7f3f3b866
33382 changed files with 8476601 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
--[[======================================
|| filename: Activity_GravenCarve
|| owner: chao.cui
|| description: 木刻插槽管理
|| LogName: TD
|| Protection: [Protection]
=======================================]]
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_GravenCarve] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
-- 自定义插槽
{ config_id = 40000003, name = "tri_slot_map_changed", event = EventType.EVENT_CUSTOM_GADGET_SLOT_MAP_CHANGED, source = "", condition = "", action = "action_EVENT_SLOT_MAP_CHANGED", trigger_count = 0 },
{ config_id = 40000004, name = "tri_enter_play_region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0 },
}
------ Local Functions -----------
function LF_Initialize_Level()
--- TRIGGER
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
table.insert(suites[1].triggers, _trigger.name)
end
return 0
end
------ conditions & actions ------
-- 自定义物件插槽变化时。切换物件状态
function action_EVENT_SLOT_MAP_CHANGED(context, evt)
-- 插槽ID
if evt.param2 == 1001 then
if evt.param3 == 0 then
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 0)
else
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 201)
end
end
return 0
end
function action_enter_region(context, evt)
if evt.param1 == defs.guide_regionID then
-- TODO: 添加新的教程
if 0 ~= ScriptLib.AssignPlayerShowTemplateReminder(context,193,{param_uid_vec={},param_vec={},uid_vec={context.uid}}) then
PrintLog(context, "弹教程失败")
else
PrintLog(context, "教程UID:"..context.uid)
end
end
return 0
end
LF_Initialize_Level()

View File

@@ -0,0 +1,304 @@
--[[======================================
|| filename: Activity_MonsterCamp
|| owner: chao.cui
|| description: 3.0大活动-营地挑战
|| LogName: TD
|| Protection: ???
=======================================]]
--- 刷怪模式0为波次刷怪。1为怪物潮刷怪。
--- defs.levelType = 0,
--- defs.challenge_id = 2010045,
--- 怪物总数
--- defs.target_count = 6,
--- 触发开启挑战的region_id
--- defs.small_region_id = 60007,
--- 触发暂停挑战的region_id
--- defs.big_region_id = 60008,
-- 波次模式配置-对应的suite
-- local monsterSuites = {2, 3, 4}
-- 怪物潮模式配置 - 对应的monsterConfigId
-- local tideMonsters = {1001, 1002, 1003}
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_MonsterCamp] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ config_id = 40000001, name = "tri_group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 40000002, name = "tri_group_will_unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_EVENT_GROUP_WILL_UNLOAD", trigger_count = 0 },
{ config_id = 40000003, name = "tri_monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0 },
{ config_id = 40000004, name = "tri_enter_region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION", action = "action_EVENT_ENTER_REGION", trigger_count = 0 },
{ config_id = 40000005, name = "tri_leave_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "condition_EVENT_LEAVE_REGION", action = "action_EVENT_LEAVE_REGION", trigger_count = 0 },
{ config_id = 40000006, name = "tri_challenge_success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_EVENT_CHALLENGE_SUCCESS", trigger_count = 0 },
{ config_id = 40000007, name = "tri_challenge_fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_EVENT_CHALLENGE_FAIL", trigger_count = 0 },
{ config_id = 40000008, name = "tri_challenge_pause", event = EventType.EVENT_CHALLENGE_PAUSE, source = "", condition = "", action = "action_EVENT_CHALLENGE_PAUSE", trigger_count = 0 },
-- 进度计数Trigger
{ config_id = 40000009, name = "tri_var_change", event = EventType.EVENT_VARIABLE_CHANGE, source = "monster_killed", condition = "condition_monster_killed", action = "", trigger_count = 0, tag = "666" },
-- 怪物入战
{ config_id = 40000010, name = "tri_monster_battle", event = EventType.EVENT_MONSTER_BATTLE, source = "", condition = "", action = "action_EVENT_MONSTER_BATTLE", trigger_count = 0 },
-- GM
--{ config_id = 40000101, name = "tri_reset_level", event = EventType.EVENT_VARIABLE_CHANGE, source = "RESET_LEVEL", condition = "", action = "action_EVENT_VARIABLE_CHANGE", trigger_count = 0 },
}
------ conditions & actions ------
-- GM指令
-- function action_EVENT_VARIABLE_CHANGE(context, evt)
-- if evt.source_name == "RESET_LEVEL" then
-- LF_Reset_Level(context)
-- end
-- return 0
-- end
function action_EVENT_GROUP_LOAD(context, evt)
if ScriptLib.GetGroupVariableValue(context, "challenge_state") == 2 then
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.REGION, defs.small_region_id)
-- 挑战完成则跳过
return -1
end
-- enterRegion启动challenge早于load触发
if not ScriptLib.IsChallengeStartedByChallengeIndex(context, base_info.group_id, 99) then
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
end
-- 第一次加载时的怪物初始化
if ScriptLib.GetGroupVariableValue(context, "initialized") == 0 then
if defs.levelType == 0 then
-- 波次刷怪初始化
local wave = ScriptLib.GetGroupVariableValue(context, "current_wave")
LF_StartMonsterWave(context, wave)
else
-- 怪物潮刷怪初始化
for i = 1, 4 do
LF_Try_Create_Monster(context)
end
end
ScriptLib.SetGroupVariableValue(context, "initialized", 1)
end
return 0
end
function action_EVENT_GROUP_WILL_UNLOAD(context, evt)
if ScriptLib.GetGroupVariableValue(context, "challenge_state") == 1 then
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
if 0 == ScriptLib.PauseChallenge(context, 99) then
PrintLog(context, "暂停挑战成功")
else
PrintLog(context, "暂停挑战失败")
end
end
return 0
end
function condition_monster_killed(context, evt)
PrintLog(context, "var_change : monster_killed "..evt.param2.." -> "..evt.param1)
if evt.param1 > evt.param2 then
return true
end
return false
end
function action_EVENT_CHALLENGE_SUCCESS(context, evt)
ScriptLib.SetGroupVariableValue(context, "challenge_state", 2)
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.REGION, defs.small_region_id)
return 0
end
function action_EVENT_CHALLENGE_FAIL(context, evt)
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
PrintLog(context, "挑战失败")
return 0
end
function action_EVENT_CHALLENGE_PAUSE(context, evt)
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
return 0
end
function action_EVENT_ANY_MONSTER_DIE(context, evt)
PrintLog(context, "怪物死亡")
-- 更新挑战进度
ScriptLib.ChangeGroupVariableValue(context, "monster_killed", 1)
local cur_progress = ScriptLib.GetGroupVariableValue(context, "monster_killed")
if cur_progress == #monsters and ScriptLib.GetGroupVariableValue(context, "challenge_state") == 0 then
LF_Try_Start_Challenge(context)
end
ScriptLib.MarkGroupLuaAction(context, "GravenInnocence_Camp_2", "", {current_progress=cur_progress, total_progress=#monsters})
if defs.levelType == 0 then
-- 波次模式。怪清空刷下一波怪
if ScriptLib.GetGroupMonsterCountByGroupId(context, base_info.group_id) == 0 then
local wave = ScriptLib.GetGroupVariableValue(context, "current_wave") + 1
ScriptLib.SetGroupVariableValue(context, "current_wave", wave)
LF_StartMonsterWave(context, wave)
end
else
-- 怪物潮模式。死一只补一只
LF_Try_Create_Monster(context)
end
return 0
end
-- 怪物入战
function action_EVENT_MONSTER_BATTLE(context, evt)
--LF_Try_Start_Challenge(context)
return 0
end
function condition_EVENT_ENTER_REGION(context, evt)
if evt.param1 ~= defs.small_region_id then return false end
if ScriptLib.GetGroupVariableValue(context, "challenge_state") == 2 then return false end
return true
end
-- 进入挑战区域
function action_EVENT_ENTER_REGION(context, evt)
PrintLog(context, "进入挑战区域")
if 0 ~= ScriptLib.AssignPlayerShowTemplateReminder(context,191,{param_uid_vec={},param_vec={},uid_vec={context.uid}}) then
PrintLog(context, "弹教程失败")
end
LF_Try_Start_Challenge(context)
return 0
end
function condition_EVENT_LEAVE_REGION(context, evt)
--if evt.param1 ~= defs.big_region_id then return false end
if evt.param1 ~= defs.small_region_id then return false end
return true
end
function action_EVENT_LEAVE_REGION(context, evt)
PrintLog(context, "离开挑战区域")
if ScriptLib.GetGroupVariableValue(context, "challenge_state") == 1 then
if 0 == ScriptLib.PauseChallenge(context, 99) then
PrintLog(context, "暂停挑战成功")
end
end
return 0
end
--------- 关卡Functions --------
function LF_Try_Start_Challenge(context)
if ScriptLib.GetGroupVariableValue(context, "challenge_state") == 0 then
local init_count = ScriptLib.GetGroupVariableValue(context, "monster_killed")
-- 挑战进度保护
local left_count = 0
local is_done = 0
if init_count < defs.target_count then
-- 安全
else
left_count = init_count - defs.target_count + 1
init_count = defs.target_count - 1
is_done = 1
end
--参数1 event_type所在枚举序号 参数2 trigger_tag参数3 次数参数4Bool次数达成是否计为成功参数5初始次数值
if 0 ~= ScriptLib.StartChallenge(context, 99, defs.challenge_id, {3, 666, defs.target_count, 1, init_count}) then
PrintLog(context, "开启挑战失败")
else
-- 成功开启挑战1
ScriptLib.MarkGroupLuaAction(context, "GravenInnocence_Camp_1", "", {})
ScriptLib.SetGroupVariableValue(context, "challenge_state", 1)
-- 重走tagTrigger保证challenge正常流转
if is_done == 1 then
ScriptLib.ChangeGroupVariableValue(context, "monster_killed", -1)
ScriptLib.ChangeGroupVariableValue(context, "monster_killed", 1)
end
--[[if left_count > 0 then
-- 挑战进度还原
for i = 1, left_count do
ScriptLib.ChangeGroupVariableValue(context, "monster_killed", 1)
end
end--]]
end
end
end
function LF_StartMonsterWave(context, wave)
PrintLog(context, "start wave: "..wave)
if wave > #monsterSuites then
PrintLog(context, "所有波次已完成")
else
--ScriptLib.MarkGroupLuaAction(context, "GravenInnocence_Camp_2", "", {current_progress=wave, total_progress=#monsterSuites})
local suite = monsterSuites[wave]
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, suite)
end
return 0
end
function LF_Try_Create_Monster(context)
local index = ScriptLib.GetGroupVariableValue(context, "monster_index")
if index < defs.target_count then
local configId = tideMonsters[index+1]
if 0 == ScriptLib.CreateMonster(context, { config_id = configId, delay_time = 0}) then
PrintLog(context, "添加怪物成功")
ScriptLib.SetGroupVariableValue(context, "monster_index", index + 1)
else
PrintLog(context, "添加怪物失败")
end
end
end
-- 测试用
-- function LF_Reset_Level(context)
-- PrintLog(context, "重置关卡")
-- ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
-- ScriptLib.SetGroupVariableValue(context, "current_wave", 1)
-- ScriptLib.SetGroupVariableValue(context, "monster_killed", 0)
-- ScriptLib.SetGroupVariableValue(context, "monster_index", 0)
-- end
function LF_Init_Vars()
-- 波次进度
table.insert(variables, {config_id = 50000001, name = "current_wave", value = 1, no_refresh = true})
-- 挑战状态
table.insert(variables, {config_id = 50000002, name = "challenge_state", value = 0, no_refresh = true})
-- 刷怪进度
table.insert(variables, {config_id = 50000003, name = "monster_killed", value = 0, no_refresh =true})
-- 怪物潮进度
table.insert(variables, {config_id = 50000005, name = "monster_index", value = 0, no_refresh =true})
-- Group状态
table.insert(variables, {config_id = 50000006, name = "initialized", value = 0, no_refresh =true})
-- GM
-- table.insert(variables, {config_id = 50000101, name = "RESET_LEVEL", value = 0, no_refresh = true})
end
function LF_Initialize_Level()
-- triggers
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggers) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
LF_Init_Vars()
return 0
end
LF_Initialize_Level()

View File

@@ -0,0 +1,312 @@
--[[======================================
|| filename: Activity_MuqadasPotion
|| owner: chao.cui
|| description: 3.0活动-时停挑战
|| LogName: TD
|| Protection: ???
=======================================]]
--[[
local defs =
{
operator_id = 574048, --操作台的configid
option_id = 175, --操作台的option id
reminder_id = 400139, -- 每波刷怪弹出reminder提示
gallery_id = 25001,
}
local monster_list =
{
-- 第1波怪
[1] =
{
-- 精英怪configID, 精英怪全部死亡就刷下一波
elite_monster = {574001,574002},
-- 附属小怪configID每个id小怪死了之后重新刷出来
tide_mons = {574003, 574004, 574005, 574006, 574007},
-- 附属小怪的刷怪间隔
tide_mon_delay = 2,
-- 下一波怪
next = 2,
-- 刷下一波怪延迟
next_delay = 2,
elite_monster_energy = 10,
elite_monster_score = 10,
tide_mons_energy = 10,
tide_mons_score = 10,
},
-- 第2波怪
[2] =
{
-- 精英怪configID, 精英怪全部死亡就刷下一波
elite_monster = {574011,574012},
-- 附属小怪configID每个id小怪死了之后重新刷出来
tide_mons = {574013, 574014, 574015, 574016, 574017},
-- 附属小怪的刷怪间隔
tide_mon_delay = 2,
-- 下一波的ID
next = 3,
-- 刷下一波怪延迟
next_delay = 2,
elite_monster_energy = 10,
elite_monster_score = 10,
tide_mons_energy = 10,
tide_mons_score = 10,
},
}
--]]
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_MuqadasPotion] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ name = "tri_group_load", config_id = 40000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ name = "tri_select_option", config_id = 40000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
{ name = "tri_monster_die_before_leave_scene", config_id = 40000003, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
{ name = "tri_gallery_stop", config_id = 40000004, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
{ name = "tri_dungeon_all_avatar_die", config_id = 40000005, event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_dungeon_all_avatar_die", trigger_count = 0},
{ name = "tri_dungeon_settle", config_id = 40000006, event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_dungeon_settle", trigger_count = 0},
{ name = "tri_timer_event", config_id = 40000007, event = EventType.EVENT_TIMER_EVENT, source = "", condition = "", action = "action_timer_event", trigger_count = 0},
}
function SLC_Self_Increase(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, { ["add_energy"] = 8 })
return 0
end
------ conditions & actions ------
-- 团灭
function action_dungeon_all_avatar_die(context,evt)
if 0 ~= ScriptLib.StopGallery(context, defs.gallery_id, true) then
PrintLog(context, "Stop Gallery失败")
end
--LF_Stop_Play(context, false)
return 0
end
-- 副本结算
function action_dungeon_settle(context,evt)
if 0 ~= ScriptLib.StopGallery(context, defs.gallery_id, true) then
PrintLog(context, "Stop Gallery失败")
end
--LF_Stop_Play(context, false)
return 0
end
function action_gallery_stop(context, evt)
LF_Stop_Play(context, false)
return 0
end
--group load后加载操作台选项
function action_group_load(context,evt)
PrintLog(context, "GroupLoad: 0608-1700")
ScriptLib.SetGadgetStateByConfigId(context, defs.operator_id, 0)
if 0 ~= ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.operator_id, {defs.option_id}) then
PrintLog(context, "设置操作选项失败")
end
return 0
end
--按下操作台按键,启动玩法
function action_select_option(context,evt)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.operator_id, defs.option_id)
ScriptLib.SetGadgetStateByConfigId(context, defs.operator_id, 202)
LF_Start_Play(context)
return 0
end
function action_monster_die_before_leave_scene(context, evt)
local current_wave = ScriptLib.GetGroupVariableValue(context, "current_wave")
local elites_tbl = monster_list[current_wave].elite_monster
-- 判断死的是否是精英怪
local monster_cid = evt.param1
local is_elite = 0
for _, _configID in pairs(elites_tbl) do
if _configID == monster_cid then
is_elite = 1
break
end
end
LF_Update_Score(context, is_elite, current_wave)
if is_elite == 1 then
-- SITUATION:精英怪死亡
local left_elites = ScriptLib.GetGroupVariableValue(context, "left_elites")
left_elites = left_elites - 1
ScriptLib.SetGroupVariableValue(context, "left_elites", left_elites)
if left_elites <= 0 then
-- 关闭现有小怪复活的timer
LF_Cancel_Monster_Timers(context, current_wave)
end
else
-- SITUATION:普通小怪死亡
local left_elites = ScriptLib.GetGroupVariableValue(context, "left_elites")
if left_elites > 0 then
-- X秒后复活
local delay_time = monster_list[current_wave].tide_mon_delay
ScriptLib.CreateGroupTimerEvent(context, base_info.group_id, tostring(monster_cid), delay_time)
end
end
-- 如果场上无怪了
if ScriptLib.GetGroupMonsterCount(context) == 0 then
-- 刷下一波怪
local delay_time = monster_list[current_wave].next_delay
ScriptLib.CreateGroupTimerEvent(context, base_info.group_id, "NEXTWAVE", delay_time)
end
return 0
end
-- 计时器
function action_timer_event(context, evt)
local timer_name = evt.source_name
if timer_name == "NEXTWAVE" then
PrintLog(context, "计时器-刷下一波怪物")
ScriptLib.ShowReminder(context, defs.reminder_id)
local current_wave = ScriptLib.GetGroupVariableValue(context, "current_wave")
local next_wave = monster_list[current_wave].next
LF_Create_Monster_Wave(context, next_wave)
else
PrintLog(context, "计时器-小怪复活"..timer_name)
local monster_cid = tonumber(timer_name)
ScriptLib.CreateMonster(context, { config_id = monster_cid, delay_time = 0 })
end
return 0
end
--------- 关卡Functions --------
function LF_Update_Score(context, is_elite, wave)
local wave_info = monster_list[wave]
local score = 0
local energy = 0
if wave_info ~= nil then
if is_elite == 1 then
PrintLog(context, "精英怪死亡")
score = wave_info.elite_monster_score or 0
energy = wave_info.elite_monster_energy or 0
else
PrintLog(context, "普通怪死亡")
score = wave_info.tide_mons_score or 0
energy = wave_info.tide_mons_energy or 0
end
end
PrintLog(context, "怪物分数:"..score.."。怪物能量:"..energy)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, { ["add_score"] = score, ["add_energy"] = energy })
end
function LF_Create_Monster_Wave(context, wave)
PrintLog(context, "怪物波次:"..wave)
--ScriptLib.ShowReminder(context, defs.reminder_id)
ScriptLib.SetGroupVariableValue(context, "current_wave", wave)
-- 精英怪
local elites = monster_list[wave].elite_monster
for _, _configID in pairs(elites) do
ScriptLib.CreateMonster(context, { config_id = _configID, delay_time = 0 })
end
local left_elites = #elites or 0
ScriptLib.SetGroupVariableValue(context, "left_elites", left_elites)
PrintLog(context, "该波次精英怪数量:"..left_elites)
--ScriptLib.SetGroupVariableValue(context, "wave_pause", 0)
-- 普通怪
local monsters = monster_list[wave].tide_mons
for _, _configID in pairs(monsters) do
ScriptLib.CreateMonster(context, { config_id = _configID, delay_time = 0 })
end
end
function LF_Cancel_Monster_Timers(context, wave)
local monsters = monster_list[wave].tide_mons
for _, _cid in pairs(monsters) do
if 0 ~= ScriptLib.CancelGroupTimerEvent(context, base_info.group_id, tostring(_cid)) then
PrintLog(context, "找不到Timer:".._cid)
else
PrintLog(context, "取消TIMER成功:".._cid)
end
end
end
function LF_Initialize_Level()
for k, v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables, { config_id = 50000001, name = "current_wave", value = 1})
table.insert(variables, { config_id = 50000002, name = "left_elites", value = 99})
table.insert(variables, { config_id = 50000003, name = "level_stopped", value = 0})
end
function LF_Start_Play(context)
ScriptLib.SetGroupVariableValue(context, "level_stopped", 0)
ScriptLib.StartGallery(context, defs.gallery_id)
if defs.energy_gadget ~= nil then
ScriptLib.KillEntityByConfigId(context, {config_id = defs.energy_gadget})
end
-- 刷怪
local next_wave = 1
LF_Create_Monster_Wave(context, next_wave)
end
--终止玩法
function LF_Stop_Play(context, success)
if ScriptLib.GetGroupVariableValue(context, "level_stopped") == 1 then
return 0
end
ScriptLib.SetGroupVariableValue(context, "level_stopped", 1)
-- if 0 ~= ScriptLib.StopGallery(context, defs.gallery_id, true) then
-- PrintLog(context, "Stop Gallery失败")
-- end
-- 关卡重置
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
ScriptLib.SetGadgetStateByConfigId(context, defs.operator_id, 202)
-- success比fail多了avatar复活逻辑。本次活动应该只会用到fail
if success == true then
ScriptLib.CauseDungeonSuccess(context)
else
ScriptLib.CauseDungeonFail(context)
end
end
LF_Initialize_Level()

View File

@@ -0,0 +1,446 @@
--[[======================================
|| filename: Activity_Parkour
|| owner: chao.cui
|| description: 3.0大活动-跑酷
|| LogName: TD
|| Protection: ???
=======================================]]
--[[
local defs = {
gallery_id = ,
--开启机关交互后,加载哪个/些suit
load_on_start = {2},
--开启机关的configIDSelectOption为175
starter_gadget = 0,
--终点region的configID
end_regionID = 0,
--玩法RegionID进入此圈开启性能优化在suit1
parkour_regions = {},
--全程终点在哪个suit,如果这个group非终点则配0
end_suite = 0,
--挑战限时秒
challenge_time = 300,
--镜头注目
look_pos = {x=555, y=555, z=555},
duration = 2,
}
]]--
local global =
{
father_challengeID = 2010050,
total_coin_count = 0,
}
local triggers_start =
{
--测试用
--{ config_id = 8000000, name = "Test_GM", event = EventType.EVENT_VARIABLE_CHANGE, source = "testGM", condition = "", action = "", trigger_count = 0, tag = "100"},
{ config_id = 41000001, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0 },
{ config_id = 40000000, name = "Gadget_Create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
{ config_id = 40000001, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_select_option", action = "action_select_option", trigger_count = 0 },
{ config_id = 40000002, name = "Challenge_Fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "",condition = "", action = "action_challenge_fail", trigger_count= 0 },
{ config_id = 40000003, name = "Coin_Get", event = EventType.EVENT_VARIABLE_CHANGE, source = "coin_counter", condition = "", action = "", trigger_count = 0, tag = "888" },
--{ config_id = 8000004, name = "Spec_Coin_Get", event = EventType.EVENT_VARIABLE_CHANGE, source = "spec_coin_counter", condition = "", action = "", trigger_count = 0, tag = "999"},
--玩法RegionID进入此圈开启性能优化放在load_on_start第一个suit里
{ config_id = 40000005, name = "Enter_Optimiz_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_OptimizRegion", trigger_count = 0 },
{ config_id = 40000006, name = "Leave_Optimiz_Region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "",action = "action_leave_OptimizRegion", trigger_count= 0 },
{ config_id = 40000007, name = "Group_Will_Unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0 },
{ config_id = 40000008, name = "Enter_Tutorial_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_TutorialRegion", trigger_count = 0 },
}
local triggers_end =
{
--终点的trigger
{ config_id = 40000009, name = "Enter_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_enter_final", action = "", trigger_count = 0, tag = "666" },
{ config_id = 40000010, name = "Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count= 0 },
}
---------- Basic Functions -------------
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_Parkour] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
--用于检查value是否在目标table中
function CheckIsInTable(context, value, check_table)
for i = 1,#check_table do
if check_table[i] == value then
return true
end
end
return false
end
--------- Local Functions -----------
function LF_Initialize_Group(triggers, suites)
--起点用触发器
for k,v in pairs(triggers_start) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--全程结尾触发器
for k,v in pairs(triggers_end) do
table.insert(triggers, v)
table.insert(suites[defs.end_suite].triggers, v.name)
end
-- Vars
table.insert(variables, { config_id = 50000001, name = "coin_counter", value = 0})
--table.insert(variables,{ config_id=50000002,name = "spec_coin_counter", value = 0})
LF_Calculate_Coin_Num()
return 0
end
-- 统计关卡的金币总数
function LF_Calculate_Coin_Num()
local sum = 0
for _, gadgetInfo in pairs(gadgets) do
if gadgetInfo.gadget_id == 70220121 then
sum = sum + 1
end
end
global.total_coin_count = sum
end
function LF_InitChallenge(context)
--挑战状态标记
ScriptLib.SetGroupTempValue(context, "challenge_state", 1, {})
-- 开父挑战再Attach保序
ScriptLib.CreateFatherChallenge(context, 1, global.father_challengeID, defs.challenge_time, {success = 10, fail = 5})
if 0 == ScriptLib.StartFatherChallenge(context, 1) then
--PrintLog(context, "开启父挑战成功")
else
PrintLog(context, "开启父挑战失败")
end
-- param tableparam1-event类型, param2-Tag, param3:次数, param4:达到次数是否success
-- 限时到达
if 0 ~= ScriptLib.AttachChildChallenge(context, 1, 101, 2010051, {4, 666, 1, 1}, {}, {success = 10, fail = 5}) then
PrintLog(context, "子挑战2010051添加失败")
end
-- 收集金币
if 0 ~= ScriptLib.AttachChildChallenge(context, 1, 102, 2010052, {3, 888, 999}, {}, {success = 0, fail = 0}) then
PrintLog(context, "子挑战2010052添加失败")
end
return 0
end
function LF_Try_StartTutorial(context)
--local ownerUid = context.owner_uid
if 0 ~= ScriptLib.AssignPlayerShowTemplateReminder(context,192,{param_uid_vec={},param_vec={},uid_vec={context.uid}}) then
PrintLog(context, "弹教程失败")
else
PrintLog(context, "弹教程成功")
end
return 0
end
function LF_FailChallenge(context, reason)
PrintLog(context, "挑战失败处理")
--停Gallery
--Reason 0-NONE 1-超时 2-客户端中断 3-lua设置成功 4-lua设置失败
ScriptLib.StopGalleryByReason(context, defs.gallery_id, reason)
LF_Reset_Level(context)
return 0
end
function LF_RevertVisionType(context)
local uidList = ScriptLib.GetSceneUidList(context)
for k, v in pairs(uidList) do
if 0 == ScriptLib.RevertPlayerRegionVision(context, v) then
PrintLog(context, "Revert Vision成功"..v)
end
if 0 ~= ScriptLib.SetPlayerGroupVisionType(context, {v}, {1}) then
PrintLog(context, "设置VisionType失败"..v)
end
end
return 0
end
function CameraAction(context)
if defs.look_pos and defs.duration then
--触发镜头注目,强制注目形式,不广播其他玩家
local pos_follow = {x=0, y=0, z=0}
ScriptLib.BeginCameraSceneLook(context, { look_pos = defs.look_pos, is_allow_input = false, duration = defs.duration, is_force = true, is_broadcast = false, is_recover_keep_current = true, delay = 0,
is_set_follow_pos = false, follow_pos = pos_follow, is_force_walk = false, is_change_play_mode = false,
is_set_screen_XY = false, screen_x = 0, screen_y = 0 })
return 0
else
PrintLog(context, "缺少镜头参数")
end
return 0
end
function LF_Reset_Level(context)
--重置变量
ScriptLib.SetGroupVariableValue(context, "coin_counter", 0)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
-- 设置操作台
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.starter_gadget, {175})
ScriptLib.SetGadgetStateByConfigId(context, defs.starter_gadget, GadgetState.Default)
for i = 2, #suites do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i)
end
--环境小动物恢复
ScriptLib.SwitchSceneEnvAnimal(context, 2)
LF_RevertVisionType(context)
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
end
--------- Server Lua Call -----------
function SLC_Activity_Parkour_PickCoin(context)
-- 触发挑战trigger
ScriptLib.ChangeGroupVariableValue(context, "coin_counter", 1)
-- pick_up为拾取类型。0金币
if 0 ~= ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["pick_up"] = 0}) then
PrintLog(context, "Gallery通信失败")
end
return 0
end
---------- Triggers -----------
function action_gallery_stop(context, evt)
-- TEST
PrintLog(context, "GalleryID:"..evt.param1.."终止。原因:"..evt.param3)
--环境小动物恢复
ScriptLib.SwitchSceneEnvAnimal(context, 2)
--VisionType恢复
LF_RevertVisionType(context)
return 0
end
function action_enter_TutorialRegion(context, evt)
if defs.guide_regionID == nil then
return 0
elseif evt.param1 == defs.guide_regionID then
LF_Try_StartTutorial(context)
end
return 0
end
function action_gadget_create(context, evt)
if defs.starter_gadget ~= evt.param1 then
return -1
end
-- 设置操作台选项
if 0 ~= ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.starter_gadget, {175}) then
PrintLog(context, "设置操作台选项失败")
return -1
end
return 0
end
function condition_select_option(context, evt)
--幻梦之门玩法中阻止挑战开启
if ScriptLib.IsChallengeStartedByChallengeId(context, 267) then
ScriptLib.ShowReminderByUid(context, {context.uid}, 400046)
return false
end
return true
end
--机关开启处理
function action_select_option(context, evt)
--检查SelectOption
if defs.starter_gadget ~= evt.param1 or 175 ~= evt.param2 then
return -1
end
--检查是否单机
if true == ScriptLib.CheckIsInMpMode(context) then
for k,v in pairs(gadgets) do
if v.config_id == defs.starter_gadget then
center = v.pos
break
end
end
-- 400053:多人游戏状态下无法进行挑战
ScriptLib.ShowReminderRadius(context, 400053, center, 2)
return -1
end
--LD用多个Region覆盖赛道范围这个变量用于判断是否出圈
ScriptLib.SetGroupTempValue(context, "is_in_region", 0, {})
--切操作台状态
ScriptLib.SetGadgetStateByConfigId(context, defs.starter_gadget, GadgetState.GearStart)
--去掉操作台SelectOption
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.starter_gadget, 175)
--加载第一波suite
for k, v in pairs(defs.load_on_start) do
if 0 == ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v) then
PrintLog(context, "加载suite"..v)
end
end
--环境小动物关闭
ScriptLib.SwitchSceneEnvAnimal(context, 0)
-- VISION TYPE
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
-- if base_info.group_id == 133008671 then
-- ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0,3})
-- end
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
LF_InitChallenge(context)
--开启Gallery
if 0 ~= ScriptLib.StartGallery(context, defs.gallery_id) then
PrintLog(context, "开启Gallery失败")
else
PrintLog(context, "金币总数-"..global.total_coin_count)
if 0 ~= ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["total_coin_count"] = global.total_coin_count}) then
PrintLog(context, "Gallery传金币数量失败")
end
end
--TODO:镜头注目
CameraAction(context)
return 0
end
function action_challenge_success(context,evt)
if evt.param1 ~= global.father_challengeID then
return -1
end
PrintLog(context, "挑战成功处理")
--停Gallery
--Reason 0-NONE 1-超时 2-客户端中断 3-lua设置成功 4-lua设置失败
ScriptLib.StopGalleryByReason(context, defs.gallery_id, 3)
LF_Reset_Level(context)
-- -- 终点kill特效
-- ScriptLib.KillEntityByConfigId(context, { group_id = base_info.group_id, config_id = defs.end_gadget, entity_type = EntityType.GADGET })
-- -- Remove所有关卡suite
-- for i = 2, (#suites-1) do
-- ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i)
-- end
return 0
end
function action_challenge_fail(context, evt)
--param2 剩余时间
if evt.param2 <= 0 then
-- 超时
LF_FailChallenge(context, 1)
else
if ScriptLib.IsPlayerAllAvatarDie(context, context.owner_uid) then
-- 团灭
PrintLog(context, "挑战失败-灭队")
LF_FailChallenge(context, 8)
else
-- 主动中断
PrintLog(context, "挑战失败-客户端中断/其他")
LF_FailChallenge(context, 2)
end
end
return 0
end
function action_enter_OptimizRegion(context, evt)
--检查Region的configId是否是优化圈
if CheckIsInTable(context,evt.param1, defs.parkour_regions) then
ScriptLib.ChangeGroupTempValue(context, "is_in_region", 1, {})
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
PrintLog(context, "进入跑酷区域"..evt.param1)
end
end
return 0
end
function action_leave_OptimizRegion(context,evt)
--检查Region的configId是否是优化圈
if CheckIsInTable(context,evt.param1,defs.parkour_regions) then
ScriptLib.ChangeGroupTempValue(context, "is_in_region", -1, {})
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) ~= 1 then
return 0
end
PrintLog(context, "出赛道区域"..evt.param1)
--如果完全出圈了,触发挑战失败
local is_in_region = ScriptLib.GetGroupTempValue(context, "is_in_region", {})
if is_in_region <= 0 then
LF_FailChallenge(context, 4)
end
end
return 0
end
--终点检查
function condition_enter_final(context, evt)
if evt.param1 ~= defs.end_regionID then
return false
end
return true
end
--卸载保护
function action_group_will_unload(context,evt)
PrintLog(context, "GROUP UNLOAD.")
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,96 @@
--[[======================================
|| filename: Activity_Photo
|| owner: chao.cui
|| description: 3.0大活动-拍照
|| LogName: TD
|| Protection: ???
=======================================]]
-- @李鸿杰 还没布设相关GROUP
--[[
local defs =
{
-- Group对应的groupbundle
group_bundle_id = 0,
}
--]]
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_Photo] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
--{ config_id = 40000001, name = "tri_group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
--{ config_id = 40000002, name = "tri_group_will_unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_EVENT_GROUP_WILL_UNLOAD", trigger_count = 0 },
{ config_id = 40000003, name = "tri_monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0 },
--{ config_id = 40000004, name = "tri_enter_region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION", action = "action_EVENT_ENTER_REGION", trigger_count = 0 },
{ config_id = 40000005, name = "tri_leave_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "condition_EVENT_LEAVE_REGION", action = "action_EVENT_LEAVE_REGION", trigger_count = 0 },
{ config_id = 40000006, name = "force_refresh_group", event = EventType.EVENT_GRAVEN_PHOTO_REFRESH_GROUP, source = "", condition = "", action = "action_force_refresh_group", trigger_count = 0}
}
------ conditions & actions ------
-- function action_EVENT_GROUP_LOAD(context, evt)
-- return 0
-- end
-- function action_EVENT_GROUP_WILL_UNLOAD(context, evt)
-- return 0
-- end
function action_EVENT_ANY_MONSTER_DIE(context, evt)
PrintLog(context, "小动物死亡/消失")
-- @唐天鹏 小动物死亡/消失都会触发 event_any_monster_die
if ScriptLib.GetGroupMonsterCount(context) == 0 then
-- @唐天鹏 新增ScriptLib关闭当前groupbundle的mark并寻找其他的groupbundle显示mark
ScriptLib.InvaildGravenPhotoBundleMark(context, defs.group_bundle_id)
--if ScriptLib.IsInRegion(context, context.owner_uid, defs.play_region) then
ScriptLib.SetGroupVariableValue(context, "Act_GI_Photo_MonsterClear", 1)
--end
end
return 0
end
function condition_EVENT_LEAVE_REGION(context, evt)
if evt.param1 == defs.play_region then
return true
end
return false
end
function action_EVENT_LEAVE_REGION(context, evt)
PrintLog(context, "离开区域")
-- 刷新小动物
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
return 0
end
function action_force_refresh_group(context, evt)
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
return 0
end
--------- 关卡Functions --------
function LF_Initialize_Level()
-- Triggers
for _, _tri in pairs(extraTriggers) do
table.insert(triggers, _tri)
table.insert(suites[1].triggers, _tri.name)
end
table.insert(variables, {config_id = 50000001, name = "Act_GI_Photo_MonsterClear", value = 0, no_refresh = false})
return 0
end
LF_Initialize_Level()

View File

@@ -0,0 +1,931 @@
--[[======================================
|| filename: Activity_TreasureSeelie
|| owner: chao.cui
|| description: 3.0 寻宝仙灵
|| LogName: TD
|| Protection: ???
=======================================]]
--[[
local defs =
{
-- 挑战编号
challenge_id = 2009009,
-- 探查点交互选项ID
starter_option_id = 175,
-- 挖掘点交互选项ID
dig_option_id = 39,
-- 能量球所在suite
energy_ball_suite = 10,
-- 备用元素微粒suite
-- element_suite = 11,
}
-- 各玩法阶段配置
local play_stage =
{
[1] =
{
gallery_id = 26001,
-- 挑战限时
challenge_time = 300,
-- 收集元素微粒数量
element_target = 3,
-- 探查点configID
starter_operator_configID = ,
-- 挖掘点configID
dig_operator_configID = ,
-- 宝箱configID
treasure_configID = ,
-- 探查点suite
starter_operator_suite = ,
-- 玩法suite
level_suite = ,
-- 挖掘点suite
dig_operator_suite ,
-- 宝箱suite
treasure_suite = ,
},
[2] =
{
},
[3] =
{
}
}
-- 备用元素微粒的configID
local extra_elements =
{
73017,73018,73019,73020,73021,73022,73023,73024
}
]]--
local extraTriggers =
{
--测试用
--{ config_id = 41000001, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0 },
--{ config_id = 49000001, name = "tri_reminder", event = EventType.EVENT_VARIABLE_CHANGE, source = "style", condition = "", action = "action_reminder_style", trigger_count = 0 },
--
{ config_id = 40000001, name = "tri_group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 40000003, name = "tri_select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
-- 挑战触发Trigger
{ config_id = 40000004, name = "tri_element_get", event = EventType.EVENT_VARIABLE_CHANGE, source = "element_counter", condition = "condition_element_get", action = "", trigger_count = 0, tag = "666" },
--{ config_id = 40000002, name = "tri_energy_ball_get", event = EventType.EVENT_VARIABLE_CHANGE, source = "energy_ball_counter", condition = "", action = "action_energy_ball_picked", trigger_count = 0 },
{ config_id = 40000005, name = "tri_gadget_create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
{ config_id = 40000006, name = "tri_challenge_fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count= 0 },
{ config_id = 40000007, name = "tri_challenge_success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count= 0 },
-- 玩法区域
{ config_id = 40000008, name = "tri_enter_play_region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", forbid_guest = false, trigger_count = 0 },
{ config_id = 40000009, name = "tri_leave_play_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", forbid_guest = false, trigger_count = 0 },
--
{ config_id = 40000010, name = "tri_gadget_state_change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "condition_gadget_state_change", action = "action_gadget_state_change", trigger_count = 0 },
{ config_id = 40000011, name = "tri_group_will_unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0 },
{ config_id = 40000012, name = "tri_monster_die", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die", trigger_count = 0 },
{ config_id = 40000013, name = "tri_perform_timer", event = EventType.EVENT_TIMER_EVENT, source = "", condition = "", action = "action_perform_timer", trigger_count = 0 },
{ config_id = 40000014, name = "tri_seelie_out", event = EventType.EVENT_VARIABLE_CHANGE, source = "seelie_out", condition = "", action = "action_var_seelie_out", trigger_count = 0 },
}
---------- Basic Functions -------------
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_TreasureSeelie] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
--------- Level Functions -----------
function LF_Initialize_Group(triggers, suites)
-- Triggers
for _k, _tri in pairs(extraTriggers) do
table.insert(triggers, _tri)
table.insert(suites[1].triggers, _tri.name)
end
-- Vars
table.insert(variables, { config_id = 50000001, name = "energy_ball_counter", value = 0, no_refresh = true})
table.insert(variables, { config_id = 50000002, name = "element_counter", value = 0, no_refresh = false})
table.insert(variables, { config_id = 50000003, name = "current_challenge_stage", value = 0, no_refresh = false})
-- 进度存储
table.insert(variables, { config_id = 50000004, name = "stage_progress1", value = 0, no_refresh = true})
table.insert(variables, { config_id = 50000005, name = "stage_progress2", value = 0, no_refresh = true})
table.insert(variables, { config_id = 50000006, name = "stage_progress3", value = 0, no_refresh = true})
-- 总进度
table.insert(variables, { config_id = 50000007, name = "stage_counter", value = 0, no_refresh = true})
-- 仙灵是否离体
table.insert(variables, { config_id = 50000008, name = "seelie_out", value = 0, no_refresh = true})
-- 仙灵是否装备
-- var并没有什么用,改为从GV:_SeekerSeelieV3_equipped直接获取 by siyu.li
table.insert(variables, { config_id = 50000009, name = "seelie_equipped", value = 0, no_refresh = false})
-- 元素微粒使用计数
table.insert(variables, { config_id = 50000010, name = "element_used", value = 0, no_refresh = false})
return 0
end
-- 进入玩法区域弹提示
function LF_Try_StartTutorial(context)
ScriptLib.ShowCommonPlayerTips(context, 1, {"UI_ACTIVITY_TREASURE_ENTER_AREA_REMIND_TITLE", "UI_ACTIVITY_TREASURE_ENTER_AREA_REMIND_DESC"})
return 0
end
-- 重置关卡
function LF_Reset_Level(context)
PrintLog(context, "LF_Reset_Level")
-- 修复区域完成后的仙灵BUG区域探索完成后不再重置
if ScriptLib.GetGroupVariableValue(context, "stage_counter") >= 3 then
-- 通知小道具卸下
--ScriptLib.SetGroupVariableValue(context, "seelie_equipped", 0)
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_SeelieGameplayGroup", 0)
return 0
end
for i = 2, #suites do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i)
end
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
return 0
end
-- 第stage个探查点被发现
function LF_SearchPoint_Found(context, stage)
PrintLog(context, "发现探查点:"..stage)
ScriptLib.ShowReminder(context, 600128)
-- 存档
ScriptLib.SetGroupVariableValue(context, "stage_progress"..stage, 1)
-- 探查点出现
LF_Show_Search_Point(context, stage, true)
end
-- 第stage个挖掘点被发现
function LF_DigPoint_Found(context, stage)
PrintLog(context, "发现挖掘点:"..stage)
-- 存档
ScriptLib.SetGroupVariableValue(context, "stage_progress"..stage, 2)
-- 挖掘点出现
LF_Show_Dig_Point(context, stage, true)
end
-- 与configID探查点交互开启玩法
function LF_Search_Point_Interacted(context, configID)
local stage = 1
for i = 1, #play_stage do
if play_stage[i].starter_operator_configID == configID then
stage = i
break
end
end
if ScriptLib.IsGalleryStart(context, play_stage[stage].gallery_id) then
return -1
end
LF_Start_Play(context, stage)
end
-- 与挖掘点交互(挖出宝箱)
function LF_Dig_Point_Interacted(context, configID)
--local widget_equipped = ScriptLib.GetGroupVariableValue(context, "seelie_equipped")
local widget_equipped = ScriptLib.GetTeamAbilityFloatValue(context, context.owner_uid, "_SeekerSeelieV3_equipped")
if widget_equipped == nil then
widget_equipped = 0
end
if widget_equipped == 0 then
--REMINDER "请先装备小道具"
ScriptLib.ShowReminder(context, 600132)
return
end
local stage = 1
for i = 1, #play_stage do
if play_stage[i].dig_operator_configID == configID then
stage = i
break
end
end
-- 存档
ScriptLib.SetGroupVariableValue(context, "stage_progress"..stage, 3)
-- 隐藏挖掘点
-- 宝箱不开不隐藏mark,只隐藏效果 by siyu.li
ScriptLib.SetGadgetStateByConfigId(context, play_stage[stage].dig_operator_configID, 202)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, play_stage[stage].dig_operator_configID, defs.dig_option_id)
-- LF_Show_Dig_Point(context, stage, false)
-- 加载宝箱suite
suite_index = play_stage[stage].treasure_suite
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, suite_index)
-- 仙灵回身边
PrintLog(context, "仙灵回身边")
ScriptLib.SetGroupVariableValue(context, "seelie_out", 0)
LF_Objects_Display(context, true)
end
-- (根据小道具是否离体)控制【能量球】和【探查点】的显隐
function LF_Objects_Display(context, is_display)
if is_display == true then
-- 恢复能量球显示
LF_Show_Energy_Balls(context, true)
-- 恢复所有未完成的探查点
for i = 1, #play_stage do
local progress = ScriptLib.GetGroupVariableValue(context, "stage_progress"..i)
if progress == 1 then
LF_Show_Search_Point(context, i, true)
-- 如果宝箱未开启,则额外标记mark by siyu.li
elseif progress == 3 then
ScriptLib.SetGadgetStateByConfigId(context, play_stage[i].dig_operator_configID, 202)
end
end
PrintLog(context, "显示能量球&探查点")
else
-- 隐藏全部探查点
for i = 1, #play_stage do
local progress = ScriptLib.GetGroupVariableValue(context, "stage_progress"..i)
LF_Show_Search_Point(context, i, false)
-- 若宝箱未开启,同时隐藏mark by siyu.li
if progress == 3 then
ScriptLib.SetGadgetStateByConfigId(context, play_stage[i].dig_operator_configID, 201)
end
end
-- 卸载能量球suite
LF_Show_Energy_Balls(context, false)
PrintLog(context, "隐藏能量球&探查点")
end
end
-- 开启第stage个玩法
function LF_Start_Play(context, stage)
PrintLog(context, "开启玩法阶段"..stage)
ScriptLib.SetGroupVariableValue(context, "current_challenge_stage", stage)
ScriptLib.SetGroupVariableValue(context, "element_used", 0)
-- 重置element_counter
ScriptLib.SetGroupVariableValue(context, "element_counter", 0)
-- 加载玩法suite
LF_Show_Level(context, stage, true)
local configID = play_stage[stage].starter_operator_configID
--切探查点状态(发射子弹)
ScriptLib.SetGadgetStateByConfigId(context, configID, 201)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, configID, defs.starter_option_id)
-- 隐藏小道具
PrintLog(context, "仙灵飞出去")
ScriptLib.SetGroupVariableValue(context, "seelie_out", 1)
-- 能量球和探查点不可见
LF_Objects_Display(context, false)
-- 开挑战
LF_Init_Challenge(context, stage)
-- 开Gallery
local gallery_id = play_stage[stage].gallery_id
if 0 ~= ScriptLib.StartGallery(context, gallery_id) then
PrintLog(context, "开启Gallery失败")
end
local progress_tbl = {0, play_stage[stage].element_target}
PrintLog(context, "进度需求:"..play_stage[stage].element_target)
ScriptLib.InitGalleryProgressScore(context, "Seelie", gallery_id, progress_tbl, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_TREASURE, GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NO_DEGRADE)
end
function LF_Stop_Play(context, stage, success)
PrintLog(context, "stop stage"..stage)
ScriptLib.SetGroupVariableValue(context, "element_counter", 0)
-- 停Gallery (param3-is_fail)
ScriptLib.StopGallery(context, play_stage[stage].gallery_id, not success)
-- 移除玩法suite
LF_Show_Level(context, stage, false)
-- 移除动态添加的元素微粒
local num = ScriptLib.GetGroupVariableValue(context, "element_used")
for i = 1, num do
local cid = extra_elements[i]
ScriptLib.KillEntityByConfigId(context, { config_id = cid })
end
ScriptLib.SetGroupVariableValue(context, "current_challenge_stage", 0)
end
-- 检查是否满足【能量球】和【探查点】的显示条件(小道具装备&&仙灵未离体)
function LF_Player_Can_See(context)
if not ScriptLib.IsInRegion(context, context.owner_uid, suites[1].regions[1]) then
return false
end
local seelie_out = ScriptLib.GetGroupVariableValue(context, "seelie_out")
PrintLog(context, "小道具离体:"..seelie_out)
--local widget_equipped = ScriptLib.GetGroupVariableValue(context, "seelie_equipped")
--[[if context.owner_uid == nil then
PrintLog(context, "LF_Player_Can_See : owner_uid=nil")
else
PrintLog(context, "LF_Player_Can_See : owner_uid="..context.owner_uid)
end--]]
local uid_list = ScriptLib.GetSceneUidList(context)
host_uid = context.owner_uid
if uid_list[1] ~= nil then
host_uid = uid_list[1]
end
local widget_equipped = ScriptLib.GetTeamAbilityFloatValue(context, host_uid, "_SeekerSeelieV3_equipped")
if widget_equipped == nil then
widget_equipped = 0
end
PrintLog(context, "小道具装备:"..widget_equipped)
if seelie_out == 0 and widget_equipped == 1 then
return true
end
return false
end
-- function LF_Get_Owner_UID(context)
-- local UidList = ScriptLib.GetSceneUidList(context)
-- local ownerUid = UidList[1]
-- PrintLog(context, "OWNER_UID:"..ownerUid)
-- return ownerUid
-- end
-- 显示/隐藏【能量球】
function LF_Show_Energy_Balls(context, show)
if show == true then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.energy_ball_suite)
else
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, defs.energy_ball_suite)
end
end
-- 显示/隐藏某阶段的【探查点】
function LF_Show_Search_Point(context, stage, show)
local configID = play_stage[stage].starter_operator_configID
if show == true then
ScriptLib.SetGadgetStateByConfigId(context, configID, 0)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, configID, {defs.starter_option_id})
else
ScriptLib.SetGadgetStateByConfigId(context, configID, 202)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, configID, defs.starter_option_id)
end
end
-- 显示/隐藏某阶段的【挖掘点】
function LF_Show_Dig_Point(context, stage, show)
local suite_index = play_stage[stage].dig_operator_suite
local configID = play_stage[stage].dig_operator_configID
if show == true then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, suite_index)
-- 切状态显示mark
ScriptLib.SetGadgetStateByConfigId(context, configID, 0)
else
-- 切状态隐藏mark
if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, configID, 201) then
PrintLog(context, "隐藏挖掘点mark失败")
end
--ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, suite_index)
end
end
-- 显示/隐藏某阶段的【关卡内容】
function LF_Show_Level(context, stage, show)
local suite_index = play_stage[stage].level_suite
if show == true then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, suite_index)
else
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, suite_index)
end
end
function LF_Init_Challenge(context, stage)
local challenge_time = play_stage[stage].challenge_time
local target = play_stage[stage].element_target
--参数1限时时间 参数2event_type所在枚举序号 参数3 trigger_tag参数4次数
local c_index = 1 --跑酷
if #suites[play_stage[stage].level_suite].monsters > 0 then
c_index = 2 --战斗
end
c_index = stage * 10 +c_index
if 0 ~= ScriptLib.StartChallenge(context, c_index, defs.challenge_id, {challenge_time, 3, 666, target}) then
PrintLog(context, "开启挑战失败")
else
local uid_list = ScriptLib.GetSceneUidList(context)
for i,uid in ipairs(uid_list) do
if ScriptLib.IsInRegion(context, uid, play_stage[stage].optimize_region) then
ScriptLib.SetPlayerGroupVisionType(context, {uid}, {0})
ScriptLib.ForbidPlayerRegionVision(context, uid)
end
end
end
end
function LF_Set_Seelie_Light_Level(context, light_level)
--local ownerUid = LF_Get_Owner_UID(context)
local ownerUid = ScriptLib.GetSceneOwnerUid(context)
if 0 == ScriptLib.SetTeamServerGlobalValue(context, ownerUid, "SGV_SeelieLightLevel", light_level) then
PrintLog(context, "设置仙灵亮度等级:"..light_level)
end
if light_level == 3 then
-- 延时X秒设亮度为0
ScriptLib.CreateGroupTimerEvent(context, base_info.group_id, "PerformEnd", 4)
end
end
-- 恢复存档
function LF_Load_Level(context)
-- progress 存档
-- 1- 探查点出现
-- 2- 挖掘点出现
-- 3- 宝箱出现
-- 4- 宝箱开启
-- 能量球
-- if LF_Player_Can_See(context) == true then
-- LF_Show_Energy_Balls(context, true)
-- end
-- 服务器core可能引起seelie_out未能重置,以及原始能量球残留
ScriptLib.SetGroupVariableValue(context, "seelie_out", 0)
for i = 1, #play_stage do
LF_Show_Level(context, i, false)
end
-- 加载所有探查点suite。探查点的可见性与物件状态关联
for i = 1, #play_stage do
local suite_index = play_stage[i].starter_operator_suite
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, suite_index)
end
-- 根据存档加载挖掘点&宝箱
for i = 1, #play_stage do
local progress = ScriptLib.GetGroupVariableValue(context, "stage_progress"..i)
-- 宝箱未开恢复mark by siyu.li
if progress == 2 or progress == 3 then
local suite_index = play_stage[i].dig_operator_suite
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, suite_index)
if progress == 3 then
if ScriptLib.IsInRegion(context, context.owner_uid, suites[1].regions[1]) then
ScriptLib.SetGadgetStateByConfigId(context, play_stage[i].dig_operator_configID, 202)
else
ScriptLib.SetGadgetStateByConfigId(context, play_stage[i].dig_operator_configID, 201)
end
end
end
--[[ if progress == 3 then
local suite_index = play_stage[i].treasure_suite
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, suite_index)
end--]]
end
end
--------- Server Lua Call -----------
-- 拾取能量球
function SLC_Activity_TreasureSeelie_PickEnergyBall(context)
-- 能量球计数
local num = ScriptLib.GetGroupVariableValue(context, "energy_ball_counter")
num = num + 1
ScriptLib.SetGroupVariableValue(context, "energy_ball_counter", num)
PrintLog(context, "拾取能量球"..num)
-- 仙灵表现(亮度)
local light_level = num % 3
if light_level == 0 then
light_level = 3
end
LF_Set_Seelie_Light_Level(context, light_level)
-- 显示能量球进度的定制REMINDER "x/3"
ScriptLib.TreasureSeelieCollectOrbsNotify(context, light_level, 3)
local order = ScriptLib.GetTreasureSeelieDayByGroupId(context, 0)
-- 发现新的探查点
if num == 3 or num == 6 or num == 9 then
local stage = math.floor(num/3)
LF_SearchPoint_Found(context, stage)
-- 运营埋点:能量球进度 & 探查点发现进度
ScriptLib.MarkGroupLuaAction(context, "ActivityTreasureSeelie1", "", {["region_order"] = order, ["energy_ball_counter"] = num, ["find_point"] = stage})
else
-- 运营埋点:能量球进度 & 探查点发现进度
ScriptLib.MarkGroupLuaAction(context, "ActivityTreasureSeelie1", "", {["region_order"] = order, ["energy_ball_counter"] = num})
end
return 0
end
-- 拾取元素微粒
function SLC_Activity_TreasureSeelie_PickElementParticle(context)
local num = ScriptLib.GetGroupVariableValue(context, "element_counter")
num = num + 1
ScriptLib.SetGroupVariableValue(context, "element_counter", num)
PrintLog(context, "拾元素微粒"..num)
-- Gallery通信
local stage = ScriptLib.GetGroupVariableValue(context, "current_challenge_stage")
PrintLog(context, "stage:"..stage)
if stage > 0 then
local gallery_id = play_stage[stage].gallery_id
PrintLog(context, "galleryID:"..gallery_id)
ScriptLib.AddGalleryProgressScore(context, "Seelie", gallery_id, 1)
end
return 0
end
-- 仙灵小道具玩家主动操作 (0-卸下, 1-装备)
function SLC_Activity_TreasureSeelie_SeelieEquipStateChanged(context, equipped)
PrintLog(context, "仙灵小道具装备状态:"..equipped)
--ScriptLib.SetGroupVariableValue(context, "seelie_equipped", math.floor(equipped))
if equipped == 1 then
if LF_Player_Can_See(context) == true then
if ScriptLib.GetGroupTempValue(context, "widget_first_used", {}) == 0 then
local _r = suites[1].regions[1]
if ScriptLib.IsInRegion(context, context.owner_uid, _r) then
local order = ScriptLib.GetTreasureSeelieDayByGroupId(context, base_info.group_id)
ScriptLib.MarkGroupLuaAction(context, "ActivityTreasureSeelie2", "", {["region_order"] = order, ["widget_first_use"] = ScriptLib.GetServerTime(context)})
ScriptLib.SetGroupTempValue(context, "widget_first_used", 1, {})
end
end
LF_Objects_Display(context, true)
end
else
LF_Objects_Display(context, false)
end
return 0
end
---------- Triggers -----------
function condition_element_get(context, evt)
if evt.param1 > evt.param2 then
return true
end
return false
end
function action_group_load(context, evt)
PrintLog(context, "寻宝仙灵 GROUP LOAD: 0610-1314")
LF_Load_Level(context)
return 0
end
-- 进入玩法区域
function action_enter_region(context, evt)
if evt.param1 == suites[1].regions[1] then
if context.uid ~= context.owner_uid then
return -1
end
PrintLog(context, "进入玩法区域")
if ScriptLib.GetGroupVariableValue(context, "stage_counter") >= 3 then
return 0
end
-- 弹引导REMINDER
LF_Try_StartTutorial(context)
-- 通知team仙灵小道具已进入玩法区域可装备
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_SeelieGameplayGroup", 1)
-- 根据关卡进度通知team仙灵是否可见
local seelie_out = ScriptLib.GetGroupVariableValue(context, "seelie_out")
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_SeelieInvisible", seelie_out)
-- 根据关卡进度还原仙灵亮度
local num = ScriptLib.GetGroupVariableValue(context, "energy_ball_counter")
local light_level = num % 3
LF_Set_Seelie_Light_Level(context, light_level)
--
if LF_Player_Can_See(context) == true then
LF_Objects_Display(context, true)
else
LF_Objects_Display(context, false)
end
for i = 1, #play_stage do
local progress = ScriptLib.GetGroupVariableValue(context, "stage_progress"..i)
if progress == 3 then
ScriptLib.SetGadgetStateByConfigId(context, play_stage[i].dig_operator_configID, 201)
local suite_index = play_stage[i].treasure_suite
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, suite_index)
end
end
return 0
else
for stage=1,#play_stage do
if evt.param1 == play_stage[stage].optimize_region then
if ScriptLib.IsChallengeStartedByChallengeId(context, defs.challenge_id) then
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
PrintLog(context, "进入挑战区域")
return 0
else
break
end
end
end
return -1
end
end
-- 离开玩法区域
function action_leave_region(context, evt)
local stage = ScriptLib.GetGroupVariableValue(context, "current_challenge_stage")
if evt.param1 == suites[1].regions[1] then
if context.uid ~= context.owner_uid then
return -1
end
PrintLog(context, "离开玩法区域")
ScriptLib.SetGroupTempValue(context, "widget_first_used", 0, {})
-- 将未结束的挑战设置失败
if stage > 0 then
ScriptLib.StopChallenge(context, 1, 0)
end
-- 通知小道具卸下
--ScriptLib.SetGroupVariableValue(context, "seelie_equipped", 0)
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_SeelieGameplayGroup", 0)
-- 隐藏能量球和探查点
LF_Objects_Display(context, false)
return 0
elseif stage ~= 0 and evt.param1 == play_stage[stage].optimize_region then
if ScriptLib.IsChallengeStartedByChallengeId(context, defs.challenge_id) then
PrintLog(context, "离开玩法区域")
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
ScriptLib.RevertPlayerRegionVision(context, context.uid)
if context.uid ~= context.owner_uid then
return -1
end
-- 将未结束的挑战设置失败
local c_index = 1
if #suites[play_stage[stage].level_suite].monsters > 0 then
c_index = 2
end
c_index = stage * 10 + c_index
ScriptLib.StopChallenge(context, c_index, 0)
end
return 0
else
return -1
end
end
function action_gadget_create(context, evt)
local configID = evt.param1
-- 给探查点和挖掘点分别上选项
for i = 1, #play_stage do
local progress = ScriptLib.GetGroupVariableValue(context, "stage_progress"..i)
if configID == play_stage[i].starter_operator_configID then
if progress == 1 and LF_Player_Can_See(context) == true then
LF_Show_Search_Point(context, i, true)
else
LF_Show_Search_Point(context, i, false)
end
elseif configID == play_stage[i].dig_operator_configID then
PrintLog(context, "挖掘点create")
if progress == 2 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, configID, {defs.dig_option_id})
end
end
end
return 0
end
function action_var_seelie_out(context, evt)
PrintLog(context, "seelie_out变化")
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_SeelieInvisible", evt.param1)
return 0
end
-- 操作台交互
function action_select_option(context, evt)
PrintLog(context, "操作台选项事件")
local config_id = evt.param1
local option_id = evt.param2
if option_id == defs.starter_option_id then
LF_Search_Point_Interacted(context, config_id)
end
if option_id == defs.dig_option_id then
LF_Dig_Point_Interacted(context, config_id)
end
return 0
end
function action_challenge_success(context, evt)
local stage = ScriptLib.GetGroupVariableValue(context, "current_challenge_stage")
local uid_list = ScriptLib.GetSceneUidList(context)
for i,uid in ipairs(uid_list) do
-- 防止联机玩家提前出圈被强迫处理视野
if ScriptLib.IsInRegion(context, uid, play_stage[stage].optimize_region) then
ScriptLib.SetPlayerGroupVisionType(context, {uid}, {1})
ScriptLib.RevertPlayerRegionVision(context, uid)
end
end
local stage = ScriptLib.GetGroupVariableValue(context, "current_challenge_stage")
local order = ScriptLib.GetTreasureSeelieDayByGroupId(context, 0)
-- 运营埋点探查点stage完成
ScriptLib.MarkGroupLuaAction(context, "ActivityTreasureSeelie2", "", {["region_order"] = order, ["region_progress_type"] = 3, ["challenge_order"] = stage})
-- 发现挖掘点
LF_DigPoint_Found(context, stage)
LF_Stop_Play(context, stage, true)
return 0
end
function action_challenge_fail(context, evt)
local stage = ScriptLib.GetGroupVariableValue(context, "current_challenge_stage")
local uid_list = ScriptLib.GetSceneUidList(context)
for i,uid in ipairs(uid_list) do
-- 防止联机玩家提前出圈被强迫处理视野
if ScriptLib.IsInRegion(context, uid, play_stage[stage].optimize_region) then
ScriptLib.SetPlayerGroupVisionType(context, {uid}, {1})
ScriptLib.RevertPlayerRegionVision(context, uid)
end
end
LF_Stop_Play(context, stage, false)
-- 仙灵回身边
PrintLog(context, "仙灵回身边")
ScriptLib.SetGroupVariableValue(context, "seelie_out", 0)
LF_Objects_Display(context, true)
-- 联机不能确保情况
local uid_list = ScriptLib.GetSceneUidList(context)
--PrintLog(context, "离开玩法区域")
return 0
end
function condition_gadget_state_change(context, evt)
PrintLog(context, evt.param2.."|"..evt.param1.."->"..evt.param3)
if evt.param1 ~= 102 then
return false
else return true
end
end
function action_gadget_state_change(context, evt)
local new_state = evt.param1
if new_state == 102 then
PrintLog(context, "宝箱打开")
-- 宝箱的configID
local configID = evt.param2
local stage = 1
for i = 1, #play_stage do
if play_stage[i].treasure_configID == configID then
stage = i
break
end
end
ScriptLib.SetGroupVariableValue(context, "stage_progress"..stage, 4)
-- 开宝箱删除mark by siyu.li
-- LF_Show_Dig_Point(context, stage, false)
ScriptLib.SetGadgetStateByConfigId(context, play_stage[stage].dig_operator_configID, 203)
-- 总进度+1
ScriptLib.ChangeGroupVariableValue(context, "stage_counter", 1)
local counter = ScriptLib.GetGroupVariableValue(context, "stage_counter")
PrintLog(context, "区域完成进度:"..counter)
local order = ScriptLib.GetTreasureSeelieDayByGroupId(context, 0)
-- Reminder "显示宝箱进度"
if counter == 1 then
ScriptLib.ShowReminder(context, 600129)
-- 运营埋点挖掘点1完成
ScriptLib.MarkGroupLuaAction(context, "ActivityTreasureSeelie2", "", {["region_order"] = order, ["region_progress_type"] = 2, ["dig_point_order"] = stage, ["token_progress"] = 60, ["token_goal"] = 180})
elseif counter == 2 then
ScriptLib.ShowReminder(context, 600130)
-- 运营埋点挖掘点2完成
ScriptLib.MarkGroupLuaAction(context, "ActivityTreasureSeelie2", "", {["region_order"] = order, ["region_progress_type"] = 2, ["dig_point_order"] = stage, ["token_progress"] = 120, ["token_goal"] = 180})
elseif counter == 3 then
ScriptLib.ShowReminder(context, 600131)
PrintLog(context, "区域完成")
-- 运营埋点区域完成挖掘点3完成
ScriptLib.MarkGroupLuaAction(context, "ActivityTreasureSeelie2", "", {["region_order"] = order, ["region_progress_type"] = 1, ["dig_point_order"] = stage, ["token_progress"] = 180, ["token_goal"] = 180})
-- 活动cond中直接做掉了,按理不需要lua处理,改为卸载自身 by siyu.li
--if 0 ~= ScriptLib.DeactivateGroupLinkBundle(context, base_info.group_id) then
-- PrintLog(context, "关闭黄圈失败")
--end
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_SeelieGameplayGroup", 0)
--ScriptLib.updateBundleMarkShowStateByGroupId(context, base_info.group_id, false)
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, 1)
end
end
return 0
end
--卸载保护
function action_group_will_unload(context,evt)
PrintLog(context, "GROUP UNLOAD.")
LF_Reset_Level(context)
return 0
end
function action_monster_die(context, evt)
local eid = evt.source_eid
local pos = ScriptLib.GetPosByEntityId(context, eid)
local index = ScriptLib.GetGroupVariableValue(context, "element_used")
index = index + 1
ScriptLib.SetGroupVariableValue(context, "element_used", index)
local cid = extra_elements[index]
local ret = ScriptLib.CreateGadgetByConfigIdByPos(context, cid, {x=pos.x,y=pos.y,z=pos.z}, {x=0.000,y=0.000,z=0.000})
--PrintLog(context, "ret"..ret)
-- if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, cid, 201) then
-- PrintLog(context, "改元素微粒状态失败")
-- end
return 0
end
function action_perform_timer(context, evt)
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_SeelieLightLevel", 0)
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,141 @@
--[[======================================
|| filename: Activity_WorldBoss
|| owner: chao.cui
|| description: 大世界BOSS
|| LogName: TD
|| Protection: [Protection]
=======================================]]
---
-- defs.small_region_id
-- defs.big_region_id
-- LD布设
-- 大小两个Region
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_WorldBoss] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
--{ config_id = 40000001, name = "tri_monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "condition_EVENT_ANY_MONSTER_DIE", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0},
{ config_id = 40000002, name = "tri_enter_region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION", action = "action_EVENT_ENTER_REGION", forbid_guest = false, trigger_count = 0},
{ config_id = 40000003, name = "tri_leave_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "condition_EVENT_LEAVE_REGION", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0},
}
------ conditions & actions ------
-- function condition_EVENT_ANY_MONSTER_DIE(context, evt)
-- if ScriptLib.GetGroupMonsterCountByGroupId(context, defs.group_id) ~= 0 then
-- return false
-- end
-- return true
-- end
-- function action_EVENT_ANY_MONSTER_DIE(context, evt)
-- if 0 ~= ScriptLib.CreateGadget(context, { config_id = defs.chest_config_id }) then
-- PrintLog(context, "生成宝箱失败")
-- return -1
-- end
-- return 0
-- end
function condition_EVENT_ENTER_REGION(context, evt)
if evt.param1 ~= defs.small_region_id then return false end
return true
end
function action_EVENT_ENTER_REGION(context, evt)
PrintLog(context, "进入内圈")
ScriptLib.SetPlayerEyePoint(context, defs.small_region_id, defs.big_region_id)
return 0
end
-- 触发条件
function condition_EVENT_LEAVE_REGION(context, evt)
if evt.param1 ~= defs.big_region_id then return false end
return true
end
-- 触发操作
function action_EVENT_LEAVE_REGION(context, evt)
PrintLog(context, "离开外圈")
if context.uid ~= 0 then
ScriptLib.ClearPlayerEyePoint(context, defs.small_region_id)
end
return 0
end
------ SLC ------
-- charge_type: 0-负电荷 1-正电荷
function SLC_Activity_Boss_Watcher_Charge(context, charge_type)
PrintLog(context, "电荷类型:"..charge_type)
local uidlist = ScriptLib.GetSceneUidList(context)
for i = 1, #uidlist do
-- 迁移3.3的接口,替换原计算逻辑 by siyu.li
local r = defs.watcher_region_id or defs.big_region_id
if ScriptLib.IsInRegion(context, uidlist[i], r) then
if charge_type == 1 then
-- 正电荷
ScriptLib.AddExhibitionAccumulableData(context, uidlist[i], "Activity_GravenBOSS_Positive_Charge", 1)
end
if charge_type == 0 then
-- 负电荷
ScriptLib.AddExhibitionAccumulableData(context, uidlist[i], "Activity_GravenBOSS_Negative_Charge", 1)
end
end
end
return 0
end
------ LF -------
function LF_Avatar_Is_In_Region(context, uid, region_id)
local avatar_id = ScriptLib.GetAvatarEntityIdByUid(context, uid)
local pos1 = ScriptLib.GetPosByEntityId(context, avatar_id)
local region
for _, _region in pairs(regions) do
if _region.config_id == region_id then
region = _region
break
end
end
local X = pos1.x - region.pos.x
local Y = pos1.y - region.pos.y
local Z = pos1.z - region.pos.z
if region.shape == RegionShape.SPHERE then
if math.sqrt(X*X+Y*Y+Z*Z) <= region.radius then
return true
else
return false
end
elseif region.shape == RegionShape.CUBIC then
if math.abs(X) > region.size.x/2 or math.abs(Y) > region.size.y/2 or math.abs(Z) > region.size.z/2 then
return false
else
return true
end
end
end
function LF_Initialize_Level()
for _k, _tri in pairs(extraTriggers) do
table.insert(triggers, _tri)
table.insert(suites[1].triggers, _tri.name)
end
return 0
end
LF_Initialize_Level()

View File

@@ -0,0 +1,226 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
-- V3_0/AranaraCollection
--[[======================================
|| filename: AranaraCollection
|| owner: zijun.ma
|| description: 兰那罗邮箱控制
|| LogName: TD_AranaraCollection
|| Protection: [Protection]
=======================================]]
--[[
Group = 133301087
-- 标准相册页 解锁
拿到空的书
item add 220055;
quest accept 7302515
会更新两页新内容
quest finish 7302515;
quest accept 7303803
第一页会更新两行新内容
quest finish 7303803
goto -233 238.214 3467
-- 修改收集进度
COLLECTION STATE 1 1 1;
COLLECTION STATE 1 2 1;
COLLECTION STATE 1 3 1
--]]
-- 数据结构
--[[
local ACPlay = {
MailBoxCid = 87001, 邮箱cid
OptionCid = 87002, 操作台cid
PageLevel02 = 2, 可领取邮件为2以上时邮箱以202显示
PageLevel03 = 3, 可领取邮件为3以上时邮箱以203显示
WorkOption = 75, 操作台
TargetMailCount01 = 1, 领取多少邮件后显示Reminder01
Reminder01 = 1110013,
TargetMailCount02 = 2, 领取多少邮件后显示Reminder02
Reminder02 = 1110013,
}
--]]
local ACDict = {
[0] = { level=0, suite = 1, boxState = 0 },
[1] = { level=1, suite = 2, boxState = 201 },
[2] = { level=2, suite = 3, boxState = 202 },
[3] = { level=3, suite = 4, boxState = 203 },
}
local AC_Trigger = {
{ keyWord = "CheckMail", event = EventType.EVENT_GROUP_LOAD, source = "", trigger_count = 0},
{ keyWord = "ReceiveMail", event = EventType.EVENT_SELECT_OPTION, source = "", trigger_count = 0},
--{ keyWord = "MailCallBack", event = EventType.EVENT_ARANARA_COLLECTION_COLLECTED, source = "", trigger_count = 0},
}
function LF_Initialize_Level()
local startConfigID = 40020001
for _,v in pairs(AC_Trigger) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(AC_Trigger,{})
local var = { config_id= 40020101, name = "ReceiveMailCount", value = 0, no_refresh = true }
variables[var.name] = var
local var = { config_id= 40020102, name = "ReminderProgress", value = 0, no_refresh = true }
variables[var.name] = var
return 0
end
--[[=====================================
|| action函数
--======================================]]
-- EVENT_GROUP_LOAD
function action_CheckMail(context,evt)
ScriptLib.PrintContextLog(context, "## TD_AranaraCollection: ## == INITIALIZE 1 == ")
-- 拿页片数据(state => 0 不可收集 1 可收集 2 已收集 3 已完成
local curCollectablePageNum = ScriptLib.GetAranaraCollectableCountByTypeAndState(context,1,1)
ScriptLib.PrintContextLog(context, "## TD_AranaraCollection: action_CheckMail curCollectablePageNum" .. curCollectablePageNum)
if -1 == curCollectablePageNum then
ScriptLib.PrintContextLog(context, "## TD_AranaraCollection action_CheckMail")
return -1
end
if curCollectablePageNum >= ACPlay.PageLevel03 then
LF_ChangeLevel(context,3)
return 0
end
if curCollectablePageNum >= ACPlay.PageLevel02 then
LF_ChangeLevel(context,2)
return 0
end
if curCollectablePageNum > 0 then
LF_ChangeLevel(context,1)
return 0
end
LF_ChangeLevel(context,0)
return 0
end
function action_ReceiveMail(context,evt)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, ACPlay.OptionCid, ACPlay.WorkOption)
ScriptLib.RecieveAllAranaraCollectionByType(context,base_info.group_id,1)
ScriptLib.PrintContextLog(context, "## TD_AranaraCollection: action_ReceiveMail Trigger!")
-- 邮箱显示状态清空
ScriptLib.SetGadgetStateByConfigId(context, ACPlay.MailBoxCid, 0)
-- 见://design_data_depot/dev/Excel/Data/PushTipsData.xlsx
ScriptLib.MarkPlayerAction(context, 1144, 1, 1)
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
-- 根据数量等级,切布设式样和邮箱状态
function LF_ChangeLevel(context,level)
if ACDict[level] == nil then
ScriptLib.PrintContextLog(context, "## TD_AranaraCollection 非法levellevel = " .. level)
return 0
end
local levelInfo = ACDict[level]
--周围布设已相同刷了Group也没啥用考虑后续可能还要迭代暂时保留)
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = levelInfo.suite })
ScriptLib.SetGadgetStateByConfigId(context, ACPlay.MailBoxCid, levelInfo.boxState)
local msg = "## TD_AranaraCollection : LF_ChangeLevel"
msg = msg .. "|gotoSuite = " .. levelInfo.suite
msg = msg .. "|setState = " .. levelInfo.boxState
if level>0 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, ACPlay.OptionCid, {ACPlay.WorkOption})
msg = msg .. "|Have Set Option"
end
ScriptLib.PrintContextLog(context, msg)
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据数组的长度修饰num
function Fix(value,array,error)
if value < 1 then
ScriptLib.PrintLog(error .. "value = " .. value)
return 1
end
if value > #array then
ScriptLib.PrintLog(error .. "value = " .. value)
return #array
end
return value
end
LF_Initialize_Level()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,289 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
-- goto 1176 296 -1594
--[[======================================
|| filename: Boss_MaranaSub
|| owner: zijun.ma
|| description: 零级WQBoss战三小岛特殊RQ
|| LogName: TD_BossMaranaSub
|| Protection: [Protection]
=======================================]]
-- 测试用例
--[[
goto -766 -153 3947
group SETVAR 133301038 BossBattleProgress 3
--]]
-- 数据结构
--[[
local BattleCfg = {
BossGroup = 133301038,
VarKey = "State_Island01",
BossCidList = {39011},
CoreCid = 39003,
RegionCid = 39002,
SeedCid = 39004,
}
--]]
local ProgressGroup = {
BossMissionStart = {0},
FirstNearMarana = {1},
TryAttackBoss = {2},
EnterLittleIsland = {3,7,12},
BossSkillChange = {8},
CompleteLittleIsland = {4,9,13},
ReturnMain = {5,10,14},
BossRecover = {6,11,15},
LastBattle = {16},
BossDie = {17},
BossMissionOver = {18},
BossBattleEnd = {19},
}
local MaranaSub_Trigger = {
{ keyWord = "EnterIsland", event = EventType.EVENT_ENTER_REGION, source = "", trigger_count = 0},
{ keyWord = "CoreDie", event = EventType.EVENT_LUA_NOTIFY, source = "DF_CoreDie", trigger_count = 0},
{ keyWord = "PointDie", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", trigger_count = 0},
{ keyWord = "BossDie", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", trigger_count = 0},
--初始化依赖任务回滚处理
--{ keyWord = "IslandInit", event = EventType.EVENT_GROUP_LOAD, source = "", trigger_count = 0},
}
function LF_Initialize_MaranaSub()
local startConfigID = 50030001
for _,v in pairs(MaranaSub_Trigger) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(MaranaSub_Trigger,{1})
local var = { config_id= 50030101, name = "DeathPointNum", value = 0, no_refresh = false } --Boss战的步骤计数器
variables[var.name] = var
return 0
end
--[[=====================================
|| action函数
--======================================]]
-- IslandInit
function action_IslandInit(context,evt)
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
return 0
end
-- EVENT_ENTER_REGION
function action_EnterIsland(context,evt)
if evt.param1 ~= BattleCfg.RegionCid then
return 0
end
if LF_CheckProgressNoMatchGroup(context,ProgressGroup.EnterLittleIsland,"action_EnterIsland") then
return 0
end
local waveNum = LF_GetWaveNum(context,ProgressGroup.EnterLittleIsland,"action_EnterIsland")
if "State_Island0" .. waveNum ~= BattleCfg.VarKey then
ScriptLib.PrintContextLog(context,"TD_BossMaranaSub 提前进入区域不触发")
return 0
end
ScriptLib.SetGroupVariableValueByGroup(context, BattleCfg.VarKey, 1, BattleCfg.BossGroup)
ScriptLib.SetGadgetStateByConfigId(context, BattleCfg.SeedCid, 201)
ScriptLib.PrintContextLog(context,"TD_BossMaranaSub 进入区域,切换大草种子状态")
return 0
end
function action_PointDie(context,evt)
if gadgets[evt.param2].gadget_id ~= 70310195 or 202 ~= evt.param1 then
local msg = "TD_BossMaranaSub PointDie 未进入,检测到物件状态改变。"
msg = msg .. "ConfigID为" .. evt.param2
msg = msg .. "GadgetState为" .. evt.param1
ScriptLib.PrintContextLog(context,msg)
return 0
end
local curDeathPointNum = ScriptLib.GetGroupVariableValue(context, "DeathPointNum")
ScriptLib.SetGroupVariableValue(context,"DeathPointNum",curDeathPointNum + 1)
ScriptLib.PrintContextLog(context,"TD_BossMaranaSub 节点死亡流程DeathPointNum + 1 = " .. curDeathPointNum + 1)
if curDeathPointNum == 0 then
if not LF_CheckProgressNoMatchGroup(context,ProgressGroup.BossSkillChange,"action_PointDieSP") then
-- 第二场Boss战专用
ScriptLib.SetGroupVariableValueByGroup(context, BattleCfg.VarKey, 3, BattleCfg.BossGroup)
end
end
if curDeathPointNum + 1 >= 3 then
-- 核心状态切换为1
ScriptLib.SetGadgetStateByConfigId(context, BattleCfg.CoreCid, 1)
-- 召唤怪物
ScriptLib.AddExtraGroupSuite(context, 0, 2)
-- 处理计数
ScriptLib.SetGroupTempValue(context, "BossDieNum", #BattleCfg.BossCidList, {})
ScriptLib.PrintContextLog(context,"TD_BossMaranaSub 节点死亡流程侦测到全部节点死亡核心状态切换为1")
end
return 0
end
function action_BossDie(context,evt)
if not LF_IsInTable(evt.param1,BattleCfg.BossCidList) then
ScriptLib.PrintContextLog(context,"TD_BossMaranaSub BossDie未进入检测到怪物死亡ConfigID为 " .. evt.param1)
return 0
end
ScriptLib.ChangeGroupTempValue(context, "BossDieNum", -1, {})
local BossDieNum = ScriptLib.GetGroupTempValue(context, "BossDieNum", {})
ScriptLib.PrintContextLog(context,"TD_BossMaranaSub 死域之主战死Cid =" .. evt.param1 .. "||BossDieNum = " .. BossDieNum)
if BossDieNum == 0 then
-- 核心切换到201
ScriptLib.SetGadgetStateByConfigId(context, BattleCfg.CoreCid, 201)
ScriptLib.PrintContextLog(context,"TD_BossMaranaSub 死域之主已全部死亡,核心状态切换为201")
end
return 0
end
function action_CoreDie(context,evt)
if LF_CheckProgressNoMatchGroup(context,ProgressGroup.CompleteLittleIsland,"action_EnterIsland") then
-- 进度不对,不接受核心死亡消息
return 0
end
ScriptLib.SetGadgetStateByConfigId(context, BattleCfg.CoreCid, 202)
ScriptLib.SetGroupVariableValueByGroup(context, BattleCfg.VarKey, 2, BattleCfg.BossGroup)
ScriptLib.PrintContextLog(context,"TD_BossMaranaSub 死域核心已被玩家破坏")
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
function LF_CheckProgressNoMatchGroup(context,groupKey,functionName)
local targetProgressList = groupKey
local bossBattleProgress = ScriptLib.GetGroupVariableValueByGroup(context, "BossBattleProgress", 133301038)
local targetProgress = targetProgressList[#targetProgressList]
for i = #targetProgressList,1,-1 do
if bossBattleProgress <= targetProgressList[i] then
targetProgress = targetProgressList[i]
end
end
if bossBattleProgress == targetProgress then
ScriptLib.PrintContextLog(context, "## TD_BossMaranaSub From:" .. functionName .." || 当前[Progress:".. bossBattleProgress .."]符合目标进度" ..targetProgress )
return false
end
ScriptLib.PrintContextLog(context, "## TD_BossMaranaSub From:" .. functionName .." || 当前[Progress:".. bossBattleProgress .."]不符合目标进度" ..targetProgress .."!!!" )
return true
end
function LF_GetWaveNum(context,groupKey,functionName)
local targetProgressList = groupKey
local bossBattleProgress = ScriptLib.GetGroupVariableValueByGroup(context, "BossBattleProgress", 133301038)
local waveNum = #targetProgressList
for i = #targetProgressList,1,-1 do
if bossBattleProgress <= targetProgressList[i] then
waveNum = i
end
end
ScriptLib.PrintContextLog(context, "## TD_BossMarana From:" .. functionName .." || WaveNum = " .. waveNum )
return waveNum
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据数组的长度修饰num
function Fix(value,array,error)
if value < 1 then
ScriptLib.PrintLog(error .. "value = " .. value)
return 1
end
if value > #array then
ScriptLib.PrintLog(error .. "value = " .. value)
return #array
end
return value
end
-- 判断特定值是否在Table中
function LF_IsInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return true;
end
end
return false;
end
LF_Initialize_MaranaSub()

View File

@@ -0,0 +1,69 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: CameraLook
|| owner: zijun.ma
|| description: 方便LD调用的绝对注目Action
|| LogName: TD_CameraLook
|| Protection: [Protection]
=======================================]]
local CameraLookPlay = {
CameraPointCid = defs.point_camera,
LookEntityCid = defs.gadget_lookEntity,
Duration = defs.look_duration,
}
--[[
local CameraLookSetting = {
blend_type = 0,
blend_duration = 1.5,
is_force_walk = false,
is_allow_input = true,
delay = 0,
}
--]]
--[[=====================================
|| action函数
--======================================]]
function LF_PointLook(context)
-- 触发镜头注目,注目位置为坐标{x=-3024.84, y=268.74, z=4872.4}持续时间为3秒并且为强制注目形式不广播其他玩家
if CameraLookPlay.LookEntityCid == nil or CameraLookPlay.CameraPointCid == nil then
ScriptLib.PrintContextLog(context, "## TD_CameraLook Misc 配置非法")
return -1
end
if gadgets[CameraLookPlay.LookEntityCid] == nil then
ScriptLib.PrintContextLog(context, "## TD_CameraLook LookPosInfo 配置非法")
return 0
end
local LookPosInfo = gadgets[CameraLookPlay.LookEntityCid]
if points[CameraLookPlay.CameraPointCid] == nil then
ScriptLib.PrintContextLog(context, "## TD_CameraLook CameraPointInfo 配置非法")
return 0
end
local CameraPointInfo = points[CameraLookPlay.CameraPointCid]
local lookPos = LookPosInfo.pos
local cameraPos = CameraPointInfo.pos
ScriptLib.BeginCameraSceneLook(context,
{ look_pos = lookPos,
is_allow_input = CameraLookSetting.is_allow_input,
is_force = true,
is_broadcast = false,
is_recover_keep_current = true,
is_set_follow_pos = true,
is_abs_follow_pos = true,
follow_pos = cameraPos,
is_force_walk = CameraLookSetting.is_force_walk,
duration = CameraLookPlay.Duration,
delay = CameraLookSetting.delay,
blend_type = CameraLookSetting.blend_type,
blend_duration = CameraLookSetting.blend_duration,
disable_protect = 1,
})
return 0
end

View File

@@ -0,0 +1,279 @@
--[[======================================
|| filename: ContinuousTrampoline
|| owner: shuyi.chang
|| description: 连续弹跳蘑菇
|| LogName: ## [ContinuousTrampoline]
|| Protection:
=======================================]]
-- local defs =
-- {
-- maxRegion = 34004,
-- maxJumpTimes = 5,
-- mushroomList = {
-- [1] = {34001, 34002,},
-- [2] = {34003},
-- [3] = {34004, 34005, 34006,},
-- [4] = {34007,},
-- [5] = {34008,},
-- [6] = {34019,},
-- [7] = {34010,},
-- },
-- }
local challengeId = 84
local extraTriggers =
{
{ config_id = 5000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_GROUP_LOAD", trigger_count = 0},
{ config_id = 5000002, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_ENTER_REGION", forbid_guest = true, trigger_count = 0},
{ config_id = 5000003, name = "AVATAR_JUMP", event = EventType.EVENT_VARIABLE_CHANGE, source = "jumpTimes", condition = "", action = "action_AVATAR_JUMP", trigger_count = 0, tag = "99"},
{ config_id = 5000004, name = "CHALLENGE_FAIL", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_CHALLENGE_FAIL", trigger_count = 0 },
{ config_id = 5000005, name = "CHALLENGE_SUCCESS", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_CHALLENGE_SUCCESS", trigger_count = 0 },
{ config_id = 5000006, name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_LEAVE_REGION", trigger_count = 0},
{ config_id = 5000007, name = "GROUP_WILL_UNLOAD", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_GROUP_WILL_UNLOAD", trigger_count = 0},
}
local extraVariables =
{
-- 记录玩家连续跳跃次数
{ config_id = 5000101, name = "jumpTimes", value = 0, no_refresh = false },
-- 记录最后一个跳过的蘑菇的index
{ config_id = 5000102, name = "mushroomIdx", value = 1, no_refresh = true },
-- 记录最后一个跳过的蘑菇的index
{ config_id = 5000103, name = "succeed", value = 0, no_refresh = true },
{ config_id = 5000104, name = "onMushroom", value = 0, no_refresh = false },
}
local mushroomRegion = {}
local abilityGroup = "ActivityAbility_ContinuousTrampoline"
--================================================================
-- Local Functions
--================================================================
function LF_Initialize_Group(triggers, suites, variables, gadgets, regions)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
end
-- add triggers to suite
for i = 1, #extraTriggers do
table.insert(suites[1].triggers,extraTriggers[i].name)
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
-- add ability group
-- regions[defs.maxRegion].team_ability_group_list = {abilityGroup}
-- local regionBaseId = 4000000
-- -- 每个蘑菇都加一个region
-- for i = 1, #defs.mushroomList do
-- for j = 1, #defs.mushroomList[i] do
-- local idTemp = regionBaseId + i * 10 + j
-- local posTemp = {x = gadgets[defs.mushroomList[i][j]].pos.x, y = gadgets[defs.mushroomList[i][j]].pos.y + 2.5, z = gadgets[defs.mushroomList[i][j]].pos.z}
-- local regionTemp = { config_id = idTemp,
-- shape = RegionShape.CYLINDER, radius = 1.5, pos = { x = posTemp.x, y = posTemp.y, z = posTemp.z }, height = 3.000 }
-- regions[idTemp] = regionTemp
-- mushroomRegion[i] = idTemp
-- -- add region to suites
-- table.insert(suites[1].regions, idTemp)
-- end
-- end
end
function LF_CreateMushrooms(context, index)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] LF_CreateMushrooms is called, index = "..index)
for i = 1, #defs.mushroomList[index] do
ScriptLib.CreateGadget(context, { config_id = defs.mushroomList[index][i] })
end
end
function LF_KillMushrooms(context, index)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] LF_KillMushrooms is called, index = "..index)
for i = 1, #defs.mushroomList[index] do
ScriptLib.KillEntityByConfigId(context, { group_id = base_info.group_id, config_id = defs.mushroomList[index][i] })
end
end
function LF_RestartChallenge(context)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] LF_RestartChallenge is called")
ScriptLib.StopChallenge(context, challengeId, 0)
ScriptLib.StartChallenge(context, challengeId, challengeId, {3, 99, defs.maxJumpTimes})
end
--================================================================
-- Trigger functions
--================================================================
function action_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] group is loaded")
if ScriptLib.GetGroupVariableValue(context, "succeed") == 0 then
local currentMushroomIdx = ScriptLib.GetGroupVariableValue(context, "mushroomIdx")
LF_CreateMushrooms(context, currentMushroomIdx)
end
return 0
end
function action_GROUP_WILL_UNLOAD(context, evt)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] group will unload")
-- 挑战底层问题group unload时强制挑战失败
ScriptLib.StopChallenge(context, challengeId, 0)
return 0
end
function action_ENTER_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] enter region = "..evt.param1)
if evt.param1 == defs.maxRegion and ScriptLib.GetGroupVariableValue(context, "succeed") == 0 then
-- 开启挑战
ScriptLib.StartChallenge(context, challengeId, challengeId, {3, 99, defs.maxJumpTimes})
-- else
-- for i = 1, #mushroomRegion do
-- if evt.param1 == mushroomRegion[i] then
-- -- 进入了一个蘑菇区域
-- ScriptLib.SetGroupVariableValue(context, "onMushroom", 1)
-- break
-- end
-- end
end
return 0
end
function action_LEAVE_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] leave region = "..evt.param1)
local uid_list = ScriptLib.GetSceneUidList(context)
if evt.param1 == defs.maxRegion then
ScriptLib.StopChallenge(context, challengeId, 0)
-- else
-- for i = 1, #mushroomRegion do
-- if evt.param1 == mushroomRegion[i] then
-- -- 离开了一个蘑菇区域
-- ScriptLib.SetGroupVariableValue(context, "onMushroom", 0)
-- local isJumping = ScriptLib.GetTeamServerGlobalValue(context, uid_list[1], "_ABILITY_Activity_Trampoline_Jump")
-- if isJumping == false then
-- LF_RestartChallenge(context)
-- end
-- break
-- end
-- end
end
return 0
end
function action_CHALLENGE_FAIL(context, evt)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] challenge "..evt.param1.." fails")
ScriptLib.SetGroupVariableValue(context, "jumpTimes", 0)
return 0
end
function action_CHALLENGE_SUCCESS(context, evt)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] challenge "..evt.param1.." succeeds")
ScriptLib.SetGroupVariableValue(context, "succeed", 1)
return 0
end
function action_AVATAR_JUMP(context, evt)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] "..evt.source_name.." changes from "..evt.param2.." to ".. evt.param1)
return 0
end
--================================================================
-- SLC functions
--================================================================
function SLC_Jump_Succeed_Once(context, evt)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] SLC_Jump_Succeed_Once is called")
-- 为了处理断网情况需要给ability层一个callback把gv值设回0ability层只有在对应gv值为0的情况下才允许发slc
ScriptLib.SetTeamEntityGlobalFloatValue(context, {context.owner_uid}, "_ABILITY_Activity_Trampoline_JumpTimes", 0)
-- 跳跃成功一次
ScriptLib.ChangeGroupVariableValue(context, "jumpTimes", 1)
ScriptLib.ChangeGroupVariableValue(context, "mushroomIdx", 1)
local curJumpTimes = ScriptLib.GetGroupVariableValue(context, "jumpTimes")
local currentMushroomIdx = ScriptLib.GetGroupVariableValue(context, "mushroomIdx");
local lastOne = false
if currentMushroomIdx > #defs.mushroomList then
ScriptLib.SetGroupVariableValue(context, "mushroomIdx", 1)
currentMushroomIdx = ScriptLib.GetGroupVariableValue(context, "mushroomIdx");
lastOne = true
end
-- 检查挑战是否成功
if curJumpTimes < defs.maxJumpTimes and currentMushroomIdx > 0 then
LF_CreateMushrooms(context, currentMushroomIdx)
end
if lastOne then
LF_KillMushrooms(context, #defs.mushroomList)
elseif currentMushroomIdx > 1 then
-- 这里主要是保一下要干掉的蘑菇组index一定大于0
LF_KillMushrooms(context, currentMushroomIdx - 1)
end
return 0
end
function SLC_Fall_Onto_Ground(context, evt)
-- 玩家进入落到地上的动画状态超级跳前会短暂进入FallOnGround和FallOnGroundLit在ability层过滤掉了这种情况
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context, "## [ContinuousTrampoline] SLC_Fall_Onto_Ground is called")
-- 判断是不是落在了蘑菇上的region落在上面了不算失败
-- local onMushroom = ScriptLib.GetGroupVariableValue(context, "onMushroom")
-- if onMushroom == 1 then
-- return 0
-- end
-- 检查跳了几次
local jumpTimes = ScriptLib.GetGroupVariableValue(context, "jumpTimes")
if jumpTimes < defs.maxJumpTimes and jumpTimes > 0 then
LF_RestartChallenge(context)
end
return 0
end
--================================================================
-- Initialize
--================================================================
LF_Initialize_Group(triggers, suites, variables, gadgets, regions)

View File

@@ -0,0 +1,162 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
-- goto 1296.946 271.098 -1590.922
--[[======================================
|| filename: DeathFieldAbilityGroup
|| owner: zijun.ma
|| description: 测试死域中的AbilityGroup效果
|| LogName: TD_DeathFieldAbilityGroup
|| Protection: [Protection]
=======================================]]
-- 该功能仅用于模拟死域的基础感受
--[[
local DFAGConfig ={
BasicCounter = 3,
ExtraCounter = 0,
Region = 33007,
TimeAxis = {10},
}
--]]
local DeathFieldAbilityGroup_Trigger = {
{ config_id = 41000001, name = "DFAG_EnterRegion", event = EventType.EVENT_ENTER_REGION, source = "",
condition = "", action = "action_DFAG_EnterRegion", trigger_count = 0},
{ config_id = 41000002, name = "DFAG_LeaveRegion", event = EventType.EVENT_LEAVE_REGION, source = "",
condition = "", action = "action_DFAG_LeaveRegion", trigger_count = 0},
{ config_id = 41000003, name = "DFAG_TimeAxis", event= EventType.EVENT_TIME_AXIS_PASS, source = "StartAddCounter",
condition = "", action = "action_DFAG_TimeAxis", trigger_count = 0 },
}
function LF_Initialize_Level()
for k,v in pairs(DeathFieldAbilityGroup_Trigger) do
table.insert(triggers, v)
end
LF_InsertTriggers(DeathFieldAbilityGroup_Trigger,{})
return 0
end
-- 玩家进入Region后用来上SGV的
function action_DFAG_EnterRegion(context,evt)
if evt.param1 ~= DFAGConfig.Region then
return 0
end
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. evt.uid .. "进入死域内")
ScriptLib.SetTeamServerGlobalValue(context, evt.uid, "SGV_DeathZone_BasicCounter", DFAGConfig.BasicCounter)
ScriptLib.SetTeamServerGlobalValue(context, evt.uid, "SGV_DeathZone_ExtraCounter", DFAGConfig.ExtraCounter)
-- 开启时间轴
-- TODO 这个地方联机有Bug
ScriptLib.InitTimeAxis(context, "StartAddCounter",DFAGConfig.TimeAxis, true)
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. evt.uid .. "设置其TeamSGV并开启了时间轴增加SGV")
return 0
end
-- 玩家离开Region后用来清除GV
function action_DFAG_LeaveRegion(context,evt)
if evt.param1 ~= DFAGConfig.Region then
return 0
end
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. evt.uid .. "离开死域")
ScriptLib.SetTeamServerGlobalValue(context, evt.uid, "SGV_DeathZone_BasicCounter", 0)
ScriptLib.SetTeamServerGlobalValue(context, evt.uid, "SGV_DeathZone_ExtraCounter", 0)
-- 关闭时间轴
ScriptLib.EndTimeAxis(context, "StartAddCounter")
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. evt.uid .. "已清除SGV并关闭时间轴")
return 0
end
-- 每10秒增加1格死域值
function action_DFAG_TimeAxis(context,evt)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. uid_list[1] .. "死域时间到!")
local extraCounter = ScriptLib.GetTeamServerGlobalValue(context, uid_list[1], "SGV_DeathZone_ExtraCounter")
if DFAGConfig.BasicCounter + extraCounter <= 9 then
ScriptLib.AddTeamServerGlobalValue(context, uid_list[1], "SGV_DeathZone_ExtraCounter", 1)
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. uid_list[1] .. "死域附加值+1")
else
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. uid_list[1] .. "死域附加值已满")
end
return 0
end
function SLC_ExtraAttack(context,param1)
-- 临时增加extraLevel
local uid_list = ScriptLib.GetSceneUidList(context)
local extraCounter = ScriptLib.GetTeamServerGlobalValue(context, uid_list[1], "SGV_DeathZone_ExtraCounter")
if DFAGConfig.BasicCounter + extraCounter <= 9 then
ScriptLib.AddTeamServerGlobalValue(context, uid_list[1], "SGV_DeathZone_ExtraCounter", 1)
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. uid_list[1] .. "受到死域重击,死域附加值+1")
else
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. uid_list[1] .. "受到死域重击,死域附加值已满")
end
return 0
end
function SLC_LifePointBuff(context)
-- 临时增加extraLevel
local uid_list = ScriptLib.GetSceneUidList(context)
local extraCounter = ScriptLib.GetTeamServerGlobalValue(context, uid_list[1], "SGV_DeathZone_ExtraCounter")
if extraCounter > 0 then
ScriptLib.AddTeamServerGlobalValue(context, uid_list[1], "SGV_DeathZone_ExtraCounter", -1)
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. uid_list[1] .. "处于生命源质附近,死域附加值-1")
else
ScriptLib.PrintContextLog(context,"TD_DFAG 玩家" .. uid_list[1] .. "处于生命源质附近,死域附加值已为零")
end
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
LF_Initialize_Level()

View File

@@ -0,0 +1,332 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
-- goto 1296.946 271.098 -1590.922
--[[======================================
|| filename: DeathFieldPlay
|| owner: zijun.ma
|| description: 死域玩法
|| LogName: TD_DeathFieldPlay
|| Protection: [Protection]
=======================================]]
--[[
GROUP GETVAR 133301250 PlayPhase
--]]
--[[
local RequireSuite = {} --死域玩法的初始suit。若不填或不注入默认走init_config.suite
local DeathField ={
CoreID = 33001,
BossID = 33006,
BossSuite = 2,
EndSuite = 3, -- 不为空时,
PointList = {33002,33003,33004},
}
--]]
-- 流程规划(一次性玩法)
-- PlayPhase = 0 => 死域核心、死域之主、死域节点、草种子、死域节点与死域核心的链接
-- 中期流程 => 草种子交互后破坏死域节点,同时清理相关指引
-- PlayPhase = 1 => 所有节点破坏后,死域之主创生
-- PlayPhase = 2 => 死域之主死亡后,玩家可与死域核心交互
-- PlayPhase = 3 => 死域核心破坏后,死域被切换
-- goto 1296 271 -1590
local DeathFieldGadget ={
--Core = 70310193,
Point = 70310195,
}
local DeathFieldPlay_Trigger = {
{ config_id = 40000001, name = "tri_DeathField_PointDie", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "",
condition = "", action = "action_DeathField_PointDie", trigger_count = 0},
{ config_id = 40000002, name = "tri_DeathField_BossDie", event = EventType.EVENT_ANY_MONSTER_DIE, source = "",
condition = "", action = "action_DeathField_BossDie", trigger_count = 0},
{ config_id = 40000003, name = "tri_DeathField_CoreDie", event = EventType.EVENT_LUA_NOTIFY, source = "DF_CoreDie",
condition = "", action = "action_DeathField_CoreDie", trigger_count = 0},
{ config_id = 40000004, name = "tri_DeathField_GroupLoad", event = EventType.EVENT_GROUP_LOAD, source = "",
condition = "", action = "action_DeathField_GroupLoad", trigger_count = 0},
}
function LF_Initialize_DeathFieldPlay()
for k,v in pairs(DeathFieldPlay_Trigger) do
table.insert(triggers, v)
end
LF_InsertTriggers(DeathFieldPlay_Trigger,RequireSuite)
LF_BossDataCheck()
LF_PointDataCheck()
local var = { config_id= 40000101, name = "DeathPointNum", value = 0, no_refresh = false } --死亡节点计数
variables[var.name] = var
if DeathField.NoProtect == true then
-- 不做保底处理Group刷新时会刷到初始状态
local var = { config_id= 40000102, name = "PlayPhase", value = 0, no_refresh = false } -- 玩法阶段
variables[var.name] = var
else
local var = { config_id= 40000102, name = "PlayPhase", value = 0, no_refresh = true } -- 玩法阶段
variables[var.name] = var
end
return 0
end
-- Boss SGV同步
function LF_BossDataCheck()
-- 死域之主的独立注入
if nil == DeathField.BossID then
return 0
end
if nil == monsters[DeathField.BossID] then
return 0
end
local boss = monsters[DeathField.BossID]
if nil == boss.logic_state then
boss.logic_state = {"SGV_DeathZoneState"}
elseif not LF_IsInTable("SGV_DeathZoneState",boss.logic_state) then
table.insert(boss.logic_state,"SGV_DeathZoneState")
end
return 0
end
function LF_PointDataCheck()
-- 统一使所有死域节点的状态修改为可存档
if DeathField.PointList == nil then
return 0
end
for _,v in ipairs(DeathField.PointList) do
local gadgetData = gadgets[v]
if gadgetData ~= nil then
if nil == gadgetData.persistent then
-- 如果无logic_state则直接写入
gadgetData.persistent = true
end
end
end
return 0
end
-- 所有节点破坏时Core切1
function action_DeathField_PointDie(context,evt)
if gadgets[evt.param2].gadget_id ~= DeathFieldGadget.Point or 202 ~= evt.param1 then
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay PointDie 未进入检测到物件状态改变ConfigID为 " .. evt.param2 .. "GadgetState为" .. evt.param1)
return 0
end
-- 死域节点击杀数+1
local curDeathPointNum = ScriptLib.GetGroupVariableValue(context, "DeathPointNum")
ScriptLib.SetGroupVariableValue(context,"DeathPointNum",curDeathPointNum + 1)
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay 节点死亡流程DeathPointNum + 1 = " .. curDeathPointNum + 1)
-- 若3个节点死亡死域切为1
if curDeathPointNum + 1 >= #DeathField.PointList then
LF_DeathField_Phase01(context)
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay 节点死亡流程侦测到全部节点死亡核心状态切换为201")
end
return 0
end
-- 死域之主死亡时Core切201
function action_DeathField_BossDie(context,evt)
local playPhase = ScriptLib.GetGroupVariableValue(context, "PlayPhase")
if playPhase ~= 1 then
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay BossDie未进入当前阶段为 " .. playPhase)
return 0
end
local tempList = ScriptLib.GetGroupAliveMonsterList(context, base_info.group_id)
-- 如果当前Group没有存活怪物就会转阶段
if next(tempList)==nil then
-- 切阶段2
LF_DeathField_Phase02(context)
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay 死域之主已死亡,核心状态切换为201")
end
return 0
end
-- 死域核心死亡时Core切202进入死域转换流程
function action_DeathField_CoreDie(context,evt)
local playPhase = ScriptLib.GetGroupVariableValue(context, "PlayPhase")
if playPhase ~= 2 then
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay CoreDie未进入当前阶段为 " .. playPhase)
return 0
end
LF_DeathField_Phase03(context)
-- 通知指定ConfigID的死域切换
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay 死域核心已被玩家破坏")
return 0
end
function action_DeathField_GroupLoad(context,evt)
if DeathField.NoProtect == true then
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay GroupLoad时 仅DynamicGroup用不做保底处理")
return 0
end
local playPhase = ScriptLib.GetGroupVariableValue(context, "PlayPhase")
local curDeathZoneID =
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay GroupLoad时当前阶段为" .. playPhase)
-- playPhase = 0 时刷新Group为状态1
if playPhase == 0 then
-- 刷初始Suite
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 0})
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay 将Group刷新到初始Group")
end
-- playPhase = 1 时,重新招怪
if playPhase == 1 then
LF_DeathField_Phase01(context)
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay Boss未死亡重刷出来")
end
if playPhase == 2 then
LF_DeathField_Phase02(context)
ScriptLib.PrintContextLog(context,"TD_DeathFieldPlay 死亡核心待解除的状态")
end
if playPhase == 3 then
-- 检查死域是否已关闭
if ScriptLib.GetDeathZoneStatus(context,0) ~= 0 then
ScriptLib.ChangeDeathZone(context,0,{is_open = false})
end
if DeathField.EndSuite ~= nil and DeathField.EndSuite ~= ScriptLib.GetGroupSuite(context, 0) then
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = DeathField.EndSuite})
end
end
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
function LF_DeathField_Phase01(context)
-- 核心状态切换为1
ScriptLib.SetGadgetStateByConfigId(context, DeathField.CoreID, 1)
-- 召唤怪物
ScriptLib.AddExtraGroupSuite(context, 0, DeathField.BossSuite)
-- 阶段流转
ScriptLib.SetGroupVariableValue(context,"PlayPhase",1)
return 0
end
function LF_DeathField_Phase02(context)
-- 核心状态切换为201
ScriptLib.SetGadgetStateByConfigId(context, DeathField.CoreID, 201)
-- 阶段流转
ScriptLib.SetGroupVariableValue(context,"PlayPhase",2)
return 0
end
function LF_DeathField_Phase03(context)
-- 核心状态切换为202
ScriptLib.SetGadgetStateByConfigId(context, DeathField.CoreID, 202)
-- 指定死域关闭
ScriptLib.ChangeDeathZone(context,0,{is_open = false})
-- 阶段流转
ScriptLib.SetGroupVariableValue(context,"PlayPhase",3)
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
function LF_IsInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return true
end
end
return false
end
-- 根据数组的长度修饰num
function Fix(value,array,error)
local arrayType= type(array)
if arrayType ~= "table" then
ScriptLib.PrintLog(error .. "array 非法")
return 1
end
local valueType= type(value)
if valueType ~= "number" then
ScriptLib.PrintLog(error .. "value 非法")
return 1
end
if value < 1 then
ScriptLib.PrintLog(error .. "value = " .. value)
return 1
end
if value > #array then
ScriptLib.PrintLog(error .. "value = " .. value)
return #array
end
return value
end
LF_Initialize_DeathFieldPlay()

View File

@@ -0,0 +1,216 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: DeathFieldStandard
|| owner: zijun.ma
|| description: 死域Group标准Require所有死域Group中会实装的Require
|| LogName: TD_DeathFieldStandard
|| Protection: [Protection]
=======================================]]
local deathMonsterDict = {
[26090101] = {monsterid = 26090101,name = "蕈兽-小-飞-水"},
[26090201] = {monsterid = 26090201,name = "蕈兽-小-飞-草"},
[26090301] = {monsterid = 26090301,name = "蕈兽-小-飞-风"},
[26090401] = {monsterid = 26090401,name = "蕈兽-小-转-雷"},
[26090501] = {monsterid = 26090501,name = "蕈兽-小-转-冰"},
[26090601] = {monsterid = 26090601,name = "蕈兽-小-转-火"},
[26090701] = {monsterid = 26090701,name = "蕈兽-小-伸-火"},
[26090801] = {monsterid = 26090801,name = "蕈兽-小-伸-风"},
[26090901] = {monsterid = 26090901,name = "蕈兽-小-伸-岩"},
[26091001] = {monsterid = 26091001,name = "蕈兽-小-伸-雷"},
[26120301] = {monsterid = 26120301,name = "蕈兽-精英-走-水"},
[26120401] = {monsterid = 26120401,name = "蕈兽-精英-走-岩"},
[26120101] = {monsterid = 26120101,name = "蕈兽-精英-飞-草"},
[26120201] = {monsterid = 26120201,name = "蕈兽-精英-飞-冰"},
}
local deathGadgetDict = {
--三态物件
[70330197] = {gadgetid = 70330197,name = "弹跳蘑菇"},
[70330199] = {gadgetid = 70330199,name = "可抬起石块"},
[70330200] = {gadgetid = 70330200,name = "三态显形植物"},
[70330216] = {gadgetid = 70330216,name = "毒气蘑菇"},
[70330221] = {gadgetid = 70330221,name = "生命之菇"},
[70330230] = {gadgetid = 70330230,name = "草神透镜"},
[70220104] = {gadgetid = 70220104,name = "梦境灵花"},
--死域物件
[70310192] = {gadgetid = 70310192,name = "死域飞弹"},
[70310196] = {gadgetid = 70310196,name = "死域指示特效01"},
[70290513] = {gadgetid = 70290513,name = "死域指示特效02"},
[70290491] = {gadgetid = 70290491,name = "死域核心光源"},
[70290492] = {gadgetid = 70290492,name = "死域节点光源"},
}
local deathGatherDict = {
[2045] = {point_type = 2045,name = "生命之菇"},
}
local DeathFieldStandard_Trigger = {
{ config_id = 90700001, name = "DeathFieldStandard_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "",
condition = "", action = "action_CheckDeathEntity", trigger_count = 0},
{ config_id = 90700002, name = "DeathFieldStandard_DEATH_ZONE_STATUS_CHANGE", event = EventType.EVENT_DEATH_ZONE_STATUS_CHANGE, source = "",
condition = "", action = "action_DeathZoneChange", trigger_count = 0},
}
function LF_Initialize_DeathFieldStandard()
for k,v in pairs(DeathFieldStandard_Trigger) do
table.insert(triggers, v)
end
LF_InsertTriggers(DeathFieldStandard_Trigger,{})
local var = { config_id= 90700101, name = "SGV_DeathZoneState", value = 0, no_refresh = true, variable_type = 1 } --死域状态
variables[var.name] = var
LF_InitialDeathMonster()
LF_InitialDeathGadget()
LF_InitialDeathGather()
return 0
end
--[[=====================================
|| 初始化函数
--======================================]]
function LF_InitialDeathMonster()
for _,v in pairs(monsters) do
local monsterID = v.monster_id
if deathMonsterDict[monsterID] ~= nil then
if nil == v.logic_state then
-- 如果无logic_state则直接写入
v.logic_state = {"SGV_DeathZoneState"}
elseif not LF_IsInTable("SGV_DeathZoneState",v.logic_state) then
-- 如果有其它LogicState,则插入数据
table.insert(v.logic_state,"SGV_DeathZoneState")
end
end
end
end
function LF_InitialDeathGadget()
for _,v in pairs(gadgets) do
local gadgetsID = v.gadget_id
if deathGadgetDict[gadgetsID] ~= nil then
if nil == v.logic_state then
-- 如果无logic_state则直接写入
v.logic_state = {"SGV_DeathZoneState"}
elseif not LF_IsInTable("SGV_DeathZoneState",v.logic_state) then
-- 如果有其它LogicState,则插入数据
table.insert(v.logic_state,"SGV_DeathZoneState")
end
end
end
end
function LF_InitialDeathGather()
for _,v in pairs(gadgets) do
local gadgetsID = v.gadget_id
local pointType = v.point_type
if gadgetsID == 70500000 and pointType ~= nil then
if deathGatherDict[pointType] ~= nil then
if nil == v.logic_state then
-- 如果无logic_state则直接写入
v.logic_state = {"SGV_DeathZoneState"}
elseif not LF_IsInTable("SGV_DeathZoneState",v.logic_state) then
-- 如果有其它LogicState,则插入数据
table.insert(v.logic_state,"SGV_DeathZoneState")
end
end
end
end
end
--[[=====================================
|| 流程函数
--======================================]]
function action_CheckDeathEntity(context,evt)
-- 查询死域值并根据死域值设置LogicState
local curDeathStatus = ScriptLib.GetDeathZoneStatus(context,0)
ScriptLib.PrintContextLog(context, "## TD_DeathFieldStandard GroupLoad: 当前Group"..base_info.group_id.."死域状态为"..curDeathStatus)
if -1 == curDeathStatus then
ScriptLib.PrintContextLog(context, "## TD_DeathFieldStandard GroupLoad: 当前Group"..base_info.group_id.."没有对应死域")
return -1
end
ScriptLib.SetGroupLogicStateValue(context,"SGV_DeathZoneState",curDeathStatus)
ScriptLib.PrintContextLog(context, "## TD_DeathFieldStandard GroupLoad: 以根据curDeathStatus设置当前死域LogicState")
return 0
end
function action_DeathZoneChange(context,evt)
-- 查询死域值并根据死域值设置LogicState
local curDeathStatus = ScriptLib.GetDeathZoneStatus(context,0)
ScriptLib.SetGroupLogicStateValue(context,"SGV_DeathZoneState",curDeathStatus)
ScriptLib.PrintContextLog(context, "## TD_DeathFieldStandard DeathZoneChange 死域LogicState切换为" .. curDeathStatus)
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
function LF_IsInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return true
end
end
return false
end
LF_Initialize_DeathFieldStandard()

View File

@@ -0,0 +1,99 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: DeathFieldVolume
|| owner: zijun.ma
|| description: 巨人之杯草Volume专用
|| LogName: TD_DeathFieldVolume
|| Protection: [Protection]
=======================================]]
local DeathFieldVolume_Trigger = {
{ config_id = 90800001, name = "CheckVolumeLoad_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "",
condition = "", action = "action_CheckVolumeLoad", trigger_count = 0},
{ config_id = 90800002, name = "VolumeSuiteChange_DEATH_ZONE_STATUS_CHANGE", event = EventType.EVENT_DEATH_ZONE_STATUS_CHANGE, source = "",
condition = "", action = "action_VolumeSuiteChange", trigger_count = 0},
}
function LF_Initialize_DeathFieldVolume()
for k,v in pairs(DeathFieldVolume_Trigger) do
table.insert(triggers, v)
end
LF_InsertTriggers(DeathFieldVolume_Trigger,{1})
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
function action_CheckVolumeLoad(context,evt)
-- 查询死域值并根据死域值设置LogicState
local curDeathStatus = ScriptLib.GetDeathZoneStatus(context,0)
ScriptLib.PrintContextLog(context, "## TD_DeathFieldVolume GroupLoad: 当前Group"..base_info.group_id.."死域状态为"..curDeathStatus)
if 0 == curDeathStatus then
ScriptLib.PrintContextLog(context, "## TD_DeathFieldVolume GroupLoad: 当前Group"..base_info.group_id.."已解除但是Suite没有修改切换Suite到2")
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 2 })
return 0
end
return 0
end
function action_VolumeSuiteChange(context,evt)
-- 查询死域值并根据死域值设置LogicState
local curDeathStatus = ScriptLib.GetDeathZoneStatus(context,0)
ScriptLib.PrintContextLog(context, "## TD_DeathFieldStandard DeathZoneChange 死域LogicState切换为" .. curDeathStatus)
if 0 == curDeathStatus then
ScriptLib.PrintContextLog(context, "## TD_DeathFieldVolume GroupLoad: 当前Group"..base_info.group_id.."已解除切换Suite到2")
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 2 })
return 0
end
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
LF_Initialize_DeathFieldVolume()

View File

@@ -0,0 +1,577 @@
--[[======================================
|| filename: DeathZoneObservation
|| owner: shuyi.chang
|| description: 死域观测站
|| LogName: ## [DeathZoneObservation]
|| Protection:
=======================================]]
--[[
local defs_miscs =
{
-- 死域观测站透镜的config id
lensConfigId = 103001,
-- 这个透镜对应的隐藏父任务的回退参数
resetParam = "rewindSmoke"
-- 兰纳罗的config id
lnlConfigId = 103004,
-- 兰纳罗隐藏任务的回退参数
hiddenlnlParam = "hiddenlnl",
-- 一个smoke拥有一项
smokeTable =
{
-- 每项格式如下,通常应该只有两项,即一个透镜对应两个黑烟
--[smoke_id] = {smoke = smoke_config_id, maxRegion = region_id, group = group_id, observeQuest = quest_id, finishQuest = quest_id, questParam = "任务前进变量"}
[103002] = {smoke = 103002, group = 133304105, observeQuest = 7305103, finishQuest = 7305104, questParam = "smokeObserved1"},
[103003] = {smoke = 103003, group = 133304106, observeQuest = 7305105, finishQuest = 7305106, questParam = "smokeObserved2"},
}
}
--]]
local extraTriggers =
{
{ config_id = 50000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 50000002, name = "DEATH_ZONE_OBSERVE", event = EventType.EVENT_DEATH_ZONE_OBSERVE, source = "", condition = "", action = "action_EVENT_DEATH_ZONE_OBSERVE", trigger_count = 0 },
{ config_id = 50000004, name = "SMOKE_QUEST_FINISH", event = EventType.EVENT_QUEST_FINISH, source = "", condition = "", action = "action_SMOKE_QUEST_FINISH", trigger_count = 0 },
{ config_id = 50000005, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", trigger_count = 0 },
-- { config_id = 50000006, name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", trigger_count = 0 },
-- { config_id = 50000007, name = "GROUP_WILL_UNLOAD", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_EVENT_GROUP_WILL_UNLOAD", trigger_count = 0 },
{ config_id = 50000008, name = "GADGET_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_EVENT_GADGET_STATE_CHANGE", trigger_count = 0 },
}
local extraVariables =
{
-- 已完成几个黑烟玩法group
{ config_id = 50000101, name = "smokeFinishedNum", value = 0, no_refresh = true },
-- 已观测到几个兰纳罗
{ config_id = 50000102, name = "aranaraObservedNum", value = 0, no_refresh = true },
-- 目前有几个黑烟处于状态1已被观测到
{ config_id = 50000103, name = "smokeObservedNum", value = 0, no_refresh = true },
}
local smokeGadgetId = 70310219
local lnlGadgetId = 70310440
local smokeCount
local lnlDisappearRmd = 33040007
--================================================================
-- Local Functions
--================================================================
function LF_Initialize_Group(triggers, suites, variables, gadgets, regions)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
end
-- add triggers to suite
for i = 1, #extraTriggers do
-- 都放到初始suite 1中
table.insert(suites[1].triggers,extraTriggers[i].name)
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
local temp = 0
for k, v in pairs(defs_miscs.smokeTable) do
temp = temp + 1
-- 每个smoke给一个group var记录状态0未观测1已观测2已完成
local smoke = { config_id = 40000000 + temp, name = "smoke_"..tostring(v.smoke), value = 0, no_refresh = true }
table.insert(variables, smoke)
gadgets[k].mark_flag = 1
end
smokeCount = LF_GetTableLength(defs_miscs.smokeTable)
-- set lens mark_flag
gadgets[defs_miscs.lensConfigId].mark_flag = 1
end
function LF_GetTableLength(t)
local count = 0
for _ in pairs(t) do count = count + 1 end
return count
end
function LF_SetGlobalValueByGroupVar(context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_SetGlobalValue is called")
-- SGV不存档所以每次load的时候要手动设回正常值断线重连同理
local curSmokeCount = ScriptLib.GetGroupVariableValue(context, "smokeObservedNum")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs_miscs.lensConfigId, "SGV_Cur_Smoke_Count", curSmokeCount)
local smokeLeftCount = smokeCount - ScriptLib.GetGroupVariableValue(context, "smokeFinishedNum")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs_miscs.lensConfigId, "SGV_Smoke_Count", smokeLeftCount)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] smokeFinishedNum = "..ScriptLib.GetGroupVariableValue(context, "smokeFinishedNum")
..", smokeCount = "..smokeCount)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] SGV_Smoke_Count is set to "..smokeLeftCount..", SGV_Cur_Smoke_Count is set to "..curSmokeCount)
-- SGV记录观测到了多少兰那罗,设计上应该只有一个
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs_miscs.lensConfigId, "SGV_Cur_Aranara_Count", 0)
end
-- 设置指定黑烟的状态,并更新目前观测到的黑烟数量
-- function LF_SetSmokeStatus(context, smokeId, status)
-- ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_SetSmokeByStatus is called, smokeId = "..smokeId..", status is set to "..status)
-- local variableName = "smoke_"..smokeId
-- -- 更改前的黑烟状态
-- local statusBefore = ScriptLib.GetGroupVariableValue(context, variableName)
-- ScriptLib.SetGroupVariableValue(context, variableName, status)
-- local variableValue = ScriptLib.GetGroupVariableValue(context, variableName)
-- local gadgetState = 0
-- if status == 0 then
-- -- 还没被观测到在0
-- gadgetState = 0
-- elseif status == 2 then
-- -- 未观测死域已清除在202
-- gadgetState = 202
-- elseif status == 1 then
-- -- 已被观测到,不清楚玩家在相对黑烟的什么位置
-- gadgetState = 201
-- -- 黑烟对应的观察任务流转
-- -- todo如果任务没收到消息这里要加保底
-- LF_LoadSmokeGroup(context, smokeId)
-- -- todo远近视距黑烟特效切换放在ability里判断
-- end
-- -- 如果状态改变需要更新sgv和相关group var
-- if status ~= statusBefore then
-- LF_UpdateObservedSmokeCount(context)
-- LF_SetGlobalValueByGroupVar(context)
-- end
-- -- 更新此smoke的gadget state
-- ScriptLib.SetGadgetStateByConfigId(context, smokeId, gadgetState)
-- ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] smoke id = ".. smokeId..", gadget state is set to "..gadgetState..
-- ", group variable "..variableName.." is set to "..variableValue)
-- end
function LF_SetSmokeGroupVar(context, smokeId, var)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_SetSmokeGroupVar is called")
local variableName = "smoke_"..smokeId
-- 更改前的黑烟状态
local statusBefore = ScriptLib.GetGroupVariableValue(context, variableName)
-- 设置group var的唯一时刻
ScriptLib.SetGroupVariableValue(context, variableName, var)
local variableValue = ScriptLib.GetGroupVariableValue(context, variableName)
-- 如果设置了group var肯定需要紧接着修改黑烟gadget state
LF_SetSmokeStatus_New(context, smokeId, variableValue)
-- 如果状态改变需要更新sgv和相关group var
if var ~= statusBefore then
LF_UpdateObservedSmokeCount(context)
LF_SetGlobalValueByGroupVar(context)
end
end
function LF_UpdateObservedSmokeCount(context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_UpdateObservedSmokeCount is called")
-- 更新目前观测到了的黑烟数量
local temp1 = 0
local temp2 = 0
for k, v in pairs(defs_miscs.smokeTable)do
if 1 == ScriptLib.GetGroupVariableValue(context, "smoke_"..k) then
temp1 = temp1 + 1
elseif 2 == ScriptLib.GetGroupVariableValue(context, "smoke_"..k) then
temp2 = temp2 + 1
end
end
ScriptLib.SetGroupVariableValue(context, "smokeObservedNum", temp1)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] group variable smokeObservedNum is set to "..temp1)
ScriptLib.SetGroupVariableValue(context, "smokeFinishedNum", temp2)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] group variable smokeFinishedNum is set to "..temp2)
end
function LF_LoadSmokeGroup(context, smokeId)
-- 通过任务参数流转任务让任务动态加载死域group
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_LoadSmokeGroup is called")
local questParam = defs_miscs.smokeTable[smokeId].questParam
ScriptLib.AddQuestProgress(context, questParam)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] gadget id = "..smokeId.." adds progress to quest param = "..questParam)
end
function LF_SetCurGroupSmokes(context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_ResetGroup is called")
-- 查询自己是否是当前组
local curGroupId = ScriptLib.GetGroupVariableValueByGroup(context, "curGroupId", 133304143)
if curGroupId == base_info.group_id then
-- 自己就是当前组同组的黑烟需要根据group var设置一下
LF_SetSmokeByGroupVar(context)
else
-- 不是当前组,黑烟都卸载
LF_KillAllSmokesInGroup(context)
end
-- 不管是不是当前组都要按黑烟的group var设置sgv和兰纳罗
LF_SetGlobalValueByGroupVar(context)
LF_ResetLNLByGroupVar(context)
end
function LF_ResetLNLByGroupVar(context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_ResetLNLByGroupVar is called")
-- 根据group变量设置兰纳罗
local aranaraObservedNum = ScriptLib.GetGroupVariableValue(context, "aranaraObservedNum")
local lnlStatus = 0
if aranaraObservedNum == 1 then
-- lnl只有一个
lnlStatus = 2
else
lnlStatus = 0
end
LF_SetLNLStatus(context, defs_miscs.lnlConfigId, lnlStatus)
end
-- function LF_SetAllSmokesByGroupVar(context)
-- -- 黑烟和对应的动态group
-- for k, v in pairs(defs_miscs.smokeTable) do
-- --检查每个黑烟
-- -- group var存档通过group var重置smoke gadget state和任务任务重置动态group
-- local smokeId = v.smoke
-- local status = ScriptLib.GetGroupVariableValue(context, "smoke_"..smokeId)
-- LF_SetSmokeStatus(context, smokeId, status)
-- end
-- end
function LF_KillAllSmokesInGroup(context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_KillAllSmokesInGroup is called")
-- kill all smokes
for k, v in pairs(defs_miscs.smokeTable) do
ScriptLib.KillEntityByConfigId(context, { config_id = k })
end
-- -- 把这个透镜group里status = 1的smoke重置回0任务一起回滚
-- for k, v in pairs(defs_miscs.smokeTable) do
-- local smokeId = k
-- local status = ScriptLib.GetGroupVariableValue(context, "smoke_"..smokeId)
-- -- 如果smokeStatus = 1已被观测到则重置回0
-- if status == 1 then
-- LF_SetSmokeStatus(context, smokeId, 0)
-- end
-- -- 如果smokeStatus = 2已被清除或者0没观测则不重置group var
-- -- 任务尝试回滚,已清除的黑烟任务已经成功,不会参与回滚
-- ScriptLib.AddQuestProgress(context, defs_miscs.resetParam)
-- end
end
function LF_SetLNLStatus(context, lnlId, status)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_SetLNLStatus is called")
local gadgetState = 0
if status == 0 then
-- 未观测
gadgetState = 0
elseif status == 1 then
-- 观测中
gadgetState = 201
elseif status == 2 then
-- 已观测
gadgetState = 202
-- set sgv
ScriptLib.SetGroupVariableValue(context, "aranaraObservedNum", 1)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs_miscs.lensConfigId, "SGV_Cur_Aranara_Count", 1)
-- 通知任务流转
ScriptLib.AddQuestProgress(context, defs_miscs.hiddenlnlParam)
end
-- set gadget state
ScriptLib.SetGadgetStateByConfigId(context, lnlId, gadgetState)
end
function LF_ResetObservedSmoke_FromOther(context, prev_context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_ResetObservedSmoke_FromOther is called")
LF_KillAllSmokesInGroup(context)
return 0
end
function LF_SetSmokeByGroupVar(context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_SetCurGroupActive is called")
-- 接近了一个透镜,需要创建同组黑烟并设置到对应状态
for k, v in pairs(defs_miscs.smokeTable) do
local groupVar = ScriptLib.GetGroupVariableValue(context, "smoke_"..k)
if groupVar == 0 then
LF_SetSmokeStatus_New(context, k, 0)
elseif groupVar == 1 then
LF_SetSmokeStatus_New(context, k, 1)
elseif groupVar == 2 then
LF_SetSmokeStatus_New(context, k, 2)
end
end
end
function LF_SetCurSmokeActive(context, smokeId)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_SetCurSmokeActive is called")
local groupVar = ScriptLib.GetGroupVariableValue(context, "smoke_"..smokeId)
if groupVar == 1 then
LF_SetSmokeStatus_New(context, smokeId, 1)
end
end
-- 设置指定黑烟的表现(或者是创建/销毁)不更改group var
function LF_SetSmokeStatus_New(context, smokeId, status)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_SetSmokeByStatus is called, smokeId = "..smokeId..", status is set to "..status)
-- 黑烟只有三种表现gadget state 0, gadget state 201, 不存在gadget(202)
local gadgetState = 0
if status == 0 then
-- 仅透镜可观测
-- 保底创建gadget state在0
ScriptLib.CreateGadget(context, { config_id = smokeId })
gadgetState = 0
elseif status == 1 then
-- 大世界可观测
-- 保底创建gadget state在201
ScriptLib.CreateGadget(context, { config_id = smokeId })
gadgetState = 201
-- 黑烟对应的观察任务流转
LF_LoadSmokeGroup(context, smokeId)
elseif status == 2 then
-- 不用特意创建如果黑烟在的话gadget state在202物件自行销毁
ScriptLib.SetGadgetStateByConfigId(context, smokeId, 202)
gadgetState = 202
end
-- 更新此smoke的gadget state
ScriptLib.SetGadgetStateByConfigId(context, smokeId, gadgetState)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] smoke id = ".. smokeId..", gadget state is set to "..gadgetState)
end
function LF_SetCurLensActive(context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] LF_SetCurLensGroup is called")
-- 查看自己是不是当前lens
local before = ScriptLib.GetGroupVariableValueByGroup(context, "curGroupId", 133304143)
if before ~= base_info.group_id then
-- 不是的话把自己设置成当前lens
ScriptLib.SetGroupVariableValueByGroup(context, "curGroupId", base_info.group_id, 133304143)
-- 有人设置过这个group var再通知其他透镜group没设置过说明还没人接近过任何一个透镜
if before ~= 0 then
ScriptLib.ExecuteGroupLua(context, before, "LF_ResetObservedSmoke_FromOther", {})
end
end
local after = ScriptLib.GetGroupVariableValueByGroup(context, "curGroupId", 133304143)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] group 133304143 var curGroupId = "..after)
end
--================================================================
-- Triggers
--================================================================
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] group is loaded")
LF_SetCurGroupSmokes(context)
return 0
end
-- function action_EVENT_GROUP_WILL_UNLOAD(context, evt)
-- ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] group will unload")
-- -- 不设置group var只回滚任务
-- ScriptLib.AddQuestProgress(context, defs_miscs.resetParam)
-- return 0
-- end
function action_EVENT_ENTER_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] player enters region "..evt.param1)
for k, v in pairs(defs_miscs.smokeTable) do
if evt.param1 == v.maxRegion then
-- 玩家进入黑烟区域, 要把这个黑烟加载出来
LF_SetCurSmokeActive(context, v.smoke)
-- 查看自己是不是当前组,不是的话设置为当前组,并通知上一个当前组删除自己同组的所有黑烟
LF_SetCurLensActive(context)
end
end
if defs.lensRegion == nil then
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] WARNING, doesn't have lensRegion in defs")
return 0
end
if evt.param1 == defs.lensRegion then
LF_ResetLNLByGroupVar(context)
end
return 0
end
-- function action_EVENT_LEAVE_REGION(context, evt)
-- ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] player leaves region "..evt.param1)
-- -- 如果玩家离开了某个黑烟的最大区域
-- for k, v in pairs(defs_miscs.smokeTable) do
-- if evt.param1 == v.maxRegion then
-- -- 如果当前状态是已观测,需要重置回未观测
-- if 1 == ScriptLib.GetGroupVariableValue(context, "smoke_"..k) then
-- LF_SetSmokeStatus(context, k, 0)
-- ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] smoke = "..k.." is set from 1 to 0")
-- end
-- end
-- end
-- return 0
-- end
-- 在透镜中观测到了一个黑烟
function action_EVENT_DEATH_ZONE_OBSERVE(context, evt)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] lens config id = "..evt.param1..
", observed gadget config id = ".. evt.param2..", group id = "..evt.param3)
if evt.param2 == defs_miscs.lnlConfigId then
-- 如果是兰纳罗
LF_SetLNLStatus(context, defs_miscs.lnlConfigId, 2)
elseif gadgets[evt.param2].gadget_id == smokeGadgetId then
-- 如果是黑烟
-- 尽量不用for loop
-- 被观测到的黑烟config id
local smokeId = evt.param2
-- 黑烟状态改变
LF_SetSmokeGroupVar(context, smokeId, 1)
end
return 0
end
-- 完成一个未爆发死域玩法group
-- 一定要主机交互一下任务才能成功,所以任务一定能成功通知到玩家
function action_SMOKE_QUEST_FINISH(context, evt)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] quest id = "..evt.param1..", status = "..evt.param2)
-- 只检测是不是成功
if evt.param2 ~= 1 then
return 0
end
-- 某个黑烟对应的玩法group的任务已经完成
for k, v in pairs(defs_miscs.smokeTable) do
if v.finishQuest == evt.param1 then
-- 黑烟可以永久消失了
LF_SetSmokeGroupVar(context, k, 2)
end
end
return 0
end
function action_EVENT_GADGET_STATE_CHANGE(context, evt)
-- 只在状态有所改变的时候判断
if evt.param3 == evt.param1 then
return 0
end
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] gadget "..evt.param2.." changes from state "..evt.param3.."to state "..evt.param1)
-- 检测草神透镜的grassState是否从激化态回到正常态
if defs_miscs.lensConfigId == evt.param2 and 0 == evt.param1 and 200 == evt.param3 then
-- 兰纳罗还没被发现播一个reminder说兰纳罗无了
-- 这个时机无论如何都可以播,透镜开着自然就不显示了
if ScriptLib.GetGroupVariableValue(context, "aranaraObservedNum") == 0 then
ScriptLib.ShowReminder(context, lnlDisappearRmd)
end
end
return 0
end
--================================================================
-- ServerLuaCall
--================================================================
function SLC_Player_Approach_Self(context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] SLC_Player_Approach_Self is triggered")
-- 查看自己是不是当前组,不是的话设置为当前组,并通知上一个当前组删除自己同组的所有黑烟
LF_SetCurLensActive(context)
-- 根据自己是否是当前透镜这里一定是设置同组黑烟、兰纳罗状态并同步一次sgv
LF_SetCurGroupSmokes(context)
return 0
end
function SLC_Lens_Closed_Excited(context)
ScriptLib.PrintContextLog(context, "## [DeathZoneObservation] SLC_Lens_Closed_Excited is triggered")
-- 进这个slc说明本次打开界面的时候透镜一定在激化态现在关上了可能需要rmd
-- 只有兰纳罗还没被发现+透镜已经不在激化态了才出现这个reminder 33040007
if ScriptLib.GetGroupVariableValue(context, "aranaraObservedNum") == 0
and ScriptLib.GetGadgetStateByConfigId(context, 0, defs_miscs.lensConfigId) ~= 200 then
ScriptLib.ShowReminder(context, lnlDisappearRmd)
end
return 0
end
--================================================================
-- Initialize
--================================================================
LF_Initialize_Group(triggers, suites, variables, gadgets, regions)

View File

@@ -0,0 +1,258 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: DreamStone
|| owner: zijun.ma
|| description: 根据目前梦境系统的要求进行处理
|| LogName: TD_DreamStone
|| Protection: [Protection]
=======================================]]
--[[
需求
1梦境石可以交互时能自由切换
2GroupLoad时检查梦境石可否交互
3GroupLoad时检查是否满足对应梦境条件
--]]
--[[
local DreamStonePlay = {
LevelTagGroup = 12,
DreamStoneCid = 306001,
}
-- 在对应LevelTag中操作梦境石发生的切换
local LevelTagState = {
["3.0_Dream"] ={
ChangeTag = 39,
WeatherStateList = {
{AreaID = 4037,State =0},
{AreaID = 4038,State =1},
{AreaID = 4039,State =0},
{AreaID = 4040,State =1},
{AreaID = 4041,State =1},
},
},
["3.0_Reality"] ={
ChangeTag = 38,
WeatherStateList = {
{AreaID = 4037,State =1},
{AreaID = 4038,State =0},
{AreaID = 4039,State =1},
{AreaID = 4040,State =0},
{AreaID = 4041,State =0},
},
},
}
local KeyQuest = {
["Lock"] = {7302518,7302519,7302515,7303201,7303202,7303203},
["Unlock"] ={7302525,7302506,7302511,7302514,7303301},
}
--]]
local Tri_DreamStone = {
-- GadgetStateChange
{ keyWord = "ChangeLevelTag",event = EventType.EVENT_LUA_NOTIFY, source = "AraraDreamStone", trigger_count = 0},
-- 部分初始化的逻辑见 LF_AutoGenTri
}
function LF_Initialize_DreamStone()
LF_AutoGenTri()
local startConfigID = 50050001
for _,v in pairs(Tri_DreamStone) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(Tri_DreamStone,{1})
return 0
end
function LF_AutoGenTri()
local keyWord = 100
local questList = KeyQuest["Lock"]
for i = 1,#questList do
keyWord = keyWord + 1
local keyWordType = tostring(keyWord)
local sourceQuest = tostring(questList[i])
local trigger = { keyWord = "CheckLock",keyWordType = keyWordType,event = EventType.EVENT_QUEST_START, source = sourceQuest, trigger_count = 0}
table.insert(Tri_DreamStone, trigger)
end
keyWord = 200
questList = KeyQuest["Unlock"]
for i = 1,#questList do
keyWord = keyWord + 1
local keyWordType = tostring(keyWord)
local sourceQuest = tostring(questList[i])
local trigger = { keyWord = "CheckUnlock",keyWordType = keyWordType,event = EventType.EVENT_QUEST_START, source = sourceQuest, trigger_count = 0}
table.insert(Tri_DreamStone, trigger)
end
return 0
end
--[[=====================================
|| Action
--======================================]]
-- 修改LevelTag
function action_ChangeLevelTag(context,evt)
-- 检查梦境石状态是否合法,仅做网络延迟时的保护。
if 201 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, DreamStonePlay.DreamStoneCid) then
local msg = "## [TD_DreamStone] 对应梦境石已上锁,无法切状态"
ScriptLib.PrintContextLog(context, msg)
return 0
end
local tag_name = LF_GetCurLevelTagName(context)
local changeData = LevelTagState[tag_name]
if changeData == nil then
local msg = "## [TD_DreamStone] LF_GetCurLevelTagName"
msg = msg .."||current_env_state = ".. tag_name
ScriptLib.PrintContextLog(context, msg)
return 0
end
local changeWeatherStateList = changeData.WeatherStateList
local msg = "## [TD_DreamStone] action_ChangeLevelTag"
msg = msg .."||changeToLevelTag = " .. changeData.ChangeTag
ScriptLib.PrintContextLog(context, msg)
for i = 1,#changeWeatherStateList do
local weatherState = changeWeatherStateList[i]
ScriptLib.SetWeatherAreaState(context, weatherState.AreaID, weatherState.State)
end
ScriptLib.ChangeToTargetLevelTag(context, changeData.ChangeTag)
return 0
end
function action_CheckLock(context,evt)
local msg = "## [TD_DreamStone] action_CheckLock"
msg = msg .."||QuestStart = ".. evt.param1
ScriptLib.PrintContextLog(context, msg)
ScriptLib.SetGadgetStateByConfigId(context, DreamStonePlay.DreamStoneCid, 0)
return 0
end
function action_CheckUnlock(context,evt)
local msg = "## [TD_DreamStone] action_CheckUnlock"
msg = msg .."||QuestStart = ".. evt.param1
ScriptLib.PrintContextLog(context, msg)
ScriptLib.SetGadgetStateByConfigId(context, DreamStonePlay.DreamStoneCid, 201)
return 0
end
--[[=====================================
|| LocalFunction
--======================================]]
function LF_GetCurLevelTagName(context)
local cur_TagVec = ScriptLib.GetCurrentLevelTagVec(context, DreamStonePlay.LevelTagGroup)
if cur_TagVec[1] == nil then
return "Empty"
end
local cur_tag = cur_TagVec[1]
local tag_name = ScriptLib.GetLevelTagNameById(context,cur_tag)
local msg = "## [TD_DreamStone] LF_GetCurLevelTagName"
msg = msg .."||current_env_state = ".. tag_name
ScriptLib.PrintContextLog(context, msg)
return tag_name
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for _,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for _,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for _,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for _,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据数组的长度修饰num
function Fix(value,array,error)
if value < 1 then
ScriptLib.PrintLog(error .. "value = " .. value)
return 1
end
if value > #array then
ScriptLib.PrintLog(error .. "value = " .. value)
return #array
end
return value
end
-- 判断特定值是否在Table中
function LF_IsInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return true;
end
end
return false;
end
-- 返回特定值在Table中的第一个位置
function LF_GetIndexInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return k;
end
end
return 0;
end
LF_Initialize_DreamStone()

View File

@@ -0,0 +1,583 @@
--[[======================================
|| filename: DreamLand
|| owner: shuyi.chang
|| description: 幻梦之门玩法
|| LogName: ## [DreamlandChallenge]
|| Protection:
=======================================]]
-- 【高亮注意】Lua Require: V3_0/Dreamland
-- 【高亮注意】必须勾上LuaEntity可索引
-- 【高亮注意】此玩法需要特别注意suite的配置方法
-- suite1必须包括门和保底区域即defs中的challengeRegion
-- suite2必须包括灵花和怪即挑战开始后需要出现的东西都必须放在suite 2中
-- suite3必须包括挑战成功后被创建的内容基本为宝箱
-- 综上所述需要LD手动配置的内容包括宝箱没有特殊需求不需要创建其他东西
--[[
local defs = {
-- 【根据实际情况修改】幻梦之门的config id
door = 17001,
-- 【根据实际情况修改】禁联机挑战的gallery id
galleryId = 19101,
-- 【根据实际情况修改】挑战的保底区域,出了这个区域挑战即失败
challengeRegion = 17021,
-- 【根据实际情况修改】天气id
weatherId = 4307,
-- 【根据实际情况修改】失败传送坐标
transParam_Pos = {x = 1437, y = 261.3, z = -1696},
transParam_Rot = {x = 0, y = 0, z = 0},
transParam_Radius = 1,
-- 【需要LD配置正式版本】挑战id没有特殊情况保持不变即可
fatherChallenge = 267,
childChallenge = {268, 269},
-- 【根据LD需求修改】拾取spirit的最大间隔时间
maxPickupTime = 30,
-- 被怪物打到后挑战时间修改值,应该是负数
minusTime = -15,
-- vision type id, 需要在编辑器里每个block创建
visionType = 11020002,
-- 门上的隐形操作台id
worktopId = 1,
}
--]]
local extraTriggers =
{
{ config_id = 50000001, name = "GADGET_STATE_CHANGE_DOOR", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_GADGET_STATE_CHANGE_DOOR", trigger_count = 0 },
{ config_id = 50000002, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_GROUP_LOAD", trigger_count = 0 },
-- { config_id = 50000003, name = "MONSTER_BATTLE", event = EventType.EVENT_MONSTER_BATTLE, source = "", condition = "", action = "action_MONSTER_BATTLE", trigger_count = 0 },
{ config_id = 50000004, name = "SPIRIT_PICKUP", event = EventType.EVENT_LUA_NOTIFY, source = "pickUp", condition = "", action = "action_SPIRIT_PICKUP", trigger_count = 0, tag = "99" },
{ config_id = 50000005, name = "CHALLENGE_FAIL", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_CHALLENGE_FAIL", trigger_count = 0 },
{ config_id = 50000006, name = "CHALLENGE_SUCCESS", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_CHALLENGE_SUCCESS", trigger_count = 0 },
{ config_id = 50000007, name = "TIME_AXIS_PASS", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_TIME_AXIS_PASS", trigger_count = 0 },
{ config_id = 50000008, name = "DOOR_FINISH", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_DOOR_FINISH", trigger_count = 0, tag = "98" },
{ config_id = 50000009, name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_LEAVE_REGION", trigger_count = 0 },
{ config_id = 50000010, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_ENTER_REGION", trigger_count = 0 },
{ config_id = 50000011, name = "GROUP_WILL_UNLOAD", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_GROUP_WILL_UNLOAD", trigger_count = 0 },
}
local extraVariables =
{
-- 记录已获得的梦境之灵数量
{ config_id = 50000101, name = "spiritNum", value = 0, no_refresh = false },
-- 记录门的状态0未弹琴在01已弹琴在9022挑战已成功在202
{ config_id = 50000102, name = "doorStatus", value = 0, no_refresh = true },
-- 记录挑战第一阶段是否已成功
{ config_id = 50000103, name = "collectionFinished", value = 0, no_refresh = false },
}
local spirits = {}
local spiritGadgetId = 70220104
local worktopField =
{
configId = 50000099,
gadgetId = 70950145,
optionId = 758,
}
local waitEnd = 2
local reminderId = 1109002
local forbidStartRmd = 33010199
-- 幻梦之门上的隐形操作台初始不属于任何suite【目前用不上】
-- local worktop = { config_id = worktopField.configId, gadget_id = worktopField.gadgetId, pos = gadgets[defs.door].pos, rot = gadgets[defs.door].rot, level = 1, area_id = gadgets[defs.door].area_id, }
local spiritActiveTime = 10
--================================================================
-- Local Functions
--================================================================
function LF_Initialize_Group(triggers, suites, variables, gadgets, regions)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
end
-- add triggers to suite
for i = 1, #extraTriggers do
if extraTriggers[i].name == "GADGET_STATE_CHANGE_DOOR"
or extraTriggers[i].name == "GROUP_LOAD"
or extraTriggers[i].name == "TIME_AXIS_PASS" then
table.insert(suites[1].triggers,extraTriggers[i].name)
else
table.insert(suites[2].triggers,extraTriggers[i].name)
end
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
-- -- insert gadgets【暂时废弃LD手种不然没法配ui提示】
-- gadgets[worktopField.configId] = worktop
-- table.insert(suites[1].gadgets, worktopField.configId)
-- -- add door to all suites
-- table.insert(suites[2].gadgets, defs.door)
-- table.insert(suites[3].gadgets, defs.door)
-- add spirits to local list
for i, v in pairs(gadgets) do
if v.gadget_id == spiritGadgetId then
table.insert(spirits, i)
end
end
-- set vision type
if defs.visionType == nil then
defs.visionTYpe = 1102002
end
regions[defs.challengeRegion].vision_type_list = { defs.visionType }
end
function LF_ChallengeEnd(context, status)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] LF_ChallengeEnd is called, fail = "..status)
-- local uid_list = ScriptLib.GetSceneUidList(context)
local doorState = 0
if status == 0 then
-- 成功
doorState = 202
ScriptLib.InitTimeAxis(context, "DreamlandSuccess", {waitEnd}, false)
-- gallery成功(true是fail)
ScriptLib.StopGallery(context, defs.galleryId, false)
elseif status == 1 then
-- 失败
doorState = 902
if ScriptLib.GetGroupTempValue(context, "forbidTransmit", {}) ~= 1 and ScriptLib.IsPlayerTransmittable(context, context.owner_uid) == true then
-- 只有玩家没出区域的时候传送
ScriptLib.TransPlayerToPos(context, {uid_list = {context.owner_uid}, pos = defs.transParam_Pos, radius = defs.transParam_Radius, rot = defs.transParam_Rot, is_skip_ui = false})
end
-- gallery失败
ScriptLib.StopGallery(context, defs.galleryId, true)
end
-- -- gallery成功或失败【走上面区分成功和失败】
-- ScriptLib.StopGallery(context, defs.galleryId, true)
-- 重置变量和sgv
LF_ResetVariables(context)
--重置group
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, 2)
-- ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, worktopField.configId, worktopField.optionId)
ScriptLib.SetGadgetStateByConfigId(context, defs.door, doorState)
if #suites >= 4 then
-- suite 4里LD创建出的伏击怪都干掉
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, 4)
end
if #suites >= 5 then
-- suite 5里各种提示都干掉
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, 5)
end
-- 关闭天气
ScriptLib.SetWeatherAreaState(context, defs.weatherId, 0)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] weather "..defs.weatherId.." stops")
-- 恢复视野
ScriptLib.RevertPlayerRegionVision(context, context.owner_uid)
ScriptLib.SetPlayerGroupVisionType(context, {context.owner_uid}, {1})
end
function LF_ResetVariables(context)
-- local uid_list = ScriptLib.GetSceneUidList(context)
-- 挑战阶段重置
ScriptLib.SetGroupVariableValue(context, "collectionFinished", 0)
ScriptLib.SetGroupTempValue(context, "forbidTransmit", 0, {})
-- 仇恨回归
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_CAN_CLEAR_THREAT", 0)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] SGV_CAN_CLEAR_THREAT = 0")
-- 玩家身上计数归零
ScriptLib.SetGroupVariableValue(context, "spiritNum", 0)
ScriptLib.AddTeamServerGlobalValue(context, context.owner_uid, "SGV_DreamLand_SpiritNum", 0)
local var = ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_DreamLand_SpiritNum", 0)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] SGV_DreamLand_SpiritNum is created and set to 0, var = "..var)
-- 所有小精灵高亮取消
for i, v in ipairs(spirits) do
-- 修改SGV值
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_SPIRIT_ACTIVE", 0)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge]spirit "..v..", SGV_SPIRIT_ACTIVE changes to 0")
end
end
function LF_FailAndForbidTransmit(context, reason)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] LF_FaileAndForbidTransmit is called, reason = "..reason)
ScriptLib.SetGroupTempValue(context, "forbidTransmit", 1, {})
-- 父挑战失败
ScriptLib.ModifyFatherChallengeProperty(context, defs.fatherChallenge, FatherChallengeProperty.CUR_FAIL, 2)
end
--================================================================
-- Triggers
--================================================================
-- 触发操作
function action_GADGET_STATE_CHANGE_DOOR(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] gadget "..evt.param2.." changes from state "..evt.param3.."to state "..evt.param1)
local uid_list = ScriptLib.GetSceneUidList(context)
-- 只管门的状态变化
if evt.param2 ~= defs.door then
return 0
end
if evt.param1 == 902 then
-- 玩家已经对门弹完琴了
ScriptLib.SetGroupVariableValue(context, "doorStatus", 1)
elseif evt.param1 == 201 then
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] challenge starts")
-- 挑战开始前保底重置group var和sgv
LF_ResetVariables(context)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
-- 改变天气
ScriptLib.SetWeatherAreaState(context, defs.weatherId, 1)
ScriptLib.EnterWeatherArea(context, defs.weatherId)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] change weather to "..defs.weatherId)
-- 开启挑战,父挑战给保底十分钟
ScriptLib.CreateFatherChallenge(context, defs.fatherChallenge, defs.fatherChallenge, 99999999, {success = 200, fail = 2})
ScriptLib.AttachChildChallenge(context, defs.fatherChallenge, defs.childChallenge[1], defs.childChallenge[1], {defs.maxPickupTime, 106, 99, #spirits}, {}, {success = 100, fail = 3})
ScriptLib.StartFatherChallenge(context, defs.fatherChallenge)
-- 开启gallery
ScriptLib.StartGallery(context, defs.galleryId)
-- 所有小精灵进激化态
for i, v in ipairs(spirits) do
-- 修改SGV值
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_SPIRIT_ACTIVE", 1)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge]spirit "..v..", SGV_SPIRIT_ACTIVE changes to 1")
-- 起一个时间轴到时间之后reset SGV to 0
ScriptLib.InitTimeAxis(context, "SpiritActive", {spiritActiveTime}, false)
end
-- 开启视野
ScriptLib.SetPlayerGroupVisionType(context, {context.owner_uid}, {defs.visionType})
ScriptLib.ForbidPlayerRegionVision(context, context.owner_uid)
elseif evt.param1 == 202 then
ScriptLib.SetGroupVariableValue(context, "doorStatus", 2)
end
return 0
end
-- -- 触发操作
-- function action_MONSTER_BATTLE(context, evt)
-- ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] monster "..evt.param1.." enters battle")
-- -- ScriptLib.ShowReminder(context, reminderId)
-- return 0
-- end
-- 触发操作
function action_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] group is loaded")
-- 保底关闭天气
local temp = ScriptLib.SetWeatherAreaState(context, defs.weatherId, 0)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] weather "..defs.weatherId.." stops when group is loaded, succeed = "..temp)
local doorStatus = ScriptLib.GetGroupVariableValue(context, "doorStatus")
if doorStatus == 1 then
ScriptLib.SetGadgetStateByConfigId(context, defs.door, 902)
elseif doorStatus == 2 then
ScriptLib.SetGadgetStateByConfigId(context, defs.door, 202)
-- 保底创建宝箱
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 3)
end
-- 保底回归仇恨
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_CAN_CLEAR_THREAT", 0)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] SGV_CAN_CLEAR_THREAT = 0")
return 0
end
-- 触发操作
function action_SPIRIT_PICKUP(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] A spirit is picked up")
local configId = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
-- 先判是否允许执行
if gadgets[configId].gadget_id ~= spiritGadgetId or ScriptLib.CheckIsInGroup(context, 0, configId) == false then
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] a spirit is picked up, target entity is not a spirit, or is already dead, return immediately")
return 0
end
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] a spirit is picked up, entity id = "..context.target_entity_id..", config id = "..configId)
-- kill spirit以防触发两次
ScriptLib.KillEntityByConfigId(context, { config_id = configId })
-- Avatar拿到一个新的spirit
ScriptLib.ChangeGroupVariableValue(context, "spiritNum", 1)
local spiritNumCurrent = ScriptLib.GetGroupVariableValue(context, "spiritNum")
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] spiritNum = "..spiritNumCurrent)
-- 把值同步给SGV
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_DreamLand_SpiritNum", spiritNumCurrent)
-- 子挑战计时更新
ScriptLib.SetChallengeDuration(context, defs.childChallenge[1], defs.maxPickupTime)
return 0
end
-- 触发操作
function action_CHALLENGE_FAIL(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] challenge "..evt.param1.." fails")
-- 父挑战失败
if defs.fatherChallenge == evt.param1 then
LF_ChallengeEnd(context, 1)
end
return 0
end
-- 触发操作
function action_CHALLENGE_SUCCESS(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] challenge index = "..evt.param1.." succeeds")
-- 子挑战1号成功
if defs.childChallenge[1] == evt.param1 then
-- 创建操作台选项
-- ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, worktopField.configId, {worktopField.optionId})
-- 最新更新添加suite5里面是各种提示和操作台
if #suites >= 5 then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 5)
end
-- 接第二个子挑战
ScriptLib.AttachChildChallenge(context, defs.fatherChallenge, defs.childChallenge[2], defs.childChallenge[2], {defs.maxPickupTime, 9, 98, 1}, {}, {success = 100, fail = 3})
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] child challenge "..defs.childChallenge[2].." starts")
-- 设置参数
ScriptLib.SetGroupVariableValue(context, "collectionFinished", 1)
-- todo: 正常流程里不需要此步骤给LD测试保底临时加一下
-- 保底把所有spirit都set to 202
for k, v in pairs(spirits) do
ScriptLib.SetGadgetStateByConfigId(context, k, GadgetState.GearStop)
end
end
-- 子挑战2号成功即父挑战成功生成宝箱
if defs.childChallenge[2] == evt.param1 then
-- 目前成功后的action在操作台option逻辑上
end
return 0
end
function action_TIME_AXIS_PASS(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] time axis "..evt.source_name.." , stage "..evt.param1.." is finished")
if evt.source_name == "SpiritActive" then
-- 这个时间轴结束的时候所有spirit上的激化特效都要消失
for i, v in ipairs(spirits) do
-- 修改SGV值
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_SPIRIT_ACTIVE", 0)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge]spirit "..v..", SGV_SPIRIT_ACTIVE changes to 0")
end
elseif evt.source_name == "DreamlandSuccess" then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 3)
-- elseif evt.source_name == "DreamlandFail" then
-- ScriptLib.TransPlayerToPos(context, {uid_list = {uid_list[1]}, pos = defs.transParam_Pos, radius = defs.transParam_Radius, rot = defs.transParam_Rot, is_skip_ui = false})
end
return 0
end
-- 触发操作
function action_DOOR_FINISH(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] worktop configId = "..evt.param1..", option = "..evt.param2)
-- 和门的隐藏操作台完成操作
-- 现在操作台放在suite5里面了拿不到configId但是这个玩法里目前只有一个操作台挂选项所以只判断选项也行
if worktopField.optionId == evt.param2 then
-- 事件成功
LF_ChallengeEnd(context, 0)
end
return 0
end
-- 触发操作
function action_LEAVE_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] leave region " .. evt.param1)
-- 判断是保底区域
if evt.param1 == defs.challengeRegion then
LF_FailAndForbidTransmit(context, "leave region")
end
return 0
end
function action_ENTER_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] enter region " .. evt.param1)
-- 判断是保底区域
if evt.param1 == defs.challengeRegion then
ScriptLib.SetGroupTempValue(context, "forbidTransmit", 0, {})
end
return 0
end
function action_GROUP_WILL_UNLOAD(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] group will unload")
LF_FailAndForbidTransmit(context, "group will be unloaded")
return 0
end
--================================================================
-- SLC functions
--================================================================
function SLC_Player_Enter_Door(context, evt)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] SLC_Player_Enter_Door is called")
if ScriptLib.GetGadgetStateByConfigId(context, 0, defs.door) ~= 902 then
-- 只有弹完琴了才能开挑战
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] challenge can't stop cuz door is not prepared")
return 0
end
local uid_list = ScriptLib.GetSceneUidList(context)
if #uid_list > 1 or ScriptLib.CheckIsInMpMode(context) == true then
-- 只有非联机状态下才能开挑战
-- 如果联机状态+门在902弹一个reminder
ScriptLib.ShowReminder(context, forbidStartRmd)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] challenge can't stop cuz of other players in scene")
return 0
end
-- 可以开的话直接改门的gadget state
ScriptLib.SetGadgetStateByConfigId(context, defs.door, 201)
return 0
end
function SLC_ClearAvatarTeamThreat(context, evt)
-- local uid_list = ScriptLib.GetSceneUidList(context)
-- 用SGV清除玩家队伍身上的仇恨
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] SGV_CAN_CLEAR_THREAT Set: 1")
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_CAN_CLEAR_THREAT", 1)
return 0
end
function SLC_AvatarIsHitInDreamland(context, evt)
-- 减挑战时间只要这个function被触发了就肯定减cd保护在ability上
local collectionFinished = ScriptLib.GetGroupVariableValue(context, "collectionFinished")
local challengeId = 0
if collectionFinished == 0 then
challengeId = defs.childChallenge[1]
else
challengeId = defs.childChallenge[2]
end
ScriptLib.AddChallengeDuration(context, challengeId, defs.minusTime, false)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] challenge time delta = "..defs.minusTime..
" cuz player is hit in challenge "..challengeId)
return 0
end
function SLC_ReturnAvatarTeamThreat(context, evt)
-- local uid_list = ScriptLib.GetSceneUidList(context)
-- 用SGV回归玩家队伍身上的仇恨
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_CAN_CLEAR_THREAT", 0)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] SGV_CAN_CLEAR_THREAT Set: 0")
return 0
end
function SLC_HighlightSpirit(context)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge] SLC_HighlightSpirit is called")
-- 改所有spirit的SGV值在ability层限制只有状态0的spirit会根据值的变化上modifier
for i, v in ipairs(spirits) do
-- 修改SGV值
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_SPIRIT_ACTIVE", 1)
ScriptLib.PrintContextLog(context, "## [DreamlandChallenge]spirit "..v..", SGV_SPIRIT_ACTIVE changes to 1")
-- 起一个时间轴到时间之后reset SGV to 0
ScriptLib.InitTimeAxis(context, "SpiritActive", {spiritActiveTime}, false)
end
return 0
end
--================================================================
-- Initialize
--================================================================
LF_Initialize_Group(triggers, suites, variables, gadgets, regions)

View File

@@ -0,0 +1,444 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
-- goto 1176 296 -1594
--[[======================================
|| filename: GopherPlay
|| owner: zijun.ma
|| description: 地鼠玩法
|| LogName: TD_GopherPlay
|| Protection: [Protection]
=======================================]]
-- local defs =
-- {
-- regionId = 12345,
-- targetScore = 3,
-- maxTime = 90,
-- startId = 0,
-- }
local GopherPlay = {
RegionCid = defs.regionId,
ChallengeIndex = 83,
OptionId = 175,
LargeMushroomId = 70310220,
ConfigList =
{
defs.gadget_mushroom01,defs.gadget_mushroom02,defs.gadget_mushroom03,
defs.gadget_mushroom04,defs.gadget_mushroom05,defs.gadget_mushroom06
},
ZeroArray = {0,0,0,0,0,0},
}
-- local GopherArray = {
-- [1] =
-- {-- time里面有两个值一个是指延时多久出现一个是指延时多久消失。譬如{1,5}是指第1秒后出现第5秒后消失。
-- [1] = { array = { 0, 0, 0, 1, 2, 1}, time = {1,5}},
-- [2] = { array = { 1, 2, 1, 0, 0, 0}, time = {1,5}},
-- [3] = { array = { 0, 1, 0, 2, 1, 0}, time = {1,5}},
-- [4] = { array = { 0, 2, 1, 2, 0, 0}, time = {1,5}},
-- },
-- [2] =
-- {
-- [1] = { array = { 0, 0, 0, 1, 2, 1}, time = {1,5}},
-- [2] = { array = { 1, 2, 1, 0, 0, 0}, time = {1,5}},
-- [3] = { array = { 0, 1, 0, 2, 1, 0}, time = {1,5}},
-- [4] = { array = { 0, 2, 1, 2, 0, 0}, time = {1,5}},
-- },
-- }
local GopherState = {
[0] = 0,
[1] = 901,
[2] = 902,
}
-- 流程规划
-- 严格根据Size初始化地鼠列表
-- LF_StartChallenge()
-- 按照选取的资料组开始挑战
-- LF_TimeAxisManager()
-- LF_SummonGopher()
-- LF_GopherDisappear()
-- LF_GopherBeHit()
-- LF_ChallengeJudge()
local GopherPlay_Trigger = {
{ keyWord = "TimeAxisManager", event = EventType.EVENT_TIME_AXIS_PASS, source = "", trigger_count = 0},
-- Group是DynamicGroup所以初始化倒不是问题
--{ keyWord = "ChallengeInit", event = EventType.EVENT_GROUP_LOAD, source = "GopherPlay", trigger_count = 0},
{ keyWord = "ChallengeSuccess", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", trigger_count = 0},
{ keyWord = "ChallengeFail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", trigger_count = 0},
{ keyWord = "SelectOption", event = EventType.EVENT_SELECT_OPTION, source = "", trigger_count = 0},
{ keyWord = "GroupLoad", event = EventType.EVENT_GROUP_LOAD, source = "", trigger_count = 0},
-- { keyWord = "GadgetStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, condition = "condition_GadgetStateChange", source = "", trigger_count = 0},
{ keyWord = "VariableChange", event = EventType.EVENT_VARIABLE_CHANGE, source = "score", trigger_count = 0, tag = "99"},
{ keyWord = "TempVariableChange", event = EventType.EVENT_VARIABLE_CHANGE, source = "scoreTemp", trigger_count = 0},
}
local GopherPlay_Variables = {
-- 记录是否已成功
{ config_id = 50000001, name = "succeed", value = 0, no_refresh = true },
-- -- 记录这一轮击杀了多少个大蘑菇
-- { config_id = 50000002, name = "scoreTemp", value = 0, no_refresh = false },
}
function LF_Initialize_Level()
local startConfigID = 40000001
for _,v in pairs(GopherPlay_Trigger) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
if v.condition == nil then
v.condition = ""
end
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(GopherPlay_Trigger,RequireSuite)
-- add variables
for _,v in pairs(GopherPlay_Variables) do
table.insert(variables, v)
end
return 0
end
--[[=====================================
|| action函数
--======================================]]
function action_TimeAxisManager(context,evt)
local timeProcess = evt.param1
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: time axis "..evt.source_name..", stage "..timeProcess.. " is finished")
if timeProcess%2 == 0 then
-- 偶数时,走消失逻辑
LF_GopherDisappear(context)
else
-- 奇数时,走出现逻辑
LF_SummonGopher(context)
end
return 0
end
function action_ChallengeSuccess(context,evt)
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: challenge index = "..evt.param1.." succeeds")
ScriptLib.SetGroupVariableValue(context, "succeed", 1)
LF_StopChallenge(context, true)
return 0
end
function action_ChallengeFail(context,evt)
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: challenge index = "..evt.param1.." fails")
LF_StopChallenge(context, false)
return 0
end
function action_SelectOption(context, evt)
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: worktop "..evt.param1..", option = "..evt.param2)
-- 和操作台交互,开启挑战
LF_StartChallenge(context)
return 0
end
function action_GroupLoad(context, evt)
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: group is loaded")
local succeed = ScriptLib.GetGroupVariableValue(context, "succeed")
if succeed == 0 then
succeed = false
else
succeed = true
end
LF_StopChallenge(context, succeed)
return 0
end
function action_VariableChange(context, evt)
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: group var "..evt.source_name.." changes from "..evt.param2.." to "..evt.param1)
return 0
end
function action_TempVariableChange(context, evt)
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: group var "..evt.source_name.." changes from "..evt.param2.." to "..evt.param1)
local largeMushroomCount = ScriptLib.GetGroupTempValue(context, "LargeMushroomCount", {})
-- 击杀了这一轮所有大蘑菇,而且不能是最后成功的那一下
if evt.param1 >= largeMushroomCount and ScriptLib.GetGroupTempValue(context, "score", {}) < defs.targetScore then
LF_GopherDisappear(context)
end
return 0
end
-- function condition_GadgetStateChange(context, evt)
-- -- 只有当是大蘑菇并且进入202的时候才能触发这个trigger
-- local config_id = evt.param2
-- local gadget_id = ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid)
-- local gadgetState = ScriptLib.GetGadgetStateByConfigId(context, 0, config_id)
-- ScriptLib.PrintContextLog(context, "## TD_GopherPlay configId = ".. config_id .. ", gadgetId = "..gadget_id..", gadgetState change from "..evt.param2.." to "..gadgetState)
-- if 202 == gadgetState and gadget_id == GopherPlay.LargeMushroomId then
-- return true
-- end
-- return false
-- end
-- function action_GadgetStateChange(context, evt)
-- SLC_AddScore(context, evt)
-- return 0
-- end
--[[=====================================
|| 流程函数
--======================================]]
function LF_StartChallenge(context)
-- 删除操作台选项操作台进202
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.startId, GopherPlay.OptionId)
ScriptLib.SetGadgetStateByConfigId(context, defs.startId, 202)
-- 运行后,开启挑战
math.randomseed(tostring(ScriptLib.GetServerTime(context)):reverse():sub(1, 6))
local randomIndex = math.random(#GopherArray)
ScriptLib.PrintContextLog(context, "## TD_GopherPlay : 使用Index=".. randomIndex .."的矩阵作为当前的挑战矩阵")
ScriptLib.StartChallenge(context, GopherPlay.ChallengeIndex, GopherPlay.ChallengeIndex, {defs.maxTime, 3, 99, defs.targetScore})
ScriptLib.AddExtraGroupSuite(context, 0, 2)
-- 初始化地鼠index
ScriptLib.SetGroupTempValue(context, "CurIndex", randomIndex, {})
ScriptLib.SetGroupTempValue(context, "CurArrayIndex", 1, {})
-- ScriptLib.SetGroupTempValue(context, "Score", 0, {})
local timeAxis = GopherArray[randomIndex][1].time
ScriptLib.InitTimeAxis(context, "GopherPlay_1", timeAxis, false)
return 0
end
function LF_StopChallenge(context, success)
-- 关闭时间轴
local curArrayIndex = ScriptLib.GetGroupTempValue(context, "CurArrayIndex", {})
ScriptLib.EndTimeAxis(context, "GopherPlay_"..curArrayIndex)
ScriptLib.EndTimeAxis(context, "GopherPlay_"..curArrayIndex + 1)
-- 设置所有蘑菇钻地
LF_SetArrayGadgetState(context,GopherPlay.ZeroArray)
if success == true then
-- 成功删除操作台选项操作台进202
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.startId, GopherPlay.OptionId)
ScriptLib.SetGadgetStateByConfigId(context, defs.startId, 202)
else
-- 失败重置回suite 1
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
ScriptLib.SetWorktopOptionsByGroupId(context, 0, defs.startId, {GopherPlay.OptionId})
end
return 0
end
function LF_SummonGopher(context)
-- 召唤地鼠
local currentIndex = ScriptLib.GetGroupTempValue(context, "CurIndex", {})
currentIndex = Fix(currentIndex,GopherArray,"LF_SummonGopher:currentIndex")
local curArrayIndex = ScriptLib.GetGroupTempValue(context, "CurArrayIndex", {})
curArrayIndex = Fix(curArrayIndex,GopherArray[currentIndex],"LF_SummonGopher:curArrayIndex")
local tempArray = GopherArray[currentIndex][curArrayIndex].array
LF_SetArrayGadgetState(context,tempArray)
ScriptLib.PrintContextLog(context, "## TD_GopherPlay : 已成功设置第"..currentIndex.."种,第"..curArrayIndex.."轮的地鼠出场")
-- 记录这一轮有多少大蘑菇,并把tempScore清零
local largeMushroomCount = LF_CalLargeMushroom(context, tempArray)
ScriptLib.SetGroupTempValue(context, "LargeMushroomCount", largeMushroomCount, {})
ScriptLib.SetGroupTempValue(context, "scoreTemp", 0, {})
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: largeMushroomCount = "..largeMushroomCount..", group var scoreTemp is reset to 0")
ScriptLib.SetGroupTempValue(context, "last", 0, {})
return 0
end
function LF_CalLargeMushroom(context, array)
local temp = 0
for i = 1, #array do
if array[i] == 2 then
temp = temp + 1
end
end
return temp
end
function LF_GopherDisappear(context)
-- 地鼠消失
local currentIndex = ScriptLib.GetGroupTempValue(context, "CurIndex", {})
local currentArrayIndex = ScriptLib.GetGroupTempValue(context, "CurArrayIndex", {})
local arrayLens = #GopherArray[currentIndex]
-- 设置所有蘑菇钻地
LF_SetArrayGadgetState(context,GopherPlay.ZeroArray)
ScriptLib.PrintContextLog(context, "## TD_GopherPlay : 已成功设置第"..currentIndex.."轮的地鼠消失" )
local temp = currentArrayIndex + 1
if temp > arrayLens then
temp = 1
end
ScriptLib.SetGroupTempValue(context, "CurArrayIndex", temp, {})
local nextIdx = ScriptLib.GetGroupTempValue(context, "CurArrayIndex", {})
ScriptLib.PrintContextLog(context, "## TD_GopherPlay : current index = "..currentIndex..", next array index = "..nextIdx)
-- 开启下一个时间轴
local timeAxis = GopherArray[currentIndex][nextIdx].time
if #timeAxis ~= 2 then
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: next time axis not allowed")
return 0
end
ScriptLib.PrintContextLog(context, "## TD_GopherPlay: time axis = "..timeAxis[1]..", "..timeAxis[2])
ScriptLib.EndTimeAxis(context, "GopherPlay_"..currentArrayIndex)
ScriptLib.InitTimeAxis(context, "GopherPlay_"..nextIdx, timeAxis, false)
return 0
end
-- 根据给定的Array分别对GopherPlay.ConfigList进行设置
function LF_SetArrayGadgetState(context,array)
for i = 1,#GopherPlay.ConfigList do
local configId = GopherPlay.ConfigList[i]
local index = Fix(i,array,"LF_SetArrayGadgetState:index")
local curState = array[index]
if curState < 0 or curState > 2 then
curState = 0
end
local gadgetState = GopherState[curState]
ScriptLib.PrintContextLog(context, "## TD_GopherPlay : cid -> " .. configId .. " | gadgetState -> " .. gadgetState)
ScriptLib.SetGadgetStateByConfigId(context, configId, gadgetState)
end
return 0
end
function SLC_AddScore(context,evt)
local configId = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
if configId == 0 then
ScriptLib.PrintContextLog(context, "## TD_GopherPlay : SLC_AddScore is called, configId = "..configId..", wrong config id and return immediately")
return 0
end
local before = ScriptLib.GetGroupTempValue(context, "last", {})
ScriptLib.SetGroupTempValue(context, "last", configId, {})
local last = ScriptLib.GetGroupTempValue(context, "last", {})
if before == last then
-- 防止短时间内被打两次
ScriptLib.PrintContextLog(context, "## TD_GopherPlay : SLC_AddScore is called, configId = "..configId..", before = "..before..
", last = "..last..", mushroom is hit twice, ignore second time")
return 0
end
local temp1 = ScriptLib.GetGroupTempValue(context, "score", {})
local temp2 = ScriptLib.GetGroupTempValue(context, "scoreTemp", {})
ScriptLib.SetGroupTempValue(context, "score", temp1 + 1, {})
ScriptLib.SetGroupTempValue(context, "scoreTemp", temp2 + 1, {})
local temp = ScriptLib.GetGroupTempValue(context, "score", {})
ScriptLib.PrintContextLog(context, "## TD_GopherPlay : 成功击碎一枚大箱子,分数+1,当前分数为".. temp)
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据数组的长度修饰num
function Fix(value,array,error)
if value < 1 then
ScriptLib.PrintLog(error .. "value = " .. value)
return 1
end
if value > #array then
ScriptLib.PrintLog(error .. "value = " .. value)
return #array
end
return value
end
LF_Initialize_Level()

View File

@@ -0,0 +1,49 @@
--[[======================================
|| filename: GrapplingHook
|| owner: zijun.ma
|| description: 用于临时让钩爪可以绑定AbilityGroup之后应该弃用。
|| LogName: TD_GrapplingHook
|| Protection:
=======================================]]--
local GrapplingHook=
{
RegionConfigId = 8100001,
GadgetId = 70900403
}
function LF_Initialize_Level_ForHook()
local initRegionConfigId=GrapplingHook.RegionConfigId
local regionRelated = {}
for k,v in ipairs(gadgets) do
local gadgetConfig = v
if gadgetConfig.gadget_id == GrapplingHook.GadgetId then
local gadgetConfigID = gadgetConfig.config_id
-- 插入regions //GrapplingHookSkill_GroupPlay
local insertRegion={ config_id = initRegionConfigId, shape = RegionShape.SPHERE, radius = 30, pos=gadgetConfig.pos, area_id = gadgetConfig.area_id,ability_group_list = { "GrapplingHookSkill_GroupPlay" } }
table.insert(regions,insertRegion)
-- 关联钩爪与region
regionRelated[gadgetConfigID] = {gadgetConfigID = gadgetConfigID,regionConfigID = initRegionConfigId}
-- id+1
initRegionConfigId = initRegionConfigId + 1
end
end
AddRegionInSuite(regionRelated)
end
function Electric_Core_Explain(context)
ScriptLib.MarkPlayerAction(context, 7002, 3, 1)
return 0
end
function AddRegionInSuite(regionRelated)
for i = 1,#suites do
for _k,v in ipairs(suites[i].gadgets) do
if nil ~= regionRelated[v] then
table.insert(suites[i].regions,regionRelated[v].regionConfigID)
end
end
end
end
LF_Initialize_Level_ForHook()
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_0] ---

View File

@@ -0,0 +1,175 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: HookLook
|| owner: zijun.ma
|| description: 钩爪点发射器通用注目
|| LogName: TD_HookLook
|| Protection: [Protection]
=======================================]]
--[[
local RequireSuite = {1}
local HookLookPlay = {
HookPoint = defs.gadget_LookHookCid,
Duration = 3,
}
--]]
local HookLook_Trigger = {
{ keyWord = "HookLook", event = EventType.EVENT_LUA_NOTIFY, source = "RaioFlowerBeHit", trigger_count = 0},
}
function LF_Initialize_HookLook()
local startConfigID = 40040001
for _,v in pairs(HookLook_Trigger) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(HookLook_Trigger,RequireSuite)
return 0
end
--[[=====================================
|| action函数
--======================================]]
function action_HookLook(context, evt)
-- 触发镜头注目,注目位置为坐标(-1747.105336.14543702.49持续时间为3秒并且为强制注目形式不广播其他玩家
if HookLookPlay.HookPoint == nil then
ScriptLib.PrintContextLog(context, "## TD_HookLook Misc 配置非法")
return -1
end
if gadgets[HookLookPlay.HookPoint] == nil then
ScriptLib.PrintContextLog(context, "## TD_HookLook gadgetInfo 配置非法")
return 0
end
if not LF_Owner_is_Nearby(context) then
return 0
end
-- 取所有玩家最近的位置
local gadgetInfo = gadgets[HookLookPlay.HookPoint]
local pos = gadgetInfo.pos
ScriptLib.BeginCameraSceneLook(context,
{
look_pos = pos,
is_allow_input = true,
duration = HookLookPlay.Duration,
is_force = true,
is_broadcast = false,
})
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 检查Owner是否在附近
function LF_Owner_is_Nearby(context)
local ownerUid = ScriptLib.GetSceneOwnerUid(context)
local ownerEid = ScriptLib.GetAvatarEntityIdByUid(context, ownerUid)
local ownerPos = ScriptLib.GetPosByEntityId(context,ownerEid)
-- 配合LUANOTIFY专用
local configId = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
if gadgets[configId] == nil then
return false
end
local targetPos = gadgets[configId].pos
local X = ownerPos.x - targetPos.x
local Y = ownerPos.y - targetPos.y
local Z = ownerPos.z - targetPos.z
local radius = 20
if HookLookPlay.radius ~= nil then
radius = HookLookPlay.radius
end
local msg = "## TD_HookLook : LF_Owner_is_Nearby 距离为 = "
msg = msg .. math.sqrt(X*X+Y*Y+Z*Z)
msg = msg .. "Radius为 = ".. radius
ScriptLib.PrintContextLog(context, msg)
if math.sqrt(X*X+Y*Y+Z*Z) <= radius then
return true
else
return false
end
end
LF_Initialize_HookLook()

View File

@@ -0,0 +1,134 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: LanlaluoCommander
|| owner: zijun.ma
|| description: 兰纳罗指挥输入
|| LogName: TD_LanlaluoCommander
|| Protection: [Protection]
=======================================]]
-- 特定Region或者Group可以写每次EnterRegion会检测
--[[
local defs ={
regionList = {123},
-- 1,2,3,4对应4套等级
curCommander =1,
}
--]]
local LanlaluoCommander_Trigger = {
{ keyWord = "EnterLanlaluoRegion",event = EventType.EVENT_ENTER_REGION, source = "", trigger_count = 0},
{ keyWord = "LeaveLanlaluoRegion",event = EventType.EVENT_LEAVE_REGION, source = "", trigger_count = 0},
}
function LF_Initialize_LanlaluoCommander()
local startConfigID = 50030001
for _,v in pairs(LanlaluoCommander_Trigger) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(LanlaluoCommander_Trigger,{})
return 0
end
--
function action_EnterLanlaluoRegion(context,evt)
if LF_IsTargetRegion(evt.param1) then
ScriptLib.PrintContextLog(context,"##TD_LanlaluoCommander:玩家进入合法区域")
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_LanlaluoCommander", defs.curCommander)
end
return 0
end
function action_LeaveLanlaluoRegion(context,evt)
if LF_IsTargetRegion(evt.param1) then
ScriptLib.PrintContextLog(context,"##TD_LanlaluoCommander:玩家离开合法区域")
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_LanlaluoCommander", 0)
end
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
function LF_IsTargetRegion(regionCid)
for i = 1,#defs.regionList,1 do
if regionCid == defs.regionList[i] then
return true
end
end
return false
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
LF_Initialize_LanlaluoCommander()

View File

@@ -0,0 +1,217 @@
--[[======================================
|| filename: LibraryElevator
|| owner: chen.chen
|| description: 大图书馆电梯
|| LogName: TD
|| Protection: [Protection]
=======================================]]
--[[
定义每个任务环节的电梯锁定情况
local questLockInfo=
{
[1]={
[1]={uplock=true}
[2]={uplock=true,downlock=true }
},
[2]={
[2]={downlock=true }
},
}
]]
local globalInfo=
{
platformConfigId=1001,
routeId=1,
upOption=761,
downOption=762,
lockOption=763,
summonOption=765,
enterFloor=2
}
local floorInfo =
{
[1]={console=1002,arrayPoint=1},
[2]={console=1003,arrayPoint=2},
[3]={console=1004,arrayPoint=3},
}
local floorSummonInfo =
{
[1]={console=1005},
[2]={console=1006},
[3]={console=1007},
}
-- 打印日志
function PrintLog(context, content)
local log = "## [LibraryElevator] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ config_id = 40000001, name = "tri_select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0 },
{ config_id = 40000002, name = "tri_group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 40000003, name = "tri_reach_point", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_EVENT_PLATFORM_REACH_POINT", trigger_count = 0 },
{ config_id = 41000004, name = "tri_variable_change", event = EventType.EVENT_VARIABLE_CHANGE, source = "questUnlockProgress", condition = "", action = "action_VARIABLE_CHANGE", trigger_count = 0 },
}
------ Local Functions -----------
function LF_Initialize_Level()
--- VAR
table.insert(variables, { config_id = 50000001, name = "currentFloor", value = 2,no_refresh = false})
table.insert(variables, { config_id = 50000002, name = "questUnlockProgress", value = 1,no_refresh = true})
--- TRIGGER
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggers) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
return 0
end
function LF_SetConsoleOptions(context,floor)
if floorInfo[floor]==nil then
PrintLog(context, "没有该楼层")
return 0
end
--获取任务进度
local progress=ScriptLib.GetGroupVariableValue(context, "questUnlockProgress")
local consoleConfigId=floorInfo[floor].console
--底层只上向上按钮
if floor==1 then
if questLockInfo[progress]~=nil and questLockInfo[progress][floor]~=nil and questLockInfo[progress][floor].uplock==true then
PrintLog(context, "向上被锁")
else
ScriptLib.SetWorktopOptionsByGroupId(context, 0, consoleConfigId, {globalInfo.upOption})
end
--顶层只上向下按钮
elseif floor==#floorInfo then
if questLockInfo[progress]~=nil and questLockInfo[progress][floor]~=nil and questLockInfo[progress][floor].downlock==true then
PrintLog(context, "向下被锁")
else
ScriptLib.SetWorktopOptionsByGroupId(context, 0, consoleConfigId, {globalInfo.downOption})
end
else
if questLockInfo[progress]~=nil and questLockInfo[progress][floor]~=nil and questLockInfo[progress][floor].uplock==true and questLockInfo[progress][floor].downlock then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, consoleConfigId, {globalInfo.lockOption})
elseif questLockInfo[progress]~=nil and questLockInfo[progress][floor]~=nil and questLockInfo[progress][floor].uplock==true then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, consoleConfigId, {globalInfo.downOption})
elseif questLockInfo[progress]~=nil and questLockInfo[progress][floor]~=nil and questLockInfo[progress][floor].downlock==true then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, consoleConfigId, {globalInfo.upOption})
else
ScriptLib.SetWorktopOptionsByGroupId(context, 0, consoleConfigId, {globalInfo.upOption,globalInfo.downOption})
end
end
--非当前层亮召唤电梯按钮
for i=1,#floorSummonInfo do
if i~=floor then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, floorSummonInfo[i].console, {globalInfo.summonOption})
end
end
return 0
end
function LF_DeleteConsoleOptions(context,floor)
if floorInfo[floor]==nil then
PrintLog(context, "没有该楼层")
return 0
end
local consoleConfigId=floorInfo[floor].console
--全部删一波这里不判断实际的lock情况了感觉得不偿失
ScriptLib.DelWorktopOptionByGroupId(context, 0, consoleConfigId, globalInfo.upOption)
ScriptLib.DelWorktopOptionByGroupId(context, 0, consoleConfigId, globalInfo.downOption)
ScriptLib.DelWorktopOptionByGroupId(context, 0, consoleConfigId, globalInfo.lockOption)
--[[]
if floor==1 then
ScriptLib.DelWorktopOptionByGroupId(context, 0, consoleConfigId, globalInfo.upOption)
elseif floor==#floorInfo then
ScriptLib.DelWorktopOptionByGroupId(context, 0, consoleConfigId, globalInfo.downOption)
else
ScriptLib.DelWorktopOptionByGroupId(context, 0, consoleConfigId, globalInfo.upOption)
ScriptLib.DelWorktopOptionByGroupId(context, 0, consoleConfigId, globalInfo.downOption)
end
]]
--非当前层删召唤电梯按钮
for i=1,#floorSummonInfo do
if i~=floor then
ScriptLib.DelWorktopOptionByGroupId(context, 0, floorSummonInfo[i].console, globalInfo.summonOption)
end
end
return 0
end
function LF_FindSummonLevel(context,configId)
for i=1,#floorSummonInfo do
if floorSummonInfo[i].console==configId then
return i
end
end
PrintLog(context, "召唤楼层未找到")
return -1
end
function LF_MovePlatform(context,fromFloor,toFloor)
ScriptLib.SetGroupVariableValue(context, "currentFloor", toFloor)
ScriptLib.SetPlatformPointArray(context, globalInfo.platformConfigId, globalInfo.routeId, {floorInfo[fromFloor].arrayPoint,floorInfo[toFloor].arrayPoint,}, { route_type = 0 })
return 0
end
------ conditions & actions ------
--任务进度改变刷一下按钮锁定状态
function action_VARIABLE_CHANGE(context, evt)
local curFloor=ScriptLib.GetGroupVariableValue(context, "currentFloor")
LF_DeleteConsoleOptions(context,curFloor)
LF_SetConsoleOptions(context,curFloor)
return 0
end
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.SetGroupVariableValue(context, "currentFloor", 2)
--设置当前层电梯的按钮
LF_SetConsoleOptions(context,globalInfo.enterFloor)
return 0
end
function action_EVENT_PLATFORM_REACH_POINT(context, evt)
PrintLog(context, "action_EVENT_PLATFORM_REACH_POINT")
local curFloor=ScriptLib.GetGroupVariableValue(context, "currentFloor")
LF_SetConsoleOptions(context,curFloor)
return 0
end
function action_EVENT_SELECT_OPTION(context, evt)
local curFloor=ScriptLib.GetGroupVariableValue(context, "currentFloor")
local questStep=ScriptLib.GetGroupVariableValue(context, "questUnlockProgress")
if evt.param2 == globalInfo.downOption then
LF_DeleteConsoleOptions(context,curFloor)
LF_MovePlatform(context,curFloor,curFloor-1)
elseif evt.param2 ==globalInfo.upOption then
LF_DeleteConsoleOptions(context,curFloor)
LF_MovePlatform(context,curFloor,curFloor+1)
elseif evt.param2 ==globalInfo.lockOption then
ScriptLib.ShowReminder(context, 400168)
elseif evt.param2 ==globalInfo.summonOption then
local summonFloor=LF_FindSummonLevel(context,evt.param1)
if summonFloor == -1 then
return 0
end
LF_DeleteConsoleOptions(context,curFloor)
LF_MovePlatform(context,curFloor,summonFloor)
else
PrintLog(context, "按钮触发错误")
end
return 0
end
LF_Initialize_Level()

View File

@@ -0,0 +1,574 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
-- goto 1176 296 -1594
--[[======================================
|| filename: SumeruFarm
|| owner: zijun.ma
|| description: 须弥苗圃玩法
|| LogName: TD_SumeruFarm
|| Protection: [Protection]
=======================================]]
--[[
当下已知问题:
1初始田的任务需要提前领取
2列表需要填对数据
--]]
--[[
goto -217.528 210.144 3658.720
item add 101796 12
quest accept 7301822;
quest finish 7301822;
QUEST CLEAR FATHER 73018;
QUEST CLEAR FATHER 73068;
QUEST CLEAR FATHER 73145;
QUEST CLEAR FATHER 73152;
Group refresh 133301057 1;
Group refresh 133301161 1;
Group refresh 133301162 1;
QUEST ACCEPT 7314502
QUEST Finish 7314502
GROUP SETVAR 133301057 FarmExhibition 8191
GROUP SETVAR 133301057 activecount 13
QUEST ACCEPT 7306805
QUEST ACCEPT 7314501
QUEST Finish 7314501 -- 任务不能同时获取并完成受Group层级影响会收不到消息
QUEST SET_TIMEVAR 73145 1 162311153
QUEST Finish 7315201
QUEST SET_TIMEVAR 73152 1 162311153
level_tag change 38
level_tag change 39
-- QUEST CLEAR FATHER 73157
-- QUEST CLEAR FATHER 73068
-- QUEST Finish 7315701
QUEST State 7315701
-- EXHIBITION REPLACEABLE 11601102
-- GROUP SETVAR 133301057 GM_Reset 1
-- group unload 133301057 1
-- group load 133301057 1
--]]
-- 数据结构
local FarmPlay = {
FirstFarm = defs.gadget_farm13,
FirstCropQuest = 7306805,
SuccessQuest = 7307502,
FirstCropQuestMSG = "73068_FinishQuest",
SeedlingMSG = "SeedingCompleted",
SuccessMSG = "73075_CountFinish",
SuccessKey = "activecount",
ExhibitionKey = "FarmExhibition",
Exhibition = {id = 11601102, key = "Permanent_SumeruNurseryPlay_FarmCount"},
}
local FarmState = {
Hole = 0,
Seedling = 201,
Hide = 202,
CSShowHole = 203,
}
local FarmIndex = {} -- [cid] = index
local QuestIndex = {} -- [questid] = index
local FarmDic = {
[1] = {cid = defs.gadget_farm01, quest = 73146, index = 1},
[2] = {cid = defs.gadget_farm02, quest = 73147, index = 2},
[3] = {cid = defs.gadget_farm03, quest = 73148, index = 3},
[4] = {cid = defs.gadget_farm04, quest = 73149, index = 4},
[5] = {cid = defs.gadget_farm05, quest = 73150, index = 5},
[6] = {cid = defs.gadget_farm06, quest = 73151, index = 6},
[7] = {cid = defs.gadget_farm07, quest = 73152, index = 7},
[8] = {cid = defs.gadget_farm08, quest = 73153, index = 8},
[9] = {cid = defs.gadget_farm09, quest = 73154, index = 9},
[10] = {cid = defs.gadget_farm10, quest = 73155, index = 10},
[11] = {cid = defs.gadget_farm11, quest = 73156, index = 11},
[12] = {cid = defs.gadget_farm12, quest = 73157, index = 12},
[13] = {cid = defs.gadget_farm13, quest = 73145, index = 13},
}
local SumeruFarm_Trigger = {
{ keyWord = "FirstCrop", event = EventType.EVENT_QUEST_START, source = "7306805", trigger_count = 0},
{ keyWord = "PlayerCrop", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", trigger_count = 0},
{ keyWord = "CheckFarm", event = EventType.EVENT_GROUP_LOAD, source = "", trigger_count = 0},
{ keyWord = "CropGrow", event = EventType.EVENT_QUEST_FINISH, source = "", trigger_count = 0},
{ keyWord = "PlayEnd", event = EventType.EVENT_VARIABLE_CHANGE, source = FarmPlay.SuccessKey, trigger_count = 0},
--{ keyWord = "GMReset", event = EventType.EVENT_VARIABLE_CHANGE, source = "GM_Reset", trigger_count = 0},
--{ keyWord = "DelayFarmGrow", event = EventType.EVENT_TIME_AXIS_PASS, source = "DelayFarmGrow", trigger_count = 0},
}
function LF_Initialize_Level()
local startConfigID = 40000001
for _,v in pairs(SumeruFarm_Trigger) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(SumeruFarm_Trigger,{1})
LF_GenFarmIndex()
local var = { config_id= 40000100, name = FarmPlay.ExhibitionKey, value = 0, no_refresh = true }
variables[var.name] = var
local var = { config_id= 40000101, name = "GM_Reset", value = 0, no_refresh = false }
variables[var.name] = var
local var = { config_id= 40000102, name = "QA_Watcher01", value = 0, no_refresh = true }
variables[var.name] = var
return 0
end
-- 生成快速索引(Initialize时使用)
function LF_GenFarmIndex()
for k, v in pairs(FarmDic) do
FarmIndex[v.cid] = k
QuestIndex[v.quest] = k
end
return 0
end
--[[=====================================
|| action函数
--======================================]]
function action_GMReset(context,evt)
-- 重置陈列室
local uid = ScriptLib.GetSceneOwnerUid(context)
-- ScriptLib.ClearExhibitionReplaceableData(context, uid, FarmPlay.Exhibition.key)
LF_KnowQuestState(context)
return 0
end
-- 由任务触发的种植流程
function action_FirstCrop(context,evt)
-- 初始田201
local msg = "## TD_SumeruFarm : 将" .. FarmPlay.FirstFarm
msg = msg .. "的状态切到201"
ScriptLib.PrintContextLog(context, msg)
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm : FirstCrop 将Group切至Suite2")
-- 推送任务消息
ScriptLib.AddQuestProgress(context, FarmPlay.FirstCropQuestMSG)
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm: FirstCrop 任务流转。ID" .. FarmPlay.FirstCropQuestMSG)
ScriptLib.SetGadgetStateByConfigId(context, FarmPlay.FirstFarm, FarmState.Seedling)
-- 全部变成可交互
for i = 1,12 do
if FarmDic[i] ~= nil then
-- 不是已种植状态就重设为可种植状态
if FarmState.Seedling ~= ScriptLib.GetGadgetStateByConfigId(context,0,FarmDic[i].cid) then
ScriptLib.SetGadgetStateByConfigId(context, FarmDic[i].cid, FarmState.Hole)
end
end
end
return 0
end
-- EVENT_GADGET_STATE_CHANGE
function action_PlayerCrop(context,evt)
if evt.param1 ~= FarmState.Seedling or FarmIndex[evt.param2] == nil then
return 0
end
local curIndex = FarmIndex[evt.param2]
local questID = LF_CurFarmMSG(curIndex)
-- 推送对应任务消息
ScriptLib.AddQuestProgress(context, questID)
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm: PlayerCrop 任务流转。ID" .. questID .. "|Index = ".. curIndex)
return 0
end
-- EVENT_GROUP_LOAD
function action_CheckFarm(context,evt)
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm: ## == INITIALIZE 5 == ")
if 1 == LF_GroupDieProgress(context) then
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm : action_CheckFarm| 这个Group要拜拜了")
return 0
end
LF_CheckSeedling(context)
return 0
end
-- EVENT_QUEST_FINISH
function action_CropGrow(context,evt)
if QuestIndex[math.floor(evt.param1/100)] == nil or 1~= evt.param2 then
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm: CropGrow 接收到任务完成 param1 = " .. evt.param1)
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm: CropGrow 接收到任务完成 param2 = " .. evt.param2)
return 0
end
local curFarmIndex = QuestIndex[math.floor(evt.param1/100)]
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm: CropGrow 在线监听到任务完成。 Index = " .. curFarmIndex)
LF_FarmGrow(context,curFarmIndex)
return 0
end
-- 针对计时任务特性的时间轴保底
function action_DelayFarmGrow(context,evt)
local uidList=ScriptLib.GetSceneUidList(context)
if 0 == #uidList then
--当前没有玩家,无法修改陈列室,开启一个时间轴延后处理
ScriptLib.InitTimeAxis(context,"DelayFarmGrow",{1},false)
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm: DelayFarmGrow 未发现玩家,Delay下一秒")
return 0
end
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm: DelayFarmGrow 重新检查一下任务状态")
LF_CheckSeedling(context)
return 0
end
function action_PlayEnd(context,evt)
if 13 > evt.param1 or evt.param1 == evt.param2 then
return 0
end
local levelData = LF_Exhibition_GetLevelData(context)
if 8191 ~= levelData then
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm action_PlayEnd 数据异常,levelData应为8191")
return 0
end
-- 推任务进度
ScriptLib.AddQuestProgress(context, FarmPlay.SuccessMSG)
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm: PlayEnd 任务流转。ID" .. FarmPlay.SuccessMSG)
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
-- 查看指定任务确认Group是否结束自身生命
function LF_GroupDieProgress(context)
local levelData = LF_Exhibition_GetLevelData(context)
if 3 == ScriptLib.GetHostQuestState(context,FarmPlay.SuccessQuest) then
if 8191 ~= levelData then
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm action_PlayEnd 数据异常,levelData应为8191")
return 0
end
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm : action_CheckFarm| 对应玩法已结束")
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 2 })
return 1
end
if 8191 == levelData then
ScriptLib.AddQuestProgress(context, FarmPlay.SuccessMSG)
-- QA监听01
ScriptLib.ChangeGroupVariableValueByGroup(context, "QA_Watcher01", 1, base_info.group_id)
end
return 0
end
-- Todo
function LF_KnowQuestState(context)
msg = "## TD_SumeruFarm : LF_KnowQuestState"
local questStateA = ScriptLib.GetHostQuestState(context,73145)
msg = msg .. " |73145 = " .. questStateA
local questStateA01 = ScriptLib.GetHostQuestState(context,7314501)
msg = msg .. " |7314501 = " .. questStateA01
local questStateA02 = ScriptLib.GetHostQuestState(context,7314502)
msg = msg .. " |7314502 = " .. questStateA02
local questStateB = ScriptLib.GetHostQuestState(context,73068)
msg = msg .. " |73068 = " .. questStateB
local questStateB01 = ScriptLib.GetHostQuestState(context,7306805)
msg = msg .. " |7306805 = " .. questStateB01
local questStateB02 = ScriptLib.GetHostQuestState(context,7306806)
msg = msg .. " |7306806 = " .. questStateB02
ScriptLib.PrintContextLog(context, msg)
return 0
end
-- 检查幼苗田是否需要切状态,同时核对数据是否正确。
function LF_CheckSeedling(context)
local successCount = 0
-- 陈列室复写,不用陈列室不再复写
-- LF_OverrideExhibition(context)
-- 查询bin获取所有已种植list
local levelDataArray = LF_Exhibition_GetLevelDataArray(context)
local msg = "| levelDataArray = " .. LF_ArrayToString(levelDataArray)
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm : LF_CheckSeedling"..msg)
for k,v in pairs(levelDataArray) do
local farmIndex = k
if 0 == v then
local cid = FarmDic[farmIndex].cid
local quest = FarmDic[farmIndex].quest
local state = ScriptLib.GetGadgetStateByConfigId(context, 0, cid)
if 201 == state then
-- 所有201Gadget对应任务若完成切202。
local questState = ScriptLib.GetHostQuestState(context,quest*100+2)
msg = "## TD_SumeruFarm : LF_CheckSeedling quest =" .. quest*100+2
msg = msg .. "|questState = " .. questState
msg = msg .. "|farmIndex = " .. farmIndex
msg = msg .. "|cid = " .. cid
ScriptLib.PrintContextLog(context, msg)
-- 补发推送任务消息
local questID = LF_CurFarmMSG(farmIndex)
ScriptLib.AddQuestProgress(context, questID)
if 3 == questState then
LF_FarmGrow(context,farmIndex)
successCount = successCount + 1
end
end
else
successCount = successCount + 1
end
end
local curSuccessCount = ScriptLib.GetGroupVariableValue(context, FarmPlay.SuccessKey)
if successCount ~= curSuccessCount then
local msg1 = " |successCount = " .. successCount
local msg2 = " |curSuccessCount = " .. curSuccessCount
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm action_CheckFarm 数据异常。" .. msg1 .. msg2)
end
return 0
end
function LF_OverrideExhibition(context)
--获取陈列室值复写到Group上
local uid = ScriptLib.GetSceneOwnerUid(context)
local oldDataDec = ScriptLib.GetExhibitionReplaceableData(context, uid, FarmPlay.Exhibition.id)
local oldLevelDataArray = LF_DecToBin(oldDataDec)
local curLevelDataArray = LF_Exhibition_GetLevelDataArray(context)
local msg = "## TD_SumeruFarm : LF_OverrideExhibition"
msg = msg .. " |oldLevelDataArray = " .. LF_ArrayToString(oldLevelDataArray)
msg = msg .. " |curLevelDataArray = " .. LF_ArrayToString(curLevelDataArray)
ScriptLib.PrintContextLog(context, msg)
for k,v in pairs(oldLevelDataArray) do
if 1 == v and 0 == curLevelDataArray[k] then
curLevelDataArray[k] = 1
end
end
local newLevelDataDec = LF_BinToDec(curLevelDataArray)
local msg = "## TD_SumeruFarm : LF_OverrideExhibition"
msg = msg .. " |oldDataDec = " .. oldDataDec
msg = msg .. " |newLevelDataDec = " .. newLevelDataDec
ScriptLib.PrintContextLog(context, msg)
LF_Exhibition_SetLevelData(context,newLevelDataDec)
return 0
end
function LF_FarmGrow(context,index)
-- 对应田切202
local cid = FarmDic[index].cid
ScriptLib.SetGadgetStateByConfigId(context, cid, FarmState.Hide)
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm : LF_FarmGrow| cid = " .. cid)
-- 计数+1
ScriptLib.ChangeGroupVariableValue(context, FarmPlay.SuccessKey,1)
-- 陈列室写数据
LF_CompleteCurLevel(context,index)
return 0
end
-- 写入指定农田
function LF_CompleteCurLevel(context,index)
local levelData = LF_Exhibition_GetLevelData(context)
local changeLevelData = LF_Exhibition_SetTargetLevel(levelData,index,1)
local msg1 = " |changeLevelDataArray = " .. LF_ArrayToString(LF_DecToBin(changeLevelData))
local msg2 = " | index = " .. index
ScriptLib.PrintContextLog(context, "## TD_SumeruFarm : LF_CompleteCurFarm"..msg1..msg2)
LF_Exhibition_SetLevelData(context,changeLevelData)
return 0
end
function LF_CurFarmMSG(index)
if FarmDic[index] == nil then
ScriptLib.PrintLog("启用错误的Index.index = " .. index)
return "ErrorMessage"
end
return tostring(FarmDic[index].quest).."_"..FarmPlay.SeedlingMSG
end
--[[=====================================
|| 永久陈列室工具包
--======================================]]
-- 写入陈列室值
function LF_Exhibition_SetLevelData(context,levelDataDec)
local curDataDec = ScriptLib.GetGroupVariableValue(context,FarmPlay.ExhibitionKey)
local msg = "## TD_SumeruFarm : LF_Exhibition_SetLevelData"
msg = msg .. " |levelDataDec = " .. levelDataDec
msg = msg .. " |curDataDec = " .. curDataDec
ScriptLib.PrintContextLog(context, msg)
ScriptLib.SetGroupVariableValue(context,FarmPlay.ExhibitionKey,levelDataDec)
return 0
end
-- 返回当前的陈列室值
function LF_Exhibition_GetLevelData(context)
local levelDataDec = ScriptLib.GetGroupVariableValue(context,FarmPlay.ExhibitionKey)
local msg = "## TD_SumeruFarm : LF_Exhibition_GetLevelData"
msg = msg .. " |levelDataDec = " .. levelDataDec
ScriptLib.PrintContextLog(context, msg)
return levelDataDec
end
-- 返回当前的陈列室值导出的数组
function LF_Exhibition_GetLevelDataArray(context)
local levelDataDec = LF_Exhibition_GetLevelData(context)
local levelDataArray = LF_DecToBin(levelDataDec)
return levelDataArray
end
-- 修改bin中指定Index数据
function LF_Exhibition_SetTargetLevel(levelDataDec,targetIndex,value)
local dataArray = LF_DecToBin(levelDataDec)
if value ~= 0 and value ~=1 then
ScriptLib.PrintLog("Error: LF_Exhibition_SetTargetCompelete: value = " .. value)
value = 0
end
-- 指定关卡设为完成
dataArray[targetIndex] = value
local changeLevelData = LF_BinToDec(dataArray)
return changeLevelData
end
-- 通过bin查询对应Index的关卡情况
function LF_Exhibition_CheckTargetComplete(targetIndex,levelDataDec)
local dataArray = LF_DecToBin(levelDataDec)
if targetIndex == 0 or nil == dataArray[targetIndex] then
local msg1 = " |dataArray = " .. LF_ArrayToString(dataArray)
local msg2 = " | index = " .. targetIndex
ScriptLib.PrintLog("Error: LF_Exhibition_CheckTargetCompelete" .. msg1 .. msg2)
return 0
end
if dataArray[targetIndex] == 0 then
return 0
end
return 1
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据数组的长度修饰num
function Fix(value,array,error)
local arrayType= type(array)
if arrayType ~= "table" then
ScriptLib.PrintLog(error .. "array 非法")
return 1
end
local valueType= type(value)
if valueType ~= "number" then
ScriptLib.PrintLog(error .. "value 非法")
return 1
end
if value < 1 then
ScriptLib.PrintLog(error .. "value = " .. value)
return 1
end
if value > #array then
ScriptLib.PrintLog(error .. "value = " .. value)
return #array
end
return value
end
-- 顺序0,1数组转十进制保存
function LF_BinToDec(binArray)
local decValue = 0
local bin = table.concat(binArray)
decValue = tonumber(bin,2)
return decValue
end
-- 十进制转成0,1数组位数对应为1~13
function LF_DecToBin(decValue)
local binArray = {}
local value = decValue
local bit = 13 -1 --按需设置对应位数,当前需要13个数据
for i = bit,0,-1 do
binArray[#binArray+1] = math.floor(value/2^i)
value = value % 2^i
end
return binArray
end
LF_Initialize_Level()

View File

@@ -0,0 +1,356 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
-- goto 1176 296 -1594
--[[======================================
|| filename: SumeruFarmSub
|| owner: zijun.ma
|| description: 须弥苗圃玩法(附属梦见花/甜甜花控制)
|| LogName: TD_SubSumeruFarm
|| Protection: [Protection]
=======================================]]
-- 数据结构
local FarmPlay = {
Exhibition = {id = 11601102, key = "Permanent_SumeruNurseryPlay_FarmCount"},
ExhibitionVar = "ExhibitionVar",
SuccessQuest = 7307502,
}
local FlowerState = {
Show = 0,
Hide = 201,
}
local QuestIndex = {} -- [questid] = index
local FlowerDic = {
[1] = { cidList = defs.flowerList01, quest = 73146, index = 1},
[2] = { cidList = defs.flowerList02, quest = 73147, index = 2},
[3] = { cidList = defs.flowerList03, quest = 73148, index = 3},
[4] = { cidList = defs.flowerList04, quest = 73149, index = 4},
[5] = { cidList = defs.flowerList05, quest = 73150, index = 5},
[6] = { cidList = defs.flowerList06, quest = 73151, index = 6},
[7] = { cidList = defs.flowerList07, quest = 73152, index = 7},
[8] = { cidList = defs.flowerList08, quest = 73153, index = 8},
[9] = { cidList = defs.flowerList09, quest = 73154, index = 9},
[10] = { cidList = defs.flowerList10, quest = 73155, index = 10},
[11] = { cidList = defs.flowerList11, quest = 73156, index = 11},
[12] = { cidList = defs.flowerList12, quest = 73157, index = 12},
[13] = { cidList = defs.flowerList13, quest = 73145, index = 13},
}
local SumeruFlower_Trigger = {
{ keyWord = "CheckAllFlower", event = EventType.EVENT_GROUP_LOAD, source = "", trigger_count = 0},
{ keyWord = "CheckHarvest", event = EventType.EVENT_QUEST_FINISH, source = "", trigger_count = 0},
}
function LF_Initialize_Level()
local startConfigID = 40010001
for _,v in pairs(SumeruFlower_Trigger) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(SumeruFlower_Trigger,{1})
LF_GenFlowerIndex()
local var = { config_id= 40010101, name = FarmPlay.ExhibitionVar, value = 0, no_refresh = true }
variables[var.name] = var
return 0
end
-- 生成快速索引(Initialize时使用)
function LF_GenFlowerIndex()
for k, v in pairs(FlowerDic) do
QuestIndex[v.quest] = k
end
return 0
end
--[[=====================================
|| action函数
--======================================]]
-- EVENT_GROUP_LOAD
function action_CheckAllFlower(context,evt)
ScriptLib.PrintContextLog(context, "## TD_SubSumeruFarm: ## == INITIALIZE 5 == ")
LF_CheckFlower(context)
return 0
end
-- EVENT_QUEST_FINISH
function action_CheckHarvest(context,evt)
if QuestIndex[math.floor(evt.param1/100)] == nil or 1~= evt.param2 then
ScriptLib.PrintContextLog(context, "## TD_SubSumeruFarm: CropGrow 接收到任务完成 param1 = " .. evt.param1)
ScriptLib.PrintContextLog(context, "## TD_SubSumeruFarm: CropGrow 接收到任务完成 param2 = " .. evt.param2)
return 0
end
local curFlowerIndex = QuestIndex[math.floor(evt.param1/100)]
ScriptLib.PrintContextLog(context, "## TD_SubSumeruFarm: CropGrow 在线监听到任务完成。 Index = " .. curFlowerIndex)
LF_FlowerShow(context,curFlowerIndex)
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
-- 检查幼苗田是否需要切状态,同时核对数据是否正确。
function LF_CheckFlower(context)
if 3 == ScriptLib.GetHostQuestState(context,FarmPlay.SuccessQuest) then
-- 特定任务已经完成
LF_FarmSubComplete(context)
LF_FarmProtect(context)
return 0
end
-- 查询bin获取所有已种植list
local levelData = LF_GetCurLevelData(context)
local exhibitionData = LF_Exhibition_GetLevelData(context)
if levelData ~= exhibitionData then
local exhibitionDataArray = LF_DecToBin(exhibitionData)
local levelDataArray = LF_DecToBin(levelData)
local msg = "## TD_SubSumeruFarm : LF_CheckFlower 数据不一致"
msg = msg .. " |levelDataArray = " .. LF_ArrayToString(levelDataArray)
msg = msg .. " |exhibitionDataArray = " .. LF_ArrayToString(exhibitionDataArray)
ScriptLib.PrintContextLog(context, msg)
-- 若本地与陈列室数据不一致,将未解锁的花解锁出来
for k,v in pairs(exhibitionDataArray) do
if v == 1 and levelDataArray[k] ~= 1 then
local msg = "## TD_SubSumeruFarm : LF_CheckFlower 正在修改Index"
msg = msg .. " |index = " .. k
ScriptLib.PrintContextLog(context, msg)
LF_FlowerShow(context,k)
end
end
end
LF_FarmProtect(context)
return 0
end
-- Sub只听自身Group的指挥
function LF_FlowerShow(context,index)
-- 对应田切202
local cidlist = FlowerDic[index].cidList
ScriptLib.PrintContextLog(context, "## TD_SubSumeruFarm : LF_FlowerShow| cidlist = " .. LF_ArrayToString(cidlist))
for k, v in pairs(cidlist) do
ScriptLib.PrintContextLog(context, "## TD_SubSumeruFarm : LF_FlowerShow| cid = " .. v)
ScriptLib.SetGadgetStateByConfigId(context, v, FlowerState.Show)
end
-- 更新本地陈列室数据
LF_CompleteCurLevel(context,index)
return 0
end
-- 对本地GVV存档进行修改
function LF_CompleteCurLevel(context,index)
local levelData = LF_GetCurLevelData(context)
local changeLevelData = LF_SetTargetLevel(levelData,index,1)
local msg1 = " |changeLevelDataArray = " .. LF_ArrayToString(LF_DecToBin(changeLevelData))
local msg2 = " | index = " .. index
ScriptLib.PrintContextLog(context, "## TD_SubSumeruFarm : LF_CompleteCurFarm"..msg1..msg2)
LF_SetCurLevelData(context,changeLevelData)
return 0
end
-- 当特定任务完成后检查对应GadgetState
function LF_FarmSubComplete(context)
local levelData = LF_GetCurLevelData(context)
if 8191 == levelData then
ScriptLib.PrintContextLog(context, "## TD_SubSumeruFarm LF_CheckMissionOver 关卡已完成")
return 0
end
-- 逐一将所有花设为已完成
local levelDataArray = LF_DecToBin(levelData)
for k,v in pairs(levelDataArray) do
if v == 0 then
local msg = "## TD_SubSumeruFarm : LF_FarmSubComplete 正在修改Index"
msg = msg .. " |index = " .. k
ScriptLib.PrintContextLog(context, msg)
LF_FlowerShow(context,k)
end
end
return 0
end
-- 苗圃种植保护
function LF_FarmProtect(context)
-- 遍历所有植物设置状态
local levelData = LF_GetCurLevelData(context)
local levelDataArray = LF_DecToBin(levelData)
for k,v in pairs(levelDataArray) do
if v == 1 then
local msg = "## TD_SubSumeruFarm : LF_FarmProtect 保护需要设置的状态"
msg = msg .. " |index = " .. k
ScriptLib.PrintContextLog(context, msg)
local cidlist = FlowerDic[k].cidList
for k1, v1 in pairs(cidlist) do
if ScriptLib.CheckIsInGroup(context, 0, v1) == true then
ScriptLib.PrintContextLog(context, "## TD_SubSumeruFarm : LF_FarmProtect| cid = " .. v1)
ScriptLib.SetGadgetStateByConfigId(context, v1, FlowerState.Show)
end
end
end
end
end
--[[=====================================
|| 永久陈列室工具包
--======================================]]
-- 获取Group上的bin
function LF_GetCurLevelData(context)
local levelData = ScriptLib.GetGroupVariableValueByGroup(context, FarmPlay.ExhibitionVar,0)
return levelData
end
-- 写入Group上的bin
function LF_SetCurLevelData(context,levelData)
ScriptLib.SetGroupVariableValueByGroup(context, FarmPlay.ExhibitionVar,levelData,0)
return 0
end
-- 修改bin中指定Index数据
function LF_SetTargetLevel(levelDataDec,targetIndex,value)
local dataArray = LF_DecToBin(levelDataDec)
if value ~= 0 and value ~=1 then
ScriptLib.PrintLog("Error: LF_Exhibition_SetTargetCompelete: value = " .. value)
value = 0
end
-- 指定关卡设为完成
dataArray[targetIndex] = value
local changeLevelData = LF_BinToDec(dataArray)
return changeLevelData
end
-- 返回当前的陈列室值
function LF_Exhibition_GetLevelData(context)
local levelDataDec = ScriptLib.GetGroupVariableValueByGroup(context, "FarmExhibition", 133301057)
local msg = "## TD_SubSumeruFarm : LF_Exhibition_GetLevelData"
msg = msg .. " |levelDataDec = " .. levelDataDec
ScriptLib.PrintContextLog(context, msg)
return levelDataDec
end
-- 返回当前的陈列室值导出的数组
function LF_Exhibition_GetLevelDataArray(context)
local levelDataDec = LF_Exhibition_GetLevelData(context)
local levelDataArray = LF_DecToBin(levelDataDec)
return levelDataArray
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据数组的长度修饰num
function Fix(value,array,error)
if value < 1 then
ScriptLib.PrintLog(error .. "value = " .. value)
return 1
end
if value > #array then
ScriptLib.PrintLog(error .. "value = " .. value)
return #array
end
return value
end
-- 顺序0,1数组转十进制保存
function LF_BinToDec(binArray)
local decValue = 0
local bin = table.concat(binArray)
decValue = tonumber(bin,2)
return decValue
end
-- 十进制转成0,1数组位数对应为1~13
function LF_DecToBin(decValue)
local binArray = {}
local value = decValue
local bit = 13 -1 --按需设置对应位数,当前需要13个数据
for i = bit,0,-1 do
binArray[#binArray+1] = math.floor(value/2^i)
value = value % 2^i
end
return binArray
end
LF_Initialize_Level()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
--[[======================================
|| filename: Test_ServerVisionType
|| owner: siyu.li
|| description: 测试group加载的性能优化,代替工具功能
|| LogName:
|| Protection:
=======================================]]
function Initialize()
regions[63001].is_trigger_reload_group = true
end
Initialize()

View File

@@ -0,0 +1,515 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: TitanElevator
|| owner: zijun.ma
|| description: 泰坦机器人的电梯管理系统
|| LogName: TD_Elevator
|| Protection: [Protection]
=======================================]]
--[[
goto -1557 235 2338
group unload 133304011;
group load 133304011
group refresh 133304011 1;
GROUP SETVAR 133304011 1F 1;
GROUP SETVAR 133304011 2F 1;
GROUP SETVAR 133304011 3F 1
GROUP SETVAR 133304011 1F 0;
GROUP SETVAR 133304011 2F 0;
GROUP SETVAR 133304011 3F 0
--]]
--[[
local LevelInfo = {
ELCid = defs.gadget_ELCid,
GearCidList = { defs.gadget_GearCid01,defs.gadget_GearCid02,defs.gadget_GearCid03 }, -- defs.GearCid//务必按照电梯最底层排序到电梯最上层
GearIDList = { 780, 781, 782}, -- defs.GearId//对应去操作台第几层,ID不准重复
PassVarList = {"1F","2F","3F"}, -- 对应电梯是否解锁
RouteList = {
[1] = {
[1] = 0,
[2] = 330400003,
[3] = 330400013,
},
[2] = {
[1] = 330400004,
[2] = 0,
[3] = 330400011,
},
[3] = {
[1] = 330400014,
[2] = 330400012,
[3] = 0,
},
}
}
--]]
local VarInfo = {
-- 值String
CurStep = "CurPlayStep",
CurELPos = "CurELPos",
TargetPos = "TargetPos",
}
local PlayStep = {
Init = 0, -- 电梯无目标。操作台可用。
Come = 1, -- 操作台不可用。End状态下可能会进入
Wait = 2, -- 电梯有目标玩家进入后Start。操作台可用。
Start = 3, -- 电梯有目标。操作台不可用。抵达楼层后进入End。
}
local ObjState = {
Elevator = { Deactivate = 0, Active = 201, Check = 202 },
Switch = {Deactivate = 0, Active = 201, Runing = 202}
}
local Tri_TitanElevator = {
-- 检查Event
{ keyWord = "GadgetCheck",event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", trigger_count = 0},
-- GroupLoad
{ keyWord = "ELInit",event = EventType.EVENT_GROUP_LOAD, source = "", trigger_count = 0},
-- 电梯抵达
{ keyWord = "ELReach", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", trigger_count = 0},
-- 电梯开始移动时
{ keyWord = "ELMove", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", trigger_count = 0},
-- 按钮
{ keyWord = "PressButton", event = EventType.EVENT_SELECT_OPTION, source = "", trigger_count = 0},
-- 电梯Key改变时
{ keyWord = "PassChange", event = EventType.EVENT_VARIABLE_CHANGE, source = "", trigger_count = 0},
}
function LF_Initialize_TitanElevator()
local startConfigID = 50020001
for _,v in pairs(Tri_TitanElevator) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(Tri_TitanElevator,{1})
local var = { config_id= 50020101, name = VarInfo.CurStep, value = 0, no_refresh = false } -- 步骤计数器
variables[var.name] = var
local var = { config_id= 50020102, name = VarInfo.CurELPos, value = 1, no_refresh = false } -- 电梯层数
variables[var.name] = var
local var = { config_id= 50020103, name = VarInfo.TargetPos, value = 0, no_refresh = false } -- 电梯层数
variables[var.name] = var
return 0
end
function action_GadgetCheck(context,evt)
ScriptLib.PrintContextLog(context, "## TD_Elevator GadgetCheck| configID = " .. evt.param2 .. " 的状态被修改为" .. evt.param1 )
return 0
end
-- GroupLoad
function action_ELInit(context,evt)
ScriptLib.SetGroupVariableValue(context, VarInfo.TargetPos, 0)
ScriptLib.SetGroupVariableValue(context, VarInfo.CurELPos, 1)
LF_SetPlayStep(context,PlayStep.Init,"action_ELInit")
LF_SetAllELOption(context)
return 0
end
-- EVENT_PLATFORM_ARRIVAL
function action_ELReach(context,evt)
if LevelInfo.ELCid ~= evt.param1 then
return 0
end
if LF_CheckPlayStep(context,{PlayStep.Come},"action_ELReach 01") then
LF_SetPlayStep(context,PlayStep.Wait,"action_ELReach 02")
-- 电梯进入检查模式
ScriptLib.SetGadgetStateByConfigId(context, LevelInfo.ELCid, ObjState.Elevator.Check)
-- 操作台全启
LF_SetAllELOption(context)
return 0
end
if LF_CheckPlayStep(context,{PlayStep.Start},"action_ELReach 02") then
LF_SetPlayStep(context,PlayStep.Init,"action_ELReach 02")
-- 电梯静默
ScriptLib.SetGadgetStateByConfigId(context, LevelInfo.ELCid, ObjState.Elevator.Deactivate)
-- 操作台全启
LF_SetAllELOption(context)
return 0
end
return 0
end
-- EVENT_GADGET_STATE_CHANGE
function action_ELMove(context,evt)
if evt.param1 ~= ObjState.Elevator.Active or evt.param2 ~= LevelInfo.ELCid then
return 0
end
if not LF_CheckPlayStep(context,{PlayStep.Wait},"action_ELMove") then
return 0
end
local curELPos = ScriptLib.GetGroupVariableValue(context, VarInfo.CurELPos)
local curELTarget = ScriptLib.GetGroupVariableValue(context, VarInfo.TargetPos)
local routeID = LF_GetRouteID(curELPos,curELTarget)
if -1 == ScriptLib.SetPlatformRouteId(context, LevelInfo.ELCid, routeID) then
ScriptLib.PrintContextLog(context, "## TD_Elevator : action_ELMove 电梯设置没成功拿到的routeID为" .. routeID)
return 0
end
LF_DelAllELOption(context)
ScriptLib.SetGroupVariableValue(context, VarInfo.CurELPos, curELTarget)
ScriptLib.SetGroupVariableValue(context, VarInfo.TargetPos, 0)
ScriptLib.StartPlatform(context, LevelInfo.ELCid)
LF_SetPlayStep(context,PlayStep.Start,"action_ELMove")
return 0
end
-- EVENT_SELECT_OPTION
function action_PressButton(context,evt)
local gearCid = evt.param1
-- 确认是第几层操作台
local curGearPos = LF_GetIndexInTable(gearCid,LevelInfo.GearCidList)
if curGearPos <= 0 then
return 0
end
ScriptLib.SetGadgetStateByConfigId(context, gearCid, ObjState.Switch.Runing)
local targetPos = LF_GetIndexInTable(evt.param2,LevelInfo.GearIDList)
ScriptLib.PrintContextLog(context, "## TD_Elevator action_PressButton: Cid" .. gearCid .. "|Gear:" .. evt.param2 .. "|targetPos:" .. targetPos)
-- 确认现在状态
if LF_CheckPlayStep(context,{PlayStep.Init, PlayStep.Wait},"action_PressButton") then
-- 确认是否要Come
local curELPos = ScriptLib.GetGroupVariableValue(context, VarInfo.CurELPos)
if curELPos == curGearPos then
ScriptLib.PrintContextLog(context, "## TD_Elevator action_PressButton: 当前电梯在同楼层")
if LF_CheckPlayStep(context,{PlayStep.Init},"action_PressButton") then
ScriptLib.PrintContextLog(context, "## TD_Elevator action_PressButton: 这个操作台是Init")
-- 当前就是目标楼层
LF_SetPlayStep(context,PlayStep.Wait,"action_PressButton")
-- 电梯进入检查模式
ScriptLib.SetGadgetStateByConfigId(context, LevelInfo.ELCid, ObjState.Elevator.Check)
end
-- 修改前往的地方
ScriptLib.SetGroupVariableValue(context, VarInfo.TargetPos, targetPos)
-- 刷新操作台
LF_DelELOption(context, gearCid)
LF_SetELOption(context, gearCid)
else
ScriptLib.PrintContextLog(context, "## TD_Elevator action_PressButton: 当前电梯不在同楼层")
-- 操作台无了
LF_DelAllELOption(context)
-- 电梯开始移动
local routeID = LF_GetRouteID(curELPos,curGearPos)
if -1 == ScriptLib.SetPlatformRouteId(context, LevelInfo.ELCid, routeID) then
ScriptLib.PrintContextLog(context, "## TD_Elevator action_PressButton: 电梯设置没成功拿到的routeID为" .. routeID)
end
-- 电梯移动
ScriptLib.StartPlatform(context, LevelInfo.ELCid)
-- 电梯切换为激活模式
ScriptLib.SetGadgetStateByConfigId(context, LevelInfo.ELCid, ObjState.Elevator.Active)
-- 转阶段
LF_SetPlayStep(context,PlayStep.Come,"action_PressButton")
-- 参数变化
ScriptLib.SetGroupVariableValue(context, VarInfo.CurELPos, curGearPos)
ScriptLib.SetGroupVariableValue(context, VarInfo.TargetPos, targetPos)
end
return 0
end
return 0
end
function action_PassChange(context,evt)
local varName = evt.source_name
if not LF_IsInTable(varName,LevelInfo.PassVarList) then
return 0
end
if evt.param1 == evt.param2 or evt.param1 < 0 then
return 0
end
--修改对应物件
if LF_CheckPlayStep(context,{PlayStep.Init,PlayStep.Wait},"action_PassChange") then
LF_DelAllELOption(context)
LF_SetAllELOption(context)
end
return 0
end
--[[=====================================
|| LocalFunction
--======================================]]
function LF_GetRouteID(curPos,targetPos)
local tempCurPos = Fix(curPos,LevelInfo.RouteList,"LF_GetRouteID")
local curRouteList = LevelInfo.RouteList[tempCurPos]
local tempTarget = Fix(targetPos,curRouteList,"LF_GetRouteID")
local routeID = curRouteList[tempTarget]
return routeID
end
-- 获取所有钥匙数据
function LF_GetKeyList(context)
local curKeyList = {}
for i = 1,#LevelInfo.PassVarList do
local curkey = ScriptLib.GetGroupVariableValue(context, LevelInfo.PassVarList[i])
curKeyList[i] = curkey
end
ScriptLib.PrintContextLog(context, "## TD_Elevator 当前KeyList为" .. LF_ArrayToString(curKeyList))
return curKeyList
end
function LF_CheckUnLock(context,curKeyList,index)
local tempIndex = Fix(index,curKeyList,"检查前往的电梯是否已解锁")
if curKeyList[tempIndex] > 0 then
return true
end
return false
end
function LF_CheckGearEnable(context,fromPos,targetPos)
local curPos = ScriptLib.GetGroupVariableValue(context, VarInfo.CurELPos)
local curTargetPos = ScriptLib.GetGroupVariableValue(context, VarInfo.TargetPos)
if fromPos ~= targetPos and (curPos ~= fromPos or curTargetPos ~= targetPos) then
return true
end
return false
end
function LF_GetGearID(index)
local idIndex = Fix(index,LevelInfo.GearIDList,"LF_SetAllELOption 根据Index拿对应的gearid")
local gearID = LevelInfo.GearIDList[idIndex]
return gearID
end
-- 所有机关上操作台
function LF_SetAllELOption(context)
local curKeyList = LF_GetKeyList(context)
local unlockShiled= false
-- 借助这个取一下当前已经操作的操作台,不用重复创建
for i = 1,#LevelInfo.GearCidList do
local curGear = LevelInfo.GearCidList[i]
local isUnlock_i = LF_CheckUnLock(context,curKeyList,i)
local gearList = {}
if isUnlock_i then
for j = 1,#LevelInfo.GearCidList do
local isUnlock_j = LF_CheckUnLock(context,curKeyList,j)
local gearEnable = LF_CheckGearEnable(context,i,j)
-- 检查前往的电梯是否已解锁
-- 判断是否已经设置了电梯前往目标楼层
if isUnlock_j and gearEnable then
local gearID = LF_GetGearID(j)
table.insert(gearList, gearID)
end
end
if #gearList>0 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, curGear, gearList)
ScriptLib.SetGadgetStateByConfigId(context, curGear, ObjState.Switch.Active)
unlockShiled = true
ScriptLib.PrintContextLog(context, "## TD_Elevator LF_SetAllELOption: 当前操作台" .. curGear .. "设置成功")
else
ScriptLib.SetGadgetStateByConfigId(context, curGear, ObjState.Switch.Deactivate)
ScriptLib.PrintContextLog(context, "## TD_Elevator LF_SetAllELOption: 当前操作台" .. curGear .. "无指令可用")
end
else
ScriptLib.SetGadgetStateByConfigId(context, curGear, ObjState.Switch.Deactivate)
ScriptLib.PrintContextLog(context, "## TD_Elevator LF_SetAllELOption: 当前操作台" .. curGear .. "未解锁")
end
end
-- 确认是否解锁光罩
if unlockShiled then
ScriptLib.AddExtraGroupSuite(context, 0, 2)
end
return 0
end
-- 目标机关上操作台
function LF_SetELOption(context,cid)
local curKeyList = LF_GetKeyList(context)
local curGear = cid
-- 确认是第几层操作台
local curGearPos = LF_GetIndexInTable(curGear,LevelInfo.GearCidList)
local isUnlock_From = LF_CheckUnLock(context,curKeyList,curGearPos)
if curGearPos <= 0 then
ScriptLib.PrintContextLog(context, "## TD_Elevator LF_SetELOption: 操作不是电梯的操作台")
return 0
end
if not isUnlock_From then
ScriptLib.PrintContextLog(context, "## TD_Elevator LF_SetAllELOption: 当前操作台" .. curGear .. "未解锁")
end
local gearList = {}
for j = 1,#LevelInfo.GearIDList do
local isUnlock_To = LF_CheckUnLock(context,curKeyList,j)
local gearEnable = LF_CheckGearEnable(context,curGearPos,j)
-- 检查前往的电梯是否已解锁
-- 判断是否已经设置了电梯前往目标楼层
if isUnlock_To and gearEnable then
local gearID = LF_GetGearID(j)
table.insert(gearList, gearID)
end
end
if #gearList>0 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, curGear, gearList)
else
ScriptLib.PrintContextLog(context, "## TD_Elevator LF_SetELOption: 当前操作台" .. curGear .. "无指令可用")
end
return 0
end
-- 删除机关全部操作台
function LF_DelAllELOption(context)
for i = 1,#LevelInfo.GearCidList do
local curGear = LevelInfo.GearCidList[i]
for j = 1,#LevelInfo.GearIDList do
local gear = LevelInfo.GearIDList[j]
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, curGear, gear)
end
end
return 0
end
-- 删除目标机关全部操作台
function LF_DelELOption(context,cid)
local curGear = cid
for j = 1,#LevelInfo.GearIDList do
local gear = LevelInfo.GearIDList[j]
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, curGear, gear)
end
return 0
end
-- 步骤检查
function LF_CheckPlayStep(context,phase,functionName)
local curPlayStep = ScriptLib.GetGroupVariableValue(context, VarInfo.CurStep)
for _,v in pairs(phase) do
if v == curPlayStep then
ScriptLib.PrintContextLog(context, "## TD_Elevator From:" .. functionName .." || 当前[Phase:".. curPlayStep .."]符合目标进度" ..LF_ArrayToString(phase) )
return true
end
end
ScriptLib.PrintContextLog(context, "## TD_Elevator From:" .. functionName .." || 当前[Phase:".. curPlayStep .."]不符合目标进度" .. LF_ArrayToString(phase) .."!!!" )
return false
end
-- 步骤设置
function LF_SetPlayStep(context,phase,functionName)
ScriptLib.SetGroupVariableValue(context, VarInfo.CurStep, phase)
ScriptLib.PrintContextLog(context, "## TD_Elevator From" .. functionName .." || 流程进度变化,当前[Phase:"..phase .."]" )
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for _,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for _,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for _,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for _,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据数组的长度修饰num
function Fix(value,array,error)
if value < 1 then
ScriptLib.PrintLog(error .. "value = " .. value)
return 1
end
if value > #array then
ScriptLib.PrintLog(error .. "value = " .. value)
return #array
end
return value
end
-- 判断特定值是否在Table中
function LF_IsInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return true
end
end
return false
end
-- 返回特定值在Table中的第一个位置
function LF_GetIndexInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return k
end
end
return 0
end
LF_Initialize_TitanElevator()

View File

@@ -0,0 +1,986 @@
--[[======================================
|| filename: TitanEnergy
|| owner: shuyi.chang
|| description: 泰坦内舱能量玩法
|| LogName: ## [TitanEnergy]
|| Protection:
=======================================]]
--[[
local defs = {
-- 【特别注意】所有流程必需的machine必须放在suite1中在电池全亮后自动开启
-- 【特别注意】探索性质的machine必须放在suite2中在电池全亮后不会自动开启
-- 【特别注意】只有suite1会在group load时加载
maxPlayerEnergyLev = 3,
-- 出了这个区域整个玩法就被reset了
titanRegion = 42017,
-- todo: 保底判断一下各个位置的config id对应的是否是正确的gadget id
cells = {
-- 每一项均需严格遵循下述格式没有line或者node则留空不能不创建
-- [cell_config_id] = {cell = cell_config_id, lines = {line01_config_id, line02_config_id, ...}, nodes = {node01_config_id, ...}}
[42002] = {cell = 42002, lines = {42003, 42004}, nodes = {42007}},
[42006] = {cell = 42006, lines = {42005}, nodes = {42007}},
[42018] = {cell = 42018, lines = {42003}, nodes = {}},
[42019] = {cell = 42019, lines = {42021, 42022}, nodes = {}},
[42020] = {cell = 42020, lines = {42021}, nodes = {}},
},
-- 指定初始激活的电池id未指定则默认初始未激活
activeCells = {42002},
}
--]]
local extraTriggers =
{
{ config_id = 50000001, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_ENTER_REGION", trigger_count = 0 },
{ config_id = 50000002, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_GROUP_LOAD", trigger_count = 0 },
{ config_id = 50000003, name = "CELL_INTERACT", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_CELL_INTERACT", trigger_count = 0 },
{ config_id = 50000004, name = "MACHINE_INTERACT", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_MACHINE_INTERACT", trigger_count = 0 },
{ config_id = 50000005, name = "ENERGY_PICKUP", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_ENERGY_PICKUP", trigger_count = 0 },
{ config_id = 50000006, name = "VARIABLE_CHANGE", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_VARIABLE_CHANGE", trigger_count = 0 },
{ config_id = 50000007, name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_LEAVE_REGION", trigger_count = 0 },
{ config_id = 50000008, name = "GROUP_WILL_UNLOAD", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_GROUP_WILL_UNLOAD", trigger_count = 0 },
{ config_id = 50000009, name = "TIME_AXIS_PASS", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_TIME_AXIS_PASS", trigger_count = 0 },
}
local extraVariables =
{
-- 记录玩家身上有几格能量
{ config_id = 50000101, name = "playerEnergyLevel", value = 0, no_refresh = true },
-- 已经激活几节电池
{ config_id = 50000102, name = "activeCellNum", value = 0, no_refresh = true },
-- 已经激活几个机关,目前没什么用
{ config_id = 50000103, name = "activeMachineNum", value = 0, no_refresh = true },
-- 0不能开始 1可以开始但是未开始 2已开始 3已完成
{ config_id = 50000104, name = "groupStatus", value = 0, no_refresh = true },
-- 【弃用】是否所有电池都已经激活
{ config_id = 50000105, name = "allFinished", value = 0, no_refresh = true },
-- 【弃用】控制此group的玩法能否开启0为关闭1为开启初始默认为0关闭
{ config_id = 50000106, name = "enabled", value = 0, no_refresh = true },
}
local machineGadgetIds = {
-- key表示这个机器需要几格能量才能开启
[1] = 70350439,
[2] = 70350440,
[3] = 70350441,
}
local cellGadgetId = 70350442
local nodeGadgetId = 70350446
local stoneGadgetId = 70350449
local lineGadgetIds = {
70350443,
70350444,
70350445,
}
-- 都是常量记一下各个类别的gadget
local stones = {}
local lines = {}
local nodes = {}
local machines = {}
-- 这里的机关单指suite1中玩法必需的机关
local questMachines = {}
local cellCount
-- worktop option表中对应充能和回收的id
local worktopOpt = {
charge = 35,
recycle = 69,
collect = 68,
}
local abilityGroup = "ActivityAbility_TitanEnergy"
local reminderTable =
{
playerFull = 60010321, -- 【玩家拥有的能量到达最大值】好了,去下一处吧!
}
-- 能量机关交互后等1s再上新选项
local optionCd = 1
--================================================================
-- Local Functions
--================================================================
function LF_Initialize_Group(triggers, suites, variables, gadgets, regions)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
end
-- add triggers to suite
for i = 1, #extraTriggers do
table.insert(suites[1].triggers,extraTriggers[i].name)
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
LF_InitiateLuaVariables(gadgets, suites, variables)
-- 用于玩家身上特效的ability group
regions[defs.titanRegion].team_ability_group_list = {abilityGroup}
end
function LF_InitiateLuaVariables(gadgets, suites, variables)
local temp = 0
for i, v in pairs(gadgets) do
-- check the number of machines
for k, j in pairs(machineGadgetIds) do
-- is machine
if v.gadget_id == j then
temp = temp + 1
-- group variable记录这个机关有几格能量
local machineEnergyLev = { config_id = 50000006 + temp, name = tostring(i), value = 0, no_refresh = true }
table.insert(variables, machineEnergyLev)
-- all machines
table.insert(machines, i)
-- only quest machines
-- 用所在suite判断
for n = 1, #suites[1].gadgets do
if v.config_id == suites[1].gadgets[n] then
table.insert(questMachines, i)
end
end
end
end
-- check the number of stones
if v.gadget_id == stoneGadgetId then
-- 往table中增加一项记录这个stone的config id
table.insert(stones, i)
end
-- check the number of nodes
if v.gadget_id == nodeGadgetId then
-- 往gadgets的node里加一项cells
gadgets[i]["cells"] = {}
table.insert(nodes, i)
end
-- check the number of lines
for k, j in pairs(lineGadgetIds) do
if v.gadget_id == j then
-- 往gadgets的line里加一项cells
gadgets[i]["cells"] = {}
table.insert(lines, i)
end
end
end
for k, v in pairs(defs.cells) do
-- 在group的gadget list中的node和line里加一项cells, 记录关联哪些cells
for i = 1, #defs.cells[k].nodes do
table.insert(gadgets[defs.cells[k].nodes[i]].cells, k)
end
-- lines
for i = 1, #defs.cells[k].lines do
table.insert(gadgets[defs.cells[k].lines[i]].cells, k)
end
end
-- 一共有多少个电池
cellCount = LF_GetTableLength(defs.cells)
end
function LF_GetTableLength(t)
local count = 0
for _ in pairs(t) do count = count + 1 end
return count
end
function LF_UpdateStone(context, stoneId, gadgetState)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_UpdateStone is called")
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, stoneId, gadgetState)
if gadgetState == 0 then
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, stoneId, worktopOpt.collect)
elseif gadgetState == 201 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, stoneId, {worktopOpt.collect})
elseif gadgetState == 202 then
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, stoneId, worktopOpt.collect)
end
ScriptLib.PrintContextLog(context, "## [TitanEnergy] stone ".. stoneId.." is set to state ".. gadgetState)
end
function LF_UpdateWorktopOption(context)
-- 更新cell和machine的操作台选项
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_UpdateWorktopOption is called")
-- cell
for k, v in pairs(defs.cells) do
-- 对电池来说,充能和回收不可能同时出现,所以这么写暂时是正确的
-- 如果能同时出现就要改成下面machines的写法了因为worktop只能set不能add
-- 1可充能玩家的能量 > 0 && cell在0
if ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel") > 0 and
ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, k) == 0 then
-- 添加充能选项
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, k, {worktopOpt.charge})
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] cell ".. k.." adds option "..worktopOpt.charge)
else
-- 删除充能选项
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, k, worktopOpt.charge)
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] cell ".. k.." deletes option "..worktopOpt.charge)
end
-- 2可回收玩家的能量 < max && cell在201 && 并不是所有cell都被点亮
if ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel") < defs.maxPlayerEnergyLev and
ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, k) == 201 and
ScriptLib.GetGroupVariableValue(context, "activeCellNum") ~= cellCount then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, k, {worktopOpt.recycle})
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] cell ".. k.." adds option "..worktopOpt.recycle)
else
-- 删除回收选项
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, k, worktopOpt.recycle)
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] cell ".. k.." deletes option "..worktopOpt.recycle)
end
end
-- machine
for i = 1, #machines do
local worktopState = {charge = false, recycle = false}
-- 大前提条件是并不是所有电池都被点亮了
if ScriptLib.GetGroupVariableValue(context, "activeCellNum") ~= cellCount then
-- 1) 可充能:玩家的能量 > 0 && machine能量不到最大值
if ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel") > 0 and
ScriptLib.GetGroupVariableValue(context, tostring(machines[i])) < LF_GetMaxEnergyLevelByConfigId(context, machines[i]) then
-- 添加充能选项
worktopState.charge = true
else
-- 删除充能选项
worktopState.charge = false
end
-- 2可回收玩家的能量 < max && machine拥有能量aka machine上有能量
if ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel") < defs.maxPlayerEnergyLev and
ScriptLib.GetGroupVariableValue(context, tostring(machines[i])) > 0 then
-- 添加回收选项
worktopState.recycle = true
else
-- 删除回收选项
worktopState.recycle = false
end
-- 如果所有电池都被点亮了quest machine就不能再操作了
else
-- 不能充能也不能回收
worktopState.charge = false
worktopState.recycle = false
end
-- 按状态重新设定操作台
if worktopState.charge == true and worktopState.recycle == true then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, machines[i], {worktopOpt.charge, worktopOpt.recycle})
elseif worktopState.charge == true and worktopState.recycle == false then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, machines[i], {worktopOpt.charge})
elseif worktopState.charge == false and worktopState.recycle == true then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, machines[i], {worktopOpt.recycle})
elseif worktopState.charge == false and worktopState.recycle == false then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, machines[i], {})
end
ScriptLib.PrintContextLog(context, "## [TitanEnergy] machine = "..machines[i]..", charge = "..tostring(worktopState.charge)..", recycle = "..tostring(worktopState.recycle))
end
end
--todo: 直接从table中找value对应的key
function LF_GetMaxEnergyLevelByConfigId(context, configId)
-- 先判空
if gadgets[configId] == nil then
return 0
end
local max = 0
if gadgets[configId].gadget_id == 70350439 then
max = 1
elseif gadgets[configId].gadget_id == 70350440 then
max = 2
elseif gadgets[configId].gadget_id == 70350441 then
max = 3
end
ScriptLib.PrintContextLog(context, "## [TitanEnergy] current machine ".. configId..", max energyLevel = ".. max)
return max
end
function LF_UpdateNodeStatByCell(context, isCharge, cellId)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_UpdateNodeStatByCell is called")
-- 找到这个cell关联的所有node是个table
local curNodes = defs.cells[cellId].nodes
for i = 1, #curNodes do
-- 一个node的config id
local curNode = curNodes[i]
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] curNode = "..curNode)
-- 先把node设置为亮的
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, curNode, 201)
-- 找到这个node关联的所有电池
local relatedCells = gadgets[curNode].cells
for j = 1, #relatedCells do
if ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, relatedCells[j]) == 0 then
-- 任何一个电池不亮node就不能亮
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, curNode, 0)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] node "..curNode..", status = dark")
break
end
-- 所有电池都是亮的node也是亮的
ScriptLib.PrintContextLog(context, "## [TitanEnergy] node "..curNode..", status = light")
end
-- -- 更新节点计数
-- if isCharge == true then
-- -- 充电
-- nodes[curNode] = nodes[curNode] + 1
-- else
-- -- 回收
-- nodes[curNode] = nodes[curNode] - 1
-- end
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] node "..curNode..", charge = "..tostring(isCharge)..
-- ", energyNum = "..nodes[curNode])
-- -- 根据节点计数,更新节点亮暗
-- if nodes[curNode] == 2 then
-- -- 如果一个节点的计数为2aka周围两个电池都亮了这个节点也亮
-- ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, curNode, 201)
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] node "..curNode..", status = light")
-- else
-- ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, curNode, 0)
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] node "..curNode..", status = dark")
-- end
end
end
function LF_UpdateLineStatByCell(context, isCharge, cellId)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_UpdateLineStatByCell is called")
-- 先判空
if defs.cells[cellId] == nil then
return
end
-- 此电池关联的电线组
local curLines = defs.cells[cellId].lines
for i = 1, #curLines do
-- 当前line的config id
local curLine = curLines[i]
-- 电线先变暗,但只要有一个电池是亮的,电线就需要亮
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, curLine, 0)
-- 找到当前line关联的所有电池
local relatedCells = gadgets[curLine].cells
for j = 1, #relatedCells do
if ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, relatedCells[j]) == 201 then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, curLine, 201)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] node "..curLine..", status = light")
break
end
ScriptLib.PrintContextLog(context, "## [TitanEnergy] node "..curLine..", status = dark")
end
-- -- 更新节点计数
-- if isCharge == true then
-- -- 充电
-- lines[curLine] = lines[curLine] + 1
-- else
-- -- 回收
-- lines[curLine] = lines[curLine] - 1
-- end
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] line "..curLine..", charge = "..tostring(isCharge)..
-- ", energyNum = "..lines[curLine])
-- -- 根据节点计数,更新节点亮暗
-- if lines[curLine] > 0 then
-- -- 如果一个电线周围有任何一个电池是亮的,电线就亮
-- ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, curLine, 201)
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] node "..curLine..", status = light")
-- else
-- ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, curLine, 0)
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] node "..curLine..", status = dark")
-- end
end
end
function LF_UpdateCellEnergy(context, isCharge, cellId)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_UpdateCellEnergy is called")
local destGadgetState
local delta
if isCharge then
destGadgetState = 201
delta = 1
else
destGadgetState = 0
delta = -1
end
-- 更新电池gadget state
ScriptLib.SetGadgetStateByConfigId(context, cellId, destGadgetState)
-- 更新group变量
ScriptLib.ChangeGroupVariableValue(context, "activeCellNum", delta)
-- local temp = 0
-- for k, v in pairs(defs.cells) do
-- if ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, k) == 201 then
-- temp = temp + 1
-- end
-- end
-- ScriptLib.SetGroupVariableValue(context, "activeCellNum", temp)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] cell ".. cellId.." energy "..delta..
", activeCellNum = "..ScriptLib.GetGroupVariableValue(context, "activeCellNum"))
end
function LF_UpdateEnergyStatByCell(context, isCharge, cellId)
-- 更新电池状态
LF_UpdateCellEnergy(context, isCharge, cellId)
-- 更新节点状态
LF_UpdateNodeStatByCell(context, isCharge, cellId)
-- 更新电线状态
LF_UpdateLineStatByCell(context, isCharge, cellId)
end
function LF_UpdateMachineEnergy(context, delta, machineId)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_UpdateMachineEnergy is called")
-- 更新能量机关的能量和表现
-- 给机关增加delta的能量值
ScriptLib.ChangeGroupVariableValue(context, tostring(machineId), delta)
local curMachineEnergyNum = ScriptLib.GetGroupVariableValue(context, tostring(machineId))
ScriptLib.SetEntityServerGlobalValueByConfigId(context, machineId, "SGV_MACHINE_ENERGY_LEVEL", curMachineEnergyNum)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] machine "..machineId..", energyNum = "..curMachineEnergyNum)
end
function LF_UpdatePlayerEnergyLev(context, delta)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_UpdatePlayerEnergyLev is called")
-- 更新玩家身上能量
ScriptLib.ChangeGroupVariableValue(context, "playerEnergyLevel", delta)
local curPlayerEnergyLev = ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel")
-- 同步给SGV
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_ENERGY_LEVEL", curPlayerEnergyLev)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] SGV_ENERGY_LEVEL = "..curPlayerEnergyLev)
end
function LF_ResetGroup(context)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_ResetGroup is called")
local uidList = ScriptLib.GetSceneUidList(context)
-- 取不到uid list就不要往下走了
if #uidList == 0 then
ScriptLib.PrintContextLog(context, "## [TitanEnergy] no player in scene when resetting group")
return
end
local groupStatus = ScriptLib.GetGroupVariableValue(context, "groupStatus")
ScriptLib.PrintContextLog(context, "## [TitanEnergy] group status = "..groupStatus)
if groupStatus == 2 then
-- -- 进行中,表现不固定,不做特殊操作
-- -- 玩家身上能量和group变量对齐(如果身上有能量的时候断线重连了)
-- local playerEnergyLev = ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel")
-- local var = ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_ENERGY_LEVEL", playerEnergyLev)
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] SGV_ENERGY_LEVEL is created and set to "..playerEnergyLev..", var = "..var)
-- -- 机器能量值SGV和group var对齐
-- for i = 1, #machines do
-- local machineEnergy = ScriptLib.GetGroupVariableValue(context, tostring(machines[i]))
-- ScriptLib.SetEntityServerGlobalValueByConfigId(context, machines[i], "SGV_MACHINE_ENERGY_LEVEL", machineEnergy)
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] machine "..machines[i]..", SGV_MACHINE_ENERGY_LEVEL is set to "..machineEnergy)
-- end
return
end
-- 只要不在进行中,玩家身上无能量
ScriptLib.SetGroupVariableValue(context, "playerEnergyLevel", 0)
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_ENERGY_LEVEL", 0)
if groupStatus == 3 then
-- 已结束,一系列保底操作
-- cell在201
for k, v in pairs(defs.cells) do
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, k, 201)
end
-- line在201
for i = 1, #lines do
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, lines[i], 201)
end
-- node在201
for i = 1, #nodes do
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, nodes[i], 201)
end
-- 只有任务机关在201
for i = 1, #questMachines do
local maxEnergy = LF_GetMaxEnergyLevelByConfigId(context, questMachines[i])
ScriptLib.SetGroupVariableValue(context, tostring(questMachines[i]), maxEnergy)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, questMachines[i], "SGV_MACHINE_ENERGY_LEVEL", maxEnergy)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] quest machine "..questMachines[i]..", SGV_MACHINE_ENERGY_LEVEL is set to "..maxEnergy)
-- 以下为保底
-- ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, questMachines[i], 201)
-- ScriptLib.PrintContextLog(context, "## [TitanEnergy] quest machine "..questMachines[i].." is set to 201")
end
-- 销毁所有stone
for i = 1, #stones do
LF_UpdateStone(context, stones[i], 202)
end
ScriptLib.SetGroupVariableValue(context, "activeCellNum", cellCount)
ScriptLib.SetGroupVariableValue(context, "activeMachineNum", #machines)
-- 所有gadget都处于正确的结束状态玩家身上无能量按此状态更新操作台选项即删除所有操作台选项
else
-- 不能开始或者还没开始
-- 每个机器注册SGV并重置到0
for i = 1, #machines do
ScriptLib.SetGroupVariableValue(context, tostring(machines[i]), 0)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, machines[i], "SGV_MACHINE_ENERGY_LEVEL", 0)
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, machines[i], 0)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] SGV_MACHINE_ENERGY_LEVEL on machine "..machines[i].." is created and set to 0")
end
-- 所有电池都在0带动line和node都在0
for k, v in pairs(defs.cells) do
LF_UpdateEnergyStatByCell(context, false, k)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] cell "..k.." is set to inactive")
end
ScriptLib.SetGroupVariableValue(context, "activeCellNum", 0)
ScriptLib.SetGroupVariableValue(context, "activeMachineNum", 0)
if groupStatus == 0 then
-- 不能开始
-- 所有能量块都在,但是不能上操作台
for i = 1, #stones do
LF_UpdateStone(context, stones[i], 0)
end
elseif groupStatus == 1 then
-- 可以开始但是未开始
-- 更新初始激活的电池状态
for k, v in pairs(defs.activeCells) do
LF_UpdateEnergyStatByCell(context, true, v)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] cell "..v.." is set to active")
end
-- 所有能量块加操作台
for i = 1, #stones do
LF_UpdateStone(context, stones[i], 201)
end
end
end
-- 更新操作台选项
LF_UpdateWorktopOption(context)
end
function LF_ForceLevelStop(context)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_ForceLevelStop is called")
-- 联机专用function没走正常逻辑只是表面上把所有操作台选项删掉+所有物件进入未激活状态(即都暗掉了)
-- 顺便除了groupStatus的变量也归零了以免有什么我不知道的地方用它们做了判断
local uidList = ScriptLib.GetSceneUidList(context)
-- 所有玩家身上都不能有能量
for i = 1, #uidList do
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_ENERGY_LEVEL", 0)
end
ScriptLib.SetGroupVariableValue(context, "playerEnergyLevel", 0)
-- 每个机器注册SGV并重置到0
for i = 1, #machines do
ScriptLib.SetGroupVariableValue(context, tostring(machines[i]), 0)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, machines[i], "SGV_MACHINE_ENERGY_LEVEL", 0)
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, machines[i], 0)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] SGV_MACHINE_ENERGY_LEVEL on machine "..machines[i].." is created and set to 0")
end
-- 所有电池都在0带动line和node都在0
for k, v in pairs(defs.cells) do
LF_UpdateEnergyStatByCell(context, false, k)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] cell "..k.." is set to inactive")
end
ScriptLib.SetGroupVariableValue(context, "activeCellNum", 0)
ScriptLib.SetGroupVariableValue(context, "activeMachineNum", 0)
-- 更新操作台选项
LF_UpdateWorktopOption(context)
-- 所有能量块都在,但是不能上操作台
for i = 1, #stones do
LF_UpdateStone(context, stones[i], 0)
end
end
function LF_IsMPMode(context)
local isMP = ScriptLib.CheckIsInMpMode(context)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_IsMPMode is called, isMPMode = "..tostring(isMP))
if isMP == true then
-- 如果在联机状态下且未完成玩法不能进行任务【假装】流转到未开始状态取消所有操作台所有物件都变成未激活但是不能改存档的groupvar
if ScriptLib.GetGroupVariableValue(context, "groupStatus") ~= 3 then
LF_ForceLevelStop(context)
else
-- 如果已经完成了,按完成状态重置组内物件状态
LF_ResetGroup(context)
end
elseif isMP == false then
-- 要干的事情不一样
end
return isMP
end
function LF_RestartLevel(context)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] LF_RestartLevel is called")
if LF_IsMPMode(context) == false then
LF_ResetGroup(context)
if ScriptLib.GetGroupVariableValue(context, "groupStatus") == 2 then
-- 如果玩家已经参与玩法未完成的时候离开导致group卸载那么恢复到未开始的状态
ScriptLib.SetGroupVariableValue(context, "groupStatus", 1)
end
end
end
--================================================================
-- Triggers
--================================================================
function action_ENTER_REGION(context, evt)
-- 断线重连和联机后会被触发
ScriptLib.PrintContextLog(context, "## [TitanEnergy] player enters region "..evt.param1)
if evt.param1 == defs.titanRegion then
LF_RestartLevel(context)
end
return 0
end
function action_LEAVE_REGION(context, evt)
-- 断线重连和联机后会被触发
ScriptLib.PrintContextLog(context, "## [TitanEnergy] player leaves region "..evt.param1)
if evt.param1 == defs.titanRegion then
LF_RestartLevel(context)
end
return 0
end
function action_GROUP_LOAD(context, evt)
-- 断线重连后不会被触发
ScriptLib.PrintContextLog(context, "## [TitanEnergy] group is loaded")
LF_RestartLevel(context)
return 0
end
function action_GROUP_WILL_UNLOAD(context, evt)
-- 断线重连后不会被触发
ScriptLib.PrintContextLog(context, "## [TitanEnergy] group will unload")
LF_RestartLevel(context)
return 0
end
function action_VARIABLE_CHANGE(context, evt)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] variable "..evt.source_name.." changes from "..evt.param2.." to "..evt.param1 )
if evt.source_name == "activeCellNum" then
-- 如果所有电池都已经完成了电池和机关都维持201状态
if ScriptLib.GetGroupVariableValue(context, "activeCellNum") == cellCount then
-- 已经完成这组机关会再次触发此事件走下面else里的resetGroup
ScriptLib.SetGroupVariableValue(context, "groupStatus", 3)
end
elseif evt.source_name == "groupStatus" then
if evt.param1 ~= evt.param2 then
if LF_IsMPMode(context) == false then
LF_ResetGroup(context)
end
end
end
return 0
end
function action_CELL_INTERACT(context, evt)
-- 以防万一,如果联机的时候出现了交互选项,立刻结束
if LF_IsMPMode(context) == true then
return 0
end
-- local uidList = ScriptLib.GetSceneUidList(context)
-- 先判空
if gadgets[evt.param1] == nil then
return 0
end
if gadgets[evt.param1].gadget_id == cellGadgetId then
ScriptLib.PrintContextLog(context, "## [TitanEnergy] player interact with cell worktop "..evt.param1..", option = "..evt.param2)
-- 玩法进行中
if ScriptLib.GetGroupVariableValue(context, "groupStatus") == 1 then
ScriptLib.SetGroupVariableValue(context, "groupStatus", 2)
end
-- 先拿到这个电池的config id
local curCellId = evt.param1
-- 充能
if evt.param2 == worktopOpt.charge then
-- 更新和电池相关的能量状态
LF_UpdateEnergyStatByCell(context, true, curCellId)
-- 更新玩家身上能量
LF_UpdatePlayerEnergyLev(context, -1)
-- 回收
elseif evt.param2 == worktopOpt.recycle then
-- 更新和电池相关的能量状态
LF_UpdateEnergyStatByCell(context, false, curCellId)
-- 更新玩家身上能量
LF_UpdatePlayerEnergyLev(context, 1)
end
-- 更新操作台选项
LF_UpdateWorktopOption(context)
end
return 0
end
function action_MACHINE_INTERACT(context, evt)
-- 以防万一,如果联机的时候出现了交互选项,立刻结束
if LF_IsMPMode(context) == true then
return 0
end
-- local uidList = ScriptLib.GetSceneUidList(context)
if gadgets[evt.param1].gadget_id == 70350439 or
gadgets[evt.param1].gadget_id == 70350440 or
gadgets[evt.param1].gadget_id == 70350441 then
ScriptLib.PrintContextLog(context, "## [TitanEnergy] player interact with machine worktop "..evt.param1..", option = "..evt.param2)
-- 玩法进行中
if ScriptLib.GetGroupVariableValue(context, "groupStatus") == 1 then
ScriptLib.SetGroupVariableValue(context, "groupStatus", 2)
end
-- 是机关, 拿到机关的config id
local curMachineId = evt.param1
-- 机关最大能量数
local curMachineMaxEnergy = LF_GetMaxEnergyLevelByConfigId(context, curMachineId)
-- 机关目前能量数
local curMachineEnergy = ScriptLib.GetGroupVariableValue(context, tostring(curMachineId))
local machineNeed = curMachineMaxEnergy - curMachineEnergy
local playerNeed = defs.maxPlayerEnergyLev - ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel")
local delta
-- 充能
if evt.param2 == worktopOpt.charge then
-- 取玩家拥有能量,和机关缺能量,两者中的较小值,充到机关身上
delta = math.min(machineNeed, ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel"))
LF_UpdateMachineEnergy(context, delta, curMachineId)
LF_UpdatePlayerEnergyLev(context, -delta)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] charge "..delta.." energy to machine ".. curMachineId)
-- 如果机关能量满了, update group variable
if curMachineEnergy + delta == curMachineMaxEnergy then
ScriptLib.ChangeGroupVariableValue(context, "activeMachineNum", 1)
end
-- 回收
elseif evt.param2 == worktopOpt.recycle then
-- 取玩家缺能量,和机关拥有的能量,两者中的较小值,回收到玩家身上
delta = math.min(playerNeed, curMachineEnergy)
LF_UpdateMachineEnergy(context, -delta, curMachineId)
LF_UpdatePlayerEnergyLev(context, delta)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] recycle "..delta.." energy from machine ".. curMachineId)
end
-- 更新操作台选项
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, curMachineId, {})
ScriptLib.InitTimeAxis(context, "optionCD", {optionCd}, false)
end
return 0
end
function action_ENERGY_PICKUP(context, evt)
-- 以防万一,如果联机的时候出现了交互选项,立刻结束
if LF_IsMPMode(context) == true then
return 0
end
-- 只通过工作台选项id判断玩家是否在捡能量块并且身上是不是少于三格能量
if evt.param2 == worktopOpt.collect then
ScriptLib.PrintContextLog(context, "## [TitanEnergy] player interact with stone worktop "..evt.param1..", option = "..evt.param2)
-- 玩法进行中
if ScriptLib.GetGroupVariableValue(context, "groupStatus") == 1 then
ScriptLib.SetGroupVariableValue(context, "groupStatus", 2)
end
local curStoneId = evt.param1
-- local uidList = ScriptLib.GetSceneUidList(context)
if ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel") < defs.maxPlayerEnergyLev then
-- 能量块和操作台选项都无了
LF_UpdateStone(context, curStoneId, 202)
-- 玩家身上energy level ++
LF_UpdatePlayerEnergyLev(context, 1)
else
-- 玩家能量满了,不能拿
ScriptLib.ShowReminder(context, reminderTable.playerFull)
ScriptLib.PrintContextLog(context, "## [TitanEnergy] playher cannot take energy stones, current playerEnergyLevel = "
..ScriptLib.GetGroupVariableValue(context, "playerEnergyLevel"))
end
-- 更新操作台选项
LF_UpdateWorktopOption(context)
end
return 0
end
function action_TIME_AXIS_PASS(context, evt)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] Time axis "..evt.source_name..", stage "..evt.param1.." is finished")
if evt.source_name == "optionCD" then
LF_UpdateWorktopOption(context)
end
return 0
end
--================================================================
-- Initialize
--================================================================
LF_Initialize_Group(triggers, suites, variables, gadgets, regions)

View File

@@ -0,0 +1,437 @@
--[[======================================
|| filename: UnstableSpray
|| owner: shuyi.chang
|| description: 爆炸魔药活动
|| LogName: ## [UnstableSpray]
|| Protection:
=======================================]]
--[[
local defs =
{
-- 本轮对应的gallery id
galleryId = 0,
-- 开启挑战的场景物件id
startId = 46002,
-- todo: 临时,挑战区域,进了区域之后加载操作台
maxRegion = 46027,
-- 是否是起始group
isStartLevel = true,
-- 下一关的group id
nextGroupId = xxxxx,
-- 怪物资源包configs约定好只会有两波怪物潮配多了也不会刷
monsterPoolTable = {
{
pool_list = {35001},
point_array_id = 0,
point_id_list = {},
affix_list = {},
param = {total_count = 99, min_count = 1, max_count = 3, tag = 0, fill_time = 0, fill_count = 0, is_ordered = false, is_tag_bit_match = false},
},
{
pool_list = {35001},
point_array_id = 0,
point_id_list = {},
affix_list = {},
param = {total_count = 99, min_count = 1, max_count = 3, tag = 0, fill_time = 0, fill_count = 0, is_ordered = false, is_tag_bit_match = false},
},
},
-- 第一波怪物潮持续秒数不能大于总时间90s
switchTime = 45,
-- buff持续时间通常不需要修改
buffDuration = 15,
-- 每轮中每阶段的最大时间一共有3个阶段总时长为3*30s = 90s通常不用改
stageMaxDuration = 30,
}
--]]
local extraTriggers =
{
{ config_id = 50000001, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_ENTER_REGION", trigger_count = 0},
{ config_id = 50000002, name = "START_CHALLENGE", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_START_CHALLENGE", trigger_count = 0 },
{ config_id = 50000003, name = "STAGE_COMPLETE", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_STAGE_COMPLETE", trigger_count = 0 },
{ config_id = 50000004, name = "MONSTER_DIE", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_MONSTER_DIE", trigger_count = 0 },
{ config_id = 50000005, name = "GALLERY_STOP", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_GALLERY_STOP", trigger_count = 0 },
{ config_id = 50000006, name = "DUNGEON_ALL_PLAYER_DIE", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_DUNGEON_ALL_AVATAR_DIE", trigger_count = 0 },
{ config_id = 50000007, name = "VARIABLE_CHANGE", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_VARIABLE_CHANGE", trigger_count = 0 },
{ config_id = 50000008, name = "DUNGEON_SETTLE", event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_DUNGEON_SETTLE", trigger_count = 0 },
}
local extraVariables =
{
-- 记录目前是第几个三十秒
{ config_id = 5000101, name = "stage", value = 0, no_refresh = false },
-- 记录自己能不能加载
{ config_id = 5000102, name = "levelEnabled", value = 0, no_refresh = false },
-- 当前是第几个怪物潮
{ config_id = 5000103, name = "firstTideClose", value = 0, no_refresh = false },
-- 记录此关用到的buff
{ config_id = 5000201, name = "sgv1", value = 0, no_refresh = false },
{ config_id = 5000202, name = "sgv2", value = 0, no_refresh = false },
{ config_id = 5000203, name = "sgv3", value = 0, no_refresh = false },
{ config_id = 5000204, name = "sgv4", value = 0, no_refresh = false },
}
local worktopField =
{
configId = 10460099,
gadgetId = 70360001,
optionId = 429,
}
-- local transParam =
-- {
-- pos = {x = 0, y = 0, z = 0},
-- rot = {x = 0, y = 0, z = 0},
-- radius = 1,
-- }
-- local offset = {x = 0, y = 0, z = 0}
-- local worktop = { config_id = worktopField.configId, gadget_id = worktopField.gadgetId, pos = gadgets[defs.startId].pos, rot = gadgets[defs.startId].rot, level = 1, area_id = gadgets[defs.startId].area_id, worktop_config = { init_options = { worktopField.optionId } } }
--================================================================
-- Local Functions
--================================================================
function LF_Initialize_Group(triggers, suites, variables, gadgets, regions)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
end
-- add triggers to suite
for i = 1, #extraTriggers do
table.insert(suites[1].triggers,extraTriggers[i].name)
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
-- insert gadgets
-- gadgets[worktopField.configId] = worktop
-- -- set transport parameter
-- transParam.pos.x = transParam.pos.x + offset.x
-- transParam.pos.y = transParam.pos.y + offset.y
-- transParam.pos.z = transParam.pos.z + offset.z
end
function LF_PrintList(context, name, list)
local emptyStr = name
for k, v in pairs(list) do
emptyStr = emptyStr..", "..v
end
ScriptLib.PrintContextLog(context, "## [UnstableSpray] list = "..emptyStr)
end
function LF_LevelStart(context)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] LF_LevelStart is called")
-- 生成操作台和选项
ScriptLib.SetGadgetStateByConfigId(context, defs.startId, 0)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.startId, {worktopField.optionId})
-- 保底把所有sgv的group var都设为0
for i = 1, 4 do
local varName = "sgv"..i
ScriptLib.SetGroupVariableValue(context, varName, 0)
end
end
function LF_CheckAndRecordBuff(context, buffIdx)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] LF_CheckAndRecordBuff is called, buffIdx = ".. buffIdx)
-- 检查这个buff idx是不是已经被记录在group var里了
for i = 1, 4 do
local varName = "sgv"..i
local varValue = ScriptLib.GetGroupVariableValue(context, varName)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] group var "..varName.." = "..varValue )
if varValue == buffIdx then
-- 如果这个var记录了这个buff idx就不用再继续了
ScriptLib.PrintContextLog(context, "## [UnstableSpray] group varName = "..varName.." is already set to "..varValue )
return 0
elseif varValue == 0 then
-- 还没有被记录过检查自己是否是0即还未记录过buff是则用这个var记录
ScriptLib.SetGroupVariableValue(context, varName, buffIdx)
local temp = ScriptLib.GetGroupVariableValue(context, varName)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] group varName "..varName.." is unused and set to "..temp )
return 0
end
-- 如果这个var记录了别的buff idx继续for loop
end
end
--================================================================
-- Triggers
--================================================================
-- todo: 应该放在group load的时刻?
function action_ENTER_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] player enters region "..evt.param1)
if defs.isStartLevel == true then
ScriptLib.SetGroupVariableValue(context, "levelEnabled", 1)
end
return 0
end
function action_START_CHALLENGE(context, evt)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] worktop "..evt.param1..", option = "..evt.param2)
local uid = ScriptLib.GetSceneOwnerUid(context)
if evt.param2 == worktopField.optionId then
-- 操作台物件转换状态,选项失效
ScriptLib.SetGadgetStateByConfigId(context, defs.startId, 202)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.startId, worktopField.optionId)
-- 挑战开始
-- ScriptLib.ActiveChallenge(context, challengeId, challengeId, base_info.group_id, 999, 90, 0)
-- 开启gallery通过gallery给玩家身上挂t键ability group服务器直接挂本轮使用的buff abilitygroup
ScriptLib.StartGallery(context, defs.galleryId)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] start gallery "..defs.galleryId)
-- 临时每个可用的ability group都给team身上添加对应的SGV
-- for i = 1, #sgvStringTable do
-- ScriptLib.AddTeamServerGlobalValue(context, uid_list[1], sgvStringTable[i], 0)
-- end
-- 起state时间轴
ScriptLib.InitTimeAxis(context, "challengeTimer", {defs.stageMaxDuration, 2 * defs.stageMaxDuration, 3 * defs.stageMaxDuration}, false)
ScriptLib.SetGroupVariableValue(context, "stage", 1)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] group variable stage is set to 1")
-- 起怪物潮切换时间轴
ScriptLib.InitTimeAxis(context, "poolTimer", {defs.switchTime}, false)
if defs.monsterPoolTable[1] == nil then
return 0
end
-- 刷怪
-- ScriptLib.AutoMonsterTide(context, 1, base_info.group_id, defs.tides.monsters, defs.tides.sum, defs.tides.max, defs.tides.min)
ScriptLib.AutoPoolMonsterTide(context, 1, base_info.group_id, defs.monsterPoolTable[1].pool_list, defs.monsterPoolTable[1].point_array_id,
defs.monsterPoolTable[1].point_id_list, defs.monsterPoolTable[1].affix_list, defs.monsterPoolTable[1].param)
end
return 0
end
function action_STAGE_COMPLETE(context, evt)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] time axis "..evt.source_name..", stage "..evt.param1.. " is finished")
local uid = ScriptLib.GetSceneOwnerUid(context)
if evt.source_name == "challengeTimer" then
-- 更新阶段
local temp = evt.param1 + 1
ScriptLib.SetGroupVariableValue(context, "stage", temp)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] group variable stage is set to "..temp)
-- 【时间轴总长度会比90s多一点应该跑不到这里gallery就已经结束并强制卸载group了目前走event gallery stop】
if evt.param1 == 3 then
-- -- 第三轮结束,停止刷怪
-- -- ScriptLib.KillMonsterTide(context, base_info.group_falseid, 1)
-- ScriptLib.ClearPoolMonsterTide(context, base_info.group_id, 1)
-- ScriptLib.ClearPoolMonsterTide(context, base_info.group_id, 2)
-- -- gallery成功
-- ScriptLib.StopGallery(context, defs.galleryId, false)
end
elseif evt.source_name == "poolTimer" then
-- 关闭上一个怪物潮
ScriptLib.EndPoolMonsterTide(context, base_info.group_id, 1)
ScriptLib.SetGroupVariableValue(context, "firstTideClose", 1)
else
-- 不是challenge timer也不是怪物潮timer就肯定是sgv timer
-- SGV设为0buff效果结束
ScriptLib.SetTeamServerGlobalValue(context, uid, evt.source_name, 0)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] "..evt.source_name.." is set to 0")
end
return 0
end
function action_MONSTER_DIE(context, evt)
local monsterId = ScriptLib.GetMonsterIdByEntityId(context, evt.source_eid)
ScriptLib.UpdatePlayerGalleryScore(context, defs.galleryId, {["monster_id"] = monsterId})
ScriptLib.PrintContextLog(context, "## [UnstableSpray] monster id = "..monsterId..", config id = "..evt.param1..
", entity id = "..evt.source_eid.." is dead")
local firstTideClose = ScriptLib.GetGroupVariableValue(context, "firstTideClose")
local remainMax = 0
if defs.remainMax ~= nil then
remainMax = defs.remainMax
end
if firstTideClose == 1 and #ScriptLib.GetGroupAliveMonsterList(context, base_info.group_id) == remainMax then
if defs.monsterPoolTable[2] == nil then
return 0
end
-- 第一波怪物潮都死了
-- 开下一个怪物潮
ScriptLib.AutoPoolMonsterTide(context, 2, base_info.group_id, defs.monsterPoolTable[2].pool_list, defs.monsterPoolTable[2].point_array_id,
defs.monsterPoolTable[2].point_id_list, defs.monsterPoolTable[2].affix_list, defs.monsterPoolTable[2].param)
ScriptLib.SetGroupVariableValue(context, "firstTideClose", 2)
end
return 0
end
function action_GALLERY_STOP(context, evt)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] gallery = "..evt.param1.." finishes, fail = "..evt.param2)
local uid = ScriptLib.GetSceneOwnerUid(context)
-- gallery结束停止刷怪
ScriptLib.ClearPoolMonsterTide(context, base_info.group_id, 1)
ScriptLib.ClearPoolMonsterTide(context, base_info.group_id, 2)
-- 只有gallery成功才算这一轮结束
if evt.param2 == 0 then
-- 通知下一个group加载下一轮的group的操作台
if defs.nextGroupId ~= -1 then
ScriptLib.SetGroupVariableValueByGroup(context, "levelEnabled", 1, defs.nextGroupId)
end
end
-- 所有buff sgv保底归零
for i = 1, 4 do
local buffIdx = ScriptLib.GetGroupVariableValue(context, "sgv"..i)
local sgv = ScriptLib.InstableSprayGetSGVByBuffId(context, buffIdx)
if sgv ~= "" then
ScriptLib.EndTimeAxis(context, sgv)
ScriptLib.SetTeamServerGlobalValue(context, uid, sgv, 0)
local v = ScriptLib.GetTeamServerGlobalValue(context, uid, sgv)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] level ends and "..sgv.." = "..v)
end
end
return 0
end
function action_DUNGEON_ALL_AVATAR_DIE(context, evt)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] all avatar dies in dungeon"..evt.source_name.."uid = "..evt.uid)
ScriptLib.CauseDungeonFail(context)
-- gallery失败
ScriptLib.StopGallery(context, defs.galleryId, true)
return 0
end
-- 副本结算
function action_DUNGEON_SETTLE(context, evt)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] dungeon settles, result = "..evt.param1)
-- gallery失败
ScriptLib.StopGallery(context, defs.galleryId, true)
return 0
end
function action_VARIABLE_CHANGE(context, evt)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] variable "..evt.source_name.." changes from "..evt.param2.." to "..evt.param1 )
if evt.source_name ~= "levelEnabled" or evt.param2 == evt.param1 then
return 0
end
if evt.param1 == 1 then
-- 加载操作台
LF_LevelStart(context)
end
return 0
end
--================================================================
-- Server Lua Call Functions
--================================================================
function SLC_TriggerAbility(context, evt)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] SLC_TriggerAbility is called")
local uid = ScriptLib.GetSceneOwnerUid(context)
local stage = ScriptLib.GetGroupVariableValue(context, "stage")
-- 本次随机出可用的buff index listidx为活动表中idx
local curBuffIdx = ScriptLib.InstableSprayRandomBuffs(context, defs.galleryId, stage)
LF_PrintList(context, "curBuffIdx", curBuffIdx)
for i = 1, #curBuffIdx do
local sgv = ScriptLib.InstableSprayGetSGVByBuffId(context, curBuffIdx[i])
-- 修改team身上sgv为1
ScriptLib.AddTeamServerGlobalValue(context, uid, sgv, 0)
local var = ScriptLib.SetTeamServerGlobalValue(context, uid, sgv, 1)
local v = ScriptLib.GetTeamServerGlobalValue(context, uid, sgv)
ScriptLib.PrintContextLog(context, "## [UnstableSpray] "..sgv.." is set to "..v..", var = "..var)
-- 通知gallery重置buff icon时间轴
ScriptLib.UpdatePlayerGalleryScore(context, defs.galleryId, {buff_id = curBuffIdx[i], buff_max_time = defs.buffDuration})
-- 起控制modifier生效时间长度的时间轴
-- 时间轴的key就是SGV name
ScriptLib.InitTimeAxis(context, sgv, {defs.buffDuration}, false)
-- 50000201开始的4个id专门用来记录本局的4个buff
-- group var名称为sgv1,sgv2,sgv3,sgv4
-- group var值为活动表中buff idx
-- 更新group var
LF_CheckAndRecordBuff(context, curBuffIdx[i])
-- local var1 = ScriptLib.SetGroupVariableValue(context, "sgv"..i, curBuffIdx[i])
-- local r = ScriptLib.GetGroupVariableValue(context, "sgv"..i)
-- ScriptLib.PrintContextLog(context, "## [UnstableSpray] group variable sgv"..i.." is set to "..r..", var = "..var1)
end
return 0
end
--================================================================
-- Initialize
--================================================================
LF_Initialize_Group(triggers, suites, variables, gadgets, regions)

View File

@@ -0,0 +1,297 @@
--[[======================================
|| filename: VarunaStandard
|| owner: shuyi.chang
|| description: 回流之柱被控制组
|| LogName: ## [VarunaStandard]
|| Protection:
=======================================]]
--[[
local defs =
{
-- 钓鱼点
fishingPoint = {
bottom = suite_id01,
top = suite_id02,
},
-- 升降水面,应该只有一项
rootWaterTable =
{
[188001] = 330300001,
},
}
--]]
local extraTriggers =
{
{ config_id = 50000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 50000002, name = "PLATFORM_ARRIVAL", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_EVENT_PLATFORM_ARRIVAL", trigger_count = 0 },
}
local extraVariables =
{
}
local rootGadgetId = 70290436
local bubbleGadgetId = 70290437
local waterGadgetId = 70310225
local fishingGadgetId = 70950099
local bubbles = {}
local roots = {}
local waterConfigId = 0
local fishPoints = {}
local fishGroupId = 133303151
--================================================================
-- Local Functions
--================================================================
function LF_Initialize_Group(triggers, suites, variables, gadgets, regions)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
end
-- add triggers to suite
for i = 1, #extraTriggers do
if extraTriggers[i].name == "GROUP_LOAD" then
-- 每个suite都放group load
for j = 1, #suites do
table.insert(suites[j].triggers,extraTriggers[i].name)
end
else
-- 另外的只放到初始suite 1中
table.insert(suites[1].triggers,extraTriggers[i].name)
end
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
for k, v in pairs(gadgets) do
-- find all roots
if v.gadget_id == rootGadgetId then
table.insert(roots, v.config_id)
end
-- find all bubbles
if v.gadget_id == bubbleGadgetId then
table.insert(bubbles, v.config_id)
end
-- find all waters(should only have one)
if v.gadget_id == waterGadgetId then
waterConfigId = v.config_id
end
-- find all fishing point(should only have two)
if v.gadget_id == fishingGadgetId then
table.insert(fishPoints, v.config_id)
end
end
end
function LF_SetGadgetState(context, configId, gadgetState)
-- ScriptLib.PrintContextLog(context, "## [VarunaStandard] LF_SetSpoutGadgetState is called")
ScriptLib.SetGadgetStateByConfigId(context, configId, gadgetState)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] gadget = "..configId..", state is set to "..gadgetState)
end
function LF_SetRootAndBubbleState(context, prev_context, weatherState)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] LF_SetRootAndBubbleState is called")
LF_SetRootAndBubbleState_Local(context, weatherState)
return 0
end
function LF_CreateFishingPoint(context, weatherState)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] LF_CreateFishingPoint is called")
-- 0雨天用低处的1晴天用高处的
local suite = 0
if weatherState == 0 then
-- 雨天,创建低的
suite = defs.fishingPoint.bottom
elseif weatherState == 1 then
-- 晴天,创建高的
suite = defs.fishingPoint.top
end
if suite ~= 0 then
-- ScriptLib.CreateGadget(context, { config_id = pointId })
ScriptLib.AddExtraGroupSuite(context, fishGroupId, suite)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] create fish point "..suite)
end
end
function LF_CreateFishingPoint_FromOther(context, prev_context, weatherState)
LF_CreateFishingPoint(context, weatherState)
return 0
end
function LF_DelFishingPoint(context, weatherState)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] LF_DelFishingPoint is called")
local suite = 0
if weatherState == 0 then
-- 雨天,删除高的
suite = defs.fishingPoint.top
elseif weatherState == 1 then
-- 晴天,删除低的
suite = defs.fishingPoint.bottom
end
if suite == 0 then
-- 组里没有钓鱼点,啥也不干
return 0
end
-- 移动水面只有一个,这里就写死了,简单一点
local exist = ScriptLib.CheckIsInGroup(context, 133303188, 188001)
if exist == true then
local waterStatus = ScriptLib.GetGroupVariableValueByGroup(context, "waterStatus", 133303188)
if waterStatus == 2 then
-- 水片已存在,且在移动中,需要把钓鱼点干掉,创建等移动平台到位通知
ScriptLib.RemoveExtraGroupSuite(context, fishGroupId, defs.fishingPoint.top)
ScriptLib.RemoveExtraGroupSuite(context, fishGroupId, defs.fishingPoint.bottom)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] del all fish points cuz water is moving")
end
-- 存在但没在移动,只干掉不需要的那个钓鱼点(这个不需要的钓鱼点其实也应该已经不在了)
ScriptLib.RemoveExtraGroupSuite(context, fishGroupId, suite)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] del fish point "..suite)
else
ScriptLib.RemoveExtraGroupSuite(context, fishGroupId, defs.fishingPoint.top)
ScriptLib.RemoveExtraGroupSuite(context, fishGroupId, defs.fishingPoint.bottom)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] del all fish points cuz water doesn't exist")
end
end
function LF_DelFishingPoint_FromOther(context, prev_context, weatherState)
LF_DelFishingPoint(context, weatherState)
return 0
end
function LF_SetRootAndBubbleState_Local(context, weatherState)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] LF_SetRootAndBubbleState_Local is called")
-- 0雨天1晴天
LF_SetBubbleState(context, weatherState)
LF_SetRootState(context, weatherState)
LF_SetWaterState(context, weatherState)
if #fishPoints ~= 0 then
LF_DelFishingPoint(context, weatherState)
end
return 0
end
function LF_SetBubbleState(context, weatherState)
-- 下雨的时候有泡泡
local gadgetState
if weatherState == 0 then
gadgetState = 0
elseif weatherState == 1 then
gadgetState = 201
end
for i = 1, #bubbles do
-- 只设置非202状态的泡泡
if 202 ~= ScriptLib.GetGadgetStateByConfigId(context, 0, bubbles[i]) then
LF_SetGadgetState(context, bubbles[i], gadgetState)
end
end
end
function LF_SetRootState(context, weatherState)
-- 下雨的时候不能和树桩交互
local gadgetState
if weatherState == 0 then
gadgetState = 0
elseif weatherState == 1 then
gadgetState = 201
end
for i = 1, #roots do
LF_SetGadgetState(context, roots[i], gadgetState)
end
end
function LF_SetWaterState(context, weatherState)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] LF_SetWaterState is called, waterConfigId = "..waterConfigId)
-- 下雨的时候水面下降(把水吸走了)
local pointId
if weatherState == 0 then
pointId = 2
elseif weatherState == 1 then
pointId = 1
end
if waterConfigId ~= 0 then
for k, v in pairs(defs.rootWaterTable) do
-- 水面上升和下降
ScriptLib.SetPlatformPointArray(context, k, v, {pointId}, { route_type = 0 })
ScriptLib.PrintContextLog(context, "## [VarunaStandard] water "..k.." is moving, pointId = "..pointId)
ScriptLib.SetGroupVariableValueByGroup(context, "waterStatus", 2, 133303188)
end
end
end
--================================================================
-- Triggers
--================================================================
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] group is loaded")
-- group 加载时查询当前天气
local weather = ScriptLib.GetGroupVariableValueByGroup(context, "SGV_WeatherState", 133303126)
LF_SetRootAndBubbleState_Local(context, weather)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] there are "..#fishPoints.." items in table fishPoints")
return 0
end
function action_EVENT_PLATFORM_ARRIVAL(context, evt)
ScriptLib.PrintContextLog(context, "## [VarunaStandard] platform "..evt.param1.." arrives at point id "..evt.param2..", index = "..evt.param3)
-- 根据平台到了哪个点决定出现哪个
-- 平台所在group和钓鱼点所在group不是同一个平台需要通知钓鱼点group创建时机
-- 删除听133303126的天气group var通知
if evt.param3 == 2 then
-- 雨天低点通知133303151
ScriptLib.ExecuteGroupLua(context, 133303151, "LF_CreateFishingPoint_FromOther", {0})
ScriptLib.SetGroupVariableValueByGroup(context, "waterStatus", 0, 133303188)
elseif evt.param3 == 1 then
-- 晴天,高点
ScriptLib.ExecuteGroupLua(context, 133303151, "LF_CreateFishingPoint_FromOther", {1})
ScriptLib.SetGroupVariableValueByGroup(context, "waterStatus", 1, 133303188)
end
return 0
end
--================================================================
-- Initialize
--================================================================
LF_Initialize_Group(triggers, suites, variables, gadgets, regions)

View File

@@ -0,0 +1,530 @@
--[[======================================
|| filename: VarunaWaterspout
|| owner: shuyi.chang
|| description: 回流之柱
|| LogName: ## [VarunaWaterspout]
|| Protection:
=======================================]]
--[[
local defs =
{
-- 受回流之柱控制的group id
groupTable =
{
},
-- 回流之柱副中枢所在的group id
deviceGroupTable =
{
},
-- 用于照相的gadget在本组中的config id
photoTable = {configId_01, configId_02, configId_03, ...},
-- 区域,用于断线重连时重新计算时间
regionId = ,
-- 回流之柱的config id
waterSpoutId = 41001,
-- 水柱升空的现实时间,单位为秒
waterRise = 5,
-- 水柱持平的现实时间,单位为秒
waterStayup = 20,
-- 水柱下降的现实时间,单位为秒
waterDown = 5,
}
--]]
local extraTriggers =
{
{ config_id = 50000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 50000002, name = "TIME_AXIS_PASS", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_EVENT_TIME_AXIS_PASS", trigger_count = 0 },
{ config_id = 50000003, name = "SET_GAME_TIME", event = EventType.EVENT_SET_GAME_TIME, source = "", condition = "", action = "action_EVENT_SET_GAME_TIME", trigger_count = 0 },
{ config_id = 50000004, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", trigger_count = 0 },
{ config_id = 50000005, name = "VARIABLE_CHANGE", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_VARIABLE_CHANGE", trigger_count = 0 },
}
local extraVariables =
{
-- 0雨天1晴天不要在其他group里改这个变量的值
{ config_id = 50000101, name = "SGV_WeatherState", value = 0, no_refresh = true },
-- 0未完成任务自动切换1已完成任务玩家控制天气状态
{ config_id = 50000102, name = "questStatus", value = 0, no_refresh = true },
-- 【目前没用到】水柱的状态0上升1循环2下降
-- { config_id = 50000103, name = "spoutState", value = 0, no_refresh = true },
-- 任务完成后天气状态, 0持续雨天1持续晴天2晴雨切换
{ config_id = 50000104, name = "finalWeatherState", value = 2, no_refresh = true },
}
local weatherTable =
{
clearBefore = 4013,
rainBefore = 4014,
clearAfter = 4015,
rainAfter = 4016,
}
local clearWeather = weatherTable.clearBefore
local rainWeather = weatherTable.rainBefore
--================================================================
-- Local Functions
--================================================================
function LF_Initialize_Group(triggers, suites, variables, gadgets, regions)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
end
-- add triggers to suite
for i = 1, #extraTriggers do
-- 都放到初始suite 1中
table.insert(suites[1].triggers,extraTriggers[i].name)
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
end
function LF_CheckTime(context, destTime)
-- 每次时间轴到时之后需要再检查一次时间,以防中途出现什么意外导致时间计算不对
local temp = false
local time = LF_GetGameTime(context)
if #time ~= 3 then
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_Check_Weather_Status is cancelled because LF_GetGameTime failed")
return temp
end
if #destTime ~= 2 then
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_Check_Weather_Status is cancelled because destTime is illegal")
return temp
end
local curGameMinutePassed = time[3]
local destTimePassed = destTime[1] * 60 + destTime[2]
-- 允许前后2s内的误差
if math.abs(curGameMinutePassed - destTimePassed) < 2 then
temp = true
end
return temp
end
function LF_SetSpoutGadgetState(context, gadgetState)
-- ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_SetSpoutGadgetState is called")
ScriptLib.SetGadgetStateByConfigId(context, defs.waterSpoutId, gadgetState)
local photoIdList = "photo gadget, "
local photoState = 0
-- 只要水柱不在0,照相物件就要进入可照相状态201
if gadgetState ~= 0 then
photoState = 201
else
photoState = 0
end
for i = 1, #defs.photoTable do
ScriptLib.SetGadgetStateByConfigId(context, defs.photoTable[i], photoState)
photoIdList = photoIdList..defs.photoTable[i].." state = "..photoState..","
end
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] water spout gadget state is set to "..gadgetState..
", "..photoIdList)
end
function LF_CheckSpoutStatusByTime(context, hour, minute)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_CheckSpoutStatusByMinute is called")
if LF_CheckTime(context, {0, 0}) or LF_CheckTime(context, {12, 0}) then
-- 有的时候时间轴会有1-2s的误差
LF_SetSpoutGadgetState(context, 901)
LF_WaterSpoutTimeAxis(context, false, hour, minute)
end
local temp = hour % 12
if temp == 0 then
-- 是起水柱的那个小时0或12
if minute == 0 then
-- 暂时不走这里,走上面,允许一点误差
elseif minute < defs.waterRise + defs.waterStayup then
-- 如果还没到该下落的时间,保持循环状态(通常是调时间之后走这里先等几秒不出特效等镜头上移之后从物件层进201)
LF_SetSpoutGadgetState(context, 903)
LF_WaterSpoutTimeAxis(context, true, hour, minute)
else
-- 水柱要下降了,或者压根不是应该有水柱的分钟数
LF_SetSpoutGadgetState(context, 0)
end
else
-- 压根不在水柱的小时数
LF_SetSpoutGadgetState(context, 0)
end
end
function LF_WaterSpoutTimeAxis(context, temp, hour, minute)
if temp then
-- 从中间起水柱,直接出现,到该下落的时候准备下落
ScriptLib.InitTimeAxis(context, "tempWaterSpout_"..LF_TempAxisValue(context, 2), {defs.waterRise + defs.waterStayup - minute, defs.waterRise + defs.waterStayup + defs.waterDown - minute}, false)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] start a time axis, name = tempWaterSpout_"..LF_TempAxisValue(context, 2)..", time = "..hour..":"..minute)
else
-- 从头起水柱
ScriptLib.InitTimeAxis(context, "waterSpout_"..LF_TempAxisValue(context, 3), {defs.waterRise, defs.waterRise + defs.waterStayup, defs.waterRise + defs.waterStayup + defs.waterDown}, false)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] start a time axis, name = waterSpout_"..LF_TempAxisValue(context, 3)..", time = "..hour..":"..minute)
end
end
function LF_GetGameTime(context)
local temp = ScriptLib.GetGameTimePassed(context)
if #temp ~= 2 then
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] cannot get current time")
return {}
end
local curGameHour = temp[1]
local curGameMinutePassed = temp[2]
-- 得到精确到提瓦特分钟(现实世界秒)的当前时间
local curGameMinute = curGameMinutePassed - curGameHour * 60
local time = {curGameHour, curGameMinute, curGameMinutePassed}
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] curGameHour = ".. curGameHour..
", curGameMinute = "..curGameMinute..", totalMinutePassed = ".. curGameMinutePassed)
return time
end
-- 用于其他group强制重新计算时间
function LF_Force_Check_Weather_Status(context, prev_context)
LF_Check_Weather_Status(context)
return 0
end
function LF_Check_Weather_Status(context)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_Check_Weather_Status is called")
-- 只有在任务完成前,以及完成后的晴雨切换状态下才能切换天气
if ScriptLib.GetGroupVariableValue(context, "questStatus") ~= 0 then
if ScriptLib.GetGroupVariableValue(context, "finalWeatherState") ~= 2 then
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_Check_Weather_Status is cancelled")
return
end
end
-- 只要进了这个function就一定会起新的tempWeather时间轴所以一定要把所有时间轴都取消掉
LF_CancelAllAxis(context)
local temp = LF_GetGameTime(context)
-- 要是没取到时间,就不往下更新天气了
if #temp ~= 3 then
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_Check_Weather_Status is cancelled because LF_GetGameTime failed")
return
end
local curGameHour = temp[1]
local curGameMinute = temp[2]
local curGameMinutePassed = temp[3]
-- 判断 当前小时数/6 是奇数还是偶数,暂定奇数为晴天
-- 提瓦特的24小时晴雨状况 |-水柱-|----0雨----|----1晴----|-水柱-|----0雨----|----1晴----|
-- stage |--------0--------|-----1-----|---------2--------|-----3-----|
local stage = math.floor(curGameHour / 6)
local weather = stage % 2
local timeRemain
ScriptLib.SetGroupVariableValue(context, "SGV_WeatherState", weather)
LF_ChangeWeather(context, weather)
LF_CheckSpoutStatusByTime(context, curGameHour, curGameMinute)
LF_NotifyOtherGroups(context, weather)
timeRemain = (stage + 1) * 6 * 60 - curGameMinutePassed
ScriptLib.InitTimeAxis(context, "tempWeather_"..LF_TempAxisValue(context, 0), {timeRemain}, false)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] current game time = "..curGameHour
..":"..curGameMinute..", weatherState = "..tostring(ScriptLib.GetGroupVariableValue(context, "SGV_WeatherState"))..", current stage = "
..stage..", "..timeRemain.." seconds before next stage")
end
function LF_NotifyOtherGroups(context, weatherState)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_NotifyOtherGroups is called")
for i = 1, #defs.groupTable do
ScriptLib.ExecuteActiveGroupLua(context, defs.groupTable[i], "LF_SetRootAndBubbleState", {weatherState})
end
return 0
end
function LF_NotifyDeviceGroups(context, finalWeatherState)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_ChangeDeviceState is called")
for i = 1, #defs.deviceGroupTable do
ScriptLib.ExecuteActiveGroupLua(context, defs.deviceGroupTable[i], "LF_ChangeDeviceState", {finalWeatherState})
end
return 0
end
function LF_ChangeWeather(context, weatherState)
-- 根据当前的任务状态,自动切换到对应的天气
local questStatus = ScriptLib.GetGroupVariableValue(context, "questStatus")
local curWeather = ScriptLib.GetGroupTempValue(context, "weatherId", {})
local destWeather
local lowWeather
local highWeather
if questStatus == 0 then
lowWeather = weatherTable.clearBefore
highWeather = weatherTable.rainBefore
if weatherState == 0 then
destWeather = weatherTable.rainBefore
else
destWeather = weatherTable.clearBefore
end
else
lowWeather = weatherTable.clearAfter
highWeather = weatherTable.rainAfter
if weatherState == 0 then
destWeather = weatherTable.rainAfter
else
destWeather = weatherTable.clearAfter
end
end
ScriptLib.SetGroupTempValue(context, "weatherId", destWeather, {})
-- 判断一下是否要换天气不用换就不往下走了否则可能会突然切到默认天气4000
if curWeather == destWeather then
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_ChangeWeather is called, weather = "..curWeather..", no need to change")
return
end
-- 先开优先级最低的天气
local var1 = ScriptLib.SetWeatherAreaState(context, lowWeather, 1)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] set base weather = "..lowWeather..", succeed = "..var1)
if destWeather == lowWeather then
-- 判断目标天气的优先级,如果是低优先级,需要关掉高优先级天气
local var2 = ScriptLib.SetWeatherAreaState(context, highWeather, 0)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_ChangeWeather is called, destWeather = "..destWeather..
", close higher priority weather = "..highWeather..", succeed = ".. var2)
elseif destWeather == highWeather then
-- 如果是高优先级,直接开
local var3 = ScriptLib.SetWeatherAreaState(context, highWeather, 1)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_ChangeWeather is called, weather changes from "..curWeather.." to "..destWeather..
", succeed = ".. var3)
end
-- -- 为了测试方便新加,强制关闭所有天气,不然天气配了不一样的优先级没办法退到任务完成前状态
-- for k, v in pairs(weatherTable) do
-- local temp = ScriptLib.SetWeatherAreaState(context, v, 0)
-- ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] weather id = "..v.." is closed, succeed = "..temp)
-- end
-- local var2 = ScriptLib.SetWeatherAreaState(context, destWeather, 1)
-- ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_ChangeWeather is called, weather changes from "..curWeather.." to "..destWeather..
-- ", succeed = ".. var2)
end
function LF_CancelAllAxis(context)
-- temp和formal loop都要停
local temp1 = ScriptLib.GetGroupTempValue(context, "axis_tempWeather", {})
-- local temp2 = ScriptLib.GetGroupTempValue(context, "axis_loopWeather", {})
local temp3 = ScriptLib.GetGroupTempValue(context, "axis_tempWaterSpout", {})
local temp4 = ScriptLib.GetGroupTempValue(context, "axis_waterSpout", {})
ScriptLib.EndTimeAxis(context, "tempWeather_"..temp1)
-- ScriptLib.EndTimeAxis(context, "loopWeather_"..temp2)
ScriptLib.EndTimeAxis(context, "tempWaterSpout_"..temp3)
ScriptLib.EndTimeAxis(context, "waterSpout_"..temp4)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] LF_CancelAllAxis is finished")
end
function LF_TempAxisValue(context, type)
-- 0临时天气时间轴1整循环天气时间轴2水柱时间轴
local tempValue
local tempName
if type == 0 then
tempName = "axis_tempWeather"
tempValue = ScriptLib.GetGroupTempValue(context, "axis_tempWeather", {})
-- elseif type == 1 then
-- tempName = "axis_loopWeather"
-- tempValue = ScriptLib.GetGroupTempValue(context, "axis_loopWeather", {})
elseif type == 2 then
tempName = "axis_tempWaterSpout"
tempValue = ScriptLib.GetGroupTempValue(context, "axis_tempWaterSpout", {})
elseif type == 3 then
tempName = "axis_waterSpout"
tempValue = ScriptLib.GetGroupTempValue(context, "axis_waterSpout", {})
end
if tempValue == 1 then
ScriptLib.SetGroupTempValue(context, tempName, 0, {})
return 0
elseif tempValue == 0 then
ScriptLib.SetGroupTempValue(context, tempName, 1, {})
return 1
end
end
--================================================================
-- Triggers
--================================================================
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] group is loaded")
ScriptLib.SetGroupTempValue(context, "axis_tempWeather", 0, {})
-- ScriptLib.SetGroupTempValue(context, "axis_loopWeather", 0, {})
ScriptLib.SetGroupTempValue(context, "axis_tempWaterSpout", 0, {})
ScriptLib.SetGroupTempValue(context, "axis_waterSpout", 0, {})
ScriptLib.SetGroupTempValue(context, "weatherId", 4014, {})
ScriptLib.SetWeatherAreaState(context, 4014, 1)
-- 更新当前天气
LF_Check_Weather_Status(context)
return 0
end
function action_EVENT_ENTER_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] player enters region "..evt.param1)
if evt.param1 == defs.regionId then
-- 更新当前天气
LF_Check_Weather_Status(context)
end
return 0
end
function action_VARIABLE_CHANGE(context, evt)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] group variable "..evt.source_name..
" changes from "..evt.param2.." to "..evt.param1)
if evt.param1 == evt.param2 or ScriptLib.GetGroupVariableValue(context, "questStatus") == 0 then
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] \"questStatus\" = 0 " ..
ScriptLib.GetGroupVariableValue(context, "questStatus"))
return 0
end
if evt.source_name == "finalWeatherState" then
-- 通知中枢所在组
LF_NotifyDeviceGroups(context, evt.param1)
-- 玩家手动切换天气
if evt.param1 == 0 then
-- 雨天
-- 改变天气,且时间轴都停掉,不用再跟着时间走了
ScriptLib.SetGroupVariableValue(context,"SGV_WeatherState", 0)
LF_CancelAllAxis(context)
LF_ChangeWeather(context, 0)
LF_NotifyOtherGroups(context, 0)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] quest finished, weather is forced to be rainy")
elseif evt.param1 == 1 then
-- 晴天
-- 改变天气,且时间轴都停掉,不用再跟着时间走了
ScriptLib.SetGroupVariableValue(context,"SGV_WeatherState", 1)
LF_CancelAllAxis(context)
LF_ChangeWeather(context, 1)
LF_NotifyOtherGroups(context, 1)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] quest finished, weather is forced to be clear")
elseif evt.param1 == 2 then
-- 晴雨转换S
LF_Check_Weather_Status(context)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] quest finished, weather changes according to time")
end
elseif evt.source_name == "questStatus" then
local curWeather = ScriptLib.GetGroupVariableValue(context,"SGV_WeatherState")
LF_ChangeWeather(context, curWeather)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] quest finished, weather changes to "..curWeather)
end
return 0
end
function action_EVENT_SET_GAME_TIME(context, evt)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] player sets game time")
LF_Check_Weather_Status(context)
return 0
end
function action_EVENT_TIME_AXIS_PASS(context, evt)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] Time axis "..evt.source_name..", stage "..evt.param1.." is finished")
-- 只要时间轴走完一个阶段,一定切换天气状态
-- 目前一个循环包括晴天6min雨天6min
if string.sub(evt.source_name, 0, 11) == "tempWeather" then
LF_Check_Weather_Status(context)
ScriptLib.PrintContextLog(context, "## [VarunaWaterspout] game hour = "..ScriptLib.GetGameHour(context)..
", current weather state = "..ScriptLib.GetGroupVariableValue(context, "SGV_WeatherState"))
elseif string.sub(evt.source_name, 0, 10) == "waterSpout" then
if evt.param1 == 1 then
-- if LF_CheckTime(context, {0, 5}) == false and LF_CheckTime(context, {12, 5}) == false then
-- LF_CheckSpoutStatusByMinute(context, curGameMinute)
-- return 0
-- else
LF_SetSpoutGadgetState(context, 201)
-- end
elseif evt.param1 == 2 then
LF_SetSpoutGadgetState(context, 902)
elseif evt.param1 == 3 then
LF_SetSpoutGadgetState(context, 0)
end
elseif string.sub(evt.source_name, 0, 14) == "tempWaterSpout" then
if evt.param1 == 1 then
LF_SetSpoutGadgetState(context, 902)
elseif evt.param1 == 2 then
LF_SetSpoutGadgetState(context, 0)
end
end
return 0
end
--================================================================
-- Initialize
--================================================================
LF_Initialize_Group(triggers, suites, variables, gadgets, regions)

View File

@@ -0,0 +1,266 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: VarunaWorkOption
|| owner: zijun.ma
|| description: 根据GadgetState切换对应WorkOption
|| LogName: TD_VarunaWorkOption
|| Protection: [Protection]
=======================================]]
--[[
--]]
--def描述状态
--[[
local optionPlay ={
gadgetCid = 257001, --只确认该物件的GadgetState
optionCid = 257002, --只修改此物件的操作台
}
--]]
local gadgetStateTable =
{
[201] = {optionList = {776,777}}, --晴天
[202] = {optionList = {775,777}}, --阴天
[203] = {optionList = {775,776}}, --切换
}
local weatherStateTable = {
[0] = {state = 202}, --雨
[1] = {state = 201}, --晴
[2] = {state = 203}, --切换
}
local gearTable = {
[775] = {weatherState = 1}, --晴
[776] = {weatherState = 0}, --雨
[777] = {weatherState = 2}, --切换
}
local Tri_VarunaWorkOption = {
-- GroupLoad
{ keyWord = "CheckState",event = EventType.EVENT_GROUP_LOAD, source = "", trigger_count = 0},
-- GadgetStateChange
{ keyWord = "PressButton",event = EventType.EVENT_SELECT_OPTION, source = "", trigger_count = 0},
-- GadgetStateChange
{ keyWord = "ChangeState",event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", trigger_count = 0},
-- 中枢开启
{ keyWord = "DeviceActive",event = EventType.EVENT_LUA_NOTIFY, source = "VarunaDevice", trigger_count = 0},
}
function LF_Initialize_VarunaWorkOption()
local startConfigID = 50040001
for _,v in pairs(Tri_VarunaWorkOption) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(Tri_VarunaWorkOption,{2})
return 0
end
--[[=====================================
|| Action
--======================================]]
function action_CheckState(context,evt)
-- 检查状态
local finalWeatherState = ScriptLib.GetGroupVariableValueByGroup(context, "finalWeatherState", 133303126)
local state = ScriptLib.GetGadgetStateByConfigId(context, 0, optionPlay.gadgetCid)
ScriptLib.PrintContextLog(context, "## [TD_VarunaWorkOption] action_CheckState || finalWeatherState = "..finalWeatherState..", ||state = "..state)
if state > 0 and nil ~= weatherStateTable[finalWeatherState] then
local targetState = weatherStateTable[finalWeatherState].state
if targetState ~= state then
-- 如果状态不一致就切换,因为状态修改会切换状态
ScriptLib.SetGadgetStateByConfigId(context, optionPlay.gadgetCid, targetState)
else
-- 如果状态一致,就仅设置操作台
LF_SetOptionByState(context,state)
end
end
return 0
end
function action_PressButton(context,evt)
local gearid = evt.param2
local gearData = gearTable[gearid]
ScriptLib.PrintContextLog(context, "## [TD_VarunaWorkOption] action_PressButton || gearCid = "..gearid)
if gearData ~= nil then
local weatherState = gearData.weatherState
local oldState = ScriptLib.GetGadgetStateByConfigId(context, 0, optionPlay.gadgetCid)
LF_ClearOptionByState(context,oldState)
ScriptLib.SetGroupVariableValueByGroup(context, "finalWeatherState", weatherState, 133303126)
ScriptLib.PrintContextLog(context, "## [TD_VarunaWorkOption] 修改finalWeatherState 为" .. weatherState)
end
return 0
end
function action_ChangeState(context,evt)
-- 检查状态
local cid = evt.param2
if optionPlay.gadgetCid ~= cid then
return 0
end
local newState = evt.param1
LF_SetOptionByState(context,newState)
return 0
end
function action_DeviceActive(context,evt)
-- 获取对应天气
local finalWeatherState = ScriptLib.GetGroupVariableValueByGroup(context, "finalWeatherState", 133303126)
if nil == weatherStateTable[finalWeatherState] then
ScriptLib.PrintContextLog(context, "## [TD_VarunaWorkOption] 不合法的finalWeatherState值为" .. finalWeatherState)
return 0
end
-- 根据finalWeatherState设置中枢的状态
local gadgetState = weatherStateTable[finalWeatherState].state
ScriptLib.SetGadgetStateByConfigId(context, optionPlay.gadgetCid, gadgetState)
ScriptLib.PrintContextLog(context, "## [TD_VarunaWorkOption] gadget = "..optionPlay.gadgetCid..", state is set to "..gadgetState)
return 0
end
--[[=====================================
|| LocalFunction
--======================================]]
function LF_SetOptionByState(context,state)
local stateData = gadgetStateTable[state]
if nil ~= stateData then
local gearList = stateData.optionList
ScriptLib.PrintContextLog(context, "## TD_VarunaWorkOption 对应需要添加的 gearList = " .. LF_ArrayToString(gearList))
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, optionPlay.optionCid, gearList)
end
return 0
end
function LF_ClearOptionByState(context,state)
local stateData = gadgetStateTable[state]
if nil ~= stateData then
local gearList = stateData.optionList
ScriptLib.PrintContextLog(context, "## TD_VarunaWorkOption 对应需要删除的 gearList = " .. LF_ArrayToString(gearList))
for i = 1,#gearList do
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, optionPlay.optionCid, gearList[i])
end
end
return 0
end
function LF_ChangeDeviceState(context, prev_context, finalWeatherState)
ScriptLib.PrintContextLog(context, "## [TD_VarunaWorkOption] LF_ChangeDeviceState is called. finalWeatherState =" .. finalWeatherState)
local state = ScriptLib.GetGadgetStateByConfigId(context, 0, optionPlay.gadgetCid)
if 0 == state then
ScriptLib.PrintContextLog(context, "## [TD_VarunaWorkOption] 当前中枢未解锁")
return 0
end
if nil ~= weatherStateTable[finalWeatherState] then
local gadgetState = weatherStateTable[finalWeatherState].state
ScriptLib.SetGadgetStateByConfigId(context, optionPlay.gadgetCid, gadgetState)
ScriptLib.PrintContextLog(context, "## [TD_VarunaWorkOption] gadget = "..optionPlay.gadgetCid..", state is set to "..gadgetState)
end
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for _,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for _,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for _,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for _,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据数组的长度修饰num
function Fix(value,array,error)
if value < 1 then
ScriptLib.PrintLog(error .. "value = " .. value)
return 1
end
if value > #array then
ScriptLib.PrintLog(error .. "value = " .. value)
return #array
end
return value
end
-- 判断特定值是否在Table中
function LF_IsInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return true;
end
end
return false;
end
-- 返回特定值在Table中的第一个位置
function LF_GetIndexInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return k;
end
end
return 0;
end
LF_Initialize_VarunaWorkOption()

View File

@@ -0,0 +1,221 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: VisualizationPlant
|| owner: zijun.ma
|| description: 显形植物机制
|| LogName: TD_VisualizationPlant
|| Protection: [Protection]
=======================================]]
--
local RequireSuite = {}
--[[
local WatcherList ={
[84001] = { pointArray = 110200022,pointArrayList = {1,2,3}},
[84002] = { pointArray = 110200022,pointArrayList = {4,5,6}},
}
--]]
local VisualizationPlant_Trigger = {
{ keyWord = "CheckFlowerCreate", event = EventType.EVENT_GADGET_CREATE, source = "", trigger_count = 0},
{ keyWord = "CheckPoint", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", trigger_count = 0},
{ keyWord = "StageChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", trigger_count = 0},
}
function LF_Initialize_VisualizationPlant()
local startConfigID = 40030001
for _,v in pairs(VisualizationPlant_Trigger) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(VisualizationPlant_Trigger,RequireSuite)
return 0
end
--[[=====================================
|| action函数
--======================================]]
function action_CheckFlowerCreate(context,evt)
ScriptLib.PrintContextLog(context, "## TD_VisualizationPlant CheckFlowerCreate| configID = " .. evt.param1 )
local cid = evt.param1
if WatcherList[cid] ~= nil then
LF_StartMove(context,cid)
end
return 0
end
function action_CheckPoint(context,evt)
local cid = evt.param1
local curPoint = evt.param3
if WatcherList[cid] == nil then
return 0
end
local pointList = WatcherList[cid].pointArrayList
local curIndex = LF_GetIndexInTable(curPoint,pointList)
local nextIndex = LF_GetNextPointIndex(pointList,curIndex)
ScriptLib.SetGroupTempValue(context, "Cid_"..cid.."_Index",nextIndex, {})
local msg = "## TD_VisualizationPlant CheckPoint"
msg = msg .. "| configID = " .. cid
msg = msg .. "| nextIndex被保存 = " .. nextIndex
ScriptLib.PrintContextLog(context, msg)
return 0
end
function action_StageChange(context,evt)
local msg = "## TD_VisualizationPlant GadgetCheck"
msg = msg .. "| configID = " .. evt.param2
msg = msg .. "的状态被修改为 = " .. evt.param1
ScriptLib.PrintContextLog(context, msg)
local cid = evt.param2
if WatcherList[cid] ~= nil then
if 0 ~= evt.param1 then
-- 停下来!
ScriptLib.StopPlatform(context, cid)
else
-- 启动
LF_StartMove(context,cid)
end
-- 运营埋点
ScriptLib.MarkGroupLuaAction(context, "VisualizationPlant", "", {["group_id"] = base_info.group_id, ["config_id"] = cid, ["state_id"] = evt.param1})
end
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
function LF_StartMove(context,cid)
local curPointIndex = ScriptLib.GetGroupTempValue(context, "Cid_"..cid.."_Index", {})
local pointArray = WatcherList[cid].pointArray
local pointList = WatcherList[cid].pointArrayList
if 0 == curPointIndex then
ScriptLib.SetGroupTempValue(context, "Cid_"..cid.."_Index", 1, {})
curPointIndex = 1
end
local curPath = LF_GetStartPath(pointList,curPointIndex)
ScriptLib.SetPlatformPointArray(context, cid, pointArray, curPath, { route_type = 2,record_mode=0 })
local msg = "## TD_VisualizationPlant LF_StartMove"
msg = msg .. "| curPointIndex = " .. cid
msg = msg .. "| configID = " .. cid
msg = msg .. "| pointArray = " .. pointArray
msg = msg .. "| pointArrayList = " .. LF_ArrayToString(pointList)
msg = msg .. "| curPath = " .. LF_ArrayToString(curPath)
msg = msg .. " 开始移动 "
ScriptLib.PrintContextLog(context, msg)
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据起点获得点阵资料
function LF_GetStartPath(pointArrayList, curPointIndex)
local path = {}
local pointList = pointArrayList
if pointList[curPointIndex] == nil then
return path
end
for i = 1,#pointList do
local point = pointList[curPointIndex]
table.insert(path,point)
curPointIndex = LF_GetNextPointIndex(pointList,curPointIndex)
end
return path
end
function LF_GetNextPointIndex(pointList, curPointIndex)
local nextPointIndex = curPointIndex + 1
if nextPointIndex > #pointList then
nextPointIndex = 1
end
return nextPointIndex
end
-- 返回特定值在Table中的第一个位置
function LF_GetIndexInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return k;
end
end
return 0;
end
LF_Initialize_VisualizationPlant()

View File

@@ -0,0 +1,233 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_0]
--[[======================================
|| filename: VisualizationPlantOne
|| owner: zijun.ma
|| description: 显形植物机制
|| LogName: TD_VPOne
|| Protection: [Protection]
=======================================]]
--
local RequireSuite = {}
local WatcherList ={
[defs.gadget_VP] = { pointArray = defs.pointarray_id},
}
local VPOne_Trigger = {
{ keyWord = "CheckFlowerCreate", event = EventType.EVENT_GADGET_CREATE, source = "", trigger_count = 0},
{ keyWord = "CheckPoint", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", trigger_count = 0},
{ keyWord = "StageChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", trigger_count = 0},
}
function LF_Initialize_VPOne()
local startConfigID = 40030001
for _,v in pairs(VPOne_Trigger) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_AutoGenList()
LF_InsertTriggers(VPOne_Trigger,RequireSuite)
return 0
end
function LF_AutoGenList()
local pointArrayList = {}
for i = defs.minPoint,defs.maxPoint do
table.insert(pointArrayList,i)
end
WatcherList[defs.gadget_VP].pointArrayList = pointArrayList
end
--[[=====================================
|| action函数
--======================================]]
function action_CheckFlowerCreate(context,evt)
ScriptLib.PrintContextLog(context, "## TD_VPOne CheckFlowerCreate| configID = " .. evt.param1 )
local cid = evt.param1
if WatcherList[cid] ~= nil and ScriptLib.GetGadgetStateByConfigId(context, 0, cid) == 0 then
LF_StartMove(context,cid)
end
return 0
end
function action_CheckPoint(context,evt)
local cid = evt.param1
local curPoint = evt.param3
if WatcherList[cid] == nil then
return 0
end
local pointList = WatcherList[cid].pointArrayList
local curIndex = LF_GetIndexInTable(curPoint,pointList)
local nextIndex = LF_GetNextPointIndex(pointList,curIndex)
ScriptLib.SetGroupTempValue(context, "Cid_"..cid.."_Index",nextIndex, {})
local msg = "## TD_VPOne CheckPoint"
msg = msg .. "| configID = " .. cid
msg = msg .. "| nextIndex被保存 = " .. nextIndex
ScriptLib.PrintContextLog(context, msg)
return 0
end
function action_StageChange(context,evt)
local msg = "## TD_VPOne GadgetCheck"
msg = msg .. "| configID = " .. evt.param2
msg = msg .. "的状态被修改为 = " .. evt.param1
ScriptLib.PrintContextLog(context, msg)
local cid = evt.param2
if WatcherList[cid] ~= nil then
if 0 ~= evt.param1 then
local resultVec = ScriptLib.GetPlatformPointArray(context, cid)
if resultVec ~= nil and resultVec[1] ~= 0 then
-- 停下来!
ScriptLib.StopPlatform(context, cid)
end
else
-- 启动
LF_StartMove(context,cid)
end
end
return 0
end
--[[=====================================
|| 流程函数
--======================================]]
function LF_StartMove(context,cid)
local curPointIndex = ScriptLib.GetGroupTempValue(context, "Cid_"..cid.."_Index", {})
local pointArray = WatcherList[cid].pointArray
local pointList = WatcherList[cid].pointArrayList
local gadgetState = ScriptLib.GetGadgetStateByConfigId(context,0,cid)
if 0 ~= gadgetState then
ScriptLib.PrintContextLog(context, "## TD_VPOne GadgetState为0不移动")
return 0
end
if 0 == curPointIndex then
ScriptLib.SetGroupTempValue(context, "Cid_"..cid.."_Index", 1, {})
curPointIndex = 1
end
local curPath = LF_GetStartPath(pointList,curPointIndex)
ScriptLib.SetPlatformPointArray(context, cid, pointArray, curPath, { route_type = 2,record_mode=0 })
local msg = "## TD_VPOne LF_StartMove"
msg = msg .. "| curPointIndex = " .. cid
msg = msg .. "| configID = " .. cid
msg = msg .. "| pointArray = " .. pointArray
msg = msg .. "| pointArrayList = " .. LF_ArrayToString(pointList)
msg = msg .. "| curPath = " .. LF_ArrayToString(curPath)
msg = msg .. " 开始移动 "
ScriptLib.PrintContextLog(context, msg)
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for k,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 根据起点获得点阵资料
function LF_GetStartPath(pointArrayList, curPointIndex)
local path = {}
local pointList = pointArrayList
if pointList[curPointIndex] == nil then
return path
end
for i = 1,#pointList do
local point = pointList[curPointIndex]
table.insert(path,point)
curPointIndex = LF_GetNextPointIndex(pointList,curPointIndex)
end
return path
end
function LF_GetNextPointIndex(pointList, curPointIndex)
local nextPointIndex = curPointIndex + 1
if nextPointIndex > #pointList then
nextPointIndex = 1
end
return nextPointIndex
end
-- 返回特定值在Table中的第一个位置
function LF_GetIndexInTable(value, table)
for k,v in ipairs(table) do
if v == value then
return k;
end
end
return 0;
end
LF_Initialize_VPOne()