添加配置表

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,119 @@
-- Trigger变量
---[[
local screenGadgetID = { 70310076, 70310077}
local transPos =
{
[1] = { x = 1.5, y = 0.147, z = -15 },
[2] = { x = -1.5, y = 0.147, z = -15 },
[3] = { x = 4.5, y = 0.147, z = -15 },
[4] = { x = -4.5, y = 0.147, z = -15 },
}
local bossConfigID = 1004
--]]
--------Boss女士-------------
local tempTrigger = {
{ config_id = 2330001, name = "TIME_AXIS_MovieEventSolo", event = EventType.EVENT_TIME_AXIS_PASS, source = "MovieEventSolo",
condition = "", action = "action_TIME_AXIS_MovieEventSolo", trigger_count = 0},
{ config_id = 2330002, name = "TIME_AXIS_MovieEvent", event = EventType.EVENT_TIME_AXIS_PASS, source = "MovieEvent",
condition = "", action = "action_TIME_AXIS_MovieEvent", trigger_count = 0},
{ config_id = 2330003, name = "ANY_MONSTER_DIE_ThirdBoss", event = EventType.EVENT_ANY_MONSTER_DIE, source = "",
condition = "", action = "action_ANY_MONSTER_DIE_ThirdBoss", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
local var = { config_id=50000001,name = "PhaseStep", value = 0, no_refresh = false } --阶段数据
variables[var.name] = var
return 0
end
--------公用函数----------
function PlayCutScene(context)
ScriptLib.PrintContextLog(context, "-------------- INITIALIZE 1 ------------------")
--播CS前直接切当前气候为自然气候
ScriptLib.ModifyClimatePolygonParamTable(context, 1, {climate_type=0,meter_inherit_ratio=0})
ScriptLib.PrintContextLog(context, "## TD LaSignora Boss1已死亡气候重置等待创生Boss切换新气候")
local uidList=ScriptLib.GetSceneUidList(context)
if #uidList < 2 then
ScriptLib.PlayCutScene(context, defs.cutSceneID, 0)
ScriptLib.InitTimeAxis(context, "MovieEventSolo",{2}, false)
ScriptLib.PrintContextLog(context, "## TD LaSignora 单机下开启Cs事件 Send Time Axis")
else
if #uidList <=4 then
for i=1,#uidList do
ScriptLib.TransPlayerToPos(context, {uid_list ={uidList[i]}, pos = transPos[i], radius = 2, rot = {x=0, y=0, z=0}})
end
end
ScriptLib.InitTimeAxis(context, "MovieEvent",{1}, false)
ScriptLib.PrintContextLog(context, "## TD LaSignora 联网下开启Cs事件 Send Time Axis")
end
return 0
end
function CallPhaseChange(context,phaseNum)
ScriptLib.PrintContextLog(context, "## TD LaSignora 战斗脚本通知阶段改变,当前阶段为阶段" .. phaseNum)
ScriptLib.SetGroupVariableValue(context, "PhaseStep", phaseNum)
end
-- 切换Climate为HotMonster(ModifyClimatePolygonParamTable)
function ChangeClimateToHotMonster(context)
-- 该功能仅用于女士地城
ScriptLib.ModifyClimatePolygonParamTable(context, 1, {climate_type=4,meter_inherit_ratio=0})
ScriptLib.PrintContextLog(context, "## TD LaSignora 当前气候已切换为HotMonster")
return 0
end
--------事件函数----------
function action_TIME_AXIS_MovieEventSolo(context)
local uidList=ScriptLib.GetSceneUidList(context)
ScriptLib.CreateMonster(context, { config_id = 1004, delay_time = 0.5 })
for k,v in pairs(gadgets) do
if IsGadgetScreen(v.config_id) then
ScriptLib.PrintContextLog(context, "## TD LaSignora Config_id == " .. v.config_id)
ScriptLib.RemoveEntityByConfigId(context, defs.groupID, EntityType.GADGET, v.config_id )
end
end
ScriptLib.TransPlayerToPos(context, {uid_list = {uidList[1]}, pos = transPos[1], radius = 2, rot = {x=0, y=0, z=0},is_skip_ui = true})
return 0
end
function action_TIME_AXIS_MovieEvent(context)
-- 创建怪
ScriptLib.CreateMonster(context, { config_id = 1004, delay_time = 0 })
-- 移除Gadget
for k,v in pairs(gadgets) do
if IsGadgetScreen(v.config_id) then
ScriptLib.PrintContextLog(context, "## TD LaSignora Config_id == " .. v.config_id)
ScriptLib.RemoveEntityByConfigId(context, defs.groupID, EntityType.GADGET, v.config_id )
end
end
return 0
end
function action_ANY_MONSTER_DIE_ThirdBoss(context,evt)
if evt.param1 == bossConfigID then
ScriptLib.ModifyClimatePolygonParamTable(context, 1, {climate_type=0,meter_inherit_ratio=0})
ScriptLib.PrintContextLog(context, "## TD LaSignora :战斗结束,天气切换回默认")
end
return 0
end
--------私有函数----------
-- 是否为屏风Gadget
function IsGadgetScreen(config_id)
local gadgetId = gadgets[config_id].gadget_id
for i = 1, #screenGadgetID, 1 do
if(screenGadgetID[i] == gadgetId) then
return true
end
end
return false
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,122 @@
--[[======================================
|| filename: Boss_Raijin
|| owner: zijun.ma
|| description: 雷音权现Boss战专用
|| LogName: ##[TD_Raijin]
|| Protection:
=======================================]]--
-- Trigger变量
--[[
local defs = {
BossConfigID = 181001,
regionID = 181005,
}
--]]
--------Boss女士-------------
local tempTrigger = {
{ config_id = 2330001, name = "EVENT_ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "",
condition = "", action = "action_BattleStart", trigger_count = 0,forbid_guest = false },
{ config_id = 2330002, name = "EVENT_LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "",
condition = "", action = "action_LeaveRegion", trigger_count = 0,forbid_guest = false},
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
--------公用函数----------
-- 入圈时ForceRefreshAuthorityByConfigId
-- 离圈时TryReallocateEntityAuthority
-- 入战时强制将Authority刷新到主机
function action_BattleStart(context,evt)
if evt.param1 ~= defs.regionID then
return 0
end
ScriptLib.PrintContextLog(context,"##TD_Raijin: 玩家"..context.uid.. "进战斗圈")
-- 入战时尽可能分配Hosthost在圈里分给host、host不在分给任意圈内玩家)
local no_avatar_in_region = true
local uidlist = ScriptLib.GetSceneUidList(context)
if uidlist == -1 or uidlist == nil or #uidlist == 0 then
ScriptLib.PrintContextLog(context,"##TD_Raijin: 没有取到uidlist上限触发region强制锁Auth为入圈者")
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.BossConfigID, context.uid)
return 0
end
for i = 1, #uidlist do
if (LF_Avatar_is_in_region(context,uidlist[i],defs.regionID) and uidlist[i] ~= context.uid) then
no_avatar_in_region = false
ScriptLib.PrintContextLog(context,"##TD_Raijin: 圈内存在玩家:"..uidlist[i].."不分配authortiy")
break
end
end
if (no_avatar_in_region) then
ScriptLib.PrintContextLog(context,"##TD_Raijin: 第一个进入region的玩家"..context.uid.."分配authortiy")
--将Authority强行设置为进圈的玩家
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.BossConfigID, context.uid)
end
return 0
end
-- 切阶段二环境
function action_LeaveRegion(context,evt)
if evt.param1 ~= defs.regionID then
return 0
end
ScriptLib.PrintContextLog(context, "## TD_Raijin : 离开的玩家uid = "..context.uid)
local ret = ScriptLib.TryReallocateEntityAuthority(context, context.uid, defs.BossConfigID, evt.param1)
ScriptLib.PrintContextLog(context, "## TD_Raijin : 返回值为 "..ret)
return 0
end
function LF_Avatar_is_in_region(context,uid,region_id)
local avatar_id = ScriptLib.GetAvatarEntityIdByUid(context, uid)
local pos1 = ScriptLib.GetPosByEntityId(context, avatar_id)
local region = {}
for i = 1, #regions do
if regions[i].config_id == region_id then
region = regions[i]
end
end
local X = pos1.x - region.pos.x
local Y = pos1.y - region.pos.y
local Z = pos1.z - region.pos.z
if region.shape == RegionShape.SPHERE then
ScriptLib.PrintContextLog(context, "## TD_Raijin : LF_Avatar_is_in_region 距离为 = "..math.sqrt(X*X+Y*Y+Z*Z))
ScriptLib.PrintContextLog(context, "## TD_Raijin : LF_Avatar_is_in_region Radius为 = "..region.radius)
if math.sqrt(X*X+Y*Y+Z*Z) <= region.radius then
return true
else
return false
end
elseif region.shape == RegionShape.CUBIC then
ScriptLib.PrintContextLog(context, "## TD_Raijin : LF_Avatar_is_in_region 距离为 = "..math.sqrt(X*X+Y*Y+Z*Z))
ScriptLib.PrintContextLog(context, "## TD_Raijin : LF_Avatar_is_in_region size为 = "..region.size.z/2)
if math.abs(X) > region.size.x/2 or math.abs(Y) > region.size.y/2 or math.abs(Z) > region.size.z/2 then
return false
else
return true
end
end
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,114 @@
-- Trigger变量
--[[
local defs = {
BossConfigID = 1002,
EnvConfigID = 1001,
GroupID = 220117001,
}
--]]
--------Boss女士-------------
local tempTrigger = {
--[[
{ config_id = 2330001, name = "EVENT_QUEST_START", event = EventType.EVENT_QUEST_START, source = "202010",
condition = "", action = "action_NoticeMonsterEnterPhaseSecond", trigger_count = 0},
--]]
{ config_id = 2330002, name = "VARIABLE_CHANGE_DebugTest", event = EventType.EVENT_VARIABLE_CHANGE, source = "DebugPhase",
condition = "", action = "action_DebugTest", trigger_count = 0},
{ config_id = 2330003, name = "TIME_AXIS_MovieEvent1", event = EventType.EVENT_TIME_AXIS_PASS, source = "PhaseAxis1",
condition = "", action = "action_TIME_AXIS_MovieEvent1", trigger_count = 0},
{ config_id = 2330004, name = "TIME_AXIS_MovieEvent2", event = EventType.EVENT_TIME_AXIS_PASS, source = "PhaseAxis2",
condition = "", action = "action_TIME_AXIS_MovieEvent2", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
local var = { config_id=50000001,name = "PhaseStep", value = 1, no_refresh = false } --阶段计数器
variables[var.name] = var
var = { config_id=50000002,name = "DebugPhase", value = 1, no_refresh = false } -- Debug用阶段计数器
variables[var.name] = var
return 0
end
--------公用函数----------
-- 通知关卡播CS
function SLC_PlayCutScene(context)
ScriptLib.PrintContextLog(context, "-------------- INITIALIZE 1 ------------------")
ScriptLib.AddQuestProgress(context, "202010")
ScriptLib.PrintContextLog(context, "## TD Shougun 通知任务202010进度增加")
action_NoticeMonsterEnterPhaseSecond(context)
return 0
end
-- 关卡通知怪物 (EVENT_CUTSCENE_END//_MONSTER_SHOUGUN_STAGE_) GROUP GET_TRIGGER 220117001 EVENT_QUEST_START
function action_NoticeMonsterEnterPhaseSecond(context)
ScriptLib.PrintContextLog(context, "## TD Shougun CutScene已播完开始进入二阶段")
-- 传送
ScriptLib.InitTimeAxis(context, "PhaseAxis1",{1}, false)
return 0
end
-- 切阶段二环境
function action_TIME_AXIS_MovieEvent1(context,evt)
ScriptLib.PrintContextLog(context, "## TD Shougun CutScene已播完延迟1秒转阶段")
--将环境GadgetState切至201
ScriptLib.SetGadgetStateByConfigId(context, defs.EnvConfigID, 201)
--关卡通知怪物 _MONSTER_SHOUGUN_TACHI_
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.BossConfigID, "SGV_MONSTER_SHOUGUN_CHANGETOTACHI", 2)
--阶段计数为2
-- GROUP GETVAR 220117001 PhaseStep
ScriptLib.SetGroupVariableValue(context, "PhaseStep", 2)
return 0
end
-- 怪物通知关卡进入阶段三
function SLC_EnterPhaseThird(context)
ScriptLib.PrintContextLog(context, "## TD Shougun 开始进入三阶段")
--将环境GadgetState切至202
ScriptLib.SetGadgetStateByConfigId(context, defs.EnvConfigID, 202)
ScriptLib.InitTimeAxis(context, "PhaseAxis2",{1}, false)
return 0
end
-- 切阶段三环境
function action_TIME_AXIS_MovieEvent2(context,evt)
ScriptLib.PrintContextLog(context, "## TD Shougun 延迟1秒,切环境")
--阶段计数为3
ScriptLib.SetGroupVariableValue(context, "PhaseStep", 3)
return 0
end
--------事件函数----------
--------私有函数----------
function action_TIME_AXIS_MovieEvent(context,evt)
-- 传送
ScriptLib.TransPlayerToPos(context, {uid_list =ScriptLib.GetSceneUidList(context), pos = { x = 502.498, y = 100.542, z = 498.351}, radius = 2, rot = {x=0, y=220, z=0}})
return 0
end
function action_DebugTest(context,evt)
-- Dungeon 1122
-- GROUP SETVAR 220117001 DebugPhase 1
if 1 == evt.param1 then
SLC_PlayCutScene(context)
return 0
end
if 2 == evt.param1 then
SLC_EnterPhaseThird(context)
return 0
end
return 0
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,92 @@
-- Trigger变量
--[[
local defs = {
BossConfigID = 1002,
EnvConfigID = 1001,
GroupID = 220117001,
}
--]]
--------Boss女士-------------
local tempTrigger = {
{ config_id = 2330002, name = "VARIABLE_CHANGE_DebugTest", event = EventType.EVENT_VARIABLE_CHANGE, source = "DebugPhase",
condition = "", action = "action_DebugTest", trigger_count = 0},
{ config_id = 2330003, name = "TIME_AXIS_MovieEvent1", event = EventType.EVENT_TIME_AXIS_PASS, source = "PhaseAxis1",
condition = "", action = "action_TIME_AXIS_MovieEvent1", trigger_count = 0},
{ config_id = 2330004, name = "TIME_AXIS_MovieEvent2", event = EventType.EVENT_TIME_AXIS_PASS, source = "PhaseAxis2",
condition = "", action = "action_TIME_AXIS_MovieEvent2", trigger_count = 0},
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
local var = { config_id=50000001,name = "PhaseStep", value = 1, no_refresh = false } --阶段计数器
variables[var.name] = var
var = { config_id=50000002,name = "DebugPhase", value = 1, no_refresh = false } -- Debug用阶段计数器
variables[var.name] = var
return 0
end
--------公用函数----------
-- 通知关卡播CS
function SLC_PlayCutScene(context)
ScriptLib.PrintContextLog(context, "-------------- INITIALIZE 1 ------------------")
ScriptLib.PrintContextLog(context, "Beta用测试流程")
--1秒后通知怪物变化动
ScriptLib.InitTimeAxis(context, "PhaseAxis1",{1}, false)
return 0
end
-- 切阶段二环境
function action_TIME_AXIS_MovieEvent1(context,evt)
ScriptLib.PrintContextLog(context, "## TD Shougun CutScene已播完开始进入二阶段")
-- 通知将军切换状态
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.BossConfigID, "SGV_MONSTER_SHOUGUN_CHANGETOTACHI", 2)
--阶段计数为2
-- GROUP GETVAR 220117001 PhaseStep
ScriptLib.SetGroupVariableValue(context, "PhaseStep", 2)
return 0
end
-- 怪物通知关卡进入阶段三
function SLC_EnterPhaseThird(context)
ScriptLib.PrintContextLog(context, "## TD Shougun 开始进入三阶段")
ScriptLib.InitTimeAxis(context, "PhaseAxis2",{1}, false)
return 0
end
-- 切阶段三环境
function action_TIME_AXIS_MovieEvent2(context,evt)
ScriptLib.PrintContextLog(context, "## TD Shougun 延迟1秒,切环境")
--阶段计数为3
ScriptLib.SetGroupVariableValue(context, "PhaseStep", 3)
return 0
end
--------事件函数----------
--------私有函数----------
function action_DebugTest(context,evt)
-- Dungeon 1122
-- GROUP SETVAR 220117001 DebugPhase 1
if 1 == evt.param1 then
SLC_PlayCutScene(context)
return 0
end
if 2 == evt.param1 then
SLC_EnterPhaseThird(context)
return 0
end
return 0
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,549 @@
--2.1换人挑战玩法
--miscs
----fever进度升级节点
--local fever_progress_table = {
-- 0,50,100,200,300,500
--}
----各等级fever的下降速率
--local fever_attenuation = {
-- -1,-2,-3,-4,-5
--}
--
--local monster_tide = {
-- [1] = {2001,2002,2003,2004,2005,2006,2007},
-- [2] = {2008,2009,2010,2011,2012,2013,2014}
--}
--
--local elite = {
-- 2015,2016,2017,2018,2019,2020,2021
--}
--
--local elite_born_points = {
-- 3001,3002,3003,3004,3005,3006,3007
--}
------
--local defs = {
-- group_id = 235801002,
-- worktop_id = 123,
-- minion_fever = 5,
-- game_time = 360,
-- minion_interval = 120,
-- elite_interval = 30,
-- elite_fever = 50,
-- min_monster_count = 5,
-- max_monster_count = 5,
-- environment_suite = 4,
--}
local local_defs = {
worktop_option = 30110,
progress_key = 1,
team_global_value = "FEVER_LEVEL",
team_noswitch_pubishment = "NOSWITCH_PUNISHMENT",
team_has_switch = "HAS_SWITCHED_TEAM",
burn_effect_level = 2,
environment_change_level = 1,
base_upgrade_reminder = 358010102,
team_noswitch_pubishment_reminder = 144,
}
local time_axis = {
--小怪潮替换时间轴,每次触发时替换小怪潮
minion_tide_axis = {defs.minion_tide_interval},
--精英怪潮替换时间轴,每次触发时替换精英怪潮
elite_tide_axis = {defs.elite_tide_interval},
--精英怪时间轴,每次触发时刷新一只精英怪
elite_axis = {defs.elite_interval},
--扣分时间轴,每秒掉一定的分数
fever_axis = {1},
noswitch_punishment_axis = {defs.noswitch_punishment_interval}
}
local Tri = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "select_option", config_id = 8000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[3] = { name = "time_axis_pass", config_id = 8000003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[4] = { name = "gallery_progress_pass", config_id = 8000004, event = EventType.EVENT_GALLERY_PROGRESS_PASS, source = "", condition = "", action = "action_gallery_progress_pass", trigger_count = 0},
[5] = { name = "monster_tide_die", config_id = 8000005, event = EventType.EVENT_MONSTER_TIDE_DIE, source = "", condition = "", action = "action_monster_tide_die", trigger_count = 0},
[6] = { name = "monster_die_before_leave_scene", config_id = 8000006, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[7] = { name = "gallery_stop", config_id = 8000007, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
[8] = { name = "sumo_switch_team", config_id = 8000008, event = EventType.EVENT_SUMO_SWITCH_TEAM_EVENT, source = "", condition = "", action = "action_sumo_switch_team", trigger_count = 0},
[9] = { name = "dungeon_all_avatar_die", config_id = 8000009, event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_dungeon_all_avatar_die", trigger_count = 0},
[10] = { name = "dungeon_settle", config_id = 8000010, event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_dungeon_settle", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id=50000001,name = "current_monster_tide", value = 0})
table.insert(variables,{ config_id=50000002,name = "current_elite", value = 1})
table.insert(variables,{ config_id=50000003,name = "fever_ratio", value = 1})
--用于记录当前是否开启不换队惩罚,用于客户端断线重连时恢复状态
table.insert(variables,{ config_id=50000004,name = "is_noswitch_punishment", value = 0})
--用于记录当前精英是否在场,精英在场时,怪物潮不做刷新
table.insert(variables,{ config_id=50000005,name = "is_elite_on_ground", value = 0})
--用于记录当前怪物潮是否结束,当精英死亡时判断当前怪物潮是否处于结束状态,如果是,则直接加载下一波怪物潮
table.insert(variables,{ config_id=50000006,name = "is_current_minion_tide_end", value = 0})
end
------------------------------------------------------------------
--group load后加载操作台选项
function action_group_load(context,evt)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, defs.worktop_id, {local_defs.worktop_option})
--开场就直接加载氛围物件,不要等玩家开启挑战
--加载环境氛围物件
ScriptLib.AddExtraGroupSuite(context,defs.group_id,defs.environment_suite)
--启动第一个地城天气
--local ret = ScriptLib.SetWeatherAreaState(context, DungeonWeather[1],1)
--ScriptLib.PrintContextLog(context,"FS: The result of starting weather".. DungeonWeather[1].."is "..ret)
--ret = ScriptLib.EnterWeatherArea(context, DungeonWeather[1])
--ScriptLib.PrintContextLog(context,"FS: The result of entering weather".. DungeonWeather[1].."is "..ret)
return 0
end
--按下操作台按键,启动玩法
function action_select_option(context,evt)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, defs.worktop_id, local_defs.worktop_option)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.worktop_id, GadgetState.GearStop)
LF_Start_Play(context)
return 0
end
--时间轴tick事件根据tick的时间轴不同处理不同逻辑
function action_time_axis_pass(context,evt)
--小怪时间轴tick将小怪潮的index指向下一位修改group variable
if (evt.source_name == "MINION_TIDE_AXIS") then
ScriptLib.PrintContextLog(context,"FS: MINION_TIDE_AXIS tick!")
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
LF_Set_Current_Monster_Tide(context,current_monster_tide+1)
end
--精英波次时间轴tick将精英怪的index指向下一位
if (evt.source_name == "ELITE_TIDE_AXIS") then
ScriptLib.PrintContextLog(context,"FS: ELITE_TIDE_AXIS tick!")
local current_elite_index = LF_Get_Current_Elite_Index(context)
LF_Set_Current_Elite_Index(context,current_elite_index+1)
end
--精英时间轴tick刷新下一只精英
if (evt.source_name == "ELITE_AXIS") then
ScriptLib.PrintContextLog(context,"FS: ELITE_AXIS tick!")
local current_elite_index = LF_Get_Current_Elite_Index(context)
LF_Create_Elite_Monster(context,current_elite_index)
--性能优化:刷出精英怪时,暂停怪物潮
ScriptLib.PrintContextLog(context,"FS: elite created. Stop monster tide ["..LF_Get_Current_Tide_Num(context).."]")
ScriptLib.SetGroupVariableValue(context,"is_elite_on_ground",1)
ScriptLib.PauseAutoMonsterTide(context, defs.group_id, LF_Get_Current_Tide_Num(context))
end
--fever条tick扣分
if (evt.source_name == "FEVER_AXIS") then
LF_Update_Fever(context,LF_Get_Fever_Subnum(context))
end
--不换队tick如果长时间不换队则将设置惩罚gv
if (evt.source_name == "NOSWITCH_PUNISHMENT_AXIS") then
--ScriptLib.PrintContextLog(context,"FS: Showing reminder "..local_defs.team_noswitch_pubishment_reminder)
ScriptLib.ShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {0})
--ScriptLib.ShowReminder(context, local_defs.team_noswitch_pubishment_reminder)
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",1)
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,1)
end
return 0
end
--fever升级时给team挂global value并激活场景氛围物件
function action_gallery_progress_pass(context,evt)
local fever_level = evt.param1
ScriptLib.PrintContextLog(context,"FS: Fever uprade to level "..fever_level)
ScriptLib.ShowReminder(context, local_defs.base_upgrade_reminder+fever_level)
LF_Set_Team_Global_Value(context,local_defs.team_global_value,fever_level)
LF_Activate_Environment_Gadget(context,fever_level)
return 0
end
function action_gallery_stop(context,evt)
LF_Stop_Play(context)
return 0
end
--当前的怪物潮刷完的时候,重置当前的怪物潮
function action_monster_tide_die(context,evt)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
--如果当前怪物潮已经被杀完了,且精英怪不在场
if (evt.param1 >= #monster_tide[current_monster_tide]) then
--记录一下当前怪物潮结束,精英怪死亡时需要手动打开一次
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",1)
local is_elite_on_ground = ScriptLib.GetGroupVariableValue(context,"is_elite_on_ground")
ScriptLib.PrintContextLog(context,"FS: Current tide ends, is elite on ground?? "..is_elite_on_ground)
if (is_elite_on_ground == 0) then
--精英不在场,才能开一个新的怪物潮
ScriptLib.PrintContextLog(context,"FS: No elite on ground. Create a new monster tide!")
ScriptLib.KillMonsterTide(context, defs.group_id, LF_Get_Current_Tide_Num(context))
LF_Create_Monster_Tide(context,current_monster_tide)
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",0)
end
end
return 0
end
--有怪死亡时计分并更新fever条
function action_monster_die_before_leave_scene(context,evt)
local monster_eid = evt.source_eid
local monster_cid = evt.param1
local is_elite = LF_Is_Elite(context,monster_cid)
local fever_ratio = ScriptLib.GetGroupVariableValue(context,"fever_ratio")
if (not is_elite) then
LF_Update_Fever(context,defs.minion_fever*fever_ratio)
else
LF_Update_Fever(context,defs.elite_fever*fever_ratio)
--精英死亡时,重新开始计时
ScriptLib.EndTimeAxis(context,"ELITE_AXIS")
ScriptLib.InitTimeAxis(context,"ELITE_AXIS",time_axis.elite_axis,false)
ScriptLib.SetGroupVariableValue(context,"is_elite_on_ground",0)
local is_current_minion_tide_end = ScriptLib.GetGroupVariableValue(context,"is_current_minion_tide_end")
if (is_current_minion_tide_end == 0) then
--当前怪物潮没有结束,则恢复怪物潮即可
ScriptLib.PrintContextLog(context,"FS: elite died. Restart monster tide")
--性能优化:精英怪死亡时,恢复怪物潮
ScriptLib.ContinueAutoMonster(context, defs.group_id, LF_Get_Current_Tide_Num(context))
else
--当前怪物潮已经结束了,但因为精英在场所以被卡住了。精英死亡时,手动开启新的怪物潮
ScriptLib.PrintContextLog(context,"FS: elite died but current tide is dead. Start a new tide!")
ScriptLib.KillMonsterTide(context, defs.group_id, LF_Get_Current_Tide_Num(context))
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
LF_Create_Monster_Tide(context,current_monster_tide)
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",0)
end
end
LF_Update_Score(context,monster_eid)
return 0
end
--玩家换队时触发启动一个一定时间的时间轴时间轴tick时修改global value给玩家挂debuff
function action_sumo_switch_team(context,evt)
--刚刚换队先清掉team上的换队惩罚global value并开始计时如果tick时没有换队则挂上惩罚标记gv
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.EndTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS")
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
--换队增加热情值
LF_Update_Fever(context,defs.switch_team_fever)
--换队的时候给服务端发送消息让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
--清除当前显示的换队惩罚的reminder
local uid_list = ScriptLib.GetSceneUidList(context)
local ret = ScriptLib.RevokePlayerShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {})
ScriptLib.PrintContextLog(context,"FS: Clear reminder result"..ret)
--换队的时候修改team的gv重新刷一下新的avatar身上的加成效果
--ScriptLib.PrintContextLog(context,"FS: team has changed, team_has_change = 1")
LF_Set_Team_Global_Value(context,local_defs.team_has_switch,1)
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",0)
return 0
end
--团灭触发,直接结束玩法
function action_dungeon_all_avatar_die(context,evt)
LF_Stop_Play(context)
return 0
end
function action_dungeon_settle(context,evt)
LF_Stop_Play(context)
return 0
end
------------------------------------------------------------------
--辅助方法---------------------------------------------------------
------------------------------------------------------------------
--关卡相关方法-----------------------------------------------------
--启动玩法方法,初始化各种东西
function LF_Start_Play(context)
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.InitGalleryProgressScore(context, "fever", defs.gallery_id, fever_progress_table, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_SUMO_STAGE, GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NO_DEGRADE)
ScriptLib.InitTimeAxis(context,"FEVER_AXIS",time_axis.fever_axis,true)
ScriptLib.InitTimeAxis(context,"MINION_TIDE_AXIS",time_axis.minion_tide_axis,true)
ScriptLib.InitTimeAxis(context,"ELITE_TIDE_AXIS",time_axis.elite_tide_axis,true)
ScriptLib.InitTimeAxis(context,"ELITE_AXIS",time_axis.elite_axis,false)
LF_Set_Current_Tide_Num(context,0)
LF_Set_Current_Monster_Tide(context,1)
LF_Set_Current_Elite_Index(context,1)
LF_Create_Monster_Tide(context,1)
--启动玩法时给第一队挂一下gv防止一开始就受到惩罚并开启时间轴开始计时
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
--玩法开始的时候给服务端发送消息让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
--加载空气墙
ScriptLib.CreateGadget(context,{config_id = defs.airwall})
end
--终止玩法方法,关掉各种东西
function LF_Stop_Play(context)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
--清理一下空气墙,防止其他问题
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.GADGET, defs.airwall)
--玩法结束,清理掉当前的怪物潮
ScriptLib.KillMonsterTide(context, defs.group_id, current_monster_tide)
ScriptLib.StopGallery(context, defs.gallery_id,true)
ScriptLib.EndTimeAxis(context,"FEVER_AXIS")
ScriptLib.EndTimeAxis(context,"MINION_TIDE_AXIS")
ScriptLib.EndTimeAxis(context,"ELITE_AXIS")
ScriptLib.EndTimeAxis(context,"ELITE_TIDE_AXIS")
--关闭一下地城,以正确触发重新挑战
ScriptLib.CauseDungeonFail(context)
end
--启动一波指定ID的怪物潮需要传入该波怪物潮的ID具体配置在miscs中定义
function LF_Create_Monster_Tide(context,monster_tide_index)
ScriptLib.PrintContextLog(context,"FS: Creating monster tide ["..monster_tide_index.."]")
local monster_config_id_list = monster_tide[monster_tide_index]
--增加怪物潮的计数下一次开启时index会+1防止索引到同一波怪物潮
local tide_num = LF_Get_Current_Tide_Num(context)
LF_Set_Current_Tide_Num(context,tide_num+1)
ScriptLib.AutoMonsterTide(context, tide_num+1, defs.group_id, monster_config_id_list, #monster_config_id_list, defs.min_monster_count,defs.max_monster_count)
end
--在指定的point召唤一个指定ID的精英怪
function LF_Create_Elite_Monster(context,elite_index)
local elite_config_id = elite[elite_index]
local elite_born = LF_Get_Point(context,elite_born_points[elite_index])
ScriptLib.PrintContextLog(context,"FS: Creating elite ["..elite_index.."] at point "..elite_born.pos.x..","..elite_born.pos.y..","..elite_born.pos.z)
ScriptLib.CreateMonsterByConfigIdByPos(context, elite_config_id, elite_born.pos, elite_born.rot)
end
--通用类方法-------------------------------------------------------
--切换场上的场景氛围物件状态
function LF_Activate_Environment_Gadget(context,fever_level)
ScriptLib.PrintContextLog(context,"FS: Activate environment gadgets!")
--根据当前的fever等级改变天气
if (fever_level>local_defs.environment_change_level) then
--ScriptLib.PrintContextLog(context,"FS: Changing environment weather!")
local ret = ScriptLib.SetWeatherAreaState(context, DungeonWeather[fever_level],1)
--ScriptLib.PrintContextLog(context,"FS: The result of starting weather ".. DungeonWeather[fever_level].."is "..ret)
local ret = ScriptLib.EnterWeatherArea(context, DungeonWeather[fever_level])
--ScriptLib.PrintContextLog(context,"FS: The result of changing weather".. DungeonWeather[fever_level].."is "..ret)
end
--切换场上所有的物件的状态
for i = 1, #suites[defs.environment_suite].gadgets do
local config_id = suites[defs.environment_suite].gadgets[i]
local gadget_id = LF_Get_Gadget_Id_By_Config_Id(context,config_id)
--大小火盆
if (gadget_id == 70350306 or gadget_id == 70350307) then
if (fever_level<local_defs.burn_effect_level) then
--点燃小火
--ScriptLib.PrintContextLog(context,"FS: Burn little fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 101)
end
if (fever_level<#fever_progress_table-2 and fever_level>=local_defs.burn_effect_level) then
--喷大火5秒后转回小火
--ScriptLib.PrintContextLog(context,"FS: Burn middle fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
if (fever_level >= #fever_progress_table-2) then
--持续喷大火
--ScriptLib.PrintContextLog(context,"FS: Burn super fire!")
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 202)
end
end
--挂灯
if (gadget_id == 70350308) then
if (fever_level>=local_defs.burn_effect_level) then
--点燃小火
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
end
--场景氛围
if (gadget_id == 70350309) then
--转到对应的gadgetStatedefault-0、phase1-201、phase2-202、phase3-203、phase4-204
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 200+fever_level)
end
end
end
--给team挂global value角色处理各种特殊效果
function LF_Set_Team_Global_Value(context,gv_name,value)
--ScriptLib.PrintContextLog(context,"FS: Sending global values to team!")
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, gv_name, value)
end
-----CRUD类方法----------------------------------------------------
--更新fever条fever_delta为fever条改变值
function LF_Update_Fever(context,fever_delta)
ScriptLib.AddGalleryProgressScore(context, "fever", defs.gallery_id, fever_delta)
end
--更新积分需要传入目标monster的entity id
function LF_Update_Score(context,monster_eid)
local uid_list = ScriptLib.GetSceneUidList(context)
local monster_id = ScriptLib.GetMonsterIdByEntityId(context,monster_eid)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["monster_id"] = monster_id})
end
--返回当前等级下的积分衰减速率
function LF_Get_Fever_Subnum(context)
local fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
for i = 1, #fever_progress_table-1 do
local lower_bound = fever_progress_table[i]
local higher_bound = fever_progress_table[i+1]
if fever>=lower_bound and fever<higher_bound then
return fever_attenuation[i]
end
end
return -1
end
--设置当前怪物潮的波次数注意不等于怪物潮的index。每次创建怪物潮会使波次数+1方便索引新的怪物潮
function LF_Set_Current_Tide_Num(context,value)
ScriptLib.SetGroupTempValue(context, "MinionTide", value, {})
end
--获取当前怪物潮的波次数注意不等于怪物潮的index。每次创建怪物潮会使波次数+1方便索引新的怪物潮
function LF_Get_Current_Tide_Num(context)
return ScriptLib.GetGroupTempValue(context, "MinionTide", {})
end
--设置当前大怪的进度index
function LF_Set_Current_Elite_Index(context,index)
ScriptLib.SetGroupVariableValue(context,"current_elite",index)
end
--获取当前大怪的进度index
function LF_Get_Current_Elite_Index(context)
local elite_index = ScriptLib.GetGroupVariableValue(context,"current_elite")
return elite_index
end
--设置当前怪物潮波次的index
function LF_Set_Current_Monster_Tide(context,index)
ScriptLib.SetGroupVariableValue(context,"current_monster_tide",index)
end
--获取当前怪物潮波次的index
function LF_Get_Current_Monster_Tide(context)
local monster_tide = ScriptLib.GetGroupVariableValue(context,"current_monster_tide")
return monster_tide
end
--根据config id 返回一个点位
function LF_Get_Point(context,point_cid)
for i = 1,#points do
if (points[i].config_id == point_cid) then
return points[i]
end
end
return -1
end
--根据gadget的config_id查询gadget_id
function LF_Get_Gadget_Id_By_Config_Id(context, config_id)
for i = 1,#gadgets do
if (gadgets[i].config_id == config_id) then
return gadgets[i].gadget_id
end
end
return 0
end
--返回一个指定configid的怪物是否是大怪
function LF_Is_Elite(context,monster_cid)
for i = 1,#elite do
if monster_cid == elite[i] then
return true
end
end
return false
end
------------------------------------------------------------------
--server lua call-------------------------------------------------
function SLC_Update_Fever_Ratio(context,new_fever_ratio)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Changing fever ratio to: "..new_fever_ratio)
ScriptLib.SetGroupVariableValue(context,"fever_ratio",new_fever_ratio)
return 0
end
--向客户端下发当前的惩罚状态和fever值用于客户端重连时请求
function SLC_Refresh_Team_State(context)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Request for refresh punishment state: ")
local is_noswitch_punishment = ScriptLib.GetGroupVariableValue(context,"is_noswitch_punishment")
LF_Set_Team_Global_Value(context,"NOSWITCH_PUNISHMENT",is_noswitch_punishment)
local fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
LF_Set_Team_Global_Value(context,"fever",fever)
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,284 @@
-- gallery+challenge。保持challenge和gallery生命周期同步
-- 挑战无达成目标,只是借用侧边栏
--钓鱼开启如果当前没有在挑战则开Gallery开挑战
--挑战倒计时结束关Gallery停止钓鱼
--另外处理Gallery意外先结束同步退出钓鱼-停挑战
-- local defs = {
-- --对应GalleryID
-- gallery_id = 11001,
-- --GroupID
-- group_id = 100000000,
-- --挑战方式 0-指定ID的鱼钓起计数 1-记录指定ID的鱼最大连续成功数
-- fishing_type = 0,
-- --这个Group对应的挑战ID
-- challenge_id = 0,
-- --本挑战中算作计数目标的鱼IDs 鱼ID在FishData表
-- target_fish_id =
-- {1,2,3,4,5},
-- }
--2021.7.14迭代部分挑战时长改为2分钟其余为3分钟
local shortChallenges = {
111178,
111180
}
local extraTriggers = {
--检测挑战结束了的情况
{ name = "challenge_success", config_id = 8000001, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
{ name = "challenge_fail", config_id = 8000002, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
--Gallery结束时关挑战
{ name = "gallery_stop", config_id = 800003, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
--钓鱼开始开Gallery开挑战
{ name = "fishing_start", config_id = 8000004, event = EventType.EVENT_FISHING_START, source = "", condition = "", action = "action_fishing_start", trigger_count = 0},
{ name = "fishing_timeout_flee", config_id = 8000005, event = EventType.EVENT_FISHING_TIMEOUT_FLEE, source = "", condition = "", action = "action_fishing_timeout_flee", trigger_count = 0},
{ name = "fishing_qte_finish", config_id = 8000006, event = EventType.EVENT_FISHING_QTE_FINISH, source = "", condition = "", action = "action_fishing_qte_finish", trigger_count = 0},
{ name = "fishing_score_change", config_id = 8000007, event = EventType.EVENT_VARIABLE_CHANGE, source = "challenge_score", condition = "", action = "", trigger_count = 0, tag = "1000"},
{ name = "leave_region", config_id = 8000008, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0}
}
function Initialize()
for i,v in ipairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
--挑战计数进度
table.insert(variables,{ config_id=50000001,name = "challenge_score", value = 0})
return 0
end
function action_fishing_start(context, evt)
ScriptLib.PrintContextLog(context, "[fishing] action_fishing_start.")
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 0 then
local timeLimit = 180 --默认挑战时长
--重置计分
ScriptLib.SetGroupTempValue(context, "tempScore", 0, {})
ScriptLib.SetGroupTempValue(context, "tempUnmissScore", 0, {})
--设置uid
ScriptLib.SetGroupTempValue(context,"fisher_uid", context.uid, {})
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 1, {})
--开启钓鱼活动Gallery
ScriptLib.PrintContextLog(context, "[fishing] Starting Gallery @"..defs.gallery_id)
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.SetGroupTempValue(context,"gallery_state", 1, {})
--开启挑战
ScriptLib.PrintContextLog(context, "[fishing] Starting Challenge ChallengeID@"..defs.challenge_id.." GroupID@"..defs.group_id)
if CheckIsInTable(context, defs.challenge_id, shortChallenges) then
timeLimit = 120
end
----ScriptLib.ActiveChallenge(context,创建的区域挑战的识别id,DungeonChallengeData里的id,限定的时间,Event_Type所在枚举的序号,Trigger的tag字段值,触发几次)
ScriptLib.ActiveChallenge(context,defs.challenge_id, defs.challenge_id, timeLimit, 3, 1000, 999)
ScriptLib.SetGroupTempValue(context,"challenge_state", 1, {})
end
return 0
end
--处理Gallery万一比挑战先结束
function action_gallery_stop(context, evt)
ScriptLib.SetGroupTempValue(context, "gallery_state", 0, {})
--正常应该Gallery结束控制Challenge结束
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
--停挑战
ScriptLib.StopChallenge(context, defs.challenge_id, 1)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.PrintContextLog(context, "[fishing] Gallery stopped while fishing. StopFishing UID@"..fisher_uid)
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--处理挑战结束
function action_challenge_fail(context, evt)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停止Gallery false失败 true成功。这里需要填false
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
ScriptLib.PrintContextLog(context, "[fishing] Gallery stopped by challenge end.")
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--兜底,处理挑战万一以成功结束
function action_challenge_success(context, evt)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停止Gallery false失败 true成功
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--如果触发了超时逃走直接按一次QTE失败处理
function action_fishing_timeout_flee(context, evt)
--if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
if defs.fishing_type == 1 then
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
end
--end
return 0
end
--每次退出钓鱼QTE状态时触发
--evt.param1 鱼id
--evt.param2 0-失败 1-成功
--evt.param3 0-未进包(即背包满/到达活动要求的获取上限1-进包
--evt.param4 本次QTE中bonus最长持续时间
function action_fishing_qte_finish(context, evt)
local target_fish = evt.param1
local score = 0
local fishing_score = {}
ScriptLib.PrintContextLog(context, "[fishing] fishing_qte_finish. target_fish is @"..target_fish.." is_Free @".. evt.param3)
------计分模式0钓鱼成功直接计数
if defs.fishing_type == 0 then
--若成功钓起
if evt.param2 == 1 then
--如果是目标鱼,加分
if CheckIsInTable(context,target_fish,defs.target_fish_id) then
--单局计数+1
ScriptLib.ChangeGroupTempValue(context, "tempScore", 1, {})
--["fishing_score"]:{钓鱼个数, 最大连续数, 最大Bonus时长} 单目标挑战传单元素就行
score = ScriptLib.GetGroupTempValue(context, "tempScore", {})
fishing_score = {score}
--触发挑战计数Trigger
ScriptLib.SetGroupVariableValue(context, "challenge_score", score)
--如果不是目标鱼不加分但还是要UpdateGallery非目标鱼也要算上
else
score = ScriptLib.GetGroupTempValue(context, "tempScore", {})
fishing_score = {score}
end
--处理是否放生
local is_free = false
if evt.param3 ~= 1 then
is_free = true
end
--更新Gallery分数
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["fishing_score"] = fishing_score, ["fish_id"] = evt.param1, ["is_free"] = is_free})
end
return 0
end
------计分模式1记录最大连续成功数
if defs.fishing_type == 1 then
--若成功钓起...
if evt.param2 == 1 then
--单局计数+1
ScriptLib.ChangeGroupTempValue(context, "tempScore", 1, {})
local tempUnmissScore = ScriptLib.GetGroupTempValue(context, "tempUnmissScore", {})
local tempScore = ScriptLib.GetGroupTempValue(context, "tempScore", {})
--检查是不是该刷新最大连续记录
if tempUnmissScore < tempScore then
--若是,则连续挑战计分更新
ScriptLib.SetGroupTempValue(context,"tempUnmissScore", tempScore, {})
--触发挑战计数Trigger
ScriptLib.SetGroupVariableValue(context, "challenge_score", score)
end
--更新Gallery分数
--["fishing_score"]:{钓鱼个数, 最大连续数, 最大Bonus时长} 单目标挑战传单元素就行
local score = ScriptLib.GetGroupTempValue(context, "tempUnmissScore", {})
fishing_score = {score}
local is_free = false
if evt.param3 ~= 1 then
is_free = true
end
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["fishing_score"] = fishing_score, ["fish_id"] = evt.param1, ["is_free"] =is_free})
--若失败逃逸..
else
ScriptLib.PrintContextLog(context, "[fishing] Type 1: tempScore reset")
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
end
return 0
end
return 0
end
function action_leave_region(context, evt)
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停挑战
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
ScriptLib.StopChallenge(context, defs.challenge_id, 1)
end
--停Gallery false失败 true成功
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.PrintContextLog(context, "[fishing] Leave challenge region. StopFishing UID@"..fisher_uid)
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--用于检查value是否在目标table中
function CheckIsInTable(context,value,table)
for k, v in pairs(table) do
if v == value then
return true
end
end
return false
end
Initialize()

