0
0
mirror of https://gitlab.com/YuukiPS/GC-Resources.git synced 2025-04-28 09:05:26 +00:00

Revert "remove local in defs"

This reverts commit 7e0a645ef33da87ddd5c402c6a64180001c6b03d.
This commit is contained in:
Yuuki 2023-11-23 23:27:47 +08:00
parent 317b6ca37a
commit b09934e7b9
4706 changed files with 48792 additions and 5311 deletions

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
RegionID = 575001
}
--]]

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
RegionID = 575001
}
--]]

View File

@ -84,7 +84,7 @@ local progress_def = {
["nightmare"] = {0,1500,3000,4500,6500}
}
defs = {
local defs = {
--group_main
gadget_aster = 413001,
gadget_reward = 123456,

View File

@ -1,6 +1,6 @@
--地脉花循环营地模板
--defs = {
--local defs = {
-- group_id = xxx ,
-- monster_waves = 4,
-- chest_id = xxx,

View File

@ -48,7 +48,7 @@ end
Initialize_Group()
----------------------------------------------
--[[
defs = {
local defs = {
operator = 431009,
blossom_chest = 431010,
ice_storm = 431011,

View File

@ -52,7 +52,7 @@ end
Initialize_Group()
----------------------------------------------
--[[
defs = {
local defs = {
operator = 422010,
blossom_chest = 422011,
platform = 422013

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
gallery_id = 1,
gadget_entry = 1,
balloon_clear_state = 202,

View File

@ -0,0 +1,236 @@
--[[
local defs = {
gallery_id = 1,
option_1 = 7,
option_2 = 2905,
gadget_final = 453012,
gadget_operator = 453001,
group_list = {133004454,133004455,133004456,133004457,133004458},
trans_pos = {x=2771,y=436,z=12},
top = 453009,
bottom = 453004,
region_list = {453004,453006,453007,453008,453009}
}
--]]
-----------------------
local Tri = {
--{ config_id = 8000001, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
{ config_id = 8000002, name = "enter_region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false },
{ config_id = 8000003, name = "leave_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "condition_leave_region", action = "action_leave_region", trigger_count = 0, forbid_guest = false },
{ config_id = 8000004, name = "gadget_create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "condition_gadget_create", action = "action_gadget_create", trigger_count = 0 },
{ config_id = 8000005, name = "gallery_start", event = EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_gallery_start", trigger_count = 0},
{ config_id = 8000006, name = "gallery_stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
{ config_id = 8000007, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0}
}
local Var = {
--{name = "timer_ptr", value = 0, no_refresh = false}
}
function Initialize()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
if v.name == "enter_region" or v.name == "leave_region" then
table.insert(suites[2].triggers, v.name)
else
table.insert(suites[1].triggers, v.name)
end
end
end
--[[function action_select_option(context, evt)
if evt.param1 ~= defs.gadget_operator then
return -1
end
if evt.param2 == defs.option_1 then
ScriptLib.StartGallery(context, defs.gallery_id)
return 0
elseif evt.param2 == defs.option_2 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
return 0
end--]]
function action_enter_region(context, evt)
if context.uid == 0 then
return -1
end
local position = ScriptLib.GetPosByEntityId(context, context.target_entity_id)
for i,v in ipairs(regions) do
if math.abs(v.pos.y - position.y) <= v.size.y/2 then
return LF_SET_VISION_TYPE(context, v.config_id)
end
end
return -1
end
function condition_leave_region(context, evt)
if context.uid == 0 then
return false
end
local position = ScriptLib.GetPosByEntityId(context, context.target_entity_id)
local bottom = 0
local top = 0
for i,v in ipairs(regions) do
if v.config_id == defs.bottom then
bottom = i
end
if v.config_id == defs.top then
top = i
end
end
if position.y <= regions[bottom].pos.y - regions[bottom].size.y/2 then
return true
elseif position.y >= regions[top].pos.y + regions[top].size.y/2 then
return true
elseif math.abs(position.x - regions[top].pos.x) >= regions[top].size.x/2 then
return true
elseif math.abs(position.z - regions[bottom].pos.z) >= regions[bottom].size.z/2 then
return true
end
return false
end
function action_leave_region(context, evt)
-- 将玩家的GroupVisionType设为1
if 0 ~= ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1}) then
return -1
end
return 0
end
function condition_gadget_create(context, evt)
if evt.param1 ~= defs.gadget_operator then
return false
end
return true
end
function action_gadget_create(context, evt)
--ScriptLib.SetGadgetEnableInteract(context, 0, defs.gadget_operator, true)
return 0
end
function action_gallery_start(context, evt)
if evt.param1 ~= defs.gallery_id then
return -1
end
local act_time = ScriptLib.GetActivityOpenAndCloseTimeByScheduleId(context, 2003001)
local cur_time = ScriptLib.GetServerTime(context)
if cur_time >= act_time[1] and cur_time < act_time[2] - 86400*7 then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.operator_group_id, defs.gadget_operator, 901)
end
LF_GALLERY_START(context, evt)
return 0
end
function action_gallery_stop(context, evt)
local act_time = ScriptLib.GetActivityOpenAndCloseTimeByScheduleId(context, 2003001)
local cur_time = ScriptLib.GetServerTime(context)
if cur_time >= act_time[1] and cur_time < act_time[2] - 86400*7 then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.operator_group_id, defs.gadget_operator, 0)
end
LF_GALLERY_STOP(context, evt)
return 0
end
function action_group_load(context, evt)
ScriptLib.CreateGadget(context, {config_id = defs.gadget_airwall})
--ScriptLib.SetGadgetEnableInteract(context, 0, defs.gadget_operator, true)
return 0
end
--------------------------
function LF_SET_VISION_TYPE(context, cid)
local layer = 0
for i,v in ipairs(defs.region_list) do
if v == cid then
layer = i
break
end
end
if layer < 1 or layer > #defs.region_list then
return -1
end
local array = {}
--[[
--常规的区间分布
for i=-1,0,1 do
if layer+i >= 1 and layer+i <= #defs.region_list then
table.insert(array,layer+i+10)
end
end
for i,v in ipairs(array) do
ScriptLib.PrintContextLog(context, "## uid = "..context.uid.." | vision = "..v)
end
--]]
if layer == 1 then
array = {11}
elseif layer >= 2 and layer < #defs.region_list then
array = {9+layer,10+layer}
elseif layer == #defs.region_list then
array = {16}
end
return ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, array)
end
function LF_GALLERY_START(context, evt)
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.gadget_airwall)
--local uid_arr = ScriptLib.GetSceneUidList(context)
--ScriptLib.TransPlayerToPos(context, {uid_list=uid_arr, pos = defs.trans_pos, rot = {x=0,y=0,z=0}})
--ScriptLib.SetGadgetEnableInteract(context, 0, defs.gadget_operator, false)
ScriptLib.AddExtraGroupSuite(context, 0, 2)
-- 启动移动平台
if 0 ~= ScriptLib.StartPlatform(context, defs.gadget_final) then
return -1
end
for i,v in ipairs(defs.group_list) do
ScriptLib.AddExtraGroupSuite(context, v, 2)
end
end
function LF_GALLERY_STOP(context, evt)
ScriptLib.CreateGadget(context, {config_id = defs.gadget_airwall})
--ScriptLib.SetGadgetEnableInteract(context, 0, defs.gadget_operator, true)
ScriptLib.RemoveExtraGroupSuite(context, 0, 2)
for i,v in ipairs(defs.group_list) do
ScriptLib.RemoveExtraGroupSuite(context, v, 2)
end
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {1})
end
-------------------------------------------
function FlyBalloonDestinationScore(context)
ScriptLib.PrintContextLog(context, "## FlyBalloonDestinationScore | uid -> "..context.uid.." | source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
--ScriptLib.AddTeamEntityGlobalFloatValue(context, {context.uid}, "has_end_game", 1)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70360139,["has_end_game"]=true})
return 0
end
function FlyBalloonHighScore(context)
ScriptLib.PrintContextLog(context, "## FlyBalloonHighScore | uid -> "..context.uid.." | source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70360138})
return 0
end
function FlyBalloonLowScore(context)
ScriptLib.PrintContextLog(context, "## FlyBalloonLowScore | uid -> "..context.uid.." | source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70360137})
return 0
end
function FlyBalloonLanding(context)
ScriptLib.PrintContextLog(context, "## FlyBalloonLanding | uid -> "..context.uid.." | source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local eid = ScriptLib.GetAvatarEntityIdByUid(context, context.uid)
local pos = ScriptLib.GetPosByEntityId(context, eid)
if defs.landing_Y == nil or pos.y <= defs.landing_Y then
--ScriptLib.AddTeamEntityGlobalFloatValue(context, {context.uid}, "has_end_game", 1)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["has_end_game"]=true})
return 0
end
return -1
end
-------------------------------------------
Initialize()

View File

@ -1,4 +1,4 @@
--[[defs = {
--[[local defs = {
gadget_operator = xxx,
group_id = xxx,
gadget_prison_list = {1,2,3,4}

View File

@ -1,4 +1,4 @@
--[[defs = {
--[[local defs = {
group_id = xxx,
gadget_prison_list = {1,2,3,4},
gadget_guide = {1,2,3},

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
timer_region = 1,
challenge_region = 2,
monster_hilichurl = 3,

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
need_kill_hint = true,
group_id = 144001108, --对应的GroupID
gadget_init = {108013, 108014}, --defs.gadget_init里按顺序填入 开启挑战机关ConfigID、 限时终点ConfigID

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
group_id = xxx,
tide_sum = 25,
tide_max = 8,

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
monster_boss = xxx,
summon_region_list = {1,2,3}, --region出怪的list
summon_interval = 15, --自动出怪时间

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
gadget_up = 1, --向上压板
gadget_down = 2, --向下压板
gadget_water = 7001, --水片

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
group_id = xxx ,
monster_shaman = 1,
gadget_barrier = {1,2,3,4,5},

View File

@ -0,0 +1,203 @@
--地脉花循环营地模板
--local defs = {
-- group_id = xxx ,
-- monster_waves = 4,
-- chest_id = xxx,
-- operator1_id = xxx,
-- operator2_id = xxx
--}
local Tri = {
[1] = { name = "any_monster_die", config_id = 8000001, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0 },
[2] = { name = "blossom_progress_finish", config_id = 8000002, event = EventType.EVENT_BLOSSOM_PROGRESS_FINISH, source = "", condition= "", action = "action_blossom_progress_finish", trigger_count = 0 },
[4] = { name = "group_load", config_id = 8000004, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
[5] = { name = "group_refresh", config_id = 8000005, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0 },
--[6] = { name = "chest_die", config_id = 8000006, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0 },
[7] = { name = "select_option", config_id = 8000007, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
[8] = { name = "blossom_chest_die", config_id = 8000008, event = EventType.EVENT_BLOSSOM_CHEST_DIE, source = "", condition = "", action = "action_blossom_chest_die", trigger_count = 0 },
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--注入一个blossom的标志位。下次groupload时如果为1说明玩法已经开始了不再走一次init
table.insert(variables,{ config_id=50000001,name = "HasStarted", value = 0, no_refresh = true})
table.insert(variables,{ config_id=50000002,name = "wave", value = 0, no_refresh = true})
end
----------------------------------
function action_any_monster_die(context, evt)
--当怪物死的时候,增加循环营地进度
ScriptLib.AddBlossomScheduleProgressByGroupId(context, 0)
--如果还有怪物活着,无事发生
if ScriptLib.GetGroupMonsterCountByGroupId(context, 0) ~= 0 then
return -1
end
--当前波次怪物死光了,则加载下一波怪物
LF_Create_Next_Monster_Wave(context)
return 0
end
function action_group_load(context, evt)
--group加载时刷新循环营地
ScriptLib.PrintContextLog(context,"BG: Group has been loaded!")
ScriptLib.SetGroupVariableValue(context,"GroupCompletion",0)
--group load时判定一下这个group是否已经开启如果已经开启则无事发生
local has_started = ScriptLib.GetGroupVariableValue(context,"HasStarted")
if (has_started == 1) then
ScriptLib.PrintContextLog(context,"BG: Group has been started, refresh failed!")
return 0
end
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 1, exclude_prev = true, is_delay_unload = true })
LF_Init_Blossom_Group(context)
return 0
end
function action_group_refresh(context, evt)
ScriptLib.PrintContextLog(context,"BG: Group has been refreshed!")
--group load时判定一下这个group是否已经开启如果已经开启则无事发生
local has_started = ScriptLib.GetGroupVariableValue(context,"HasStarted")
if (has_started == 1) then
ScriptLib.PrintContextLog(context,"BG: Group has been started, refresh failed!")
return 0
end
--group刷新时初始化整个group
LF_Init_Blossom_Group(context)
return 0
end
function action_blossom_chest_die(context,evt)
--领取完奖励后,刷新循环营地
if evt.param1 == defs.chest then
ScriptLib.PrintContextLog(context,"BG: blossom has been opened. Refreh the next blossom group")
--group重置为没有开始的状态
ScriptLib.SetGroupVariableValue(context,"HasStarted",0)
ScriptLib.SetGroupVariableValue(context,"wave",0)
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 1, exclude_prev = true })
end
return 0
end
function action_select_option(context,evt)
--玩家选择选项后隐藏地脉淤积gadget清除gadget上的选项激活第一波怪物
ScriptLib.PrintContextLog(context,"BG: Option has been selected! Monster waves start!")
ScriptLib.SetGadgetStateByConfigId(context, LF_Get_Blossom_Operator(context), 201)
ScriptLib.DelWorktopOptionByGroupId(context,0,LF_Get_Blossom_Operator(context),187)
--所有东西成功刷出来了将group设置为已开始状态
ScriptLib.SetGroupVariableValue(context,"HasStarted",1)
LF_Start_Monster_Wave(context)
return 0
end
function action_blossom_progress_finish(context,evt)
--进度打满以后,创建奖励
LF_Create_Reward(context)
ScriptLib.SetGroupVariableValue(context,"GroupCompletion",1)
return 0
end
----------------------------------
function LF_Create_Reward(context)
--创建循环营地奖励方法并将循环营地进度置到reward
ScriptLib.PrintContextLog(context,"BG: Monster wave has ended, creating blossom group reward")
ScriptLib.SetBlossomScheduleStateByGroupId(context,0,3)
ScriptLib.PrintContextLog(context,"BG: Creaing blossom chest!!")
ScriptLib.CreateBlossomChestByGroupId(context,0,defs.chest)
end
function LF_Create_Next_Monster_Wave(context)
--更新下一波怪物潮的方法如果已经到了最后一波则不刷新此时理论上来说打完应该直接触发blossom group finish
local wave = ScriptLib.GetGroupVariableValue(context,"wave")
--local wave = ScriptLib.GetGroupTempValue(context, "wave", {})
local nextWave = wave + 1
if nextWave+1 > #suites then
ScriptLib.PrintContextLog(context, "BG: This is final wave ")
else
ScriptLib.PrintContextLog(context,"BG: Creating monster wave: "..nextWave)
ScriptLib.AddExtraGroupSuite(context, 0, nextWave+1)
ScriptLib.PrintContextLog(context,"BG: We are trying to load suite : "..nextWave+1)
ScriptLib.SetGroupVariableValue(context,"wave",nextWave)
--ScriptLib.SetGroupTempValue(context, "wave", nextWave, {})
end
end
function LF_Start_Monster_Wave(context)
--启动怪物潮,进入打怪阶段
ScriptLib.SetBlossomScheduleStateByGroupId(context, 0, 2)
ScriptLib.SetGroupVariableValue(context,"wave",0)
--ScriptLib.SetGroupTempValue(context, "wave", 0, {})
--加载第一波怪物
LF_Create_Next_Monster_Wave(context)
end
function LF_Init_Blossom_Group(context)
--初始化循环营地方法移除全部的怪物group并刷新地脉淤积操作台
ScriptLib.PrintContextLog(context,"BG: Blossom group is initiating")
--初始化时先移除掉所有怪物的suite
for i = 2, #suites do
ScriptLib.RemoveExtraGroupSuite(context,0,i)
end
if (LF_Get_Blossom_Operator(context) == -1) then
return -1
end
ScriptLib.PrintContextLog(context,"BG: Current operator config id is: "..LF_Get_Blossom_Operator(context))
--加载地脉淤积的gadget
local ret = ScriptLib.CreateGadget(context, {config_id = LF_Get_Blossom_Operator(context)})
ScriptLib.PrintContextLog(context,"BG: Create worktop result: "..ret)
--给地脉淤积的gadget增加操作选项
ScriptLib.SetWorktopOptionsByGroupId(context,0,LF_Get_Blossom_Operator(context),{187})
return 0
end
function LF_Get_Blossom_Operator(context)
--获取当前BlossomGroup的地脉淤积操作台的方法根据当前的刷新类型返回不同的操作台
local operator = {[1]=defs.operator_1,[2]=nil,[3]=defs.operator_2}
local refreshType = ScriptLib.GetBlossomRefreshTypeByGroupId(context, 0)
if not (refreshType == 1 or refreshType == 3) then
return -1
end
ScriptLib.PrintContextLog(context,"BG: Current blossom group refresh type: "..refreshType)
return operator[refreshType]
end
----------------------------------
Initialize()

View File

@ -0,0 +1,672 @@
--2.0奥博伦派对玩法
--local defs = {
-- group_id = 111101122 ,
-- tamari_gadget_id = defs.temari_gadget_id,
-- host_option_id = 184,
-- guset_option_id = 185,
-- host_chest_id = 122001,
--}
local tempDefs = {
pre_quest = 7217605,
host_option = 2351,
guest_option = 2350,
find_ball_challenge_offline = 244,
hide_ball_challenge = 236,
find_ball_challenge = 235,
father_hide_ball_challenge = 242,
father_find_ball_challenge = 243,
challenge_time = 30
}
local chests = {}
local temari_gadgets = {}
local Tri1 = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "quest_finish", config_id = 8000002, event = EventType.EVENT_QUEST_FINISH, source = "",condition = "",action = "action_quest_finish",trigger_count= 0},
}
local Tri2 = {
[1] = { name = "quest_start", config_id = 8000003, event = EventType.EVENT_QUEST_START, source = "",condition = "",action = "action_quest_start",trigger_count= 0},
[2] = { name = "challenge_success", config_id = 8000004, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "",condition = "",action = "action_challenge_success",trigger_count= 0},
[3] = { name = "challenge_fail", config_id = 8000005, event = EventType.EVENT_CHALLENGE_FAIL, source = "",condition = "",action = "action_challenge_fail",trigger_count= 0},
[4] = { name = "select_option", config_id = 8000006, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0, forbid_guest = false },
[5] = { name = "group_refresh", config_id = 8000007, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0},
[6] = { name = "gadget_create", config_id = 8000008, event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri1) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(Tri2) do
table.insert(triggers, v)
table.insert(suites[2].triggers, v.name)
end
table.insert(chests,defs.chest_1)
table.insert(chests,defs.chest_2)
table.insert(chests,defs.chest_3)
--table.insert(chests,defs.chest_online)
table.insert(temari_gadgets,defs.temari_1)
table.insert(temari_gadgets,defs.temari_2)
table.insert(temari_gadgets,defs.temari_3)
table.insert(temari_gadgets,defs.temari_online)
table.insert(variables,{ config_id=50000001,name = "has_hidden", value = 0,no_refresh = true})
--记录uid的低四位
table.insert(variables,{ config_id=50000002,name = "challenger_uid1", value = 0})
--记录uid的高位challenger_uid2*10000+challenger_uid就是最后正确的uid
table.insert(variables,{ config_id=50000003,name = "challenger_uid2", value = 0})
--记录放球的小数位
table.insert(variables,{ config_id=50000004,name = "pos_x1", value = 0})
table.insert(variables,{ config_id=50000005,name = "pos_z1", value = 0})
end
--------------------------------------------------------------------
--group load时无事发生
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"TMR: Group Load!")
LF_Initiate_Play(context)
return 0
end
--group refresh时重置group状态回到第一关
function action_group_refresh(context,evt)
ScriptLib.PrintContextLog(context,"TMR: Group Refresh!")
LF_Reset_Group(context)
return 0
end
--任务开始时,加载下一关(单机挑战)
function action_quest_start(context,evt)
ScriptLib.PrintContextLog(context,"TMR: Player has triggered some quest!!")
--校验一下任务id确保是奥博伦任务触发的任务开始
if string.sub(evt.param1,1,5) == tostring(defs.FatherQuest) then
ScriptLib.PrintContextLog(context,"TMR: Triggered quest is :"..evt.param1)
LF_Set_Challenge_State(context,1)
LF_Load_Next_Level(context)
LF_Start_Challenge(context,0)
end
return 0
end
--操作台创建时,直接挂选项
function action_gadget_create(context,evt)
if (evt.param1 == defs.temari_gadget_id) then
LF_Set_Gadget_Option(context)
end
return 0
end
function action_quest_finish(context,evt)
ScriptLib.PrintContextLog(context,"TMR: pre quest has been finished, load the second suite!!")
if (evt.param1 == tempDefs.pre_quest) then
LF_Initiate_Play(context)
end
return 0
end
--选择了选项,根据当前主客机,触发不同的挑战(联机挑战)
function action_select_option(context,evt)
--试图开启主机藏球挑战
if evt.param2 == tempDefs.host_option then
--藏球挑战
if LF_Is_Host(context) then
if LF_Get_Challenge_State(context) == 10 or LF_Get_Challenge_State(context) == 12 then
--仅在联机玩法初始化以及主机已完成藏球的情况下,可以开启藏球挑战
ScriptLib.PrintContextLog(context,"TMR: !!!!!!!!!!!!Hide ball challenge starts!!!!!!!")
LF_Load_Online_Level(context,1)
LF_Set_Challenge_State(context,11)
LF_Start_Challenge(context,1)
ScriptLib.DelWorktopOptionByGroupId(context,defs.group_id,defs.temari_gadget_id,tempDefs.host_option)
elseif LF_Get_Challenge_State(context) == 11 then
--主机在藏球挑战中再次交互,试图开启藏球挑战(理论上不存在这种情况)
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!! Cannot start duplicated challenges!!!")
elseif LF_Get_Challenge_State(context) == 13 then
--客机正在找球,不允许主机开启藏球挑战
ScriptLib.SendServerMessageByLuaKey(context, "GUEST_CHALLENGING", {context.uid})
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!! Guest is challenging!!!")
end
else
--客机不能开启主机的藏球挑战
ScriptLib.SendServerMessageByLuaKey(context, "HOST_ONLY_CHALLENGE", {context.uid})
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Guest cannot hide ball!")
end
end
if evt.param2 == tempDefs.guest_option then
--找球挑战(允许主机也开启挑战,因此这里不做主客机的区分)
if LF_Get_Challenge_State(context)==12 then
--主机已完成藏球,可以开始挑战
ScriptLib.PrintContextLog(context,"TMR: !!!!!!!!!!!Find ball challenge starts!!!!!!!!!!!!")
LF_Load_Online_Level(context,2)
local ret = LF_Start_Challenge(context,2)
if (ret == -1) then
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Same gallery is activating!")
LF_Online_Hide_Level(context)
return 0
end
LF_Set_Challenge_State(context,13)
ScriptLib.DelWorktopOptionByGroupId(context,defs.group_id,defs.temari_gadget_id,tempDefs.guest_option)
elseif LF_Get_Challenge_State(context)== 10 then
--主机没有藏球,不能挑战
ScriptLib.SendServerMessageByLuaKey(context, "LEVEL_NOT_SETTLED", {context.uid})
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Host hasn't hide the ball!")
elseif LF_Get_Challenge_State(context)== 11 then
--主机正在藏球,不能挑战
ScriptLib.SendServerMessageByLuaKey(context, "LEVEL_SETTLING", {context.uid})
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Host is hiding the ball!")
elseif LF_Get_Challenge_State(context)== 13 then
--挑战中试图再开启一个找球挑战,理论上不存在这种情况
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Cannot start duplicated challenges!!!")
end
end
return 0
end
--分别处理单机玩法和联机玩法挑战失败的情况
function action_challenge_fail(context,evt)
if LF_Get_Play_Phase(context) == 1 then
if evt.param1 == tempDefs.find_ball_challenge_offline then
ScriptLib.PrintContextLog(context,"TMR: Offline Challenge fails!")
LF_Stop_Temari_Gallery(context)
LF_Update_Quest_State(context,false)
end
else
--联机挑战阶段挑战失败
if evt.param1 == tempDefs.father_hide_ball_challenge then
--藏球失败
ScriptLib.PrintContextLog(context,"TMR: Host Challenge fails!")
--创建一个藏球宝箱 5.27需求,不需要联机奖励宝箱了
--ScriptLib.CreateGadget(context,{config_id=chests[#chests]})
--修改挑战状态。如果玩家至少藏过一次球则即使失败也将状态置为12即藏过球否则置为10认为没有藏球
if (LF_Has_Hidden_Ball(context)) then
LF_Set_Challenge_State(context,12)
else
LF_Set_Challenge_State(context,10)
end
LF_Set_Gadget_Option(context)
--移除掉联机用的关卡布设
LF_Online_Hide_Level(context)
--LF_Teleport_Player(context)
end
if evt.param1 == tempDefs.father_find_ball_challenge then
--客机找球挑战失败
ScriptLib.PrintContextLog(context,"TMR: Guest Challenge fails!")
LF_Set_Challenge_State(context,12)
--移除掉联机用的关卡布设
LF_Online_Hide_Level(context)
LF_Set_Gadget_Option(context)
LF_Stop_Temari_Gallery(context)
end
end
return 0
end
--分别处理单机玩法和联机玩法挑战成功的情况
function action_challenge_success(context,evt)
ScriptLib.PrintContextLog(context,"TMR: Some challenge has been finished!!!")
if LF_Get_Play_Phase(context) == 1 then
if evt.param1 == tempDefs.find_ball_challenge_offline then
ScriptLib.PrintContextLog(context,"TMR: Offline Challenge success!")
LF_Stop_Temari_Gallery(context)
LF_Update_Quest_State(context,true)
--创建一个单机找球挑战宝箱,仅单机挑战的最后一关给一个宝箱
if (LF_Get_OfflineChallenge_Level(context)-2 == 3) then
ScriptLib.CreateGadget(context,{config_id=chests[LF_Get_OfflineChallenge_Level(context)-2]})
end
end
else
--联机挑战阶段挑战成功
if evt.param1 == tempDefs.father_hide_ball_challenge then
--藏球挑战成功
ScriptLib.PrintContextLog(context,"TMR: Host Challenge finishes!")
--创建一个藏球宝箱 5.27需求,不需要联机奖励宝箱了
--ScriptLib.CreateGadget(context,{config_id=chests[#chests]})
--修改挑战状态
LF_Set_Challenge_State(context,12)
LF_Set_Gadget_Option(context)
LF_Teleport_Player(context)
end
if evt.param1 == tempDefs.father_find_ball_challenge then
--找球挑战成功挑战状态回到12
ScriptLib.PrintContextLog(context,"TMR: Guest Challenge success!")
LF_Set_Challenge_State(context,12)
--移除掉联机用的关卡布设
LF_Online_Hide_Level(context)
LF_Set_Gadget_Option(context)
LF_Stop_Temari_Gallery(context)
end
end
return 0
end
--------------------------------------------------------------------
--辅助方法-----------------------------------------------------------
--------------------------------------------------------------------
--关卡相关方法---------------------------------------------------
--初始化整个玩法的方法仅当groupload时调用
function LF_Initiate_Play(context)
local uidList = ScriptLib.GetSceneUidList(context)
--上线的时候如果同时group load可能找不到uidlist做一个保护
if (uidList == nil or #uidList == 0) then
return 0
end
local avatar_entity = ScriptLib.GetAvatarEntityIdByUid(context, uidList[1])
local quest_state = ScriptLib.GetQuestState(context, avatar_entity, tempDefs.pre_quest)
ScriptLib.PrintContextLog(context,"TMR: Prequest state is: "..quest_state)
if ScriptLib.GetQuestState(context, avatar_entity, tempDefs.pre_quest) == QuestState.FINISHED then
ScriptLib.PrintContextLog(context,"TMR: pre quest has been finished, group load!!")
local ret = ScriptLib.GoToGroupSuite(context,defs.group_id,2)
--将当前suite切换到2确保下一次从suite3开始加载
LF_Set_OfflineChallenge_Level(context,2)
ScriptLib.PrintContextLog(context,"TMR: The result of loading suite 2 : "..ret)
end
end
--加载单机挑战的下一个关卡
function LF_Load_Next_Level(context)
local curLevel = LF_Get_OfflineChallenge_Level(context)
curLevel = curLevel + 1
ScriptLib.PrintContextLog(context,"TMR: Ready to load SUITE: "..curLevel)
LF_Set_OfflineChallenge_Level(context,curLevel)
ScriptLib.AddExtraGroupSuite(context,defs.group_id,curLevel)
end
--初始化联机玩法
function LF_Initiate_Online_Challenge(context)
--把交互用的奥博伦球创建出来
ScriptLib.CreateGadget(context,{config_id = defs.temari_gadget_id})
--给奥博伦交互球设置选项
LF_Set_Gadget_Option(context)
end
--加载联机挑战的关卡
--phase = 1主机藏球挑战phase = 2客机找球挑战
function LF_Load_Online_Level(context,phase)
if ( phase == 1 ) then
--加载最后一组suite和LD约定最后一组suite为联机关卡
ScriptLib.AddExtraGroupSuite(context,0,#suites)
--去掉场景内现在藏着的球
ScriptLib.KillEntityByConfigId(context,{config_id = defs.temari_online})
else
--加载最后一组suite和LD约定最后一组suite为联机关卡
ScriptLib.AddExtraGroupSuite(context,0,#suites)
--把存储的球的位置加载出来
local pos = LF_Load_Online_Temari_Pos(context)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.temari_online, {x=pos.x,y=pos.y,z=pos.z}, {x=0,y=0,z=0})
end
end
--重置整个group的方法将group还原至最初的状态
function LF_Reset_Group(context)
if LF_Get_Play_Phase(context) == 1 then
LF_Set_OfflineChallenge_Level(context,2)
LF_Set_Challenge_State(context,0)
else
--移除掉联机用的关卡布设
ScriptLib.RemoveExtraGroupSuite(context,0,#suites)
ScriptLib.KillEntityByConfigId(context,{config_id = defs.temari_online})
LF_Set_Challenge_State(context,10)
LF_Set_Gadget_Option(context)
end
end
--gallery/challenge/quest相关方法--------------------------------------------------
--启动挑战的方法,对于联机挑战,需要把启动的子挑战挂在父挑战上一起启动。
--target:0单机找球1联机藏球2联机找球
function LF_Start_Challenge(context,target)
if LF_Get_Play_Phase(context) == 1 then
--要求开启挑战,因为是单机的,直接开就可以了
ScriptLib.ActiveChallenge(context,tempDefs.find_ball_challenge_offline,tempDefs.find_ball_challenge_offline,tempDefs.challenge_time, 0, tempDefs.find_ball_challenge_offline, 1)
LF_Start_Temari_Gallery(context)
else
if (target == 2) then
local ret = LF_Start_Temari_Gallery(context)
--如果gallery没有开出来说明同scene下已经有一个同名gallery了整个玩法都不允许开启
if (ret == -1) then
return -1
end
--开启挑战的时候存一下开启挑战者的uid
LF_Save_Challenger(context)
end
--联机状态下,要把子挑战挂给父挑战后再开启
local challenge = 0
local father_challenge = 0
if (target == 1) then
challenge = tempDefs.hide_ball_challenge
father_challenge = tempDefs.father_hide_ball_challenge
elseif target == 2 then
challenge = tempDefs.find_ball_challenge_offline
father_challenge = tempDefs.father_find_ball_challenge
end
local child_challenge_param_table = {tempDefs.challenge_time,0,challenge,1}
ScriptLib.CreateFatherChallenge(context, father_challenge, father_challenge, tempDefs.challenge_time, {success=2, fail=1})
ScriptLib.AttachChildChallenge(context, father_challenge, challenge, challenge, child_challenge_param_table, {context.uid},{success=1, fail=1})
ScriptLib.StartFatherChallenge(context,father_challenge)
end
return 0
end
--终止挑战的方法challenge目标的挑战ID
--target: 0:单机挑战1联机藏球2联机找球
--resulttrue=1false=0
function LF_Stop_Challenge(context,target,result)
if LF_Get_Play_Phase(context) == 1 then
--单机的直接关掉即可
ScriptLib.PrintContextLog(context,"TMR: Stop offline challenge here!!!")
ScriptLib.StopChallenge(context,tempDefs.find_ball_challenge_offline,result)
else
if (target == 1) then
--结束联机藏球挑战
ScriptLib.PrintContextLog(context,"TMR: Stop hide ball challenge with result: "..result)
ScriptLib.StopChallenge(context,tempDefs.father_hide_ball_challenge,result)
elseif (target == 2) then
--结束联机找球挑战
ScriptLib.PrintContextLog(context,"TMR: Stop find ball challenge with result: "..result)
ScriptLib.StopChallenge(context,tempDefs.father_find_ball_challenge,result)
end
end
end
--启动藏球的方向指示gallery
function LF_Start_Temari_Gallery(context)
local ret = ScriptLib.SetPlayerStartGallery(context, 9001, {context.uid})
--如果gallery没有开出来说明同scene下已经有一个同名gallery了整个玩法都不允许开启
if (ret == -1) then
return -1
end
local temari_pos = LF_Get_Temari_Pos(context)
ScriptLib.SetHandballGalleryBallPosAndRot(context, 9001, {x=temari_pos.x,y=temari_pos.y,z=temari_pos.z}, {x=0,y=0,z=0})
end
--关闭藏球的方向指示gallery
function LF_Stop_Temari_Gallery(context)
ScriptLib.StopGallery(context, 9001, true)
end
--根据参数更新单机挑战的任务状态传入true为成功、false为失败
function LF_Update_Quest_State(context, questState)
local curLevel = LF_Get_OfflineChallenge_Level(context)
local quest_level = curLevel-2
local quest_suffix = "01"
if (questState) then
quest_suffix = "01"
else
quest_suffix = "02"
end
local quest_param = defs.group_id.."0"..quest_level..quest_suffix
local ret = ScriptLib.AddQuestProgress(context,quest_param)
ScriptLib.PrintContextLog(context,"TMR: quest param is "..quest_param)
ScriptLib.PrintContextLog(context,"TMR: The result of Adding quest progress is "..ret)
--不论挑战是否胜利,都要移除掉当前加载的关卡
ScriptLib.PrintContextLog(context,"TMR: The removed suite is "..curLevel)
ScriptLib.RemoveExtraGroupSuite(context,defs.group_id,curLevel)
--如果胜利且是单机挑战的最后一个suite胜利后直接进入联机玩法状态
if (questState) then
if (curLevel+1>=#suites) then
ScriptLib.PrintContextLog(context,"TMR:!!!!!!!!!!!!!!!!!Offline challenge has finished!!!!!!!!!!!!!!!!")
LF_Set_Challenge_State(context,10)
LF_Initiate_Online_Challenge(context)
end
end
--如果挑战失败,要将当前的关卡向前回滚一关,这样下次开启任务才能再次开启当前关卡
if (not questState) then
LF_Set_OfflineChallenge_Level(context,curLevel-1)
end
end
--通用类方法-----------------------------------------------------------
--将玩家传送回奥博伦球控制台附近
function LF_Teleport_Player(context)
local temari_worktop_id = ScriptLib.GetEntityIdByConfigId(context,defs.temari_gadget_id)
local temari_pos = ScriptLib.GetPosByEntityId(context, temari_worktop_id)
local uidlist = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context,"TMR: Current host player is :"..uidlist[1])
ScriptLib.PrintContextLog(context,"TMR: The context uid is: "..context.uid)
if (LF_Is_Host(context)) then
ScriptLib.TransPlayerToPos(context, {uid_list = {uidlist[1]}, pos = {x=temari_pos.x,y=temari_pos.y,z=temari_pos.z}, radius = 1, rot = {x=0, y=0, z=1},is_skip_ui=false} )
else
ScriptLib.TransPlayerToPos(context, {uid_list = {context.uid}, pos = {x=temari_pos.x,y=temari_pos.y,z=temari_pos.z}, radius = 1, rot = {x=0, y=0, z=1},is_skip_ui=false} )
end
end
--给奥博伦球gadget设置选项
function LF_Set_Gadget_Option(context)
ScriptLib.SetWorktopOptionsByGroupId(context,defs.group_id,defs.temari_gadget_id,{tempDefs.guest_option,tempDefs.host_option})
end
--联机玩法中,隐藏关卡配置的方法,调用后隐藏掉当前的关卡配置以及放着的球
function LF_Online_Hide_Level(context)
--干掉藏起来的球
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.temari_online)
--干掉放置用关卡
ScriptLib.RemoveExtraGroupSuite(context,0,#suites)
end
--通用的放球方法,把球放下来并记录其位置
function LF_Hide_Ball(context)
local uid_list = ScriptLib.GetSceneUidList(context)
local avatar_id = ScriptLib.GetAvatarEntityIdByUid(context, uid_list[1])
local pos = ScriptLib.GetPosByEntityId(context, avatar_id)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.temari_online, {x=pos.x+1,y=pos.y+1.5,z=pos.z}, {x=0,y=0,z=0})
--存一下球的位置,马上要销毁掉
LF_Save_Online_Temari_Pos(context)
LF_Online_Hide_Level(context)
end
--挑战开启时,将挑战者记录下来
function LF_Save_Challenger(context)
ScriptLib.PrintContextLog(context,"TMR: Save challenger uid: "..context.uid)
--拆一下uid存下来防止位数超了
local uid1 = context.uid % 10000 --低位
local uid2 = math.floor(context.uid / 10000) --高位
ScriptLib.SetGroupVariableValue(context,"challenger_uid1",uid1)
ScriptLib.SetGroupVariableValue(context,"challenger_uid2",uid2)
ScriptLib.PrintContextLog(context,"TMR: Saving uid2"..uid2)
ScriptLib.PrintContextLog(context,"TMR: Saving uid1"..uid1)
end
function LF_Is_Same_Challenger(context)
local uid1 = ScriptLib.GetGroupVariableValue(context,"challenger_uid1")
local uid2 = ScriptLib.GetGroupVariableValue(context,"challenger_uid2")
local uid = uid2 * 10000 + uid1
ScriptLib.PrintContextLog(context,"TMR: Player touching ball is: "..context.uid.." and the player set ball is "..uid)
return context.uid == uid
end
-----CRUD类方法-----------------------------------------------------------
--改变当前玩法状态
--0group初始化状态完全没有开始
--1单机挑战进行中用level参数确定当前正在进行的单机关卡数
--10已完成单机挑战联机挑战未开启
--11主机进行藏球挑战
--12主机已完成藏球
--13客机进行找球挑战
function LF_Set_Challenge_State(context,target_state)
ScriptLib.PrintContextLog(context,"TMR: Changing play state to: "..target_state)
ScriptLib.SetGroupVariableValue(context,"ChallengeState",target_state)
end
--获取当前玩法状态
--0group初始化状态完全没有开始
--1单机挑战进行中用level参数确定当前正在进行的单机关卡数
--10已完成单机挑战联机挑战未开启
--11主机进行藏球挑战
--12主机已完成藏球
--13客机进行找球挑战
function LF_Get_Challenge_State(context)
return ScriptLib.GetGroupVariableValue(context,"ChallengeState")
end
--设置单机挑战的当前关卡
function LF_Set_OfflineChallenge_Level(context,targetLevel)
ScriptLib.SetGroupVariableValue(context,"ChallengeLevel",targetLevel)
end
--读取单机挑战的当前关卡
function LF_Get_OfflineChallenge_Level(context)
return ScriptLib.GetGroupVariableValue(context,"ChallengeLevel")
end
--返回当前关卡的手鞠球位置
function LF_Get_Temari_Pos(context)
if (LF_Get_Play_Phase(context) == 1) then
--一阶段获取手鞠球的位置
local curLevel = LF_Get_OfflineChallenge_Level(context)
local temari_entity_id = ScriptLib.GetEntityIdByConfigId(context,temari_gadgets[curLevel-2])
local temari_pos = ScriptLib.GetPosByEntityId(context, temari_entity_id)
ScriptLib.PrintContextLog(context,"TMR: Temari pos: "..temari_pos.x..","..temari_pos.y..","..temari_pos.z)
return temari_pos
else
--二阶段获取手鞠球的位置
local temari_entity_id = ScriptLib.GetEntityIdByConfigId(context,defs.temari_online)
local temari_pos = ScriptLib.GetPosByEntityId(context, temari_entity_id)
ScriptLib.PrintContextLog(context,"TMR: Temari pos: "..temari_pos.x..","..temari_pos.y..","..temari_pos.z)
return temari_pos
end
end
--存储联机玩法中当前球的位置
function LF_Save_Online_Temari_Pos(context)
local pos = LF_Get_Temari_Pos(context)
ScriptLib.PrintContextLog(context,"TMR: Save Temari pos: "..pos.x..","..pos.y..","..pos.z)
local ret = ScriptLib.SetGroupVariableValue(context,"pos_x",math.floor(pos.x))
ScriptLib.SetGroupVariableValue(context,"pos_y",math.ceil(pos.y))
ScriptLib.SetGroupVariableValue(context,"pos_z",math.floor(pos.z))
ScriptLib.SetGroupVariableValue(context,"pos_x1",math.floor((pos.x-math.floor(pos.x))*10))
ScriptLib.SetGroupVariableValue(context,"pos_z1",math.floor((pos.z-math.floor(pos.z))*10))
ScriptLib.PrintContextLog(context,"TMR: set pos ret = "..ret)
end
--读取联机玩法中当前球的位置
function LF_Load_Online_Temari_Pos(context)
local pos_x = ScriptLib.GetGroupVariableValue(context,"pos_x")
local pos_y = ScriptLib.GetGroupVariableValue(context,"pos_y")
local pos_z = ScriptLib.GetGroupVariableValue(context,"pos_z")
local pos_x1 = ScriptLib.GetGroupVariableValue(context,"pos_x1")/10
local pos_z1 = ScriptLib.GetGroupVariableValue(context,"pos_z1")/10
ScriptLib.PrintContextLog(context,"TMR: Load Temari pos: "..pos_x+pos_x1..","..pos_y..","..pos_z+pos_z1)
local pos = {x=pos_x+pos_x1,y=pos_y,z=pos_z+pos_z1}
return pos
end
--返回玩家是否至少藏了一次球
function LF_Has_Hidden_Ball(context)
if ScriptLib.GetGroupVariableValue(context,"has_hidden")==1 then
return true
else
return false
end
end
--返回当前整体玩法进度
--phase1单机挑战阶段
--phase2联机挑战阶段phase 2下刷新group不会再回到phase 1
function LF_Get_Play_Phase(context)
if (LF_Get_Challenge_State(context)<10) then
return 1
else
return 2
end
end
--返回当前(触发事件)的玩家是否是主机
function LF_Is_Host(context)
local uid_List = ScriptLib.GetSceneUidList(context)
local host_id = uid_List[1]
ScriptLib.PrintContextLog(context,"TMR: Current user id is "..context.uid)
ScriptLib.PrintContextLog(context,"TMR: Host user id is "..host_id)
return (host_id==context.uid) or (context.uid == 0)
end
--------------------------------------------------------------------
--server lua call---------------------------------------------------
--找球胜利通过球自身的ability调用调用时需要判定当前玩家主客机如果是主机则无事发生
function SLC_Find_Ball(context)
if LF_Get_Play_Phase(context) == 1 then
ScriptLib.PrintContextLog(context,"TMR: Player has found the ball!")
local curLevel = LF_Get_OfflineChallenge_Level(context)
ScriptLib.KillEntityByConfigId(context,{config_id = temari_gadgets[curLevel-2]})
LF_Stop_Challenge(context,0,1)
else
--联机情况下,判断挑战开启者和碰到球的是否是一个人,如果不是则无事发生
if (LF_Is_Same_Challenger(context)) then
ScriptLib.PrintContextLog(context,"TMR: Guest has found the ball!")
ScriptLib.KillEntityByConfigId(context,{config_id = defs.temari_online})
--成就相关,如果当前完成的玩家并不是主机,则发送一次成就完成的消息
if (not LF_Is_Host(context)) then
ScriptLib.MarkPlayerAction(context, 6018 , 3 , 1)
end
LF_Stop_Challenge(context,2,1)
end
end
return 0
end
--放球的server lua call被主机的E技能键调用
function SLC_Hide_Ball(context)
local avatar_id = ScriptLib.GetAvatarEntityIdByUid(context, context.uid)
local pos = ScriptLib.GetPosByEntityId(context, avatar_id)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.temari_online, {x=pos.x,y=pos.y+1,z=pos.z}, {x=0,y=0,z=0})
----存一下球的位置,马上要销毁掉
LF_Save_Online_Temari_Pos(context)
LF_Stop_Challenge(context,1,1)
LF_Online_Hide_Level(context)
--藏球后将藏球的标志置为1说明玩家至少藏了一次球
ScriptLib.SetGroupVariableValue(context,"has_hidden",1)
return 0
end
--------------------------------------------------------------------
Initialize()

View File

@ -0,0 +1,152 @@
--雷元素溢出洞口
--需求:
--1. 同group内的溢出洞口每经过时间randomTime发一次球
--2. 每次randomCount个洞口会发球
--[[
local defs = {
--GroupID
group_id = 240950005,
--控制挑战开始的操作机关configID
--starter_configID = ,
--随机时间轴。每个轴上数字间隔8~15秒,请人力随机
RandomTimeAxis = {
{2,18,38,56,81,99,115,133,148,165,180,196,211,235,257,276,300,315,330,349,367,383,400,416,431,449,471,487},
{1,17,36,53,69,89,109,134,158,173,197,213,231,249,264,289,305,324,347,362,385,407,429,453,473,491},
{2,19,42,61,85,104,128,146,167,190,209,232,255,271,288,307,327,348,368,393,412,430,455,477,500},
},
--配置每次几个洞口发球
random_thunderhole_sum = {
min = 1,
max = 3,
},
}
]]--
local define = {
gadgetList = {},
groupID = defs.group_id,
starter_configID = defs.starter_configID,
RandomTimeAxis = defs.RandomTimeAxis,
random_thunderhole_sum = defs.random_thunderhole_sum,
}
local extraTriggers={
initialtrigger =
{
--["Select_Option"] = { config_id = 8000001, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
["TimeAxis_Event"] = { config_id = 8000002, name = "TimeAxis_Event", event= EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_trigger_timeaxis", trigger_count = 0 },
--["Challenge_Fail"] = { config_id = 8000003, name = "Challenge_Fail", event= EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0 },
["GroupVariable_Change"] = { config_id = 8000003, name = "GroupVariable_Change", event= EventType.EVENT_VARIABLE_CHANGE, source = "challenge", condition = "", action = "action_group_variable_change", trigger_count = 0 },
--["GadgetState_Change"] = { config_id = 8000004, name = "GadgetState_Change", event= EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
--["Challenge_Success"] = { config_id = 8000005, name = "Challenge_Success", event= EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0 },
}
}
function LF_Initialize_Group(triggers, suites)
for k,v in pairs(extraTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
GetThunderHoleGadget(context)
return 0
end
--取得所有的溢出洞口
function GetThunderHoleGadget(context)
for k,v in pairs(gadgets) do
if v.gadget_id == 70330086 then
table.insert(define.gadgetList,v.config_id)
end
end
return 0
end
--[[function action_select_option(context, evt)
-- 判断是gadgetid starter_configID option_id 7
if evt.param1 == define.starter_configID then
if evt.param2 == 7 then
--所有溢出洞口物件切状态
for k,v in pairs(define.gadgetList) do
ScriptLib.SetGadgetStateByConfigId(context, v, 201)
end
--初始化时间轴
ScriptLib.InitTimeAxis(context, "shoot", define.RandomTimeAxis[math.random(#define.RandomTimeAxis)], true)
end
end
return 0
end
]]--
function action_trigger_timeaxis(context, evt)
RandomThunderHole(context, define.random_thunderhole_sum.min, define.random_thunderhole_sum.max)
return 0
end
-- 在suit中随机抽取randomCount个幸运物件让它们发球
function RandomThunderHole(context, minNum, maxNum)
math.randomseed(ScriptLib.GetServerTime(context))
randomNum = math.random(minNum, maxNum)
for i=1,randomNum do
if ScriptLib.GetGadgetStateByConfigId(context, define.groupID, define.gadgetList[i]) ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, define.gadgetList[i], 202)--物件切202发球后会自己切回201
end
end
return 0
end
--[[function action_gadget_state_change(context, evt)
if evt.param2 == define.starter_configID and evt.param1 == 0 then
--停止时间轴
ScriptLib.EndTimeAxis(context, "shoot")
--关闭未关闭的溢出洞口
StopAllGear(context)
else
--检查是不是关卡把洞口物件关了,如果关卡给关了,把时间轴停下
CheckThunderHoleState(context)
end
return 0
end]]--
function action_group_variable_change(context, evt)
--如果是开启挑战
if evt.param1 == 0 and evt.param2 == 1 then
--停止时间轴
ScriptLib.EndTimeAxis(context, "shoot")
--关闭未关闭的溢出洞口
StopAllGear(context)
end
--如果是结束挑战
if evt.param1 == 1 and evt.param2 == 0 then
--所有溢出洞口物件切状态
for k,v in pairs(define.gadgetList) do
ScriptLib.SetGadgetStateByConfigId(context, v, 201)
end
--初始化时间轴
ScriptLib.InitTimeAxis(context, "shoot", define.RandomTimeAxis[math.random(#define.RandomTimeAxis)], true)
end
return 0
end
function StopAllGear(context)
--所有溢出洞口物件停
for k,v in pairs(define.gadgetList) do
if ScriptLib.GetGadgetStateByConfigId(context, define.groupID, v) ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, v, 0)
end
end
return 0
end
function CheckThunderHoleState(context)
for i=1,#define.gadgetList do
if ScriptLib.GetGadgetStateByConfigId(context, define.groupID, define.gadgetList[i]) == 0 then
ScriptLib.EndTimeAxis(context, "shoot")
break
end
end
return 0
end
LF_Initialize_Group(triggers, suites)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
--- def参数
--- 描述长宽
--[[
defs = {
local defs = {
-- 该参数用来确认合法对子地板
FloorGadgetID = {70310062,70310063,70310064,70310065,70310087,70310088},
FloorNum = 8,

View File

@ -0,0 +1,560 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V2_2]
--[[
local defs = {
region_Enter = 191004,
region_Leave = 191006
Boss = 222,
}
-- DEFS_MISCS
local Pursina = {
{191001,191008},
{191002,191009},
{191003,191007},
}
]]
--[[ 陈列室的key
2.2__完成boss挑战 Activity_PursinaChallenge_watcher_1
2.2__完成且保持桩子血量 Activity_PursinaChallenge_watcher_2
2.2__n分钟内完成挑战 Activity_PursinaChallenge_watcher_3
2.2__完成且中断特殊技能n次 Activity_PursinaChallenge_watcher_4
2.2__完成且击倒少于n次 Activity_PursinaChallenge_watcher_5
2.2__累计击破弱点n次 Activity_PursinaChallenge_watcher_6
]]
local RMD_HP_LOW = {600077,600090,600091}
local LOWPOWER_SPEED = 0 --低电量充能速度(千分比)
local MEDIUMPOWER_SPEED = 5 --中电量充能速度(千分比)
local HIGHPOWER_SPEED = 10 --高电量充能速度(千分比)
local GALLERY_ID = defs.gallery_id
local CHALLENGEID = 2002007
local CHALLENGEID_CHILD = 2001007
local Operator_Config_id = 0
local Watcher_Condition = { --watcher的条件检测用
[1] = 1, --完成boss挑战【无用】
[2] = 50, --完成且保持所有桩子血量 填0~100
[3] = 180, --n秒内完成挑战 填秒数
[4] = 2, --完成且中断特殊技能n次 填次数
[5] = 2, --完成且击倒少于n次 填次数
[6] = 6, --已废弃
}
local temp_Variables = {
{ config_id=50000001,name = "IsFinished", value = 2, no_refresh = false }, --用于标识是否已完成未开始为2战斗中为0完成后变1.
{ config_id=50000002,name = "Boss_Enhance", value = 0, no_refresh = false }, --用于标识是否狂暴挑战开始时初始化为0其他时候由ServerLuaCall控制
{ config_id=50000003,name = "Active_Count", value = 0, no_refresh = false }, --用于表示当前运行中挖掘器数量。(0~3)
{ config_id=50000004,name = "test_quickFinish", value = 0, no_refresh = false }, --快速完成
{ config_id=50000005,name = "Boss_SetBattle", value = 0, no_refresh = false }, --快速完成
}
local Tirgger_Start = {
{ name = "1", config_id = 9000001, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "Finteract",trigger_count = 0},
{ name = "2", config_id = 9000002, event = EventType.EVENT_TIME_AXIS_PASS, source = "tick", condition = "", action = "tick",trigger_count = 0},
{ name = "3", config_id = 9000003, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "gallerytimeout",trigger_count = 0},
{ name = "4", config_id = 9000004, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "groupLoad",trigger_count = 0},
{ name = "5", config_id = 9000005, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "groupRefresh",trigger_count = 0},
{ name = "6", config_id = 9000006, event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "SetOptionToOperator",trigger_count = 0},
{ name = "7", config_id = 9000007, event = EventType.EVENT_LEAVE_REGION, source = "1", condition = "", action = "leaveRegion",trigger_count = 0},
{ name = "8", config_id = 9000008, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "gadgetDie",trigger_count = 0},
{ name = "9", config_id = 9000009, event = EventType.EVENT_TIME_AXIS_PASS, source = "watcher3", condition = "", action = "action_watcher3",trigger_count = 0},
{ name = "10", config_id = 9000010, event = EventType.EVENT_TIME_AXIS_PASS, source = "refreshgroup", condition = "", action = "action_refreshgroup",trigger_count = 0},
{ name = "11", config_id = 9000011, event = EventType.EVENT_VARIABLE_CHANGE, source = "IsFinished", condition = "condition_EndGameCheck", action = "action_EndGame",tag = "1000",trigger_count = 0},
{ name = "12", config_id = 9000012, event = EventType.EVENT_VARIABLE_CHANGE, source = "test_quickFinish", condition = "", action = "test_quickFinish",trigger_count = 0},
{ name = "13", config_id = 9000013, event = EventType.EVENT_VARIABLE_CHANGE, source = "Boss_SetBattle", condition = "", action = "action_Boss_SetBattle",trigger_count = 1},
{ name = "14", config_id = 9000014, event = EventType.EVENT_VARIABLE_CHANGE, source = "Active_Count", condition = "", action = "action_Active_Count",trigger_count = 0},
{ name = "15", config_id = 9000015, event = EventType.EVENT_ENTER_REGION, source = "1", condition = "", action = "enterRegion",trigger_count = 0},
{ name = "16", config_id = 9000016, event = EventType.EVENT_SCENE_MP_PLAY_ALL_AVATAR_DIE, source = "", condition = "", action = "action_ALL_AVATAR_DIE",trigger_count = 0},
{ name = "17", config_id = 9000017, event = EventType.EVENT_TIME_AXIS_PASS, source = "reminder", condition = "", action = "action_showReminder",trigger_count = 0},
{ name = "18", config_id = 9000018, event = EventType.EVENT_TIME_AXIS_PASS, source = "CreateBoss", condition = "", action = "action_CreateBoss",trigger_count = 0},
}
function action_CreateBoss(context,evt)
ScriptLib.PrintContextLog(context,"【[action_CreateBoss]】evt.param1 = ".. evt.param1)
local result = ScriptLib.CreateMonster(context, {config_id = defs.Boss, delay_time = 0})
ScriptLib.SetGadgetStateByConfigId(context, Pursina[1][1], GadgetState.Default)
ScriptLib.SetGadgetStateByConfigId(context, Pursina[2][1], GadgetState.Default)
ScriptLib.SetGadgetStateByConfigId(context, Pursina[3][1], GadgetState.Default)
if evt.param1 == 1 then
for k,v in pairs(gadgets) do
if v.gadget_id == 70800055 then
ScriptLib.CreateGadget(context,{config_id = v.config_id})
end
if v.gadget_id == 70800054 then
ScriptLib.SetWorktopOptionsByGroupId(context, ScriptLib.GetContextGroupId(context), v.config_id,{175})
ScriptLib.SetGroupTempValue(context,"Operator_Config_id",v.config_id,{})
end
end
end
ScriptLib.PrintContextLog(context,"【[action_CreateBoss]】result = " .. result)
return 0
end
function action_showReminder(context,evt)
ScriptLib.PrintContextLog(context,"【[action_showReminder]】")
ScriptLib.ShowReminder(context,600073)
return 0
end
function log_ActivityDig_2(context,result) --胜负结果 & 失败原因 埋点
ScriptLib.PrintContextLog(context,"【[log_ActivityDig_2]】"..result)
--埋点
local hp1=ScriptLib.GetGroupTempValue(context, "HP_1",{})
local hp2=ScriptLib.GetGroupTempValue(context, "HP_2",{})
local hp3=ScriptLib.GetGroupTempValue(context, "HP_3",{})
ScriptLib.MarkGroupLuaAction(context, "ActivityDig_2",ScriptLib.GetGalleryTransaction(context, GALLERY_ID) , {["result"] = result,["left_hp1"]=hp1,["left_hp2"]=hp2,["left_hp3"]=hp3})
return 0
end
function action_ALL_AVATAR_DIE(context,evt)
ScriptLib.PrintContextLog(context,"【[action_ALL_AVATAR_DIE]】")
log_ActivityDig_2(context,3)
return 0
end
function enterRegion(context,evt)
ScriptLib.PrintContextLog(context,"【[enterRegion]】")
if evt.param1 == defs.region_Enter then
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
end
return 0
end
function action_Active_Count(context,evt) --纯reminder 用 无逻辑
if defs.Boss ~= nil then
if evt.param1 == 2 and evt.param1 > evt.param2 then ScriptLib.ShowReminder(context,600081) end
if evt.param1 == 3 and evt.param1 > evt.param2 then ScriptLib.ShowReminder(context,600080) end
end
return 0
end
function action_Boss_SetBattle(context,evt)
local groupID = ScriptLib.GetContextGroupId(context)
--if defs.Boss ~= nil then ScriptLib.SetMonsterBattleByGroup(context, defs.Boss, groupID) end --LD负责通知进战
if defs.Boss ~= nil then
--给血量物件增加血量modifier
ScriptLib.PrintContextLog(context, "【[find3digger]】defs.Boss ~= nil")
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {Pursina[1][2]}, "Upgrade_HP", 1)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {Pursina[2][2]}, "Upgrade_HP", 1)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {Pursina[3][2]}, "Upgrade_HP", 1)
end
return 0
end
function test_quickFinish(context,evt)
finishPlay(context)
return 0
end
function condition_EndGameCheck(context,evt)
ScriptLib.PrintContextLog(context,"【onEndGameCheck】")
if evt.param1 == 1 then return true end
return false
end
function action_EndGame(context,evt)--只用来触发挑战,同时关gallery
ScriptLib.PrintContextLog(context,"【EndGame】")
ScriptLib.StopGallery(context,GALLERY_ID,true)
return 0
end
function action_refreshgroup(context,evt)
local groupID = ScriptLib.GetContextGroupId(context)
ScriptLib.RefreshGroup(context, { group_id = groupID, suite = init_config.suite})
return 0
end
function action_watcher3(context,evt)
ScriptLib.PrintContextLog(context, "【[action_watcher3]】")
ScriptLib.SetGroupTempValue(context,"watcher3",1,{})
return 0
end
function gadgetDie(context,evt)
ScriptLib.PrintContextLog(context, "【[gadgetDie]】")
for i = 1 , #Pursina do
if evt.param1 == Pursina[i][2] then
log_ActivityDig_2(context,1)
fail(context)
end
end
return 0
end
function leaveRegion(context,evt)
ScriptLib.PrintContextLog(context, "【[leaveRegion]】")
if evt.param1 == defs.region_Leave then
ScriptLib.PrintContextLog(context, "【[leaveRegion]】2")
ScriptLib.RevertPlayerRegionVision(context, context.uid)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
if ScriptLib.GetGroupVariableValue(context,"IsFinished") == 0 then --该then内为 未完成玩法时离开region时执行的操作
log_ActivityDig_2(context,4)
fail(context)
end
end
return 0
end
function fail(context) --离场、超时后执行。关tick、关gallery、标记玩法结束、refresh
ScriptLib.PrintContextLog(context, "【[fail]】")
ScriptLib.EndTimeAxis(context, "tick")
--标识回到未开始状态
ScriptLib.SetGroupVariableValue(context, "IsFinished", 2)
local groupID = ScriptLib.GetContextGroupId(context)
-- 停止标识为"looptime"的时间轴【LD需求】
ScriptLib.EndTimeAxis(context, "looptime")
ScriptLib.StopGallery(context,GALLERY_ID,false)
ScriptLib.EndFatherChallenge(context, CHALLENGEID)
--让他清理残留gadget
ScriptLib.SetEntityServerGlobalValueByConfigId(context, Operator_Config_id, "SGV_Try_Clean_Gadgets", 1.0)
ScriptLib.RefreshGroup(context, { group_id = groupID, suite = init_config.suite})
end
--gadget创建时如果是挑战操作台增加挑战选项。
function SetOptionToOperator(context,evt)
ScriptLib.PrintContextLog(context, "【[SetOptionToOperator]】")
if evt.param2 == 70350082 or evt.param2 == 70800055 then
ScriptLib.SetWorktopOptions(context, {175})
ScriptLib.SetGroupTempValue(context,"Operator_Config_id",evt.param1,{})
end
return 0
end
--设置挖掘桩的state为201、给他们创建血量物件、给他们创建billboard
function find3digger(context)
ScriptLib.PrintContextLog(context, "【[find3digger]】")
if Pursina == nil then ScriptLib.PrintContextLog(context, "【LD请注意】未在DEFS_MISCS中找到table:Pursina") end
for i = 1 , #Pursina do
ScriptLib.SetGadgetStateByConfigId(context, Pursina[i][1], GadgetState.GearStart)
ScriptLib.CreateGadget(context, {config_id = Pursina[i][2]})
ScriptLib.CreateGadget(context, {config_id = 888880 + i})
ScriptLib.InitGalleryProgressScore(context, "digProgress".. i - 1, GALLERY_ID, {0,100}, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_DIG,GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NONE)
ScriptLib.SetGroupTempValue(context, "FinishPursina_"..i,0,{})
end
return 0
end
function groupLoad(context,evt)
ScriptLib.PrintContextLog(context, "【[groupLoad]】")
ScriptLib.InitTimeAxis(context,"CreateBoss",{1},false)
return 0
end
function groupRefresh(context,evt)
ScriptLib.PrintContextLog(context, "【[groupRefresh]】[2021_7_29_171549]")
ScriptLib.EndTimeAxis(context, "refreshgroup")
ScriptLib.StopGallery(context,GALLERY_ID,false)
ScriptLib.EndFatherChallenge(context, CHALLENGEID)
ScriptLib.InitTimeAxis(context,"CreateBoss",{1},false)
return 0
end
function Finteract(context, evt)
if evt.param2 == 175 then
local groupID = ScriptLib.GetContextGroupId(context)
--boss专用:设置进战、初始化watcher
if defs.Boss ~= nil then
ScriptLib.PrintContextLog(context, "【[bOSS]1】")
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {defs.Boss}, "isFinalChallenge", 1)
ScriptLib.SetGroupTempValue(context,"watcher2",0,{})
ScriptLib.SetGroupTempValue(context,"watcher3",0,{}) --代表耗时是否能完成watcher
ScriptLib.InitTimeAxis(context, "watcher3", {Watcher_Condition[3]}, false) --限时watcher用
ScriptLib.SetGroupTempValue(context,"watcher4",0,{}) --代表中断特殊技能多少次
ScriptLib.SetGroupTempValue(context,"watcher5",0,{}) --代表boss被击倒多少次
ScriptLib.SetGroupTempValue(context,"watcher6",0,{}) --代表boss被击破弱点多少次
ScriptLib.SetEntityServerGlobalValueByConfigId(context, Pursina[1][1], "SGV_NeedCollider", 1.0)--打开ScenePropCollider激光用
ScriptLib.SetEntityServerGlobalValueByConfigId(context, Pursina[2][1], "SGV_NeedCollider", 1.0)--打开ScenePropCollider激光用
ScriptLib.SetEntityServerGlobalValueByConfigId(context, Pursina[3][1], "SGV_NeedCollider", 1.0)--打开ScenePropCollider激光用
end
--初始化LD用变量
ScriptLib.SetGroupVariableValue(context, "IsFinished", 0)
ScriptLib.SetGroupVariableValue(context, "Boss_Enhance", 0)
ScriptLib.SetGroupVariableValue(context, "Active_Count", 0)
--初始化TD用变量
ScriptLib.SetGroupTempValue(context,"FinishPursinaCount",0,{}) --已经挖完多少个
ScriptLib.SetGroupTempValue(context,"HP_1",100,{}) --初始血量1
ScriptLib.SetGroupTempValue(context,"HP_2",100,{}) --初始血量2
ScriptLib.SetGroupTempValue(context,"HP_3",100,{}) --初始血量3
ScriptLib.SetGroupTempValue(context,"Progress_To_Add_1",0,{}) --挖掘进度中转变量
ScriptLib.SetGroupTempValue(context,"Progress_To_Add_2",0,{}) --挖掘进度中转变量
ScriptLib.SetGroupTempValue(context,"Progress_To_Add_3",0,{}) --挖掘进度中转变量
-- 卸载操作台
if defs.Boss == nil then ScriptLib.SetGadgetStateByConfigId(context, evt.param1, GadgetState.GearStart) end
ScriptLib.DelWorktopOptionByGroupId(context, groupID, evt.param1, 175)
--gallery+challenge同开同关
local uid = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerStartGallery(context, GALLERY_ID, {uid[1]})
ScriptLib.CreateFatherChallenge(context,CHALLENGEID,CHALLENGEID,99999999, {success=1, fail=1,fail_on_wipe=false})
ScriptLib.StartFatherChallenge(context, CHALLENGEID)
ScriptLib.AttachChildChallenge(context,CHALLENGEID,CHALLENGEID_CHILD,CHALLENGEID_CHILD,{3,1000,1},{uid[1]},{success=1, fail=1})
--标记挖掘桩设置为201
find3digger(context)
-- 创建标识为"tick",时间节点为{1}的时间轴true用于控制该时间轴是否循环
ScriptLib.InitTimeAxis(context, "tick", {1}, true)
--5秒后显示reminder
ScriptLib.InitTimeAxis(context, "reminder", {6}, false)
end
return 0
end
function tick(context,evt)--每tick计算进度 "Progress_To_Add_"..i
local FinishPursina = {}
for i = 1, #Pursina do
FinishPursina[i] = ScriptLib.GetGroupTempValue(context,"FinishPursina_"..i,{})
if FinishPursina[i] ~= 1 then
local Progress_wait_for_Add = ScriptLib.GetGroupTempValue(context, "Progress_To_Add_"..i,{}) --取当前待增加进度
if Progress_wait_for_Add >= 10 then
local real_add = math.floor(Progress_wait_for_Add/10)
ScriptLib.AddGalleryProgressScore(context, "digProgress"..i-1, GALLERY_ID, real_add)
ScriptLib.SetGroupTempValue(context,"Progress_To_Add_"..i,Progress_wait_for_Add - real_add*10,{})
local nowProgress = ScriptLib.GetGalleryProgressScore(context,"digProgress".. i-1,GALLERY_ID)
if nowProgress >= 100 then
local groupID = ScriptLib.GetContextGroupId(context)
ScriptLib.SetGadgetStateByConfigId(context,Pursina[i][1], GadgetState.GearAction1)
ScriptLib.RemoveEntityByConfigId(context, groupID, EntityType.GADGET, Pursina[i][2])
ScriptLib.RemoveEntityByConfigId(context, groupID, EntityType.GADGET, 888880+i)
ScriptLib.SetGroupTempValue(context, "FinishPursina_"..i,1,{})
end
end
end
end
if FinishPursina[1] == 1 and FinishPursina[2] == 1 and FinishPursina[3] == 1 then
finishPlay(context)
end
return 0
end
function finishPlay(context)
ScriptLib.PrintContextLog(context, "【[finishPlay]】")
ScriptLib.EndTimeAxis(context, "tick")
local groupID = ScriptLib.GetContextGroupId(context)
--标识设为1
ScriptLib.SetGroupVariableValue(context, "IsFinished", 1)
-- 停止标识为"looptime"的时间轴【LD需求】
ScriptLib.EndTimeAxis(context, "looptime")
--让他清理残留gadget
if Operator_Config_id ~= 0 then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, Operator_Config_id, "SGV_Try_Clean_Gadgets", 1.0)
end
--中间操作台特效关掉
ScriptLib.SetGadgetStateByConfigId(context, ScriptLib.GetGroupTempValue(context,"Operator_Config_id",{}), GadgetState.GearStop)
--处理watcher
local uid = ScriptLib.GetSceneUidList(context)
local groupID = ScriptLib.GetContextGroupId(context)
if defs.Boss ~= nil then
--杀死boss
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {defs.Boss}, "Monster_Konungmathr_None_RealDie_Label", 1)
--2.2挖矿活动__完成
ScriptLib.AddExhibitionAccumulableData(context, uid[1], "Activity_PursinaChallenge_watcher_1",1)
--2.2挖矿活动__完成且所有光钉血量高于xx
if ScriptLib.GetGroupTempValue(context,"watcher2",{}) == 0 then
ScriptLib.AddExhibitionAccumulableData(context, uid[1], "Activity_PursinaChallenge_watcher_2", 1)
end
--2.2挖矿活动__特定时间内完成
local temp_result = ScriptLib.GetGroupTempValue(context,"watcher3",{})
if temp_result ~= 1 then
ScriptLib.AddExhibitionAccumulableData(context, uid[1], "Activity_PursinaChallenge_watcher_3", 1)
ScriptLib.PrintContextLog(context, "[通关成就]特定时间内完成")
end
--[[ --2.2挖矿活动__完成且中断特殊技能n次
local temp_result = ScriptLib.GetGroupTempValue(context,"watcher4",{})
ScriptLib.PrintContextLog(context, "[通关计数]中断特殊技能".. temp_result.. "")
if temp_result >= Watcher_Condition[4] then
ScriptLib.AddExhibitionAccumulableData(context, uid[1], "Activity_PursinaChallenge_watcher_4", 1)
end ]]
--2.2挖矿活动__完成且击倒boss不少于n次
local temp_result = ScriptLib.GetGroupTempValue(context,"watcher5",{})
ScriptLib.PrintContextLog(context, "[通关计数]击倒boss".. temp_result.. "")
if temp_result >= Watcher_Condition[5] then
ScriptLib.AddExhibitionAccumulableData(context, uid[1], "Activity_PursinaChallenge_watcher_5", 1)
end
--2.2挖矿活动__完成且未击倒boss
if temp_result == 0 then
ScriptLib.AddExhibitionAccumulableData(context, uid[1], "Activity_PursinaChallenge_watcher_4", 1)
end
--完成后等待一段时间refreshgroup
ScriptLib.InitTimeAxis(context, "refreshgroup", {15}, false)
else
ScriptLib.AddExhibitionAccumulableData(context, uid[1], "Activity_Pursina_Group_".. groupID,1)
ScriptLib.FinishGroupLinkBundle(context, groupID)
end
log_ActivityDig_2(context,0)
return 0
end
function gallerytimeout(context,evt)
ScriptLib.PrintContextLog(context, "【[gallerytimeout]】")
ScriptLib.PrintContextLog(context, "【[gallerytimeout]】evt.param1="..evt.param1)
ScriptLib.PrintContextLog(context, "【[gallerytimeout]】evt.param2="..evt.param2)
ScriptLib.PrintContextLog(context, "【[gallerytimeout]】GALLERY_ID="..GALLERY_ID)
if evt.param1 == GALLERY_ID and evt.param2 == 0 then
if evt.param3 == 1 then
ScriptLib.PrintContextLog(context, "【[gallerytimeout]】evt.param3="..evt.param3)
--埋点
log_ActivityDig_2(context,2)
end
fail(context)
end
return 0
end
function action_HPChange_1(context,evt)
ScriptLib.PrintContextLog(context, "【[action_HPChange_1]】")
ScriptLib.SetGroupTempValue(context,"HP_1",evt.param3,{})
if evt.param3 < 20 then ScriptLib.ShowReminder(context,RMD_HP_LOW[1]) end
if evt.param3 < Watcher_Condition[2] then ScriptLib.SetGroupTempValue(context,"watcher2",1,{}) end
return 0
end
function action_HPChange_2(context,evt)
ScriptLib.PrintContextLog(context, "【[action_HPChange_2]】")
ScriptLib.SetGroupTempValue(context,"HP_2",evt.param3,{})
if evt.param3 < 20 then ScriptLib.ShowReminder(context,RMD_HP_LOW[2]) end
if evt.param3 < Watcher_Condition[2] then ScriptLib.SetGroupTempValue(context,"watcher2",1,{}) end
return 0
end
function action_HPChange_3(context,evt)
ScriptLib.PrintContextLog(context, "【[action_HPChange_3]】")
ScriptLib.SetGroupTempValue(context,"HP_3",evt.param3,{})
if evt.param3 < 20 then ScriptLib.ShowReminder(context,RMD_HP_LOW[3]) end
if evt.param3 < Watcher_Condition[2] then ScriptLib.SetGroupTempValue(context,"watcher2",1,{}) end
return 0
end
--以下为ServerLuaCall函数。
function AddProgress_LowPower(context)
local configID = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
for i = 1 , #Pursina do
if configID ==Pursina[i][1] then
ScriptLib.ChangeGroupTempValue(context,"Progress_To_Add_"..i, LOWPOWER_SPEED,{})
end
end
return 0
end
function AddProgress_MediumPower(context)
local configID = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
for i = 1 , #Pursina do
if configID ==Pursina[i][1] then
ScriptLib.ChangeGroupTempValue(context,"Progress_To_Add_"..i, MEDIUMPOWER_SPEED,{})
end
end
return 0
end
function AddProgress_HighPower(context)
local configID = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
for i = 1 , #Pursina do
if configID ==Pursina[i][1] then
ScriptLib.ChangeGroupTempValue(context,"Progress_To_Add_"..i, HIGHPOWER_SPEED,{})
end
end
return 0
end
function LowPower(context)
ScriptLib.PrintContextLog(context, "【[LowPower]】")
local configID = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
ScriptLib.MarkGroupLuaAction(context, "ActivityDig_3",ScriptLib.GetGalleryTransaction(context, GALLERY_ID), {["Pursina_ID"] = configID,["change_type"]=4})
return 0
end
function MediumPower(context)
ScriptLib.PrintContextLog(context, "【[MediumPower]】")
local configID = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
ScriptLib.MarkGroupLuaAction(context, "ActivityDig_3",ScriptLib.GetGalleryTransaction(context, GALLERY_ID) , {["Pursina_ID"] = configID,["change_type"]=3})
return 0
end
function HighPower(context)
ScriptLib.PrintContextLog(context, "【[HighPower]】")
local configID = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
if defs.Boss ~= nil then ScriptLib.SetGroupVariableValue(context, "Boss_SetBattle", 1) end
ScriptLib.MarkGroupLuaAction(context, "ActivityDig_3",ScriptLib.GetGalleryTransaction(context, GALLERY_ID), {["Pursina_ID"] = configID,["change_type"]=2})
return 0
end
function SLC_ShowUI(context)
ScriptLib.PrintContextLog(context, "【[SLC_ShowUI]】")
local configID = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
for i = 1, #Pursina do
if Pursina[i][2] == configID then ScriptLib.CreateGadget(context, {config_id = 888880 + i}) end
end
return 0
end
function SLC_HideUI(context)
ScriptLib.PrintContextLog(context, "【[SLC_HideUI]】")
local configID = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
local groupID = ScriptLib.GetContextGroupId(context)
for i = 1, #Pursina do
if Pursina[i][2] == configID then ScriptLib.RemoveEntityByConfigId(context, groupID, EntityType.GADGET, 888880+i) end
end
return 0
end
function ServerLuaCall_Pursina_Start(context)--桩子物件用,用于当前激活桩子的计数,顺便埋个点
ScriptLib.ChangeGroupVariableValue(context, "Active_Count", 1)
ScriptLib.MarkGroupLuaAction(context, "ActivityDig_3",ScriptLib.GetGalleryTransaction(context, GALLERY_ID), {["Pursina_ID"] = configID,["change_type"]=1})
return 0
end
function ServerLuaCall_Pursina_End(context)--桩子物件用,用于当前激活桩子的计数
ScriptLib.ChangeGroupVariableValue(context, "Active_Count", -1)
return 0
end
function ServerLuaCall_Enhance_Start(context)--事件[Boss狂暴开始]供战斗组的ServerLuaCall调用
ScriptLib.SetGroupVariableValue(context, "Boss_Enhance", 1)
ScriptLib.ShowReminder(context,600083)
return 0
end
function ServerLuaCall_Enhance_End(context)--事件[Boss狂暴结束]供战斗组的ServerLuaCall调用
ScriptLib.SetGroupVariableValue(context, "Boss_Enhance", 0)
return 0
end
function watcher4_count(context)--事件[中断特殊技能]供战斗组的ServerLuaCall调用
ScriptLib.PrintContextLog(context, "【[watcher4_count]】")
ScriptLib.ChangeGroupTempValue(context, "watcher4", 1, {})
return 0
end
function watcher5_count(context)--事件[击倒]供战斗组的ServerLuaCall调用
ScriptLib.PrintContextLog(context, "【[watcher5_count]】")
ScriptLib.ChangeGroupTempValue(context, "watcher5", 1, {})
ScriptLib.ShowReminder(context,600078)
return 0
end
function watcher6_count(context)--事件[击破弱点]供战斗组的ServerLuaCall调用 【直接add陈列室因为不用局内计算 而是累计值】
ScriptLib.PrintContextLog(context, "【[watcher6_count]】")
local uid = ScriptLib.GetSceneUidList(context)
ScriptLib.AddExhibitionAccumulableData(context, uid[1], "Activity_PursinaChallenge_watcher_6", 1)
return 0
end
function ChargeBarChange(context)
ScriptLib.PrintContextLog(context, "【[ChargeBarChange]】")
return 0
end
function Initialize()
--加触发器
for k,v in pairs(Tirgger_Start) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(Pursina) do --根据桩子数量创建监控桩子血量的触发器
table.insert(triggers,{ name = "HP"..k, config_id = 8000000+k, event = EventType.EVENT_SPECIFIC_GADGET_HP_CHANGE, source = tostring(Pursina[k][2]), condition = "", action = "action_HPChange_"..k,trigger_count = 0})
table.insert(suites[1].triggers, "HP"..k)
end
--加变量
for k,v in pairs(temp_Variables) do
table.insert(variables,v)
end
--调整血量物件位置
for k,v in pairs(gadgets) do
for k2,v2 in pairs(Pursina) do
if v.config_id == v2[2] then
for k3,v3 in pairs(gadgets) do
if v3.config_id == v2[1] then v.pos = v3.pos end
end
end
end
if v.config_id == 70800055 then
v.server_global_value_config = {["SGV_Try_Clean_Gadgets"]= 0}
Operator_Config_id = 70800055
end
end
--加物件隐形billboard挂点
for k,v in pairs(gadgets) do
if v.gadget_id == 70800047 then
table.insert(gadgets , {config_id = 888881 , gadget_id = 70800050, pos = v.pos, rot = v.rot, level = v.level, area_id = v.area_id })
break
end
end
for k,v in pairs(gadgets) do
if v.gadget_id == 70800048 then
table.insert(gadgets , {config_id = 888882 , gadget_id = 70800051, pos = v.pos, rot = v.rot, level = v.level, area_id = v.area_id })
break
end
end
for k,v in pairs(gadgets) do
if v.gadget_id == 70800049 then
table.insert(gadgets , {config_id = 888883 , gadget_id = 70800052, pos = v.pos, rot = v.rot, level = v.level, area_id = v.area_id })
break
end
end
return 0
end
Initialize()

View File

@ -6,7 +6,7 @@
--怪物脱战时会在一系列表演之后发一个SLC_BossBattleResetgroup重置
]]
--[[
defs = {
local defs = {
--开启怪物用的特效gadget
gadget_starter = 275001,

View File

@ -4,7 +4,7 @@
--[[
defs = {
local defs = {
}
]]

View File

@ -10,7 +10,7 @@
--[[
defs = {
local defs = {
buff_gadget = ,
}

View File

@ -4,7 +4,7 @@
--[[
defs = {
local defs = {
group_id = ,

View File

@ -4,7 +4,7 @@
--[[
defs = {
local defs = {
group_id = 246101001,
--Boss目标点
target_points = {1004,1005,1006,1007,1008,1009,1010,1011,1012}

View File

@ -0,0 +1,586 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_3] ---
--[[
2.3
]]
--[[
local defs = {
group_id = ,
--触发开始/接续挑战的region此region在suite1
start_region_id = ,
--开始挑战后哪些suit要Add
challenge_suits =
{ 2 },
--挑战index
ChallengeIndex = 1001,
--开始小光柱
starting_point_id = 590040,
--玩法限定region出圈触发暂离此region在suite1
level_region_id = ,
--挑战id
challenge_id = 2003001,
--目标捕捉数
taget_score = 5,
--已捕捉数
exhibition_id = 5,
--狗和寻路点。格式为:[狗configid] = {startMarkFlag, endMarkFlag},
waypoint = {
[0000] = {1, 10},
[0000] = {11, 20},
}
}
]]
local extraTriggers={
{ config_id = 8000000, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 8000001,name = "Enter_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0 },
{ config_id = 8000002,name = "LeaveRegion_Region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0 },
--挑战计数trigger
{ config_id = 8000003, name = "Variable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "saved_progress", condition = "", action = "", trigger_count = 0 ,tag = "1000"},
{ config_id = 8000004,name = "Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0 },
{ config_id = 8000005, name = "Group_Refresh", event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0 },
{ config_id = 8000006, name = "Any_Monster_Die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0 },
{ config_id = 8000007, name = "Group_Will_Unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
{ config_id = 8000008,name = "Challenge_Fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0 },
--挑战暂离
{ config_id = 8000009,name = "Challenge_Pause", event = EventType.EVENT_CHALLENGE_PAUSE, source = "", condition = "", action = "action_challenge_pause", trigger_count = 0 },
--活动任务中,第一个潜行、战斗营地的首次挑战是由任务通知开启的
{ config_id = 8800001, name = "Quest_Notify_Challenge", event= EventType.EVENT_QUEST_FINISH, source = "4003109", condition = "", action = "action_quest4003109_notify", trigger_count = 0 },
{ config_id = 8800002, name = "Quest_Notify_Challenge2", event= EventType.EVENT_QUEST_FINISH, source = "4003103", condition = "", action = "action_quest4003103_notify", trigger_count = 0 },
}
--运营日志所需key都是累计值。
--作为groupTempVa在挑战开始时重置在挑战结束时上报。需求见单号 1286672
local log_enum = {
"found_times",--本次挑战中被狗子发现的次数 怪物SLC
"tool1_used_times",--本次挑战中使用潜行物件烟雾的次数 物件SLC
"tool2_used_times",--本次挑战中使用潜行物件诱饵的次数 物件SLC
"widget_times",--本次挑战中使用抓捕小道具的次数 小道具SLC
"capture_times"--本次挑战中抓到小动物的次数 小道具SLC
}
function 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 = "saved_progress", value = 0, no_refresh =true})
--挑战状态标记
table.insert(variables,{ config_id=50000002,name = "challenge_state", value = 0})
--路点状态标记
table.insert(variables,{ config_id=50000003,name = "waypoint_set", value = 0})
--最多4只动物 存活记录
table.insert(variables,{ config_id=50000004,name = "animal", value = 10000})
--第一个营地的挑战是否已通过任务正常开启(如果不是的话,接到第二次任务通知,要再开一次挑战)
table.insert(variables,{ config_id=50000005,name = "quest_done", value = 0, no_refresh =true})
end
function action_challenge_pause(context, evt)
UpLoadActionLog(context, evt.param_str1)
return 0
end
--处理小动物意外死亡 约定小动物都在Suit 5
function action_any_monster_die(context, evt)
if CheckIsInTable(context, evt.param1, suites[5].monsters) then
local exist_int = ScriptLib.GetGroupVariableValue(context, "animal")
local exist_table = LF_Split_Int(context, exist_int)
ScriptLib.PrintContextLog(context, "[HachiSneak] Try Set Animal. exist_int@"..exist_int)
local animal_index = GetIndexInTable(context, evt.param1, suites[5].monsters)
if exist_table[animal_index] == 0 then
local ret = ScriptLib.CreateMonster(context, { config_id = evt.param1, delay_time = 2 })
ScriptLib.PrintContextLog(context, "[HachiSneak] Reset animal@"..evt.param1.." ret@"..ret)
end
end
return 0
end
--Group一旦被卸载的保护
function action_group_will_unload(context,evt)
--清SGV
ScriptLib.PrintContextLog(context, "[HachiSneak] SGV_CAN_CLEAR_THREAT Set: 0")
local uidList = ScriptLib.GetSceneUidList(context)
if #uidList > 0 then
ScriptLib.SetTeamServerGlobalValue(context, uidList[1], "SGV_CAN_CLEAR_THREAT", 0)
--ScriptLib.SetTeamServerGlobalValue(context, uidList[1], "Hachi_IsInSmokeArea", 0)
end
--弹出暂离提示
--ScriptLib.PauseChallenge(context, defs.ChallengeIndex)
--如果正在挑战中,清挑战标记
if ScriptLib.GetGroupVariableValue(context, "challenge_state") == 1 then
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
end
return 0
end
function action_group_load(context, evt)
if defs.group_id == 133212590 then--首个潜行营地和任务耦合
PrepareStartPoint(context)
end
--LF_SetAnimal(context)
return 0
end
function action_group_refresh(context, evt)
if defs.group_id == 133212590 then--首个潜行营地和任务耦合
PrepareStartPoint(context)
end
return 0
end
--根据任务状态,是否显示常规潜行起点。 4003103任务状态为finished时开启黄点
function PrepareStartPoint(context)
if ScriptLib.GetGroupVariableValue(context, "challenge_state") == 2 then
return 0
end
if true == ScriptLib.CheckIsInMpMode(context) then
--ScriptLib.ShowReminder(context, 400053)
return 0
end
--此处不能通过get玩家questState来判断因为可能取不到玩家uid
if ScriptLib.GetGroupVariableValue(context, "quest_done") == 0 then
--隐藏黄点
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.starting_point_id, 201)
else
--显示黄点
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.starting_point_id, 0)
end
return 0
end
--狗潜行活动的挑战ability上给玩家挂一个onKill时执行的SLC
--关卡接到后检查任务状态如果标志任务4003103没完成则退出挑战状态
function SLC_PlayerDie_DuringQuest(context)
if ScriptLib.GetGroupVariableValue(context,"challenge_state") ~= 1 then
return 0
end
local quest_state = ScriptLib.GetQuestState(context, context.source_entity_id, 4003103)
if 3 ~= quest_state then
--允许再次接受任务通知
ScriptLib.SetGroupVariableValue(context, "quest_done", 0)
--恢复玩家SGV
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_CAN_CLEAR_THREAT", 0)
--ScriptLib.SetTeamServerGlobalValue(context, context.uid, "Hachi_IsInSmokeArea", 0)
--暂离挑战
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
--ScriptLib.StopChallenge(context,defs.challenge_id,1)
ScriptLib.PauseChallenge(context, defs.ChallengeIndex)
--处理黄点
--ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.starting_point_id, 0)
--移除开挑战时添加的suit
for k,v in pairs(defs.challenge_suits) do
ScriptLib.RemoveExtraGroupSuite(context, defs.group_id, v)
end
end
return 0
end
function LF_SetAnimal(context)
if #suites[5].monsters > 4 then
ScriptLib.PrintContextLog(context, "[HachiSneak] #WARN# Too Many Animal in Suit 5! Tell LD.")
return -1
end
local exist_int = ScriptLib.GetGroupVariableValue(context, "animal")
local exist_table = LF_Split_Int(context, exist_int)
ScriptLib.PrintContextLog(context, "[HachiSneak] Try Set Animal. exist_int@"..exist_int)
for i=1, #suites[5].monsters do
if exist_table[i] == 0 then
ScriptLib.CreateMonster(context, { config_id = suites[5].monsters[i], delay_time = 0 })
end
end
return 0
end
function LF_Split_Int(context, num)
local tb = {0,0,0,0}
for i=1, #tb do
tb[i] = num%10
num = math.floor(num/10)
end
return tb
end
function action_challenge_success(context, evt)
--任务通知
ScriptLib.AddQuestProgress(context, defs.group_id.."_finish")
--挑战标记
ScriptLib.SetGroupVariableValue(context, "challenge_state", 2)
--处理黄点
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.starting_point_id, GadgetState.GearStart)
--移除开挑战时添加的suit
for k,v in pairs(defs.challenge_suits) do
ScriptLib.RemoveExtraGroupSuite(context, defs.group_id, v)
end
--恢复玩家SGV
ScriptLib.PrintContextLog(context, "[HachiSneak] SGV_CAN_CLEAR_THREAT Set: 0")
local uidList = ScriptLib.GetSceneUidList(context)
if #uidList > 0 then
ScriptLib.SetTeamServerGlobalValue(context, uidList[1], "SGV_CAN_CLEAR_THREAT", 0)
--ScriptLib.SetTeamServerGlobalValue(context, uidList[1], "Hachi_IsInSmokeArea", 0)
end
UpLoadActionLog(context, evt.param_str1)
return 0
end
--常规流程不会有失败,做个保底
function action_challenge_fail(context,evt)
UpLoadActionLog(context, evt.param_str1)
--挑战标记
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
--处理黄点
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.starting_point_id, 0)
--恢复玩家SGV
ScriptLib.PrintContextLog(context, "[HachiSneak] SGV_CAN_CLEAR_THREAT Set: 0")
local uidList = ScriptLib.GetSceneUidList(context)
if #uidList > 0 then
ScriptLib.SetTeamServerGlobalValue(context, uidList[1], "SGV_CAN_CLEAR_THREAT", 0)
--ScriptLib.SetTeamServerGlobalValue(context, uidList[1], "Hachi_IsInSmokeArea", 0)
--移除开挑战时添加的suit
end
for k,v in pairs(defs.challenge_suits) do
ScriptLib.RemoveExtraGroupSuite(context, defs.group_id, v)
end
return 0
end
function ResetGroupTempVar(context)
for k,v in pairs(log_enum) do
ScriptLib.SetGroupTempValue(context, v,0,{})
end
return 0
end
--给狗分配路点。为了保证时序这个方法由怪物在ability准备好后调用只调用一次
function SetHachiWayPointGV(context)
if ScriptLib.GetGroupVariableValue(context, "waypoint_set") == 0 then
ScriptLib.SetGroupVariableValue(context, "waypoint_set", 1)
for k,v in pairs(defs.waypoint) do
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {k}, "_INU_SHIHANDAI_SEARCH_START" ,v[1])
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {k}, "_INU_SHIHANDAI_SEARCH_END" ,v[2])
local tmp = ScriptLib.GetEntityIdByConfigId(context, k)
ScriptLib.PrintContextLog(context, "[HachiSneak] Add GV: DogConfigID@"..k.." EntityID@"..tmp.." SEARCH_START@"..v[1].." SEARCH_END@"..v[2])
end
end
return 0
end
function action_quest4003109_notify(context,evt)
ScriptLib.PrintContextLog(context, "[HachiSneak] 4003109 Quest notify Challenge. UID@"..context.uid)
--不再接受任务通知
ScriptLib.SetGroupVariableValue(context, "quest_done", 1)
--处理开始挑战
--挑战标记
ScriptLib.SetGroupVariableValue(context, "challenge_state", 1)
ScriptLib.SetGroupVariableValue(context, "waypoint_set", 0)
ScriptLib.SetGroupTempValue(context, "player_uid", context.uid, {} )
--处理黄点
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.starting_point_id, 201)
local start_process = ScriptLib.GetGroupVariableValue(context,"saved_progress")
ScriptLib.PrintContextLog(context, "[HachiSneak] Start Challenge. ChallengeID@ "..defs.challenge_id.." TargetScore@".. defs.taget_score.." CurrentScore@"..start_process)
--参数1 event_type所在枚举序号 参数2 trigger_tag参数3 次数参数4Bool次数达成是否计为成功参数5初始次数值
ScriptLib.StartChallenge(context, defs.ChallengeIndex, defs.challenge_id, {3, 1000, defs.taget_score, 1, start_process})
--迭代后suite 5 的内容不通过addsuit来加由LF_SetAnimal管
for k,v in pairs(defs.challenge_suits) do
if k ~= 5 then
ScriptLib.AddExtraGroupSuite(context, defs.group_id, v)
ScriptLib.PrintContextLog(context, "[HachiSneak] Add Suit @"..v)
end
end
--安排动物
LF_SetAnimal(context)
--重置日志
ResetGroupTempVar(context)
return 0
end
function action_quest4003103_notify(context,evt)
ScriptLib.PrintContextLog(context, "[HachiSneak] 4003103 Quest notify Challenge. UID@"..context.uid)
if ScriptLib.GetGroupVariableValue(context, "quest_done") ~= 0 then
return 0
end
--不再接受任务通知
ScriptLib.SetGroupVariableValue(context, "quest_done", 1)
--处理开始挑战
--挑战标记
ScriptLib.SetGroupVariableValue(context, "challenge_state", 1)
ScriptLib.SetGroupVariableValue(context, "waypoint_set", 0)
ScriptLib.SetGroupTempValue(context, "player_uid", context.uid, {} )
--处理黄点
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.starting_point_id, 201)
local start_process = ScriptLib.GetGroupVariableValue(context,"saved_progress")
ScriptLib.PrintContextLog(context, "[HachiSneak] Start Challenge. ChallengeID@ "..defs.challenge_id.." TargetScore@".. defs.taget_score.." CurrentScore@"..start_process)
--参数1 event_type所在枚举序号 参数2 trigger_tag参数3 次数参数4Bool次数达成是否计为成功参数5初始次数值
ScriptLib.StartChallenge(context, defs.ChallengeIndex, defs.challenge_id, {3, 1000, defs.taget_score, 1, start_process})
--迭代后suite 5 的内容不通过addsuit来加由LF_SetAnimal管
for k,v in pairs(defs.challenge_suits) do
if k ~= 5 then
ScriptLib.AddExtraGroupSuite(context, defs.group_id, v)
ScriptLib.PrintContextLog(context, "[HachiSneak] Add Suit @"..v)
end
end
--安排动物
LF_SetAnimal(context)
--重置日志
ResetGroupTempVar(context)
return 0
end
function action_leave_region(context,evt)
if defs.level_region_id ~= evt.param1 then
return -1
end
if ScriptLib.GetGroupVariableValue(context, "challenge_state") ~= 1 then
return -1
end
--暂离挑战
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
--ScriptLib.StopChallenge(context,defs.challenge_id,1)
ScriptLib.PauseChallenge(context, defs.ChallengeIndex)
--处理黄点
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.starting_point_id, 0)
--移除开挑战时添加的suit
for k,v in pairs(defs.challenge_suits) do
ScriptLib.RemoveExtraGroupSuite(context, defs.group_id, v)
end
--恢复玩家SGV
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_CAN_CLEAR_THREAT", 0)
--ScriptLib.SetTeamServerGlobalValue(context, context.uid, "Hachi_IsInSmokeArea", 0)
return 0
end
function action_enter_region(context,evt)
--检查是不是起点区域
if defs.start_region_id ~= evt.param1 then
return -1
end
--检查前置任务 4003103任务状态不为finished时隐藏黄点不可踩region开挑战
local avatar_entity = ScriptLib.GetAvatarEntityIdByUid(context, context.uid)
if 3 ~= ScriptLib.GetQuestState(context, avatar_entity, 4003103) then
return -1
end
--检查联机
if true == ScriptLib.CheckIsInMpMode(context) then
ScriptLib.ShowReminder(context, 400053)
return -1
end
--检查挑战状态
if ScriptLib.GetGroupVariableValue(context, "challenge_state") ~= 0 then
return -1
else
--处理开始挑战
--挑战标记
ScriptLib.SetGroupVariableValue(context, "challenge_state", 1)
ScriptLib.SetGroupVariableValue(context, "waypoint_set", 0)
ScriptLib.SetGroupTempValue(context, "player_uid", context.uid, {} )
--处理黄点
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.starting_point_id, GadgetState.GearStart)
--读取进度
--local start_process = ScriptLib.GetGroupVariableValue(context,"saved_progress")
local start_process = ScriptLib.GetExhibitionAccumulableData(context, context.uid, defs.exhibition_id)
ScriptLib.PrintContextLog(context, "[HachiSneak] Start Challenge. ChallengeID@ "..defs.challenge_id.." TargetScore@".. defs.taget_score.." CurrentScore@"..start_process)
--参数1 event_type所在枚举序号 参数2 trigger_tag参数3 次数参数4Bool次数达成是否计为成功参数5初始次数值
ScriptLib.StartChallenge(context, defs.ChallengeIndex, defs.challenge_id, {3, 1000, defs.taget_score, 1, start_process})
--迭代后suite 5 的内容不通过addsuit来加由LF_SetAnimal管
for k,v in pairs(defs.challenge_suits) do
if v ~= 5 then
ScriptLib.AddExtraGroupSuite(context, defs.group_id, v)
ScriptLib.PrintContextLog(context, "[HachiSneak] Add Suit @"..v)
end
end
--安排动物
LF_SetAnimal(context)
--重置日志
ResetGroupTempVar(context)
end
return 0
end
--小动物被抓时,告诉关卡进度+1, 然后移除它并标记到GroupVar
function MonsterCallCaught(context)
if ScriptLib.GetGroupVariableValue(context, "challenge_state") ~= 1 then
ScriptLib.PrintContextLog(context, "[HachiSneak] #WARN# Challenge Not Open but Got Animal LuaCall!!")
return -1
end
local player_uid = ScriptLib.GetGroupTempValue(context, "player_uid", {})
ScriptLib.ChangeGroupTempValue(context, "capture_times", 1, {})
ScriptLib.ChangeGroupVariableValue(context,"saved_progress",1)
ScriptLib.AddExhibitionAccumulableData(context, player_uid, "Activity_Hachi_Group_"..defs.group_id, 1)
ScriptLib.PrintContextLog(context, "[HachiSneak] Exhibition Update. UID@"..player_uid.." key@".."Activity_Hachi_Group_"..defs.group_id)
--
local animal = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id })
LF_MarkAnimal(context,animal)
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.MONSTER, animal)
--ScriptLib.KillEntityByConfigId(context, { config_id = animal })
return 0
end
function LF_MarkAnimal(context,animal_id)
local animal_index = GetIndexInTable(context, animal_id, suites[5].monsters)
local mark = math.pow(10,animal_index-1)
ScriptLib.PrintContextLog(context, "[HachiSneak] Exhibition Update. animal_index@"..animal_index.." AnimalMark@"..mark)
ScriptLib.ChangeGroupVariableValue(context, "animal",mark)
return 0
end
--日志埋点 小道具使用次数
function HachiSneakWidgetUsed(context)
if ScriptLib.GetGroupVariableValue(context, "challenge_state") ~= 1 then
ScriptLib.PrintContextLog(context, "[HachiSneak] #WARN# Challenge Not Open but Got Widget LuaCall!!")
return -1
end
ScriptLib.PrintContextLog(context, "[HachiSneak] Widget Use!!")
ScriptLib.ChangeGroupTempValue(context, "widget_times", 1, {})
return 0
end
--用于记录本次挑战中被狗子发现的次数 日志埋点
function MonsterCallPlayerCaught(context)
if ScriptLib.GetGroupVariableValue(context, "challenge_state") ~= 1 then
return -1
end
ScriptLib.PrintContextLog(context, "[HachiSneak] Got PlayerCaught LuaCall!!")
ScriptLib.ChangeGroupTempValue(context, "found_times", 1, {})
return 0
end
--烟雾弹物件会serverLuaCall处理玩家清仇恨的SGV。清仇恨功能详见单子s1260223。
function SLC_SmokeClearThreat(context)
if ScriptLib.GetGroupVariableValue(context, "challenge_state") ~= 1 then
return -1
end
ScriptLib.PrintContextLog(context, "[HachiSneak] SGV_CAN_CLEAR_THREAT Set: 1")
local uidList = ScriptLib.GetSceneUidList(context)
if #uidList > 0 then
ScriptLib.SetTeamServerGlobalValue(context, uidList[1], "SGV_CAN_CLEAR_THREAT", 1)
end
return 0
end
--烟雾弹物件会serverLuaCall处理玩家清仇恨的SGV。清仇恨功能详见单子s1260223。
function SLC_SmokeSetThreat(context)
--[[if ScriptLib.GetGroupVariableValue(context, "challenge_state") ~= 1 then
return -1
end]]
ScriptLib.PrintContextLog(context, "[HachiSneak] SGV_CAN_CLEAR_THREAT Set: 0")
local uidList = ScriptLib.GetSceneUidList(context)
if #uidList > 0 then
ScriptLib.SetTeamServerGlobalValue(context, uidList[1], "SGV_CAN_CLEAR_THREAT", 0)
end
return 0
end
--上报运营日志数据
function UpLoadActionLog(context,transaction)
local log = {
["found_times"] = 0,--本次挑战中被狗子发现的次数 怪物SLC
["tool1_used_times"] = 0,--本次挑战中使用潜行物件烟雾的次数 物件SLC
["tool2_used_times"] = 0,--本次挑战中使用潜行物件诱饵的次数 物件SLC
["widget_times"] = 0,--本次挑战中使用抓捕小道具的次数 小道具SLC
["capture_times"] = 0--本次挑战中抓到小动物的次数 小道具SLC
}
for k, v in pairs(log) do
log[k] = ScriptLib.GetGroupTempValue(context, k ,{})
end
ScriptLib.MarkGroupLuaAction(context, "ActivityHachi_1", transaction, log)
ScriptLib.PrintContextLog(context, "[HachiSneak] UpLoadActionLog: "..log["found_times"].." |"..log["tool1_used_times"].." |"..log["tool2_used_times"].." |"..log["widget_times"].." |"..log["capture_times"])
return 0
end
function SLC_HachiGadgetActionMark(context,param1)
--["tool1_used_times"] = 0,--本次挑战中使用潜行物件烟雾的次数
--["tool2_used_times"] = 0,--本次挑战中使用潜行物件诱饵的次数
ScriptLib.PrintContextLog(context, "[HachiSneak] Got SLC_HachiGadgetActionMark @"..param1)
if param1 == 1 then
ScriptLib.ChangeGroupTempValue(context, "tool1_used_times", 1, {})
elseif param1 == 2 then
ScriptLib.ChangeGroupTempValue(context, "tool2_used_times", 1, {})
end
return 0
end
--用于检查value是否在目标table中
function CheckIsInTable(context,value,check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
function GetIndexInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return i
end
end
return 0
end
Initialize_Group(triggers, suites)

View File

@ -13,7 +13,7 @@
903
]]
--[[
defs = {
local defs = {
--galleryID
gallery_id = ,

View File

@ -6,7 +6,7 @@
--[[
defs = {
local defs = {
--按想要的解谜顺序, 填子装置的config_id
branch_gadgets = {117012, 117013, 117014},
--主装置的config_id,可填一个或多个

View File

@ -3,7 +3,7 @@
]]
--[[
defs = {
local defs = {
--挑战ID
challenge_id = ,

View File

@ -4,7 +4,7 @@
]]
--[[
defs = {
local defs = {
--战斗开始加载suit空气墙等
add_onStart = {2},
--开启流程的操作台configID

View File

@ -4,7 +4,7 @@
]]
--[[
defs = {
local defs = {
--战斗开始加载suit空气墙等
add_onStart = {2},
--开启流程的操作台configID

View File

@ -7,7 +7,7 @@
--[[
defs = {
local defs = {
gallery_id = ,

View File

@ -3,7 +3,7 @@
]]
--[[
defs = {
local defs = {
guide_regionID = [configID],
}
]]

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
box_gadget_id = 1,
point_array_id = 1,
option_id = 1,

View File

@ -1,4 +1,4 @@
--[[defs = {
--[[local defs = {
group_id = xxx,
gadget_prison_list = {1,2,3,4},
gadget_guide = {1,2,3},

View File

@ -0,0 +1,492 @@
--2.5换人挑战玩法
--ServerUploadTool Save to [/root/env/data/lua/common/V2_5]
--miscs配置内容
--[[
54
352
--fever进度升级节点
local fever_progress_table = {
0,40,120,270,570,800
}
--各等级fever的下降速率
local fever_attenuation = {
-1,-1,-2,-2,-3
}
--地城对应的天气配置
local DungeonWeather = {
10039,10040,10041,10042
}
--怪物潮
local monster_tide = {
[1] = {2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2048,2049,2050,2051},
[2] = {2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2052,2053,2054,2055},
[3] = {2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2056,2057,2058,2059},
[4] = {2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2056,2057,2058,2059},
[5] = {2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2056,2057,2058,2059},
}
local defs = {
group_id = 235801002,
worktop_id = 123, --操作台对应的操作数
air_wall = 2005, --场内空气墙对应的ConfigID
minion_fever = 5, --普通怪物死亡增加的热度值
game_time = 360, --挑战时间
min_monster_count = 5, --场上最少怪物数量
max_monster_count = 5, --场上最多怪物数量
environment_suite = 4, --环境灯光所在的Suite
noswitch_punishment_interval = 30, --不换人开始有惩罚的最小时间间隔
num_killed_per_tide = {20, 20, 20, 20, 0} --每组怪物潮对应需要的杀怪数量
}
--配置一个region,覆盖场内的战斗空间,用来在玩家进入时创建空气墙
]]
local local_defs = {
worktop_option = 30110,
progress_key = 1,
team_global_value = "FEVER_LEVEL",
team_noswitch_pubishment = "NOSWITCH_PUNISHMENT",
team_has_switch = "HAS_SWITCHED_TEAM",
burn_effect_level = 2,
environment_change_level = 1,
base_upgrade_reminder = 358010102,
team_noswitch_pubishment_reminder = 144,
punish_inAdvance_reminder = 201
}
local time_axis = {
--扣分时间轴,每秒掉一定的分数
fever_axis = {1},
noswitch_punishment_axis = {defs.noswitch_punishment_interval},
noswitch_punishment_inAdvance_axis = {defs.noswitch_punishment_interval-(defs.punish_inAdvance_reminder_time or 3)}
}
local Tri = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "select_option", config_id = 8000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[3] = { name = "time_axis_pass", config_id = 8000003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[4] = { name = "gallery_progress_pass", config_id = 8000004, event = EventType.EVENT_GALLERY_PROGRESS_PASS, source = "", condition = "", action = "action_gallery_progress_pass", trigger_count = 0},
[5] = { name = "monster_tide_die", config_id = 8000005, event = EventType.EVENT_MONSTER_TIDE_DIE, source = "", condition = "", action = "action_monster_tide_die", trigger_count = 0},
[6] = { name = "monster_die_before_leave_scene", config_id = 8000006, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[7] = { name = "gallery_stop", config_id = 8000007, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
[8] = { name = "sumo_switch_team", config_id = 8000008, event = EventType.EVENT_SUMO_SWITCH_TEAM_EVENT, source = "", condition = "", action = "action_sumo_switch_team", trigger_count = 0},
[9] = { name = "dungeon_all_avatar_die", config_id = 8000009, event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_dungeon_all_avatar_die", trigger_count = 0},
[10] = { name = "dungeon_settle", config_id = 8000010, event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_dungeon_settle", trigger_count = 0},
[11] = { name = "enter_start_region", config_id = 8000011, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_start_region", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for config_id,infos in pairs(monsters) do
table.insert(infos.affix, 9009)
end
table.insert(variables,{ config_id=50000001,name = "current_monster_tide", value = 0})
table.insert(variables,{ config_id=50000002,name = "current_elite", value = 1})
table.insert(variables,{ config_id=50000003,name = "fever_ratio", value = 1})
--用于记录当前是否开启不换队惩罚,用于客户端断线重连时恢复状态
table.insert(variables,{ config_id=50000004,name = "is_noswitch_punishment", value = 0})
--用于记录当前怪物潮中的击杀数量,当击杀数量达到配置数量时,加载下一波怪物潮
table.insert(variables,{ config_id=50000005,name = "num_current_minion_killed", value = 0})
--用于记录是否已经创建空气墙,防止玩家卡在空气墙外
table.insert(variables,{ config_id=50000006,name = "is_air_wall_created", value = 0})
--用于记录当前怪物潮是否处于切换状态
table.insert(variables,{ config_id=50000007,name = "is_tide_being_switched", value = 0})
end
------------------------------------------------------------------
--group load后加载操作台选项
function action_group_load(context,evt)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, defs.worktop_id, {local_defs.worktop_option})
--开场就直接加载氛围物件,不要等玩家开启挑战
--加载环境氛围物件
ScriptLib.AddExtraGroupSuite(context,defs.group_id, defs.environment_suite)
return 0
end
--按下操作台按键,启动玩法
function action_select_option(context,evt)
--如果空气墙没有提前创建,那么不会处理开始事件
if 1~= ScriptLib.GetGroupVariableValue(context,"is_air_wall_created") then
return -1
end
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, defs.worktop_id, local_defs.worktop_option)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.worktop_id, GadgetState.GearStop)
LF_Start_Play(context)
return 0
end
--时间轴tick事件根据tick的时间轴不同处理不同逻辑
function action_time_axis_pass(context,evt)
--纯数量刷怪不再走刷怪Tick
--fever条tick扣分
if (evt.source_name == "FEVER_AXIS") then
LF_Update_Fever(context,LF_Get_Fever_Subnum(context))
end
--提前显示一下需要换队
if (evt.source_name == "NOSWITCH_PUNISHMENT_INADVANCE_AXIS") then
ScriptLib.ShowTemplateReminder(context, local_defs.punish_inAdvance_reminder, {defs.punish_inAdvance_reminder_time or 3})
end
--不换队tick如果长时间不换队则将设置惩罚gv
if (evt.source_name == "NOSWITCH_PUNISHMENT_AXIS") then
ScriptLib.ShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {0})
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",1)
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,1)
end
return 0
end
--fever升级时给team挂global value并激活场景氛围物件
function action_gallery_progress_pass(context,evt)
local fever_level = evt.param1
ScriptLib.PrintContextLog(context,"FS: Fever uprade to level "..fever_level)
ScriptLib.ShowReminder(context, local_defs.base_upgrade_reminder+fever_level)
LF_Set_Team_Global_Value(context,local_defs.team_global_value,fever_level)
LF_Activate_Environment_Gadget(context,fever_level)
return 0
end
function action_gallery_stop(context,evt)
LF_Stop_Play(context)
return 0
end
--当前的怪物潮刷完的时候,重置当前的怪物潮或者刷下一波怪物潮
function action_monster_tide_die(context,evt)
-- ScriptLib.PrintContextLog(context,"FS: Tide Clear"..evt.param1)
-- local is_being_switched = ScriptLib.GetGroupVariableValue(context,"is_tide_being_switched")
-- ScriptLib.PrintContextLog(context,"FS: Tide Switch"..is_being_switched)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
local current_tide_list = monster_tide[current_monster_tide]
-- ScriptLib.PrintContextLog(context,"FS: Tide Max"..(#current_tide_list))
--不在刷够怪物切换怪物潮的过程中
--如果当前怪物潮已经被杀完了
if evt.param1 >= #current_tide_list then
if defs.num_killed_per_tide[current_monster_tide] == 0 then
LF_Refresh_Monster_Tide(context,"Current")
else
LF_Refresh_Monster_Tide(context,"Next")
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 fever_ratio = ScriptLib.GetGroupVariableValue(context,"fever_ratio")
local monster_fever = monsters[monster_cid].kill_score
LF_Update_Fever(context,monster_fever*fever_ratio)
LF_Update_Score(context,monster_eid)
return 0
end
function LF_Refresh_Monster_Tide(context, refresh_mode)
local current_monster_tide_index = LF_Get_Current_Monster_Tide(context)
-- ScriptLib.KillMonsterTide(context, defs.group_id, LF_Get_Current_Tide_Num(context))
-- ScriptLib.SetGroupVariableValue(context,"is_tide_being_switched",1)
if refresh_mode == "Current" then
LF_Set_Current_Monster_Tide(context, current_monster_tide_index)
LF_Create_Monster_Tide(context,current_monster_tide_index)
ScriptLib.PrintContextLog(context,"FS: Tide Clear Refresh Current")
end
if refresh_mode == "Next" then
LF_Set_Current_Monster_Tide(context, current_monster_tide_index + 1)
LF_Create_Monster_Tide(context,current_monster_tide_index + 1)
ScriptLib.PrintContextLog(context,"FS: Tide Clear Refresh Next")
end
-- LF_Set_Current_Tide_Minion_Killed(context,0)
-- ScriptLib.SetGroupVariableValue(context,"is_tide_being_switched",0)
end
--玩家换队时触发启动一个一定时间的时间轴时间轴tick时修改global value给玩家挂debuff
function action_sumo_switch_team(context,evt)
--刚刚换队先清掉team上的换队惩罚global value并开始计时如果tick时没有换队则挂上惩罚标记gv
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.EndTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS")
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
--清理换队提示
ScriptLib.EndTimeAxis(context,"NOSWITCH_PUNISHMENT_INADVANCE_AXIS")
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_INADVANCE_AXIS",time_axis.noswitch_punishment_inAdvance_axis,false)
--换队增加热情值
LF_Update_Fever(context,defs.switch_team_fever)
--换队的时候给服务端发送消息让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
--清除当前显示的换队惩罚的reminder
local uid_list = ScriptLib.GetSceneUidList(context)
local ret = ScriptLib.RevokePlayerShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {})
ScriptLib.RevokePlayerShowTemplateReminder(context, local_defs.punish_inAdvance_reminder, {})
ScriptLib.PrintContextLog(context,"FS: Clear reminder result"..ret)
--换队的时候修改team的gv重新刷一下新的avatar身上的加成效果
LF_Set_Team_Global_Value(context,local_defs.team_has_switch,1)
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",0)
return 0
end
--玩家进入区域直接创建空气墙,防止卡延迟出圈
function action_enter_start_region(context,evt)
--加载空气墙
ScriptLib.CreateGadget(context,{config_id = defs.air_wall})
ScriptLib.SetGroupVariableValue(context,"is_air_wall_created",1)
return 0
end
--团灭触发,直接结束玩法
function action_dungeon_all_avatar_die(context,evt)
LF_Stop_Play(context)
return 0
end
function action_dungeon_settle(context,evt)
LF_Stop_Play(context)
return 0
end
------------------------------------------------------------------
--辅助方法---------------------------------------------------------
------------------------------------------------------------------
--关卡相关方法-----------------------------------------------------
--启动玩法方法,初始化各种东西
function LF_Start_Play(context)
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.InitGalleryProgressScore(context, "fever", defs.gallery_id, fever_progress_table, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_SUMO_STAGE, GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NO_DEGRADE)
ScriptLib.InitTimeAxis(context,"FEVER_AXIS",time_axis.fever_axis,true)
LF_Set_Current_Tide_Num(context,0)
LF_Set_Current_Monster_Tide(context,1)
LF_Create_Monster_Tide(context,1)
--启动玩法时给第一队挂一下gv防止一开始就受到惩罚并开启时间轴开始计时
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_INADVANCE_AXIS",time_axis.noswitch_punishment_inAdvance_axis,false)
--玩法开始的时候给服务端发送消息让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
end
--终止玩法方法,关掉各种东西
function LF_Stop_Play(context)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
--清理一下空气墙,防止其他问题
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.GADGET, defs.air_wall)
--玩法结束,清理掉当前的怪物潮
ScriptLib.KillMonsterTide(context, defs.group_id, current_monster_tide)
ScriptLib.StopGallery(context, defs.gallery_id,true)
ScriptLib.EndTimeAxis(context,"FEVER_AXIS")
--关闭一下地城,以正确触发重新挑战
ScriptLib.CauseDungeonFail(context)
end
--启动一波指定ID的怪物潮需要传入该波怪物潮的ID具体配置在miscs中定义
function LF_Create_Monster_Tide(context,monster_tide_index)
ScriptLib.PrintContextLog(context,"FS: Creating monster tide ["..monster_tide_index.."]")
local monster_config_id_list = monster_tide[monster_tide_index]
--增加怪物潮的计数下一次开启时index会+1防止索引到同一波怪物潮
local tide_num = LF_Get_Current_Tide_Num(context)
LF_Set_Current_Tide_Num(context,tide_num+1)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
ScriptLib.AutoMonsterTide(context, tide_num+1, defs.group_id, monster_config_id_list, #monster_config_id_list, tide_suite_config[current_monster_tide].min, tide_suite_config[current_monster_tide].max)
end
--刷新指定
--通用类方法-------------------------------------------------------
--切换场上的场景氛围物件状态
function LF_Activate_Environment_Gadget(context,fever_level)
ScriptLib.PrintContextLog(context,"FS: Activate environment gadgets! Fever Level_"..fever_level)
--根据当前的fever等级改变天气
if (fever_level>local_defs.environment_change_level) then
ScriptLib.PrintContextLog(context,"FS: Changing environment weather!")
local ret = ScriptLib.SetWeatherAreaState(context, DungeonWeather[fever_level],1)
ScriptLib.PrintContextLog(context,"FS: The result of starting weather ".. DungeonWeather[fever_level].."is "..ret)
local ret = ScriptLib.EnterWeatherArea(context, DungeonWeather[fever_level])
ScriptLib.PrintContextLog(context,"FS: The result of changing weather".. DungeonWeather[fever_level].."is "..ret)
end
--切换场上所有的物件的状态
for i = 1, #suites[defs.environment_suite].gadgets do
local config_id = suites[defs.environment_suite].gadgets[i]
local gadget_id = LF_Get_Gadget_Id_By_Config_Id(context,config_id)
--大小火盆
if (gadget_id == 70350306 or gadget_id == 70350307) then
if (fever_level<local_defs.burn_effect_level) then
--点燃小火
--ScriptLib.PrintContextLog(context,"FS: Burn little fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 101)
end
if (fever_level<#fever_progress_table-2 and fever_level>=local_defs.burn_effect_level) then
--喷大火5秒后转回小火
--ScriptLib.PrintContextLog(context,"FS: Burn middle fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
if (fever_level >= #fever_progress_table-2) then
--持续喷大火
--ScriptLib.PrintContextLog(context,"FS: Burn super fire!")
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 202)
end
end
--挂灯
if (gadget_id == 70350308) then
if (fever_level>=local_defs.burn_effect_level) then
--点燃小火
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
end
--场景氛围
if (gadget_id == 70350309) then
--转到对应的gadgetStatedefault-0、phase1-201、phase2-202、phase3-203、phase4-204
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 200+fever_level)
end
end
end
--给team挂global value角色处理各种特殊效果
function LF_Set_Team_Global_Value(context,gv_name,value)
--ScriptLib.PrintContextLog(context,"FS: Sending global values to team!")
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, gv_name, value)
end
-----CRUD类方法----------------------------------------------------
--更新fever条fever_delta为fever条改变值
function LF_Update_Fever(context,fever_delta)
-- ScriptLib.PrintContextLog(context,"FS: Update Fever!")
ScriptLib.AddGalleryProgressScore(context, "fever", defs.gallery_id, fever_delta)
end
--更新积分需要传入目标monster的entity id
function LF_Update_Score(context,monster_eid)
-- ScriptLib.PrintContextLog(context,"FS: Update Score!")
local uid_list = ScriptLib.GetSceneUidList(context)
local monster_id = ScriptLib.GetMonsterIdByEntityId(context,monster_eid)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["monster_id"] = monster_id})
end
--返回当前等级下的积分衰减速率
function LF_Get_Fever_Subnum(context)
local fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
for i = 1, #fever_progress_table-1 do
local lower_bound = fever_progress_table[i]
local higher_bound = fever_progress_table[i+1]
if fever>=lower_bound and fever<higher_bound then
return fever_attenuation[i]
end
end
return -1
end
--设置当前怪物潮的波次数注意不等于怪物潮的index。每次创建怪物潮会使波次数+1方便索引新的怪物潮
function LF_Set_Current_Tide_Num(context,value)
ScriptLib.SetGroupTempValue(context, "MinionTide", value, {})
end
--获取当前怪物潮的波次数注意不等于怪物潮的index。每次创建怪物潮会使波次数+1方便索引新的怪物潮
function LF_Get_Current_Tide_Num(context)
return ScriptLib.GetGroupTempValue(context, "MinionTide", {})
end
--设置当前怪物潮波次的index
function LF_Set_Current_Monster_Tide(context,index)
ScriptLib.SetGroupVariableValue(context,"current_monster_tide",index)
end
--获取当前怪物潮波次的index
function LF_Get_Current_Monster_Tide(context)
local monster_tide = ScriptLib.GetGroupVariableValue(context,"current_monster_tide")
return monster_tide
end
--2.5新增
--获取当前怪物潮的击杀数量
function LF_Get_Current_Tide_Minion_Killed(context)
local num_minion_killed = ScriptLib.GetGroupVariableValue(context,"num_current_minion_killed")
return num_minion_killed
end
--增加当前怪物潮的击杀数量
function LF_Add_Current_Tide_Minion_Killed(context, num)
ScriptLib.ChangeGroupVariableValue(context,"num_current_minion_killed",num)
end
--设置当前怪物潮的击杀数量
function LF_Set_Current_Tide_Minion_Killed(context, num)
ScriptLib.SetGroupVariableValue(context,"num_current_minion_killed", num)
end
--根据gadget的config_id查询gadget_id
function LF_Get_Gadget_Id_By_Config_Id(context, config_id)
return gadgets[config_id].gadget_id
end
------------------------------------------------------------------
--server lua call-------------------------------------------------
function SLC_Update_Fever_Ratio(context,new_fever_ratio)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Changing fever ratio to: "..new_fever_ratio)
ScriptLib.SetGroupVariableValue(context,"fever_ratio",new_fever_ratio)
return 0
end
--向客户端下发当前的惩罚状态和fever值用于客户端重连时请求
function SLC_Refresh_Team_State(context)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Request for refresh punishment state: ")
local is_noswitch_punishment = ScriptLib.GetGroupVariableValue(context,"is_noswitch_punishment")
LF_Set_Team_Global_Value(context,"NOSWITCH_PUNISHMENT",is_noswitch_punishment)
local fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
LF_Set_Team_Global_Value(context,"fever",fever)
return 0
end
------------------------------------------------------------------
Initialize()

View File

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

View File

@ -0,0 +1,156 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V2_5]
--[[
=====================================================================================================================
|| Filename || RecircleChallenge
|| RelVersion || 2.5
|| Owner || xudong.sun
|| Description || 2.5
|| LogName || ## RC_LOG
|| Protection || group卸载时清空怪物
=====================================================================================================================
-- local defs = {
-- --groupID
-- groupID = 177006001,
-- --挑战操作台
-- challenge_gadget = 1006,
-- --挑战时间
-- duration = 240,
-- --出范围失败region
-- regionID = 1008,
-- --挑战ID
-- challengeID = 111195,
-- --怪物列表
-- monster_array = {1001,1002,1003,1004,1005},
-- monster_min = 5,
-- monster_max = 5,
-- monster_count = 5
-- }
=======================================================================================]]
local extrTriggers = {
initialtrigger = {
["Interact_Dwon"] = { config_id = 80000002, name = "Interact_Dwon", event= EventType.EVENT_MICHIAE_INTERACT, source = "", condition = "", action = "action_InteractDwon", trigger_count = 0 },
["Challenge_Success"] = { config_id = 80000003, name = "Challenge_Success", event= EventType.EVENT_CHALLENGE_SUCCESS, source = "233", condition = "", action = "action_ChallengeSuccess", trigger_count = 0 },
["Challenge_Fail"] = { config_id = 80000004, name = "Challenge_Fail", event= EventType.EVENT_CHALLENGE_FAIL, source = "233", condition = "", action = "action_ChallengeFail", trigger_count = 0 },
["Group_Unload"] = { config_id = 80000005, name = "Group_Unload", event= EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_GroupUnload", trigger_count = 0 },
["Leave_Region"] = { config_id = 80000006, name = "Leave_Region", event= EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_LeaveRegion", trigger_count = 0,forbid_guest = false },
["Group_Refresh"] = { config_id = 80000007, name = "Group_Refresh", event= EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_GroupRefresh", trigger_count = 0 },
}
}
--local challengeID = 0
--local groupID = 1
--local switchGadgetID = 1
local challengeRange = 50
function LF_GetPointDistance(x1,y1,x2,y2)
return math.sqrt(math.pow((y2-y1),2)+math.pow((x2-x1),2))
end
function action_LeaveRegion( context, evt)
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR })~=0 then
return 0
end
ScriptLib.KillMonsterTide(context, defs.groupID, 1)
ScriptLib.StopChallenge(context, 233, 0)
return 0
end
function action_GroupRefresh( context, evt )
ScriptLib.PrintContextLog(context,"RC_LOG: Group Refresh")
ScriptLib.SetGroupTempValue(context, "ChallengeMode", 0, {})
return 0
end
function action_GroupUnload( context, evt)
ScriptLib.PrintContextLog(context,"RC_LOG: Group Unload")
ScriptLib.SetGroupTempValue(context, "ChallengeMode", 0, {})
if ScriptLib.GetGadgetStateByConfigId(context, defs.groupID, defs.challenge_gadget) == 202 then
return 0
end
ScriptLib.SetGadgetStateByConfigId(context, defs.challenge_gadget, 0)
ScriptLib.KillMonsterTide(context, defs.groupID, 1)
return 0
end
function action_InteractDwon( context, evt )
ScriptLib.PrintContextLog(context,"RC_LOG: ChallengeMode = "..ScriptLib.GetGroupTempValue(context, "ChallengeMode", {}))
if evt.param1 ~= 2 then
return 0
end
if ScriptLib.GetGroupTempValue(context, "ChallengeMode", {}) ~=0 then
return 0
end
ScriptLib.PrintContextLog(context,"RC_LOG: Start Challenge")
ScriptLib.StartChallenge(context, 233, defs.challengeID,{defs.duration,defs.groupID,defs.monster_count})
--ScriptLib.ActiveChallenge(context, 233, defs.challengeID, defs.duration, defs.groupID, defs.monster_count, 0 )
ScriptLib.SetGadgetStateByConfigId(context, defs.challenge_gadget, 201)
ScriptLib.AutoMonsterTide(context, 1, defs.groupID, defs.monster_array, defs.monster_count, defs.monster_min, defs.monster_max)
ScriptLib.SetGroupTempValue(context, "ChallengeMode", 1, {})
return 0
end
function action_ChallengeSuccess( context, evt )
ScriptLib.SetGroupTempValue(context, "ChallengeMode", 0, {})
ScriptLib.KillMonsterTide(context, defs.groupID, 1)
ScriptLib.updateBundleMarkShowStateByGroupId(context, defs.groupID, false)
ScriptLib.SetGadgetStateByConfigId(context, defs.challenge_gadget, 202)
return 0
end
function action_ChallengeFail( context, evt )
ScriptLib.SetGroupTempValue(context, "ChallengeMode", 0, {})
ScriptLib.SetGadgetStateByConfigId(context, defs.challenge_gadget, 0)
ScriptLib.KillMonsterTide(context, defs.groupID, 1)
return 0
end
function LF_Initialize_Group()
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Group()

View File

@ -0,0 +1,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,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

@ -14,7 +14,7 @@
--[[
-- Trigger变量
defs = {
local defs = {
group_id = 245002001,
gear_group_id = 245002002,
route_guide_timer = 5,

View File

@ -15,7 +15,7 @@
--[[
-- Trigger变量
defs = {
local defs = {
group_id = 245002002,
fundation_id = 70350145,
challange_group_id = 245002001,

View File

@ -15,7 +15,7 @@
--编辑器配置
--[[
defs = {
local defs = {
group_id = 245002003,
gear_group_id = 245002002
}

View File

@ -15,7 +15,7 @@
--[[
-- Trigger变量
defs = {
local defs = {
group_id = 245002013,
challenge_group_id = 245002001,
close_cd = 5,

View File

@ -0,0 +1,498 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V2_7]
--======================================================================================================================
--|| Filename || Activity_LumenCharge
--|| RelVersion || V2_7
--|| Owner || chao-jin
--|| Description ||
--|| LogName || ##[Activity_LumenCharge]
--|| Protection ||
--======================================================================================================================
--[[Defs & Miscs
local defs = {
challenge_time = 300,
pursina = 581032,
pursina_tip = 581105,
muds_lv1 = {581066,581067,581068,581069,581070,581071},
muds_lv2 = {581014,581016},
score_lv1 = 3,
score_lv2 = 6,
fail_region = 581197,
}
local extra_info = {
start_operator = 581002,
lantern = 581011,
}
local mud_list = {
--普通黑泥
[581016] = { mud_id = 581009, cover_list= {}, respawn_time = 8, mutex_id = 0, score = 6, cover_content = {} },
[581014] = { mud_id = 581008, cover_list= {}, respawn_time = 8, mutex_id = 0, score = 6, cover_content = {} },
--黑泥核心1
[581066] = { mud_id = 581082, cover_list= {581094}, respawn_time = 4, mutex_id = 581067, score = 3,
cover_content = {
[1] = {581025},
[2] = {581033},
[3] = {581051},
[4] = {581079},
[5] = {581123},}
},
--黑泥核心2
[581068] = { mud_id = 581081, cover_list= {581095,581096}, respawn_time = 4, mutex_id = 581071, score = 3,
cover_content = {
[1] = {581020,581026},
[2] = {581049,581044},
[3] = {581054,581055},
[4] = {581108,581080},
[5] = {581127,581124},}
},
--黑泥核心3
[581069] = { mud_id = 581083, cover_list= {581093}, respawn_time = 4, mutex_id = 581070, score = 3,
cover_content = {
[1] = {581022},
[2] = {581045},
[3] = {581099},
[4] = {581098},
[5] = {581125},}
},
--黑泥核心4
[581067] = {mud_id = 581084, cover_list = {581091, 581092}, respawn_time = 6, mutex_id = 581066, score = 3,
cover_content = {
[1] = {581031,581036},
[2] = {581053,581046},
[3] = {581056,581100},
[4] = {581101,581113},
[5] = {581126,581128},},
},
--黑泥核心5
[581070] = {mud_id = 581085, cover_list = {581087, 581088}, respawn_time = 6, mutex_id = 581069, score = 3,
cover_content = {
[1] = {581029,581039},
[2] = {581047,581048},
[3] = {581102,581103},
[4] = {581115,581116},
[5] = {581129,581130},},
},
--黑泥核心6
[581071] = {mud_id = 581086, cover_list = {581017,581019,581089, 581090}, respawn_time = 6, mutex_id = 581068, score = 3,
cover_content = {
[1] = {581040,581041,581042,581043},
[2] = {581052,581058,581059,581050},
[3] = {581104,581106,581057,581076},
[4] = {581078,581119,581118,581117},
[5] = {581122,581131,581132,581139},},
},
}
--====================================================================================================================]]
--======================================================================================================================
local LumenCharge_Triggers = {
{ config_id = 9100401, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
{ config_id = 9100402, name = "add_charge_progress", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "condition_add_charge_progress", action = "", trigger_count = 0, tag = "1001" },
{ config_id = 9100403, name = "variable_change", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", trigger_count = 0,},
{ config_id = 9100404, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0,},
{ config_id = 9100405, name = "challenge_success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0,},
{ config_id = 9100406, name = "challenge_fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0,},
{ config_id = 9100407, name = "any_gadget_die", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0},
{ config_id = 9100408, name = "leave_fail_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_fail_region", trigger_count = 0},
{ config_id = 9100409, name = "time_axis_pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
}
--Events
--Group加载时处理内容
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context,"##[LumenCharge]:加载Group")
ScriptLib.ActivateGroupLinkBundle(context, base_info.group_id)
LF_ResetAllValues(context)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, extra_info.start_operator, {7})
return 0
end
--处理进度计数,当能量增加时增加进度
function condition_add_charge_progress(context, evt)
if evt.source_name == "energy" and evt.param1 ~= 0 then
return true
end
return false
end
--处理能量进度变化时的进度显示
function action_variable_change(context, evt)
if evt.source_name == "energy" then
--充能进度10%刷怪
if evt.param1 == 10 then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:刷新第1波怪")
ScriptLib.ChangeGroupVariableValue(context, "stage", 1)
ScriptLib.ShowReminder(context, 4000144)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 5)
ScriptLib.CreateGadget(context, {config_id = defs.enemy_gadget})
-- ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, 9)
end
--充能进度35%刷怪
if evt.param1 == 35 then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:刷新第2波怪")
ScriptLib.ChangeGroupVariableValue(context, "stage", 1)
ScriptLib.ShowReminder(context, 4000144)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 6)
-- ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, 11)
end
--充能进度60%刷怪
if evt.param1 == 60 then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:刷新第3波怪")
ScriptLib.ChangeGroupVariableValue(context, "stage", 1)
ScriptLib.ShowReminder(context, 4000144)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 7)
-- ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, 13)
end
--充能进度85%刷怪
if evt.param1 == 85 then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:刷新第4波怪")
ScriptLib.ChangeGroupVariableValue(context, "stage", 1)
ScriptLib.ShowReminder(context, 4000144)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 17)
-- ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, 15)
--移除BGM物件
if 0 ~= ScriptLib.GetEntityIdByConfigId(context, defs.enemy_gadget) then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:移除BGM物件")
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.enemy_gadget)
end
end
end
return 0
end
--玩家与操作台交互
function action_select_option(context, evt)
if extra_info.start_operator ~= evt.param1 then
return 0
end
LF_ResetAllValues(context)
ScriptLib.PrintContextLog(context,"##[LumenCharge]:开启挑战")
ScriptLib.CreateFatherChallenge(context, 1, 2009007, defs.challenge_time, {success = 10, fail = 5})
ScriptLib.AttachChildChallenge(context, 1, 2009009, 2009009, { defs.challenge_time, 3, 1002, 100},{},{success = 1,fail = 1})
ScriptLib.AttachChildChallenge(context, 1, 2009010, 2009010, { defs.challenge_time, 3, 1003, 100},{},{success = 1,fail = 1})
ScriptLib.AttachChildChallenge(context, 1, 2009008, 2009008, { defs.challenge_time, 3, 1001, 100},{},{success = 10,fail = 5})
ScriptLib.StartFatherChallenge(context,1)
--启动reminder开灯
ScriptLib.ShowReminder(context, 4000143)
ScriptLib.SetGadgetStateByConfigId(context, extra_info.lantern, GadgetState.GearStart)
--刷新黑泥对应Group
ScriptLib.AddExtraGroupSuite(context, 166001581, 2)
ScriptLib.AddExtraGroupSuite(context, 166001581, 3)
ScriptLib.AddExtraGroupSuite(context, 166001581, 4)
--处理光钉,启动,嘲讽
LF_StartPursina(context)
LF_SetPursinaMidSpeed(context)
--开启充能进度时间轴
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, extra_info.start_operator, 7)
ScriptLib.InitTimeAxis(context, "energyBasic", {2}, true)
return 0
end
--玩家距离过远挑战失败
function action_leave_fail_region(context, evt)
if evt.param1 == defs.fail_region then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:玩家脱离战斗区域,手动结束挑战")
ScriptLib.StopChallenge(context, 1, 0)
end
return 0
end
--处理时间轴
function action_time_axis_pass(context, evt)
--充能的时间轴
if evt.source_name == "energyBasic" then
--增加进度
ScriptLib.ChangeGroupVariableValue(context, "energy", 1)
end
--黑泥重生的时间轴
local core_id = tonumber(evt.source_name)
if core_id ~= nil then
if mud_list[core_id] ~= nil then
--普通黑泥,没有互斥,直接创生核心和黑泥
if mud_list[core_id].mutex_id == 0 then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:[普通黑泥]时间轴触发")
LF_CreateMudSet(context, core_id)
else
--核心黑泥
--互斥黑泥不存在
if 0 == ScriptLib.GetEntityIdByConfigId(context, mud_list[core_id].mutex_id) then
LF_CreateMudSet(context, core_id)
ScriptLib.EndTimeAxis(context, tostring(core_id))
ScriptLib.PrintContextLog(context,"##[LumenCharge]:[核心黑泥]复活完成,关闭自身时间轴")
else
--互斥黑泥存在
ScriptLib.PrintContextLog(context,"##[LumenCharge]:[核心黑泥]互斥黑泥存在,此次不刷新"..(mud_list[core_id].mutex_id ))
return 0
end
end
end
end
return 0
end
--处理黑泥死亡,加进度,计入统计
function action_any_gadget_die(context,evt)
if not ScriptLib.IsChallengeStartedByChallengeId(context, 2009007) then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:挑战未開啟,不處理")
return 0
end
local core_id = evt.param1
--确定死亡的是黑泥核心
if mud_list[core_id] ~= nil then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:增加清除黑泥的总计数")
ScriptLib.ChangeGroupTempValue(context, "MUD_REMOVED", 1, {})
if 1 ~= ScriptLib.GetGroupTempValue(context, "PURSINA_WORKING", {}) then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:光钉损坏中,清除黑泥不增加进度")
else
ScriptLib.PrintContextLog(context,"##[LumenCharge]:清除黑泥,增加进度")
for i=1,mud_list[core_id].score do
ScriptLib.ChangeGroupVariableValue(context, "energy", 1)
end
end
--移除黑泥对应的组件
LF_RemoveMudSet(context,core_id)
if mud_list[core_id].mutex_id == 0 then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:创建普通黑泥复生时间轴")
ScriptLib.InitTimeAxis(context, tostring(core_id), {mud_list[core_id].respawn_time}, false)
else
ScriptLib.PrintContextLog(context,"##[LumenCharge]:创建核心黑泥复生时间轴")
ScriptLib.InitTimeAxis(context, tostring(core_id), {mud_list[core_id].respawn_time}, true)
end
end
return 0
end
--处理挑战成功
function action_challenge_success(context, evt)
if evt.param1 ~= 2009007 then
return 0
end
ScriptLib.PrintContextLog(context,"##[LumenCharge]:总挑战成功")
--处理运营数据
local transaction = evt.param_str1
local used_time = defs.challenge_time - evt.param2
local remove_mud = ScriptLib.GetGroupTempValue(context, "MUD_REMOVED", {})
local lumen_level = ScriptLib.GetTeamServerGlobalValue(context, context.owner_uid, "SGV_Light_Stone_Level")
ScriptLib.PrintContextLog(context,"##[LumenCharge]:埋点数据, 挑战成功,流水号"..transaction.."耗时"..used_time.."清除黑泥总数"..remove_mud.."流明石等级"..lumen_level)
ScriptLib.MarkGroupLuaAction(context, "Luminous_challenge_2", transaction, {["challenge_id"] = 2009007,["end_reason"] = 1,["use_time"]= used_time ,["remove_mud"]= remove_mud,["luminous_level"] = lumen_level})
--Group流转
LF_ClearGroup(context)
--跳转到EndSuite
ScriptLib.GoToGroupSuite(context, base_info.group_id, 16)
ScriptLib.TryFinishLuminanceStoneChallengeStage(context, base_info.group_id)
ScriptLib.FinishGroupLinkBundle(context, base_info.group_id)
return 0
end
--处理挑战失败
function action_challenge_fail(context, evt)
if evt.param1 ~= 2009007 then
return 0
end
ScriptLib.PrintContextLog(context,"##[LumenCharge]:总挑战失败")
--处理运营数据
local transaction = evt.param_str1
local used_time = defs.challenge_time - evt.param2
local remove_mud = ScriptLib.GetGroupTempValue(context, "MUD_REMOVED", {})
local lumen_level = ScriptLib.GetTeamServerGlobalValue(context, context.owner_uid, "SGV_Light_Stone_Level")
if evt.param2 <= 0 then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:埋点数据,时间用尽,流水号"..transaction.."耗时"..used_time.."清除黑泥总数"..remove_mud.."流明石等级"..lumen_level)
ScriptLib.MarkGroupLuaAction(context, "Luminous_challenge_2", transaction, {["challenge_id"] = 2009007,["end_reason"] = 2,["use_time"]= used_time ,["remove_mud"]= remove_mud, ["luminous_level"] = lumen_level})
else
if ScriptLib.IsPlayerAllAvatarDie(context, context.owner_uid) then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:埋点数据,团灭,流水号"..transaction.."耗时"..used_time.."清除黑泥总数"..remove_mud.."流明石等级"..lumen_level)
ScriptLib.MarkGroupLuaAction(context, "Luminous_challenge_2", transaction, {["challenge_id"] = 2009007,["end_reason"] = 0,["use_time"]= used_time ,["remove_mud"]= remove_mud, ["luminous_level"] = lumen_level})
else
ScriptLib.PrintContextLog(context,"##[LumenCharge]:挑战失败,未团灭")
end
end
--重置部分内容
LF_ClearGroup(context)
ScriptLib.CreateGadget(context, {config_id = defs.pursina_tip})
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, extra_info.start_operator, {7})
return 0
end
--======================================================================================================================
--LevelFunctions
--Group结束重置内容
function LF_ClearGroup(context, evt)
ScriptLib.PrintContextLog(context,"##[LumenCharge]:移除Group额外内容")
LF_StopPursina(context)
LF_SetPursinaNormal(context)
--保底移除BGM物件
if 0 ~= ScriptLib.GetEntityIdByConfigId(context, defs.enemy_gadget) then
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.enemy_gadget)
end
--移除额外Suite
for i=1,17 do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i+1)
end
--停掉时间轴
ScriptLib.EndTimeAxis(context, "energyBasic")
for core_id,infos in pairs(mud_list) do
ScriptLib.EndTimeAxis(context, tostring(core_id))
end
end
--初始化所有变量
function LF_ResetAllValues(context)
ScriptLib.SetGroupTempValue(context, "MUD_REMOVED", 0, {})
ScriptLib.SetGroupVariableValue(context, "energy", 0)
ScriptLib.SetGroupVariableValue(context, "stage", 1)
end
--无特效和无冲击波状态
function LF_SetPursinaNormal(context)
ScriptLib.PrintContextLog(context,"##[LumenCharge]:光钉移除破损状态效果")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_ROTATE", 0)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 1, {})
end
--故障状态
function LF_SetPursinaBroken(context)
ScriptLib.PrintContextLog(context,"##[LumenCharge]:光钉破损")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_ROTATE", 1)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 0, {})
end
--中速正常运转
function LF_SetPursinaMidSpeed(context)
ScriptLib.PrintContextLog(context,"##[LumenCharge]:正常充能")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_ROTATE", 2)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 1, {})
end
--高速运转,这里第二天玩法里用不到
function LF_SetPursinaHighSpeed(context)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_ROTATE", 3)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 1, {})
end
--启动光钉,打开嘲讽
function LF_StartPursina(context, evt)
ScriptLib.PrintContextLog(context,"##[LumenCharge]:启动光钉")
ScriptLib.SetGadgetStateByConfigId(context, defs.pursina, 202)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 1, {})
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_TAUNT", 1)
--启动时移除指示物
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.pursina_tip)
end
--停止光钉,关闭嘲讽
function LF_StopPursina(context, evt)
ScriptLib.PrintContextLog(context,"##[LumenCharge]:关闭光钉")
ScriptLib.SetGadgetStateByConfigId(context, defs.pursina, 203)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 0, {})
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_TAUNT", 0)
end
--创建黑泥套组
function LF_CreateMudSet(context, core_id)
if mud_list[core_id] ~= nil then
local covers = mud_list[core_id].cover_list
local content = mud_list[core_id].cover_content
ScriptLib.PrintContextLog(context,"##[LumenCharge]:创建黑泥,黑泥白盒")
ScriptLib.CreateGadget(context, {config_id = core_id})
ScriptLib.CreateGadget(context, {config_id = mud_list[core_id].mud_id})
if #covers ~= 0 then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:创建黑泥包裹物")
for k,cover_id in pairs(covers) do
ScriptLib.CreateGadget(context, {config_id = cover_id})
end
end
if #content ~= 0 then
-- local cur_stage = ScriptLib.GetGroupVariableValue(context, "stage")
ScriptLib.PrintContextLog(context,"##[LumenCharge]:遍历移除包裹内容物")
-- 这里遍历了所有stage的包裹物全部尝试进行一次移除
for stage_index=1,5 do
for k,content_id in pairs(content[stage_index]) do
if 0 ~= ScriptLib.GetEntityIdByConfigId(context, content_id) then
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, content_id)
end
end
end
end
else
ScriptLib.PrintContextLog(context,"##[LumenCharge]:[WARINING] 使用了错误的黑泥核心ID注意检查")
end
end
--移除黑泥套组
function LF_RemoveMudSet(context, core_id)
if mud_list[core_id] ~= nil then
local covers = mud_list[core_id].cover_list
local content= mud_list[core_id].cover_content
ScriptLib.PrintContextLog(context,"##[LumenCharge]:移除黑泥白盒")
if 0 ~= ScriptLib.GetEntityIdByConfigId(context, mud_list[core_id].mud_id) then
ScriptLib.KillEntityByConfigId(context, { group_id = base_info.group_id, config_id = mud_list[core_id].mud_id, entity_type = EntityType.GADGET })
-- ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, mud_list[core_id].mud_id)
end
ScriptLib.PrintContextLog(context,"##[LumenCharge]:移除黑泥包裹物")
for k,cover_id in pairs(covers) do
if 0 ~= ScriptLib.GetEntityIdByConfigId(context, cover_id) then
ScriptLib.KillEntityByConfigId(context, { group_id = base_info.group_id, config_id = cover_id, entity_type = EntityType.GADGET })
-- ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, cover_id)
end
end
local cur_stage = ScriptLib.GetGroupVariableValue(context, "stage")
if content[cur_stage] ~= nil then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:创建包裹内容物")
for k,content_id in pairs(content[cur_stage]) do
ScriptLib.CreateGadget(context, {config_id = content_id})
end
end
else
ScriptLib.PrintContextLog(context,"##[LumenCharge]:[WARINING] 使用了错误的黑泥核心ID注意检查")
end
end
--移除黑泥套组,创建内容物
--======================================================================================================================
--ServerLuaCalls
function SLC_PausePursina(context)
LF_SetPursinaBroken(context)
ScriptLib.EndTimeAxis(context, "energyBasic")
return 0
end
function SLC_ResumePursina(context)
if not ScriptLib.IsChallengeStartedByChallengeId(context, 2009007) then
ScriptLib.PrintContextLog(context,"##[LumenCharge]:挑战已结束,不再恢复时间轴")
return 0
end
LF_SetPursinaMidSpeed(context)
ScriptLib.InitTimeAxis(context, "energyBasic", {2}, true)
return 0
end
--=====================================================================================================================
--初始化GroupTrigger
function LumenCharge_Initialize()
for config_id,infos in pairs(monsters) do
if infos.affix ~= nil then
table.insert(infos.affix, 4160)
else
infos["affix"] = {4160}
end
end
for k,v in pairs(LumenCharge_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
LumenCharge_Initialize()

View File

@ -0,0 +1,295 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V2_7]
--======================================================================================================================
--|| Filename || Activity_LumenWipeout
--|| RelVersion || V2_7
--|| Owner || chao-jin
--|| Description ||
--|| LogName || ##[Activity_LumenWipeout]
--|| Protection ||
--[[======================================================================================================================
--Defs & Miscs
local defs = {
pursina = 630015,
pursina_tip = 630087,
fail_region = 630038
}
local mud_list = {
[630009] = 630063,
[630012] = 630062,
[630023] = 630028,
}
local extra_infos = {
start_operator = 630002,
mud_cover = 630096,
}
--======================================================================================================================]]
local LumenWipeout_Triggers = {
{config_id = 8002001, name = "pursina_state", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_pursina_state", trigger_count = 0},
{config_id = 8002002, name = "challenge_success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0 },
{config_id = 8002003, name = "challenge_fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0 },
{config_id = 8002004, name = "any_gadget_die", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0},
{config_id = 8002005, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
{config_id = 8002006, name = "leave_fail_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_fail_region", trigger_count = 0},
{config_id = 8002007, name = "gadget_create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0},
{config_id = 8002008, name = "time_axis_pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
{config_id = 8002009, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
{config_id = 8002010, name = "pause_battle_bgm", event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "", action = "action_pause_battle_bgm", trigger_count = 0},
}
--Events
function action_pursina_state(context, evt)
if evt.source_name == "pursina_state" then
if evt.param1 == 0 then
LF_SetPursinaNormal(context)
return 0
end
if evt.param1 == 1 then
LF_SetPursinaBroken(context)
return 0
end
if evt.param1 == 2 then
LF_SetPursinaMidSpeed(context)
return 0
end
if evt.param3 == 3 then
LF_SetPursinaHighSpeed(context)
return 0
end
end
return 0
end
--挑战成功处理
function action_challenge_success(context, evt)
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:挑战成功")
--运营用的埋点数据
local used_time = 300 - evt.param2
local remove_mud = ScriptLib.GetGroupTempValue(context, "MUD_REMOVED", {})
local transaction = evt.param_str1
local lumen_level = ScriptLib.GetTeamServerGlobalValue(context, context.owner_uid, "SGV_Light_Stone_Level")
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:埋点数据,挑战成功,流水号"..transaction.."耗时"..used_time.."清除黑泥总数"..remove_mud.."流明石等级"..lumen_level)
ScriptLib.MarkGroupLuaAction(context, "Luminous_challenge_2", transaction, {["challenge_id"] = 2009002,["end_reason"] = 1,["use_time"]= used_time ,["remove_mud"]= remove_mud,["luminous_level"] = lumen_level})
LF_ClearGroup(context)
ScriptLib.TryFinishLuminanceStoneChallengeStage(context, base_info.group_id)
ScriptLib.GoToGroupSuite(context, base_info.group_id, 10)
ScriptLib.FinishGroupLinkBundle(context, base_info.group_id)
return 0
end
--处理BGM物件
function action_pause_battle_bgm(context, evt)
if evt.param1 == 630078 then
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:刷最后一波怪移除BGM入战物件")
if 0 ~= ScriptLib.GetEntityIdByConfigId(context, defs.enemy_gadget) then
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.enemy_gadget)
end
end
return 0
end
--挑战失败处理
function action_challenge_fail(context, evt)
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:挑战失败")
--运营用的埋点数据
local used_time = 300 - evt.param2
local remove_mud = ScriptLib.GetGroupTempValue(context, "MUD_REMOVED", {})
local lumen_level = ScriptLib.GetTeamServerGlobalValue(context, context.owner_uid, "SGV_Light_Stone_Level")
local transaction = evt.param_str1
if evt.param2 <= 0 then
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:埋点数据,时间用尽,流水号"..transaction.."耗时"..used_time.."清除黑泥总数"..remove_mud.."流明石等级"..lumen_level)
ScriptLib.MarkGroupLuaAction(context, "Luminous_challenge_2", transaction, {["challenge_id"] = 2009002,["end_reason"] = 2,["use_time"]= used_time ,["remove_mud"]= remove_mud, ["luminous_level"] = lumen_level})
else
if ScriptLib.IsPlayerAllAvatarDie(context, context.owner_uid) then
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:埋点数据,团灭,流水号"..transaction.."耗时"..used_time.."清除黑泥总数"..remove_mud.."流明石等级"..lumen_level)
ScriptLib.MarkGroupLuaAction(context, "Luminous_challenge_2", transaction, {["challenge_id"] = 2009002,["end_reason"] = 0,["use_time"]= used_time ,["remove_mud"]= remove_mud, ["luminous_level"] = lumen_level})
end
end
--清除额外内容并恢复
LF_ClearGroup(context)
ScriptLib.CreateGadget(context, {config_id = defs.pursina_tip})
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, extra_infos.start_operator, {7})
return 0
end
--Group加载
function action_group_load( context, evt )
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:加载Group,初始化一些内容")
ScriptLib.SetGroupTempValue(context, "MUD_REMOVED", 0, {})
return 0
end
--玩家脱离战斗区域,挑战失败
function action_leave_fail_region(context, evt)
if evt.param1 == defs.fail_region then
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:玩家脱离战斗区域,手动结束挑战")
ScriptLib.StopChallenge(context, 233, 0)
end
return 0
end
-- 触发操作
function action_select_option(context, evt)
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:开启挑战")
--记录场上的黑泥数量
ScriptLib.SetGroupTempValue(context, "MUD_NUMS", 0, {})
ScriptLib.SetGroupTempValue(context, "MUD_REMIND", 0, {})
--开启挑战
ScriptLib.ActiveChallenge(context, 233, 2009005, 300, 166001630, 29, 0)
ScriptLib.DelWorktopOptionByGroupId(context, 166001630, 630002, 7)
--启动光钉
LF_StartPursina(context)
LF_SetPursinaNormal(context)
ScriptLib.InitTimeAxis(context, "pursinaDelay", {2}, false)
--创建两个喷气岩
ScriptLib.CreateGadget(context, { config_id = 630068 })
ScriptLib.CreateGadget(context, { config_id = 630076 })
ScriptLib.CreateGadget(context, { config_id = defs.enemy_gadget })
--刷第一波怪
ScriptLib.AddExtraGroupSuite(context, 166001630, 2)
ScriptLib.ShowReminder(context, 400012)
local pos = {x=993, y=737, z=409}
ScriptLib.ScenePlaySound(context, {play_pos = pos, sound_name = "LevelHornSound001", play_type= 1, is_broadcast = false })
return 0
end
-- 黑泥创生处理
function action_gadget_create(context,evt)
--黑泥核心创建时,同步创建黑泥
if mud_list[evt.param1] ~= nil then
-- ScriptLib.CreateGadget(context, {config_id = mud_list[evt.param1]})
ScriptLib.ChangeGroupTempValue(context, "MUD_NUMS", 1, {})
--创建黑泥,看看光钉的工作状态
if 0 ~= ScriptLib.GetGroupTempValue(context, "MUD_NUMS", {}) then
if 1 == ScriptLib.GetGroupTempValue(context, "PURSINA_WORKING", {}) then
if 0 == ScriptLib.GetGroupTempValue(context, "MUD_REMIND", {}) then
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:弹出第一次Reminder")
ScriptLib.ShowReminder(context, 4000146)
ScriptLib.SetGroupTempValue(context, "MUD_REMIND",1, {})
end
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:创建黑泥,光钉在工作中,光钉损坏")
ScriptLib.ShowReminder(context, 4000151)
LF_SetPursinaBroken(context)
end
end
end
if evt.param1 == extra_infos.start_operator then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, extra_infos.start_operator, {7})
end
return 0
end
--统计黑泥核心死亡数量
function action_any_gadget_die(context,evt)
if mud_list[evt.param1] ~= nil then
--移除对应的黑泥白盒
ScriptLib.ChangeGroupTempValue(context, "MUD_NUMS", -1, {})
ScriptLib.KillEntityByConfigId(context, { group_id = base_info.group_id, config_id = mud_list[evt.param1], entity_type = EntityType.GADGET })
-- ScriptLib.RemoveEntityByConfigId(context, 166001630, EntityType.GADGET, mud_list[evt.param1])
if not ScriptLib.IsChallengeStartedByChallengeId(context, 2009005) then
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:挑战未开始,不增加统计")
return 0
end
--场上没有黑泥了,移除包裹物,恢复光钉
if 0 == ScriptLib.GetGroupTempValue(context, "MUD_NUMS", {}) then
if 0 ~= ScriptLib.GetEntityIdByConfigId(context, extra_infos.mud_cover) then
ScriptLib.KillEntityByConfigId(context, { group_id = base_info.group_id, config_id = extra_infos.mud_cover, entity_type = EntityType.GADGET })
-- ScriptLib.RemoveEntityByConfigId(context, 166001630, EntityType.GADGET, extra_infos.mud_cover)
end
LF_SetPursinaMidSpeed(context)
end
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:黑泥核心死亡,增加统计")
ScriptLib.ChangeGroupTempValue(context, "MUD_REMOVED", 1, {})
end
return 0
end
--时间轴移动
function action_time_axis_pass(context,evt)
if evt.source_name == "pursinaDelay" then
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:光钉开始正常运转")
LF_SetPursinaMidSpeed(context)
ScriptLib.ShowReminder(context, 4000145)
end
return 0
end
--======================================================================================================================
--LevelFunctions
function LF_ClearGroup(context)
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:移除Group额外内容")
if 0 ~= ScriptLib.GetEntityIdByConfigId(context, defs.enemy_gadget) then
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.enemy_gadget)
end
for i=1,8 do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i+1)
end
LF_SetPursinaNormal(context)
LF_StopPursina(context)
ScriptLib.EndTimeAxis(context, "pursinaDelay")
end
--无特效和无冲击波状态
function LF_SetPursinaNormal(context)
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:光钉移除破损状态效果")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_ROTATE", 0)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 1, {})
end
--故障状态
function LF_SetPursinaBroken(context)
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:光钉破损")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_ROTATE", 1)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 0, {})
end
--中速正常运转
function LF_SetPursinaMidSpeed(context)
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:正常充能")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_ROTATE", 2)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 1, {})
end
--高速运转,这里第三天玩法里用不到
function LF_SetPursinaHighSpeed(context)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.pursina, "SGV_PURSINA_ROTATE", 3)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 1, {})
end
--启动光钉
function LF_StartPursina(context, evt)
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:启动光钉")
ScriptLib.SetGadgetStateByConfigId(context, defs.pursina, 202)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 1, {})
--启动时移除指示物
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.pursina_tip)
end
--停止光钉
function LF_StopPursina(context, evt)
ScriptLib.PrintContextLog(context,"##[LumenWipeout]:关闭光钉")
ScriptLib.SetGadgetStateByConfigId(context, defs.pursina, 203)
ScriptLib.SetGroupTempValue(context, "PURSINA_WORKING", 0, {})
end
function LumenWipeout_Initialize()
for config_id,infos in pairs(monsters) do
if infos.affix ~= nil then
table.insert(infos.affix, 4160)
else
infos["affix"] = {4160}
end
end
table.insert(variables, { config_id=50000001,name = "pursina_state", value = 0,no_refresh = false})
table.insert(variables, { config_id=50000002,name = "ChallengeSuccess", value = 0,no_refresh = false})
-- suites[1].triggers = {}
for k,v in pairs(LumenWipeout_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
LumenWipeout_Initialize()

View File

@ -0,0 +1,130 @@
--[[
local defs={
air_wall = 999,
}
]]
local T_Gruop_ID = 246202004
local T_Air_Wall = 4001
local Next_Group_List = {
[246202001] = 246202002,
[246202002] = 246202003,
[246202003] = 246202005,
[246202005] = 246202006,
[246202006] = 246202007,
[246202007] = 246202001,
}
local temp_Gadget = {
{ config_id = 20000991, gadget_id = 70800183, pos = { x = 17.537, y = -43.175, z = 0.008 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1 },
}
local temp_Variables_Rogue_Terrain_2 = {
{ config_id=50000001,name = "Terrain", value = 2, no_refresh = false },
{ config_id=50000002,name = "Ready", value = 0, no_refresh = false },
}
local temp_Tirgger_Rogue_Terrain_2 = {
{event = EventType.EVENT_CHALLENGE_SUCCESS,source = "",condition="",action="action_t2_EVENT_CHALLENGE_SUCCESS",trigger_count=0},
{event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_t2_EVENT_GROUP_LOAD",trigger_count = 0},
{event = EventType.EVENT_ROGUE_OPEN_ACCESS, source = "", condition = "", action = "action_t2_action_EVENT_ROGUE_OPEN_ACCESS",trigger_count = 0},
{event = EventType.EVENT_VARIABLE_CHANGE, source = "Ready", condition = "", action = "action_t2_EVENT_VARIABLE_CHANGE_Ready", trigger_count = 0 },
{event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_t2_EVENT_SELECT_OPTION", trigger_count = 0 },
{event = EventType.EVENT_GADGET_STATE_CHANGE,source = "",condition="",action="action_t2_EVENT_GADGET_STATE_CHANGE",trigger_count=0},
{event = EventType.EVENT_ROGUE_START_FIGHT,source = "",condition="",action="action_t2_EVENT_ROGUE_START_FIGHT",trigger_count=0},
}
--通知下个group延迟创建操作台时点1开始战斗
function action_t2_EVENT_ROGUE_START_FIGHT(context,evt)
ScriptLib.PrintContextLog(context,"## Rogue_Terraion_2 action_t2_EVENT_ROGUE_START_FIGHT:")
LF_Notify_Next_Group_Wait(context)
return 0
end
--通知下个group延迟创建操作台时点2触发备战
function action_t2_EVENT_GADGET_STATE_CHANGE(context,evt)
ScriptLib.PrintContextLog(context,"## Rogue_Terraion_2 action_t2_EVENT_GADGET_STATE_CHANGE:p1="..evt.param1.."|p2="..evt.param2)
if evt.param1 ~= 201 then return 0 end
if evt.param2 == Rogue_Cell.Prepare_Operator_Config_ID then
LF_Notify_Next_Group_Wait(context)
end
return 0
end
function LF_Notify_Next_Group_Wait(context)
for k , v in pairs(Next_Group_List) do
local _targetgroup = 0
if k ==base_info.group_id then
_targetgroup = v
ScriptLib.SetGroupTempValue(context,"Need_Wait",1,{ group_id = _targetgroup})
end
end
return 0
end
function action_t2_EVENT_SELECT_OPTION(context,evt)
ScriptLib.PrintContextLog(context,"## Rogue_Terraion_2 action_t2_EVENT_SELECT_OPTION:")
if evt.param1 == 20000991 then
ScriptLib.SetGroupVariableValueByGroup(context,"Turn",4,T_Gruop_ID)
end
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 1})
ScriptLib.KillEntityByConfigId(context, {config_id=20000991, entity_type = EntityType.GADGET})
ScriptLib.KillEntityByConfigId(context, {group_id = T_Gruop_ID, config_id= T_Air_Wall, entity_type = EntityType.GADGET})
return 0
end
function action_t2_EVENT_VARIABLE_CHANGE_Ready(context,evt)
local _wait = ScriptLib.GetGroupTempValue(context,"Need_Wait",{})
ScriptLib.PrintContextLog(context,"## Rogue_Terraion_2 action_t2_EVENT_VARIABLE_CHANGE_Ready: _wait=".._wait)
if _wait == 1 then
ScriptLib.SetGroupTempValue(context,"Need_Wait",0,{})
local _hard = ScriptLib.GetGroupTempValue(context,"operator_is_hard",{})
local _boss = ScriptLib.GetGroupTempValue(context,"operator_is_boss",{})
LF_Create_Fight_Operator(context,_hard,_boss)
local _vec = ScriptLib.GetRogueDiaryRoundAndRoom(context)
--地城2特殊处理创建操作台时给个reminder
if #_vec == 2 then
local _stage = _vec[1]
local _cell = _vec[2]
local _uidlist = ScriptLib.GetSceneUidList(context)
ScriptLib.AssignPlayerShowTemplateReminder(context, 167+_stage, {param_vec={_cell},param_uid_vec={},uid_vec={_uidlist[1]}})
else
ScriptLib.PrintContextLog(context,"## Rogue_Cell action_EVENT_ENTER_REGION[Warning]:#_vec="..#_vec)
end
end
return 0
end
function action_t2_action_EVENT_ROGUE_OPEN_ACCESS(context,evt)
ScriptLib.PrintContextLog(context,"## Rogue_Terraion_2 action_t2_action_EVENT_ROGUE_OPEN_ACCESS:")
if evt.param1 == 1 then return 0 end --通关后不需要开通路
ScriptLib.CreateGadget(context, { config_id = 20000991})
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, 20000991, {198})
return 0
end
function action_t2_EVENT_CHALLENGE_SUCCESS(context,evt)
ScriptLib.SetGroupVariableValueByGroup(context,"Clear",0,T_Gruop_ID)
return 0
end
function action_t2_EVENT_GROUP_LOAD(context,evt)
ScriptLib.PrintContextLog(context,"## Rogue_Terraion_2 action_t2_EVENT_GROUP_LOAD:")
ScriptLib.SetGroupTempValue(context,"Need_Wait",0,{})
return 0
end
--初始化
function Initialize_2()
--加变量
if temp_Variables_Rogue_Terrain_2 ~= nil then
for k,v in pairs(temp_Variables_Rogue_Terrain_2) do
table.insert(variables,v)
end
end
--加触发器
if temp_Tirgger_Rogue_Terrain_2 ~= nil then
for k,v in pairs(temp_Tirgger_Rogue_Terrain_2) do
v.name = "temp_Tirgger2_"..k
v.config_id = 40200000 + k
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
end
--地城2部分
--加奇点传送门
for k , v in pairs(temp_Gadget) do
table.insert(gadgets,v)
end
return 0
end
Initialize_2()

View File

@ -1,5 +1,5 @@
--[[
defs={
local defs={
Portal_Eff = 999,
Portal_Trigger = 999,
Streaming_Gadget = 999,

View File

@ -8,7 +8,7 @@
--[[
var: level_start为1以开启推箱子流程
var_change接source为"level_finish"
defs = {
local defs = {
box_gadget_id_1 = 1, --可推箱子的gadget_id
box_gadget_id_2 = 2, --可推箱子的gadget_id
config_suites = {1} --注册逻辑的suite队列

View File

@ -9,7 +9,7 @@
=======================================]]
--[[
defs = {
local defs = {
gadget_animal = 26001,
pointarray_ID = 110200012,
maxPointCount = 8,

View File

@ -1,5 +1,5 @@
--[[
defs = {
local defs = {
--开启操作台configID
starter_gadget = ,
--终点Region的ConfigID

View File

@ -9,7 +9,7 @@
=======================================]]
--[[
defs = {
local defs = {
stages =
{
--key为第几段value1为这一段的起点suitevalue2为这一段的主体suite

View File

@ -7,7 +7,7 @@
|| Protection:
=======================================]]
--[[
defs = {
local defs = {
--是否教学关
is_tutorial = 1,
--起始操作台

View File

@ -7,7 +7,7 @@
|| Protection:
=======================================]]
--[[
defs =
local defs =
{
--玩法完成时 这个gadget如果为GearStop则会被设为Default
finish_gadget = ,

View File

@ -9,7 +9,7 @@
=======================================]]
--[[
defs = {
local defs = {
--每个操作台config_id, 控制的markfalg和它的解最多5位数字。
--玩家按按钮左转写2 右转写3。
--例如“左左右左”即为“{2,2,3,2}”

View File

@ -7,7 +7,7 @@
|| Protection:
=======================================]]--
--[[
defs = {
local defs = {
target_leveltag = 22,
pos = { x=-677.9, y=135, z=-16},
rot = {x=0, y=0, z=1},

View File

@ -7,7 +7,7 @@
|| Protection:
=======================================]]--
--[[
defs = {
local defs = {
reverse_time = 10,--回溯倒计时,整数秒
}
]]

View File

@ -9,7 +9,7 @@
--[[
defs =
local defs =
{
operator_id = 574048, --操作台的configid
option_id = 175, --操作台的option id

View File

@ -7,7 +7,7 @@
=======================================]]
--[[
defs = {
local defs = {
gallery_id = ,

View File

@ -9,7 +9,7 @@
-- @李鸿杰 还没布设相关GROUP
--[[
defs =
local defs =
{
-- Group对应的groupbundle
group_bundle_id = 0,

View File

@ -7,7 +7,7 @@
=======================================]]
--[[
defs =
local defs =
{
-- 挑战编号
challenge_id = 2009009,

View File

@ -6,7 +6,7 @@
|| Protection:
=======================================]]
-- defs =
-- local defs =
-- {
-- maxRegion = 34004,
-- maxJumpTimes = 5,

View File

@ -7,7 +7,7 @@
=======================================]]
--[[
defs_miscs =
local defs_miscs =
{
-- 死域观测站透镜的config id
lensConfigId = 103001,

View File

@ -16,7 +16,7 @@
-- 综上所述需要LD手动配置的内容包括宝箱没有特殊需求不需要创建其他东西
--[[
defs = {
local defs = {
-- 【根据实际情况修改】幻梦之门的config id
door = 17001,

View File

@ -8,7 +8,7 @@
|| Protection: [Protection]
=======================================]]
-- defs =
-- local defs =
-- {
-- regionId = 12345,
-- targetScore = 3,

View File

@ -9,7 +9,7 @@
-- 特定Region或者Group可以写每次EnterRegion会检测
--[[
defs ={
local defs ={
regionList = {123},
-- 1,2,3,4对应4套等级
curCommander =1,

View File

@ -7,7 +7,7 @@
=======================================]]
--[[
defs = {
local defs = {
-- 【特别注意】所有流程必需的machine必须放在suite1中在电池全亮后自动开启
-- 【特别注意】探索性质的machine必须放在suite2中在电池全亮后不会自动开启
-- 【特别注意】只有suite1会在group load时加载

View File

@ -6,7 +6,7 @@
|| Protection:
=======================================]]
--[[
defs =
local defs =
{
-- 本轮对应的gallery id
galleryId = 0,

View File

@ -7,7 +7,7 @@
=======================================]]
--[[
defs =
local defs =
{
-- 钓鱼点
fishingPoint = {

View File

@ -6,7 +6,7 @@
|| Protection:
=======================================]]
--[[
defs =
local defs =
{
-- 受回流之柱控制的group id
groupTable =

View File

@ -0,0 +1,159 @@
--[[======================================
|| filename: Activity_Hunt_Stage_1
|| owner: juntao.chen
|| description:
|| LogName: Activity_Hunt_Stage_1
|| Protection: [Protection]
=======================================]]
--需求defs
--[[
local defs = {
gallery_id = 111,
region = 111
}
]]
--[[ 一阶段:
add_timid_cnt
add_brutal_cnt
add_elite_cnt
monster_id
left_num
total_num ]]
local stage_2_group_id = 133002100
local temp_Variables = {--已自动添加config_id
{ name = "gm_Try_End", value = 0, no_refresh = false },
{ name = "gm_Try_Start", value = 0, no_refresh = false },
--一阶段
{ name = "add_timid_cnt", value = 0, no_refresh = false },
{ name = "add_brutal_cnt", value = 0, no_refresh = false },
{ name = "add_elite_cnt", value = 0, no_refresh = false },
--二阶段
{ name = "left_num", value = 0, no_refresh = false },
{ name = "total_num", value = 0, no_refresh = false },
{ name = "monster_id", value = 0, no_refresh = false },
{ name = "monster_id_sneak", value = 0, no_refresh = false },
{ name = "Stage_2_Monster_Count", value = 0, no_refresh = false },--仅策划用
--三阶段
{ name = "is_finish", value = 0, no_refresh = false },
{ name = "go_weak", value = 0, no_refresh = false },
}
local temp_Tirgger = {
{event = EventType.EVENT_VARIABLE_CHANGE, source = "", action = "action_EVENT_VARIABLE_CHANGE"},
{event = EventType.EVENT_GALLERY_START, source = "", action = "action_EVENT_GALLERY_START"},
{event = EventType.EVENT_GROUP_REFRESH, source = "", action = "action_EVENT_GROUP_REFRESH"},
{event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", action = "action_EVENT_GROUP_WILL_UNLOAD"},
{event = EventType.EVENT_LEAVE_REGION, source = "", action = "action_EVENT_LEAVE_REGION"},
{event = EventType.EVENT_GALLERY_STOP, source = "", action = "action_EVENT_GALLERY_STOP"},
}
function action_EVENT_GALLERY_STOP(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_1 action_EVENT_GALLERY_STOP:evt.param1="..evt.param1)
local _uidlist = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, _uidlist, {1})
return 0
end
function action_EVENT_LEAVE_REGION(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_1 action_EVENT_LEAVE_REGION:evt.param1="..evt.param1)
if ScriptLib.IsGalleryStart(context, defs.gallery_id) and evt.param1 == defs.region then
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_1 action_EVENT_LEAVE_REGION:StopGalleryByReason")
ScriptLib.StopGalleryByReason(context, defs.gallery_id, 5)
end
return 0
end
function action_EVENT_GROUP_WILL_UNLOAD(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_1 action_EVENT_GROUP_WILL_UNLOAD")
return 0
end
function action_EVENT_GROUP_REFRESH(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_1 action_EVENT_GROUP_REFRESH")
return 0
end
function action_EVENT_GALLERY_START(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_1 action_EVENT_GALLERY_START:2022_6_21_205629")
if base_info.group_id == stage_2_group_id then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{["total_num"] = defs.stage_2_goal})
ScriptLib.SetGroupVariableValue(context, "Stage_2_Monster_Count", 0)
local _uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.SetTeamServerGlobalValue(context, _uid, "SGV_CUR_STAGE", 2)
else
local _uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.SetTeamServerGlobalValue(context, _uid, "SGV_CUR_STAGE", 0)
end
return 0
end
function action_EVENT_VARIABLE_CHANGE(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_1 action_EVENT_VARIABLE_CHANGE:evt.source_name = ".. evt.source_name.."| value = "..evt.param1)
--还是判一下name避免发无用key到gallery上
if evt.source_name == "add_timid_cnt" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
end
if evt.source_name == "add_brutal_cnt" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
end
if evt.source_name == "add_elite_cnt" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
end
if evt.source_name == "left_num" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
end
if evt.source_name == "total_num" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
end
if evt.source_name == "monster_id" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
end
if evt.source_name == "monster_id_sneak" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{["monster_id"] = evt.param1,["sneak_count"] = 1})
end
if evt.source_name == "is_finish" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
end
if evt.source_name == "go_weak" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
end
--二阶段抓到动物后 判断是否完成
if evt.source_name == "Stage_2_Monster_Count" then
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_1 action_EVENT_VARIABLE_CHANGE1:defs.stage_2_goal="..defs.stage_2_goal)
if evt.param1 >= defs.stage_2_goal then
ScriptLib.StopGallery(context, 27002, false)
end
end
return 0
end
function LF_Try_Start(context)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_1 LF_Try_Start:")
return 0
end
function SLC_onStageReady(context)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 SLC_onStageReady:")
ScriptLib.SetGroupVariableValueByGroup(context,"start", 1,133002075)
return 0
end
--初始化
function Initialize()
--加触发器
if temp_Tirgger ~= nil then
for k,v in pairs(temp_Tirgger) do
v.name = v.action
v.config_id = 40000000 + k
v.trigger_count = 0
v.condition = ""
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
end
--加变量
if temp_Variables ~= nil then
for k,v in pairs(temp_Variables) do
v.config_id = 50000000 + k
table.insert(variables,v)
end
end
return 0
end
Initialize()

View File

@ -0,0 +1,342 @@
--[[======================================
|| filename: Activity_Hunt_Stage_2
|| owner: juntao.chen
|| description: (group)
|| LogName: Activity_Hunt_Stage_2
|| Protection: [Protection]
=======================================]]
--需求defs
--[[
local defs = {
target_group = 111
}
]]
--[[ 一阶段:
add_timid_cnt
add_brutal_cnt
add_elite_cnt
monster_id
left_num
total_num ]]
local stage_1_group_id = 133002075
local stage_2_group_id = {133002081,133002082,133002099}
local stage_3_group_id = 133002068
local monster_list = {
[28020310] = "add_timid_cnt",
[28020311] = "add_brutal_cnt",
[28020312] = "add_elite_cnt",
}
local score_list = {
[28020310] = 10,
[28020311] = 50,
[28020312] = 100,
}
local temp_Variables = {
{ config_id=50000009,name = "create_random_shield_orb", value = 0, no_refresh = false },
{ config_id=50000001,name = "create_monster_1", value = 0, no_refresh = false },
{ config_id=50000002,name = "create_monster_2", value = 0, no_refresh = false },
{ config_id=50000003,name = "create_monster_3", value = 0, no_refresh = false },
}
local temp_Tirgger = {
{event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", action = "action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE"},
{event = EventType.EVENT_ENTER_REGION, source = "", action = "action_EVENT_ENTER_REGION"},
{event = EventType.EVENT_VARIABLE_CHANGE, source = "", action = "action2_EVENT_VARIABLE_CHANGE"},
{event = EventType.EVENT_GROUP_LOAD, source = "", action = "action_EVENT_GROUP_LOAD"},
{event = EventType.EVENT_TIME_AXIS_PASS, source = "Active_Trap", action = "action_EVENT_TIME_AXIS_PASS_Active_Trap"},
{event = EventType.EVENT_TIME_AXIS_PASS, source = "create_random_shield_orb", action = "action_EVENT_TIME_AXIS_PASS_create_random_shield_orb"},
{event = EventType.EVENT_ANY_MONSTER_DIE, source = "", action = "action_EVENT_ANY_MONSTER_DIE"},
}
function action_EVENT_TIME_AXIS_PASS_create_random_shield_orb(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_TIME_AXIS_PASS_create_random_shield_orb:")
local _cfgid = ScriptLib.GetGroupTempValue(context,"last_cfgid",{})
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_TIME_AXIS_PASS_create_random_shield_orb:_cfgid=".._cfgid)
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, 20000002)
ScriptLib.CreateGadget(context, { config_id = _cfgid })
return 0
end
--剩余怪物数量检测:用于二阶段线性解锁黄圈
function action_EVENT_ANY_MONSTER_DIE(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_ANY_MONSTER_DIE:")
--非二阶段不跑该function
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_ANY_MONSTER_DIE:base_info.group_id="..base_info.group_id)
if stage_2_group_id == nil then
return 0
end
if #stage_2_group_id ~= 3 then
return 0
end
if base_info.group_id ~=stage_2_group_id[1] and base_info.group_id ~=stage_2_group_id[2] and base_info.group_id ~=stage_2_group_id[3] then
return 0
end
local _count = ScriptLib.GetGroupMonsterCount(context)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_ANY_MONSTER_DIE:_count=".._count)
--1解锁22解锁3
if _count == 2 and base_info.group_id == stage_2_group_id[1] then
ScriptLib.ActivateGroupLinkBundle(context, stage_2_group_id[2])
ScriptLib.AddExtraGroupSuite(context, stage_2_group_id[2], 2)
elseif _count == 2 and base_info.group_id == stage_2_group_id[2] then
ScriptLib.ActivateGroupLinkBundle(context, stage_2_group_id[3])
ScriptLib.AddExtraGroupSuite(context, stage_2_group_id[3], 2)
end
--如果最近踩过的黄圈是本group的圈则更新左侧剩余数量
local _circle = ScriptLib.GetGroupTempValue(context, "Cur_Circle",{ group_id = defs.target_group})
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_ANY_MONSTER_DIE:_circle=".._circle)
if _circle == defs.circle_region then
--更新左侧面板
ScriptLib.SetGroupVariableValueByGroup(context, "left_num", _count, defs.target_group)
end
--如果数量为0关闭黄圈
if _count == 0 then
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_ENTER_REGION:DeactivateGroupLinkBundle")
ScriptLib.DeactivateGroupLinkBundle(context,base_info.group_id)
end
return 0
end
--三阶段用 定时激活捕网机关
function action_EVENT_TIME_AXIS_PASS_Active_Trap(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_TIME_AXIS_PASS_Active_Trap:")
if evt.param1 == 1 then
ScriptLib.ShowReminder(context, 400174)
--随机挑选一个未激活的trap记录config_id生成倒三角箭头
local _list = {}
for k,v in pairs(gadgets) do
if v.gadget_id == 70800230 and ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,v.config_id) ~= 201 then
table.insert(_list,v.config_id)
end
end
if #_list > 0 then
local _t = math.random(#_list)
ScriptLib.SetGroupTempValue(context,"random_cfgid",_list[_t],{})
--找到待激活的机关,在他头顶创建一个倒三角
for k,v in pairs(gadgets) do
if v.config_id == _list[_t] then
ScriptLib.CreateGadgetByConfigIdByPos(context, 20000001,{x=v.pos.x, y=v.pos.y+2, z=v.pos.z}, v.rot)
end
end
end
elseif evt.param1 == 2 then
--根据_t生成gadget移除倒三角
local _cfgid = ScriptLib.GetGroupTempValue(context,"random_cfgid",{})
ScriptLib.SetGadgetStateByConfigId(context,_cfgid,201)
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, 20000001)
end
return 0
end
--二阶段逻辑:更新当前区域剩余怪物显示
function action_EVENT_ENTER_REGION(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_ENTER_REGION:evt.param1="..evt.param1)
--是否二阶段
if base_info.group_id ~= stage_2_group_id[1] and base_info.group_id ~= stage_2_group_id[2] and base_info.group_id ~= stage_2_group_id[3] then
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_ENTER_REGION:是否二阶段")
return 0
end
--是否走进黄圈
if evt.param1 ~= defs.circle_region then
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_ENTER_REGION:是否走进黄圈")
return 0
end
--记录最新踩到的黄圈
ScriptLib.SetGroupTempValue(context,"Cur_Circle",evt.param1,{ group_id = defs.target_group})
--更新当前区域剩余怪物显示
local _count = ScriptLib.GetGroupMonsterCount(context)
ScriptLib.SetGroupVariableValueByGroup(context, "left_num", _count, defs.target_group)
return 0
end
function action_EVENT_GROUP_LOAD(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_GROUP_LOAD33:")
local _uid = ScriptLib.GetSceneOwnerUid(context)
--三个阶段分别弹图文教程
if base_info.group_id == stage_1_group_id then
ScriptLib.AssignPlayerShowTemplateReminder(context,194,{param_uid_vec={},param_vec={},uid_vec={_uid}})
end
if base_info.group_id == stage_2_group_id[1] then
ScriptLib.AssignPlayerShowTemplateReminder(context,195,{param_uid_vec={},param_vec={},uid_vec={_uid}})
--二阶段额外初始化下变量
ScriptLib.SetGroupTempValue(context,"catched",0,{})
end
if base_info.group_id == stage_3_group_id then
--三阶段帮忙激活下八方网
ScriptLib.AssignPlayerShowTemplateReminder(context,196,{param_uid_vec={},param_vec={},uid_vec={_uid}})
local _time = 20
if defs.Active_Trap_Time ~= nil then _time = defs.Active_Trap_Time end
ScriptLib.InitTimeAxis(context,"Active_Trap",{_time-5,_time},true)
end
return 0
end
function action2_EVENT_VARIABLE_CHANGE(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action2_EVENT_VARIABLE_CHANGE:"..evt.source_name.."="..evt.param1)
if evt.source_name == "create_random_shield_orb" then
local _last_cfgid = ScriptLib.GetGroupTempValue(context,"last_cfgid",{})
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action2_EVENT_VARIABLE_CHANGE:_last_cfgid=" .. _last_cfgid)
local _list = {}
for k,v in pairs(gadgets) do
if v.gadget_id == 70800232 and v.config_id ~= _last_cfgid then
table.insert(_list,v.config_id)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action2_EVENT_VARIABLE_CHANGE:v.config_id=" .. v.config_id)
end
end
local _t = math.random(#_list)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action2_EVENT_VARIABLE_CHANGE:_t=" .. _t .. "| _list[_t] =" .. _list[_t] )
ScriptLib.SetGroupTempValue(context,"last_cfgid",_list[_t] , {})
ScriptLib.InitTimeAxis(context,"create_random_shield_orb",{5},false)
--找到待创建的护盾球,在他头顶创建一个倒三角
for k,v in pairs(gadgets) do
if v.config_id == _list[_t] then
ScriptLib.CreateGadgetByConfigIdByPos(context, 20000002,{x=v.pos.x, y=v.pos.y+1, z=v.pos.z}, v.rot)
end
end
end
if evt.source_name == "create_monster_1" then
LF_Create_Monster_By_Random_Point(context,28020310,evt.param1)
end
if evt.source_name == "create_monster_2" then
LF_Create_Monster_By_Random_Point(context,28020311,evt.param1)
end
if evt.source_name == "create_monster_3" then
LF_Create_Monster_By_Random_Point(context,28020312,evt.param1)
end
return 0
end
--只有一阶段才会走这个方式创建怪物
function LF_Create_Monster_By_Random_Point(context,m_id,num)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 LF_Create_Monster_By_Random_Point:")
local _alivelist = ScriptLib.GetGroupAliveMonsterList(context,base_info.group_id)
local _count = 0
local _list = {}
for k,v in pairs(monsters) do
if v.monster_id == m_id then
local _isalive = false
for i = 1 , #_alivelist do
if _alivelist[i] == v.config_id then
_isalive = true
break
end
end
if _isalive == false then
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 LF_Create_Monster_By_Random_Point:v.config_id="..v.config_id)
table.insert(_list,v.config_id)
else
_count = _count + 1
end
end
end
local _max = 0
if m_id == 28020310 then _max = defs.monster_max_1 end
if m_id == 28020311 then _max = defs.monster_max_2 end
if m_id == 28020312 then _max = defs.monster_max_3 end
--创建相应数量怪物且不超过max值
local _create_count = 0
if _count + num <= _max then
_create_count = num
else
_create_count = _max - _count
end
--开始创建
for i = 1 ,_create_count do
if #_list ~= 0 then
local _t = math.random(#_list)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 LF_Create_Monster_By_Random_Point:_list[_t]=".._list[_t])
--创建且给小猪、野林猪加初始sgv 设为0 只有一阶段其他阶段会默认1
if m_id == 28020310 or m_id == 28020311 then
ScriptLib.CreateMonsterWithGlobalValue(context, _list[_t], {["SGV_STAGE"] = 0})
else
ScriptLib.CreateMonster(context, {config_id = _list[_t], delay_time = 0})
end
--创建完移出待创建list
table.remove(_list,_t)
end
end
return 0
end
function action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE:"..evt.source_eid)
local _v = ScriptLib.GetGroupTempValue(context,"eid_"..evt.source_eid,{})
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE:_v=".._v)
if base_info.group_id == stage_1_group_id then
--一阶段
local _id = ScriptLib.GetMonsterIdByEntityId(context, evt.source_eid)
--一阶段 林野猪和雪猪不看v直接算分(他们不会逃跑,死了肯定都是捕捉)
if _id == 28020311 or _id == 28020312 then
ScriptLib.SetGroupVariableValueByGroup(context, monster_list[_id], 1, defs.target_group)
elseif _id == 28020310 then--一阶段小猪
if _v ~= 0 then --非0都算捕捉
--根据一阶段怪物id发对应key
ScriptLib.SetGroupVariableValueByGroup(context, monster_list[_id], 1, defs.target_group)
end
end
elseif base_info.group_id == stage_3_group_id then
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE:base_info.group_id == stage_3_group_id")
--三阶段
ScriptLib.SetGroupVariableValueByGroup(context, "is_finish", 1, defs.target_group)
else
--二阶段
if _v ~= 0 then
--走到这里的怪都是抓到的发monsterid
local _monster_id = ScriptLib.GetMonsterIdByEntityId(context, evt.source_eid)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE:_monster_id=".._monster_id)
if _v == 1 then
ScriptLib.SetGroupVariableValueByGroup(context, "monster_id", _monster_id, defs.target_group)
elseif _v == 2 then
ScriptLib.SetGroupVariableValueByGroup(context, "monster_id_sneak", _monster_id, defs.target_group)
end
--发数量检测变量
ScriptLib.ChangeGroupVariableValueByGroup(context, "Stage_2_Monster_Count", 1, defs.target_group)
end
end
return 0
end
function SLC_BeCaptured(context)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 SLC_BeCaptured:")
if ScriptLib.GetGroupTempValue(context,"eid_"..context.source_entity_id,{}) == 0 then
ScriptLib.SetGroupTempValue(context,"eid_"..context.source_entity_id,1,{})
end
return 0
end
function SLC_HuntAnimal_Sneak(context)
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 SLC_HuntAnimal_Sneak:")
ScriptLib.SetGroupTempValue(context,"eid_"..context.source_entity_id,2,{})
return 0
end
function SLC_GoWeak(context)--三阶段雪猪王眩晕计数
ScriptLib.PrintContextLog(context,"## Activity_Hunt_Stage_2 SLC_GoWeak:")
if base_info.group_id ~= stage_3_group_id then
return 0
end
ScriptLib.SetGroupVariableValueByGroup(context, "go_weak", 1, defs.target_group)
return 0
end
--初始化
function Initialize()
--加触发器
if temp_Tirgger ~= nil then
for k,v in pairs(temp_Tirgger) do
v.name = v.action
v.config_id = 40000000 + k
v.trigger_count = 0
v.condition = ""
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
end
--加变量
if temp_Variables ~= nil then
for k,v in pairs(temp_Variables) do
table.insert(variables,v)
end
end
--指示物件倒三角
local _temp_gadget = {config_id = 20000001, gadget_id = 70710432, pos = { x = 1074.944, y = 286.500, z = -424.074 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1, area_id = 10 }
table.insert(gadgets,_temp_gadget)
local _temp_gadget = {config_id = 20000002, gadget_id = 70710432, pos = { x = 1074.944, y = 286.500, z = -424.074 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1, area_id = 10 }
table.insert(gadgets,_temp_gadget)
return 0
end
Initialize()

View File

@ -8,7 +8,7 @@
--需求defs
--[[
defs = {
local defs = {
enter_region = 111,
leave_region = 111,
}

View File

@ -8,7 +8,7 @@
--需求misc
--[[
defs ={
local defs ={
gallery_id = 27004,
finish_region = 111,
}

View File

@ -0,0 +1,504 @@
--[[======================================
|| filename: Activity_WindMaze_Normal
|| owner: juntao.chen
|| description:
|| LogName: Activity_WindMaze_Normal
|| Protection: [Protection]
=======================================]]
--需求misc
--[[
local defs ={
gallery_id = 27004,
finish_region = 111,
challenge_id = 2,
ball_challenge_id = 1,
}
]]
--测试结束
local Stage_Normal = {
BigOrb_Gadget_ID = 70800281,
SmallOrb_Gadget_ID = 70800268,
Coin_Gadget_ID = 70800269,
Ball_Challenge_Time = 15,
}
local level_list = {
[247021001] = 1,
[247022002] = 2,
[247023001] = 3,
[247024001] = 4,
}
local temp_Variables = {
{ name = "gm_Try_Start", value = 0, no_refresh = false },
{ name = "gm_Try_End", value = 0, no_refresh = false },
{ name = "element_ball", value = 0, no_refresh = false },
{ name = "coin", value = 0, no_refresh = false },
{ name = "killed_monster", value = 0, no_refresh = false },
{ name = "rotate1", value = 0, no_refresh = false },
{ name = "rotate2", value = 0, no_refresh = false },
{ name = "gm_Try_Start_Ball", value = 0, no_refresh = false },
{ name = "gm_Try_Finish_Ball", value = 0, no_refresh = false },
{ name = "Ball_Challenge_Finish", value = 0, no_refresh = false },
}
local temp_Tirgger = {
{event = EventType.EVENT_GROUP_LOAD, source = "", action = "action_EVENT_GROUP_LOAD"},
{event = EventType.EVENT_VARIABLE_CHANGE, source = "", action = "action_EVENT_VARIABLE_CHANGE"},
{event = EventType.EVENT_ENTER_REGION, source = "", action = "action_EVENT_ENTER_REGION", forbid_guest = false },
{event = EventType.EVENT_ANY_GADGET_DIE, source = "", action = "action_EVENT_ANY_GADGET_DIE"},
{event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", action = "action_EVENT_GADGET_STATE_CHANGE"},
{event = EventType.EVENT_TIME_AXIS_PASS, source = "Ball_Challenge", action = "action_EVENT_TIME_AXIS_PASS_Ball_Challenge"},
{event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", action = "action_EVENT_GROUP_WILL_UNLOAD"},
{event = EventType.EVENT_ANY_MONSTER_DIE, source = "", action = "action_EVENT_ANY_MONSTER_DIE"},
{event = EventType.EVENT_GALLERY_STOP, source = "", action = "action_EVENT_GALLERY_STOP"},
{event = EventType.EVENT_GALLERY_PLAYER_LEAVE_SCENE, source = "", action = "action_EVENT_GALLERY_PLAYER_LEAVE_SCENE"},
{event = EventType.EVENT_DUNGEON_SETTLE, source = "", action = "action_EVENT_DUNGEON_SETTLE"},
{event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", action = "action_EVENT_DUNGEON_ALL_AVATAR_DIE"},
--
}
--团灭检测器
function action_EVENT_DUNGEON_ALL_AVATAR_DIE(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_DUNGEON_ALL_AVATAR_DIE" )
local _uidlist = ScriptLib.GetSceneUidList(context)
if _uidlist == nil then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_DUNGEON_ALL_AVATAR_DIE:_uidlist == nil")
return 0
end
for i = 1 ,#_uidlist do
if ScriptLib.IsPlayerAllAvatarDie(context,_uidlist[i]) == false then --任一活着则结束
return 0
end
end
ScriptLib.StopGalleryByReason(context, defs.gallery_id, 8)
return 0
end
--处理地城关闭如单人Esc退出
function action_EVENT_DUNGEON_SETTLE(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_DUNGEON_SETTLE" )
LF_Try_End(context,true)
return 0
end
--处理联机时其中一人离开的情况
function action_EVENT_GALLERY_PLAYER_LEAVE_SCENE(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_GALLERY_PLAYER_LEAVE_SCENE" )
local _region_eid = ScriptLib.GetGroupTempValue(context,"region_eid",{})
LF_Check_Finish(context,false)
return 0
end
function action_EVENT_GALLERY_STOP(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_GALLERY_STOP |is_fail = "..evt.param2.." |reason = "..evt.param3 )
--[[ enum GalleryStopReason
{
GALLERY_STOP_NONE = 0;
GALLERY_STOP_TIMEUP = 1;
GALLERY_STOP_CLIENT_INTERRUPT = 2;
GALLERY_STOP_LUA_INTERRUPT_SUCCESS = 3;
GALLERY_STOP_LUA_INTERRUPT_FAIL = 4;
GALLERY_STOP_OWNER_LEAVE_SCENE = 5;
GALLERY_STOP_PLAY_INIT_FAILED = 6; //
GALLERY_STOP_OTHER_PLAYER_ENTER = 7;//
GALLERY_STOP_AVATAR_DIE = 8; // AVATAR阵亡
GALLERY_STOP_FINISHED = 9; // gallery
GALLERY_STOP_FUNGUS_ALL_DIE = 10; // 3.2gallery stop
} ]]
if evt.param3 == 3 or evt.param3 == 9 then
ScriptLib.CauseDungeonSuccess(context)
else
ScriptLib.CauseDungeonFail(context)
end
return 0
end
function action_EVENT_ANY_MONSTER_DIE(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_ANY_MONSTER_DIE")
ScriptLib.ChangeGroupVariableValue(context,"killed_monster",1)
return 0
end
function action_EVENT_GROUP_WILL_UNLOAD(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_GROUP_WILL_UNLOAD")
LF_Try_End(context,true)
return 0
end
function action_EVENT_TIME_AXIS_PASS_Ball_Challenge(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_TIME_AXIS_PASS_Ball_Challenge: evt.param1=" .. evt.param1)
--重置各组吃球
LF_Try_FailBall(context)
--重置标记
ScriptLib.SetGroupTempValue(context,"Ball_Cfgid",0,{})
return 0
end
function action_EVENT_GADGET_STATE_CHANGE(context,evt)--吃大球
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_GADGET_STATE_CHANGE: evt.param1=" .. evt.param1)
--查询gadget_id
local _gadgetid = 0
for k,v in pairs(gadgets) do
if v.config_id == evt.param2 then
_gadgetid = v.gadget_id
break
end
end
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_GADGET_STATE_CHANGE: _gadgetid=" .. _gadgetid)
if _gadgetid == Stage_Normal.BigOrb_Gadget_ID and evt.param1 == 201 then
--如果大球切了
if ScriptLib.GetGroupTempValue(context,"Ball_Cfgid",{}) ==0 then
--且没有正在进行的吃球挑战
LF_Try_StartBall(context,evt.param2)
end
end
return 0
end
function action_EVENT_ANY_GADGET_DIE(context,evt)--吃金币、吃小球
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_ANY_GADGET_DIE: evt.param1=" .. evt.param1)
--查询gadgetid
local _gadgetid = 0
for k,v in pairs(gadgets) do
if v.config_id == evt.param1 then
_gadgetid = v.gadget_id
break
end
end
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_ANY_GADGET_DIE:_gadgetid = ".._gadgetid)
--金币
if _gadgetid == Stage_Normal.Coin_Gadget_ID then
ScriptLib.ChangeGroupVariableValue(context,"coin",1)
--watcher单局收集金币数量
local _uidlist = ScriptLib.GetSceneUidList(context)
if _uidlist == nil then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_ANY_GADGET_DIE:_uidlist == nil")
return 0
end
if level_list == nil then
return 0
end
if level_list[base_info.group_id] == nil then
return 0
end
for i = 1 , #_uidlist do
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_ANY_GADGET_DIE:level_list[base_info.group_id] = "..level_list[base_info.group_id])
ScriptLib.AddExhibitionReplaceableDataAfterSuccess(context, _uidlist[i], "Activity_WindField_"..level_list[base_info.group_id].."_Coin", 1, {play_type=ExhibitionPlayType.Gallery,gallery_id=defs.gallery_id})
end
end
--小球
if _gadgetid == Stage_Normal.SmallOrb_Gadget_ID then
ScriptLib.ChangeGroupTempValue(context,"ball_count",-1,{})
ScriptLib.ChangeGroupTempValue(context,"temp_ball_current_count",1,{})
--update到服务器
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{["ball_current_count"] = ScriptLib.GetGroupTempValue(context,"temp_ball_current_count",{})})
end
return 0
end
function action_EVENT_ENTER_REGION(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_ENTER_REGION:p1="..evt.param1.."|defs.finish_region="..defs.finish_region)
if evt.param1 == defs.finish_region then
ScriptLib.SetGroupTempValue(context,"region_eid",evt.source_eid,{})
LF_Check_Finish(context,true)
end
if evt.param1 == defs.ability_region then
if level_list == nil then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_ENTER_REGION:level_list == nil")
return 0
end
if level_list[base_info.group_id] == nil then
return 0
end
if level_list[base_info.group_id] == 4 then
--ScriptLib.AttachGalleryTeamAbilityGroup(context, {evt.uid}, defs.gallery_id, 0)
end
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_ENTER_REGION:清空陈列室替换值=".."Activity_WindField_"..level_list[base_info.group_id].."_Ball")
--清空陈列室替换值
--球
ScriptLib.ClearExhibitionReplaceableData(context, evt.uid, "Activity_WindField_"..level_list[base_info.group_id].."_Ball")
--金币
ScriptLib.ClearExhibitionReplaceableData(context, evt.uid, "Activity_WindField_"..level_list[base_info.group_id].."_Coin")
end
return 0
end
function LF_Check_Finish(context,is_enter_region)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Check_Finish:")
--[[ --Step1 检查吃够球了没【砍了】
local _maxcount = 0
for k,v in pairs(gadgets) do
if v.gadget_id == Stage_Normal.BigOrb_Gadget_ID then
_maxcount = _maxcount + 1
end
end
local _ball = ScriptLib.GetGroupVariableValue(context,"element_ball")
if _ball < _maxcount then
--没吃够球弹reminderreturn
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Check_Finish:没吃够球弹reminderreturn")
ScriptLib.ShowReminder(context,470210101)
return 0
end ]]
--Step2 检查都进region了没
--2.1 取活着的玩家_alive_uidlist
local _eid = ScriptLib.GetEntityIdByConfigId(context, defs.finish_region)
local _count = ScriptLib.GetRegionEntityCount(context, { region_eid =_eid, entity_type = EntityType.AVATAR })
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Check_Finish:_count".._count)
local _alive_uidlist = {}
local _uidlist = ScriptLib.GetSceneUidList(context)
if _uidlist == nil then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Check_Finish:_uidlist == nil")
return 0
end
for i = 1 , #_uidlist do
if ScriptLib.IsPlayerAllAvatarDie(context, _uidlist[i]) == false then
table.insert(_alive_uidlist,_uidlist[i])
end
end
--2.2 判断活着的玩家都到达
if _count == 0 then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Check_Finish:终点位置没人")
--终点没人return
return 0
end
if _count ~= #_alive_uidlist then
--还有人没到达终点return
if is_enter_region == true then
--如果这次检测是由enter_region引起则提示玩家
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Check_Finish:需要全部人到达终点弹reminderreturn")
ScriptLib.ShowReminder(context,470210102)
end
return 0
end
--完成watcher[要先于gallerystop执行
--watcher完成
--local _uidlist = ScriptLib.GetSceneUidList(context)--上面有了
if level_list == nil then
return 0
end
if level_list[base_info.group_id] == nil then
return 0
end
for i = 1 , #_uidlist do
ScriptLib.AddExhibitionReplaceableDataAfterSuccess(context, _uidlist[i], "Activity_WindField_"..level_list[base_info.group_id].."_LevelFinish", 1, {play_type=ExhibitionPlayType.Gallery,gallery_id=defs.gallery_id})
end
--完成
LF_Try_End(context,false)
return 0
end
function action_EVENT_VARIABLE_CHANGE(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_VARIABLE_CHANGE:"..evt.source_name.." = "..evt.param1)
--gm
if evt.source_name == "gm_Try_Start" and evt.param1 ~= 0 then
LF_Try_Start(context,evt.param1)
elseif evt.source_name == "gm_Try_End" and evt.param1 ~= 0 then
LF_Try_End(context,true)
elseif evt.source_name == "gm_Try_Start_Ball" then
LF_Try_StartBall(context,ball_id)
elseif evt.source_name == "gm_Try_Finish_Ball" then
LF_Try_FinishBall(context)
--gm结束
--正式:
elseif evt.source_name == "ball_count" then
if evt.param1 == 0 then
LF_Try_FinishBall(context)
end
elseif evt.source_name == "element_ball" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
elseif evt.source_name == "killed_monster" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
elseif evt.source_name == "coin" then
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,{[evt.source_name] = evt.param1})
end
return 0
end
function action_EVENT_GROUP_LOAD(context,evt)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal action_EVENT_GROUP_LOAD:")
ScriptLib.SetGroupVariableValue(context,"element_ball",0)
ScriptLib.SetGroupVariableValue(context,"coin",0)
LF_Try_Start(context,2)
return 0
end
function LF_Try_End(context,is_fail)
if is_fail then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_End:true")
else
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_End:false")
end
ScriptLib.StopGallery(context, defs.gallery_id, is_fail)
return 0
end
function LF_Try_StartBall(context,ball_id)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_StartBall")
local _get_config_suc = false
--对大小球suite的操作
for k,v in pairs(windball_list) do
if k == ball_id then --找到对应配置
_get_config_suc = true
if suites[v] == nil then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_StartBall:suites[v] == nil")
return 0
end
--创建小球们
ScriptLib.AddExtraGroupSuite(context,base_info.group_id,v)
--记录有多少个小球(用于本次挑战计数,吃一个-1直到0
ScriptLib.SetGroupTempValue(context,"ball_count",#suites[v].gadgets,{})
--组织数据tableupdate到服务器
local _uidlist = ScriptLib.GetSceneUidList(context)
if _uidlist == nil then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_StartBall:_uidlist == nil")
return 0
end
local _time = defs.ball_challenge_time
if _time == nil then
_time = Stage_Normal.Ball_Challenge_Time
ScriptLib.PrintGroupWarning(context,"## Activity_WindMaze_Normal LF_Try_StartBall:没配吃球挑战时间设为20秒")
else
end
local _score = {
["is_start"] = true,
["is_success"] = false,
["challenge_time"] = _time,
["show_id"] = defs.ball_challenge_id,
["ball_max_count"] = #suites[v].gadgets,
["ball_current_count"] = 0,
}
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,_score)
--temp变量归零用来每次吃球给服务器发"ball_current_count"
ScriptLib.SetGroupTempValue(context,"temp_ball_current_count",0,{})
--记录当前处于哪组捡球小挑战。(完成的时候根据这个判断完成了哪组)
ScriptLib.SetGroupTempValue(context,"Ball_Cfgid",ball_id,{})
--计时
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_StartBall:_time=".._time)
ScriptLib.InitTimeAxis(context,"Ball_Challenge",{_time},false)
else
--其他的大球暂时隐藏
ScriptLib.SetGadgetStateByConfigId(context,k,201)
end
end
if _get_config_suc == false then ScriptLib.PrintGroupWarning(context,"## Activity_WindMaze_Normal LF_Try_StartBall:找不到吃球配置大球configid:"..ball_id) end
return 0
end
function LF_Try_FailBall(context)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_FailBall")
--结束捡球挑战
local _score = {
["is_start"] = false,
["is_success"] = false,
["challenge_time"] = 0,
["show_id"] = defs.ball_challenge_id,
}
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,_score)
--切回原挑战
local _score = {
["is_start"] = true,
["is_success"] = false,
["challenge_time"] = 180,
["show_id"] = defs.challenge_id,
}
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,_score)
local _cfgid = ScriptLib.GetGroupTempValue(context,"Ball_Cfgid",{})
for k,v in pairs(windball_list) do
if k == _cfgid then
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
ScriptLib.SetGadgetStateByConfigId(context,k,0)
else
--未完成的大球重新显示
if ScriptLib.GetGroupTempValue(context,"BigOrb_Is_Fisnish_"..k,{}) ~=1 then
ScriptLib.SetGadgetStateByConfigId(context,k,0)
end
end
end
--重置标记
ScriptLib.SetGroupTempValue(context,"Ball_Cfgid",0,{})
return 0
end
function LF_Try_FinishBall(context)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_FinishBall")
--结束捡球挑战
local _score = {
["is_start"] = false,
["is_success"] = true,
["challenge_time"] = 0,
["show_id"] = defs.ball_challenge_id,
}
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,_score)
--切回原挑战
local _score = {
["is_start"] = true,
["is_success"] = false,
["challenge_time"] = 180,
["show_id"] = defs.challenge_id,
}
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,_score)
--给大球计数+1
ScriptLib.ChangeGroupVariableValue(context,"element_ball",1)
--记录该组吃球已完成
local _cfgid = ScriptLib.GetGroupTempValue(context,"Ball_Cfgid",{})
ScriptLib.SetGroupTempValue(context,"BigOrb_Is_Fisnish_".._cfgid,1,{})
--重置其他大球
for k,v in pairs(windball_list) do
if ScriptLib.GetGroupTempValue(context,"BigOrb_Is_Fisnish_"..k,{}) ~= 1 then
ScriptLib.SetGadgetStateByConfigId(context,k,0)
end
end
--重置标记
ScriptLib.SetGroupTempValue(context,"Ball_Cfgid",0,{})
--停掉计时器
ScriptLib.EndTimeAxis(context,"Ball_Challenge")
--通知LD完成,值为大球的id
ScriptLib.SetGroupVariableValue(context,"Ball_Challenge_Finish",_cfgid)
--watcher单局收集风元素球数量
local _uidlist = ScriptLib.GetSceneUidList(context)
if _uidlist == nil then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_StartBall:_uidlist == nil")
return 0
end
if level_list == nil then
return 0
end
if level_list[base_info.group_id] == nil then
return 0
end
for i = 1 , #_uidlist do
ScriptLib.AddExhibitionReplaceableDataAfterSuccess(context, _uidlist[i], "Activity_WindField_"..level_list[base_info.group_id].."_Ball", 1, {play_type=ExhibitionPlayType.Gallery,gallery_id=defs.gallery_id})
end
return 0
end
function LF_Try_Start(context,show_id)
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_Start: is_start = true")
local uidlist = ScriptLib.GetSceneUidList(context)
if uidlist == nil then
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_StartBall:uidlist == nil")
return 0
end
ScriptLib.PrintContextLog(context,"## Activity_WindMaze_Normal LF_Try_Start: #uidlist = "..#uidlist)
ScriptLib.SetPlayerStartGallery(context,defs.gallery_id,uidlist)
local _score = {
["is_start"] = true,
["is_success"] = false,
["challenge_time"] = 180,
["show_id"] = defs.challenge_id,
}
ScriptLib.UpdatePlayerGalleryScore(context,defs.gallery_id,_score)
return 0
end
--初始化
function Initialize()
--加触发器
if temp_Tirgger ~= nil then
for k,v in pairs(temp_Tirgger) do
v.name = v.action
v.config_id = 40000000 + k
v.trigger_count = 0
v.condition = ""
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
end
--加变量
if temp_Variables ~= nil then
for k,v in pairs(temp_Variables) do
v.config_id = 50000000 + k
table.insert(variables,v)
end
end
return 0
end
Initialize()

View File

@ -0,0 +1,186 @@
--[[======================================
|| filename: CampChallenge
|| owner: juntao.chen
|| description:
|| LogName: CampChallenge
|| Protection: [Protection]
=======================================]]
--需求defs
--[[
local defs = {
challenge_id = 111,
enter_region = 1,
leave_region = 1,
trigger_time = 1
}
]]
local buff_id_list = {
[2010060] = 1,
[2010061] = 3,
[2010062] = 2,
[2010063] = 3,
[2010064] = 1,
}
local temp_Variables = {
{ config_id=50000001,name = "SET_TRIGGER", value = 0, no_refresh = true },
}
local temp_Tirgger = {
{event = EventType.EVENT_ENTER_REGION, source = "", action = "action_EVENT_ENTER_REGION",forbid_guest = false},
{event = EventType.EVENT_LEAVE_REGION, source = "", action = "action_EVENT_LEAVE_REGION",forbid_guest = false},
{event = EventType.EVENT_VARIABLE_CHANGE, source = "SET_TRIGGER", action = "EVENT_VARIABLE_CHANGE_SET_TRIGGER",tag = "111"},
{event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", action = "action_EVENT_CHALLENGE_SUCCESS"},
{event = EventType.EVENT_CHALLENGE_FAIL, source = "", action = "action_EVENT_CHALLENGE_FAIL"},
{event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", action = "action_EVENT_GADGET_STATE_CHANGE"},
--{event = EventType.EVENT_MONSTER_BATTLE, source = "", action = "action_EVENT_MONSTER_BATTLE"}, --不需要了
}
--[[ function action_EVENT_MONSTER_BATTLE(context,evt)
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_MONSTER_BATTLE ")
return 0
end
]]
--风种子被拾取,传日志
function action_EVENT_GADGET_STATE_CHANGE(context,evt)
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_GADGET_STATE_CHANGE ")
if evt.param1 ~= 201 then return 0 end
if ScriptLib.GetGadgetIdByEntityId(context,evt.source_eid) ~= 70800251 then return 0 end
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_GADGET_STATE_CHANGE 风种子被拾取")
--【【3.1 backlog内】数据埋点 - 蒙德佳酿节TD相关运营埋点】
--https://www.tapd.cn/22963631/prong/stories/view/1122963631001540454
local _trans = ScriptLib.GetChallengeTransaction(context, defs.challenge_id)
ScriptLib.MarkGroupLuaAction(context, "Vintage_Camp_4",_trans,{})
return 0
end
--挑战失败,传日志
function action_EVENT_CHALLENGE_FAIL(context,evt)
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_CHALLENGE_FAIL ")
--【【3.1 backlog内】数据埋点 - 蒙德佳酿节TD相关运营埋点】
--https://www.tapd.cn/22963631/prong/stories/view/1122963631001540454
ScriptLib.MarkGroupLuaAction(context, "Vintage_Camp_3",evt.param_str1,{})
--失败后删掉额外suite
ScriptLib.RefreshGroup(context,{group_id = base_info.group_id, suite = init_config.suite})
return 0
end
--挑战成功关grouplink、传日志
function action_EVENT_CHALLENGE_SUCCESS(context,evt)
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_CHALLENGE_SUCCESS ")
--移除ability region(该操作会导致被移除的region触发leave_region,顺便会恢复visionType)
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.REGION, defs.leave_region)
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.REGION, defs.enter_region)
--bundle完成
ScriptLib.FinishGroupLinkBundle(context, base_info.group_id)
return 0
end
--挑战进度变化,传日志
function EVENT_VARIABLE_CHANGE_SET_TRIGGER(context,evt)
ScriptLib.PrintContextLog(context, "## CampChallenge : EVENT_VARIABLE_CHANGE_SET_TRIGGER ")
--【【3.1 backlog内】数据埋点 - 蒙德佳酿节TD相关运营埋点】
--https://www.tapd.cn/22963631/prong/stories/view/1122963631001540454
local _trans = ScriptLib.GetChallengeTransaction(context, defs.challenge_id)
ScriptLib.MarkGroupLuaAction(context, "Vintage_Camp_2",_trans,{["cur_progress"] = evt.param1,["total_progress"]= defs.trigger_time})
return 0
end
--主客机进区域设置visiontype主机进区域开挑战、恢复suite内容、传日志
function action_EVENT_ENTER_REGION(context,evt)
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_ENTER_REGION:evt.param1 = "..evt.param1.."uid = "..evt.uid)
if evt.param1 ~= defs.enter_region then
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_ENTER_REGION:".." evt.param1 ~= defs.enter_region")
return 0
end
-- 主客机都设置visionType
ScriptLib.SetPlayerGroupVisionType(context, {evt.uid}, {0})
if evt.uid ~= ScriptLib.GetSceneOwnerUid(context) then --剩余操作只对主机执行
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_ENTER_REGION:".."evt.uid ~= ScriptLib.GetSceneOwnerUid(context) ")
return 0
end
if ScriptLib.IsChallengeStartedByChallengeIndex(context,base_info.group_id,defs.challenge_id) == true then
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_ENTER_REGION:".." ScriptLib.IsChallengeStartedByChallengeIndex(context,base_info.group_id,defs.challenge_id) == true ")
return 0
end
local _cur_count = ScriptLib.GetGroupVariableValue(context,"SET_TRIGGER")
if _cur_count >= defs.trigger_time then
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_ENTER_REGION:".."_cur_count >= defs.trigger_time")
ScriptLib.FinishGroupLinkBundle(context, base_info.group_id)--保底再次finish一下
return 0 --进度已完成,不开挑战
end
--开挑战
ScriptLib.StartChallenge(context, defs.challenge_id, defs.challenge_id, {3, 111, defs.trigger_time, 1, _cur_count})
--【【3.1 backlog内】数据埋点 - 蒙德佳酿节TD相关运营埋点】
--https://www.tapd.cn/22963631/prong/stories/view/1122963631001540454
local _trans = ScriptLib.GetChallengeTransaction(context, defs.challenge_id)
ScriptLib.MarkGroupLuaAction(context, "Vintage_Camp_1",_trans,{})
--恢复suite内容
if Phase == nil then
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_ENTER_REGION LD注意没有配置Phase")
return 0
end
local _p = ScriptLib.GetGroupVariableValue(context,"STAGE")
if _p ==0 then
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_ENTER_REGION LD注意没有找到Variable:STAGE")
return 0
end
if Phase[_p] == nil then
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_ENTER_REGION LD注意没有找到STAGE=".._p.."对应的suite配置")
return 0
end
for i = 1 , #Phase[_p] do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, Phase[_p][i])
end
return 0
end
--主客机出区域恢复visiontype 主机出区域挑战失败、group重置
function action_EVENT_LEAVE_REGION(context,evt)
ScriptLib.PrintContextLog(context, "## CampChallenge : action_EVENT_LEAVE_REGION evt.param1="..evt.param1 .. "|defs.leave_region = "..defs.leave_region)
if evt.param1 ~= defs.leave_region then return 0 end
--主客机离开恢复visionType
ScriptLib.SetPlayerGroupVisionType(context, {evt.uid}, {1})
if evt.uid ~= ScriptLib.GetSceneOwnerUid(context) then
return 0
end
--主机离开关挑战
if ScriptLib.IsChallengeStartedByChallengeIndex(context,base_info.group_id,defs.challenge_id) == true then
ScriptLib.StopChallenge(context, defs.challenge_id, 0)
end
return 0
end
--初始化
function Initialize()
--加触发器
if temp_Tirgger ~= nil then
for k,v in pairs(temp_Tirgger) do
v.name = v.action
v.config_id = 40000000 + k
v.trigger_count = 0
v.condition = ""
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
end
--加变量
if temp_Variables ~= nil then
for k,v in pairs(temp_Variables) do
table.insert(variables,v)
end
end
return 0
end
Initialize()

View File

@ -0,0 +1,498 @@
--2.5换人挑战玩法
--ServerUploadTool Save to [/root/env/data/lua/common/V2_5]
--miscs配置内容
--[[
54
352
--fever进度升级节点
local fever_progress_table = {
0,40,120,270,570,800
}
--各等级fever的下降速率
local fever_attenuation = {
-1,-1,-2,-2,-3
}
--地城对应的天气配置
local DungeonWeather = {
10039,10040,10041,10042
}
--怪物潮
local monster_tide = {
[1] = {2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2048,2049,2050,2051},
[2] = {2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2052,2053,2054,2055},
[3] = {2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2056,2057,2058,2059},
[4] = {2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2056,2057,2058,2059},
[5] = {2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2056,2057,2058,2059},
}
local defs = {
group_id = 235801002,
worktop_id = 123, --操作台对应的操作数
air_wall = 2005, --场内空气墙对应的ConfigID
minion_fever = 5, --普通怪物死亡增加的热度值
game_time = 360, --挑战时间
min_monster_count = 5, --场上最少怪物数量
max_monster_count = 5, --场上最多怪物数量
environment_suite = 4, --环境灯光所在的Suite
noswitch_punishment_interval = 30, --不换人开始有惩罚的最小时间间隔
num_killed_per_tide = {20, 20, 20, 20, 0} --每组怪物潮对应需要的杀怪数量
}
--配置一个region,覆盖场内的战斗空间,用来在玩家进入时创建空气墙
]]
local local_defs = {
worktop_option = 30110,
progress_key = 1,
team_global_value = "FEVER_LEVEL",
team_noswitch_pubishment = "NOSWITCH_PUNISHMENT",
team_has_switch = "HAS_SWITCHED_TEAM",
burn_effect_level = 2,
environment_change_level = 1,
base_upgrade_reminder = 358010102,
team_noswitch_pubishment_reminder = 144,
punish_inAdvance_reminder = 201
}
local time_axis = {
--扣分时间轴,每秒掉一定的分数
fever_axis = {1},
noswitch_punishment_axis = {defs.noswitch_punishment_interval},
noswitch_punishment_inAdvance_axis = {defs.noswitch_punishment_interval-(defs.punish_inAdvance_reminder_time or 3)}
}
local Tri = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "select_option", config_id = 8000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[3] = { name = "time_axis_pass", config_id = 8000003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[4] = { name = "gallery_progress_pass", config_id = 8000004, event = EventType.EVENT_GALLERY_PROGRESS_PASS, source = "", condition = "", action = "action_gallery_progress_pass", trigger_count = 0},
[5] = { name = "monster_tide_die", config_id = 8000005, event = EventType.EVENT_MONSTER_TIDE_DIE, source = "", condition = "", action = "action_monster_tide_die", trigger_count = 0},
[6] = { name = "monster_die_before_leave_scene", config_id = 8000006, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[7] = { name = "gallery_stop", config_id = 8000007, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
[8] = { name = "sumo_switch_team", config_id = 8000008, event = EventType.EVENT_SUMO_SWITCH_TEAM_EVENT, source = "", condition = "", action = "action_sumo_switch_team", trigger_count = 0},
[9] = { name = "dungeon_all_avatar_die", config_id = 8000009, event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_dungeon_all_avatar_die", trigger_count = 0},
[10] = { name = "dungeon_settle", config_id = 8000010, event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_dungeon_settle", trigger_count = 0},
[11] = { name = "enter_start_region", config_id = 8000011, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_start_region", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for config_id,infos in pairs(monsters) do
table.insert(infos.affix, 9009)
end
table.insert(variables,{ config_id=50000001,name = "current_monster_tide", value = 0})
table.insert(variables,{ config_id=50000002,name = "current_elite", value = 1})
table.insert(variables,{ config_id=50000003,name = "fever_ratio", value = 1})
--用于记录当前是否开启不换队惩罚,用于客户端断线重连时恢复状态
table.insert(variables,{ config_id=50000004,name = "is_noswitch_punishment", value = 0})
--用于记录当前怪物潮中的击杀数量,当击杀数量达到配置数量时,加载下一波怪物潮
table.insert(variables,{ config_id=50000005,name = "num_current_minion_killed", value = 0})
--用于记录是否已经创建空气墙,防止玩家卡在空气墙外
table.insert(variables,{ config_id=50000006,name = "is_air_wall_created", value = 0})
--用于记录当前怪物潮是否处于切换状态
table.insert(variables,{ config_id=50000007,name = "is_tide_being_switched", value = 0})
end
------------------------------------------------------------------
--group load后加载操作台选项
function action_group_load(context,evt)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, defs.worktop_id, {local_defs.worktop_option})
--开场就直接加载氛围物件,不要等玩家开启挑战
--加载环境氛围物件
ScriptLib.AddExtraGroupSuite(context,defs.group_id, defs.environment_suite)
return 0
end
--按下操作台按键,启动玩法
function action_select_option(context,evt)
--如果空气墙没有提前创建,那么不会处理开始事件
if 1~= ScriptLib.GetGroupVariableValue(context,"is_air_wall_created") then
return -1
end
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, defs.worktop_id, local_defs.worktop_option)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.worktop_id, GadgetState.GearStop)
LF_Start_Play(context)
return 0
end
--时间轴tick事件根据tick的时间轴不同处理不同逻辑
function action_time_axis_pass(context,evt)
--纯数量刷怪不再走刷怪Tick
--fever条tick扣分
if (evt.source_name == "FEVER_AXIS") then
LF_Update_Fever(context,LF_Get_Fever_Subnum(context))
end
--提前显示一下需要换队
if (evt.source_name == "NOSWITCH_PUNISHMENT_INADVANCE_AXIS") then
ScriptLib.ShowTemplateReminder(context, local_defs.punish_inAdvance_reminder, {defs.punish_inAdvance_reminder_time or 3})
end
--不换队tick如果长时间不换队则将设置惩罚gv
if (evt.source_name == "NOSWITCH_PUNISHMENT_AXIS") then
ScriptLib.ShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {0})
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",1)
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,1)
end
return 0
end
--fever升级时给team挂global value并激活场景氛围物件
function action_gallery_progress_pass(context,evt)
local fever_level = evt.param1
ScriptLib.PrintContextLog(context,"FS: Fever uprade to level "..fever_level)
ScriptLib.ShowReminder(context, local_defs.base_upgrade_reminder+fever_level)
LF_Set_Team_Global_Value(context,local_defs.team_global_value,fever_level)
LF_Activate_Environment_Gadget(context,fever_level)
return 0
end
function action_gallery_stop(context,evt)
LF_Stop_Play(context)
return 0
end
--当前的怪物潮刷完的时候,重置当前的怪物潮或者刷下一波怪物潮
function action_monster_tide_die(context,evt)
-- ScriptLib.PrintContextLog(context,"FS: Tide Clear"..evt.param1)
-- local is_being_switched = ScriptLib.GetGroupVariableValue(context,"is_tide_being_switched")
-- ScriptLib.PrintContextLog(context,"FS: Tide Switch"..is_being_switched)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
local current_tide_list = monster_tide[current_monster_tide]
-- ScriptLib.PrintContextLog(context,"FS: Tide Max"..(#current_tide_list))
--不在刷够怪物切换怪物潮的过程中
--如果当前怪物潮已经被杀完了
if evt.param1 >= #current_tide_list then
if defs.num_killed_per_tide[current_monster_tide] == 0 then
LF_Refresh_Monster_Tide(context,"Current")
else
LF_Refresh_Monster_Tide(context,"Next")
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 fever_ratio = ScriptLib.GetGroupVariableValue(context,"fever_ratio")
local monster_fever = monsters[monster_cid].kill_score
LF_Update_Fever(context,monster_fever*fever_ratio)
LF_Update_Score(context,monster_eid)
return 0
end
function LF_Refresh_Monster_Tide(context, refresh_mode)
local current_monster_tide_index = LF_Get_Current_Monster_Tide(context)
-- ScriptLib.KillMonsterTide(context, defs.group_id, LF_Get_Current_Tide_Num(context))
-- ScriptLib.SetGroupVariableValue(context,"is_tide_being_switched",1)
if refresh_mode == "Current" then
LF_Set_Current_Monster_Tide(context, current_monster_tide_index)
LF_Create_Monster_Tide(context,current_monster_tide_index)
ScriptLib.PrintContextLog(context,"FS: Tide Clear Refresh Current")
end
if refresh_mode == "Next" then
LF_Set_Current_Monster_Tide(context, current_monster_tide_index + 1)
LF_Create_Monster_Tide(context,current_monster_tide_index + 1)
ScriptLib.PrintContextLog(context,"FS: Tide Clear Refresh Next")
end
-- LF_Set_Current_Tide_Minion_Killed(context,0)
-- ScriptLib.SetGroupVariableValue(context,"is_tide_being_switched",0)
end
--玩家换队时触发启动一个一定时间的时间轴时间轴tick时修改global value给玩家挂debuff
function action_sumo_switch_team(context,evt)
--刚刚换队先清掉team上的换队惩罚global value并开始计时如果tick时没有换队则挂上惩罚标记gv
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.EndTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS")
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
--清理换队提示
ScriptLib.EndTimeAxis(context,"NOSWITCH_PUNISHMENT_INADVANCE_AXIS")
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_INADVANCE_AXIS",time_axis.noswitch_punishment_inAdvance_axis,false)
--换队增加热情值
LF_Update_Fever(context,defs.switch_team_fever)
--换队的时候给服务端发送消息让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
if uid_list and nil~=uid_list[1]then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
end
--清除当前显示的换队惩罚的reminder
local uid_list = ScriptLib.GetSceneUidList(context)
local ret = ScriptLib.RevokePlayerShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {})
ScriptLib.RevokePlayerShowTemplateReminder(context, local_defs.punish_inAdvance_reminder, {})
ScriptLib.PrintContextLog(context,"FS: Clear reminder result"..ret)
--换队的时候修改team的gv重新刷一下新的avatar身上的加成效果
LF_Set_Team_Global_Value(context,local_defs.team_has_switch,1)
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",0)
return 0
end
--玩家进入区域直接创建空气墙,防止卡延迟出圈
function action_enter_start_region(context,evt)
--加载空气墙
ScriptLib.CreateGadget(context,{config_id = defs.air_wall})
ScriptLib.SetGroupVariableValue(context,"is_air_wall_created",1)
return 0
end
--团灭触发,直接结束玩法
function action_dungeon_all_avatar_die(context,evt)
LF_Stop_Play(context)
return 0
end
function action_dungeon_settle(context,evt)
LF_Stop_Play(context)
return 0
end
------------------------------------------------------------------
--辅助方法---------------------------------------------------------
------------------------------------------------------------------
--关卡相关方法-----------------------------------------------------
--启动玩法方法,初始化各种东西
function LF_Start_Play(context)
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.InitGalleryProgressScore(context, "fever", defs.gallery_id, fever_progress_table, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_SUMO_STAGE, GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NO_DEGRADE)
ScriptLib.InitTimeAxis(context,"FEVER_AXIS",time_axis.fever_axis,true)
LF_Set_Current_Tide_Num(context,0)
LF_Set_Current_Monster_Tide(context,1)
LF_Create_Monster_Tide(context,1)
--启动玩法时给第一队挂一下gv防止一开始就受到惩罚并开启时间轴开始计时
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_INADVANCE_AXIS",time_axis.noswitch_punishment_inAdvance_axis,false)
--玩法开始的时候给服务端发送消息让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
if uid_list and nil~=uid_list[1]then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
end
end
--终止玩法方法,关掉各种东西
function LF_Stop_Play(context)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
--清理一下空气墙,防止其他问题
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.GADGET, defs.air_wall)
--玩法结束,清理掉当前的怪物潮
ScriptLib.KillMonsterTide(context, defs.group_id, current_monster_tide)
ScriptLib.StopGallery(context, defs.gallery_id,true)
ScriptLib.EndTimeAxis(context,"FEVER_AXIS")
--关闭一下地城,以正确触发重新挑战
ScriptLib.CauseDungeonFail(context)
end
--启动一波指定ID的怪物潮需要传入该波怪物潮的ID具体配置在miscs中定义
function LF_Create_Monster_Tide(context,monster_tide_index)
ScriptLib.PrintContextLog(context,"FS: Creating monster tide ["..monster_tide_index.."]")
local monster_config_id_list = monster_tide[monster_tide_index]
--增加怪物潮的计数下一次开启时index会+1防止索引到同一波怪物潮
local tide_num = LF_Get_Current_Tide_Num(context)
LF_Set_Current_Tide_Num(context,tide_num+1)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
ScriptLib.AutoMonsterTide(context, tide_num+1, defs.group_id, monster_config_id_list, #monster_config_id_list, tide_suite_config[current_monster_tide].min, tide_suite_config[current_monster_tide].max)
end
--刷新指定
--通用类方法-------------------------------------------------------
--切换场上的场景氛围物件状态
function LF_Activate_Environment_Gadget(context,fever_level)
ScriptLib.PrintContextLog(context,"FS: Activate environment gadgets! Fever Level_"..fever_level)
--根据当前的fever等级改变天气
if (fever_level>local_defs.environment_change_level) then
ScriptLib.PrintContextLog(context,"FS: Changing environment weather!")
local ret = ScriptLib.SetWeatherAreaState(context, DungeonWeather[fever_level],1)
ScriptLib.PrintContextLog(context,"FS: The result of starting weather ".. DungeonWeather[fever_level].."is "..ret)
local ret = ScriptLib.EnterWeatherArea(context, DungeonWeather[fever_level])
ScriptLib.PrintContextLog(context,"FS: The result of changing weather".. DungeonWeather[fever_level].."is "..ret)
end
--切换场上所有的物件的状态
for i = 1, #suites[defs.environment_suite].gadgets do
local config_id = suites[defs.environment_suite].gadgets[i]
local gadget_id = LF_Get_Gadget_Id_By_Config_Id(context,config_id)
--大小火盆
if (gadget_id == 70350306 or gadget_id == 70350307) then
if (fever_level<local_defs.burn_effect_level) then
--点燃小火
--ScriptLib.PrintContextLog(context,"FS: Burn little fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 101)
end
if (fever_level<#fever_progress_table-2 and fever_level>=local_defs.burn_effect_level) then
--喷大火5秒后转回小火
--ScriptLib.PrintContextLog(context,"FS: Burn middle fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
if (fever_level >= #fever_progress_table-2) then
--持续喷大火
--ScriptLib.PrintContextLog(context,"FS: Burn super fire!")
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 202)
end
end
--挂灯
if (gadget_id == 70350308) then
if (fever_level>=local_defs.burn_effect_level) then
--点燃小火
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
end
--场景氛围
if (gadget_id == 70350309) then
--转到对应的gadgetStatedefault-0、phase1-201、phase2-202、phase3-203、phase4-204
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 200+fever_level)
end
end
end
--给team挂global value角色处理各种特殊效果
function LF_Set_Team_Global_Value(context,gv_name,value)
--ScriptLib.PrintContextLog(context,"FS: Sending global values to team!")
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, gv_name, value)
end
-----CRUD类方法----------------------------------------------------
--更新fever条fever_delta为fever条改变值
function LF_Update_Fever(context,fever_delta)
-- ScriptLib.PrintContextLog(context,"FS: Update Fever!")
ScriptLib.AddGalleryProgressScore(context, "fever", defs.gallery_id, fever_delta)
end
--更新积分需要传入目标monster的entity id
function LF_Update_Score(context,monster_eid)
-- ScriptLib.PrintContextLog(context,"FS: Update Score!")
local uid_list = ScriptLib.GetSceneUidList(context)
local monster_id = ScriptLib.GetMonsterIdByEntityId(context,monster_eid)
if uid_list and nil~=uid_list[1]then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["monster_id"] = monster_id})
end
end
--返回当前等级下的积分衰减速率
function LF_Get_Fever_Subnum(context)
local fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
for i = 1, #fever_progress_table-1 do
local lower_bound = fever_progress_table[i]
local higher_bound = fever_progress_table[i+1]
if fever>=lower_bound and fever<higher_bound then
return fever_attenuation[i]
end
end
return -1
end
--设置当前怪物潮的波次数注意不等于怪物潮的index。每次创建怪物潮会使波次数+1方便索引新的怪物潮
function LF_Set_Current_Tide_Num(context,value)
ScriptLib.SetGroupTempValue(context, "MinionTide", value, {})
end
--获取当前怪物潮的波次数注意不等于怪物潮的index。每次创建怪物潮会使波次数+1方便索引新的怪物潮
function LF_Get_Current_Tide_Num(context)
return ScriptLib.GetGroupTempValue(context, "MinionTide", {})
end
--设置当前怪物潮波次的index
function LF_Set_Current_Monster_Tide(context,index)
ScriptLib.SetGroupVariableValue(context,"current_monster_tide",index)
end
--获取当前怪物潮波次的index
function LF_Get_Current_Monster_Tide(context)
local monster_tide = ScriptLib.GetGroupVariableValue(context,"current_monster_tide")
return monster_tide
end
--2.5新增
--获取当前怪物潮的击杀数量
function LF_Get_Current_Tide_Minion_Killed(context)
local num_minion_killed = ScriptLib.GetGroupVariableValue(context,"num_current_minion_killed")
return num_minion_killed
end
--增加当前怪物潮的击杀数量
function LF_Add_Current_Tide_Minion_Killed(context, num)
ScriptLib.ChangeGroupVariableValue(context,"num_current_minion_killed",num)
end
--设置当前怪物潮的击杀数量
function LF_Set_Current_Tide_Minion_Killed(context, num)
ScriptLib.SetGroupVariableValue(context,"num_current_minion_killed", num)
end
--根据gadget的config_id查询gadget_id
function LF_Get_Gadget_Id_By_Config_Id(context, config_id)
return gadgets[config_id].gadget_id
end
------------------------------------------------------------------
--server lua call-------------------------------------------------
function SLC_Update_Fever_Ratio(context,new_fever_ratio)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Changing fever ratio to: "..new_fever_ratio)
ScriptLib.SetGroupVariableValue(context,"fever_ratio",new_fever_ratio)
return 0
end
--向客户端下发当前的惩罚状态和fever值用于客户端重连时请求
function SLC_Refresh_Team_State(context)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Request for refresh punishment state: ")
local is_noswitch_punishment = ScriptLib.GetGroupVariableValue(context,"is_noswitch_punishment")
LF_Set_Team_Global_Value(context,"NOSWITCH_PUNISHMENT",is_noswitch_punishment)
local fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
LF_Set_Team_Global_Value(context,"fever",fever)
return 0
end
------------------------------------------------------------------
Initialize()

View File

@ -0,0 +1,693 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V2_5]
----fever进度升级节点
--local fever_progress_table = {
-- 0,50,100,200,300,500
--}
----各等级fever的下降速率
--local fever_attenuation = {
-- -1,-2,-3,-4,-5
--}
--
--local monster_tide = {
-- [1] = {2001,2002,2003,2004,2005,2006,2007},
-- [2] = {2008,2009,2010,2011,2012,2013,2014}
--}
--
--local elite = {
-- 2015,2016,2017,2018,2019,2020,2021
--}
--local elite = {
-- [1] = {2001},
-- [2] = {2011,2012},
-- [3] = {2038,2039},
-- [4] = {2040}
--}
--
--local elite_born_points = {
-- 3001,3002,3003,3004,3005,3006,3007
--}
--defs.punish_inAdvance_reminder_time = 3
------
--local defs = {
-- group_id = 235801002,
-- worktop_id = 123,
-- minion_fever = 5,
-- game_time = 360,
-- minion_interval = 120,
-- elite_interval = 30,
-- elite_fever = 50,
-- min_monster_count = 5,
-- max_monster_count = 5,
-- environment_suite = 4,
--}
local local_defs = {
worktop_option = 30110,
progress_key = 1,
team_global_value = "FEVER_LEVEL",
team_noswitch_pubishment = "NOSWITCH_PUNISHMENT",
team_has_switch = "HAS_SWITCHED_TEAM",
burn_effect_level = 2,
environment_change_level = 1,
base_upgrade_reminder = 358010102,
team_noswitch_pubishment_reminder = 144,
punish_inAdvance_reminder = 201
}
local time_axis = {
--小怪潮替换时间轴,每次触发时替换小怪潮
minion_tide_axis = {defs.minion_tide_interval},
--精英怪潮替换时间轴,每次触发时替换精英怪潮
elite_tide_axis = {defs.elite_tide_interval},
--精英怪时间轴,每次触发时刷新一只精英怪
elite_axis = {defs.elite_interval},
--扣分时间轴,每秒掉一定的分数
fever_axis = {1},
noswitch_punishment_axis = {defs.noswitch_punishment_interval},
noswitch_punishment_inAdvance_axis = {defs.noswitch_punishment_interval-(defs.punish_inAdvance_reminder_time or 3)}
}
local Tri = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "select_option", config_id = 8000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[3] = { name = "time_axis_pass", config_id = 8000003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[4] = { name = "gallery_progress_pass", config_id = 8000004, event = EventType.EVENT_GALLERY_PROGRESS_PASS, source = "", condition = "", action = "action_gallery_progress_pass", trigger_count = 0},
[5] = { name = "monster_tide_die", config_id = 8000005, event = EventType.EVENT_MONSTER_TIDE_DIE, source = "", condition = "", action = "action_monster_tide_die", trigger_count = 0},
[6] = { name = "monster_die_before_leave_scene", config_id = 8000006, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[7] = { name = "gallery_stop", config_id = 8000007, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
[8] = { name = "sumo_switch_team", config_id = 8000008, event = EventType.EVENT_SUMO_SWITCH_TEAM_EVENT, source = "", condition = "", action = "action_sumo_switch_team", trigger_count = 0},
[9] = { name = "dungeon_all_avatar_die", config_id = 8000009, event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_dungeon_all_avatar_die", trigger_count = 0},
[10] = { name = "dungeon_settle", config_id = 8000010, event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_dungeon_settle", trigger_count = 0},
[11] = { name = "enter_start_region", config_id = 8000011, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_start_region", trigger_count = 0},
-- [12] = { name = "monster_create", config_id = 8000012, event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "", action = "action_monster_create", trigger_count = 0},
[13] = { name = "monster_tide_over", config_id = 8000013, event = EventType.EVENT_MONSTER_TIDE_OVER, source = "", condition = "", action = "action_monster_tide_over", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for config_id,infos in pairs(monsters) do
table.insert(infos.affix, 9009)
end
table.insert(variables,{ config_id=50000001,name = "current_monster_tide", value = 0})
table.insert(variables,{ config_id=50000002,name = "current_elite", value = 1})
table.insert(variables,{ config_id=50000003,name = "fever_ratio", value = 1})
--用于记录当前是否开启不换队惩罚,用于客户端断线重连时恢复状态
table.insert(variables,{ config_id=50000004,name = "is_noswitch_punishment", value = 0})
--用于记录当前精英是否在场,精英在场时,怪物潮不做刷新
table.insert(variables,{ config_id=50000005,name = "is_elite_on_ground", value = 0})
--用于记录当前怪物潮是否结束,当精英死亡时判断当前怪物潮是否处于结束状态,如果是,则直接加载下一波怪物潮
table.insert(variables,{ config_id=50000006,name = "is_current_minion_tide_end", value = 0})
--用于记录是否已经创建空气墙,防止玩家卡在空气墙外
table.insert(variables,{ config_id=50000007,name = "is_air_wall_created", value = 0})
--用于记录场上的怪物总数,当需要切怪物潮时,需要先判断场上已经没有怪物了
table.insert(variables,{ config_id=50000008,name = "monster_count", value = 0})
--用于标记需要监听场上怪物死亡直到怪物数量为0
table.insert(variables,{ config_id=50000009,name = "last_end_tide", value = 0})
table.insert(variables,{ config_id=50000010,name = "refresh_end_tide", value = 0})
end
------------------------------------------------------------------
--group load后加载操作台选项
function action_group_load(context,evt)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, defs.worktop_id, {local_defs.worktop_option})
--开场就直接加载氛围物件,不要等玩家开启挑战
--加载环境氛围物件
ScriptLib.AddExtraGroupSuite(context,defs.group_id,defs.environment_suite)
return 0
end
--按下操作台按键,启动玩法
function action_select_option(context,evt)
--如果空气墙没有提前创建,那么不会处理开始事件
if 1~= ScriptLib.GetGroupVariableValue(context,"is_air_wall_created") then
return -1
end
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, defs.worktop_id, local_defs.worktop_option)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.worktop_id, GadgetState.GearStop)
LF_Start_Play(context)
return 0
end
--时间轴tick事件根据tick的时间轴不同处理不同逻辑
function action_time_axis_pass(context,evt)
--小怪时间轴tick将小怪潮的index指向下一位修改group variable
if (evt.source_name == "MINION_TIDE_AXIS") then
ScriptLib.PrintContextLog(context,"FS: MINION_TIDE_AXIS tick!")
LF_Refresh_Currtent_Monster_Tide(context)
end
--精英波次时间轴tick将精英怪的index指向下一位
if (evt.source_name == "ELITE_TIDE_AXIS") then
ScriptLib.PrintContextLog(context,"FS: ELITE_TIDE_AXIS tick!")
local current_elite_index = LF_Get_Current_Elite_Index(context)
LF_Set_Current_Elite_Index(context,current_elite_index+1)
end
--精英时间轴tick刷新下一只精英
if (evt.source_name == "ELITE_AXIS") then
ScriptLib.PrintContextLog(context,"FS: ELITE_AXIS tick!")
local current_elite_index = LF_Get_Current_Elite_Index(context)
LF_Create_Elite_Monster(context,current_elite_index)
--性能优化:刷出精英怪时,暂停怪物潮
ScriptLib.PrintContextLog(context,"FS: elite created. Stop monster tide ["..LF_Get_Current_Tide_Num(context).."]")
ScriptLib.PauseAutoMonsterTide(context, defs.group_id, LF_Get_Current_Tide_Num(context))
end
--fever条tick扣分
if (evt.source_name == "FEVER_AXIS") then
LF_Update_Fever(context,LF_Get_Fever_Subnum(context))
end
--提前显示一下需要换队
if (evt.source_name == "NOSWITCH_PUNISHMENT_INADVANCE_AXIS") then
ScriptLib.ShowTemplateReminder(context, local_defs.punish_inAdvance_reminder, {defs.punish_inAdvance_reminder_time or 3})
end
--不换队tick如果长时间不换队则将设置惩罚gv
if (evt.source_name == "NOSWITCH_PUNISHMENT_AXIS") then
--ScriptLib.PrintContextLog(context,"FS: Showing reminder "..local_defs.team_noswitch_pubishment_reminder)
ScriptLib.ShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {0})
--ScriptLib.ShowReminder(context, local_defs.team_noswitch_pubishment_reminder)
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",1)
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,1)
end
return 0
end
--fever升级时给team挂global value并激活场景氛围物件
function action_gallery_progress_pass(context,evt)
local fever_level = evt.param1
ScriptLib.PrintContextLog(context,"FS: Fever uprade to level "..fever_level)
ScriptLib.ShowReminder(context, local_defs.base_upgrade_reminder+fever_level)
LF_Set_Team_Global_Value(context,local_defs.team_global_value,fever_level)
LF_Activate_Environment_Gadget(context,fever_level)
return 0
end
function action_gallery_stop(context,evt)
LF_Stop_Play(context)
return 0
end
--当前的怪物潮刷完的时候,重置当前的怪物潮,这里只处理怪物潮的怪物
function action_monster_tide_die(context,evt)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
local tide_index = tonumber(evt.source_name)
local refresh_end_tide = ScriptLib.GetGroupVariableValue(context,"refresh_end_tide")
if tide_index == refresh_end_tide then
local elite_num = ScriptLib.GetGroupVariableValue(context,"is_elite_on_ground")
local monster_count = ScriptLib.GetGroupMonsterCount(context)
ScriptLib.PrintContextLog(context,"FS:[TIDE_DIE] 死亡的怪物来源于刷新时手动结束的怪物潮,剩余总怪物数量"..monster_count.."精英怪"..elite_num)
if monster_count == elite_num and elite_num ~= 0 then
ScriptLib.PrintContextLog(context,"FS:[TIDE_DIE] 场上仅剩精英怪,标记需要在精英怪死亡时创建新的怪物潮")
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",1)
end
if monster_count == 0 then
ScriptLib.PrintContextLog(context,"FS:[TIDE_DIE] 场上没有怪物了,直接创建")
LF_Create_Monster_Tide(context,current_monster_tide)
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",0)
end
return 0
end
--如果当前怪物潮已经被杀完了,且精英怪不在场
if (evt.param1 >= #monster_tide[current_monster_tide]) then
--标记非手动结束的怪物潮里的怪已经刷完了
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",1)
local is_elite_on_ground = ScriptLib.GetGroupVariableValue(context,"is_elite_on_ground")
ScriptLib.PrintContextLog(context,"FS:[TIDE_DIE] 怪物潮"..tide_index.."所有怪物清空")
if (is_elite_on_ground == 0) then
--精英不在场,才能开一个新的怪物潮
ScriptLib.PrintContextLog(context,"FS: [TIDE_DIE] 场上没有精英怪,获取当前对应波次,创建怪物潮")
LF_Create_Monster_Tide(context,current_monster_tide)
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",0)
end
end
return 0
end
--记录当前结束的MonsterTideIndex
function action_monster_tide_over(context, evt)
local end_index = tonumber(evt.source_name)
if end_index ~= nil then
ScriptLib.SetGroupVariableValue(context,"last_end_tide", end_index)
ScriptLib.PrintContextLog(context,"FS:[DEBUG][TIDE_OVER] 当前怪物潮结束,波次"..end_index)
end
return 0
end
--有怪死亡时计分并更新fever条这里只处理怪物计分和精英怪阻塞
function action_monster_die_before_leave_scene(context,evt)
local monster_eid = evt.source_eid
local monster_cid = evt.param1
local is_elite = LF_Is_Elite(context,monster_cid)
local fever_ratio = ScriptLib.GetGroupVariableValue(context,"fever_ratio")
local monster_fever = monsters[monster_cid].kill_score
LF_Update_Fever(context,monster_fever*fever_ratio)
LF_Update_Score(context,monster_eid)
--死的是精英怪,看看之前有没有阻塞
if is_elite then
--精英死亡时,检测该组刷新的精英怪数量,如果全部死亡就重新开始计时
local elite_num = ScriptLib.GetGroupVariableValue(context,"is_elite_on_ground")
if elite_num > 1 then
--场上还有别的精英怪
ScriptLib.SetGroupVariableValue(context,"is_elite_on_ground",elite_num-1)
else
ScriptLib.SetGroupVariableValue(context,"is_elite_on_ground",0)
ScriptLib.EndTimeAxis(context,"ELITE_AXIS")
ScriptLib.InitTimeAxis(context,"ELITE_AXIS",time_axis.elite_axis,false)
if ScriptLib.GetGroupVariableValue(context,"is_current_minion_tide_end") == 0 then
if not LF_Is_Current_Index_End(context) then
ScriptLib.PrintContextLog(context,"FS:[DEBUG][MonDie] 精英怪死亡当前怪物潮没有触发OVER继续刷新,波次"..LF_Get_Current_Tide_Num(context))
ScriptLib.ContinueAutoMonster(context, defs.group_id, LF_Get_Current_Tide_Num(context))
else
if 0 == ScriptLib.GetGroupMonsterCount(context) then
ScriptLib.PrintContextLog(context,"FS:[DEBUG] [MonDie]精英怪死亡当前怪物潮已经触发OVER且场上没有Monster重新创建怪物潮")
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
LF_Create_Monster_Tide(context,current_monster_tide)
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",0)
end
end
else
--当前怪物潮已经结束了,因为场上有精英怪被卡住了。精英死亡时,手动开启新的怪物潮
if 0 == ScriptLib.GetGroupMonsterCount(context) then
ScriptLib.PrintContextLog(context,"FS:[DEBUG][MonDie] 精英怪死亡且场上没有怪物,波次"..LF_Get_Current_Tide_Num(context))
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
LF_Create_Monster_Tide(context,current_monster_tide)
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",0)
end
end
end
end
return 0
end
--玩家换队时触发启动一个一定时间的时间轴时间轴tick时修改global value给玩家挂debuff
function action_sumo_switch_team(context,evt)
--刚刚换队先清掉team上的换队惩罚global value并开始计时如果tick时没有换队则挂上惩罚标记gv
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.EndTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS")
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
--清理换队提示
ScriptLib.EndTimeAxis(context,"NOSWITCH_PUNISHMENT_INADVANCE_AXIS")
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_INADVANCE_AXIS",time_axis.noswitch_punishment_inAdvance_axis,false)
--换队增加热情值
LF_Update_Fever(context,defs.switch_team_fever)
--换队的时候给服务端发送消息让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
if uid_list and nil~=uid_list[1]then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
end
--清除当前显示的换队惩罚的reminder
local uid_list = ScriptLib.GetSceneUidList(context)
local ret = ScriptLib.RevokePlayerShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {})
ScriptLib.RevokePlayerShowTemplateReminder(context, local_defs.punish_inAdvance_reminder, {})
ScriptLib.PrintContextLog(context,"FS: Clear reminder result"..ret)
--换队的时候修改team的gv重新刷一下新的avatar身上的加成效果
--ScriptLib.PrintContextLog(context,"FS: team has changed, team_has_change = 1")
LF_Set_Team_Global_Value(context,local_defs.team_has_switch,1)
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",0)
return 0
end
--玩家进入区域直接创建空气墙,防止卡延迟出圈
function action_enter_start_region(context,evt)
--加载空气墙
ScriptLib.CreateGadget(context,{config_id = defs.air_wall})
ScriptLib.SetGroupVariableValue(context,"is_air_wall_created",1)
return 0
end
--团灭触发,直接结束玩法
function action_dungeon_all_avatar_die(context,evt)
LF_Stop_Play(context)
return 0
end
function action_dungeon_settle(context,evt)
LF_Stop_Play(context)
return 0
end
------------------------------------------------------------------
--辅助方法---------------------------------------------------------
------------------------------------------------------------------
--关卡相关方法-----------------------------------------------------
--启动玩法方法,初始化各种东西
function LF_Start_Play(context)
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.InitGalleryProgressScore(context, "fever", defs.gallery_id, fever_progress_table, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_SUMO_STAGE, GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NO_DEGRADE)
ScriptLib.InitTimeAxis(context,"FEVER_AXIS",time_axis.fever_axis,true)
ScriptLib.InitTimeAxis(context,"MINION_TIDE_AXIS",time_axis.minion_tide_axis,true)
ScriptLib.InitTimeAxis(context,"ELITE_TIDE_AXIS",time_axis.elite_tide_axis,true)
ScriptLib.InitTimeAxis(context,"ELITE_AXIS",time_axis.elite_axis,false)
LF_Set_Current_Tide_Num(context,0)
LF_Set_Current_Monster_Tide(context,1)
LF_Set_Current_Elite_Index(context,1)
LF_Create_Monster_Tide(context,1)
--启动玩法时给第一队挂一下gv防止一开始就受到惩罚并开启时间轴开始计时
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_INADVANCE_AXIS",time_axis.noswitch_punishment_inAdvance_axis,false)
--玩法开始的时候给服务端发送消息让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
if uid_list and nil~=uid_list[1]then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
end
--加载空气墙
ScriptLib.CreateGadget(context,{config_id = defs.air_wall})
end
--终止玩法方法,关掉各种东西
function LF_Stop_Play(context)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
--清理一下空气墙,防止其他问题
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.GADGET, defs.air_wall)
--玩法结束,清理掉当前的怪物潮
if not LF_Is_Current_Index_End(context) then
ScriptLib.KillMonsterTide(context, defs.group_id, current_monster_tide)
end
ScriptLib.StopGallery(context, defs.gallery_id,true)
ScriptLib.EndTimeAxis(context,"FEVER_AXIS")
ScriptLib.EndTimeAxis(context,"MINION_TIDE_AXIS")
ScriptLib.EndTimeAxis(context,"ELITE_AXIS")
ScriptLib.EndTimeAxis(context,"ELITE_TIDE_AXIS")
--关闭一下地城,以正确触发重新挑战
ScriptLib.CauseDungeonFail(context)
end
--启动一波指定ID的怪物潮需要传入该波怪物潮的ID具体配置在miscs中定义
function LF_Create_Monster_Tide(context,monster_tide_index)
local monster_config_id_list = monster_tide[monster_tide_index]
--增加怪物潮的计数下一次开启时index会+1防止索引到同一波怪物潮
local tide_num = LF_Get_Current_Tide_Num(context)
LF_Set_Current_Tide_Num(context,tide_num+1)
ScriptLib.PrintContextLog(context,"FS: [DEBUG][CREATE] 创建怪物潮,怪物波次 ["..monster_tide_index.."]".."怪物潮INDEX"..(tide_num+1))
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
ScriptLib.AutoMonsterTide(context, tide_num+1, defs.group_id, monster_config_id_list, #monster_config_id_list, tide_suite_config[current_monster_tide].min, tide_suite_config[current_monster_tide].max)
end
--停止目前的怪物潮,下次刷新新配置的怪物潮
function LF_Refresh_Currtent_Monster_Tide(context)
ScriptLib.PrintContextLog(context,"FS:[DEBUG] [REFRESH]时间轴刷新怪物潮,标记当前怪物潮结束")
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
--标记当前怪物潮结束,如果怪物潮没有结束则手动结束
local tide_index = LF_Get_Current_Tide_Num(context)
ScriptLib.SetGroupVariableValue(context,"refresh_end_tide",tide_index)
if not LF_Is_Current_Index_End(context) then
ScriptLib.PrintContextLog(context,"FS:[DEBUG] [REFRESH]手动结束当前怪物潮")
ScriptLib.EndMonsterTide(context, defs.group_id, tide_index, 1)
end
-- ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",1)
LF_Set_Current_Monster_Tide(context,current_monster_tide+1)
--如果场上没有怪就直接创建
if 0 == ScriptLib.GetGroupMonsterCount(context) then
LF_Create_Monster_Tide(context,current_monster_tide+1)
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",0)
ScriptLib.PrintContextLog(context,"FS:[DEBUG] [REFRESH]更新怪物潮,刷新怪物,并且标记这一波怪没有结束")
end
end
--在随机的位置,刷新指定序列的精英怪
function LF_Create_Elite_Monster(context,elite_index)
local elite_list = elite[elite_index]
ScriptLib.PrintContextLog(context,"FS: Creating elite nums_"..#elite_list)
--生成一个点的序列表,每次随机的时候把结果踢出
local point_index = {}
local choices = {}
for i=1,#elite_born_points do
table.insert(point_index,i)
end
for i=1,#elite_list do
local randomNum = math.random(1,#point_index)
table.insert(choices, point_index[randomNum])
table.remove(point_index, randomNum)
end
for i=1,#elite_list do
for k,v in pairs(points) do
if elite_born_points[choices[i]] == v.config_id then
ScriptLib.PrintContextLog(context,"FS: Creating elite ["..elite_list[i].."] at point "..v.pos.x..","..v.pos.y..","..v.pos.z)
ScriptLib.CreateMonsterByConfigIdByPos(context, elite_list[i], v.pos, v.rot)
end
end
end
ScriptLib.SetGroupVariableValue(context,"is_elite_on_ground",#elite_list)
end
--从1~max间随机nums个
function LF_Random_Choice(max, nums)
local choices = {}
local list = {}
for i=1,nums do
local randomNum = math.random(1,#list)
table.insert(choices, list[randomNum])
table.remove(list, randomNum)
end
return choices
end
function LF_Is_Current_Index_End(context)
if LF_Get_Current_Tide_Num(context) > ScriptLib.GetGroupVariableValue(context,"last_end_tide") then
ScriptLib.PrintContextLog(context,"FS:[DEBUG] [JUDGE]判断当前怪物潮没有结束")
return false
end
ScriptLib.PrintContextLog(context,"FS:[DEBUG] [JUDGE] 判断当前怪物潮已经结束")
return true
end
--通用类方法-------------------------------------------------------
--切换场上的场景氛围物件状态
function LF_Activate_Environment_Gadget(context,fever_level)
ScriptLib.PrintContextLog(context,"FS: Activate environment gadgets!")
--根据当前的fever等级改变天气
if (fever_level>local_defs.environment_change_level) then
ScriptLib.PrintContextLog(context,"FS: Changing environment weather!")
local ret = ScriptLib.SetWeatherAreaState(context, DungeonWeather[fever_level],1)
--ScriptLib.PrintContextLog(context,"FS: The result of starting weather ".. DungeonWeather[fever_level].."is "..ret)
local ret = ScriptLib.EnterWeatherArea(context, DungeonWeather[fever_level])
--ScriptLib.PrintContextLog(context,"FS: The result of changing weather".. DungeonWeather[fever_level].."is "..ret)
end
--切换场上所有的物件的状态
for i = 1, #suites[defs.environment_suite].gadgets do
local config_id = suites[defs.environment_suite].gadgets[i]
local gadget_id = LF_Get_Gadget_Id_By_Config_Id(context,config_id)
--大小火盆
if (gadget_id == 70350306 or gadget_id == 70350307) then
if (fever_level<local_defs.burn_effect_level) then
--点燃小火
--ScriptLib.PrintContextLog(context,"FS: Burn little fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 101)
end
if (fever_level<#fever_progress_table-2 and fever_level>=local_defs.burn_effect_level) then
--喷大火5秒后转回小火
--ScriptLib.PrintContextLog(context,"FS: Burn middle fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
if (fever_level >= #fever_progress_table-2) then
--持续喷大火
--ScriptLib.PrintContextLog(context,"FS: Burn super fire!")
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 202)
end
end
--挂灯
if (gadget_id == 70350308) then
if (fever_level>=local_defs.burn_effect_level) then
--点燃小火
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
end
--场景氛围
if (gadget_id == 70350309) then
--转到对应的gadgetStatedefault-0、phase1-201、phase2-202、phase3-203、phase4-204
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 200+fever_level)
end
end
end
--给team挂global value角色处理各种特殊效果
function LF_Set_Team_Global_Value(context,gv_name,value)
--ScriptLib.PrintContextLog(context,"FS: Sending global values to team!")
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, gv_name, value)
end
-----CRUD类方法----------------------------------------------------
--更新fever条fever_delta为fever条改变值
function LF_Update_Fever(context,fever_delta)
ScriptLib.AddGalleryProgressScore(context, "fever", defs.gallery_id, fever_delta)
end
--更新积分需要传入目标monster的entity id
function LF_Update_Score(context,monster_eid)
local uid_list = ScriptLib.GetSceneUidList(context)
local monster_id = ScriptLib.GetMonsterIdByEntityId(context,monster_eid)
if uid_list and nil~=uid_list[1]then
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["monster_id"] = monster_id})
end
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
--增加场上的怪物总数
function LF_Add_MonsterCount(context, num)
-- local monster_count = ScriptLib.GetGroupVariableValue(context,"monster_count")
-- ScriptLib.SetGroupVariableValue(context,"monster_count", monster_count+num)
ScriptLib.ChangeGroupVariableValue(context,"monster_count",num)
end
function LF_Get_MonsterCount(context)
local monster_count = ScriptLib.GetGroupVariableValue(context,"monster_count")
return monster_count
end
--设置当前怪物潮的波次数注意不等于怪物潮的index。每次创建怪物潮会使波次数+1方便索引新的怪物潮
function LF_Set_Current_Tide_Num(context,value)
ScriptLib.SetGroupTempValue(context, "MinionTide", value, {})
end
--获取当前怪物潮的波次数注意不等于怪物潮的index。每次创建怪物潮会使波次数+1方便索引新的怪物潮
function LF_Get_Current_Tide_Num(context)
return ScriptLib.GetGroupTempValue(context, "MinionTide", {})
end
--设置当前大怪的进度index
function LF_Set_Current_Elite_Index(context,index)
ScriptLib.SetGroupVariableValue(context,"current_elite",index)
end
--获取当前大怪的进度index
function LF_Get_Current_Elite_Index(context)
local elite_index = ScriptLib.GetGroupVariableValue(context,"current_elite")
return elite_index
end
--设置当前怪物潮波次的index
function LF_Set_Current_Monster_Tide(context,index)
ScriptLib.SetGroupVariableValue(context,"current_monster_tide",index)
end
--获取当前怪物潮波次的index
function LF_Get_Current_Monster_Tide(context)
local monster_tide = ScriptLib.GetGroupVariableValue(context,"current_monster_tide")
return monster_tide
end
--根据config id 返回一个点位
function LF_Get_Point(context,point_cid)
for i = 1,#points do
if (points[i].config_id == point_cid) then
return points[i]
end
end
return -1
end
--根据gadget的config_id查询gadget_id
function LF_Get_Gadget_Id_By_Config_Id(context, config_id)
return gadgets[config_id].gadget_id
end
--返回一个指定configid的怪物是否是大怪
function LF_Is_Elite(context,monster_cid)
for i=1,#elite do
for k,cfg_id in pairs(elite[i]) do
if monster_cid == cfg_id then
return true
end
end
end
return false
end
------------------------------------------------------------------
--server lua call-------------------------------------------------
function SLC_Update_Fever_Ratio(context,new_fever_ratio)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Changing fever ratio to: "..new_fever_ratio)
ScriptLib.SetGroupVariableValue(context,"fever_ratio",new_fever_ratio)
return 0
end
--向客户端下发当前的惩罚状态和fever值用于客户端重连时请求
function SLC_Refresh_Team_State(context)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Request for refresh punishment state: ")
local is_noswitch_punishment = ScriptLib.GetGroupVariableValue(context,"is_noswitch_punishment")
LF_Set_Team_Global_Value(context,"NOSWITCH_PUNISHMENT",is_noswitch_punishment)
local fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
LF_Set_Team_Global_Value(context,"fever",fever)
return 0
end
------------------------------------------------------------------
Initialize()

View File

@ -0,0 +1,679 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_BaseBall
|| owner: weiwei.sun
|| description: 3.2
|| ServerGadgetremote体验
|| LogName: ## [CharAmuse_BaseBall]
|| Protection:
=======================================]]
--[[
local defs = {
local defs = {
--玩法范围region cube
play_region = 6010,
--进入时加载内容例如棒球发球机。依次为单人、2人…
enter_suites = {5,4,3,2},
--启动时加载内容例如史莱姆球。依次为单人、2人…
play_suites = {},
--玩法限时秒
limit_time = 60,
target = 15,
--射击波次 默认
order =
{
easy,
normal,
hard,
normal,
hard,
},
--射击波次 云锦
order_yunjin =
{
easy,
normal,
hard,
normal,
hard,
},
--从哪一波开始使每个发球机节奏不同0为不处理
diff_from = 0,
multi_shoot =
{ --有几个坐标就发几个球,坐标是相对于默认发射点的偏移
[21] = { {x = 0, z = 0}, {x = 0, z = 0}, {x = 0, z = 0} }
},
--波次随机池配置 {{射击模式}, {间隔}}
-- 1-单个普通 2-单个快速 3-双普 4-双快 5-三普 6-三快 7-左右旋 8-单快速左旋 9-(空) 10-单快速右旋 20以上-multi_shoot
seq =
{
},
easy=
{
{ {2,1,2,1,2}, {5,5,5,5,5} },
},
normal=
{
{ {2,1,2,1,2}, {4,4,4,4,5} },
},
hard=
{
{ {2,1,2,1,2}, {3,3,3,3,5} },
},
--球物件池
ball_pool =
{ --普通
[2] = {6006,6007,6008,6009,6031,6032,6033,6035},
--快速
[1] = {6023.6024.6025,6026,6035,6036,6037,6038},
--曲线左旋gadgetID70320050
[4] = {},
--曲线右旋gadgetID70320051
[3] = {},
},
--射击基准点位
shoot_points =
{
--1人
[1] ={6016},
--2人
[2] ={6002,6004},
--3人
[3] ={6011,6013,6017},
--4人
[4] ={6019,6021,6027,6029},
},
--连发间距 进行连发时,在基准点位每隔此距离创建一个球
multishoot_distance = 0.5,
}
}
]]
local cfg = {
--主控GroupID
main_group = 251008007,
-- 1-单个普通 2-单个快速 3-双普 4-双快 5-三普 6-三快 7-左右旋 8-单快速左旋 9-(空) 10-单快速右旋
shoot_info =
{
[1] = { ball_type = 2, shoot_count = 1, rot = { x = 0.000, y = 180.000, z = 0.000 }},
[2] = { ball_type = 1, shoot_count = 1, rot = { x = 0.000, y = 180.000, z = 0.000 }},
[3] = { ball_type = 2, shoot_count = 2, rot = { x = 0.000, y = 180.000, z = 0.000 }},
[4] = { ball_type = 1, shoot_count = 2, rot = { x = 0.000, y = 180.000, z = 0.000 }},
[5] = { ball_type = 2, shoot_count = 3, rot = { x = 0.000, y = 180.000, z = 0.000 }},
[6] = { ball_type = 1, shoot_count = 3, rot = { x = 0.000, y = 180.000, z = 0.000 }},
--[7] = { ball_type = 3, shoot_count = 2, rot = { x = 0.000, y = 220.000, z = 0.000 }},--双曲线配置在LF_Create_DualCurveBall
[8] = { ball_type = 3, shoot_count = 1, rot = { x = 0.000, y = 220.000, z = 0.000 }},
--[9] = { ball_type = 4, shoot_count = 1, rot = { x = 0.000, y = 157.000, z = 0.000 }},--空
[10] = { ball_type = 4, shoot_count = 1, rot = { x = 0.000, y = 140.000, z = 0.000 }},
[20] = { ball_type = 1, shoot_count = 1, rot = { x = 0.000, y = 180.000, z = 0.000 }}, -- multi_shoot慢速直线球
[30] = { ball_type = 2, shoot_count = 1, rot = { x = 0.000, y = 180.000, z = 0.000 }}, -- multi_shoot快速直线球
},
}
local extraTriggers = {
{ config_id = 8000001, name = "AirWallVariable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "air_wall", condition = "", action = "action_AirWallVariable_Change", trigger_count = 0 },
{ config_id = 8000002, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_Gallery_Stop", trigger_count = 0 },
{ config_id = 8000003, name = "Enter_Play_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Play_Region", trigger_count = 1, forbid_guest = false },
{ config_id = 8000004, name = "Interval_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_Interval_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000005, name = "Separate_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_Separate_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000006, name = "TimeAxis_StopGallery_Fail", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery_Fail", condition = "", action = "action_TimeAxis_StopGallery_Fail", trigger_count = 0 },
{ config_id = 8000007, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000008, name = "TimeAxis_StopGallery", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery", condition = "", action = "action_TimeAxis_StopGallery", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "air_wall", value = 0})
end
--主控调用
function EX_StartGallery(context, prev_context, gallery_id, is_last_level)
--根据当前人数加载玩法suite
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetGroupTempValue(context, "player_count", #uid_list, {})
if nil ~= defs.play_suites and nil ~= defs.play_suites[#uid_list] then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.play_suites[#uid_list])
end
ScriptLib.SetGroupTempValue(context, "is_last_level", is_last_level, {})
--开启gallery
ScriptLib.StartGallery(context, gallery_id)
ScriptLib.SetGroupTempValue(context, "gallery_id", gallery_id, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] EX_StartGallery. Gallery Started. player_count@"..#uid_list.." --------------")
--玩法启动
ScriptLib.SetGroupVariableValue(context, "air_wall", 0)
LF_Start_Play(context)
return 0
end
function action_Group_Load(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == ScriptLib.GetGroupVariableValue(context, "air_wall") then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
return 0
end
function action_AirWallVariable_Change(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == evt.param1 and 0 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
elseif 0 == evt.param1 and 1 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
end
return 0
end
--evt.param2: 1-失败 0-成功
function action_Gallery_Stop(context, evt)
--卸载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
end
--清除全部球
LF_ClearAllBalls(context)
--停止时间轴
ScriptLib.EndAllTimeAxis(context)
if 3 ~= evt.param3 then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
--ScriptLib.InitTimeAxis(context, "StopGallery_Fail", { 3 } , false) 9.21修改 失败不要延时结束
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
else
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)--最后一关无等待
if is_last_level then
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
else
ScriptLib.InitTimeAxis(context, "StopGallery", { 3 } , false)
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] Gallery stoped. reason@".. evt.param3.." --------------")
return 0
end
function action_Enter_Play_Region(context, evt)
--根据当前人数加载suite
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] Enter_Play_Region. player_count@"..#uid_list)
--地城Group没有卸载 TriggerCount 1 直接上就完了
if nil ~= defs.enter_suites and nil ~= defs.enter_suites[#uid_list] then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.enter_suites[#uid_list])
end
return 0
end
---------------------------------------------------------------------------------------------------------------
function LF_Start_Play(context)
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local target = 0
if player_count > 1 then
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, true)
else
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, false)
end
ScriptLib.SetGroupTempValue(context, "cur_score", target, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["max_score"]= target} )
--order_index: 当前执行到defs.order列表中的哪一位
ScriptLib.SetGroupTempValue(context, "order_index", 1, {})
--rand_index 本次在当前难度的池中,随机到哪一条发射序列
ScriptLib.SetGroupTempValue(context, "rand_index", 1, {})
--这个计数用于使TimeAxis名字不同
ScriptLib.SetGroupTempValue(context, "time_axis_index", 0, {})
--埋点计数
ScriptLib.SetGroupTempValue(context, "hit", 0, {})
ScriptLib.SetGroupTempValue(context, "wave_num", 0, {})
local order = defs.order
if 28008 == ScriptLib.GetGroupTempValue(context, "gallery_id", {}) then
order = defs.order_yunjin
end
if nil == order[1] or nil == defs.seq[order[1]] then
return 0
end
LF_StartSequenceShoot_Normal(context, defs.seq[order[1]])
return 0
end
function action_TimeAxis_StopGallery(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
return 0
end
function action_TimeAxis_StopGallery_Fail(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
return 0
end
function LF_HandleOrderFinish(context, is_normal)
--order_index ++
local ret = ScriptLib.ChangeGroupTempValue(context, "order_index", 1, {})
if -1 == ret then
ScriptLib.SetGroupTempValue(context, "order_index", 1, {})
end
local order_index = ScriptLib.GetGroupTempValue(context, "order_index", {})
if defs.high_reminder ~= nil and defs.high_from ~= nil and defs.high_from == order_index then
ScriptLib.ShowReminder(context, defs.high_reminder)
end
--区分云锦、北斗
local order = defs.order
if 28008 == ScriptLib.GetGroupTempValue(context, "gallery_id", {}) then
order = defs.order_yunjin
end
--全order结束则循环最后一order
if order_index > #order then
order_index = #order
ScriptLib.SetGroupTempValue(context, "order_index", order_index, {})
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] LF_HandleOrderFinish. is_normal@"..is_normal.." next order_index@".. order_index)
ScriptLib.ChangeGroupTempValue(context, "time_axis_index", 1, {})
--当前是齐射阶段
if 1 == is_normal then
--下一个是齐射还是不齐射
if 0 < defs.diff_from and order_index >= defs.diff_from then
LF_StartSequenceShoot_Diff(context, defs.seq[order[order_index]])
else
LF_StartSequenceShoot_Normal(context, defs.seq[order[order_index]])
end
else
LF_StartSequenceShoot_Diff(context, defs.seq[order[order_index]])
end
--埋点
ScriptLib.ChangeGroupTempValue(context, "wave_num", 1, {})
local hit = ScriptLib.GetGroupTempValue(context, "hit", {})
local wave_num = ScriptLib.GetGroupTempValue(context, "wave_num", {})
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_BaseBall", ScriptLib.GetDungeonTransaction(context), {["wave_num"] = wave_num, ["hit"] = hit})
ScriptLib.SetGroupTempValue(context, "hit", 0, {})
return 0
end
--启动时间轴 齐射
function LF_StartSequenceShoot_Normal(context, difficulty)
--取得波次
local order_index = ScriptLib.GetGroupTempValue(context, "order_index", {})
--取得当前发射序列
math.randomseed(ScriptLib.GetServerTime(context))
local rand_index = math.random(#difficulty)
local sequence = difficulty[rand_index]
if nil == sequence[1] or nil == sequence[2] then
return 0
end
ScriptLib.SetGroupTempValue(context, "rand_index", rand_index, {})
local time_axis_index = ScriptLib.GetGroupTempValue(context, "time_axis_index", {})
--起动该发射序列的时间轴
ScriptLib.InitTimeAxis(context, "interval_"..order_index.."_"..rand_index.."_"..time_axis_index, LF_MakeTimeAxis(context, sequence[2]), false)
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] LF_StartSequenceShoot_Normal. rand_index@"..rand_index)
--打出第一球
LF_CreateBall_All(context, sequence[1][1])
return 0
end
--启动时间轴 单个
function LF_StartSequenceShoot_Diff(context, difficulty)
--给每个起单独的时间轴
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
for k, shoot_point in pairs(defs.shoot_points[player_count]) do
math.randomseed(ScriptLib.GetServerTime(context))
local rand_index = math.random(#difficulty)
sequence = difficulty[rand_index]
if nil == sequence[1] or nil == sequence[2] then
return 0
end
local time_axis_index = ScriptLib.GetGroupTempValue(context, "time_axis_index", {})
ScriptLib.InitTimeAxis(context, tostring(shoot_point).."_"..rand_index.."_"..time_axis_index, LF_MakeTimeAxis(context, sequence[2]), false)
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] LF_StartSequenceShoot_Diff. InitTimeAxis@"..tostring(shoot_point).."_"..rand_index)
--打出第一球
LF_CreateBall_Single(context, shoot_point, sequence[1][1])
end
return 0
end
function action_Interval_TimeAxis_Pass(context, evt)
local name = string.sub(evt.source_name, 1, 8)
if "interval" ~= name then
return 0
end
local order_index = ScriptLib.GetGroupTempValue(context, "order_index", {})
local rand_index = ScriptLib.GetGroupTempValue(context, "rand_index", {})
local order = defs.order
if 28008 == ScriptLib.GetGroupTempValue(context, "gallery_id", {}) then
order = defs.order_yunjin
end
local difficulty = order[order_index]
local sequence = defs.seq[difficulty][rand_index]
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] Interval_TimeAxis_Pass. order_index@"..order_index.." difficulty@".. difficulty .." rand_index@"..rand_index.." evt.param1@"..evt.param1)
--时间轴中间点
if evt.param1 < #sequence[1] then
LF_CreateBall_All(context, sequence[1][evt.param1 + 1])
--时间轴结束
else
LF_HandleOrderFinish(context, 1)
end
return 0
end
function action_Separate_TimeAxis_Pass(context, evt)
local name = string.sub(evt.source_name, 1, 8)
if "interval" == name then
return 0
end
local order_index = ScriptLib.GetGroupTempValue(context, "order_index", {})
local order = defs.order
if 28008 == ScriptLib.GetGroupTempValue(context, "gallery_id", {}) then
order = defs.order_yunjin
end
if nil == order[order_index] then
return 0
end
--还原 发射点的config_id 和 射击序列的index
local div = string.find(evt.source_name, "_")
if nil == div then
return 0
end
local config_id = tonumber(string.sub(evt.source_name, 1, div - 1))
local rand_index = tonumber(string.sub(evt.source_name, div + 1, string.len(evt.source_name)))
--校验
local difficulty = defs.seq[order[order_index]]
local sequence = difficulty[rand_index]
if nil == gadgets[config_id] or nil == sequence then
return 0
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] Separate_TimeAxis_Pass. source_name@"..evt.source_name.. " config_id@"..config_id.." rand_index@"..rand_index)
--时间轴中间点
if evt.param1 < #sequence[1] then
LF_CreateBall_Single(context, gadgets[config_id], sequence[1][evt.param1 + 1])
--时间轴结束
else
LF_HandleOrderFinish(context, 0)
end
return 0
end
--全发射点创球
--shoot_type: 射击模式 1-单个普通 2-单个快速 3-双普 4-双快 5-三普 6-三快 7-单普通左旋 8-单快速左旋 9-单普通右旋 10-单快速右旋 20+ multi_shoot
function LF_CreateBall_All(context, shoot_type)
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] LF_CreateBall_All. shoot_type@"..shoot_type)
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
if 20 < shoot_type then
for k, shoot_point in pairs(defs.shoot_points[player_count]) do
local pos = {
x = gadgets[shoot_point].pos.x,
y = gadgets[shoot_point].pos.y,
z = gadgets[shoot_point].pos.z
}
LF_Create_MultiShootBall(context, pos, shoot_type)
end
else
if nil == cfg.shoot_info[shoot_type] then
return 0
end
local ball_type = cfg.shoot_info[shoot_type].ball_type
--连发次数
local shoot_count = cfg.shoot_info[shoot_type].shoot_count
--出生朝向
local rot = cfg.shoot_info[shoot_type].rot
if 7 == shoot_type then
for k, shoot_point in pairs(defs.shoot_points[player_count]) do
local pos = {
x = gadgets[shoot_point].pos.x,
y = gadgets[shoot_point].pos.y,
z = gadgets[shoot_point].pos.z
}
LF_Create_DualCurveBall(context, pos)
end
else
for k, shoot_point in pairs(defs.shoot_points[player_count]) do
for i = 1, shoot_count do
local pos = {
x = gadgets[shoot_point].pos.x,
y = gadgets[shoot_point].pos.y,
z = gadgets[shoot_point].pos.z + (i-1)*defs.multishoot_distance
}
LF_CreateBallFromPool(context, pos, rot, ball_type)
end
end
end
end
return 0
end
--单发射点创球
--shoot_type: 射击模式 1-单个普通 2-单个快速 3-双普 4-双快 5-三普 6-三快 7-单普通左旋 8-单快速左旋 9-单普通右旋 10-单快速右旋 20+ multi_shoot
function LF_CreateBall_Single(context, shoot_point, shoot_type)
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] LF_CreateBall_Single. shoot_type@"..shoot_type)
if 20 < shoot_type then
local pos = {
x = gadgets[shoot_point].pos.x,
y = gadgets[shoot_point].pos.y,
z = gadgets[shoot_point].pos.z
}
LF_Create_MultiShootBall(context, pos)
else
if nil == cfg.shoot_info[shoot_type] then
return 0
end
local ball_type = cfg.shoot_info[shoot_type].ball_type
--连发次数
local shoot_count = cfg.shoot_info[shoot_type].shoot_count
--出生朝向
local rot = cfg.shoot_info[shoot_type].rot
if 7 == shoot_type then
local pos = {
x = gadgets[shoot_point].pos.x,
y = gadgets[shoot_point].pos.y,
z = gadgets[shoot_point].pos.z
}
LF_Create_DualCurveBall(context, pos)
else
for i = 1, shoot_count do
local pos = {
x = gadgets[shoot_point].pos.x,
y = gadgets[shoot_point].pos.y,
z = gadgets[shoot_point].pos.z + (i-1)*defs.multishoot_distance
}
LF_CreateBallFromPool(context, pos, rot, ball_type)
end
end
end
return 0
end
function LF_CreateBallFromPool(context, pos_table, rot_table, ball_type)
local ball_state = 0
if defs.high_from ~= nil and defs.high_from <= ScriptLib.GetGroupTempValue(context, "order_index", {}) then
ball_state = 1
end
for ik , iv in pairs(defs.ball_pool[ball_type]) do
local ret = ScriptLib.CreateGadgetByParamTable(context, {config_id = iv, pos = pos_table, rot = rot_table, sgv_key = {"SGV_BaseBall_State"}, sgv_value = {ball_state} })
if 0 == ret then
return 0
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] LF_CreateBallFromPool. Create gadget failed. ")
return 0
end
function LF_Create_DualCurveBall(context, pos_table)
local ball_state = 0
if defs.high_from ~= nil and defs.high_from <= ScriptLib.GetGroupTempValue(context, "order_index", {}) then
ball_state = 1
end
--左旋
for ik , iv in pairs(defs.ball_pool[4]) do
local ret = ScriptLib.CreateGadgetByParamTable(context, {config_id = iv, pos = pos_table, rot = { x = 0.000, y = 140.000, z = 0.000 }, sgv_key = {"SGV_BaseBall_State"}, sgv_value = {ball_state} })
if 0 == ret then
break
end
end
--右旋
for ik , iv in pairs(defs.ball_pool[3]) do
local ret = ScriptLib.CreateGadgetByParamTable(context, {config_id = iv, pos = pos_table, rot = { x = 0.000, y = 220.000, z = 0.000 }, sgv_key = {"SGV_BaseBall_State"}, sgv_value = {ball_state} })
if 0 == ret then
break
end
end
return 0
end
function LF_Create_MultiShootBall(context, pos_table, shoot_type)
local ball_state = 0
if defs.high_from ~= nil and defs.high_from <= ScriptLib.GetGroupTempValue(context, "order_index", {}) then
ball_state = 1
end
if nil == defs.multi_shoot[shoot_type] then
return 0
end
for i = 1, #defs.multi_shoot[shoot_type] do
local pos = { x = pos_table.x + defs.multi_shoot[shoot_type][i].x, y = pos_table.y, z = pos_table.z + defs.multi_shoot[shoot_type][i].z }
for ik , iv in pairs(defs.ball_pool[2]) do
local ret = ScriptLib.CreateGadgetByParamTable(context, {config_id = iv, pos = pos, rot = { x = 0.000, y = 180.000, z = 0.000 }, sgv_key = {"SGV_BaseBall_State"}, sgv_value = {ball_state} })
if 0 == ret then
break
end
end
end
return 0
end
--玩家击球
--param1: 基础分
--param2是否翻倍球
function SLC_CharAmusement_BaseBallHit(context, param1, param2)
if 1 ~= param1 and 3 ~= param1 then--校验 高速球3分普通速度球1分
return 0
end
local multiply = 1
if 0 < param2 then
multiply = 2
end
--移除球
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, config_id)
ScriptLib.PrintContextLog(context,"## [CharAmuse_BaseBall] SLC_CharAmusement_BaseBallHit. config_id@"..config_id)
--加分
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= 1*param1*multiply } )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, 1*param1*multiply)--给MultStage更新分数 服务器侧埋点用
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1*param1*multiply , {})
ScriptLib.ChangeGroupTempValue(context, "hit", 1, {})--埋点计数
--是否结束
if 0 >= ScriptLib.GetGroupTempValue(context, "cur_score", {}) then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["is_last_level"] = is_last_level, ["is_finish"] = true, ["is_success"] = true } )
ScriptLib.StopGallery(context, gallery_id, false)
local hit = ScriptLib.GetGroupTempValue(context, "hit", {})
local wave_num = ScriptLib.GetGroupTempValue(context, "wave_num", {})
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_BaseBall", ScriptLib.GetDungeonTransaction(context), {["wave_num"] = wave_num, ["hit"] = hit})
return 0
end
return 0
end
--球自杀
function SLC_CharAmusement_BaseBallDie(context)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, config_id)
return 0
end
function LF_ClearAllBalls(context)
for k,v in pairs(defs.ball_pool) do
for ik, iv in pairs(v) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, iv )
end
end
return 0
end
function LF_MakeTimeAxis(context, time_table)
local t = {}
for i = 1, #time_table do
local num = 0
for j = i, 1, -1 do
num = num + time_table[j]
end
table.insert(t, num)
end
return t
end
LF_Initialize()

View File

@ -0,0 +1,233 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_Battle
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [CharAmuse_Battle]
|| Protection:
=======================================]]
--[[
local defs = {
--依次刷怪
suite_queue =
{ --随机情况1
{2,3,4,5},
--随机情况2
{2,3,4,5},
}
}
]]
local cfg = {
--主控GroupID
main_group = 251008007,
}
local extraTriggers = {
{ config_id = 8000001, name = "TimeAxis_StopGallery", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery", condition = "", action = "action_TimeAxis_StopGallery", trigger_count = 0 },
{ config_id = 8000002, name = "Any_Monster_Die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_Any_Monster_Die", trigger_count = 0 },
{ config_id = 8000003, name = "AirWallVariable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "air_wall", condition = "", action = "action_AirWallVariable_Change", trigger_count = 0 },
{ config_id = 8000004, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_Gallery_Stop", trigger_count = 0 },
{ config_id = 8000005, name = "TimeAxis_StopGallery_Fail", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery_Fail", condition = "", action = "action_TimeAxis_StopGallery_Fail", trigger_count = 0 },
{ config_id = 8000006, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000007, name = "TimeAxis_NewRound", event = EventType.EVENT_TIME_AXIS_PASS, source = "NewRound", condition = "", action = "action_TimeAxis_NewRound", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "air_wall", value = 0})
end
--主控调用
function EX_StartGallery(context, prev_context, gallery_id, is_last_level)
--加载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
end
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetGroupTempValue(context, "player_count", #uid_list, {})
ScriptLib.SetGroupTempValue(context, "is_last_level", is_last_level, {})
--开启gallery
ScriptLib.StartGallery(context, gallery_id)
ScriptLib.SetGroupTempValue(context, "gallery_id", gallery_id, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_Battle] EX_StartGallery. player_count@"..#uid_list.." --------------")
--玩法启动
ScriptLib.SetGroupVariableValue(context, "air_wall", 0)
LF_Start_Play(context)
return 0
end
function action_Group_Load(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == ScriptLib.GetGroupVariableValue(context, "air_wall") then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
return 0
end
function action_AirWallVariable_Change(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == evt.param1 and 0 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
elseif 0 == evt.param1 and 1 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
end
return 0
end
--evt.param2: 1-失败 0-成功
function action_Gallery_Stop(context, evt)
--卸载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
end
ScriptLib.EndAllTimeAxis(context)
if 3 ~= evt.param3 then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
--ScriptLib.InitTimeAxis(context, "StopGallery_Fail", { 3 } , false) 9.21修改 失败不要延时结束
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
else
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)--最后一关无等待
if is_last_level then
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
else
ScriptLib.InitTimeAxis(context, "StopGallery", { 3 } , false)
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_Battle] Gallery stoped. reason@".. evt.param3.." --------------")
return 0
end
---------------------------------------------------------------------------------------------------------------
function LF_Start_Play(context)
ScriptLib.SetGroupTempValue(context, "round", 0, {})
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local target = 0
if player_count > 1 then
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, true)
else
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, false)
end
ScriptLib.SetGroupTempValue(context, "cur_score", target, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["max_score"]= target} )
--随机序列
math.randomseed(ScriptLib.GetServerTime(context))
local rand_index = math.random(#defs.suite_queue)
ScriptLib.SetGroupTempValue(context, "rand_index", rand_index, {})
LF_StartRound(context)
return 0
end
function LF_ClearRound(context)
local round = ScriptLib.GetGroupTempValue(context, "round", {})
local rand_index = ScriptLib.GetGroupTempValue(context, "rand_index", {})
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, defs.suite_queue[rand_index][round])
--埋点
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_BreakingShield", ScriptLib.GetDungeonTransaction(context), {["wave_num"] = round})
return 0
end
function LF_StartRound(context)
--round++
ScriptLib.ChangeGroupTempValue(context, "round", 1, {})
local round = ScriptLib.GetGroupTempValue(context, "round", {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_Battle] LF_StartRound. New round@"..round)
--如果已经到了LD配置尽头则循环最后一波
local rand_index = ScriptLib.GetGroupTempValue(context, "rand_index", {})
if round > #defs.suite_queue[rand_index] then
round = #defs.suite_queue[rand_index]
ScriptLib.SetGroupTempValue(context, "round", round, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_Battle] LF_StartRound. All round finished. Set to final.")
end
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.suite_queue[rand_index][round])
return 0
end
function action_TimeAxis_StopGallery(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
return 0
end
function action_TimeAxis_StopGallery_Fail(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
return 0
end
--循环刷怪
function action_Any_Monster_Die(context)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
if false == ScriptLib.IsGalleryStart(context, gallery_id) then
return 0
end
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= 1} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, 1)--给MultStage更新分数 服务器侧埋点用
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1 , {})
if 0 >= ScriptLib.GetGroupTempValue(context, "cur_score", {}) then
--客户端弹提示
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["is_last_level"] = is_last_level, ["is_finish"] = true, ["is_success"] = true } )
ScriptLib.KillGroupEntity(context, { group_id = base_info.group_id, kill_policy = GroupKillPolicy.GROUP_KILL_MONSTER })
LF_ClearRound(context)
ScriptLib.StopGallery(context, gallery_id, false)
return 0
end
if 0 < ScriptLib.GetGroupMonsterCount(context) then
return 0
end
if nil ~= defs.refresh_delay then
ScriptLib.InitTimeAxis(context, "NewRound", {defs.refresh_delay}, false)
else
LF_ClearRound(context)
LF_StartRound(context)
end
return 0
end
function action_TimeAxis_NewRound(context, evt)
LF_ClearRound(context)
LF_StartRound(context)
return 0
end
LF_Initialize()

View File

@ -0,0 +1,353 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_BattleTide
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [CharAmuse_BattleTide]
|| Protection:
=======================================]]
--[[
local defs = {
rule =
{
[1] =
{ --[杀怪数] = { 启动的tide 停止补怪的tide}
[10] = { toStart = {}, toStop = {} },
},
[2] =
{ --[杀怪数] = { 启动的tide 停止补怪的tide}
[10] = { toStart = {}, toStop = {}},
},
[3] =
{ --[杀怪数] = { 启动的tide 停止补怪的tide}
[10] = { toStart = {}, toStop = {}},
},
[4] =
{ --[杀怪数] = { 启动的tide 停止补怪的tide}
[10] = { toStart = {}, toStop = {}},
},
},
--怪物信息 每个tide每次只出一只按次序刷出
tide =
{
[1] = { 1001, 1002 },
[2] = { 1001, 1002 },
[3] = { 1001, 1002 },
}
}
]]
local cfg = {
--主控GroupID
main_group = 251008007,
}
local extraTriggers = {
{ config_id = 8000001, name = "TimeAxis_StopGallery", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery", condition = "", action = "action_TimeAxis_StopGallery", trigger_count = 0 },
{ config_id = 8000002, name = "Any_Monster_Die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_Any_Monster_Die", trigger_count = 0 },
{ config_id = 8000004, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_Gallery_Stop", trigger_count = 0 },
{ config_id = 8000005, name = "TimeAxis_StopGallery_Fail", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery_Fail", condition = "", action = "action_TimeAxis_StopGallery_Fail", trigger_count = 0 },
{ config_id = 8000006, name = "AirWallVariable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "air_wall", condition = "", action = "action_AirWallVariable_Change", trigger_count = 0 },
{ config_id = 8000007, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
{ config_id = 8000008, name = "Clear_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "clear_delay", condition = "", action = "action_Clear_TimeAxis_Pass", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "air_wall", value = 0})
end
--主控调用
function EX_StartGallery(context, prev_context, gallery_id, is_last_level)
--加载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
end
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetGroupTempValue(context, "player_count", #uid_list, {})
ScriptLib.SetGroupTempValue(context, "is_last_level", is_last_level, {})
--开启gallery
ScriptLib.StartGallery(context, gallery_id)
ScriptLib.SetGroupTempValue(context, "gallery_id", gallery_id, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_BattleTide] EX_StartGallery. player_count@"..#uid_list.." --------------")
--玩法启动
ScriptLib.SetGroupVariableValue(context, "air_wall", 0)
LF_Start_Play(context)
return 0
end
function action_Group_Load(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == ScriptLib.GetGroupVariableValue(context, "air_wall") then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
return 0
end
function action_AirWallVariable_Change(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == evt.param1 and 0 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
elseif 0 == evt.param1 and 1 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
end
return 0
end
--evt.param2: 1-失败 0-成功
function action_Gallery_Stop(context, evt)
--卸载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
end
if 3 ~= evt.param3 then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
--ScriptLib.InitTimeAxis(context, "StopGallery_Fail", { 3 } , false) 9.21修改 失败不要延时结束
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
else
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)--最后一关无等待
if is_last_level then
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
else
ScriptLib.InitTimeAxis(context, "StopGallery", { 3 } , false)
end
end
--埋点
local counter_1 = ScriptLib.GetGroupTempValue(context, "action_counter_1", {})
local counter_2 = ScriptLib.GetGroupTempValue(context, "action_counter_2", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
if 28015 == gallery_id or 28016 == gallery_id then
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_ElecAttack", ScriptLib.GetDungeonTransaction(context), {["reaction"] = counter_1})
elseif 28017 == gallery_id or 28018 == gallery_id then
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_NormalAttack", ScriptLib.GetDungeonTransaction(context), {["attack"] = counter_2})
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_BattleTide] Gallery stoped. reason@".. evt.param3.." --------------")
return 0
end
---------------------------------------------------------------------------------------------------------------
function LF_Start_Play(context)
--埋点计数器
ScriptLib.SetGroupTempValue(context, "action_counter_1", 0, {})
ScriptLib.SetGroupTempValue(context, "action_counter_2", 0, {})
--怪物队列index初始化
--0: 关闭
for k,v in pairs(defs.tide) do
ScriptLib.SetGroupTempValue(context, "tide_"..k, 1, {})
end
--杀怪数
ScriptLib.SetGroupTempValue(context, "kill_num", 0, {})
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local target = 0
if player_count > 1 then
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, true)
else
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, false)
end
ScriptLib.SetGroupTempValue(context, "cur_score", target, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["max_score"]= target} )
if nil == defs.rule[player_count] then
return 0
end
if nil == defs.rule[player_count][0] then
return 0
end
LF_InitMonsterByQueueList(context, defs.rule[player_count][0].toStart)
return 0
end
function action_TimeAxis_StopGallery(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
return 0
end
function action_TimeAxis_StopGallery_Fail(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
return 0
end
--循环刷怪
function action_Any_Monster_Die(context, evt)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
if false == ScriptLib.IsGalleryStart(context, gallery_id) then
return 0
end
--加分
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= 1} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, 1)--给MultStage更新分数 服务器侧埋点用
--是否结算
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1 , {})
if 0 >= ScriptLib.GetGroupTempValue(context, "cur_score", {}) then
--客户端弹提示
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["is_last_level"] = is_last_level, ["is_finish"] = true, ["is_success"] = true } )
--ScriptLib.KillGroupEntity(context, { group_id = base_info.group_id, kill_policy = GroupKillPolicy.GROUP_KILL_MONSTER })
ScriptLib.InitTimeAxis(context, "clear_delay", {1.2}, false)--有delay出现的怪
ScriptLib.StopGallery(context, gallery_id, false)
return 0
end
--启动/停止怪物队列
ScriptLib.ChangeGroupTempValue(context, "kill_num", 1, {})
local kill_num = ScriptLib.GetGroupTempValue(context, "kill_num", {})
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
if nil == defs.rule[player_count] then
return 0
end
if nil ~= defs.rule[player_count][kill_num] then
if nil ~= defs.rule[player_count][kill_num].toStart and 0 ~= defs.rule[player_count][kill_num].toStart then
local tide_index_list = defs.rule[player_count][kill_num].toStart
LF_InitMonsterByQueueList(context, tide_index_list)
end
if nil ~= defs.rule[player_count][kill_num].toStop and 0 ~= defs.rule[player_count][kill_num].toStop then
local tide_index_list = defs.rule[player_count][kill_num].toStop
LF_StopMonsterByQueue(context, tide_index_list)
end
end
--所在怪物队列补怪
local from_tide = LF_GetMonsterTideIndexByConfigID(context, evt.param1)
if 0 < ScriptLib.GetGroupTempValue(context, "tide_"..from_tide, {}) then
LF_CreateMonsterByQueue(context, from_tide)
end
return 0
end
function action_Clear_TimeAxis_Pass(context, evt)
ScriptLib.KillGroupEntity(context, { group_id = base_info.group_id, kill_policy = GroupKillPolicy.GROUP_KILL_MONSTER })
return 0
end
function LF_InitMonsterByQueueList(context, tide_index_list)
for i,v in ipairs(tide_index_list) do
if nil == defs.tide[v] then
ScriptLib.PrintContextLog(context, "## [CharAmuse_BattleTide] LF_InitMonsterByQueueList. Undefined tide index. index@"..v )
return 0
end
local monster_index = ScriptLib.GetGroupTempValue(context, "tide_"..v, {})
if 0 < monster_index then
if nil == defs.tide[v][monster_index] then
ScriptLib.PrintContextLog(context, "## [CharAmuse_BattleTide] LF_InitMonsterByQueueList. Undefined monster_index. tide@"..v.." monster_index@"..monster_index )
return 0
end
ScriptLib.CreateMonster(context, { config_id = defs.tide[v][monster_index], delay_time = 0 })
if monster_index >= #defs.tide[v] then
ScriptLib.SetGroupTempValue(context, "tide_"..v, 1, {})
else
ScriptLib.ChangeGroupTempValue(context, "tide_"..v, 1, {})
end
end
end
return 0
end
function LF_CreateMonsterByQueue(context, tide_index)
local monster_index = ScriptLib.GetGroupTempValue(context, "tide_"..tide_index, {})
ScriptLib.PrintContextLog(context, "## [CharAmuse_BattleTide] LF_CreateMonsterByQueue. tide@tide_"..tide_index.." monster_index@"..monster_index )
if nil == defs.tide[tide_index] then
ScriptLib.PrintContextLog(context, "## [CharAmuse_BattleTide] LF_CreateMonsterByQueue. Undefined tide index. index@"..tide_index )
return 0
end
if 0 < monster_index then
if nil == defs.tide[tide_index][monster_index] then
ScriptLib.PrintContextLog(context, "## [CharAmuse_BattleTide] LF_CreateMonsterByQueue. Undefined monster_index. tide@"..tide_index.." monster_index@"..monster_index )
return 0
end
ScriptLib.CreateMonster(context, { config_id = defs.tide[tide_index][monster_index], delay_time = 1 })
if monster_index >= #defs.tide[tide_index] then
ScriptLib.SetGroupTempValue(context, "tide_"..tide_index, 1, {})
else
ScriptLib.ChangeGroupTempValue(context, "tide_"..tide_index, 1, {})
end
end
return 0
end
function LF_StopMonsterByQueue(context, tide_index_list)
for i,v in ipairs(tide_index_list) do
if nil == defs.tide[v] then
ScriptLib.PrintContextLog(context, "## [CharAmuse_BattleTide] LF_StopMonsterByQueue. Undefined tide index. index@"..v )
return 0
end
ScriptLib.SetGroupTempValue(context, "tide_"..v, 0, {})
end
return 0
end
function LF_GetMonsterTideIndexByConfigID(context, config_id)
for k,v in pairs(defs.tide) do
for i, j in ipairs(v) do
if config_id == j then
return k
end
end
end
return 0
end
--玩家行为埋点
--param1 1-触发感电激化 2-触发普攻重击
function SLC_CharAmuse_BattleAction(context, param1)
if 1 == param1 then
ScriptLib.ChangeGroupTempValue(context, "action_counter_1", 1, {})
elseif 2 == param1 then
ScriptLib.ChangeGroupTempValue(context, "action_counter_2", 1, {})
end
return 0
end
LF_Initialize()

View File

@ -0,0 +1,343 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_BrickWall
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [CharAmuse_BrickWall]
|| Protection:
=======================================]]
--[[
local defs = {
}
]]
local cfg = {
--主控GroupID
main_group = 251008007,
--默认血量
hp =
{ --[人数] = {各种砖块血量}
[1] = { Normal = 130, Stamina = 200, Line = 500, All = 1200,},
[2] = { Normal = 130, Stamina = 200, Line = 500, All = 1200,},
[3] = { Normal = 130, Stamina = 200, Line = 500, All = 1200,},
[4] = { Normal = 130, Stamina = 200, Line = 500, All = 1200,},
}
}
local extraTriggers = {
{ config_id = 8000001, name = "TimeAxis_StopGallery", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery", condition = "", action = "action_TimeAxis_StopGallery", trigger_count = 0 },
{ config_id = 8000002, name = "Enter_Play_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Play_Region", trigger_count = 1, forbid_guest = false},
{ config_id = 8000004, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_Gallery_Stop", trigger_count = 0 },
{ config_id = 8000005, name = "TimeAxis_StopGallery_Fail", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery_Fail", condition = "", action = "action_TimeAxis_StopGallery_Fail", trigger_count = 0 },
{ config_id = 8000006, name = "AirWallVariable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "air_wall", condition = "", action = "action_AirWallVariable_Change", trigger_count = 0 },
{ config_id = 8000007, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "air_wall", value = 0})
end
--主控调用
function EX_StartGallery(context, prev_context, gallery_id, is_last_level)
--加载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
end
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetGroupTempValue(context, "player_count", #uid_list, {})
ScriptLib.SetGroupTempValue(context, "is_last_level", is_last_level, {})
--开启gallery
ScriptLib.StartGallery(context, gallery_id)
ScriptLib.PrintContextLog(context,"## [CharAmuse_BrickWall] EX_StartGallery. player_count@"..#uid_list.." --------------")
ScriptLib.SetGroupTempValue(context, "gallery_id", gallery_id, {})
--玩法启动
ScriptLib.SetGroupVariableValue(context, "air_wall", 0)
LF_Start_Play(context)
return 0
end
function action_Group_Load(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == ScriptLib.GetGroupVariableValue(context, "air_wall") then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
return 0
end
function action_AirWallVariable_Change(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == evt.param1 and 0 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
elseif 0 == evt.param1 and 1 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
end
return 0
end
--evt.param2: 1-成功 0-失败
function action_Gallery_Stop(context, evt)
--卸载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
end
if 3 ~= evt.param3 then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
--ScriptLib.InitTimeAxis(context, "StopGallery_Fail", { 3 } , false) 9.21修改 失败不要延时结束
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
else
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)--最后一关无等待
if is_last_level then
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
else
ScriptLib.InitTimeAxis(context, "StopGallery", { 3 } , false)
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_BrickWall] Gallery stoped. reason@".. evt.param3.." --------------")
return 0
end
function action_Enter_Play_Region(context, evt)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetGroupTempValue(context, "player_count", #uid_list, {})
--根据当前人数加载suite
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
if nil ~= defs.enter_suites and nil ~= defs.enter_suites[player_count] then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.enter_suites[player_count])
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_BrickWall] Enter_Play_Region. player_count@"..#uid_list)
--重新创建砖墙 重置GV、SGV
if 1 < player_count then
if nil ~= defs.hp then
ScriptLib.CreateGadgetByParamTable(context, {config_id = defs.wall, pos = gadgets[defs.wall].pos, rot = gadgets[defs.wall].rot,
sgv_key = {
"SGV_BrickWall_Mode",
"SGV_BrickWall_HP_Normal",
"SGV_BrickWall_HP_Stamina",
"SGV_BrickWall_HP_Line",
"SGV_BrickWall_HP_All",
},
sgv_value = {
1,
defs.hp[player_count].Normal,
defs.hp[player_count].Stamina,
defs.hp[player_count].Line,
defs.hp[player_count].All,
}
})
else
ScriptLib.CreateGadgetByParamTable(context, {config_id = defs.wall, pos = gadgets[defs.wall].pos, rot = gadgets[defs.wall].rot,
sgv_key = {
"SGV_BrickWall_Mode",
"SGV_BrickWall_HP_Normal",
"SGV_BrickWall_HP_Stamina",
"SGV_BrickWall_HP_Line",
"SGV_BrickWall_HP_All",
},
sgv_value = {
1,
cfg.hp[player_count].Normal,
cfg.hp[player_count].Stamina,
cfg.hp[player_count].Line,
cfg.hp[player_count].All,
}
})
end
else
if nil ~= defs.hp then
ScriptLib.CreateGadgetByParamTable(context, {config_id = defs.wall, pos = gadgets[defs.wall].pos, rot = gadgets[defs.wall].rot,
sgv_key = {
"SGV_BrickWall_Mode",
"SGV_BrickWall_HP_Normal",
"SGV_BrickWall_HP_Stamina",
"SGV_BrickWall_HP_Line",
"SGV_BrickWall_HP_All",
},
sgv_value = {
0,
defs.hp[player_count].Normal,
defs.hp[player_count].Stamina,
defs.hp[player_count].Line,
defs.hp[player_count].All,
}
})
else
ScriptLib.CreateGadgetByParamTable(context, {config_id = defs.wall, pos = gadgets[defs.wall].pos, rot = gadgets[defs.wall].rot,
sgv_key = {
"SGV_BrickWall_Mode",
"SGV_BrickWall_HP_Normal",
"SGV_BrickWall_HP_Stamina",
"SGV_BrickWall_HP_Line",
"SGV_BrickWall_HP_All",
},
sgv_value = {
0,
cfg.hp[player_count].Normal,
cfg.hp[player_count].Stamina,
cfg.hp[player_count].Line,
cfg.hp[player_count].All,
}
})
end
end
return 0
end
---------------------------------------------------------------------------------------------------------------
function LF_Start_Play(context)
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local target = 0
if player_count > 1 then
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, true)
else
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, false)
end
ScriptLib.SetGroupTempValue(context, "cur_score", target, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["max_score"]= target} )
ScriptLib.SetGroupTempValue(context, "cur_num", 0, {})
----测试关存在连续2场砖墙玩法的情况在此重新尝试创建一次砖墙configID在场无事发生
if nil ~= defs.enter_suites and nil ~= defs.enter_suites[player_count] then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.enter_suites[player_count])
end
--重新创建砖墙 重置GV、SGV。测试期间有两关连续打砖墙的情况
if 1 < player_count then
ScriptLib.CreateGadgetByParamTable(context, {config_id = defs.wall, pos = gadgets[defs.wall].pos, rot = gadgets[defs.wall].rot,
sgv_key = {
"SGV_BrickWall_Mode",
"SGV_BrickWall_HP_Normal",
"SGV_BrickWall_HP_Stamina",
"SGV_BrickWall_HP_Line",
"SGV_BrickWall_HP_All",
},
sgv_value = {
1,
defs.hp[player_count].Normal,
defs.hp[player_count].Stamina,
defs.hp[player_count].Line,
defs.hp[player_count].All,
}
})
else
ScriptLib.CreateGadgetByParamTable(context, {config_id = defs.wall, pos = gadgets[defs.wall].pos, rot = gadgets[defs.wall].rot,
sgv_key = {
"SGV_BrickWall_Mode",
"SGV_BrickWall_HP_Normal",
"SGV_BrickWall_HP_Stamina",
"SGV_BrickWall_HP_Line",
"SGV_BrickWall_HP_All",
},
sgv_value = {
0,
defs.hp[player_count].Normal,
defs.hp[player_count].Stamina,
defs.hp[player_count].Line,
defs.hp[player_count].All,
}
})
end
return 0
end
function action_TimeAxis_StopGallery(context, evt)
--重新创建砖墙 重置GV
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.wall)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
return 0
end
function action_TimeAxis_StopGallery_Fail(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
return 0
end
--DoActionOnGlobalValueChange
function SLC_CharAmusePillar_BrickCount(context, param1)
local cur_num = ScriptLib.GetGroupTempValue(context, "cur_num", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_BrickWall] SLC_CharAmusePillar_BrickCount. cur_count@"..cur_num.. " param1@"..param1)
if 0 < param1 and param1 < 999 then
local diff = param1 -cur_num
if 0 <= diff then
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= diff} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, diff)--给MultStage更新分数 服务器侧埋点用
ScriptLib.ChangeGroupTempValue(context, "cur_num", diff, {})
else
ScriptLib.PrintContextLog(context,"## [CharAmuse_BrickWall] Unexpected score change! diff@"..diff)
return 0 --diff异常直接return了
end
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1*diff, {})
if 0 >= ScriptLib.GetGroupTempValue(context, "cur_score", {}) then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["is_last_level"] = is_last_level, ["is_finish"] = true, ["is_success"] = true } )
--通知砖墙上报埋点计数
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.wall, "SGV_BrickWall_Report", 1)
ScriptLib.StopGallery(context, gallery_id, false)
return 0
end
end
return 0
end
--埋点用
function SLC_CharAmusePillar_Report_Normal(context, param1)
if 0 < param1 then
ScriptLib.PrintContextLog(context,"## [CharAmuse_BrickWall] SLC_CharAmusePillar_Report_Normal. param1@"..param1)
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_BrickWall", ScriptLib.GetDungeonTransaction(context), { ["normal"] = param1 })
end
return 0
end
--埋点用
function SLC_CharAmusePillar_Report_UnNormal(context, param1, param2, param3)
if 0 < param1 and 0 < param2 and 0 < param3 then --埋点数据 校验应该不需要太严格
ScriptLib.PrintContextLog(context,"## [CharAmuse_BrickWall] SLC_CharAmusePillar_Report_UnNormal. param1@"..param1.. " param2@"..param2.." param3@"..param3)
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_BrickWall", ScriptLib.GetDungeonTransaction(context), { ["Stamina"] = param1, ["lateral"] = param2, ["fullscreen"] = param3 })
end
return 0
end
LF_Initialize()

View File

@ -0,0 +1,475 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_FootBall
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [CharAmuse_FootBall]
|| Protection:
=======================================]]
--[[
--踢球玩法配置
local defs = {
-----全玩法通用配置-----
--玩法范围region cube
play_region = 1003,
--玩法限时秒
limit_time = 120,
target = 15,
-----踢足球配置-----
--每波球强制结束时间
rounf_time = 60,
--每波球强制结束前Reminder时机
rmd_time = 55,
reminder_id = 470310102,
--内容配置
-- 如果是琴的关卡,用这套
Jean = {
-- 球门和空气墙所在的suite
goal_suite =10,
-- 刷球和空气墙的规则
setting = {
-- 单人玩家
[1] = {
--第1波球从ball_suite中随机出1个从wall_suite中随机出1个
{ball_suite = {1,2}, wall_suite = {}},
},
-- 2人玩家
[2] = {
{ball_suite = {1,2}, wall_suite = {}},
},
-- 3人玩家
[3] = {
{ball_suite = {1,2}, wall_suite = {}},
{ball_suite = {3,4}, wall_suite = {2}},
{ball_suite = {3,4}, wall_suite = {4}},
},
-- 4人玩家
[4] = {
{ball_suite = {1,2}, wall_suite = {}},
{ball_suite = {3,4}, wall_suite = {2}},
{ball_suite = {3,4}, wall_suite = {4}},
},
},
},
-- 如果是可莉&烟绯的关卡,用这套
Klee = {
goal_suite =2,
setting = {
[1] = {
{ball_suite = {1,2}, wall_suite = {}},
{ball_suite = {3,4}, wall_suite = {2}},
{ball_suite = {3,4}, wall_suite = {4}},
},
[2] = {
{ball_suite = {1,2}, wall_suite = {}},
{ball_suite = {3,4}, wall_suite = {2}},
{ball_suite = {3,4}, wall_suite = {4}},
},
[3] = {
{ball_suite = {1,2}, wall_suite = {}},
{ball_suite = {3,4}, wall_suite = {2}},
{ball_suite = {3,4}, wall_suite = {4}},
},
[4] = {
{ball_suite = {1,2}, wall_suite = {}},
{ball_suite = {3,4}, wall_suite = {2}},
{ball_suite = {3,4}, wall_suite = {4}},
},
},
},
}
]]
local cfg = {
main_group = 251008007,
--
gallery_match =
{
--[1000] = defs.Jean,
[28009] = defs.Klee,
[28010] = defs.Jean
},
monter_score =
{
[20011204] = 1,
[20011305] = 5,
[20010503] = 1,
[20010605] = 5,
}
}
local extraTriggers = {
{ config_id = 8000002, name = "Enter_Play_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Play_Region", trigger_count = 1, forbid_guest = false},
{ config_id = 8000003, name = "TimeAxis_StopGallery", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery", condition = "", action = "action_TimeAxis_StopGallery", trigger_count = 0 },
{ config_id = 8000004, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_Gallery_Stop", trigger_count = 0 },
{ config_id = 8000005, name = "TimeAxis_StopGallery_Fail", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery_Fail", condition = "", action = "action_TimeAxis_StopGallery_Fail", trigger_count = 0 },
{ config_id = 8000007, name = "FootBallClear_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "FootBallClear", condition = "", action = "action_FootBallClear_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000008, name = "ClearReminder_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "ClearRmd", condition = "", action = "action_ClearReminder_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000009, name = "Any_Monster_Die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_Any_Monster_Die", trigger_count = 0 },
{ config_id = 8000010, name = "TimeAxis_NewRound", event = EventType.EVENT_TIME_AXIS_PASS, source = "NewRound", condition = "", action = "action_TimeAxis_NewRound", trigger_count = 0 },
{ config_id = 8000011, name = "MovingWall_ReachPoint", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_MovingWall_ReachPoint", trigger_count = 0 },
{ config_id = 8000012, name = "AirWallVariable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "air_wall", condition = "", action = "action_AirWallVariable_Change", trigger_count = 0 },
{ config_id = 8000013, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "air_wall", value = 0})
end
--主控调用
function EX_StartGallery(context, prev_context, gallery_id, is_last_level)
--加载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
end
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetGroupTempValue(context, "player_count", #uid_list, {})
ScriptLib.SetGroupTempValue(context, "is_last_level", is_last_level, {})
--开启gallery
ScriptLib.StartGallery(context, gallery_id)
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] EX_StartGallery. player_count@"..#uid_list.." --------------")
ScriptLib.SetGroupTempValue(context, "gallery_id", gallery_id, {})
--玩法启动
ScriptLib.SetGroupVariableValue(context, "air_wall", 0)
LF_Start_Play(context)
return 0
end
function action_Group_Load(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == ScriptLib.GetGroupVariableValue(context, "air_wall") then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
return 0
end
function action_AirWallVariable_Change(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == evt.param1 and 0 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
elseif 0 == evt.param1 and 1 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
end
return 0
end
--evt.param2: 1-成功 0-失败
function action_Gallery_Stop(context, evt)
--卸载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
end
LF_ClearRound(context)
ScriptLib.EndAllTimeAxis(context)
if 3 ~= evt.param3 then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
--ScriptLib.InitTimeAxis(context, "StopGallery_Fail", { 3 } , false) 9.21修改 失败不要延时结束
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
else
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)--最后一关无等待
if is_last_level then
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
else
ScriptLib.InitTimeAxis(context, "StopGallery", { 3 } , false)
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] Gallery stoped. reason@".. evt.param3.." --------------")
return 0
end
function action_Enter_Play_Region(context, evt)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] Enter_Play_Region. player_count@"..#uid_list)--这里只是打一下logLF_AddGoalSuite不涉及人数
LF_AddGoalSuite(context)
return 0
end
---------------------------------------------------------------------------------------------------------------
function LF_Start_Play(context)
ScriptLib.SetGroupTempValue(context, "round", 0, {})
player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local target = 0
if player_count > 1 then
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, true)
else
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, false)
end
ScriptLib.SetGroupTempValue(context, "cur_score", target, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["max_score"]= target} )
LF_StartRound(context)
return 0
end
function action_TimeAxis_StopGallery(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
return 0
end
function action_TimeAxis_StopGallery_Fail(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
return 0
end
--主控提前通知GalleryID
function EX_SetGalleryID(context, prev_context, gallery_id)
ScriptLib.SetGroupTempValue(context, "gallery_id", gallery_id, {})
return 0
end
function LF_AddGoalSuite(context)
--移除旧有的
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, defs.Klee.goal_suite)
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, defs.Jean.goal_suite)
--添加新的
local char_type = LF_GetFootBallCharType(context)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, char_type.goal_suite)
return 0
end
function action_FootBallClear_TimeAxis_Pass(context, evt)
LF_ClearRound(context)
LF_StartRound(context)
return 0
end
function action_ClearReminder_TimeAxis_Pass(context, evt)
ScriptLib.ShowReminder(context, defs.reminder_id)
return 0
end
function LF_StartRound(context)
ScriptLib.EndTimeAxis(context, "ClearRmd")
ScriptLib.EndTimeAxis(context, "FootBallClear")
ScriptLib.InitTimeAxis(context, "FootBallClear", { defs.rounf_time } , true)
ScriptLib.InitTimeAxis(context, "ClearRmd", { defs.rmd_time } , false)
ScriptLib.SetGroupTempValue(context, "ball_counter", 0, {})
ScriptLib.SetGroupTempValue(context, "score_gain", 0, {})
local char_type = LF_GetFootBallCharType(context)
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local setting = char_type.setting[player_count]
if nil == setting then
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] LF_StartRound. Nil setting. player_count@"..player_count)
return 0
end
--round++
ScriptLib.ChangeGroupTempValue(context, "round", 1, {})
local round = ScriptLib.GetGroupTempValue(context, "round", {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] LF_StartRound. New round@"..round)
--如果已经到了LD配置尽头则循环最后一波
if round > #char_type.setting[player_count] then
round = #char_type.setting[player_count]
ScriptLib.SetGroupTempValue(context, "round", round, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] LF_StartRound. All round finished. Set to final.")
end
--随机球
local ball_suite = setting[round].ball_suite
if nil ~= ball_suite and 0 < #ball_suite then
math.randomseed(ScriptLib.GetServerTime(context))
local rand_index = math.random(#ball_suite)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, ball_suite[rand_index])
ScriptLib.SetGroupTempValue(context, "ball_num", #suites[ball_suite[rand_index]].monsters, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] LF_AddSuiteByFootBallRule. round@"..round.." ball_suite@"..ball_suite[rand_index].." num@"..#suites[ball_suite[rand_index]].monsters)
end
--随机墙
local wall_suite = setting[round].wall_suite
if nil ~= wall_suite and 0 < #wall_suite then
math.randomseed(ScriptLib.GetServerTime(context) + 99)
local rand_index = math.random(#wall_suite)
ScriptLib.SetGroupTempValue(context, "wall_suite_index", rand_index, {})
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, wall_suite[rand_index])
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] LF_AddSuiteByFootBallRule. round@"..round.." wall_suite@"..wall_suite[rand_index])
end
--随机buff
local stamina_suite = setting[round].stamina_suite
if nil ~= stamina_suite and 0 < #stamina_suite then
math.randomseed(ScriptLib.GetServerTime(context) + 98)
local rand_index = math.random(#stamina_suite)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, stamina_suite[rand_index])
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] LF_AddSuiteByFootBallRule. round@"..round.." stamina_suite@"..stamina_suite[rand_index])
end
return 0
end
function LF_ClearRound(context)
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local char_type = LF_GetFootBallCharType(context)
local setting = char_type.setting[player_count]
local round = ScriptLib.GetGroupTempValue(context, "round", {})
--移除墙
local wall_suite_index = ScriptLib.GetGroupTempValue(context, "wall_suite_index", {})
local wall_suites = setting[round].wall_suite
local wall_suite = wall_suites[wall_suite_index]
if nil ~= wall_suite and nil ~= suites[wall_suite] then
for i,v in pairs(suites[wall_suite].gadgets) do
ScriptLib.KillEntityByConfigId(context, { config_id = v })--kill播放onKill动画
end
end
--移除其他
for i = 2, #suites do
if defs.Jean.goal_suite ~= i and defs.Klee.goal_suite ~= i and wall_suite ~= i then
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i)
end
end
--埋点
local score_gain = ScriptLib.GetGroupTempValue(context, "score_gain", {})
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_Football", ScriptLib.GetDungeonTransaction(context), {["wave_num"] = round, ["score_gain"] = score_gain})
return 0
end
function LF_GetFootBallCharType(context)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local char_type = {}
if -1 == gallery_id or nil == cfg.gallery_match[gallery_id] then
char_type = defs.Jean
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] LF_GetFootBallCharType. Gallery id undefined, use default setting.")
return char_type
else
char_type = cfg.gallery_match[gallery_id]
end
return char_type
end
function action_Any_Monster_Die(context, evt)
LF_HandleMonsterDie(context, evt.param1)
return 0
end
function action_TimeAxis_NewRound(context, evt)
LF_ClearRound(context)
LF_StartRound(context)
return 0
end
function action_MovingWall_ReachPoint(context, evt)
local gadget_id = ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid)
if 70320021 == gadget_id then
if 201 == ScriptLib.GetGadgetStateByConfigId(context, 0, evt.param1) then
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 0)
else
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 201)
end
end
return 0
end
--[[function SLC_CharAmuse_KillSlime(context)
local config_id = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id})
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] SLC_CharAmuse_KillSlime. source_entity_id@".. context.source_entity_id.. " target_entity_id@".. context.target_entity_id.." GetMonsterConfigId@"..config_id)
if nil == cfg.monter_score[monsters[config_id].monster_id] then
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] SLC_CharAmuse_KillSlime. Got unexpected config_id@")
return 0
end
ScriptLib.KillEntityByConfigId(context, { config_id = config_id }) --这个会触发AnyMonsterDie
--LF_HandleMonsterDie(context, config_id)
return 0
end]]
--加分 计数
function LF_HandleMonsterDie(context, config_id)
if nil == cfg.monter_score[monsters[config_id].monster_id] then
return 0
end
local score = cfg.monter_score[monsters[config_id].monster_id]
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1*score, {})
ScriptLib.ChangeGroupTempValue(context, "score_gain", score, {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"] = score} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, score)--给MultStage更新分数 服务器侧埋点用
--挑战完成
if 0 >= ScriptLib.GetGroupTempValue(context, "cur_score", {}) then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["is_last_level"] = is_last_level, ["is_finish"] = true, ["is_success"] = true } )
ScriptLib.StopGallery(context, gallery_id, false)
return 0
end
ScriptLib.ChangeGroupTempValue(context, "ball_counter", 1, {})
local ball_counter = ScriptLib.GetGroupTempValue(context, "ball_counter", {})
local ball_num = ScriptLib.GetGroupTempValue(context, "ball_num", {})
if ball_counter >= ball_num then
ScriptLib.EndTimeAxis(context, "FootBallClear")
if nil ~= defs.refresh_delay then
ScriptLib.InitTimeAxis(context, "NewRound", {defs.refresh_delay}, false)
else
LF_ClearRound(context)
LF_StartRound(context)
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_FootBall] Monster die. config_id@"..config_id)
return 0
end
LF_Initialize()

View File

@ -0,0 +1,442 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_Main
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [CharAmuse_Main]
|| Protection:
=======================================]]
--[[
local defs = {
--每个房间传送点坐标列表,key为GalleryID
transpoint_list =
{
--玩法1
[6001] = {
[1] = {pos = {x = 224.4635, y = 21.55999, z = 17.19053}, rot = {x = 0, y = 180, z = 0}},
[2] = {pos = {x = 224.4635, y = 21.55999, z = 19.95908}, rot = {x = 0, y = 180, z = 0}},
[3] = {pos = {x = 227.272, y = 21.55999, z = 18.4593}, rot = {x = 0, y = 180, z = 0}},
[4] = {pos = {x = 221.5798, y = 21.55999, z = 18.4593}, rot = {x = 0, y = 180, z = 0}}
},
}
--每个小活动关卡Group列表
group_list =
{
--玩法1
[6001] = 235800006,
}
}
]]
local cfg = {
--multistage数量
total_stage = 3,
--完成wait阶段传送玩家,等待传送完成的延时
trans_delay = 8,
--IdleStgae等待时间
idle_delay = 12,
--等待Preview界面先弹出后再换人
switchteam_delay = 2,
--需要提前取到GalleryID以创建布设的Group
groups_need_gallery =
{
[251008011] = {28009, 28010}
},
--战斗关
battle_gallery =
{
28013,28014,28015,28016,28017,28018
},
--战斗关
pillar_gallery =
{
28003,28004
}
}
local extraTriggers = {
{ config_id = 8000001, name = "Group_Load_Main", event= EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load_Main", trigger_count = 0 },
{ config_id = 8000002, name = "MultiStage_End", event= EventType.EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END, source = "", condition = "", action = "action_MultiStage_End", trigger_count = 0 },
{ config_id = 8000003, name = "MPMode_All_PlayerEnter", event = EventType.EVENT_CHAR_AMUSEMENT_DUNGEON_ALL_PLAYER_ENTER, source = "", condition = "", action = "action_MPMode_All_PlayerEnter", trigger_count = 0},
{ config_id = 8000004, name = "Dungeon_Settle", event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_Dungeon_Settle", trigger_count = 0},
{ config_id = 8000005, name = "Trans_Delay", event = EventType.EVENT_TIME_AXIS_PASS, source = "trans_delay", condition = "", action = "action_Trans_Delay", trigger_count = 0},
{ config_id = 8000006, name = "SwitchTeam_Delay", event = EventType.EVENT_TIME_AXIS_PASS, source = "switchteam_delay", condition = "", action = "action_SwitchTeam_Delay", trigger_count = 0},
{ config_id = 8000007, name = "All_Avator_Die", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_All_Avator_Die", trigger_count = 0},
{ config_id = 8000008, name = "Enter_Scene_Trans", event = EventType.EVENT_TIME_AXIS_PASS, source = "enterscene_delay", condition = "", action = "action_Enter_Scene_Trans", trigger_count = 0},
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
end
function action_Group_Load_Main(context, evt)
--当前关卡index 有几个Gallery stage_index就到几
ScriptLib.SetGroupTempValue(context, "stage_index", 1, {})
--序号 每End一个Stage++,校验用 用于防止意外客户端AbilitySLC重复EndStage
ScriptLib.SetGroupTempValue(context, "stage_num", 1, {})
--初始化Multistage
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.InitSceneMultistagePlay(context, 1, MultistagePlayType.CharAmusement, { gallery_stage_count = cfg.total_stage }, uid_list)
--获取gallery_id列表存为tempValue
local play_gallery_list = ScriptLib.GetCharAmusementMultistagePlayGalleryIdVec(context, base_info.group_id, 1)
if nil == play_gallery_list or 0 == #play_gallery_list then
ScriptLib.PrintGroupWarning(context,"## [CharAmuse_Main] Get multi stage gallery id list failed.")
return 0
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_Main] Get multi stage gallery id. vec@".. table.concat( play_gallery_list, ", "))
--处理需要提前通知玩法Group的内容
LF_SendGalleryIDVec_ToPlayGroup(context, play_gallery_list)
ScriptLib.SetGroupTempValue(context, "gallery_num", #play_gallery_list, {})
for i=1,#play_gallery_list do
ScriptLib.SetGroupTempValue(context, "gallery_"..i, play_gallery_list[i], {})
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Get gallery list. gallery_" .. i .. "@".. play_gallery_list[i])
end
--进入MultiStage阶段 - 关卡展示界面
LF_StartWaitStage(context, 1)
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Main group loaded.")
return 0
end
function action_Dungeon_Settle(context, evt)
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
local cur_gallery = ScriptLib.GetGroupTempValue(context, "gallery_"..stage_index, {})
ScriptLib.StopGallery(context, cur_gallery, true)
ScriptLib.EndSceneMultiStagePlay(context, 1, false)
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Dungeon settled.")
return 0
end
--联机 通过Event判断玩家全部入场
function action_MPMode_All_PlayerEnter(context, evt)
local has_transed = ScriptLib.GetGroupTempValue(context, "has_transed", {})
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
if 1 == stage_index and 1 ~= has_transed then
ScriptLib.SetGroupTempValue(context, "has_transed", 1, {})
--LF_TranAllPlayerToGalleryPos(context, stage_index) --需要确保客户端Wait界面已经开启所以首次进场时晚一点传送
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Trans player on first round. Start timeaxis enterscene_delay。")
ScriptLib.InitTimeAxis(context, "enterscene_delay", { 2 }, false)
end
ScriptLib.InitTimeAxis(context, "trans_delay", { cfg.trans_delay }, false)
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] All player enter. Init time axis trans_delay.")
return 0
end
--SLC入场传送 目的是用于重连时处理被打断传送的玩家。但进场都会调用在EX_DoReTransCheck_Single用IsPlayerTransmittable过滤
function SLC_CharAmuseMain_PlayerEnter(context)
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
if -1 == stage_index then
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Get level entity ability onstart. Got stage_index failed.")
return 0
end
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_"..stage_index, {})
if nil == defs.group_list[gallery_id] then
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Get level entity ability onstart. Got unexpected gallery_id@"..gallery_id)
return 0
end
if nil == context.uid then
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Get level entity ability onstart. SLC_CharAmuseMain_PlayerEnter context.uid is nil.")
return 0
end
ScriptLib.ExecuteGroupLua(context, defs.group_list[gallery_id], "EX_DoReTransCheck_Single", {context.uid})
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Get level entity ability onstart. Execute EX_DoReTransCheck. uid@"..context.uid)
return 0
end
function action_All_Avator_Die(context, evt)
-- 所有玩家死亡
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
if ScriptLib.IsPlayerAllAvatarDie(context, v) == false then
return 0
end
end
ScriptLib.CauseDungeonFail(context)
--multistage gallery 在DungeonSettle关闭
return 0
end
function action_Enter_Scene_Trans(context, evt)
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
LF_TranAllPlayerToGalleryPos(context, stage_index)
return 0
end
function action_Trans_Delay(context, evt)
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
local stage_num = ScriptLib.GetGroupTempValue(context, "stage_num", {})
--1,4,7是Preview
if 1 == stage_num or 4 == stage_num or 7 == stage_num then
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Trans delay time axis passed. End waitStage@".."WaitStage_"..stage_index)
ScriptLib.EndSceneMultiStagePlayStage(context, 1, "WaitStage_"..stage_index, true)
end
return 0
end
function action_SwitchTeam_Delay(context, evt)
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
ScriptLib.CharAmusementMultistagePlaySwitchTeam(context, base_info.group_id, 1, stage_index)
LF_TranAllPlayerToGalleryPos(context, stage_index)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_"..stage_index, {})
--特殊处理1如果接下来是战斗关则移除打桩关的suite布设
if LF_CheckIsInTable(context, gallery_id, cfg.battle_gallery) then
ScriptLib.ExecuteGroupLua(context, 251008012, "EX_ClearPillarSuite", { })
return 0
end
--特殊处理2如果接下来是打桩关则添加打桩关的suite布设
if LF_CheckIsInTable(context, gallery_id, cfg.pillar_gallery) then
ScriptLib.ExecuteGroupLua(context, 251008012, "EX_SetPillarSuite", { })
return 0
end
return 0
end
--任意MultiStageEnd根据stage_index做对应处理
--evt.source_name: 阶段名 evt.param3: 1成功 0失败
function action_MultiStage_End(context, evt)
--玩到第几关了
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
--End的是哪一种Stage
local name = string.sub(evt.source_name, 1, 9)
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] MultiStage_End. stage_index@"..stage_index.." source_name@"..evt.source_name.. " evt.param3@".. evt.param3)
--失败
if 0 == evt.param3 then
if "PlayStage" == name then
ScriptLib.EndSceneMultiStagePlay(context, 1, false)
end
return 0
end
--成功
ScriptLib.ChangeGroupTempValue(context, "stage_num", 1, {})
--换人与传送 WaitStage_x -> 倒计时 IdleStage_x -> 开始 PlayStage_x
if "WaitStage" == name then
ScriptLib.EndTimeAxis(context, "trans_delay")
--如果首轮传送在WaitStage结束后还没有执行则在此时传送
local has_transed = ScriptLib.GetGroupTempValue(context, "has_transed", {})
if 1 ~= has_transed then
ScriptLib.SetGroupTempValue(context, "has_transed", 1, {})
LF_TranAllPlayerToGalleryPos(context, stage_index)
end
LF_StartIdleStage(context, stage_index)
elseif "IdleStage" == name then
LF_StartPlayStage(context, stage_index)
elseif "PlayStage" == name then
ScriptLib.ChangeGroupTempValue(context, "stage_index", 1, {})
if true == LF_IsAllStageFinish(context) then
ScriptLib.EndSceneMultiStagePlay(context, 1, true)
else
stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
LF_StartWaitStage(context, stage_index)
end
end
return 0
end
--换人与传送阶段 先进阶段让客户端开界面 然后延迟两秒换人
function LF_StartWaitStage(context, stage_index)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_"..stage_index, {})
--开启阶段
ScriptLib.StartSceneMultiStagePlayStage(context, 1, 40, Multistage.CharAmusementPreview, "WaitStage_"..stage_index, { preview_stage_index = stage_index, preview_display_duration = 40})
if 1 < stage_index then
ScriptLib.InitTimeAxis(context, "switchteam_delay", {cfg.switchteam_delay}, false)
else
--特殊处理1如果接下来是战斗关则移除打桩关的suite布设
if LF_CheckIsInTable(context, gallery_id, cfg.battle_gallery) then
ScriptLib.ExecuteGroupLua(context, 251008012, "EX_ClearPillarSuite", { })
elseif LF_CheckIsInTable(context, gallery_id, cfg.pillar_gallery) then
--特殊处理2如果接下来是打桩关则添加打桩关的suite布设
ScriptLib.ExecuteGroupLua(context, 251008012, "EX_SetPillarSuite", { })
end
end
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] LF_StartWaitStage. stage_index@"..stage_index)
--开启下一玩法的空气墙
ScriptLib.SetGroupVariableValueByGroup(context, "air_wall", 1, defs.group_list[gallery_id])
return 0
end
--倒计时阶段
function LF_StartIdleStage(context, stage_index)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_"..stage_index, {})
--进行一次超界检测
ScriptLib.ExecuteGroupLua(context, defs.group_list[gallery_id], "EX_DoReTransCheck", {})
--开启阶段
ScriptLib.StartSceneMultiStagePlayStage(context, 1, cfg.idle_delay, Multistage.Idle, "IdleStage_"..stage_index,{})
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] LF_StartIdleStage. stage_index@"..stage_index)
return 0
end
--开启玩法阶段 通知对应GroupId
function LF_StartPlayStage(context, stage_index)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_"..stage_index, {})
local is_last_level = 0
if stage_index >= ScriptLib.GetGroupTempValue(context, "gallery_num", {}) then
is_last_level = 1
end
if nil == defs.group_list[gallery_id] then
ScriptLib.PrintGroupWarning(context,"## [CharAmuse_Main] LF_StartPlayStage: gallery_id@"..gallery_id.." is not in group_list. Check defs.")
return 0
end
--开启对应阶段
ScriptLib.StartSceneMultiStagePlayStage(context, 1, 0, Multistage.CharAmusementGallery, "PlayStage_"..stage_index, { gallery_stage_index = stage_index })
--开启对应的玩法
ScriptLib.ExecuteGroupLua(context, defs.group_list[gallery_id], "EX_StartGallery", {gallery_id, is_last_level})
--开启超界检测
ScriptLib.ExecuteGroupLua(context, defs.group_list[gallery_id], "EX_StartReTransCheck", {})
--激活复活点
LF_Set_Revive_Point(context, gallery_id)
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] LF_StartPlayStage. stage_index@"..stage_index.. " gallery_id@"..gallery_id .. " play_group@".. defs.group_list[gallery_id])
return 0
end
--外部玩法通知结束玩法阶段
function EX_EndPlayStage( context, prev_context, is_fail, from_group)
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
ScriptLib.ExecuteGroupLua(context, from_group, "EX_StopReTransCheck", {})
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] EX_EndPlayStage. stage_index@"..stage_index.." from_group@"..from_group.. " is_fail@"..is_fail)
if is_fail == 1 then
--EndSceneMultiStagePlayStage(context, play_index, stage_name, is_succ)
--ScriptLib.EndSceneMultiStagePlayStage(context, 1, "PlayStage_"..stage_index, false)
ScriptLib.CauseDungeonFail(context)
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] EX_EndPlayStage. CauseDungeonFail")
return 0
else
ScriptLib.EndSceneMultiStagePlayStage(context, 1, "PlayStage_"..stage_index, true)
end
--是否全部结束
if cfg.total_stage <= stage_index then
ScriptLib.CauseDungeonSuccess(context)
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] EX_EndPlayStage. CauseDungeonSuccess")
return 0
end
return 0
end
function LF_TranAllPlayerToGalleryPos(context, stage_index)
--传送至配置的坐标
local uid_list = ScriptLib.GetSceneUidList(context)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_"..stage_index, {})
if uid_list ~= nil then
for k,v in pairs(uid_list) do
local pos = defs.transpoint_list[gallery_id][k].pos
local rot = defs.transpoint_list[gallery_id][k].rot
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] LF_TranAllPlayerToGalleryPos. Start trans player@"..v.." X@"..pos.x.. " Y@"..pos.y.. " Z@"..pos.z)
ScriptLib.TransPlayerToPos(context, { uid_list = {v}, pos = pos, radius = 0, rot = rot , is_skip_ui = true })
end
else
ScriptLib.PrintGroupWarning(context,"## [CharAmuse_Main] LF_TranAllPlayerToGalleryPos: uid_list got nil. ")
end
return 0
end
function EX_ReTrans(context, prev_context, uid)
local uid_list = ScriptLib.GetSceneUidList(context)
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_"..stage_index, {})
--玩家对应站位
for i,v in ipairs(uid_list) do
if v == uid then
local pos = defs.transpoint_list[gallery_id][i].pos
local rot = defs.transpoint_list[gallery_id][i].rot
ScriptLib.TransPlayerToPos(context, { uid_list = {uid}, pos = pos, radius = 0, rot = rot , is_skip_ui = false})
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Player@"..uid.." ReTransed.")
end
end
return 0
end
function LF_IsAllStageFinish(context)
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", {})
local gallery_num = ScriptLib.GetGroupTempValue(context, "gallery_num", {})
if stage_index > gallery_num then
return true
end
return false
end
--需要提前取到GalleryID以创建布设的Group
function LF_SendGalleryIDVec_ToPlayGroup(context, gallery_vec)
for k,v in pairs(cfg.groups_need_gallery) do
for ik,iv in ipairs(v) do
if LF_CheckIsInTable(context, iv, gallery_vec) then
ScriptLib.ExecuteGroupLua(context, k, "EX_SetGalleryID", { iv })
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] LF_SendGalleryIDVec_ToPlayGroup. To@"..k.." gallery_id@"..iv)
return 0
end
end
end
return 0
end
--用于检查value是否在目标table中
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
function LF_Set_Revive_Point(context, gallery_id)
if nil == defs.way_point[gallery_id] then
return 0
end
ScriptLib.ActivateDungeonCheckPoint(context, defs.way_point[gallery_id])
ScriptLib.PrintContextLog(context, "## [CharAmuse_Main] Way point actived. point@"..defs.way_point[gallery_id].." gallery_id@"..gallery_id)
return 0
end
LF_Initialize()

View File

@ -0,0 +1,860 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_Pillar
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [CharAmuse_Pillar]
|| Protection:
=======================================]]
--[[
local defs = {
--玩法范围region cube
play_region = 12111,
--进入时加载内容例如棒球发球机。依次为单人、2人。。
enter_suites = {2,2,2,2},
--启动时加载内容例如史莱姆球。依次为单人、2人。。
play_suites = {},
--挑战限时秒
limit_time = 100000,
--挑战目标
target = 150,
clear_delay = 100000,
--刷出延迟
refresh_delay = 3,
-----打桩配置-----
matrix =
{
{12001,12002,12003,12004,12005,12049},
{12006,12007,12008,12009,12010,12050},
{12011,12012,12013,12014,12015,12051},
{12016,12017,12018,12019,12020,12052},
{12021,12022,12023,12024,12025,12053},
{12054,12055,12056,12057,12058,12059},
},
rounds =
{ --第一个数字表示普通地板个数,第二个数字表示高级地板个数 迭代第三个数字为特殊布设ID舍弃前两个数字读spec
--单人玩家
[1] = {{1,0},{1,1},{1,1},{1,1},{0,1},{0,1},{0,1},{0,1},{0,1}},
--2人
[2] = {{2,0},{2,1},{2,1},{0,1},{0,1},{0,1},{0,1},{0,1},{0,1}},
--3人
[3] = {{3,0},{2,1},{1,2},{0,2},{0,2},{0,2},{0,2},{0,2},{0,2}},
--4人
[4] = {{4,0},{2,2},{2,2},{0,2},{0,2},{0,2},{0,2},{0,2},{0,2}}
},
spec =
{-- pillars = {柱子ConfigID列表}, reward_suite = {奖励suite}
[1] = { pillars = {}, reward_suite = {}}
}
high_from = 4,
--每个GalleryID 特殊奖励用哪个Suite
--1000为测试用
reward_by_gallery =
{
[1000] = {5},
[28003] = {5,6},
[28004] = {5,6},
},
high_reward_by_gallery =
{
[1000] = {5},
[28003] = {7},
[28004] = {7},
},
simple_reward_suite = 4,
}
]]
local cfg = {
--主控GroupID
main_group = 251008007,
--root格备选区
corner_area =
{
[1] = {11,21,31,12,13,22},
[2] = {14,15,16,25,26,36},
[3] = {64,65,66,55,56,46},
[4] = {61,62,63,51,52,41}
},
--4个root格备选区对应的leaf格备选区域
--这个是能算的但数学不好直接列出来
--当计算延申时,首位横纵延申 二三位横向延申 四五位纵向延伸
leaf_area =
{
[1] = {55,53,64,35,46},
[2] = {52,41,63,32,54},
[3] = {22,31,13,42,24},
[4] = {25,23,14,45,36},
},
--1*1柱子可出现范围 彼此互不相邻
normal_area =
{
21,41,61,13,33,53,25,45,65
},
--矩阵内环,列出来更方便
center_area =
{
22,23,24,25,
32, 35,
42,43,44,45,
},
--格子边长
tile_length = 5,
--最后一个柱子打下去后多久开始下一波
clear_delay = 30,
hp =
{ --温迪
[28003] =
{ --人数 = {普通桩,高级桩}
[1] = {1,2},
[2] = {1,3},
[3] = {1,4},
[4] = {1,4},
},
--xiao
[28004] =
{
[1] = {2,4},
[2] = {2,6},
[3] = {2,8},
[4] = {2,8},
}
}
}
local extraTriggers = {
{ config_id = 8000002, name = "TimeAxis_StopGallery", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery", condition = "", action = "action_TimeAxis_StopGallery", trigger_count = 0 },
{ config_id = 8000003, name = "ClearDelay_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "ClearDelay", condition = "", action = "action_ClearDelay_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000004, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_Gallery_Stop", trigger_count = 0 },
{ config_id = 8000005, name = "TimeAxis_StopGallery_Fail", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery_Fail", condition = "", action = "action_TimeAxis_StopGallery_Fail", trigger_count = 0 },
{ config_id = 8000007, name = "TimeAxis_NewRound", event = EventType.EVENT_TIME_AXIS_PASS, source = "NewRound", condition = "", action = "action_TimeAxis_NewRound", trigger_count = 0 },
{ config_id = 8000008, name = "AirWallVariable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "air_wall", condition = "", action = "action_AirWallVariable_Change", trigger_count = 0 },
{ config_id = 8000009, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "air_wall", value = 0})
end
--主控调用
function EX_StartGallery(context, prev_context, gallery_id, is_last_level)
--加载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
end
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetGroupTempValue(context, "player_count", #uid_list, {})
ScriptLib.SetGroupTempValue(context, "is_last_level", is_last_level, {})
--开启gallery
ScriptLib.StartGallery(context, gallery_id)
ScriptLib.SetGroupTempValue(context, "gallery_id", gallery_id, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] EX_StartGallery. player_count@"..#uid_list.." --------------")
--玩法启动
ScriptLib.SetGroupVariableValue(context, "air_wall", 0)
LF_Start_Play(context)
return 0
end
function action_Group_Load(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == ScriptLib.GetGroupVariableValue(context, "air_wall") then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
return 0
end
function action_AirWallVariable_Change(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == evt.param1 and 0 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
elseif 0 == evt.param1 and 1 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
end
return 0
end
--evt.param2: 1-成功 0-失败
function action_Gallery_Stop(context, evt)
--卸载玩法suite
if nil ~= defs.play_suites then
for k,v in pairs(defs.play_suites) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
end
LF_ClearRound(context)
ScriptLib.EndAllTimeAxis(context)
if 3 ~= evt.param3 then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
--ScriptLib.InitTimeAxis(context, "StopGallery_Fail", { 3 } , false) 9.21修改 失败不要延时结束
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
else
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)--最后一关无等待
if is_last_level then
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
else
ScriptLib.InitTimeAxis(context, "StopGallery", { 3 } , false)
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] Gallery stoped. reason@".. evt.param3.." --------------")
return 0
end
---------------------------------------------------------------------------------------------------------------
function LF_Start_Play(context)
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local target = 0
if player_count > 1 then
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, true)
else
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, false)
end
ScriptLib.SetGroupTempValue(context, "cur_score", target, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["max_score"]= target} )
ScriptLib.SetGroupTempValue(context, "round", 0, {})
LF_StartRound(context)
return 0
end
function action_TimeAxis_StopGallery(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
return 0
end
function action_TimeAxis_StopGallery_Fail(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
return 0
end
function LF_StartRound(context)
ScriptLib.SetGroupTempValue(context, "is_round_clear", 0, {})
--清理
ScriptLib.SetGroupTempValue(context, "root_config", 0, {})
ScriptLib.SetGroupTempValue(context, "leaf_config", 0, {})
ScriptLib.SetGroupTempValue(context, "spec_index", 0, {})
--round++
ScriptLib.ChangeGroupTempValue(context, "round", 1, {})
local round = ScriptLib.GetGroupTempValue(context, "round", {})
--埋点
local hit = ScriptLib.GetGroupTempValue(context, "hit", {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_StartRound. New round@"..round)
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
--如果已经到了LD配置尽头则从头循环
if round > #defs.rounds[player_count] then
round = 1
ScriptLib.SetGroupTempValue(context, "round", round, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_StartRound. All round finished. Set to 1.")
end
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
--本轮要升起的柱子列表
local pillar_list = defs.rounds[player_count][round]
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_StartRound. pillar_list@"..table.concat( pillar_list, ", "))
local avalid_normal_pos = {}
--本轮是否放置spec布设,若是,则不产生随机布设---------------------------------
if nil ~= pillar_list[3] and 0 < pillar_list[3] then
if nil ~= defs.spec[pillar_list[3]] then
for i,v in ipairs(defs.spec[pillar_list[3]].pillars) do
LF_RisePillar(context, v, 1, gallery_id, player_count)
end
ScriptLib.SetGroupTempValue(context, "spec_index", pillar_list[3], {})
return 0
end
end
--放置高级柱子-----------------------------------------
local root_pos = 0
local leaf_pos = 0
local extend_list = {}
--若只有1个高级则在center_area随机一个
if 1 == pillar_list[2] then
root_pos = LF_SelectSingleMainPillar(context)
local root_config = LF_GetConfigIdByPos(context, root_pos)
--记录
ScriptLib.SetGroupTempValue(context, "root_config", root_config, {})
--决定奖励的延伸方向extend_dir,并延申2格
extend_list = LF_GetExtendArea(context, root_pos, 0)
--升起
LF_RisePillar(context, root_config, 1, gallery_id, player_count)
--若2个高级 则一个root 一个leaf2以上当做2
elseif 2 <= pillar_list[2] then
--选Root柱子
root_pos = LF_SelectRootPillar(context)
local root_config = LF_GetConfigIdByPos(context, root_pos)
--选Leaf柱子
leaf_pos = LF_SelectLeafPillar(context)
local leaf_config = LF_GetConfigIdByPos(context, leaf_pos)
--记录
ScriptLib.SetGroupTempValue(context, "root_config", root_config, {})
ScriptLib.SetGroupTempValue(context, "leaf_config", leaf_config, {})
--决定奖励的延伸方向extend_dir,并延申2格
extend_list = LF_GetExtendArea(context, root_pos, 0)
local leaf_extend_list = LF_GetExtendArea(context, leaf_pos, root_pos)
for k,v in pairs(leaf_extend_list) do
table.insert(extend_list, v)
end
--升起
LF_RisePillar(context, root_config, 1, gallery_id, player_count)
LF_RisePillar(context, leaf_config, 1, gallery_id, player_count)
end
--放置普通柱子-----------------------------------------
if 0 >= pillar_list[1] or 5 < pillar_list[1] then --数量校验
return 0
end
--将extend_list覆盖范围从普通柱子备选列表中移除
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_StartRound. normal_area@" ..table.concat( cfg.normal_area, ", ").. " extend_list@"..table.concat( extend_list, ", ").. " root_pos@"..root_pos.." leaf_pos@"..leaf_pos)
for k,v in pairs(cfg.normal_area) do
if false == LF_CheckIsInTable(context, v, extend_list) then
if false == LF_CheckIsAround(context, v, root_pos) and false == LF_CheckIsAround(context, v, leaf_pos) then
table.insert(avalid_normal_pos, v)
end
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_StartRound. Get avalid_normal_pos@" ..table.concat( avalid_normal_pos, ", ").. ". Need rise num@" .. pillar_list[1])
if 0 >= #avalid_normal_pos then
return 0
end
local seed = tostring(ScriptLib.GetServerTime(context)):reverse():sub(1, 6)
math.randomseed(seed)
for i = 1, pillar_list[1] do
local rand_index = math.random(#avalid_normal_pos)
--升起
local normal_config = LF_GetConfigIdByPos(context, avalid_normal_pos[rand_index])
table.remove(avalid_normal_pos, rand_index)
LF_RisePillar(context, normal_config, 0, gallery_id, player_count)
end
return 0
end
--取得两个延展格
--root_pos: 0-root柱子 非空- leaf柱子 决定延展方式
function LF_GetExtendArea(context, pos, root_pos)
local y = pos%10
local x_raw = pos - y
local temp = {}
--离边缘距离
local up = x_raw - 10
local down = 60 - x_raw
local left = y - 1
local right = 6 - y
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_GetExtendArea. source x@"..x_raw.." y@"..y..". Distance up@"..up.. " down@".. down .." left@".. left .." right@"..right.. ". Reference root_pos@"..root_pos)
--main柱子或root柱子
if 0 == root_pos then
if 20 < up then
table.insert(temp, "up")
elseif 20 < down then
table.insert(temp, "down")
end
if 2 < right then
table.insert(temp, "right")
elseif 2 < left then
table.insert(temp, "left")
end
--leaf柱子
else
--如果本格和Root同行或同列则不向该方向延展
--纵向同列 向左或向右延展
if math.floor(root_pos/10) == x_raw then
if 2 < right then
table.insert(temp, "right")
else
table.insert(temp, "left")
end
--横向同列 向上或向下延展
elseif root_pos%10 == y then
if 20 < up then
table.insert(temp, "up")
else
table.insert(temp, "down")
end
--不同行列
else
if 20 < up then
table.insert(temp, "up")
elseif 20 < down then
table.insert(temp, "down")
end
if 2 < right then
table.insert(temp, "right")
elseif 2 < left then
table.insert(temp, "left")
end
end
end
math.randomseed(ScriptLib.GetServerTime(context) + 999)
local extend_list = { }
if 0 == #temp then
temp = { "up" }
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_GetExtendArea. Cannot get room for extand area!! Check distance rule.")
return 0
end
local rand_index = math.random(1, #temp)
if "up" == temp[rand_index] then
table.insert(extend_list, ( x_raw - 20 + y))
table.insert(extend_list, ( x_raw - 10 + y))
elseif "down" == temp[rand_index] then
table.insert(extend_list, ( x_raw + 20 + y))
table.insert(extend_list, ( x_raw + 10 + y))
elseif "left" == temp[rand_index] then
table.insert(extend_list, ( x_raw + y - 2))
table.insert(extend_list, ( x_raw + y - 1))
elseif "right" == temp[rand_index] then
table.insert(extend_list, ( x_raw + y + 2))
table.insert(extend_list, ( x_raw + y + 1))
end
if nil == extend_list[1] then
return 0
end
--最后记录这个格子朝哪个方向摆奖励 1234上下左右
--通过取extend_list里的一个格子 和 传入的pos 做比较 来知道位置
local sample_pos = extend_list[1]
--在上
local x = math.floor( x_raw/10)
if x > math.floor(sample_pos/10) then
if 0 == root_pos then
ScriptLib.SetGroupTempValue(context, "root_extend_dir", 1, {})
else
ScriptLib.SetGroupTempValue(context, "leaf_extend_dir", 1, {})
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_GetExtendArea. Final extend_list@".. table.concat( extend_list, ", ") .. ". extend_dir@1")
return extend_list
end
--在下
if x < math.floor(sample_pos/10) then
if 0 == root_pos then
ScriptLib.SetGroupTempValue(context, "root_extend_dir", 2, {})
else
ScriptLib.SetGroupTempValue(context, "leaf_extend_dir", 2, {})
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_GetExtendArea. Final extend_list@".. table.concat( extend_list, ", ") .. ". extend_dir@2")
return extend_list
end
--在左
if y > sample_pos%10 then
if 0 == root_pos then
ScriptLib.SetGroupTempValue(context, "root_extend_dir", 3, {})
else
ScriptLib.SetGroupTempValue(context, "leaf_extend_dir", 3, {})
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_GetExtendArea. Final extend_list@".. table.concat( extend_list, ", ") .. ". extend_dir@3")
return extend_list
end
--在右
if y < sample_pos%10 then
if 0 == root_pos then
ScriptLib.SetGroupTempValue(context, "root_extend_dir", 4, {})
else
ScriptLib.SetGroupTempValue(context, "leaf_extend_dir", 4, {})
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_GetExtendArea. Final extend_list@".. table.concat( extend_list, ", ") .. ". extend_dir@4")
return extend_list
end
return 0
end
function LF_ClearRound(context)
--移除创生金币
for k,v in pairs(defs.gadget_pool) do
for ik, iv in pairs(v) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, iv)
end
end
--移除因spec布设添加的额外suite
for i = 3, #suites do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i)
end
--1是空Suite 2是柱子Suite 其余是各种奖励suite
for k,v in pairs(suites[2].gadgets) do
ScriptLib.SetGadgetStateByConfigId(context, v, 0)
end
local round = ScriptLib.GetGroupTempValue(context, "round", {})
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_Pillar", ScriptLib.GetDungeonTransaction(context), {["wave_num"] = round})
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_ClearRound.")
return 0
end
--本轮柱子全部打落
function LF_IsRoundFinish(context)
for k , v in pairs(defs.matrix) do
for ik, iv in pairs(v) do
local state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, iv)
if 201 == state or 202 == state then
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_IsRoundFinish. UnFinished@"..iv)
return false
end
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_IsRoundFinish. Finished.")
return true
end
function action_ClearDelay_TimeAxis_Pass(context, evt)
LF_ClearRound(context)
LF_StartRound(context)
return 0
end
--创建奖励
function SLC_CharAmusePillar_TryCreatReward(context)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
if 0 == config_id or -1 == config_id then
return 0
end
local from_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, config_id)
if 201 ~= from_state and 202 ~= from_state then
return 0
end
local spec_index = ScriptLib.GetGroupTempValue(context, "spec_index", {})
--降下柱子
ScriptLib.SetGadgetStateByConfigId(context, config_id, 0)
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] SLC_CharAmusePillar_TryCreatReward. config_id@"..config_id)
--非spec布设 创建奖励金币
if 0 >= spec_index then
local root_config = ScriptLib.GetGroupTempValue(context, "root_config", {})
local leaf_config = ScriptLib.GetGroupTempValue(context, "leaf_config", {})
if root_config == config_id then
local root_extend_dir = ScriptLib.GetGroupTempValue(context, "root_extend_dir", {})
LF_Create_Reward(context, LF_GetRandRewardSuite(context), gadgets[config_id].pos, root_extend_dir)
elseif leaf_config == config_id then
local leaf_extend_dir = ScriptLib.GetGroupTempValue(context, "leaf_extend_dir", {})
LF_Create_Reward(context, LF_GetRandRewardSuite(context), gadgets[config_id].pos, leaf_extend_dir)
else
LF_Create_Reward(context, defs.simple_reward_suite, gadgets[config_id].pos, 0)
end
end
--是否本轮柱子全部打落
if LF_IsRoundFinish(context) then
ScriptLib.SetGroupTempValue(context, "is_round_clear", 1, {})
if nil ~= defs.clear_delay then
ScriptLib.InitTimeAxis(context, "ClearDelay", { defs.clear_delay } , false)
else
ScriptLib.InitTimeAxis(context, "ClearDelay", { cfg.clear_delay } , false)
end
--是否有spec布设若是则创建对应奖励suite
if 0 < spec_index and nil ~= defs.spec[spec_index] then
for i, v in pairs(defs.spec[spec_index].reward_suite) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
return 0
end
end
return 0
end
function LF_GetRandRewardSuite(context)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local round = ScriptLib.GetGroupTempValue(context, "round", {})
local reward_suites= {}
if -1 == gallery_id or 0 == gallery_id then
gallery_id = 1000 --无外围测试用
end
if round >= defs.high_from then
reward_suites = defs.high_reward_by_gallery[gallery_id]
else
reward_suites = defs.reward_by_gallery[gallery_id]
end
local rand_index = math.random(1, #reward_suites)
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_GetRandRewardSuite. Gallery_id@"..gallery_id.. " rand_index@"..rand_index.. " result@".. reward_suites[rand_index])
return reward_suites[rand_index]
end
--将指定suite内的entity以pos为轴按dir转置后创生
function LF_Create_Reward(context, suite, target_pos, dir)
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_Create_Reward. suite@"..suite.. " pivot_pos@".. target_pos.x..","..target_pos.z.." dir@".. dir)
local gadget_list = suites[suite].gadgets
local pivot_pos = gadgets[gadget_list[1]].pos
for i,v in ipairs(suites[suite].gadgets) do
--原本和pivot之间的相对距离
local origin_offset_x = math.abs(gadgets[v].pos.x - pivot_pos.x)
local origin_offset_z = math.abs(gadgets[v].pos.z - pivot_pos.z)
--ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_Create_Reward. origin_offset_x@"..origin_offset_x.. " origin_offset_z@".. origin_offset_z)
local final_pos_x = 0
local final_pos_z = 0
--1234上下左右
if 1 == dir or 0 == dir then
final_pos_x = target_pos.x + origin_offset_x
final_pos_z = target_pos.z + origin_offset_z
LF_CreateGadgetFromPool(context, gadgets[v].gadget_id, { x = final_pos_x, y = gadgets[v].pos.y, z = final_pos_z }, gadgets[v].rot)
elseif 2 == dir then
final_pos_x = target_pos.x + origin_offset_x
final_pos_z = target_pos.z - origin_offset_z
LF_CreateGadgetFromPool(context, gadgets[v].gadget_id, { x = final_pos_x, y = gadgets[v].pos.y, z = final_pos_z }, gadgets[v].rot)
elseif 3 == dir then
final_pos_x = target_pos.x - origin_offset_z
final_pos_z = target_pos.z - origin_offset_x
LF_CreateGadgetFromPool(context, gadgets[v].gadget_id, { x = final_pos_x, y = gadgets[v].pos.y, z = final_pos_z }, gadgets[v].rot)
elseif 4 == dir then
final_pos_x = target_pos.x + origin_offset_z
final_pos_z = target_pos.z + origin_offset_x
LF_CreateGadgetFromPool(context, gadgets[v].gadget_id, { x = final_pos_x, y = gadgets[v].pos.y, z = final_pos_z }, gadgets[v].rot)
end
end
return 0
end
function LF_CreateGadgetFromPool(context, gadget_id, pos, rot)
if nil == defs.gadget_pool[gadget_id] then
ScriptLib.PrintGroupWarning(context, "## [CharAmuse_Pillar] Gadget pool got unperpared gadget id!! gadget_id@"..gadget_id)
return 0
end
for i,v in ipairs(defs.gadget_pool[gadget_id]) do
local ret = ScriptLib.CreateGadgetByConfigIdByPos(context, v, pos, rot)
if 0 == ret then
--ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_Create_Reward. gadget@"..v.. " pos.x@".. pos.x.. " pos.z@"..pos.z)
return 0
end
end
ScriptLib.PrintGroupWarning(context, "## [CharAmuse_Pillar] Gadget pool has been used up!! gadget_id@"..gadget_id)
return 0
end
function LF_SelectSingleMainPillar(context)
math.randomseed(ScriptLib.GetServerTime(context))
local rand_index = math.random(1, #cfg.center_area)
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_SelectSingleMainPillar. Select from center area. rand_index@"..rand_index.. "result@"..cfg.center_area[rand_index])
return cfg.center_area[rand_index]
end
--选出图形root柱子返回matrix坐标
function LF_SelectRootPillar(context)
math.randomseed(ScriptLib.GetServerTime(context))
--随机一个4*4角落作为首选区域
local corner_index = math.random(1, 4)
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_SelectRootPillar. first corner selection@"..corner_index)
ScriptLib.SetGroupTempValue(context, "corner_index", corner_index, {})
local tile_index = math.random(1, #cfg.corner_area[corner_index])
return cfg.corner_area[corner_index][tile_index]
end
--在root柱子的矩阵内环对角5个点位中 随机一个leaf柱子
function LF_SelectLeafPillar(context)
local corner_index = ScriptLib.GetGroupTempValue(context, "corner_index", {})
math.randomseed(ScriptLib.GetServerTime(context) + 888)
local leaf_tile_index = math.random(1, 5)
local leaf_pos = cfg.leaf_area[corner_index][leaf_tile_index]
return leaf_pos
end
function LF_GetConfigIdByPos(context, pos)
local x = math.floor(pos/10)
local y = pos%10
if nil == defs.matrix[x][y] or 0 == defs.matrix[x][y] then
ScriptLib.PrintGroupWarning(context, "## [CharAmuse_Pillar] Pillar matrix is not complete. Check defs!")
return 0
end
return defs.matrix[x][y]
end
--SGV_FallAttackPillar_MaxHP
function LF_RisePillar(context, config_id, is_deluxe, gallery_id, player_count)
if nil == cfg.hp[gallery_id] then
return 0
end
if nil == cfg.hp[gallery_id][player_count] then
return 0
end
local hp_map = cfg.hp[gallery_id][player_count]
if nil == hp_map[1] or nil == hp_map[2] then
return 0
end
if 1 == is_deluxe then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_FallAttackPillar_MaxHP", hp_map[2])
ScriptLib.SetGadgetStateByConfigId(context, config_id, 202)
else
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_FallAttackPillar_MaxHP", hp_map[1])
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201)
end
LF_Create_Reward(context, defs.rise_reward_suite, gadgets[config_id].pos, 0)
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_RisePillar. config_id@"..config_id)
return 0
end
--param1: 1-普通 2-大金币
function SLC_CharAmusement_CoinGet(context, param1)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
if 1 == param1 then
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, config_id)
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= 1} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, 1)--给MultStage更新分数 服务器侧埋点用
elseif 2 == param1 then
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, config_id)
if nil ~= defs.super_coin and 1 <= defs.super_coin then
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1*math.floor(defs.super_coin), {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= math.floor(defs.super_coin)} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, math.floor(defs.super_coin))--给MultStage更新分数 服务器侧埋点用
else
ScriptLib.ChangeGroupTempValue(context, "cur_score", -5, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= 5} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, 5)--给MultStage更新分数 服务器侧埋点用
end
end
--挑战完成
if 0 >= ScriptLib.GetGroupTempValue(context, "cur_score", {}) then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["is_last_level"] = is_last_level, ["is_finish"] = true, ["is_success"] = true } )
ScriptLib.StopGallery(context, gallery_id, false)
return 0
end
--是否本轮金币都吃完
if 1 ~= ScriptLib.GetGroupTempValue(context, "is_round_clear", {}) then
return 0
end
local remain_coin_1 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320015 }})
local remain_coin_2 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320022 }})
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] SLC_CharAmusement_CoinGet. Get coin while round clear. remain_coin_1@"..remain_coin_1.." remain_coin_2@"..remain_coin_2)
if 0 >= remain_coin_1 + remain_coin_2 then
ScriptLib.EndTimeAxis(context, "ClearDelay")
if nil ~= defs.refresh_delay then
ScriptLib.InitTimeAxis(context, "NewRound", {defs.refresh_delay}, false)
else
LF_ClearRound(context)
LF_StartRound(context)
end
end
return 0
end
function action_TimeAxis_NewRound(context, evt)
LF_ClearRound(context)
LF_StartRound(context)
return 0
end
--由于和战斗关共用场地,由主控通知加载
function EX_SetPillarSuite(context, prev_context)
LF_SetPillarSuite(context)
return 0
end
--由于和战斗关共用场地,由主控通知加载
function EX_ClearPillarSuite(context, prev_context)
LF_ClearPillarSuite(context)
return 0
end
function LF_SetPillarSuite(context)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context,"## [CharAmuse_Pillar] LF_SetPillarSuite. player_count@"..#uid_list)
if nil ~= defs.enter_suites and nil ~= defs.enter_suites[#uid_list] then
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, defs.enter_suites[#uid_list])
end
return 0
end
function LF_ClearPillarSuite(context)
for i = 2, #suites do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i)
end
return 0
end
function LF_CheckIsAround(context, pos, check_pos)
if 0 == check_pos then
return false
end
local x = math.floor(pos/10)
local y = pos%10
local check_pos_x = math.floor(check_pos/10)
local check_pos_y = check_pos%10
if 1 >= math.abs(x - check_pos_x) or 1 >= math.abs(y - check_pos_y) then
return true
end
return false
end
--用于检查value是否在目标table中
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
LF_Initialize()

View File

@ -0,0 +1,94 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_Retrans
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [CharAmuse_Retrans]
|| Protection:
=======================================]]
--[[
local defs = {
--玩法范围region玩法进行期间不在此Region内的玩家会被拉回
play_region = ,
}
]]
local retrans_cfg = {
--主控GroupID
main_group = 251008007,
--检查频率
check_interval = 5,
}
local Retrans_Triggers = {
{ config_id = 8800001, name = "Time_Axis_ReTrans", event = EventType.EVENT_TIME_AXIS_PASS, source = "retranstimer", condition = "", action = "action_Time_Axis_ReTrans", trigger_count = 0}
}
function LF_Initialize_Retrans()
for k,v in pairs(Retrans_Triggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
end
function EX_StartReTransCheck(context, prev_context)
if nil ~= defs.play_region and 0 ~= defs.play_region then
ScriptLib.InitTimeAxis(context, "retranstimer", { retrans_cfg.check_interval }, true)
ScriptLib.PrintContextLog(context, "## [CharAmuse_Retrans] EX_StartReTransCheck. play_region@"..defs.play_region)
end
return 0
end
function EX_StopReTransCheck(context, prev_context)
if nil ~= defs.play_region and 0 ~= defs.play_region then
ScriptLib.EndTimeAxis(context, "retranstimer")
ScriptLib.PrintContextLog(context, "## [CharAmuse_Retrans] EX_StopReTransCheck. ")
end
return 0
end
function action_Time_Axis_ReTrans(context, evt)
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
LF_DoReTransCheck(context, v)
end
return 0
end
function EX_DoReTransCheck(context, prev_context)
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
LF_DoReTransCheck(context, v)
end
return 0
end
function EX_DoReTransCheck_Single(context, prev_context, uid)
LF_DoReTransCheck(context, uid)
return 0
end
function LF_DoReTransCheck(context, uid)
if nil == regions[defs.play_region] then
return 0
end
if false == ScriptLib.IsPlayerTransmittable(context, uid) then
ScriptLib.PrintContextLog(context, "## [CharAmuse_Retrans] LF_DoReTransCheck. Player@"..uid.." is not transmittable.")
return 0
end
if false == ScriptLib.IsInRegion(context, uid, defs.play_region) then
ScriptLib.PrintContextLog(context, "## [CharAmuse_Retrans] Player@"..uid.." need retrans.")
ScriptLib.ExecuteGroupLua(context, retrans_cfg.main_group, "EX_ReTrans", {uid} )
end
return 0
end
LF_Initialize_Retrans()

View File

@ -0,0 +1,443 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_RunOnWater
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [CharAmuse_RunOnWater]
|| Protection:
=======================================]]
--[[
local defs = {
-----全玩法通用配置-----
--玩法范围region cube
play_region = 1003,
--玩法限时秒
limit_time = 120,
target = 15,
-----水上漂配置-----
reminder = 400171,
--波次轮替时不被移除的suite
ignore_on_clear = {},
-- 如果是早柚的关卡,用这套
Sayu =
{
-- 史莱姆 buff 所在的suite
add_suite ={10,11},
-- 每波金币刷出来之后多少秒后会rmd
rmd_time = 25,
-- 每波金币刷出来之后,多少秒后会刷掉
refresh_time = 30,
-- 上一波刷掉之后,刷下一波的等待时间
wait_time = 3,
-- 金币即将消失时提前5秒弹的Reminder
reminder = 400171,
-- 刷金币suite的规则
coin_list = {
-- 单人玩家
["SP"] = {
--随机情况一
{
[1] = { coin = {4, 5}, other = {6} }, --第一波
[2] = { coin = {4, 5}, other = {6} }, --第二波。。
},
--随机情况二
{
},
},
-- 多人玩家
["MP"] = {
--随机情况一
{
},
--随机情况二
{
},
},
},
},
-- 如果是神里的关卡,用这套
Ayaka = {
},
}
]]
local cfg = {
--主控GroupID
main_group = 251008007,
gallery_match =
{
--[1000] = defs.Jean,
[28005] = defs.Sayu,
[28006] = defs.Ayaka
},
}
local extraTriggers = {
{ config_id = 8000003, name = "TimeAxis_StopGallery", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery", condition = "", action = "action_TimeAxis_StopGallery", trigger_count = 0 },
{ config_id = 8000004, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_Gallery_Stop", trigger_count = 0 },
{ config_id = 8000005, name = "TimeAxis_StopGallery_Fail", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery_Fail", condition = "", action = "action_TimeAxis_StopGallery_Fail", trigger_count = 0 },
{ config_id = 8000008, name = "CoinClear_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000009, name = "NextRound_TimeAxis_Pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "NextRound", condition = "", action = "action_NextRound_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000010, name = "AirWallVariable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "air_wall", condition = "", action = "action_AirWallVariable_Change", trigger_count = 0 },
{ config_id = 8000011, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "air_wall", value = 0})
end
--主控调用
function EX_StartGallery(context, prev_context, gallery_id, is_last_level)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetGroupTempValue(context, "player_count", #uid_list, {})
ScriptLib.SetGroupTempValue(context, "is_last_level", is_last_level, {})
--开启gallery
ScriptLib.StartGallery(context, gallery_id)
ScriptLib.SetGroupTempValue(context, "gallery_id", gallery_id, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_RunOnWater] EX_StartGallery. player_count@"..#uid_list.." --------------")
--玩法启动
ScriptLib.SetGroupVariableValue(context, "air_wall", 0)
LF_Start_Play(context)
return 0
end
function action_Group_Load(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == ScriptLib.GetGroupVariableValue(context, "air_wall") then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
return 0
end
function action_AirWallVariable_Change(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == evt.param1 and 0 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
elseif 0 == evt.param1 and 1 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
end
return 0
end
--evt.param2: 1-成功 0-失败
function action_Gallery_Stop(context, evt)
--清理金币
LF_ClearRound(context)
--清理史莱姆和体力球
local char_type = LF_GetRunOnWaterCharType(context)
for k,v in pairs(char_type.add_suite) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
ScriptLib.EndAllTimeAxis(context)
if 3 ~= evt.param3 then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
--ScriptLib.InitTimeAxis(context, "StopGallery_Fail", { 3 } , false) 9.21修改 失败不要延时结束
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
else
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)--最后一关无等待
if is_last_level then
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
else
ScriptLib.InitTimeAxis(context, "StopGallery", { 3 } , false)
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_RunOnWater] Gallery stoped. reason@".. evt.param3.." --------------")
return 0
end
---------------------------------------------------------------------------------------------------------------
function LF_Start_Play(context)
ScriptLib.SetGroupTempValue(context, "coin_num", 0, {})
ScriptLib.SetGroupTempValue(context, "round", 0, {})
ScriptLib.SetGroupTempValue(context, "index", 0, {})--这个用于使最后一波循环时timeaxis名称不同
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local target = 0
if player_count > 1 then
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, true)
else
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, false)
end
ScriptLib.SetGroupTempValue(context, "cur_score", target, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["max_score"]= target} )
local rand_length = 1
local char_type = LF_GetRunOnWaterCharType(context)
ScriptLib.PrintContextLog(context,"## [CharAmuse_RunOnWater] LF_Start_Play. player_count@"..player_count)
if 1 < player_count then
rand_length = #char_type.coin_list["MP"]
else
rand_length = #char_type.coin_list["SP"]
end
math.randomseed(ScriptLib.GetServerTime(context))
local rand_index = math.random(rand_length)
ScriptLib.SetGroupTempValue(context, "rand_index", rand_index, {})
LF_StartRound(context, rand_index)
return 0
end
function action_TimeAxis_StopGallery(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
return 0
end
function action_TimeAxis_StopGallery_Fail(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
return 0
end
--param1: 1-普通 2-大金币
function SLC_CharAmusement_CoinGet(context, param1)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
if 1 == param1 then
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, config_id)
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1, {})
ScriptLib.ChangeGroupTempValue(context, "coin_num", -1, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= 1} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, 1)--给MultStage更新分数 服务器侧埋点用
elseif 2 == param1 then
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, config_id)
if nil ~= defs.super_coin and 1 <= defs.super_coin then
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1*math.floor(defs.super_coin), {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= math.floor(defs.super_coin)} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, math.floor(defs.super_coin))--给MultStage更新分数 服务器侧埋点用
else
ScriptLib.ChangeGroupTempValue(context, "cur_score", -5, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= 5} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, 5)--给MultStage更新分数 服务器侧埋点用
end
ScriptLib.ChangeGroupTempValue(context, "coin_num", -1, {})
end
if 0 >= ScriptLib.GetGroupTempValue(context, "cur_score", {}) then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["is_last_level"] = is_last_level, ["is_finish"] = true, ["is_success"] = true } )
ScriptLib.StopGallery(context, gallery_id, false)
return 0
end
local coin_num = ScriptLib.GetGroupTempValue(context, "coin_num", {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_RunOnWater] SLC_CharAmusement_CoinGet. param1@"..param1.." coin_num@"..coin_num)
if 0 >= coin_num then
--ScriptLib.EndAllTimeAxis(context)
--局内不能用EndAll 因为会停掉超界检测
local round = ScriptLib.GetGroupTempValue(context, "round", {})
local rand_index = ScriptLib.GetGroupTempValue(context, "rand_index", {})
local index = ScriptLib.GetGroupTempValue(context, "index", {})
ScriptLib.EndTimeAxis(context, "CoinClr_"..round.."_"..rand_index.."_"..index)
ScriptLib.EndTimeAxis(context, "CoinRmd_"..round.."_"..rand_index.."_"..index)
local char_type = LF_GetRunOnWaterCharType(context)
ScriptLib.InitTimeAxis(context, "NextRound", { char_type.wait_time } , false)
LF_ClearRound(context)
end
return 0
end
function LF_ClearRound(context)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
if ScriptLib.IsGalleryStart(context, gallery_id) then
--埋点
local round = ScriptLib.GetGroupTempValue(context, "round", {})
local score_total = ScriptLib.GetGroupTempValue(context, "score_total", {})
local coin_1 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320015 }})
local coin_2 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320022 }})
local score_left = coin_1 + ( coin_2 * 5 )
if nil ~= defs.super_coin and 1 <= defs.super_coin then
score_left = coin_1 + (coin_2 *math.floor(defs.super_coin))
end
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_RunOnWater", ScriptLib.GetDungeonTransaction(context), {["wave_num"] = round, ["score_gain"] = score_total - score_left, ["score_left"] = score_left})
end
for i = 3, #suites do
--史莱姆、体力球suite不移除
if nil ~= defs.ignore_on_clear then
if false == LF_CheckIsInTable(context, i, defs.ignore_on_clear) then
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i)
end
end
end
return 0
end
function LF_StartRound(context, rand_index)
local char_type = LF_GetRunOnWaterCharType(context)
local player_num = ScriptLib.GetGroupTempValue(context, "player_count", {})
local coin_list = {}
if 1 < player_num then
coin_list = char_type.coin_list["MP"]
else
coin_list = char_type.coin_list["SP"]
end
ScriptLib.SetGroupTempValue(context, "coin_num", 0, {})--个数 记录金币吃完用
ScriptLib.SetGroupTempValue(context, "score_total", 0, {})--分数 埋点用
if nil == coin_list then
ScriptLib.PrintGroupWarning(context,"## [CharAmuse_RunOnWater] LF_StartRound. Nil SPMP coin_list. player_num@"..player_num)
return 0
end
--round++
ScriptLib.ChangeGroupTempValue(context, "round", 1, {})
local round = ScriptLib.GetGroupTempValue(context, "round", {})
ScriptLib.ChangeGroupTempValue(context, "index", 1, {})--这个用于使最后一波循环时timeaxis名称不同
local index = ScriptLib.GetGroupTempValue(context, "index", {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_RunOnWater] LF_StartRound. New round@"..round.. ". in rand_index@"..rand_index)
--如果已经到了LD配置尽头则循环最后一波
if round > #coin_list[rand_index] then
round = #coin_list[rand_index]
ScriptLib.SetGroupTempValue(context, "round", round, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_RunOnWater] LF_StartRound. All round finished. Set to final.")
end
--创建金币 统计波次金币总数
if nil == coin_list[rand_index][round].coin then
ScriptLib.PrintGroupWarning(context,"## [CharAmuse_RunOnWater] LF_StartRound. Nil round. round@"..round)
return 0
end
for k,v in pairs(coin_list[rand_index][round].coin) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
--埋点统计本波总分
local coin_1 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320015 }})
local coin_2 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320022 }})
ScriptLib.SetGroupTempValue(context, "coin_num", coin_1 + coin_2, {})
if nil ~= defs.super_coin and 1 <= defs.super_coin then
ScriptLib.SetGroupTempValue(context, "score_total", coin_1 + (coin_2 *math.floor(defs.super_coin)), {})
else
ScriptLib.SetGroupTempValue(context, "score_total", coin_1 + (coin_2 * 5), {})
end
--非首轮 弹reminder
if 1 < round then
ScriptLib.ShowReminder(context, 470310104)
end
--创建其他物件
for k,v in pairs(coin_list[rand_index][round].other) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
ScriptLib.InitTimeAxis(context, "CoinClr_"..round.."_"..rand_index.."_"..index, { char_type.refresh_time } , false)
ScriptLib.InitTimeAxis(context, "CoinRmd_"..round.."_"..rand_index.."_"..index, { char_type.rmd_time } , false)
--首轮创建史莱姆和体力球
if 1 ~= round then
return 0
end
for k,v in pairs(char_type.add_suite) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
return 0
end
--限时内全清
function action_NextRound_TimeAxis_Pass(context, evt)
local rand_index = ScriptLib.GetGroupTempValue(context, "rand_index", {})
LF_StartRound(context, rand_index)
return 0
end
function action_TimeAxis_Pass(context, evt)
local name = string.sub(evt.source_name, 1, 7)--CoinClr_ CoinRmd_
if "CoinClr" == name then
LF_ClearRound(context)
local char_type = LF_GetRunOnWaterCharType(context)
ScriptLib.InitTimeAxis(context, "NextRound", { char_type.wait_time } , false)
elseif "CoinRmd" == name then
ScriptLib.ShowReminder(context, defs.reminder)
end
return 0
end
function LF_GetRunOnWaterCharType(context)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local char_type = {}
if -1 == gallery_id or nil == cfg.gallery_match[gallery_id] then
char_type = defs.Sayu
ScriptLib.PrintContextLog(context,"## [CharAmuse_RunOnWater] LF_GetRunOnWaterCharType. Gallery id undefined, use default setting.")
return char_type
else
char_type = cfg.gallery_match[gallery_id]
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_RunOnWater] LF_GetRunOnWaterCharType. Gallery@"..gallery_id)
return char_type
end
--用于检查value是否在目标table中
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
LF_Initialize()

View File

@ -0,0 +1,471 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: CharAmuse_SpinBall
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [CharAmuse_SpinBall]
|| Protection:
=======================================]]
--[[
local defs = {
-----全玩法通用配置-----
--玩法范围region cube
play_region = 1003,
--玩法限时秒
limit_time = 120,
target = 15,
-----弹球配置-----
--新一波弹球的出现时间
round_time = 10,
--提示时间
rmd_time = 8,
--提示reminder
reminder = 400171,
--点阵长度
length =
{--[点阵id] =点阵长度
[1] = 9,
[2] = 4.
},
--创生配置
born =
{--[点阵id] ={ pos = { x=,y=,z=}, rot = pos = { x=,y=,z=}}
[1]={ pos = { x=,y=,z=}, rot = pos = { x=,y=,z=}}
}
--点阵组
array_combine =
{
[1] = {5, 6},
}
-- 刷金币suite的规则
coin_list =
{
-- 单人玩家
["SP"] = {
--随机情况一
{--ball点阵组coin金币suite
[1] = { ball = 1, coin ={4, 4}, buff = {5} , mona_buff = {}}, --第一波
[2] = { ball = 1, coin ={4, 4}, buff = {5} }, --第二波。。
},
--随机情况二
{--ball点阵组coin金币suite
[1] = { ball = 1, coin ={4, 4}, buff = {5} }, --第一波
[2] = { ball = 1, coin ={4, 4}, buff = {5} }, --第二波。。
},
},
-- 多人玩家
["MP"] = {
--随机情况一
{--ball点阵组coin金币suite
[1] = { ball = 1, coin ={4, 4}}, --第一波
[2] = { ball = 1, coin ={4, 4}}, --第二波。。
},
--随机情况二
{--ball点阵组coin金币suite
[1] = { ball = 1, coin ={4, 4}}, --第一波
[2] = { ball = 1, coin ={4, 4}}, --第二波。。
},
}
-----以下内容通常不需关注-----
ball_pool = {}
}
]]
local cfg = {
--主控GroupID
main_group = 251008007,
}
local extraTriggers = {
{ config_id = 8000003, name = "TimeAxis_StopGallery", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery", condition = "", action = "action_TimeAxis_StopGallery", trigger_count = 0 },
{ config_id = 8000004, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_Gallery_Stop", trigger_count = 0 },
{ config_id = 8000005, name = "TimeAxis_StopGallery_Fail", event = EventType.EVENT_TIME_AXIS_PASS, source = "StopGallery_Fail", condition = "", action = "action_TimeAxis_StopGallery_Fail", trigger_count = 0 },
{ config_id = 8000006, name = "BallWait_TimeAxis", event = EventType.EVENT_TIME_AXIS_PASS, source = "ball_wait", condition = "", action = "action_Wait_TimeAxis_Pass", trigger_count = 0 },
{ config_id = 8000007, name = "Round_TimeAxis", event = EventType.EVENT_TIME_AXIS_PASS, source = "round_time", condition = "", action = "action_Round_TimeAxis", trigger_count = 0 },
{ config_id = 8000008, name = "Reminder_TimeAxis", event = EventType.EVENT_TIME_AXIS_PASS, source = "reminder_time", condition = "", action = "action_Reminder_TimeAxis", trigger_count = 0 },
{ config_id = 8000009, name = "RoundWait_TimeAxis", event = EventType.EVENT_TIME_AXIS_PASS, source = "roundwait_time", condition = "", action = "action_RoundWait_TimeAxis", trigger_count = 0 },
--{ config_id = 8000010, name = "Ball_Point_Arrival", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_Ball_Point_Arrival", trigger_count = 0 },
{ config_id = 8000011, name = "AirWallVariable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "air_wall", condition = "", action = "action_AirWallVariable_Change", trigger_count = 0 },
{ config_id = 8000012, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "air_wall", value = 0})
end
--主控调用
function EX_StartGallery(context, prev_context, gallery_id, is_last_level)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetGroupTempValue(context, "player_count", #uid_list, {})
ScriptLib.SetGroupTempValue(context, "is_last_level", is_last_level, {})
--开启gallery
ScriptLib.StartGallery(context, gallery_id)
ScriptLib.SetGroupTempValue(context, "gallery_id", gallery_id, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] Gallery Started. player_count@"..#uid_list.." --------------")
--玩法启动
ScriptLib.SetGroupVariableValue(context, "air_wall", 0)
LF_Start_Play(context)
return 0
end
function action_Group_Load(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == ScriptLib.GetGroupVariableValue(context, "air_wall") then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
return 0
end
function action_AirWallVariable_Change(context, evt)
if nil == defs.air_wall then
return 0
end
if 1 == evt.param1 and 0 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.CreateGadget(context, { config_id = v })
end
elseif 0 == evt.param1 and 1 == evt.param2 then
for i,v in ipairs(defs.air_wall) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
end
return 0
end
--evt.param2: 1-成功 0-失败
function action_Gallery_Stop(context, evt)
LF_ClearRound(context)
ScriptLib.EndAllTimeAxis(context)
if 3 ~= evt.param3 then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
--ScriptLib.InitTimeAxis(context, "StopGallery_Fail", { 3 } , false) 9.21修改 失败不要延时结束
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
else
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)--最后一关无等待
if is_last_level then
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
else
ScriptLib.InitTimeAxis(context, "StopGallery", { 3 } , false)
end
end
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] Gallery stoped. reason@".. evt.param3.." --------------")
return 0
end
---------------------------------------------------------------------------------------------------------------
function LF_Start_Play(context)
ScriptLib.SetGroupTempValue(context, "round", 0, {})
local player_count = ScriptLib.GetGroupTempValue(context, "player_count", {})
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local target = 0
if player_count > 1 then
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, true)
else
target = ScriptLib.GetCharAmusementGalleryTarget(context, gallery_id, false)
end
ScriptLib.SetGroupTempValue(context, "cur_score", target, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["max_score"]= target} )
local rand_length = 1
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] LF_Start_Play. player_count@"..player_count)
if 1 < player_count then
rand_length = #defs.coin_list["MP"]
else
rand_length = #defs.coin_list["SP"]
end
math.randomseed(ScriptLib.GetServerTime(context))
local rand_index = math.random(rand_length)
ScriptLib.SetGroupTempValue(context, "rand_index", rand_index, {})
LF_StartRound(context)
return 0
end
function action_TimeAxis_StopGallery(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {0, base_info.group_id})
return 0
end
function action_TimeAxis_StopGallery_Fail(context, evt)
ScriptLib.ExecuteGroupLua(context, cfg.main_group, "EX_EndPlayStage", {1, base_info.group_id})
return 0
end
function LF_StartRound(context)
local rand_index = ScriptLib.GetGroupTempValue(context, "rand_index", {})
local player_num = ScriptLib.GetGroupTempValue(context, "player_count", {})
ScriptLib.SetGroupTempValue(context, "coin_num", 0, {})
ScriptLib.SetGroupTempValue(context, "score_total", 0, {})
local coin_list = {}
if 1 < player_num then
coin_list = defs.coin_list["MP"]
else
coin_list = defs.coin_list["SP"]
end
if nil == coin_list then
ScriptLib.PrintGroupWarning(context,"## [CharAmuse_SpinBall] LF_StartRound. Nil SPMP coin_list. player_num@"..player_num)
return 0
end
--round++
ScriptLib.ChangeGroupTempValue(context, "round", 1, {})
local round = ScriptLib.GetGroupTempValue(context, "round", {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] LF_StartRound. New round@".. round .. ". in rand_index@"..rand_index)
--如果已经到了LD配置尽头则循环最后一波
if round > #coin_list[rand_index] then
round = #coin_list[rand_index]
ScriptLib.SetGroupTempValue(context, "round", round, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] LF_StartRound. All round finished. Set to final.")
end
--创建Buff球
if nil ~= coin_list[rand_index][round].buff then
for i,v in ipairs(coin_list[rand_index][round].buff) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
end
--创建Buff球
if nil ~= coin_list[rand_index][round].mona_buff and 28002 == ScriptLib.GetGroupTempValue(context, "gallery_id", {}) then
for i,v in ipairs(coin_list[rand_index][round].mona_buff) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
end
--创建球
-- 根据点阵数量 创建球 等待后,开始点阵移动
local ball_index = coin_list[rand_index][round].ball
ScriptLib.SetGroupTempValue(context, "ball_index", ball_index, {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] ball_index@"..ball_index)
for k,v in pairs(defs.array_combine[ball_index]) do
local config_id = LF_CreateBall(context, defs.born[v].pos, defs.born[v].rot)
ScriptLib.SetGroupTempValue(context, "ball_"..k, config_id, {})
end
ScriptLib.InitTimeAxis(context, "ball_wait", { 1.5 } , false)
ScriptLib.InitTimeAxis(context, "round_time", { defs.round_time } , false)
ScriptLib.InitTimeAxis(context, "reminder_time", { defs.rmd_time } , false)
return 0
end
function action_Wait_TimeAxis_Pass(context, evt)
local rand_index = ScriptLib.GetGroupTempValue(context, "rand_index", {})
local round = ScriptLib.GetGroupTempValue(context, "round", {})
local player_num = ScriptLib.GetGroupTempValue(context, "player_count", {})
local coin_list = {}
if 1 < player_num then
coin_list = defs.coin_list["MP"]
else
coin_list = defs.coin_list["SP"]
end
local ball_index = ScriptLib.GetGroupTempValue(context, "ball_index", {})
for k,v in pairs(defs.array_combine[ball_index]) do
local config_id = ScriptLib.GetGroupTempValue(context, "ball_"..k, {})
--设置点阵
if 0 < config_id then
local path = {}
if nil == defs.length[v] then
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] Get path length failed. point_array_id@"..v)
return 0
end
for i = 1, defs.length[v] do
table.insert(path, i)
end
local tempParam = {route_type = 2, turn_mode = false}
ScriptLib.SetPlatformPointArray(context, config_id, v, path, tempParam)
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] SetPlatformPointArray. config_id@".. config_id.. "point_array_id@"..v)
end
end
-- 创建金币
local coin_suites = coin_list[rand_index][round].coin
for k,v in pairs(coin_suites) do
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v)
end
--埋点统计本波总分
local coin_1 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320015 }})
local coin_2 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320022 }})
ScriptLib.SetGroupTempValue(context, "coin_num", coin_1 + coin_2, {})
if nil ~= defs.super_coin and 1 <= defs.super_coin then
ScriptLib.SetGroupTempValue(context, "score_total", coin_1 + (coin_2 *math.floor(defs.super_coin)), {})
else
ScriptLib.SetGroupTempValue(context, "score_total", coin_1 + (coin_2 * 5), {})
end
return 0
end
function LF_ClearRound(context)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local round = ScriptLib.GetGroupTempValue(context, "round", {})
if ScriptLib.IsGalleryStart(context, gallery_id) then
--埋点
local score_total = ScriptLib.GetGroupTempValue(context, "score_total", {})
local coin_1 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320015 }})
local coin_2 = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320022 }})
local score_left = coin_1 + (coin_2 *5)
if nil ~= defs.super_coin and 1 <= defs.super_coin then
score_left = coin_1 + (coin_2 *math.floor(defs.super_coin))
end
ScriptLib.MarkGroupLuaAction(context, "CharAmuse_SpinBall", ScriptLib.GetDungeonTransaction(context), {["wave_num"] = round, ["score_gain"] = score_total - score_left, ["score_left"] = score_left})
end
for k,v in pairs(defs.ball_pool) do
ScriptLib.KillEntityByConfigId(context, { config_id = v })--kill播放onKill动画
end
local player_num = ScriptLib.GetGroupTempValue(context, "player_count", {})
local coin_list = {}
if 1 < player_num then
coin_list = defs.coin_list["MP"]
else
coin_list = defs.coin_list["SP"]
end
local rand_index = ScriptLib.GetGroupTempValue(context, "rand_index", {})
for i,v in ipairs(coin_list[rand_index][round].coin) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
if nil ~= coin_list[rand_index][round].buff then
for i,v in ipairs(coin_list[rand_index][round].buff) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, v)
end
end
return 0
end
function LF_CreateBall(context, pos, rot)
for k , v in pairs(defs.ball_pool) do
local ret = ScriptLib.CreateGadgetByConfigIdByPos(context, v, pos, rot)
if 0 == ret then
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] LF_CreateBall. Create gadget@"..v)
return v
end
end
ScriptLib.PrintGroupWarning(context,"## [CharAmuse_SpinBall] LF_CreateBall. Unable to create ball.")
return 0
end
function action_Round_TimeAxis(context, evt)
ScriptLib.EndTimeAxis(context, "ball_wait")
ScriptLib.EndTimeAxis(context, "round_time")
ScriptLib.EndTimeAxis(context, "reminder_time")
LF_ClearRound(context)
ScriptLib.InitTimeAxis(context, "roundwait_time", { defs.wait_time } , false)
return 0
end
function action_RoundWait_TimeAxis(context, evt)
LF_StartRound(context)
return 0
end
function action_Reminder_TimeAxis(context, evt)
ScriptLib.ShowReminder(context, defs.reminder)
return 0
end
function action_Ball_Point_Arrival(context, evt)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {evt.param1}, "GV_SpiningBall_Action", 1)
return 0
end
--param1: 1-普通 2-大金币
function SLC_CharAmusement_CoinGet(context, param1)
local gallery_id = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
local stage_index = ScriptLib.GetGroupTempValue(context, "stage_index", { cfg.main_group })
if 1 == param1 then
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, config_id)
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1, {})
ScriptLib.ChangeGroupTempValue(context, "coin_num", -1, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= 1} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, 1)--给MultStage更新分数 服务器侧埋点用
elseif 2 == param1 then
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, config_id)
if nil ~= defs.super_coin and 1 <= defs.super_coin then
ScriptLib.ChangeGroupTempValue(context, "cur_score", -1*math.floor(defs.super_coin), {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= math.floor(defs.super_coin)} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, math.floor(defs.super_coin))--给MultStage更新分数 服务器侧埋点用
else
ScriptLib.ChangeGroupTempValue(context, "cur_score", -5, {})
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["add_score"]= 5} )
ScriptLib.CharAmusementUpdateScore(context, cfg.main_group, 1, 5)--给MultStage更新分数 服务器侧埋点用
end
ScriptLib.ChangeGroupTempValue(context, "coin_num", -1, {})
end
if 0 >= ScriptLib.GetGroupTempValue(context, "cur_score", {}) then
local is_last_level = (ScriptLib.GetGroupTempValue(context, "is_last_level", {}) >= 1)
ScriptLib.UpdatePlayerGalleryScore(context, gallery_id, { ["is_last_level"] = is_last_level, ["is_finish"] = true, ["is_success"] = true } )
ScriptLib.StopGallery(context, gallery_id, false)
return 0
end
local coin_num = ScriptLib.GetGroupTempValue(context, "coin_num", {})
ScriptLib.PrintContextLog(context,"## [CharAmuse_SpinBall] SLC_CharAmusement_CoinGet. param1@"..param1.." coin_num@"..coin_num)
if 0 >= coin_num then
LF_ClearRound(context)
ScriptLib.EndTimeAxis(context, "ball_wait")
ScriptLib.EndTimeAxis(context, "round_time")
ScriptLib.EndTimeAxis(context, "reminder_time")
ScriptLib.InitTimeAxis(context, "roundwait_time", { defs.wait_time } , false)
end
return 0
end
LF_Initialize()

Some files were not shown because too many files have changed in this diff Show More