添加配置表

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,228 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: AnimalSeelie
|| owner: weiwei.sun
|| description: 2.8海岛动物仙灵移动逻辑。 按LD配置习惯沿用雷电飞贼的GroupVar结构(group例: 133212006)
|| LogName: ## [AnimalSeelie]
|| Protection:
=======================================]]
--[[
local defs = {
gadget_animal = 26001,
pointarray_ID = 110200012,
maxPointCount = 8,
gadget_Reward = 26002,--完成后创生物件
addSuite_Info = 2,--完成后创生suite
pointInfo = {2,5,8},
animal_state = {201, 202, 203}
}
]]
local Triggers_AnimalSeelie = {
{ config_id = 8000001, name = "Avatar_Near_Platform", event = EventType.EVENT_AVATAR_NEAR_PLATFORM, source = "", condition = "", action = "action_Avatar_Near_Platform", trigger_count = 0 },
{ config_id = 8000002, name = "Platform_Reach", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_Platform_Reach", trigger_count = 0 },
{ config_id = 8000003, name = "AnimalSeelie_Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_AnimalSeelie_Group_Load", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1, #Triggers_AnimalSeelie do
table.insert(triggers, Triggers_AnimalSeelie[i])
end
--非flow
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(Triggers_AnimalSeelie) do
table.insert(suites[i].triggers, v.name)
end
end
--是否已结束
table.insert(variables,{ config_id = 50000001, name = "isFinished", value = 0, no_refresh = true })
--当前在pointArray第几个点
table.insert(variables,{ config_id = 50000002, name = "cur_point_index", value = 0, no_refresh = true })
--下次要停在defs.pointInfo的第几个点
table.insert(variables,{ config_id = 50000003, name = "next_index", value = 1, no_refresh = true })
--flow
else
table.insert(variables,{ config_id = 50000001, name = "isFinished", value = 0, no_refresh = true })
table.insert(variables,{ config_id = 50000002, name = "cur_point_index", value = 0, no_refresh = true })
table.insert(variables,{ config_id = 50000003, name = "next_index", value = 1, no_refresh = true })
for i = 1, #suite_disk do
for k,v in pairs(Triggers_AnimalSeelie) do
table.insert(suite_disk[i].triggers, v.name)
end
if defs.addSuite_Info == i then
table.insert(suite_disk[i].variables,{ config_id = 50000001, name = "isFinished", value = 1, no_refresh = true })
table.insert(suite_disk[i].variables,{ config_id = 50000002, name = "cur_point_index", value = 0, no_refresh = true })
table.insert(suite_disk[i].variables,{ config_id = 50000003, name = "next_index", value = 1, no_refresh = true })
else
table.insert(suite_disk[i].variables,{ config_id = 50000001, name = "isFinished", value = 0, no_refresh = true })
table.insert(suite_disk[i].variables,{ config_id = 50000002, name = "cur_point_index", value = 0, no_refresh = true })
table.insert(suite_disk[i].variables,{ config_id = 50000003, name = "next_index", value = 1, no_refresh = true })
end
end
end
end
function action_AnimalSeelie_Group_Load(context)
ScriptLib.SetGroupVariableValue(context, "cur_point_index", 0)
ScriptLib.SetGroupVariableValue(context, "next_index", 1)
return 0
end
function LF_GetNextPath(context)
local path = {}
--当前在pointArray的第几个点
local cur_point = ScriptLib.GetGroupVariableValue(context, "cur_point_index")
--范围检查 cur_point是否不在table内,则设为初始点
if false == LF_CheckIsInTable(context, cur_point, defs.pointInfo) then
cur_point = defs.pointInfo[1]
ScriptLib.PrintContextLog(context, "## [AnimalSeelie] LF_GetNextPath: cur_point not in pointInfo!")
end
--下次要停在defs.pointInfo的第几个点
local next_index = ScriptLib.GetGroupVariableValue(context, "next_index")
if 0 > next_index then
next_index = 1
end
local stop_point = cur_point
ScriptLib.PrintContextLog(context, "## [AnimalSeelie] LF_GetNextPath: Set path. cur_point_index@"..cur_point.." next_index@"..next_index)
--范围检查
if next_index > #defs.pointInfo then
ScriptLib.PrintContextLog(context, "## [AnimalSeelie] LF_GetNextPath: path index overflow!")
--设为当前点位
table.insert(path, defs.pointInfo[#defs.pointInfo])
else
stop_point = defs.pointInfo[next_index]
--从起步点(当前点+1开始到下次停的点为止存为一个table
--如果由于LD手动修改stop_point小于起步点则将该点直接设为目标点没有过程点
if cur_point >= stop_point then
table.insert(path, stop_point)
else
for i = cur_point + 1, stop_point do
table.insert(path, i)
end
end
end
ScriptLib.PrintContextLog(context, "## [AnimalSeelie] LF_GetNextPath: Set path. From point@"..path[1].." to point@"..stop_point)
return path
end
function LF_MovePlatform(context)
ScriptLib.SetPlatformPointArray(context, defs.gadget_animal, defs.pointarray_ID, LF_GetNextPath(context), { route_type = 0 })
return 0
end
-- 到达路点时触发操作
function action_Platform_Reach(context, evt)
--消息不是组内动物仙灵
if defs.gadget_animal ~= evt.param1 then
return -1
end
ScriptLib.PrintContextLog(context, "## [AnimalSeelie] Platform_Reach: param2@"..evt.param2.." param3@"..evt.param3)
--是否到达终点
if evt.param3 == defs.maxPointCount then
--埋点
ScriptLib.MarkGroupLuaAction(context, "AnimalSeelieEnd", "", {["group_id"] = base_info.group_id, ["config_id"] = 0})
ScriptLib.SetGroupVariableValue(context, "isFinished", 1)
ScriptLib.KillEntityByConfigId(context, { config_id = defs.gadget_animal })
ScriptLib.StopPlatform(context, defs.gadget_animal)
--创生奖励
if nil ~= defs.gadget_Reward and 0 ~= defs.gadget_Reward then
ScriptLib.CreateGadget(context, { config_id = defs.gadget_Reward })
end
if nil ~= defs.addSuite_Info and 0 ~= defs.addSuite_Info then
ScriptLib.SetFlowSuite(context, base_info.group_id, defs.addSuite_Info)
end
return 0
end
--是否需要停下
local next = ScriptLib.GetGroupVariableValue(context, "next_index")
if evt.param3 == defs.pointInfo[next] then
ScriptLib.StopPlatform(context, defs.gadget_animal)
next = next + 1
ScriptLib.SetGroupVariableValue(context, "cur_point_index", evt.param3)
ScriptLib.SetGroupVariableValue(context, "next_index", next)
end
return 0
end
--玩家靠近时触发操作
function action_Avatar_Near_Platform(context, evt)
ScriptLib.PrintContextLog(context, "## [AnimalSeelie] Avatar_Near_Platform: configID@"..evt.param1)
--不是自己Group里的飞贼
if defs.gadget_animal ~= evt.param1 then
return 0
end
--903底座状态,kill 结束
local state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.gadget_animal)
if state == 903 then
ScriptLib.KillEntityByConfigId(context, { config_id = defs.gadget_animal })
return 0
end
if 1 == ScriptLib.GetGroupVariableValue(context, "isFinished") then
return 0
end
if nil ~= defs.animal_state then
LF_SetAnimaState(context)
end
--埋点
if 0 == ScriptLib.GetGroupVariableValue(context, "cur_point_index") then
ScriptLib.MarkGroupLuaAction(context, "AnimalSeelieStart", "", {["group_id"] = base_info.group_id, ["config_id"] = evt.param1, ["animal"] = state})
end
LF_MovePlatform(context)
return 0
end
function LF_SetAnimaState(context)
local next = ScriptLib.GetGroupVariableValue(context, "next_index")
--范围修正
if next > #defs.animal_state then
next = #defs.animal_state
ScriptLib.SetGroupVariableValue(context, "next_index", next)
ScriptLib.PrintContextLog(context, "## [AnimalSeelie] LF_SetAnimaState: next_index overflow!. Set to@"..next)
end
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_animal, defs.animal_state[next])
return 0
end
--用于检查value是否在目标table中
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,453 @@
--[[
local defs = {
--开启操作台configID
starter_gadget = ,
--终点Region的ConfigID
end_region = ,
--限定region的configID
play_region = ,
--限定region所在suite
play_region_suite = ,
--gallery_id
gallery_id = ,
--计数定义。
--这个赛道中每种行为写入哪个param
--行为1-持续加速20秒 2-障碍破坏 3-(未定义)
counter =
{
["param1"] = 2,
["param2"] = 0,
["param3"] = 0,
},
father_challenge = 父挑战挑战ID,
child_time_challenge =
{
{challenge_id = 计时挑战1挑战ID, aim = 时间限制秒},
{challenge_id = 计时挑战2挑战ID, aim = 时间限制秒},
},
child_count_challenge =
{
{challenge_id = 计数挑战1挑战ID, aim = 目标数},
},
}
]]--
local cfg = {
--开启挑战选项id
start_option = 175,
--父挑战ID
challenge_id = 2018,
--子挑战1 ID
child_1 = 2019,
--子挑战2 ID
child_2 = 2020,
--子挑战3 ID
child_3 = 2021,
--隐藏子挑战 ID
child_end = 2022,
--父挑战总限时
total_time = 9999,
--赛道和陈列室对应
exhiKey_all ={
[199003065] = {"Activity_SummerTimeV2_BoatRace_L1_Count1","Activity_SummerTimeV2_BoatRace_L1_Count2"},
[199004061] = {"Activity_SummerTimeV2_BoatRace_L2_Count1"},
[199003025] = {"Activity_SummerTimeV2_BoatRace_L3_Count1"},
[199001094] = {"Activity_SummerTimeV2_BoatRace_L4_Count1"},
[199001098] = {"Activity_SummerTimeV2_BoatRace_L5_Count1"},
[199002079] = {"Activity_SummerTimeV2_BoatRace_L6_Count1"},
}
}
local extraTriggers = {
{ config_id = 8000001, name = "Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "",condition = "",action = "action_Challenge_Success",trigger_count= 0},
{ config_id = 8000002, name = "Challenge_Fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "",condition = "",action = "action_Challenge_Fail",trigger_count= 0},
{ config_id = 8000003, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "",condition = "",action = "action_Gallery_Stop",trigger_count= 0},
{ config_id = 8000004, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Select_Option", trigger_count = 0 },
{ config_id = 8000005, name = "Group_Will_Unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_Group_Will_Unload", trigger_count = 0 },
{ config_id = 8000006, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000007, name = "Enter_Final_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_Enter_Final_Region", action = "", trigger_count = 0, tag = "666" },
{ config_id = 8000008, name = "Leave_Play_Region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_Leave_Play_Region", trigger_count = 0 },
--挑战计数项
{ config_id = 8000009, name = "Counter_Variable_Change_1", event = EventType.EVENT_VARIABLE_CHANGE, source = "counter_1", condition = "", action = "", trigger_count = 0 , tag = "1" },
{ config_id = 8000010, name = "Counter_Variable_Change_2", event = EventType.EVENT_VARIABLE_CHANGE, source = "counter_2", condition = "", action = "", trigger_count = 0 , tag = "2" },
{ config_id = 8000011, name = "Counter_Variable_Change_3", event = EventType.EVENT_VARIABLE_CHANGE, source = "counter_3", condition = "", action = "", trigger_count = 0 , tag = "3" },
--进入隐藏道路计数
{ config_id = 8000012, name = "Enter_Hiden_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Hiden_Region", trigger_count = 0 },
--教学圈
{ config_id = 8000013, name = "Enter_Tutorial_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Tutorial_Region", trigger_count = 0 },
}
function Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "counter_1", value = 0})
table.insert(variables,{ config_id = 50000002, name = "counter_2", value = 0})
table.insert(variables,{ config_id = 50000003, name = "counter_3", value = 0})
return 0
end
--机关开启条件及开启处理
function action_Select_Option(context, evt)
if defs.starter_gadget ~= evt.param1 or cfg.start_option ~= evt.param2 then
return 0
end
--检查玩家处于开船状态
if 2 ~= ScriptLib.GetPlayerVehicleType(context,context.uid) then
ScriptLib.ShowReminder(context, 400041)
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Player not in boat.")
return 0
end
--检查联机状态
if true == ScriptLib.CheckIsInMpMode(context) then
ScriptLib.ShowReminder(context, 400053)
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Player in MP mode.")
return 0
end
--检查赛船挑战开启状态
if ScriptLib.IsChallengeStartedByChallengeId(context, cfg.challenge_id) then
ScriptLib.ShowReminder(context, 400046)
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Boat race has started.")
return 0
end
--清空陈列室
for k, v in pairs(cfg.exhiKey_all[base_info.group_id]) do
ScriptLib.ClearExhibitionReplaceableData(context, context.uid, v)
end
ScriptLib.SetGroupTempValue(context, "exhi_counter_1", 0, {})
ScriptLib.SetGroupTempValue(context, "exhi_counter_2", 0, {})
ScriptLib.SetGroupTempValue(context, "exhi_counter_3", 0, {})
--开启挑战
ScriptLib.CreateFatherChallenge(context, cfg.challenge_id, cfg.challenge_id, cfg.total_time, {success = 10, fail = 5})
ScriptLib.StartFatherChallenge(context, cfg.challenge_id)
--填加计时类子挑战
for k,v in pairs(defs.child_time_challenge) do
ScriptLib.AttachChildChallenge(context, cfg.challenge_id, v.challenge_id*10 + k, v.challenge_id, { v.aim, 4, 666, 1},{},{success = 10,fail = 0})
end
--填加计数类子挑战
for k,v in pairs(defs.child_count_challenge) do
--参数1 event_type所在枚举序号 参数2 trigger_tag参数3 次数参数4Bool次数达成是否计为成功参数5初始次数值
ScriptLib.AttachChildChallenge(context, cfg.challenge_id, v.challenge_id*10 + k, v.challenge_id, { 3, k, v.aim},{},{success = 0,fail = 0})
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Challenge started. start galleryID@"..defs.gallery_id.." father_challengeID@"..cfg.challenge_id)
end
--不限时抵达终点隐藏挑战
ScriptLib.AttachChildChallenge(context, cfg.challenge_id, cfg.child_end, cfg.child_end, { 4, 666, 1, 1},{},{success = 10,fail = 0})
--处理操作台
ScriptLib.SetGadgetStateByConfigId(context, defs.starter_gadget, GadgetState.GearStart)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.starter_gadget, cfg.start_option)
--开Gallery
ScriptLib.StartGallery(context, defs.gallery_id)
--添加region
if nil ~= defs.play_region_suite then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.play_region_suite)
end
-- 添加suite2内容
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
--处理VisionType
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Challenge started. start galleryID@"..defs.gallery_id.." father_challengeID@"..cfg.challenge_id)
return 0
end
function action_Enter_Tutorial_Region(context, evt)
if nil == defs.guide_region then
return 0
end
if evt.param1 ~= defs.guide_region then
return 0
end
LF_TryShowGuide(context)
return 0
end
-- 处理成功
function action_Challenge_Success(context, evt)
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Challenge success.")
if evt.param1 ~= cfg.challenge_id then
return 0
end
local uid = ScriptLib.GetSceneOwnerUid(context)
LF_ReportSkillExhibition(context, uid)
local time = cfg.total_time - evt.param2
if time > 0 then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, { ["time"]= time, ["uid"] = uid })
else
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, { ["time"]= 0, ["uid"] = uid })
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] #WARN# Get unexpected time usage.")
end
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
--设置操作台选项
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.starter_gadget, {cfg.start_option})
--结束Gallery
ScriptLib.StopGallery(context, defs.gallery_id, false)
return 0
end
-- 处理挑战失败(超时、Group卸载、P键)
function action_Challenge_Fail(context, evt)
if evt.param1 ~= cfg.challenge_id then
return -1
end
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Challenge failed.")
local uid = ScriptLib.GetSceneOwnerUid(context)
local time = cfg.total_time - evt.param2
if time > 0 then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, { ["time"]= time, ["uid"] = uid })
else
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, { ["time"]= 0, ["uid"] = uid })
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] #WARN# Get unexpected time usage.")
end
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
--设置操作台选项
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.starter_gadget, {cfg.start_option})
--结束Gallery
ScriptLib.StopGallery(context, defs.gallery_id, true)
return 0
end
-- Gallery结束
function action_Gallery_Stop(context, evt)
--恢复VisionType
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.SetPlayerGroupVisionType(context, {uid}, {1})
ScriptLib.RevertPlayerRegionVision(context, uid)
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Gallery stoped. is_fail@"..evt.param2.." reason@"..evt.param3)
--挑战计数重置
ScriptLib.SetGroupVariableValue(context, "counter_1", 0)
ScriptLib.SetGroupVariableValue(context, "counter_2", 0)
ScriptLib.SetGroupVariableValue(context, "counter_3", 0)
return 0
end
-- 进入最终区域
function condition_Enter_Final_Region(context, evt)
-- 判断角色数量不少于1
if evt.param1 ~= defs.end_region then
return false
end
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
return false
end
return true
end
--处理Group重载
function action_Group_Load( context,evt )
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Group load.")
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = init_config.suite })
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.starter_gadget, {cfg.start_option})
return 0
end
function action_Group_Will_Unload( context,evt )
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Group will unload.")
ScriptLib.StopChallenge(context, cfg.challenge_id, 0)
return 0
end
function action_Leave_Play_Region(context, evt)
if defs.play_region ~= evt.param1 then
return 0
end
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Player leave play region.")
ScriptLib.StopChallenge(context, cfg.challenge_id, 0)
return 0
end
--陈列室上传
function LF_ReportSkillExhibition(context, uid)
for i, v in ipairs(cfg.exhiKey_all[base_info.group_id]) do
local record = ScriptLib.GetGroupTempValue(context, "exhi_counter_"..i, {})
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] LF_ReportSkillExhibition. exhi_counter_"..i.. "record@"..record)
if 0 < record then
ScriptLib.AddExhibitionReplaceableData(context, uid, v, record)
end
end
return 0
end
function LF_GetGalleryParamName(context, type)
for k,v in pairs(defs.counter) do
if v == type then
return k
end
end
return 0
end
--type1-冲刺20秒 2-障碍破坏 3-(未定义) 4-冲刺时吸
function SLC_BoatRaceV2_Counter(context, type)
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] SLC_BoatRaceV2_Counter. type@"..type)
--确认是要加本赛道gallery的哪个param
local gallery_param = LF_GetGalleryParamName(context, type)
if 0 == gallery_param then
return 0
end
--如果是物件破坏,看是否在计数白名单内
if 2 == type then
if nil ~= defs.gadget_filter then
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
local gadget_id = gadgets[config_id].gadget_id
if LF_CheckIsInTable(context, gadget_id, defs.gadget_filter) then
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] SLC_BoatRaceV2_Counter. Count gadget. config_id@"..config_id.." gadget_id@"..gadget_id)
else
return 0
end
end
end
--update gallery
if 0 ~= gallery_param then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, { [gallery_param]= 1 , ["uid"] = ScriptLib.GetSceneOwnerUid(context)})
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Update gallery. param@"..gallery_param)
end
--设置陈列室缓存、触发挑战计数
if "param1" == gallery_param then
ScriptLib.ChangeGroupTempValue(context, "exhi_counter_1", 1, {})
ScriptLib.ChangeGroupVariableValue(context, "counter_1", 1)
elseif "param2" == gallery_param then
ScriptLib.ChangeGroupTempValue(context, "exhi_counter_2", 1, {})
ScriptLib.ChangeGroupVariableValue(context, "counter_2", 1)
elseif "param3" == gallery_param then
ScriptLib.ChangeGroupTempValue(context, "exhi_counter_3", 1, {})
ScriptLib.ChangeGroupVariableValue(context, "counter_3", 1)
end
return 0
end
--进入隐藏赛道的计数
function action_Enter_Hiden_Region(context, evt)
if nil == defs.hiden_region then
return 0
end
--是否是指定region
if LF_CheckIsInTable(context, evt.param1, defs.hiden_region) then
--看看计入哪个param
local gallery_param = 0
for k,v in pairs(defs.counter) do
if v == 3 then
gallery_param = k
end
end
--update gallery
if 0 ~= gallery_param then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, { [gallery_param]= 1 })
ScriptLib.PrintContextLog(context, "## [BoatRaceV2] Updata gallery. param@"..gallery_param)
end
--设置陈列室缓存、触发挑战计数
if "param1" == gallery_param then
ScriptLib.ChangeGroupTempValue(context, "exhi_counter_1", 1, {})
ScriptLib.ChangeGroupVariableValue(context, "counter_1", 1)
elseif "param2" == gallery_param then
ScriptLib.ChangeGroupTempValue(context, "exhi_counter_2", 1, {})
ScriptLib.ChangeGroupVariableValue(context, "counter_2", 1)
elseif "param3" == gallery_param then
ScriptLib.ChangeGroupTempValue(context, "exhi_counter_3", 1, {})
ScriptLib.ChangeGroupVariableValue(context, "counter_3", 1)
end
--直接移除region免得记录是否enter过
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.REGION, evt.param1)
else
return 0
end
return 0
end
--[[
需求:
1-1 触发1174判断是否触发过1173
1-2 如果触发过1174没触发过1173则触发1173否则触发1175
其他 如果触发过1174和1175不触发否则触发1173
]]
function LF_TryShowGuide(context)
--是否弹过
--Activity_SummerTimeV2_BoatRace_Guide1
local havePlayed1 = ScriptLib.GetExhibitionAccumulableData(context, context.uid, 11405108)
--Activity_SummerTimeV2_BoatRace_Guide2
local havePlayed2 = ScriptLib.GetExhibitionAccumulableData(context, context.uid, 11405109)
--Activity_SummerTimeV2_BoatRace_Guide3
local havePlayed3 = ScriptLib.GetExhibitionAccumulableData(context, context.uid, 11405110)
if 0 < havePlayed3 then
return 0
end
--如果弹过第一关
if 0 < havePlayed1 then
--第二关1175
if 199004061 == base_info.group_id and 1 > havePlayed2 then
ScriptLib.ShowClientTutorial(context, 1175, {context.uid})
ScriptLib.AddExhibitionAccumulableData(context,context.uid, "Activity_SummerTimeV2_BoatRace_Guide2", 1)
else
--第二关以外其他关不弹
end
--如果没弹过第一关
else
--第一关 1174
if 199003065 == base_info.group_id then
ScriptLib.ShowClientTutorial(context, 1174, {context.uid})
ScriptLib.AddExhibitionAccumulableData(context,context.uid, "Activity_SummerTimeV2_BoatRace_Guide1", 1)
else
--如果没玩过第一关,任意关 1173
if 1 > havePlayed1 then
ScriptLib.ShowClientTutorial(context, 1173, {context.uid})
ScriptLib.AddExhibitionAccumulableData(context,context.uid, "Activity_SummerTimeV2_BoatRace_Guide3", 1)
end
end
end
return 0
end
--船行为埋点
function SLC_BoatRace_LuaMark(context, param1, param2, param3)
ScriptLib.MarkGroupLuaAction(context, "SummerTimeV2_Boat_1", "", {["change_type"] = param1, ["change_num"] = param2, ["after_num"] = param3})
return 0
end
--用于检查value是否在目标table中
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
Initialize()

View File

@@ -0,0 +1,39 @@
--[[======================================
|| filename: CloudNet
|| owner: luyao.huang
|| description: 2.8云网物件用
|| LogName: CloudNet
|| Protection:
=======================================]]--
local Tri = {
[1] = { name = "any_gadget_die_cloud_net", config_id = 8000001, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die_cloud_net", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
------------------------------------------------------------------
function action_any_gadget_die_cloud_net(context,evt)
for i = 1, #CloudNets do
if (evt.param1 == CloudNets[i].pillar_1 or evt.param1 == CloudNets[i].pillar_2) then
ScriptLib.PrintContextLog(context,"## [CloudNet]action_any_gadget_die_cloud_net: 柱子死亡"..evt.param1)
ScriptLib.KillEntityByConfigId(context,{group_id = base_info.group_id, config_id = CloudNets[i].pillar_1, EntityType.GADGET})
ScriptLib.KillEntityByConfigId(context,{group_id = base_info.group_id, config_id = CloudNets[i].pillar_2, EntityType.GADGET})
ScriptLib.KillEntityByConfigId(context,{group_id = base_info.group_id, config_id = CloudNets[i].net_1, EntityType.GADGET})
end
end
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,245 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: CloudPlatform
|| owner: weiwei.sun
|| description: 2.8踩亮云平台逻辑。分段加载、卸载
|| LogName: ## [CloudPlatform]
|| Protection:
=======================================]]
--[[
local defs = {
stages =
{
--key为第几段value1为这一段的起点suitevalue2为这一段的主体suite
--这些suite里不要放台子以外的gadget, 不要有InitSuite
[1] = { 1, 2 },
},
--判断玩家掉落region的在哪个suite里
--这个suite会在踩了第一个起点后加载在失败和成功时移除
region_suite = ,
--玩法完成时goto哪个suite
end_suite = ,
--防跳水板子config_id
board_id = ,
--防跳水板子config_id list
board_id_list = {},
}
]]
local Triggers = {
{ config_id = 8000001, name = "Tile_State_Change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Tile_State_Change", trigger_count = 0 },
{ config_id = 8000002, name = "FallDown_Leave_Region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_FallDown_Leave_Region", trigger_count = 0, forbid_guest = false},
{ config_id = 8000003, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1, #Triggers do
table.insert(triggers, Triggers[i])
table.insert(suites[init_config.suite].triggers,Triggers[i].name)
end
end
function action_Group_Load(context, evt)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.stages[1][1])
ScriptLib.SetGroupTempValue(context,"stage_index", 1, {})
LF_UnLoadAntiDivingBoard(context)
return 0
end
function LF_KillSuiteGadgets(context, suite)
for k,v in pairs(suites[suite].gadgets) do
ScriptLib.KillEntityByConfigId(context, { config_id = v })
end
return 0
end
function action_Tile_State_Change(context, evt)
--只监听踩亮
if 201 ~= evt.param1 then
return 0
end
--取得当前在第几段
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
--踩亮的是起点格,则加载对应的主体suite
local starter_gadget_table = suites[defs.stages[stage_index][1]].gadgets
if LF_CheckIsInTable(context, evt.param2, starter_gadget_table) then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.stages[stage_index][2])
--移除上一阶段的主体suite和起点suite
if 1 < stage_index then
--ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, defs.stages[stage_index - 1][1])
--ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, defs.stages[stage_index - 1][2])
--迭代为Kill
LF_KillSuiteGadgets(context, defs.stages[stage_index - 1][1])
LF_KillSuiteGadgets(context, defs.stages[stage_index - 1][2])
elseif 1 == stage_index then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.region_suite)
LF_LoadAntiDivingBoard(context)
LF_TryShowGuide(context)
end
--否则是主体里面的格子检查stage是否完成
else
if LF_CheckStageSuccess(context, stage_index) then
if LF_CheckIsFinalStage(context) then
ScriptLib.GoToGroupSuite(context, base_info.group_id, defs.end_suite)
LF_UnLoadAntiDivingBoard(context)
--埋点
ScriptLib.MarkGroupLuaAction(context, "CloudPlatform", "", {["group_id"] = base_info.group_id, ["result"] = 1})
else
--当前主体格全部锁定
LF_LockAllGadgets(context, stage_index)
--更新阶段
ScriptLib.SetGroupTempValue(context, "stage_index", stage_index + 1, {})
--加载下一阶段的起点suite
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.stages[stage_index][1])
end
end
end
return 0
end
--是否全部玩家离开Region
function LF_Check_AllPlayer_OutRegion(context, region_id)
local eid = ScriptLib.GetEntityIdByConfigId(context, region_id)
local count = ScriptLib.GetRegionEntityCount(context, { region_eid = eid, entity_type = EntityType.AVATAR })
ScriptLib.PrintContextLog(context, "## [CloudPlatform] Count player in region: regionID@"..region_id.. " playerCount@".. count)
if count < 1 then
return true
end
return false
end
--当前主体格、起点格全部切至202
function LF_LockAllGadgets(context, stage_index)
ScriptLib.PrintContextLog(context, "## [CloudPlatform] LF_LockAllGadgets. stage_index@"..stage_index)
local tile_gadget_table = suites[defs.stages[stage_index][2]].gadgets
for k,v in pairs(tile_gadget_table) do
ScriptLib.SetGadgetStateByConfigId(context, v, 202)
end
local starter_gadget_table = suites[defs.stages[stage_index][1]].gadgets
ScriptLib.SetGadgetStateByConfigId(context, starter_gadget_table[1], 202)
return 0
end
--检查是否完成当前stage的格子
function LF_CheckStageSuccess(context, stage_index)
ScriptLib.PrintContextLog(context, "## [CloudPlatform] LF_CheckStageSuccess. stage_index@"..stage_index)
--检查当前阶段的主体suite内gadgetstate是否均为201
local tile_gadget_table = suites[defs.stages[stage_index][2]].gadgets
for k,v in pairs(tile_gadget_table) do
if 201 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, v) then
ScriptLib.PrintContextLog(context, "## [CloudPlatform] LF_CheckStageSuccess return false. gadget@"..v)
return false
end
end
ScriptLib.PrintContextLog(context, "## [CloudPlatform] LF_CheckStageSuccess return true.")
return true
end
--检查当前stage是否为最后一个
function LF_CheckIsFinalStage(context)
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
ScriptLib.PrintContextLog(context, "## [CloudPlatform] LF_CheckIsFinalStage. stage_index@"..stage_index.." total stages@"..#defs.stages)
if stage_index >= #defs.stages then
return true
end
return false
end
function action_FallDown_Leave_Region(context, evt)
ScriptLib.PrintContextLog(context, "## [CloudPlatform] Player falled down. uid@"..evt.uid)
if LF_Check_AllPlayer_OutRegion(context, evt.param1) then
--埋点
ScriptLib.MarkGroupLuaAction(context, "CloudPlatform", "", {["group_id"] = base_info.group_id, ["result"] = 2})
ScriptLib.RefreshGroup(context, { group_id = 0, suite = 1 })
ScriptLib.SetGroupTempValue(context,"stage_index", 1, {})
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.stages[1][1])
end
return 0
end
--用于检查value是否在目标table中
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
function LF_UnLoadAntiDivingBoard(context)
if nil ~= defs.board_id then
ScriptLib.KillEntityByConfigId(context, { config_id = defs.board_id })
end
if nil ~= defs.board_id_list then
for k,v in pairs(defs.board_id_list) do
ScriptLib.KillEntityByConfigId(context, { config_id = v })
end
end
return 0
end
function LF_LoadAntiDivingBoard(context)
if nil ~= defs.board_id then
ScriptLib.CreateGadget(context, { config_id = defs.board_id })
end
if nil ~= defs.board_id_list then
for k,v in pairs(defs.board_id_list) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
return 0
end
function LF_TryShowGuide(context)
--在NewActivityPushTipsData配置中查找对应id, 并通过lua添加进活动中
--重复添加已有push tips返回-1 成功添加返回0
local ret = ScriptLib.TryRecordActivityPushTips(context, 2014001)
if 0 == ret then
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.ShowClientTutorial(context, 1167, uid_list)
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,392 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: ConstellationMachine
|| owner: weiwei.sun
|| description: 莫娜岛光线机关解谜逻辑。
|| LogName: ## [ConstellationMachine]
|| Protection:
=======================================]]
--[[
local defs = {
gear_info =
{ --connect: 每个物件各个旋转档位可连接的对象 0表示无可连接
--start_index: 初始在哪个旋转档位
[1] = { config_id= , connect = {0,0,0}, point_array_id = ,}
[2] = { config_id= , connect = {0,0,0,0}, point_array_id = ,}
[3] = { config_id= , connect = {0,0,0}, point_array_id = ,}
},
--几种解
solutions =
{
--[解法x] = {connect = {gear_info[1]切到它的第x档, gear_info[2]切到它的第y档...}ends = {这个连法中,哪些机关作为末端}}
[1] = { connection = {1,3,2,4,0,3,2,1,3,1}, ends = {11008,11008 }},
},
}
]]
local cfg =
{
connect_sgv = "SGV_Constellation_Target",--物件在Group中找此SGV的对象进行连线
mark_sgv = "SGV_Constellation_Mark",--物件自身的SGV
}
local extraTriggers={
{ config_id = 8000001, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Select_Option", trigger_count = 0 },
{ config_id = 8000002, name = "Reach_Point", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_Reach_Point", trigger_count = 0 },
{ config_id = 8000003, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000004, name = "Solution_Variable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "solution", condition = "", action = "action_Solution_Variable_Change", trigger_count = 0 },
{ config_id = 8000005, name = "Enter_Guide_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Guide_Region", trigger_count = 0 }
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
for k, v in pairs(defs.gear_info) do
local cfg = 50000000 + k
table.insert(variables,{ config_id = cfg, name = v.config_id.."rot", value = 1, no_refresh = true})
end
table.insert(variables,{ config_id = 51000001, name = "solution", value = 0, no_refresh = true})
end
--玩家旋转机关
function action_Select_Option(context, evt)
--排除非连线机关
if false == LF_CheckIsGear(context, evt.param1) then
return 0
end
--排除非旋转选项
if defs.turn_option ~= evt.param2 then
return 0
end
--操作台选项移除
ScriptLib.DelWorktopOption(context, evt.param2)
--开始转动物件
LF_TurnByStep(context, evt.param1)
--埋点 日志量太大 取消了
--ScriptLib.MarkGroupLuaAction(context, "ConstellationMachine", "", {["group_id"] = base_info.group_id, ["config_id"] = evt.param1, ["op_type"] = 1})
return 0
end
--当玩家匹配出一个解时将var设成解的index供外部监听
function action_Solution_Variable_Change(context, evt)
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] Solution_Variable_Change: Player finished solution. from@"..evt.param2.." to@"..evt.param1)
return 0
end
function LF_CheckSuccess(context)
--取得玩家的解
local player_result = LF_GetPlayerSolution(context)
if #player_result == 0 then
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] LF_CheckSuccess: Get player solution failed!")
return 0
end
--检查匹配的解
local match_solution = LF_CompareWithSolution(context, player_result)
if 0 == match_solution then
return 0
else
ScriptLib.SetGroupVariableValue(context, "solution", match_solution)
end
return 0
end
--返回当前匹配哪一个解
function LF_CompareWithSolution(context, player_result)
--每种解依次和玩家的解对比
for i, v in ipairs(defs.solutions) do
if true == LF_CompareList(context, player_result, v.connection, v.ends) then
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] LF_CompareWithSolution: solution@"..i.." match.")
return i
end
end
return 0
end
--取得玩家当前解
function LF_GetPlayerSolution(context)
local player_result = {}
for i = 1, #defs.gear_info do
local state = 0
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.gear_info[i].config_id)
if 201 == gadget_state then
state = ScriptLib.GetGroupVariableValue(context, defs.gear_info[i].config_id.."rot")
end
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] LF_GetPlayerSolution: Player_result. gear@"..defs.gear_info[i].config_id.." @"..state)
table.insert(player_result, i, state)
end
return player_result
end
--用于比较玩家的解和目标解是否相同
function LF_CompareList(context, player_result, connection, ends_list)
if #player_result ~= #connection then
return false
end
for i = 1, #player_result do
--发现玩家的第i个机关和正解的第i个朝向不同。
--若不是末端,则不成功如果是末端其gadget_state必须为0否则不成功
if player_result[i] ~= connection[i] then
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.gear_info[i].config_id)
if LF_CheckIsInTable(context, defs.gear_info[i].config_id, ends_list) and 0 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.gear_info[i].config_id) then
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] LF_CompareList: Ignore ending gear@"..defs.gear_info[i].config_id)
else
return false
end
end
end
return true
end
function action_Group_Load(context, evt)
--当前有几个机关在旋转。当此值不为0时机关不接受玩家攻击交互
ScriptLib.SetGroupTempValue(context, "turning_num", 0, {})
--Ability就绪后的物件数量当达到总数时分配SGV
ScriptLib.SetGroupTempValue(context, "ready_count", 0, {})
--计算总数
local total = 0
for k,v in pairs(defs.gear_info) do
total = total + 1
end
ScriptLib.SetGroupTempValue(context, "total", total, {})
LF_InitRotation(context)
return 0
end
function SLC_Constellation_AbilityReady(context)
ScriptLib.ChangeGroupTempValue(context, "ready_count", 1, {})
local ready = ScriptLib.GetGroupTempValue(context, "ready_count", {})
local total = ScriptLib.GetGroupTempValue(context, "total", {})
if ready >= total then
LF_SetConnectMark(context)
LF_SetConnectTarget(context)
end
return 0
end
--根据保存的旋转档位,设置物件旋转
function LF_InitRotation(context)
for k, v in pairs(defs.gear_info) do
local saved_point = ScriptLib.GetGroupVariableValue(context, v.config_id.."rot")
--开始旋转
ScriptLib.SetPlatformPointArray(context, v.config_id, v.point_array_id, { saved_point }, { route_type = 0, turn_mode = true })
--增加一个正在旋转的机关计数
ScriptLib.ChangeGroupTempValue(context, "turning_num", 1, {})
local turning_num = ScriptLib.GetGroupTempValue(context, "turning_num", {})
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] LF_InitRotation: gear@"..v.config_id.." saved_point@"..saved_point.." turning_num@"..turning_num)
end
return 0
end
--每个机关给自己上标识, 给其他机关找目标用
function LF_SetConnectMark(context)
for k, v in pairs(defs.gear_info) do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v.config_id, cfg.mark_sgv, v.config_id)
end
return 0
end
--根据当前场上的旋转情况为所有机关分配连线SGV
function LF_SetConnectTarget(context)
for k, v in pairs(defs.gear_info) do
--先清掉之前的连线对象
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v.config_id, cfg.connect_sgv, 0)
--设置新的连线对象
local turn_index = ScriptLib.GetGroupVariableValue(context, v.config_id.."rot")
if 0 >= turn_index then --返回-1、0为异常
return 0
end
if nil == v.connect[turn_index] then --配置不匹配
return 0
end
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v.config_id, cfg.connect_sgv, v.connect[turn_index])
--ScriptLib.PrintContextLog(context, "## [ConstellationMachine] LF_SetConnectTarget: gear@"..v.config_id.." turn_index@"..turn_index.." target@"..v.connect[turn_index])
end
return 0
end
--按档位循环切换
function LF_TurnByStep(context, config_id)
--取得config_id对应的机关信息
local gear = {}
for i, v in ipairs(defs.gear_info) do
if v.config_id == config_id then
gear = v
end
end
--关闭连线
if 0 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, gear.config_id) then
ScriptLib.SetGadgetStateByConfigId(context, gear.config_id, 0)
--记录 在结束转动时尝试恢复连线
ScriptLib.SetGroupTempValue(context, "closed_"..gear.config_id, 1, {})
end
--当前在哪个档位
local cur_point = ScriptLib.GetGroupVariableValue(context, config_id.."rot")
local next_point = 1
if #gear.connect > cur_point then
next_point = cur_point + 1
end
--开始旋转
ScriptLib.SetPlatformPointArray(context, config_id, gear.point_array_id, { next_point }, { route_type = 0, turn_mode = true })
--更新记录的旋转档位
ScriptLib.SetGroupVariableValue(context, config_id.."rot", next_point)
--增加一个正在旋转的机关计数
ScriptLib.ChangeGroupTempValue(context, "turning_num", 1, {})
return 0
end
--旋转结束
function action_Reach_Point(context, evt)
--排除非连线机关
if false == LF_CheckIsGear(context, evt.param1) then
return 0
end
--减少一个正在旋转的机关计数
ScriptLib.ChangeGroupTempValue(context, "turning_num", -1, {})
--恢复操作台选项
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, evt.param1, {defs.turn_option})
local turning_num = ScriptLib.GetGroupTempValue(context, "turning_num", {})
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] Reach_Point: Current turning_num@"..turning_num)
--如果都转完了,设置连接关系
if 0 == turning_num then
LF_SetConnectTarget(context)
--尝试恢复连线
if 1 == ScriptLib.GetGroupTempValue(context, "closed_"..evt.param1, {}) then
LF_TryConnect(context, evt.param1)
end
end
return 0
end
--机关在State 0被玩家攻击且SGV不为0则尝试连线。
function SLC_Constellation_TryConnect(context)
local turning_num = ScriptLib.GetGroupTempValue(context, "turning_num", {})
if 0 ~= turning_num then
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] Get SLC_Constellation_TryConnect while turning_num@"..turning_num..". Refused")
return 0
end
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
LF_TryConnect(context, config_id)
--埋点 日志量太大 取消了
--ScriptLib.MarkGroupLuaAction(context, "ConstellationMachine", "", {["group_id"] = base_info.group_id, ["config_id"] = config_id, ["op_type"] = 2})
return 0
end
--机关尝试连线
function LF_TryConnect(context, config_id)
local cur_point = ScriptLib.GetGroupVariableValue(context, config_id.."rot")
local cur_target = 0
for k, v in pairs(defs.gear_info) do
if v.config_id == config_id then
cur_target = v.connect[cur_point]
end
end
if 0 == cur_target then
return 0
end
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] LF_TryConnect: from gear@"..config_id.."cur_point@"..cur_point.." cur_target@"..cur_target)
if LF_CheckIsGear(context, cur_target) then
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201)
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] LF_TryConnect: Trace On! From gear@"..config_id.." to@"..cur_target)
else
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] LF_TryConnect: cur_target is not expected gear. Refused.")
return 0
end
LF_CheckSuccess(context)
return 0
end
--机关在State 201被玩家攻击关闭连线
function SLC_Constellation_CloseConnect(context)
local turning_num = ScriptLib.GetGroupTempValue(context, "turning_num", {})
if 0 ~= turning_num then
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] Get SLC_Constellation_CloseConnect while turning_num@"..turning_num..". Refused")
return 0
end
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.SetGadgetStateByConfigId(context, config_id, 0)
LF_CheckSuccess(context)
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] SLC_Constellation_CloseConnect state set 0. gear@@"..config_id)
return 0
end
function action_Enter_Guide_Region(context, evt)
if evt.param1 ~= defs.guide_region then
return 0
end
LF_TryShowGuide(context)
return 0
end
function LF_TryShowGuide(context)
--在NewActivityPushTipsData配置中查找对应id, 并通过lua添加进活动中
--重复添加已有push tips返回-1 成功添加返回0
local ret = ScriptLib.TryRecordActivityPushTips(context, 2014003)
if 0 == ret then
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.ShowClientTutorial(context, 1169, {uid})
end
return 0
end
--检查configID是否为配置的光线机关
function LF_CheckIsGear(context, value)
for k, v in pairs(defs.gear_info) do
if v.config_id == value then
return true
end
end
return false
end
--用于检查value是否在目标table中
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,248 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: ConstellationPattern
|| owner: weiwei.sun
|| description: 莫娜岛星座图案连线逻辑。连线逻辑和ConstellationMachine相同不含解谜逻辑。
|| LogName: ## [ConstellationPattern]
|| Protection:
=======================================]]
--[[
local defs = {
--是否使用移动模式
is_movable = 1,
--连线形态 静态模式
patterns =
{
--形态1
[1] =
{
[点1的configID] = 连哪个configID,
[点2的configID] = 连哪个configID,
},
--形态2
[2] =
{
[点1的configID] = 连哪个configID,
[点2的configID] = 连哪个configID,
}
},
--连线形态 移动模式
--在静态模式的基础上加一个切换过程表现是先关闭所有连线然后开始点阵移动等大家都停下来后按pattern2连线
--本质上和ConstellationMachine的逻辑一样
patterns =
{
--形态1
[1] =
{
[点1的configID] = {connect = , point_array = 1, point_id = {1},} ,
},
}
--是否在GroupLoad时回到pattern 1
reset_onload=1,
}
]]
local cfg =
{
connect_sgv = "SGV_Constellation_Target",--物件在Group中找此SGV的对象进行连线
mark_sgv = "SGV_Constellation_Mark",--物件自身的SGV
}
local extraTriggers={
--{ config_id = 8000001, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Select_Option", trigger_count = 0 },
{ config_id = 8000002, name = "Reach_Point", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_Reach_Point", trigger_count = 0 },
{ config_id = 8000003, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000004, name = "Pattern_Variable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "pattern", condition = "", action = "action_Pattern_Variable_Change", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
for k,v in pairs(suites) do
table.insert(v.triggers,extraTriggers[i].name)
end
end
--代表现在要显示连线样式几
table.insert(variables,{ config_id = 50000001, name = "pattern", value = 1})
end
function action_Group_Load(context, evt)
ScriptLib.SetGroupTempValue(context, "ready_count", 0, {})
if 1 == defs.reset_onload then
ScriptLib.SetGroupVariableValue(context, "pattern", 1)
end
--计算总数
local total = 0
for k,v in pairs(defs.patterns[1]) do
total = total + 1
end
ScriptLib.SetGroupTempValue(context, "total", total, {})
if nil ~= defs.is_movable then
LF_InitPosition(context)
end
return 0
end
--根据当前pattern设置物件位置
function LF_InitPosition(context)
local pattern_index = ScriptLib.GetGroupVariableValue(context, "pattern")
ScriptLib.SetGroupTempValue(context, "turning_num", 0, {})
for k, v in pairs(defs.patterns[pattern_index]) do
if 0 ~= v.point_array then
--开始移动
ScriptLib.SetPlatformPointArray(context, k, v.point_array, v.point_id, { route_type = 0, turn_mode = false })
--增加一个正在移动的机关计数
ScriptLib.ChangeGroupTempValue(context, "turning_num", 1, {})
end
end
return 0
end
function LF_InitPattern(context, pattern_index)
ScriptLib.PrintContextLog(context, "## [ConstellationPattern] LF_InitPattern. pattern@"..pattern_index)
if pattern_index > #defs.patterns then
pattern_index = #defs.patterns
ScriptLib.PrintContextLog(context, "## [ConstellationPattern] #WARN# Pattern index overflow. Set to pattern@"..pattern_index)
end
if pattern_index < 1 then
pattern_index = 1
ScriptLib.PrintContextLog(context, "## [ConstellationPattern] #WARN# Pattern less than 1. Set to 1.")
end
LF_SetConnectMark(context, pattern_index)
LF_SetConnectTarget(context, pattern_index)
return 0
end
--当所有ability准备好时再分配GV
function SLC_ConstellationPattern_Ready(context)
local pattern_index = ScriptLib.GetGroupVariableValue(context, "pattern")
ScriptLib.ChangeGroupTempValue(context, "ready_count", 1, {})
local ready = ScriptLib.GetGroupTempValue(context, "ready_count", {})
local total = ScriptLib.GetGroupTempValue(context, "total", {})
ScriptLib.PrintContextLog(context, "## [ConstellationPattern] SLC_ConstellationPattern_Ready. ready@"..ready.." total@"..total)
if ready >= total then
LF_InitPattern(context, pattern_index)
end
return 0
end
function action_Pattern_Variable_Change(context, evt)
if evt.param1 == evt.param2 then
return 0
end
local pattern_index = evt.param1
ScriptLib.PrintContextLog(context, "## [ConstellationPattern] Pattern_Variable_Change. pattern@"..pattern_index)
if pattern_index > #defs.patterns then
pattern_index = #defs.patterns
ScriptLib.PrintContextLog(context, "## [ConstellationPattern] #WARN# Pattern index overflow. Set to pattern@"..pattern_index)
end
if pattern_index < 1 then
pattern_index = 1
ScriptLib.PrintContextLog(context, "## [ConstellationPattern] #WARN# Pattern less than 1. Set to 1.")
end
if nil ~= defs.is_movable then
LF_MoveByPatternIndex(context, pattern_index)
else
LF_SetConnectTarget(context, pattern_index)
end
return 0
end
--每个机关给自己上标识, 给其他机关找目标用
function LF_SetConnectMark(context, pattern_index)
for k, v in pairs(defs.patterns[pattern_index]) do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, k, cfg.mark_sgv, k)
end
return 0
end
--根据当前pattern为所有机关分配连线SGV
function LF_SetConnectTarget(context, pattern_index)
if nil ~= defs.is_movable then
for k, v in pairs(defs.patterns[pattern_index]) do
--设置新的连线对象
ScriptLib.SetEntityServerGlobalValueByConfigId(context, k, cfg.connect_sgv, v.connect)
--ScriptLib.PrintContextLog(context, "## [ConstellationPattern] LF_SetConnectTarget: gear@"..k.." target@"..v.connect)
end
else
for k, v in pairs(defs.patterns[pattern_index]) do
--设置新的连线对象
ScriptLib.SetEntityServerGlobalValueByConfigId(context, k, cfg.connect_sgv, v)
--ScriptLib.PrintContextLog(context, "## [ConstellationPattern] LF_SetConnectTarget: gear@"..k.." target@"..v)
end
end
return 0
end
--移动结束
function action_Reach_Point(context, evt)
--排除非连线机关
if false == LF_CheckIsGear(context, evt.param1) then
return 0
end
local pattern_index = ScriptLib.GetGroupVariableValue(context, "pattern")
--检查是否reach它最后一个point
local point_table = defs.patterns[pattern_index][evt.param1].point_id
local final_point = point_table[#point_table]
if final_point ~= evt.param3 then
return 0
end
--减少一个正在旋转的机关计数
ScriptLib.ChangeGroupTempValue(context, "turning_num", -1, {})
local turning_num = ScriptLib.GetGroupTempValue(context, "turning_num", {})
ScriptLib.PrintContextLog(context, "## [ConstellationMachine] Reach_Point: Current turning_num@"..turning_num)
--如果都转完了,设置连接关系
if 0 == turning_num then
LF_SetConnectTarget(context, pattern_index)
end
return 0
end
--检查configID是否为配置的光线机关
function LF_CheckIsGear(context, value)
for k, v in pairs(defs.patterns[1]) do
if k == value then
return true
end
end
return false
end
--根据patternIndex移动
function LF_MoveByPatternIndex(context, pattern_index)
ScriptLib.SetGroupTempValue(context, "turning_num", 0, {})
for k, v in pairs(defs.patterns[pattern_index]) do
--关闭连线 GadgetState被LD拿去做别的用此处用SGV使星座点失去目标
ScriptLib.SetEntityServerGlobalValueByConfigId(context, k, cfg.connect_sgv, 0)
if 0 ~= v.point_array then
--开始移动
ScriptLib.SetPlatformPointArray(context, k, v.point_array, v.point_id, { route_type = 0, turn_mode = false })
--增加一个正在旋转的机关计数
ScriptLib.ChangeGroupTempValue(context, "turning_num", 1, {})
end
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,934 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: CrowTheatre_Howdunit
|| owner: weiwei.sun
|| description: 夜鸦剧场演剧模式的流程逻辑。
|| LogName: ## [CrowTheatre]
|| Protection:
=======================================]]
--[[
local defs =
{
--每个阶段(Stage)的所有演员物件config_id。用于统一设置可拾取/可对话状态
actor_list =
{
[1] =
{
[4001] = 201190701,
},
[2] = {}
},
--可拾取的gadget列表即not in any suite的夜鸦雕像列表为每个阶段(Stage)的最终站位点的configID
pickable_gadget =
{
[4002] = {0, 4013, 4013},
},
--同上,用于常驻夜鸦的位置保存
static_gadget =
{
[4002] = {0, 4013, 4013},
},
--每个阶段(Stage)的行动action序列
actions =
{
{
[1] = { config_id = 9001, reminder_id = 31021109, arg = 0, point_array = 0, point_id_list = {}, duration = 5},
},
{
[1] = { config_id = 9002, reminder_id = 31021107, arg = 0, point_array = 0, point_id_list = {}, duration = 3},
},
},
spec_actions =
{
{
[1] = { config_id = 22, reminder_id = 31021109, arg = 0, point_array = {11, 22}, point_id_list = {1,2,3}, duration = 5},
},
},
--每阶段(Stage)剧情结束时加载的对应suite(放聚光灯和操作台用),和正确的放置槽位config_id
--key是阶段序号
question_suits =
{
[1] = { add_suite = 3, correct_slot = 1111, correct_gadget = 11, spec = 22,},
[2] = { add_suite = 4, correct_slot = 2222, correct_gadget = 22},
},
}
]]
local cfg =
{
--reminder广播范围
reminder_radius = 30,
--成功失败物件表现等待时间
ani_wait_time = 2,
--"开启第一幕"操作台选项id
starter_option_1 = 403,
--"开启第二幕"操作台选项id
starter_option_2 = 407,
--"放置"操作台选项id
place_option = 426,
--物件在哪个suite 剧场处于激活状态时加载
play_suite = 2,
--"回放第一幕"操作台选项id
review_option_1 = 404,
--"回放第二幕"操作台选项id
review_option_2 = 408,
}
local extraTriggers={
{ config_id = 8000001, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
--玩法Trigger
{ config_id = 8000003, name = "TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000006, name = "Place_NightCrow_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Place_NightCrow_Option", trigger_count = 0 },
--外部Group控制是否开启
{ config_id = 8000008, name = "Thearte_Variable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "play_state", condition = "", action = "action_Thearte_Variable_Change", trigger_count = 0 },
{ config_id = 8000009, name = "Talk_Variable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "talk_done", condition = "", action = "action_Talk_Variable_Change", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--状态标志位 0- 等待开启 1- 正在表演 2- 等待选择 3-完成 4-hide状态
--改为LD在关卡编辑器上声明以便配置初始值
--table.insert(variables, { name = "play_state", value = 0 , no_refresh = true})
--当前第几段剧情。
table.insert(variables, { config_id = 50000001, name = "cur_stage", value = 1 , no_refresh = true})
--是否做过解谜阶段,可以回放
table.insert(variables, { config_id = 50000002, name = "is_done", value = 0 , no_refresh = true})
table.insert(variables, { config_id = 50000003, name = "qa", value = 0})
end
--根据演出阶段 重置static_gadget里的夜鸦位置
function action_Group_Load(context, evt)
if nil == defs.static_gadget then
return 0
end
local play_state = ScriptLib.GetGroupVariableValue(context, "play_state")
if 4 == play_state then
return 0
end
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
for k,v in pairs(defs.static_gadget) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, k)
--按配置位置重新创建
LF_InitStateStaticActor(context, k)
end
return 0
end
function EX_InitTheatre(context, prev_context)
LF_InitTheatre(context)
ScriptLib.SetGroupVariableValue(context, "qa", 0)
return 0
end
function LF_InitTheatre(context)
local play_state = ScriptLib.GetGroupVariableValue(context, "play_state")
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_InitTheatre. play_state@"..play_state.." stage@"..stage)
--初始化动作序号
ScriptLib.SetGroupTempValue(context,"action_index", 0, {})
--Group加载时玩家应重新拾取乌鸦
ScriptLib.SetGroupTempValue(context,"picked_up", 0, {})
--local uid = ScriptLib.GetSceneOwnerUid(context) --不处理SGV因为玩家正在玩其他Group会影响到,改到主控Group的EnterRegion
--ScriptLib.SetTeamServerGlobalValue(context, uid, "SGV_NightCrow_Picked", 0)
--hide状态下移除演出suite如有
if 4 == play_state then
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, cfg.play_suite)
return 0
--非hide状态拉出夜鸦
else
--加载演出suite
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, cfg.play_suite)
--5.16迭代 如果stage大于1即上次是演到一半中断了则执行LF_InitStateActors
if 1 < stage then
--pickable夜鸦
LF_InitStateActors(context)
--statice夜鸦
if nil ~= defs.static_gadget then
for k,v in pairs(defs.static_gadget) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, k)
--按配置位置重新创建
LF_InitStateStaticActor(context, k)
end
end
end
end
--间幕3下 特殊对话夜鸦阿诺德 在init时需要替换talk
if 199002043 == base_info.group_id then
LF_HandleTalkGadget(context)
end
return 0
end
function LF_HandleTalkGadget(context)
--7902603的已接取未完成状态
if 2 == ScriptLib.GetHostQuestState(context,7902603) then
local ret = ScriptLib.SetGadgetTalkByConfigId(context,199002048,48008,0)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_HandleTalkGadget. ret@"..ret)
end
return 0
end
function action_Talk_Variable_Change(context, evt)
--判断终幕下半场
if 199002043 ~= base_info.group_id then
return 0
end
--阿诺德特殊对话结束
if 1 ~= evt.param1 then
return 0
end
--判断剧场处于选人阶段
if 2 ~= ScriptLib.GetGroupVariableValue(context, "play_state") then
return 0
end
--断剧场处于stage 4
if 4 ~= ScriptLib.GetGroupVariableValue(context, "cur_stage") then
return 0
end
--判断当前未持有夜鸦
if 0 < ScriptLib.GetGroupTempValue(context, "picked_up", {}) then
return 0
end
ScriptLib.SetGadgetStateByConfigId(context, 43005, 201)
return 0
end
--重置各种变量
function LF_ResetVariables(context)
--重置 动作序号
ScriptLib.SetGroupTempValue(context,"action_index", 0, {})
--重置 拾取乌鸦标记
ScriptLib.SetGroupTempValue(context,"picked_up", 0, {})
--如果在玩的是当前Group则清掉玩家身上特效 state 2、1是本Group的游玩状态
local state = ScriptLib.GetGroupVariableValue(context, "play_state")
if 2 == state or 1 == state then
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.SetTeamServerGlobalValue(context, uid, "SGV_NightCrow_Picked", 0)
end
--重置演出阶段
ScriptLib.SetGroupVariableValue(context, "cur_stage", 1)
return 0
end
function action_Thearte_Variable_Change(context, evt)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] Thearte_Variable_Change from@"..evt.param2.." to@"..evt.param1)
--在任何状态下,被通知关闭
if 4 == evt.param1 then
LF_ResetVariables(context)
--隐藏
--ScriptLib.RefreshGroup(context, { group_id = 0, suite = init_config.suite })--不用这个 LD的大宝箱要留在场上
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, cfg.play_suite)--移除固定演员
for k,v in pairs(defs.pickable_gadget) do--移除可拾取演员
--特判199002043的阿诺德43005
if 199002043 == base_info.group_id and 43005 == k then
if 1 == ScriptLib.GetGroupVariableValue(context, "talk_done") then
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, k)
end
else
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, k)
end
end
return 0
end
--在关闭状态下,被通知开启
if 0 == evt.param1 and 4 == evt.param2 then
LF_ResetVariables(context)
--加载演出suite
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, cfg.play_suite)
return 0
end
return 0
end
--可拾取夜鸦雕像 拾取
function SLC_NightCrowPickUp(context)
local state = ScriptLib.GetGroupVariableValue(context, "play_state")
--检查是否处于正确阶段
if 2 ~= state then
return 0
end
--检查重复交互
if 0 < ScriptLib.GetGroupTempValue(context,"picked_up", {}) then
return 0
end
local cfg_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.SetGroupTempValue(context,"picked_up", cfg_id, {})
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.SetTeamServerGlobalValue(context, uid, "SGV_NightCrow_Picked", 1)
--将可拾取夜鸦置为无交互状态
LF_SetAllActorsState(context, 0)
ScriptLib.KillEntityByConfigId(context, { config_id = cfg_id })
ScriptLib.PrintContextLog(context, "## [CrowTheatre] SLC_NightCrowPickUp. By@"..cfg_id)
--添加“放置”选项
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
local stage_table = defs.question_suits[stage]
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, stage_table.correct_slot, {cfg.place_option})
return 0
end
--可拾取夜鸦雕像 对话
function SLC_NightCrowHint(context)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] SLC_NightCrowHint")
local state = ScriptLib.GetGroupVariableValue(context, "play_state")
if 2 == state then
local cfg_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.PrintContextLog(context, "## [CrowTheatre] SLC_NightCrowHint. By@"..cfg_id)
LF_ShowHintReminder(context, cfg_id)
else
ScriptLib.PrintContextLog(context, "## [CrowTheatre] #WARN# Get SLC_NightCrowHint at wrong state@"..state)
end
return 0
end
--播放当前阶段的提示reminder
function LF_ShowHintReminder(context, config_id)
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_ShowHintReminder. cur_stage@"..stage.." by@"..config_id)
for k, v in pairs(defs.actor_list) do
if k == stage then
ScriptLib.ShowReminderRadius(context, v[config_id] , gadgets[config_id].pos, cfg.reminder_radius)
end
end
return 0
end
--向config_id的操作台位置放置夜鸦雕像
function LF_PlaceNightCrow(context, option_configID, gadget_configID)
local ret = ScriptLib.CreateGadgetByConfigIdByPos(context, gadget_configID, gadgets[option_configID].pos, gadgets[option_configID].rot)
if 0 ~= ret then
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_PlaceNightCrow CreateGadgetByConfigIdByPos failed. ret@"..ret)
return 0
end
--placed用于放错时将其放回
ScriptLib.SetGroupTempValue(context,"picked_up", 0, {})
ScriptLib.SetGroupTempValue(context,"placed", gadget_configID, {})
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.SetTeamServerGlobalValue(context, uid, "SGV_NightCrow_Picked", 0)
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_PlaceNightCrow. cur_stage@"..stage)
--移除“放置”选项,移除question_suite
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
local stage_table = defs.question_suits[stage]
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, stage_table.correct_slot, cfg.place_option)
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, defs.question_suits[stage].add_suite)
--检查是否是正确位置,正确的雕像
local stage_table = defs.question_suits[stage]
if option_configID == stage_table.correct_slot and gadget_configID == stage_table.correct_gadget then
--标记play_state 2的结束
ScriptLib.SetGroupVariableValue(context, "play_state", 1)
if #defs.actions <= stage then
--全阶段完成
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_PlaceNightCrow success. All stage finished")
else
local next_stage = stage + 1
LF_SetAllActorsState(context, 0)
ScriptLib.SetGroupVariableValue(context, "cur_stage", next_stage)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_PlaceNightCrow success. new_stage@"..next_stage)
--初始化动作序号
ScriptLib.SetGroupTempValue(context, "action_index", 0, {})
LF_SequenceAction(context, 0)
end
--埋点
ScriptLib.MarkGroupLuaAction(context, "NightCrowTheater", "", {["group_id"] = base_info.group_id, ["config_id"] = gadget_configID, ["result"] = 1, ["slot_id"] = option_configID})
else
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_PlaceNightCrow wrong. ")
--埋点
ScriptLib.MarkGroupLuaAction(context, "NightCrowTheater", "", {["group_id"] = base_info.group_id, ["config_id"] = gadget_configID, ["result"] = 0, ["slot_id"] = option_configID})
--检查是否是spec(彩蛋夜鸦)
if gadget_configID == stage_table.spec then
LF_HandleSpecCrowAction(context, stage)
LF_StageFail(context, defs.spec_actions[stage].duration, option_configID)
else
LF_StageFail(context, 0, option_configID)
end
end
return 0
end
function LF_HandleSpecCrowAction(context, stage)
local step = defs.spec_actions[stage]
--取实时位置
local pos = LF_GetEntityPosition(context, step.config_id)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_HandleSpecCrowAction: Try show reminder@"..step.reminder_id.." pos@"..pos.x.." "..pos.y.." "..pos.z)
if 0 ~= pos then
ScriptLib.ShowReminderRadius(context, step.reminder_id, pos, cfg.reminder_radius)
end
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_HandleSpecCrowAction: Try Set GadgetState. ConfigId@"..step.config_id)
--切GadgetState到203状态 发光+气泡
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 203)
--处理移动
if 0 ~= step.point_array then
ScriptLib.SetPlatformPointArray(context, step.config_id, step.point_array[1], step.point_id_list, {route_type = 0, turn_mode = true, record_mode = 0})
end
return 0
end
--清场
function LF_ClearStateActors(context)
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_ClearActors. stage@"..stage)
--移除全部pickable_gadget演员
for k,v in pairs(defs.pickable_gadget) do
--特判199002043的阿诺德43005
if 199002043 == base_info.group_id and 43005 == k then
if 1 == ScriptLib.GetGroupVariableValue(context, "talk_done") then
ScriptLib.KillEntityByConfigId(context, { config_id = k })
end
else
ScriptLib.KillEntityByConfigId(context, { config_id = k })
end
end
--移除本stage行动序列中所有移动过的演员
for k,v in pairs(defs.actions[stage]) do
if 0 < v.point_array then
ScriptLib.KillEntityByConfigId(context, { config_id = v.config_id })
end
end
return 0
end
--根据当前阶段Create 单个static_gadget夜鸦雕像
function LF_InitStateStaticActor(context, config_id)
if nil == defs.static_gadget then
return 0
end
if nil == defs.static_gadget[config_id] then
return 0
end
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_InitStateStaticActor. stage@"..stage.." configid@".. config_id)
--如果是一阶段则按原始坐标CreateGadget
if 1 == stage then
ScriptLib.CreateGadget(context, { config_id = config_id })
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_InitStateStaticActor. Create gadget@"..config_id)
--若非一阶段则在stage对应的配置位置CreateGadget
elseif 1 < stage then
--范围检查
if #defs.question_suits < stage - 1 then
ScriptLib.PrintContextLog(context, "## [CrowTheatre] #WARN# LF_InitStateStaticActor. Get unexpected stage! stage@"..stage.." question_suits count@"..#defs.question_suits)
return 0
end
LF_CreateActorByStage(context, config_id, defs.static_gadget, stage)
else
ScriptLib.PrintContextLog(context, "## [CrowTheatre] #WARN# LF_InitStateStaticActor. Get cur stage Failed! stage@"..stage)
end
return 0
end
--根据当前阶段Create pickable_gadget中的全部夜鸦雕像
function LF_InitStateActors(context)
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_InitStateActors. stage@"..stage)
--特判阿诺德 在登场后stage 5要先杀后创
if 199002043 == base_info.group_id and 5 <= stage then
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, 43005)
end
--如果是一阶段则按原始坐标CreateGadget
if 1 == stage then
for k, v in pairs(defs.pickable_gadget) do
ScriptLib.CreateGadget(context, { config_id = k })
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_InitStateActors. Create gadget@"..k)
end
--若非一阶段则在stage对应的配置位置CreateGadget
elseif 1 < stage then
--范围检查
if #defs.question_suits < stage - 1 then
ScriptLib.PrintContextLog(context, "## [CrowTheatre] #WARN# LF_InitStateActors. Get unexpected stage! stage@"..stage.." question_suits count@"..#defs.question_suits)
return 0
end
--开始放置
for k, v in pairs(defs.pickable_gadget) do
LF_CreateActorByStage(context, k, defs.pickable_gadget, stage)
end
else
ScriptLib.PrintContextLog(context, "## [CrowTheatre] #WARN# LF_InitStateActors. Get cur stage Failed! stage@"..stage)
end
--特判 19900204444006以101形态创建
if 199002044 == base_info.group_id then
ScriptLib.SetGadgetStateByConfigId(context, 44006, 101)
end
return 0
end
function LF_CreateActorByStage(context, config_id, pos_table, stage)
--根据当前stage找到对应的目标点物件
if nil == pos_table[config_id][stage] then
--取空了LD没配告警在原地Create
ScriptLib.CreateGadget(context, { config_id = config_id })
ScriptLib.PrintContextLog(context, "## [CrowTheatre] #WARN# Stage num and point configs are not match!")
elseif 0 == pos_table[config_id][stage] then
--配置目标点为0原地Create。 已在前阶段登场的夜鸦正常都不该配0否则会在不合理的位置出现
ScriptLib.CreateGadget(context, { config_id = config_id })
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_CreateActorByStage. Create gadget@"..config_id)
elseif 0 > pos_table[config_id][stage] then
--配置目标点为-1此物件在本stage不出现。 用于登场过但是退场不再出现的夜鸦
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_CreateActorByStage. Skip gadget@"..config_id)
else
--有目标点就按目标点Create
ScriptLib.CreateGadgetByConfigIdByPos(context, config_id, gadgets[pos_table[config_id][stage]].pos, gadgets[pos_table[config_id][stage]].rot)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_CreateActorByStage. Create gadget@"..config_id.." at point@"..pos_table[config_id][stage])
end
return 0
end
function LF_AutoPickAndPlace(context)
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
--stage异常 直接主动重置剧场
if nil == defs.question_suits[stage] then
LF_ResetStagePlay(context)
LF_ResetVariables(context)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_AutoPickAndPlace. Invalid stage, reset.")
end
local config_id = defs.question_suits[stage].correct_gadget
local slot = defs.question_suits[stage].correct_slot
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_AutoPickAndPlace. stage@"..stage .." config_id@"..config_id.." slot@"..slot)
--ScriptLib.KillEntityByConfigId(context, { config_id = config_id })
ScriptLib.CreateGadgetByConfigIdByPos(context, config_id, gadgets[slot].pos, gadgets[slot].rot)
if #defs.actions <= stage then
--全阶段完成
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_AutoPickAndPlace success. All stage finished")
else
local next_stage = stage + 1
LF_SetAllActorsState(context, 0)
ScriptLib.SetGroupVariableValue(context, "cur_stage", next_stage)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_AutoPickAndPlace success. new_stage@"..next_stage)
--初始化动作序号
ScriptLib.SetGroupTempValue(context, "action_index", 0, {})
LF_SequenceAction(context, 1)
end
return 0
end
function EX_SequenceAction(context, prev_context, type)
--初始化动作序号
ScriptLib.SetGroupTempValue(context, "action_index", 0, {})
LF_SequenceAction(context, type)
return 0
end
--根据action配置执行行动
-- type0-演剧模式 1-回放模式
function LF_SequenceAction(context, type)
local ret = ScriptLib.ChangeGroupTempValue(context, "action_index", 1, {})
if -1 == ret then
ScriptLib.SetGroupTempValue(context, "action_index", 1, {})
end
local cur_index = ScriptLib.GetGroupTempValue(context, "action_index", {})
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SequenceAction. stage@"..stage)
--stage异常这种不大可能出现一旦出现则去stage 1
if nil == defs.actions[stage] then
stage = 1
ScriptLib.SetGroupVariableValue(context, "cur_stage", stage)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] Invalid stage. set to 1.")
end
local stage_table = defs.actions[stage]
--重置上一步演员状态
if 1 < cur_index then
local last_actor = stage_table[cur_index - 1].config_id
--上一步无演员或演员有特殊动作 则不置为0
if 0 == last_actor or nil ~= stage_table[cur_index - 1].arg then
--ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SequenceAction. Last actor has action arg. last_actor@"..last_actor.." arg@"..stage_table[cur_index - 1].arg)
else
ScriptLib.SetGadgetStateByConfigId(context, last_actor, 0)
end
end
--是否已结束
if #stage_table < cur_index then
ScriptLib.PrintContextLog(context, "## [CrowTheatre] Sequence actions finished. action_count@"..#stage_table.." cur_index@"..cur_index)
if stage == #defs.actions then
--如果是最后一段剧情,不进入断案阶段,成功
LF_Success(context, type)
else
--如果不是最后一段剧情,
if 0 == type then
--在演剧模式下进入断案阶段,
LF_SetPickPhrase(context, 0)
else
--在回放模式下销毁和创生目标夜鸦,然后继续下一段
LF_AutoPickAndPlace(context)
end
end
return 0
end
--action_index异常按1算
if nil == stage_table[cur_index] then
cur_index = 1
ScriptLib.SetGroupTempValue(context, "action_index", cur_index, {})
ScriptLib.PrintContextLog(context, "## [CrowTheatre] Invalid action_index. set to 1.")
end
--这一步总共要干啥
local step = stage_table[cur_index]
ScriptLib.PrintContextLog(context, "## [CrowTheatre] Sequence actions Set. Step_index@"..cur_index.." cfg_id@"..step.config_id.." rmd_id@"..step.reminder_id.." point_array@"..step.point_array)
--这一步是否是一个有主语的动作
if 0 ~= step.config_id then
--如果有台词以物件为中心范围内ShowReminder
if 0 ~= step.reminder_id then
--取实时位置
local pos = LF_GetEntityPosition(context, step.config_id)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SequenceAction: Try show reminder@"..step.reminder_id.." pos@"..pos.x.." "..pos.y.." "..pos.z)
if 0 ~= pos then
ScriptLib.ShowReminderRadius(context, step.reminder_id, pos, cfg.reminder_radius)
end
--处理GadgetState
if nil ~= step.arg then
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SequenceAction: Try Set GadgetState. ConfigId@"..step.config_id.." arg@"..step.arg)
--1-进入隐身无交互状态(101)
if 1 == step.arg then
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 101)
--2-进入隐身有交互状态(102)
elseif 2 == step.arg then
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 102)
--3-脱离隐身并加上交互(0)
elseif 3 == step.arg then
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 0)
end
else
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SequenceAction: Try Set GadgetState. ConfigId@"..step.config_id.." without arg.")
--切GadgetState到203状态 发光+气泡
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 203)
end
--处理移动
if 0 ~= step.point_array then
ScriptLib.SetPlatformPointArray(context, step.config_id, step.point_array, step.point_id_list, {route_type = 0, turn_mode = false, record_mode = 0})
end
--没有台词,只做动作
else
--移动
if 0 ~= step.point_array then
ScriptLib.SetPlatformPointArray(context, step.config_id, step.point_array, step.point_id_list, {route_type = 0, turn_mode = false, record_mode = 0})
--切GadgetState到204状态 发光+无气泡
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 204)
else
--切状态
if nil ~= step.arg then
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SequenceAction: Try Set GadgetState. ConfigId@"..step.config_id.." arg@"..step.arg)
--1-进入隐身无交互状态(101)
if 1 == step.arg then
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 101)
--2-进入隐身有交互状态(102)
elseif 2 == step.arg then
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 102)
--3-脱离隐身并加上交互(0)
elseif 3 == step.arg then
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 0)
end
end
end
end
else
--无主语动作以区域中心为中心范围内ShowReminder
local pos = LF_GetEntityPosition(context, 0)
if 0 ~= pos then
ScriptLib.ShowReminderRadius(context, step.reminder_id, pos, cfg.reminder_radius)
end
end
--这一步是否是一个瞬时动作
if 0 ~= step.duration then
--QA模式
if 1 == ScriptLib.GetGroupVariableValue(context, "qa") then
ScriptLib.InitTimeAxis(context, "duration"..type.."_"..stage.."_"..cur_index, {2}, false)
else
ScriptLib.InitTimeAxis(context, "duration"..type.."_"..stage.."_"..cur_index, { math.floor(step.duration) }, false)
end
ScriptLib.PrintContextLog(context, "## [CrowTheatre] Actions has duration. duration@".. math.floor(step.duration))
--不用等的话直接走下一步
else
LF_SequenceAction(context, type)
end
return 0
end
--is_fail:是否是选项错误重置,只重置单个
function LF_SetPickPhrase(context, is_fail)
--进入断案阶段
ScriptLib.SetGroupVariableValue(context, "play_state", 2)
--获取当前阶段
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SetPickPhrase. stage@"..stage)
--stage异常 直接主动重置剧场
if nil == defs.question_suits[stage] then
LF_ResetStagePlay(context)
LF_ResetVariables(context)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SetPickPhrase. Invalid stage, reset.")
end
local stage_table = defs.question_suits[stage]
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, stage_table.add_suite)
if 1 == is_fail then
local config_id = ScriptLib.GetGroupTempValue(context, "placed", {})
LF_CreateActorByStage(context, config_id, defs.pickable_gadget, stage)
else
LF_InitStateActors(context)
end
LF_SetAllActorsState(context, 201)
return 0
end
function action_Place_NightCrow_Option(context, evt)
--cfg.place_option
if cfg.place_option ~= evt.param2 then
return 0
end
local picked_up = ScriptLib.GetGroupTempValue(context, "picked_up", {})
ScriptLib.PrintContextLog(context, "## [CrowTheatre] Place_NightCrow_Option. evt.param2@"..evt.param2.." picked_up@"..picked_up)
if 0 >= picked_up then
--没有拾取雕像
return 0
else
LF_PlaceNightCrow(context, evt.param1, picked_up)
end
return 0
end
-- type0-演剧模式 1-回放模式
function LF_Success(context, type)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_Success. type@"..type)
ScriptLib.SetGroupVariableValue(context, "is_done", 1)
--物件做动画表现
LF_SetAllActorsState(context, 903)
ScriptLib.SetGroupVariableValue(context, "play_state", 3)
ScriptLib.ExecuteGroupLua(context, defs.curtain_group,"EX_PlayFinished",{ base_info.group_id, type})
return 0
end
--config_id: ShowRaminder中心物
--spec_duration: 彩蛋夜鸦的表现时间
function LF_StageFail(context, spec_duration, config_id)
--弹Reminder
ScriptLib.ShowReminderRadius(context, 1111355, gadgets[config_id].pos, 5)
--延时调用LF_ResetSelection
if 0 ~= spec_duration then
ScriptLib.InitTimeAxis(context, "ani_wait", { spec_duration }, false)
else
ScriptLib.InitTimeAxis(context, "ani_wait", { cfg.ani_wait_time }, false)
end
--物件做动画表现
LF_SetAllActorsState(context, 902)
return 0
end
function EX_ResetStagePlay(context, prev_context)
LF_ResetStagePlay(context)
return 0
end
--重置玩法物件位置至Stage开端
function LF_ResetStagePlay(context)
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
local theatre_state = ScriptLib.GetGroupVariableValue(context, "play_state")
local cur_index = ScriptLib.GetGroupTempValue(context, "action_index", {})
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_ResetStagePlay at theatre_state@" ..theatre_state.." Stage@"..stage)
--停止时间轴
if 1 == theatre_state then
if 1 == ScriptLib.GetGroupVariableValue(context, "is_done") then
ScriptLib.EndTimeAxis(context, "duration1_"..stage.."_"..cur_index)--回放模式演出时间轴 --"duration"..type.."_"..stage.."_"..cur_index
else
ScriptLib.EndTimeAxis(context, "duration0_"..stage.."_"..cur_index)--游玩模式演出时间轴
end
elseif 2 == theatre_state then
ScriptLib.EndTimeAxis(context, "ani_wait")--动画表现延时
end
--清除pickable gadget重置常驻演员位置
LF_ClearStateActors(context)
--若为选人阶段 移除“放置”选项,移除question_suite
if 2 == theatre_state then
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
local stage_table = defs.question_suits[stage]
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, stage_table.correct_slot, cfg.place_option)
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, defs.question_suits[stage].add_suite)
end
--初始化动作序号
ScriptLib.SetGroupTempValue(context, "action_index", 0, {})
--重置剧场状态为0
ScriptLib.SetGroupVariableValue(context, "play_state", 0)
LF_SetAllActorsState(context, 0)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_ResetStagePlay done.")
return 0
end
--重置选项
function LF_ResetSelection(context)
--清除可放置夜鸦
local config_id = ScriptLib.GetGroupTempValue(context, "placed", {})
ScriptLib.KillEntityByConfigId(context, { config_id = config_id })
--重新设置选项和夜鸦
LF_SetPickPhrase(context, 1)
return 0
end
function action_TimeAxis_Pass(context, evt)
local theatre_state = ScriptLib.GetGroupVariableValue(context, "play_state")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] TimeAxis_Pass. source_name@".. evt.source_name.." theatre_state@"..theatre_state)
if 1 == theatre_state or 2 == theatre_state then
if "duration0" == (string.sub(evt.source_name,1,9)) then
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SequenceAction duration finished. Do next action.")
LF_SequenceAction(context, 0)
return 0
end
if "duration1" == (string.sub(evt.source_name,1,9)) then
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SequenceAction duration finished. Do next action.")
LF_SequenceAction(context, 1)
return 0
end
if "ani_wait" == evt.source_name then
ScriptLib.PrintContextLog(context, "## [CrowTheatre] ani_wait Finished. Execute LF_ResetSelection.")
LF_ResetSelection(context)
return 0
end
end
return 0
end
function LF_GetEntityPosition(context, config_id)
local position = { x = 0, y = 0, z = 0}
local entity_id = ScriptLib.GetEntityIdByConfigId(context, config_id)
--未能找到实体,返回玩法区域中心的坐标
if 0 >= entity_id then
for k, v in pairs(regions) do
position = v.pos
return position
end
end
local pos_raw = ScriptLib.GetPosByEntityId(context, entity_id)
--取整 太多小数位数导致ShowReminder谜之失败
position.x = math.floor(pos_raw.x)
position.y = math.floor(pos_raw.y)
position.z = math.floor(pos_raw.z)
return position
end
--返回夜鸦是否为pickableGadget
function LF_IsPickableGadget(context, config_id)
--判断依据是是否布设在play_suite
for k, v in pairs(suites[cfg.play_suite].gadgets) do
if v == config_id then
return false
end
end
return true
end
--当前stage演员物件统一切到指定状态
--target_state:切入的状态
function LF_SetAllActorsState(context, target_state)
local stage = ScriptLib.GetGroupVariableValue(context, "cur_stage")
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_SetAllActorsState. cur_stage@"..stage.." target_state@"..target_state)
for k, v in pairs(defs.actor_list) do
if k == stage then
for ik, iv in pairs(v) do
--2022.4.25新增超级特判 199002043的43005阿诺德 如果LD侧的标志位为0 则不参与统一切状态
if 199002043 == base_info.group_id then
local flag = ScriptLib.GetGroupVariableValue(context, "talk_done")
if 43005 == ik and 0 == flag then
--
else
ScriptLib.SetGadgetStateByConfigId(context, ik, target_state)
end
--2022.6.10新增特判 19900204444006别人切201的时候它切102别人切0的时候它切101,其他state不管
elseif 199002044 == base_info.group_id and 44006 == ik then
if 201 == target_state then
ScriptLib.SetGadgetStateByConfigId(context, ik, 102)
elseif 0 == target_state then
ScriptLib.SetGadgetStateByConfigId(context, ik, 101)
end
else
ScriptLib.SetGadgetStateByConfigId(context, ik, target_state)
end
end
end
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,370 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: CrowTheatre_TheatreHandle
|| owner: weiwei.sun
|| description: 夜鸦剧场演剧模式多Group管理
|| LogName: ## [CrowTheatre]
|| Protection:
=======================================]]
--[[
local defs =
{
--操作台
start_operator = ,
--幕布物件configID
curtain_gadget = 0,
--第一幕GroupID
play_group_1 = ,
--第二幕GroupID
play_group_2 = ,
--散场GroupID
play_group_3 = ,
--玩法范围,主机出圈则重置
play_region = ,
}
]]
local cfg =
{
--"回放第一幕"操作台选项id
review_option_1 = 404,
--"开启第一幕"操作台选项id
starter_option_1 = 403,
--"回放第二幕"操作台选项id
review_option_2 = 408,
--"开启第二幕"操作台选项id
starter_option_2 = 407,
}
local extraTriggers={
{ config_id = 8000001, name = "Manager_Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Manager_Select_Option", trigger_count = 0, forbid_guest = true},
{ config_id = 8000002, name = "Manager_Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Manager_Group_Load", trigger_count = 0},
{ config_id = 8000003, name = "Leave_PlayRegion", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_Leave_PlayRegion", trigger_count = 0, forbid_guest = true },
{ config_id = 8000004, name = "Starter_Gadget_Create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_Starter_Gadget_Create", trigger_count = 0 },
{ config_id = 8000005, name = "Enter_PlayRegion", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_PlayRegion", trigger_count = 0, forbid_guest = true },
{ config_id = 8000006, name = "Manager_Group_UnLoad", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_Manager_Group_UnLoad", trigger_count = 0},
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--当前 逻辑上应当是第几幕在场
table.insert(variables, { config_id = 50000001, name = "cur_play", value = 1 , no_refresh = true})
end
function action_Manager_Group_UnLoad(context, evt)
LF_Try_ResetStagePlay(context)
return 0
end
function action_Manager_Group_Load(context, evt)
local cur_play = ScriptLib.GetGroupVariableValue(context, "cur_play")
ScriptLib.PrintContextLog(context, "##[CrowTheatre] Manager group loaded. cur_play@"..cur_play)
if 0 < cur_play and 3 >= cur_play then
LF_SwitchToPlay(context, cur_play)
LF_HandleWorkTopOption(context)
else
--取值异常,告警并加载第一幕
ScriptLib.PrintContextLog(context, "##[CrowTheatre] #WARN# Get Unknown cur_play. load play_group_1.")
LF_SwitchToPlay(context, 1)
LF_HandleWorkTopOption(context)
end
return 0
end
function action_Starter_Gadget_Create(context, evt)
if defs.start_operator ~= evt.param1 then
return 0
end
LF_HandleWorkTopOption(context)
return 0
end
--台上Group切换
--to_play: 第几个Group 1-上幕 2-下幕 3-散场幕
function LF_SwitchToPlay(context, to_play)
ScriptLib.PrintContextLog(context, "##[CrowTheatre] LF_SwitchToPlay. to_play@"..to_play)
if 1 == to_play then
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 0, defs.play_group_1)
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 4, defs.play_group_2)
if nil ~= defs.play_group_3 then
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 4, defs.play_group_3)
end
elseif 2 == to_play then
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 4, defs.play_group_1)
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 0, defs.play_group_2)
if nil ~= defs.play_group_3 then
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 4, defs.play_group_3)
end
elseif 3 == to_play then
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 4, defs.play_group_1)
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 4, defs.play_group_2)
if nil ~= defs.play_group_3 then
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 0, defs.play_group_3)
end
else
--取值异常,告警并加载第一幕
ScriptLib.PrintContextLog(context, "##[CrowTheatre] #WARN# Get Unknown cur_play. load play_group_1.")
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 0, defs.play_group_1)
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 4, defs.play_group_2)
if nil ~= defs.play_group_3 then
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 4, defs.play_group_3)
end
end
return 0
end
--演出Group通知主控Group播放完成
--第一幕完成 ->幕布自动关 -> 等幕布关完切Group
function EX_PlayFinished(context, prev_context, group_id, is_review)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] EX_PlayFinished called. group_id@"..group_id.. " is_review@".. is_review)
--终幕的 下幕 游玩模式
if 199002077 == base_info.group_id and 0 == is_review and defs.play_group_2 == group_id then
--不关幕布 但要移除隐形操作台
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.start_operator)
--并且切出散场幕
LF_SwitchToPlay(context, 3)
--其他情况
else
--关上幕布
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.curtain_gadget, 0)
end
--如果是第一幕的非回放结束,
--切换 逻辑在场group 为2
if group_id == defs.play_group_1 and is_review == 0 then
ScriptLib.SetGroupVariableValue(context, "cur_play", 2)
else
ScriptLib.SetGroupVariableValue(context, "cur_play", 3)
end
return 0
end
function action_Manager_Select_Option(context, evt)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] Manager_Select_Option. gadget@"..evt.param1.." option@"..evt.param2)
if defs.start_operator ~= evt.param1 then
return 0
end
LF_ClearOptions(context)
--如果幕布关着则缓存选项id拉开幕布切换在场幕等待幕布SLC再开演
if 0 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.curtain_gadget) then
ScriptLib.SetGroupTempValue(context, "selection", evt.param2,{})
--"开始第一幕"
if cfg.starter_option_1 == evt.param2 then
LF_SwitchToPlay(context, 1)
--"开始第二幕"
elseif cfg.starter_option_2 == evt.param2 then
LF_SwitchToPlay(context, 2)
--"回看第一幕"
elseif cfg.review_option_1 == evt.param2 then
LF_SwitchToPlay(context, 1)
--"回看第二幕"
elseif cfg.review_option_2 == evt.param2 then
LF_SwitchToPlay(context, 2)
end
--拉开幕布
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.curtain_gadget, 201)
--如果幕布开着,则直接开演
else
--"开始第一幕"
if cfg.starter_option_1 == evt.param2 then
LF_SwitchToPlay(context, 1)
LF_StartPlay(context, 1, 0)
--"开始第二幕"
elseif cfg.starter_option_2 == evt.param2 then
LF_SwitchToPlay(context, 2)
LF_StartPlay(context, 2, 0)
--"回看第一幕"
elseif cfg.review_option_1 == evt.param2 then
LF_SwitchToPlay(context, 1)
LF_StartPlay(context, 1, 1)
--"回看第二幕"
elseif cfg.review_option_2 == evt.param2 then
LF_SwitchToPlay(context, 2)
LF_StartPlay(context, 2, 1)
end
end
return 0
end
--type:0-游玩模式 1-回看模式
function LF_StartPlay(context, play_to_start, type)
ScriptLib.PrintContextLog(context, "##[CrowTheatre] LF_StartPlay. play_to_start@"..play_to_start.." type@"..type)
if 1 == play_to_start then
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 1, defs.play_group_1)
ScriptLib.ExecuteGroupLua(context, defs.play_group_1, "EX_SequenceAction", {type})
elseif 2 == play_to_start then
ScriptLib.SetGroupVariableValueByGroup(context, "play_state", 1, defs.play_group_2)
ScriptLib.ExecuteGroupLua(context, defs.play_group_2, "EX_SequenceAction", {type})
end
return 0
end
function LF_ClearOptions(context)
ScriptLib.PrintContextLog(context, "##[CrowTheatre] LF_ClearOptions.")
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.start_operator, cfg.starter_option_1)
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.start_operator, cfg.starter_option_2)
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.start_operator, cfg.review_option_1)
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.start_operator, cfg.review_option_2)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_ClearOptions done.")
return 0
end
--幕布物件开启动画完成
function SLC_CrowTheatre_Curtain_On(context)
local selection = ScriptLib.GetGroupTempValue(context, "selection", {})
ScriptLib.PrintContextLog(context, "##[CrowTheatre] SLC_CrowTheatre_Curtain_On. selection@"..selection)
--通知当前场上的Group开演
--"开始第一幕"
if cfg.starter_option_1 == selection then
LF_StartPlay(context, 1, 0)
--"开始第二幕"
elseif cfg.starter_option_2 == selection then
LF_StartPlay(context, 2, 0)
--"回看第一幕"
elseif cfg.review_option_1 == selection then
LF_StartPlay(context, 1, 1)
--"回看第二幕"
elseif cfg.review_option_2 == selection then
LF_StartPlay(context, 2, 1)
end
return 0
end
--幕布物件关闭动画完成
function SLC_CrowTheatre_Curtain_Off(context)
--设置操作台选项
LF_HandleWorkTopOption(context)
--如果此时逻辑幕,非当前在场幕,切出逻辑幕
--取得当前逻辑幕
local cur_play = ScriptLib.GetGroupVariableValue(context, "cur_play")
LF_SwitchToPlay(context, cur_play)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] SLC_CrowTheatre_Curtain_Off. cur_play@"..cur_play)
return 0
end
function LF_HandleWorkTopOption(context)
ScriptLib.PrintContextLog(context, "## [CrowTheatre] LF_HandleWorkTopOption. play_group_1@"..defs.play_group_1.. " play_group_2@".. defs.play_group_2)
local is_done_1 = ScriptLib.GetGroupVariableValueByGroup(context, "is_done", defs.play_group_1)
local is_done_2 = ScriptLib.GetGroupVariableValueByGroup(context, "is_done", defs.play_group_2)
--取值异常,紧急模式,上下幕都
if is_done_1 == -1 or is_done_2 == -1 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.start_operator, { cfg.starter_option_1, cfg.starter_option_2})
end
if 0 == is_done_1 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.start_operator, { cfg.starter_option_1 })
else
if 0 == is_done_2 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.start_operator, { cfg.starter_option_2, cfg.review_option_1 })
else
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.start_operator, { cfg.review_option_1, cfg.review_option_2 })
end
end
return 0
end
--出圈触发重置不能以GroupLoad/Unload作为边界因为有SetTeamServerGlobalValue的原因。游玩A Group时会被远处加载的B Group影响
function action_Leave_PlayRegion(context, evt)
if defs.play_region ~= evt.param1 then
return 0
end
LF_Try_ResetStagePlay(context)
--关闭幕布
--特判终幕 且任务环7902605已接取未完成 不落幕布
if 199002077 ~= base_info.group_id then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.curtain_gadget, 0)
else
if 2 ~= ScriptLib.GetHostQuestState(context,7902605) and 2 ~= ScriptLib.GetHostQuestState(context,7902606) and 2 ~= ScriptLib.GetHostQuestState(context,7902607)then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.curtain_gadget, 0)
end
end
--清除拾取buff表现
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_NightCrow_Picked", 0)
ScriptLib.PrintContextLog(context, "[CrowTheatre] Host leave region.")
return 0
end
--入圈回来
function action_Enter_PlayRegion(context, evt)
if defs.play_region ~= evt.param1 then
return 0
end
ScriptLib.ExecuteGroupLua(context, defs.play_group_1, "EX_InitTheatre", {})
ScriptLib.ExecuteGroupLua(context, defs.play_group_2, "EX_InitTheatre", {})
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_NightCrow_Picked", 0)
LF_HandleWorkTopOption(context)
ScriptLib.PrintContextLog(context, "[CrowTheatre] Host enter region.")
return 0
end
function LF_Try_ResetStagePlay(context)
local cur_play = ScriptLib.GetGroupVariableValue(context, "cur_play")
--play_state不为4隐藏态需要执行LF_ResetStagePlay
if 1 == cur_play then
local play_state = ScriptLib.GetGroupVariableValueByGroup(context, "play_state", defs.play_group_1)
if 4 ~= play_state then
ScriptLib.ExecuteGroupLua(context, defs.play_group_1, "EX_ResetStagePlay", {})
end
elseif 2 == cur_play then
local play_state = ScriptLib.GetGroupVariableValueByGroup(context, "play_state", defs.play_group_2)
if 4 ~= play_state then
ScriptLib.ExecuteGroupLua(context, defs.play_group_2, "EX_ResetStagePlay", {})
end
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,275 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: CrowTheatre_Whodunit
|| owner: weiwei.sun
|| description: 夜鸦剧场推理模式的流程逻辑。
|| LogName: ## [CrowTheatre]
|| Protection:
=======================================]]
--[[
每个Group只有一段演出要看。
演出结束后玩家根据推理选择交互一个正确的雕像,
选错了则全体闪一下红光,随后位置重置,演出需要玩家重播。
选对了则全体闪一下蓝光,刷宝箱。
local defs =
{
group_id = ,
--起始操作台configID
start_operator = ,
--所有演员物件。用于统一设置状态
actor_list =
{
},
--行动序列
actions =
{
[1] = { config_id = 雕像configID1, reminder_id = xxx, point_array = xxx, point_id_list = xxx, duration = xx},
},
--断案阶段加载哪些suite。用于放置操作台和聚光灯
question_suits =
{
},
--真正的凶手对应哪个操作台config_id
answer = ,
--玩法范围,主机出圈则重置
play_region = ,
}
]]
--reminder广播范围
local reminder_radius = 30
--成功失败物件表现等待时间
local ani_wait_time = 2
local extraTriggers={
{ config_id = 8000001, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000002, name = "TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000003, name = "Starter_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Starter_Option", trigger_count = 0, forbid_guest = true},
{ config_id = 8000004, name = "Leave_PlayRegion", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_Leave_PlayRegion", trigger_count = 0, forbid_guest = true },
{ config_id = 8000005, name = "Select_Suspect", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Select_Suspect", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--状态标志位 0- 等待开启 1- 正在表演 2- 等待选择 3-完成
table.insert(variables, { config_id = 50000001, name = "theatre_state", value = 0 })
end
function action_Group_Load(context, evt)
local state = ScriptLib.GetGroupVariableValue(context, "theatre_state")
ScriptLib.PrintContextLog(context, "[CrowTheatre] Group Load. state@"..state)
--初始化动作序号
ScriptLib.SetGroupTempValue(context, "action_index", 0, {})
if 3 == theatre_state then
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.start_operator, 401)
end
return 0
end
function action_Starter_Option(context, evt)
if defs.start_operator ~= evt.param1 then
return 0
end
if 0 == ScriptLib.GetGroupVariableValue(context, "theatre_state") then
--状态标志
ScriptLib.SetGroupVariableValue(context, "theatre_state", 1)
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.start_operator, 401)
LF_SequenceAction(context)
end
return 0
end
function LF_SequenceAction(context)
--先重置掉上一步的演员物件状态
LF_SetAllActorsState(context, 0)
ScriptLib.ChangeGroupTempValue(context, "action_index", 1, {})
local cur_index = ScriptLib.GetGroupTempValue(context, "action_index", {})
--是否已结束
if #defs.actions < cur_index then
ScriptLib.PrintContextLog(context, "[CrowTheatre] Sequence actions finished.")
--进入断案阶段
LF_SetSuspects(context)
return 0
end
--这一步总共要干啥
local step = defs.actions[cur_index]
ScriptLib.PrintContextLog(context, "[CrowTheatre] Sequence actions Set. Step_index@"..cur_index.." cfg_id@"..step.config_id.." rmd_id@"..step.reminder_id.." point_array@"..step.point_array)
--这一步是否是一个有主语的动作
if 0 ~= step.config_id then
--如果有台词以物件为中心范围内ShowReminder
if 0 ~= step.reminder_id then
local pos = LF_GetEntityPosition(context, gadgets, step.config_id)
ScriptLib.PrintContextLog(context, "[CrowTheatre] LF_SequenceAction: Try show reminder@"..step.reminder_id.." pos@"..pos.x.." "..pos.y.." "..pos.z)
if 0 ~= pos then
ScriptLib.ShowReminderRadius(context, step.reminder_id, pos, reminder_radius)
end
--切GadgetState到203状态 发光+气泡
ScriptLib.PrintContextLog(context, "[CrowTheatre] LF_SequenceAction: Try Set GadgetState. ConfigId@"..step.config_id)
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 203)
--是否同时需要移动
if 0 ~= step.point_array then
ScriptLib.SetPlatformPointArray(context, step.config_id, step.point_array, step.point_id_list, {route_type = 0, turn_mode = false, record_mode = 0})
end
else
--没有台词,仅移动
if 0 ~= step.point_array then
ScriptLib.SetPlatformPointArray(context, step.config_id, step.point_array, step.point_id_list, {route_type = 0, turn_mode = false, record_mode = 0})
--切GadgetState到204状态 发光+无气泡
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 204)
end
end
else
--无主语动作以区域中心为中心范围内ShowReminder
local pos = LF_GetEntityPosition(context, regions, defs.play_region)
if 0 ~= pos then
ScriptLib.ShowReminderRadius(context, step.reminder_id, pos, reminder_radius)
end
end
--这一步是否是一个瞬时动作
if 0 ~= step.duration then
local axis_key = "duration"..cur_index
ScriptLib.InitTimeAxis(context, axis_key, { math.floor(step.duration) }, false)
ScriptLib.PrintContextLog(context, "[CrowTheatre] Actions has duration. InitTimeAxis@".. axis_key.." with duration@".. math.floor(step.duration))
--不用等的话直接走下一步
else
LF_SequenceAction(context)
end
return 0
end
--设置断案阶段
function LF_SetSuspects(context)
--状态标志
ScriptLib.SetGroupVariableValue(context, "theatre_state", 2)
--加载suite
for k, v in pairs(defs.question_suits) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
return 0
end
function action_Select_Suspect(context, evt)
if 2 ~= ScriptLib.GetGroupVariableValue(context, "theatre_state") then
return 0
end
ScriptLib.PrintContextLog(context, "[CrowTheatre] Selected Suspect. config_id@"..evt.param1)
if defs.answer == evt.param1 then
LF_Success(context)
return 0
else
LF_Fail(context)
end
return 0
end
function LF_Success(context)
--引用这个re和谐quire的Group监听这个GroupVar来自行处理后续逻辑。
ScriptLib.SetGroupVariableValue(context, "theatre_state", 3)
ScriptLib.PrintContextLog(context, "[CrowTheatre] LF_Success")
--物件做动画表现
LF_SetAllActorsState(context, 903)
--移除操作台suite
for k, v in pairs(defs.question_suits) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.start_operator, 401)
--加载EndSuite
--ScriptLib.GoToGroupSuite(context, base_info.group_id, init_config.end_suite)
return 0
end
function LF_Fail(context)
--切状态标志为等待开始
ScriptLib.SetGroupVariableValue(context, "theatre_state", 0)
--物件做动画表现
LF_SetAllActorsState(context, 902)
--延时调用LF_ResetPlay
ScriptLib.InitTimeAxis(context, "ani_wait", { ani_wait_time }, false)
return 0
end
--重置玩法物件位置
function LF_ResetPlay(context)
ScriptLib.RefreshGroup(context, { group_id = 0, suite = 1 })
ScriptLib.SetGroupVariableValue(context, "theatre_state", 0)
--初始化动作序号
ScriptLib.SetGroupTempValue(context, "action_index", 0, {})
ScriptLib.PrintContextLog(context, "[CrowTheatre] LF_ResetPlay done.")
return 0
end
function action_TimeAxis_Pass(context, evt)
local theatre_state = ScriptLib.GetGroupVariableValue(context, "theatre_state")
ScriptLib.PrintContextLog(context, "[CrowTheatre] TimeAxis_Pass. source_name@".. evt.source_name.." theatre_state@"..theatre_state)
if 1 == theatre_state then
if "duration" == (string.sub(evt.source_name,1,8)) then
ScriptLib.PrintContextLog(context, "[CrowTheatre] LF_SequenceAction")
LF_SequenceAction(context)
return 0
end
else
if "ani_wait" == evt.source_name then
LF_ResetPlay(context)
return 0
end
end
return 0
end
function action_Leave_PlayRegion(context, evt)
if defs.play_region ~= evt.param1 then
return 0
end
local theatre_state = ScriptLib.GetGroupVariableValue(context, "theatre_state")
if 0 ~= theatre_state and 3 ~= theatre_state then
ScriptLib.PrintContextLog(context, "[CrowTheatre] Host leave region. Execute LF_Fail.")
LF_Fail(context)
end
return 0
end
function LF_GetEntityPosition(context, type_table, config_id)
local position = {0, 0, 0}
for k,v in pairs(type_table) do
if k == config_id then
position = v.pos
return position
end
end
return 0
end
--演员物件统一切到指定状态
function LF_SetAllActorsState(context, target_state)
for i, v in ipairs(defs.actor_list) do
ScriptLib.SetGadgetStateByConfigId(context, v, target_state)
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,929 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: DLActivityDungeon
|| owner: weiwei.sun
|| description: DreamLand大活动角色地城通用Buff控制器 挂在挑战Group上
|| LogName: ## [DLDungeon]
|| Protection:
=======================================]]
--[[
local defs = {
--是否教学关
is_tutorial = 1,
--起始操作台
starter = ,
--起始操作台选项
option_id = ,
--波次之间延时 秒
delay = ,
--挑战总时限 秒
time_limit = ,
--怪物潮信息
--monsters填入怪物configID
--当场上本列表的怪数量小于min时触发补怪补至max。max勿超过mosnters数量
--mona_buffs:莫娜地城限定本次怪物潮对应的buff。为LD约定好的枚举。
tide_cfg = {
[1] = { monsters = {1001,1002,1003,1004}, min = 3, max = 4},
[2] = { monsters = {1001,1002,1003,1004}, min = 3, max = 4, mona_buffs = {}},
},
--怪物潮随机表
--随机固定顺序怪物潮组合 每次进地城随机取key。
--key对应value代表依序出现的MonsterTide小花括号内配置复数个表示同时刷出。
rand_table = {
[1] =
{
{1,2},
{3},
{4}
},
},
--谁的地城 1-万叶 2-辛焱 3-菲谢尔 4-莫娜
type = ,
--莫娜、辛焱需配这里-随机suite池
rand_suites = {},
--万叶、菲谢尔需配这里-生成buff随机点位configIDs
point_list = {},
--万叶、菲谢尔需配这里-普通buff物件池
buff_pool = {},
--万叶、菲谢尔需配这里-限定buff物件池
buff_pool_spec = {},
--万叶、菲谢尔需配这里-buff物件每次刷几个
buff_count = ,
--莫娜地城星星和压板对应关系
stars = {
--suite x
[x] = {{星星configID1, 板子configID1}, {星星configID2, 板子configID2}},
....
},
}
]]
local cfg = {
--1-万叶 2-辛焱 3-菲谢尔 4-莫娜
challenge_id = {2010037,2010046,2010048,2010047},
--持续刷buff时间隔时间
buff_interval = 30,
exhiKey_succ =
{
[1] = {"Activity_SummerTimeV2_Kazuha_Succ", "Activity_SummerTimeV2_Kazuha_SuccOnce"},
[2] = {"Activity_SummerTimeV2_Xinyan_Succ", "Activity_SummerTimeV2_Xinyan_SuccOnce"},
[3] = {"Activity_SummerTimeV2_Fischl_Succ", "Activity_SummerTimeV2_Fischl_SuccOnce"},
[4] = {"Activity_SummerTimeV2_Mona_Succ", "Activity_SummerTimeV2_Mona_SuccOnce"},
},
--需要遍历上传的玩家陈列室 累计值
exhiKey_all ={
"Activity_SummerTimeV2_Kazuha_TSkill",
"Activity_SummerTimeV2_Mona_Push",
"Activity_SummerTimeV2_Mona_Buff",
"Activity_SummerTimeV2_Fischl_ElecShock",
"Activity_SummerTimeV2_Fischl_Buff",
"Activity_SummerTimeV2_Xinyan_Enbreak",
--"Activity_SummerTimeV2_Xinyan_FallAttack",--改为单人跨局累计
},
--陈列室替换值,每次开挑战需要手动重置
exhiKey_all_replace = {
--万叶
[1] = {
"Activity_SummerTimeV2_Kazuha_TotalBuff", --2.8大活动地城-万叶-单局拾取Buff总数
"Activity_SummerTimeV2_Kazuha_TSkillOnce", --2.8大活动地城-万叶-单局使用T键技能数
},
--辛焱
[2] = {
"Activity_SummerTimeV2_Xinyan_GadgetUsage",--2.8大活动地城-辛焱-单局交互传音花次数
"Activity_SummerTimeV2_Xinyan_EnbreakOnce",--2.8大活动地城-辛焱-单局传音花碎盾次数
"Activity_SummerTimeV2_Xinyan_FallAttackOnce",--2.8大活动地城-辛焱-单局下落冲击波击中次数
},
--菲谢尔
[3] = {
"Activity_SummerTimeV2_Fischl_BuffOnce",--2.8大活动地城-菲谢尔-单局获得奥兹buff次数
"Activity_SummerTimeV2_Fischl_ElecShockOnce",--2.8大活动地城-菲谢尔-单局雷冲击波击中次数
},
--莫娜
[4] = {
"Activity_SummerTimeV2_Mona_PushOnce",--2.8大活动地城-莫娜-单局撞怪数
"Activity_SummerTimeV2_Mona_BuffOnce",--2.8大活动地城-莫娜-单局获得星座buff次数
}
},
--局内reminder
--1-万叶 2-辛焱 3-菲谢尔 4-莫娜
reminder = {
[1] = 600123,--刷出buff时
[2] = 600124,--刷出monsterTide 3、4、5、6时
[3] = 600125,--刷出buff时
[4] = 600126,--星星按键可踩时
}
}
local extra_Triggers = {
{ config_id = 8000001, name = "Monster_Tide_Die", event = EventType.EVENT_MONSTER_TIDE_DIE, source = "", condition = "", action = "action_Monster_Tide_Die", trigger_count = 0},
--每30秒一刷直到开始新的一波怪
{ config_id = 8000004, name = "Buff_Sub_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "routine_buff", condition = "", action = "action_RoutineBuff_TimeAxis_Pass", trigger_count = 0},
{ config_id = 8000006, name = "MonaBuff2_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "mona_buff2", condition = "", action = "action_MonaBuff2_TimeAxis_Pass", trigger_count = 0},
{ config_id = 8000007, name = "WindField_GadgetCreate", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_WindField_GadgetCreate", trigger_count = 0},
{ config_id = 8000008, name = "WindField_GadgetDie", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_WindField_GadgetDie", trigger_count = 0},
{ config_id = 8000009, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0},
{ config_id = 8000010, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Select_Option", trigger_count = 0},
{ config_id = 8000011, name = "Dungeon_All_Avatar_Die", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_Dungeon_All_Avatar_Die", trigger_count = 0},
{ config_id = 8000012, name = "Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_Challenge_Success", trigger_count = 0},
{ config_id = 8000013, name = "Challenge_Fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_Challenge_Fail", trigger_count = 0},
}
function LF_Initialize(triggers, suites)
for i=1,#extra_Triggers do
table.insert(triggers, extra_Triggers[i])
table.insert(suites[init_config.suite].triggers,extra_Triggers[i].name)
end
--本次打哪个怪物潮套餐
table.insert(variables,{ config_id = 50000001, name = "rand_index", value = 1, no_refresh = true })
--本次创哪个suite
table.insert(variables,{ config_id = 50000002, name = "rand_suite", value = 0, no_refresh = true })
end
function action_Group_Load(context, evt)
--莫娜、辛焱地城add随机suite
if 2 == defs.type or 4 == defs.type then
LF_AddRandomSuite(context)
end
return 0
end
function action_Select_Option(context, evt)
-- 判断是starter
if evt.param1 ~= defs.starter then
return 0
end
if nil ~= defs.option_id then
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.starter, defs.option_id)
end
LF_SetRandIndex(context)
LF_InitChallenge(context)
LF_InitExhibitionTemp(context)
if nil == defs.is_tutorial then
LF_ClearReplacableExhibition(context)
if 2 == defs.type then
LF_Init_XinyanWatcherCounter(context)
end
end
ScriptLib.SetGroupTempValue(context, "wave", 1, {})
LF_StartMonsterTide(context, 1)
--辛焱 风场计数
if 2 == defs.type then
ScriptLib.SetGroupTempValue(context, "xinyan_wind", 0,{})
end
--ability SGVchange触发器
ScriptLib.SetGroupTempValue(context, "sgv_changer", 1, {})
return 0
end
--每次挑战清除翻牌子的陈列室替换值
function LF_ClearReplacableExhibition(context)
local uid_list = ScriptLib.GetSceneUidList(context)
for k, v in pairs(uid_list) do
for ik, iv in pairs(cfg.exhiKey_all_replace[defs.type]) do
ScriptLib.ClearExhibitionReplaceableData(context, v, iv)
end
end
return 0
end
function LF_SetRandIndex(context)
local rand_index = 1
--若配置了复数个,则随机一个
if 1 < #defs.rand_table then
math.randomseed(ScriptLib.GetServerTime(context))
rand_index = math.random(#defs.rand_table)
end
ScriptLib.SetGroupVariableValue(context, "rand_index", rand_index)
ScriptLib.PrintContextLog(context, "## [DLDungeon] LF_SetRandIndex. Monster tide table index@"..rand_index)
return 0
end
function action_RoutineBuff_TimeAxis_Pass(context)
ScriptLib.PrintContextLog(context, "## [DLDungeon] RoutineBuff_TimeAxis_Pass.")
LF_ClearBuffGadget(context)
LF_CreateRandomBuff(context, defs.buff_count)
return 0
end
function LF_InitChallenge(context)
local rand_index = ScriptLib.GetGroupVariableValue(context, "rand_index")
--计算怪物数量
local tide_queue = defs.rand_table[rand_index]
local sum = 0
for k,v in pairs(tide_queue) do
for ik, iv in pairs(v) do
sum = sum + #defs.tide_cfg[iv].monsters
end
end
--开启挑战
ScriptLib.StartChallenge(context, defs.challenge_id, defs.challenge_id, { defs.time_limit, base_info.group_id, sum })
return 0
end
function action_Dungeon_All_Avatar_Die(context, evt)
local uid_list = ScriptLib.GetSceneUidList(context)
for k,v in pairs(uid_list) do
local is_all_dead = ScriptLib.IsPlayerAllAvatarDie(context, v)
if false == is_all_dead then
return 0
end
end
ScriptLib.SetGroupTempValue(context, "is_all_dead", 1, {})
ScriptLib.CauseDungeonFail(context)
ScriptLib.StopChallenge(context, defs.challenge_id, 0)
return 0
end
function LF_ClearAllMonsterTide(context)
--取得rand_index
local rand_index = ScriptLib.GetGroupVariableValue(context, "rand_index")
--取得波次。找已刷出的,所以应该-1
local wave = ScriptLib.GetGroupTempValue(context, "wave", {}) - 1
--数值越界 由于tide_index获取不正确所以直接return不清怪了
if nil == defs.rand_table[rand_index] or nil == defs.rand_table[rand_index][wave] then
return 0
end
--正常值 clear指定的怪物潮
for k,v in pairs(defs.rand_table[rand_index][wave]) do
--怪物潮索引
local tide_index = wave*1000 + v
ScriptLib.PrintContextLog(context, "## [DLDungeon] Clear monster tide. tide_cfg@"..v.." tide_index@"..tide_index)
ScriptLib.KillMonsterTide(context, base_info.group_id, tide_index)
end
return 0
end
--开启一个波次的怪物潮
--wave波次序号rand_table的key
function LF_StartMonsterTide(context, wave)
--万叶、菲谢尔刷buff
if 1 == defs.type or 3 == defs.type then
ScriptLib.EndTimeAxis(context, "routine_buff")
LF_ClearBuffGadget(context)
LF_CreateRandomBuff(context, defs.buff_count)
ScriptLib.InitTimeAxis(context, "routine_buff", {cfg.buff_interval}, true)
ScriptLib.PrintContextLog(context, "## [DLDungeon] Buff_TimeAxis_Pass. Start routine buff time axis.")
end
--莫娜亮石板
if 4 == defs.type then
LF_ActiveMonaStar(context)
end
local rand_index = ScriptLib.GetGroupVariableValue(context, "rand_index")
--越界修正
--rand_index异常直接取1
if rand_index > #defs.rand_table then
rand_index = 1
ScriptLib.SetGroupVariableValue(context, "rand_index", rand_index)
end
--波次异常直接停止 以免无限循环
if wave > #defs.rand_table[rand_index] then
return 0
end
--本轮有几个并行怪物潮
local tide_num = #defs.rand_table[rand_index][wave]
--莫娜用 标记并行怪物潮的第一位
ScriptLib.SetGroupTempValue(context, "mona_buff_idx", defs.rand_table[rand_index][wave][1],{})
ScriptLib.SetGroupTempValue(context, "tide_num", tide_num, {})
--启动并行怪物潮
for k,v in pairs(defs.rand_table[rand_index][wave]) do
--设置怪物潮索引
local tide_index = wave*1000 + v
ScriptLib.PrintContextLog(context, "## [DLDungeon] Start monster tide. tide_cfg@"..v.." tide_index@"..tide_index)
--创建怪物潮
ScriptLib.AutoMonsterTide(context, tide_index, base_info.group_id, defs.tide_cfg[v].monsters, #defs.tide_cfg[v].monsters, defs.tide_cfg[v].min, defs.tide_cfg[v].max)
end
--波次++
ScriptLib.ChangeGroupTempValue(context, "wave", 1, {})
--辛焱reminder 如果本次中有 tide_cfg 3、4、5、6 则ShowHintReminder
if 2 == defs.type and 1 ~= defs.is_tutorial then
for k,v in pairs(defs.rand_table[rand_index][wave]) do
if 3 == v or 4 == v or 5 == v or 6 == v then
LF_ShowHintReminder(context)
return 0
end
end
end
return 0
end
function action_Monster_Tide_Die(context, evt)
local tide_index = tonumber(evt.source_name)
local wave = ScriptLib.GetGroupTempValue(context, "wave", {})
local tide_cfg_index = tide_index%10
ScriptLib.PrintContextLog(context, "## [DLDungeon]: Tide monster die. tide_index@".. tide_index.." die_count@".. evt.param1)
--是否杀光了一tide 如果tide_index异常没有修正的办法了直接终止挑战
if nil == defs.tide_cfg[tide_cfg_index] then
ScriptLib.CauseDungeonFail(context)
ScriptLib.StopChallenge(context, defs.challenge_id, 0)
return 0
end
if evt.param1 < #defs.tide_cfg[tide_cfg_index].monsters then
return 0
end
ScriptLib.ChangeGroupTempValue(context, "tide_num", -1, {})
--检查本轮怪物潮都已经结束
local tide_num = ScriptLib.GetGroupTempValue(context, "tide_num", {})
ScriptLib.PrintContextLog(context, "## [DLDungeon]: Tide index ".. tide_index.." all monster die. remain_tide_num@".. tide_num)
if 0 >= tide_num then
local rand_index = ScriptLib.GetGroupVariableValue(context, "rand_index")
if wave > #defs.rand_table[rand_index] then
--全部完成
else
--刷下一轮
ScriptLib.PrintContextLog(context, "## [DLDungeon] Monster_TimeAxis_Pass. Next wave@"..wave)
LF_StartMonsterTide(context, wave)
end
end
return 0
end
function action_Challenge_Success(context, evt)
if defs.challenge_id ~= evt.param1 then
return 0
end
------清理-------
--莫娜石板清除
if 4 == defs.type then
--灭掉星星和石板
LF_CloseMonaStar(context)
end
--万叶、菲谢尔清理场上Buff
if 1 == defs.type or 3 == defs.type then
--停止所有时间轴
ScriptLib.EndTimeAxis(context, "routine_buff")
LF_ClearBuffGadget(context)
end
if nil ~= defs.is_tutorial then
return 0
end
------陈列室-------
--陈列室
LF_ReportSkillExhibition(context)
LF_Report_XinyanWatcherCounter(context)
LF_Exhibition_Succ(context)
------结算-----
ScriptLib.CauseDungeonSuccess(context)
return 0
end
function action_Challenge_Fail(context, evt)
if defs.challenge_id ~= evt.param1 then
return 0
end
------清理-------
LF_ClearAllMonsterTide(context)
--莫娜石板cd清除
if 4 == defs.type then
--灭掉星星和石板
LF_CloseMonaStar(context)
end
--万叶、菲谢尔清理场上Buff
if 1 == defs.type or 3 == defs.type then
--停止所有时间轴
ScriptLib.EndTimeAxis(context, "routine_buff")
LF_ClearBuffGadget(context)
end
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = init_config.suite })
--莫娜、辛焱地城add随机suite
if 2 == defs.type or 4 == defs.type then
LF_AddRandomSuite(context)
end
-- 设置操作台选项
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.starter, { defs.option_id })
--教学关不DungeonFail
if nil ~= defs.is_tutorial then
return 0
end
--超时 弹结算框
if 0 >= evt.param2 then
ScriptLib.CauseDungeonFail(context)
end
return 0
end
function LF_AddRandomSuite(context)
math.randomseed(ScriptLib.GetServerTime(context))
local rand_index = math.random(#defs.rand_suites)
ScriptLib.SetGroupVariableValue(context, "rand_suite", rand_index)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.rand_suites[rand_index])
ScriptLib.PrintContextLog(context, "## [DLDungeon]: LF_AddRandomSuite. suite_index@".. rand_index)
return 0
end
--清场上buff
function LF_ClearBuffGadget(context)
for k, v in pairs(defs.buff_pool) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
for k, v in pairs(defs.buff_pool_spec) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
return 0
end
--创建随机buff调用之前需要清场 保证所有point都是可用的
function LF_CreateRandomBuff(context, count)
local spawn_queue = {table.unpack(defs.buff_pool)}
--需求先刷0~2个限定buff(无、A、B、A+B)其余部分刷普通buff。不需要再对buff种类做随机了
if nil ~= defs.buff_pool_spec and 2 <= #defs.buff_pool_spec then
math.randomseed(ScriptLib.GetServerTime(context))
local spec_num = math.random(0, 3)
--数量确定,只枚举情况不洗牌了
if 3 == spec_num then
table.insert(spawn_queue, 1, defs.buff_pool_spec[1])
table.insert(spawn_queue, 2, defs.buff_pool_spec[2])
elseif 1 == spec_num or 2 == spec_num then
table.insert(spawn_queue, 1, defs.buff_pool_spec[spec_num])
end
end
--检测count上限
count = math.min(count, #spawn_queue)
--依次创建spawn_queue中的buff物件直到达到count
local point_list = LF_Get_RandomPointList(context)
for i = 1, count do
--获取生成点位
local point_configID = point_list[i]
ScriptLib.PrintContextLog(context, "## [DLDungeon] To Create gadget. gadget@"..spawn_queue[i].." at Point@"..point_configID)
ScriptLib.CreateGadgetByConfigIdByPos(context, spawn_queue[i], gadgets[point_configID].pos, gadgets[point_configID].rot)
end
--有生成buff则提示
if count > 0 then
LF_ShowHintReminder(context)
end
return 0
end
--将point_list乱序返回
function LF_Get_RandomPointList(context)
math.randomseed(ScriptLib.GetServerTime(context))
local shuffled = {table.unpack(defs.point_list)}
for i = #shuffled, 1, -1 do
local j = math.random(i)
local tmp = shuffled[i]
shuffled[i] = shuffled[j]
shuffled[j] = tmp
end
return shuffled
end
--辛焱 风场创建
function action_WindField_GadgetCreate(context, evt)
if 2 ~= defs.type then
return 0
end
ScriptLib.PrintContextLog(context, "## [DLDungeon] WindField_GadgetCreate. evt.param1@"..evt.param1)
if 70220118 ~= gadgets[evt.param1].gadget_id then
return 0
end
ScriptLib.ChangeGroupTempValue(context, "xinyan_wind", 1, {})
LF_SetGV_AllTeam(context, "GV_XINYAN_BUFF", 1)
return 0
end
--辛焱 风场创建
function action_WindField_GadgetDie(context, evt)
if 70220118 ~= gadgets[evt.param1].gadget_id then
return 0
end
ScriptLib.ChangeGroupTempValue(context, "xinyan_wind", -1, {})
if 0 >= ScriptLib.GetGroupTempValue(context, "xinyan_wind", {}) then
LF_SetGV_AllTeam(context, "GV_XINYAN_BUFF", 0)
end
return 0
end
--莫娜 随机亮起一个当前suite的星星与石板
function LF_ActiveMonaStar(context)
--先关闭
LF_CloseMonaStar(context)
ScriptLib.SetGroupTempValue(context, "mona_btn", 1,{})
local suite_index = ScriptLib.GetGroupVariableValue(context, "rand_suite")
--越界修正
if nil == defs.rand_suites[suite_index] then
suite_index = 1
ScriptLib.SetGroupVariableValue(context, "rand_suite", suite_index)
end
local star_list = defs.stars[defs.rand_suites[suite_index]]
--越界修正
if nil == star_list then
star_list = defs.stars[1]
end
math.randomseed(ScriptLib.GetServerTime(context))
local star_idx = math.random(#star_list)
ScriptLib.SetGadgetStateByConfigId(context, star_list[star_idx][1], 201)
ScriptLib.SetGadgetStateByConfigId(context, star_list[star_idx][2], 201)
--非目标石板切202假亮
for k,v in pairs(gadgets) do
if v.gadget_id == 70310323 and k ~= star_list[star_idx][2] then
ScriptLib.SetGadgetStateByConfigId(context, k, 202)
end
end
LF_ShowHintReminder(context)
return 0
end
--莫娜 关闭星星与石板
function LF_CloseMonaStar(context)
local suite_index = ScriptLib.GetGroupVariableValue(context, "rand_suite")
local star_list = defs.stars[defs.rand_suites[suite_index]]
for k, v in pairs(star_list) do
ScriptLib.SetGadgetStateByConfigId(context, v[1], 0)
ScriptLib.SetGadgetStateByConfigId(context, v[2], 0)
end
return 0
end
--莫娜 石板被踩
function SLC_DLActivityDungeon_StarBtn(context)
if 1 ~= ScriptLib.GetGroupTempValue(context, "mona_btn", {}) then
return 0
end
--施加buff
LF_ActiveMonaBuff(context)
ScriptLib.SetGroupTempValue(context, "mona_btn", 0,{})
--记陈列室
LF_DLActivityDungeon_Exhi_MonaBuff(context)
--灭掉星星和石板
LF_CloseMonaStar(context)
return 0
end
--莫娜 施加当前怪物潮对应的buff并行怪物潮取第一个
function LF_ActiveMonaBuff(context)
local monster_tide_idx = ScriptLib.GetGroupTempValue(context, "mona_buff_idx", {})
local buff_list = defs.tide_cfg[monster_tide_idx].mona_buffs
if nil == buff_list then
return 0
end
math.randomseed(ScriptLib.GetServerTime(context))
local buff_idx = math.random(#buff_list)
ScriptLib.PrintContextLog(context, "## [DLDungeon] LF_ActiveMonaBuff. buff@"..buff_list[buff_idx])
--开启弹飞buff
if 1 == buff_list[buff_idx] then
LF_SetGV_AllTeam(context, "GV_MONA_BUFF1", 1)
--下雨、增伤buff
elseif 2 == buff_list[buff_idx] then
LF_SetGV_AllTeam(context, "GV_MONA_BUFF2", 1)
LF_HandleMonaWater(context, 1)
--全场控怪
elseif 3 == buff_list[buff_idx] then
LF_SetGV_AllMonster(context, "GV_MONA_BUFF3", 1)
LF_SetGV_AllTeam(context, "GV_MONA_BUFF3", 1)
end
--埋点
ScriptLib.MarkGroupLuaAction(context, "SummerTimeV2_Dungeon4_1", "", {["bufftype"] = buff_list[buff_idx]})
return 0
end
--莫娜buff2结束
function action_MonaBuff2_TimeAxis_Pass(context, evt)
LF_HandleMonaWater(context, 2)
return 0
end
function LF_ShowHintReminder(context)
ScriptLib.ShowReminder(context, cfg.reminder[defs.type])
ScriptLib.PrintContextLog(context, "[DLDungeon] LF_ShowHintReminder. rmd@"..cfg.reminder[defs.type])
return 0
end
--请求获取联机玩家数量
function SLC_Get_PlayerCount(context)
local uidList = ScriptLib.GetSceneUidList(context)
local num = #uidList
ScriptLib.PrintContextLog(context, "[DLDungeon] SLC_Get_PlayerCount. result@"..num)
LF_SetSGV_AllTeam(context,"SGV_DLDungeon_PlayerNum", num)
return 0
end
--万叶地城吃球
--param1: 1-球A大跳 2-球B减T键CD 3-球C增伤至最多三层
function SLC_DLActivityDungeon_Kazuha(context, param1)
ScriptLib.PrintContextLog(context, "## [DLDungeon] SLC_DLActivityDungeon_Kazuha. param1@"..param1.." uid@"..context.uid)
if 1 == param1 then
LF_SetGV_AllTeam(context, "GV_KAZUHA_BUFF1", 1)
elseif 2 == param1 then
LF_SetGV_AllTeam(context,"GV_KAZUHA_BUFF2", 1)
elseif 3 == param1 then
LF_SetGV_AllTeam(context, "GV_KAZUHA_BUFF3", 1)
end
if nil ~= defs.is_tutorial or 1 ~= defs.type then
return 0
end
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_SummerTimeV2_Kazuha_TotalBuff", 1)
--埋点
ScriptLib.MarkGroupLuaAction(context, "SummerTimeV2_Dungeon1_2", "", {["bufftype"] = param1})
return 0
end
--万叶地城减CD触发
--param1: 0-元素战技 1-元素爆发 2-下落攻击
function SLC_DLActivityDungeon_TCoolDown(context, param1)
ScriptLib.PrintContextLog(context, "## [DLDungeon] SLC_DLActivityDungeon_TCoolDown. param1@"..param1)
if 1 == param1 then
LF_TriggerSGVChangeAllTeam(context, "GV_SKILL_CD")
elseif 2 == param1 then
LF_TriggerSGVChangeAllTeam(context, "GV_ULTIMATESKILL_CD")
elseif 3 == param1 then
LF_TriggerSGVChangeAllTeam(context, "GV_FALLINGATK_CD")
end
LF_Exhibition_CoolDown(context, context.uid)
return 0
end
--菲谢尔地城
--param1: 1-雷震荡波 2-奥兹 3-刷大招
function SLC_DLActivityDungeon_Fischl(context, param1)
ScriptLib.PrintContextLog(context, "## [DLDungeon] SLC_DLActivityDungeon_Fischl. param1@"..param1.." uid@"..context.uid)
if 1 == param1 then
LF_SetGV_OnePlayer(context, "GV_CREATE_ELECTRICZONE", 1)
LF_Exhibition_FischlBuff(context)
elseif 2 == param1 then
LF_Exhibition_FischlBuff(context)
elseif 3 == param1 then
LF_SetGV_OnePlayer(context, "GV_FISCHL_BUFF3", 1)
LF_Exhibition_FischlBuff(context)
end
--埋点
ScriptLib.MarkGroupLuaAction(context, "SummerTimeV2_Dungeon3_1", "", {["bufftype"] = param1})
return 0
end
--招奥兹需要冲物件SLC所以陈列室另起一个SLC
function SLC_DLActivityDungeon_FischlOzSummon(context)
local position = { x = 0, y = 0, z = 0}
local pos_raw = ScriptLib.GetPosByEntityId(context, context.source_entity_id)
position.x = pos_raw.x - pos_raw.x % 0.01
position.y = pos_raw.y - pos_raw.y % 0.01
position.z = pos_raw.z - pos_raw.z % 0.01
if nil ~= defs.crow_id then
for k , v in pairs(defs.crow_id) do
local ret = ScriptLib.CreateGadgetByConfigIdByPos(context, v, position, gadgets[v].rot)
if 0 == ret then
break
end
end
end
return 0
end
function LF_HandleMonaWater(context, dir)
ScriptLib.SetPlatformPointArray(context, defs.move_water.config_id, defs.move_water.point_array, {defs.move_water.point[dir]}, {route_type = 0, turn_mode = false, record_mode = 0})
if 1 == dir then
ScriptLib.InitTimeAxis(context, "mona_buff2", {10}, false)
end
return 0
end
function LF_TriggerSGVChangeAllTeam(context, key)
local value = ScriptLib.GetGroupTempValue(context, "sgv_changer", {})
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, key, value)
ScriptLib.PrintContextLog(context, "## [DLDungeon] LF_TriggerSGVChangeAllTeam. key@"..key.." value@"..value)
if value > 1000 then
ScriptLib.SetGroupTempValue(context, "sgv_changer", 0, {})
else
ScriptLib.ChangeGroupTempValue(context, "sgv_changer", 1, {})
end
return 0
end
function LF_SetGV_AllMonster(context, key, value)
local mon_list = ScriptLib.GetGroupAliveMonsterList(context, base_info.group_id)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, mon_list, key, value)
ScriptLib.PrintContextLog(context, "## [DLDungeon] LF_SetGV_AllMonster. key@"..key.." value@"..value)
return 0
end
function LF_SetGV_AllTeam(context, key, value)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, key, value)
ScriptLib.PrintContextLog(context, "## [DLDungeon] LF_SetGV_AllTeam. key@"..key.." value@"..value)
return 0
end
function LF_SetGV_OnePlayer(context, key, value)
ScriptLib.SetTeamEntityGlobalFloatValue(context, {context.uid}, key, value)
ScriptLib.PrintContextLog(context, "## [DLDungeon] LF_SetGV_OnePlayer. key@"..key.." value@"..value.." uid@"..context.uid)
return 0
end
function LF_SetSGV_AllTeam(context, key, value)
local uid_list = ScriptLib.GetSceneUidList(context)
for k,v in pairs(uid_list) do
ScriptLib.SetTeamServerGlobalValue(context, v, key, value)
end
ScriptLib.PrintContextLog(context, "## [DLDungeon] LF_SetSGV_AllTeam. key@"..key.." value@"..value)
return 0
end
--群体都加的陈列室统一处理,减少遍历次数
function LF_ReportSkillExhibition(context)
local uid_list = ScriptLib.GetSceneUidList(context)
for k, v in pairs(cfg.exhiKey_all) do
local record = ScriptLib.GetGroupTempValue(context, v, {})
if 0 < record then
for ik,iv in pairs(uid_list) do
ScriptLib.AddExhibitionAccumulableData(context, iv, v, record)
end
end
end
return 0
end
--陈列室 通用 全体 通关次数
function LF_Exhibition_Succ(context)
if nil ~= defs.is_tutorial then
return 0
end
local uid_list = ScriptLib.GetSceneUidList(context)
for k,v in pairs(uid_list) do
ScriptLib.AddExhibitionAccumulableData(context, v, cfg.exhiKey_succ[defs.type][1], 1)
ScriptLib.AddExhibitionReplaceableData(context, v, cfg.exhiKey_succ[defs.type][2], 1)
end
return 0
end
--重置陈列室缓存值
function LF_InitExhibitionTemp(context)
if nil ~= defs.is_tutorial then
return 0
end
for k, v in pairs(cfg.exhiKey_all) do
ScriptLib.SetGroupTempValue(context, v, 0, {})
end
return 0
end
--陈列室 万叶 单人 单局减CD触发次数
function LF_Exhibition_CoolDown(context, uid)
if nil ~= defs.is_tutorial or 1 ~= defs.type then
return 0
end
ScriptLib.AddExhibitionReplaceableData(context, uid, "Activity_SummerTimeV2_Kazuha_CoolDown", 1)
return 0
end
--缓存陈列室 万叶 T键次数
function SLC_DLActivityDungeon_Exhi_TSkill(context)
if nil ~= defs.is_tutorial or 1 ~= defs.type then
return 0
end
--全体
ScriptLib.ChangeGroupTempValue(context, "Activity_SummerTimeV2_Kazuha_TSkill", 1, {})
--单人
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_SummerTimeV2_Kazuha_TSkillOnce", 1)
--埋点
ScriptLib.MarkGroupLuaAction(context, "SummerTimeV2_Dungeon1_1", "", {})
return 0
end
--缓存陈列室 莫娜 撞怪击中次数
function SLC_DLActivityDungeon_Exhi_MonaPush(context)
if nil ~= defs.is_tutorial or 4 ~= defs.type then
return 0
end
--全体
ScriptLib.ChangeGroupTempValue(context, "Activity_SummerTimeV2_Mona_Push", 1, {})
--单人
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_SummerTimeV2_Mona_PushOnce", 1)
return 0
end
--缓存陈列室 菲谢尔 全体 冲击波击中次数
function SLC_DLActivityDungeon_Exhi_FischlElecShock(context)
if nil ~= defs.is_tutorial or 3 ~= defs.type then
return 0
end
--全体
ScriptLib.ChangeGroupTempValue(context, "Activity_SummerTimeV2_Fischl_ElecShock", 1, {})
--单人
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_SummerTimeV2_Fischl_ElecShockOnce", 1)
return 0
end
--缓存陈列室 菲谢尔 获得奥兹buff次数
function LF_Exhibition_FischlBuff(context)
if nil ~= defs.is_tutorial or 3 ~= defs.type then
return 0
end
--全体
ScriptLib.ChangeGroupTempValue(context, "Activity_SummerTimeV2_Fischl_Buff", 1, {})
--单人
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_SummerTimeV2_Fischl_BuffOnce", 1)
return 0
end
--缓存陈列室 莫娜 全体 获得星星buff次数
function LF_DLActivityDungeon_Exhi_MonaBuff(context)
if nil ~= defs.is_tutorial or 4 ~= defs.type then
return 0
end
--全体
ScriptLib.ChangeGroupTempValue(context, "Activity_SummerTimeV2_Mona_Buff", 1, {})
--单人
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_SummerTimeV2_Mona_BuffOnce", 1)
return 0
end
--缓存陈列室 辛焱 全体 交互传音花次数
--param1: 1-风场 2-声波
function SLC_DLActivityDungeon_Exhi_GadgetUsage(context, param1)
if nil ~= defs.is_tutorial or 2 ~= defs.type then
return 0
end
--单人
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_SummerTimeV2_Xinyan_GadgetUsage", 1)
--埋点
if 1 == param1 then
ScriptLib.MarkGroupLuaAction(context, "SummerTimeV2_Dungeon2_1", "", {})
elseif 2 == param1 then
ScriptLib.MarkGroupLuaAction(context, "SummerTimeV2_Dungeon2_2", "", {})
end
return 0
end
--缓存陈列室 辛焱 全体 花冲击波击中盾怪次数
function SLC_DLActivityDungeon_Exhi_XinyanEnbreak(context)
if nil ~= defs.is_tutorial or 2 ~= defs.type then
return 0
end
--全体
ScriptLib.ChangeGroupTempValue(context, "Activity_SummerTimeV2_Xinyan_Enbreak", 1, {})
--单人
-- ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_SummerTimeV2_Xinyan_EnbreakOnce", 1)
return 0
end
--缓存陈列室 辛焱 全体 下落攻击击中次数
function SLC_DLActivityDungeon_Exhi_XinyanFallAttack(context)
if nil ~= defs.is_tutorial or 2 ~= defs.type then
return 0
end
--单人跨局累计wathcer
ScriptLib.ChangeGroupTempValue(context, tostring(context.uid), 1, {})
--单人单局
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_SummerTimeV2_Xinyan_FallAttackOnce", 1)
return 0
end
--用于辛焱单人watcher 因为挑战完成才计数,所以缓存一下
function LF_Init_XinyanWatcherCounter(context)
--对每个玩家以uid为key创建tempValue
local uid_list = ScriptLib.GetSceneUidList(context)
for k,v in pairs(uid_list) do
ScriptLib.SetGroupTempValue(context, tostring(v), 0, {})
end
return 0
end
function LF_Report_XinyanWatcherCounter(context)
local uid_list = ScriptLib.GetSceneUidList(context)
for k,v in pairs(uid_list) do
local result = ScriptLib.GetGroupTempValue(context, tostring(v), {})
if 0 < result then
ScriptLib.AddExhibitionAccumulableData(context, v, "Activity_SummerTimeV2_Xinyan_FallAttack", result)
end
end
return 0
end
LF_Initialize(triggers, suites)

View File

@@ -0,0 +1,557 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: DrawOneLine_Dreamland
|| owner: weiwei.sun
|| description: 一笔画 辛焱岛版本。
|| LogName: ## [DrawOneLine]
|| Protection:
=======================================]]
--[[
local defs =
{
--玩法完成时 这个gadget如果为GearStop则会被设为Default
finish_gadget = ,
--起点格configid
starter = ,
--终点格configid
ender = ,
--矩阵 用于踩格子时判断是否相邻
matrix =
{
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
},
--每个还原格控制哪些离散格
reveal_tiles=
{
[还原格] = {被还原的格子1, 被还原的格子2},
},
--离散格拼入哪个位置拼入位置需要布设普通格初始状态为903
reveal_match=
{
[离散格1] = 初始状态为903普通格configID1,
},
--移动格的目标位置和使用的点阵
movable_pos =
{--[移动格子configID] = new_pos: 两位数字的矩阵坐标x是十位y是个位
[10011] = { new_pos = 12},
},
lines=
{
[移动格] = 线,
},
}
]]
local cfg = {
--玩法中,最多存在多少石板
--tile_limit = 25,
--矩阵在哪个suite中
matrix_suite = 2,
}
local extraTriggers={
{ config_id = 8000001, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000002,name = "Leave_Region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_Leave_Region", trigger_count = 0 },
{ config_id = 8000003, name = "Reach_Point", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_Reach_Point", trigger_count = 0 },
{ config_id = 8000004, name = "Group_Refresh", event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_Group_Refresh", trigger_count = 0 },
{ config_id = 8000005, name = "Enter_Guide_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Guide_Region", trigger_count = 0 }
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables, { config_id = 50000001, name = "is_finish", value = 0 , no_refresh = true})
end
function SLC_DrawOneLine_Start(context)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
--SLC来源没有配置为起点 return
if config_id ~= defs.starter then
return 0
end
local state = ScriptLib.GetGroupTempValue(context, "puzzle_state", {})
ScriptLib.PrintContextLog(context, "## [DrawOneLine] Get SLC_DrawOneLine_Start. state@"..state)
if 0 == state then
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201)
LF_SetCurTileIndex(context, config_id)
LF_InitMatrix(context)
elseif 1 == state then
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201)
LF_SetCurTileIndex(context, config_id)
LF_RestartMatrix(context)
else
ScriptLib.PrintContextLog(context, "## [DrawOneLine] #WARN# Get SLC_DrawOneLine_Start at unexpected state!")
end
--埋点
ScriptLib.MarkGroupLuaAction(context, "NoteSlateStart", "", {["group_id"] = base_info.group_id, ["gadget_id"] = config_id})
return 0
end
--5.26迭代 未失败时触发起点格重置
function SLC_DrawOneLine_Reset(context)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
--SLC来源没有配置为起点 return
if config_id ~= defs.starter then
return 0
end
local state = ScriptLib.GetGroupTempValue(context, "puzzle_state", {})
ScriptLib.PrintContextLog(context, "## [DrawOneLine] Get SLC_DrawOneLine_Reset. state@"..state)
if 1 ~= state then
return 0
end
--如果已经离开了起点 则重置
local cur_tile = ScriptLib.GetGroupTempValue(context, "cur_tile", {})
local x = math.floor(cur_tile/10)
local y = cur_tile%10
if defs.matrix[x][y] ~= config_id then
LF_SetCurTileIndex(context, config_id)
LF_RestartMatrix(context)
end
return 0
end
function action_Group_Load(context, evt)
--测试用
--LF_CheckGadgetCount(context)
if 1 == ScriptLib.GetGroupVariableValue(context, "is_finish") then
return 0
end
--初始化tempVar当前踩在哪个块
ScriptLib.SetGroupTempValue(context, "cur_tile", 0, {})
--初始化tempVar矩阵是否加载 0-未加 1-加了 2-完成
ScriptLib.SetGroupTempValue(context, "puzzle_state", 0, {})
LF_SetStarterTile(context, 0)
return 0
end
function action_Group_Refresh(context, evt)
if 1 ~= evt.param1 then
return
end
--初始化tempVar当前踩在哪个块
ScriptLib.SetGroupTempValue(context, "cur_tile", 0, {})
--初始化tempVar矩阵是否加载 0-未加 1-加了 2-完成
ScriptLib.SetGroupTempValue(context, "puzzle_state", 0, {})
LF_SetStarterTile(context, 0)
return 0
end
--移动格到达路点
function action_Reach_Point(context, evt)
ScriptLib.PrintContextLog(context, "## [DrawOneLine] Moving tile reach point. config_id@"..evt.param2)
return 0
end
function action_Leave_Region(context, evt)
if evt.param1 == defs.guide_region then
return 0
end
if 1 == ScriptLib.GetGroupTempValue(context, "puzzle_state", {}) then
LF_FailProgress(context, 2)
end
return 0
end
function action_Enter_Guide_Region(context, evt)
if evt.param1 ~= defs.guide_region then
return 0
end
LF_TryShowGuide(context)
return 0
end
function SLC_DrawOneLine_Fail(context)
if 1 == ScriptLib.GetGroupTempValue(context, "puzzle_state", {}) then
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.PrintContextLog(context, "## [DrawOneLine] SLC_DrawOneLine_Fail. config_id@"..config_id)
--检查是否是当前格
local cur_tile = ScriptLib.GetGroupTempValue(context, "cur_tile", {})
local is_adjust = LF_CheckTwoGadgetIsAdjacent(context, cur_tile, config_id)
if 2 ~= is_adjust then
if config_id == defs.starter then
--如果是起点格 重开
LF_SetStarterTile(context, 1)
else
LF_FailProgress(context, 0)
end
end
end
return 0
end
--非起点终点的格子被踩亮
--param1格子类型 0-普通和离散 1-移动 2-还原
function SLC_DrawOneLine_LightOn(context, param1)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
--如果当前格,无事发生
local cur_tile = ScriptLib.GetGroupTempValue(context, "cur_tile", {})
local is_adjust = LF_CheckTwoGadgetIsAdjacent(context, cur_tile, config_id)
ScriptLib.PrintContextLog(context, "## [DrawOneLine] SLC_DrawOneLine_LightOn. config_id@"..config_id.." cur_tile@"..cur_tile.. " is_adjust@"..is_adjust)
if 2 == is_adjust then
return 0
end
--是否是起点格
if config_id == defs.starter then
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201)
LF_SetCurTileIndex(context, config_id)
LF_InitMatrix(context)
else
if 1 == ScriptLib.GetGroupTempValue(context, "is_fail", {}) then
return 0
end
--检测是否相邻
if 0 == is_adjust then
LF_FailProgress(context, 1)
return 0
end
--点亮格子
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201)
LF_SetCurTileIndex(context, config_id)
end
--处理功能性格
if 1 == param1 then
LF_HandleMoveTile(context, config_id)
elseif 2 == param1 then
LF_HandleRevealTile(context, config_id)
end
return 0
end
--终点格踩亮
function SLC_DrawOneLine_CheckSuccess(context)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.PrintContextLog(context, "## [DrawOneLine] SLC_DrawOneLine_CheckSuccess. config_id@"..config_id)
--是否相邻
local cur_tile = ScriptLib.GetGroupTempValue(context, "cur_tile", {})
local is_adjust = LF_CheckTwoGadgetIsAdjacent(context, cur_tile, config_id)
if 0 == is_adjust then
LF_FailProgress(context, 1)
return 0
end
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201)
--是否已成功
local ret = LF_CheckSuccess(context)
ScriptLib.PrintContextLog(context, "## [DrawOneLine] SLC_DrawOneLine_CheckSuccess called. ret@"..ret)
if 1 == ret then
LF_SuccessProgress(context)
else
LF_FailProgress(context, 1)
end
return 0
end
function LF_HandleMoveTile(context, config_id)
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_HandleMoveTile called. config_id@".. config_id)
--移除线
if nil ~= defs.lines then
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.lines[config_id])
end
--route
local ret = ScriptLib.StartPlatform(context, config_id)
if -1 == ret then
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_HandleMoveTile. StartPlatform failed!")
return 0
end
--设置新cur_tile
ScriptLib.SetGroupTempValue(context, "cur_tile", defs.movable_pos[config_id].new_pos, {})
local cur_tile = ScriptLib.GetGroupTempValue(context, "cur_tile", {})
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_HandleMoveTile done. cur_tile@".. cur_tile)
return 0
end
function LF_HandleRevealTile(context, config_id)
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_HandleRevealTile called. config_id@".. config_id)
--找到对应的所有离散格子以其configID查找对应的隐藏格
for k, v in ipairs(defs.reveal_tiles[config_id]) do
LF_CreateTileByMatchCfg(context, v)
end
return 0
end
--处理还原格 正向操作
function LF_CreateTileByMatchCfg(context, config_id)
--先切换隐藏格
ScriptLib.SetGadgetStateByConfigId(context, defs.reveal_match[config_id], 0)
--再移除离散格
ScriptLib.KillEntityByConfigId(context, { config_id = config_id })
return 0
end
--处理还原格 逆向操作
function LF_RemoveTileByMatchCfg(context, config_id)
--先切换隐藏格
ScriptLib.SetGadgetStateByConfigId(context, defs.reveal_match[config_id], 903)
--再添加离散格
ScriptLib.CreateGadget(context, { config_id = config_id })
return 0
end
--失败流程 所有格子置为202 起点格为0 踩起点格后重新开始
--reason: 0-踩了已经被踩亮的格子 1-踩了不相邻的格子 2-出圈
function LF_FailProgress(context, reason)
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_FailProgress called. reason@"..reason)
--出圈,直接清掉矩阵重来
if 2 == reason then
LF_SetStarterTile(context, 1)
else
--其他情况切到错误态
ScriptLib.SetGroupTempValue(context, "is_fail", 1, {})
--矩阵内
for k, v in pairs(defs.matrix) do
for ik, iv in pairs(v) do
--起点格切default
if defs.starter == iv then
ScriptLib.SetGadgetStateByConfigId(context, iv, 0)
--其他格子如果未处于隐藏态切GearStop
elseif 0 ~= iv then
if 903 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, iv) then
ScriptLib.SetGadgetStateByConfigId(context, iv, 202)
end
end
end
end
--矩阵外
for k, v in pairs(defs.reveal_tiles) do
for ik,iv in pairs(v) do
ScriptLib.SetGadgetStateByConfigId(context, iv, 202)
end
end
end
--埋点
ScriptLib.MarkGroupLuaAction(context, "NoteSlateEnd", "", {["group_id"] = base_info.group_id, ["result"] = 2})
return 0
end
function LF_KillAllGadget(context)
--用Kill 以播放onKill效果
for k,v in pairs(suites[cfg.matrix_suite].gadgets) do
ScriptLib.KillEntityByConfigId(context, { config_id = v })
end
return 0
end
function LF_SuccessProgress(context)
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_SuccessProgress called.")
--2022.3.3迭代:玩法完成,所有板子消失
local finish_gadget_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.finish_gadget)
if 202 == finish_gadget_state then
ScriptLib.SetGadgetStateByConfigId(context, defs.finish_gadget, 0)
end
LF_KillAllGadget(context)
--标记完成
ScriptLib.SetGroupVariableValue(context, "is_finish", 1)
--埋点
ScriptLib.MarkGroupLuaAction(context, "NoteSlateEnd", "", {["group_id"] = base_info.group_id, ["result"] = 1})
return 0
end
--矩阵内所有板子都是201状态则玩法成功, return 1
function LF_CheckSuccess(context)
for k, v in pairs(defs.matrix) do
for ik, iv in pairs(v) do
if 0 ~= iv and 201 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, iv) and 0 ~= iv then
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_CheckSuccess ret 0. Found blank tile@"..iv)
return 0
end
end
end
ScriptLib.SetGroupTempValue(context, "puzzle_state", 2 , {})
return 1
end
--加载起点格
--type 0-常规加载 1-处理重置,然后加载
function LF_SetStarterTile(context, type)
if type == 0 then
ScriptLib.CreateGadget(context, { config_id = defs.starter })
else
LF_KillAllGadget(context)
if 1 == ScriptLib.GetGroupTempValue(context, "puzzle_state", {}) then
ScriptLib.SetGroupTempValue(context, "puzzle_state", 0, {})
end
ScriptLib.CreateGadget(context, { config_id = defs.starter })
end
return 0
end
--一笔画矩阵 加载
function LF_InitMatrix(context)
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_InitMatrix.")
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, cfg.matrix_suite)
ScriptLib.SetGroupTempValue(context, "puzzle_state", 1, {})
ScriptLib.SetGroupTempValue(context, "is_fail", 0, {})
return 0
end
--一笔画矩阵 不销毁重开
function LF_RestartMatrix(context)
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_RestartMatrix called.")
ScriptLib.SetGroupTempValue(context, "is_fail", 0, {})
--遍历矩阵每个格子
for k, v in pairs(defs.matrix) do
for ik, iv in pairs(v) do
LF_ResetTile(context, iv)
end
end
--处理矩阵外
for k, v in pairs(defs.reveal_tiles) do
for ik, iv in pairs(v) do
ScriptLib.SetGadgetStateByConfigId(context, iv, 0)
end
end
return 0
end
function LF_ResetTile(context, config_id)
--处理还原格
if nil ~= defs.reveal_tiles[config_id] then
--对还原格控制的每个离散格,调下还原函数
for k, v in ipairs(defs.reveal_tiles[config_id]) do
LF_RemoveTileByMatchCfg(context, v)
end
--还原格恢复
ScriptLib.SetGadgetStateByConfigId(context, config_id, 0)
--处理移动格
elseif nil ~= defs.movable_pos[config_id] then
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_ResetTile. MoveTile config_id@"..config_id)
--移动格重置
ScriptLib.KillEntityByConfigId(context, { config_id = config_id })
ScriptLib.CreateGadget(context, { config_id = config_id })
--移动格的连线
if nil ~= defs.lines then
ScriptLib.CreateGadget(context, {config_id = defs.lines[config_id]})
end
else
--处理普通格(非起点 非初始隐藏格)
if defs.starter ~= config_id and 0 ~= config_id and gadgets[config_id].state ~= GadgetState.Action03 then
ScriptLib.SetGadgetStateByConfigId(context, config_id, 0)
end
end
return 0
end
--设置当前在哪个方块
function LF_SetCurTileIndex(context, config_id)
for i=1,#defs.matrix do
for j=1,#defs.matrix[i] do
if defs.matrix[i][j] == config_id then
ScriptLib.SetGroupTempValue(context, "cur_tile", i*10 + j, {})
end
end
end
return 0
end
--检测两个方块是否是相邻方块
--返回值 0-不相邻 1-相邻 2-当前格
function LF_CheckTwoGadgetIsAdjacent(context, current_idx, config_step_in)
local x = math.floor(current_idx/10)
local y = current_idx%10
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_CheckTwoGadgetIsAdjacent. cur_x@"..x.." cur_y@"..y.." step_in@"..config_step_in)
if defs.matrix[x][y] == config_step_in then
ScriptLib.PrintContextLog(context, "## [DrawOneLine] LF_CheckTwoGadgetIsAdjacent. Step in a same tile.")
return 2
end
if y > 1 then
--上方
if defs.matrix[x][y-1] == config_step_in then
local new_idx = x*10+y-1
ScriptLib.SetGroupTempValue(context, "cur_tile", new_idx, {})
return 1
end
end
if y < #defs.matrix[x] then
--下方
if defs.matrix[x][y+1] == config_step_in then
local new_idx = x*10+y+1
ScriptLib.SetGroupTempValue(context, "cur_tile", new_idx, {})
return 1
end
end
if x > 1 then
--左侧
if defs.matrix[x-1][y] == config_step_in then
local new_idx = (x-1)*10+y
ScriptLib.SetGroupTempValue(context, "cur_tile", new_idx, {})
return 1
end
end
if x < #defs.matrix then
--右侧
if defs.matrix[x+1][y] == config_step_in then
local new_idx = (x+1)*10+y
ScriptLib.SetGroupTempValue(context, "cur_tile", new_idx, {})
return 1
end
end
return 0
end
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
--检查物件数量是否超标超过数量则玩法逻辑不work。锁dev后可以考虑不再调用
function LF_CheckGadgetCount(context)
local sum = 0
for k, v in pairs(defs.matrix) do
for ik, iv in pairs(v) do
if iv ~= 0 then
sum = sum + 1
end
end
end
if sum > cfg.tile_limit then
ScriptLib.PrintContextLog(context, "## [DrawOneLine] #WARN# Gadget over use! Tell LD.")
return 1
end
return 0
end
function LF_TryShowGuide(context)
--在NewActivityPushTipsData配置中查找对应id, 并通过lua添加进活动中
--重复添加已有push tips返回-1 成功添加返回0
local ret = ScriptLib.TryRecordActivityPushTips(context, 2014011)
if 0 == ret then
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.ShowClientTutorial(context, 1182, {uid})
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,197 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: DreamLandSuiteState
|| owner: weiwei.sun
|| description: 2.8Group内容切换类玩法泛用型物件状态保存器。存9个物件9个状态
|| LogName: ## [DreamLandSuiteState]
|| Protection:
=======================================]]
--[[
defs = {
--本Group用哪组LevelTag控制请查LevelTagData表
levelTagGroupID = 3,
--是否由re-quire控制切suite填0则不需要配置switchByLevelTag_suites
switchByLevelTag = 1,
--切入该LevelTag时加载且仅加载的suite。
--注意被此操作Remove掉的物件不会保留GadgetState
switchByLevelTag_suites = {
["2_8_BuDing_MDLY"] = {2},
["2_8_BuDing_MDDQ"] = {2},
["2_8_BuDing_DQLY"] = {3,2},
},
--需要保存gadgetState的物件configID最多9个
saved_gadget =
{
4004, 4005, 4006
}
}
]]
--定义数字对应的gadgetState
local state_define={
[1] = 0,--Default
[2] = 101,--ChestLocked
[3] = 102,--ChestOpened
[4] = 104,--ChestBramble
[5] = 105,--ChestFrozen
[6] = 201,--GearStart
[7] = 202,--GearStop
[8] = 203,--GearAction1
[9] = 204,--GearAction2
}
local state_Triggers = {
{ config_id = 8800001, name = "Group_Load_Dreamland", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load_Dreamland", trigger_count = 0 },
{ config_id = 8800002, name = "LevelTag_Change_Dreamland", event = EventType.EVENT_LEVEL_TAG_CHANGE, source = "", condition = "", action = "action_LevelTag_Change_Dreamland", trigger_count = 0 },
{ config_id = 8800003, name = "Gadget_StateChange_Dreamland", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Gadget_StateChange_Dreamland", trigger_count = 0 },
}
function LF_Initialize_Dreamland_Group(triggers, suites)
for i=1,#state_Triggers do
table.insert(triggers, state_Triggers[i])
table.insert(suites[init_config.suite].triggers,state_Triggers[i].name)
end
table.insert(variables,{ config_id = 58800001, name = "saved_state", value = 1000000000, no_refresh = true })
end
--在GadgetStateChange时如果为saved_gadget中的物件则记录
--evt.param2:configID
--evt.param1:切换后的state
function action_Gadget_StateChange_Dreamland(context, evt)
local index = LF_GetIndexInTable(context, evt.param2, defs.saved_gadget)
--非存档物件
if 0 == index then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] Save gadget state ignored. configID@"..evt.param2.." index@"..index)
return 0
end
--写什么数字
local state_index = LF_GetStateIndexByGadgetState(context, evt.param1)
--写在哪一位
local state_place = math.pow(10, index - 1)
--该位数字现在是几
local saved_int = ScriptLib.GetGroupVariableValue(context, "saved_state")
local saved_table = LF_Split_Int(context, saved_int)
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] LF_GetStateIndexByGadgetState: Get state_place@"..state_place.." state_index@"..state_index)
--写
ScriptLib.ChangeGroupVariableValue(context, "saved_state", (state_index - saved_table[index]) * state_place)
local result = ScriptLib.GetGroupVariableValue(context, "saved_state")
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] Save gadget state. configID@"..evt.param2.." index@"..index.." saved_state@"..result)
return 0
end
function LF_GetStateIndexByGadgetState(context, state_id)
local state_index = 0
for k,v in pairs(state_define) do
if v == state_id then
state_index = k
return state_index
end
end
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] #WARN# LF_GetStateIndexByGadgetState: Get undefined gadget state! state@"..state_id)
return 0
end
function LF_GadgetStateRecover(context)
--检查gadget数量是否在合法范围内
if 9 < #defs.saved_gadget then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] #WARN# saved_gadget over used!")
return 0
end
local saved_int = ScriptLib.GetGroupVariableValue(context, "saved_state")
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] LF_GadgetStateRecover. saved_int@"..saved_int..". num to save@"..#defs.saved_gadget)
local saved_table = LF_Split_Int(context, saved_int)
for i = 1, #defs.saved_gadget do
if 0 ~= saved_table[i] then
local ret = ScriptLib.SetGadgetStateByConfigId(context, defs.saved_gadget[i], state_define[saved_table[i]])
end
if -1 == ret then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] #WARN# LF_GadgetStateRecover: Set gadget state failed! config_id@"..defs.saved_gadget[i].." stateIndex@"..saved_table[i])
end
end
return 0
end
function action_LevelTag_Change_Dreamland(context, evt)
local tag_name = ScriptLib.GetLevelTagNameById(context, evt.param2)
if "" == tag_name then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] LevelTag_Change_Dreamland: Get level tag name failed.")
return 0
end
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] LevelTag_Change_Dreamland: Get level tag name@"..tag_name)
LF_SwitchByDreamlandLevelTag(context, tag_name)
LF_GadgetStateRecover(context)
return 0
end
function action_Group_Load_Dreamland(context ,evt)
local tag_name = LF_GetCurLevelTagName(context)
if "" == tag_name then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] Group_Load_Dreamland: Get level tag name failed.")
return 0
end
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] Group_Load_Dreamland: Get level tag name@"..tag_name)
LF_SwitchByDreamlandLevelTag(context, tag_name)
LF_GadgetStateRecover(context)
return 0
end
function LF_GetCurLevelTagName(context)
--2.8海岛中每个levelTagGroup即series中的tag都是互斥关系所以取第一位
local cur_tag = ScriptLib.GetCurrentLevelTagVec(context, defs.levelTagGroupID)[1]
local tag_name = ScriptLib.GetLevelTagNameById(context, cur_tag)
return tag_name
end
--根据LevelTagName切suite。含有Trigger的suite1不动
function LF_SwitchByDreamlandLevelTag(context, tag_name)
if 1 ~= defs.switchByLevelTag then
return 0
end
for k, v in pairs(suites) do
if k ~= 1 then
if 0 ~= LF_GetIndexInTable(context, k, defs.switchByLevelTag_suites[tag_name]) then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, k)
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] SwitchByDreamlandLevelTag: tag_name@"..tag_name.." add suite@"..k)
else
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, k)
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] SwitchByDreamlandLevelTag: tag_name@"..tag_name.." remove suite@"..k)
end
end
end
return 0
end
function LF_GetIndexInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return i
end
end
return 0
end
function LF_Split_Int(context, num)
local tb = {0,0,0,0,0,0,0,0,0}
for i=1, #tb do
tb[i] = num%10
num = math.floor(num/10)
end
return tb
end
LF_Initialize_Dreamland_Group(triggers, suites)

View File

@@ -0,0 +1,229 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: DreamLandSuiteState
|| owner: weiwei.sun
|| description: 2.8Group内容切换类玩法泛用型物件状态保存器。存9个物件9个状态
|| 特判万叶晶石物件这些物件在GroupLoad时若为State 202则切成
|| LogName: ## [DreamLandSuiteState]
|| Protection:
=======================================]]
--[[
defs = {
--本Group用哪组LevelTag控制请查LevelTagData表
levelTagGroupID = 3,
--是否由re-quire控制切suite填0则不需要配置switchByLevelTag_suites
switchByLevelTag = 1,
--切入该LevelTag时加载且仅加载的suite。
--注意被此操作Remove掉的物件不会保留GadgetState
switchByLevelTag_suites = {
["2_8_BuDing_MDLY"] = {2},
["2_8_BuDing_MDDQ"] = {2},
["2_8_BuDing_DQLY"] = {3,2},
},
--需要保存gadgetState的物件configID最多9个
saved_gadget =
{
4004, 4005, 4006
}
--特判万叶晶石物件这些物件在GroupLoad时若为State 202则切成
spec_gadget=
{
}
}
]]
--定义数字对应的gadgetState
local state_define={
[1] = 0,--Default
[2] = 101,--ChestLocked
[3] = 102,--ChestOpened
[4] = 104,--ChestBramble
[5] = 105,--ChestFrozen
[6] = 201,--GearStart
[7] = 202,--GearStop
[8] = 203,--GearAction1
[9] = 204,--GearAction2
}
local state_Triggers = {
{ config_id = 8800001, name = "Group_Load_Dreamland", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load_Dreamland", trigger_count = 0 },
{ config_id = 8800002, name = "LevelTag_Change_Dreamland", event = EventType.EVENT_LEVEL_TAG_CHANGE, source = "", condition = "", action = "action_LevelTag_Change_Dreamland", trigger_count = 0 },
{ config_id = 8800003, name = "Gadget_StateChange_Dreamland", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Gadget_StateChange_Dreamland", trigger_count = 0 },
}
function LF_Initialize_Dreamland_Group(triggers, suites)
for i=1,#state_Triggers do
table.insert(triggers, state_Triggers[i])
table.insert(suites[init_config.suite].triggers,state_Triggers[i].name)
end
table.insert(variables,{ config_id = 58800001, name = "saved_state", value = 1000000000, no_refresh = true })
end
--在GadgetStateChange时如果为saved_gadget中的物件则记录
--evt.param2:configID
--evt.param1:切换后的state
function action_Gadget_StateChange_Dreamland(context, evt)
local index = LF_GetIndexInTable(context, evt.param2, defs.saved_gadget)
--非存档物件
if 0 == index then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] Save gadget state ignored. configID@"..evt.param2.." index@"..index)
return 0
end
--写什么数字
local state_index = LF_GetStateIndexByGadgetState(context, evt.param1)
--写在哪一位
local state_place = math.pow(10, index - 1)
--该位数字现在是几
local saved_int = ScriptLib.GetGroupVariableValue(context, "saved_state")
local saved_table = LF_Split_Int(context, saved_int)
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] LF_GetStateIndexByGadgetState: Get state_place@"..state_place.." state_index@"..state_index)
--写
ScriptLib.ChangeGroupVariableValue(context, "saved_state", (state_index - saved_table[index]) * state_place)
local result = ScriptLib.GetGroupVariableValue(context, "saved_state")
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] Save gadget state. configID@"..evt.param2.." index@"..index.." saved_state@"..result)
return 0
end
function LF_GetStateIndexByGadgetState(context, state_id)
local state_index = 0
for k,v in pairs(state_define) do
if v == state_id then
state_index = k
return state_index
end
end
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] #WARN# LF_GetStateIndexByGadgetState: Get undefined gadget state! state@"..state_id)
return 0
end
function LF_GadgetStateRecover_GroupLoad(context)
--检查gadget数量是否在合法范围内
if 9 < #defs.saved_gadget then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] #WARN# saved_gadget over used!")
return 0
end
local saved_int = ScriptLib.GetGroupVariableValue(context, "saved_state")
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] LF_GadgetStateRecover. saved_int@"..saved_int..". num to save@"..#defs.saved_gadget)
local saved_table = LF_Split_Int(context, saved_int)
for i = 1, #defs.saved_gadget do
if 0 == LF_GetIndexInTable(context, defs.saved_gadget[i], defs.spec_gadget) then
if 0 ~= saved_table[i] then
local ret = ScriptLib.SetGadgetStateByConfigId(context, defs.saved_gadget[i], state_define[saved_table[i]])
if -1 == ret then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] #WARN# LF_GadgetStateRecover: Set gadget state failed! config_id@"..defs.saved_gadget[i].." stateIndex@"..saved_table[i])
end
end
else
if 202 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.saved_gadget[i]) then
ScriptLib.SetGadgetStateByConfigId(context, defs.saved_gadget[i], 0)
end
end
end
return 0
end
function LF_GadgetStateRecover(context)
--检查gadget数量是否在合法范围内
if 9 < #defs.saved_gadget then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] #WARN# saved_gadget over used!")
return 0
end
local saved_int = ScriptLib.GetGroupVariableValue(context, "saved_state")
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] LF_GadgetStateRecover. saved_int@"..saved_int..". num to save@"..#defs.saved_gadget)
local saved_table = LF_Split_Int(context, saved_int)
for i = 1, #defs.saved_gadget do
if 0 ~= saved_table[i] then
local ret = ScriptLib.SetGadgetStateByConfigId(context, defs.saved_gadget[i], state_define[saved_table[i]])
if -1 == ret then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] #WARN# LF_GadgetStateRecover: Set gadget state failed! config_id@"..defs.saved_gadget[i].." stateIndex@"..saved_table[i])
end
end
end
return 0
end
function action_LevelTag_Change_Dreamland(context, evt)
local tag_name = ScriptLib.GetLevelTagNameById(context, evt.param2)
if "" == tag_name then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] LevelTag_Change_Dreamland: Get level tag name failed.")
return 0
end
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] LevelTag_Change_Dreamland: Get level tag name@"..tag_name)
LF_SwitchByDreamlandLevelTag(context, tag_name)
LF_GadgetStateRecover(context)
return 0
end
function action_Group_Load_Dreamland(context ,evt)
local tag_name = LF_GetCurLevelTagName(context)
if "" == tag_name then
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] Group_Load_Dreamland: Get level tag name failed.")
return 0
end
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] Group_Load_Dreamland: Get level tag name@"..tag_name)
LF_SwitchByDreamlandLevelTag(context, tag_name)
LF_GadgetStateRecover_GroupLoad(context)
return 0
end
function LF_GetCurLevelTagName(context)
--2.8海岛中每个levelTagGroup即series中的tag都是互斥关系所以取第一位
local cur_tag = ScriptLib.GetCurrentLevelTagVec(context, defs.levelTagGroupID)[1]
local tag_name = ScriptLib.GetLevelTagNameById(context, cur_tag)
return tag_name
end
--根据LevelTagName切suite。含有Trigger的suite1不动
function LF_SwitchByDreamlandLevelTag(context, tag_name)
if 1 ~= defs.switchByLevelTag then
return 0
end
for k, v in pairs(suites) do
if k ~= 1 then
if 0 ~= LF_GetIndexInTable(context, k, defs.switchByLevelTag_suites[tag_name]) then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, k)
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] SwitchByDreamlandLevelTag: tag_name@"..tag_name.." add suite@"..k)
else
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, k)
ScriptLib.PrintContextLog(context, "## [DreamLandSuiteState] SwitchByDreamlandLevelTag: tag_name@"..tag_name.." remove suite@"..k)
end
end
end
return 0
end
function LF_GetIndexInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return i
end
end
return 0
end
function LF_Split_Int(context, num)
local tb = {0,0,0,0,0,0,0,0,0}
for i=1, #tb do
tb[i] = num%10
num = math.floor(num/10)
end
return tb
end
LF_Initialize_Dreamland_Group(triggers, suites)

View File

@@ -0,0 +1,132 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: DreamOperation
|| owner: weiwei.sun
|| description: 2.8愚人众操作台旋转输密码逻辑
|| LogName: ## [DreamOperation]
|| Protection:
=======================================]]
--[[
local defs = {
--每个操作台config_id, 控制的markfalg和它的解最多5位数字。
--玩家按按钮左转写2 右转写3。
--例如“左左右左”即为“{2,2,3,2}”
answers = {
[操作台config_id1] = { markflag = 1, key = {2,2,3,2},
[操作台config_id2] = { markflag = 2, key = {2,2,3,2},
}
}
]]
local Triggers = {
{ config_id = 8000001, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1, #Triggers do
table.insert(triggers, Triggers[i])
table.insert(suites[init_config.suite].triggers,Triggers[i].name)
end
--组内完成的操作台数量
table.insert(variables,{ config_id = 50000001, name = "unlock_num", value = 0, no_refresh = true })
end
function action_Group_Load(context, evt)
LF_InitGear(context)
return 0
end
--操作台初始化
function LF_InitGear(context)
for k,v in pairs(defs.answers) do
--重设输入位数,
ScriptLib.SetGroupTempValue(context, "g_"..k, 1 , {})
end
return 0
end
--ability Init完成后再赋值
function SLC_DreamOperation_GetFlag(context)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_Control_Target", defs.answers[config_id].markflag)
ScriptLib.PrintContextLog(context, "## [DreamOperation] LF_InitGear. config_id@"..config_id.." markflag@"..defs.answers[config_id].markflag)
return 0
end
--param 左转为2 右转为3
function SLC_DreamOperation_Turn(context, param)
--本组解谜是否完成
local count = LF_CountTableNum(context, defs.answers)
if count <= ScriptLib.GetGroupVariableValue(context, "unlock_num") then
return 0
end
--是否为组内已被完成的操作台
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, config_id)
if 202 == gadget_state then
return 0
end
--检查合法的param
if param == 2 or param == 3 then
LF_HandleInput(context, config_id, param)
end
return 0
end
--比较玩家的输入
--param 左转为2 右转为3
function LF_HandleInput(context, config_id, param)
--获取当前是该操作台的第几次输入
local index = ScriptLib.GetGroupTempValue(context, "g_"..config_id, {})
local key = defs.answers[config_id].key
ScriptLib.PrintContextLog(context, "## [DreamOperation] LF_HandleInput. input_index@"..index.." input@"..param.." answer@"..key[index])
--如果正确则index前进一位
if key[index] == param then
index = index + 1
--否则index回到1
else
index = 1
end
if index > #key then
--本操作台输入完成切GadgetState。客户端关闭交互服务器不再接受它SLC
ScriptLib.SetGadgetStateByConfigId(context, config_id, 202)
ScriptLib.ChangeGroupVariableValue(context, "unlock_num", 1)
local num = ScriptLib.GetGroupVariableValue(context, "unlock_num")
ScriptLib.PrintContextLog(context, "## [DreamOperation] DreamOperation puzzle done. config_id@"..config_id)
else
--继续
ScriptLib.SetGroupTempValue(context, "g_"..config_id, index, {})
end
return 0
end
function LF_CountTableNum(context, t)
local count = 0
for k,v in pairs(t) do
count = count + 1
end
return count
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,70 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V2_8]
--[[
=====================================================================================================================
|| Filename || EchoConch
|| RelVersion || 2.8
|| Owner || xudong.sun
|| Description || 2.8回声海螺,影像海螺
|| LogName || ## EchoConch_LOG
|| Protection || 离开范围后保证reminder被中断
=====================================================================================================================
local conchConfigID = 0
local shadowConfigIDList = {}
=======================================================================================]]
local extrTriggers = {
initialtrigger = {
["Triger_Interact"] = { config_id = 80000001, name = "Triger_Interact", event= EventType.EVENT_ECHO_SHELL_INTERACT, source = "", condition = "", action = "action_trigger_interact", trigger_count = 0},
["Leave_Region"] = { config_id = 80000002, name = "Leave_Region", event= EventType.EVENT_LEAVE_REGION, source = "1", condition = "", action = "action_player_leave_region", trigger_count = 0},
}
}
function action_trigger_interact( context, evt )
--获取reminderID
--local reminderID = gadgets[conchConfigID].arguments[1]
local reminderID = evt.param3
ScriptLib.SetGroupTempValue(context, "reminderID", reminderID,{})
ScriptLib.PrintContextLog(context, "## EchoConch_LOG : remindferID is"..reminderID)
--创建虚影
for i,v in ipairs(shadowConfigIDList) do
ScriptLib.CreateGadget(context, { config_id = v })
end
--玩家按下按键播放reminder
ScriptLib.ShowReminderByUid(context, {context.owner_uid},reminderID)
return 0
end
function action_player_leave_region( context, evt )
--获取reminderID
--local reminderID = gadgets[conchConfigID].arguments[1]
local reminderID = ScriptLib.GetGroupTempValue(context, "reminderID",{})
ScriptLib.PrintContextLog(context, "## EchoConch_LOG : remindferID is"..reminderID)
--玩家离开区域后停止对应的reminder
if reminderID ~= 0 then
ScriptLib.StopReminder(context, reminderID)
end
return 0
end
function LF_Initialize_Group()
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Group()

View File

@@ -0,0 +1,195 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: EchoConch_Puzzle
|| owner: xudong.sun
|| description: 物件交付接口返回值是列表。提供一个将列表第一位ID设为GroupVariable的功能供关卡编辑器使用
|| LogName: ## EchoPuzzle_LOG
|| Protection:
=======================================]]
--[[
local GivingID = {0,0,0}
local MaterialID = {0,0,0}
local ConchConfigID = {}
local CreateList = {
{[material_A]={{虚影_A,point_1},{configid,point}}, [materialID]={{configid,point},{configid,point}}, [materialID]={{configid,point},{configid,point}}},
{[material_A]={{虚影_A,point_2},{configid,point}}, [materialID]={{configid,point},{configid,point}}, [materialID]={{configid,point},{configid,point}}},
{[material_A]={{虚影_A,point_3},{configid,point}}, [materialID]={{configid,point},{configid,point}}, [materialID]={{configid,point},{configid,point}}},
}
local NoticeReminder= {
[12]= 0,
[13]= 0,
}
]]
--[[
未交付不可交互 - 没特定State
未交付(可交互) - 0
交付不可取回(不可交互) - 101
交付可取回 - 102
]]
local giving_Triggers = {
{ config_id = 8800001, name = "Gadget_Giving_Finished", event = EventType.EVENT_GADGET_GIVING_FINISHED, source = "", condition = "", action = "action_Gadget_Giving_Finished", trigger_count = 0 },
{ config_id = 8800002, name = "Gadget_Giving_TakeBack", event = EventType.EVENT_GADGET_GIVING_TAKEBACK, source = "", condition = "", action = "action_Gadget_Giving_TakeBack", trigger_count = 0 },
{ config_id = 8800003, name = "Group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
}
function LF_Initialize_GadgetGiving(triggers, suites)
for i=1,#giving_Triggers do
table.insert(triggers, giving_Triggers[i])
table.insert(suites[init_config.suite].triggers,giving_Triggers[i].name)
end
table.insert(variables,{ config_id=50000001, name = "conch_puzzle_success", value = 0})
end
--监听Gadget交付完成事件
--evt.param1: 交付Gadget的config_id
--evt.param2: 使用的giving_id
function action_Group_Load( context, evt)
--打开交付开关 初始化当前givingID的信息
for i,v in ipairs(ConchConfigID) do
local tempList = ScriptLib.GetGivingItemList(context, GivingID[i])
if ScriptLib.GetGroupVariableValue(context, "conch_puzzle_success")==1 then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, ConchConfigID[i], 101)
elseif next(tempList) == nil then
ScriptLib.PrintContextLog(context, "## EchoPuzzle_LOG : empty configID is"..ConchConfigID[i])
ScriptLib.ActiveGadgetItemGiving(context, GivingID[i], base_info.group_id, ConchConfigID[i])
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, ConchConfigID[i], 0)
ScriptLib.SetGroupTempValue(context, "Conch_Slot"..i, 0, {})
else
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, ConchConfigID[i], 102)
ScriptLib.SetGroupTempValue(context, "Conch_Slot"..i, tempList[1], {})
end
end
if ScriptLib.GetGroupVariableValue(context, "conch_puzzle_success")==1 then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
end
return 0
end
function action_Gadget_Giving_Finished(context, evt)
--evt.param1物件的configID evt.param2物件的GivingID
local slotNum = 0
--获取当前Slot的ID
for i=1,3 do
if GivingID[i]== evt.param2 then
slotNum = i
end
end
if slotNum == 0 then
ScriptLib.PrintGroupWarning(context,"## EchoConch_Puzzle action_Gadget_Giving_Finished: 没有找到当前所在的海螺Slot ID")
return 0
end
ScriptLib.PrintContextLog(context, "## EchoPuzzle_LOG : slotNum = "..slotNum)
--设置slot为取回模式
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 102)
--创建虚影
--获取当前交付的materialID
local _materialID = ScriptLib.GetGivingItemList(context, evt.param2)[1]
ScriptLib.PrintContextLog(context, "## EchoPuzzle_LOG : _materialID = ".._materialID)
--根据materialID创建对应的虚影
for i,v in ipairs(CreateList[slotNum][_materialID]) do
ScriptLib.PrintContextLog(context, "## EchoPuzzle_LOG : configid = "..v.configid)
ScriptLib.PrintContextLog(context, "## EchoPuzzle_LOG : point = "..v.point)
ScriptLib.CreateGadgetByConfigIdByPos(context, v.configid, points[v.point].pos, points[v.point].rot)
end
--记录当前slot装载的materialid
ScriptLib.SetGroupTempValue(context, "Conch_Slot"..slotNum, _materialID, {})
--2022/4/20新增提示reminder
--获取当前提交的materialindex
local materialIndex = 0
for i,v in ipairs(MaterialID) do
if v == _materialID then
materialIndex = i
end
end
if materialIndex == 0 then
ScriptLib.PrintGroupWarning(context,"## EchoConch_Puzzle action_Gadget_Giving_Finished: 没有获取到当前materialIndex")
elseif slotNum ~= materialIndex then
--slotNum和materialIndex不对应需要弹出错误提示
local reminderIndex = slotNum*10 + materialIndex
if NoticeReminder[reminderIndex]~= nil then
ScriptLib.ShowReminderByUid(context, {context.owner_uid},NoticeReminder[reminderIndex])
end
end
--检测解谜是否成功
for i=1,3 do
if ScriptLib.GetGroupTempValue(context, "Conch_Slot"..i, {}) ~= MaterialID[i] then
return 0
end
end
--解谜成功执行以下操作
--切换海螺状态到不可交互
for i,v in ipairs(ConchConfigID) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 101)
end
--发送成功通知
ScriptLib.SetGroupVariableValue(context, "conch_puzzle_success", 1)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
return 0
end
function action_Gadget_Giving_TakeBack(context, evt)
local slotNum = 0
--获取当前Slot的ID
for i=1,3 do
if GivingID[i]== evt.param2 then
slotNum = i
end
end
ScriptLib.PrintContextLog(context, "## EchoPuzzle_LOG : Get slotNum = "..slotNum)
--获取当前slotID对应的虚影materialID
local _materialID = ScriptLib.GetGroupTempValue(context, "Conch_Slot"..slotNum, {})
ScriptLib.PrintContextLog(context, "## EchoPuzzle_LOG : Get _materialID = ".._materialID)
--删除虚影
for i,v in ipairs(CreateList[slotNum][_materialID]) do
ScriptLib.KillEntityByConfigId(context, { group_id = base_info.group_id, config_id = v.configid, entity_type=EntityType.GADGET })
end
ScriptLib.SetGroupTempValue(context, "Conch_Slot"..slotNum, 0, {})
ScriptLib.ActiveGadgetItemGiving(context, evt.param2, base_info.group_id, evt.param1)
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 0)
return 0
end
LF_Initialize_GadgetGiving(triggers, suites)

View File

@@ -0,0 +1,58 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V2_8]
--[[
=====================================================================================================================
|| Filename || EchoConch_Quest
|| RelVersion || 2.8
|| Owner || xudong.sun
|| Description || 2.8回声海螺任务版不播放reminder只推进任务
|| LogName || ## EchoConch_LOG
|| Protection ||
=====================================================================================================================
local questID = 0
local shadowConfigIDList = {}
local remainMode = 1
=======================================================================================]]
local extrTriggers = {
initialtrigger = {
["Triger_Interact"] = { config_id = 80000001, name = "Triger_Interact", event= EventType.EVENT_ECHO_SHELL_INTERACT, source = "", condition = "", action = "action_trigger_interact", trigger_count = 0},
}
}
function action_trigger_interact( context, evt )
--推进任务进度
ScriptLib.AddQuestProgress(context, ""..questID)
--创建虚影
if shadowConfigIDList ~= nil then
for i,v in ipairs(shadowConfigIDList) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
if remainMode == nil or remainMode == 0 then
--删除回声海螺
ScriptLib.KillEntityByConfigId(context, {config_id = evt.param1})
elseif remainMode == 1 then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 202)
end
return 0
end
function LF_Initialize_Group()
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Group()

View File

@@ -0,0 +1,473 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: FireMachineColorHandle
|| owner: weiwei.sun
|| description: 万叶岛 变色传音炮逻辑
|| LogName: ## [FireMachine]
|| Protection:
=======================================]]
--[[
每个Group最多允许3个发射器
color_stateInt: 后3位用于存档每个发射器能切几种颜色、哪几种
local defs = {
--本Group中发射器gadget的configID最多3个,
fireMachineList = {
},
--key为发射器configIDvalue为ColorDefine
initConfig = {
[发射器configID1] = color_defined的key,
},
--Key为操作台。value为发射器。允许有多个操作台控制同一个发射器
controlRelation = {
[发射器configID1] = 操作台configID1,
},
--左右旋转的SelectOptionID
selectID_horizon = ,
--上下俯仰的SelectOptionID
selectID_vertical = ,
--定义左右旋转的步长,key为传递装置configIDvalue为GadgetState
horizon_steps = {
[装置configID1] = {0, 102, 103, 104},
},
--定义上下俯仰的步长,key为传递装置configIDvalue为GadgetState
vertical_steps = {
[装置configID1] = {0, 302, 303, 304, 305},
},
--反射装置初始state
init_state = {
[装置configID1] = 302,
}
}
]]
local color_define = {
--index刚好唯一对应GadgetState末位之和
--当可切state列表变化时通过这个性质来知道自己的新index
[1] = {201},
[2] = {202},
[3] = {201, 202},
[4] = {204},
[5] = {201, 204},
[6] = {202, 204},
[7] = {201, 202, 204}
}
local cfg = {
switch_option = 601,--切换颜色optionID
crystal_201 = {70310163,70310364},--A色晶石GadgetID
crystal_202 = {70310164,70310365},--B色晶石GadgetID
crystal_204 = {70310165,70310366},--C色晶石GadgetID
}
local extraTriggers = {
{ config_id = 8000001, name = "Shooter_Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Shooter_Select_Option", trigger_count = 0 },
{ config_id = 8000002, name = "FireMachine_Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_FireMachine_Group_Load", trigger_count = 0 },
{ config_id = 8000003, name = "Transfer_Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Transfer_Select_Option", trigger_count = 0 },
{ config_id = 8000004, name = "FireMachine_LevelTag_Change", event = EventType.EVENT_LEVEL_TAG_CHANGE, source = "", condition = "", action = "action_FireMachine_LevelTag_Change", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
-- 后3位用于存档每个发射器能切几种颜色、哪几种
table.insert(variables, { config_id = 50000001, name = "color_stateInt", value = 1000, no_refresh = true})
-- 是否执行过LF_InitColorStateInt
table.insert(variables, { config_id = 50000002, name = "has_inited", value = 0, no_refresh = true})
end
function action_FireMachine_Group_Load(context, evt)
if 0 == ScriptLib.GetGroupVariableValue(context, "has_inited") then
--根据LD配置的初始GadgetState初始化int存档
LF_InitColorStateInt(context)
--如果有可切的颜色设置optionID
LF_SetSwitchColorOption(context)
ScriptLib.SetGroupVariableValue(context , "has_inited", 1)
else
--根据Int存档设置客户端SGV
LF_InitSGV(context)
end
--初始化反射机关旋转角度
LF_InitRotation(context)
return 0
end
function action_FireMachine_LevelTag_Change(context, evt)
--重置反射机关旋转角度
LF_InitRotation(context)
return 0
end
--设置客户端SGV
function LF_InitSGV(context)
for k,v in pairs(defs.fireMachineList) do
local color_define = LF_GetColorDefineIndex(context, k)
--”x晶石是否可装填“
--246可装填晶石A201
if 2 == color_define or 4 == color_define or 6 == color_define then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_FireMachineColorReceive_A", 1)
end
--145可装填晶石B202)
if 1 == color_define or 4 == color_define or 5 == color_define then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_FireMachineColorReceive_B", 1)
end
--123可装填晶石C204)
if 1 == color_define or 2 == color_define or 3 == color_define then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_FireMachineColorReceive_C", 1)
end
--”总共有x色可切
if 1 == color_define or 2 == color_define or 4 == color_define then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_FireMachineColor_Num", 1)
elseif 3 == color_define or 5== color_define or 6 == color_define then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_FireMachineColor_Num", 2)
elseif 7 == color_define then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_FireMachineColor_Num", 3)
end
end
return 0
end
function LF_InitRotation(context)
if nil == defs.init_state then
return 0
end
for k,v in pairs(defs.init_state) do
ScriptLib.SetGadgetStateByConfigId(context, k, v)
end
return 0
end
--物件请求给自己增加一种可切颜色(GadgetState)
--param1: 颜色代号。 A色-201 B色-202 C色-204
function SLC_AddFireMachineColor(context, param1)
--检查是否为合法param
if 0 == LF_GetIndexInTable(context, param1, {201, 202, 204}) then
ScriptLib.PrintContextLog(context, "## [FireMachine] SLC get wrong param, check ability. param1: "..param1)
return 0
end
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
--检查SLC来源是否为Group内登记在册的发射器
local gadget_index = LF_GetIndexInTable(context, config_id, defs.fireMachineList)
if 0 == gadget_index then
return 0
end
--获取自己当前可切state列表
local color_define_index = LF_GetColorDefineIndex(context, gadget_index)
--如果param1没在table中则增加param1,并以此找到对应的新color_define_index
local index_temp = 0
if 0 ~= color_define_index then
for i, v in ipairs(color_define[color_define_index]) do
--将可切的state加和
index_temp = index_temp + v
--如果param1已存在直接return
if v == param1 then
ScriptLib.SetGadgetStateByConfigId(context, config_id, param1)
ScriptLib.PrintContextLog(context, "## [FireMachine] Trying to add an existed color, only switch state: "..param1)
return 0
end
end
end
--state加和再加上param1
index_temp = index_temp + param1
--取个位数得到ColorDefineIndex
local index_new = index_temp%10
LF_SetColorDefineIndex(context, gadget_index, index_new)
--如果本次加颜色使其有2种及以上可切则增加操作台选项
if 0 ~= color_define_index then
if 2 > #color_define[color_define_index] and 2 <= #color_define[index_new] then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, config_id, {cfg.switch_option})
end
end
--切到新添加的GadgetState
ScriptLib.SetGadgetStateByConfigId(context, config_id, param1)
--kill掉本Group中对应颜色的晶石。
--一个Group中同一颜色的晶石只会有一个如果LD配多了则删除configID靠前的那一个
--注意如果GroupA的晶石来GroupB交则删除的是GroupB的晶石。
local gadget_id = {}
if 201 == param1 then
gadget_id = cfg.crystal_201
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_FireMachineColorReceive_A", 0)
elseif 202 == param1 then
gadget_id = cfg.crystal_202
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_FireMachineColorReceive_B", 0)
elseif 204 == param1 then
gadget_id = cfg.crystal_204
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_FireMachineColorReceive_C", 0)
end
for k,v in pairs(gadgets) do
if v.gadget_id == gadget_id[1] or v.gadget_id == gadget_id[2] then
ScriptLib.KillEntityByConfigId(context, { config_id = v.config_id })
end
end
return 0
end
--根据LD配置的初始GadgetState初始化int存档
function LF_InitColorStateInt(context)
ScriptLib.PrintContextLog(context, "## [FireMachine] LF_InitColorStateInt.")
for k, v in pairs(defs.initConfig) do
if 0 ~= v then
local gadget_index = LF_GetIndexInTable(context, k, defs.fireMachineList)
LF_InitColorDefineIndex(context, gadget_index, v)
ScriptLib.SetGadgetStateByConfigId(context, defs.fireMachineList[gadget_index], color_define[v][1])
end
--设置SGV客户端Ability用
--246可装填晶石A201
if 2 == v or 4 == v or 6 == v then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, k, "SGV_FireMachineColorReceive_A", 1)
end
--145可装填晶石B202)
if 1 == v or 4 == v or 5 == v then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, k, "SGV_FireMachineColorReceive_B", 1)
end
--123可装填晶石C204)
if 1 == v or 2 == v or 3 == v then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, k, "SGV_FireMachineColorReceive_C", 1)
end
end
return 0
end
function LF_SetSwitchColorOption(context)
for i = 1, #defs.fireMachineList do
--获取自己当前可切state列表
local color_define_index = LF_GetColorDefineIndex(context, i)
if 0 ~= color_define_index then
if 1 < #color_define[color_define_index] then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, defs.fireMachineList[i], {cfg.switch_option})
end
end
end
return 0
end
--玩家操作发射器
function action_Shooter_Select_Option(context, evt)
for k,v in pairs(defs.controlRelation) do
if k == evt.param1 then
LF_SwitchColor(context, v)
return 0
end
end
return 0
end
--玩家操作发射器SLC
function SLC_FireMachine_Switch(context)
local cfg_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
LF_SwitchColor(context, cfg_id)
return 0
end
--发射器Ability就绪后请求SGV
function SLC_FireMachine_AbilityReady(context)
LF_InitSGV(context)
return 0
end
--玩家操作传递装置
function action_Transfer_Select_Option(context, evt)
if evt.param2 == defs.selectID_horizon then
LF_TurnByStep(context, evt.param1, defs.horizon_steps)
return 0
elseif evt.param2 == defs.selectID_vertical then
LF_TurnByStep(context, evt.param1, defs.vertical_steps)
return 0
end
return 0
end
--传递机关根据配置的步长切state
function LF_TurnByStep(context, config_id, step_table)
for k,v in pairs(step_table) do
if k == config_id then
local current_state = ScriptLib.GetGadgetStateByConfigId(context, 0, config_id)
local current_index = LF_GetIndexInTable(context, current_state, v)
if 0 == current_index then
--传递装置的state并不在配置table中告警
ScriptLib.PrintContextLog(context, "## [FireMachine] #WARN# FireMachine Transfer at unexpected state! Check defs. config_id@"..config_id.." current_state@"..current_state)
else
--切到下一个State
if current_index >= #v then
ScriptLib.SetGadgetStateByConfigId(context, config_id, v[1])
else
ScriptLib.SetGadgetStateByConfigId(context, config_id, v[current_index + 1])
end
end
return 0
end
--传进来的configID不是配置的传递装置告警
ScriptLib.PrintContextLog(context, "## [FireMachine] #WARN# LF_TurnByStep find config_id failed, check defs. config_id@"..config_id)
end
return 0
end
--切到下一个颜色
function LF_SwitchColor(context, config_id)
--查这个configID对应哪一位数字是几
local gadget_index = LF_GetIndexInTable(context, config_id, defs.fireMachineList)
if gadget_index ~= 0 then
--它当前的可用GadgetState列表
local color_define_index = LF_GetColorDefineIndex(context, gadget_index)
if 0 == color_define_index then
return 0
end
local availible_list = color_define[color_define_index]
--取其当前state再取得此state在它可用GadgetState列表中的index
local current_state = ScriptLib.GetGadgetStateByConfigId(context, 0, config_id)
local state_index = LF_GetIndexInTable(context, current_state, availible_list)
--然后切到下一个State
if state_index >= #availible_list then
ScriptLib.SetGadgetStateByConfigId(context, config_id, availible_list[1])
else
ScriptLib.SetGadgetStateByConfigId(context, config_id, availible_list[state_index + 1])
end
else
ScriptLib.PrintContextLog(context, "## [FireMachine] #WARN# Get fireMachine index by configID failed, check defs.")
end
return 0
end
--Init
function LF_InitColorDefineIndex(context, gadget_index, new_colorDefine_index)
--将gadget_index对应的位数设为指定值
local temp_stateInt = ScriptLib.GetGroupVariableValue(context, "color_stateInt")
ScriptLib.PrintContextLog(context, "## [FireMachine] LF_InitColorDefineIndex Start. gadget_index@"..gadget_index.." new_colorDefine_index@"..new_colorDefine_index.." color_stateInt@"..temp_stateInt)
temp_stateInt = temp_stateInt + (new_colorDefine_index * math.pow(10, gadget_index - 1))
if 1999 < temp_stateInt or 0 >= temp_stateInt then
ScriptLib.PrintContextLog(context, "## [FireMachine] LF_InitColorDefineIndex fail. temp_stateInt@"..temp_stateInt)
return 0
end
ScriptLib.SetGroupVariableValue(context, "color_stateInt", temp_stateInt)
ScriptLib.PrintContextLog(context, "## [FireMachine] LF_InitColorDefineIndex Finished. color_stateInt@"..temp_stateInt)
return 0
end
--Set
function LF_SetColorDefineIndex(context, gadget_index, new_colorDefine_index)
--不大于7的整数
if new_colorDefine_index < 0 or new_colorDefine_index > 7 then
ScriptLib.PrintContextLog(context, "## [FireMachine] SetColorDefineIndex fail. new_colorDefine_index@"..new_colorDefine_index)
return 0
end
--将gadget_index对应的位数设为指定值
local temp_stateInt = ScriptLib.GetGroupVariableValue(context, "color_stateInt")
ScriptLib.PrintContextLog(context, "## [FireMachine] SetColorDefineIndex Start. gadget_index@"..gadget_index.." new_colorDefine_index@"..new_colorDefine_index.." color_stateInt@"..temp_stateInt)
local old_colorDefine_index = LF_GetColorDefineIndex(context, gadget_index)
if old_colorDefine_index < 0 or old_colorDefine_index > 7 then
ScriptLib.PrintContextLog(context, "## [FireMachine] SetColorDefineIndex fail. old_colorDefine_index@"..old_colorDefine_index)
return 0
end
temp_stateInt = temp_stateInt + (new_colorDefine_index - old_colorDefine_index) * math.pow(10, gadget_index - 1)
if 1999 < temp_stateInt or 0 >= temp_stateInt then
ScriptLib.PrintContextLog(context, "## [FireMachine] LF_SetColorDefineIndex fail. temp_stateInt@"..temp_stateInt)
return 0
end
ScriptLib.SetGroupVariableValue(context, "color_stateInt", temp_stateInt)
--设置物件SGV这个SGv被客户端Ability使用
if 1 == new_colorDefine_index or 2 == new_colorDefine_index or 4 == new_colorDefine_index then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.fireMachineList[gadget_index], "SGV_FireMachineColor_Num", 1)
elseif 3 == new_colorDefine_index or 5== new_colorDefine_index or 6 == new_colorDefine_index then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.fireMachineList[gadget_index], "SGV_FireMachineColor_Num", 2)
elseif 7 == new_colorDefine_index then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.fireMachineList[gadget_index], "SGV_FireMachineColor_Num", 3)
end
ScriptLib.PrintContextLog(context, "## [FireMachine] SetColorDefineIndex Finished. color_stateInt@"..temp_stateInt)
return 0
end
--Get
function LF_GetColorDefineIndex(context, gadget_index)
local color_define_index = 0
local color_stateInt = ScriptLib.GetGroupVariableValue(context, "color_stateInt")
local color_stateList = LF_Split_Int(context, color_stateInt)
color_define_index = color_stateList[gadget_index]
--检查color_define_index合法性
if nil == color_define[color_define_index] and 0 ~= color_define_index then
--如不是合法范围内,则返回原始配置
ScriptLib.PrintContextLog(context, "## [FireMachine] #WARN# Get illegal color_define_index @"..color_define_index)
color_define_index = defs.initConfig[defs.fireMachineList[gadget_index]]
end
ScriptLib.PrintContextLog(context, "## [FireMachine] GetColorDefineIndex. gadget_index@"..gadget_index.." color_define_index@"..color_define_index)
return color_define_index
end
--将整数各位切分为table
function LF_Split_Int(context, num)
local tb = {0,0,0}
if 0 >= num then
ScriptLib.PrintContextLog(context, "## [FireMachine] #WARN# LF_Split_Int Get illegal num @"..num)
return tb
end
for i=1, #tb do
tb[i] = num%10
num = math.floor(num/10)
end
return tb
end
--用value查key
function LF_GetIndexInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return i
end
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,113 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: HandleGivingResult
|| owner: weiwei.sun
|| description: 物件交付接口返回值是列表。提供一个将列表第一位ID设为GroupVariable的功能供关卡编辑器使用
|| LogName: ## [HandleGivingResult]
|| Protection:
=======================================]]
--[[
未交付不可交互 - 没特定State
未交付(可交互) - 0
交付不可取回(不可交互) - 101
交付可取回 - 102
]]
local cfg = {
can_return = 1,--是否可取回
}
local giving_Triggers = {
{ config_id = 8800001, name = "Gadget_Giving_Finished", event = EventType.EVENT_GADGET_GIVING_FINISHED, source = "", condition = "", action = "action_Gadget_Giving_Finished", trigger_count = 0 },
{ config_id = 8800002, name = "Gadget_Giving_TakeBack", event = EventType.EVENT_GADGET_GIVING_TAKEBACK, source = "", condition = "", action = "action_Gadget_Giving_TakeBack", trigger_count = 0 },
}
function LF_Initialize_GadgetGiving(triggers, suites)
for i=1,#giving_Triggers do
table.insert(triggers, giving_Triggers[i])
table.insert(suites[init_config.suite].triggers,giving_Triggers[i].name)
end
table.insert(variables,{ config_id = 50000001, name = "given_item", value = 0})
end
--监听Gadget交付完成事件
--evt.param1: 交付Gadget的config_id
--evt.param2: 使用的giving_id
function action_Gadget_Giving_Finished(context, evt)
ScriptLib.PrintContextLog(context, "## [HandleGivingResult] Gadget_Giving_Finished. gadget@"..evt.param1.." giving_id@"..evt.param2)
if cfg.can_return == 1 then
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 102)
else
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 101)
end
local item_list = ScriptLib.GetGivingItemList(context, evt.param2)
if nil ~= item_list and 0 ~= #item_list then
ScriptLib.SetGroupVariableValue(context, "given_item", item_list[1])
else
ScriptLib.PrintContextLog(context, "## [HandleGivingResult] Get item_list by givingID failed!")
end
--星空投影灯逻辑
if nil ~= defs.control then
LF_HandleStarProjector(context, 1)
end
--埋点
ScriptLib.MarkGroupLuaAction(context, "StarProjectorGiving", "", {["group_id"] = base_info.group_id, ["config_id"] = evt.param1, ["mat_id"] = item_list[1], ["op_type"] = 1})
return 0
end
function action_Gadget_Giving_TakeBack(context, evt)
ScriptLib.PrintContextLog(context, "## [HandleGivingResult] Gadget_Giving_TakeBack. gadget@"..evt.param1.." giving_id@"..evt.param2)
ScriptLib.SetGroupVariableValue(context, "given_item", 0)
ScriptLib.ActiveGadgetItemGiving(context, evt.param2, base_info.group_id, evt.param1)
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 0)
--星空投影灯逻辑
if nil ~= defs.control then
LF_HandleStarProjector(context, 0)
end
--埋点
ScriptLib.MarkGroupLuaAction(context, "StarProjectorGiving", "", {["group_id"] = base_info.group_id, ["config_id"] = evt.param1, ["mat_id"] = 0, ["op_type"] = 2})
return 0
end
--当星空投影仪ability准备好时SLC请求设置亮点
function SLC_HandleGivingResult_Init(context)
--星空投影灯逻辑
if nil ~= defs.control then
if 102 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.control.giving_gadget) then
LF_HandleStarProjector(context, 1)
ScriptLib.PrintContextLog(context, "## [HandleGivingResult] SLC_HandleGivingResult_Init. giving_gadget@"..defs.control.giving_gadget.." is_on: 1")
else
LF_HandleStarProjector(context, 0)
ScriptLib.PrintContextLog(context, "## [HandleGivingResult] SLC_HandleGivingResult_Init. giving_gadget@"..defs.control.giving_gadget.." is_on: 0")
end
end
return 0
end
function LF_HandleStarProjector(context, is_on)
local match = defs.control
ScriptLib.ExecuteGroupLua(context, match.group_id, "EX_SetStarProjectorSGV", { match.config_id, match.light_index, is_on})
return 0
end
--[[
--贴在投影以所在Group
function EX_SetStarProjectorSGV(context, prev_context, config_id, light_index, is_on)
ScriptLib.PrintContextLog(context, "## [StarProjector] EX_SetStarProjectorSGV called. light_index@"..light_index.. " is_on@".. is_on)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_StarProjector_LightOn_"..light_index, is_on)
return 0
end
]]
LF_Initialize_GadgetGiving(triggers, suites)

View File

@@ -0,0 +1,211 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: KazuhaServeItem
|| owner: weiwei.sun
|| description: 1.拾取了多个供奉物在身上去交付时需要判断先拾取的哪一个然后删除对应gadgetre-quire统一处理.
2.GadgetState需求切Suite即Gadget的Remove和Add希望供奉物保留切之前的State0或201
重进地城即GroupLoad希望供奉物为201
3.供奉物还有一个锁态GadgetState 101希望能根据一个”是否解锁“的变量恢复
|| LogName: ## [KazuhaServeItem]
|| Protection:
=======================================]]
local ServeItem_Triggers = {
{ config_id = 8300001, name = "ServeItem_Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_ServeItem_Group_Load", trigger_count = 0 },
{ config_id = 8300002, name = "Device_Gadget_State_Change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Device_Gadget_State_Change", trigger_count = 0 },
{ config_id = 8300003, name = "Item_Gadget_Create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_Item_Gadget_Create", trigger_count = 0 },
{ config_id = 8300004, name = "Item_Gadget_State_Change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Item_Gadget_State_Change", trigger_count = 0 },
-- { config_id = 8300005, name = "Group_Will_Unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_Group_Will_UnLoad", trigger_count = 0 },
}
function LF_Initialize_ServeItem(triggers, suites)
for i=1,#ServeItem_Triggers do
table.insert(triggers, ServeItem_Triggers[i])
table.insert(suites[init_config.suite].triggers,ServeItem_Triggers[i].name)
end
--为了实现且Suite时GadgetState保留必须以变量暂存一下GadgetState
table.insert(variables,{ config_id = 53000004, name = "state_1", value = 201, no_refresh = true})
table.insert(variables,{ config_id = 53000005, name = "state_2", value = 201, no_refresh = true})
table.insert(variables,{ config_id = 53000006, name = "state_3", value = 201, no_refresh = true})
end
function action_ServeItem_Group_Load(context,evt)
--重置拾取计数
ScriptLib.SetGroupTempValue(context, "pick_num", 1, {})
ScriptLib.SetGroupTempValue(context, "picked_1", 0, {})
ScriptLib.SetGroupTempValue(context, "picked_2", 0, {})
ScriptLib.SetGroupTempValue(context, "picked_3", 0, {})
--GroupLoad时Gadget不是101就应该是201没有0
for k, v in pairs(defs.serve_items) do
-- isLock_x 变量优先
if 1 == ScriptLib.GetGroupVariableValue(context, "isLock_"..k) then
ScriptLib.SetGroupVariableValue(context, "state_"..k, 101)
ScriptLib.SetGadgetStateByConfigId(context, v, 101)
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem]: Handle gadget state on Group Load. configID@".. v.. " state@101")
else
ScriptLib.SetGroupVariableValue(context, "state_"..k, 201)
ScriptLib.SetGadgetStateByConfigId(context, v, 201)
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem]: Handle gadget state on Group Load. configID@".. v.. " state@201")
end
end
ScriptLib.SetGroupTempValue(context, "group_loaded", 1, {})
return 0
end
--处理切Suite时当供奉物创建根据自己对应的Variable恢复GadgetState
function action_Item_Gadget_Create(context, evt)
--判断是供奉物
if 70290374 ~= evt.param2 and 70310363 ~= evt.param2 then
return 0
end
--判断这次Create是属于切Suite导致的
if 1 == ScriptLib.GetGroupTempValue(context, "group_loaded", {}) then
LF_ResetServeItem(context, evt.param1)
end
return 0
end
--记录供奉物状态切换
function action_Item_Gadget_State_Change(context, evt)
local index = LF_ServeItem_GetIndexInTable(context, evt.param2, defs.serve_items)
if 0 == index then
return 0
end
ScriptLib.SetGroupVariableValue(context, "state_"..index, evt.param1)
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem]: Update gadget state record. configID@".. evt.param2.. " state@".. evt.param1)
return 0
end
function LF_ResetServeItem(context, config_id)
local index = LF_ServeItem_GetIndexInTable(context, config_id, defs.serve_items)
if 0 == index then
return 0
end
-- isLock_x 变量优先
if 1 == ScriptLib.GetGroupVariableValue(context, "isLock_"..index) then
ScriptLib.SetGroupVariableValue(context, "state_"..index, 101)
ScriptLib.SetGadgetStateByConfigId(context, config_id, 101)
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem]: Handle gadget state on create. configID@".. config_id.. " state@101")
--无 isLock_ 配置或0 以state_x变量设GadgetSate
else
local state = ScriptLib.GetGroupVariableValue(context, "state_"..index)
ScriptLib.SetGadgetStateByConfigId(context, config_id, state)
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem]: Handle gadget state on create. configID@".. config_id.. " state@".. state)
end
return 0
end
function SLC_ServeItem_Picked(context)
--判断是供奉物
local gadget_id = ScriptLib.GetGadgetIdByEntityId(context, context.source_entity_id)
if 70290374 ~= gadget_id and 70310363 ~= gadget_id then
return 0
end
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
--根据是第几次拾取记录供奉物configID
local num = ScriptLib.GetGroupTempValue(context, "pick_num", {})
if 1 == num then
ScriptLib.SetGroupTempValue(context, "picked_1", config_id, {})
ScriptLib.SetGadgetStateByConfigId(context, config_id, 0)
ScriptLib.ChangeGroupTempValue(context, "pick_num", 1, {})
elseif 2 == num then
ScriptLib.SetGroupTempValue(context, "picked_2", config_id, {})
ScriptLib.SetGadgetStateByConfigId(context, config_id, 0)
ScriptLib.ChangeGroupTempValue(context, "pick_num", 1, {})
elseif 3 == num then
ScriptLib.SetGroupTempValue(context, "picked_3", config_id, {})
ScriptLib.SetGadgetStateByConfigId(context, config_id, 0)
ScriptLib.ChangeGroupTempValue(context, "pick_num", 1, {})
else
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem] Picking item while all item picked!")
end
return 0
end
function action_Device_Gadget_State_Change(context, evt)
--特殊Group走EX_Device_Gadget_State_Change
if 220142013 == base_info.group_id or 220142012 == base_info.group_id then
return 0
end
--判断切201
if 201 ~= evt.param1 then
return 0
end
--判断是供奉台
local gadget_id = ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid)
if 70290373 ~= gadget_id and 70290375 ~= gadget_id then
return 0
end
--移除最早拾取的供奉物
local picked_1 = ScriptLib.GetGroupTempValue(context, "picked_1", {})
local picked_2 = ScriptLib.GetGroupTempValue(context, "picked_2", {})
local picked_3 = ScriptLib.GetGroupTempValue(context, "picked_3", {})
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem] Device_Gadget_State_Change. picked_1@"..picked_1 .." picked_2@"..picked_2.." picked_3@"..picked_3)
if 0 < picked_1 then
ScriptLib.KillEntityByConfigId(context, { config_id = picked_1 })
ScriptLib.SetGroupTempValue(context, "picked_1", 0, {})
elseif 0 < picked_2 then
ScriptLib.KillEntityByConfigId(context, { config_id = picked_2 })
ScriptLib.SetGroupTempValue(context, "picked_2", 0, {})
elseif 0 < picked_3 then
ScriptLib.KillEntityByConfigId(context, { config_id = picked_3 })
ScriptLib.SetGroupTempValue(context, "picked_3", 0, {})
else
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem] Serving item while no item picked!")
end
return 0
end
function EX_Device_Gadget_State_Change(context, prev_context, param1)
--判断切201
if 201 ~= param1 then
return 0
end
--判断是供奉台
--[[local gadget_id = ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid)
if 70290373 ~= gadget_id and 70290375 ~= gadget_id then
return 0
end]]
--移除最早拾取的供奉物
local picked_1 = ScriptLib.GetGroupTempValue(context, "picked_1", {})
local picked_2 = ScriptLib.GetGroupTempValue(context, "picked_2", {})
local picked_3 = ScriptLib.GetGroupTempValue(context, "picked_3", {})
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem] Device_Gadget_State_Change. picked_1@"..picked_1 .." picked_2@"..picked_2.." picked_3@"..picked_3)
if 0 < picked_1 then
ScriptLib.KillEntityByConfigId(context, { config_id = picked_1 })
ScriptLib.SetGroupTempValue(context, "picked_1", 0, {})
elseif 0 < picked_2 then
ScriptLib.KillEntityByConfigId(context, { config_id = picked_2 })
ScriptLib.SetGroupTempValue(context, "picked_2", 0, {})
elseif 0 < picked_3 then
ScriptLib.KillEntityByConfigId(context, { config_id = picked_3 })
ScriptLib.SetGroupTempValue(context, "picked_3", 0, {})
else
ScriptLib.PrintContextLog(context, "## [KazuhaServeItem] Serving item while no item picked!")
end
return 0
end
function LF_ServeItem_GetIndexInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return i
end
end
return 0
end
LF_Initialize_ServeItem(triggers, suites)

View File

@@ -0,0 +1,213 @@
--[[======================================
|| filename: LuaGadgetPool
|| owner: luyao.huang
|| description: 物件池机制
|| 这是一个简单的池机制,只实现了简单的池管理。没有(也做不到)动态扩容等功能。所以如果用完了就是用完了,会出现创建不出物件的情况
|| LogName: LuaGadgetPool
|| Protection:
=======================================]]--
------
local pool_defs =
{
--物件池的基础configid后续id都在上面做增量
pool_base_config_id = 1000000,
}
function Pool_Initialize()
local pool_gadget_config = {}
if pool_object_gadget_id ~= nil then
for k = 1, #pool_object_gadget_id do
local pool_max = 0
if elite_drop ~= nil then
--for m,v in pairs(elite_drop) do
-- pool_max = pool_max + v[k]
--end
if monster_drop_num ~= nil then
if monster_drop_num[k] ~= nil then
pool_max = monster_drop_num[k] * #monsters
end
end
for i = 1, pool_max do
pool_gadget_config = { config_id = 0, gadget_id = 0, pos = { x = 0, y = 0, z = 0 }, rot = { x = 0, y = 0, z = 0 }, level = 1 }
pool_gadget_config.config_id = pool_defs.pool_base_config_id + (k-1) * pool_max + i
pool_gadget_config.gadget_id = pool_object_gadget_id[k]
local legal_config = {}
if #gadgets > 0 then
legal_config = gadgets[1]
end
if #monsters > 0 then
legal_config = monsters[1]
end
pool_gadget_config.pos = legal_config.pos
pool_gadget_config.rot = legal_config.rot
pool_gadget_config.level = 1
if legal_config.area_id ~= nil then
pool_gadget_config.area_id = legal_config.area_id
end
table.insert(gadgets,pool_gadget_config)
end
table.insert(variables,{config_id = 150000000+k, name = "pool_top_"..k, value = 1})
table.insert(variables,{config_id = 150000000+k+ #pool_object_gadget_id +1, name = "pool_max_"..k, value = pool_max})
end
end
end
--物件池的物件计数
end
------------------------------------------------------------------------------------------------------
--找一个未被占用的object创建出来需要指定创建位置
function LF_Create_Object_From_Pool(context,k,pos,rot)
local pool_top = LF_Get_Pool_Top(context,k)
if pool_top == -1 then
ScriptLib.PrintContextLog(context,"## [LuaGadgetPool] 物件池全部被占用,创建失败")
return
end
ScriptLib.SetGroupVariableValue(context,"pool_top_"..k,pool_top+1)
ScriptLib.CreateGadgetByConfigIdByPos(context,LF_Get_Config_Id_By_Index(context,k,pool_top), {x=pos.x,y=pos.y,z=pos.z}, {x=rot.x,y=rot.y,z=rot.z})
end
--尝试获取一个当前未被占用的物件
function LF_Get_Pool_Top(context,k)
local pool_top = ScriptLib.GetGroupVariableValue(context,"pool_top_"..k)
if pool_top < ScriptLib.GetGroupVariableValue(context,"pool_max_"..k) then
return ScriptLib.GetGroupVariableValue(context,"pool_top_"..k)
else
return -1
end
end
--常用工具方法。根据特定config_id的怪物所在位置创建物件
function LF_Create_Object_From_Pool_By_Monster_Config_Id(context,k,config_id)
local eid = ScriptLib.GetEntityIdByConfigId(context,config_id)
local pos = ScriptLib.GetPosByEntityId(context, eid)
local rot = ScriptLib.GetRotationByEntityId(context,eid)
ScriptLib.PrintContextLog(context,"## [LuaGadgetPool] 在怪物死亡位置创建第"..k.."个池物件")
LF_Create_Object_From_Pool(context,k,{x=pos.x,y=pos.y+0.25,z=pos.z},rot)
end
function LF_Create_Object_Random_Pos_From_Pool_By_Monster_Config_Id(context,k,config_id,r)
local eid = ScriptLib.GetEntityIdByConfigId(context,config_id)
local pos = ScriptLib.GetPosByEntityId(context, eid)
local rot = ScriptLib.GetRotationByEntityId(context,eid)
ScriptLib.PrintContextLog(context,"## [LuaGadgetPool] 在怪物死亡位置创建第"..k.."个池物件")
local deltaX = math.cos(2 * math.pi * math.random()) * r
local deltaZ = math.sin(2 * math.pi * math.random()) * r
LF_Create_Object_From_Pool(context,k,{x=pos.x+deltaX,y=pos.y+0.25,z=pos.z+deltaZ},rot)
end
--重置整个物件池回收所有释放的物件i
function LF_Reset_Gadget_Pool(context)
for i = 1, #pool_object_gadget_id do
local base = LF_Get_Base_Config_Id(context,i)
for j = base, base + ScriptLib.GetGroupVariableValue(context,"pool_max_"..i) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, base+j)
end
ScriptLib.SetGroupVariableValue(context,"pool_top_"..i,1)
end
end
--输入config_id检查是否是整个物件池内的物件
function LF_Is_In_Pool(context,config_id)
for i = 1, #pool_object_gadget_id-1 do
local lower = LF_Get_Base_Config_Id(context,i)
local upper = LF_Get_Base_Config_Id(context,i+1)
if (config_id >= lower and config_id < upper) then
return true
end
end
return false
end
--输入config_id检查是否是特定池内的物件
function LF_Is_In_Specific_Pool(context,k,config_id)
local lower = LF_Get_Base_Config_Id(context,k)
local upper = LF_Get_Base_Config_Id(context,k+1)
return (config_id >= lower and config_id < upper)
end
function LF_Get_Pool_Index(context,config_id)
for i = 1 , #pool_object_gadget_id do
if LF_Is_In_Specific_Pool(context,i,config_id) then
return i
end
end
return -1
end
--根据config_id反查它是第几个物件以及池内的index
function LF_Get_Index_By_Config_Id(context,config_id)
local ret = {k = 0, index = 0}
for i = 1, #pool_object_gadget_id-1 do
local lower = LF_Get_Base_Config_Id(context,i)
local upper = LF_Get_Base_Config_Id(context,i+1)
if (config_id >= lower and config_id < upper) then
ret.k = i
ret.index = config_id - lower
return ret
end
end
end
--根据第几个物件、以及物件在池内的偏移找到物件的config_id
function LF_Get_Config_Id_By_Index(context,k,i)
return LF_Get_Base_Config_Id(context,k) + i
end
--找到特定id物件的偏移基础值
function LF_Get_Base_Config_Id(context,k)
local _k = k-1
if _k ~= 0 then
return pool_defs.pool_base_config_id + _k * ScriptLib.GetGroupVariableValue(context,"pool_max_".._k)
else
return pool_defs.pool_base_config_id
end
end
--尝试从当前的group配置中找到一个合理的配置如果有gadget先取第一个gadget如果没有则取第一个monster
function LF_Get_Group_Legal_Entity_Config()
if #gadgets > 0 then
return gadgets[1]
end
if #monsters > 0 then
return monsters[1]
end
end
function LF_Get_Monster_Config_By_Id(config_id)
for i = 1, #monsters do
if monsters[i].config_id == config_id then
return monsters[i]
end
end
end
------------------------------------------------------------------------------------------------------
Pool_Initialize()

View File

@@ -0,0 +1,40 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: MonaPortal
|| owner: weiwei.sun
|| description: 2.8莫娜梦境 传送门
|| LogName: MonaPortal
|| Protection:
=======================================]]--
--[[
local defs = {
target_leveltag = 22,
pos = { x=-677.9, y=135, z=-16},
rot = {x=0, y=0, z=1},
radius = 2,
}
]]
function SLC_MonaPortal_Start(context)
if true == ScriptLib.CheckIsInMpMode(context) then
local cfg_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.ShowReminderRadius(context, 321700501, gadgets[cfg_id].pos, 5)
return 0
end
--埋点
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.MarkGroupLuaAction(context, "MonaPortal", "", {["group_id"] = base_info.group_id, ["config_id"] = config_id, ["to_leveltag"] = defs.target_leveltag})
ScriptLib.ChangeToTargetLevelTagWithParamTable(context, defs.target_leveltag, {pos = defs.pos, radius = defs.radius, rot = defs.rot})
return 0
end
function SLC_MonaPortal_TryShowReminder(context)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
if 22 == defs.target_leveltag then
ScriptLib.ShowReminderRadius(context, 1111377, gadgets[config_id].pos, 5)
end
return 0
end

View File

@@ -0,0 +1,129 @@
--[[======================================
|| filename: MonsterTidePerformanceTest
|| owner: luyao.huang
|| description: 2.8怪物潮优化性能测试
|| LogName: MonsterTidePerformanceTest
|| Protection:
=======================================]]--
--miscs
local local_defs = {
monster_tide_index = 1,
worktop_option = 30110,
}
local Tri = {
{ config_id = 40000000, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
{ config_id = 40000001, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
{ config_id = 40000002, name = "variable_change", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--GM暂停怪物潮
table.insert(variables,{config_id = 50000000, name = "GM_Stop_Tide", value = 0})
--GM启动怪物潮
table.insert(variables,{config_id = 50000001, name = "GM_Start_Tide", value = 0})
--GM重启测试
table.insert(variables,{config_id = 50000002, name = "GM_Restart_Test", value = 0})
--GM选择是否开启优化怪物潮
table.insert(variables,{config_id = 50000003, name = "GM_Optimize_Tide", value = 0})
--GM选择是否开启轻量化怪物潮
table.insert(variables,{config_id = 50000004, name = "GM_Light_Tide", value = 0})
end
------------------------------------------------------------------
--group load如果是上半场则开始玩法初始化
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"## [MonsterTidePerformanceTest]action_group_load group加载测试初始化")
LF_Init_Play(context)
return 0
end
function action_variable_change(context,evt)
if (evt.source_name == "GM_Stop_Tide" and evt.param1 == 1) then
ScriptLib.PauseAutoMonsterTide(context, base_info.group_id, local_defs.monster_tide_index)
ScriptLib.SetGroupVariableValue(context,"GM_Stop_Tide",0)
end
if (evt.source_name == "GM_Start_Tide" and evt.param1 == 1) then
ScriptLib.ContinueAutoMonster(context, base_info.group_id, local_defs.monster_tide_index)
ScriptLib.SetGroupVariableValue(context,"GM_Start_Tide",0)
end
if (evt.source_name == "GM_Restart_Test" and evt.param1 == 1) then
LF_Stop_Play(context)
LF_Init_Play(context)
ScriptLib.SetGroupVariableValue(context,"GM_Restart_Test",0)
end
return 0
end
--按下操作台按键,启动玩法
function action_select_option(context,evt)
ScriptLib.PrintContextLog(context,"## [MonsterTidePerformanceTest]action_select_option 玩家按下选项,启动测试")
LF_Start_Play(context)
return 0
end
------------------------------------------------------------------
--辅助方法---------------------------------------------------------
------------------------------------------------------------------
function LF_Init_Play(context)
ScriptLib.CreateGadget(context,{config_id = defs.worktop_id})
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.worktop_id, 0)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.worktop_id, {local_defs.worktop_option})
end
function LF_Start_Play(context)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.worktop_id, local_defs.worktop_option)
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.worktop_id, GadgetState.GearStop)
local is_optimize_tide = ScriptLib.GetGroupVariableValue(context,"GM_Optimize_Tide")
local is_light_tide = ScriptLib.GetGroupVariableValue(context,"GM_Light_Tide")
local tide_monster_list = {}
if is_optimize_tide == 1 then
tide_monster_list = optimize_monster_list
ScriptLib.PrintContextLog(context,"## [MonsterTidePerformanceTest]LF_Start_Play加载客户端优化逻辑怪物潮")
elseif is_light_tide == 1 then
tide_monster_list = light_monster_list
ScriptLib.PrintContextLog(context,"## [MonsterTidePerformanceTest]LF_Start_Play加载轻量化ability配置怪物潮")
else
tide_monster_list = monster_list
ScriptLib.PrintContextLog(context,"## [MonsterTidePerformanceTest]LF_Start_Play加载普通怪物潮")
end
ScriptLib.AutoMonsterTide(context, local_defs.monster_tide_index, base_info.group_id, tide_monster_list, 0, defs.min , defs.max)
end
function LF_Stop_Play(context)
ScriptLib.KillMonsterTide(context, base_info.group_id, local_defs.monster_tide_index)
end
function LF_Get_All_Monster_In_Group(context)
local monster_list = {}
for i = 1, #monsters do
table.insert(monster_list,monsters[i].config_id)
end
return monster_list
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,507 @@
--[[======================================
|| filename: SocialActivity_Common
|| owner: luyao.huang
|| description: 2.8社交活动-通用流程框架
|| LogName: SocialActivity_Common
|| Protection:
=======================================]]--
------
local local_defs = {
--刷出下一波怪时的提示reminder
monster_chain_reminder = 400158,
day_weather = 9019
}
local common_Tri = {
[1] = { name = "group_load_common", config_id = 10000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load_common", trigger_count = 0},
[2] = { name = "gallery_start_common", config_id = 10000002, event = EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_gallery_start", trigger_count = 0},
[3] = { name = "variable_change_common", config_id = 10000003, event = EventType.EVENT_VARIABLE_CHANGE, source = "current_stage", condition = "", action = "action_variable_change_common", trigger_count = 0},
[4] = { name = "gallery_stop_common", config_id = 10000004, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
[5] = { name = "variable_change_GM", config_id = 10000100, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change_GM", trigger_count = 0},
[6] = { name = "group_will_unload_common", config_id = 1000005, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_common", trigger_count = 0},
}
function Common_Initialize()
for k,v in pairs(common_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--记录阶段数
table.insert(variables,{config_id = 10000000, name = "current_stage", value = 0})
--GM用variable用于直接开启玩法不用匹配
table.insert(variables,{config_id = 10000001, name = "GM_Start_Play", value = 0})
--GM用variable用于直接关闭玩法
table.insert(variables,{config_id = 10000002, name = "GM_Stop_Play", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--玩法加载初始化
function action_group_load_common(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] group_load_common group加载玩法初始化")
LF_Init_Play(context)
return 0
end
--玩法启动
function action_gallery_start(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] action_gallery_start: gallery启动启动玩法")
LF_Start_Play(context)
return 0
end
--进入下一个阶段
function action_variable_change_common(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] variable_change_common 进入阶段"..LF_Get_Current_Stage(context))
if (evt.param1 > 0) then
if (LF_Get_Current_Stage(context) > defs.final_stage) then
--如果当前阶段已经到了最终阶段,则进行玩法结算
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] variable_change_common 已进入最终阶段,开始结算")
LF_Finish_Play(context,true)
else
--否则加载下一阶段布设
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] variable_change_common 加载下一阶段布设")
LF_Build_Next_Stage(context)
end
end
return 0
end
--gallery结束不论是什么原因结束的都需要清理当前关卡
function action_gallery_stop(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] action_gallery_stop: gallery结束结果为"..1-evt.param2)
LF_Clear_Stage(context)
--gallery拿到的成功失败是反过来的要拿1减一下
LF_Special_Play_Finish(context,1-evt.param2)
return 0
end
--调试用GM
function action_variable_change_GM(context,evt)
if evt.source_name == "GM_Start_Play" then
ScriptLib.StartGallery(context,defs.gallery_id)
end
if evt.source_name == "GM_Stop_Play" and evt.param1 == 1 then
LF_Finish_Play(context,true)
end
if evt.source_name == "GM_Stop_Play" and evt.param1 == -1 then
LF_Finish_Play(context,false)
end
return 0
end
--保底恢复大世界天气
function action_group_will_unload_common(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] action_group_will_unload_commongroup保底卸载恢复天气")
--设置全局白天天气
LF_Set_Weather(context,local_defs.day_weather,false)
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
--玩法初始化
function LF_Init_Play(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Init_Play初始化玩法")
ScriptLib.SetGroupVariableValue(context,"current_stage",0)
LF_Set_Weather(context,local_defs.day_weather,true)
--各个玩法特殊的初始化逻辑
LF_Special_Play_Init(context)
end
--玩法启动
function LF_Start_Play(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Start_Play玩法启动")
ScriptLib.SetGroupVariableValueByGroup(context, "prepare_state", 0, defs.prepare_group_id)
LF_Goto_Next_Stage(context)
--各个玩法特殊的玩法启动逻辑
LF_Special_Play_Start(context)
end
--玩法结算
--主要是关掉gallery玩法清理部分通过回调处理
function LF_Finish_Play(context,is_success)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Finish_Play挑战结算")
LF_Clear_Stage(context)
if is_success then
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Finish_Play挑战成功")
LF_Special_Play_Finish(context,true)
ScriptLib.StopGallery(context,defs.gallery_id,false)
else
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Finish_Play挑战失败")
LF_Special_Play_Finish(context,false)
ScriptLib.StopGallery(context,defs.gallery_id,true)
end
end
--进入下一阶段
function LF_Goto_Next_Stage(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Goto_Next_Stage进入下一阶段")
local current_stage = LF_Get_Current_Stage(context)
LF_Set_Current_Stage(context,current_stage+1)
--设置阶段复活点
local revive_point = LF_Get_Stage_Revive_Point(LF_Get_Current_Stage(context))
LF_Set_Revive_Point(context,revive_point)
if (LF_Get_Current_Stage(context) <= defs.final_stage) then
LF_Special_State_Change(context)
end
end
--加载下一阶段布设
function LF_Build_Next_Stage(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Build_Next_Stage加载下一阶段布设")
local current_stage = LF_Get_Current_Stage(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Build_Next_Stage目标加载的阶段为"..current_stage)
--加载下一阶段的布设
for k,v in pairs(LF_Get_Stage_Start_Suites(context,current_stage)) do
ScriptLib.AddExtraGroupSuite(context,0,v)
end
end
--尝试加载链上的下一组怪物(适用于多波刷怪的逻辑)
function LF_Try_Create_Next_Chain_Suite(context, monster_suite_id)
if monster_suite_chain ~= nil then
--如果死亡的怪物是它所在suite的最后一只尝试通过chain加载下一组suite
if (LF_Is_Monster_In_List_All_Killed(context,suites[monster_suite_id].monsters)) then
if (monster_suite_chain[monster_suite_id]~=nil) then
ScriptLib.ShowReminder(context,local_defs.monster_chain_reminder)
for i = 1, #monster_suite_chain[monster_suite_id] do
ScriptLib.AddExtraGroupSuite(context,0,monster_suite_chain[monster_suite_id][i])
end
return true
end
end
end
return false
end
--清理当前关卡所有内容
function LF_Clear_Stage(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Clear_Stage: 清理玩法布设")
--强行刷新到suite 1清除所有布设
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
LF_Init_Play(context)
LF_Set_Weather(context,local_defs.day_weather,false)
end
--移除一个stage下所有suite(注意这里只清monster_suite如果LD有一些suite不放monster这种操作还得额外处理一下)
function LF_Clear_Specific_Stage(context,stage_index)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Clear_Specific_Stage: 清理stage "..stage_index.."的内容")
local monster_suites = LF_Get_Stage_Monster_Suites(context,stage_index)
for i = 1, #monster_suites do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, monster_suites[i])
end
end
--移除一个stage下所有怪物(注意这里只清monster_suite如果LD有一些suite不放monster这种操作还得额外处理一下)
function LF_Clear_Specific_Stage_Monsters(context,stage_index)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Clear_Specific_Stage_Monsters: 清理stage "..stage_index.."的所有怪物")
local monster_list = LF_Get_Stage_Monsters(context,stage_index)
for i = 1, #monster_list do
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.MONSTER, monster_list[i])
end
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
-------------------------阶段相关查询------------------------------
--获取当前阶段数
function LF_Get_Current_Stage(context)
return ScriptLib.GetGroupVariableValue(context, "current_stage")
end
--设置当前阶段数
function LF_Set_Current_Stage(context,stage)
ScriptLib.SetGroupVariableValue(context,"current_stage",stage)
end
--根据输入的阶段数找到阶段对应的所有suite
function LF_Get_Stage_All_Suites(context,index)
if stage[index].all_suites == nil then
return {}
end
return stage[index].all_suites
end
--根据输入的阶段数找到所有包含了当前阶段怪物的suite
function LF_Get_Stage_Monster_Suites(context,index)
if stage[index].monster_suites == nil then
return {}
end
return stage[index].monster_suites
end
--根据输入的阶段数找到所有启动suite切换到该stage时加载的suite
function LF_Get_Stage_Start_Suites(context,index)
if stage[index].start_suites == nil then
return {}
end
return stage[index].start_suites
end
--根据输入的阶段数,获取该阶段的怪物列表
function LF_Get_Stage_Monsters(context,stage)
local _stage_suites = LF_Get_Stage_Monster_Suites(context,stage)
local stage_monsters = {}
for i = 1, #_stage_suites do
for j = 1,#suites[_stage_suites[i]].monsters do
table.insert(stage_monsters,(suites[_stage_suites[i]].monsters)[j])
end
end
return stage_monsters
end
--检查一个stage是否有特定标签
function LF_Stage_Has_Tag(context,id,tag)
if stage[id] == nil then
return false
end
local stage_tag = stage[id].tag
if stage_tag == nil or stage_tag ~= tag then
return false
else
return true
end
end
--检查一个stage是否是leagal的以Stage_Suites为准
function LF_Is_Legal_Stage(id)
return stage[id] ~= nil
end
--查询当前阶段对应的复活点id
function LF_Get_Stage_Revive_Point(id)
if LF_Is_Legal_Stage(id) then
if stage[id].revive_point ~= nil then
return stage[id].revive_point
else
return 0
end
end
return 0
end
-------------------------关卡配置查询------------------------------
function LF_Get_Point_Config(context,point_id)
for i = 1, #points do
if (points[i].config_id == point_id) then
return points[i]
end
end
return nil
end
--输入一个config_id返回其是第几个suite的物件/怪物
function LF_Get_Suite_By_Config_Id(config_id, is_gadget)
for i = 1, #suites do
if is_gadget then
for j = 1, #suites[i].gadgets do
if suites[i].gadgets[j] == config_id then
return i
end
end
else
for j = 1, #suites[i].monsters do
if suites[i].monsters[j] == config_id then
return i
end
end
end
end
end
--输入一个config_id返回其是第几个stage的物件/怪物
function LF_Get_Stage_By_Config_Id(config_id, is_gadget)
for i = 1, #suites do
if is_gadget then
for j = 1, #suites[i].gadgets do
if suites[i].gadgets[j] == config_id then
return LF_Get_Suite_Stage(i)
end
end
else
for j = 1, #suites[i].monsters do
if suites[i].monsters[j] == config_id then
return LF_Get_Suite_Stage(i)
end
end
end
end
end
--根据suiteid反查所属的stage
function LF_Get_Suite_Stage(suite_id)
for i = 1, #stage do
if (stage[i].all_suites~=nil) then
for j = 1, #stage[i].all_suites do
if stage[i].all_suites[j] == suite_id then
return i
end
end
end
if (stage[i].monster_suites~=nil) then
for j = 1, #stage[i].monster_suites do
if stage[i].monster_suites[j] == suite_id then
return i
end
end
end
if (stage[i].start_suites~=nil) then
for j = 1, #stage[i].start_suites do
if stage[i].start_suites[j] == suite_id then
return i
end
end
end
end
return 0
end
--检查表内的怪物是否已经都死了
function LF_Is_Monster_In_List_All_Killed(context,check_monster_list)
local alive_monster_list = ScriptLib.GetGroupAliveMonsterList(context,base_info.group_id)
for i = 1, #alive_monster_list do
for j = 1,#check_monster_list do
if (alive_monster_list[i] == check_monster_list[j]) then
return false
end
end
end
return true
end
function LF_Get_Gadget_Id_By_Config_Id(config_id)
for k,v in pairs(gadgets) do
if config_id == v.config_id then
return v.gadget_id
end
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
--通用打印表的方法
function LF_Print_Table(context,print_table)
for k,v in pairs(print_table) do
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] "..k.." : "..v)
end
end
--设置复活点
function LF_Set_Revive_Point(context,point_id)
if point_id == 0 or point_id == nil then
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Set_Revive_Point: 复活点为空,返回")
return
end
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Set_Revive_Point: 设置复活点"..point_id)
ScriptLib.SetGalleryRevivePoint(context, defs.gallery_id, base_info.group_id, point_id)
end
--设置天气
function LF_Set_Weather(context,weather_id,is_on)
if is_on then
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Set_Weather: 开启天气")
ScriptLib.SetWeatherAreaState(context, weather_id, 1)
ScriptLib.EnterWeatherArea(context, weather_id)
else
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] LF_Set_Weather: 关闭天气")
ScriptLib.SetWeatherAreaState(context, weather_id, 0)
end
end
--运营打点功能
function LF_Mark_Lua_Action(context,param_table)
for k,v in pairs(param_table) do
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common]LF_Mark_Lua_Action: 运营打点key = "..k..", value = "..v)
end
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common]LF_Mark_Lua_Action: 运营打点:----------------------------")
ScriptLib.MarkGroupLuaAction(context, "IslandParty_1","",param_table)
end
function LF_Is_In_Range(value, bound_1, bound_2)
if bound_1 > bound_2 then
local t = bound_1
bound_1 = bound_2
bound_2 = t
end
if bound_1 <= value and value < bound_2 then
return true
end
return false
end
--[[-----------------------------------------------------------------
|| ||
|| 陈列室同步 ||
|| ||
-----------------------------------------------------------------]]--
--写陈列室
--如果输入uid = -2避开0和-1则为全部玩家都写
function LF_Update_Exhibition(context,uid,trigger_name,value)
if uid == -2 then
local uidlist = ScriptLib.GetGalleryUidList(context,defs.gallery_id)
for i = 1, #uidlist do
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] 向陈列室同步uid"..uidlist[i]..", trigger名"..trigger_name..", 增量:"..value)
ScriptLib.AddExhibitionReplaceableData(context, uidlist[i], trigger_name, value)
end
else
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common] 向陈列室同步uid"..uid..", trigger名"..trigger_name..", 增量:"..value)
ScriptLib.AddExhibitionReplaceableData(context, uid, trigger_name, value)
end
end
------------------------------------------------------------------
Common_Initialize()

View File

@@ -0,0 +1,259 @@
--[[======================================
|| filename: SocialActivity_DownHill
|| owner: luyao.huang
|| description: 2.8社交活动-跳楼挑战
|| LogName: SocialActivity_DownHill
|| Protection:
=======================================]]--
------
local local_defs =
{
--激流纹章
coin_id = 70380240,
mechanism_ball_id = 70380227,
platform_1_id = 70380311,
platform_2_id = 70380312,
--间隔几个stage将之前的stage清空
clear_stage_interval = 2,
dive_reminder = 60010448
}
local gadget_config_id_map = {}
local Tri = {
[1] = { name = "monster_die_before_leave_scene", config_id = 9000001, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[2] = { name = "any_gadget_die", config_id = 9000002, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0},
[3] = { name = "enter_region", config_id = 9000003, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for i = 1, #gadgets do
gadget_config_id_map[gadgets[i].config_id] = gadgets[i].gadget_id
end
table.insert(variables,{config_id = 20000000, name = "total_die_monster_count", value = 0})
table.insert(variables,{config_id = 20000001, name = "coin_num", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--怪物死亡时。如果当前不是跳水阶段,那么直接进入下一个阶段
function action_monster_die_before_leave_scene(context,evt)
ScriptLib.ChangeGroupVariableValue(context,"total_die_monster_count",1)
LF_Gallery_Update(context,"MONSTER_DIE")
--先看看chain上有没有需要加载的下一位的suite。如果有直接加载不考虑进入下一个stage
local monster_suite_id = LF_Get_Suite_By_Config_Id(evt.param1,false)
if LF_Try_Create_Next_Chain_Suite(context,monster_suite_id) then
return 0
end
--如果chain上没有要加载的下一个suite则看是否可以进入下一个stage
if LF_Is_Monster_In_List_All_Killed(context,LF_Get_Stage_Monsters(context,LF_Get_Current_Stage(context))) then
ScriptLib.PrintContextLog(context,"## [SocialActivity_DownHill] action_any_monster_die: 怪物全部死完")
if LF_Stage_Has_Tag(context,LF_Get_Current_Stage(context),"Battle") then
LF_Goto_Next_Stage(context)
end
end
return 0
end
--机制球被吃掉时转换关卡的某个形态。LD自己写逻辑处理
function action_any_gadget_die(context,evt)
--吃掉机制球
local cid = evt.param1
local gid = gadget_config_id_map[cid]
local level_change_variable = LF_Get_Mechanism_Ball_Level_Variable(evt.param1)
--这里强判一下机制球的gadget id了应该不会变动
if gid == local_defs.mechanism_ball_id and level_change_variable ~= nil then
ScriptLib.PrintContextLog(context,"## [SocialActivity_DownHill] action_any_gadget_die: 死的是机制球")
LF_Change_Level_By_Mechanism_Ball(context,level_change_variable)
end
--吃掉金币
if gid == local_defs.coin_id then
ScriptLib.ChangeGroupVariableValue(context,"coin_num",1)
LF_Gallery_Update(context,"COIN")
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Downhill_TeamCoin",1)
end
return 0
end
--进入落水区域。如果是最终阶段则玩法结束,否则传送到起点
function action_enter_region(context,evt)
if (evt.param1 == defs.dive_region) then
ScriptLib.PrintContextLog(context,"## [SocialActivity_DownHill] action_enter_region: 玩家进入跳水区域")
if LF_Stage_Has_Tag(context,LF_Get_Current_Stage(context),"Dive") then
--最后一阶段时进入region结束玩法
LF_Update_Exhibition(context,evt.uid,"Activity_IslandParty_Downhill_ArriveFirst",1)
LF_Finish_Play(context,1)
else
if LF_Get_Current_Stage(context) ~= 0 then
--其他阶段时进入region直接传回当前存档点
local start_point = LF_Get_Point_Config(context,LF_Get_Stage_Revive_Point(LF_Get_Current_Stage(context)))
if start_point ~= nil then
ScriptLib.TransPlayerToPos(context, {uid_list = {evt.uid}, pos = start_point.pos, radius = 0, rot = start_point.rot})
end
end
end
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Special_Play_Init(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_DownHill] LF_Special_Play_Init: 特殊玩法初始化逻辑")
end
--特殊玩法启动逻辑
function LF_Special_Play_Start(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_DownHill] LF_Special_Play_Start: 特殊玩法启动逻辑")
ScriptLib.SetGroupVariableValue(context,"total_die_monster_count",0)
ScriptLib.SetGroupVariableValue(context,"coin_num",0)
LF_Gallery_Update(context,"START_PLAY")
end
--特殊阶段转换事件
function LF_Special_State_Change(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_DownHill] LF_Special_State_Change: 特殊阶段转换逻辑")
--根据LD的需求隔X个stage清理前面所有stage的内容
for i = 1, LF_Get_Current_Stage(context)-local_defs.clear_stage_interval do
LF_Clear_Specific_Stage(context,i)
end
if LF_Stage_Has_Tag(context,LF_Get_Current_Stage(context),"Dive") then
ScriptLib.ShowReminder(context,local_defs.dive_reminder)
end
end
--特殊玩法结算逻辑
function LF_Special_Play_Finish(context,is_success)
if is_success then
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Downhill_Success",1)
end
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
--找到特定机制球对应的关卡variable名
function LF_Get_Mechanism_Ball_Level_Variable(ball_id)
return mechanism_ball_level_variable[ball_id]
end
--吃到机制球时修改一个关卡变量。LD监听这个变量的变化做不同的关卡逻辑表现
function LF_Change_Level_By_Mechanism_Ball(context,level_change_variable)
ScriptLib.SetGroupVariableValue(context,level_change_variable,1)
end
--[[-----------------------------------------------------------------
|| ||
|| gallery同步 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Gallery_Update(context,command)
ScriptLib.PrintContextLog(context,"## [SocialActivity_DownHill] LF_Gallery_Update: 向gallery同步")
if command == "START_PLAY" then
ScriptLib.PrintContextLog(context,"## [SocialActivity_DownHill] LF_Gallery_Update: "..#monsters)
local param_table = {["total_kill_monster_count"] = 0, ["max_kill_monster_count"] = #monsters }
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
if command == "MONSTER_DIE" then
local total_die_monster_count = ScriptLib.GetGroupVariableValue(context,"total_die_monster_count")
local param_table = {["total_kill_monster_count"] = total_die_monster_count}
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
if command == "COIN" then
local coin = ScriptLib.GetGroupVariableValue(context,"coin_num")
local param_table = {["coin"] = coin}
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
--陈列室SLC
--陈列室速降拾取buff数
function SLC_Exhibition_Pick_Up_Ball(context)
LF_Update_Exhibition(context,context.uid,"Activity_IslandParty_Downhill_Buff",1)
return 0
end
--陈列室:速降拾取金币数个人
function SLC_Exhibition_Pick_Up_Coin(context)
LF_Update_Exhibition(context,context.uid,"Activity_IslandParty_Downhill_PersonalCoin",1)
return 0
end
--陈列室:速降累积降落到平台数量
function SLC_Exhibition_Land_On_Platform(context)
LF_Update_Exhibition(context,context.uid,"Activity_IslandParty_Downhill_Platform",1)
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,92 @@
--[[======================================
|| filename: SocialActivity_Optimization
|| owner: luyao.huang
|| description: 2.8社交活动-用于社交玩法group的性能优化
|| LogName: SocialActivity_Optimization
|| Protection:
=======================================]]--
local optimize_Tri={
{config_id = 13000001, name = "enter_region_optimization", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region_optimization", forbid_guest = false,trigger_count = 0 },
{config_id = 13000002, name = "leave_region_optimization", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region_optimization", forbid_guest = false,trigger_count = 0 },
{config_id = 13000003, name = "group_will_unload_optimization", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_optimization",trigger_count = 0 },
{config_id = 13000004, name = "gallery_cannot_start_after_countdown_optimization", event = EventType.EVENT_GALLERY_CANNOT_START_AFTER_COUNTDOWN, source = "", condition = "", action = "action_gallery_cannot_start_after_countdown_optimization",trigger_count = 0 },
}
function Optimization_Initialize()
for k,v in pairs(optimize_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--用于记录当前玩法启动是否成功
table.insert(variables,{config_id = 30000000, name = "play_start_fails", value = 0})
end
--进入玩法region时给对应uid玩家上visiontype
function action_enter_region_optimization(context, evt)
if evt.param1 == defs.optimize_region then
ScriptLib.PrintContextLog(context,"## [SocialActivity_Optimization] action_enter_region_optimization进入优化圈尝试开启优化")
LF_Start_Optimization(context)
end
return 0
end
--离开玩法region时给对应uid玩家下visiontype
function action_leave_region_optimization(context, evt)
if evt.param1 == defs.optimize_region then
ScriptLib.PrintContextLog(context,"## [SocialActivity_Optimization] action_leave_region_optimization离开优化圈关闭优化")
LF_Stop_Optimization(context)
end
return 0
end
--group被卸载时保底要恢复所有玩家的visiontype
function action_group_will_unload_optimization(context, evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Optimization] action_leave_region_optimizationgroup即将卸载保底清除优化")
LF_Stop_Optimization_All(context)
--玩法标记为启动失败或结束
ScriptLib.SetGroupVariableValue(context,"play_start_fails",1)
return 0
end
function action_gallery_cannot_start_after_countdown_optimization(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl]action_gallery_cannot_start_after_countdown_optimization玩法启动失败保底清除优化逻辑")
LF_Stop_Optimization_All(context)
--玩法标记为启动失败或结束
ScriptLib.SetGroupVariableValue(context,"play_start_fails",1)
return 0
end
-------------------------------------------------------------------------------
function LF_Start_Optimization(context)
--仅当玩法处于正常状态时,才开启优化
if ScriptLib.GetGroupVariableValue(context,"play_start_fails") ~= 1 then
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {30010001})
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
end
end
function LF_Stop_Optimization(context)
if ScriptLib.GetGroupVariableValue(context,"play_start_fails") ~= 1 then
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
ScriptLib.RevertPlayerRegionVision(context, context.uid)
end
end
--恢复所有玩家
function LF_Stop_Optimization_All(context)
if ScriptLib.GetGroupVariableValue(context,"play_start_fails") ~= 1 then
local uid_list = ScriptLib.GetSceneUidList(context)
for i = 1, #uid_list do
ScriptLib.SetPlayerGroupVisionType(context, {uid_list[i]}, {1})
ScriptLib.RevertPlayerRegionVision(context, uid_list[i])
end
end
end
Optimization_Initialize()

View File

@@ -0,0 +1,144 @@
--[[======================================
|| filename: SocialActivity_PrepareControl
|| owner: luyao.huang
|| description: 2.8社交活动-用于处理开场空气墙等开场的逻辑
|| LogName: SocialActivity_PrepareControl
|| Protection:
=======================================]]--
local prepare_Tri={
{config_id = 14000001, name = "group_load_prepare", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load_prepare",trigger_count = 1 },
--{config_id = 14000002, name = "leave_region_prepare", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region_prepare", forbid_guest = false,trigger_count = 0 },
{config_id = 14000003, name = "variable_change_prepare", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change_prepare",trigger_count = 0 },
{config_id = 14000004, name = "gallery_cannot_start_after_countdown_prepare", event = EventType.EVENT_GALLERY_CANNOT_START_AFTER_COUNTDOWN, source = "", condition = "", action = "action_gallery_cannot_start_after_countdown_prepare",trigger_count = 0 },
{config_id = 14000005, name = "group_will_unload_prepare", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_prepare",trigger_count = 0 },
}
local_defs =
{
prepare_airwall = 70380323,
day_weather = 9019
}
function Prepare_Initialize()
for k,v in pairs(prepare_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--是否在准备阶段。group load时为1玩法开启后变为0
table.insert(variables,{config_id = 40000000, name = "prepare_state", value = -1})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_group_load_prepare(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl]action_group_load_preparegroup加载设置为等待状态")
ScriptLib.SetGroupVariableValue(context,"prepare_state",1)
LF_Set_Weather(context,local_defs.day_weather,true)
return 0
end
function action_variable_change_prepare(context,evt)
if evt.source_name == "prepare_state" and evt.param1 == 1 then
ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl]action_variable_change_prepare进入等待状态开启空气墙")
LF_Create_Prepare_Airwall(context)
--设置全局白天天气
--LF_Set_Weather(context,local_defs.day_weather,true)
end
if evt.source_name == "prepare_state" and evt.param1 == 0 then
ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl]action_variable_change_prepare离开等待状态关闭空气墙")
LF_Destroy_Prepare_Airwall(context)
end
return 0
end
function action_gallery_cannot_start_after_countdown_prepare(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl]action_gallery_cannot_start_after_countdown_preparegallery启动失败离开等待状态")
--玩法开启失败的情况下,要保底卸载掉天气
LF_Set_Weather(context,local_defs.day_weather,false)
ScriptLib.SetGroupVariableValue(context,"prepare_state",0)
return 0
end
--离开准备区域region时拉回准备点
--function action_leave_region_prepare(context, evt)
-- if evt.param1 == defs.prepare_region then
-- if LF_Is_In_Prepare_Stage(context) then
-- ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl]action_enter_region_prepare处于等待阶段并离开圈子")
-- local prepare_point = LF_Get_Point_Config(context,defs.prepare_point)
-- local ret = ScriptLib.TransPlayerToPos(context, {uid_list = {evt.uid}, pos = prepare_point.pos, radius = 0, rot = prepare_point.rot})
-- ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl]action_enter_region_prepare传送的结果为"..ret)
-- end
-- end
-- return 0
--end
--保底恢复大世界天气
function action_group_will_unload_prepare(context,evt)
if LF_Is_In_Prepare_Stage(context) then
ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl] action_group_will_unload_preparegroup保底卸载恢复天气")
--group卸载时如果玩法未开启保底恢复天气
LF_Set_Weather(context,local_defs.day_weather,false)
end
return 0
end
-------------------------------------------------------------------------------
function LF_Create_Prepare_Airwall(context)
local ret = ScriptLib.CreateGadget(context, {config_id = defs.prepare_airwall})
ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl]LF_Create_Prepare_Airwall创建空气墙的结果为"..ret)
end
function LF_Destroy_Prepare_Airwall(context)
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.prepare_airwall)
end
function LF_Is_In_Prepare_Stage(context)
return ScriptLib.GetGroupVariableValue(context,"prepare_state") == 1
end
function LF_Get_Point_Config(context,point_id)
for i = 1, #points do
if (points[i].config_id == point_id) then
return points[i]
end
end
return nil
end
--设置天气
function LF_Set_Weather(context,weather_id,is_on)
if is_on then
ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl] LF_Set_Weather: 开启天气")
ScriptLib.SetWeatherAreaState(context, weather_id, 1)
ScriptLib.EnterWeatherArea(context, weather_id)
else
ScriptLib.PrintContextLog(context,"## [SocialActivity_PrepareControl] LF_Set_Weather: 关闭天气")
ScriptLib.SetWeatherAreaState(context, weather_id, 0)
end
end
Prepare_Initialize()

View File

@@ -0,0 +1,996 @@
--[[======================================
|| filename: SocialActivity_RaftChallenge
|| owner: luyao.huang
|| description: 2.8社交活动-木筏挑战
|| LogName: SocialActivity_RaftChallenge
|| Protection:
=======================================]]--
------
local time_axis =
{
energy_tick_axis = {1},
low_hp_reminder_interval = {15}
}
local local_defs =
{
--激流纹章
coin_id = 70380240,
fuel_ball = 70380225,
part_ball = 70380226,
--间隔几个stage将之前的stage清空
clear_stage_interval = 3,
clear_monster_stage_interval = 1,
no_energy_reminder = 60010446,
fuel_guarantee_max_times = 2,
fuel_guarantee_num = 50,
low_hp_reminder = 60010449,
}
local gadget_config_id_map = {}
local Tri = {
[1] = { name = "monster_die_before_leave_scene", config_id = 9000001, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[2] = { name = "any_gadget_die", config_id = 9000002, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0},
[3] = { name = "platform_arrival", config_id = 9000003, event = EventType.EVENT_PLATFORM_ARRIVAL, source = tostring(raft.engine), condition = "", action = "action_platform_arrival", trigger_count = 0},
[4] = { name = "time_axis_pass",config_id = 90000004, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[5] = { name = "specific_gadget_hp_change_1",config_id = 90000011, event = EventType.EVENT_SPECIFIC_GADGET_HP_CHANGE, source = tostring(raft.part_1), condition = "", action = "action_specific_gadget_hp_change", trigger_count = 0},
[6] = { name = "specific_gadget_hp_change_2",config_id = 90000012, event = EventType.EVENT_SPECIFIC_GADGET_HP_CHANGE, source = tostring(raft.part_2), condition = "", action = "action_specific_gadget_hp_change", trigger_count = 0},
[7] = { name = "specific_gadget_hp_change_3",config_id = 90000013, event = EventType.EVENT_SPECIFIC_GADGET_HP_CHANGE, source = tostring(raft.part_3), condition = "", action = "action_specific_gadget_hp_change", trigger_count = 0},
[8] = { name = "specific_gadget_hp_change_4",config_id = 90000014, event = EventType.EVENT_SPECIFIC_GADGET_HP_CHANGE, source = tostring(raft.part_4), condition = "", action = "action_specific_gadget_hp_change", trigger_count = 0},
[9] = { name = "variable_change",config_id = 90000005, event = EventType.EVENT_VARIABLE_CHANGE, source = "engine_energy", condition = "", action = "action_engine_energy_change", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for i = 1, #gadgets do
gadget_config_id_map[gadgets[i].config_id] = gadgets[i].gadget_id
end
--燃料数
table.insert(variables,{config_id = 50000000, name = "fuel_num", value = 0})
--零件数
table.insert(variables,{config_id = 50000001, name = "part_num", value = 0})
--金币数
table.insert(variables,{config_id = 50000002, name = "coin_num", value = 0})
--各个分块是否存活,存成一个四位二进制数方便管理
table.insert(variables,{config_id = 50000003, name = "raft_part_alive", value = 1111})
--发动机的能量数,相当于发动机的血量
table.insert(variables,{config_id = 50000004, name = "engine_energy", value = 0})
--船是否处于运动状态
table.insert(variables,{config_id = 50000005, name = "is_running", value = 0})
--临时能量池缓存SLC上来的能量恢复值每秒与运行时的能量消耗统一结算防止0能量时反复充能放能导致振荡
table.insert(variables,{config_id = 50000006, name = "engine_energy_pool", value = 0})
--记录当前是否因没有能量处于停船状态如果是则在下一次能量大于0时恢复一次船的行动
table.insert(variables,{config_id = 50000007, name = "has_stopped_by_no_energy", value = 0})
--记录当前是否因路障导致停船,如果是,下次路障死掉的时候要恢复一次行动
table.insert(variables,{config_id = 50000008, name = "has_stopped_by_road_block", value = 0})
--停船操作计数。当计数小于等于0时才能启动船
table.insert(variables,{config_id = 50000009, name = "stop_raft_op_num", value = 0})
--当前阶段怪物是否已经全死了
table.insert(variables,{config_id = 50000010, name = "current_stage_monster_all_killed", value = 0})
--当前阶段的障碍物是否被消灭
table.insert(variables,{config_id = 50000011, name = "current_stage_obstacled_all_killed", value = 0})
--检查点计数,用于给客户端同步的
table.insert(variables,{config_id = 50000012, name = "checkpoint_index", value = 1})
--燃料保底机制触发次数超过guarantee_times后不再触发
table.insert(variables,{config_id = 50000013, name = "fuel_guarantee_times", value = 0})
table.insert(variables,{config_id = 50000014, name = "can_show_low_hp_reminder", value = 1})
--记录一个最近触发的路点事件,用于识别可能存在的丢掉路点事件的问题
table.insert(variables,{ config_id = 50000015,name = "last_route_point", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--怪物死亡时
function action_monster_die_before_leave_scene(context,evt)
--看看chain上有没有需要加载的下一位的suite。如果有则直接加载
local monster_suite_id = LF_Get_Suite_By_Config_Id(evt.param1,false)
LF_Try_Create_Next_Chain_Suite(context,monster_suite_id)
for i = 1, monster_drop_num[1] do
LF_Create_Object_Random_Pos_From_Pool_By_Monster_Config_Id(context,1,evt.param1,1.5)
end
for i = 1, monster_drop_num[2] do
LF_Create_Object_Random_Pos_From_Pool_By_Monster_Config_Id(context,2,evt.param1,1.5)
end
--if elite_drop[evt.param1] ~= nil then
-- for i = 1, #elite_drop[evt.param1] do
-- for j = 1,elite_drop[evt.param1][i] do
-- LF_Create_Object_Random_Pos_From_Pool_By_Monster_Config_Id(context,i,evt.param1,1.5)
-- end
-- end
--end
return 0
end
--当前阶段障碍物全部死完,进入下一阶段
function action_any_gadget_die(context,evt)
--是否障碍物死亡
local obstacles = LF_Get_Stage_Obstacle(context,LF_Get_Current_Stage(context))
if (obstacles ~= 0) then
if (evt.param1 == obstacles[1]) then
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] action_any_gadget_die: 当前阶段的障碍物死亡")
ScriptLib.SetGroupVariableValue(context,"current_stage_obstacled_all_killed",1)
--如果当前因为路障停船,则尝试启动一次船
if (ScriptLib.GetGroupVariableValue(context,"has_stopped_by_road_block") == 1) then
LF_Try_Start_Raft(context)
ScriptLib.SetGroupVariableValue(context,"has_stopped_by_road_block",0)
end
LF_Goto_Next_Stage(context)
return 0
end
end
--处理筏子分块死亡
if evt.param1 == raft.part_1 then
LF_Set_Raft_Part_Alive(context,1,0)
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Raft_Protection",1)
--分块死亡事件打点
local gid = LF_Get_Gadget_Id_By_Config_Id(evt.param1)
local param_table =
{
["gadget_id"] = gid,
["change_type"] = 1,
["percentage_stage"] = 4
}
LF_Mark_Lua_Action(context,param_table)
if LF_Is_Part_All_Dead(context) then
LF_Finish_Play(context,false)
end
return 0
end
if evt.param1 == raft.part_2 then
LF_Set_Raft_Part_Alive(context,2,0)
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Raft_Protection",1)
--分块死亡事件打点
local gid = LF_Get_Gadget_Id_By_Config_Id(evt.param1)
local param_table =
{
["gadget_id"] = gid,
["change_type"] = 1,
["percentage_stage"] = 4
}
LF_Mark_Lua_Action(context,param_table)
if LF_Is_Part_All_Dead(context) then
LF_Finish_Play(context,false)
end
return 0
end
if evt.param1 == raft.part_3 then
LF_Set_Raft_Part_Alive(context,3,0)
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Raft_Protection",1)
--分块死亡事件打点
local gid = LF_Get_Gadget_Id_By_Config_Id(evt.param1)
local param_table =
{
["gadget_id"] = gid,
["change_type"] = 1,
["percentage_stage"] = 4
}
LF_Mark_Lua_Action(context,param_table)
if LF_Is_Part_All_Dead(context) then
LF_Finish_Play(context,false)
end
return 0
end
if evt.param1 == raft.part_4 then
LF_Set_Raft_Part_Alive(context,4,0)
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Raft_Protection",1)
--分块死亡事件打点
local gid = LF_Get_Gadget_Id_By_Config_Id(evt.param1)
local param_table =
{
["gadget_id"] = gid,
["change_type"] = 1,
["percentage_stage"] = 4
}
LF_Mark_Lua_Action(context,param_table)
if LF_Is_Part_All_Dead(context) then
LF_Finish_Play(context,false)
end
return 0
end
--处理吃零件球和燃料球
local index = LF_Get_Pool_Index(context,evt.param1)
if index == 1 then
LF_Change_Part_Num(context,part.part_ball)
return 0
end
if index == 2 then
LF_Change_Fuel_Num(context,fuel.fuel_ball)
return 0
end
--处理吃金币
local cid = evt.param1
local gid = gadget_config_id_map[cid]
if (gid == local_defs.coin_id) then
ScriptLib.ChangeGroupVariableValue(context,"coin_num",1)
LF_Gallery_Update(context,"COIN")
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Raft_TeamCoin",1)
return 0
end
return 0
end
--木筏到达检查点
function action_platform_arrival(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] action_platform_reach_point: 木筏到达检查点"..evt.param3)
--记录最近一次收到的路点事件下次StopMove时如果发现所在路点漏发了事件需要补做相关逻辑
ScriptLib.SetGroupVariableValue(context,"last_route_point",evt.param3)
--这里客户端要求传过去的点id是连续的所有得自己记一个当前的id
local checkpoint_index = ScriptLib.GetGroupVariableValue(context,"checkpoint_index")
LF_Gallery_Update(context,"REACH_POINT",{point_id = checkpoint_index})
ScriptLib.ChangeGroupVariableValue(context,"checkpoint_index",1)
if LF_Is_Checkpoint(evt.param3) then
--当前阶段障碍物是否活着?活着停船,否则重新开船
if LF_Is_Current_Obstacle_Alive(context) then
ScriptLib.SetGroupVariableValue(context,"has_stopped_by_road_block",1)
LF_Try_Stop_Raft(context)
end
LF_Goto_Next_Stage(context)
end
return 0
end
--时间轴触发
--船处于运行状态时,每秒扣除能量
function action_time_axis_pass(context,evt)
--每秒tick如果当前处于运行状态则扣除一定量的燃料
if (evt.source_name == "ENERGY_TICK_AXIS") then
local energy_pool = ScriptLib.GetGroupVariableValue(context,"engine_energy_pool")
if LF_Is_Running(context) then
local energy_delta = energy_pool + (-energy.energy_consume_by_tick)
if energy_delta ~= 0 then
LF_Change_Engine_Energy(context,energy_delta)
end
ScriptLib.SetGroupVariableValue(context,"engine_energy_pool",0)
else
if energy_pool ~= 0 then
LF_Change_Engine_Energy(context,energy_pool)
end
ScriptLib.SetGroupVariableValue(context,"engine_energy_pool",0)
end
end
if evt.source_name == "LOW_HP_REMINDER_INTERVAL" then
ScriptLib.SetGroupVariableValue(context,"can_show_low_hp_reminder",1)
end
return 0
end
function action_specific_gadget_hp_change(context,evt)
if evt.param3 <= 50 then
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] action_specific_gadget_hp_change: 分块血量低于50%弹出reminder"..evt.param3)
LF_Show_Low_Hp_Reminder(context)
end
--处理运营打点
local gid = ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid)
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common]LF_Mark_Lua_Action: 筏子"..gid.."运营打点:----------------------------")
local percentage_stage = {80,50,30,0}
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Mark_Lua_Action: 筏子"..gid.."血量变化前为"..evt.param2)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Mark_Lua_Action: 筏子"..gid.."血量变化后为"..evt.param3)
for i = 1, 4 do
--gadget血量变化事件是每10%血量记一次,所以即可能是上界碰到、也有可能是下界碰到、也有可能是横跨,三种情况都要算
--去掉血量为0的计数放到死亡事件里单独处理
if (LF_Is_In_Range(percentage_stage[i],evt.param2,evt.param3) or percentage_stage[i] == evt.param2 or percentage_stage[i] == evt.param3) and evt.param3 ~= 0 then
local change_type = 0
if (evt.param2 > evt.param3) then
change_type = 1
else
change_type = 2
end
local gid = ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid)
local param_table =
{
["gadget_id"] = gid,
["change_type"] = change_type,
["percentage_stage"] = i
}
LF_Mark_Lua_Action(context,param_table)
break
end
end
return 0
end
--发动机能量变化,处理运营打点需求
function action_engine_energy_change(context,evt)
--处理运营打点
ScriptLib.PrintContextLog(context,"## [SocialActivity_Common]LF_Mark_Lua_Action: 运营打点:----------------------------")
local percentage_stage = {energy.max_energy * 0.8,energy.max_energy * 0.5,energy.max_energy * 0.3,0}
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Mark_Lua_Action: 引擎能量变化前为"..evt.param2)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Mark_Lua_Action: 引擎能量变化后为"..evt.param1)
for i = 1, 4 do
if LF_Is_In_Range(percentage_stage[i],evt.param1,evt.param2) then
local change_type = 0
if (evt.param1 < evt.param2) then
change_type = 1
else
change_type = 2
end
--木筏发动机的gid
local gid = 70380224
local param_table =
{
["gadget_id"] = gid,
["change_type"] = change_type,
["percentage_stage"] = i
}
LF_Mark_Lua_Action(context,param_table)
break
end
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
--木筏挑战的特殊玩法启动逻辑
--加载船的四个分块和发动机
function LF_Special_Play_Init(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Special_Play_Init: 特殊玩法初始化逻辑")
ScriptLib.CreateGadget(context, {config_id = raft.engine})
ScriptLib.CreateGadget(context, {config_id = raft.part_1})
ScriptLib.CreateGadget(context, {config_id = raft.part_2})
ScriptLib.CreateGadget(context, {config_id = raft.part_3})
ScriptLib.CreateGadget(context, {config_id = raft.part_4})
end
--木筏挑战的特殊玩法启动逻辑
--设置木筏的移动点阵、初始化variable
function LF_Special_Play_Start(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Special_Play_Start: 特殊玩法启动逻辑")
--玩法开始时,重置一次对象池
LF_Reset_Gadget_Pool(context)
local PointArray = {}
for i = point_id_array.from, point_id_array.to do
local flag = true
if point_id_array.except ~= nil then
for j = 1, #point_id_array.except do
if point_id_array.except[j] == i then
flag = false
end
end
end
if flag then
table.insert(PointArray,i)
end
end
--做一个保护防止拿到的table为空
if #PointArray == 0 then
ScriptLib.PrintGroupWarning(context,"## [SocialActivity_RaftChallenge]LF_Special_Play_Start生成的点阵为空检查LD点阵配置是否正确")
else
local ret = ScriptLib.SetPlatformPointArray(context,raft.engine, defs.pointarray_route, PointArray, { route_type = 0,turn_mode=false })
end
LF_Gallery_Update(context,"START_PLAY",{})
ScriptLib.SetGroupVariableValue(context,"is_running",1)
ScriptLib.SetGroupVariableValue(context,"engine_energy",energy.init_energy)
ScriptLib.SetGroupVariableValue(context,"fuel_num",fuel.init_fuel)
ScriptLib.SetGroupVariableValue(context,"part_num",part.init_part)
ScriptLib.SetGroupVariableValue(context,"fuel_guarantee_times", 0)
ScriptLib.SetGroupVariableValue(context,"can_show_low_hp_reminder",1)
ScriptLib.SetGroupVariableValue(context,"last_route_point",0)
LF_Gallery_Update(context,"PART_CHANGE",{})
LF_Gallery_Update(context,"FUEL_CHANGE",{})
end
--木筏挑战的特殊阶段转换事件注意取current_stage已经是转阶段后的stage了
function LF_Special_State_Change(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Special_State_Change: 特殊阶段转换逻辑")
ScriptLib.InitTimeAxis(context,"ENERGY_TICK_AXIS",time_axis.energy_tick_axis,true)
if LF_Stage_Has_Tag(context,LF_Get_Current_Stage(context),"Sailing") then
--转到航行阶段以后,要把当前阶段的一些临时变量清回来
ScriptLib.SetGroupVariableValue(context,"current_stage_monster_all_killed",0)
ScriptLib.SetGroupVariableValue(context,"current_stage_obstacled_all_killed",0)
end
--根据LD的需求隔X个stage清理前面所有stage的内容
for i = 1, LF_Get_Current_Stage(context)-local_defs.clear_stage_interval do
LF_Clear_Specific_Stage(context,i)
end
--根据LD的需求隔Y个stage清理前面所有怪物
for i = 1, LF_Get_Current_Stage(context)-local_defs.clear_monster_stage_interval do
LF_Clear_Specific_Stage_Monsters(context,i)
end
end
function LF_Special_Play_Finish(context,is_success)
ScriptLib.EndTimeAxis(context,"ENERGY_TICK_AXIS")
if is_success then
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Raft_Success",1)
end
end
--[[-----------------------------------------------------------------
|| ||
|| 木筏移动平台控制 ||
|| ||
-----------------------------------------------------------------]]--
--尝试启动木筏
function LF_Try_Start_Raft(context)
LF_Try_Set_Stop_Raft_Op_Num(context, -1)
local stop_raft_op_num = ScriptLib.GetGroupVariableValue(context,"stop_raft_op_num")
--停船的操作数小于等于0的情况下才能继续启动船
if (stop_raft_op_num <= 0) then
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Try_Start_Raft: 启动木筏")
--当前移动平台目标直接指向下一个点,防止出现倒着开船的表现
--ScriptLib.SetPlatformRouteIndexToNext(context, raft.engine)
--服务端的目标直接指向了下一个点,要同步发给客户端
--ScriptLib.ChangeGroupVariableValue(context,"checkpoint_index",1)
--local checkpoint_index = ScriptLib.GetGroupVariableValue(context,"checkpoint_index")
--LF_Gallery_Update(context,"REACH_POINT",{point_id = checkpoint_index})
ScriptLib.StartPlatform(context,raft.engine)
ScriptLib.SetGroupVariableValue(context,"is_running",1)
end
end
--尝试暂停木筏
function LF_Try_Stop_Raft(context)
LF_Try_Set_Stop_Raft_Op_Num(context, 1)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Try_Stop_Raft: 暂停木筏")
ScriptLib.StopPlatform(context,raft.engine)
ScriptLib.SetGroupVariableValue(context,"is_running",0)
local current_point = ScriptLib.GetPlatformPointArray(context,raft.engine)[2]
local last_point = ScriptLib.GetGroupVariableValue(context,"last_route_point")
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Try_Stop_Raft: 当前所在路点为"..current_point)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Try_Stop_Raft: 最近获得事件的路点为"..last_point)
if current_point ~= last_point then
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Try_Stop_Raft: 出现路点到达事件丢失的情况,开始做保底")
--给客户端更新路点信息
--这里客户端要求传过去的点id是连续的所有得自己记一个当前的id
local checkpoint_index = ScriptLib.GetGroupVariableValue(context,"checkpoint_index")
LF_Gallery_Update(context,"REACH_POINT",{point_id = checkpoint_index})
ScriptLib.ChangeGroupVariableValue(context,"checkpoint_index",1)
--如果跳过了检查点,那么补一个转阶段事件
if LF_Is_Checkpoint(current_point) then
--当前阶段障碍物是否活着?活着停船,否则重新开船
if LF_Is_Current_Obstacle_Alive(context) then
ScriptLib.SetGroupVariableValue(context,"has_stopped_by_road_block",1)
--这里要补一个增加一次操作数,确保如果同时因为空能量和路点停船,要做两次恢复才能正常开船
LF_Try_Set_Stop_Raft_Op_Num(context, 1)
end
LF_Goto_Next_Stage(context)
end
end
end
function LF_Try_Set_Stop_Raft_Op_Num(context, delta)
local stop_raft_op_num = ScriptLib.GetGroupVariableValue(context,"stop_raft_op_num")
if stop_raft_op_num+delta <=0 then
ScriptLib.SetGroupVariableValue(context,"stop_raft_op_num",0)
else
ScriptLib.ChangeGroupVariableValue(context,"stop_raft_op_num",delta)
end
end
--[[-----------------------------------------------------------------
|| ||
|| 木筏参数控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Heal_Part(context,heal_percentage)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Heal_Part: 尝试给分块回血")
end
--修改发动机的能量值
function LF_Change_Engine_Energy(context,energy_delta)
ScriptLib.ChangeGroupVariableValue(context,"engine_energy",energy_delta)
if ScriptLib.GetGroupVariableValue(context,"engine_energy") > energy.max_energy then
ScriptLib.SetGroupVariableValue(context,"engine_energy", energy.max_energy)
end
if ScriptLib.GetGroupVariableValue(context,"engine_energy") <= 0 then
ScriptLib.SetGroupVariableValue(context,"engine_energy", 0)
end
--把能量写到客户端上面
LF_Set_SGV_To_Raft(context,"SGV_Engine_Energy","engine_energy")
--每次修改能量数后判定如果能量数小于0则暂停木筏大于0则尝试启动木筏
if (not LF_Have_Enough_Engine_Energy(context)) and (ScriptLib.GetGroupVariableValue(context,"has_stopped_by_no_energy") == 0) then
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Change_Engine_Energy: 没有能量了!木筏停止!!!")
ScriptLib.ShowReminder(context,local_defs.no_energy_reminder)
LF_Try_Stop_Raft(context)
ScriptLib.SetGroupVariableValue(context,"has_stopped_by_no_energy",1)
else
--如果曾经因为没有能量停船,恢复一次就够了
if LF_Have_Enough_Engine_Energy(context) and (ScriptLib.GetGroupVariableValue(context,"has_stopped_by_no_energy") == 1) then
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Change_Engine_Energy: 有能量了!木筏尝试开始运行!!!")
LF_Try_Start_Raft(context)
ScriptLib.SetGroupVariableValue(context,"has_stopped_by_no_energy",0)
end
end
end
--修改零件值
function LF_Change_Part_Num(context, part_delta)
ScriptLib.ChangeGroupVariableValue(context,"part_num",part_delta)
if ScriptLib.GetGroupVariableValue(context,"part_num") <= 0 then
ScriptLib.SetGroupVariableValue(context,"part_num", 0)
end
LF_Gallery_Update(context,"PART_CHANGE",{})
end
--修改燃料值
function LF_Change_Fuel_Num(context, fuel_delta)
ScriptLib.ChangeGroupVariableValue(context,"fuel_num",fuel_delta)
if ScriptLib.GetGroupVariableValue(context,"fuel_num") <= 0 then
ScriptLib.SetGroupVariableValue(context,"fuel_num", 0)
LF_On_Fuel_Zero(context)
end
LF_Gallery_Update(context,"FUEL_CHANGE",{})
end
--燃料数量为空时,触发保底机制
function LF_On_Fuel_Zero(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_On_Fuel_Zero: 燃料数为空,触发保底机制")
local guarantee_times = ScriptLib.GetGroupVariableValue(context,"fuel_guarantee_times")
if guarantee_times < local_defs.fuel_guarantee_max_times then
LF_Change_Fuel_Num(context,local_defs.fuel_guarantee_num)
ScriptLib.ChangeGroupVariableValue(context,"fuel_guarantee_times",1)
end
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD操作 ||
|| ||
-----------------------------------------------------------------]]--
--根据当前阶段数找到当前阶段的目标障碍物。没找到返回nil
function LF_Get_Stage_Obstacle(context,id)
if stage[id].obstacle ~= nil then
return stage[id].obstacle
end
return 0
end
function LF_Is_Checkpoint(pointId)
for i = 1, #checkpoint do
if checkpoint[i] == pointId then
return true
end
end
return false
end
function LF_Get_Part_Config_Id_By_Index(index)
if index == 1 then
return raft.part_1
end
if index == 2 then
return raft.part_2
end
if index == 3 then
return raft.part_3
end
if index == 4 then
return raft.part_4
end
return 0
end
--返回木筏是否处于运行状态
function LF_Is_Running(context)
return ScriptLib.GetGroupVariableValue(context,"is_running") == 1
end
function LF_Is_Current_Obstacle_Alive(context)
return ScriptLib.GetGroupVariableValue(context,"current_stage_obstacled_all_killed") == 0
end
--设置第n个分块的存活情况
function LF_Set_Raft_Part_Alive(context,part_id,alive)
local raft_part_alive = ScriptLib.GetGroupVariableValue(context,"raft_part_alive")
local exact_part_alive = LF_Get_N_Digit(context,raft_part_alive,(5-part_id))
if alive == 1 and exact_part_alive == 0 then
raft_part_alive = math.floor(raft_part_alive + 10^(4-part_id))
ScriptLib.SetGroupVariableValue(context,"raft_part_alive",raft_part_alive)
LF_Set_SGV_To_Raft_By_Num(context,"SGV_Part_"..part_id.."_Alive",1)
end
if alive == 0 and exact_part_alive == 1 then
raft_part_alive = math.floor(raft_part_alive - 10^(4-part_id))
ScriptLib.SetGroupVariableValue(context,"raft_part_alive",raft_part_alive)
LF_Set_SGV_To_Raft_By_Num(context,"SGV_Part_"..part_id.."_Alive",0)
end
end
--返回第n个分块的存活情况
function LF_Get_Raft_Part_Alive(context,part_id)
local raft_part_alive = ScriptLib.GetGroupVariableValue(context,"raft_part_alive")
local exact_part_alive = LF_Get_N_Digit(context,raft_part_alive,(5-part_id))
return exact_part_alive == 1
end
function LF_Is_Part_All_Dead(context)
return ScriptLib.GetGroupVariableValue(context,"raft_part_alive") == 0
end
function LF_Is_Part_Hp_Full(context,part_index)
local part_config_id = LF_Get_Part_Config_Id_By_Index(part_index)
if part_config_id == 0 then
return false
end
local hp_percent = ScriptLib.GetGadgetHpPercent(context, base_info.group_id, part_config_id)
return hp_percent >= 100
end
function LF_Is_Engine_Energy_Full(context)
return ScriptLib.GetGroupVariableValue(context,"engine_energy") >= energy.max_energy
end
--是否有足够的能量
function LF_Have_Enough_Engine_Energy(context)
return ScriptLib.GetGroupVariableValue(context,"engine_energy") > 0
end
--是否有足够的零件
function LF_Have_Enough_Part(context)
return ScriptLib.GetGroupVariableValue(context,"part_num") > 0
end
--是否有足够的燃料
function LF_Have_Enough_Fuel(context)
return ScriptLib.GetGroupVariableValue(context,"fuel_num") > 0
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
--给team上写SGV
function LF_Set_SGV_To_All_Team(context, gv_name, group_variable)
local uid_list = ScriptLib.GetSceneUidList(context)
local value = ScriptLib.GetGroupVariableValue(context,group_variable)
for i = 1, #uid_list do
ScriptLib.SetTeamServerGlobalValue(context, uid_list[i], gv_name, value)
end
end
--给船上面写SGV
function LF_Set_SGV_To_Raft(context,gv_name, group_variable)
local value = ScriptLib.GetGroupVariableValue(context,group_variable)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, raft.engine, gv_name, value)
end
function LF_Set_SGV_To_Raft_By_Num(context,gv_name,num)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, raft.engine, gv_name, num)
end
function LF_Show_Low_Hp_Reminder(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] action_specific_gadget_hp_change: 血量低于50%")
if ScriptLib.GetGroupVariableValue(context,"can_show_low_hp_reminder") == 1 then
ScriptLib.ShowReminder(context,local_defs.low_hp_reminder)
ScriptLib.SetGroupVariableValue(context,"can_show_low_hp_reminder",0)
ScriptLib.InitTimeAxis(context,"LOW_HP_REMINDER_INTERVAL",time_axis.low_hp_reminder_interval,false)
end
end
--获取一个数字的第N位
function LF_Get_N_Digit(context,number,N)
return math.floor((number%(10^N))/(10^(N-1)))
end
--[[-----------------------------------------------------------------
|| ||
|| gallery同步 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Gallery_Update(context,command,param)
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] LF_Gallery_Update: 向gallery同步")
if command == "START_PLAY" then
local raft_entity_id = ScriptLib.GetEntityIdByConfigId(context, raft.engine)
local param_table = {["raft_entity_id"] = raft_entity_id }
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
if command == "REACH_POINT" then
local param_table = {["point_id"] = param.point_id }
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
if command == "FUEL_CHANGE" then
local fuel = ScriptLib.GetGroupVariableValue(context,"fuel_num")
local param_table = {["fuel"] = fuel}
--LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
if command == "PART_CHANGE" then
local part = ScriptLib.GetGroupVariableValue(context,"part_num")
local param_table = {["part"] = part}
--LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
if command == "COIN" then
local coin = ScriptLib.GetGroupVariableValue(context,"coin_num")
local param_table = {["coin"] = coin}
--LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
end
function LF_Print_Table(context,print_table)
for k,v in pairs(print_table) do
ScriptLib.PrintContextLog(context,"## [SocialActivity_RaftChallenge] "..k.." : "..v)
end
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
--引擎请求回血
function SLC_Try_Recover_Engine(context,avatar_num)
--校验合法性
if avatar_num == nil then
return 0
end
if avatar_num <= 0 or avatar_num > 4 then
return 0
end
if ScriptLib.IsGalleryStart(context,defs.gallery_id) then
--有燃料,且燃料没满:恢复能量,并将发动机切到能量恢复状态
if LF_Have_Enough_Fuel(context) and not LF_Is_Engine_Energy_Full(context) then
--当下一次补充会直接补满能量时,按比例进行消耗而不是全部消耗
local current_energy = ScriptLib.GetGroupVariableValue(context,"engine_energy")
local max_energy = energy.max_energy
local consumed_energy = max_energy - current_energy
local ratio = consumed_energy / (energy.energy_heal_by_tick * avatar_num)
if ratio > 1 then
ratio = 1
end
--SLC上来的能量先存到池里tick时统一结算
ScriptLib.ChangeGroupVariableValue(context,"engine_energy_pool",energy.energy_heal_by_tick * avatar_num)
LF_Change_Fuel_Num(context,-math.ceil(fuel.fuel_consume_by_tick * avatar_num * ratio))
ScriptLib.SetGroupGadgetStateByConfigId(context,0,raft.engine,201)
else
ScriptLib.SetGroupGadgetStateByConfigId(context,0,raft.engine,0)
end
end
return 0
end
--分块请求自身被受击
function SLC_Try_Hit_Engine(context)
if ScriptLib.IsGalleryStart(context,defs.gallery_id) then
LF_Change_Engine_Energy(context,-energy.energy_consume_by_hit)
end
return 0
end
--分块请求自身被受击,云网的攻击,要走一个特殊的伤害值
function SLC_Try_Hit_Engine_By_Cloud_Net(context)
if ScriptLib.IsGalleryStart(context,defs.gallery_id) then
LF_Change_Engine_Energy(context,-energy.energy_consume_by_cloud_net_hit)
end
return 0
end
--分块请求回血
function SLC_Try_Recover_Part_Hp(context,part_id,avatar_num)
--校验合法性
if avatar_num == nil or part_id == nil then
return 0
end
if avatar_num <= 0 and avatar_num > 4 then
return 0
end
if part_id <= 0 and part_id > 4 then
return 0
end
if ScriptLib.IsGalleryStart(context,defs.gallery_id) then
local part_config_id = LF_Get_Part_Config_Id_By_Index(part_id)
if part_config_id == 0 then
return 0
end
if LF_Have_Enough_Part(context) and not LF_Is_Part_Hp_Full(context,part_id) then
--当下一次补充会直接补满血量时,按比例进行消耗而不是全部消耗
local hp_percent = ScriptLib.GetGadgetHpPercent(context, base_info.group_id, part_config_id)
local max_hp_percent = 100
local consumed_hp = max_hp_percent - hp_percent
local ratio = consumed_hp / (part.hp_recover_by_tick * avatar_num)
if ratio > 1 then
ratio = 1
end
ScriptLib.SetGadgetHp(context,base_info.group_id, part_config_id,hp_percent+part.hp_recover_by_tick*avatar_num)
LF_Change_Part_Num(context,-math.ceil(part.part_consume_by_tick * avatar_num * ratio))
hp_percent = ScriptLib.GetGadgetHpPercent(context, base_info.group_id, part_config_id)
ScriptLib.SetGroupGadgetStateByConfigId(context,0,part_config_id,201)
else
ScriptLib.SetGroupGadgetStateByConfigId(context,0,part_config_id,0)
end
end
return 0
end
--陈列室SLC
--陈列室木筏累积拾取修复buff数
function SLC_Exhibition_Pick_Up_Ball(context)
LF_Update_Exhibition(context,context.uid,"Activity_IslandParty_Raft_Buff",1)
return 0
end
--陈列室:木筏拾取金币数个人
function SLC_Exhibition_Pick_Up_Coin(context)
LF_Update_Exhibition(context,context.uid,"Activity_IslandParty_Raft_PersonalCoin",1)
return 0
end
--陈列室:木筏累积修复秒数
function SLC_Exhibition_Repair_Time(context,part_id)
--校验合法性
if part_id == nil then
return 0
end
if part_id < 0 and part_id > 4 then
return 0
end
--引擎修复的计数
if part_id == 0 then
if not LF_Is_Engine_Energy_Full(context) and LF_Have_Enough_Fuel(context) then
LF_Update_Exhibition(context,context.uid,"Activity_IslandParty_Raft_Fix",1)
return 0
end
end
local part_config_id = LF_Get_Part_Config_Id_By_Index(part_id)
if part_config_id == 0 then
return 0
end
--必须要真的能回复分块血量才计入统计
local hp_percent = ScriptLib.GetGadgetHpPercent(context, base_info.group_id, part_config_id)
if hp_percent < 100 and LF_Have_Enough_Part(context) then
LF_Update_Exhibition(context,context.uid,"Activity_IslandParty_Raft_Fix",1)
end
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,377 @@
--[[======================================
|| filename: SocialActivity_SailChallenge
|| owner: luyao.huang
|| description: 2.8社交活动-开船停车
|| LogName: SocialActivity_SailChallenge
|| Protection:
=======================================]]--
------
local local_defs =
{
--激流纹章
coin_id = 70380235,
boat_id = 45001001,
--间隔几个stage将之前的stage清空
clear_stage_interval = 3,
clear_berth_reminder = 400164
}
local stage_target_reminder =
{
400159,400160,400161
}
local gadget_config_id_map = {}
local Tri = {
[1] = { name = "monster_die_before_leave_scene", config_id = 9000001, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[2] = { name = "gadget_state_change", config_id = 9000002, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
[3] = { name = "any_gadget_die", config_id = 9000003, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0},
[4] = { name = "enter_region", config_id = 9000004, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false},
[5] = { name = "player_back_gallery_revive_point", config_id = 9000005, event = EventType.EVENT_PLAYER_BACK_GALLERY_REVIVE_POINT, source = "", condition = "", action = "action_player_back_gallery_revive_point", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for i = 1, #gadgets do
gadget_config_id_map[gadgets[i].config_id] = gadgets[i].gadget_id
end
for k,v in pairs(stage_berth_windzone) do
table.insert(variables,{config_id = 60000000+k, name = "stage_berth_"..tostring(k).."_active_num", value = 0})
end
table.insert(variables,{config_id = 60000100, name = "current_stage_die_monster_num", value = 0})
table.insert(variables,{config_id = 60000101, name = "coin_num", value = 0})
table.insert(variables,{config_id = 60000102, name = "reminder_index", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--怪物死亡时,如果当前阶段所有怪死亡,进入下一阶段
function action_monster_die_before_leave_scene(context,evt)
--当前阶段怪物死亡计数
ScriptLib.ChangeGroupVariableValue(context,"current_stage_die_monster_num",1)
LF_Gallery_Update(context,"MONSTER_DIE")
--先看看chain上有没有需要加载的下一位的suite。如果有直接加载不考虑进入下一个stage
local monster_suite_id = LF_Get_Suite_By_Config_Id(evt.param1,false)
if LF_Try_Create_Next_Chain_Suite(context,monster_suite_id) then
return 0
end
--如果chain上没有要加载的下一个suite则看是否可以进入下一个stage
if LF_Is_Monster_In_List_All_Killed(context,LF_Get_Stage_Monsters(context,LF_Get_Current_Stage(context))) then
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] action_any_monster_die: 怪物全部死完")
if LF_Stage_Has_Tag(context,LF_Get_Current_Stage(context),"Battle") then
LF_Goto_Next_Stage(context)
end
end
return 0
end
--停船圈状态改变时,如果当前阶段所有停船圈都已经激活,则创生风场
function action_gadget_state_change(context,evt)
local config_id = evt.param2
if (evt.param1 == 201) then
local berth_stage = LF_Get_Stage_By_Config_Id(config_id, true)
if berth_stage ~= 0 then
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] action_gadget_state_change: 物件状态改变,阶段为"..berth_stage)
ScriptLib.ChangeGroupVariableValue(context,"stage_berth_"..tostring(berth_stage).."_active_num",1)
local active_num = ScriptLib.GetGroupVariableValue(context,"stage_berth_"..tostring(berth_stage).."_active_num")
if stage_berth_windzone[berth_stage]~= nil then
if (active_num >= stage_berth_windzone[berth_stage].berth_num) then
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] action_gadget_state_change: 阶段"..berth_stage.."停车圈全部触发,创生风场")
for i = 1, #stage_berth_windzone[berth_stage].windzone do
ScriptLib.CreateGadget(context,{config_id = stage_berth_windzone[berth_stage].windzone[i]})
end
for j = 1, #stage_berth_windzone[berth_stage].berth do
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] action_gadget_state_change: 设置gadgetstate"..stage_berth_windzone[berth_stage].berth[j])
ScriptLib.SetGadgetStateByConfigId(context,stage_berth_windzone[berth_stage].berth[j],202)
end
end
end
end
end
return 0
end
--吃掉金币触发
function action_any_gadget_die(context,evt)
local cid = evt.param1
local gid = gadget_config_id_map[cid]
if (gid == local_defs.coin_id) then
ScriptLib.ChangeGroupVariableValue(context,"coin_num",1)
LF_Gallery_Update(context,"COIN")
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Sail_TeamCoin",1)
end
return 0
end
--进入每个区域前的region触发加载怪物
function action_enter_region(context,evt)
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] action_enter_region: 进入region")
if evt.param1 == LF_Get_Stage_Region(LF_Get_Current_Stage(context)) then
if LF_Stage_Has_Tag(context,LF_Get_Current_Stage(context),"Sail") then
LF_Goto_Next_Stage(context)
end
end
return 0
end
--玩家主动传送到复活点后,给玩家造一艘船
function action_player_back_gallery_revive_point(context,evt)
LF_Create_Boat(context,evt.param1,LF_Get_Stage_Boat_Point(LF_Get_Current_Stage(context)))
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Special_Play_Init(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] LF_Special_Play_Init: 特殊玩法初始化逻辑")
end
--特殊玩法启动逻辑
function LF_Special_Play_Start(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] LF_Special_Play_Start: 特殊玩法启动逻辑")
--初始化时,清一下怪物死亡计数
ScriptLib.SetGroupVariableValue(context,"current_stage_die_monster_num",0)
ScriptLib.SetGroupVariableValue(context,"coin_num",0)
--玩法开始时,给各个玩家造船
local uid_list = ScriptLib.GetGalleryUidList(context,defs.gallery_id)
if start_boat_points ~= nil then
for i = 1, #uid_list do
if start_boat_points[i] ~= nil then
LF_Create_Boat(context,uid_list[i],start_boat_points[i])
end
end
end
LF_Gallery_Update(context,"START_PLAY")
end
--特殊阶段转换事件
function LF_Special_State_Change(context)
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] LF_Special_State_Change: 特殊阶段转换逻辑")
if LF_Stage_Has_Tag(context,LF_Get_Current_Stage(context),"Sail") then
--转阶段时,清一下上阶段的怪物死亡计数
ScriptLib.SetGroupVariableValue(context,"current_stage_die_monster_num",0)
LF_Gallery_Update(context,"CHANGE_TO_SAIL")
--显示每个航行阶段的目标提示文字
ScriptLib.ChangeGroupVariableValue(context,"reminder_index",1)
local reminder_index = ScriptLib.GetGroupVariableValue(context,"reminder_index")
if stage_target_reminder[reminder_index]~=nil then
ScriptLib.ShowReminder(context,stage_target_reminder[reminder_index])
end
end
if LF_Stage_Has_Tag(context,LF_Get_Current_Stage(context),"Battle") then
ScriptLib.ShowReminder(context,local_defs.clear_berth_reminder)
LF_Gallery_Update(context,"CHANGE_TO_BATTLE")
end
--根据LD的需求隔X个stage清理前面所有stage的内容
for i = 1, LF_Get_Current_Stage(context)-local_defs.clear_stage_interval do
LF_Clear_Specific_Stage(context,i)
end
end
--特殊玩法结算逻辑
function LF_Special_Play_Finish(context,is_success)
if is_success then
LF_Update_Exhibition(context,-2,"Activity_IslandParty_Sail_Success",1)
end
end
--检查是否已经满足当前阶段的转换条件
function LF_Has_Satisfy_Current_Stage_Condition(context)
return true
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Get_Stage_Region(current_stage)
if stage[current_stage] ~= nil then
return stage[current_stage].region
else
return nil
end
end
--返回当前阶段复活点旁边的船点
function LF_Get_Stage_Boat_Point(current_stage)
if stage[current_stage].boat_point ~= nil then
return stage[current_stage].boat_point
else
return nil
end
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项功能 ||
|| ||
-----------------------------------------------------------------]]--
--在指定的point位置给指定的uid造一艘船
function LF_Create_Boat(context,uid,point_id)
if point_id == nil then
ScriptLib.PrintGroupWarning(context,"## [SocialActivity_SailChallenge]LF_Create_Boat取到的造船点为空")
return
end
local boat_point = {}
for i = 1, #points do
if points[i].config_id == point_id then
boat_point = points[i]
break
end
end
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] LF_Create_Boat: 在点位"..point_id.."建船")
local ret = ScriptLib.CreateVehicle(context, uid, local_defs.boat_id, {x=boat_point.pos.x,y=boat_point.pos.y,z=boat_point.pos.z},{x=boat_point.rot.x,y=boat_point.rot.y,z=boat_point.rot.z})
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] LF_Create_Boat:建船的结果为 "..ret)
end
--[[-----------------------------------------------------------------
|| ||
|| gallery同步 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Gallery_Update(context,command)
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] LF_Gallery_Update: 向gallery同步")
if command == "START_PLAY" then
local camp_num = 0
for i = 1, #stage do
if stage[i].tag == "Battle" then
camp_num = camp_num + 1
end
end
local param_table = {["sail_stage"] = 1, ["progress"] = 0, ["max_progress"] = camp_num}
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
if command == "CHANGE_TO_SAIL" then
local camp_num = 0
for i = 1, LF_Get_Current_Stage(context) do
if stage[i].tag == "Battle" then
camp_num = camp_num + 1
end
end
local param_table = {["sail_stage"] = 1, ["progress"] = camp_num }
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
if command == "CHANGE_TO_BATTLE" then
local monster_num = 0
for i = 1, #LF_Get_Stage_Monster_Suites(context,LF_Get_Current_Stage(context)) do
monster_num = monster_num + #suites[LF_Get_Stage_Monster_Suites(context,LF_Get_Current_Stage(context))[i]].monsters
end
local param_table = {["sail_stage"] = 2, ["kill_monster_count"] = 0, ["max_monster_count"] = monster_num}
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id,param_table)
end
if command == "MONSTER_DIE" then
local current_stage_die_monster_num = ScriptLib.GetGroupVariableValue(context,"current_stage_die_monster_num")
local param_table = {["kill_monster_count"] = current_stage_die_monster_num}
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
if command == "COIN" then
local coin = ScriptLib.GetGroupVariableValue(context,"coin_num")
local param_table = {["coin"] = coin}
LF_Print_Table(context,param_table)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, param_table)
end
end
function LF_Print_Table(context,print_table)
for k,v in pairs(print_table) do
ScriptLib.PrintContextLog(context,"## [SocialActivity_SailChallenge] "..k.." : "..v)
end
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
--陈列室SLC
--陈列室:开船停车到指定区域数
function SLC_Exhibition_Enter_Berth(context)
LF_Update_Exhibition(context,context.uid,"Activity_IslandParty_Sail_ArriveArea",1)
return 0
end
--陈列室:开船停车拾取金币数个人
function SLC_Exhibition_Pick_Up_Coin(context)
LF_Update_Exhibition(context,context.uid,"Activity_IslandParty_Sail_PersonalCoin",1)
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,151 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: StarShooter
|| owner: weiwei.sun
|| description: 2.8莫娜梦境地城 弹幕控制
|| LogName: CloudNet
|| Protection:
=======================================]]--
--[[defs = {
queue = {
[1] = { config_id = 4012, bullet_type = 2, duration = 0, shoot_time = 25, shoot_interval = 1, point_array = 3, point_id = {1,2},turn_mode = true,route_type = 1},
},
hit_max = 1,
}]]
local extraTriggers={
{ config_id = 8000001, name = "TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000002, name = "Variable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "star_shooter", condition = "", action = "action_Variable_Change", trigger_count = 0 },
{ config_id = 8000003, name = "PlayerHit_Variable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "player_hit", condition = "", action = "", tag = "777",trigger_count = 0},
{ config_id = 8000004, name = "Group_Will_Unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_Group_Will_Unload", trigger_count = 0 },
{ config_id = 8000005, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000006, name = "Challenge_Fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_Challenge_Fail", trigger_count = 0 },
{ config_id = 8000007, name = "Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_Challenge_Success", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[1].triggers,extraTriggers[i].name)
end
--启动 关闭,外部控制
table.insert(variables, { config_id = 50000001, name = "star_shooter", value = 0})
--挑战计数项
table.insert(variables, { config_id = 50000002, name = "player_hit", value = 0})
end
function action_Group_Load(context, evt)
ScriptLib.SetGroupTempValue(context, "action_index", 0, {})
return 0
end
function action_Group_Will_Unload(context, evt)
ScriptLib.SetGroupVariableValue(context, "star_shooter", 0)
return 0
end
function action_Variable_Change(context, evt)
--在关闭状态下,被通知开启
if 1 == evt.param1 and 0 == evt.param2 then
ScriptLib.SetGroupTempValue(context, "action_index", 0, {})
LF_SequenceAction(context)
end
return 0
end
function action_TimeAxis_Pass(context, evt)
LF_SequenceAction(context)
return 0
end
function LF_SequenceAction(context)
ScriptLib.ChangeGroupTempValue(context, "action_index", 1, {})
local cur_index = ScriptLib.GetGroupTempValue(context, "action_index", {})
if #defs.queue < cur_index then
ScriptLib.SetGroupVariableValue(context, "star_shooter", 0)
return 0
end
local step = defs.queue[cur_index]
ScriptLib.PrintContextLog(context, "## [StartShooter] Sequence actions Set. Step_index@"..cur_index.." cfg_id@"..step.config_id)
--处理SGV
if nil ~= step.shoot_interval and nil ~= step.shoot_time then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, step.config_id, "SGV_Shoot_Interval", step.shoot_interval)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, step.config_id, "SGV_Shoot_Time", step.shoot_time)
end
--处理GadgetState
if nil ~= step.bullet_type then
ScriptLib.PrintContextLog(context, "## [StartShooter] LF_SequenceAction: Try Set GadgetState. ConfigId@"..step.config_id.." bullet_type@"..step.bullet_type)
--1-单个(201)
if 1 == step.bullet_type then
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 201)
--2-五个散射(203)
elseif 2 == step.bullet_type then
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 203)
--3-五个一排(204)
elseif 3 == step.bullet_type then
ScriptLib.SetGadgetStateByConfigId(context, step.config_id, 204)
end
end
--处理移动
if 0 ~= step.point_array then
ScriptLib.SetPlatformPointArray(context, step.config_id, step.point_array, step.point_id, {route_type = step.route_type, turn_mode = step.turn_mode, record_mode = 0})
end
--这一步是否是一个瞬时动作
if 0 ~= step.duration then
ScriptLib.InitTimeAxis(context, "duration"..cur_index, { math.floor(step.duration) }, false)
ScriptLib.PrintContextLog(context, "## [StartShooter] Actions has duration. duration@".. math.floor(step.duration))
--不用等的话直接走下一步
else
LF_SequenceAction(context)
end
return 0
end
function action_Challenge_Fail(context, evt)
local cur_index = ScriptLib.GetGroupTempValue(context, "action_index", {})
ScriptLib.EndTimeAxis(context, "duration"..cur_index)
ScriptLib.SetGroupVariableValue(context, "player_hit", 0)
return 0
end
function action_Challenge_Success(context, evt)
if 1 == ScriptLib.GetGroupVariableValue(context, "star_shooter") then
ScriptLib.SetGroupVariableValue(context, "star_shooter", 0)
ScriptLib.SetGroupVariableValue(context, "player_hit", 0)
end
return 0
end
function SLC_StarShooter_PlayerHit(context)
ScriptLib.ChangeGroupVariableValue(context,"player_hit", 1)
return 0
end
function SLC_StarShooter_TryStartChallenge(context)
if ScriptLib.GetHostQuestState(context,4007410)==2 then
ScriptLib.AddExtraGroupSuite(context, 220136004, 3)
ScriptLib.CreateFatherChallenge(context, 260, 262, 61, {success = 1, fail = 1, fail_on_wipe = true})
ScriptLib.StartFatherChallenge(context, 260)
ScriptLib.AttachChildChallenge(context, 260, 262, 260,{3, 777, 30, 0, 0},{},{success=1, fail=1})
ScriptLib.AttachChildChallenge(context, 260, 261, 261,{60, 0},{},{success=1, fail=1})
ScriptLib.SetGroupVariableValue(context, "star_shooter", 1)
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,122 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: TimeReverser
|| owner: weiwei.sun
|| description: 2.8莫娜梦境 时间回溯
|| LogName: TimeReverser
|| Protection:
=======================================]]--
--[[
local defs = {
reverse_time = 10,--回溯倒计时,整数秒
}
]]
local extraTriggers={
{ config_id = 8000001, name = "TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "reverse", condition = "", action = "action_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000002, name = "Gadget_State_Change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Gadget_State_Change", trigger_count = 0 },
{ config_id = 8000003, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000004, name = "Revert_VariableChange", event = EventType.EVENT_VARIABLE_CHANGE, source = "revert", condition = "", action = "action_Revert_VariableChange", trigger_count = 0 },
{ config_id = 8000005, name = "Device_Gadget_State_Change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Device_Gadget_State_Change", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--外部手动触发回溯
table.insert(variables,{ config_id = 50000001, name = "revert", value = 0, no_refresh = true })
--是否正处于待回溯状态
table.insert(variables,{ config_id = 50000002, name = "is_reverting", value = 0, no_refresh = true })
end
function action_Group_Load(context, evt)
if 1 == ScriptLib.GetGroupVariableValue(context, "is_reverting") then
for k, v in pairs(gadgets) do
if nil ~= v.mark_flag then
ScriptLib.SetGadgetStateByConfigId(context, v.config_id, 0)
end
end
end
ScriptLib.SetGroupVariableValue(context, "revert", 0)
ScriptLib.SetGroupVariableValue(context, "is_reverting", 0)
return 0
end
function action_Device_Gadget_State_Change(context, evt)
local gadget_id = ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid)
if 70310390 ~= gadget_id then
return 0
end
if 0 ~= evt.param1 then
return 0
end
ScriptLib.SetGroupVariableValue(context, "is_reverting", 0)
return 0
end
function action_Gadget_State_Change(context, evt)
if nil == gadgets[evt.param2] then
ScriptLib.PrintContextLog(context, "## [TimeReverser] Gadget_State_Change get unknown param2.")
return 0
end
if nil == gadgets[evt.param2].mark_flag then
return 0
end
if 201 ~= evt.param1 then
return 0
end
--检查是否处于待回溯状态若不处于则尝试init回溯时间轴
if 1 ~= ScriptLib.GetGroupVariableValue(context, "is_reverting") then
LF_TryInitReverseTimeAxis(context)
end
return 0
end
function action_TimeAxis_Pass(context, evt)
for k, v in pairs(gadgets) do
if nil ~= v.mark_flag then
ScriptLib.SetGadgetStateByConfigId(context, v.config_id, 0)
end
--其中回溯机关 做回溯表现
if 70310390 == v.gadget_id then
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {v.config_id}, "GV_TimeReverse", 1)
end
end
ScriptLib.SetGroupVariableValue(context, "is_reverting", 0)
return 0
end
function action_Revert_VariableChange(context, evt)
if 1 == evt.param1 and 0 == evt.param2 then
ScriptLib.PrintContextLog(context, "## [TimeReverser] Revert_VariableChange.")
ScriptLib.SetGroupVariableValue(context, "revert", 0)
--检查是否处于待回溯状态若不处于则尝试init回溯时间轴
if 1 ~= ScriptLib.GetGroupVariableValue(context, "is_reverting") then
LF_TryInitReverseTimeAxis(context)
end
end
return 0
end
function LF_TryInitReverseTimeAxis(context)
local state = -1
--根据GadgetState判断是否要准备回溯
for k, v in pairs(gadgets) do
if 70310390 == v.gadget_id then
state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, v.config_id)
ScriptLib.PrintContextLog(context, "## [TimeReverser] LF_TryInitReverseTimeAxis. Operator gadget state@"..state)
break
end
end
--如果state为0 时间回溯不生效
if 0 == state then
ScriptLib.SetGroupVariableValue(context, "is_reverting", 0)
return 0
else
ScriptLib.InitTimeAxis(context, "reverse", {defs.reverse_time}, false)
ScriptLib.SetGroupVariableValue(context, "is_reverting", 1)
ScriptLib.PrintContextLog(context, "## [TimeReverser] LF_TryInitReverseTimeAxis. InitTimeAxis.")
return 0
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,207 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_8] ---
--[[======================================
|| filename: TransferFlower
|| owner: weiwei.sun
|| description: 辛焱岛 传音炮逻辑
|| LogName: ## [TransferFlower]
|| Protection:
=======================================]]
--[[
有左右摆头4档可调和上下俯仰5档可调两种传音花
关卡中并不是所有档位都要切这个re。quire让LD可以配置每个花用到哪些档
可操作调整的传音花需要配置操作台选项, 左右转和上下转的SelectOption不同
导出GroupLua需要勾选可索引
local defs = {
--左右旋转的SelectOptionID
selectID_horizon = ,
--上下俯仰的SelectOptionID
selectID_vertical = ,
--定义左右旋转的步长,key为传音花configIDvalue为GadgetState
horizon_steps = {
[传音花configID1] = {0, 102, 103, 104},
},
--定义上下俯仰的步长,key为传音花configIDvalue为GadgetState
vertical_steps = {
[传音花configID1] = {0, 302, 303, 304, 305},
}
}
]]
local extraTriggers={
{ config_id = 8000001, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Select_Option", trigger_count = 0 },
{ config_id = 8000002, name = "BigFlower_Var_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "big_flower", condition = "", action = "action_BigFlower_Var_Change", trigger_count = 0 },
{ config_id = 8000003, name = "Group_Init", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Init", trigger_count = 1 },
{ config_id = 8000004, name = "Enter_Guide_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Guide_Region", trigger_count = 0 },
{ config_id = 8000005, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 }
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--大传音花开闭
table.insert(variables, { config_id = 50000001, name = "big_flower", value = 0})
end
--玩家操作传音花
function action_Select_Option(context, evt)
if evt.param2 == defs.selectID_horizon then
LF_TurnByStep(context, evt.param1, defs.horizon_steps)
return 0
elseif evt.param2 == defs.selectID_vertical then
LF_TurnByStep(context, evt.param1, defs.vertical_steps)
return 0
end
return 0
end
--玩家操作传音花SLC
function SLC_TransferFlower_Turn(context)
local cfg_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
for k,v in pairs(defs.horizon_steps) do
if k == cfg_id then
LF_TurnByStepSLC(context, cfg_id, v)
return 0
end
end
for k,v in pairs(defs.vertical_steps) do
if k == cfg_id then
LF_TurnByStepSLC(context, cfg_id, v)
return 0
end
end
return 0
end
function action_Enter_Guide_Region(context, evt)
if evt.param1 ~= defs.guide_region then
return 0
end
LF_TryShowGuide(context)
return 0
end
function action_Group_Init(context, evt)
LF_InitRotation(context)
return 0
end
function action_Group_Load(context, evt)
ScriptLib.SetGroupVariableValue(context, "big_flower", 0)
return 0
end
function LF_InitRotation(context)
if nil == defs.init_state then
return 0
end
for k,v in pairs(defs.init_state) do
ScriptLib.SetGadgetStateByConfigId(context, k, v)
end
return 0
end
--根据配置的步长切state(SLC用)
function LF_TurnByStepSLC(context, config_id, step_table)
local current_state = ScriptLib.GetGadgetStateByConfigId(context, 0, config_id)
local current_index = LF_GetIndexInTable(context, current_state, step_table)
if 0 == current_index then
--传音花的state并不在配置table中告警
ScriptLib.PrintContextLog(context, "## [TransferFlower] #WARN# TransferFlower at unexpected state! Check defs. config_id@"..config_id.." current_state@"..current_state)
else
--切到下一个State
if current_index >= #step_table then
ScriptLib.SetGadgetStateByConfigId(context, config_id, step_table[1])
else
ScriptLib.SetGadgetStateByConfigId(context, config_id, step_table[current_index + 1])
end
end
return 0
end
--根据配置的步长切state
function LF_TurnByStep(context, config_id, step_table)
for k,v in pairs(step_table) do
if k == config_id then
local current_state = ScriptLib.GetGadgetStateByConfigId(context, 0, config_id)
local current_index = LF_GetIndexInTable(context, current_state, v)
if 0 == current_index then
--传音花的state并不在配置table中告警
ScriptLib.PrintContextLog(context, "## [TransferFlower] #WARN# TransferFlower at unexpected state! Check defs. config_id@"..config_id.." current_state@"..current_state)
else
--切到下一个State
if current_index >= #v then
ScriptLib.SetGadgetStateByConfigId(context, config_id, v[1])
else
ScriptLib.SetGadgetStateByConfigId(context, config_id, v[current_index + 1])
end
end
return 0
end
--传进来的configID不是配置的传音花告警
ScriptLib.PrintContextLog(context, "## [TransferFlower] #WARN# LF_HorizonalTurnByStep find config_id failed, check defs. config_id@"..config_id)
end
return 0
end
--当大传音花被打时如果变量为0则设为1
function SLC_TransferFlower_BigFlowerHit(context)
--记下本Group内大传音花的configID
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.SetGroupTempValue(context, "big_flower_id", config_id, {})
if 0 == ScriptLib.GetGroupVariableValue(context, "big_flower") then
ScriptLib.SetGroupVariableValue(context, "big_flower", 1)
end
return 0
end
function action_BigFlower_Var_Change(context, evt)
local big_flowerID = ScriptLib.GetGroupTempValue(context, "big_flower_id", {})
if 0 >= big_flowerID then
return 0
end
if 1 == evt.param1 and 0 == evt.param2 then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, big_flowerID, "SGV_BigFlower_On", 1)
elseif 0 == evt.param1 and 1 == evt.param2 then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, big_flowerID, "SGV_BigFlower_On", 0)
end
return 0
end
--用value查key
function LF_GetIndexInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return i
end
end
return 0
end
function LF_TryShowGuide(context)
--在NewActivityPushTipsData配置中查找对应id, 并通过lua添加进活动中
--重复添加已有push tips返回-1 成功添加返回0
local ret = ScriptLib.TryRecordActivityPushTips(context, 2014010)
if 0 == ret then
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.ShowClientTutorial(context, 1181, {uid})
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,618 @@
--[[======================================
|| filename: V2_8ArenaChallenge
|| owner: luyao.huang
|| description: 2.8幻影心流复刻活动
|| LogName: V2_8ArenaChallenge
|| Protection:
=======================================]]--
--计数型挑战
local counting_challenge =
{
[1] = {challenge_id = defs.kill_monster_challenge_id, tag = tostring(defs.kill_monster_challenge_id), var_name = "challenge_kill_monster"},
[2] = {challenge_id = defs.state_change_challenge_id, tag = tostring(defs.state_change_challenge_id), var_name = "challenge_state_change_condition"}
}
------
local local_defs =
{
father_challenge_index = 101,
time_challenge_index = 11,
kill_monster_challenge_index = 13,
state_change_challenge_index = 12,
reminder_id = 400157,
stage_1_weather_id = 1011,
stage_2_weather_id = 1010
}
local time_axis = {
ELITE_INTERVAL_AXIS = {defs.elite_interval},
CHANGE_STAGE_INTERVAL_AXIS = {defs.change_stage_interval},
SECOND_STAGE_ELITE_DELAY_AXIS = {2}
}
local Tri = {
[1] = { name = "group_load", config_id = 10000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "variable_change", config_id = 10000002, event = EventType.EVENT_VARIABLE_CHANGE, source = "state_change_condition_num", condition = "", action = "action_variable_change", trigger_count = 0},
[3] = { name = "time_axis_pass", config_id = 10000003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[4] = { name = "monstert_die_before_leave_scene", config_id = 10000004, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[5] = { name = "challenge_fail", config_id = 10000005, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
[6] = { name = "pool_monster_tide_over", config_id = 10000006, event = EventType.EVENT_POOL_MONSTER_TIDE_OVER, source = "", condition = "", action = "action_pool_monster_tide_over", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(counting_challenge) do
if v.challenge_id ~= nil then
local t = {name = "variable_change_"..v.challenge_id, config_id = 1000000+k, event = EventType.EVENT_VARIABLE_CHANGE,source = v.var_name, condition = "", action = "", trigger_count = 0, tag = v.tag}
table.insert(triggers, t)
table.insert(suites[1].triggers, t.name)
table.insert(variables,{config_id = 30000000+k, name = v.var_name, value = 0})
end
end
--阶段数
table.insert(variables,{config_id = 30000100, name = "current_stage", value = 0})
--小怪潮的index
table.insert(variables,{config_id = 30000101, name = "current_monster_tide", value = 0})
--精英怪的index
table.insert(variables,{config_id = 30000102, name = "current_elite", value = 1})
--小怪潮的计数当计数为0时才能继续怪物潮
table.insert(variables,{config_id = 30000103, name = "tide_op_num", value = 0})
--转阶段条件完成计数
table.insert(variables,{config_id = 30000104, name = "state_change_condition_num", value = 0})
--是否是第一组精英怪
table.insert(variables,{config_id = 30000105, name = "is_first_elite", value = 1})
--阶段1开始时间
table.insert(variables,{config_id = 30000106, name = "stage1_start_time", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_group_load(context,evt)
LF_Init_Play(context)
LF_Start_Play(context)
return 0
end
function action_variable_change(context,evt)
if not LF_Is_Easy_Mode() then
if evt.param1 >= defs.state_change_condition_num and LF_Get_Current_Stage(context) == 0 then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_variable_change: 完成转阶段条件")
LF_Change_To_Second_Stage(context)
end
end
return 0
end
function action_time_axis_pass(context,evt)
--精英怪刷新时间轴
if (evt.source_name == "ELITE_INTERVAL_AXIS") then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_time_axis_pass: 精英怪时间轴tick刷出精英怪")
ScriptLib.PauseTimeAxis(context,"ELITE_INTERVAL_AXIS")
LF_Create_Elite(context)
LF_Goto_Next_Elite_Index(context)
LF_Try_Pause_Monster_Tide(context)
end
--简单模式转阶段时间轴
if (evt.source_name == "CHANGE_STAGE_INTERVAL_AXIS") and LF_Is_Easy_Mode() then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_time_axis_pass: 简单模式转阶段tick转阶段")
ScriptLib.EndTimeAxis(context,"CHANGE_STAGE_INTERVAL_AXIS")
LF_Change_To_Second_Stage(context)
end
if (evt.source_name == "SECOND_STAGE_ELITE_DELAY_AXIS") then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_time_axis_pass: 二阶段的精英怪时间轴延迟")
LF_Start_Elite_Tide(context)
end
return 0
end
function action_monster_die_before_leave_scene(context,evt)
if ScriptLib.IsGalleryStart(context,defs.gallery_id) then
if LF_Is_Elite(evt.param1) then
LF_Trigger_Challenge_Count(context,1)
if LF_Is_Current_Elite_All_Dead(context) then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_monster_die_before_leave_scene: 精英怪死亡,恢复小怪潮")
--这里如果是第一组精英怪死亡则是init一个时间轴而不是continue
if ScriptLib.GetGroupVariableValue(context,"is_first_elite") == 1 then
ScriptLib.InitTimeAxis(context,"ELITE_INTERVAL_AXIS",time_axis.ELITE_INTERVAL_AXIS,true)
ScriptLib.SetGroupVariableValue(context,"is_first_elite",0)
else
ScriptLib.ContinueTimeAxis(context, "ELITE_INTERVAL_AXIS")
end
LF_Try_Continue_Monster_Tide(context)
--如果当前的精英计数已经超过了精英总数(精英怪刷完了),玩法以成功结算
if LF_Get_Current_Elite_Index(context) > #elite_list then
ScriptLib.StopChallenge(context,local_defs.time_challenge_index,1)
ScriptLib.StopChallenge(context,local_defs.kill_monster_challenge_index,1)
local state_change_condition_num = ScriptLib.GetGroupVariableValue(context,"state_change_condition_num")
--结束时如果完成了转阶段的条件挑战,才算成功,否则算失败
if state_change_condition_num >= defs.state_change_condition_num or LF_Is_Easy_Mode() then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_monster_die_before_leave_scene: 完成了条件转换逻辑,成功")
--挑战成功,补一个性能优化恢复的逻辑
LF_Stop_Optimization(context)
LF_Set_Worktop_State(context,true)
LF_Clear_All(context)
ScriptLib.StopChallenge(context,local_defs.father_challenge_index,1)
else
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_monster_die_before_leave_scene: 未完成了条件转换逻辑,失败")
--挑战失败,补一个性能优化恢复的逻辑
LF_Stop_Optimization(context)
LF_Set_Worktop_State(context,true)
LF_Clear_All(context)
ScriptLib.StopChallenge(context,local_defs.father_challenge_index,0)
end
return 0
end
end
end
end
return 0
end
function action_challenge_fail(context,evt)
if evt.param1 == defs.father_challenge_id then
--挑战失败,补一个性能优化恢复的逻辑
LF_Stop_Optimization(context)
LF_Set_Worktop_State(context,true)
LF_Clear_All(context)
end
return 0
end
--如果一阶段怪刷完了,直接失败
function action_pool_monster_tide_over(context,evt)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_pool_monster_tide_over: 小怪潮刷完了当前的index为"..evt.source_eid.."对比记录的index为"..LF_Get_Current_Tide(context))
if LF_Get_Current_Stage(context) == 0 and LF_Get_Current_Tide(context) == 1 then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_pool_monster_tide_over: 小怪潮刷完了,但没有转阶段,直接转阶段")
LF_Change_To_Second_Stage(context)
end
if LF_Get_Current_Stage(context) == 1 and LF_Get_Current_Tide(context) == 2 then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_pool_monster_tide_over: 二阶段小怪潮刷完了,挑战失败,几乎不可能出现这种情况")
--ScriptLib.StopChallenge(context,local_defs.father_challenge_index,0)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
--玩法初始化
function LF_Init_Play(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Init_Play: 玩法初始化")
--LF_Clear_All(context)
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
LF_Init_Variables(context)
end
--玩法启动
function LF_Start_Play(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Start_Play: 玩法启动")
LF_Set_Worktop_State(context,false)
ScriptLib.CreateGadget(context,{config_id = defs.airwall})
ScriptLib.CreateFatherChallenge(context, local_defs.father_challenge_index, defs.father_challenge_id, defs.challenge_time, {success = 5, fail = 10,fail_on_wipe = true})
local uid = ScriptLib.GetSceneOwnerUid(context)
--先开再attach给子挑战保序
ScriptLib.StartFatherChallenge(context,local_defs.father_challenge_index)
ScriptLib.AttachChildChallenge(context,local_defs.father_challenge_index, local_defs.time_challenge_index, defs.time_challenge_id,{3,666,999999},{uid},{success = 0,fail = 0}) --挑战计时
if not LF_Is_Easy_Mode() then
ScriptLib.AttachChildChallenge(context,local_defs.father_challenge_index, local_defs.state_change_challenge_index, defs.state_change_challenge_id,{3,defs.state_change_challenge_id,defs.state_change_condition_num},{uid},{success = 0,fail = 0}) --普通挑战
end
ScriptLib.AttachChildChallenge(context,local_defs.father_challenge_index, local_defs.kill_monster_challenge_index, defs.kill_monster_challenge_id,{3,defs.kill_monster_challenge_id,LF_Get_Elite_Num(context)},{uid},{success = 0,fail = 0}) --触发精英怪死亡计数
LF_Try_Start_Monster_Tide(context,monster_tide_config[1])
if LF_Is_Easy_Mode() then
ScriptLib.InitTimeAxis(context,"CHANGE_STAGE_INTERVAL_AXIS",time_axis.CHANGE_STAGE_INTERVAL_AXIS,false)
end
--在控制group记一下当前激活的玩法group
ScriptLib.SetGroupVariableValueByGroup(context, "active_group", base_info.group_id, defs.control_group_id)
--初始化一下team上的SGV
LF_Set_Team_SGV(context,"SGV_CHANGE_STAGE",0)
--一阶段屏蔽天气,固定为晴天
LF_Set_Weather(context,local_defs.stage_1_weather_id,true)
local stage1_start_time = ScriptLib.GetSceneTimeSeconds(context)
ScriptLib.SetGroupVariableValue(context,"stage1_start_time", stage1_start_time)
end
--转到二阶段
function LF_Change_To_Second_Stage(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Change_To_Second_Stage: 转到二阶段")
local stage1_end_time = ScriptLib.GetSceneTimeSeconds(context)
local stage1_start_time = ScriptLib.GetGroupVariableValue(context,"stage1_start_time")
local stage1_time = stage1_end_time - stage1_start_time
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Change_To_Second_Stage: 运营打点consume_time 参数为"..stage1_time)
ScriptLib.MarkGroupLuaAction(context, "ArenaChallenge","",{["consume_time"]=stage1_time})
LF_Goto_Next_Stage(context)
LF_Stage_Environment_Change(context)
LF_Try_Start_Monster_Tide(context,monster_tide_config[2])
ScriptLib.InitTimeAxis(context,"SECOND_STAGE_ELITE_DELAY_AXIS",time_axis.SECOND_STAGE_ELITE_DELAY_AXIS,false)
LF_Set_Team_SGV(context,"SGV_CHANGE_STAGE",1)
ScriptLib.ShowReminder(context,local_defs.reminder_id)
--关一阶段天气,开启二阶段天气
LF_Set_Weather(context,local_defs.stage_1_weather_id,false)
LF_Set_Weather(context,local_defs.stage_2_weather_id,true)
end
function LF_Stage_Environment_Change(context)
ScriptLib.SetGadgetStateByConfigId(context,defs.airwall,201)
end
--清理玩法
function LF_Clear_All(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Clear_All: 开始清理玩法")
--清理怪物潮
LF_Clear_Current_Monster_Tide(context)
--清理空气墙
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.airwall)
--暂停精英怪
ScriptLib.EndTimeAxis(context,"ELITE_INTERVAL_AXIS")
if LF_Is_Easy_Mode() then
--清理转阶段时间轴
ScriptLib.EndTimeAxis(context,"CHANGE_STAGE_INTERVAL_AXIS")
end
--清理控制group当前记的玩法group值
ScriptLib.SetGroupVariableValueByGroup(context, "active_group", 0, defs.control_group_id)
--恢复天气
LF_Set_Weather(context,local_defs.stage_1_weather_id,false)
LF_Set_Weather(context,local_defs.stage_2_weather_id,false)
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项功能 ||
|| ||
-----------------------------------------------------------------]]--
--所有变量的初始化
function LF_Init_Variables(context)
ScriptLib.SetGroupVariableValue(context,"current_stage",0)
ScriptLib.SetGroupVariableValue(context,"current_monster_tide",0)
ScriptLib.SetGroupVariableValue(context,"current_elite",1)
ScriptLib.SetGroupVariableValue(context,"tide_op_num",0)
ScriptLib.SetGroupVariableValue(context,"state_change_condition_num",0)
ScriptLib.SetGroupVariableValue(context,"is_first_elite",1)
ScriptLib.SetGroupVariableValue(context,"stage1_start_time",0)
end
--设置操作台状态
function LF_Set_Worktop_State(context,enable)
if enable then
ScriptLib.SetGroupGadgetStateByConfigId(context,defs.control_group_id,defs.worktop_id,0)
else
ScriptLib.SetGroupGadgetStateByConfigId(context,defs.control_group_id,defs.worktop_id,201)
end
end
--向team上设置SGV
function LF_Set_Team_SGV(context,SGV_name,value)
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.SetTeamServerGlobalValue(context, uid, SGV_name, value)
end
--触发计数型挑战的触发器
function LF_Trigger_Challenge_Count(context,counting_challenge_id)
ScriptLib.ChangeGroupVariableValue(context,counting_challenge[counting_challenge_id].var_name,1)
end
--转阶段条件完成,修改计数,并同步到客户端显示
function LF_State_Condition_Complete(context,prev_context,param_table)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_State_Condition_Complete: 玩法group收到转阶段条件完成")
ScriptLib.ChangeGroupVariableValue(context,"state_change_condition_num",1)
LF_Trigger_Challenge_Count(context,2)
return 0
end
--是否是简单模式
function LF_Is_Easy_Mode()
return defs.is_easy_mode == 1
end
function LF_Set_Weather(context,weather_id,is_on)
if is_on then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Set_Weather: 打开天气"..weather_id)
ScriptLib.SetWeatherAreaState(context, weather_id, 1)
else
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Set_Weather: 关闭天气"..weather_id)
ScriptLib.SetWeatherAreaState(context, weather_id, 0)
end
end
--玩法结束的时候,要帮性能优化大礼包补一个恢复优化的逻辑,不然优化去不掉了
function LF_Stop_Optimization(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Stop_Optimization: 补一个恢复优化的逻辑")
local uid = ScriptLib.GetSceneOwnerUid(context)
--关闭视野锚点
--ScriptLib.ClearPlayerEyePoint(context, defs.inner_region)
ScriptLib.SetLimitOptimization(context, uid, false)
--环境小动物优化
ScriptLib.SwitchSceneEnvAnimal(context, 2)
--重置visiontype
ScriptLib.SetPlayerGroupVisionType(context, {uid}, {1})
--还原LD配置的visiontype变化
ScriptLib.RevertPlayerRegionVision(context, uid)
end
function LF_Stop_Gallery(context,is_fail)
if ScriptLib.IsGalleryStart(context,defs.gallery_id) then
ScriptLib.StopGallery(context,defs.gallery_id,is_fail)
end
end
--[[-----------------------------------------------------------------
|| ||
|| 精英怪操作 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Start_Elite_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Start_Elite_Tide: 启动精英怪怪物潮")
--转到二阶段时,直接生成一波精英怪
LF_Create_Elite(context)
LF_Goto_Next_Elite_Index(context)
LF_Try_Pause_Monster_Tide(context)
end
function LF_Create_Elite(context)
local elite_index = LF_Get_Current_Elite_Index(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Create_Elite: 生成精英怪"..elite_index)
if elite_list[elite_index] ~= nil then
for i = 1, #elite_list[elite_index] do
ScriptLib.CreateMonster(context, { config_id = elite_list[elite_index][i], delay_time = 0 })
end
end
end
--[[-----------------------------------------------------------------
|| ||
|| 怪物潮操作 ||
|| ||
-----------------------------------------------------------------]]--
--尝试暂停当前的怪物潮
function LF_Try_Pause_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Pause_Monster_Tide: 尝试暂停怪物潮")
LF_Change_Tide_Op_Num(context,1)
ScriptLib.PauseAutoPoolMonsterTide(context, base_info.group_id, LF_Get_Current_Tide(context))
end
--尝试继续当前的怪物潮
function LF_Try_Continue_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Continue_Monster_Tide: 尝试继续怪物潮")
LF_Change_Tide_Op_Num(context,-1)
local op_num = LF_Get_Tide_Op_Num(context)
if op_num <= 0 then
ScriptLib.ResumeAutoPoolMonsterTide(context, base_info.group_id, LF_Get_Current_Tide(context))
end
end
--尝试清理当前的怪物潮
function LF_Try_Kill_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Kill_Monster_Tide: 尝试清理当前怪物潮")
ScriptLib.ClearPoolMonsterTide(context, base_info.group_id, LF_Get_Current_Tide(context))
LF_Set_Tide_Op_Num(context,0)
end
--尝试开启/重启一个怪物潮
function LF_Try_Start_Monster_Tide(context,monster_tide_config)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Start_Monstert_Tide: 尝试开启一波新的怪物潮")
--如果当前怪物潮index已超过1说明怪物潮开启中需要先清理当前的怪物潮
if LF_Get_Current_Tide(context) > 0 then
LF_Try_Kill_Monster_Tide(context)
end
LF_Goto_Next_Tide(context)
ScriptLib.AutoPoolMonsterTide(context, LF_Get_Current_Tide(context), base_info.group_id, {monster_tide_config.pool_id}, 0, {}, {}, {total_count=monster_tide_config.total_num, min_count=monster_tide_config.min, max_count=monster_tide_config.max, tag=0, fill_time=0, fill_count=0})
LF_Set_Tide_Op_Num(context,0)
end
--清理当前的怪物潮
function LF_Clear_Current_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Clear_Current_Monster_Tide: 清理当前怪物潮")
--清干净场上残存的怪物
local alive_monster_list = ScriptLib.GetGroupAliveMonsterList(context,base_info.group_id)
for i = 1,#alive_monster_list do
ScriptLib.RemoveEntityByConfigId(context,base_info.group_id,EntityType.MONSTER,alive_monster_list[i])
end
--清理小怪潮、清理精英怪潮
LF_Try_Kill_Monster_Tide(context)
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD类方法 ||
|| ||
-----------------------------------------------------------------]]--
----------------------怪物相关查询-----------------------------------
--检查一个monster_id是否是精英怪
function LF_Is_Elite(monster_id)
for i = 1, #elite_list do
for j = 1, #elite_list[i] do
if monster_id == elite_list[i][j] then
return true
end
end
end
return false
end
--返回当前场上精英怪是否全死了
function LF_Is_Current_Elite_All_Dead(context)
local alive_monster_list = ScriptLib.GetGroupAliveMonsterList(context,base_info.group_id)
for i = 1, #alive_monster_list do
if (LF_Is_Elite(alive_monster_list[i])) then
return false
end
end
return true
end
--获取精英怪的总数
function LF_Get_Elite_Num(context)
local num = 0
for i = 1, #elite_list do
num = num + #elite_list[i]
end
return num
end
----------------------当前阶段数-----------------------------------
function LF_Get_Current_Stage(context)
return ScriptLib.GetGroupVariableValue(context,"current_stage")
end
function LF_Set_Current_Stage(context,stage)
ScriptLib.SetGroupVariableValue(context,"current_stage",stage)
end
function LF_Goto_Next_Stage(context)
local stage = LF_Get_Current_Stage(context)
LF_Set_Current_Stage(context,stage+1)
end
----------------------当前精英怪索引数------------------------------
function LF_Get_Current_Elite_Index(context)
return ScriptLib.GetGroupVariableValue(context,"current_elite")
end
function LF_Set_Current_Elite_Index(context,elite)
ScriptLib.SetGroupVariableValue(context,"current_elite",elite)
end
function LF_Goto_Next_Elite_Index(context)
local elite = LF_Get_Current_Elite_Index(context)
LF_Set_Current_Elite_Index(context,elite+1)
end
----------------------当前怪物潮索引数------------------------------
function LF_Get_Current_Tide(context)
return ScriptLib.GetGroupVariableValue(context,"current_monster_tide")
end
function LF_Set_Current_Tide(context,tide)
ScriptLib.SetGroupVariableValue(context,"current_monster_tide",tide)
end
function LF_Goto_Next_Tide(context)
local tide = LF_Get_Current_Tide(context)
LF_Set_Current_Tide(context,tide+1)
end
----------------------怪物潮引用计数相关------------------------------
function LF_Get_Tide_Op_Num(context)
return ScriptLib.GetGroupVariableValue(context,"tide_op_num")
end
function LF_Change_Tide_Op_Num(context,delta)
local tide_op_num = LF_Get_Tide_Op_Num(context)
if tide_op_num + delta < 0 then
ScriptLib.SetGroupVariableValue(context,"tide_op_num",0)
else
ScriptLib.SetGroupVariableValue(context,"tide_op_num",tide_op_num+delta)
end
end
function LF_Set_Tide_Op_Num(context,op_num)
ScriptLib.SetGroupVariableValue(context,"tide_op_num",op_num)
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,52 @@
--[[======================================
|| filename: V2_8ArenaChallenge_Control
|| owner: luyao.huang
|| description: 2.8幻影心流复刻活动-主控group
|| LogName: V2_8ArenaChallenge_Control
|| Protection:
=======================================]]--
local Tri = {
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--主控group记一下当前激活的玩法group方便两个group之间通讯
table.insert(variables,{config_id = 10000000, name = "active_group", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
--主控group的SLC实际上要负责转发给玩法group的SLC
function SLC_State_Condition_Complete(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge_Control]SLC_State_Condition_Complete: 转阶段条件完成向玩法group转发")
local active_group = ScriptLib.GetGroupVariableValue(context,"active_group")
if active_group ~= 0 then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge_Control]SLC_State_Condition_Complete: 当前激活的玩法group为"..active_group)
ScriptLib.ExecuteGroupLua(context, active_group, "LF_State_Condition_Complete", {})
end
return 0
end
---------------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,483 @@
--[[======================================
|| filename: V2_8ArenaChallenge_Quest
|| owner: luyao.huang
|| description: 2.8幻影心流复刻活动-活动任务
|| LogName: V2_8ArenaChallenge_Quest
|| Protection:
=======================================]]--
------
local local_defs =
{
father_challenge_index = 101,
time_challenge_index = 11,
kill_monster_challenge_index = 12,
state_change_challenge_index = 13,
reminder_id = 400157,
stage_1_weather_id = 1011,
stage_2_weather_id = 1010,
success_quest_param = "133001096",
fail_quest_param = "1330010960",
}
local time_axis = {
ELITE_INTERVAL_AXIS = {defs.elite_interval},
CHANGE_STAGE_INTERVAL_AXIS = {defs.change_stage_interval}
}
--计数型挑战
local counting_challenge =
{
[1] = {challenge_id = defs.kill_monster_challenge_id, tag = tostring(defs.kill_monster_challenge_id), var_name = "challenge_kill_monster"},
}
local Tri = {
[1] = { name = "group_load", config_id = 10000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[3] = { name = "time_axis_pass", config_id = 10000003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[4] = { name = "monstert_die_before_leave_scene", config_id = 10000004, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[5] = { name = "challenge_fail", config_id = 10000005, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
[6] = { name = "pool_monster_tide_over", config_id = 10000006, event = EventType.EVENT_POOL_MONSTER_TIDE_OVER, source = "", condition = "", action = "action_pool_monster_tide_over", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(counting_challenge) do
if v.challenge_id ~= nil then
local t = {name = "variable_change_"..v.challenge_id, config_id = 1000000+k, event = EventType.EVENT_VARIABLE_CHANGE,source = v.var_name, condition = "", action = "", trigger_count = 0, tag = v.tag}
table.insert(triggers, t)
table.insert(suites[1].triggers, t.name)
table.insert(variables,{config_id = 20000000+k, name = v.var_name, value = 0})
end
end
--阶段数
table.insert(variables,{config_id = 20000100, name = "current_stage", value = 0})
--小怪潮的index
table.insert(variables,{config_id = 20000101, name = "current_monster_tide", value = 0})
--精英怪的index
table.insert(variables,{config_id = 20000102, name = "current_elite", value = 1})
--小怪潮的计数当计数为0时才能继续怪物潮
table.insert(variables,{config_id = 20000103, name = "tide_op_num", value = 0})
--是否是第一组精英怪
table.insert(variables,{config_id = 20000104, name = "is_first_elite", value = 1})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_group_load(context,evt)
LF_Init_Play(context)
LF_Start_Play(context)
return 0
end
function action_time_axis_pass(context,evt)
--精英怪刷新时间轴
if (evt.source_name == "ELITE_INTERVAL_AXIS") then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_time_axis_pass: 精英怪时间轴tick刷出精英怪")
ScriptLib.PauseTimeAxis(context,"ELITE_INTERVAL_AXIS")
LF_Create_Elite(context)
LF_Goto_Next_Elite_Index(context)
LF_Try_Pause_Monster_Tide(context)
end
--简单模式转阶段时间轴
if (evt.source_name == "CHANGE_STAGE_INTERVAL_AXIS") then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_time_axis_pass: 简单模式转阶段tick转阶段")
ScriptLib.EndTimeAxis(context,"CHANGE_STAGE_INTERVAL_AXIS")
LF_Change_To_Second_Stage(context)
end
return 0
end
function action_monster_die_before_leave_scene(context,evt)
if LF_Is_Elite(evt.param1) then
LF_Trigger_Challenge_Count(context,1)
if LF_Is_Current_Elite_All_Dead(context) then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_monster_die_before_leave_scene: 精英怪死亡,恢复小怪潮")
LF_Trigger_Challenge_Count(context,1)
--这里如果是第一组精英怪死亡则是init一个时间轴而不是continue
if ScriptLib.GetGroupVariableValue(context,"is_first_elite") == 1 then
ScriptLib.InitTimeAxis(context,"ELITE_INTERVAL_AXIS",time_axis.ELITE_INTERVAL_AXIS,true)
ScriptLib.SetGroupVariableValue(context,"is_first_elite",0)
else
ScriptLib.ContinueTimeAxis(context, "ELITE_INTERVAL_AXIS")
end
LF_Try_Continue_Monster_Tide(context)
--如果当前的精英计数已经超过了精英总数(精英怪刷完了),玩法以成功结算
if LF_Get_Current_Elite_Index(context) > #elite_list then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_monster_die_before_leave_scene: 精英怪刷完了,玩法结束")
ScriptLib.StopChallenge(context,local_defs.time_challenge_index,1)
ScriptLib.StopChallenge(context,local_defs.kill_monster_challenge_index,1)
ScriptLib.StopChallenge(context,local_defs.father_challenge_index,1)
ScriptLib.AddQuestProgress(context,local_defs.success_quest_param)
LF_Init_Play(context)
return 0
end
end
end
return 0
end
function action_challenge_fail(context,evt)
if evt.param1 == defs.father_challenge_id then
ScriptLib.AddQuestProgress(context,local_defs.fail_quest_param)
LF_Init_Play(context)
end
return 0
end
--如果一阶段怪刷完了,直接失败
function action_pool_monster_tide_over(context,evt)
if LF_Get_Current_Stage(context) == 0 and LF_Get_Current_Tide(context) == 1 then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_pool_monster_tide_over: 小怪潮刷完了,但没有转阶段,直接转到二阶段")
LF_Change_To_Second_Stage(context)
end
if LF_Get_Current_Stage(context) == 1 and LF_Get_Current_Tide(context) == 2 then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]action_pool_monster_tide_over: 二阶段小怪潮刷完了,挑战失败,几乎不可能出现这种情况")
ScriptLib.StopChallenge(context,local_defs.father_challenge_index,0)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
--玩法初始化
function LF_Init_Play(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Init_Play: 玩法初始化")
LF_Clear_All(context)
--ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
LF_Init_Variables(context)
end
--玩法启动
function LF_Start_Play(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Start_Play: 玩法启动")
ScriptLib.CreateGadget(context,{config_id = defs.airwall})
ScriptLib.CreateFatherChallenge(context, local_defs.father_challenge_index, defs.father_challenge_id, defs.challenge_time, {success = 5, fail = 10,fail_on_wipe = true})
local uid = ScriptLib.GetSceneOwnerUid(context)
--先开再attach给子挑战保序
ScriptLib.StartFatherChallenge(context,local_defs.father_challenge_index)
ScriptLib.AttachChildChallenge(context,local_defs.father_challenge_index, local_defs.time_challenge_index, defs.time_challenge_id,{3,666,999999},{uid},{success = 0,fail = 0}) --挑战计时
ScriptLib.AttachChildChallenge(context,local_defs.father_challenge_index, local_defs.kill_monster_challenge_index, defs.kill_monster_challenge_id,{3,defs.kill_monster_challenge_id,LF_Get_Elite_Num(context)},{uid},{success = 0,fail = 0}) --触发精英怪死亡计数
LF_Try_Start_Monster_Tide(context,monster_tide_config[1])
ScriptLib.InitTimeAxis(context,"CHANGE_STAGE_INTERVAL_AXIS",time_axis.CHANGE_STAGE_INTERVAL_AXIS,false)
--一阶段屏蔽天气,固定为晴天
LF_Set_Weather(context,local_defs.stage_1_weather_id,true)
end
--转到二阶段
function LF_Change_To_Second_Stage(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Change_To_Second_Stage: 转到二阶段")
LF_Goto_Next_Stage(context)
LF_Stage_Environment_Change(context)
LF_Try_Start_Monster_Tide(context,monster_tide_config[2])
LF_Start_Elite_Tide(context)
--ScriptLib.ShowReminder(context,local_defs.reminder_id)
--开启二阶段天气
LF_Set_Weather(context,local_defs.stage_1_weather_id,false)
LF_Set_Weather(context,local_defs.stage_2_weather_id,true)
end
function LF_Stage_Environment_Change(context)
ScriptLib.SetGadgetStateByConfigId(context,defs.airwall,201)
end
--清理玩法
function LF_Clear_All(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Clear_All: 开始清理玩法")
--清理怪物潮
LF_Clear_Current_Monster_Tide(context)
--清理空气墙
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.airwall)
--暂停精英怪
ScriptLib.EndTimeAxis(context,"ELITE_INTERVAL_AXIS")
ScriptLib.EndTimeAxis(context,"CHANGE_STAGE_INTERVAL_AXIS")
--恢复天气
LF_Set_Weather(context,local_defs.stage_1_weather_id,false)
LF_Set_Weather(context,local_defs.stage_2_weather_id,false)
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项功能 ||
|| ||
-----------------------------------------------------------------]]--
--所有变量的初始化
function LF_Init_Variables(context)
ScriptLib.SetGroupVariableValue(context,"current_stage",0)
ScriptLib.SetGroupVariableValue(context,"current_monster_tide",0)
ScriptLib.SetGroupVariableValue(context,"current_elite",1)
ScriptLib.SetGroupVariableValue(context,"tide_op_num",0)
end
--触发计数型挑战的触发器
function LF_Trigger_Challenge_Count(context,counting_challenge_id)
ScriptLib.ChangeGroupVariableValue(context,counting_challenge[counting_challenge_id].var_name,1)
end
function LF_Set_Weather(context,weather_id,is_on)
if is_on then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Set_Weather: 打开天气"..weather_id)
ScriptLib.SetWeatherAreaState(context, weather_id, 1)
else
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Set_Weather: 打开天气"..weather_id)
ScriptLib.SetWeatherAreaState(context, weather_id, 0)
end
end
--[[-----------------------------------------------------------------
|| ||
|| 精英怪操作 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Start_Elite_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Start_Elite_Tide: 启动精英怪怪物潮")
--转到二阶段时,直接生成一波精英怪
LF_Create_Elite(context)
LF_Goto_Next_Elite_Index(context)
LF_Try_Pause_Monster_Tide(context)
end
function LF_Create_Elite(context)
local elite_index = LF_Get_Current_Elite_Index(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Create_Elite: 生成精英怪"..elite_index)
if elite_list[elite_index] ~= nil then
for i = 1, #elite_list[elite_index] do
ScriptLib.CreateMonster(context, { config_id = elite_list[elite_index][i], delay_time = 0 })
end
end
end
--[[-----------------------------------------------------------------
|| ||
|| 怪物潮操作 ||
|| ||
-----------------------------------------------------------------]]--
--尝试暂停当前的怪物潮
function LF_Try_Pause_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Pause_Monster_Tide: 尝试暂停怪物潮")
LF_Change_Tide_Op_Num(context,1)
ScriptLib.PauseAutoPoolMonsterTide(context, base_info.group_id, LF_Get_Current_Tide(context))
end
--尝试继续当前的怪物潮
function LF_Try_Continue_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Continue_Monster_Tide: 尝试继续怪物潮")
LF_Change_Tide_Op_Num(context,-1)
local op_num = LF_Get_Tide_Op_Num(context)
if op_num <= 0 then
ScriptLib.ResumeAutoPoolMonsterTide(context, base_info.group_id, LF_Get_Current_Tide(context))
end
end
--尝试清理当前的怪物潮
function LF_Try_Kill_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Kill_Monster_Tide: 尝试清理当前怪物潮")
ScriptLib.ClearPoolMonsterTide(context, base_info.group_id, LF_Get_Current_Tide(context))
LF_Set_Tide_Op_Num(context,0)
end
--尝试开启/重启一个怪物潮
function LF_Try_Start_Monster_Tide(context,monster_tide_config)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Start_Monstert_Tide: 尝试开启一波新的怪物潮")
--如果当前怪物潮index已超过1说明怪物潮开启中需要先清理当前的怪物潮
if LF_Get_Current_Tide(context) > 0 then
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Start_Monstert_Tide: 需要清理上一波怪物潮,当前波次为"..LF_Get_Current_Tide(context))
LF_Try_Kill_Monster_Tide(context)
end
LF_Goto_Next_Tide(context)
local ret = ScriptLib.AutoPoolMonsterTide(context, LF_Get_Current_Tide(context), base_info.group_id, {monster_tide_config.pool_id}, 0, {}, {}, {total_count=monster_tide_config.total_num, min_count=monster_tide_config.min, max_count=monster_tide_config.max, tag=1, fill_time=0, fill_count=0})
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Try_Start_Monstert_Tide: 怪物潮成功返回值为"..ret)
LF_Set_Tide_Op_Num(context,0)
end
--清理当前的怪物潮
function LF_Clear_Current_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [V2_8ArenaChallenge]LF_Clear_Current_Monster_Tide: 清理当前怪物潮")
--清干净场上残存的怪物
local alive_monster_list = ScriptLib.GetGroupAliveMonsterList(context,base_info.group_id)
for i = 1,#alive_monster_list do
ScriptLib.RemoveEntityByConfigId(context,base_info.group_id,EntityType.MONSTER,alive_monster_list[i])
end
--清理小怪潮、清理精英怪潮
LF_Try_Kill_Monster_Tide(context)
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD类方法 ||
|| ||
-----------------------------------------------------------------]]--
----------------------怪物相关查询-----------------------------------
--检查一个monster_id是否是精英怪
function LF_Is_Elite(monster_id)
for i = 1, #elite_list do
for j = 1, #elite_list[i] do
if monster_id == elite_list[i][j] then
return true
end
end
end
return false
end
--返回当前场上精英怪是否全死了
function LF_Is_Current_Elite_All_Dead(context)
local alive_monster_list = ScriptLib.GetGroupAliveMonsterList(context,base_info.group_id)
for i = 1, #alive_monster_list do
if (LF_Is_Elite(alive_monster_list[i])) then
return false
end
end
return true
end
--获取精英怪的总数
function LF_Get_Elite_Num(context)
local num = 0
for i = 1, #elite_list do
num = num + #elite_list[i]
end
return num
end
----------------------当前阶段数-----------------------------------
function LF_Get_Current_Stage(context)
return ScriptLib.GetGroupVariableValue(context,"current_stage")
end
function LF_Set_Current_Stage(context,stage)
ScriptLib.SetGroupVariableValue(context,"current_stage",stage)
end
function LF_Goto_Next_Stage(context)
local stage = LF_Get_Current_Stage(context)
LF_Set_Current_Stage(context,stage+1)
end
----------------------当前精英怪索引数------------------------------
function LF_Get_Current_Elite_Index(context)
return ScriptLib.GetGroupVariableValue(context,"current_elite")
end
function LF_Set_Current_Elite_Index(context,elite)
ScriptLib.SetGroupVariableValue(context,"current_elite",elite)
end
function LF_Goto_Next_Elite_Index(context)
local elite = LF_Get_Current_Elite_Index(context)
LF_Set_Current_Elite_Index(context,elite+1)
end
----------------------当前怪物潮索引数------------------------------
function LF_Get_Current_Tide(context)
return ScriptLib.GetGroupVariableValue(context,"current_monster_tide")
end
function LF_Set_Current_Tide(context,tide)
ScriptLib.SetGroupVariableValue(context,"current_monster_tide",tide)
end
function LF_Goto_Next_Tide(context)
local tide = LF_Get_Current_Tide(context)
LF_Set_Current_Tide(context,tide+1)
end
----------------------怪物潮引用计数相关------------------------------
function LF_Get_Tide_Op_Num(context)
return ScriptLib.GetGroupVariableValue(context,"tide_op_num")
end
function LF_Change_Tide_Op_Num(context,delta)
local tide_op_num = LF_Get_Tide_Op_Num(context)
if tide_op_num + delta < 0 then
ScriptLib.SetGroupVariableValue(context,"tide_op_num",0)
else
ScriptLib.SetGroupVariableValue(context,"tide_op_num",tide_op_num+delta)
end
end
function LF_Set_Tide_Op_Num(context,op_num)
ScriptLib.SetGroupVariableValue(context,"tide_op_num",op_num)
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
------------------------------------------------------------------
Initialize()