View File

@@ -0,0 +1,310 @@
-- gallery+challenge。保持challenge和gallery生命周期同步
-- 挑战无达成目标,只是借用侧边栏
--钓鱼开启如果当前没有在挑战则开Gallery开挑战
--挑战倒计时结束关Gallery停止钓鱼
--另外处理Gallery意外先结束同步退出钓鱼-停挑战
-- local defs = {
-- --GroupID
-- group_id = 100000000,
-- --对应的GalleryID
-- gallery_id = 11005,
---本挑战中算作计数目标的鱼IDs 鱼ID在FishData表
-- target_fish_id = 19
-- }
local cfg = {
--父挑战ID
father_id = 111181,
--子挑战ID - 钓鱼总数
child_total = 111186,
--子挑战ID - 连续
child_unmiss= 111187,
--子挑战ID - 尽量呆在Bonus区域
child_bonus= 111188
}
local extraTriggers = {
--检测挑战结束
{ name = "challenge_success", config_id = 8000001, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
{ name = "challenge_fail", config_id = 8000002, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
--Gallery结束时关挑战
{ name = "gallery_stop", config_id = 800003, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
--钓鱼开始开Gallery开挑战
{ name = "fishing_start", config_id = 8000004, event = EventType.EVENT_FISHING_START, source = "", condition = "", action = "action_fishing_start", trigger_count = 0},
{ name = "fishing_qte_finish", config_id = 8000005, event = EventType.EVENT_FISHING_QTE_FINISH, source = "", condition = "", action = "action_fishing_qte_finish", trigger_count = 0},
{ name = "fishing_timeout_flee", config_id = 8000010, event = EventType.EVENT_FISHING_TIMEOUT_FLEE, source = "", condition = "", action = "action_fishing_timeout_flee", trigger_count = 0},
--挑战计数用Trigger
{ name = "score_change_total", config_id = 8000006, event = EventType.EVENT_VARIABLE_CHANGE, source = "score_total", condition = "", action = "", trigger_count = 0, tag = "1000"},
{ name = "score_change_unmiss", config_id = 8000007, event = EventType.EVENT_VARIABLE_CHANGE, source = "score_unmiss", condition = "", action = "", trigger_count = 0, tag = "1001"},
{ name = "score_change_bonus", config_id = 8000008, event = EventType.EVENT_VARIABLE_CHANGE, source = "bonus_time", condition = "", action = "", trigger_count = 0, tag = "1002"},
{ name = "leave_region", config_id = 8000009, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0}
}
function Initialize()
for i,v in ipairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
--挑战计数进度-总数
table.insert(variables,{ config_id=50000001,name = "score_total", value = 0})
--挑战计数进度-连续上钩
table.insert(variables,{ config_id=50000002,name = "score_unmiss", value = 0})
--挑战计数进度-最大Bonus时长
table.insert(variables,{ config_id=50000003,name = "bonus_time", value = 0})
--隐藏任务用标志 0-未满足任务条件 1-已满足条件,可触发任务
--这个标志不做no_refresh因为任务那边希望每次都触发
table.insert(variables,{ config_id=50000004,name = "quest_mark", value = 0})
return 0
end
function action_fishing_start(context, evt)
ScriptLib.PrintContextLog(context, "[fishing] action_fishing_start")
--检查钓鱼状态标记
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 0 then
--重置计分
ScriptLib.SetGroupTempValue(context, "tempScore", 0, {})--连续成功计数器
ScriptLib.SetGroupTempValue(context, "tempUnmissScore", 0, {})--最大连续成功数
ScriptLib.SetGroupTempValue(context, "bonusTime", 0, {})--最大Bonus时长
ScriptLib.SetGroupTempValue(context, "totalCount", 0, {}) --钓起目标鱼总数
--设置uid
ScriptLib.SetGroupTempValue(context,"fisher_uid", context.uid, {})
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 1, {})
--开启钓鱼活动Gallery
ScriptLib.PrintContextLog(context, "[fishing] Starting Gallery @"..defs.gallery_id)
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.SetGroupTempValue(context,"gallery_state", 1, {})
--组合挑战
ScriptLib.PrintContextLog(context, "[fishing] Creating Challenge Father ID@"..cfg.father_id)
--创建父挑战
ScriptLib.CreateFatherChallenge(context, cfg.father_id, cfg.father_id, 180, {success=1, fail=1})
ScriptLib.StartFatherChallenge(context, cfg.father_id)
--添加子挑战-总数cfg.child_total
ScriptLib.AttachChildChallenge(context,cfg.father_id,cfg.child_total,cfg.child_total, {3,1000,99}, {context.uid},{success=1, fail=1})
--添加子挑战-连续cfg.child_unmiss
ScriptLib.AttachChildChallenge(context,cfg.father_id,cfg.child_unmiss,cfg.child_unmiss, {3,1001,99}, {context.uid},{success=1, fail=1})
--添加子挑战-bonus cfg.child_bonus
ScriptLib.AttachChildChallenge(context,cfg.father_id,cfg.child_bonus,cfg.child_bonus, {3,1002,99}, {context.uid},{success=1, fail=1})
ScriptLib.SetGroupTempValue(context,"challenge_state", 1, {})
end
return 0
end
--处理Gallery结束
function action_gallery_stop(context, evt)
ScriptLib.SetGroupTempValue(context, "gallery_state", 0, {})
--检查是否要触发隐藏任务
if ScriptLib.GetGroupVariableValue(context, "quest_mark") == 1 then
--ScriptLib.SetGroupVariableValue(context, "quest_mark", 2)
ScriptLib.AddQuestProgress(context, "7266801")
end
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
--停挑战
ScriptLib.EndFatherChallenge(context, cfg.father_id)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--处理挑战自己失败结束
function action_challenge_fail(context, evt)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停止Gallery false失败 true成功。这里需要填false
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
ScriptLib.PrintContextLog(context, "[fishing] Gallery stopped by challenge end.")
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--处理挑战万一成功结束
function action_challenge_success(context, evt)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停止Gallery false失败 true成功
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--如果触发了超时逃走直接按一次QTE失败处理
function action_fishing_timeout_flee(context, evt)
--if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
ScriptLib.PrintContextLog(context, "[fishing] action_fishing_timeout_flee.")
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
--end
return 0
end
--每次退出钓鱼QTE状态时触发
--evt.param1 鱼id
--evt.param2 0-失败 1-成功
--evt.param3 0-未进包(即背包满/到达活动要求的获取上限1-进包
--evt.param4 本次QTE中bonus最长持续时间
function action_fishing_qte_finish(context, evt)
--QTE失败/钓到其他鱼 都算打断连续记录
--若成功钓起
if evt.param2 == 1 then
--拿到当前连续成功数
local tempScore = ScriptLib.GetGroupTempValue(context, "tempScore", {})
local tempUnmissScore = ScriptLib.GetGroupTempValue(context, "tempUnmissScore", {})
--看是不是目标鱼
if evt.param1 == defs.target_fish_id then
---------处理隐藏任务
if ScriptLib.GetGroupVariableValue(context, "quest_mark") == 0 then
ScriptLib.SetGroupVariableValue(context, "quest_mark", 1)
end
---------处理总数
--单局计数+1
ScriptLib.ChangeGroupTempValue(context, "totalCount", 1, {})
ScriptLib.ChangeGroupTempValue(context, "tempScore", 1, {})
tempScore = ScriptLib.GetGroupTempValue(context, "tempScore", {})
--触发总数挑战的计数Trigger
ScriptLib.SetGroupVariableValue(context, "score_total", tempScore)
--------处理连续成功
--检查是不是该刷新最大连续记录
if tempUnmissScore < tempScore then
--若是,则连续挑战计分更新
ScriptLib.SetGroupTempValue(context,"tempUnmissScore", tempScore, {})
--触发连续成功挑战计数Trigger
ScriptLib.SetGroupVariableValue(context, "score_unmiss", tempScore)
end
--------处理Bonus时间
--检查是不是该刷新最大bonus时间记录,evt里发过来是整数还是取一下floor保险
ScriptLib.PrintContextLog(context, "This BonusTime@"..evt.param4)
local diff = 0
--不大于180秒正常算差
if evt.param4 <= 180 then
diff = math.floor(evt.param4 - ScriptLib.GetGroupTempValue(context, "bonusTime", {}))
--大于180秒按180秒算差
else
diff = math.floor(180 - ScriptLib.GetGroupTempValue(context, "bonusTime", {}))
end
--差值是几就触发几次Trigger
if diff > 0 then
ScriptLib.SetGroupTempValue(context,"bonusTime", evt.param4, {})
UpdateBonusTimeForChallenge(context,diff)
end
--如果不是目标鱼也要更新Gallery
else
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
end
--------更新Gallery分数
--["fishing_score"]:{钓鱼个数, 最大连续数, 最大Bonus时长} 单目标挑战传单元素就行
tempUnmissScore = ScriptLib.GetGroupTempValue(context, "tempUnmissScore", {})
local totalCount = ScriptLib.GetGroupTempValue(context, "totalCount", {})
local bonusTime = ScriptLib.GetGroupTempValue(context, "bonusTime", {})
local fishing_score = {totalCount, tempUnmissScore, bonusTime}
local is_free = false
if evt.param3 ~= 1 then
is_free = true
end
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["fishing_score"] = fishing_score, ["fish_id"] = evt.param1, ["is_free"] = is_free})
ScriptLib.PrintContextLog(context, "[fishing] Gallery Score updated. score_total@"..totalCount.." score_unmiss@"..tempUnmissScore.." MaxBounesTime@"..bonusTime)
--若失败逃逸
else
ScriptLib.PrintContextLog(context, "[fishing] Moonfin: tempScore reset")
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
end
return 0
end
function UpdateBonusTimeForChallenge(context, count)
for i = 1, count do
ScriptLib.ChangeGroupVariableValue(context, "bonus_time", 1)
end
return 0
end
function action_leave_region(context, evt)
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停挑战
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
--停挑战
ScriptLib.EndFatherChallenge(context, cfg.father_id)
end
--停Gallery false失败 true成功
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.PrintContextLog(context, "[fishing] Leave challenge region. StopFishing UID@"..fisher_uid)
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
Initialize()

View File

@@ -0,0 +1,312 @@
-- Trigger变量
--[[
local defs = {
PotConfigIDA =148004,
PotConfigIDB =148005,
PotConfigIDC =148006,
targetColdTime = 10,
targetHeatTime = 10,
BeHitByFireTemp = 10,
BeHitByIceWaterTemp = -10
}
--]]
---------------------
local tempTrigger = {
--监听GadgetState变化
--监听值变化
{ config_id = 2330001, name = "EVENT_VARIABLE_CHANGE_A", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenATemp",
condition = "", action = "action_VARIABLE_CHANGE_A", trigger_count = 0},
{ config_id = 2330002, name = "EVENT_VARIABLE_CHANGE_B", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenBTemp",
condition = "", action = "action_VARIABLE_CHANGE_B", trigger_count = 0},
{ config_id = 2330003, name = "EVENT_VARIABLE_CHANGE_C", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenCTemp",
condition = "", action = "action_VARIABLE_CHANGE_C", trigger_count = 0},
{ config_id = 2330004, name = "TIME_AXIS_PotOverColdA", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdA",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330005, name = "TIME_AXIS_PotOverColdB", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdB",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330006, name = "TIME_AXIS_PotOverColdC", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdC",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330007, name = "TIME_AXIS_PotOverHeatA", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatA",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330008, name = "TIME_AXIS_PotOverHeatB", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatB",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330009, name = "TIME_AXIS_PotOverHeatC", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatC",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330010, name = "EVENT_VARIABLE_CHANGE_StartPotTaunt", event = EventType.EVENT_TIME_AXIS_PASS, source = "StartPotTaunt",
condition = "", action = "action_StartPotTaunt", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
return 0
end
--------公用函数----------
function action_VARIABLE_CHANGE_A(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDA,evt.param1)
return 0
end
function action_VARIABLE_CHANGE_B(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDB,evt.param1)
return 0
end
function action_VARIABLE_CHANGE_C(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDC,evt.param1)
return 0
end
-- 过冷过热双检查
function action_PotOverState(context, evt)
local state = GetKeyWord(evt.source_name) -- 返回值为 “Cold" or "Heat"
local characterState = GetCharacterKeyWord(state)[1] -- 返回值为 冷 or 热
local overStateValue = GetCharacterKeyWord(state)[2] -- 返回值为 203 or 202
local targetConfigID = GetTargetConfigID(context,evt.source_name)
if (targetConfigID == 0) then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : source_name = ".. evt.source_name .. "非法")
return 0
end
local targetPotName = GetPotName(context,targetConfigID)
local tickTimeKey = "Over".. state .."Time"..targetPotName
local timeAxisKey = "PotOver" ..state.. targetPotName
local targetTime = defs.targetColdTime
local currentTime = ScriptLib.GetGroupTempValue(context, tickTimeKey, {}) + 1 --增加1秒计时
if 201 ~= ScriptLib.GetGadgetStateByConfigId(context, 0, targetConfigID) then
-- 如果锅子已经切进其它状态关闭当前TimeAxis
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉"..targetPotName .. " 强制结束时间轴")
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
end
-- 已超时
if currentTime >= targetTime then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 过".. characterState .."超时,关闭锅炉" .. targetPotName)
-- 锅子切冷炸
ScriptLib.SetGadgetStateByConfigId(context, targetConfigID, overStateValue)
-- 时间轴结束/计时清空
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
else
local IsOverState = false
if state == "Cold" then
IsOverState = IsOverCold(context,targetConfigID)
end
if state == "Heat" then
IsOverState = IsOverHeat(context,targetConfigID)
end
if false == IsOverState then
-- 已炸锅
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉".. targetPotName .. " 结束过".. characterState) --描述切换
-- 时间轴结束/计时清空
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
else
-- 锅子异常中
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉".. targetPotName .. " 持续过".. characterState ..",已经过" .. currentTime .."") --描述切换
-- 计时累加
ScriptLib.SetGroupTempValue(context, tickTimeKey, currentTime, {})
return 0
end
end
end
-- 侦测LD调用
function action_StartPotTaunt(context, evt)
local actionName = evt.source_name
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 嘲讽开启判定 actionName = "..actionName .. " tempValue = " .. evt.param1 - evt.param2)
if 1 == evt.param1 - evt.param2 then
local functionParam1 = ScriptLib.GetGroupTempValue(context,actionName .. "Param1",{})
local functionParam2 = ScriptLib.GetGroupTempValue(context,actionName .. "Param2",{})
StartPotTaunt(context,functionParam1,functionParam2)
end
return 0
end
-- serverLuaCall 锅子挨火打
function BeHitByFire(context, evt)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨火打| source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local configId = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
local targetPotName = GetPotName(context,configId)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
ScriptLib.SetGroupVariableValue(context,tempKey,tempValue+defs.BeHitByFireTemp)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨火打| Change "..tempKey.." from" .. tempValue ..
" to ".. tempValue+defs.BeHitByFireTemp)
return 0
end
-- serverLuaCall 锅子挨冰水打
function BeHitByIceWater(context, evt)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨冰水打| source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local configId = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
local targetPotName = GetPotName(context,configId)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
ScriptLib.SetGroupVariableValue(context,tempKey,tempValue+defs.BeHitByIceWaterTemp)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨冰水打| Change "..tempKey.." from" .. tempValue ..
" to ".. tempValue+defs.BeHitByIceWaterTemp)
return 0
end
------------设置仙人锅开启嘲讽---------
function StartPotTaunt(context,configId,startTaunt)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : configId = "..configId .. " startTaunt = " .. startTaunt)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, configId, "SGV_Is_Taunting", startTaunt)
return 0
end
--------私有函数----------
function Pot_Pipeline(context,config_id,value)
-- 即时更新SGV_Thermometer_Value
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : configId = ".. config_id .. " SGV_Thermometer_Value= " .. value)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_Thermometer_Value", value)
-- 确认是否进入炸锅倒计时
Pot_OverColdPipeline(context,config_id)
Pot_OverHeatPipeline(context,config_id)
return 0
end
function Pot_OverColdPipeline(context,config_id)
local targetPotName = GetPotName(context,config_id)
local tempKey = "PotOverCold".. targetPotName
local tickTimeKey = "OverColdTime"..targetPotName
if IsOverCold(context,config_id) and 1 ~= ScriptLib.GetGroupTempValue(context, tempKey, {}) then
-- 过冷状态且没有开启独立时间轴时
local coldTimeAxis = {}
local timeValue = 1
local targetColdTime = math.ceil(defs.targetColdTime/timeValue)
-- 解析时间轴数组
for i = 1, targetColdTime, 1 do
coldTimeAxis[i] = timeValue
timeValue = timeValue + 1
end
-- tempKey依赖时间轴结束自己关闭
ScriptLib.SetGroupTempValue(context, tickTimeKey, 0, {})
ScriptLib.SetGroupTempValue(context, tempKey, 1, {})
-- 开启一个每秒Tick的时间轴
ScriptLib.InitTimeAxis(context, tempKey, coldTimeAxis, false)
ScriptLib.ShowReminder(context, 400066)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 开启OverCold观测 Send Time Axis")
end
return 0
end
function Pot_OverHeatPipeline(context,config_id)
local targetPotName = GetPotName(context,config_id)
local tempKey = "PotOverHeat".. targetPotName
local tickTimeKey = "OverHeatTime"..targetPotName
if IsOverHeat(context,config_id) and 1 ~= ScriptLib.GetGroupTempValue(context, tempKey, {}) then
-- 过冷状态且没有开启独立时间轴时
local heatTimeAxis = {}
local timeValue = 1
local targetColdTime = math.ceil(defs.targetHeatTime/timeValue)
-- 解析时间轴数组
for i = 1, targetColdTime, 1 do
heatTimeAxis[i] = timeValue
timeValue = timeValue + 1
end
-- tempKey依赖时间轴结束自己关闭
ScriptLib.SetGroupTempValue(context, tickTimeKey, 0, {})
ScriptLib.SetGroupTempValue(context, tempKey, 1, {})
-- 开启一个每秒Tick的时间轴
ScriptLib.InitTimeAxis(context, tempKey, heatTimeAxis, false)
ScriptLib.ShowReminder(context, 400066)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 开启OverHeat观测 Send Time Axis")
end
return 0
end
-- 返回当前ConfigID是否过冷
function IsOverCold(context,config_id)
if config_id == nil then
return true
end
local safeFrom = gadgets[config_id].server_global_value_config["SGV_Thermometer_SafeFrom"] * 100
local targetPotName = GetPotName(context,config_id)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
return tempValue<=safeFrom
end
-- 返回当前ConfigID是否过热
function IsOverHeat(context,config_id)
if config_id == nil then
return true
end
local safeTo = gadgets[config_id].server_global_value_config["SGV_Thermometer_SafeTo"] * 100
local targetPotName = GetPotName(context,config_id)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
return tempValue>=safeTo
end
--根据ConfigID,获取对应锅关键词
function GetPotName(context,config_id)
if config_id == defs.PotConfigIDA then
return "A"
end
if config_id == defs.PotConfigIDB then
return "B"
end
if config_id == defs.PotConfigIDC then
return "C"
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : Error! Config_id = ".. config_id)
return 0
end
--根据时间轴关键词,获取对应锅ConfigID
function GetTargetConfigID(context,keyName)
if keyName == "PotOverHeatA" or keyName == "PotOverColdA" then
return defs.PotConfigIDA
end
if keyName == "PotOverHeatB" or keyName == "PotOverColdB" then
return defs.PotConfigIDB
end
if keyName == "PotOverHeatC" or keyName == "PotOverColdC" then
return defs.PotConfigIDC
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : Error! KeyName = ".. keyName)
return 0
end
--根据时间轴关键词,获取冷还是热
function GetKeyWord(keyName)
if keyName == "PotOverColdA" or keyName == "PotOverColdB" or keyName == "PotOverColdC" then
return "Cold"
end
if keyName == "PotOverHeatA" or keyName == "PotOverHeatB" or keyName == "PotOverHeatC" then
return "Heat"
end
return 0
end
--根据冷还是热,返回相关汉字 以及 GadgetState
function GetCharacterKeyWord(keyName)
if keyName == "Cold" then
return {"",203}
end
if keyName == "Heat"then
return {"",202}
end
return { "",0 }
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---
--ScriptLib.SetGroupVariableValue(context,"ovenATemp",85)
--Pot_Pipeline(context,148004,85)

