添加配置表

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,176 @@
--[[======================================
|| filename: BW_LightRoadTrack
|| owner: chen.chen
|| description: 光路路径节点玩法
|| LogName: ## [BW_LightRoadTrack]
|| Protection:
=======================================]]--
--defs的静态映射表因为playbundle只支持gadget_的形式
--[[
local nodeTable={
[1]=defs.gadget_node01,
[2]=defs.gadget_node02,
[3]=defs.gadget_node03,
[4]=defs.gadget_node04,
[5]=defs.gadget_node05,
[6]=defs.gadget_node06,
[7]=defs.gadget_node07,
[8]=defs.gadget_node08,
}
local guideEffTable={
[1]=defs.gadget_hint01,
[2]=defs.gadget_hint02,
[3]=defs.gadget_hint03,
[4]=defs.gadget_hint04,
[5]=defs.gadget_hint05,
[6]=defs.gadget_hint06,
[7]=defs.gadget_hint07,
[8]=defs.gadget_hint08,
}
]]--
local extraTriggers={
{ config_id = 40000000, name = "EVENT_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_event_group_load", trigger_count = 0 },
{ config_id = 40000001, name = "EVENT_GADGET_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
{ config_id = 40000002, name = "EVENT_ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0 ,forbid_guest = true},
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--玩法状态
table.insert(variables, { config_id=50000001,name = "PlayStep", value = 0,no_refresh = true})
--为每一个光路路径节点增加一个region
local id=30000000
for i=1,#gadgets do
if gadgets[i].gadget_id==70290319 then
local configId=gadgets[i].config_id
local insertRegion={ config_id = id+configId, shape = RegionShape.SPHERE, radius = 2, pos=gadgets[i].pos, area_id = gadgets[i].area_id }
table.insert(regions,insertRegion)
table.insert(suites[2].regions,id+configId)
end
end
end
--[[
PlayStep:
0:未开始
1:寻找中
2:已完成
]]
-----------------------------EventActions-----------------------------------------
--关卡被加载时根据完成状态恢复group
function action_event_group_load(context, evt)
local playStep=ScriptLib.GetGroupVariableValue(context, "PlayStep")
--进入方法log
ScriptLib.PrintContextLog(context,"##[BW_LightRoadTrack] group load with playstep:"..playStep)
--如果处于未开始状态加载suite2
if playStep==0 then
ScriptLib.AddExtraGroupSuite(context, 0, 2)
--如果已开始,本玩法不记录中间状态,所以重置玩法
elseif playStep==1 then
ScriptLib.SetGroupVariableValue(context, "PlayStep", 0)
ScriptLib.AddExtraGroupSuite(context, 0, 2)
--如果玩法已完成则直接加载suite3并点亮底座
else
ScriptLib.AddExtraGroupSuite(context, 0, 3)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.gadget_startpoint, 204)
end
return 0
end
--用于处理重力压板的状态变化
function action_gadget_state_change(context, evt)
--进入方法log
ScriptLib.PrintContextLog(context,"##[BW_LightRoadTrack] group gadget state change, config_id="..evt.param2)
--如果重力压板状态变化了
if evt.param2==defs.gadget_startpoint then
--checkstate
ScriptLib.PrintContextLog(context,"##[BW_LightRoadTrack] start point state change:"..evt.param1)
--如果重力压板被激活,则需要展示节点和指引
if evt.param1==203 then
LF_SetAllNodeState(context,201)
for k,v in pairs(guideEffTable) do
if v ~=0 then
ScriptLib.CreateGadget(context, { config_id = v })
end
end
--标志玩法开始
ScriptLib.SetGroupVariableValue(context, "PlayStep", 1)
end
--离开压板,需要开启玩法计时,但不改变物件状态
if evt.param1==201 and evt.param3==203 then
for k,v in pairs(guideEffTable) do
if v ~=0 then
ScriptLib.KillGroupEntity(context, { group_id = 0, gadgets = {v} })
end
end
--标志未开始
ScriptLib.SetGroupVariableValue(context, "PlayStep", 0)
LF_SetAllNodeState(context,0)
end
end
return 0
end
--用于处理玩法过程中达到节点
function action_enter_region(context, evt)
--进入方法log
ScriptLib.PrintContextLog(context,"##[BW_LightRoadTrack] enter region, config_id="..(evt.param1-30000000))
--如果不处于玩法中,则直接返回
if ScriptLib.GetGroupVariableValue(context, "PlayStep")~=1 then
return 0
end
--判定是否按照步骤开始踩
local enterConfigId=evt.param1-30000000
--判断是否踩到的正确的节点
--踩了熄灭消除流光并将目标index+1
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, enterConfigId, 0)
for k,v in pairs(nodeTable) do
if v==enterConfigId then
ScriptLib.KillGroupEntity(context, { group_id = 0, gadgets = {guideEffTable[k]} })
end
end
--判断玩法是否已经完成
if LF_CheckAllNodeActive(context)==true then
--标志玩法结束
ScriptLib.SetGroupVariableValue(context, "PlayStep", 2)
--创建宝箱
ScriptLib.AddExtraGroupSuite(context, 0, 3)
--常亮路径压板
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.gadget_startpoint, 204)
end
return 0
end
--封装一下用于全量设置node的状态
function LF_SetAllNodeState(context,state)
for k,v in pairs(nodeTable) do
if v ~= 0 then
--改成active状态
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, state)
end
end
return 0
end
--确认是否所有节点都踩到了
function LF_CheckAllNodeActive(context)
for k,v in pairs(nodeTable) do
if v~=nil and v~=0 then
if ScriptLib.GetGadgetStateByConfigId(context, 0, v)==201 then
--找到不符合的config
ScriptLib.PrintContextLog(context,"##[BW_LightRoadTrack] check all node active fail, config_id="..v)
return false
end
end
end
return true
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,74 @@
--[[======================================
|| filename: BW_RandomLoadSuite
|| owner: chen.chen
|| description: 初次load时用来根据suiteWeightTable配置的权重随机一个suite加载并存档之后加载都使用第一次的随机结果
|| LogName: BW_RandomLoadSuite
|| Protection:
=======================================]]--
local suiteWeightTable={
[2]=100,
[3]=100,
[4]=100,
[5]=100,
[6]=100,
[7]=100,
[8]=100,
[9]=100,
[10]=100,
[11]=100,
[12]=40,
[13]=40,
}
local extraTriggers={
{ config_id = 40000001, name = "EVENT_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--需要额外创建的suite number
table.insert(variables, { config_id=50000001,name = "ExtraSuite", value = 0,no_refresh = true})
end
function action_EVENT_GROUP_LOAD(context, evt)
local _extraSuite=ScriptLib.GetGroupVariableValue(context, "ExtraSuite")
--如果已经随机过初始suite了则直接加载对应的suite
if _extraSuite~=0 then
--ScriptLib.AddExtraGroupSuite(context, 0, _extraSuite)
ScriptLib.RefreshGroup(context, { group_id = 0, suite = _extraSuite })
return 0
--如果还没有随机过则按权重随机一个新的suite加载
else
--计算一下权重的和
local _maxWeight=0
for k,v in pairs(suiteWeightTable) do
_maxWeight=_maxWeight+v
end
if _maxWeight==0 then
ScriptLib.PrintContextLog(context,"## [BW_RandomLoadSuite] Warning没有配置任何加载权重")
return 0
end
--根据权重配置随机一个值
math.randomseed(ScriptLib.GetServerTime(context))
weight=math.random(1,_maxWeight)
--根据随机结果找到对应的suite存档并加载
for k,v in pairs(suiteWeightTable) do
if weight<=v then
_extraSuite=k
ScriptLib.SetGroupVariableValue(context, "ExtraSuite", _extraSuite)
--ScriptLib.AddExtraGroupSuite(context, 0, _extraSuite)
ScriptLib.RefreshGroup(context, { group_id = 0, suite = _extraSuite })
break
else
weight=weight-v
end
end
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,5 @@
--传送玩家到scene6
function SLC_Try_Trans_Player(context)
ScriptLib.TransPlayerToPos(context, {uid_list = {context.uid}, pos = {x=1021, y= 1086, z=880}, radius = 2, rot = {x=0, y=250.4503, z=0},scene_id=6})
return 0
end

View File

@@ -0,0 +1,182 @@
--[[======================================
|| filename: CalculateBulletForward
|| owner: chen.chen
|| description: 用于楔子玩法管理玩法阶段和回滚逻辑,之前做八方向射击导致文件名比较无关,但已经有多处引用就先不改了
|| LogName: ##[CalculateBulletForward]
|| Protection:
=======================================]]--
--[[
local shootLightMap={
[10024]=23334
}
local lawfulGadgets=
{
[1]={1002,1003},
[3]={1004,1005}
}
]]--
local extraTriggers={
{ config_id = 40000000, name = "EVENT_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 40000001, name = "VARIABLE_CHANGE", event = EventType.EVENT_VARIABLE_CHANGE, source = "MoveStep", condition = "", action = "action_variable_change", trigger_count = 0},
{ config_id = 40000002, name = "EVENT_GADGET_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
{ config_id = 40000003, name = "EVENT_PLATFORM_REACH_POINT", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_reach_point", trigger_count = 0},
{ config_id = 40000004, name = "EVENT_TIME_AXIS_PASS", event = EventType.EVENT_TIME_AXIS_PASS, source = "success", condition = "", action = "action_time_axis_pass_success", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables, { config_id=50000001,name = "MoveStep", value = 0,no_refresh = true})
table.insert(variables, { config_id=50000002,name = "Successed", value = 0,no_refresh = true})
end
function LF_CheckContainGonfigID(checkTable,targetId)
for k,v in pairs(checkTable) do
if v==targetId then
return true
end
end
return false
end
--ServerLuaCall楔子被命中
function WedgeOfSealBreak(context)
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法:楔子被命中")
if context.target_entity_id~=nil then
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法target_entity_id="..context.target_entity_id)
end
if context.source_entity_id~=nil then
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法source_entity_id="..context.source_entity_id)
end
--找触发者
local configID = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
--local configID = ScriptLib.GetConfigIdByEntityId(context, context.source_entity_id )
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法configID="..configID)
for k,v in pairs(gadgets) do
if v.config_id==configID then
if lawfulGadgets~=nil then
local tempValue=ScriptLib.GetGroupVariableValue(context, "MoveStep")
if tempValue<defs.steps then
tempValue=tempValue+1
if lawfulGadgets[tempValue]==nil or LF_CheckContainGonfigID(lawfulGadgets[tempValue],configID) then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, configID, 203)
ScriptLib.SetGroupVariableValue(context, "MoveStep", tempValue)
return 0
else
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法:触发了不合法的楔子发射器")
end
else
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法:路径已走完")
end
else
local tempValue=ScriptLib.GetGroupVariableValue(context, "MoveStep")
if tempValue<defs.steps then
tempValue=tempValue+1
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, configID, 203)
ScriptLib.SetGroupVariableValue(context, "MoveStep", tempValue)
else
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法:路径已走完")
end
end
end
end
return 0
end
-----------------------------EventActions-----------------------------------------
--时间轴用来在CS播放时后台回收逻辑楔子加载纯表现楔子和底座
function action_time_axis_pass_success(context, evt)
--进入方法log
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法:完成时间轴触发")
ScriptLib.KillGroupEntity(context, { group_id = 0, gadgets = {defs.config_id}})
ScriptLib.AddExtraGroupSuite(context, 0, 3)
return 0
end
--记录玩法是否完成,以及让楔子播掉落尘埃特效
function action_reach_point(context, evt)
--如果event不来自楔子则不处理
if evt.param1~=defs.config_id then
return 0
end
--如果是策划配置的落烟点,则播放匝地特效
if evt.param3==defs.shake_point then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.config_id, 203)
return 0
end
if ScriptLib.GetGroupVariableValue(context, "MoveStep")>=defs.steps then
--如果发现走完了所有路劲则记录玩法完成用于下次load是处理加载
ScriptLib.SetGroupVariableValue(context, "Successed", 1)
--播放匝地
if defs.shake_point==nil then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.config_id, 203)
end
--同时起一个2S的时间轴用来在CS过程中隐藏掉坠落的楔子加载纯氛围的楔子
ScriptLib.InitTimeAxis(context, "success", {2}, false)
else
--否则处理播一下抖落特效
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.config_id, 202)
end
return 0
end
--初始化楔子位置
function action_group_load(context, evt)
--进入方法log
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法group load")
--如果玩法已经完成,则只加载静态的物件
if ScriptLib.GetGroupVariableValue(context, "Successed")==1 then
ScriptLib.AddExtraGroupSuite(context, 0, 3)
return 0
end
--如果玩法未完成,则恢复玩进度
ScriptLib.AddExtraGroupSuite(context, 0, 2)
if ScriptLib.GetGroupVariableValue(context, "MoveStep")==0 then
return 0
end
tempStep=ScriptLib.GetGroupVariableValue(context, "MoveStep")
for i=tempStep,1,-1 do
if defs.routes[i].route~=nil then
ScriptLib.SetPlatformPointArray(context, defs.config_id, defs.routes[i].route, defs.routes[i].points, { route_type = 0 })
break
end
end
return 0
end
--variable改变时移动楔子
function action_variable_change(context, evt)
--进入方法log
ScriptLib.PrintContextLog(context, "##[CalculateBulletForward]楔子玩法:楔子开始移动")
--播放开始下落特效
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.config_id, 201)
tempStep=ScriptLib.GetGroupVariableValue(context, "MoveStep")
if defs.routes[tempStep]~=nil then
if defs.routes[tempStep].route~=nil then
ScriptLib.SetPlatformPointArray(context, defs.config_id, defs.routes[tempStep].route, defs.routes[tempStep].points, { route_type = 0 })
end
end
return 0
end
--楔子发射器关闭时,将对应流光也隐藏
function action_gadget_state_change(context, evt)
--如果某个发射器被关闭了,则查一下有没有配关联的流光,如果有的话就隐藏
if evt.param3==201 and evt.param1==203 then
if shootLightMap~=nil then
if shootLightMap[evt.param2]~=nil then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, shootLightMap[evt.param2], 201)
end
end
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,828 @@
--[[======================================
|| filename: CrystalLink
|| owner: luyao.huang
|| description: 2.6连线buff地城玩法
|| LogName: CrystalLink
|| Protection:
=======================================]]--
--miscs
--全局表数据定义
--fever进度升级节点
--local fever_progress_table = {
-- 0,50,100,200,300,500
--}
----各等级fever的下降速率
--local fever_attenuation = {
-- -1,-2,-3,-4,-5
--}
--
--怪物潮定义
--local monster_tide = {
-- {2001,2002,2003,2004,2005,2006,2007,2008,2009,2010},
-- {2011,2012,2013,2014,2015,2016,2017,2018,2019,2020},
-- {2021,2022,2023,2024,2025,2026,2027,2028,2029,2030},
-- {2031,2032,2033,2034,2035,2036,2037,2038,2039,2040},
--}
--
----精英怪定义
--local elite = {
-- {2041,2042},
-- {2043,2044},
-- {2045,2046},
-- {2047,2048}
--}
--
--local defs = {
-- play_round = 1, --战斗轮次,上半场 = 1下半场 = 2
-- next_play_group = 100000, --下一个轮次的groupid
--
-- worktop_id = 123, --启动操作台
--
-- minion_fever = 5, --杀死小怪获得的热度值
-- minion_interval = 120, --小怪潮切换间隔
-- elite_interval = 30, --精英怪刷新间隔
-- elite_fever = 50, --杀死精英怪获得的热度值
-- min_monster_count = 5, --在场最小的小怪数
-- max_monster_count = 5, --在场最大的小怪数
-- environment_suite = 4, --环境氛围物件所在suite
--}
--内部表数据定义
local local_defs = {
worktop_option = 30110, --操作台选项id
team_global_value = "SGV_FEVER_LEVEL", --team上的SGV名称
--monster_create_min_interval = 5 --性能优化:刷怪最小间隔
}
local time_axis = {
--小怪潮替换时间轴,每次触发时替换小怪潮
minion_tide_axis = {defs.minion_tide_interval},
--精英怪潮替换时间轴,每次触发时替换精英怪潮
elite_tide_axis = {defs.elite_tide_interval},
--精英怪时间轴,每次触发时刷新一组精英怪
elite_axis = {defs.elite_interval},
--精英怪预览reminder时间轴
elite_preview_reminder_axis = {defs.elite_preview_reminder_time},
--fever衰减间隔时间轴
attenuation_interval_axis = {defs.attenuation_interval},
--增加fever触发不超过n次的检测时间窗口
add_fever_check_window_axis = {defs.add_fever_check_window},
--性能优化:刷怪最小间隔
monster_create_min_interval_axis = {defs.monster_create_min_interval},
--扣分时间轴,每秒掉一定的分数
fever_axis = {1},
}
local Tri = {
{ config_id = 40000000, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
{ config_id = 40000001, name = "variable_change", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", trigger_count = 0},
{ config_id = 40000002, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
{ config_id = 40000003, name = "time_axis_pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
{ config_id = 40000004, name = "gallery_progress_pass", event = EventType.EVENT_GALLERY_PROGRESS_PASS, source = "", condition = "", action = "action_gallery_progress_pass", trigger_count = 0},
{ config_id = 40000005, name = "monster_tide_die", event = EventType.EVENT_MONSTER_TIDE_DIE, source = "", condition = "", action = "action_monster_tide_die", trigger_count = 0},
{ config_id = 40000006, name = "monster_die_before_leave_scene", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
{ config_id = 40000007, name = "gallery_stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
{ config_id = 40000008, name = "dungeon_all_avatar_die", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_dungeon_all_avatar_die", trigger_count = 0},
{ config_id = 40000009, name = "dungeon_settle", 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
--保存当前fever值并传给下半场
table.insert(variables,{ config_id=50000001,name = "current_fever", value = 0})
--是否允许开始玩法
table.insert(variables,{ config_id=50000002,name = "can_start", value = 0})
--当前玩法group是否激活
table.insert(variables,{ config_id=50000003,name = "is_active", value = 0})
table.insert(variables,{ config_id=50000004,name = "current_monster_tide", value = 0})
table.insert(variables,{ config_id=50000005,name = "current_elite", value = 1})
table.insert(variables,{ config_id=50000006,name = "fever_ratio", value = 1})
--以下用于控制怪物潮的启停逻辑
--记录最近一波刷出的怪物index如果current_monster_tide超过这个值说明index已经推进
table.insert(variables,{ config_id=50000007,name = "last_created_tide_index", value = 0})
--记录当前怪物潮是否死完了
table.insert(variables,{ config_id=50000008,name = "current_tide_all_killed", value = 1})
--是否因波次推进而被暂停
table.insert(variables,{ config_id=50000009,name = "has_paused_by_index_move_forward", value = 0})
--是否因小怪死亡而被暂停
table.insert(variables,{ config_id=50000010,name = "has_paused_by_minion_die", value = 0})
--记录pause操作的数量相当于一个栈。pause操作全部弹出后continue或create操作才能生效
table.insert(variables,{ config_id=50000011,name = "pause_operation_num", value = 0})
end
------------------------------------------------------------------
--group load如果是上半场则开始玩法初始化
function action_group_load(context,evt)
if (defs.play_round == 1) then
ScriptLib.PrintContextLog(context,"## [CrystalLink] Group Load 上半场group加载玩法初始化")
LF_Init_Play(context)
end
return 0
end
--下半场玩法启动,开始玩法初始化
function action_variable_change(context,evt)
if (evt.source_name == "can_start" and evt.param1 == 1) then
ScriptLib.PrintContextLog(context,"## [CrystalLink] variable change 下半场group启动玩法初始化")
LF_Init_Play(context)
end
return 0
end
--按下操作台按键,启动玩法
function action_select_option(context,evt)
ScriptLib.PrintContextLog(context,"## [CrystalLink] Select Option 玩家按下选项,启动玩法")
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.worktop_id, local_defs.worktop_option)
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.worktop_id, GadgetState.GearStop)
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,"## [CrystalLink] time axis pass 小怪潮切换时间轴tick指向下一波小怪潮索引")
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
LF_Set_Current_Monster_Tide(context,current_monster_tide+1)
--场上没怪不需要做暂停
if (not LF_Is_Current_Minion_All_Dead(context)) then
--怪物潮操作:怪物潮波次推进时,暂停怪物潮
LF_Try_Pause_Monster_Tide(context)
ScriptLib.SetGroupVariableValue(context,"has_paused_by_index_move_forward",1)
end
end
--精英波次时间轴tick将精英怪的index指向下一位
if (evt.source_name == "ELITE_TIDE_AXIS") then
ScriptLib.PrintContextLog(context,"## [CrystalLink] time axis pass 精英怪切换时间轴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,"## [CrystalLink] time axis pass 精英怪时间轴tick刷新下一波精英怪")
local current_elite_index = LF_Get_Current_Elite_Index(context)
LF_Create_Elite_Monster(context,current_elite_index)
--怪物潮操作:精英怪刷新时,暂停怪物潮
LF_Try_Pause_Monster_Tide(context)
end
--精英预警reminder时间轴tick刷一条精英怪出现预警
if (evt.source_name == "ELITE_PREVIEW_REMINDER_AXIS") then
ScriptLib.PrintContextLog(context,"## [CrystalLink] time axis pass 精英怪预警时间轴tick")
ScriptLib.ShowReminder(context, defs.elite_preview_reminder)
end
--fever衰减间隔时间轴tick打开开关允许fever衰减
if (evt.source_name == "ATTENUATION_INTERVAL_AXIS") then
ScriptLib.SetGroupTempValue(context,"can_attenuate",1,{})
end
--增加fever检测时间窗口这个窗口内玩家增加fever的次数应该少于指定次数
if (evt.source_name == "ADD_FEVER_CHECK_WINDOW_AXIS") then
ScriptLib.SetGroupTempValue(context,"add_fever_times",0,{})
end
--刷怪最小间隔tick尝试新建或重启怪物潮
if (evt.source_name == "MONSTER_CREATE_MIN_INTERVAL_AXIS") then
ScriptLib.PrintContextLog(context,"## [CrystalLink] time axis pass 怪物潮间隔tick可以继续创怪了")
LF_Try_Continue_Or_Create_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [CrystalLink] time axis pass重置怪物潮因为怪物死亡的停止状态")
ScriptLib.SetGroupVariableValue(context,"has_paused_by_minion_die",0)
end
--fever条tick扣分
if (evt.source_name == "FEVER_AXIS") then
LF_Update_Fever(context,LF_Get_Fever_Subnum(context))
end
return 0
end
--fever升级时给team挂global value并激活场景氛围物件
function action_gallery_progress_pass(context,evt)
ScriptLib.PrintContextLog(context,"## [CrystalLink] gallery progress pass fever条升级给角色发gv强化并激活场景物件")
local fever_level = evt.param1
ScriptLib.PrintContextLog(context,"## [CrystalLink] gallery progress pass 当前fever为"..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
--当前的怪物潮刷完的时候,重置当前的怪物潮
--这个方法仅处理同一波次怪物的循环刷新。如果当前怪物潮结束且波次已经前进则由monster_die负责刷新的怪物潮
function action_monster_tide_die(context,evt)
--这里要获取场上当前的index因为index变化以后再用evt.param1比对就不对了
local current_monster_tide = ScriptLib.GetGroupVariableValue(context,"last_created_tide_index")
local monster_eid = evt.source_eid
local monster_cid = ScriptLib.GetMonsterConfigId(context, {monster_eid})
local is_elite = LF_Is_Elite(context,monster_cid)
if (not is_elite) then
--当前怪物潮全部死亡(怪物潮无限循环,不存在这种情况了) 或 场上怪物全部死亡且进度已推进
--if (evt.param1 >= #monster_tide[current_monster_tide]) or (LF_Is_Current_Minion_All_Dead(context) and LF_Monster_Tide_Index_Has_Move_Forward(context)) then
-- ScriptLib.SetGroupVariableValue(context,"current_tide_all_killed", 1)
if LF_Is_Current_Minion_All_Dead(context) and LF_Monster_Tide_Index_Has_Move_Forward(context) then
ScriptLib.SetGroupVariableValue(context,"current_tide_all_killed", 1)
--如果没有时间轴,怪物潮结束时要重新开一波新的怪物潮
--这里相当于是手动做出了一个循环怪物潮,和怪物潮启停的逻辑本身没有关系
if (defs.monster_create_min_interval == 0) then
if (LF_Is_Pause_Operation_Stack_Empty(context)) then
if (LF_Is_Current_Tide_All_Killed(context)) then
ScriptLib.PrintContextLog(context,"## [CrystalLink]action_monster_tide_die当前波次死完要手动重开一次怪物潮")
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
LF_Create_Monster_Tide(context,current_monster_tide)
end
end
end
end
if (LF_Is_Current_Minion_All_Dead(context) and LF_Monster_Tide_Index_Has_Move_Forward(context)) then
ScriptLib.PrintContextLog(context,"## [CrystalLink] monster die轮次已切换重开一波怪物潮")
if ScriptLib.GetGroupVariableValue(context,"has_paused_by_index_move_forward") == 1 then
LF_Try_Continue_Or_Create_Monster_Tide(context)
ScriptLib.SetGroupVariableValue(context,"has_paused_by_index_move_forward",0)
end
end
ScriptLib.PrintContextLog(context,"## [CrystalLink] monster die怪物死亡重启时间轴")
local has_paused_by_minion_die = ScriptLib.GetGroupVariableValue(context,"has_paused_by_minion_die")
if (has_paused_by_minion_die == 0) then
if (defs.monster_create_min_interval ~= 0) then
ScriptLib.PrintContextLog(context,"## [CrystalLink] monster die之前没有怪物死亡了pause一次怪物潮")
ScriptLib.InitTimeAxis(context,"MONSTER_CREATE_MIN_INTERVAL_AXIS",time_axis.monster_create_min_interval_axis,false)
LF_Try_Pause_Monster_Tide(context)
ScriptLib.SetGroupVariableValue(context,"has_paused_by_minion_die",1)
end
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)
if (is_elite) then
if (LF_Is_Current_Elite_All_Dead(context)) then
ScriptLib.PrintContextLog(context,"## [CrystalLink] monster die本轮次的精英怪死完了精英怪重新开始计时")
--精英死亡时,重新开始计时
ScriptLib.EndTimeAxis(context,"ELITE_AXIS")
ScriptLib.InitTimeAxis(context,"ELITE_AXIS",time_axis.elite_axis,false)
--精英死亡时,重新开始精英怪预警计时
ScriptLib.EndTimeAxis(context,"ELITE_PREVIEW_REMINDER_AXIS")
ScriptLib.InitTimeAxis(context,"ELITE_PREVIEW_REMINDER_AXIS",time_axis.elite_preview_reminder_axis,false)
--精英怪死亡时,可能波次已经推进且场上小怪死完,但小怪是在波次推进之前死完的,无法触发这个事件
if (LF_Is_Current_Minion_All_Dead(context) and LF_Monster_Tide_Index_Has_Move_Forward(context)) then
ScriptLib.SetGroupVariableValue(context,"current_tide_all_killed", 1)
end
--精英怪死亡create or continue
LF_Try_Continue_Or_Create_Monster_Tide(context)
end
end
--根据怪物eid计分
LF_Update_Score(context,monster_eid)
return 0
end
--gallery倒计时结束开始清理玩法
function action_gallery_stop(context,evt)
--如果gallery时间到结算则执行一次当前轮次玩法结算流程否则是其他情况强行中断直接使地城fail
ScriptLib.PrintContextLog(context,"## [CrystalLink] gallery stop Gallery终止原因为"..evt.param3)
if evt.param3 == 1 then
LF_Stop_Play(context)
end
return 0
end
--团灭,直接结束玩法
function action_dungeon_all_avatar_die(context,evt)
--触发事件时做一次校验只在当前激活的group做清理
local is_active = ScriptLib.GetGroupVariableValue(context,"is_active")
if (is_active == 1) then
ScriptLib.CauseDungeonFail(context)
end
return 0
end
--副本结算,结束玩法
function action_dungeon_settle(context,evt)
--触发事件时做一次校验只在当前激活的group做清理
local is_active = ScriptLib.GetGroupVariableValue(context,"is_active")
if (is_active == 1) then
LF_Immediate_Stop_Play(context)
ScriptLib.CauseDungeonSuccess(context)
end
return 0
end
------------------------------------------------------------------
--辅助方法---------------------------------------------------------
------------------------------------------------------------------
--关卡相关方法-----------------------------------------------------
--初始化玩法,加载操作台等物件
function LF_Init_Play(context)
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Init Play ----------玩法初始化开始----------")
--先将当前group置为激活状态
ScriptLib.SetGroupVariableValue(context,"is_active",1)
ScriptLib.CreateGadget(context,{config_id = defs.worktop_id})
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.worktop_id, {local_defs.worktop_option})
--加载环境氛围物件
ScriptLib.AddExtraGroupSuite(context,base_info.group_id,defs.environment_suite)
--上半场开场将team上的半场SGV记录为0
if (defs.play_round == 1) then
LF_Set_Team_Global_Value(context,"SGV_CLEAR_LEVEL",0)
end
--如果是下半场,需要直接将振晶石切换到上半场的状态
if (defs.play_round == 2) then
local current_fever = ScriptLib.GetGroupVariableValue(context,"current_fever")
local fever_level = LF_Get_Fever_Level(context,current_fever)
LF_Activate_Environment_Gadget(context,fever_level)
end
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Init Play ----------玩法初始化结束----------")
end
--启动玩法方法,初始化各种东西
function LF_Start_Play(context)
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Start Play ----------玩法启动开始----------")
--先启动gallery并设置热度条
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.InitGalleryProgressScore(context, "fever", defs.gallery_id, fever_progress_table, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_CRYSTAL_LINK, GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NO_DEGRADE)
--如果是下半场在开场的时候用current_fever刷新一次fever值把上半场的fever带过来
if (defs.play_round == 2) then
local current_fever = ScriptLib.GetGroupVariableValue(context,"current_fever")
LF_Update_Fever(context,current_fever)
end
--启动各种时间轴
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)
ScriptLib.InitTimeAxis(context,"ELITE_PREVIEW_REMINDER_AXIS",time_axis.elite_preview_reminder_axis,false)
ScriptLib.InitTimeAxis(context,"ATTENUATION_INTERVAL_AXIS",time_axis.attenuation_interval_axis,false)
ScriptLib.InitTimeAxis(context,"ADD_FEVER_CHECK_WINDOW_AXIS",time_axis.add_fever_check_window_axis,true)
--玩法变量初始化
--设置怪物潮编号(仅用于内部怪物潮自增计数)
LF_Set_Current_Tide_Num(context,0)
--设置怪物潮波次
LF_Set_Current_Monster_Tide(context,1)
--设置精英怪波次
LF_Set_Current_Elite_Index(context,1)
--local current_monster_tide = LF_Get_Current_Monster_Tide(context)
--LF_Create_Monster_Tide(context,current_monster_tide)
--开始生成第一波怪物潮
LF_Try_Continue_Or_Create_Monster_Tide(context)
--加载空气墙
ScriptLib.CreateGadget(context,{config_id = defs.airwall})
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Start Play ----------玩法启动结束----------")
end
--终止玩法方法,关掉各种东西
function LF_Stop_Play(context)
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Stop Play ----------当前玩法轮次开始结束----------")
LF_Play_Clear_All(context)
--玩法自然结束时将group设置为未激活状态
ScriptLib.SetGroupVariableValue(context,"is_active",0)
if (defs.play_round == 1) then
--上半场结束,让下半场开始加载
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Stop Play 当前为上半场挑战结束,切换到下半场")
--将当前热度值转移到下半场
local current_fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
ScriptLib.SetGroupVariableValueByGroup(context,"current_fever",current_fever,defs.next_play_group)
ScriptLib.SetGroupVariableValueByGroup(context,"can_start",1,defs.next_play_group)
LF_Set_Team_Global_Value(context,"SGV_CLEAR_LEVEL",1)
if ScriptLib.CrystalLinkDungeonTeamSetUp(context,2,{init_gallery_progress=current_fever})~=0 then
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Stop Play 切换队伍失败,直接结束地城")
ScriptLib.CauseDungeonFail(context)
end
else
--下半场结束,地城结算
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Stop Play 当前为下半场挑战结束,地城结算")
ScriptLib.CauseDungeonSuccess(context)
end
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Stop Play ----------当前玩法轮次结束----------")
end
--立刻终止玩法,用于玩家地城退出或团灭等情况
function LF_Immediate_Stop_Play(context,is_success)
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Stop Play ----------玩法需要立刻结束----------")
LF_Play_Clear_All(context)
ScriptLib.StopGallery(context,defs.gallery_id,false)
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Stop Play ----------玩法结束,地城结算----------")
end
--清理玩法数据方法,将当前开启的物件、怪物、时间轴全部清空
function LF_Play_Clear_All(context)
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Clear Play All ----------开始清理当前玩法数据----------")
--清理一下操作台和环境物件,防止其他问题
--ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.airwall)
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.worktop_id)
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, defs.environment_suite)
--玩法结束,清理掉当前的怪物潮和精英怪
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
ScriptLib.KillMonsterTide(context, base_info.group_id, current_monster_tide)
--清干净场上残存的怪物
local alive_monster_list = ScriptLib.GetGroupAliveMonsterList(context,base_info.group_id)
for i = 1,#alive_monster_list do
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Clear Play All 清理在场monster "..alive_monster_list[i])
ScriptLib.RemoveEntityByConfigId(context,base_info.group_id,EntityType.MONSTER,alive_monster_list[i])
end
--结束各个时间轴
ScriptLib.EndTimeAxis(context,"FEVER_AXIS")
ScriptLib.EndTimeAxis(context,"MINION_TIDE_AXIS")
ScriptLib.EndTimeAxis(context,"ELITE_AXIS")
ScriptLib.EndTimeAxis(context,"ELITE_TIDE_AXIS")
ScriptLib.EndTimeAxis(context,"ELITE_PREVIEW_REMINDER_AXIS")
ScriptLib.EndTimeAxis(context,"ATTENUATION_INTERVAL_AXIS")
ScriptLib.EndTimeAxis(context,"ADD_FEVER_CHECK_WINDOW_AXIS")
ScriptLib.EndTimeAxis(context,"MONSTER_CREATE_MIN_INTERVAL_AXIS")
ScriptLib.PrintContextLog(context,"## [CrystalLink] LF Clear Play All ----------清理当前玩法数据结束----------")
end
--启动一波指定ID的怪物潮需要传入该波怪物潮的ID具体配置在miscs中定义
function LF_Create_Monster_Tide(context,monster_tide_index)
ScriptLib.PrintContextLog(context,"## [CrystalLink] Create 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)
local min = monster_tide_count[monster_tide_index].min
local max = monster_tide_count[monster_tide_index].max
ScriptLib.AutoMonsterTide(context, tide_num+1, base_info.group_id, monster_config_id_list, 0, min ,max)
--创建一波怪物潮后将当前怪物潮的index记下来方便怪物潮指针前进后的比对
ScriptLib.SetGroupVariableValue(context,"last_created_tide_index",monster_tide_index)
--重置记录monstertide的变量
ScriptLib.SetGroupVariableValue(context,"current_tide_all_killed",0)
ScriptLib.PrintContextLog(context,"## [CrystalLink] Create Monster Tide ----------怪物潮生成结束----------")
end
--召唤指定ID的精英怪组
function LF_Create_Elite_Monster(context,elite_index)
ScriptLib.PrintContextLog(context,"## [CrystalLink] Create Elite Monster ----------开始生成精英怪,精英怪索引为 = "..elite_index.."----------")
local elite_list = elite[elite_index]
math.randomseed(ScriptLib.GetServerTime(context))
local point_index=math.random(#elite_born_points)
local points = elite_born_points[point_index]
for i = 1,#elite_list do
local born_point = LF_Get_Point(context,points[i])
ScriptLib.CreateMonsterByConfigIdByPos(context, elite_list[i],born_point.pos,born_point.rot)
end
ScriptLib.PrintContextLog(context,"## [CrystalLink] Create Elite Monster ----------精英怪生成结束----------")
end
--以下为怪物潮的暂停、继续、生成操作。为了保证逻辑之间耦合正确所有对怪物潮的操作都要走这2个接口
--尝试暂停怪物潮
function LF_Try_Pause_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [CrystalLink]LF_Try_Pause_Monster_Tide尝试暂停怪物潮")
LF_Push_Pause_Operation(context)
ScriptLib.PauseAutoMonsterTide(context, base_info.group_id, LF_Get_Current_Tide_Num(context))
end
--尝试重启或新建当前怪物潮
function LF_Try_Continue_Or_Create_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"## [CrystalLink]LF_Try_Continue_Or_Create_Monster_Tide尝试重启或新建怪物潮")
LF_Pop_Pause_Operation(context)
if (LF_Is_Pause_Operation_Stack_Empty(context)) then
if (LF_Is_Current_Tide_All_Killed(context)) then
ScriptLib.PrintContextLog(context,"## [CrystalLink]LF_Try_Continue_Or_Create_Monster_Tide当前波次怪物死完新建怪物潮")
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
LF_Create_Monster_Tide(context,current_monster_tide)
else
ScriptLib.PrintContextLog(context,"## [CrystalLink]LF_Try_Continue_Or_Create_Monster_Tide当前波次怪物未死完重启怪物潮")
ScriptLib.ContinueAutoMonster(context, base_info.group_id, LF_Get_Current_Tide_Num(context))
end
end
end
--尝试pause向栈内push一个pause操作
function LF_Push_Pause_Operation(context)
ScriptLib.ChangeGroupVariableValue(context,"pause_operation_num",1)
end
--尝试重启或新建怪物潮从栈内pop一个pause操作
function LF_Pop_Pause_Operation(context)
if (not LF_Is_Pause_Operation_Stack_Empty(context)) then
ScriptLib.ChangeGroupVariableValue(context,"pause_operation_num",-1)
end
end
--返回Pause操作栈是否为空
function LF_Is_Pause_Operation_Stack_Empty(context)
local pause_operation_num = ScriptLib.GetGroupVariableValue(context,"pause_operation_num")
ScriptLib.PrintContextLog(context,"## [CrystalLink]LF_Is_Pause_Operation_Stack_Empty: Pause指令计数为"..pause_operation_num)
return pause_operation_num == 0
end
--通用类方法-------------------------------------------------------
--切换场上的场景氛围物件状态
function LF_Activate_Environment_Gadget(context,fever_level)
ScriptLib.PrintContextLog(context,"## [CrystalLink] Activate Environment Gadget ----------激活场景物件!----------")
if (ReactionGems == nil) then
return 0
end
if (fever_level < #fever_progress_table-2) then
for i = 1, fever_level do
ScriptLib.SetGroupGadgetStateByConfigId(context,base_info.group_id,ReactionGems[i][1],201)
ScriptLib.SetGroupGadgetStateByConfigId(context,base_info.group_id,ReactionGems[i][2],201)
end
else
for i = 1, #ReactionGems do
ScriptLib.SetGroupGadgetStateByConfigId(context,base_info.group_id,ReactionGems[i][1],202)
ScriptLib.SetGroupGadgetStateByConfigId(context,base_info.group_id,ReactionGems[i][2],202)
end
end
ScriptLib.PrintContextLog(context,"## [CrystalLink] Activate Environment Gadget ----------激活场景物件结束!----------")
end
--给team挂global value角色处理各种特殊效果
function LF_Set_Team_Global_Value(context,gv_name,value)
ScriptLib.PrintContextLog(context,"## [CrystalLink] Set Team GV ----------开始向team写gv: "..gv_name.." = "..value.."----------")
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.SetTeamServerGlobalValue(context, uid, gv_name, value)
ScriptLib.PrintContextLog(context,"## [CrystalLink] Set Team GV ----------设置team gv结束----------")
end
-----CRUD类方法----------------------------------------------------
--更新fever条fever_delta为fever条改变值
--增补需求单位m时间内获取的fever的次数存在上限超过上限后无法继续增加fever
--增补需求超过一定时间未增加fever后fever开始衰减
function LF_Update_Fever(context,fever_delta)
--增加fever的情况
if (fever_delta>0) then
local add_fever_times = ScriptLib.GetGroupTempValue(context,"add_fever_times",{})
--如果增加的次数小于上限,则允许增加,并次数+1
if (add_fever_times<defs.add_fever_upper_bound) then
ScriptLib.AddGalleryProgressScore(context, "fever", defs.gallery_id, fever_delta)
ScriptLib.SetGroupTempValue(context,"add_fever_times",add_fever_times+1,{})
--增加了fever重置一次衰减时间轴并修正temp value不允许fever降低
ScriptLib.EndTimeAxis(context,"ATTENUATION_INTERVAL_AXIS")
ScriptLib.InitTimeAxis(context,"ATTENUATION_INTERVAL_AXIS",time_axis.attenuation_interval_axis,false)
ScriptLib.SetGroupTempValue(context,"can_attenuate",0,{})
else
end
else
--减少fever的情况
local can_attenuate = ScriptLib.GetGroupTempValue(context,"can_attenuate",{})
if (can_attenuate == 1) then
ScriptLib.AddGalleryProgressScore(context, "fever", defs.gallery_id, fever_delta)
else
end
end
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_Level(context,fever)
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 i-1
end
end
return -1
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
function LF_Set_Current_Elite_Index(context,index)
--做一下校验如果超出elite范围则强制限定到elite范围内
if (index > #elite) then
index = #elite
end
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)
--做一下校验如果超出monster_tide范围则强制限定到monster_tide范围内
if (index > #monster_tide) then
index = #monster_tide
end
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
--设置当前怪物潮的波次数注意这不是怪物潮的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
--根据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
for j = 1,#elite[i] do
if monster_cid == elite[i][j] then
return true
end
end
end
return false
end
--返回当前场上精英怪是否全死了
function LF_Is_Current_Elite_All_Dead(context)
local alive_monster_list = ScriptLib.GetGroupAliveMonsterList(context,base_info.group_id)
for i = 1, #alive_monster_list do
if (LF_Is_Elite(context,alive_monster_list[i])) then
return false
end
end
return true
end
--返回当前场上小怪是否全死了
function LF_Is_Current_Minion_All_Dead(context)
local alive_monster_list = ScriptLib.GetGroupAliveMonsterList(context,base_info.group_id)
for i = 1, #alive_monster_list do
if (not LF_Is_Elite(context,alive_monster_list[i])) then
return false
end
end
return true
end
--返回当前场上是否已经没怪了
function LF_Is_Monster_All_Dead(context)
return #ScriptLib.GetGroupAliveMonsterList(context,0) == 0
end
function LF_Get_Current_Tide_Max(context)
local current_tide = LF_Get_Current_Monster_Tide(context)
return monster_tide_count[current_tide].max
end
--返回怪物潮index是否已经推进
function LF_Monster_Tide_Index_Has_Move_Forward(context)
local last_created_tide_index = ScriptLib.GetGroupVariableValue(context,"last_created_tide_index")
local current_tide_index = LF_Get_Current_Monster_Tide(context)
if (last_created_tide_index == current_tide_index) then
return false
end
return true
end
function LF_Is_Current_Tide_All_Killed(context)
return ScriptLib.GetGroupVariableValue(context,"current_tide_all_killed") == 1
end
------------------------------------------------------------------
--server lua call-------------------------------------------------
function SLC_Add_Fever(context)
ScriptLib.PrintContextLog(context,"## [CrystalLink]SLC_Add_Fever---------SLC: 连线buff触发fever增加---------")
LF_Update_Fever(context,defs.buff_fever)
ScriptLib.PrintContextLog(context,"## [CrystalLink]SLC_Update buff Icon State---------SLC: 连线buff触发处理完成---------")
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,323 @@
--[[digMaps={
[1]={
{1,0,0,1,0},
{0,0,1,2,1},
{1,0,0,1,0},
{0,0,0,1,0},
{1,0,0,0,0},
},
[2]={
{1,0,0,1,0},
{0,0,1,2,1},
{1,0,0,1,0},
{0,0,0,1,0},
{1,0,0,0,0},
},
[3]={
{1,0,0,1,0},
{0,0,1,2,1},
{1,0,0,1,0},
{0,0,0,1,0},
{1,0,0,0,0},
},
}]]--
local extraTriggers={
{ config_id = 8000001, name = "EVENT_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 8000002, name = "VARIABLE_CHANGE", event = EventType.EVENT_VARIABLE_CHANGE, source = "PlayStartTrigger", condition = "", action = "action_VARIABLE_CHANGE", trigger_count = 0},
{ config_id = 8000003, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_SELECT_OPTION", trigger_count = 0},
{ config_id = 8000004, name = "GADGET_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_GADGET_STATE_CHANGE", trigger_count = 0},
{ config_id = 8000005, name = "EVENT_LUA_NOTIFY", event = EventType.EVENT_LUA_NOTIFY, source = "BombDie", condition = "", action = "action_LUA_NOTIFY", trigger_count = 0},
{ config_id = 8000006, name = "VARIABLE_CHANGE_Reset", event = EventType.EVENT_VARIABLE_CHANGE, source = "PlayResetTrigger", condition = "", action = "action_VARIABLE_CHANGE_RESET", trigger_count = 0},
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables, { config_id=50000001,name = "PlayStartTrigger", value = 0,no_refresh = false})
table.insert(variables, { config_id=50000002,name = "PlayResetTrigger", value = 0,no_refresh = false})
table.insert(variables, { config_id=50000003,name = "SuccessTrigger", value = 0,no_refresh = false})
table.insert(variables, { config_id=50000004,name = "FailTrigger", value = 0,no_refresh = false})
table.insert(variables, { config_id=50000005,name = "PlayStep", value = 0,no_refresh = true})
table.insert(variables, { config_id=50000006,name = "TreasureBoxPos", value = 0,no_refresh = true})
table.insert(variables, { config_id=50000007,name = "Strategy", value = 0,no_refresh = true})
table.insert(variables, { config_id=50000008,name = "Playing", value = 0,no_refresh = true})
end
--[[
PlayStep:
0一阶段玩法未完成
1一阶段玩法完成宝箱未领取
2二阶段玩法未完成
3二阶段玩法完成宝箱未领取
4三阶段玩法未完成
5三阶段玩法完成宝箱未领取
6全部玩法完成
]]--
-----------------------------EventActions-----------------------------------------
--炸药桶被打爆后会给一个reminder
function action_LUA_NOTIFY(context, evt)
if not(defs.is_quest_group==1) then
ScriptLib.ShowReminder(context, 310645006)
end
return 0
end
--如果宝箱未被领取则group创建时恢复宝箱和位置
function action_EVENT_GROUP_LOAD(context, evt)
local playStep= ScriptLib.GetGroupVariableValue(context, "PlayStep")
--如果宝箱还未领,创建宝箱
if playStep==1 or playStep==3 or playStep==5 then
local treasureBoxPos=ScriptLib.GetGroupVariableValue(context, "TreasureBoxPos")
--找到宝箱创建位置
local configID=defs["gadget_"..treasureBoxPos]
for i=1,#gadgets do
if gadgets[i].config_id==configID then
local treasureBoxID=(playStep+1)/2
treasureBoxID=math.floor(treasureBoxID)
if defs["treasurebox_"..treasureBoxID]~=nil then
ScriptLib.PrintContextLog(context,"DigPlayLog:load treasurebox pos:"..gadgets[i].pos.x.."|"..gadgets[i].pos.y.."|"..gadgets[i].pos.z)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs["treasurebox_"..treasureBoxID], gadgets[i].pos, gadgets[i].rot)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, configID, 203)
else
ScriptLib.PrintContextLog(context,"DigPlayError:load treasurebox index failed")
end
break
end
end
return 0
end
--如果玩法还在继续,则恢复之前的状态
local isPlaying = ScriptLib.GetGroupVariableValue(context, "Playing")
if isPlaying==1 then
AddOptions(context)
end
return 0
end
--宝箱开启后推进流程
function action_GADGET_STATE_CHANGE(context, evt)
if evt.param1==102 then
local playStep= ScriptLib.GetGroupVariableValue(context, "PlayStep")
playStep=playStep+1
ScriptLib.SetGroupVariableValue(context, "PlayStep", playStep)
end
return 0
end
--group主动任务触发玩法开始
function action_VARIABLE_CHANGE(context, evt)
--复原物件
ResetHoles(context)
--记录正在游玩状态
ScriptLib.SetGroupVariableValue(context, "Playing", 1)
ScriptLib.SetGroupVariableValue(context, "Strategy", 0)
AddOptions(context)
return 0
end
--group任务触发玩法结束
function action_VARIABLE_CHANGE_RESET(context, evt)
--复原物件
ResetHoles(context)
EndGame(context)
--复原正在游玩状态
ScriptLib.SetGroupVariableValue(context, "Playing", 0)
ScriptLib.SetGroupVariableValue(context, "Strategy", 0)
--把宝箱干掉并回退playstep
local playStep = ScriptLib.GetGroupVariableValue(context, "PlayStep")
if playStep==1 then
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs["treasurebox_"..1])
elseif playStep==3 then
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs["treasurebox_"..2])
elseif playStep==5 then
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs["treasurebox_"..3])
end
if playStep==1 or playStep==3 or playStep==5 then
playStep=playStep-1
ScriptLib.SetGroupVariableValue(context, "PlayStep", playStep)
end
return 0
end
function action_SELECT_OPTION(context, evt)
if evt.param2~=99 then
return 0
end
local strategy=ScriptLib.GetGroupVariableValue(context, "Strategy")
--strategy为0则说明是第一次挖此时尽可能随机一个挖掘处不是炸弹的strategy
if strategy<=0 or strategy==nil then
strategy=LF_InitialStrategy(context,evt)
end
ScriptLib.DelWorktopOptionByGroupId(context, 0, evt.param1, evt.param2)
--查询如果是地雷或宝箱,结束玩法
for k,v in pairs(defs) do
if v==evt.param1 then
local tempIdx=string.sub(k,#k-1)
tempIdx=tonumber(tempIdx)
local digNum=digMaps[strategy][math.floor(tempIdx/10)][tempIdx%10]
--挖到炸弹
if digNum==1 then
--提示
if not(defs.is_quest_group==1) then
ScriptLib.ShowReminder(context, 310645005)
end
--如果是任务的group则只播放reminder而不结束游戏
if defs.is_quest_group==1 then
if defs.reminder_id~=nil then
ScriptLib.ShowReminder(context, defs.reminder_id)
end
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 204)
else
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 204)
--给group发送玩法失败消息
ScriptLib.ChangeGroupVariableValue(context, "FailTrigger", 1)
EndGame(context)
end
--挖到宝箱
elseif digNum==2 then
--保存宝箱位置
ScriptLib.SetGroupVariableValue(context, "TreasureBoxPos", tempIdx)
--增加关卡进度
local playStep = ScriptLib.GetGroupVariableValue(context, "PlayStep")
playStep=playStep+1
ScriptLib.SetGroupVariableValue(context, "PlayStep", playStep)
--创建宝箱
for i=1,#gadgets do
if gadgets[i].config_id==evt.param1 then
local treasureBoxID=(playStep+1)/2
treasureBoxID=math.floor(treasureBoxID)
--挖到宝箱后说一句话,纯表现
if not(defs.is_quest_group==1) then
local reminderId=310645001+treasureBoxID
ScriptLib.ShowReminder(context, reminderId)
end
ScriptLib.PrintContextLog(context,"DigPlayLog:treasureBoxID:"..treasureBoxID)
ScriptLib.PrintContextLog(context,"DigPlayLog:treasureBoxID:"..treasureBoxID.."|"..defs["treasurebox_"..treasureBoxID])
if defs["treasurebox_"..treasureBoxID]~=nil then
ScriptLib.CreateGadgetByConfigIdByPos(context, defs["treasurebox_"..treasureBoxID], gadgets[i].pos, gadgets[i].rot)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 203)
else
ScriptLib.PrintContextLog(context,"DigPlayError:get treasurebox index failed")
end
break
end
end
--给group发送玩法成功消息
ScriptLib.ChangeGroupVariableValue(context, "SuccessTrigger", 1)
--结束玩法
EndGame(context)
--挖到物品
else
local bombNum=0
--计算目标位置周围有几个雷
local ti=math.floor(tempIdx/10)
local tj=tempIdx%10
for i=(ti>1 and ti-1 or ti),(ti<5 and ti+1 or ti) do
for j=(tj>1 and tj-1 or tj),(tj<5 and tj+1 or tj) do
if digMaps[strategy][i][j]==1 then
if not (math.abs(i-ti)>=1 and math.abs(j-tj)>=1) then
bombNum=bombNum+1
end
end
end
end
ScriptLib.PrintContextLog(context,"## [DigPlay] Log : arround bomb num:"..bombNum)
--根据雷数切换状态
if bombNum==0 or bombNum>3 then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 205)
elseif bombNum==1 then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 201)
elseif bombNum==2 or bombNum==3 then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 202)
end
end
end
end
return 0
end
function EndGame(context)
for i=1,5 do
for j=1,5 do
tempIdx=i*10+j
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs["gadget_"..tempIdx], 99)
end
end
ScriptLib.SetGroupVariableValue(context, "Playing", 0)
return 0
end
function AddOptions(context)
local tempIdx=0
for i=1,5 do
for j=1,5 do
tempIdx=i*10+j
if ScriptLib.GetGadgetStateByConfigId(context, 0, defs["gadget_"..tempIdx])==0 then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, defs["gadget_"..tempIdx], {99})
end
end
end
return 0
end
function ResetHoles(context)
local tempIdx=0
for i=1,5 do
for j=1,5 do
tempIdx=i*10+j
if ScriptLib.GetGadgetStateByConfigId(context, 0, defs["gadget_"..tempIdx])~=0 then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs["gadget_"..tempIdx], 0)
end
end
end
return 0
end
function LF_InitialStrategy(context,evt)
--标志在前半遍历是否找到合适的strategy
local firstHalf=0
math.randomseed(ScriptLib.GetServerTime(context))
--先随一次
local tempStrategy=math.random(#digMaps)
for k,v in pairs(defs) do
if v==evt.param1 then
local tempIdx=string.sub(k,#k-1)
tempIdx=tonumber(tempIdx)
local digNum=digMaps[tempStrategy][math.floor(tempIdx/10)][tempIdx%10]
--如果首次挖到的位置是炸弹
if digNum==1 then
ScriptLib.PrintContextLog(context,"## [DigPlay] Log : 第一次随机策略随到了雷:"..tempStrategy)
--从随机位置开始顺序遍历table直到找到第一个不是炸弹的配置找不到则按原来的结果输出
for i=tempStrategy,#digMaps do
if digMaps[i][math.floor(tempIdx/10)][tempIdx%10]~=1 then
tempStrategy=i
firstHalf=1
break
end
end
if firstHalf==0 then
for i=1,tempStrategy do
if digMaps[i][math.floor(tempIdx/10)][tempIdx%10]~=1 then
tempStrategy=i
break
end
end
end
end
end
end
ScriptLib.SetGroupVariableValue(context, "Strategy", tempStrategy)
ScriptLib.PrintContextLog(context,"## [DigPlay] Log : 随机策略最后的输出策略:"..tempStrategy)
return tempStrategy
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,23 @@
function LF_Initialize_Group(triggers, suites)
table.insert(variables, { config_id=51200001,name = "DropRockAbyssBulletTrigger", value = 0,no_refresh = false})
end
--增加对应的variable
function DropRockAbyssBulletTrigger(context)
local value=ScriptLib.GetGroupVariableValue(context, "DropRockAbyssBulletTrigger")
if value == -1 then
ScriptLib.PrintContextLog(context,"##[DropRockAbyssBulletTrigger] variable get failed")
return 0
end
if value==0 then
value=value+1
ScriptLib.SetGroupVariableValue(context, "DropRockAbyssBulletTrigger", value)
else
ScriptLib.SetGroupVariableValue(context, "DropRockAbyssBulletTrigger", 0)
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,114 @@
local extraTriggers={
{ config_id = 8000001, name = "EVENT_ANY_GADGET_DIE", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_EVENT_ANY_GADGET_DIE", trigger_count = 0 },
{ config_id = 8000002, name = "EVENT_TIME_AXIS_PASS", event = EventType.EVENT_TIME_AXIS_PASS, source = "WoodenStakeChallenge", condition = "", action = "action_EVENT_TIME_AXIS_PASS", trigger_count = 0 },
{ config_id = 8000003, name = "EVENT_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 8000004, name = "EVENT_Refresh_Delay", event = EventType.EVENT_TIME_AXIS_PASS, source = "RefreshDelay", condition = "", action = "action_Refresh_Delay", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
end
function action_EVENT_ANY_GADGET_DIE(context, evt)
ScriptLib.PrintContextLog(context,"HM_WoodenStakeChallenge:gadget die")
--如果uid非空则记录是谁干的
if context.uid~=0 and context.uid~=nil then
ScriptLib.PrintContextLog(context,"HM_WoodenStakeChallenge uid:"..context.uid)
--计数标志加一
ScriptLib.ChangeGroupTempValue(context, "uidListIndex", 1, {})
local tempIdx=ScriptLib.GetGroupTempValue(context, "uidListIndex", {})
--存uid
ScriptLib.SetGroupTempValue(context, "uid"..tempIdx, context.uid, {})
else
ScriptLib.PrintContextLog(context,"HM_WoodenStakeChallenge uid is null")
end
--木箱销毁相关判定
if ScriptLib.GetGroupTempValue(context, "TimeAxisPlaying", {})==0 then
ScriptLib.PrintContextLog(context,"HM_WoodenStakeChallenge:TimeAxisPlaying Zero")
--毁坏木箱计数
ScriptLib.ChangeGroupTempValue(context, "destoryedStakeNum", 1, {})
--修改flag表示玩法开启
ScriptLib.SetGroupTempValue(context, "TimeAxisPlaying", 1, {})
--起2S的时间轴
ScriptLib.InitTimeAxis(context, "WoodenStakeChallenge", {defs.challengeTime or 2}, false)
ScriptLib.PrintContextLog(context,"HM_WoodenStakeChallenge:WoodenStakeChallenge start")
--起reminder提示开始
--ScriptLib.ShowReminder(context, 400125)
else
--毁坏木箱计数
ScriptLib.ChangeGroupTempValue(context, "destoryedStakeNum", 1, {})
--log
ScriptLib.PrintContextLog(context,"HM_WoodenStakeChallenge:destoryedStakeNum check")
--检测是否所有木箱都销毁
if ScriptLib.GetGroupTempValue(context, "destoryedStakeNum", {})>=6 then
--根据uidListIndex拿取参与击杀的uidList
local uidList={}
for i=1,ScriptLib.GetGroupTempValue(context, "uidListIndex", {}) do
local repeated=false
local tempUid=ScriptLib.GetGroupTempValue(context, "uid"..i, {})
for j=1,#uidList do
if uidList[j]==tempUid then
repeated=true
break
end
end
if repeated==false then
table.insert(uidList,tempUid)
end
end
--上传接口上传展示数据
ScriptLib.UpdateStakeHomePlayRecord(context, uidList)
--reminer提示成功
ScriptLib.ShowReminder(context, 400126)
--关闭时间轴
ScriptLib.EndTimeAxis(context, "WoodenStakeChallenge")
ScriptLib.InitTimeAxis(context, "RefreshDelay", {defs.delayTime or 1}, false)
end
end
return 0
end
function action_EVENT_TIME_AXIS_PASS(context, evt)
ScriptLib.PrintContextLog(context,"HM_WoodenStakeChallenge:fail time axis in")
--重置参数
ScriptLib.SetGroupTempValue(context, "uidListIndex", 0, {})
ScriptLib.SetGroupTempValue(context, "TimeAxisPlaying", 0, {})
ScriptLib.SetGroupTempValue(context, "destoryedStakeNum", 0, {})
--起reminder提示结束
--ScriptLib.ShowReminder(context, 400127)
--刷新group
ScriptLib.RefreshGroup(context, { group_id = 0, suite = 1 })
return 0
end
function action_Refresh_Delay(context, evt)
ScriptLib.PrintContextLog(context,"HM_WoodenStakeChallenge:success time axis in")
--重置参数
ScriptLib.SetGroupTempValue(context, "uidListIndex", 0, {})
ScriptLib.SetGroupTempValue(context, "TimeAxisPlaying", 0, {})
ScriptLib.SetGroupTempValue(context, "destoryedStakeNum", 0, {})
--刷新group
ScriptLib.RefreshGroup(context, { group_id = 0, suite = 1 })
return 0
end
function action_EVENT_GROUP_LOAD(context, evt)
--重置记录的被销毁木桩数目
ScriptLib.SetGroupTempValue(context, "destoryedStakeNum", 0, {})
--重置记录的玩家数目
ScriptLib.SetGroupTempValue(context, "uidListIndex", 0, {})
--重置游玩状态
ScriptLib.SetGroupTempValue(context, "TimeAxisPlaying", 0, {})
--清空时间轴
ScriptLib.EndTimeAxis(context, "WoodenStakeChallenge")
ScriptLib.EndTimeAxis(context, "RefreshDelay")
return 0
end
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,188 @@
--[[======================================
|| filename: IrodoriMaster
|| owner: luyao.huang
|| description: 2.6容彩祭-剑道大师挑战
|| LogName: IrodoriMaster
|| Protection:
=======================================]]--
------
--local defs = {
-- challenge_time = 240,
-- hard_challenge_time = 120,
-- father_challenge_id = 123,
-- normal_challenge_id = 1234,
-- hard_challenge_id = 1235,
-- gallery_id = 123456,
-- swordmaster_id = 120,
--}
local local_defs =
{
swordmaster_reminder_hp_ratio = 50
}
local Tri = {
[1] = { name = "select_difficulty", config_id = 8000001, event = EventType.EVENT_SELECT_DIFFICULTY, source = "", condition = "", action = "action_select_difficulty", trigger_count = 0},
[2] = { name = "irodori_master_ready", config_id = 8000002, event = EventType.EVENT_IRODORI_MASTER_READY, source = "", condition = "", action = "action_irodori_master_ready", trigger_count = 0},
[3] = { name = "challenge_success", config_id = 8000003, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
[4] = { name = "challenge_fail", config_id = 8000004, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
--[5] = { name = "leave_region", config_id = 8000005, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0},
[6] = { name = "group_will_unload", config_id = 8000006, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
[7] = { name = "specific_monster_hp_change_1", config_id = 80000007, event = EventType.EVENT_SPECIFIC_MONSTER_HP_CHANGE, source = tostring(swordmaster_id[1]), condition = "condition_specific_monster_hp_change", action = "action_specific_monster_hp_change_1", trigger_count = 1},
[8] = { name = "specific_monster_hp_change_2", config_id = 80000008, event = EventType.EVENT_SPECIFIC_MONSTER_HP_CHANGE, source = tostring(swordmaster_id[2]), condition = "condition_specific_monster_hp_change", action = "action_specific_monster_hp_change_2", trigger_count = 1},
[9] = { name = "specific_monster_hp_change_3", config_id = 80000009, event = EventType.EVENT_SPECIFIC_MONSTER_HP_CHANGE, source = tostring(swordmaster_id[3]), condition = "condition_specific_monster_hp_change", action = "action_specific_monster_hp_change_3", trigger_count = 1},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
------------------------------------------------------------------
--选择难度后加载剑道大师、空气墙并卸载剑道大师NPC
function action_select_difficulty(context,evt)
ScriptLib.PrintContextLog(context,"## [IrodoriMaster] action_select_difficulty 玩家选择挑战难度加载对应suite")
local difficulty = evt.param3
ScriptLib.SetGroupTempValue(context, "current_difficulty", difficulty, { group_id = base_info.group_id})
ScriptLib.PrintContextLog(context,"## [IrodoriMaster] action_select_difficulty 选择的难度为"..difficulty)
LF_Init_Play(context,difficulty)
return 0
end
--挑战开启前准备工作准备完毕,正式开启挑战
function action_irodori_master_ready(context,evt)
ScriptLib.PrintContextLog(context,"## [IrodoriMaster] action_cutscene_end: 前置工作完成,开启挑战")
local uidList = ScriptLib.GetSceneUidList(context)
local difficulty = ScriptLib.GetGroupTempValue(context, "current_difficulty", { group_id = base_info.group_id})
--播完cutscene之后创建剑道大师怪物
ScriptLib.CreateMonster(context, { config_id = swordmaster_id[difficulty], delay_time = 0 })
ScriptLib.CreateFatherChallenge(context, 1, defs.father_challenge_id, defs.challenge_time, {success = 5, fail = 10})
--先开再attach给子挑战保序
ScriptLib.StartFatherChallenge(context,1)
ScriptLib.AttachChildChallenge(context,1, 11, defs.normal_challenge_id,{defs.challenge_time,base_info.group_id,swordmaster_id[difficulty]},{uidList[1]},{success = 5,fail = 10}) --普通挑战
--只有中等难度有两个挑战目标
if (difficulty == 2) then
ScriptLib.AttachChildChallenge(context,1, 10, defs.hard_challenge_id,{defs.hard_challenge_time,base_info.group_id,swordmaster_id[difficulty]},{uidList[1]},{success = 0,fail = 0}) --优秀挑战
end
return 0
end
--处理挑战成功
function action_challenge_success(context,evt)
local success_challenge_id = evt.param1
if (success_challenge_id == defs.normal_challenge_id) then
ScriptLib.PrintContextLog(context,"## [IrodoriMaster] action_challenge_success 普通挑战成功")
LF_Clear_Stage(context)
--普通挑战成功、优秀挑战失败
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["is_finish"] = true, ["timeout"] = false})
end
if (success_challenge_id == defs.hard_challenge_id) then
ScriptLib.PrintContextLog(context,"## [IrodoriMaster] action_challenge_success 优秀挑战成功")
LF_Clear_Stage(context)
--普通挑战成功、优秀挑战成功
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["is_finish"] = true, ["timeout"] = false})
end
return 0
end
--处理挑战失败
function action_challenge_fail(context,evt)
local fail_challenge_id = evt.param1
if (fail_challenge_id == defs.father_challenge_id) then
ScriptLib.PrintContextLog(context,"## [IrodoriMaster] action_challenge_fail 父挑战失败")
LF_Clear_Stage(context)
--只需要处理父挑战失败:普通挑战失败,则父挑战失败;优秀挑战失败,则无事发生
if (evt.param2 <= 0) then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["is_finish"] = false, ["timeout"] = true})
else
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["is_finish"] = false, ["timeout"] = false})
end
end
return 0
end
--group意外卸载保护
function action_group_will_unload(context,evt)
ScriptLib.PrintContextLog(context,"## [IrodoriMaster] action_group_will_unloadgroup即将卸载回滚所有玩法状态")
LF_Reset_Play(context)
return 0
end
function condition_specific_monster_hp_change(context,evt)
if evt.param3 <= local_defs.swordmaster_reminder_hp_ratio then
return true
end
return false
end
--剑道大师低血量说话
function action_specific_monster_hp_change_1(context,evt)
ScriptLib.ShowReminder(context,defs.swordmaster_reminder_id)
return 0
end
--剑道大师低血量说话
function action_specific_monster_hp_change_2(context,evt)
ScriptLib.ShowReminder(context,defs.swordmaster_reminder_id)
return 0
end
--剑道大师低血量说话
function action_specific_monster_hp_change_3(context,evt)
ScriptLib.ShowReminder(context,defs.swordmaster_reminder_id)
return 0
end
------------------------------------------------------------------
function LF_Init_Play(context, difficulty)
ScriptLib.CreateGadget(context, { config_id = defs.airwall_id})
--隐藏剑道大师NPC
ScriptLib.RefreshGroup(context, { group_id = defs.NPC_group_id, suite = 2})
--屏蔽天气
ScriptLib.SetWeatherAreaState(context, defs.weather_id, 1)
end
function LF_Clear_Stage(context)
--恢复剑道大师NPC
ScriptLib.RefreshGroup(context, { group_id = defs.NPC_group_id, suite = 1})
ScriptLib.PrintContextLog(context,"## [IrodoriMaster] LF_Reset_Play开始重置玩法")
--移除空气墙
local ret1 = ScriptLib.RemoveEntityByConfigId(context,0,EntityType.GADGET, defs.airwall_id)
ScriptLib.PrintContextLog(context,"## [IrodoriMaster] LF_Reset_Play移除空气墙"..ret1)
--移除怪物
--local difficulty = ScriptLib.GetGroupTempValue(context,"current_difficulty",{})
--local ret2 = ScriptLib.RemoveEntityByConfigId(context,0,EntityType.MONSTER, swordmaster_id[difficulty])
--ScriptLib.PrintContextLog(context,"## [IrodoriMaster] LF_Reset_Play移除怪物"..ret2)
--开启天气
ScriptLib.SetWeatherAreaState(context, defs.weather_id, 0)
end
--重置玩法的方法
function LF_Reset_Play(context)
LF_Clear_Stage(context)
--强行以失败终止挑战
ScriptLib.StopChallenge(context,defs.normal_challenge_id,0)
ScriptLib.StopChallenge(context,defs.hard_challenge_id,0)
ScriptLib.StopChallenge(context,defs.father_challenge_id,0)
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,190 @@
--[[======================================
|| filename: PhotographActivity
|| owner: luyao.huang
|| description: 2.6拍照活动
|| LogName: PhotographActivity
|| Protection:
=======================================]]--
------
--local defs = {
-- worktop_id = 10001,
-- gallery_id = 18001,
-- region_id = 20001,
-- client_judge_id = 1
--}
local local_defs = {
worktop_option = 190,
region_out_reminder = 600106,
}
local Tri = {
[1] = { name = "group_load", config_id = 40000000, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[3] = { name = "select_option", config_id = 40000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[4] = { name = "photo_finish", config_id = 40000003, event = EventType.EVENT_PHOTO_FINISH, source = "", condition = "", action = "action_photo_finish", trigger_count = 0},
[5] = { name = "leave_region", config_id = 40000004, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0},
[6] = { name = "group_will_unload", config_id = 40000005, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
[7] = { name = "gallery_stop", config_id = 40000006, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", 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 = "has_succeeded", value = 0, no_refresh = true})
end
------------------------------------------------------------------
--group load后根据当前玩法状态恢复物件表现
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_group_loadgroup加载恢复玩法状态")
--group load时做一次校验如果之前成功后group未被正确反注册则在group_load时手动完成一次玩法
--if (not LF_Has_Succeeded(context)) then
LF_Init_Play(context)
--else
-- LF_Stop_Play(context,true)
--end
return 0
end
--玩家与选项交互,开启挑战
function action_select_option(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_select_option: 玩家与选项交互,开启玩法")
LF_Start_Play(context)
return 0
end
--挑战成功处理
--拍照成功以成功结束gallery并流转group状态
function action_photo_finish(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_photo_finish: 收到推送的拍照成功消息")
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_photo_finish: gallery id为"..evt.param1)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_photo_finish: 客户端逻辑id为"..evt.param2)
--对客户端推送的拍照成功消息做一次校验
if (evt.param1 == defs.gallery_id and evt.param2 == defs.client_judge_id) then
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_photo_finish: 拍照成功")
LF_Stop_Play(context,true)
end
return 0
end
--挑战失败处理
--失败情况1玩家出圈
function action_leave_region(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_leave_region: 玩家出圈")
--校验当前玩法状态只有未完成状态的group才能回滚到初始状态
--if (evt.param1 == defs.region_id and not LF_Has_Succeeded(context) and ScriptLib.IsGalleryStart(context,defs.gallery_id)) then
if (evt.param1 == defs.region_id and ScriptLib.IsGalleryStart(context,defs.gallery_id)) then
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_leave_region: 挑战失败并回滚group状态")
ScriptLib.ShowReminder(context, local_defs.region_out_reminder)
LF_Stop_Play(context,false)
end
return 0
end
--失败情况2group即将卸载
function action_group_will_unload(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_group_will_unload: group即将卸载")
--校验当前玩法状态只有未完成状态的group才能回滚到初始状态
--if (not LF_Has_Succeeded(context) and ScriptLib.IsGalleryStart(context,defs.gallery_id)) then
if (ScriptLib.IsGalleryStart(context,defs.gallery_id)) then
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_group_will_unload: 回退至初始状态作为保护")
LF_Stop_Play(context,false)
end
return 0
end
--失败情况3灭队
function action_gallery_stop(context,evt)
if (evt.param3 == 0) then
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_gallery_stop: 灭队")
LF_Stop_Play(context,false)
end
return 0
end
------------------------------------------------------------------
------------------------流程相关----------------------------------
--初始化玩法
--加载操作台并上选项
function LF_Init_Play(context)
--操作台激活
LF_Set_Worktop(context,true)
--卸载打点suite
LF_Set_Photo_Point_Suite(context,false)
end
--开启玩法
function LF_Start_Play(context)
--先尝试启动gallery如果未成功则直接返回
if (ScriptLib.SetPlayerStartGallery(context, defs.gallery_id, {ScriptLib.GetSceneOwnerUid(context)}) ~= 0) then
return
end
--操作台转为未激活
LF_Set_Worktop(context,false)
--加载打点suite
LF_Set_Photo_Point_Suite(context,true)
--显示黄圈
ScriptLib.ActivateGroupLinkBundle(context, base_info.group_id)
end
function LF_Stop_Play(context, is_success)
--卸载打点suite
--LF_Set_Photo_Point_Suite(context,false)
--关闭黄圈
ScriptLib.DeactivateGroupLinkBundle(context, base_info.group_id)
if (is_success) then
--关闭操作台
--LF_Set_Worktop(context,false)
ScriptLib.StopGallery(context,defs.gallery_id,false)
--ScriptLib.SetGroupVariableValue(context,"has_succeeded",1)
--ScriptLib.FinishGroupLinkBundle(context, base_info.group_id)
else
--lua里处理的都是出界StopGallery所以Reason直接都给5
ScriptLib.StopGalleryByReason(context,defs.gallery_id,5)
end
--重新做一次初始化的流程
LF_Init_Play(context)
end
------------------------group元素操作相关----------------------------------
--设置操作台状态包括设置gadgetState和上下选项
function LF_Set_Worktop(context, is_active)
if (is_active) then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.worktop_id, 0)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.worktop_id, {local_defs.worktop_option})
else
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.worktop_id, 201)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.worktop_id, local_defs.worktop_option)
end
end
--加载/卸载打点用suite
function LF_Set_Photo_Point_Suite(context,is_active)
if (is_active) then
if #suites>=2 then
--如果有配置打点用物件,将其加载出来
ScriptLib.AddExtraGroupSuite(context,base_info.group_id,2)
end
else
if #suites>=2 then
--如果有配置打点用物件,清理加载出来的打点用物件
ScriptLib.RemoveExtraGroupSuite(context,base_info.group_id,2)
end
end
end
--返回当前group的玩法是否已经成功了
--如果已经成功group load时不能再重新开启玩法
function LF_Has_Succeeded(context)
return ScriptLib.GetGroupVariableValue(context,"has_succeeded") == 1
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,521 @@
--[[======================================
|| filename: TowerDefence_Challenge_V3.0
|| owner: chao.cui
|| description: 主控逻辑
|| LogName: TD_V3
|| Protection: ???
=======================================]]
--[[
-- Trigger变量
local defs = {
group_id = 245002001,
gear_group_id = 245002002,
route_guide_timer = 5,
max_escapable_monsters = 20,
trapGroups = {245002013},
init_building_points = 800,
-- 当前关卡
level = 0,
-- 判断怪物掉落死亡的Y值
dieY = -8,
}
-- DEFS_MISCS
--怪物group的ID
monster_group=245002003
local guide_routes={1}
routes_start_point={
[1]={start_point={x=34.46477,y=-7.699215,z=-92.27316},points={1,2,3,4,5,6,7,8,9,10}},
[2]={start_point={x=3.397061,y=-7.678518,z=-58.50145},points={1,2,3,4,5,6,7,8,9,10}},
}
guide_point_pool={1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040}
]]--
local Global =
{
totalWaves = 1,
}
-- 打印日志
function PrintLog(context, content)
local log = "## [TowerDefence_Challenge_V3.0] TD_V3: "..content
ScriptLib.PrintContextLog(context, log)
end
-- 初始化Group的各种变量
function LF_Init_Challenge_Group()
local innerTriggers =
{
t3 = { config_id = 40000003, name = "challenge_success", event = EventType.EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END, source = "", condition = "", action = "action_STAGE_END", trigger_count = 0},
t4 = { config_id = 40000004, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
t5 = { config_id = 40000005, name = "timer_event", event = EventType.EVENT_TIMER_EVENT, source = "route_points_delay", condition = "", action = "action_add_route_points", trigger_count = 0},
t6 = { config_id = 40000006, name = "point_arrive", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_REACH_POINT", trigger_count = 0 },
t7 = { config_id = 40000007, name = "end_stage_request", event = EventType.EVENT_SCENE_MULTISTAGE_PLAY_END_STAGE_REQ, source = "", condition = "", action = "action_END_STAGE_REQ", trigger_count = 0 },
-- t8 = { config_id = 8000008, name = "pick_card_event", event = EventType.EVENT_MECHANICUS_PICKED_CARD, source = "", condition = "", action = "action_PICK_CARD", trigger_count = 0 }
--t9 = { config_id = 40000009,name = "TIMER_EVENT_DELAY", event = EventType.EVENT_TIMER_EVENT, source = "delay", condition = "", action = "action_NEXT_BUILD_STAGE", trigger_count = 0 },
t10 = { config_id = 40000010,name = "TIMER_EVENT_START_REMINDER", event = EventType.EVENT_TIMER_EVENT, source = "reminder", condition = "", action = "action_START_REMINDER", trigger_count = 0 },
t11 = { config_id = 40000011,name = "ALL_AVATAR_DIE", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_ALL_AVATAR_DIE", trigger_count = 0 },
}
for i, v in ipairs(suites) do
for _, _trigger in pairs(innerTriggers) do
table.insert(v.triggers, _trigger.name)
end
end
for _, _trigger in pairs(innerTriggers) do
table.insert(triggers, _trigger)
end
-- inner variables
-- table.insert(variables, { name = "towerNum", value = 0})
-- table.insert(variables, { name = "cardEffect", value = 1})
-- table.insert(variables, { name = "newGadget", value = 0})
table.insert(variables, { config_id=50000001,name = "wave_ptr", value = 0})
--table.insert(variables, { name = "max_escapable_monsters", value = 10})
--table.insert(variables, { name = "escaped_monsters", value = 0})
table.insert(variables, { config_id=50000002,name = "left_monsters", value = 0})
table.insert(variables, { config_id=50000003,name = "route_guide_points_index", value = 1, no_refresh = true})
-- 掉落击杀的怪物获得资源点提升
table.insert(variables, { config_id=50000004,name = "CardPicked_DieReasonIsFall", value = 0})
-- 机关冷却时间减半
table.insert(variables, { config_id=50000005,name = "CardPicked_GearCoolDown", value = 0})
-- 地脉异常4是否激活
table.insert(variables, { config_id=50000006,name = "M4_Active", value = 0})
--
--table.insert(variables, { name = "DieY", value = 0})
-- GM
table.insert(variables, { config_id=50000007,name = "GM_LevelNum", value = 0})
end
-- 游戏结束条件-所有玩家角色死亡
function action_ALL_AVATAR_DIE(context, evt)
local uidList = ScriptLib.GetSceneUidList(context)
local count = 0
for i = 1, #uidList do
if ScriptLib.IsPlayerAllAvatarDie(context, uidList[i]) then
count = count + 1
end
end
if count >= #uidList then
ScriptLib.EndSceneMultiStagePlay(context, 999, false)
return 0
end
return 0
end
-- 请求结束Stage提前结束建造
function action_END_STAGE_REQ(context, evt)
if evt.param2 == Multistage.IrodoriChessBuild then
ScriptLib.EndSceneMultiStagePlayStage(context, 999, "build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"), true)
end
return 0
end
-- stage结束
function action_STAGE_END(context, evt)
if evt.param2 == Multistage.IrodoriChessBuild then
LF_StopRouteGuidePoints(context)
local wave = ScriptLib.GetGroupVariableValue(context, "wave_ptr")
ScriptLib.ExecuteGroupLua(context, monster_group, "LF_StartWave", {defs.group_id, wave})
ScriptLib.StartSceneMultiStagePlayStage(context, 999, 0, Multistage.IrodoriChessKill, "battle"..wave,{})
PrintLog(context, "战斗阶段开始: "..wave)
end
return 0
end
function action_group_load(context, evt)
PrintLog(context, "Challenge Group Load Begin.")
--ScriptLib.SetGroupVariableValue(context, "DieY", defs.dieY)
-- 初始化允许逃逸的怪物数量
-- ScriptLib.SetGroupVariableValue(context, "max_escapable_monsters", defs.max_escapable_monsters or 999)
-- 初始化波数
ScriptLib.SetGroupVariableValue(context, "wave_ptr", 1)
--local ban_list={}
-- 初始建造点
-- local initBuildingPoints = defs.init_building_points or 1000
if 0 ~= ScriptLib.InitSceneMultistagePlay(context, 999, MultistagePlayType.IrodoriChess, {}, ScriptLib.GetSceneUidList(context)) then
PrintLog(context, "MultiStage初始化失败")
else
PrintLog(context, "成功设置MultiStage")
end
-- 统计怪物总数量
ScriptLib.ExecuteGroupLua(context, monster_group, "set_monster_number_req", {defs.group_id})
PrintLog(context, "成功设置剩余怪物")
-- 通知服务器leftMonsters
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "left_monsters", ScriptLib.GetGroupVariableValue(context, "left_monsters"), true)
PrintLog(context, "成功设置显示参数 left_monsters="..ScriptLib.GetGroupVariableValue(context, "left_monsters"))
-- 生成路径引导特效
LF_AddRouteGuidePoints(context)
-- 处理局外选取的卡牌
LF_GetPickedCards(context)
-- x秒后弹出开局文字提示
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "reminder", 5)
-- 开始第一阶段BUILD准备时间为10分钟
ScriptLib.StartSceneMultiStagePlayStage(context, 999, 600, Multistage.IrodoriChessBuild,"build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
PrintLog(context, "开始第一阶段挑战")
PrintLog(context, "Challenge Group Load End.")
return 0
end
-- 开局的文字提示
function action_START_REMINDER(context, evt)
--"利用机关击败敌人"
ScriptLib.ShowReminder(context, 400025)
return 0
end
-- 进入新一WAVE的建造阶段塔防三期只有一个WAVE。所以该事件不会触发
-- function action_NEXT_BUILD_STAGE(context, evt)
-- LF_AddRouteGuidePoints(context)
-- ScriptLib.ExecuteGroupLua(context, monster_group, "set_monster_number_req", {ScriptLib.GetGroupVariableValue(context, "wave_ptr")})
-- ScriptLib.SetSceneMultiStagePlayValue(context, 999, "left_monsters", ScriptLib.GetGroupVariableValue(context, "left_monsters"), true)
-- ScriptLib.StartSceneMultiStagePlayStage(context, 999, 600, Multistage.IrodoriChessBuild,"build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
-- return 0
-- end
-- 生成新的路径引导特效TIMER事件
function action_add_route_points(context, evt)
LF_AddRouteGuidePoints(context)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "route_points_delay", defs.route_guide_timer)
return 0
end
-- 生成路径引导特效。
function LF_AddRouteGuidePoints(context)
if guide_routes == nil then
PrintLog(context, "GuideRoute is Nil.")
return 0
end
-- routes_start_point Table 看上去是标记路径信息
-- guide_point_pool Table 存储了Group中引导特效点的ConfigId
for i = 1, #guide_routes do
local idx = ScriptLib.GetGroupVariableValue(context, "route_guide_points_index")
if -2 == ScriptLib.CreateGadgetByConfigIdByPos(context, guide_point_pool[idx], routes_start_point[guide_routes[i]].start_point, { x = 0.000, y = 0.000, z = 0.000 }) then
PrintLog(context, "Guide Points Not Enough")
return 0
end
if 0 ~= ScriptLib.SetPlatformPointArray(context, guide_point_pool[idx], guide_routes[i], routes_start_point[guide_routes[i]].points, { route_type = 0 }) then
PrintLog(context, "设置点阵失败")
end
if idx >= #guide_point_pool then
idx = 1
else
idx = idx + 1
end
ScriptLib.SetGroupVariableValue(context, "route_guide_points_index", idx)
end
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "route_points_delay", defs.route_guide_timer)
return 0
end
-- 删除路径引导特效
function LF_StopRouteGuidePoints(context)
ScriptLib.CancelGroupTimerEvent(context, defs.group_id, "route_points_delay")
ScriptLib.KillGroupEntity(context,{group_id = defs.group_id, gadgets = guide_point_pool})
return 0
end
-- 移动平台到达路点触发的Action引导特效相关的
function action_REACH_POINT(context, evt)
--ScriptLib.KillEntityByConfigId(context, { config_id = evt.param1 })
-- 进入GearStart状态。5s后会KillSelf
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, evt.param1, GadgetState.GearStart)
return 0
end
-- 更新剩余怪物总数由TowerDefense_Monster_V3.0调用)
function UpdateLeftMonsterNum(context, prev_context, param1, param2, param3)
local leftMonsters = ScriptLib.GetGroupVariableValue(context, "left_monsters")
if leftMonsters == 0 then
return 0
end
leftMonsters = leftMonsters - 1
ScriptLib.SetGroupVariableValue(context, "left_monsters", leftMonsters)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "left_monsters", leftMonsters, true)
return 0
end
-- 初始化怪物总数由TowerDefense_Monster_V3.0调用)
function LF_InitLeftMonsterNum(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "left_monsters", param1)
return 0
end
-- wave结束由TowerDefense_Monster_V3.0调用)
function wave_done(context, prev_context, param1, param2, param3)
ScriptLib.EndSceneMultiStagePlayStage(context, 999, "battle"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"), true)
local wave = ScriptLib.GetGroupVariableValue(context, "wave_ptr")
wave = wave + 1
ScriptLib.SetGroupVariableValue(context, "wave_ptr", wave)
PrintLog(context, "nextWave-"..wave)
-- 游戏结束退出条件
if wave > Global.totalWaves then
ScriptLib.EndSceneMultiStagePlay(context, 999, true)
PrintLog(context, "所有波次结束")
return 0
end
-- 塔防三期只有1个WAVE。
-- ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "delay", 3)
return 0
end
-- 怪物逃跑由TowerDefense_Monster_V3.0调用)
-- function MonsterEscaped(context, prev_context, param1, param2, param3)
-- local max_escapable_monsters = ScriptLib.GetGroupVariableValue(context, "max_escapable_monsters")
-- local escaped_monsters = ScriptLib.GetGroupVariableValue(context, "escaped_monsters")
-- -- 特殊怪物
-- if param1 == 1 then
-- escaped_monsters = escaped_monsters+1
-- if escaped_monsters >= max_escapable_monsters then
-- ScriptLib.EndSceneMultiStagePlay(context, 999, false)
-- return 0
-- end
-- ScriptLib.SetGroupVariableValue(context, "escaped_monsters", escaped_monsters)
-- return 0
-- end
-- escaped_monsters = escaped_monsters + 1
-- -- 游戏失败
-- if escaped_monsters >= max_escapable_monsters then
-- ScriptLib.EndSceneMultiStagePlay(context, 999, false)
-- return 0
-- end
-- ScriptLib.SetGroupVariableValue(context, "escaped_monsters", escaped_monsters)
-- return 0
-- end
-- 处理局外选取的卡牌
function LF_GetPickedCards(context)
PrintLog(context, "设置局外选取的卡牌")
local cards = ScriptLib.GetIrodoriChessSelectedCards(context, defs.group_id, 999)
-- 掉落击杀的怪物额外获得资源卡牌编号
local Card_DieReasonIsFall = 52
-- 机关冷却时间减半卡牌编号
local Card_GearCoolDown = 53
for _, _card in pairs(cards) do
if _card == Card_DieReasonIsFall then
ScriptLib.SetGroupVariableValueByGroup(context, "CardPicked_DieReasonIsFall", 1, 0)
end
if _card == Card_GearCoolDown then
ScriptLib.SetGroupVariableValueByGroup(context, "CardPicked_GearCoolDown", 1, 0)
end
end
return 0
end
-- 增加建造点
function LF_AddBuildingPoints(context, prev_context, _buildingPoint)
local uidList = ScriptLib.GetSceneUidList(context)
for i = 1, #uidList do
ScriptLib.AddIrodoriChessBuildingPoints(context, defs.group_id, 999, _buildingPoint)
end
return 0
end
-- 关卡1的地脉异常掉落击杀可获得资源点
function LF_SpecialGameplayLevel1(context, prev_context, _isElite)
local currentLevel = defs.level or 0
-- GM
local gmLevel = ScriptLib.GetGroupVariableValue(context, "GM_LevelNum")
if gmLevel > 0 then currentLevel = gmLevel end
--region 简单1/困难1
if currentLevel ~= 1 and currentLevel ~= 5 then
return 0
end
local buildingPoint = 0
if currentLevel == 1 then
buildingPoint = 10
if _isElite > 0 then
buildingPoint = 50
end
end
if currentLevel == 5 then
buildingPoint = 15
if _isElite > 0 then
buildingPoint = 60
end
end
--endregion
-- 掉落击杀资源点翻倍卡
local cardPicked = ScriptLib.GetGroupVariableValueByGroup(context, "CardPicked_DieReasonIsFall", 0)
if cardPicked > 0 then
buildingPoint = buildingPoint * 2
end
LF_AddBuildingPoints(context, prev_context, buildingPoint)
PrintLog(context, "地脉异常LV1增加"..buildingPoint.."点建造值")
return 0
end
-- 关卡3的地脉异常塔数<N时击杀加建造值
function LF_SpecialGameplayLevel3(context, prev_context, _isElite)
local currentLevel = defs.level or 0
-- GM
local gmLevel = ScriptLib.GetGroupVariableValue(context, "GM_LevelNum")
if gmLevel > 0 then currentLevel = gmLevel end
if currentLevel ~= 3 and currentLevel ~= 7 then
return 0
end
-- 获取塔的总数
local towers = ScriptLib.GetGroupVariableValueByGroup(context, "towers", defs.gear_group_id)
local buildingPoint = 10
if _isElite > 0 then
buildingPoint = 50
end
local N = 10
if towers < N then
LF_AddBuildingPoints(context, prev_context, buildingPoint)
PrintLog(context, "地脉异常LV3增加"..buildingPoint.."点建造值")
end
return 0
end
-- 关卡4的地脉异常塔数<N时塔的伤害提升
function LF_SpecialGameplayLevel4(context, prev_context, param1)
PrintLog(context, "地脉异常4检查开始")
local currentLevel = defs.level or 0
-- GM
local gmLevel = ScriptLib.GetGroupVariableValue(context, "GM_LevelNum")
if gmLevel > 0 then currentLevel = gmLevel end
--
if currentLevel ~= 4 and currentLevel ~=8 then
return 0
end
-- 获取塔的总数
local towers = ScriptLib.GetGroupVariableValueByGroup(context, "towers", defs.gear_group_id)
-- 地脉异常4是否开启
local M4 = ScriptLib.GetGroupVariableValueByGroup(context, "M4_Active", 0)
-- 临界值条件
local N = 10
-- 关卡4简单
if currentLevel == 4 then
-- 满足开启条件
if towers < N and M4 == 0 then
PrintLog(context, "!开启L4地脉异常")
local sgvDeltaTbl =
{
SGV_AttackRatioUp = 1,
}
ScriptLib.AddIrodoriChessTowerServerGlobalValue(context, defs.group_id, 999, 0, sgvDeltaTbl)
ScriptLib.SetGroupVariableValueByGroup(context, "M4_Active", 1, defs.group_id)
end
-- 满足关闭条件
if towers >= N and M4 == 1 then
PrintLog(context, "关闭L4地脉异常")
local sgvDeltaTbl =
{
SGV_AttackRatioUp = -1,
}
ScriptLib.AddIrodoriChessTowerServerGlobalValue(context, defs.group_id, 999, 0, sgvDeltaTbl)
ScriptLib.SetGroupVariableValueByGroup(context, "M4_Active", 0, defs.group_id)
end
end
-- 关卡4困难
if currentLevel == 8 then
-- 满足开启条件
if towers < N and M4 == 0 then
PrintLog(context, "!开启L4地脉异常")
local sgvDeltaTbl =
{
SGV_AttackRatioUp = 2,
}
ScriptLib.AddIrodoriChessTowerServerGlobalValue(context, defs.group_id, 999, 0, sgvDeltaTbl)
ScriptLib.SetGroupVariableValueByGroup(context, "M4_Active", 1, defs.group_id)
end
-- 满足关闭条件
if towers >= N and M4 == 1 then
PrintLog(context, "关闭L4地脉异常")
local sgvDeltaTbl =
{
SGV_AttackRatioUp = -2,
}
ScriptLib.AddIrodoriChessTowerServerGlobalValue(context, defs.group_id, 999, 0, sgvDeltaTbl)
ScriptLib.SetGroupVariableValueByGroup(context, "M4_Active", 0, defs.group_id)
end
end
return 0
end
LF_Init_Challenge_Group()