View File

@@ -0,0 +1,622 @@
-- Trigger变量
--[[
local defs = {
ButtonLeftConfig = 51001,
ButtonRightConfig = 51002,
StoveConfig = 51003,
PotConfigIDA =51004,
PotConfigIDB =51005,
PotConfigIDC =51006,
targetColdTime = 14,
targetHeatTime = 14,
BeHitByFireTemp = 5,
BeHitByIceWaterTemp = -5,
SecondTempChange = { 7, -3}, -- 每秒对应上升或下降的温度变化
StartTemp = {50,35,56}, -- ABC三壶的初始温度
PlatFormRoute ={ -- 定义各个Route的功能只需对应Log修改数据即可
[300100395] = {curPos = 2,reachPos = 2,tempDirs = {2,1,2},log = "从中间移动到中间,在中间徘徊"},
[300100396] = {curPos = 1,reachPos = 2,tempDirs = {2,1,2},log = "从左边移动到中间"},
[300100397] = {curPos = 2,reachPos = 3,tempDirs = {2,2,1},log = "从中间移动到右边"},
[300100398] = {curPos = 3,reachPos = 2,tempDirs = {2,1,2},log = "从右边移动到中间"},
[300100399] = {curPos = 2,reachPos = 1,tempDirs = {1,2,2},log = "从中间移动到左边"}
}
}
local challengeParam = {
90, -- Time
72, -- 72//EVENT_TIME_AXIS_PASS
666,-- TAG
1 -- 触发次数
}
--]]
---------------------
local tempTrigger = {
--监听GadgetState变化
--监听值变化
{ config_id = 2330001, name = "EVENT_VARIABLE_CHANGE_A", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenATemp",
condition = "", action = "action_VARIABLE_CHANGE_A", trigger_count = 0},
{ config_id = 2330002, name = "EVENT_VARIABLE_CHANGE_B", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenBTemp",
condition = "", action = "action_VARIABLE_CHANGE_B", trigger_count = 0},
{ config_id = 2330003, name = "EVENT_VARIABLE_CHANGE_C", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenCTemp",
condition = "", action = "action_VARIABLE_CHANGE_C", trigger_count = 0},
{ config_id = 2330004, name = "TIME_AXIS_PotOverColdA", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdA",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330005, name = "TIME_AXIS_PotOverColdB", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdB",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330006, name = "TIME_AXIS_PotOverColdC", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdC",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330007, name = "TIME_AXIS_PotOverHeatA", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatA",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330008, name = "TIME_AXIS_PotOverHeatB", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatB",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330009, name = "TIME_AXIS_PotOverHeatC", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatC",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330010, name = "EVENT_VARIABLE_CHANGE_StartPotTaunt", event = EventType.EVENT_TIME_AXIS_PASS, source = "StartPotTaunt",
condition = "", action = "action_StartPotTaunt", trigger_count = 0},
{ config_id = 2330011, name = "EVENT_VARIABLE_CHANGE_ChallengeStart", event = EventType.EVENT_VARIABLE_CHANGE, source = "startOrNot",
condition = "", action = "action_CHALLENGESTART", trigger_count = 0},
{ config_id = 2330012, name = "TIME_AXIS_TempControl", event = EventType.EVENT_TIME_AXIS_PASS, source = "TempControl",
condition = "", action = "action_TEMPCONTROL", trigger_count = 0},
{ config_id = 2330013, name = "PLATFORM_REACH_POINT_STOVE", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "",
condition = "", action = "action_PLATFORM_REACH_POINT_STOVE", trigger_count = 0},
{ config_id = 2330014, name = "BUTTON_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "",
condition = "", action = "action_BUTTON_STATE_CHANGE", trigger_count = 0},
{ config_id = 2330015, name = "POT_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "",
condition = "", action = "action_POT_STATE_CHANGE", trigger_count = 0},
{ config_id = 2330016, name = "TIME_AXIS_ChallengeTimer", event = EventType.EVENT_TIME_AXIS_PASS, source = "ChallengeTimer",
condition = "", action = "", trigger_count = 0,tag = tostring(challengeParam[3])},
{ config_id = 2330017, name = "EVENT_CHALLENGE_SUCCESS_LevelChange", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "888",
condition = "", action = "action_CHALLENGE_SUCCESS_LevelChange", trigger_count = 0},
{ config_id = 2330018, name = "EVENT_CHALLENGE_FAIL_LevelChange", event = EventType.EVENT_CHALLENGE_FAIL, source = "888",
condition = "", action = "action_CHALLENGE_FAIL_LevelChange", trigger_count = 0},
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
gadgets[defs.PotConfigIDA].server_global_value_config["SGV_Thermometer_Value"] = defs.StartTemp[1]
gadgets[defs.PotConfigIDB].server_global_value_config["SGV_Thermometer_Value"] = defs.StartTemp[2]
gadgets[defs.PotConfigIDC].server_global_value_config["SGV_Thermometer_Value"] = defs.StartTemp[3]
return 0
end
--------公用函数----------
-- 当startOrNot被设置为1时挑战开始启动
function action_CHALLENGESTART(context,evt)
if 1 ~= evt.param1 then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : startOrNot被设置为" .. evt.param1 ..",无视之。" )
return 0
end
--GadgetState初始化
ScriptLib.SetGadgetStateByConfigId(context,defs.StoveConfig, 201)
ScriptLib.SetGadgetStateByConfigId(context,defs.PotConfigIDA, 201)
ScriptLib.SetGadgetStateByConfigId(context,defs.PotConfigIDB, 201)
ScriptLib.SetGadgetStateByConfigId(context,defs.PotConfigIDC, 201)
-- 因为初始位置一定在中间
ScriptLib.SetGroupVariableValue(context, "ovenATempDirection", 2)
ScriptLib.SetGroupVariableValue(context, "ovenBTempDirection", 1)
ScriptLib.SetGroupVariableValue(context, "ovenCTempDirection", 2)
--开启挑战
local challengeTime = challengeParam[1]
ScriptLib.StartChallenge(context, 888, 245, challengeParam)
-- 每秒统计温度计时器
ScriptLib.InitTimeAxis(context, "TempControl", {1}, true)
-- 挑战胜利计时器
ScriptLib.InitTimeAxis(context, "ChallengeTimer", {challengeTime-0.5}, false)
-- 挑战后控制第一波移动
StoveMoveByButtonState(context)
return 0
end
-- 挑战开始后启动的时间轴,每秒结算温度变化
function action_TEMPCONTROL(context,evt)
-- 计算温度变化
CalculateOvenTemp(context,"ovenA")
CalculateOvenTemp(context,"ovenB")
CalculateOvenTemp(context,"ovenC")
return 0
end
-- 检测炉子抵达的地点,用来处理是否要将其运往下一站
function action_PLATFORM_REACH_POINT_STOVE(context, evt)
if 1 ~= evt.param3 then
return 0
end
if defs.StoveConfig ~= evt.param1 then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 检测到无关的移动其ConfigID为" .. evt.param1 )
return 0
end
local routeID = evt.param2
local tempDirs = defs.PlatFormRoute[routeID].tempDirs
local reachPos = defs.PlatFormRoute[routeID].reachPos
local fireDirection = ScriptLib.GetGroupVariableValue(context, "fireDirection")
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 炉子移动到" .. reachPos .. "。fireDirection为".. fireDirection..",当前各炉子温度方向为" .. arrayToString(tempDirs))
ScriptLib.SetGroupVariableValue(context, "curPos", reachPos)
-- 尝试移动炉子
local moveState = StoveMove(context,reachPos,fireDirection)
-- 炉子无法移动 或者 玩家已经离开按钮时 需要重新计算温度变化
if -1 == moveState or 0 == fireDirection then
-- 到底指定地点温度变化
ScriptLib.SetGroupVariableValue(context, "ovenATempDirection", tempDirs[1])
ScriptLib.SetGroupVariableValue(context, "ovenBTempDirection", tempDirs[2])
ScriptLib.SetGroupVariableValue(context, "ovenCTempDirection", tempDirs[3])
end
return 0
end
-- 按钮的状态变化,检测后用来控制炉子位移
function action_BUTTON_STATE_CHANGE(context, evt)
if evt.param2 ~= defs.ButtonLeftConfig and evt.param2 ~= defs.ButtonRightConfig then
return 0
end
local startOrNot = ScriptLib.GetGroupVariableValue(context, "startOrNot")
if startOrNot == 0 then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 挑战没开的场合,无法移动炉子")
return 0
end
StoveMoveByButtonState(context)
return 0
end
-- 锅子状态侦测,一旦某个锅子爆炸了,立刻重置挑战并处理挑战存档
function action_POT_STATE_CHANGE(context,evt)
-- Gadget是锅子且爆了开始处理逻辑
local potName = GetPotName(context,evt.param2)
if 0 ~= potName and (202 == evt.param1 or 203 == evt.param1) then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 锅子" .. potName .. "炸了,关卡开始设置状态")
-- 切挑战失败
ScriptLib.StopChallenge(context, 888, 0)
end
return 0
end
-- 计时器结束时,关闭锅子全部状态
function action_CHALLENGE_SUCCESS_LevelChange(context,evt)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 挑战胜利,设置关卡状态")
local potList = {defs.PotConfigIDA,defs.PotConfigIDB,defs.PotConfigIDC}
for i = 1,#potList do
local targetPot = potList[i]
-- 全部锅子进入状态 0
ScriptLib.SetGadgetStateByConfigId(context,targetPot, 901)
-- 关闭全锅子的嘲讽
StartPotTaunt(context,targetPot,0)
end
RecoverLevel(context)
return 0
end
function action_CHALLENGE_FAIL_LevelChange(context,evt)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 挑战失败,重置关卡状态")
local potList = {defs.PotConfigIDA,defs.PotConfigIDB,defs.PotConfigIDC}
-- 切其它锅子进入State0
for i = 1,#potList do
local targetPot = potList[i]
-- 只要锅子不是处于202或203
local targetPotState = ScriptLib.GetGadgetStateByConfigId(context, 0, targetPot)
if 202 ~= targetPotState and 203 ~= targetPotState then
ScriptLib.SetGadgetStateByConfigId(context,targetPot, 0)
end
-- 关闭关卡计时器
ScriptLib.EndTimeAxis(context, "ChallengeTimer")
-- 关闭全锅子的嘲讽
StartPotTaunt(context,targetPot,0)
end
RecoverLevel(context)
return 0
end
-- 关卡回复逻辑
function RecoverLevel(context)
-- 关闭炉子火焰
ScriptLib.SetGadgetStateByConfigId(context,defs.StoveConfig, 0)
-- 方向停止
ScriptLib.SetGroupVariableValue(context, "fireDirection", 0)
-- 设置温度变化为0
ScriptLib.SetGroupVariableValue(context, "ovenATempDirection", 0)
ScriptLib.SetGroupVariableValue(context, "ovenBTempDirection", 0)
ScriptLib.SetGroupVariableValue(context, "ovenCTempDirection", 0)
-- 停止温度运作
ScriptLib.SetGroupVariableValue(context, "startOrNot", 0)
-- 关闭计时器
ScriptLib.EndTimeAxis(context, "TempControl")
-- 温度初始化
ScriptLib.SetGroupVariableValue(context, "ovenATemp", defs.StartTemp[1])
ScriptLib.SetGroupVariableValue(context, "ovenBTemp", defs.StartTemp[2])
ScriptLib.SetGroupVariableValue(context, "ovenCTemp", defs.StartTemp[3])
-- 让炉子回到中间
local curPos = ScriptLib.GetGroupVariableValue(context, "curPos")
local fireDirection = 2 - curPos
ScriptLib.StopPlatform(context, defs.StoveConfig)
StoveMove(context,curPos,fireDirection)
ScriptLib.SetGroupVariableValue(context, "curPos", 2)
end
-- 侦测温度值变化
function action_VARIABLE_CHANGE_A(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDA,evt.param1)
return 0
end
-- 侦测温度值变化
function action_VARIABLE_CHANGE_B(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDB,evt.param1)
return 0
end
-- 侦测温度值变化
function action_VARIABLE_CHANGE_C(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDC,evt.param1)
return 0
end
-- 过冷过热双检查
function action_PotOverState(context, evt)
local state = GetKeyWord(evt.source_name) -- 返回值为 “Cold" or "Heat"
local characterState = GetCharacterKeyWord(state)[1] -- 返回值为 冷 or 热
local overStateValue = GetCharacterKeyWord(state)[2] -- 返回值为 203 or 202
local targetConfigID = GetTargetConfigID(context,evt.source_name)
if (targetConfigID == 0) then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : source_name = ".. evt.source_name .. "非法")
return 0
end
local targetPotName = GetPotName(context,targetConfigID)
local tickTimeKey = "Over".. state .."Time"..targetPotName
local timeAxisKey = "PotOver" ..state.. targetPotName
local targetTime = defs.targetColdTime
local currentTime = ScriptLib.GetGroupTempValue(context, tickTimeKey, {}) + 1 --增加1秒计时
if 201 ~= ScriptLib.GetGadgetStateByConfigId(context, 0, targetConfigID) then
-- 如果锅子已经切进其它状态关闭当前TimeAxis
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉"..targetPotName .. " 强制结束时间轴")
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
end
-- 已超时
if currentTime >= targetTime then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 过".. characterState .."超时,关闭锅炉" .. targetPotName)
-- 锅子切冷炸
ScriptLib.SetGadgetStateByConfigId(context, targetConfigID, overStateValue)
-- 时间轴结束/计时清空
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
else
local IsOverState = false
if state == "Cold" then
IsOverState = IsOverCold(context,targetConfigID)
end
if state == "Heat" then
IsOverState = IsOverHeat(context,targetConfigID)
end
if false == IsOverState then
-- 已炸锅
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉".. targetPotName .. " 结束过".. characterState) --描述切换
-- 时间轴结束/计时清空
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
else
-- 锅子异常中
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉".. targetPotName .. " 持续过".. characterState ..",已经过" .. currentTime .."") --描述切换
-- 计时累加
ScriptLib.SetGroupTempValue(context, tickTimeKey, currentTime, {})
return 0
end
end
return 0
end
-- 侦测LD调用
function action_StartPotTaunt(context, evt)
local actionName = evt.source_name
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 嘲讽开启判定 actionName = "..actionName .. " tempValue = " .. evt.param1 - evt.param2)
if 1 == evt.param1 - evt.param2 then
local functionParam1 = ScriptLib.GetGroupTempValue(context,actionName .. "Param1",{})
local functionParam2 = ScriptLib.GetGroupTempValue(context,actionName .. "Param2",{})
StartPotTaunt(context,functionParam1,functionParam2)
end
return 0
end
-- serverLuaCall 锅子挨火打
function BeHitByFire(context, evt)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨火打| source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local configId = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
local targetPotName = GetPotName(context,configId)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
ScriptLib.SetGroupVariableValue(context,tempKey,tempValue+defs.BeHitByFireTemp)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨火打| Change "..tempKey.." from" .. tempValue ..
" to ".. tempValue+defs.BeHitByFireTemp)
return 0
end
-- serverLuaCall 锅子挨冰水打
function BeHitByIceWater(context, evt)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨冰水打| source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local configId = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
local targetPotName = GetPotName(context,configId)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
ScriptLib.SetGroupVariableValue(context,tempKey,tempValue+defs.BeHitByIceWaterTemp)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨冰水打| Change "..tempKey.." from" .. tempValue ..
" to ".. tempValue+defs.BeHitByIceWaterTemp)
return 0
end
------------设置仙人锅开启嘲讽---------
-- 控制锅子是否开启嘲讽
function StartPotTaunt(context,configId,startTaunt)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : configId = "..configId .. " startTaunt = " .. startTaunt)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, configId, "SGV_Is_Taunting", startTaunt)
return 0
end
--------私有函数----------
-- 温度管理管线
function Pot_Pipeline(context,config_id,value)
-- 即时更新SGV_Thermometer_Value
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : configId = ".. config_id .. " SGV_Thermometer_Value= " .. value)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_Thermometer_Value", value)
-- 确认是否进入炸锅倒计时
Pot_OverColdPipeline(context,config_id)
Pot_OverHeatPipeline(context,config_id)
return 0
end
-- 过冷检测管线
function Pot_OverColdPipeline(context,config_id)
local targetPotName = GetPotName(context,config_id)
local tempKey = "PotOverCold".. targetPotName
local tickTimeKey = "OverColdTime"..targetPotName
if IsOverCold(context,config_id) and 1 ~= ScriptLib.GetGroupTempValue(context, tempKey, {}) then
-- 过冷状态且没有开启独立时间轴时
local coldTimeAxis = {}
local timeValue = 1
local targetColdTime = math.ceil(defs.targetColdTime/timeValue)
-- 解析时间轴数组
for i = 1, targetColdTime, 1 do
coldTimeAxis[i] = timeValue
timeValue = timeValue + 1
end
-- tempKey依赖时间轴结束自己关闭
ScriptLib.SetGroupTempValue(context, tickTimeKey, 0, {})
ScriptLib.SetGroupTempValue(context, tempKey, 1, {})
-- 开启一个每秒Tick的时间轴
ScriptLib.InitTimeAxis(context, tempKey, coldTimeAxis, false)
ScriptLib.ShowReminder(context, 400066)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 开启OverCold观测 Send Time Axis")
end
return 0
end
-- 过热检测管线
function Pot_OverHeatPipeline(context,config_id)
local targetPotName = GetPotName(context,config_id)
local tempKey = "PotOverHeat".. targetPotName
local tickTimeKey = "OverHeatTime"..targetPotName
if IsOverHeat(context,config_id) and 1 ~= ScriptLib.GetGroupTempValue(context, tempKey, {}) then
-- 过冷状态且没有开启独立时间轴时
local heatTimeAxis = {}
local timeValue = 1
local targetColdTime = math.ceil(defs.targetHeatTime/timeValue)
-- 解析时间轴数组
for i = 1, targetColdTime, 1 do
heatTimeAxis[i] = timeValue
timeValue = timeValue + 1
end
-- tempKey依赖时间轴结束自己关闭
ScriptLib.SetGroupTempValue(context, tickTimeKey, 0, {})
ScriptLib.SetGroupTempValue(context, tempKey, 1, {})
-- 开启一个每秒Tick的时间轴
ScriptLib.InitTimeAxis(context, tempKey, heatTimeAxis, false)
ScriptLib.ShowReminder(context, 400066)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 开启OverHeat观测 Send Time Axis")
end
return 0
end
-- 返回当前ConfigID是否过冷
function IsOverCold(context,config_id)
if config_id == nil then
return true
end
local safeFrom = gadgets[config_id].server_global_value_config["SGV_Thermometer_SafeFrom"] * 100
local targetPotName = GetPotName(context,config_id)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
return tempValue<=safeFrom
end
-- 返回当前ConfigID是否过热
function IsOverHeat(context,config_id)
if config_id == nil then
return true
end
local safeTo = gadgets[config_id].server_global_value_config["SGV_Thermometer_SafeTo"] * 100
local targetPotName = GetPotName(context,config_id)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
return tempValue>=safeTo
end
-- 根据锅炉当前为加热或降温设置锅子温度
function CalculateOvenTemp(context,potName)
local tempDir = ScriptLib.GetGroupVariableValue(context, potName.."TempDirection")
local temp = ScriptLib.GetGroupVariableValue(context, potName.."Temp")
if tempDir > 2 or tempDir < 1 then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 锅子".. potName .."方向不合法,值为" .. tempDir)
end
temp = temp + defs.SecondTempChange[tempDir]
temp = math.max(math.min(temp,100),0)
ScriptLib.SetGroupVariableValue(context, potName.."Temp", temp)
return 0
end
--根据ConfigID或Pos信息,获取对应锅关键词
function GetPotName(context,keyName)
if keyName == defs.PotConfigIDA or keyName == 1 then
return "A"
end
if keyName == defs.PotConfigIDB or keyName == 2 then
return "B"
end
if keyName == defs.PotConfigIDC or keyName == 3 then
return "C"
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : GetPotName Error! KeyName = ".. keyName)
return 0
end
--根据时间轴关键词,获取对应锅ConfigID
function GetTargetConfigID(context,keyName)
if keyName == "PotOverHeatA" or keyName == "PotOverColdA" then
return defs.PotConfigIDA
end
if keyName == "PotOverHeatB" or keyName == "PotOverColdB" then
return defs.PotConfigIDB
end
if keyName == "PotOverHeatC" or keyName == "PotOverColdC" then
return defs.PotConfigIDC
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : GetTargetConfigID Error! KeyName = ".. keyName)
return 0
end
-- 根据当前踏板状态控制锅炉移动
function StoveMoveByButtonState(context)
local leftState = ScriptLib.GetGadgetStateByConfigId(context, 0, defs.ButtonLeftConfig)
local rightState = ScriptLib.GetGadgetStateByConfigId(context, 0, defs.ButtonRightConfig)
local curPos = ScriptLib.GetGroupVariableValue(context, "curPos")
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : LeftState" .. leftState .. "RightState" .. rightState)
local fireDirection = 0
if 201 == leftState and 0 == rightState then
fireDirection = -1
ScriptLib.SetGroupVariableValue(context, "fireDirection", fireDirection)
StoveMove(context,curPos,fireDirection)
return 0
end
if 0 == leftState and 201 == rightState then
fireDirection = 1
ScriptLib.SetGroupVariableValue(context, "fireDirection", fireDirection)
StoveMove(context,curPos,fireDirection)
return 0
end
if 201 == leftState and 201 == rightState then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 左右按钮已全部开启,暂时维持之前方向")
ScriptLib.SetGroupVariableValue(context, "fireDirection", 0)
return 0
end
if 0 == leftState and 0 == rightState then
ScriptLib.SetGroupVariableValue(context, "fireDirection", 0)
return 0
end
return 0
end
-- 管理炉子移动的方法
function StoveMove(context,curPos,fireDirection)
local targetPos = curPos + fireDirection
local routeID = GetRouteID(curPos,targetPos)
if 0 == routeID then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : StoveMove 不成功,参数为 curPos =" .. curPos .. ",fireDirection =" .. fireDirection )
return -1
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 炉子开始移动," .. defs.PlatFormRoute[routeID].log)
ScriptLib.SetPlatformRouteId(context, defs.StoveConfig, routeID)
ScriptLib.StartPlatform(context, defs.StoveConfig)
local potName = GetPotName(context,curPos)
local targetPotTempDirection = "oven"..potName.."TempDirection"
ScriptLib.SetGroupVariableValue(context, targetPotTempDirection, 2)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 因为炉子移开,设置锅子" .. potName .. '进入降温状态')
return 0
end
--根据时间轴关键词,获取冷还是热
function GetKeyWord(keyName)
if keyName == "PotOverColdA" or keyName == "PotOverColdB" or keyName == "PotOverColdC" then
return "Cold"
end
if keyName == "PotOverHeatA" or keyName == "PotOverHeatB" or keyName == "PotOverHeatC" then
return "Heat"
end
return 0
end
--根据冷还是热,返回相关汉字 以及 GadgetState
function GetCharacterKeyWord(keyName)
if keyName == "Cold" then
return {"",203}
end
if keyName == "Heat"then
return {"",202}
end
return { "",0 }
end
-- 计算对应的RouteID
function GetRouteID(curPos,targetPos)
for k,v in pairs(defs.PlatFormRoute) do
if curPos == v.curPos and targetPos == v.reachPos then
return k
end
end
return 0
end
-- 简单拆分一个数组
function arrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,76 @@
--[[local test_config = {
[2] = { sum = 10, max = 5, min = 3 },
}--]]
local tri = {
{ name = "GM_Debug", config_id = 8000001, event = EventType.EVENT_VARIABLE_CHANGE, source = "test", condition = "", action = "action_GM_Debug", trigger_count = 0 }
}
local var = {
{ config_id=50000001,name = "sum", value = 0, no_refresh = true },
{ config_id=50000002,name = "max", value = 0, no_refresh = true },
{ config_id=50000003,name = "min", value = 0, no_refresh = true },
{ config_id=50000004,name = "suite", value = 0, no_refresh = true },
{ config_id=50000005,name = "test", value = 0, no_refresh = true }
}
function Initialize()
for i,v in ipairs(tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for i,v in ipairs(var) do
table.insert(variables, v)
end
end
function action_GM_Debug(context, evt)
ScriptLib.PrintContextLog(context, "## tide_test: "..evt.source_name.." | "..evt.param2.." -> "..evt.param1)
if evt.param1 == evt.param2 then
return -1
end
if evt.source_name == "test" then
if evt.param1== 1 then
local _sum = ScriptLib.GetGroupVariableValue(context, "sum")
local _max = ScriptLib.GetGroupVariableValue(context, "max")
local _min = ScriptLib.GetGroupVariableValue(context, "min")
local _suite = ScriptLib.GetGroupVariableValue(context, "suite")
handle_tide(context, _sum, _max, _min, _suite)
elseif evt.param1 == 2 then
local _suite = ScriptLib.GetGroupVariableValue(context, "suite")
if test_config[_suite] ~= nil then
local _sum = test_config[_suite].sum
local _max = test_config[_suite].max
local _min = test_config[_suite].min
handle_tide(context, _sum, _max, _min, _suite)
else
ScriptLib.PrintContextLog(context, "## tide_error : invalid default suite config")
return -1
end
elseif evt.param1 == 0 then
local gid = ScriptLib.GetContextGroupId(context)
ScriptLib.KillMonsterTide(context, gid, 1001)
end
end
return 0
end
function handle_tide(context, _sum, _max, _min, _suite)
if _max > _sum or _max < _min then
ScriptLib.PrintContextLog(context, "## tide_error : invalid _max")
return -1
end
if _min <= 0 then
ScriptLib.PrintContextLog(context, "## tide_error : invalid _min")
return -1
end
if _max >= #suites[_suite].monsters then
ScriptLib.PrintContextLog(context, "## tide_error : invalid _suite")
return -1
end
local gid = ScriptLib.GetContextGroupId(context)
ScriptLib.AutoMonsterTide(context, 1001, gid, suites[_suite].monsters, _sum, _min, _max)
return 0
end
Initialize()

View File

@@ -0,0 +1,225 @@
--[[
local defs = {
-- 进入指定Region获得对应AbilityGroup
-- AG:AbilityGroup
GroupID = 133003041,
AGRegionConfigID = 41012,
AGName = "ActivityAbility_ToMoon_FoodChallenge_Part1", --AbilityGroupName
AGKey = "_Activity_ToMoon_Part1_Level", --AbilityGroupValueKey
-- 进入指定Region时开启对应挑战
ChallengeRegionConfigID = 41012,
ChallengeID = 111168,
TriggerTag = 41013,
TargetTriggerTime = 1,
-- 供奉时对应响应通知Team修改GlobalValue ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid}, key, value)
AreaID = 1, -- 1璃月 2蒙德 3雪山
-- 挑战成功时创生宝箱考虑灵活性挑战成功时逻辑交给LD处理
-- 当LD觉得应当结束Bundle时将OverKey修改为1
OverKey = "OverKey",
WatchKey = "save",
RewardSuit = 7,
}
local Phase ={
[1] = {3,4},
[2] = {3,4,5},
[3] = {7},
}
--]]
---------------------
local tempTrigger = {
{ config_id = 2230001, name = "ENTER_REGION_Challenge", event = EventType.EVENT_ENTER_REGION, source = "1",
condition = "", action = "action_ENTER_REGION_Challenge", trigger_count = 0},
{ config_id = 2230002, name = "LEAVE_REGION_Challenge", event = EventType.EVENT_LEAVE_REGION, source = "1",
condition = "", action = "action_LEAVE_REGION_Challenge", trigger_count = 0},
{ config_id = 2230003, name = "LUNA_RITE_SACRIFICE", event = EventType.EVENT_LUNA_RITE_SACRIFICE, source = "",
condition = "", action = "action_LUNA_RITE_SACRIFICE", trigger_count = 0},
{ config_id = 2230004, name = "VARIABLE_CHANGE_End", event = EventType.EVENT_VARIABLE_CHANGE, source = defs.WatchKey,
condition = "", action = "", trigger_count = 0, tag = tostring(defs.TriggerTag) },
{ config_id = 2330005, name = "VARIABLE_CHANGE_BundleEnd", event = EventType.EVENT_VARIABLE_CHANGE, source = defs.OverKey,
condition = "", action = "action_VARIABLE_CHANGE_BundleEnd", trigger_count = 0},
{ config_id = 2330006, name = "ChallengeEndCheckWin", event = EventType.EVENT_CHALLENGE_SUCCESS, source = tostring(10*defs.ChallengeID), condition = "", action = "action_ChallengeWin" },
{ config_id = 2330007, name = "ChallengeEndCheckLose", event = EventType.EVENT_CHALLENGE_FAIL, source = tostring(10*defs.ChallengeID), condition = "", action = "action_ChallengeLose" },
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
-- 给指定region挂AbilityGroup
regions[defs.AGRegionConfigID].team_ability_group_list = {defs.AGName}
return 0
end
--------公用函数----------
-- 进入Region后触发对应挑战
function action_ENTER_REGION_Challenge(context, evt)
if evt.param1 ~= defs.ChallengeRegionConfigID or ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 非对应挑战Region触发 ")
return 0
end
-- 新手教程相关
StartNewbie(context)
-- 防止连续启挑战
if -1 == CheckChallenge(context) then return 0 end
-- 检查WatcherKey是否合法
local startVariable = ScriptLib.GetGroupVariableValue(context,defs.WatchKey)
if 0 ~= CheckWatcherKey(context,startVariable) then
return 0
end
-- ☆开启挑战
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 准备开启挑战, 挑战内容是 = "..defs.ChallengeRegionConfigID
.." tag是 "..defs.TriggerTag.." 目标触发次数是 "..defs.TargetTriggerTime.." 继承次数为 "..startVariable)
ScriptLib.StartChallenge(context, 10*defs.ChallengeID, defs.ChallengeID, {3, defs.TriggerTag, defs.TargetTriggerTime, 1, startVariable})
ScriptLib.SetGroupTempValue(context, "haveStartChallenge", 1, {})
RefreshAllSacrificeNum(context)
-- 根据阶段刷新为Phase设置保底
RefreshPhaseSuit(context)
return 0
end
-- 挑战结束将值还原
function action_ChallengeWin(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战成功关闭Region ")
ScriptLib.SetGroupTempValue(context, "haveStartChallenge", 2, {})
ScriptLib.RemoveEntityByConfigId(context, defs.GroupID, EntityType.REGION, defs.ChallengeRegionConfigID)
return 0
end
function action_ChallengeLose(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战失败关闭并刷新Region ")
ScriptLib.RemoveEntityByConfigId(context, defs.GroupID, EntityType.REGION, defs.ChallengeRegionConfigID)
ScriptLib.RefreshGroup(context, { group_id = defs.GroupID, suite = 1 })
ScriptLib.SetGroupTempValue(context, "haveStartChallenge", 0, {})
return 0
end
-- 离开指定区域且区域内人员为零时挑战失败
function action_LEAVE_REGION_Challenge(context, evt)
if evt.param1 == defs.ChallengeRegionConfigID and ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
ScriptLib.StopChallenge(context, 10*defs.ChallengeID, 0)
end
return 0
end
-- 逐月节食物供奉改变时
function action_LUNA_RITE_SACRIFICE(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 玩家触发了供奉 ")
RefreshAllSacrificeNum(context)
return 0
end
-- 结束Bundle
function action_VARIABLE_CHANGE_BundleEnd(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : LD触发了指定数值操作 ")
ScriptLib.RemoveEntityByConfigId(context, defs.GroupID, EntityType.REGION, defs.ChallengeRegionConfigID)
ScriptLib.FinishGroupLinkBundle(context, defs.GroupID)
return 0
end
--------私有函数----------
-- 刷新供奉数量用于为AbilityGroup提供支持
function RefreshAllSacrificeNum(context)
local uid_list = ScriptLib.GetSceneUidList(context)
local sacrificeNum = ScriptLib.GetLunaRiteSacrificeNum(context, defs.AreaID);
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp 触发供奉 : UID_List为".. arrayToString(uid_list).." //AreaID为 " .. defs.AreaID .." //当前供奉数为 " .. sacrificeNum)
ScriptLib.SetTeamEntityGlobalFloatValue(context,uid_list, defs.AGKey, sacrificeNum)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp 触发供奉: UID_List为"..arrayToString(uid_list).." //其AbilityGroup的Key刷新了 ")
return 0
end
-- 刷新供奉数量用于为AbilityGroup提供支持
function RefreshSacrificeNum(context)
local tempUid = context.uid
local sacrificeNum = ScriptLib.GetLunaRiteSacrificeNum(context, defs.AreaID);
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp ABGroup挂起: 对应UID为".. tempUid.." //AreaID为 " .. defs.AreaID .." //当前供奉数为 " .. sacrificeNum)
ScriptLib.SetTeamEntityGlobalFloatValue(context,{ tempUid }, defs.AGKey, sacrificeNum)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp ABGroup挂起: 对应UID为"..tempUid.." //其AbilityGroup的Key刷新了 ")
return 0
end
function StartNewbie(context)
local UidList = ScriptLib.GetSceneUidList(context)
local ownerUid = UidList[1]
local havePlayed = ScriptLib.GetExhibitionAccumulableData(context,ownerUid,10501001)
if 0 == havePlayed then
ScriptLib.ShowClientTutorial(context,910,{ownerUid})
ScriptLib.AddExhibitionAccumulableData(context,ownerUid,"MoonlitCamp_HavePlayed",1)
end
return 0
end
function CheckChallenge(context)
local haveStartChallenge = ScriptLib.GetGroupTempValue(context, "haveStartChallenge",{})
if 1 == haveStartChallenge then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战已触发,不再重复触发 ")
return -1
end
if 2 == haveStartChallenge then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战已结束,不再触发 ")
return -1
end
return 0
end
function CheckWatcherKey(context,startVariable)
if startVariable < defs.TargetTriggerTime then
return 0
end
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战应已完成,请检查进入原因 ")
return -1
end
function RefreshPhaseSuit(context)
local stage = ScriptLib.GetGroupVariableValue(context, "stage")
if nil == Phase then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : Group: " .. defs.GroupID .. "没有对应Phase")
return 0
end
if stage > #Phase then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : stage超过Phase界限stage = " .. stage)
return 0
end
local needRefreshSuit = Phase[stage]
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : PhaseStage= " .. stage .. "需要刷新的suit为" .. arrayToString(needRefreshSuit))
for k,v in ipairs(needRefreshSuit) do
ScriptLib.AddExtraGroupSuite(context, defs.GroupID, v)
end
return 0
end
---自骏ToolBox数组转字符串函数---
function arrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,141 @@
--[[
local connection = {
[194001] = {194004,1,194003,0},
[194002] = {194001,1,194004,0},
[194003] = {194004,1}
...
...
}
--]]
--key为操作的config_idv[1] v[2]为关联的config_id和是否同向转动1同向0反向v[3]v[4]同理,最多关联两个物件
-----------------------------------------
local PirateHelmGadgetID = {
70360180,
70360181,
70360182,
70360183,
}
local OPTION_LEFT = 210
local OPTION_RIGHT = 211
local temp_Variables = {
{ config_id=50000001,name = "IsFinished", value = 0, no_refresh = true }, --用于标识是否已完成初始0完成时LD需要设置成1使得机关不可转动
}
local tempTrigger = {
{ config_id = 9000001, name = "EVENT_GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_SetOption", trigger_count = 0},--创建
{ config_id = 9000002, name = "EVENT_SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_SelectOption", trigger_count = 0},
{ config_id = 9000003, name = "EVENT_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_GroupLoadShowVersion", trigger_count = 0},
{ config_id = 9000004, name = "EVENT_TIME_AXIS_PASS", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_RemoveCoolDown", trigger_count = 0},
{ config_id = 9000005, name = "EVENT_VARIABLE_CHANGE", event = EventType.EVENT_VARIABLE_CHANGE, source = "IsFinished", condition = "", action = "action_IsFinished", trigger_count = 0},
}
function action_IsFinished(context,evt)
if evt.param1 == 1 then
local group_id = ScriptLib.GetContextGroupId(context)
for k,v in pairs(gadgets) do
if isPirateHelm(v.gadget_id) then
ScriptLib.DelWorktopOptionByGroupId(context, group_id, v.config_id, OPTION_LEFT)
ScriptLib.DelWorktopOptionByGroupId(context, group_id, v.config_id, OPTION_RIGHT)
end
end
end
return 0
end
function action_GroupLoadShowVersion(context,evt)
ScriptLib.PrintContextLog(context,"version:2021_7_1_105017")
return 0
end
function action_RemoveCoolDown(context,evt)
if evt.source_name == "CD" then ScriptLib.SetGroupTempValue(context,"disableInteract",0,{}) end
return 0
end
function action_SelectOption(context,evt)
if ScriptLib.GetGroupTempValue(context, "disableInteract",{}) == 0 then
if evt.param2 == OPTION_LEFT then
turnLeft(context,evt.param1)
if connection ~= nil then
for k,v in pairs(connection) do--key为操作的config_idv[1] v[2]为关联的config_id和是否同向转动1同向0反向v[3]v[4]同理,最多关联两个物件
if evt.param1 == k then
if v[2] ~=nil then
if v[2] == 1 then turnLeft(context,v[1]) end
if v[2] == 0 then turnRight(context,v[1]) end
end
if v[4] ~=nil then
if v[4] == 1 then turnLeft(context,v[3]) end
if v[4] == 0 then turnRight(context,v[3]) end
end
end
end
end
ScriptLib.SetGroupTempValue(context,"disableInteract",1,{})
ScriptLib.InitTimeAxis(context, "CD", {1}, false)
end
if evt.param2 == OPTION_RIGHT then
turnRight(context,evt.param1)
if connection ~= nil then
for k,v in pairs(connection) do--key为操作的config_idv[1] v[2]为关联的config_id和是否同向转动1同向0反向v[3]v[4]同理,最多关联两个物件
if evt.param1 == k then
if v[2] ~=nil then
if v[2] == 1 then turnRight(context,v[1]) end
if v[2] == 0 then turnLeft(context,v[1]) end
end
if v[4] ~=nil then
if v[4] == 1 then turnRight(context,v[3]) end
if v[4] == 0 then turnLeft(context,v[3]) end
end
end
end
end
ScriptLib.SetGroupTempValue(context,"disableInteract",1,{})
ScriptLib.InitTimeAxis(context, "CD", {1}, false)
end
end
return 0
end
function action_SetOption(context,evt)
if isPirateHelm(evt.param2) then
ScriptLib.SetWorktopOptions(context, {OPTION_LEFT,OPTION_RIGHT})
end
return 0
end
function isPirateHelm(gadgetID)
local result = false
for k,v in pairs(PirateHelmGadgetID) do
if gadgetID == v then result = true end
end
return result
end
function turnLeft(context,config_id)
local groupID = ScriptLib.GetContextGroupId(context)
local nowState = ScriptLib.GetGadgetStateByConfigId(context, groupID, config_id)
if nowState ==0 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 201) end
if nowState ==201 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 202) end
if nowState ==202 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 203) end
if nowState ==203 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 0) end
return 0
end
function turnRight(context,config_id)
local groupID = ScriptLib.GetContextGroupId(context)
local nowState = ScriptLib.GetGadgetStateByConfigId(context, groupID, config_id)
if nowState ==0 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 203) end
if nowState ==201 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 0) end
if nowState ==202 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 201) end
if nowState ==203 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 202) end
return 0
end
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
--加变量
for k,v in pairs(temp_Variables) do
table.insert(variables,v)
end
return 0
end
LF_Initialize_Level()

View File

@@ -0,0 +1,111 @@
--- 只要在海盗门的Group中放置Require即可
---------------------
local tempTrigger = {
{ config_id = 2460001, name = "PirateShojiOption", event = EventType.EVENT_GADGET_CREATE,
source = "",condition = "", action = "action_PirateShojiOption", trigger_count = 0},
{ config_id = 2460002, name = "PirateShojiSelectOption", event = EventType.EVENT_SELECT_OPTION,
source = "",condition = "", action = "action_PirateShojiSelectOption", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
local firstConfigID = 2450001
for k,v in ipairs(door) do
local gadgetConfig = gadgets[v]
gadgets[firstConfigID + 1000] = { config_id = firstConfigID + 1000, gadget_id = 70360001,pos = gadgetConfig.pos,
rot = gadgetConfig.rot, level = 1, area_id = gadgetConfig.area_id, chainConfigID = v }
gadgets[v].operatorConfigID = firstConfigID + 1000
local singleTrigger = { config_id = firstConfigID, name = "PirateShojiStateChange" .. v, event = EventType.EVENT_GADGET_STATE_CHANGE,
source = tostring(v),condition = "", action = "action_PirateShojiStateChange", trigger_count = 0}
table.insert(triggers, singleTrigger)
table.insert(suites[init_config.suite].gadgets, firstConfigID + 1000)
table.insert(suites[init_config.suite].triggers, singleTrigger.name)
firstConfigID = firstConfigID + 1
end
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
--------公用函数----------
------------响应地板玩法开始--------
-- 任意Gadget创建进入,为海盗门的上操作台
function action_PirateShojiOption(context,evt)
ScriptLib.PrintContextLog(context, "##TD Gadget".. evt.param2 .."ConfigID为".. evt.param1 .. "创生了")
if 70360001 == evt.param2 then
local operatorConfigID = evt.param1
local doorConfigID = gadgets[operatorConfigID].chainConfigID
local gadgetState = ScriptLib.GetGadgetStateByConfigId(context, 0, doorConfigID)
if 0 == gadgetState or 202 == gadgetState then
local groupID = ScriptLib.GetContextGroupId(context)
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .."的gadgetState为"..gadgetState.. ",直接挂起操作台")
ScriptLib.SetWorktopOptionsByGroupId(context, groupID, operatorConfigID, {1})
return 0
end
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "的gadgetState为"..gadgetState.."无需响应")
end
return 0
end
-- 对应entity被改变时重上操作台
function action_PirateShojiStateChange(context,evt)
local doorConfigID = evt.param2
local operatorConfigID = gadgets[doorConfigID].operatorConfigID
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "被检查切换到State" .. evt.param1 )
if 0 == evt.param1 or 202 == evt.param1 then
local groupID = ScriptLib.GetContextGroupId(context)
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "state合法被挂起操作台")
ScriptLib.DelWorktopOptionByGroupId(context, groupID, operatorConfigID, 1)
ScriptLib.SetWorktopOptionsByGroupId(context, groupID, operatorConfigID, {1})
return 0
end
if 201 == evt.param1 then
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "门已开启,不响应")
return 0
end
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "state不匹配不响应")
return 0
end
-- 任意操作台被交互时进入,与操作台交互时控制操作台
function action_PirateShojiSelectOption(context, evt)
local operatorConfigID = evt.param1
local doorConfigID = gadgets[operatorConfigID].chainConfigID
local uid = evt.uid
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. " 操作台被玩家".. uid.. "尝试使用开关为" .. evt.param2)
if 1 == evt.param2 and 70360169 == gadgets[doorConfigID].gadget_id then
local groupID = ScriptLib.GetContextGroupId(context)
local gadgetID = ScriptLib.GetGadgetStateByConfigId(context, 0, doorConfigID)
if 0 == gadgetID then
local isLock = ScriptLib.GetTeamAbilityFloatValue(context, uid, "_SCENEOBJ_PirateShoji_IsOpen")
if isLock < 1 then
-- 提示不能开门
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. " 无法被玩家".. uid.. "开启")
ScriptLib.ShowReminder(context, 321715301)
else
-- 打开门
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "被玩家".. uid.. "开启")
ScriptLib.SetGadgetStateByConfigId(context, doorConfigID, 201)
ScriptLib.DelWorktopOptionByGroupId(context, groupID, operatorConfigID, 1)
end
end
if 202 == gadgetID then
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID.. " 已解锁,无视方向直接开启")
ScriptLib.SetGadgetStateByConfigId(context, doorConfigID, 201)
ScriptLib.DelWorktopOptionByGroupId(context, groupID, operatorConfigID, 1)
end
end
return 0
end
--------私有函数----------
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,74 @@
--[[
local statueConfig =
{
["Statue_Rotated1"] = {config_id = 121001,valueName = "Statue_Rotate1"},
["Statue_Rotated2"] = {config_id = 121001,valueName = "Statue_Rotate2"},
["Statue_Rotated3"] = {config_id = 121001,valueName = "Statue_Rotate3"}
}
--]]
local tempTrigger = {
{ config_id = 233001, name = "VARIABLE_CHANGE_233001", event = EventType.EVENT_VARIABLE_CHANGE,
source = "Statue_Rotated1", condition = "", action = "action_VARIABLE_CHANGE_Special", trigger_count = 0},
{ config_id = 233002, name = "VARIABLE_CHANGE_233002", event = EventType.EVENT_VARIABLE_CHANGE,
source = "Statue_Rotated2", condition = "", action = "action_VARIABLE_CHANGE_Special", trigger_count = 0},
{ config_id = 233003, name = "VARIABLE_CHANGE_233003", event = EventType.EVENT_VARIABLE_CHANGE,
source = "Statue_Rotated3", condition = "", action = "action_VARIABLE_CHANGE_Special", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
for i = 1,#suite_disk do
table.insert(suite_disk[i].triggers, v.name)
end
end
local tempStatueConfig = statueConfig["Statue_Rotated1"]
gadgets[tempStatueConfig.config_id].server_global_value_config = {["SGV_SeaGodStatue_RotationState"] = 0}
tempStatueConfig = statueConfig["Statue_Rotated2"]
gadgets[tempStatueConfig.config_id].server_global_value_config = {["SGV_SeaGodStatue_RotationState"] = 0}
tempStatueConfig = statueConfig["Statue_Rotated3"]
gadgets[tempStatueConfig.config_id].server_global_value_config = {["SGV_SeaGodStatue_RotationState"] = 0}
return 0
end
--------事件函数----------
function action_VARIABLE_CHANGE_Special(context, evt)
-- 如果值为1则处理
if(1 == evt.param1) then
ScriptLib.PrintContextLog(context, "## TD SeaGodStatue : 尝试转动雕像")
TrySetSeaGodStatueRotation(context,evt.source_name)
return 0
end
return 0
end
--------公用函数----------
------------设置海神雕像转动---------
function SetSeaGodStatueRotation(context,configId,rot)
ScriptLib.PrintContextLog(context, "## TD SeaGodStatue : configId = "..configId .. " rot= " .. rot)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, configId, "SGV_SeaGodStatue_RotationState", rot)
return 0
end
------------尝试转动海神雕像---------
function TrySetSeaGodStatueRotation(context,eventName)
local configId = statueConfig[eventName].config_id
local valueName = statueConfig[eventName].valueName
-- 获取物件状态
local gadgetState = ScriptLib.GetGadgetStateByConfigId(context, 0, configId)
if( 201 == gadgetState) then
local currentRot = ScriptLib.GetGroupVariableValue(context, valueName) + 90
if (360 <=currentRot) then currentRot = 0 end
ScriptLib.SetGroupVariableValue(context, valueName, currentRot)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, configId, "SGV_SeaGodStatue_RotationState", currentRot)
ScriptLib.PrintContextLog(context, "## TD SeaGodStatue : 尝试转动成功 configId = "..configId .. " gadgetState= " .. gadgetState .. "rot" .. currentRot)
else
ScriptLib.PrintContextLog(context, "## TD SeaGodStatue : 尝试转动未成功 configId = "..configId .. " gadgetState= " .. gadgetState)
end
-- 事件处理后归零
ScriptLib.SetGroupVariableValue(context, eventName, 0)
return 0
end
--------检测函数----------
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,226 @@
--[[
local wakuraConfig =
{
-- 布设时请务必保持上下Rotation相同需要初始值不同的场合请通过GadgetState控制
-- Index与Rotation无严格要求务必锚定红色数字1为第一面按照逆时钟推算Index即可
-- 举例 上下为两个六边形红色数字1为第一面同时下六边形GadgetState为 203。
-- 那么upNum从1开始依次计数。downNum也是从1开始依次计数。(在编辑器界面你无法看到下六边形转到4
-- 然后根据纸垂特征往右依次填数即可。
groupId = 133217005,
upConfig = 5004,
downConfig = 5003,
operatorConfig = 5005,
upNum = {1,2,1,3,1,2}, -- 上层纸垂分布
downNum = {2,1,1,2,3,1}, -- 下层纸垂分布
careFaceIndex = {1,3,5}, -- 设计者关注的对应面
targetFaceNum = {3,2,5}, -- 设计者关注的最终面的数量
SGVList = {"SGV_Light_01","SGV_Light_02","SGV_Light_03","SGV_Light_04","SGV_Light_05","SGV_Light_06"}
}
local stateIndex ={
[0] = {index = 1,next = 201},
[201] ={index = 2,next = 202},
[202] ={index = 3,next = 203},
[203] ={index = 4,next = 204},
[204] ={index = 5,next = 901},
[901] ={index = 6,next = 0}
}
--]]
local tempTrigger = {
{ config_id = 2330001, name = "UpStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = tostring(wakuraConfig.upConfig),
condition = "", action = "action_StateChangeCheck", trigger_count = 0},
{ config_id = 2330002, name = "DownStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = tostring(wakuraConfig.downConfig),
condition = "", action = "action_StateChangeCheck", trigger_count = 0},
{ config_id = 2330003, name = "GADGET_CREATE_Operator", event = EventType.EVENT_GADGET_CREATE, source = "",
condition = "", action = "action_GADGET_CREATE_Operator", trigger_count = 0 },
{ config_id = 2330004, name = "OperatorStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = tostring(wakuraConfig.operatorConfig),
condition = "", action = "action_OperatorStateChange", trigger_count = 0}, -- GROUP GET_TRIGGER 133217005 OperatorStateChange
{ config_id = 2330005, name = "SELECT_OPTION_Change", event = EventType.EVENT_SELECT_OPTION, source = "",
condition = "", action = "action_SELECT_OPTION_Change", trigger_count = 0 },
{ config_id = 2330006, name = "TIME_AXIS_PASS_ReSetWorktopOption", event = EventType.EVENT_TIME_AXIS_PASS, source = "ReSetWorktopOption",
condition = "", action = "action_TIME_AXIS_PASS_ReSetWorktopOption", trigger_count = 0 },
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
for i = 1,#suites do
table.insert(suites[i].triggers, v.name)
end
end
gadgets[wakuraConfig.upConfig].server_global_value_config = {[wakuraConfig.SGVList[1]] = 0,[wakuraConfig.SGVList[2]] = 0,[wakuraConfig.SGVList[3]] = 0,[wakuraConfig.SGVList[4]] = 0,[wakuraConfig.SGVList[5]] = 0,[wakuraConfig.SGVList[6]] = 0}
gadgets[wakuraConfig.downConfig].server_global_value_config = {[wakuraConfig.SGVList[1]] = 0,[wakuraConfig.SGVList[2]] = 0,[wakuraConfig.SGVList[3]] = 0,[wakuraConfig.SGVList[4]] = 0,[wakuraConfig.SGVList[5]] = 0,[wakuraConfig.SGVList[6]] = 0}
return 0
end
--------事件函数----------
-- 创建时实装操作台
function action_GADGET_CREATE_Operator(context, evt)
if wakuraConfig.operatorConfig ~= evt.param1 then
return 0
end
local operatorState = ScriptLib.GetGadgetStateByConfigId(context, 0, wakuraConfig.operatorConfig)
if 201 == operatorState or 202 == operatorState then
CalculateEachFaceNum(context)
end
return 0
end
-- 状态改变时上下操作台
function action_OperatorStateChange(context, evt)
if 201 == evt.param1 then
CalculateEachFaceNum(context)
elseif 0 == evt.param1 or 202 == evt.param2 then
ScriptLib.DelWorktopOptionByGroupId(context, wakuraConfig.groupId, wakuraConfig.operatorConfig, 89)
ScriptLib.DelWorktopOptionByGroupId(context, wakuraConfig.groupId, wakuraConfig.operatorConfig, 90)
end
return 0
end
-- 转动交互流程控制(取消连续转动)
function action_SELECT_OPTION_Change(context, evt)
if wakuraConfig.operatorConfig ~= evt.param1 and 89 ~= evt.param2 and 90 ~= evt.param2 then
return 0
end
if true == ScriptLib.CheckIsInMpMode(context) then
ScriptLib.ShowReminder(context, 321700501)
return -1
end
if 89 == evt.param2 then
ScriptLib.PrintContextLog(context, "## TD磐座 上磐座被玩家点击旋转")
CloseAllSGVLight(context)
ScriptLib.DelWorktopOptionByGroupId(context, wakuraConfig.groupId, wakuraConfig.operatorConfig, 89)
ScriptLib.DelWorktopOptionByGroupId(context, wakuraConfig.groupId, wakuraConfig.operatorConfig, 90)
local upState = ScriptLib.GetGadgetStateByConfigId(context, 0, wakuraConfig.upConfig)
ScriptLib.SetGadgetStateByConfigId(context, wakuraConfig.upConfig, stateIndex[upState].next)
end
if 90 == evt.param2 then
ScriptLib.PrintContextLog(context, "## TD磐座 下磐座被玩家点击旋转")
CloseAllSGVLight(context)
ScriptLib.DelWorktopOptionByGroupId(context, wakuraConfig.groupId, wakuraConfig.operatorConfig, 89)
ScriptLib.DelWorktopOptionByGroupId(context, wakuraConfig.groupId, wakuraConfig.operatorConfig, 90)
local downState = ScriptLib.GetGadgetStateByConfigId(context, 0, wakuraConfig.downConfig)
ScriptLib.SetGadgetStateByConfigId(context, wakuraConfig.downConfig, stateIndex[downState].next)
end
return 0
end
-- 每次转动进行检测(合法的数字,需要对应亮灯)
function action_StateChangeCheck(context, evt)
if evt.param2 == wakuraConfig.upConfig then
ScriptLib.PrintContextLog(context, "## TD磐座 识别到上磐座发生转动")
elseif evt.param2 == wakuraConfig.downConfig then
ScriptLib.PrintContextLog(context, "## TD磐座 识别到下磐座发生转动")
else
ScriptLib.PrintContextLog(context, "## TD磐座 识别到不合法物件,其configID为" .. evt.param2)
return -1
end
-- 202状态下不再设置操作台
local operatorState = ScriptLib.GetGadgetStateByConfigId(context, 0, wakuraConfig.operatorConfig)
if 201 == operatorState then
ScriptLib.InitTimeAxis(context, "ReSetWorktopOption", {1}, false)
end
return 0
end
function action_TIME_AXIS_PASS_ReSetWorktopOption(context)
CalculateEachFaceNum(context)
return 0
end
--------公用函数----------
------------检查各个方向计数同时控制方向开关---------
function CalculateEachFaceNum(context)
local upState = ScriptLib.GetGadgetStateByConfigId(context, 0, wakuraConfig.upConfig)
local downState = ScriptLib.GetGadgetStateByConfigId(context, 0, wakuraConfig.downConfig)
local operatorState = ScriptLib.GetGadgetStateByConfigId(context, 0, wakuraConfig.operatorConfig)
ScriptLib.PrintContextLog(context, "## TD磐座统计: ".. "上层State为 " .. upState .."下层State为 " .. downState)
local upIndex = stateIndex[upState].index
local downIndex = stateIndex[downState].index
local eachFaceNum = {0,0,0,0,0,0}
for i = 1,6 do
eachFaceNum[i] = wakuraConfig.upNum[getIndex(upIndex + i - 1)] + wakuraConfig.downNum[getIndex(downIndex + i - 1)]
end
ScriptLib.PrintContextLog(context, "## TD磐座 总计数为 : " .. arrayToString(eachFaceNum))
local activeCount = 0
for i = 1,#wakuraConfig.careFaceIndex do
local targetFaceNum = wakuraConfig.targetFaceNum[i]
local targetFaceIndex = wakuraConfig.careFaceIndex[i]
if targetFaceNum == eachFaceNum[targetFaceIndex] then
ScriptLib.PrintContextLog(context, "## TD磐座 第"..targetFaceIndex.."方向符合计数要求,点亮其上下层")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, wakuraConfig.upConfig, wakuraConfig.SGVList[getIndex(upIndex + targetFaceIndex - 1)], 1)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, wakuraConfig.downConfig, wakuraConfig.SGVList[getIndex(downIndex + targetFaceIndex - 1)], 1)
activeCount = activeCount + 1
else
ScriptLib.PrintContextLog(context, "## TD磐座 第"..targetFaceIndex.."方向不符合计数要求,关闭其上下层")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, wakuraConfig.upConfig, wakuraConfig.SGVList[getIndex(upIndex + targetFaceIndex - 1)], 0)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, wakuraConfig.downConfig, wakuraConfig.SGVList[getIndex(downIndex + targetFaceIndex - 1)], 0)
end
end
-- 检查是否已完成
if activeCount == #wakuraConfig.careFaceIndex and 202 ~= operatorState then
ScriptLib.PrintContextLog(context, "## TD磐座 对应方向全部点亮。隐形操作台会被设置为202")
ScriptLib.SetGadgetStateByConfigId(context, wakuraConfig.operatorConfig, 202)
operatorState = 202
end
-- 只要状态还维持 201 就重新设置操作台
if 201 == operatorState then
ScriptLib.SetWorktopOptionsByGroupId(context, wakuraConfig.groupId, wakuraConfig.operatorConfig, {89,90})
end
ScriptLib.PrintContextLog(context, "## TD磐座 各方向处理完毕")
return 0
end
--------工具函数----------
---根据Index加算返回合适的Index---
function getIndex(index)
local circleNum = 6
local curIndex = index
if curIndex > circleNum then
curIndex = curIndex % circleNum
if 0 == curIndex then
curIndex = circleNum
end
end
return curIndex
end
---简单拆分一个数组---
function arrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
--- 关闭所有SGV发光 ---
function CloseAllSGVLight(context)
for i = 1,#wakuraConfig.SGVList do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, wakuraConfig.upConfig, wakuraConfig.SGVList[i], 0)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, wakuraConfig.downConfig, wakuraConfig.SGVList[i], 0)
end
return 0
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,213 @@
--- def参数
--- 描述长宽
--[[
local defs = {
-- 该参数 填入ConfigID 用来确认临接关系
InitFloorArrays = {
{6001,6004,6007,6010},
{6002,6006,6009,6012},
{6003,6005,6008,6011},
},
-- 该参数用来确认合法序列 (日月星)
FloorGadgetID = {70310059,70310060,70310061}, --lastFloorIndex
FloorNum = 12,
}
--]]
---------------------
local tempTrigger = {
{ config_id = 2330001, name = "floorStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "",
condition = "", action = "action_floorStateChange", trigger_count = 0},
{ config_id = 2330002, name = "EVENT_FloorPlayStart", event = EventType.EVENT_VARIABLE_CHANGE, source = "FloorPlayStart",
condition = "", action = "action_FloorPlayStart", trigger_count = 0},
{ config_id = 2330003, name = "EVENT_NoticeFloorPlayEnd", event = EventType.EVENT_VARIABLE_CHANGE, source = "totalFloorNum",
condition = "", action = "action_NoticeFloorPlayEnd", trigger_count = 0},
{ config_id = 2330004, name = "EVENT_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "",
condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0},
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
LF_InitCheckFloorStyle()
local var = { config_id=50000001,name = "lastFloorIndex", value = 0, no_refresh = false } --上一次踩亮的地板顺位Index ,每次开始游戏重置
variables[var.name] = var
var = { config_id=50000002,name = "lastConfigID", value = 0, no_refresh = false } --上一次踩亮的地板configID ,每次开始游戏重置
variables[var.name] = var
var = { config_id=50000003,name = "totalFloorNum", value = defs.FloorNum, no_refresh = false } --地板计数器,侦测玩法结束变量
variables[var.name] = var
var = { config_id=50000004,name = "FloorPlayStart", value = 0, no_refresh = false } --玩法开始变量设为1时玩法开启 玩法失败时会置为0
variables[var.name] = var
var = { config_id=50000005,name = "FloorPlayEnd", value = 0, no_refresh = true } --玩法结束变量设为1时玩法结束需要设计师侦测
variables[var.name] = var
return 0
end
function LF_InitCheckFloorStyle()
-- 处理地板边界 xNotEnd为False是下边界yNotEnd为False是右边界。
for i=1,#defs.InitFloorArrays do
local tempXNotEnd = i ~= #defs.InitFloorArrays
for j=1,#defs.InitFloorArrays[i] do
local tempYNotEnd = j ~= #defs.InitFloorArrays[i]
local tempConfigId = defs.InitFloorArrays[i][j]
if tempConfigId > 0 then
gadgets[tempConfigId].FloorParam = {x=i,y=j,xNotEnd=tempXNotEnd,yNotEnd=tempYNotEnd}
gadgets[tempConfigId].isFloor = true
end
end
end
return 0
end
--------公用函数----------
------------Group加载时保底--------
function action_EVENT_GROUP_LOAD(context,evt)
local floorPlayEnd = ScriptLib.GetGroupVariableValue(context, "FloorPlayEnd")
if 0 == floorPlayEnd then
-- Group强制刷新
local groupID = ScriptLib.GetContextGroupId(context)
ScriptLib.RefreshGroup(context, { group_id = groupID, suite = 1 })
end
return 0
end
------------响应地板玩法开始--------
function action_FloorPlayStart(context,evt)
if 1 ~= evt.param1 then return 0 end
-- 所有地板设为0
for i=1,#defs.InitFloorArrays do
for j=1,#defs.InitFloorArrays[i] do
local tempConfigId = defs.InitFloorArrays[i][j]
if tempConfigId > 0 then
ScriptLib.SetGadgetStateByConfigId(context, tempConfigId, 0)
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 将对应地板设置为0ConfigID为" .. tempConfigId)
end
end
end
ScriptLib.SetGroupVariableValue(context, "FloorPlayEnd", 0)
ScriptLib.SetGroupVariableValue(context, "lastConfigID", 0)
ScriptLib.SetGroupVariableValue(context, "lastFloorIndex", 0)
ScriptLib.SetGroupVariableValue(context, "totalFloorNum", defs.FloorNum)
return 0
end
---------------对应地板被踩时触发--------
function action_floorStateChange(context,evt)
local toGadgetState = evt.param1
local configID = evt.param2
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 侦测到物件状态切入"..toGadgetState.."ConfigID为" .. configID)
if 201 == toGadgetState and gadgets[configID].isFloor then
AnalyzeFloorByFixedOrder(context,configID)
return 0
end
return 0
end
------------通知地板玩法结束--------
function action_NoticeFloorPlayEnd(context,evt)
if 0 == evt.param1 then
-- 将地板玩法结束参数设为1
ScriptLib.SetGroupVariableValue(context, "FloorPlayEnd", 1)
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 地板玩法结束")
end
return 0
end
------------踩踏木制地板判定(日月星)--------
---地板只有进入201时才启动以下分析逻辑
function AnalyzeFloorByFixedOrder(context,currentConfigID)
local lastIndex = ScriptLib.GetGroupVariableValue(context, "lastFloorIndex") --上一个踩中地板的顺位
local lastConfigID = ScriptLib.GetGroupVariableValue(context, "lastConfigID") --上一个踩中地板的ConfigID
local currentIndex = 0
if lastConfigID == 0 then
--获取其在日月星中的顺位
currentIndex = GetFirstDataInArray(gadgets[currentConfigID].gadget_id)
ScriptLib.ChangeGroupVariableValue(context, "totalFloorNum", -1)
else
--获取其在日月星中的下一个顺位
currentIndex = lastIndex + 1
if currentIndex == #defs.FloorGadgetID+1 then currentIndex = 1 end
-- 附近地板且顺位正确
if IsNearbyFloor(lastConfigID,currentConfigID) and IsRightFloor(currentIndex,currentConfigID) then
--成功,可能需要处理特效
ScriptLib.ChangeGroupVariableValue(context, "totalFloorNum", -1)
ScriptLib.PrintContextLog(context, "## TD_Log:WoodFloorPlay : 踩入的地板顺序正确")
else
--失败,重置所有地板
ScriptLib.PrintContextLog(context, "## TD_Log:WoodFloorPlay : 踩入的地板顺序错误")
-- 所有地板设为0
for i=1,#defs.InitFloorArrays do
for j=1,#defs.InitFloorArrays[i] do
local tempConfigId = defs.InitFloorArrays[i][j]
if tempConfigId > 0 then
ScriptLib.SetGadgetStateByConfigId(context, tempConfigId, 202)
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 将对应地板设置为202ConfigID为" .. tempConfigId)
end
end
end
-- 地板玩法重启
ScriptLib.SetGroupVariableValue(context, "FloorPlayStart", 0)
ScriptLib.SetGroupVariableValue(context, "lastConfigID", 0)
return 0
end
end
--存档
ScriptLib.SetGroupVariableValue(context, "lastFloorIndex", currentIndex)
ScriptLib.SetGroupVariableValue(context, "lastConfigID", currentConfigID)
return 0
end
------------是否为附近地板---------
function IsNearbyFloor(lastConfigID,currentConfigID)
local currentFloorConfigList = GetNearbyFloorConfigList(lastConfigID)
for i = 1,#currentFloorConfigList do
if currentConfigID == currentFloorConfigList[i] then
return true
end
end
return false
end
------------是否为正确顺序地板---------
function IsRightFloor(currentIndex,currentConfigID)
local targetGadgetID = defs.FloorGadgetID[currentIndex]
local currentGadgetID = gadgets[currentConfigID].gadget_id
return currentGadgetID == targetGadgetID
end
------------Private获取附近地板ConfigList---------
function GetNearbyFloorConfigList(configID)
local currentFloorConfigList = {}
local tempPos = gadgets[configID].FloorParam
if tempPos ~= nil then
local tempX = tempPos.x
local tempY = tempPos.y
if(tempX > 1) then table.insert(currentFloorConfigList,defs.InitFloorArrays[tempX-1][tempY]) end
if(tempY > 1) then table.insert(currentFloorConfigList,defs.InitFloorArrays[tempX][tempY-1]) end
if(tempPos.xNotEnd) then table.insert(currentFloorConfigList,defs.InitFloorArrays[tempX+1][tempY]) end
if(tempPos.yNotEnd) then table.insert(currentFloorConfigList,defs.InitFloorArrays[tempX][tempY+1]) end
end
return currentFloorConfigList
end
------------Private根据gadgetID返回其在FloorGadgetID序列中的Index---------
function GetFirstDataInArray(gadgetID)
for i = 1,#defs.FloorGadgetID do
if gadgetID == defs.FloorGadgetID[i] then
return i
end
end
return 0
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

View File

@@ -0,0 +1,152 @@
--- def参数
--- 描述长宽
--[[
local defs = {
-- 该参数用来确认合法对子地板
FloorGadgetID = {70310062,70310063,70310064,70310065,70310087,70310088},
FloorNum = 8,
}
--]]
---------------------
local tempTrigger = {
{ config_id = 2330001, name = "floorStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "",
condition = "", action = "action_floorStateChange", trigger_count = 0},
{ config_id = 2330002, name = "EVENT_FloorPlayStart", event = EventType.EVENT_VARIABLE_CHANGE, source = "FloorPlayStart",
condition = "", action = "action_FloorPlayStart", trigger_count = 0},
{ config_id = 2330003, name = "EVENT_NoticeFloorPlayEnd", event = EventType.EVENT_VARIABLE_CHANGE, source = "totalFloorNum",
condition = "", action = "action_NoticeFloorPlayEnd", trigger_count = 0},
{ config_id = 2330004, name = "EVENT_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "",
condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0},
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k, v in pairs(gadgets) do
v.isFloor = LF_IsFloor(v.gadget_id)
end
local var = { config_id=50000001,name = "lastConfigID", value = 0, no_refresh = false } --上一次踩亮的地板configID
variables[var.name] = var
var = { config_id=50000002,name = "totalFloorNum", value = defs.FloorNum, no_refresh = false } --地板计数器,侦测玩法结束变量
variables[var.name] = var
var = { config_id=50000003,name = "FloorPlayStart", value = 0, no_refresh = true } --玩法开始变量设为1时玩法开启
variables[var.name] = var
var = { config_id=50000004,name = "FloorPlayEnd", value = 0, no_refresh = true } --玩法结束变量设为1时玩法结束需要设计师侦测
variables[var.name] = var
return 0
end
function LF_IsFloor(targetGadgetID)
for i = 1,#defs.FloorGadgetID do
if targetGadgetID == defs.FloorGadgetID[i] then
return true
end
end
return false
end
--------公用函数----------
------------Group加载时保底--------
function action_EVENT_GROUP_LOAD(context,evt)
local floorPlayEnd = ScriptLib.GetGroupVariableValue(context, "FloorPlayEnd")
local floorPlayStart = ScriptLib.GetGroupVariableValue(context, "FloorPlayStart")
if 0 == floorPlayEnd and 1 == floorPlayStart then
-- 玩法已开启未完成,请求回档,重新开启
NewStart(context)
end
if 1== floorPlayEnd then
for k, v in pairs(gadgets) do
local curState = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, v.config_id)
if v.isFloor and curState ~= 202 then
ScriptLib.SetGadgetStateByConfigId(context, v.config_id, 202)
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 将不为202的地板设置为202其ConfigID为" .. v.config_id)
end
end
end
return 0
end
------------对应地板被踩时触发--------
function action_floorStateChange(context,evt)
local toGadgetState = evt.param1
local configID = evt.param2
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 侦测到物件状态切位"..toGadgetState.."ConfigID为" .. configID)
if 201 == toGadgetState and gadgets[configID].isFloor then
AnalyzeFloorBySameFloor(context,configID)
return 0
end
return 0
end
------------响应地板玩法开始--------
function action_FloorPlayStart(context,evt)
if 1 ~= evt.param1 then return 0 end
NewStart(context)
return 0
end
function NewStart(context)
-- 所有地板设为0
for k, v in pairs(gadgets) do
if v.isFloor then
ScriptLib.SetGadgetStateByConfigId(context, v.config_id, 0)
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 将对应地板设置为0ConfigID为" .. v.config_id)
end
end
ScriptLib.SetGroupVariableValue(context, "lastConfigID", 0)
ScriptLib.SetGroupVariableValue(context, "totalFloorNum", defs.FloorNum)
return 0
end
------------通知地板玩法结束--------
function action_NoticeFloorPlayEnd(context,evt)
if 0 == evt.param1 then
-- 将地板玩法结束参数设为1
ScriptLib.SetGroupVariableValue(context, "FloorPlayEnd", 1)
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 地板玩法结束")
end
return 0
end
------------踩踏木制地板判定(对对子)--------
---地板只有进入201时才启动以下分析逻辑
function AnalyzeFloorBySameFloor(context,currentConfigID)
local lastConfigID = ScriptLib.GetGroupVariableValue(context, "lastConfigID")
if lastConfigID ~= 0 then
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 第二次踩中地板,ConfigID为" .. lastConfigID)
-- 这是第二次踩入的地板
local lastGadgetID = gadgets[lastConfigID].gadget_id
local currentGadgetID = gadgets[currentConfigID].gadget_id
if lastGadgetID == currentGadgetID then
-- 两个地板同时切入202
ScriptLib.SetGadgetStateByConfigId(context, lastConfigID, 202)
ScriptLib.SetGadgetStateByConfigId(context, currentConfigID, 202)
-- 计数器 - 2
ScriptLib.ChangeGroupVariableValue(context, "totalFloorNum", -2)
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 触发相同地板")
else
-- 两个地板同时切入203
ScriptLib.SetGadgetStateByConfigId(context, lastConfigID, 203)
ScriptLib.SetGadgetStateByConfigId(context, currentConfigID, 203)
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 触发不同地板")
end
-- 擦除第一次踩入地板记录
ScriptLib.SetGroupVariableValue(context, "lastConfigID", 0)
return 0
end
--记录第一次踩入地板
ScriptLib.SetGroupVariableValue(context, "lastConfigID", currentConfigID)
ScriptLib.PrintContextLog(context, "TD WoodFloorPlay : 第一次踩中地板,ConfigID为" .. currentConfigID)
return 0
end
--------检测函数----------
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---