View File

@@ -0,0 +1,250 @@
--[[======================================
|| filename: TowerDefence_Gear_V3.0
|| owner: chao.cui
|| description: 机关逻辑
|| LogName: TD_V3
|| Protection: ???
=======================================]]
--[[
-- Trigger变量
local defs = {
group_id = 245002002,
fundation_id = 70350145,
challange_group_id = 245002001,
-- gear_config_id = -1,
}
-- DEFS_MISCS
-- 预设塔配置表(底座和塔的对应关系)
local towerPrebuild =
{
foundationConfigId = towerGearId, --需要查询Excel
}
--]]
local Global =
{
-- 塔的标记槽位数。同时存在的塔不会超过这个数字
slotNum = 20,
-- 所有类型塔信息表
allTowerType =
{
-- 二期机关
[70350281] = {price = 500}, --水塔
[70350282] = {price = 500}, --火塔
[70350283] = {price = 500}, --冰塔
[70350284] = {price = 500}, --风塔
[70350285] = {price = 500}, --雷塔
[70350286] = {price = 500}, --物理塔
[70350298] = {price = 100}, --诡雷
[70350294] = {price = 250}, --回收机关
[70350303] = {price = 250}, --塔增幅器
[70350299] = {price = 100}, --禁锢机关
[70350305] = {price = 250}, --斥力机关
-- 三期机关
[70350397] = {}, --V3 物理塔
[70350412] = {}, --V3 地雷
[70350413] = {}, --V3 水塔
[70350414] = {}, --V3 火塔
[70350415] = {}, --V3 冰塔
[70350416] = {}, --V3 风塔
[70350417] = {}, --V3 雷塔
[70350418] = {}, --V3 禁锢机关
[70350419] = {}, --V3 斥力机关
[70350428] = {}, --V3 塔增幅器
},
}
-- 打印日志
function PrintLog(context, content)
local log = "## [TowerDefence_Gear_V3.0] TD_V3: "..content
ScriptLib.PrintContextLog(context, log)
end
-- 判断创生物件是否是塔
function condition_TOWER_CREATE(context, evt)
local towerGadgetId = evt.param2
if Global.allTowerType[towerGadgetId] ~= nil then
PrintLog(context, "TowerGadgetId "..evt.param2.." Created.")
return true
end
return false
end
-- 造塔事件
function action_TOWER_CREATE(context, evt)
local towerGadgetId = evt.param2
LF_AddTowerNum(context, towerGadgetId, 1)
-- 存储该塔
for i = 1, Global.slotNum do
if ScriptLib.GetGroupVariableValue(context, "Slot"..i) == 0 then
ScriptLib.SetGroupVariableValue(context, "Slot"..i, evt.param1)
break
end
end
return 0
end
-- 判断是否拆的是塔
function condition_TOWER_DESTROY(context, evt)
local configId = evt.param1
-- 清除该塔的记录
for i = 1, Global.slotNum do
if ScriptLib.GetGroupVariableValue(context, "Slot"..i) == configId then
ScriptLib.SetGroupVariableValue(context, "Slot"..i, 0)
return true
end
end
return false
end
-- 拆塔事件
function action_TOWER_DESTROY(context, evt)
LF_AddTowerNum(context, 0, -1)
return 0
end
function action_EVENT_GROUP_LOAD(context, evt)
PrintLog(context, "Gear Group Load Begin 1544")
LF_Initialize_Fundations(context)
LF_Initialize_Towers(context)
return 0
end
--
function action_CheckSpecialGameplayLevel4(context, evt)
PrintLog(context, "延时检查")
-- 地脉异常L4检查
ScriptLib.ExecuteGroupLua(context, defs.challange_group_id, "LF_SpecialGameplayLevel4", {0})
return 0
end
-- 增加X塔X个
-- @param1 towerGadgetId 塔的GadgetId (这个参数没用了)
-- @param2 num 塔数变化值
function LF_AddTowerNum(context, towerGadgetId, num)
-- 总塔计数
local towers = ScriptLib.GetGroupVariableValueByGroup(context, "towers", 0)
towers = towers + num
ScriptLib.SetGroupVariableValueByGroup(context, "towers", towers, 0)
PrintLog(context, "塔总数为: "..towers)
-- 延时检查地脉异常
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "delay", 1)
-- 地脉异常L4检查
--ScriptLib.ExecuteGroupLua(context, defs.challange_group_id, "LF_SpecialGameplayLevel4", {0})
end
-- 初始化底座
function LF_Initialize_Fundations(context, prev_context, param1, param2, param3)
-- config_id_2_point_table = {config_id: point_id}
local fundationTable = {}
-- local uidList = ScriptLib.GetSceneUidList(context)
for i = 1, math.min(#gadgets, #points) do
if gadgets[i].gadget_id == defs.fundation_id then
fundationTable[gadgets[i].config_id] = points[i].config_id
end
end
ScriptLib.CreateFoundations(context, fundationTable, defs.challange_group_id, 999)
return 0
end
-- 初始化预设塔
function LF_Initialize_Towers(context, prev_context, param1, param2, param3)
PrintLog(context, "Init Towers!")
if towerPrebuild == nil then
PrintLog(context, "towerPrebuild为nil")
else
--PrintLog(context, "towerPrebuild表长度"..#towerPrebuild)
end
local prebuildTable = towerPrebuild or {}
PrintLog(context, "预设塔列表长度"..#prebuildTable)
if 0 ~= ScriptLib.ForceSetIrodoriFoundationTowers(context, prebuildTable, defs.challange_group_id, 999) then
PrintLog(context, "设置预设塔失败!")
else
PrintLog(context, "设置预设塔成功!")
end
return 0
end
-- SLC 地雷塔爆炸返还点数
function SLC_AddBuildingPointsWhenMineExploded(context)
PrintLog(context, "进入爆炸SLC判断")
ScriptLib.ExecuteGroupLua(context, defs.challange_group_id, "LF_AddBuildingPoints", {20})
return 0
end
-- 怪物毁灭光环
function SLC_DestroyTower(context)
local entityId = context.source_entity_id
PrintLog(context, "destory entityId: "..entityId)
ScriptLib.DestroyIrodoriChessTower(context, entityId, defs.challange_group_id, 999)
return 0
end
-- 初始化Group
function LF_Initialize_Group(triggers, suites)
local extraTriggers =
{
{ config_id = 40000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0},
{ config_id = 40000012, name = "TOWER_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "condition_TOWER_CREATE", action = "action_TOWER_CREATE", trigger_count = 0 },
{ config_id = 40000013, name = "TOWER_DESTROY", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "condition_TOWER_DESTROY", action = "action_TOWER_DESTROY", trigger_count = 0 },
{ config_id = 40000014, name = "TIMER_DELAY", event = EventType.EVENT_TIMER_EVENT, source = "delay", condition = "", action = "action_CheckSpecialGameplayLevel4", trigger_count = 0 },
}
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers, extraTriggers[i].name)
end
-- 塔的总数
table.insert(variables, {config_id=50000001,name = "towers", value = 0})
-- 标记塔槽位
for i = 1, Global.slotNum do
table.insert(variables, {config_id=51000000+i,name = "Slot"..i, value = 0})
end
end
-------------------------------------
LF_Initialize_Group(triggers, suites)

View File

@@ -0,0 +1,102 @@
--[[======================================
|| filename: TowerDefence_MonsterWaveConfig_V3.0
|| owner: chao.cui
|| description: 怪物潮配置
|| LogName: TD_V3
|| Protection: ???
=======================================]]
------------------------
------- V3 测试 --------
------------------------
-- local tides_level_01_sample =
-- {
-- [1] = {{monster_package={16001}, count = 3, max = 2, min = 1, route={1}}},
-- [2] = {{monster_package={16017}, count = 4, max = 2, min = 2, route={1}}},
-- }
local tides_level_01_sample =
{
[1]= {{monster_package ={32008},count=2,max=1,min=1,route={1}},{monster_package={32001},count=6,max=3,min=3,route={2}},{monster_package={32001},count=6,max=3,min=3,route={3}}},
[2]= {{monster_package ={32008},count=3,max=3,min=1,route={1}},{monster_package={32002},count=6,max=3,min=1,route={2}},{monster_package={32002},count=6,max=3,min=1,route={3}}},
[3]= {{monster_package ={32008},count=6,max=3,min=1,route={1}},{monster_package={32003},count=6,max=6,min=6,route={2}},{monster_package={32003},count=6,max=6,min=6,route={3}}},
[4]= {{monster_package ={32009},count=2,max=1,min=1,route={1}},{monster_package={32004},count=8,max=4,min=1,route={2}},{monster_package={32004},count=8,max=4,min=1,route={3}}},
[5]= {{monster_package ={32009},count=4,max=2,min=2,route={1}},{monster_package={32005},count=6,max=3,min=1,route={2}},{monster_package={32005},count=6,max=3,min=1,route={3}}},
[6]= {{monster_package ={32010},count=2,max=1,min=1,route={1}},{monster_package={32006},count=6,max=3,min=3,route={2}},{monster_package={32006},count=6,max=3,min=3,route={3}}},
}
local tides_level_02_sample =
{
[1]= {{monster_package ={32021},count=8,max=4,min=1,route={1}},{monster_package={32021},count=8,max=4,min=1,route={2}}},
[2]= {{monster_package ={32022},count=8,max=3,min=1,route={1}},{monster_package={32022},count=8,max=3,min=1,route={2}}},
[3]= {{monster_package ={32023},count=8,max=4,min=1,route={1}},{monster_package={32024},count=8,max=4,min=1,route={2}}},
[4]= {{monster_package ={32025},count=2,max=1,min=1,route={1}},{monster_package={32025},count=2,max=1,min=1,route={2}}},
[5]= {{monster_package ={32026},count=1,max=1,min=1,route={1}},{monster_package={32027},count=1,max=1,min=1,route={2}}},
[6]= {{monster_package ={32028},count=1,max=1,min=1,route={1}},{monster_package={32027},count=1,max=1,min=1,route={2}}},
}
local tides_level_03_sample =
{
[1]= {{monster_package ={32041},count=6,max=6,min=6,route={1}}},
[2]= {{monster_package ={32042},count=12,max=6,min=4,route={1}},{monster_package={32046},count=4,max=2,min=2,route={2}}},
[3]= {{monster_package ={32044},count=12,max=6,min=6,route={1}}},
[4]= {{monster_package ={32043},count=8,max=3,min=3,route={1}},{monster_package={32046},count=3,max=2,min=2,route={2}}},
[5]= {{monster_package={32044},count=10,max=4,min=3,route={1}},{monster_package={32047},count=1,max=1,min=1,route={2}}},
}
local tides_level_04_sample =
{
[1]= {{monster_package ={32061},count=8,max=4,min=4,route={1}}},
[2]= {{monster_package ={32062},count=6,max=3,min=3,route={1}},{monster_package={32064},count=3,max=2,min=2,route={2}}},
[3]= {{monster_package ={32062},count=6,max=3,min=3,route={1}},{monster_package={32067},count=4,max=2,min=2,route={2}},{monster_package ={32065},count=6,max=3,min=3,route={3}}},
[4]= {{monster_package ={32066},count=6,max=3,min=3,route={2}},{monster_package={32065},count=6,max=4,min=3,route={3}}},
[5]= {{monster_package={32066},count=4,max=2,min=2,route={1}},{monster_package={32064},count=1,max=1,min=1,route={2}},{monster_package ={32065},count=6,max=3,min=3,route={3}}},
}
local tides_level_01_hard =
{
[1]= {{monster_package ={32088},count=2,max=1,min=1,route={1}},{monster_package={32081},count=6,max=3,min=3,route={2}},{monster_package={32081},count=6,max=3,min=3,route={3}}},
[2]= {{monster_package ={32088},count=3,max=3,min=1,route={1}},{monster_package={32082},count=6,max=3,min=1,route={2}},{monster_package={32082},count=6,max=3,min=1,route={3}}},
[3]= {{monster_package ={32088},count=6,max=3,min=1,route={1}},{monster_package={32083},count=6,max=6,min=6,route={2}},{monster_package={32083},count=6,max=6,min=6,route={3}}},
[4]= {{monster_package ={32089},count=2,max=1,min=1,route={1}},{monster_package={32084},count=8,max=4,min=1,route={2}},{monster_package={32084},count=8,max=4,min=1,route={3}}},
[5]= {{monster_package ={32089},count=4,max=1,min=1,route={1}},{monster_package={32085},count=6,max=3,min=1,route={2}},{monster_package={32085},count=6,max=3,min=1,route={3}}},
[6]= {{monster_package ={32090},count=2,max=1,min=1,route={1}},{monster_package={32086},count=6,max=3,min=3,route={2}},{monster_package={32086},count=6,max=3,min=3,route={3}}},
}
local tides_level_02_hard =
{
[1]= {{monster_package ={32101},count=8,max=4,min=1,route={1}},{monster_package={32101},count=8,max=4,min=1,route={2}}},
[2]= {{monster_package ={32102},count=8,max=3,min=1,route={1}},{monster_package={32102},count=8,max=3,min=1,route={2}}},
[3]= {{monster_package ={32103},count=8,max=4,min=1,route={1}},{monster_package={32104},count=8,max=4,min=1,route={2}}},
[4]= {{monster_package ={32105},count=2,max=1,min=1,route={1}},{monster_package={32105},count=2,max=1,min=1,route={2}}},
[5]= {{monster_package ={32106},count=1,max=1,min=1,route={1}},{monster_package={32107},count=1,max=1,min=1,route={2}}},
[6]= {{monster_package ={32108},count=1,max=1,min=1,route={1}},{monster_package={32107},count=1,max=1,min=1,route={2}}},
}
local tides_level_03_hard =
{
[1]= {{monster_package ={32121},count=6,max=6,min=6,route={1}}},
[2]= {{monster_package ={32122},count=9,max=3,min=3,route={1}},{monster_package={32130},count=5,max=3,min=2,route={2}}},
[3]= {{monster_package ={32124},count=9,max=3,min=3,route={1}},{monster_package={32127},count=1,max=1,min=1,route={2}}},
[4]= {{monster_package ={32123},count=6,max=3,min=3,route={1}},{monster_package={32128},count=3,max=2,min=2,route={2}}},
[5]= {{monster_package={32131},count=3,max=1,min=1,route={1}},{monster_package={32127},count=1,max=1,min=1,route={2}}},
}
local tides_level_04_hard =
{
[1]= {{monster_package ={32141},count=16,max=8,min=8,route={1}}},
[2]= {{monster_package ={32142},count=9,max=3,min=3,route={1}},{monster_package={32144},count=6,max=3,min=3,route={2}}},
[3]= {{monster_package ={32142},count=6,max=3,min=3,route={1}},{monster_package={32147},count=6,max=3,min=3,route={2}},{monster_package ={32145},count=6,max=6,min=6,route={3}}},
[4]= {{monster_package ={32148},count=6,max=6,min=6,route={1}},{monster_package ={32150},count=1,max=1,min=1,route={2}},{monster_package={32145},count=6,max=6,min=6,route={3}}},
[5]= {{monster_package={32150},count=1,max=1,min=1,route={1}},{monster_package={32150},count=1,max=1,min=1,route={2}},{monster_package ={32149},count=1,max=1,min=1,route={3}}},
}

View File

@@ -0,0 +1,293 @@
--[[======================================
|| filename: TowerDefence_Monster_V3.0
|| owner: chao.cui
|| description: 怪物相关逻辑
|| LogName: TD_V3
|| Protection: ???
=======================================]]
--编辑器配置
--[[
local defs = {
group_id = 245002003,
gear_group_id = 245002002
}
-- DEFS_MISCS
route_map={
[1]={route_points={1,2,3,4,5,6,7,8,9,10},tags=2},
[2]={route_points={1,2,3,4,5,6,7,8,9,10},tags=4},
[3]={route_points={1,2,3,4,5,6,7,8,9,10},tags=8},
[4]={route_points={1,2,3,4,5,6,7,8,9,10},tags=16},
}
-- 刷怪方案。在MonsterWaveConfig中配置
local monsterTides = tides_level_01_sample
]]--
-- 怪物潮概念说明
-- WAVE: 轮次。显示在屏幕上的1/1轮
-- TIDE每个WAVE中的刷挂波次
-- 打印日志
function PrintLog(context, content)
local log = "## [TowerDefence_Monster_V3.0] TD_V3: "..content
ScriptLib.PrintContextLog(context, log)
end
-- 初始化一些trigger和var
function LF_Init_Monster_Group()
local extraTriggers =
{
t1 = { config_id = 40000001, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_monster_die", trigger_count = 0 },
t3 = { config_id = 40000003, name = "MONSTER_WILL_LEAVE_SCENE", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_MONSTER_DIE_BEFORE_LEAVE_SCENE", trigger_count = 0 },
--t4 = { config_id = 40000004, name = "EVENT_ANY_MONSTER_LIVE", event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "", action = "action_ANY_MONSTER_LIVE", trigger_count = 0 },
}
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
table.insert(suites[1].triggers, _trigger.name)
end
table.insert(variables, { config_id=50000001,name = "tide_ptr", value = 0}) -- TIDE
table.insert(variables, { config_id=50000002,name = "challenge_group", value = 0}) -- 主控group
table.insert(variables, { config_id=50000003,name = "left_monsters", value = 0}) -- 该wave的怪物总数
table.insert(variables, { config_id=50000004,name = "monster_tide_index", value = 1}) -- 真正的mini刷怪波次
table.insert(variables, { config_id=50000005,name = "monster_kill_count", value = 0}) -- 死亡(包含逃走)的怪物
-- table.insert(variables, { name = "planNum", value = 1, no_refresh = true})
table.insert(variables, { config_id=50000006,name = "monster_wave_ptr", value = 1}) -- WAVE
table.insert(variables, { config_id=50000007,name = "currentTideMonsters", value = 0}) -- 当前tide的怪物数量
end
function action_monster_die(context, evt)
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "UpdateLeftMonsterNum", {0})
LF_UpdateMonsterKillCount(context)
return 0
end
function action_MONSTER_DIE_BEFORE_LEAVE_SCENE(context, evt)
PrintLog(context, "怪物在离开场景前死亡事件触发。")
-- 根据monsterId判断死亡的怪物是否是【精英怪】
local eid = evt.source_eid
local mid = ScriptLib.GetMonsterIdByEntityId(context, eid)
PrintLog(context, "MONSTERID:"..mid)
local eliteMonsters = superMonsters or {}
local isElite = 0
for _, _monsterId in pairs(eliteMonsters) do
if mid == _monsterId then
isElite = 1
end
end
-- 获取主控Group编号
local challengeGroup = ScriptLib.GetGroupVariableValue(context, "challenge_group")
-- 地脉异常L1检查掉落击杀
LF_GetDieFallBonusPoints(context, evt, isElite)
-- 地脉异常L3检查
ScriptLib.ExecuteGroupLua(context, challengeGroup, "LF_SpecialGameplayLevel3", {isElite})
return 0
end
-- 掉落死亡判定
function LF_GetDieFallBonusPoints(context, evt, _isElite)
local dieReason = evt.param3
if dieReason == nil then
PrintLog(context, "死亡原因未知")
return 0
else
PrintLog(context, "死亡原因:"..dieReason)
end
local challengeGroup = ScriptLib.GetGroupVariableValue(context, "challenge_group")
if dieReason == 5 or dieReason == 6 or dieReason == 7 then
-- 地脉异常L1检查
ScriptLib.ExecuteGroupLua(context, challengeGroup, "LF_SpecialGameplayLevel1", {_isElite})
end
end
-- SLC 怪物到达终点(成功逃跑)
-- 复用已有的塔防怪物终点物件。为不影响之前版本逻辑所以没有修改此function名称为SLC_MonsterArrive
function MonsterArrive(context)
local entityId = context.target_entity_id
ScriptLib.PrintContextLog(context, "TowerDefenseMonsterArrive"..context.target_entity_id)
-- points是刷怪点位
for k, v in pairs(points) do
if ScriptLib.GetEntityIdByConfigId(context, v.config_id) == entityId then
-- ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "MonsterEscaped", {0})
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "UpdateLeftMonsterNum", {0})
-- 直接Remove不会走掉血死亡流程
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.MONSTER, v.config_id)
-- 更新死亡怪物数量
LF_UpdateMonsterKillCount(context)
return 0
end
end
return 0
end
function LF_UpdateMonsterKillCount(context)
local monster_kill_count = ScriptLib.GetGroupVariableValue(context, "monster_kill_count")
monster_kill_count = monster_kill_count + 1
ScriptLib.SetGroupVariableValue(context, "monster_kill_count", monster_kill_count)
if monster_kill_count >= ScriptLib.GetGroupVariableValue(context, "currentTideMonsters") then
LF_MonsterTideOver(context)
end
end
-- 计算并设置当前WAVE怪物总数会由TowerDefence_Challenge_V3.0调用)
function set_monster_number_req(context, prev_context, _challengeGroup, param2, param3)
--local wave_ptr = param1
--设置挑战groupid
ScriptLib.SetGroupVariableValue(context, "challenge_group", _challengeGroup)
local monstersLeft = 0
if monsterTides == nil or #monsterTides == 0 then
PrintLog(context, "monsterTides未配置")
return 0
end
PrintLog(context, "tide count:"..#monsterTides)
-- 计算当前WAVE的怪物总数
for i = 1, #monsterTides do
-- 循环tide的资源包组
for j = 1, #monsterTides[i] do
monstersLeft = monstersLeft + (monsterTides[i][j].count * #monsterTides[i][j].route)
end
end
PrintLog(context, "剩余怪物总数"..monstersLeft)
ScriptLib.ExecuteGroupLua(context, _challengeGroup, "LF_InitLeftMonsterNum", {monstersLeft})
ScriptLib.SetGroupVariableValue(context, "left_monsters", monstersLeft)
return 0
end
-- 初始化某tide的怪物总数
function LF_SetTideMonsterNum(context, tide)
local wave = 1
local num = 0
local tideConfigInfo = monsterTides[tide]
for i = 1, #tideConfigInfo do
num = num + (tideConfigInfo[i].count * #tideConfigInfo[i].route)
end
PrintLog(context, "tide"..tide.."怪物数量设置为"..num)
ScriptLib.SetGroupVariableValue(context, "currentTideMonsters", num)
ScriptLib.SetGroupVariableValue(context, "monster_kill_count", 0)
end
--启动此wave的tide1会由TowerDefence_Challenge_V3.0调用)
-- @param1 主控GroupId
-- @param2 当前wave编号
function LF_StartWave(context, prev_context, param1, param2, param3)
PrintLog(context, "WAVE开启")
local wave = param2
ScriptLib.SetGroupVariableValue(context, "challenge_group", param1)
ScriptLib.SetGroupVariableValue(context, "monster_wave_ptr", wave)
ScriptLib.SetGroupVariableValue(context, "tide_ptr", 1)
LF_StartTide(context, 1)
return 0
end
-- tide结束
function LF_MonsterTideOver(context)
ScriptLib.PrintContextLog(context, "TIDE结束")
-- 当前wave和tide
local wave = ScriptLib.GetGroupVariableValue(context, "monster_wave_ptr")
local tide = ScriptLib.GetGroupVariableValue(context, "tide_ptr")
if tide >= #monsterTides then
local challenge_group = ScriptLib.GetGroupVariableValue(context, "challenge_group")
ScriptLib.ExecuteGroupLua(context, challenge_group, "wave_done", {0})
PrintLog(context, "此WAVE的所有TIDE结束")
return 0
end
--tide自然结束,开启下一tide
tide = tide + 1
LF_StartTide(context, tide)
return 0
end
function LF_StartTide(context, tide)
LF_SetTideMonsterNum(context, tide)
local miniTide = ScriptLib.GetGroupVariableValue(context, "monster_tide_index")
local affix={}
for i = 1, #monsterTides[tide] do
local monster_pool_table = monsterTides[tide][i].monster_package
if monster_pool_table == nil or #monster_pool_table == 0 then
PrintLog(context, "Tide"..tide.."的monster_pool_table没取到")
else
for i=1,#monster_pool_table do
PrintLog(context, "Tide"..tide.."的monster_pool_table="..monster_pool_table[i])
end
end
for j = 1, #monsterTides[tide][i].route do
if 0 ~= ScriptLib.AutoPoolMonsterTide(context, miniTide, defs.group_id, monster_pool_table, monsterTides[tide][i].route[j], route_map[monsterTides[tide][i].route[j]].route_points, affix, {total_count=monsterTides[tide][i].count, min_count=monsterTides[tide][i].min, max_count=monsterTides[tide][i].max, tag=route_map[monsterTides[tide][i].route[j]].tags,fill_time=5,fill_count=5}) then
PrintLog(context, "MiniTide"..miniTide.."AutoPool失败")
else
PrintLog(context, "MiniTide"..miniTide.."AutoPool成功")
end
miniTide = miniTide + 1
end
end
ScriptLib.SetGroupVariableValue(context, "monster_tide_index", miniTide)
ScriptLib.SetGroupVariableValue(context, "tide_ptr", tide)
return 0
end
------------------------------------
LF_Init_Monster_Group()

View File

@@ -0,0 +1,189 @@
--[[======================================
|| filename: TowerDefence_SpecialGears_V3.0
|| owner: chao.cui
|| description: 特殊机关(目前只有光桥)
|| LogName: TD_V3
|| Protection: ???
=======================================]]
--[[
-- Trigger变量
local defs = {
group_id = 245002013,
challenge_group_id = 245002001,
close_cd = 5,
reset_cd = 10,
}
-- DEFS_MISCS
-- 特殊机关
-- 关卡1光桥专用且只会放一组
local specialGears =
{
-- operatorConfigId
[1001] = {operatorEffectConfigId = 1002, bridgeConfigId = 1003},
}
--]]
-- 打印日志
function PrintLog(context, content)
local print = 1
if print > 0 then
local log = "## [TowerDefence_SpecialGears_V3.0] TD_V3: "..content
ScriptLib.PrintContextLog(context, log)
end
end
-- 初始化Group
function LF_Initialize_Group(triggers, suites)
local extraTriggers =
{
{ config_id = 40000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0},
{ config_id = 40000002, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_GADGET_CREATE", trigger_count = 0 },
{ config_id = 40000003, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0},
{ config_id = 40000004, name = "TIMER_EVENT_001", event = EventType.EVENT_TIMER_EVENT, source = "close", condition = "", action = "action_EVENT_TIMER_EVENT_CLOSE", trigger_count = 0 },
{ config_id = 40000005, name = "TIMER_EVENT_002", event = EventType.EVENT_TIMER_EVENT, source = "reset", condition = "", action = "action_EVENT_TIMER_EVENT_RESET", trigger_count = 0 },
}
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers, extraTriggers[i].name)
end
-- -- 操作次数
-- table.insert(variables, {name = "operateTimes", value = 0})
-- -- 下一个执行Close的Operator
-- table.insert(variables, {name = "closePointer", value = 0})
-- -- 下一个执行Reset的Operator
-- table.insert(variables, {name = "resetPointer", value = 0})
-- -- 20是个保险数字操作台数量上限
-- for i = 1, 20 do
-- table.insert(variables, {name = "Operator"..i, value = 0})
-- end
end
function action_EVENT_GROUP_LOAD(context, evt)
PrintLog(context, "SpecialGears Load.")
return 0
end
--
function action_GADGET_CREATE(context, evt)
-- 初始化所有操作台(其实只有一个)
for operatorConfigId, info in pairs(specialGears) do
if evt.param1 == operatorConfigId then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, operatorConfigId, {4007})
end
end
return 0
end
-- 使用操作台
function action_EVENT_SELECT_OPTION(context, evt)
if evt.param2 ~= 4007 then return 0 end
local operatorConfigId = evt.param1
-- 记录总次数
-- local times = ScriptLib.GetGroupVariableValue(context, "operateTimes")
-- times = times + 1
-- ScriptLib.SetGroupVariableValue(context, "operateTimes", times)
-- ScriptLib.SetGroupVariableValue(context, "Operator"..times, operatorConfigId)
-- 删除操作选项
ScriptLib.DelWorktopOption(context, 4007)
-- 操作台激活
ScriptLib.SetGadgetStateByConfigId(context, operatorConfigId, 201)
if specialGears[operatorConfigId] == nil then
return 0
end
-- 光桥
local bridgeConfigId = specialGears[operatorConfigId].bridgeConfigId
ScriptLib.SetGadgetStateByConfigId(context, bridgeConfigId, 0)
-- 特效
local effectConfigId = specialGears[operatorConfigId].operatorEffectConfigId
ScriptLib.KillEntityByConfigId(context, {group_id = defs.group_id, config_id = effectConfigId})
-- ScriptLib.KillEntityByConfigId(context, {defs.group_id, effectConfigId, EntityType.GADGET})
-- TIMER_CLOSE
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "close", defs.close_cd)
-- TIMER_RESET
local resetCd = defs.reset_cd
local card_picked = ScriptLib.GetGroupVariableValueByGroup(context, "CardPicked_GearCoolDown", defs.challenge_group_id)
if card_picked > 0 then
resetCd = resetCd * 0.5
end
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "reset", resetCd)
return 0
end
-- 计时器1改变光桥状态
function action_EVENT_TIMER_EVENT_CLOSE(context, evt)
-- local closePointer = ScriptLib.GetGroupVariableValue(context, "closePointer")
-- closePointer = closePointer + 1
-- ScriptLib.SetGroupVariableValue(context, "closePointer", closePointer)
--local operator = ScriptLib.GetGroupVariableValue(context, "Operator"..closePointer)
local operator = 0
for operatorConfigId, info in pairs(specialGears) do
operator = operatorConfigId
end
PrintLog(context, "操作台ConfigId: "..operator)
-- 操作台
ScriptLib.SetGadgetStateByConfigId(context, operator, 202)
-- 光桥
local bridge = specialGears[operator].bridgeConfigId
ScriptLib.SetGadgetStateByConfigId(context, bridge, 201)
return 0
end
-- 计时器2重置操作台
function action_EVENT_TIMER_EVENT_RESET(context, evt)
-- local resetPointer = ScriptLib.GetGroupVariableValue(context, "resetPointer")
-- resetPointer = resetPointer + 1
-- ScriptLib.SetGroupVariableValue(context, "resetPointer", resetPointer)
-- local operator = ScriptLib.GetGroupVariableValue(context, "Operator"..resetPointer)
local operator = 0
for operatorConfigId, info in pairs(specialGears) do
operator = operatorConfigId
end
PrintLog(context, "操作台ConfigId: "..operator)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, operator, {4007})
ScriptLib.SetGadgetStateByConfigId(context, operator, 0)
return 0
end
LF_Initialize_Group(triggers, suites)