更新配置表

This commit is contained in:
flswld
2023-01-29 13:00:55 +08:00
parent 0ab4fd1d18
commit 5fbe66113e
3108 changed files with 587829 additions and 26766 deletions

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.gadget_id_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.gadget_id_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.gadget_id_operator_1,[2]=nil,[3]=defs.gadget_id_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,185 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by binghong.shen.
--- DateTime: 2022/8/8 16:33
---
--[[======================================
|| filename: BrickBreaker
|| owner: binghong.shen
|| description: 3.3打砖块活动
|| LogName: BrickBreaker
|| Protection: [Protection]
=======================================]]
-- 测试gadget 70290608
--miscs配置内容
--[[
--传送触发器物件
defs.gadget_teleport = 10001
--砖块玩法物件
defs.gadget_bricks = 10002
--空气墙
defs.gadget_airWall = 10003
--是否是地城
defs.isDungeon = 0
--地城氛围物件
defs.gadget_envLamp = 10004
defs.envWeather =
{
[1]=10169,
[2]=10170,
[3]=10171,
}
--地城对应的天气配置
local DungeonWeather = {
10039,10040,10041,10042
}
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} --每组怪物潮对应需要的杀怪数量
}
]]
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 Tri = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "gadget_talk_done", config_id = 8000002, event = EventType.EVENT_GADGETTALK_DONE, source = "", condition = "", action = "action_gadget_talk_done", trigger_count = 0},
[3] = { name = "gallery_pre_start", config_id = 8000003, event = EventType.EVENT_GALLERY_PRE_START, source = "", condition = "", action = "action_gallery_pre_start", trigger_count = 0},
[4] = { name = "dungeon_settle", config_id = 8000004, event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_dungeon_settle", trigger_count = 0},
[5] = { name = "gallery_stop", config_id = 8000005, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", 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},
--[6] = { name = "sumo_switch_team", config_id = 8000008, event = EventType.EVENT_SUMO_SWITCH_TEAM_EVENT, source = "", condition = "", action = "action_sumo_switch_team", trigger_count = 0},
--[7] = { 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},
--[8] = { 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
table.insert(variables,{ config_id=50000003,name = "fever_ratio", value = 1})
--用于记录是否已经创建空气墙防止玩家卡在空气墙外
table.insert(variables,{ config_id=50000006,name = "is_air_wall_created", value = 0})
end
------------------------------------------------------------------
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"BrickBreaker groupLoad")
SLC_SetEnvLevel(context,1)
return 0
end
function action_gadget_talk_done(context,evt)
ScriptLib.PrintContextLog(context,"BrickBreaker action_gadget_talk_done")
local talkName = evt.source_name
local talkID = evt.param2
if talkID == 6800419 or talkName == 6800419 then
ScriptLib.CreateGadget(context, { config_id = defs.gadget_teleport })
end
return 0
end
function action_gallery_pre_start(context,evt)
ScriptLib.PrintContextLog(context,"BrickBreaker action_gallery_pre_start")
local curGallery = evt.param1
ScriptLib.SetGroupTempValue(context, "curGallery", curGallery, {})
if defs then
if defs.gadget_bricks then
ScriptLib.CreateGadget(context, { config_id = defs.gadget_bricks })
end
if defs.gadget_airWall then
ScriptLib.CreateGadget(context, { config_id = defs.gadget_airWall })
end
end
return 0
end
function action_dungeon_settle(context,evt)
ScriptLib.PrintContextLog(context,"BrickBreaker action_dungeon_settle")
local curGallery = ScriptLib.GetGroupTempValue(context, "curGallery", {})
ScriptLib.StopGallery(context, curGallery, true)
return 0
end
function action_gallery_stop(context,evt)
ScriptLib.PrintContextLog(context,"BrickBreaker action_gallery_stop")
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.gadget_bricks)
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.gadget_airWall)
SLC_SetEnvLevel(context,1)
return 0
end
function SLC_SetEnvLevel(context,value)
ScriptLib.PrintContextLog(context,"BrickBreaker SLC_SetEnvLevel In")
if value and defs.gadget_envLamp then
if value == 1 then
ScriptLib.PrintContextLog(context,"BrickBreaker SLC_SetEnvLevel 1")
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_envLamp, 0)
end
if value == 2 then
ScriptLib.PrintContextLog(context,"BrickBreaker SLC_SetEnvLevel 2")
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_envLamp, 201)
end
if value == 3 then
ScriptLib.PrintContextLog(context,"BrickBreaker SLC_SetEnvLevel 3")
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_envLamp, 202)
end
end
if value and defs.envWeather and defs.envWeather[value] then
for _,v in pairs(defs.envWeather) do
ScriptLib.SetWeatherAreaState(context, v, 0)
end
ScriptLib.PrintContextLog(context,"BrickBreaker ChangeWeather "..tostring(defs.envWeather[value]))
ScriptLib.SetWeatherAreaState(context, defs.envWeather[value], 1)
end
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,680 @@
--[[======================================
|| filename: CoinCollect
|| owner: shuyi.chang
|| description: 3.3短距寻物
|| LogName: ## TD_CoinCollect
|| Protection:
=======================================]]
--[[
local defs =
{
-- 还剩多少秒的时候出现金币提示光柱
hintTime = 30,
-- 限时金币出现的时长
coinTime = 10,
-- 挑战总时长不配的话就默认是120
totalTime = 120,
-- 技能持续时长不配的话默认是10
skillDuration = 10,
-- 对应的gallery id
galleryId = 99,
}
local defs_miscs =
{
-- 特殊金币和它们关联的普通金币们有几个特殊金币就应该有几项
specialCoinTable = {
-- 每项格式如下
[specialCoin_configId] = {coin_configId_01, coin_configId_02, coin_configId_03, ...},
},
}
--]]
-- 注意这个动态group卸载会先于gallery结束所以不能用event_gallery_stop保底在group will unload里
local extraTriggers =
{
{ config_id = 50000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 50000002, name = "TIME_AXIS_PASS", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_EVENT_TIME_AXIS_PASS", trigger_count = 0 },
-- { config_id = 50000003, name = "GADGET_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_EVENT_GADGET_STATE_CHANGE", trigger_count = 0 },
{ config_id = 50000004, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", forbid_guest = false, trigger_count = 0 },
-- { config_id = 50000005, name = "VARIABLE_CHANGE_COUNT", event = EventType.EVENT_VARIABLE_CHANGE, source = "collectedCoins", condition = "condition_EVENT_VARIABLE_CHANGE_COUNT", action = "action_EVENT_VARIABLE_CHANGE_COUNT", trigger_count = 0, tag = "99" },
-- { config_id = 50000006, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0, },
{ config_id = 50000009, name = "VARIABLE_CHANGE", event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_EVENT_VARIABLE_CHANGE", trigger_count = 0, },
{ config_id = 50000010, name = "GALLERY_START", event = EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_EVENT_GALLERY_START", trigger_count = 0, },
{ config_id = 50000011, name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", trigger_count = 0 },
{ config_id = 50000012, name = "GROUP_WILL_UNLOAD", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_EVENT_GROUP_WILL_UNLOAD", trigger_count = 0 },
{ config_id = 50000013, name = "MP_ALL_PLAYER_DIE", event = EventType.EVENT_SCENE_MP_PLAY_ALL_AVATAR_DIE, source = "", condition = "", action = "action_EVENT_MP_ALL_PLAYER_DIE", trigger_count = 0 },
}
local extraVariables =
{
{ config_id = 50000101, name = "final", value = 0, no_refresh = false },
{ config_id = 50000102, name = "collectedCoins", value = 0, no_refresh = false },
{ config_id = 50000103, name = "levelStart", value = 0, no_refresh = false },
}
local coin_gadgetId = 70220131
local specialCoin_gadgetId = 70220132
-- 所有不跟特殊金币挂钩的普通金币
local indieCoins = {}
-- 所有跟特殊金币挂钩的普通金币
local tempCoins = {}
local abilityGroup = "ActivityAbility_CoinCollect_AbilityGroup"
local totalCoinCount = 0
local totalTime = 120
local skillTable =
{
["coin"] = {name = "coin", duration = 10},
["charge"] = {name = "charge", duration = 10},
}
local skillDuration = 10
local coinState = {
["default"] = 0,
["show"] = 201,
["highlight"] = 901,
["special"] = 902,
["dead"] = 202,
}
--================================================================
-- Local Functions
--================================================================
function LF_Initialize_Group(triggers, suites, variables, gadgets, regions)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
end
-- add triggers to suite
for i = 1, #extraTriggers do
-- 都放到初始suite 1
table.insert(suites[1].triggers,extraTriggers[i].name)
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
local temp = 0
for i, v in pairs(defs_miscs.specialCoinTable) do
for j = 1, #v do
-- 每个限时金币记一下自己属于哪个特殊金币
gadgets[v[j]]["specialCoin"] = i
-- add all temp coins to table
table.insert(tempCoins, v[j])
end
-- 每个特殊金币一个group var记录自己的限时金币被吃掉了多少个
temp = temp + 1
local coinVar = { config_id = 60000000 + temp, name = tostring(i), value = 0, no_refresh = true }
table.insert(variables, coinVar)
end
-- add all independent coins to table
for i, v in pairs(gadgets) do
if v.gadget_id == coin_gadgetId then
-- 不能是跟特殊金币关联的普通金币
for j = 1, #tempCoins do
if v.config_id == tempCoins[j] then
break
end
if j == #tempCoins then
-- 最后一项还没break就是它了
table.insert(indieCoins, v.config_id)
end
end
end
end
-- add ability group
-- regions[defs.maxRegion].team_ability_group_list = {abilityGroup}
totalCoinCount = #indieCoins + #tempCoins
-- 处理下挑战时长
if defs.totalTime ~= nil then
totalTime = defs.totalTime
end
-- 处理下技能时长
if defs.skillDuration ~= nil then
skillDuration = defs.skillDuration
end
end
function LF_PrintList(context, name, list)
local emptyStr = ""
for k, v in pairs(list) do
emptyStr = emptyStr..v..", "
end
ScriptLib.PrintContextLog(context, "## TD_CoinCollect list name = "..name..", list content = "..emptyStr)
end
-- 从所有201金币中随机1个金币特殊金币+不和特殊金币关联的普通金币
function LF_RandomCoin(context)
local tempTable = {}
-- 特殊金币
for i, v in pairs(defs_miscs.specialCoinTable) do
if ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, i) == coinState.show then
table.insert(tempTable, i)
end
end
-- 不和特殊金币关联的普通金币
for i = 1, #indieCoins do
if ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, indieCoins[i]) == coinState.show then
table.insert(tempTable, indieCoins[i])
end
end
LF_PrintList(context, "randomCoins", tempTable)
if #tempTable == 0 then
ScriptLib.PrintContextLog(context, "## TD_CoinCollect no 201 coins")
return 0
end
math.randomseed(tostring(ScriptLib.GetServerTime(context)):reverse():sub(1, 6))
local coinId = tempTable[math.random(#tempTable)]
ScriptLib.PrintContextLog(context, "## TD_CoinCollect LF_RandomCoin is called, coin id = "..coinId)
return coinId
end
function LF_ThreeRandomCoins(context)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect LF_ThreeRandomCoins is called")
local tempTable = {}
-- 特殊金币
for i, v in pairs(defs_miscs.specialCoinTable) do
if ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, i) == coinState.show then
table.insert(tempTable, i)
end
end
-- 不和特殊金币关联的普通金币
for i = 1, #indieCoins do
if ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, indieCoins[i]) == coinState.show then
table.insert(tempTable, indieCoins[i])
end
end
LF_PrintList(context, "201Coins", tempTable)
-- 要是不足三个金币在201有几个用几个
if #tempTable <= 3 then
return tempTable
end
-- 多余三个
math.randomseed(tostring(ScriptLib.GetServerTime(context)):reverse():sub(1, 6))
local middle = math.random(#tempTable)
if middle <= 1 then
-- 随到了1取2
middle = 2
elseif middle == #tempTable then
-- 随到了最后一项取倒数第二项
middle = #tempTable - 1
end
local middleId = tempTable[middle]
local top = math.random(middle - 1)
local topId = tempTable[top]
local bottom = math.random(middle + 1, #tempTable)
local bottomId = tempTable[bottom]
local returnTable = {}
if topId ~= 0 then
table.insert(returnTable, topId)
end
if middleId ~= 0 then
table.insert(returnTable, middleId)
end
if bottomId ~= 0 then
table.insert(returnTable, bottomId)
end
LF_PrintList(context, "hintCoins", returnTable)
return returnTable
end
function LF_ResetGroup(context, start)
for i, v in pairs(defs_miscs.specialCoinTable) do
ScriptLib.SetGroupVariableValue(context, tostring(i), 0)
end
if start == false then
-- 结束的时候不设置任何状态
return
end
-- 重置所有金币
-- 保底把所有temp coins设置为显示状态
for i = 1, #tempCoins do
ScriptLib.SetGadgetStateByConfigId(context, tempCoins[i], coinState.show)
end
-- 保底把所有indie coins设置为显示状态
for i = 1, #indieCoins do
ScriptLib.SetGadgetStateByConfigId(context, indieCoins[i], coinState.show)
end
-- 把特殊金币设置为显示状态
for k, v in pairs(defs_miscs.specialCoinTable) do
ScriptLib.SetGadgetStateByConfigId(context, k, coinState.show)
end
end
function LF_ResetVariables(context, start)
-- 各种变量都归零
ScriptLib.SetGroupVariableValue(context, "final", 0)
ScriptLib.SetGroupVariableValue(context, "collectedCoins", 0)
ScriptLib.SetGroupVariableValue(context, "levelStart", 0)
ScriptLib.SetGroupTempValue(context, "lastCoin", 0, {})
-- 所有人的各种sgv都归零
local value = 0
if start == true then
value = 0
elseif start == false then
value = -3
end
local uidList = ScriptLib.GetSceneUidList(context)
for i = 1, #uidList do
-- 保底value是负数的话能量一定不会随时间增长
ScriptLib.SetTeamServerGlobalValue(context, uidList[i], "SGV_CoinCollect_Skill_Charge", value)
ScriptLib.SetTeamServerGlobalValue(context, uidList[i], "SGV_CoinCollect_Skill_Coin", 0)
ScriptLib.SetTeamServerGlobalValue(context, uidList[i], "SGV_CoinCollect_Widget_SkillEnabled", 0)
-- 小道具初始给100能量结束的时候能量清空(上限是200-200肯定能清空)
local ret = ScriptLib.AddTeamEntityGlobalFloatValue(context, {uidList[i]}, "GV_CoinCollect_Widget_Energy", 100 * (value + 1))
ScriptLib.PrintContextLog(context, "## TD_CoinCollect GV_CoinCollect_Widget_Energy is set to "..100 * (value + 1)..", uid = "..uidList[i]..", ret = "..ret)
end
end
function LF_LevelStart(context, start)
LF_ResetVariables(context, start)
LF_ResetGroup(context, start)
if start == true then
-- 设置vision type
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {0})
elseif start == false then
-- vision type恢复正常
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {1})
end
end
function LF_CheckSkill(context, uid)
local list = ScriptLib.GetCoinCollectGalleryPlayerSkillInfo(context, uid, defs.galleryId)
LF_PrintList(context, "skillList"..uid, list)
if #list == 0 then
ScriptLib.PrintContextLog(context, "## TD_CoinCollect WARNING!! no player skill data")
return 0
end
ScriptLib.SetGroupTempValue(context, "skill_"..uid, list[1], {})
ScriptLib.SetGroupTempValue(context, "charge_"..uid, list[2], {})
ScriptLib.SetGroupTempValue(context, "coin_"..uid, list[3], {})
ScriptLib.SetGroupTempValue(context, "times_"..uid, 0, {})
ScriptLib.PrintContextLog(context, "## TD_CoinCollect LF_CheckSkill is called, uid = "..uid..", skill_id = "..list[1]..", charge = "..list[2]..", coin = "..list[3])
end
function LF_GetTableLength(t)
local count = 0
for _ in pairs(t) do count = count + 1 end
return count
end
--================================================================
-- Triggers
--================================================================
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect group is loaded")
-- 打印一下各种变量
LF_PrintList(context, "tempCoins", tempCoins)
LF_PrintList(context, "indieCoins", indieCoins)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect total coins = "..totalCoinCount)
-- 每个玩家记三个temp var给小道具技能
local uid_list = ScriptLib.GetSceneUidList(context)
for i = 1, #uid_list do
ScriptLib.SetGroupTempValue(context, "skill_"..uid_list[i], 0, {})
ScriptLib.SetGroupTempValue(context, "charge_"..uid_list[i], 0, {})
ScriptLib.SetGroupTempValue(context, "coin_"..uid_list[i], 0, {})
end
-- 初始化其他group temp var
ScriptLib.SetGroupTempValue(context, "galleryStart", 0, {})
-- 气球默认0不出现这个时候就要设置气球状态了
LF_ResetGroup(context, true)
return 0
end
function action_EVENT_GROUP_WILL_UNLOAD(context, evt)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect group will unload")
-- 埋点:每个玩家用了多少次技能
local transaction = ScriptLib.GetGalleryTransaction(context, defs.galleryId)
local uidList = ScriptLib.GetSceneUidList(context)
for i = 1, #uidList do
local skill_id = ScriptLib.GetGroupTempValue(context, "skill_"..uidList[i], {})
local times = ScriptLib.GetGroupTempValue(context, "times_"..uidList[i], {})
ScriptLib.PrintContextLog(context,"## TD_CoinCollect: transaction = "..transaction..
", skill_id = "..skill_id..", times = "..times..", gallery_id = "..defs.galleryId)
ScriptLib.MarkGroupLuaAction(context, "CoinCollect_1", transaction,
{["gallery_id"] = defs.galleryId, ["skill_id"] = skill_id, ["times"]= times})
end
-- 保底
LF_LevelStart(context, false)
return 0
end
function action_EVENT_ENTER_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect player enters region")
-- 玩家加载时间过长可能会导致gallery开启后才enter scene(大世界均可传送)如果enter scene的时候gallery已经开了再统计一次技能
if ScriptLib.GetGroupTempValue(context, "galleryStart", {}) == 1 then
LF_CheckSkill(context, context.uid)
end
return 0
end
function action_EVENT_LEAVE_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect player leaves region")
LF_LevelStart(context, false)
return 0
end
function action_EVENT_TIME_AXIS_PASS(context, evt)
local timeProcess = evt.param1
ScriptLib.PrintContextLog(context, "## TD_CoinCollect: time axis "..evt.source_name..", stage "..timeProcess.. " is finished")
if evt.source_name == "levelCountDown" then
-- 随机若干普通金币和特殊金币光柱提示
ScriptLib.SetGroupVariableValue(context, "final", 1)
ScriptLib.ShowReminder(context, 400902)
local randomCoins = LF_ThreeRandomCoins(context)
for i = 1, #randomCoins do
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, randomCoins[i], coinState.highlight)
-- 在对应位置生成一个雷达显示专用物件
if gadgets[randomCoins[i]] ~= nil then
local pos = gadgets[randomCoins[i]].pos
local rot = gadgets[randomCoins[i]].rot
ScriptLib.CreateGadgetByParamTable(context, {config_id = bait, pos = pos, rot = rot})
end
end
elseif string.sub(evt.source_name, 1, 12) == "specialCoin_" then
-- 所有201限时金币都消失回到0特殊金币重新出现
local configId = tonumber(string.sub(evt.source_name, 13))
local tempCoins = defs_miscs.specialCoinTable[configId]
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, configId, coinState.show)
for i = 1, #tempCoins do
-- 还在902的金币消失
if ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, tempCoins[i]) == coinState.special then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, tempCoins[i], 0)
end
end
else
-- 技能结束
local uid = tonumber(evt.source_name)
if uid == nil then
ScriptLib.PrintContextLog(context, "## TD_CoinCollect: WARNING!!! no valid uid when widget skill is supposed to end")
return 0
end
-- 不在乎这个技能有没有金币和充能都可以归零
ScriptLib.SetTeamServerGlobalValue(context, uid, "SGV_CoinCollect_Skill_Charge", 0)
ScriptLib.SetTeamServerGlobalValue(context, uid, "SGV_CoinCollect_Skill_Coin", 0)
ScriptLib.SetTeamServerGlobalValue(context, uid, "SGV_CoinCollect_Widget_SkillEnabled", 0)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect: uid = "..uid..", skill end")
-- elseif string.sub(evt.source_name, 1, 4) == "coin" then
-- -- 金币技能结束
-- local uid = tonumber(string.gsub(evt.source_name, "coin_", ""))
-- if uid == nil then
-- ScriptLib.PrintContextLog(context, "## TD_CoinCollect: WARNING!!! no valid uid when coin skill is supposed to end")
-- return 0
-- end
-- ScriptLib.SetTeamServerGlobalValue(context, uid, "SGV_CoinCollect_Skill_Coin", 0)
-- ScriptLib.PrintContextLog(context, "## TD_CoinCollect: uid = "..uid..", skill = coin, end")
-- elseif string.sub(evt.source_name, 1, 6) == "charge" then
-- -- 充能技能结束
-- local uid = tonumber(string.gsub(evt.source_name, "charge_", ""))
-- if uid == nil then
-- ScriptLib.PrintContextLog(context, "## TD_CoinCollect: WARNING!!! no valid uid when charge skill is supposed to end")
-- return 0
-- end
-- ScriptLib.SetTeamServerGlobalValue(context, uid, "SGV_CoinCollect_Skill_Charge", 0)
-- ScriptLib.PrintContextLog(context, "## TD_CoinCollect: uid = "..uid..", skill = charge, end")
end
return 0
end
-- function condition_EVENT_VARIABLE_CHANGE_COUNT(context, evt)
-- if evt.param2 ~= evt.param1 then return true end
-- return false
-- end
-- function action_EVENT_VARIABLE_CHANGE_COUNT(context, evt)
-- ScriptLib.PrintContextLog(context, "## TD_CoinCollect: "..evt.source_name.." changes from "..evt.param2.." to ".. evt.param1)
-- return 0
-- end
function action_EVENT_VARIABLE_CHANGE(context, evt)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect: "..evt.source_name.." changes from "..evt.param2.." to ".. evt.param1)
if evt.param1 == evt.param2 then
return 0
end
if evt.param1 == 1 and evt.source_name == "levelStart" then
-- todo 应该服务器开启gallery暂时先lua这里手动开
local ret = ScriptLib.StartGallery(context, defs.galleryId)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect: start gallery = "..defs.galleryId..", ret = "..ret)
end
return 0
end
function action_EVENT_GALLERY_START(context, evt)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect: gallery = "..evt.param1.." starts")
ScriptLib.SetGroupTempValue(context, "galleryStart", 1, {})
-- 重置变量小道具初始给100所有金币都显示
LF_LevelStart(context, true)
-- gallery开启后开始时间轴计时
ScriptLib.InitTimeAxis(context, "levelCountDown", {totalTime - defs.hintTime, totalTime}, false)
-- 把所有temp coins设置为隐藏状态
for i = 1, #tempCoins do
ScriptLib.SetGadgetStateByConfigId(context, tempCoins[i], coinState.default)
end
-- -- todo 应该gallery自带左侧进度显示客户端还没接先用挑战代替
-- ScriptLib.StartChallenge(context, defs.challengeId, defs.challengeId, {totalTime, 3, 99, totalCoinCount})
-- 判断此局使用的技能
local uid_list = ScriptLib.GetSceneUidList(context)
for i = 1, #uid_list do
LF_CheckSkill(context, uid_list[i])
end
return 0
end
function action_EVENT_MP_ALL_PLAYER_DIE(context, evt)
ScriptLib.PrintContextLog(context, "## TD_CoinCollect: all players die in mp mode")
return 0
end
--================================================================
-- SLCs
--================================================================
function SLC_Player_Approach_Coin(context, param1, param2)
-- param1是金币的类型param2
local configId = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
local gadgetState = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, configId)
if configId == 0 then
ScriptLib.PrintContextLog(context, "## TD_CoinCollect SLC_Player_Approach_Coin is called, configId = "..configId..", empty config id, return immediately")
return 0
end
if gadgets[configId] == nil or ScriptLib.CheckIsInGroup(context, 0, configId) == false then
ScriptLib.PrintContextLog(context, "## TD_CoinCollect SLC_Player_Approach_Coin is called, configId = "..configId..", cannot find entity in group, return immediately")
return 0
end
if gadgets[configId].gadget_id ~= coin_gadgetId and gadgets[configId].gadget_id ~= specialCoin_gadgetId then
ScriptLib.PrintContextLog(context, "## TD_CoinCollect SLC_Player_Approach_Coin is called, configId = "..configId..", illegal gadget id, return immediately")
return 0
end
ScriptLib.PrintContextLog(context, "## TD_CoinCollect SLC_Player_Approach_Coin is called, configId = "..configId)
-- 1普通金币2特殊金币
if param1 == 1 then
-- ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, configId, 202)
ScriptLib.KillEntityByConfigId(context, { config_id = configId })
-- todo 通知gallery修改计分暂时先用挑战做了
ScriptLib.ChangeGroupVariableValue(context, "collectedCoins", 1)
local collectedCoins = ScriptLib.GetGroupVariableValue(context, "collectedCoins")
-- param2是消耗了多少时间
-- local timePassed = totalTime - param2/1000
local timePassed = param2/1000
ScriptLib.UpdatePlayerGalleryScore(context, defs.galleryId, {["coin_collect_num"] = collectedCoins, ["last_collect_coin_left_time"] = timePassed})
ScriptLib.PrintContextLog(context, "## TD_CoinCollect a coin is picked up, gallery score: coin_collect_num = "..collectedCoins..", last_collect_coin_left_time = "..timePassed)
-- 如果是特殊金币关联的限时金币
local specialCoin_configId = gadgets[configId].specialCoin
if specialCoin_configId ~= nil then
-- if evt.param3 == 902 then
ScriptLib.ChangeGroupVariableValue(context, tostring(specialCoin_configId), 1)
-- 如果某一个特殊金币周围的限时金币都被拾取了关联的特殊金币消失时间轴取消(不能把关联的限时金币重置回来了)
if ScriptLib.GetGroupVariableValue(context, tostring(specialCoin_configId)) == #defs_miscs.specialCoinTable[specialCoin_configId] then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, specialCoin_configId, coinState.dead)
ScriptLib.EndTimeAxis(context, "specialCoin_"..specialCoin_configId)
end
end
-- 如果已经吃完所有金币直接触发gallery成功结算
if collectedCoins >= totalCoinCount then
-- true是fail
ScriptLib.StopGallery(context, defs.galleryId, false)
end
elseif param1 == 2 then
-- 2特殊金币特殊金币消失通知这个特殊金币关联的限时普通金币出现
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, configId, coinState.special)
local tempCoins = defs_miscs.specialCoinTable[configId]
for i = 1, #tempCoins do
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, tempCoins[i], coinState.special)
ScriptLib.InitTimeAxis(context, "specialCoin_"..configId, {defs.coinTime}, false)
end
end
-- 如果是最后高亮提示时刻吃掉一个高亮金币就得再随机一个出来
if gadgetState == coinState.highlight and ScriptLib.GetGroupVariableValue(context, "final") == 1 then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, LF_RandomCoin(context), coinState.highlight)
end
return 0
end
function SLC_CoinCollect_WidgetUsed(context)
-- 使用了一次小道具需要判断是否需要修改小道具tick速度和金币拾取范围别的技能的开关是SGV_CoinCollect_Widget_SkillEnabled
local coin = ScriptLib.GetGroupTempValue(context, "coin_"..context.uid,{})
local charge = ScriptLib.GetGroupTempValue(context, "charge_"..context.uid,{})
ScriptLib.PrintContextLog(context, "## TD_CoinCollect SLC_CoinCollect_WidgetUsed is called, uid = "..context.uid..", coin = "..coin..", charge = "..charge)
local times = ScriptLib.GetGroupTempValue(context, "times_"..context.uid, {})
ScriptLib.SetGroupTempValue(context, "times_"..context.uid, times + 1, {})
if coin == 1 then
-- 能扩大金币范围
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_CoinCollect_Skill_Coin", 1)
-- ScriptLib.InitTimeAxis(context, "coin_"..context.uid, {skillTable.coin.duration}, false)
end
if charge == 1 then
-- 充能加速
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_CoinCollect_Skill_Charge", 1)
-- ScriptLib.InitTimeAxis(context, "charge_"..context.uid, {skillTable.coin.duration}, false)
end
-- 其他战斗负责的技能只听这个sgv控制
local ret = ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_CoinCollect_Widget_SkillEnabled", 1)
-- ScriptLib.PrintContextLog(context, "## TD_CoinCollect SGV_CoinCollect_Widget_SkillEnabled is set to 1, ret = "..ret)
-- 据说所有技能持续时长是一致的只起一个时间轴统一管了
ScriptLib.InitTimeAxis(context, tostring(context.uid), {skillDuration}, false)
return 0
end
--================================================================
-- Initialization
--================================================================
LF_Initialize_Group(triggers, suites, variables, gadgets, regions)

View File

@@ -0,0 +1,840 @@
--[[======================================
|| filename: HideAndSeek_Gallery_V3
|| owner: shuyi.chang
|| description: 风行迷踪三期
|| LogName: ## HideAndSeek_V3
|| Protection: [Protection]
=======================================]]
--[[
local defs =
{
gadget_prison = gadget_id,
duration = 240,
rampage_time = 40,
-- 用于固定lod 1的region千万不能填错填错了一定会炸服务器
eye_point = region_id,
}
local energy_info =
{
[1] = { time = 80, step = {-30,30}, points = {1,2,3,4,5,6}},
[2] = { time = 160, step = {-30,30}, points = {1,2,3,4,5,6}}
}
-- 这个group对应的图用哪些这里就填哪些
local disguiseList = {1, 2, 3}
--]]
--初始化给的state,V2开始全部由SGV实现
local HS_State = {
["Play"] = { name = "SGV_HideAndSeek_PlayerState_Play", value = 3 },
["Visible"] = { name = "SGV_HideAndSeek_PlayerState_Visible", value = 0 },
["OnMap"] = { name = "SGV_HideAndSeek_PlayerState_OnMap", value = 0 },
["Moveable"] = { name = "SGV_HideAndSeek_PlayerState_Moveable", value = 0 },
["Transfer"] = { name = "SGV_HideAndSeek_PlayerState_Transfer", value = 0 },
["TransferCache"] = { name = "SGV_HideAndSeek_PlayerState_TransferCache", value = 0},
["UltraMark"] = { name = "SGV_Is_In_UltraMark", value = 0 },
["GlobalSight"] = { name = "SGV_Is_In_GlobalSight", value = 0 },
["SuperPrison"] = { name = "SGV_Is_In_SuperPrison", value = 0 },
["Rampage"] = { name = "SGV_Is_In_Rampage", value = 0 },
["Dead"] = { name = "SGV_HideAndSeek_PlayerState_Dead", value = 0},
["Is_Detected"] = { name = "SGV_HideAndSeek_PlayerState_Is_Detected", value = 0},
-- ===========================三期新增隐身诱饵造成的隐身状态==========================
["Visible_Bait"] = { name = "SGV_HideAndSeek_PlayerState_Visible_Bait", value = 0},
["Visible_Mark"] = { name = "SGV_HideSeek_Real_Invisible_Mark", value = 0},
}
local skill_info = {
["HideAndSeek_Skill_CatchPrey"] = { radius = 4 },
["HideAndSeek_Skill_Guide"] = { radius = 500 },
["HideAndSeek_Skill_Detect_F"] = { radius = 10 },
["HideAndSeek_Skill_UltraMark"] = { radius = 500, duration = 60 },
["HideAndSeek_Skill_GlobalSight"] = { radius = 500, duration = 20 },
["HideAndSeek_Skill_SuperPrison"] = { radius = 500, duration = 40 },
-- ===========================三期新增隐身诱饵==========================
["HideAndSeek_Skill_InvisibleBait_Check"] = { radius = 6, duration = 40 },
-- ===========================三期新增四方八方之网==========================
["HideAndSeek_Skill_HunterNet"] = { radius = 12 },
}
local hunter_win_by_EX = 30
local hunter_win_in_time = 120
local hunter_catch_by_guide = 10
local final_time = 180 --抓捕阶段第180秒后为决胜时间猎手在该时间内抓两人记录翻牌
local map_info = {
--一期
[1001003] = { name = "QingCe", list = {1,2,3} },
[1001022] = { name = "QingQuan", list = {4,5} },
[1001004] = { name = "WuWang", list = {4,8} },
[1001002] = { name = "JiuZhuang", list = {7,8} },
[1001023] = { name = "XueShan", list = {4,8} },
--二期地图
[1001006] = { name = "test_1", list = {1,2,3} },--轻策庄二期
[1001007] = { name = "test_2", list = {4,8} },
[1001008] = { name = "test_3", list = {4,8} },
[1001009] = { name = "test_4", list = {19,17,18,20} },--离岛
[1001010] = { name = "test_5", list = {4,8} },
[1001011] = { name = "test_6", list = {11,12,13} },--神里
[1001012] = { name = "test_7", list = {14,11,15} },--绯木
[1001013] = { name = "test_8", list = {16,17,18} },--九条
[1001014] = { name = "test_9", list = {4,8} },
[1001015] = { name = "test_10", list = {4,8} },
[1001015] = { name = "test_11", list = {4,21} },--初始林地
[1001016] = { name = "test_12", list = {4,8} },
[1001017] = { name = "test_13", list = {4,8} },
[1001018] = { name = "test_14", list = {4,8} },
[1001019] = { name = "test_15", list = {4,21,22} },--璃月遗迹
[1001020] = { name = "test_16", list = {4,8} },
[1001021] = { name = "test_17", list = {4,8} },
[1001026] = { name = "test_18", list = {7,8,23} },--酒庄
--三期新增三期地图
[1001027] = { name = "CengYan", list = {21,18,13} },--层岩
[1001028] = { name = "HaiYueChi", list = {21,18,13} },--海月池
[1001029] = { name = "ShanHuGong", list = {21,18,13} },--珊瑚宫
[1001030] = { name = "GanTian", list = {20,11,15} },--绀田村
[1001031] = { name = "QingCeZhuang", list = {21,18,2} },--轻策庄
[1001032] = { name = "AuMoSi", list = {21,18,13} },--奥摩斯港
[1001033] = { name = "ChanNaYuan", list = {21,18,13} },--禅那园
[1001034] = { name = "KaSaZhaLai", list = {21,18,13} },--卡萨扎莱
[1001035] = { name = "WeiMoZhuang", list = {21,18,13} },--维摩庄
[1001036] = { name = "DaBaZha", list = {21,18,13} },--大巴扎
}
-- 上面那些变身物件的对应关系
-- 1稻草人蓝2稻草人红3枯木4丘丘人木箱5草垛6鬼火7小路灯8木桶9火仙灵10龙血矿石
-- 11木盆12水桶13纸灯14咸菜缸15泡菜缸16稻草靶子17经典木桶18经典木箱19米袋子20小板凳21qq人木桶22璃月石灯23凳子
-- 24层岩巨渊木箱25竖木桶26横木桶27石块28枯木29珊瑚30灯柱31稻妻陶罐32大酒坛33璃月木箱34须弥木箱35竹筐36须弥路灯37营地竖木桶38营地横木桶39营地罐子
--玩法中开启的天气
local weather_id_list = {3151}
local Tri = {
[1]={ name = "gallery_stop", config_id = 8000001, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
[2]={ name = "challenge_success", config_id = 8000003, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
[3]={ name = "challenge_fail", config_id = 8000004, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
[4]={ name = "variable_change", config_id = 8000005, event = EventType.EVENT_VARIABLE_CHANGE, source = "catch_sum", condition = "", action = "action_variable_change", trigger_count = 0, tag = "9012"},
[5]={ name = "time_axis_pass", config_id = 8000006, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[6]={ name = "enter_region", config_id = 8000007, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false},
[7]={ name = "GM_Debug", config_id = 8000008, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_GM_Debug", trigger_count = 0 },
[8]={ name = "multistage_end", config_id = 8000009, event = EventType.EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END, source = "", condition = "", action = "action_multistage_end", trigger_count = 0 },
[9]={ name = "group_load", config_id = 8000010, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
[10]={name = "avatar_die", config_id = 8000011, event = EventType.EVENT_AVATAR_DIE, source = "", condition = "", action = "action_avatar_die", trigger_count = 0 },
[11]={name = "player_quit", config_id = 8000012, event = EventType.EVENT_HIDE_AND_SEEK_PLAYER_QUIT, source = "", condition = "", action = "action_player_quit", trigger_count = 0 },
[12]={name = "leave_region", config_id = 8000013, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0, forbid_guest = false},
[13]={name = "group_will_unload", config_id = 8000014, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0 },
}
local Var = {
{ config_id=50000001,name = "catch_sum", value = 0, no_refresh = false},
{ config_id=50000002,name = "GM_stage", value = 0, no_refresh = false},
}
-- 三期新增有些ability specials gadget是lua自行创建的但是需要一个config id直接在lua里写死就不用在关卡编辑器里配了
-- 但是对pos和area id有一些限制所以找个地方存一下一定合法的值方便后面调用
local regionDefaultValues = {
pos = regions[defs.eye_point].pos,
area_id = regions[defs.eye_point].area_id,
radius = regions[defs.eye_point].radius,
}
local extraGadgets = {
-- 隐身诱饵一人一个
-- 不太確定為什麼level = 10不過二期都是10所以三期先照抄
[30000001] = { config_id = 30000001, gadget_id = 44000457, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000002] = { config_id = 30000002, gadget_id = 44000457, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000003] = { config_id = 30000003, gadget_id = 44000457, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
-- 普通诱饵一人三个
[30000004] = { config_id = 30000004, gadget_id = 44000107, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000005] = { config_id = 30000005, gadget_id = 44000107, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000006] = { config_id = 30000006, gadget_id = 44000107, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000007] = { config_id = 30000007, gadget_id = 44000107, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000008] = { config_id = 30000008, gadget_id = 44000107, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000009] = { config_id = 30000009, gadget_id = 44000107, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000010] = { config_id = 30000010, gadget_id = 44000107, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000011] = { config_id = 30000011, gadget_id = 44000107, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
[30000012] = { config_id = 30000012, gadget_id = 44000107, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
-- 能量球config id把不太吉利的数字跳过去
[30000015] = { config_id = 30000015, gadget_id = 44000105, pos = regionDefaultValues.pos, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 10, area_id = regionDefaultValues.area_id },
}
local gadget_energy = 30000015
local invisible_bait_list = { 30000001, 30000002, 30000003 }
local bait_list = {
[1] = {30000004, 30000005, 30000006},
[2] = {30000007, 30000008, 30000009},
[3] = {30000010, 30000011, 300000012},
}
local extraRegions = {
[40000001] = { config_id = 40000001, shape = RegionShape.SPHERE, radius = regionDefaultValues.radius + 5, pos = regionDefaultValues.pos, area_id = regionDefaultValues.area_id }
}
local eyepoint_large_region = 40000001
local challengeTable = {
fatherId = 9011,
hunterId = 9012,
hiderId = 9013,
ghostId = 2013001,
}
function Initialize_Base()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for i,v in ipairs(Var) do
table.insert(variables, v)
end
for i,v in pairs(extraGadgets) do
table.insert(gadgets, v)
end
for i,v in pairs(extraRegions) do
table.insert(regions, v)
end
-- 三期新增gadget_prison看起来只会用到一个三期就不用list了但是保底一下如果哪里的配置没改成新的
if defs.gadget_prison == nil and defs.gadget_prison_list ~= nil then
defs.gadget_prison = defs.gadget_prison_list[1]
end
end
---------------------------------------
function action_group_load(context, evt)
--根据LD铺设随机生成障碍物
LF_Bake_Random_Scene(context)
return 0
end
function action_gallery_stop(context, evt)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : Gallery Stop")
--实际gameplay仍在进行时玩法停止,则走意外终止流程
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 3)
end
return 0
end
function action_multistage_end(context, evt)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : Multistage End : "..evt.param2.." | is_succ : "..evt.param3)
if evt.param3 == 0 then
--异常终结玩法
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 3)
end
return 0
end
if evt.param2 == 2 then
--LF_Bake_Random_Scene(context)
elseif evt.param2 == 3 then
--进入逃跑阶段
ScriptLib.SetGroupTempValue(context, "in_escape", 1, {})
LF_Assign_Character_Card(context)
elseif evt.param2 == 4 then
--进入抓捕阶段
ScriptLib.SetGroupTempValue(context, "in_escape", 0, {})
LF_Start_Hide_And_Seek(context)
-- 三期新增这个时候通知一下在场的所有诱饵根据本地gv值决定是否删除effect(感觉不太需要猎人三期在逃跑阶段是4了可以跟游侠区分开)
-- LF_NotifyInvisibleBaits(context)
elseif evt.param2 == 5 then
--由于关卡流终止时说明游侠未全灭判胜
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 2)
end
end
return 0
end
function action_challenge_success(context, evt)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_Log : challenge_success -> "..evt.param1)
--猎手完成了抓人的挑战判胜
if evt.source_name == "9012" then
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 1)
end
end
return 0
end
function action_challenge_fail(context, evt)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_Log : challenge_fail -> "..evt.param1)
--猎手未能完成抓人的挑战判负
if evt.source_name == "9011" then
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 2)
end
end
return 0
end
function action_variable_change(context, evt)
-- 只管catch_sum变化
if evt.param1 == evt.param2 + 1 then
-- 这段有用的一个玩家在逃跑阶段死亡退出改变catch sum并导致catch sum等于prey总数从这里直接判猎人成功
if 1 == ScriptLib.GetGroupTempValue(context, "in_escape", {}) then
if evt.param1 == ScriptLib.GetGroupTempValue(context, "prey_sum", {}) then
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
ScriptLib.EndSceneMultiStagePlayStage(context, _index, "null", true)
end
end
--]]
return 0
else
return -1
end
end
function action_enter_region(context, evt)
if evt.param1 ~= defs.eye_point then
return -1
end
--开启视野锚点优化
ScriptLib.SetPlayerEyePointStream(context, evt.param1, evt.param1, false)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG SetPlayerEyePointStream")
-- -- 三期新增
-- -- 开启锁lod1
-- local ret = ScriptLib.SetPlayerEyePointLOD(context, defs.eye_point, eyepoint_large_region, 1)
-- ScriptLib.PrintContextLog(context, "## HideAndSeek_V3 lod level is set to 1, succeed = "..ret)
return 0
end
function action_leave_region(context, evt)
if evt.param1 ~= defs.eye_point then
return -1
end
--关闭视野锚点优化
ScriptLib.ClearPlayerEyePoint(context, evt.param1)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG ClearPlayerEyePoint")
-- -- 三期新增
-- -- 关闭锁lod1
-- local ret = ScriptLib.ClearPlayerEyePoint(context, defs.eye_point)
-- ScriptLib.PrintContextLog(context, "## HideAndSeek_V3 player eye point is cleared, succeed = "..ret)
return 0
end
function action_group_will_unload(context, evt)
--提前关闭性能圈保证关闭视野锚点优化
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.REGION, defs.eye_point)
return 0
end
function action_time_axis_pass(context, evt)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : time_axis "..evt.source_name.." -> "..evt.param1)
if evt.source_name == "rampage" then
--触发猎手暴走阶段
HideAndSeek_Hunter_Rampage(context)
elseif evt.source_name == "energy" then
--刷新一个能量球
ScriptLib.KillEntityByConfigId(context, {config_id = gadget_energy, entity_type = EntityType.GADGET})
--随机选择位置创建能量球
local p_list = energy_info[evt.param1].points
math.randomseed(ScriptLib.GetServerTime(context))
local ret = p_list[math.random(#p_list)]
local p_pos = {}
local p_rot = {}
for k,v in ipairs(points) do
if v.config_id == ret then
p_pos = v.pos
p_rot = v.rot
break
end
end
ScriptLib.CreateGadgetByConfigIdByPos(context, gadget_energy, p_pos, p_rot)
local uid_list = ScriptLib.GetSceneUidList(context)
--通知全体掉能量球
ScriptLib.AssignPlayerUidOpNotify(context, {param_index = 12,param_list={},param_uid_list={},duration=3,target_uid_list=uid_list})
elseif evt.source_name == "hunter_win_by_EX" or evt.source_name == "hunter_win_in_time" or evt.source_name == "hunter_catch_by_guide" then
--相关陈列室统计
ScriptLib.SetGroupTempValue(context, evt.source_name, 0, {})
elseif evt.source_name == "final_time" then
--抓捕阶段第180秒后为决胜时间猎手在该时间内抓两人记录翻牌
ScriptLib.SetGroupTempValue(context,"is_in_final_time",1,{})
else
--终止游侠被捕阶段并转为真死亡
for i=1,3 do
local _uid = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
if evt.source_name == tostring(_uid) then
ScriptLib.PrintContextLog(context,"## HideAndSeek_V3_LOG realDie = "..tostring(_uid))
-- ScriptLib.AssignPlayerShowTemplateReminder(context, 138, {param_vec={},param_uid_vec={},uid_vec={_uid}})
-- 三期新增换了一个UI弹窗要读表改成下面了
local _gallery = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
ScriptLib.UpdatePlayerGalleryScore(context, _gallery, {["update_type"]="updateGhostUid", ["ghost_uid"]= _uid})
LF_Set_Player_State_Value(context, _uid, HS_State.Dead.name, 1)
-- 三期新增游侠死亡后变成幽灵上新挑战目标
-- 这里挑战的具体参数不重要只是为了显示下左侧文字反正无论如何都完不成的结束只需要听关卡通知
if ScriptLib.GetGroupTempValue(context, HS_State.Play.name.."_".._uid, {}) == 2 then
-- 游侠这时候应该已经是2了
ScriptLib.AttachChildChallenge(context, challengeTable.fatherId, i*math.pow(10,5)+challengeTable.ghostId,challengeTable.ghostId,{base_info.group_id,10},{_uid},{success=1,fail=1})
end
return 0
end
end
end
return 0
end
function action_avatar_die(context, evt)
--multistage内触发的死亡回调
local char = ScriptLib.GetGroupTempValue(context, HS_State.Play.name.."_"..context.uid, {})
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : avatar_die "..context.uid.." | character = "..char)
--首先排除玩家死在玩法外的情况
if ScriptLib.GetGroupTempValue(context, "is_in_play", {}) == 0 then
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : is_in_play = 0")
return -1
end
if char == 0 then
--hunter死亡判负
ScriptLib.StopChallenge(context, 9012, 0)
elseif char == 1 then
--prey死亡算被抓
LF_Set_Prey_Die(context, context.uid)
elseif char == 3 or char == 4 then
for i = 1,3 do
local prey = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
if prey == context.uid then
--prey提前死亡不参与游戏
LF_Set_Prey_Die(context, context.uid)
return 0
end
end
--hunter提前死亡直接结算prey胜利
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
ScriptLib.EndSceneMultiStagePlayStage(context, _index, "null", true)
LF_Stop_Hide_And_Seek(context, 2)
end
return 0
end
function action_player_quit(context, evt)
--由multistage触发回调玩家离场
for j=1,3 do
if context.uid == ScriptLib.GetGroupTempValue(context, "prey_"..j, {}) then
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : Running Player_Quit : "..context.uid)
--进行中玩家离场视为hunter抓住了一个
ScriptLib.ChangeGroupVariableValue(context, "catch_sum", 1)
return 0
end
end
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : Free Player_Quit : "..context.uid)
return 0
end
function action_GM_Debug(context, evt)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : variable_change "..evt.source_name.." "..evt.param2.." -> "..evt.param1)
if evt.param1 == evt.param2 then
return -1
end
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
--处理玩家隐身显形
if evt.source_name == HS_State.OnMap.name.."_"..v then
LF_Notify_Player_Visible(context)
return -1
end
end
if evt.source_name == "catch_sum" then
return -1
end
if evt.source_name == "GM_stage" then
if evt.param1 == 1 then
LF_Bake_Random_Scene(context)
elseif evt.param1 == 2 then
LF_Assign_Character_Card(context)
elseif evt.param1 == 3 then
LF_Start_Hide_And_Seek(context)
end
end
return 0
end
---------------------------------------
function LF_Start_Hide_And_Seek(context)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_Log : LF_Start_Hide_And_Seek")
LF_Start_Comp_Challenge(context)
end
function LF_Stop_Hide_And_Seek(context, value)
--1为hunter胜2为游侠胜3为意外中断
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_Log : LF_Stop_Hide_And_Seek | value -> "..value)
ScriptLib.SetGroupTempValue(context, "is_in_play", 0, {})
ScriptLib.EndTimeAxis(context, "rampage")
ScriptLib.EndTimeAxis(context, "energy")
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
--还未进入幽灵状态的不用进了所以关掉时间轴已经结束
for i=1,3 do
local _uid = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
ScriptLib.EndTimeAxis(context, tostring(_uid))
end
--这个watcher比较特殊需要在胜利时检测prey的state所以要写在还原state之前
if value == 2 then
for i = 1 , 3 do
local _prey = ScriptLib.GetGroupTempValue(context, "prey_"..i, {})
local _const = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
if _const ~= 0 then
--存活的prey
if _prey ~= 0 then
local logvalue = ScriptLib.GetGroupTempValue(context, HS_State.Transfer.name.."_".._const, {})
ScriptLib.PrintContextLog(context,"## HideAndSeek_V3_LOG uid:".._const.."的Transfer值为:"..logvalue)
--统计胜利的时候处于变身状态
if ScriptLib.GetGroupTempValue(context, HS_State.Transfer.name.."_".._const, {}) > 0 then
ScriptLib.PrintContextLog(context,"## HideAndSeek_V3_LOG 统计:胜利的时候处于变身状态 uid:".._const)
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_win_in_transfer", 1)
end
end
end
end
end
--还原玩家所有State
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
LF_Init_Player_State(context, v)
ScriptLib.RevertPlayerRegionVision(context, uid_list[i])
end
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {1})
for i,v in ipairs(bait_list) do
for m,n in ipairs(v) do
ScriptLib.KillEntityByConfigId(context, {config_id = n, entity_type = EntityType.GADGET})
end
end
if value == 3 then
--人数不足导致异常处理
ScriptLib.StopChallenge(context, 9011, 0)
return -1
end
local _gallery = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
-------
local catch_sum = ScriptLib.GetGroupVariableValue(context, "catch_sum")
--统计抓捕总数
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_catch_sum", catch_sum)
--无论胜败都发的牌
--是猎人
ScriptLib.AddExhibitionReplaceableData(context, hunter, "is_hunter", 1)
--是游侠
for i=1,3 do
local _prey = ScriptLib.GetGroupTempValue(context, "prey_"..i, {})
ScriptLib.AddExhibitionReplaceableData(context, _prey, "is_hunter", 2)
-- 三期新增翻牌游侠-使用隐身诱饵维持多长时间的隐身
local invisible_time = ScriptLib.GetGroupTempValue(context, "Visible".._prey, {})
ScriptLib.AddExhibitionReplaceableData(context, _prey, "prey_keep_invisible", invisible_time)
end
--hunter胜利
if value == 1 then
--统计清扫时刻
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_miss_none", 1)
--统计迅捷攻势
if 1 == ScriptLib.GetGroupTempValue(context, "hunter_win_by_EX", {}) then
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_win_by_EX", 1)
end
--统计终场倒计时
if 1 == ScriptLib.GetGroupTempValue(context, "hunter_win_in_time", {}) then
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_win_in_time", 1)
end
ScriptLib.UpdatePlayerGalleryScore(context, _gallery, {["update_type"]="updateGalleryResult", ["is_hunter_win"]=true})
--prey胜利
elseif value == 2 then
LF_Handle_Exhibition_Prey_Win(context)
ScriptLib.UpdatePlayerGalleryScore(context, _gallery, {["update_type"]="updateGalleryResult", ["is_hunter_win"]=false})
end
-- 三期新增翻牌一次抓捕多个游侠
local max = ScriptLib.GetGroupTempValue(context, "catch_multiple_prey_max", {})
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_catch_multiple_prey_max", max)
LF_Clear_Random_Scene(context)
end
function LF_Assign_Character_Card(context)
-- 1prey和hunter以及各种其他局内值都用temp value记录
-- 2开启视野优化
-- 3初始化技能sgv
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : LF_Assign_Character_Card is called")
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
local _gallery = ScriptLib.GetHideAndSeekPlayGalleryId(context, _index)
ScriptLib.SetGroupTempValue(context, "gallery_id", _gallery, {})
ScriptLib.SetGroupTempValue(context, "is_in_play", 1, {})
-- local uid_list = ScriptLib.GetSceneUidList(context)
-- 三期新增新接口取prey和服务器保持一致
local prey_list = ScriptLib.GetHideAndSeekPreyUidList(context, _index)
local hunter = ScriptLib.GetHideAndSeekHunter(context, _index)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : hunter_uid = "..hunter)
-- 所有参加活动的玩家的uid list
local all_player_list = {}
for i = 1, #prey_list do
table.insert(all_player_list, prey_list[i])
end
table.insert(all_player_list, hunter)
-- 开启视野优化
for i = 1, #all_player_list do
ScriptLib.ForbidPlayerRegionVision(context, all_player_list[i])
end
ScriptLib.SetPlayerGroupVisionType(context, all_player_list, {0})
--分配局内身份信息
ScriptLib.SetGroupTempValue(context, "hunter", hunter, {})
local cnt = 1
for i,v in ipairs(prey_list) do
if v ~= hunter then-- 其实不用判先留着了
ScriptLib.SetGroupTempValue(context, "prey_"..cnt, v, {})
ScriptLib.SetGroupTempValue(context, "const_prey_"..cnt, v, {})
cnt = cnt + 1
end
end
--追加一次游侠数量统计防止在这个阶段取不到值考虑到不是很靠谱四阶段重新计算一次
ScriptLib.SetGroupTempValue(context, "prey_sum", #prey_list, {})
--关闭牢笼
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.gadget_prison, 0)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : player_sum = "..#all_player_list)
--按选择初始化技能列表
for i,v in ipairs(all_player_list) do
LF_Init_Player_Skill(context, v, i)
LF_Init_Player_State(context, v)
if v == hunter then
ScriptLib.AssignPlayerUidOpNotify(context, {param_index = 16,param_list={},param_uid_list={},duration=5,target_uid_list={v}})
else
ScriptLib.AssignPlayerUidOpNotify(context, {param_index = 17,param_list={},param_uid_list={},duration=5,target_uid_list={v}})
-- 三期新增翻牌初始化隐身状态的temp value要在逃跑阶段一开始就初始化
ScriptLib.SetGroupTempValue(context, "Visible_Mark"..v, 0, {})
end
end
end
function LF_Init_Player_Skill(context, uid, u_ptr)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : LF_Init_Player_Skill : "..uid)
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
local _gallery = ScriptLib.GetHideAndSeekPlayGalleryId(context, _index)
local skill_list = ScriptLib.GetHideAndSeekPlayerSkillList(context, _index, uid)
for p,q in ipairs(skill_list) do
ScriptLib.AttachGalleryAbilityGroup(context, {uid}, _gallery, q)
end
end
function LF_Start_Comp_Challenge(context)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : LF_Start_Comp_Challenge")
ScriptLib.CreateFatherChallenge(context, 9011, 9011, defs.duration, {success=10,fail=10})
-- local uid_list = ScriptLib.GetSceneUidList(context)
-- 三期新增新接口取prey和服务器保持一致
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
local prey_list = ScriptLib.GetHideAndSeekPreyUidList(context, _index)
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
LF_Set_Player_State_Value(context, hunter, HS_State.Play.name, 0)
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.gadget_prison, hunter)
local challenge_start_time = ScriptLib.GetServerTime(context)
--prey_sum这里统计就太晚了需要三阶段开始先统计一次
local prey_sum = 0
for i,v in ipairs(prey_list) do
-- if v == hunter then
-- LF_Set_Player_State_Value(context, v, HS_State.Play.name, 0)
-- else
local idx = 0
for j = 1,3 do
if v == ScriptLib.GetGroupTempValue(context, "prey_"..j, {}) then
idx = j
break
end
end
--只有非死亡状态的游侠才继续游戏
if ScriptLib.GetGroupTempValue(context, HS_State.Play.name.."_"..v, {}) == 3 then
LF_Set_Player_State_Value(context, v, HS_State.Play.name, 1)
ScriptLib.AttachChildChallenge(context, 9011, idx*math.pow(10,5)+9013,9013,{base_info.group_id,10},{v},{success=1,fail=1})
prey_sum = prey_sum + 1
end
-- 三期新增开始隐身的时间先设成挑战开始时间
ScriptLib.SetGroupTempValue(context, "VisibleStart"..v, challenge_start_time, {})
-- end
end
if prey_sum == 0 then
LF_Stop_Hide_And_Seek(context, 1)
-- 就不需要开挑战了
return 0
end
--获取到正确的游侠数量
ScriptLib.AttachChildChallenge(context, 9011, 9012, 9012, {0,3,9012,prey_sum}, {hunter},{success=10,fail=10})
--启动组合挑战
ScriptLib.StartFatherChallenge(context, 9011)
ScriptLib.InitTimeAxis(context, "rampage", {defs.duration - defs.rampage_time}, false)
--处理两个抓捕结算的初始化
ScriptLib.InitTimeAxis(context, "hunter_win_in_time", {hunter_win_in_time}, false)
ScriptLib.SetGroupTempValue(context, "hunter_win_in_time", 1, {})
--新增翻牌用计时器 抓捕阶段第180秒后为决胜时间猎手在该时间内抓两人记录翻牌
ScriptLib.InitTimeAxis(context, "final_time", {final_time}, false)
--处理能量球计时
LF_Set_Energy(context)
--解除hunter限制
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.gadget_prison, 201)
end
function LF_Set_Energy(context)
--出能量球的时间有略微偏移
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : LF_Set_Energy")
math.randomseed(ScriptLib.GetServerTime(context))
local energy_list = {}
for i,v in ipairs(energy_info) do
table.insert(energy_list, v.time + math.random(energy_info[i].step[1],energy_info[i].step[2]))
end
ScriptLib.InitTimeAxis(context, "energy", energy_list, false)
end
function LF_Bake_Random_Scene(context)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : LF_Bake_Random_Scene")
--根据ld需求进行调整
--开启天气
for i = 1 , #weather_id_list do
ScriptLib.SetWeatherAreaState(context, weather_id_list[i], 1)
end
--suite 2按权重随机创建
if suites[2] ~= nil then
math.randomseed(ScriptLib.GetServerTime(context))
for i,v in ipairs(suites[2].gadgets) do
if math.random(100) > 50 then
ScriptLib.CreateGadget(context, {config_id = v})
end
end
end
--suite 3创建基本空气墙
if suites[3] ~= nil then
ScriptLib.AddExtraGroupSuite(context, 0, 3)
end
end
function LF_Clear_Random_Scene(context)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : LF_Clear_Random_Scene")
--根据需求清理数据
ScriptLib.EndTimeAxis(context, "hunter_win_by_EX")
ScriptLib.EndTimeAxis(context, "hunter_win_in_time")
ScriptLib.EndTimeAxis(context, "hunter_catch_by_guide")
ScriptLib.RemoveExtraGroupSuite(context, 0, 3)
ScriptLib.RemoveExtraGroupSuite(context, 0, 4)
--清理诱饵防止local的残留
ScriptLib.KillEntityByConfigId(context, {config_id = gadget_energy, entity_type = EntityType.GADGET})
for i,v in ipairs(bait_list) do
for m,n in ipairs(v) do
ScriptLib.KillEntityByConfigId(context, {config_id = n, entity_type = EntityType.GADGET})
end
end
ScriptLib.KillEntityByConfigId(context, {config_id = defs.gadget_prison, entity_type = EntityType.GADGET})
--关闭天气
for i = 1 , #weather_id_list do
ScriptLib.SetWeatherAreaState(context, weather_id_list[i], 0)
end
end
function LF_Init_Player_State(context, uid)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG Init_Player_State : "..uid)
for m,n in pairs(HS_State) do
if n.name == "SGV_HideAndSeek_PlayerState_Play" then
-- 三期新增唯独只有这个值初始的时候要额外区分猎人4和游侠3
if uid == ScriptLib.GetGroupTempValue(context, "hunter", {}) then
LF_Set_Player_State_Value(context, uid, n.name, 4)
else
LF_Set_Player_State_Value(context, uid, n.name, n.value)
end
else
LF_Set_Player_State_Value(context, uid, n.name, n.value)
end
end
end
--用于集中处理hunter失败的结算
function LF_Handle_Exhibition_Prey_Win(context)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : LF_Handle_Exhibition_Prey_Win")
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
local prey_sum = ScriptLib.GetGroupTempValue(context, "prey_sum", {})
local catch_sum = ScriptLib.GetGroupVariableValue(context, "catch_sum")
--剩余人数结算
local prey_alive = prey_sum - catch_sum
if prey_alive == 1 then
--统计猎手的惜败
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_miss_one", 1)
for i=1,3 do
local _prey = ScriptLib.GetGroupTempValue(context, "prey_"..i, {})
if _prey ~= 0 then
--统计最后的火种
ScriptLib.AddExhibitionReplaceableData(context, _prey, "prey_alive_only", 1)
break
end
end
elseif prey_alive == 2 then
--统计猎手的失误
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_miss_two", 1)
end
if catch_sum == 0 then
--统计无从复命
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_miss_all", 1)
end
for i=1,3 do
local _prey = ScriptLib.GetGroupTempValue(context, "prey_"..i, {})
local _const = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
if _const ~= 0 then
--存活的prey
if _prey ~= 0 then
--统计抗争到底
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_alive_win", 1)
--统计全身而退
local guide_time = ScriptLib.GetGroupTempValue(context, "prey_win_by_guide", {})
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_win_by_guide", guide_time)
--统计灯下取巧
local detect_time = ScriptLib.GetGroupTempValue(context, "prey_win_by_detect_".._prey, {})
ScriptLib.AddExhibitionReplaceableData(context, _prey, "prey_win_by_detect", detect_time)
--统计无技能胜利,要反转统计一次
if 0 == ScriptLib.GetGroupTempValue(context, "prey_win_without_skill_".._const, {}) then
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_win_without_skill", 1)
end
elseif _prey == 0 then
--统计默契之力
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_dead_win", 1)
end
end
end
end
-- 三期新增隐身诱饵相关
function LF_NotifyInvisibleBaits(context)
ScriptLib.PrintContextLog(context, "## HideAndSeek_V3_LOG : LF_NotifyInvisibleBaits")
for i = 1, #invisible_bait_list do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, invisible_bait_list[i], "SGV_InvisibleBait_Display", 1)
end
end
---------------------------------------
Initialize_Base()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,779 @@
--[[======================================
|| filename: MistTrialV3
|| owner: shuyi.chang
|| description: 迷城战线三期
|| LogName: TD_MistTrialV3
|| Protection: [Protection]
=======================================]]
--[[
3.3迷城战线复刻
每个小房间内容是单独的挑战
此group负责管理负责记着3个特殊挑战的进度负责持续显示父挑战标题挑战阶段挂个大region用于触发断线重连后挑战接续
和关卡约定的challenge Index
父挑战 999
点亮三颗符文 901
启动遗迹控制台 902
最终挑战 903
--]]
--[[
local defs = {
--galleryID
gallery_id = ,
--galley限时秒数
--迷城战线v2的限时用Gallery控制excel表此处用于保证FatherChallenge的时长不要小于Gallery
time_limit = 300,
--父挑战ChallengeId
challenge_id = 228,
--父挑战大RegionID,这个region用于地城中断线重连接续挑战
region_id = ,
--激活古代符文ChallengeId
key_challenge = 229,
--启动遗迹控制台ChallengeId
worktop_challenge = 230,
--最终挑战ChallengeId
final_challenge = 231,
--激活古代符文目标数量
key_target = 3,
--三期新增暂时没用电梯所在房间的两个region idclose是更大的用于保底玩家离开之后又飞速冲回来
elevatorRegion = 99,
elevatorCloseRegion = 100,
--三期新增各种门的对应关系center指和电梯房间对应的门一定要注意左右的顺序
keyDoor =
{
[1] = { center = config_id_01, left = config_id_02, right = config_id_03, }
[2] = { center = config_id_04, left = config_id_05, right = config_id_06, }
[3] = { center = config_id_07, left = config_id_08, right = config_id_09, }
}
--三期新增暂时没用电梯所在房间的三个门123需要跟上面keyDoor的[1][2][3]对应起来
elevatorDoor = {config_id_01, config_id_02, config_id_03}
}
--]]
--Mist_trial的Buff_obtain日志
local buff_gadgetId = {
"Buff_Attack",
"Buff_Heal"
}
local extraTriggers = {
--这个Trigger用于在地城内断线重连时接续父挑战
{ config_id = 8000001, name = "Enter_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_Enter_FatherRegion", action = "action_Enter_FatherRegion", 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 = 8000004, name = "Key_Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "901", condition = "", action = "action_Key_Challenge_Success", trigger_count = 0},
{ config_id = 8000005, name = "Worktop_Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "902", condition = "", action = "action_Worktop_Challenge_Success", trigger_count = 0},
{ config_id = 8000006, name = "Final_Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "903", condition = "", action = "action_Final_Challenge_Success", trigger_count = 0},
--用于玩家开启迷城战线时初始化标志位
{ config_id = 8000007, name = "Gallery_Start", event = EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_Gallery_Start", trigger_count = 0 },
--子挑战成功时向其所在Group发消息
{ config_id = 8000008, name = "Sub_Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_Sub_Challenge_Success", trigger_count = 0},
--外部挂载子挑战用trigger---
{ config_id = 8000009, name = "Variable_Change_MistTail", event = EventType.EVENT_VARIABLE_CHANGE, source = "catchKey", condition = "", action = "",trigger_count = 0 , tag = "666" },
--三期電梯房保底
-- { config_id = 8000010, name = "Player_Enter_Room", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Player_Enter_Room",trigger_count = 0 },
-- { config_id = 8000011, name = "Player_Leave_Room", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_Player_Leave_Room",trigger_count = 0 },
-- 三期新增保底把所有门初始都打开
{ config_id = 8000012, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_Group_Load",trigger_count = 0},
-- 测试用
-- { config_id = 8000013, name = "CHALLENGE_SUCCESS", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_EVENT_CHALLENGE_SUCCESS", trigger_count = 0, },
-- { config_id = 8000014, name = "CHALLENGE_FAIL", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_EVENT_CHALLENGE_FAIL", trigger_count = 0, },
}
local extraVariables = {
--Gallery是否在进行 0-未开始 1-进行中 2-已成功不再触发
{ config_id = 50000001, name = "gallery_state", value = 0, no_refresh = true},
--父挑战状态 0-初始 1-进了地城但未开始 2-进行中正在激活古代符文 3-进行中启动遗迹控制台4-进行中最终挑战 5-全部完成
{ config_id = 50000002, name = "father_state", value = 0, no_refresh = true},
--钥匙房 激活古代符文进度
{ config_id = 50000003, name = "key_progress", value = 0, no_refresh = true},
--子挑战用的触发器
{ config_id = 50000004, name = "catchKey", value = 0, no_refresh = false},
--地脉异常等级
{ config_id = 50000005, name = "floor_level", value = 1, no_refresh = true},
-- 三期新增目前都用不到
-- 玩家是否已經離開電梯房
{ config_id = 50000006, name = "door_open", value = 0, no_refresh = true},
-- 最后一次开启的room index挑战已开启就改
{ config_id = 50000007, name = "last_room_start", value = 0, no_refresh = true},
-- 最后一次完成的room index挑战成功才改
{ config_id = 50000008, name = "last_room_finished", value = 0, no_refresh = true},
}
--和关卡约定的challenge Index
local cfg = {
["father_index"] = 999,
["key_challenge_index"] = 901,
["worktop_challenge_index"] = 902,
["final_challenge_index"] = 903
}
local doorState =
{
open = 201,
close = 0,
}
local abilitygroup = "ActivityAbility_MistTrial_AbilityGroup"
function LF_Initialize_Group(triggers, suites, variables)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[1].triggers,extraTriggers[i].name)
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
regions[defs.region_id].team_ability_group_list = {abilitygroup}
return 0
end
--================================================================
-- 以下由关卡调用
--================================================================
--小房间的操作台选项开启挑战调这个方法-----
--由于参数个数限制需要先调用SetKillMonsterTarget
--参数为 {子挑战child_index, 子挑战challengeID}
--使用前请保证父挑战已经启动
function StartSubChallengeKillMonster(context, prev_context, child_index, challenge_id)
local father_state = ScriptLib.GetGroupVariableValue(context, "father_state")
if father_state ~= 0 and father_state ~= 1 then
--添加子挑战
--挑战类型为击杀指定数量怪物 参数1 指定groupid 参数2指定group内怪物死亡的数量
local target_count = ScriptLib.GetGroupTempValue(context, "target_count",{})
--ScriptLib.SetGroupVariableValue(context, "catchKey", 0)
ScriptLib.AttachChildChallenge(context, cfg.father_index, child_index, challenge_id, {3, 666, target_count, 1}, {},{success=1, fail=1})
else
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 #WRONG# Trying to start a subchallenge while father is not actived!! ")
end
-- 三期新增控制各种门的开启关闭子挑战开启的时候来一次结束的时候也来一次
LF_DoorController_Simple(context, true, child_index)
-- 三期新增回血的sgv在这个时候归零
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_MistTrial_Revive", 0)
return 0
end
--参数为 {怪物所在group_id, 目标个数target_count}
function SetKillMonsterTarget(context, prev_context, group_id, target_count)
ScriptLib.SetGroupTempValue(context, "target_group", group_id, {})
ScriptLib.SetGroupTempValue(context, "target_count", target_count, {})
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Set Kill Monster Target. Group@" .. group_id.." Count@".. target_count)
return 0
end
-- 为StartSubChallengeCustom所创建的自定义类型子挑战加分
-- 钥匙房不要用这个 AddMistTrialKeyProgress
function AddMistTrialChildChallengeScore(context, prev_context, score)
--由于单子b1295835,一旦没结束尝试重置catchKey时会触发上一个意外没关掉的挑战的VariableChange
--迷城并不关心杀怪的数量所以在接到调用时只需要让catchKey浮动变化就可以了也就不需要重置其实不浮动变化也可因为只要Set就会触发VariableChange这个Trigger但还是变吧万一以后Trigger改了
if ScriptLib.GetGroupVariableValue(context, "catchKey") > 0 then
ScriptLib.SetGroupVariableValue(context, "catchKey", 0)
else
ScriptLib.SetGroupVariableValue(context, "catchKey", 1)
end
local catchKey = ScriptLib.GetGroupVariableValue(context, "catchKey")
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 SAddMistTrialChildChallengeScore is called, catchKey = "..catchKey)
return 0
end
--终止特定子挑战
function StopMistTrialChildChallenge(context, prev_context, childIndex, isWin)
-- isWin = 0 (失败) 1(完成)
ScriptLib.StopChallenge(context, childIndex, isWin)
return 0
end
--当钥匙房被完成时调这个方法-----
--三期新增param通常应该为1challengeId为成功的挑战id
function AddMistTrialKeyProgress(context, prev_context, param, child_index)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Get Key Progress. add@"..param)
local father_state = ScriptLib.GetGroupVariableValue(context, "father_state")
--if father_state == 2 then
ScriptLib.ChangeGroupVariableValue(context, "key_progress", param)
local key_progress = ScriptLib.GetGroupVariableValue(context, "key_progress")
Reminder_Key_Progress(context, key_progress)
--else
--ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 #WRONG# Trying to finish a key room while father challenge is @"..father_state.." (need 2)")
--end
-- 三期新增控制各种门的开启关闭子挑战结束的时候来一次开启的时候也来一次
LF_DoorController_Simple(context, false, child_index)
return 0
end
-- 三期应该没人在用这个了由于复活的实现原因不能反复Attach如果一个地城有多个复活房每次交互复活房操作台的时候先调用这个来移除
function RemoveReviveAbility(context, prev_context)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Remove MistTrial Revive Ability.")
ScriptLib.DelGalleryAbilityGroup(context, {}, defs.gallery_id, 0)
return 0
end
--LD通知Ability变动 参数 0-地脉异常升级 1-全队复活
function ModifyMistTrialAbility(context, prev_context, param)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Modify MistTrial Ability. Param@"..param)
if param == 0 then
--设置地脉异常等级初始1级 升档最多3次 一共4个档
ScriptLib.ChangeGroupTempValue(context, "Buff_Attack", 1, {})
ScriptLib.ChangeGroupVariableValue(context, "floor_level", 1)
local floor_level = ScriptLib.GetGroupVariableValue(context, "floor_level")
if floor_level > 4 or floor_level < 1 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 #WRONG# Unexpected floor_level: Got@"..floor_level.." (floor_level is 1 ~ 4 in MistTrialV2)")
return 0
else
ScriptLib.SetMistTrialServerGlobalValue(context, floor_level)
end
return 0
elseif param == 1 then
--复活三期改动复活ability一直挂在角色身上监听sgv上复活modifier
ScriptLib.ChangeGroupTempValue(context, "Buff_Heal", 1, {})
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_MistTrial_Revive", 1)
return 0
else
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 #WRONG# Unexpected ModifyMistTrialAbility param: Got@"..param.." (param is 0 or 1 in MistTrialV2)")
end
return 0
end
--================================================================
-- triggers
--================================================================
--用于获知挑战进行到哪个阶段了.三符文完成
function action_Key_Challenge_Success(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Get Challenge Success. @"..evt.param1)
ScriptLib.SetGroupVariableValue(context, "father_state", 3)
return 0
end
--用于获知挑战进行到哪个阶段了.激活操作台完成
function action_Worktop_Challenge_Success(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Get Challenge Success. @"..evt.param1)
ScriptLib.SetGroupVariableValue(context, "father_state", 4)
return 0
end
--用于获知挑战进行到哪个阶段了.最终挑战完成
function action_Final_Challenge_Success(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Get Challenge Success. @"..evt.param1)
ScriptLib.SetGroupVariableValue(context, "father_state", 5)
return 0
end
--初始化标志位
function action_Gallery_Start(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Gallery Start Detected!! GalleryId@"..evt.param1)
ScriptLib.SetGroupVariableValue(context, "gallery_state", 1)
ScriptLib.SetGroupVariableValue(context, "father_state", 2)
ResetGroupTempVar(context)
return 0
end
--当一个小房间的杀怪挑战完成时向那个group发一个success
function action_Sub_Challenge_Success(context, evt)
if CheckIsInTable(context, tonumber(evt.source_name)) == 1 then
--特殊三挑战不发发了也没用
return 0
else
local fromGroup = ScriptLib.GetGroupTempValue(context, "target_group", {})
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 A Sub Challenge Finished. ChallengeID@"..evt.param1.." ChallengeIndex@"..evt.source_name..". Send GroupVar(succcess = 1) to Group@"..fromGroup)
ScriptLib.SetGroupVariableValueByGroup(context, "success", 1, fromGroup)
end
return 0
end
function condition_Enter_FatherRegion(context, evt)
if evt.param1 ~= defs.region_id then
return false
end
return true
end
--由大Region触发用且仅用于接续父挑战
function action_Enter_FatherRegion(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Enter father region triggered...")
if ScriptLib.GetGroupVariableValue(context, "father_state") == 0 then
ScriptLib.SetGroupVariableValue(context, "father_state", 1)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 First Time Enter region. Set mark.")
return 0
end
local gallery_state = ScriptLib.GetGroupVariableValue(context, "gallery_state")
if gallery_state == 2 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 ...gallery is finished, will do nothing.")
return 0
elseif gallery_state == 1 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Gallery_state = 1 & father_state is not 0, Trying to get Challenge Progress. ")
if ResumeMistTrial(context) == -1 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 #WRONG# Unexpected Challenge Progress!!")
end
return 0
elseif gallery_state == 0 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 ...gallery is not started, will do nothing.")
return 0
else
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 #WRONG# Unexpected Gallery state! gallery_state@".. gallery_state)
return 0
end
return 0
end
function action_Gallery_Stop(context, evt)
if evt.param1 ~= defs.gallery_id then
return -1
end
UpLoadActionLog(context)
--evt.param3
--1时间到 2客户端中断 3LUA中断
if evt.param3 == 1 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Gallery Stop Triggered. reason@ Time Up.")
ScriptLib.SetGroupVariableValue(context, "gallery_state", 2)
ScriptLib.FailMistTrialDungeonChallenge(context, cfg.father_index)
ScriptLib.SetGroupVariableValue(context, "father_state", 5)
elseif evt.param3 == 2 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Gallery Stop Triggered. reason@ Client.")
ScriptLib.SetGroupVariableValue(context, "gallery_state", 2)
ScriptLib.FailMistTrialDungeonChallenge(context, cfg.father_index)
ScriptLib.SetGroupVariableValue(context, "father_state", 5)
elseif evt.param3 == 3 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Gallery Stop Triggered. reason@ Lua.")
ScriptLib.SetGroupVariableValue(context, "gallery_state", 2)
ScriptLib.SetGroupVariableValue(context, "father_state", 5)
end
return 0
end
function action_Group_Load(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 group is loaded")
LF_DoorController_Simple(context, false, 0)
return 0
end
-- function action_Player_Leave_Room(context, evt)
-- ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 leave region " .. evt.param1)
-- if evt.param1 == defs.elevatorCloseRegion then
-- -- 在没有完成三个钥匙房之前离开电梯房需要关门
-- if ScriptLib.GetGroupVariableValue(context, "father_state") < 3 then
-- -- 最后的param一定要填-1中间的填啥都行反正用不上
-- LF_DoorController(context, true, -1)
-- end
-- end
-- return 0
-- end
-- function action_Player_Enter_Room(context, evt)
-- ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 enter region " .. evt.param1)
-- if evt.param1 == defs.elevatorRegion then
-- -- 如果玩家不知为何离开之后又冲进来了而且还没完成三个钥匙房得把所有门打开
-- if ScriptLib.GetGroupVariableValue(context, "father_state") < 3 then
-- for i = 1, #defs.elevatorDoor do
-- ScriptLib.SetGadgetStateByConfigId(context, defs.elevatorDoor[i], doorState.open)
-- end
-- LF_CloseAllKeyDoors(context, false)
-- end
-- end
-- return 0
-- end
-- function action_EVENT_CHALLENGE_SUCCESS(context, evt)
-- ScriptLib.PrintContextLog(context, "## TD_CoinCollect: challenge index = "..evt.param1.." succeeds")
-- return 0
-- end
-- function action_EVENT_CHALLENGE_FAIL(context, evt)
-- ScriptLib.PrintContextLog(context, "## TD_CoinCollect: challenge index = "..evt.param1.." fails")
-- return 0
-- end
--================================================================
-- local functions
--================================================================
function LF_DoorController_Simple(context, start, childIdx)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_DoorController_Simple is called, start = "..tostring(start)..", childIdx = "..childIdx)
local destState
if start == true then destState = doorState.close
elseif start == false then destState = doorState.open
end
-- 校验一下childIdx必须是0-3
if childIdx > 3 or childIdx < 0 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_DoorController_Simple: child index = "..childIdx.." is illegal, return immediately")
return 0
end
if childIdx == 0 then
-- 电梯房间的门全打开
for i = 1, #defs.elevatorDoor do
ScriptLib.SetGadgetStateByConfigId(context, defs.elevatorDoor[i], destState)
end
-- 其他所有的门也全打开
LF_OpenAllKeyDoors(context, true)
return
end
-- 钥匙房间的门
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[childIdx].center, destState)
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[childIdx].left, destState)
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[childIdx].right, destState)
end
-- 三期新增暂时用不上控制场景中各种门的开启和关闭(都没设保底)childIdx应该为1/2/3离开电梯的特殊情况传-1
function LF_DoorController(context, start, childIdx)
-- 根据挑战id找房间在defs表里的id
local progress = ScriptLib.GetGroupVariableValue(context, "key_progress")
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_DoorController is called, start = "..tostring(start)..", childIdx = "..childIdx)
if childIdx == -1 then
-- 玩家离开电梯房间所有电梯门都关上其他门都打开(不存档所以先不写这个保底初始门应该都配成0即本来就是开着的)
for i = 1, #defs.elevatorDoor do
ScriptLib.SetGadgetStateByConfigId(context, defs.elevatorDoor[i], doorState.close)
end
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_DoorController: all doors in elevator room is closed")
return 0
end
if childIdx > 3 or childIdx < 1 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_DoorController: child index is illegal, return immediately")
return 0
end
if start == true then
-- 玩家开启任何一个钥匙挑战钥匙房的所有门都关上
LF_OpenAllKeyDoors(context, false)
-- 门的状态设置完了再改相关挑战结束room group var
ScriptLib.SetGroupVariableValue(context, "last_room_start", childIdx)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_DoorController: all doors in room "..childIdx.." is closed")
elseif start == false then
if progress == 1 then
-- 其他房间和这个房间相连的门打开(两对四个门)
for i = 1, #defs.keyDoor do
if i ~= childIdx then
LF_OpenDoorPairs(context, i, childIdx)
end
end
elseif progress == 2 then
-- 玩家完成第二个钥匙挑战这个房间左右两个门里不和上一个房间相连的门打开一对两个门
-- 找完上一个完成房间的idx再设置成新的
local finalRoomIdx
local lastRoomIdx = ScriptLib.GetGroupVariableValue(context, "last_room_finished")
for i = 1, #defs.keyDoor do
if i ~= childIdx and i ~= lastRoomIdx then
-- 找还没去过的那个房间
finalRoomIdx = i
end
end
LF_OpenDoorPairs(context, finalRoomIdx, childIdx)
elseif progress == 3 then
-- 玩家完成第三个钥匙挑战这个房间和电梯对应的门开启电梯和它对应的门也开启
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[childIdx].center, doorState.open)
ScriptLib.SetGadgetStateByConfigId(context, defs.elevatorDoor[childIdx], doorState.open)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_DoorController: door = "..defs.keyDoor[childIdx].center..", "..defs.elevatorDoor[childIdx].." is open")
end
-- 门的状态设置完了再改相关挑战结束room group var
ScriptLib.SetGroupVariableValue(context, "last_room_finished", childIdx)
end
end
-- 暂时用不上
function LF_OpenDoorPairs(context, roomIdx_01, roomIdx_02)
-- todo:判断下两个room idx[1, 3]且不能重复
-- 找这两个room idx之间的两个门的config id
-- 参数顺序无所谓这里重新设一下
local room01 = math.min(roomIdx_01, roomIdx_02)
local room02 = math.max(roomIdx_01, roomIdx_02)
if room01 == 1 and room02 == 3 then
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[room01].left, doorState.open)
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[room02].right, doorState.open)
else
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[room01].right, doorState.open)
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[room02].left, doorState.open)
end
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_GetNextDoor is called, room01 = "..room01..", room02 = "..room02..", door = "..defs.keyDoor[room01].right..
", "..defs.keyDoor[room02].left)
return 0
end
function LF_OpenAllKeyDoors(context, open)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_OpenAllKeyDoors is called, open = "..tostring(open))
local destState
if open == true then destState = doorState.open
elseif open == false then destState = doorState.close
end
for i = 1, #defs.keyDoor do
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[i].center, destState)
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[i].left, destState)
ScriptLib.SetGadgetStateByConfigId(context, defs.keyDoor[i].right, destState)
end
end
--钥匙房进度
function Reminder_Key_Progress(context, progress)
if progress == 1 then
ScriptLib.ShowReminder(context, 43001002)
return 0
elseif progress == 2 then
ScriptLib.ShowReminder(context, 43001003)
return 0
elseif progress == 3 then
ScriptLib.ShowReminder(context, 43001004)
return 0
else
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 #WRONG# Unexpected Key Progress Change! value@"..progress)
end
return 0
end
--当需要接续挑战时根据挑战阶段挂载对应的子挑战如果是一阶段还需要续上挑战进度
function ResumeMistTrial(context, evt)
--父挑战状态 0-初始 1-进了地城但未开始 2-进行中正在激活古代符文 3-进行中启动遗迹控制台4-进行中最终挑战 5-全部完成
local father_state = ScriptLib.GetGroupVariableValue(context, "father_state")
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 ResumeMistTrial Called. father_state@".. father_state)
--迷城战线v2的限时用Gallery控制excel表
--此处用于保证接续挑战时CreateFatherChallenge的时长不要小于Gallery
local father_life = 1800
if father_state == 0 or father_state == 1 then
--挑战还没开始过就触发了接续挑战
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 #WRONG# Mark has set 1 but father challenge state is 0 ! ")
return 0
elseif father_state == 2 then
--接续钥匙房挑战 defs.key_challenge
local saved = ScriptLib.GetGroupVariableValue(context, "key_progress")
--创建父挑战
ScriptLib.CreateFatherChallenge(context, cfg.father_index, defs.challenge_id, father_life , {success=99999, fail=99999})
--挑战类型为触发特定Trigger 参数1 event_type所在枚举序号 参数2 trigger_tag参数3 次数参数4Bool次数达成是否计为成功参数5初始次数值
ScriptLib.AttachChildChallenge(context, cfg.father_index, cfg.key_challenge_index, defs.key_challenge, {3,cfg.key_challenge_index,defs.key_target,1,saved}, {}, {success=1, fail=1} )
local ret = LF_StartChallenge(context, cfg.father_index)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Resuming MistTrial Starting: 激活古代符文. Saved key num@"..saved..", start challenge ret = "..ret)
return 0
elseif father_state == 3 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Resuming MistTrial Starting: 启动遗迹控制台.")
--创建父挑战
ScriptLib.CreateFatherChallenge(context, cfg.father_index, defs.challenge_id, father_life , {success=99999, fail=99999})
--接续启动遗迹控制台 defs.worktop_challenge
--挑战类型为触发特定Trigger 参数1 event_type所在枚举序号 参数2 trigger_tag参数3 次数参数4Bool次数达成是否计为成功参数5初始次数值
ScriptLib.AttachChildChallenge(context, cfg.father_index, cfg.worktop_challenge_index, defs.worktop_challenge, {7,cfg.worktop_challenge_index,1,1}, {}, {success=1, fail=1} )
LF_StartChallenge(context, cfg.father_index)
return 0
elseif father_state == 4 then
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Resuming MistTrial Starting: 最终挑战.")
--创建父挑战
ScriptLib.CreateFatherChallenge(context, cfg.father_index, defs.challenge_id, father_life , {success=99999, fail=99999})
--接续 完成最终挑战
ScriptLib.AttachChildChallenge(context, cfg.father_index, cfg.final_challenge_index, defs.final_challenge, {3,cfg.final_challenge_index,1,1}, {}, {success=99999, fail=1} )
LF_StartChallenge(context, cfg.father_index)
return 0
elseif father_state == 5 then
--挑战还没开始过就触发了接续挑战
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Trying to resume challenge but it is all clear. Do nothing.")
return 0
end
return -1
end
function ResetGroupTempVar(context)
for k,v in pairs(buff_gadgetId) do
ScriptLib.SetGroupTempValue(context, v,0,{})
end
return 0
end
--上报运营日志数据埋点
function UpLoadActionLog(context)
local log = {
["Buff_Attack"] = 0,
["Buff_Heal"] = 0
}
for k, v in pairs(log) do
log[k] = ScriptLib.GetGroupTempValue(context, k ,{})
end
ScriptLib.MarkGroupLuaAction(context, "Mist_trial", "", log)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 UpLoadActionLog: "..log["Buff_Attack"].." |"..log["Buff_Heal"])
return 0
end
--用于检查value是否在目标table中
function CheckIsInTable(context,check_value)
--和关卡约定的challenge Index
for k,v in pairs(cfg) do
if v == check_value then
--ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 Check Is SpecialChallenge. return 1")
return 1
end
end
return 0
end
function LF_StartChallenge(context, challenge_index)
-- 起challenge之前先检查一下是不是已经开了开了就不能再起了不然显示会被挤掉
local success = -1
local ret = -1
if ScriptLib.IsChallengeStartedByChallengeIndex(context, base_info.group_id, challenge_index) == false then
ret = ScriptLib.StartFatherChallenge(context, challenge_index)
success = 0
end
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 LF_StartChallenge is called, challenge index = "..challenge_index..", succees = "..success..", challenge ret = "..ret)
return success
end
--================================================================
-- ServerLuaCall
--================================================================
function SLC_MistTrial_TryStartChallenge(context)
-- 在这里第一次起挑战和gallery
ScriptLib.CreateFatherChallenge(context, cfg.father_index, 228, 1800, {success = 99999, fail = 99999, fail_on_wipe=true})
ScriptLib.AttachChildChallenge(context, cfg.father_index, cfg.key_challenge_index, 229, {3,cfg.key_challenge_index,3,1},{},{success=0,fail=0})
local ret1 = LF_StartChallenge(context, cfg.father_index)
local ret2 = ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.PrintContextLog(context, "## TD_MistTrialV3 SLC_MistTrial_TryStartChallenge is called, challenge ret = "..ret1..", gallery ret = "..ret2)
return 0
end
--================================================================
-- Initialization
--================================================================
LF_Initialize_Group(triggers, suites, variables)

View File

@@ -0,0 +1,192 @@
--[[======================================
|| filename: SandwormChallenge_DodgeChallenge
|| owner: luyao.huang
|| description:
|| LogName: SandwormChallenge_DodgeChallenge
|| Protection:
=======================================]]--
local local_defs =
{
challenge_index = 666,
challenge_id = 2012004,
live_challenge_index = 667,
live_challenge_id = 2012003,
dodge_challenge_index = 668,
dodge_challenge_id = 2012002,
challenge_option = 177,
}
local challenge_Tri = {
[1] = { name = "select_option_dodge_challenge", config_id = 200010001, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option_dodge_challenge", trigger_count = 0},
[2] = { name = "group_load_dodge_challenge", config_id = 200010002, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load_dodge_challenge", trigger_count = 0},
[3] = { name = "challenge_fail_dodge_challenge", config_id = 200010003, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail_dodge_challenge", trigger_count = 0},
[4] = { name = "challenge_success_dodge_challenge", config_id = 200010004, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success_dodge_challenge", trigger_count = 0},
[6] = { name = "gadget_state_change_dodge_challenge", config_id = 200010006, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change_dodge_challenge", trigger_count = 0},
}
function dodge_challenge_Initialize()
for k,v in pairs(challenge_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id = 200010001, name = "is_success", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_gadget_state_change_dodge_challenge(context,evt)
if evt.param2 == defs.worktop_id then
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] gadget_state_change操作台状态变化")
if evt.param1 == 0 then
--恢复选项
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] gadget_state_change操作台到0状态恢复选项")
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.worktop_id, {local_defs.challenge_option})
end
if evt.param1 == 201 or evt.param1 == 202 then
--清选项
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] gadget_state_change操作台到非0状态清理选项")
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.worktop_id, local_defs.challenge_option)
end
end
return 0
end
function action_select_option_dodge_challenge(context,evt)
if evt.param2 == local_defs.challenge_option then
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] select_option选择选项开启挑战")
--开挑战
--ScriptLib.ActiveChallenge(context, local_defs.challenge_index, local_defs.challenge_id, defs.challenge_time, defs.max_hit_times, 0, 0)
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.CreateFatherChallenge(context, local_defs.challenge_index, local_defs.challenge_id, defs.challenge_time, {success = 10, fail = 5, fail_on_wipe = true})
ScriptLib.StartFatherChallenge(context, local_defs.challenge_index)
ScriptLib.AttachChildChallenge(context, local_defs.challenge_index, local_defs.dodge_challenge_index, local_defs.dodge_challenge_id,
{3,1,defs.max_hit_times,0,0},{},{success=10, fail=5})
ScriptLib.AttachChildChallenge(context, local_defs.challenge_index, local_defs.live_challenge_index, local_defs.live_challenge_id,
{defs.challenge_time},{},{success=10, fail=5})
--转操作台状态
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.GearStart)
--开启挑战时立刻召一次沙虫
LF_Create_Normal_Sandworm_By_Custom_Params(context, defs.ambush_times, defs.attack_times)
--开启玩法杂项
LF_Start_Play(context)
end
return 0
end
function action_challenge_success_dodge_challenge(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] challenge_success挑战成功挑战id为"..evt.param1)
if evt.param1 == local_defs.live_challenge_id then
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] challenge_success挑战成功")
ScriptLib.StopChallenge(context,local_defs.challenge_index,1)
--记一个变量方便下次恢复
ScriptLib.SetGroupVariableValue(context, "is_success", 1)
--创建宝箱
ScriptLib.CreateGadget(context, { config_id = defs.chest_id })
--转操作台状态到完成
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.GearStop)
--清理玩法杂项
LF_Clear_Play(context)
end
return 0
end
function action_challenge_fail_dodge_challenge(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] challenge_success挑战失败挑战id为"..evt.param1)
if evt.param1 == local_defs.live_challenge_id then
ScriptLib.StopChallenge(context,local_defs.challenge_index,1)
--记一个变量方便下次恢复
ScriptLib.SetGroupVariableValue(context, "is_success", 1)
--创建宝箱
ScriptLib.CreateGadget(context, { config_id = defs.chest_id })
--转操作台状态到完成
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.GearStop)
--清理玩法杂项
LF_Clear_Play(context)
end
if evt.param1 == local_defs.dodge_challenge_id then
ScriptLib.StopChallenge(context,local_defs.challenge_index,0)
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] challenge_fail挑战失败")
--转操作台状态到初始
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.Default)
--清理玩法杂项
LF_Clear_Play(context)
end
return 0
end
function action_group_load_dodge_challenge(context,evt)
local is_success = ScriptLib.GetGroupVariableValue(context,"is_success") == 1
if is_success then
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] group_loadgroup加载之前已成功")
--如果之前已成功将操作台直接转到完成状态
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.GearStop)
else
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] group_loadgroup加载之前未成功")
--如果之前未成功则正常给操作台上选项
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.Default)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.worktop_id, {local_defs.challenge_option})
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Start_Play(context)
--开空气墙
ScriptLib.CreateGadget(context, { config_id = defs.airwall_id })
--打开沙虫计数开关
ScriptLib.SetGroupVariableValue(context, "is_attack_count", 1)
end
function LF_Clear_Play(context)
--清掉空气墙
ScriptLib.KillEntityByConfigId(context, { config_id = defs.airwall_id })
--关掉计数
ScriptLib.SetGroupVariableValue(context, "is_attack_count", 0)
end
------------------------------------------------------------------
dodge_challenge_Initialize()

View File

@@ -0,0 +1,89 @@
--[[======================================
|| filename: EyePointLOD
|| owner: shuyi.chang
|| description: EyePoint固定LOD测试
|| LogName: ## [TestEyepointLOD]
|| Protection:
=======================================]]
--[[
local defs = {
target_region_config_id = 1,
related_big_region_config_id = 2,
}
--]]
local extraTriggers =
{
{ config_id = 50000001, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", trigger_count = 0 },
{ config_id = 50000002, name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", trigger_count = 0 },
}
local extraVariables =
{
-- 设置LOD层级
{ config_id = 50000101, name = "lodLevel", value = 1, no_refresh = true },
}
local pos = regions[defs.related_big_region_config_id].pos
local markGadget = { config_id = 80001, gadget_id = 70220006, pos = { x = pos.x, y = pos.y, z = pos.z }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1 }
--================================================================
-- Local Functions
--================================================================
function LF_Initialize_Group(triggers, suites, variables, gadgets, regions)
-- insert triggers
for i = 1, #extraTriggers do
table.insert(triggers, extraTriggers[i])
end
-- add triggers to suite
for i = 1, #extraTriggers do
-- 都放到初始suite 1
table.insert(suites[1].triggers,extraTriggers[i].name)
end
-- insert variables
for i = 1, #extraVariables do
table.insert(variables, extraVariables[i])
end
-- table.insert(gadgets, markGadget)
-- table.insert(suites[1].gadgets, markGadget.config_id)
end
--================================================================
-- Triggers
--================================================================
function action_EVENT_ENTER_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## [TestEyepointLOD] player enters region "..evt.param1)
if evt.param1 == defs.target_region_config_id then
local fix_lod_level = ScriptLib.GetGroupVariableValue(context, "lodLevel")
local temp = ScriptLib.SetPlayerEyePointLOD(context, defs.target_region_config_id, defs.related_big_region_config_id, fix_lod_level)
ScriptLib.PrintContextLog(context, "## [TestEyepointLOD] lod level is set to "..fix_lod_level..", succeed = "..temp)
end
return 0
end
function action_EVENT_LEAVE_REGION(context, evt)
ScriptLib.PrintContextLog(context, "## [TestEyepointLOD] player leaves region "..evt.param1)
if evt.param1 == defs.target_region_config_id then
local temp = ScriptLib.ClearPlayerEyePoint(context, defs.target_region_config_id)
ScriptLib.PrintContextLog(context, "## [TestEyepointLOD] player eye point is cleared, succeed = "..temp)
end
return 0
end
--================================================================
-- Initialization
--================================================================
LF_Initialize_Group(triggers, suites, variables, gadgets, regions)

View File

@@ -0,0 +1,460 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
--======================================================================================================================
--|| Filename || Activity_SeaLampParkour
--|| RelVersion || V3_4
--|| Owner || shuo-yu
--|| Description ||
--|| LogName || ##[Activity_SeaLampParkour]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
--[[
local defs = {
gallery_id = ,
--开启机关交互后加载哪个/些suit
load_on_start = {2},
--开启机关的configIDSelectOption为175
starter_gadget = 0,
--终点region的configID
end_regionID = 0,
--玩法RegionID进入此圈开启性能优化在suit1
parkour_regions = {},
--全程终点在哪个suit,如果这个group非终点则配0
end_suite = 0,
--挑战限时秒
challenge_time = 300,
--跑酷金币gadgetID
gadget_token_id = 70220121,
--镜头注目
look_EntityCid = 333004,
follow_EntityCid = 333004,
}
--]]
--Local Field
local RefData =
{
father_challenge_id = 2010050,
child01_challenge_id = 2010051,
child02_challenge_id = 2010052,
}
local StartTriggers =
{
--gallery停止tirgger
{ config_id = 34000010, name = "Gallery_Stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0 },
--挑战操作台创建trigger
{ config_id = 34000020, name = "Gadget_Create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
--选择操作台选项对应trigger
{ config_id = 34000030, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_select_option", action = "action_select_option", trigger_count = 0 },
--挑战失败trigger 包括超时主动关闭团灭
{ config_id = 34000040, name = "Challenge_Fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "",condition = "", action = "action_challenge_fail", trigger_count= 0 },
--coin_counter变化时更新gallery计分
{ config_id = 34000050, name = "Coin_Get", event = EventType.EVENT_VARIABLE_CHANGE, source = "coin_counter", condition = "", action = "", trigger_count = 0, tag = "888" },
--进入玩法region 打标记
{ config_id = 34000060, name = "Enter_Gameplay_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_GameplayRegion", trigger_count = 0 },
--退出玩法region 挑战开启情况下退出region直接关闭gallery
{ config_id = 34000070, name = "Leave_Gameplay_Region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "",action = "action_leave_GameplayRegion", trigger_count= 0 },
--group卸载触发
{ config_id = 34000080, name = "Group_Will_Unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0 },
--进入教程region 弹相关reminderTemplate
{ config_id = 34000090, name = "Enter_Tutorial_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_TutorialRegion", trigger_count = 0 },
}
local EndTriggers =
{
--跑酷终点trigger
{ config_id = 34000091, name = "Enter_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_enter_final", action = "", trigger_count = 0, tag = "666" },
--挑战成功trigger
{ config_id = 34000092, name = "Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count= 0 },
}
--Condition Func
--处理不能开启玩法的情况
function condition_select_option(context, evt)
--幻梦之门玩法中阻止挑战开启
if ScriptLib.IsChallengeStartedByChallengeId(context, 267) then
ScriptLib.ShowReminderByUid(context, {context.uid}, 400046)
return false
end
return true
end
--判断是不是终点圈
function condition_enter_final(context, evt)
if evt.param1 ~= defs.end_regionID then
return false
end
return true
end
--Action Func
--进教程范围 弹教程reminder
function action_enter_TutorialRegion(context, evt)
if defs.guide_regionID == nil then
return 0
elseif evt.param1 == defs.guide_regionID then
LF_TryStartTutorial(context)
end
return 0
end
--跑酷操作台创建时 加操作台选项
function action_gadget_create(context, evt)
if defs.starter_gadget ~= evt.param1 then
return -1
end
-- 设置操作台选项
if 0 ~= ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.starter_gadget, {175}) then
LF_PrintLog(context, "设置操作台选项失败")
return -1
end
return 0
end
--点下选项后 玩法开启 改标记变量 切操作台 加载初始玩法suite 开启环境优化 开启gallery 开启挑战 触发镜头注目
function action_select_option(context, evt)
--检查SelectOption
if defs.starter_gadget ~= evt.param1 or 175 ~= evt.param2 then
return -1
end
--检查是否单机
if true == ScriptLib.CheckIsInMpMode(context) then
for k,v in pairs(gadgets) do
if v.config_id == defs.starter_gadget then
center = v.pos
break
end
end
-- 400053:多人游戏状态下无法进行挑战
ScriptLib.ShowReminderRadius(context, 400053, center, 2)
return -1
end
--LD用多个Region覆盖赛道范围这个变量用于判断是否出圈
ScriptLib.SetGroupTempValue(context, "is_in_region", 0, {})
--切操作台状态
ScriptLib.SetGadgetStateByConfigId(context, defs.starter_gadget, GadgetState.GearStart)
--去掉操作台SelectOption
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.starter_gadget, 175)
--加载第一波suite
for k, v in pairs(defs.load_on_start) do
if 0 == ScriptLib.AddExtraGroupSuite(context, base_info.group_id, v) then
LF_PrintLog(context, "加载suite"..v)
end
end
LF_SetEnvOptimize(context,true)
LF_InitChallenge(context)
-- --开启Gallery
-- if 0 ~= ScriptLib.StartGallery(context, defs.gallery_id) then
-- LF_PrintLog(context, "开启Gallery失败")
-- else
-- local nums = LF_GetCoinsNum()
-- LF_PrintLog(context, "金币总数-"..nums)
-- if 0 ~= ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["total_coin_count"] = nums}) then
-- LF_PrintLog(context, "Gallery传金币数量失败")
-- end
-- end
--TODO:镜头注目
LF_CameraAction(context)
return 0
end
--挑战成功 关gallery reason lua设置成功
function action_challenge_success(context,evt)
if evt.param1 ~= RefData.father_challenge_id then
return -1
end
LF_PrintLog(context, "挑战成功处理")
LF_StopGamePlayByReason(context, 3)
return 0
end
--挑战失败 关gallery reason 超时灭队主动中断
function action_challenge_fail(context, evt)
if evt.param1 ~= RefData.father_challenge_id then
return -1
end
--param2 剩余时间
if evt.param2 <= 0 then
-- 超时
LF_StopGamePlayByReason(context, 1)
else
if ScriptLib.IsPlayerAllAvatarDie(context, context.owner_uid) then
-- 团灭
LF_PrintLog(context, "挑战失败-灭队")
LF_StopGamePlayByReason(context, 8)
else
-- 主动中断
LF_PrintLog(context, "挑战失败-客户端中断/其他")
LF_StopGamePlayByReason(context, 2)
end
end
return 0
end
--进入玩法区域 打标记
function action_enter_GameplayRegion(context, evt)
--检查Region的configId是否是优化圈
if LF_CheckIsInTable(context,evt.param1, defs.parkour_regions) then
--流程未开始时不处理
if ScriptLib.GetGroupTempValue(context, "is_in_region", {}) == -1 then
LF_PrintLog(context, "is_in_region not set, group id: "..base_info.group_id)
return 0
end
ScriptLib.ChangeGroupTempValue(context, "is_in_region", 1, {})
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
LF_PrintLog(context, "进入跑酷区域"..evt.param1)
end
end
return 0
end
--退出玩法区域 如果挑战已开 关gallery reason达到次数未成功
function action_leave_GameplayRegion(context,evt)
--检查Region的configId是否是优化圈
if LF_CheckIsInTable(context,evt.param1,defs.parkour_regions) then
--流程未开始时不处理
if ScriptLib.GetGroupTempValue(context, "is_in_region", {}) == -1 then
LF_PrintLog(context, "is_in_region not set, group id: "..base_info.group_id)
return 0
end
ScriptLib.ChangeGroupTempValue(context, "is_in_region", -1, {})
--挑战未开始时不处理
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) ~= 1 then
LF_PrintLog(context, "challenge not start, group id: "..base_info.group_id)
return 0
end
LF_PrintLog(context, "出赛道区域"..evt.param1)
--如果完全出圈了触发挑战失败
local is_in_region = ScriptLib.GetGroupTempValue(context, "is_in_region", {})
if is_in_region <= 0 then
LF_StopGamePlayByReason(context, 4)
end
end
return 0
end
--group异常卸载停止挑战
function action_group_will_unload(context,evt)
LF_PrintLog(context, "GROUP UNLOAD GroupID: "..base_info.group_id)
ScriptLib.StopChallenge(context,1,0)
return 0
end
--打印停gallery原因
function action_gallery_stop(context, evt)
LF_PrintLog(context, "GalleryID:"..evt.param1.."终止。原因:"..evt.param3)
return 0
end
--LF Func
--查看是否为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
--打印本活动相关Log
function LF_PrintLog(context, content)
local log = "## [Activity_SeaLampParkour] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
--玩法triggervar初始化
function LF_SeaLampParkour_Initialize()
LF_InsertTriggers(StartTriggers,1)
LF_InsertTriggers(EndTriggers,defs.end_suite)
-- Vars
table.insert(variables, { config_id = 50000001, name = "coin_counter", value = 0})
return 0
end
--插入trigger 并对table suites做越界保护
function LF_InsertTriggers(TempTrigger,suiteIndex)
if suiteIndex <= 0 or suiteIndex > #suites then
return -1
end
for k,v in pairs(TempTrigger) do
table.insert(triggers,v)
table.insert(suites[suiteIndex].triggers,v.name)
end
return 0
end
--获取关卡配置的金币数目
function LF_GetCoinsNum()
local count = 0
for k, v in pairs(gadgets) do
if v.gadget_id == defs.gadget_token_id then
count = count + 1
end
end
return count
end
--重置关卡 变量重置操作台重置Group回到默认状态关闭环境优化
function LF_ResetLevel(context)
--变量重置 挑战状态以及金币计数
ScriptLib.SetGroupVariableValue(context, "coin_counter", 0)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
-- 设置操作台为初始待交互状态
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.starter_gadget, {175})
ScriptLib.SetGadgetStateByConfigId(context, defs.starter_gadget, GadgetState.Default)
for i = 2, #suites do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, i)
end
LF_SetEnvOptimize(context,false)
ScriptLib.RefreshGroup(context, { group_id = base_info.group_id, suite = 1 })
end
--设置环境优化的开启/关闭
function LF_SetEnvOptimize(context, IsSet)
--IsSet == true 代表对环境进行优化设置
if IsSet == true then
--关闭环境小动物
ScriptLib.SwitchSceneEnvAnimal(context, 0)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
--此玩家只能看到0的Group
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
else
--环境小动物恢复
ScriptLib.SwitchSceneEnvAnimal(context, 2)
ScriptLib.RevertPlayerRegionVision(context, context.uid)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
end
return 0
end
--设置镜头注目
function LF_CameraAction(context)
if nil ~= gadgets[defs.look_EntityCid] and nil ~= points[defs.follow_EntityCid] then
local pos = gadgets[defs.look_EntityCid].pos
local camPos = points[defs.follow_EntityCid].pos
--触发镜头注目强制注目形式不广播其他玩家
ScriptLib.BeginCameraSceneLookWithTemplate(context, 1,
{look_configid=0, look_pos = pos,
follow_type =2, follow_pos = camPos,is_broadcast =false, delay = 0, })
else
LF_PrintLog(context, "缺少镜头参数 Group: "..base_info.group_id)
end
return 0
end
--弹玩法教程templateReminder
function LF_TryStartTutorial(context)
local ownerUid = context.owner_uid
if 0 ~= ScriptLib.AssignPlayerShowTemplateReminder(context,158,{param_uid_vec={},param_vec={},uid_vec={context.uid}}) then
LF_PrintLog(context, "弹教程失败")
else
LF_PrintLog(context, "弹教程成功")
end
return 0
end
--初始化玩法挑战
function LF_InitChallenge(context)
--挑战状态标记
ScriptLib.SetGroupTempValue(context, "challenge_state", 1, {})
-- 开父挑战再Attach保序
ScriptLib.CreateFatherChallenge(context, 1, RefData.father_challenge_id, defs.challenge_time, {success = 10, fail = 5})
if 0 == ScriptLib.StartFatherChallenge(context, 1) then
LF_PrintLog(context, "开启父挑战成功")
else
LF_PrintLog(context, "开启父挑战失败")
end
-- param tableparam1-event类型, param2-Tag, param3:次数, param4:达到次数是否success
-- 限时到达
if 0 ~= ScriptLib.AttachChildChallenge(context, 1, 101, RefData.child01_challenge_id, {4, 666, 1, 1}, {}, {success = 10, fail = 5}) then
LF_PrintLog(context, "子挑战2010051添加失败")
end
-- 收集金币
if 0 ~= ScriptLib.AttachChildChallenge(context, 1, 102, RefData.child02_challenge_id, {3, 888, LF_GetCoinsNum()}, {}, {success = 0, fail = 0}) then
LF_PrintLog(context, "子挑战2010052添加失败")
end
return 0
end
--停gallery 发送reason 并重置关卡
function LF_StopGamePlayByReason(context, reason)
-- LF_PrintLog(context, "Gallery停止 GalleryID: "..defs.gallery_id)
-- --停Gallery
-- --Reason 0-NONE 1-超时 2-客户端中断 3-lua设置成功 4-lua设置失败
-- ScriptLib.StopGalleryByReason(context, defs.gallery_id, reason)
-- LF_PrintLog(context, "Reason: "..reason)
LF_ResetLevel(context)
LF_PrintLog(context, "Level Reset")
return 0
end
--ServerLuaCall
--金币更新计数 物件复用3.0 slc名称保持与3.0一致
function SLC_Activity_Parkour_PickCoin(context)
-- 触发挑战trigger
ScriptLib.ChangeGroupVariableValue(context, "coin_counter", 1)
-- -- pick_up为拾取类型0金币
-- if 0 ~= ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["pick_up"] = 0}) then
-- LF_PrintLog(context, "Gallery通信失败")
-- end
return 0
end
--End Lua
LF_SeaLampParkour_Initialize()

View File

@@ -0,0 +1,821 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
--======================================================================================================================
--|| Filename || Activity_SeaLamp_BoatRaceV3
--|| Owner || zijun.ma
--|| Description || 收纳浪船挑战船体相关
--|| LogName || TD_BoatRaceV3
--|| Protection ||
--======================================================================================================================
--=====================================
-- 测试包
--======================================
--测试指令
--[[
group SETVAR 133212587 BoatTest 1
--]]
--=====================================
-- 常量
--======================================
local PlayCfg= {
ReviveCounter = 10,
ReviveTimeAxis = {}, -- 根据ReviveCounter自动生成
AirdropDelay = {2},
SafePos = {x = -3840.878, y = 200.000, z = -1998.566}
}
-- 空投车的行进路线
local AirdropPointList = {
[1] = {pointArray = 321200054, pointCid = 587006, list = {1,2,3,4}},
[2] = {pointArray = 321200054, pointCid = 587007, list = {1,2,3,4}},
[3] = {pointArray = 321200054, pointCid = 587008, list = {1,2,3,4}},
[4] = {pointArray = 321200054, pointCid = 587009, list = {1,2,3,4}},
}
-- 空投的清单
local AirdropItemList = {
[1] = {1,1,1,2},
[2] = {2,1,1,1},
}
local SGVProp = {
HP = "SGV_BoatV3_HP",
HPMax = "SGV_BoatV3_HPMax",
Coin = "SGV_BoatV3_Coin",
Ghost = "SGV_BoatV3_Ghost", -- 是否处于幽灵模式
Progress = "SGV_BoatV3_Progress", -- 复活进度值
SkillIdx = "SGV_BoatV3_SkillIndex", -- 对应获得技能序号0为没有技能
}
local TempProp = {
NextPoint = "NextPoint",
DropCoinIdx = "DropCoinIdx",
DropBombIdx = "DropBombIdx",
AirdropIdx = "AirdropIdx", -- 游戏中的空投船计数
AirdropPointListDec = "AirdropPointListDec", -- 记录已经使用过的行进路线
}
-- 需要同时处理多个的Index
local TempIndexProp = {
AirdropPointListIdx = "AirdropPointListIdx", -- 当前对应的行进路线(关联AirdropPointList)
AirdropItemListIdx = "AirdropItemListIdx", --当前对应的空投清单(关联AirdropItemList)
AirdropItemIdx = "AirdropItemIdx", --对应AirdropItemList获取投放硬币还是炸弹
}
local ExhibitionProp ={
CollectCoinNum = "Activity_BoatRaceV3_CollectCoinNum",
HighestCoinNum = "Activity_BoatRaceV3_HighestCoinNum",
HighestLiveTime = "Activity_BoatRaceV3_HighestLiveTime",
DeathNum = "Activity_BoatRaceV3_DeathNum",
CollectItemNum = "Activity_BoatRaceV3_CollectItemNum",
UseSkillTimes = "Activity_BoatRaceV3_UseSkillTimes",
DestroyGadgetTimes = "Activity_BoatRaceV3_DestroyGadgetTimes",
DropCoinNum = "Activity_BoatRaceV3_DropCoinNum",
SeaLampNum = "Activity_BoatRaceV3_SeaLampNum",
CorrectRiddleNum = "Activity_BoatRaceV3_CorrectRiddleNum",
BigCoinNum = "Activity_BoatRaceV3_BigCoinNum",
}
local PlayerData = {
[1] = { DeathCoin = 53040101},
[2] = { DeathCoin = 53040102},
[3] = { DeathCoin = 53040103},
[4] = { DeathCoin = 53040104},
}
local LevelDataName = {
DropCoin = "DropCoin",
DropBomb = "DropBomb",
AirDrop = "AirDrop",
}
-- 关卡临时创建CidList
local LevelData = {
[LevelDataName.DropCoin] = {gadgetid = 70290784,startCid = 53040201, num = 40, tempProp = TempProp.DropCoinIdx, cidList = {}}, -- {5304020153040202}
[LevelDataName.DropBomb] = {gadgetid = 70290785,startCid = 53040301, num = 10, tempProp = TempProp.DropBombIdx, cidList = {}},
[LevelDataName.AirDrop] = {gadgetid = 70290783,startCid = 53040401, num = 4, tempProp = TempProp.AirdropIdx, cidList = {}},
}
local Tri_BoatRaceV3 = {
{ keyWord = "BoatRevive", keyWordType = "1", event = EventType.EVENT_TIME_AXIS_PASS, source = "Revive1", trigger_count = 0},
{ keyWord = "BoatRevive", keyWordType = "2", event = EventType.EVENT_TIME_AXIS_PASS, source = "Revive2", trigger_count = 0},
{ keyWord = "BoatRevive", keyWordType = "3", event = EventType.EVENT_TIME_AXIS_PASS, source = "Revive3", trigger_count = 0},
{ keyWord = "BoatRevive", keyWordType = "4", event = EventType.EVENT_TIME_AXIS_PASS, source = "Revive4", trigger_count = 0},
{ keyWord = "BoatTest", event = EventType.EVENT_VARIABLE_CHANGE, source = "BoatTest", trigger_count = 0},
{ keyWord = "GroupLoad", event = EventType.EVENT_GROUP_LOAD, source = "", trigger_count = 0},
{ keyWord = "AirdropMove", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", trigger_count = 0},
}
function LF_Initialize_BoatRaceV3()
LF_AutoGenTri()
LF_GenTrigger(Tri_BoatRaceV3,53040001,{1})
LF_InitReviveTimeAxis()
-- LevelData中Gadget数据占坑
LF_GenGadget(LevelDataName.AirDrop)
LF_GenGadget(LevelDataName.DropCoin)
LF_GenGadget(LevelDataName.DropBomb)
local var = { config_id= 53049001, name = "BoatTest", value = 0, no_refresh = false } --Boss战的步骤计数器
variables[var.name] = var
return 0
end
function LF_GenTrigger(triTable,startCid,insertSuiteList)
local startConfigID = startCid
for _,v in pairs(triTable) do
v.config_id = startConfigID
if v.keyWordType == nil then
v.name = "tri_" .. v.keyWord
else
v.name = "tri_" .. v.keyWord .. v.keyWordType
end
v.action = "action_" .. v.keyWord
v.condition = ""
startConfigID = startConfigID + 1
table.insert(triggers, v)
end
LF_InsertTriggers(Tri_BoatRaceV3,insertSuiteList)
return 0
end
function LF_InitReviveTimeAxis()
for i =1,PlayCfg.ReviveCounter do
table.insert(PlayCfg.ReviveTimeAxis,i)
end
return 0
end
function LF_GenGadget(levelDataName)
local levelData = LevelData[levelDataName]
local startCid = levelData.startCid
for i = 1,levelData.num do
gadgets[startCid] = { config_id = startCid, gadget_id = levelData.gadgetid,
pos = PlayCfg.SafePos,rot = { x = 0.000, y = 0.000, z = 0.000 },
is_use_point_array = true, vision_level = VisionLevelType.VISION_LEVEL_SUPER,
level = 1 , area_id = 13}
table.insert(levelData.cidList,startCid)
startCid = startCid + 1
end
return 0
end
function LF_AutoGenTri()
local keyWord = 0
for i = 1,4 do
keyWord = keyWord + 1
local keyWordType = tostring(keyWord)
local sourceName = "AirdropStartMove" .. keyWordType
local trigger = {keyWord = "AirdropStartMove",keyWordType=keyWordType,event=EventType.EVENT_TIME_AXIS_PASS,source = sourceName, trigger_count = 0}
table.insert(Tri_BoatRaceV3, trigger)
end
return 0
end
--=====================================
--Action
--======================================
-- GroupLoad测试
function action_GroupLoad(context,evt)
ScriptLib.PrintContextLog(context, "## TD_BoatRaceV3 GroupLoad|加载成功校验")
ScriptLib.SetGroupTempValue(context, TempProp.DropCoinIdx, 0, {})
ScriptLib.SetGroupTempValue(context, TempProp.DropBombIdx, 0, {})
ScriptLib.SetGroupTempValue(context, TempProp.AirdropIdx, 0, {})
ScriptLib.SetGroupTempValue(context, TempProp.AirdropPointListDec, 0, {})
return 0
end
-- BoatTest测试
function action_BoatTest(context,evt)
LF_Airdrop_Appear(context)
return 0
end
-- 时间轴控制幽灵计数器
function action_BoatRevive(context,evt)
local playerIndex = LF_GetIndexByKeyName(evt.source_name)
local uid = LF_GetPlayerUidByIndex(context,playerIndex)
if 0 == uid then
return 0
end
local curProgress = ScriptLib.GetTeamServerGlobalValue(context, uid, SGVProp.Progress)
curProgress = curProgress - 1
ScriptLib.SetTeamServerGlobalValue(context, uid, SGVProp.Progress, curProgress)
if curProgress == 0 then
ScriptLib.SetTeamServerGlobalValue(context, uid, SGVProp.Ghost, 0)
end
return 0
end
-- 空投船管理
function action_AirdropMove(context,evt)
-- 是不是空投船
local moveCid = evt.param1
if gadgets[moveCid] == nil then
return 0
end
if 70290783 ~= gadgets[moveCid].gadget_id then
return 0
end
-- 空投船逻辑
local index = LF_LevelData_GetIndexByCid(LevelDataName.AirDrop,moveCid)
local pointListIndex = LF_GetTempIndexProp(context,TempIndexProp.AirdropPointListIdx,index)
local pointList = AirdropPointList[pointListIndex]
if pointList == nil then
return 0
end
local curPointList = pointList.list
if curPointList == nil then
return 0
end
-- 是否是最后一个点
if evt.param3 == curPointList[#curPointList] then
-- 处理消失
LF_Airdrop_Disappear(context,index)
else
-- 处理掉落情报
LF_Airdrop_Throw(context,index)
end
return 0
end
-- 船体开始运动
function action_AirdropStartMove(context,evt)
local index = LF_GetIndexByString(evt.source_name,"AirdropStartMove")
local cid = LF_LevelData_GetCidByIndex(LevelDataName.AirDrop,index)
local pointListIdx = LF_GetTempIndexProp(context,TempIndexProp.AirdropPointListIdx,index)
local pointList = AirdropPointList[pointListIdx]
local msg = "## TD_BoatRaceV3 action_AirdropStartMove"
msg = msg .. "|index=" .. tostring(index)
msg = msg .. "|cid=" .. tostring(cid)
msg = msg .. "|pointListIdx=" .. tostring(pointListIdx)
ScriptLib.PrintContextLog(context, msg)
if pointList == nil then
return 0
end
-- 船体开始沿固定轨迹移动
ScriptLib.SetPlatformPointArray(context, cid, pointList.pointArray, pointList.list, { route_type = 0 })
return 0
end
--=====================================
--LocalFunction
--======================================
-- 船体出现
function LF_Airdrop_Appear(context)
-- 走不重复随机
local selectAirdropPointListIndex = LF_Airdrop_SelectAirdropPointList(context)
local selectAirdropPointList = AirdropPointList[selectAirdropPointListIndex]
local msg = "## TD_BoatRaceV3 LF_Airdrop_Appear"
msg = msg .. "|selectAirdropPointListIndex=" .. tostring(selectAirdropPointListIndex)
ScriptLib.PrintContextLog(context, msg)
if selectAirdropPointList == nil then
return 0
end
local selectPointCid = selectAirdropPointList.pointCid
if selectPointCid == nil then
return 0
end
local selectPointInfo = points[selectPointCid]
if selectPointInfo == nil then
return 0
end
local selectPointPos = selectPointInfo.pos
-- 创建船体会返回一个Index)
local airdropIndex = LF_LevelData_CreateLevelDataGadget(context,LevelDataName.AirDrop,selectPointPos,{x=0,y=0,z=0})
if airdropIndex > 0 then
-- 启动空投船对应的时间轴延时开始移动)
ScriptLib.InitTimeAxis(context, "AirdropStartMove".. tostring(airdropIndex), PlayCfg.AirdropDelay, false)
-- 存储对应空投船的点阵Index
LF_SetTempIndexProp(context,TempIndexProp.AirdropPointListIdx,airdropIndex,selectAirdropPointListIndex)
-- 确认对应空投船的空投清单 AirdropItemListIndex
local selectAirdropItemListIdx = LF_Random(context,#AirdropItemList)
LF_SetTempIndexProp(context,TempIndexProp.AirdropItemListIdx,airdropIndex,selectAirdropItemListIdx)
-- 初始化ItemIdx
LF_SetTempIndexProp(context,TempIndexProp.AirdropItemIdx,airdropIndex,1)
end
return 0
end
-- 随机选择一个未使用的空投车行进路线并标记
function LF_Airdrop_SelectAirdropPointList(context)
local pointListDec = ScriptLib.GetGroupTempValue(context, TempProp.AirdropPointListDec, {})
local binArray = LF_DecToBin(pointListDec,#AirdropPointList)
local selectIndex = LF_SelectRandomIdxFromDec(context,pointListDec,#AirdropPointList)
if selectIndex > 0 then
local newPointListDec = LF_ChangeIndexValueFromDec(pointListDec,#AirdropPointList,selectIndex,1)
local msg = "## TD_BoatRaceV3 LF_Airdrop_SelectAirdropPointList"
msg = msg .. "|pointListDec=" .. tostring(pointListDec)
msg = msg .. "|newPointListDec=" .. tostring(newPointListDec)
msg = msg .. "|binArray=" .. LF_ArrayToString(binArray)
msg = msg .. "|selectIndex=" .. tostring(selectIndex)
ScriptLib.PrintContextLog(context, msg)
ScriptLib.SetGroupTempValue(context,TempProp.AirdropPointListDec, newPointListDec, {})
return selectIndex
end
return 0
end
-- 船体消失
function LF_Airdrop_Disappear(context,index)
local cid = LF_LevelData_GetCidByIndex(LevelDataName.AirDrop,index)
-- 设置船体消失
ScriptLib.SetGadgetStateByConfigId(context,cid,201)
return 0
end
-- 空投抛物的LocalFunction
function LF_Airdrop_Throw(context,index)
-- 从船体点位创建一个投掷物
local cid = LF_LevelData_GetCidByIndex(LevelDataName.AirDrop,index)
local entityId = ScriptLib.GetEntityIdByConfigId(context, cid)
local curPos = ScriptLib.GetPosByEntityId(context, entityId)
local curAirdropItemListIdx = LF_GetTempIndexProp(context,TempIndexProp.AirdropItemListIdx,index)
local curAirdropItemIdx = LF_GetTempIndexProp(context,TempIndexProp.AirdropItemIdx,index)
local curItemList = AirdropItemList[curAirdropItemListIdx]
local curItem = curItemList[curAirdropItemIdx]
--日志查阅
local msg = "## TD_BoatRaceV3 LF_Airdrop_Throw"
msg = msg .. "|entityId=" .. entityId
msg = msg .. "|curPos=" .. LF_ArrayToString({ curPos.x,curPos.y,curPos.z })
msg = msg .. "|index=" .. tostring(index)
msg = msg .. "|curAirdropItemListIdx=" .. tostring(curAirdropItemListIdx)
msg = msg .. "|curAirdropItemIdx=" .. tostring(curAirdropItemIdx)
msg = msg .. "|curItemList=" .. LF_ArrayToString(curItemList)
msg = msg .. "|curItem=" .. tostring(curItem)
ScriptLib.PrintContextLog(context, msg)
if curItemList == nil then
ScriptLib.PrintContextLog(context, "## TD_BoatRaceV3 LF_Airdrop_Throw|数据不合法")
return 0
end
if 1 == curItem then
-- 出金币
LF_LevelData_CreateLevelDataGadget(context,LevelDataName.DropCoin,curPos,{ x=90, y=0, z=0 })
-- 记录进度
LF_SetTempIndexProp(context,TempIndexProp.AirdropItemIdx,index,curAirdropItemIdx+1)
return 0
end
if 2 == curItem then
-- 出炸药桶
LF_LevelData_CreateLevelDataGadget(context,LevelDataName.DropBomb,curPos,{ x=90, y=0, z=0 })
-- 记录进度
LF_SetTempIndexProp(context,TempIndexProp.AirdropItemIdx,index,curAirdropItemIdx+1)
return 0
end
return 0
end
-- 尝试创建一个LevelData对应的物件
function LF_LevelData_CreateLevelDataGadget(context,levelDataName,pos,rot)
-- 例如 LevelData[LevelDataName.DropCoin]
local levelDataProp = LevelData[levelDataName]
-- 获取当前最大Index(例如取DropCoinIdx)
local index = ScriptLib.GetGroupTempValue(context, levelDataProp.tempProp, {})
-- 最大Index + 1 (例如取DropCoinIdx += 1)
index = index + 1
if index > levelDataProp.num then
-- 如果达到上限则不予创建
ScriptLib.PrintContextLog(context, "## TD_BoatRaceV3 LF_LevelData_CreateLevelDataGadget|创建数量达到上限,不予创建")
return 0
end
-- 获取对应Cid
local createCid = levelDataProp.startCid + index - 1
-- 创建对应Gadget
ScriptLib.CreateGadgetByConfigIdByPos(context,createCid,{x=pos.x,y=pos.y,z=pos.z},rot)
-- 更新tempPropIndex(形如DropCoinIdx=> +=1)
ScriptLib.SetGroupTempValue(context, levelDataProp.tempProp, index, {})
return index
end
-- 根据Index获取对应Cid
function LF_LevelData_GetCidByIndex(levelDataName,index)
local levelDataProp = LevelData[levelDataName]
if levelDataProp ~= nil then
if index <= levelDataProp.num then
return levelDataProp.cidList[index]
end
end
return 0
end
-- 根据ConfigID获取对应Index
function LF_LevelData_GetIndexByCid(levelDataName,cid)
local levelDataProp = LevelData[levelDataName]
if levelDataProp ~= nil then
local index = cid - levelDataProp.startCid + 1
if index <= levelDataProp.num then
return index
end
end
return 0
end
-- 根据字符串解析Index
function LF_GetIndexByString(str,propName)
local indexString = string.gsub(str,propName,"")
local index = tonumber(indexString)
if index == nil then
return 0
end
return index
end
-- 获取形如"xx01"的tempValue
function LF_GetTempIndexProp(context,propName,index)
local propValue = ScriptLib.GetGroupTempValue(context, propName..tostring(index), {})
return propValue
end
-- 设置形如"xx01"的tempValue
function LF_SetTempIndexProp(context,propName,index,value)
ScriptLib.SetGroupTempValue(context, propName..tostring(index),value, {})
return 0
end
--=====================================
--SLC
--=====================================
-- 获取金币
function SLC_PlayerGetCoin(context,param1)
local uid = context.uid
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
LF_SLCDebug(context,"SLC_PlayerGetCoin")
if 0 == config_id then
-- 未发现金币
return 0
end
if 201 == ScriptLib.GetGadgetStateByConfigId(context, 0, config_id) then
-- 金币状态已扭转
return 0
end
local msg = "## TD_BoatRaceV3 SLC_PlayerGetCoin"
msg = msg .. "|config_id=" .. config_id
msg = msg .. "|param1=" .. param1
ScriptLib.PrintContextLog(context, msg)
-- 获取金币对应数量
LF_GetCoinNumByGV(context,uid,param1,config_id)
return 0
end
-- 击杀时触发
function SLC_PlayerDestroyItem(context)
LF_SLCDebug(context,"SLC_PlayerDestoryItem")
local uid = context.uid
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
if 0 == config_id then
return 0
end
ScriptLib.AddTeamServerGlobalValue(context, uid, SGVProp.Coin, 1)
return 0
end
-- 对应玩家获取道具
function SLC_PlayerGetItem(context)
LF_SLCDebug(context,"SLC_PlayerGetItem")
local uid = context.uid
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
if 0 == config_id then
return 0
end
if 201 == ScriptLib.GetGadgetStateByConfigId(context, 0, config_id) then
-- 道具状态已扭转
return 0
end
-- 改变对应道具球状态
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201)
LF_GetItemBall(context,uid)
return 0
end
-- 对应玩家使用道具
function SLC_PlayerUseItem(context)
LF_SLCDebug(context,"SLC_PlayerUseItem")
local uid = context.uid
ScriptLib.SetTeamServerGlobalValue(context, uid, SGVProp.SkillIdx, 0)
return 0
end
-- 对应玩家掉落金币的逻辑
function SLC_PlayerDamage(context)
LF_SLCDebug(context,"SLC_PlayerDropCoin")
local uid = context.uid
-- 获取对应玩家的HP
local hp = ScriptLib.GetTeamServerGlobalValue(context, uid, SGVProp.HP)
hp = math.max(0,hp-1)
ScriptLib.SetTeamServerGlobalValue(context, uid, SGVProp.HP, hp)
if hp == 0 then
LF_EnterGhost(context,evt)
end
return 0
end
--[[=====================================
|| 本地函数
--======================================]]
-- 初始化玩家序号(作为联机时唯一标记)
function LF_InitPlayerIndex(context)
local uid_list = ScriptLib.GetSceneUidList(context)
for key,uid in pairs(uid_list) do
LF_SetPlayerProp(context,"Player",uid,key)
ScriptLib.SetGroupTempValue(context, "UidIndex" .. key,uid, {})
end
return 0
end
function LF_GetPlayerUidByIndex(context,Index)
if index < 1 and index > 4 then
return 0
end
local uid = ScriptLib.GetGroupTempValue(context, UidIndex..Index, {})
return uid
end
function LF_GetIndexByKeyName(keyName)
if keyName == "Revive1" then
return 1
end
if keyName == "Revive2" then
return 2
end
if keyName == "Revive3" then
return 3
end
if keyName == "Revive4" then
return 4
end
return 0
end
-- 写入对应玩家的Prop
function LF_SetPlayerProp(context,uidProp,uid,value)
ScriptLib.SetGroupTempValue(context, uidProp..uid,value, {})
return 0
end
-- 读取对应玩家的Prop
function LF_GetPlayerProp(context,uidProp,uid)
local index = ScriptLib.GetGroupTempValue(context, uidProp..uid, {})
return index
end
-- 金币效果结算
function LF_GetCoinNumByGV(context,uid,globalValue,cid)
local msg = "## TD_BoatRaceV3 LF_GetCoinNumByGV"
msg = msg .. "|uid=" .. uid
msg = msg .. "|globalValue=" .. globalValue
msg = msg .. "|cid=" .. cid
ScriptLib.PrintContextLog(context, msg)
if globalValue == 1.0 then
-- 普通金币
ScriptLib.AddTeamServerGlobalValue(context, uid, SGVProp.Coin, 1)
-- 改变对应金币状态
ScriptLib.SetGadgetStateByConfigId(context, cid, 201)
return 1
end
if globalValue == 2.0 then
-- 大金币
ScriptLib.AddTeamServerGlobalValue(context, uid, SGVProp.Coin, 10)
-- 改变对应金币状态
ScriptLib.SetGadgetStateByConfigId(context, cid, 201)
return 10
end
if globalValue == 3.0 then
-- 亡语金币
local coinOwnerIndex = gadgets[cid].uidIndex
local coinOwnerUid = LF_GetPlayerUidByIndex(context,coinOwnerIndex)
local coinNum = LF_GetPlayerProp(context,"DropCoin",coinOwnerUid)
if coinNum > 0 then
ScriptLib.AddTeamServerGlobalValue(context, uid, SGVProp.Coin, coinNum)
-- 改变对应金币状态
ScriptLib.SetGadgetStateByConfigId(context, cid, 201)
end
return 0
end
end
-- 道具球效果结算
function LF_GetItemBall(context,uid)
-- 此处疑似可能要迭代不是纯随机
local randomSkillIndex = LF_Random(context,3)
ScriptLib.PrintContextLog(context, "##TD_BoatRaceV3 | LF_GetItemBall 获取技能道具,当前技能为 ".. randomSkillIndex)
ScriptLib.SetTeamServerGlobalValue(context, uid, SGVProp.SkillIdx, randomSkillIndex)
return 0
end
-- 生命结算流程
function LF_EnterGhost(context,uid)
local avatarEntity=ScriptLib.GetAvatarEntityIdByUid(context,uid)
local avatarPos = ScriptLib.GetPosByEntityId(context, avatarEntity)
local uidIndex = LF_GetPlayerProp(context,"Player",uid)
if nil == PlayerData[uidIndex] then
ScriptLib.PrintContextLog(context, "##TD_BoatRaceV3 | SLC_PlayerDropCoin" .. "|uidIndex=" .. uidIndex)
return 0
end
-- 计算掉落金币数量并在角色原位置创生金币
local coinCid = PlayerData[uidIndex].DeathCoin
local coinNum = ScriptLib.GetTeamAbilityFloatValue(context, uid, SGVProp.Coin)
local dropCoinNum = math.floor(coinNum/2) -- 掉落一半金币
if dropCoinNum > 0 then
ScriptLib.SetTeamServerGlobalValue(context, uid, SGVProp.Coin, coinNum-dropCoinNum)
LF_SetPlayerProp(context,SGVProp.Coin, uid, dropCoinNum)
-- todo此处要确保对应金币已移除
ScriptLib.CreateGadgetByConfigIdByPos(context, coinCid,avatarPos,{ x=0, y=0, z=0 })
end
-- 对应角色进入幽灵模式并开始倒计时
ScriptLib.SetTeamServerGlobalValue(context, uid, SGVProp.Ghost, 1)
-- 开启该角色的计时器
ScriptLib.InitTimeAxis(context, "Revive0".. tostring(uidIndex), PlayCfg.ReviveTimeAxis, false)
ScriptLib.SetTeamServerGlobalValue(context, uid, SGVProp.Progress, PlayCfg.ReviveCounter)
return 0
end
--[[=====================================
|| 常用工具包
--======================================]]
-- 标准的InsertTriggers方法
function LF_InsertTriggers(TempTrigger,TempRequireSuite)
local hasRequireSuitList = not (TempRequireSuite == nil or #TempRequireSuite <=0)
if hasRequireSuitList then
if (init_config.io_type ~= 1) then
--常规group注入trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for _,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suites) then
table.insert(suites[TempRequireSuite[i]].triggers, v.name)
end
end
end
else
--flow group注入trigger注入白名单定义的suite list
for i = 1, #TempRequireSuite do
for _,v in pairs(TempTrigger) do
if (TempRequireSuite[i]<=#suite_disk) then
table.insert(suite_disk[TempRequireSuite[i]].triggers, v.name)
end
end
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for _,v in pairs(TempTrigger) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for _,v in pairs(TempTrigger) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
end
-- 简单拆分一个数组
function LF_ArrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
-- 该功能用于从特定二进制数据中获取Index
function LF_SelectRandomIdxFromDec(context,decValue, len)
local dataArray = LF_DecToBin(decValue, len)
local selectIndexList = {}
local canSelectNum = 0
for i = 1,len do
if dataArray[i] == 0 then
table.insert(selectIndexList,i)
canSelectNum = canSelectNum + 1
end
end
if canSelectNum == 0 then
return 0
end
math.randomseed(tostring(ScriptLib.GetServerTime(context)):reverse():sub(1, 6))
local selectListIdx = LF_Random(context,canSelectNum)
local selectIndex = selectIndexList[selectListIdx]
local msg = "## TD_BoatRaceV3 LF_SelectRandomIdxFromDec"
msg = msg .. "|dataArray=" .. LF_ArrayToString(dataArray)
msg = msg .. "|selectIndexList=" .. LF_ArrayToString(selectIndexList)
msg = msg .. "|canSelectNum=" .. tostring(canSelectNum)
msg = msg .. "|selectListIdx=" .. tostring(selectListIdx)
msg = msg .. "|selectIndex=" .. tostring(selectIndex)
ScriptLib.PrintContextLog(context, msg)
return selectIndex
end
-- 对指定dec修改其特定Index的value,value必须在0,1之间
function LF_ChangeIndexValueFromDec(decValue,len,targetIndex,value)
local dataArray = LF_DecToBin(decValue,len)
if value ~= 0 and value ~=1 then
value = 0
end
-- 指定关卡设为完成
dataArray[targetIndex] = value
local changeLevelDec = LF_BinToDec(dataArray)
return changeLevelDec
end
-- 顺序0,1数组转十进制保存
function LF_BinToDec(binArray)
local decValue = 0
local bin = table.concat(binArray)
decValue = tonumber(bin,2)
return decValue
end
-- 十进制转成0,1数组
function LF_DecToBin(decValue, len)
local binArray = {}
local value = decValue
local bit = len -1
for i = bit,0,-1 do
binArray[#binArray+1] = math.floor(value/2^i)
value = value % 2^i
end
return binArray
end
function LF_Random(context,num)
math.randomseed(tostring(ScriptLib.GetServerTime(context)):reverse():sub(1, 6))
local randomIndex = math.random(1,num)
return randomIndex
end
-- SLC的通用Debug手段
function LF_SLCDebug(context,functionName)
local msg = "##TD_BoatRaceV3|" .. functionName
msg = msg .. "|uid=" .. context.uid
msg = msg .. "|source=" .. context.source_entity_id
msg = msg .. "|sourceCid=" .. ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
msg = msg .. "|target=" .. context.target_entity_id
msg = msg .. "|targetCid=" .. ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.target_entity_id })
ScriptLib.PrintContextLog(context, msg)
return 0
end
--[[=====================================
|| 初始化
--======================================]]
LF_Initialize_BoatRaceV3()

View File

@@ -0,0 +1,310 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
--======================================================================================================================
--|| Filename || Activity_TeamChainChallenge
--|| RelVersion || V3_4
--|| Owner || shuo-yu
--|| Description ||
--|| LogName || ##[Activity_TeamChainChallenge]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
-- local defs =
-- {
-- starter_gadget = 0,
-- gallery_id = 0,
-- teleportPos_id = 0,
-- groups_info =
-- {
-- [1] = {id = 1, monster_num = 10,},
-- [2] = {id = 2, monster_num = 10,},
-- [3] = {id = 3, monster_num = 10,},
-- [4] = {id = 4, monster_num = 10,},
-- },
-- }
--======================================================================================================================
--Events || Group内EVENT事件,记得初始化和return 0
--======================================================================================================================
--ServerLuaCalls || 物件SLC,记得return 0
--======================================================================================================================
--LevelFunctions || 自定义函数
local Tri = {
--主控group加载 初始化所有玩法group
{ config_id = 34000010, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
--所有玩家死掉 触发关卡失败
{ config_id = 34000020, name = "dungeon_all_avatar_die", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "condition_dungeon_all_avatar_die", action = "action_dungeon_all_avatar_die", trigger_count = 0 },
--变量变化 开启或停止玩法 GALLERY_STATE 0未开启 1开启 2子阶段成功 3子阶段失败
{ config_id = 34000030, name = "variable_change", event = EventType.EVENT_VARIABLE_CHANGE, source = "GALLERY_STATE", condition = "", action = "action_variable_change", trigger_count = 0 },
--任一怪物死亡 触发怪物计分变化
{ config_id = 34000040, name = "dungeon_any_monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "GALLERY_STATE", condition = "", action = "action_any_monster_die", trigger_count = 0 },
--时间轴开启时传送 结束后触发下一玩法group加载
{ config_id = 34000050, name = "time_axis_pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
}
function TeamChain_Initialize()
LF_InsertTriggers(Tri,1)
--子阶段开启结束Var 0未开启 1开启 2子阶段成功 3子阶段失败
--table.insert(variables,{ config_id=50000001,name = "GALLERY_STATE", value = 0, no_refresh = true})
--关卡内GroupIndex 1主控Group 2~4阶段Group
table.insert(variables,{ config_id=50000002,name = "GROUP_INDEX", value = 1, no_refresh = true})
end
------------------------------------------------------------------
--主控group load后 初始化玩法
function action_group_load(context,evt)
LF_PrintLog(context,"action_group_load主控group加载初始化玩法")
LF_InitPlay(context)
return 0
end
--判断是否所有玩家都死了
function condition_dungeon_all_avatar_die(context,evt)
local uid_list = ScriptLib.GetSceneUidList(context)
local ret = 0
for i,v in ipairs(uid_list) do
local is_all_dead = ScriptLib.IsPlayerAllAvatarDie(context, v)
if true ~= is_all_dead then
ret = -1
break
end
end
if ret ~= 0 then
return false
end
return true
end
--玩家全部死亡结束玩法并设置失败
function action_dungeon_all_avatar_die(context,evt)
LF_PrintLog(context,"action_dungeon_all_avatar_die: 所有玩家的所有角色都死掉")
LF_StopPlay(context,false)
return 0
end
--有怪物死亡更新显示
function action_any_monster_die(context,evt)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["kill_monster_cnt"] = 1})
return 0
end
--GALLERY_STATE变化 0待机 1开启玩法 2结束玩法并设置成功 3结束玩法并设置失败
function action_variable_change(context,evt)
LF_PrintLog(context,"设置参数")
LF_PrintLog(context,tostring(evt.param1))
if evt.param1 == 1 then
LF_StartPlay(context)
elseif evt.param1 == 2 then
LF_StopPlay(context, true)
elseif evt.param1 == 3 then
LF_StopPlay(context, false)
end
return 0
end
--时间轴结束 加载下一玩法group
function action_time_axis_pass(context,evt)
if evt.source_name == "teleport" then
local index = LF_GetGroupIndex(context)
if index == -1 then
LF_PrintLog(context,"Axis Pass Failed: table越界")
return 0
end
LF_PrintLog(context,"传送结束")
LF_InitNextGroup(context,index)
end
return 0
end
--ServerLuaCall
--操作台点对应选项 开启玩法
function SLC_Activity_TeanChainChallenge_StartPlay(context)
-- 触发挑战trigger
ScriptLib.SetGroupVariableValue(context,"GALLERY_STATE",1)
LF_SetWorkTopActive(context, false)
return 0
end
--LF Func
function LF_PrintLog(context, content)
local log = "## [Activity_TeamChainChallenge] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
--初始化玩法 加载所有玩法group
function LF_InitPlay(context)
for k,v in pairs(defs.groups_info) do
ScriptLib.RefreshGroup(context, { group_id = v.id, suite = 1 })
LF_PrintLog(context,"加载玩法group,id: ".. v.id)
end
LF_InitNextGroup(context,1)
return 0
end
--开启玩法 启动gallery 切换当前玩法group suite至2 传怪物数目
function LF_StartPlay(context)
--先尝试启动gallery如果未成功则直接返回
if (ScriptLib.SetPlayerStartGallery(context, defs.gallery_id, ScriptLib.GetSceneUidList(context)) ~= 0) then
return 0
end
LF_PrintLog(context,"开启gallery"..defs.gallery_id)
local index = LF_GetGroupIndex(context)
if index == -1 then
LF_PrintLog(context,"StartPlay Failed: table越界")
return 0
end
ScriptLib.AddExtraGroupSuite(context,defs.groups_info[index].id,2)
LF_PrintLog(context,"加载下个group,id: ".. defs.groups_info[index].id)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["total_kill_cnt"] = defs.groups_info[index].monster_num})
return 0
end
--结束玩法 成功初始化下一group 失败直接cause dungeon fail
function LF_StopPlay(context, is_success)
local index = LF_GetGroupIndex(context)
if index == -1 then
LF_PrintLog(context,"StopPlay Failed: table越界")
return 0
end
if (is_success) then
--成功通关
LF_PrintLog(context,"成功通关阶段"..(index))
ScriptLib.StopGalleryByReason(context,defs.gallery_id,3)
local mPos = {x=LF_GetPointPos(context, defs.teleportPos_id).x,
y=LF_GetPointPos(context, defs.teleportPos_id).y,
z=LF_GetPointPos(context, defs.teleportPos_id).z,}
if index < 4 then
ScriptLib.TransPlayerToPos(context, {uid_list =ScriptLib.GetSceneUidList(context),
pos = mPos,
radius = 0, rot = LF_GetPointRot(context, defs.teleportPos_id)})
ScriptLib.InitTimeAxis(context, "teleport", {1}, false)
elseif index == 4 then
LF_PrintLog(context,"成功通关大关")
LF_ResetAllVars(context)
ScriptLib.CauseDungeonSuccess(context)
end
else
--失败
LF_PrintLog(context,"失败")
ScriptLib.StopGalleryByReason(context,defs.gallery_id,4)
ScriptLib.CauseDungeonFail(context)
LF_ResetAllVars(context)
end
return 0
end
--清理当前group 更改GROUP_INDEX为下阶段 GALLERY_STATE重置回待命
function LF_InitNextGroup(context,index)
if index ~= 1 then
ScriptLib.RefreshGroup(context, { group_id = defs.groups_info[index].id, suite = 1 })
LF_PrintLog(context,"清空当前group,id: ".. defs.groups_info[index].id)
end
index = index + 1
ScriptLib.SetGroupVariableValue(context,"GROUP_INDEX",index)
LF_PrintLog(context,"下阶段为:["..index.."]")
LF_SetWorkTopActive(context, true)
ScriptLib.SetGroupVariableValue(context,"GALLERY_STATE",0)
return 0
end
--设置操作台状态
function LF_SetWorkTopActive(context, is_active)
LF_PrintLog(context, "更新gadget信息")
if (is_active) then
ScriptLib.SetGadgetStateByConfigId(context, defs.starter_gadget, GadgetState.Default)
else
ScriptLib.SetGadgetStateByConfigId(context, defs.starter_gadget, GadgetState.GearStop)
end
LF_PrintLog(context,"设置操作台"..(is_active and "显示" or "隐藏"))
LF_PrintLog(context, "更新gadget信息完毕")
return 0
end
--重置所有variable value
function LF_ResetAllVars(context)
ScriptLib.SetGroupVariableValue(context,"GROUP_INDEX",1)
ScriptLib.SetGroupVariableValue(context,"GALLERY_STATE",0)
end
--插入trigger
function LF_InsertTriggers(TempTrigger,suiteIndex)
if suiteIndex <= 0 or suiteIndex > #suites then
return -1
end
for k,v in pairs(TempTrigger) do
table.insert(triggers,v)
table.insert(suites[suiteIndex].triggers,v.name)
end
return 0
end
--获取Point Pos Vec3
function LF_GetPointPos(context,point_id)
for k,v in pairs(points) do
if v.config_id == point_id then
return v.pos
end
end
return 0
end
--获取Point Rot Vec3
function LF_GetPointRot(context,point_id)
for k,v in pairs(points) do
if v.config_id == point_id then
return v.rot
end
end
return 0
end
--获取当前group index 越界返回-1
function LF_GetGroupIndex(context)
local index = ScriptLib.GetGroupVariableValue(context, "GROUP_INDEX")
if index > 4 or index < 1 then
--reset
LF_PrintLog(context,"Groups下标越界"..index)
return -1
end
return index
end
------------------------------------------------------------------
TeamChain_Initialize()

View File

@@ -0,0 +1,137 @@
--[[======================================
|| filename:
|| owner: luyao.huang
|| description:
|| LogName:
|| Protection:
=======================================]]--
------
local local_defs = {
sandworm_control_group = 133314001,
--大世界业务类型为0优先级为1
request_priority = 1,
business_type = 0
}
local Tri = {
[1] = { name = "enter_region_bigworld_sandworm_region", config_id = 10010001, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region_bigworld_sandworm_region", trigger_count = 0},
[2] = { name = "leave_region_bigworld_sandworm_region", config_id = 10010002, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region_bigworld_sandworm_region", trigger_count = 0},
[3] = { name = "time_axis_pass_bigworld_sandworm_region", config_id = 10010011, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass_bigworld_sandworm_region", trigger_count = 0},
[4] = { name = "group_will_unload_bigworld_sandworm_region", config_id = 10010012, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_bigworld_sandworm_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
table.insert(variables,{ config_id = 50000001, name = "is_in_challenge_region", value = 0})
table.insert(variables,{ config_id = 50000002, name = "current_region_id", value = 0})
table.insert(variables,{ config_id = 50000100, name = "business_type", value = local_defs.business_type})
table.insert(variables,{ config_id = 50000101, name = "sandworm_params_config_id", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_enter_region_bigworld_sandworm_region(context,evt)
if LF_Is_Region_Specific_Region(context,"SandwormRegion",evt.param1) then
ScriptLib.PrintContextLog(context,"## [BigworldSandwormRegionControl]enter_region: 玩家进入大世界沙虫区域,请求创生参数")
local request =
{
group_id = base_info.group_id,
priority = local_defs.request_priority,
}
local region_config = LF_Get_Region_Config_By_Id(context,evt.param1)
if region_config ~= nil then
ScriptLib.SetGroupVariableValue(context,"sandworm_params_config_id",region_config.sandworm_params_config_id)
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Create_Sandworm_Params",{request.group_id,request.priority})
end
ScriptLib.InitTimeAxis(context,"sandworm_alert_axis",{1},true)
ScriptLib.SetGroupVariableValue(context,"current_region_id",evt.param1)
end
return 0
end
function action_leave_region_bigworld_sandworm_region(context,evt)
if LF_Is_Region_Specific_Region(context,"SandwormRegion",evt.param1) then
ScriptLib.PrintContextLog(context,"## [BigworldSandwormRegionControl]leave_region: 玩家离开大世界沙虫区域,请求销毁")
ScriptLib.SetGroupVariableValue(context,"sandworm_params_config_id",0)
--清掉当前的沙虫
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm",{base_info.group_id})
--清掉当前在占用的参数
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm_Params",{base_info.group_id})
ScriptLib.EndTimeAxis(context,"sandworm_alert_axis")
ScriptLib.SetGroupVariableValue(context,"current_region_id",0)
end
return 0
end
function action_time_axis_pass_bigworld_sandworm_region(context,evt)
if (evt.source_name == "sandworm_alert_axis") and not LF_Is_In_Challenge_Region(context) then
local current_region_id = ScriptLib.GetGroupVariableValue(context,"current_region_id")
local region_config = LF_Get_Region_Config_By_Id(context,current_region_id)
if region_config ~= nil then
local alert = math.random(region_config.alert_by_tick[1],region_config.alert_by_tick[2])
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Change_Alert_Value",{alert})
end
end
return 0
end
function action_group_will_unload_bigworld_sandworm_region(context,evt)
ScriptLib.PrintContextLog(context,"## [BigworldSandwormRegionControl]group_will_unload: group卸载做保底恢复")
ScriptLib.SetGroupVariableValue(context,"current_region_id",0)
ScriptLib.SetGroupVariableValue(context,"is_in_challenge_region",0)
ScriptLib.EndTimeAxis(context,"sandworm_alert_axis")
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Is_In_Challenge_Region(context)
return ScriptLib.GetGroupVariableValue(context,"is_in_challenge_region") == 1
end
function LF_Get_Region_Config_By_Id(context,region_id)
local region_config = special_sandworm_region_defs[region_id]
if region_config == nil then
region_config = {alert_by_tick = default_sandworm_alert_by_tick,sandworm_params_config_id = default_sandworm_params_config_id}
end
return region_config
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,222 @@
--[[
-- DEFS_MISCS
local defs = {
duration = 30,
kill_sum = 1,
GroupID = 111102025,
gadget_controller_id = 25004,
ChallengeID = 1,
MonstersuitID = 2,
}
--]]
local defs = {
duration = 30,
kill_sum = 1,
GroupID = 111102025,
gadget_controller_id = 25004,
ChallengeID = 71,
FireworkRegion = 25002,
ChallengeStartRegion = 25003,
MonsterNum = 4, --Group中所有怪物的数量用来控制挑战计数
FireworkID = 25005,
}
local Phase ={
[1] = {2},
[2] = {3},
[3] = {4},
[4] = {5},
}
---------------------
local tempTrigger_BoomMonsterCamp = {
{ config_id = 2230000, name = "RISE_CHALLENGE", event = EventType.EVENT_ENTER_REGION, source = "1",
condition = "", action = "action_RISE_CHALLENGE", trigger_count = 0},
{ config_id = 2230001, name = "ANY_MONSTER_DIE_25015", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE_25015", trigger_count = 0, tag = "25015"},
{ config_id = 2330002, name = "ChallengeEndCheckWin", event = EventType.EVENT_CHALLENGE_SUCCESS, source = tostring(10*defs.ChallengeID), condition = "", action = "action_ChallengeWin" },
{ config_id = 2330003, name = "ChallengeEndCheckLose", event = EventType.EVENT_CHALLENGE_FAIL, source = tostring(10*defs.ChallengeID), condition = "", action = "action_ChallengeLose" },
{ config_id = 2230004, name = "LEAVE_REGION_Challenge", event = EventType.EVENT_LEAVE_REGION, source = "1",
condition = "", action = "action_LEAVE_REGION_Challenge", trigger_count = 0},
{ config_id = 2330005, name = "VARIABLE_CHANGE_BundleEnd", event = EventType.EVENT_VARIABLE_CHANGE, source = "StartNextGroup",
condition = "", action = "action_VARIABLE_CHANGE_BundleEnd", trigger_count = 0},
}
--------初始化----------
function LF_Initialize_BoomMonsterCamp()
for k,v in pairs(tempTrigger_BoomMonsterCamp) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
LF_Initialize_BoomMonsterCamp()
--------公用函数----------
-- Gadget发送事件后触发对应挑战
function action_RISE_CHALLENGE(context, evt)
if evt.param1 ~= defs.ChallengeStartRegion or ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
ScriptLib.PrintContextLog(context,evt.param1, "## TD_BoomMonsterCamp : 非对应挑战Region触发 ")
return 0
end
-- 防止连续启挑战
if -1 == LF_CheckChallenge(context) then return 0 end
-- 检查Group中怪物是否已经全死
local MDNum = ScriptLib.GetGroupVariableValue(context,"MonsterDieNum")
if 0 ~= LF_CheckMonsterNum(context,MDNum) then
return 0
end
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 准备开启挑战")
--ScriptLib.PrintContextLog(context, "## MDNum" .. MDNum .. "")
ScriptLib.StartChallenge(context, 10*defs.ChallengeID, defs.ChallengeID, {1, 25015, 4, 1, MDNum})
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 挑战已经开启,设置变量,防止重复进出")
ScriptLib.SetGroupTempValue(context, "haveStartChallenge", 1, {})
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 开始添加怪物")
-- yc 这里的变量是不存档的也是不会让挑战重复开启是满足了挑战没有完成需要重复开启的情况
LF_RefreshPhaseSuit(context)
ScriptLib.PrintContextLog(context, "## test : 3333")
return 0
end
--[[
-- 触发条件
function condition_EVENT_ANY_MONSTER_DIE_25015(context, evt)
-- 判断指定group组剩余怪物数量是否是0
if ScriptLib.GetGroupMonsterCountByGroupId(context, 111102025) ~= 0 then
return false
end
return true
end
--]]
-- 触发操作
function action_EVENT_ANY_MONSTER_DIE_25015(context, evt)
ScriptLib.ChangeGroupVariableValue(context, "MonsterDieNum", 1)
if ScriptLib.GetGroupMonsterCountByGroupId(context, 111102025) ~= 0 then
return 0
end
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 怪物死亡stage变更")
ScriptLib.ChangeGroupVariableValue(context, "stage", 1)
LF_RefreshPhaseSuit(context)
return 0
end
function action_ChallengeWin(context, evt)
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 挑战成功关闭Region ")
ScriptLib.SetGroupTempValue(context, "haveStartChallenge", 2, {})
ScriptLib.AddExtraGroupSuite(context, defs.GroupID, 5)
ScriptLib.RemoveEntityByConfigId(context, defs.GroupID, EntityType.REGION, defs.ChallengeStartRegion)
return 0
end
function action_ChallengeLose(context, evt)
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 挑战失败关闭并刷新Region ")
--ScriptLib.RemoveEntityByConfigId(context, defs.GroupID, EntityType.MONSTER, 25001)
--失败了只刷新挑战启动区域不刷新烟花
ScriptLib.RefreshGroup(context, { group_id = defs.GroupID, suite = 1 })
--杀掉进入时的烟花这里要多加个参数让LD来告诉烟花的configid
ScriptLib.KillEntityByConfigId(context, {group_id=111102025, config_id=defs.FireworkID})
ScriptLib.SetGroupTempValue(context, "haveStartChallenge", 0, {})
return 0
end
function LF_CheckChallenge(context)
local haveStartChallenge = ScriptLib.GetGroupTempValue(context, "haveStartChallenge",{})
if 1 == haveStartChallenge then
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 挑战已触发,不再重复触发 ")
return -1
end
if 2 == haveStartChallenge then
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 挑战已结束,不再触发 ")
return -1
end
return 0
end
function LF_CheckMonsterNum(context,MDNum)
if MDNum < defs.MonsterNum then
return 0
end
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 挑战应已完成,请检查进入原因 ")
return -1
end
-- 离开指定区域且区域内人员为零时挑战失败
function action_LEAVE_REGION_Challenge(context, evt)
if evt.param1 == defs.ChallengeStartRegion 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 LF_RefreshPhaseSuit(context)
local stage = ScriptLib.GetGroupVariableValue(context, "stage")
if nil == Phase then
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : Group: " .. defs.GroupID .. "没有对应Phase")
return 0
end
if stage > #Phase then
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : stage超过Phase界限stage = " .. stage)
return 0
end
local needRefreshSuit = Phase[stage]
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : PhaseStage= " .. stage .. "需要刷新的suit为" .. LF_arrayToString(needRefreshSuit))
for k,v in ipairs(needRefreshSuit) do
ScriptLib.AddExtraGroupSuite(context, defs.GroupID, v)
end
ScriptLib.PrintContextLog(context, "## 添加怪物成功")
return 0
end
-- 结束Bundle
function action_VARIABLE_CHANGE_BundleEnd(context, evt)
ScriptLib.PrintContextLog(context, "## TD_BoomMonsterCamp : 开启了宝箱FinishGroupLink ")
ScriptLib.RemoveEntityByConfigId(context, defs.GroupID, EntityType.REGION, defs.ChallengeStartRegion)
ScriptLib.FinishGroupLinkBundle(context, defs.GroupID)
return 0
end
function LF_arrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end

View File

@@ -0,0 +1,154 @@
--[[======================================
|| filename:
|| owner: luyao.huang
|| description:
|| LogName:
|| Protection:
=======================================]]--
local sandworm_params_config_id = 12
------
local local_defs = {
sandworm_control_group = 133314001,
--挑战业务类型为0优先级为1
request_priority = 2,
business_type = 1
}
local Tri = {
[1] = { name = "enter_region_sandworm_challenge", config_id = 10010001, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region_sandworm_challenge", trigger_count = 0},
[2] = { name = "leave_region_sandworm_challenge", config_id = 10010002, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region_sandworm_challenge", trigger_count = 0},
[3] = { name = "time_axis_pass_sandworm_challenge", config_id = 10010011, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass_sandworm_challenge", trigger_count = 0},
[4] = { name = "group_will_unload_sandworm_challenge", config_id = 10010012, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_sandworm_challenge", 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 = 50000100, name = "business_type", value = local_defs.business_type})
table.insert(variables,{ config_id = 50000101, name = "sandworm_params_config_id", value = sandworm_params_config_id})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_enter_region_sandworm_challenge(context,evt)
if evt.param1 == defs.sandworm_region then
if ScriptLib.IsChallengeStartedByChallengeId(context, defs.challenge_id) then
ScriptLib.PrintContextLog(context,"## [ChallengeSandwormRegionControl]enter_region: 挑战中进入大世界区域,请求创生")
local request =
{
group_id = base_info.group_id,
priority = local_defs.request_priority,
}
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Create_Sandworm_Params",{request.group_id,request.priority})
ScriptLib.InitTimeAxis(context,"sandworm_alert_axis",{1},true)
ScriptLib.SetGroupVariableValueByGroup(context,"is_in_challenge_region", 1, local_defs.sandworm_control_group)
end
end
return 0
end
function action_leave_region_sandworm_challenge(context,evt)
if evt.param1 == defs.sandworm_region then
if ScriptLib.IsChallengeStartedByChallengeId(context, defs.challenge_id) then
ScriptLib.PrintContextLog(context,"## [ChallengeSandwormRegionControl]enter_region: 挑战中离开大世界区域,请求销毁")
--清掉当前的沙虫
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm",{base_info.group_id})
--清掉当前在占用的参数
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm_Params",{base_info.group_id})
ScriptLib.EndTimeAxis(context,"sandworm_alert_axis")
ScriptLib.SetGroupVariableValueByGroup(context,"is_in_challenge_region", 0, local_defs.sandworm_control_group)
end
end
return 0
end
function action_time_axis_pass_sandworm_challenge(context,evt)
if (evt.source_name == "sandworm_alert_axis") then
if ScriptLib.IsChallengeStartedByChallengeId(context, defs.challenge_id) then
local alert = math.random(sandworm_alert_by_tick[1],sandworm_alert_by_tick[2])
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Change_Alert_Value",{alert})
end
end
return 0
end
function action_group_will_unload_sandworm_challenge(context,evt)
ScriptLib.PrintContextLog(context,"## [ChallengeSandwormRegionControl]group_will_unload: group卸载要保底清除占用的沙虫参数")
--清掉当前的沙虫
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm",{base_info.group_id})
--清掉当前在占用的参数
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm_Params",{base_info.group_id})
ScriptLib.EndTimeAxis(context,"sandworm_alert_axis")
ScriptLib.SetGroupVariableValueByGroup(context,"is_in_challenge_region", 0, local_defs.sandworm_control_group)
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Challenge_Start_Change_Sandworm_Params(context)
ScriptLib.PrintContextLog(context,"## [ChallengeSandwormRegionControl]LF_Challenge_Request_Create_Sandworm: 挑战开始,请求创生")
local request =
{
group_id = base_info.group_id,
priority = local_defs.request_priority,
}
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Create_Sandworm_Params",{request.group_id,request.priority})
local ret = ScriptLib.InitTimeAxis(context,"sandworm_alert_axis",{1},true)
ScriptLib.PrintContextLog(context,"## [ChallengeSandwormRegionControl]LF_Challenge_Request_Create_Sandworm: 启动时间轴:"..ret)
ScriptLib.SetGroupVariableValueByGroup(context,"is_in_challenge_region", 1, local_defs.sandworm_control_group)
return 0
end
function LF_Challenge_Stop_Clear_Sandworm_Params(context)
ScriptLib.PrintContextLog(context,"## [ChallengeSandwormRegionControl]LF_Challenge_Request_Create_Sandworm: 挑战结束,请求销毁")
--清掉当前的沙虫
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm",{base_info.group_id})
--清掉当前在占用的参数
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm_Params",{base_info.group_id})
ScriptLib.EndTimeAxis(context,"sandworm_alert_axis")
ScriptLib.SetGroupVariableValueByGroup(context,"is_in_challenge_region", 0, local_defs.sandworm_control_group)
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,143 @@
--[[======================================
|| filename: ElectroherculesBattle
|| owner: luyao.huang
|| description: 3.4鬼兜虫斗虫活动
|| LogName: ElectroherculesBattle
|| Protection:
=======================================]]--
------
local local_defs =
{
gallery_id = 32001
}
local Tri = {
--后续换成select_difficulty
--[1] = { name = "select_difficulty", config_id = 8000001, event = EventType.EVENT_SELECT_DIFFICULTY, source = "", condition = "", action = "action_select_difficulty", trigger_count = 0},
[1] = { name = "variable_change_GM", config_id = 8000001, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change_GM", trigger_count = 0},
[2] = { name = "monster_die", config_id = 8000002, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die", trigger_count = 0},
[3] = { name = "group_will_unload", config_id = 8000003, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
--测试时间轴:每1秒显示一次血量
[4] = { name = "time_axis_pass", config_id = 8000004, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", 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 = 110000001, name = "difficulty", value = 0})
table.insert(variables,{config_id = 210000001, name = "GM_Select_Difficulty", value = 0})
end
------------------------------------------------------------------
--测试时间轴:每1秒打印一次血量
function action_time_axis_pass(context,evt)
local difficulty = ScriptLib.GetGroupVariableValue(context,"difficulty")
EnemyHP = ScriptLib.GetMonsterHpPercent(context, base_info.group_id, EnemyElectrohercules[difficulty])
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_time_axis_pass: 敌方生命:"..EnemyHP.."%")
return 0
end
--正式的开启流程
function action_select_difficulty(context,evt)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_select_difficulty 玩家选择挑战难度加载对应suite")
--设置difficulty
local difficulty = evt.param2
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_select_difficulty 玩家选择挑战难度,难度为:"..difficulty)
ScriptLib.SetGroupVariableValue(context,"difficulty",difficulty)
--拉起Gallery
local gallery_id = evt.param1
local_defs.gallery_id = gallery_id
LF_Start_Play(context,difficulty,gallery_id)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_select_difficulty 拉起GalleryID="..gallery_id)
ScriptLib.SetGroupVariableValue(context,"GM_Select_Difficulty",0)
--测试:每1秒显示一次血量
ScriptLib.InitTimeAxis(context,"Sand_Flow",{1},true)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_select_difficulty开启测试时间轴")
return 0
end
--白盒版本修改GM后开始加载
function action_variable_change_GM(context,evt)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_variable_change_GM 玩家选择挑战难度加载对应suite")
if evt.source_name == "GM_Select_Difficulty" and evt.param1 ~= 0 then
local difficulty = evt.param1
--local difficulty = evt.param3
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_variable_change_GM 玩家选择挑战难度,难度为:"..difficulty)
ScriptLib.SetGroupVariableValue(context,"difficulty",difficulty)
local gallery_id = 32001
local_defs.gallery_id = gallery_id
LF_Start_Play(context,difficulty,gallery_id)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_variable_change_GM 拉起默认GalleryID="..gallery_id)
ScriptLib.SetGroupVariableValue(context,"GM_Select_Difficulty",0)
ScriptLib.InitTimeAxis(context,"Sand_Flow",{1},true)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_variable_change_GM开启测试时间轴")
end
return 0
end
function action_group_will_unload(context,evt)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_group_will_unloadgroup即将卸载回滚所有玩法状态")
LF_Stop_Play(context)
return 0
end
function action_monster_die(context,evt)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_monster_die: 怪物死亡")
local difficulty = ScriptLib.GetGroupVariableValue(context,"difficulty")
if evt.param1 == PlayerElectrohercules then
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_monster_die: 角色死亡,失败")
ScriptLib.StopGallery(context,local_defs.gallery_id,true)
end
if evt.param1 == EnemyElectrohercules[difficulty] then
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_monster_die: 敌人死亡,成功")
ScriptLib.StopGallery(context,local_defs.gallery_id,false)
end
--运营埋点获得结束时敌我双方的生命值百分比
local PlayerHP = ScriptLib.GetMonsterHpPercent(context, base_info.group_id, PlayerElectrohercules)
local EnemyHP = ScriptLib.GetMonsterHpPercent(context, base_info.group_id, EnemyElectrohercules[difficulty])
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] action_monster_die: 对局结束,玩家生命:"..PlayerHP.."% 敌方生命:"..EnemyHP.."%")
ScriptLib.MarkGroupLuaAction(context, "ElectroherculesBattleEnd", "", {["self_hp"] = PlayerHP,["enemy_hp"] = EnemyHP})
LF_Stop_Play(context)
return 0
end
------------------------------------------------------------------
function LF_Start_Play(context, difficulty, gallery_id)
--改变斗虫台stage增加空气墙
ScriptLib.SetGroupGadgetStateByConfigId(context, Battlefield.group_id, Battlefield.config_id, 201)
--屏蔽天气
ScriptLib.SetWeatherAreaState(context, weather_id, 1)
--创建敌我Monster
ScriptLib.CreateMonster(context, { config_id = PlayerElectrohercules, delay_time = 0 })
local ret = ScriptLib.CreateMonster(context, { config_id = EnemyElectrohercules[difficulty], delay_time = 0 })
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] LF_Start_Play: 创建敌人结果为"..ret)
--拉起Gallery
ScriptLib.StartGallery(context,gallery_id)
--ScriptLib.StartGallery(context,defs.gallery_id)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] LF_Start_Play: 拉起GalleryID="..gallery_id)
end
function LF_Stop_Play(context)
ScriptLib.PrintContextLog(context,"## [ElectroherculesBattle] LF_Stop_Play开始重置玩法")
ScriptLib.RemoveEntityByConfigId(context,base_info.group_id,EntityType.MONSTER, PlayerElectrohercules)
for k,v in pairs(EnemyElectrohercules) do
ScriptLib.RemoveEntityByConfigId(context,base_info.group_id,EntityType.MONSTER, v)
end
--移除空气墙
ScriptLib.SetGroupGadgetStateByConfigId(context, Battlefield.group_id,Battlefield.config_id , 0)
--开启天气
ScriptLib.SetWeatherAreaState(context, weather_id, 0)
ScriptLib.SetGroupVariableValue(context,"difficulty",0)
--移除测试时间轴
ScriptLib.EndTimeAxis(context,"Sand_Flow")
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,146 @@
--[[======================================
|| filename: JamshidRock
|| owner: luyao.huang
|| description: 3.3赤王基石玩法
|| LogName: JamshidRock
|| Protection:
=======================================]]--
------
local local_defs = {
changing_cd = 1
}
local rock_gadget_id =
{
70290635,
70290636,
70290637
}
local state_solution_defs =
{
[0] = 1,
[201] = 2,
[202] = 3,
[203] = 4
}
local solution_state_defs =
{
[1] = 0,
[2] = 201,
[3] = 202,
[4] = 203
}
local Tri = {
[1] = { name = "gadget_state_change", config_id = 10000001, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
[2] = { name = "time_axis_pass", config_id = 10000002, event = EventType.EVENT_TIME_AXIS_PASS, source = "changing_cd", condition = "", action = "action_time_axis_pass", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for i = 1, #JamshidRocks do
local rock = JamshidRocks[i]
gadgets[rock].server_global_value_config = { ["SGV_Correct_Answer"] = CorrectAnswer[i] }
end
table.insert(variables,{ config_id = 100010001, name = "is_success", value = 0})
table.insert(variables,{ config_id = 100010002, name = "is_changing", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_gadget_state_change(context,evt)
local flag = false
for i = 1, #JamshidRocks do
if evt.param2 == JamshidRocks[i] then
flag = true
end
end
if flag then
ScriptLib.PrintContextLog(context,"## [JamshidRock] action_gadget_state_change: 赤王基石"..evt.param2.."状态变化")
local is_success = true
for i = 1, #JamshidRocks do
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,JamshidRocks[i])
if state_solution_defs[state] ~= nil then
ScriptLib.PrintContextLog(context,"## [JamshidRock] action_gadget_state_change: 正确解为"..CorrectAnswer[i])
ScriptLib.PrintContextLog(context,"## [JamshidRock] action_gadget_state_change: 当前解为"..state_solution_defs[state])
if state_solution_defs[state] ~= CorrectAnswer[i] then
is_success = false
end
end
end
if is_success then
ScriptLib.PrintContextLog(context,"## [JamshidRock] action_gadget_state_change: 玩法成功")
ScriptLib.SetGroupVariableValue(context,"is_success",1)
else
ScriptLib.SetGroupVariableValue(context,"is_success",0)
end
end
return 0
end
function action_time_axis_pass(context,evt)
ScriptLib.PrintContextLog(context,"## [JamshidRock] action_time_axis_pass: 基石cd时间轴tick允许继续变化")
ScriptLib.SetGroupVariableValue(context,"is_changing",0)
for i = 1, #JamshidRocks do
ScriptLib.SetEntityServerGlobalValueByConfigId(context,JamshidRocks[i],"SGV_Show_Hit_Effect",0)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
function SLC_Rock_Being_Hit(context)
for i = 1, #JamshidRocks do
if context.source_entity_id == ScriptLib.GetEntityIdByConfigId(context, JamshidRocks[i]) then
local rock = JamshidRocks[i]
ScriptLib.PrintContextLog(context,"## [JamshidRock] SLC_Rock_Being_Hit: 赤王基石"..JamshidRocks[i].."受击")
local is_changeing = ScriptLib.GetGroupVariableValue(context,"is_changing")
if is_changeing == 0 then
ScriptLib.PrintContextLog(context,"## [JamshidRock] SLC_Rock_Being_Hit: 当前没有基石处于变化状态")
ScriptLib.SetGroupVariableValue(context,"is_changing",1)
ScriptLib.InitTimeAxis(context,"changing_cd",{local_defs.changing_cd},false)
ScriptLib.PrintContextLog(context,"## [JamshidRock] SLC_Rock_Being_Hit: 开启基石cd时间轴")
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,rock)
local current_answer = state_solution_defs[state]
ScriptLib.PrintContextLog(context,"## [JamshidRock] SLC_Rock_Being_Hit: 当前答案为"..current_answer)
local next_answer = ((current_answer)%4)+1
ScriptLib.PrintContextLog(context,"## [JamshidRock] SLC_Rock_Being_Hit: 下一个答案为"..next_answer)
local next_state = solution_state_defs[next_answer]
ScriptLib.SetGadgetStateByConfigId(context,rock,next_state)
ScriptLib.PrintContextLog(context,"## [JamshidRock] SLC_Rock_Being_Hit: 基石切状态"..next_state)
ScriptLib.SetEntityServerGlobalValueByConfigId(context,rock,"SGV_Show_Hit_Effect",1)
end
return 0
end
end
return 0
end
Initialize()

View File

@@ -0,0 +1,173 @@
--[[======================================
|| filename: MetaRegion
|| owner: luyao.huang
|| description: 3.3MetaRegion逻辑由多个region拼成的大型region
|| LogName: MetaRegion
|| Protection:
=======================================]]--
--是否属于特定大区域
function LF_Is_In_Meta_Region(context,uid,metaRegionName)
local metaRegion = MetaRegions[metaRegionName]
if metaRegion == nil then
ScriptLib.PrintGroupWarning(context,"## [Warning] [SandstormControl] LF_Is_In_Meta_Region传入非法MetaRegion名"..metaRegionName)
return nil
end
for k,v in pairs(metaRegion) do
if ScriptLib.IsInRegion(context,uid,v) == true then
return true
end
end
return false
end
--获取特定玩家当前所在沙尘暴区域的名字
function LF_Get_SandStorm_Region(context,uid)
if LF_Is_In_Meta_Region(context,uid,"SandStorm_InnerRegion") then
return "SandStorm_InnerRegion"
end
if LF_Is_In_Meta_Region(context,uid,"SandStorm_MiddleRegion") then
return "SandStorm_MiddleRegion"
end
if LF_Is_In_Meta_Region(context,uid,"SandStorm_OuterRegion") then
return "SandStorm_OuterRegion"
end
return "SandStorm_Outside"
end
--是否处于沙尘暴区域
function LF_Is_In_SandStorm_Region(context,uid)
if LF_Get_SandStorm_Region(context,uid) ~= nil and LF_Get_SandStorm_Region(context,uid) ~= "SandStorm_Outside" then
return true
end
return false
end
--是否位于合法的沙虫区域计算了沙虫区域的洞
function LF_Is_In_Legal_Sandworm_Region(context,uid)
if LF_Is_In_Meta_Region(context,uid,"SandwormRegion") and not LF_Is_In_Meta_Region(context,uid,"SandwormHoleRegion") then
return true
end
return false
end
--获取第一个合法的在沙尘暴区域内的玩家uid支持联机从主机开始往后排
function LF_Get_Legal_Player_Uid_In_SandStorm_Region(context)
local uid_list = ScriptLib.GetSceneUidList(context)
for i = 1, #uid_list do
local uid = uid_list[i]
if LF_Is_In_SandStorm_Region(context,uid) then
return uid
end
end
--无人在沙尘暴中
return -1
end
--获取第一个合法的在沙尘暴区域内的玩家所在的圈支持联机从主机开始往后排
function LF_Get_Legal_Player_Region_In_SandStorm_Region(context)
local uid = LF_Get_Legal_Player_Uid_In_SandStorm_Region(context)
if uid ~= -1 then
return LF_Get_SandStorm_Region(context,uid)
else
return "SandStorm_Outside"
end
end
--是否至少有一个人在沙尘暴区域内
function LF_Is_Any_Player_In_SandStorm_Region(context)
return LF_Get_Legal_Player_Uid_In_SandStorm_Region(context) ~= -1
end
--找到所有在沙尘暴区域内的玩家支持联机
function LF_Get_All_Player_Uid_In_SandStorm_Region(context)
local uid_list = ScriptLib.GetSceneUidList(context)
local ret_uid_list = {}
for i = 1, #uid_list do
local uid = uid_list[i]
if LF_Is_In_SandStorm_Region(context,uid) then
table.insert(ret_uid_list,uid)
end
end
return ret_uid_list
end
function LF_Get_All_Legal_Player_Uid_In_Legal_Sandworm_Region(context)
local player_in_sandstorm_list = LF_Get_All_Player_Uid_In_SandStorm_Region(context)
local ret_uid_list = {}
for i = 1, #player_in_sandstorm_list do
local uid = player_in_sandstorm_list[i]
if LF_Is_In_Legal_Sandworm_Region(context,uid) then
table.insert(ret_uid_list,uid)
end
end
return ret_uid_list
end
--获取第一个合法的在沙虫区域内的玩家uid支持联机随机抽取一个
function LF_Get_Legal_Player_Uid_In_Legal_Sandworm_Region(context)
local player_in_sandstorm_list = LF_Get_All_Player_Uid_In_SandStorm_Region(context)
local ret_uid_list = {}
for i = 1, #player_in_sandstorm_list do
local uid = player_in_sandstorm_list[i]
if LF_Is_In_Legal_Sandworm_Region(context,uid) then
table.insert(ret_uid_list,uid)
end
end
if #ret_uid_list ~= 0 then
return LF_Get_Random_Value_In_Table(ret_uid_list)
else
return -1
end
end
--判断是否有玩家位于合法沙虫区域内
function LF_Is_Any_Player_In_Legal_Sandworm_Region(context)
return LF_Get_Legal_Player_Uid_In_Legal_Sandworm_Region(context) ~= -1
end
--判断一个config_id的region是否是特定的区域region
function LF_Is_Region_Specific_Region(context,region_name,region_id)
return LF_Is_In_Table(MetaRegions[region_name], region_id)
end
--判断元素是否属于表
function LF_Is_In_Table(t,key)
for i = 1,#t do
if (t[i] == key) then
return true
end
end
return false
end
--从table中随机抽取一个元素均匀分布
function LF_Get_Random_Value_In_Table(t)
local r = math.random(#t)
return t[r]
end

View File

@@ -0,0 +1,481 @@
--[[======================================
|| filename: OasisTimebackControl
|| owner: luyao.huang
|| description: 绿洲时间倒流控制
|| LogName: OasisTimebackControl
|| Protection:
=======================================]]--
------
local local_defs = {
timeback_tag_sgv_name = "SGV_Broadcast_GV_Tag",
timeback_is_revert = "SGV_Is_Revert",
timeback_init_sgv_name = "SGV_Init_Timeback_Value",
--控制器分段的均分数
timeback_division_sgv_name = "SGV_Timeback_Keypoint_Division",
timeback_value_min_suffix = "timeback_value_min",
timeback_value_max_suffix = "timeback_value_max",
timeback_UI_option = 5002,
rune_start_option = 5000
}
local local_timeback_gadget_config =
{
--树干
[70290603] =
{
timeback_type =
{
animator = true,
effect = true
},
eff_range = {1,1.1},
},
--石头
[70290604] =
{
timeback_type =
{
animator = true,
effect = true
},
eff_range = {0,1.2},
},
--瀑布
[70290605] =
{
timeback_type =
{
shader = true,
},
},
}
local rune_states =
{
moving = 0,
unmovable = 201,
movable = 202
}
local worktop_states =
{
rune_out = 0,
rune_in = 201
}
local Tri = {
[1] = { name = "group_load", config_id = 11000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "platform_arrival", config_id = 11000002, event = EventType.EVENT_PLATFORM_ARRIVAL, source = tostring(timeback_rune), condition = "", action = "action_platform_arrival", trigger_count = 0},
[3] = { name = "select_option", config_id = 11000003, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[4] = { name = "gadget_state_change", config_id = 11000004, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
[5] = { name = "variable_change", config_id = 11000005, event = EventType.EVENT_VARIABLE_CHANGE, source = "is_success", condition = "", action = "action_variable_change", trigger_count = 0},
[6] = { name = "gather", config_id = 11000006, event = EventType.EVENT_GATHER, source = tostring(defs.wordle_id), condition = "", action = "action_gather", trigger_count = 0},
[7] = { name = "variable_change_GM", config_id = 21000001, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change_GM", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--当前符文所在节点的id
table.insert(variables,{ config_id = 30000001, name = "current_checkpoint", value = 0})
--玩法最后一环是否成功
table.insert(variables,{ config_id = 30000002, name = "is_success", value = 0})
--当前节点是否在正确解的范围内
table.insert(variables,{ config_id = 30000003, name = "is_currect_checkpoint_success", value = 0})
--玩法是否完成
table.insert(variables,{ config_id = 30000004, name = "is_finished", value = 0})
--GM移除全部玩法物件
table.insert(variables,{ config_id = 40000001, name = "GM_Remove_Current_Group", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--玩法加载初始化
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]action_group_loadgroup加载给玩法物件上SGV标识")
--LF_Init_Timeback_Gadget_Config(context)
LF_Init_Rune_State(context)
ScriptLib.SetGadgetEnableInteract(context,base_info.group_id,defs.wordle_id,false)
if ScriptLib.GetGroupVariableValue(context,"is_finished") == 1 then
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]action_variable_change玩法成功创建宝箱")
ScriptLib.CreateGadget(context, { config_id = defs.chest_id })
end
return 0
end
function action_platform_arrival(context,evt)
if LF_Is_Checkpoint(context,evt.param3) then
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]action_platform_arrival符文抵达底座位置")
LF_Stop_Platform(context)
local current_point = LF_Get_Checkpoint_By_Route_Point(context,evt.param3)
ScriptLib.SetGroupVariableValue(context,"current_checkpoint", current_point)
LF_On_Rune_Enter_Worktop(context)
end
return 0
end
function action_select_option(context,evt)
if evt.param2 == local_defs.rune_start_option then
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]action_select_option按下选项符文开始移动")
LF_Start_Platform(context)
--允许符文开始的时候不在底座上所以要判一下是否有操作台
LF_On_Rune_Leave_Worktop(context)
end
return 0
end
function action_gadget_state_change(context,evt)
if evt.param2 == timeback_rune then
if evt.param1 == rune_states.movable then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, timeback_rune, {local_defs.rune_start_option})
else
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, timeback_rune, local_defs.rune_start_option)
end
end
return 0
end
function action_variable_change(context,evt)
if evt.param1 == 1 then
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]action_variable_change玩法成功打开赤王文字交互")
ScriptLib.SetGadgetEnableInteract(context,base_info.group_id,defs.wordle_id,true)
end
if evt.param1 == 0 then
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]action_variable_change玩法失败关闭赤王文字交互")
ScriptLib.SetGadgetEnableInteract(context,base_info.group_id,defs.wordle_id,false)
end
return 0
end
function action_gather(context,evt)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]action_gather赤王文字被取走加载宝箱")
ScriptLib.SetGroupVariableValue(context,"is_finished",1)
ScriptLib.CreateGadget(context,{config_id = defs.chest_id})
return 0
end
function action_variable_change_GM(context,evt)
if evt.source_name == "GM_Remove_Current_Group" then
for k,v in pairs(gadgets) do
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, v.config_id)
end
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Init_Timeback_Gadget_Config(context)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Init_Timeback_Gadget_Config初始化倒流物件配置")
for k,v in pairs(timeback_gadget_config) do
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Init_Timeback_Gadget_Config倒流物件为"..k)
local range = v.range
if range ~= nil then
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Init_Timeback_Gadget_Config动画时间范围为"..range[1].."~"..range[2])
end
ScriptLib.SetEntityServerGlobalValueByConfigId(context, k , local_defs.timeback_tag_sgv_name, timeback_play_tag)
if v.is_revert then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, k , local_defs.timeback_is_revert, 1)
end
--animator和shader倒流描述的是entity本身的倒流方式
if LF_Has_Ani_Timeback(context,k) then
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Init_Timeback_Gadget_Config上动画范围的SGV"..range[1].."~"..range[2])
local ret = ScriptLib.SetEntityServerGlobalValueByConfigId(context,k,"SGV_ani_"..local_defs.timeback_value_min_suffix, range[1])
ScriptLib.SetEntityServerGlobalValueByConfigId(context,k,"SGV_ani_"..local_defs.timeback_value_max_suffix, range[2])
end
if LF_Has_Shader_Timeback(context,k) then
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Init_Timeback_Gadget_Config上shader范围的SGV"..range[1].."~"..range[2])
ScriptLib.SetEntityServerGlobalValueByConfigId(context,k,"SGV_shader_"..local_defs.timeback_value_min_suffix, range[1])
ScriptLib.SetEntityServerGlobalValueByConfigId(context,k,"SGV_shader_"..local_defs.timeback_value_max_suffix, range[2])
end
--effect描述的是外加的资源的倒流方式
if LF_Has_Eff_Timeback(context,k) then
local eff_range = LF_Get_Effect_Timeback_Value_Config(context,k)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Init_Timeback_Gadget_Config特效时间范围为"..eff_range[1].."~"..eff_range[2])
ScriptLib.SetEntityServerGlobalValueByConfigId(context,k,"SGV_eff_"..local_defs.timeback_value_min_suffix, eff_range[1])
ScriptLib.SetEntityServerGlobalValueByConfigId(context,k,"SGV_eff_"..local_defs.timeback_value_max_suffix, eff_range[2])
end
end
--给控制器上玩法tag和初始化值
ScriptLib.SetEntityServerGlobalValueByConfigId(context, timeback_controller , local_defs.timeback_tag_sgv_name, timeback_play_tag)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, timeback_controller , local_defs.timeback_init_sgv_name, init_timeback_value)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, timeback_controller , local_defs.timeback_division_sgv_name, 4)
--给操作台上玩法tag
for i = 1, #timeback_worktops do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, timeback_worktops[i] , local_defs.timeback_tag_sgv_name, timeback_play_tag)
end
end
function LF_Init_Rune_State(context)
--重置一次符文所在位置
ScriptLib.SetGroupVariableValue(context,"current_checkpoint",0)
if LF_Can_Move_To_Next_Point(context) then
LF_Set_Rune_State(context,rune_states.movable)
else
LF_Set_Rune_State(context,rune_states.unmovable)
end
end
--当符文离开底座时调用
function LF_On_Rune_Leave_Worktop(context)
local worktop = LF_Get_Current_Worktop(context)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_On_Rune_Leave_Worktop符文离开底座"..worktop)
LF_Set_Rune_State(context,rune_states.moving)
local current_point = LF_Get_Current_Point(context)
--允许开始的出发点符文不在底座上因此不需要触发底座的状态变化
if LF_Current_Point_Has_Worktop(context,current_point) then
LF_Set_Worktop_State(context,worktop_states.rune_out)
end
end
--当符文进入底座时调用
function LF_On_Rune_Enter_Worktop(context)
local worktop = LF_Get_Current_Worktop(context)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_On_Rune_Enter_Worktop符文进入底座"..worktop)
--只要符文进入底座就要给底座上显示时间控制UI的选项
LF_Set_Worktop_State(context,worktop_states.rune_in)
--进入底座时先默认不能移动由客户端自己判断当前的值是否处于合法范围
LF_Set_Rune_State(context,rune_states.unmovable)
if LF_Can_Move_To_Next_Point(context) then
LF_Set_Rune_State(context,rune_states.movable)
else
LF_Set_Rune_State(context,rune_states.unmovable)
end
end
--检查下一个目标点如果目标点有正解范围那么给操作台上正解范围等客户端调整到正解
--如果没有正解范围则直接上一个可移动的选项
function LF_Can_Move_To_Next_Point(context)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Can_Move_To_Next_Point检查是否可以移动到下一个点")
local current_point = LF_Get_Current_Point(context)
if not LF_Current_Point_Has_Worktop(context,current_point) then
return true
else
return ScriptLib.GetGroupVariableValue(context,"is_currect_checkpoint_success") == 1
end
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Has_Ani_Timeback(context, config_id)
local gadget_id = LF_Get_Gadget_Id_By_Config_Id(context, config_id)
return local_timeback_gadget_config[gadget_id].timeback_type.animator
end
function LF_Has_Eff_Timeback(context, config_id)
local gadget_id = LF_Get_Gadget_Id_By_Config_Id(context, config_id)
return local_timeback_gadget_config[gadget_id].timeback_type.effect
end
function LF_Has_Shader_Timeback(context, config_id)
local gadget_id = LF_Get_Gadget_Id_By_Config_Id(context, config_id)
return local_timeback_gadget_config[gadget_id].timeback_type.shader
end
function LF_Get_Current_Point(context)
return ScriptLib.GetGroupVariableValue(context,"current_checkpoint")
end
function LF_Set_Current_Point(context,point_id)
ScriptLib.SetGroupVariableValue(context,"current_checkpoint", point_id)
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
function LF_Get_Effect_Timeback_Value_Config(context,config_id)
local gadget_id = LF_Get_Gadget_Id_By_Config_Id(context, config_id)
local eff_range = local_timeback_gadget_config[gadget_id].eff_range
local ani_range = timeback_gadget_config[config_id].range
local is_revert = timeback_gadget_config[config_id].is_revert
if is_revert then
eff_range[1] = 1 - eff_range[2]
eff_range[2] = 1 - eff_range[1]
end
local actual_max = ani_range[1] + (ani_range[2] - ani_range[1]) * eff_range[2]
local actual_min = ani_range[1] + (ani_range[2] - ani_range[1]) * eff_range[1]
return {actual_min,actual_max}
end
function LF_Is_Checkpoint(context,point_id)
for i = 1, #checkpoints_to_route_points do
if checkpoints_to_route_points[i] == point_id then
return true
end
end
return false
end
function LF_Get_Checkpoint_By_Route_Point(context,route_point)
for k,v in pairs(checkpoints_to_route_points) do
if v == route_point then
return k
end
end
return 0
end
function LF_Current_Point_Has_Worktop(context,point_id)
return checkpoint_to_worktops[point_id] ~= nil
end
function LF_Get_Current_Worktop(context)
local current_point = LF_Get_Current_Point(context)
if LF_Current_Point_Has_Worktop(context,current_point) then
return checkpoint_to_worktops[current_point]
else
return 0
end
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Is_In_Table(context,t,value)
for k,v in pairs(t) do
if v == value then
return true
end
end
return false
end
function LF_Start_Platform(context)
local current_checkpoint = ScriptLib.GetGroupVariableValue(context,"current_checkpoint")
if current_checkpoint >= #checkpoints_to_route_points then
return
end
local target_point = current_checkpoint + 1
local start_array_point = 0
if current_checkpoint > 0 then
start_array_point = checkpoints_to_route_points[current_checkpoint]
end
local target_array_point = checkpoints_to_route_points[target_point]
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Start_Platform当前所在点为"..start_array_point)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Start_Platform目标点为"..target_array_point)
local route = {}
for i = start_array_point+1, target_array_point do
table.insert(route,i)
end
ScriptLib.SetPlatformPointArray(context,timeback_rune, defs.pointarray_route, route, { route_type = 0,turn_mode=false})
end
function LF_Stop_Platform(context)
ScriptLib.StopPlatform(context,timeback_rune)
end
function LF_Set_Worktop_State(context,state)
local current_point = ScriptLib.GetGroupVariableValue(context,"current_checkpoint")
local current_worktop = checkpoint_to_worktops[current_point]
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Set_Worktop_State操作台"..current_worktop.."设置为状态"..state)
ScriptLib.SetGadgetStateByConfigId(context,current_worktop,state)
end
function LF_Set_Rune_State(context,state)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]LF_Set_Rune_State符文石设置为状态"..state)
ScriptLib.SetGadgetStateByConfigId(context,timeback_rune,state)
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
function SLC_Set_Current_Checkpoint_Correctness(context,is_correct)
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]SLC_Set_Current_Checkpoint_Correctness上报当前节点是否正确"..is_correct)
ScriptLib.SetGroupVariableValue(context,"is_currect_checkpoint_success",is_correct)
local current_checkpoint = ScriptLib.GetGroupVariableValue(context,"current_checkpoint")
if current_checkpoint >= #checkpoints_to_route_points then
ScriptLib.PrintContextLog(context,"## [OasisTimebackControl]SLC_Set_Current_Checkpoint_Correctness已经移动到终点玩法完成")
ScriptLib.SetGroupVariableValue(context,"is_success",is_correct)
end
if LF_Can_Move_To_Next_Point(context) then
LF_Set_Rune_State(context,rune_states.movable)
else
LF_Set_Rune_State(context,rune_states.unmovable)
end
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,515 @@
--[[======================================
|| filename: SandPipe
|| owner: luyao.huang
|| description: 3.3流沙管道
|| LogName: SandPipe
|| Protection:
=======================================]]--
------
local local_defs = {
base_interval = 1,
option_active = 5000,
option_deactive = 5001,
option_redirection = 5002,
}
local worktop_state_def =
{
deactive = 0,
active = 201,
locked = 202
}
local I_connector_state_def =
{
deactive = 0,
active = 201
}
local L_connector_state_def =
{
deactive = 0,
active_1 = 201,
active_2 = 202
}
local container_state_def =
{
deactive = 0,
active = 201
}
local light_state_def =
{
deactive = 0,
active = 201
}
local Tri = {
[1] = { name = "group_load", config_id = 10000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "gadget_state_change", config_id = 10000002, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
[3] = { name = "select_option", config_id = 10000003, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[4] = { name = "time_axis_pass", config_id = 10000004, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"## [SandPipe] action_group_load流沙管道group加载")
LF_Start_Sand_Flow(context,0)
return 0
end
function action_gadget_state_change(context,evt)
if LF_Is_Connector(context,evt.param2) then
ScriptLib.PrintContextLog(context,"## [SandPipe] action_gadget_state_change连接器"..evt.param2.."状态变化")
LF_Start_Sand_Flow(context,evt.param2)
end
if LF_Is_Worktop(context,evt.param2) and evt.param3 == worktop_state_def.locked and evt.param1 == worktop_state_def.deactive then
ScriptLib.PrintContextLog(context,"## [SandPipe] action_gadget_state_change操作台解锁")
if not LF_Is_In_Sandflow(context) then
--当操作台的状态从202转到0状态时说明操作台被解锁如果当前不在流沙状态就上选项否则等流沙结束统一上选项
local worktop = evt.param2
LF_Set_Worktop_Option_State(context,worktop,true)
end
end
return 0
end
function action_select_option(context,evt)
local worktop = evt.param1
if evt.param2 == local_defs.option_active then
local connector = LF_Get_Connector_By_Worktop(context,evt.param1)
ScriptLib.SetGadgetStateByConfigId(context,connector,I_connector_state_def.active)
ScriptLib.SetGadgetStateByConfigId(context,worktop,worktop_state_def.active)
end
if evt.param2 == local_defs.option_deactive then
local connector = LF_Get_Connector_By_Worktop(context,evt.param1)
ScriptLib.SetGadgetStateByConfigId(context,connector,I_connector_state_def.deactive)
ScriptLib.SetGadgetStateByConfigId(context,worktop,worktop_state_def.deactive)
end
if evt.param2 == local_defs.option_redirection then
local connector = LF_Get_Connector_By_Worktop(context,evt.param1)
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,connector)
ScriptLib.SetGadgetStateByConfigId(context,worktop,worktop_state_def.active)
if state == L_connector_state_def.active_1 then
ScriptLib.SetGadgetStateByConfigId(context,connector,L_connector_state_def.active_2)
elseif state == L_connector_state_def.active_2 then
ScriptLib.SetGadgetStateByConfigId(context,connector,L_connector_state_def.active_1)
end
end
return 0
end
function action_time_axis_pass(context,evt)
ScriptLib.PrintContextLog(context,"## [SandPipe] action_time_axis_pass时间轴tick名字为"..evt.source_name)
if string.sub(evt.source_name,0,10) == "container_" then
ScriptLib.PrintContextLog(context,"## [SandPipe] action_time_axis_pass链路时间轴tick当前为链路上第"..evt.param1.."个物件")
local container_id = tonumber(string.sub(evt.source_name,11,-1))
local between_stream = LF_Get_Stream_From_First_Inactive_Light(context,container_id)
--时间轴tick次数即亮到了stream上的第几个灯
local k = evt.param1
if LF_Is_Light(context,between_stream[1]) then
ScriptLib.SetGadgetStateByConfigId(context,between_stream[1],light_state_def.active)
end
if LF_Is_Container(context,between_stream[1]) then
ScriptLib.PrintContextLog(context,"## [SandPipe] action_time_axis_pass链路时间轴结束链路上所有物件状态转换完毕")
ScriptLib.SetGadgetStateByConfigId(context,between_stream[1],container_state_def.active)
local axis_num = ScriptLib.GetGroupTempValue(context,"active_axis_num",{})
axis_num = axis_num - 1
ScriptLib.ChangeGroupTempValue(context,"active_axis_num",-1,{})
if axis_num <= 0 then
ScriptLib.PrintContextLog(context,"## [SandPipe] action_time_axis_pass所有时间轴结束本次流沙结束")
LF_Stop_Sand_Flow(context)
end
end
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Start_Sand_Flow(context,connector_id)
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Start_Sand_Flow开始本次流沙本次流沙来源于连接器"..connector_id)
LF_Hide_Option(context)
--检查所有通路找到因这次转换连接器而发生联通变化的通路
local flag = true
ScriptLib.SetGroupTempValue(context,"active_axis_num",0,{})
for k,v in pairs(streams) do
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Start_Sand_Flow检查容器"..k.."对应的链路")
local container_state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,k)
local is_connected = LF_Is_Container_Connected(context,k)
--如果这次改动连接上了容器且容器之前状态为0
--将改动的连接器到容器间的所有灯顺次点亮
if is_connected and container_state == container_state_def.deactive then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Start_Sand_Flow容器"..k.."为空,且链路联通了")
flag = false
local stream = LF_Get_Stream_From_First_Inactive_Light(context,k)
local axis = LF_Create_Stream_Axis(context,stream)
ScriptLib.InitTimeAxis(context,"container_"..k,axis,false)
ScriptLib.ChangeGroupTempValue(context,"active_axis_num",1,{})
end
--如果这次改动断开了容器且容器之前状态为201
--将改动的连接器到容器间的所有灯立刻熄灭
if not is_connected and container_state == container_state_def.active then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Start_Sand_Flow容器"..k.."为满,且链路断开了")
local stream = LF_Get_Stream_From_Origin(context,k)
for i = 1, #stream do
--检查当前灯是否在当前任何已联通的链路中如果是则无事发生
if not LF_Is_In_Connected_Stream(context,stream[i]) then
ScriptLib.SetGadgetStateByConfigId(context,stream[i],light_state_def.deactive)
end
end
end
end
if flag then
LF_Stop_Sand_Flow(context)
end
end
function LF_Stop_Sand_Flow(context)
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Stop_Sand_Flow结束本次流沙")
LF_Show_Option(context)
end
function LF_Show_Option(context)
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Show_Option显示选项")
local connectors = LF_Get_All_Connectors(context)
for k,v in pairs(connectors) do
local worktop = connector_to_worktop[v]
--允许有的connector没有对应的worktop用其他方式解锁如果没找到对应worktop就跳过去
if worktop ~= nil then
LF_Set_Worktop_Option_State(context,worktop,true)
end
end
end
function LF_Hide_Option(context)
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Hide_Option隐藏选项")
local connectors = LF_Get_All_Connectors(context)
for k,v in pairs(connectors) do
local worktop = connector_to_worktop[v]
--允许有的connector没有对应的worktop用其他方式解锁如果没找到对应worktop就跳过去
if worktop ~= nil then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State从连接器"..v.."对应的操作台清除选项")
LF_Set_Worktop_Option_State(context,worktop,false)
else
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State没有找到连接器"..v.."对应的操作台,直接返回")
end
end
end
function LF_Set_Worktop_Option_State(context,worktop,enable)
local connector = LF_Get_Connector_By_Worktop(context,worktop)
--允许有的connector没有对应的worktop用其他方式解锁如果没找到对应worktop就跳过去
if connector == nil then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State没有找到操作台"..worktop.."对应的连接器,直接返回")
return
end
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,connector)
local worktop_state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,worktop)
if enable then
--如果操作台状态是202那么说明操作台未解锁不能上选项
if worktop_state ~= worktop_state_def.locked then
if LF_Get_Connector_Type(context,connector) == "I" then
if state == I_connector_state_def.deactive then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State在I型连接器"..worktop.."添加激活选项")
ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,worktop,{local_defs.option_active})
end
--if state == I_connector_state_def.active then
-- ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,worktop,{local_defs.option_deactive})
--end
else
if state == L_connector_state_def.deactive then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State在L型连接器"..worktop.."添加激活选项")
ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,worktop,{local_defs.option_active})
end
if state == L_connector_state_def.active_1 or state == L_connector_state_def.active_2 then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State在L型连接器"..worktop.."添加转向选项")
ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,worktop,{local_defs.option_redirection})
end
end
end
else
if LF_Get_Connector_Type(context,connector) == "I" then
if state == I_connector_state_def.deactive then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State从I型连接器"..worktop.."删除激活选项")
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,worktop,local_defs.option_active)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,worktop,local_defs.option_deactive)
end
if state == I_connector_state_def.active then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State从I型连接器"..worktop.."删除关闭选项")
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,worktop,local_defs.option_active)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,worktop,local_defs.option_deactive)
end
else
if state == L_connector_state_def.deactive then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State从L型连接器"..worktop.."删除激活选项")
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,worktop,local_defs.option_redirection)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,worktop,local_defs.option_active)
end
if state == L_connector_state_def.active_1 or state == L_connector_state_def.active_2 then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Set_Worktop_Option_State从L型连接器"..worktop.."删除转向选项")
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,worktop,local_defs.option_redirection)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,worktop,local_defs.option_active)
end
end
end
end
--[[-----------------------------------------------------------------
|| ||
|| 核心方法 ||
|| ||
-----------------------------------------------------------------]]--
--从源头出发找到指定container_id对应的链路上第一个未激活的物件开始向下游找到所有物件
function LF_Get_Stream_From_First_Inactive_Light(context,container_id)
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Get_Stream_From_Origin: 获取源头到容器"..container_id.."之间的第一个非激活物件开始后的所有物件")
local whole_stream = streams[container_id]
local stream = {}
for i = 1, #whole_stream do
if not LF_Is_Connector(context, whole_stream[i]) then
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,whole_stream[i])
if state == light_state_def.deactive then
table.insert(stream,whole_stream[i])
end
end
end
table.insert(stream,container_id)
return stream
end
--找到连接器和容器之间所有非连接器物件包括容器本身
function LF_Get_Stream_From_Origin(context,container_id)
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Get_Stream_From_Origin: 获取源头和容器"..container_id.."之间的所有非连接器物件")
local whole_stream = streams[container_id]
local stream = {}
for i = 1, #whole_stream do
if not LF_Is_Connector(context, whole_stream[i]) then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Get_Stream_Between_Connector_And_Container物件"..whole_stream[i])
table.insert(stream,whole_stream[i])
end
end
table.insert(stream,container_id)
return stream
end
--给定一个容器判断容器是否与源头相连
function LF_Is_Container_Connected(context,container_id)
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Is_Container_Connected检查"..container_id.."与源头是否联通")
local stream = streams[container_id]
local flag = true
for i = 1, #stream do
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,stream[i])
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Is_Container_Connected检查"..stream[i].."的状态为"..state)
if LF_Is_Connector(context,stream[i]) then
local connector_type = LF_Get_Connector_Type(context,stream[i])
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Is_Container_Connected是connector类型为"..connector_type)
if connector_type == "I" then
if state ~= I_connector_state_def.active then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Is_Container_ConnectedI型连接器"..stream[i].."是断开的")
flag = false
return false
end
elseif connector_type == "L" then
if state ~= L_connector_state_def.active_1 and state ~= L_connector_state_def.active_2 then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Is_Container_ConnectedL型连接器"..stream[i].."是断开的")
flag = false
return false
end
if i < #stream then
if L_connections[stream[i]][state] ~= stream[i+1] then
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Is_Container_ConnectedL型连接器"..stream[i].."方向不对,是断开的")
flag = false
return false
end
end
end
end
end
if flag == true then
return true
end
end
--返回一个物件是否处于一个联通的链路中
function LF_Is_In_Connected_Stream(context,config_id)
for k,v in pairs(streams) do
for i = 1, #v do
if config_id == v[i] then
if LF_Is_Container_Connected(context,k) then
return true
end
end
end
end
return false
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
--返回一个configid是否是容器
function LF_Is_Container(context,config_id)
return LF_Is_In_Table(context,containers,config_id)
end
--返回一个configid是否是连接器
function LF_Is_Connector(context,config_id)
return LF_Is_In_Table(context,I_connectors,config_id) or LF_Is_In_Table(context,L_connectors,config_id)
end
--返回一个configid是否是指示灯
function LF_Is_Light(context,config_id)
return LF_Is_In_Table(context,lights,config_id)
end
--返回一个configid是否是操作台
function LF_Is_Worktop(context,config_id)
return LF_Is_In_Table(context,worktops,config_id)
end
--是否处于流沙状态中
function LF_Is_In_Sandflow(context)
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Is_In_Sandflow当前激活的链路条数为"..ScriptLib.GetGroupTempValue(context, "active_axis_num", {base_info.group_id}))
return ScriptLib.GetGroupTempValue(context, "active_axis_num", {base_info.group_id}) > 0
end
--获取一个连接器的类型I或L
function LF_Get_Connector_Type(context,config_id)
if not LF_Is_Connector(context,config_id) then
return nil
end
if LF_Is_In_Table(context,I_connectors,config_id) then
return "I"
end
if LF_Is_In_Table(context,L_connectors,config_id) then
return "L"
end
end
--获取所有Connector的config_id表
function LF_Get_All_Connectors(context)
local connectors = {}
for k, v in pairs(I_connectors) do
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Get_All_Connectors将I型连接器"..v.."加入allconnectors")
table.insert(connectors,v)
end
for k, v in pairs(L_connectors) do
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Get_All_Connectors将L型连接器"..v.."加入allconnectors")
table.insert(connectors,v)
end
return connectors
end
function LF_Get_Connector_By_Worktop(context,worktop)
for k,v in pairs(connector_to_worktop) do
if v == worktop then
return k
end
end
return nil
end
--输入一个stream根据这个stream生成一个逐渐启动的时间轴
function LF_Create_Stream_Axis(context,stream)
local axis = {}
local axis_time = 0
for i = 1, #stream do
local flag = false
if special_interval ~= nil then
for k,v in pairs(special_interval) do
if v.upstream == stream[i] and v.downstream == stream[i+1] then
axis_time = axis_time + v.interval
flag = true
break
end
end
end
if not flag then
axis_time = axis_time + base_interval
end
table.insert(axis,axis_time)
end
return axis
end
function LF_Get_Gadget_Id_By_Config_Id(context,config_id)
for k,v in pairs(gadgets) do
if v.config_id == config_id then
return v.gadget_id
end
end
return nil
end
function LF_Is_In_Table(context,t,value)
if t == nil then
return false
end
for k,v in pairs(t) do
if v == value then
return true
end
end
return false
end
function LF_Print_Table(context,t)
for k,v in pairs(t) do
ScriptLib.PrintContextLog(context,"## [SandPipe] LF_Print_Table"..k.." : "..v)
end
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,305 @@
--[[======================================
|| filename: SandStair
|| owner: luyao.huang
|| description: 3.3流沙阶梯玩法
|| LogName: SandStair
|| Protection:
=======================================]]--
------
local local_defs = {
option_active = 5000,
option_deactive = 5001,
}
local Tri = {
[1] = { name = "group_load", config_id = 10000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "select_option", config_id = 10000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[3] = { name = "time_axis_pass", config_id = 10000003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[4] = { name = "gadget_state_change", config_id = 10000004, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
[5] = { name = "group_will_unload", config_id = 10000005, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for i = 1, #pools do
table.insert(variables,{config_id = 500001000+i, name = "sand_amount_"..pools[i], value = 0, no_refresh = true})
end
table.insert(variables,{config_id = 500000001, name = "origin_time", value = 0, no_refresh = true})
table.insert(variables,{config_id = 500000002, name = "is_in_axis", value = 0, no_refresh = true})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--玩法加载初始化
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"## [SandStair] action_group_loadgroup加载")
LF_Show_Option(context)
--断线重连或group加载时要尝试根据存档变量恢复一次玩法状态
LF_Set_All_SGV_To_Pools(context)
LF_Start_Axis(context)
return 0
end
--卸载时要保底清除状态变量
function action_group_will_unload(context,evt)
ScriptLib.SetGroupVariableValue(context,"is_in_axis",0)
ScriptLib.SetGroupVariableValue(context,"origin_time",0)
return 0
end
function action_select_option(context,evt)
local nozzole = evt.param1
if evt.param2 == local_defs.option_active then
ScriptLib.SetGadgetStateByConfigId(context,nozzole,201)
if evt.param1 == origin_defs.origin_nozzole then
LF_Set_Nozzole_Flow(context,evt.param1)
end
LF_Start_Axis(context)
end
if evt.param2 == local_defs.option_deactive then
ScriptLib.SetGadgetStateByConfigId(context,nozzole,0)
if evt.param1 == origin_defs.origin_nozzole then
LF_Set_Nozzole_Freeze(context,evt.param1)
end
end
return 0
end
function action_time_axis_pass(context,evt)
if evt.source_name == "Sand_Flow" then
LF_Run_Sand_Flow(context)
end
return 0
end
function action_gadget_state_change(context,evt)
if LF_Is_Nozzole(context,evt.param2) then
LF_Set_Option(context,evt.param2)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Start_Axis(context)
--将任何一个开关转到打开都可能会导致开始流沙因此要开时间轴算一遍
if ScriptLib.GetGroupVariableValue(context,"is_in_axis") == 0 then
ScriptLib.InitTimeAxis(context,"Sand_Flow",{1},true)
ScriptLib.SetGroupVariableValue(context,"is_in_axis",1)
ScriptLib.SetGroupVariableValue(context,"origin_time",0)
end
end
function LF_Run_Sand_Flow(context)
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,origin_defs.origin_nozzole)
local flag = true
if state == 201 then
flag = false
ScriptLib.ChangeGroupVariableValue(context,"origin_time",1)
LF_Change_Sand_Amount(context,origin_defs.origin_pool,origin_defs.origin_speed)
if ScriptLib.GetGroupVariableValue(context,"origin_time") > origin_defs.origin_time then
ScriptLib.SetGadgetStateByConfigId(context,origin_defs.origin_nozzole,0)
LF_Set_Nozzole_Freeze(context,origin_defs.origin_nozzole)
ScriptLib.SetGroupVariableValue(context,"origin_time",0)
end
end
for i = 1, #pools do
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow=================================================")
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow计算池子"..pools[i].."本次tick的沙量")
local pool = pools[i]
local flow_speed = 0
local up_nozzole = nozzoles[pool].up_nozzole
local down_nozzole = nozzoles[pool].down_nozzole
local up_nozzole_pool = pool_connections[pool].up_nozzole
local down_nozzole_pool = pool_connections[pool].down_nozzole
--如果池子不为空才会向下方流沙
if not LF_Is_Pool_Empty(context,pool) then
local flag_up = true
local flag_down = true
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow池子不为空")
--如果上喷口已激活
if LF_Is_Nozzole_Active(context,up_nozzole) then
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow上喷口处于激活状态")
--且沙量大于一定值允许上喷口流沙
if LF_Is_Up_Nozzole_Can_Flow(context,pool) then
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow上喷口流沙")
flag = false
flag_up = false
flow_speed = flow_speed + defs.up_flow_speed
LF_Set_Nozzole_Flow(context,up_nozzole)
--如果上喷口下方有沙池则修改下方沙池沙量
if up_nozzole_pool ~= 0 then
LF_Change_Sand_Amount(context,up_nozzole_pool,defs.up_flow_speed)
end
end
end
if flag_up then
LF_Set_Nozzole_Freeze(context,up_nozzole)
end
--如果下喷口已激活
if LF_Is_Nozzole_Active(context,down_nozzole) then
flag = false
flag_down = false
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow下喷口处于激活状态")
flow_speed = flow_speed + defs.down_flow_speed
LF_Set_Nozzole_Flow(context,down_nozzole)
--如果下喷口下方有沙池则修改下方沙池沙量
if down_nozzole_pool ~= 0 then
LF_Change_Sand_Amount(context,down_nozzole_pool,defs.down_flow_speed)
end
end
if flag_down then
LF_Set_Nozzole_Freeze(context,down_nozzole)
end
--如果池子已溢出还要计算溢出的沙量
if LF_Is_Pool_Full(context,pool) then
flag = false
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow池子已溢出")
flow_speed = flow_speed + defs.overflow_speed
end
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow本次流沙总量为"..flow_speed)
LF_Change_Sand_Amount(context,pool,-flow_speed)
else
LF_Set_Nozzole_Freeze(context,up_nozzole)
LF_Set_Nozzole_Freeze(context,down_nozzole)
end
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow=================================================")
end
--期间没有任何容器再有变化了本轮沙子流动结束关掉时间轴
if flag then
ScriptLib.EndTimeAxis(context, "Sand_Flow")
ScriptLib.SetGroupVariableValue(context,"is_in_axis",0)
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Run_Sand_Flow本轮沙子流动结束")
end
end
function LF_Set_All_SGV_To_Pools(context)
for k,v in pairs(pools) do
LF_Set_SGV_To_Pool(context,v)
end
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Get_Sand_Amount(context,pool)
return ScriptLib.GetGroupVariableValue(context,"sand_amount_"..pool)
end
function LF_Change_Sand_Amount(context,pool,delta)
local sand_amount = LF_Get_Sand_Amount(context,pool)
sand_amount = sand_amount + delta
if sand_amount > pool_defs.overflow_max then
sand_amount = pool_defs.overflow_max
end
if sand_amount < 0 then
sand_amount = 0
end
ScriptLib.SetGroupVariableValue(context,"sand_amount_"..pool,sand_amount)
LF_Set_SGV_To_Pool(context,pool)
end
function LF_Is_Pool_Empty(context,pool)
return LF_Get_Sand_Amount(context,pool) <= 0
end
function LF_Is_Pool_Full(context,pool)
return LF_Get_Sand_Amount(context,pool) > pool_defs.max
end
function LF_Is_Nozzole_Active(context,nozzole)
if nozzole == -1 then
return false
end
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,nozzole)
return state == 201
end
function LF_Set_Nozzole_Flow(context,nozzole)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, nozzole, "SGV_Is_Flow", 1)
end
function LF_Set_Nozzole_Freeze(context,nozzole)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, nozzole, "SGV_Is_Flow", 0)
end
function LF_Is_Up_Nozzole_Can_Flow(context,pool)
return LF_Get_Sand_Amount(context,pool) > pool_defs.up_nozzole_threshold
end
function LF_Is_Nozzole(context, config_id)
if config_id == origin_defs.origin_nozzole then
return true
end
for k,v in pairs(nozzoles) do
if v.up_nozzole == config_id or v.down_nozzole == config_id then
return true
end
end
return false
end
--给池子上面写SGV
function LF_Set_SGV_To_Pool(context,pool)
local sand_amount = LF_Get_Sand_Amount(context,pool)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pool, "SGV_Sand_Amount", sand_amount)
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Set_Option(context,config_id)
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Set_Option给"..config_id.."上选项")
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,config_id)
if state == 0 then
ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,config_id,{local_defs.option_active})
end
if state == 201 then
ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,config_id,{local_defs.option_deactive})
end
end
function LF_Show_Option(context)
ScriptLib.PrintContextLog(context,"## [SandStair] LF_Show_Option显示选项")
for k,v in pairs(nozzoles) do
if v.up_nozzole ~= -1 and v.up_nozzole ~= 0 then
LF_Set_Option(context,v.up_nozzole)
end
if v.down_nozzole ~= -1 and v.down_nozzole ~= 0 then
LF_Set_Option(context,v.down_nozzole)
end
end
LF_Set_Option(context,origin_defs.origin_nozzole)
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,611 @@
--[[======================================
|| filename: SandstormControl
|| owner: luyao.huang
|| description: 3.3沙尘爆发控制group白盒
|| LogName: SandstormControl
|| Protection:
=======================================]]--
------
local local_defs = {
forecast_time = 10
}
local sandstorm_Tri = {
[1] = { name = "group_load", config_id = 10000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "time_axis_pass", config_id = 10000002, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[3] = { name = "group_will_unload", config_id = 10000003, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
[4] = { name = "enter_region", config_id = 10000004, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false},
[101] = { name = "GM_variable_change", config_id = 11000001, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_GM_variable_change", trigger_count = 0},
}
function sandstorm_Initialize()
for k,v in pairs(sandstorm_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--1为沙尘暴中2为沙尘暴cd中
table.insert(variables,{ config_id = 20000001, name = "sandstorm_state", value = 2})
--记录上次时间轴CD或沙尘暴开启的时间
table.insert(variables,{ config_id = 20000011, name = "sandstorm_last_axis_start_time", value = 0})
--记录上次时间轴CD或沙尘暴持续的时间
table.insert(variables,{ config_id = 20000012, name = "sandstorm_last_axis_last_time", value = 0})
--记录上次时间轴CD或沙尘暴剩余时间这条仅会在group卸载时记录并在group load时恢复
table.insert(variables,{ config_id = 20000013, name = "sandstorm_last_axis_remain_time", value = -1})
--存档时间轴状态1-之前时间轴未结束正常恢复2-之前时间轴已结束下次应开启下一段时间轴
table.insert(variables,{ config_id = 20000014, name = "axis_saves_state", value = -1})
--改为1后会每3秒打印一次玩家所在region信息
table.insert(variables,{ config_id = 30000001, name = "GM_Show_Player_Region", value = 0})
--按照这个倍率缩小持续时间和CD时间方便调试
table.insert(variables,{ config_id = 30000002, name = "GM_Time_Scale_Down", value = 1})
--按照这个倍率放大持续时间和CD时间方便调试
table.insert(variables,{ config_id = 30000003, name = "GM_Time_Scale_Up", value = 1})
--改为1后立刻跳过当前的天气阶段进入下一个天气阶段
table.insert(variables,{ config_id = 30000004, name = "GM_Skip_Current_Weather", value = 0})
--改为1后无视当前天气阶段强制开启一次沙尘暴
table.insert(variables,{ config_id = 30000005, name = "GM_Force_Start_Sandstorm", value = 0})
--改为1后无视当前天气阶段强制开启一次沙尘暴CD时间
table.insert(variables,{ config_id = 30000006, name = "GM_Force_Start_Sandstorm_CD", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_time_axis_pass(context,evt)
if (evt.source_name == "SANDSTORM_CD_AXIS") then
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_time_axis_pass冷却时间tick尝试开启沙尘暴")
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_time_axis_pass圈内有玩家开启沙尘暴")
--开启沙尘暴
LF_On_Sandstorm_Start(context)
LF_Set_Time_Axis(context,"SANDSTORM_TIME_AXIS",{save_prefix = "sandstorm"})
else
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_time_axis_pass时间轴结束时圈内没有人那么保存一次时间轴状态等下次进入再开启")
--如果时间轴结束时圈内没人那么说明所有玩家都出圈了存档这个时间轴状态
LF_Save_Time_Axis(context)
end
end
if (evt.source_name == "SANDSTORM_TIME_AXIS") then
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_time_axis_pass沙尘暴时间轴tick结束沙尘暴开启冷却时间")
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_time_axis_pass圈内有玩家进入冷却时间阶段")
--停止沙尘暴
LF_On_Sandstorm_Stop(context)
LF_Set_Time_Axis(context,"SANDSTORM_CD_AXIS",{save_prefix = "sandstorm"})
LF_Set_Time_Axis(context,"SANDSTORM_FORECAST_AXIS")
else
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_time_axis_pass时间轴结束时圈内没有人那么保存一次时间轴状态等下次进入再开启")
--如果时间轴结束时圈内没人那么说明所有玩家都出圈了存档这个时间轴状态
LF_Save_Time_Axis(context)
end
end
if (evt.source_name == "SANDSTORM_FORECAST_TIME_AXIS") then
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_time_axis_pass沙尘暴预告时间轴tick向team写SGV")
local host = ScriptLib.GetSceneOwnerUid(context)
LF_Change_Team_SGV(context,host,"SGV_Is_Sandstorm_Coming",1)
end
--GM模式每3秒打印一次自己所在圈的信息
if (evt.source_name == "GM_SHOW_REGION_AXIS") and ScriptLib.GetGroupVariableValue(context,"GM_Show_Player_Region") == 1 then
local legal_uid = LF_Get_Legal_Player_Uid_In_SandStorm_Region(context)
if legal_uid ~= -1 then
local current_region = LF_Get_Legal_Player_Region_In_SandStorm_Region(context)
local is_in_sandworm_region = LF_Is_In_Legal_Sandworm_Region(context,legal_uid)
ScriptLib.PrintContextLog(context,"## [GM] =========================================")
ScriptLib.PrintContextLog(context,"## [GM] action_time_axis_pass当前圈内第一名合法玩家为"..legal_uid)
ScriptLib.PrintContextLog(context,"## [GM] action_time_axis_pass所在沙尘暴圈为"..current_region)
if is_in_sandworm_region then
ScriptLib.PrintContextLog(context,"## [GM] action_time_axis_pass在 沙虫区域中")
else
ScriptLib.PrintContextLog(context,"## [GM] action_time_axis_pass不在 沙虫区域中")
end
ScriptLib.PrintContextLog(context,"## [GM] =========================================")
else
ScriptLib.PrintContextLog(context,"## [GM] =========================================")
ScriptLib.PrintContextLog(context,"## [GM] action_time_axis_pass当前圈内没有合法玩家")
ScriptLib.PrintContextLog(context,"## [GM] =========================================")
end
end
return 0
end
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_group_loadgroup加载开启时间轴")
LF_Load_Time_Axis(context)
ScriptLib.InitTimeAxis(context,"GM_SHOW_REGION_AXIS",{3},true)
return 0
end
function action_group_will_unload(context,evt)
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_group_will_unloadgroup卸载存档时间轴")
LF_Save_Time_Axis(context)
return 0
end
function action_enter_region(context,evt)
if LF_Is_In_Table(MetaRegions["SandStorm_OuterRegion"], evt.param1 ) then
ScriptLib.PrintContextLog(context,"## [SandstormControl] action_enter_region有人进入外圈尝试恢复时间轴")
LF_Load_Time_Axis(context)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_On_Sandstorm_Start(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] ===========================================")
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_On_Sandstorm_Start沙尘暴启动")
--设置沙尘暴状态
LF_Set_Sandstorm_State_By_Name(context,"IN_STORM")
--开启沙尘暴天气
LF_Set_Sandstorm_Weather(context,true)
--启动沙虫阶段
--LF_Start_Sandworm_Phase(context)
end
function LF_On_Sandstorm_Stop(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_On_Sandstorm_Stop沙尘暴结束")
--设置沙尘暴CD中状态
LF_Set_Sandstorm_State_By_Name(context,"IN_CD")
--关闭沙尘暴天气
LF_Set_Sandstorm_Weather(context,false)
--停止沙虫阶段
--LF_Stop_Sandworm_Phase(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] ===========================================")
end
--[[-----------------------------------------------------------------
|| ||
|| 读档存档 ||
|| ||
-----------------------------------------------------------------]]--
--记录剩余时间轴CD或沙尘暴的时间
function LF_Save_Time_Axis(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Save_Time_Axis开始存储当前时间轴状态")
local current_time = ScriptLib.GetServerTime(context)
local last_start_time = ScriptLib.GetGroupVariableValue(context,"sandstorm_last_axis_start_time")
local last_last_time = ScriptLib.GetGroupVariableValue(context,"sandstorm_last_axis_last_time")
local remain_time = last_last_time - (current_time - last_start_time)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Save_Time_Axis剩余时间为"..remain_time)
if remain_time > 0.5 then
ScriptLib.SetGroupVariableValue(context,"sandstorm_last_axis_remain_time",remain_time)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Save_Time_Axis下次应恢复时间轴")
--记录存在时间轴存档状态为状态1下次应恢复时间轴
ScriptLib.SetGroupVariableValue(context,"axis_saves_state",1)
else
ScriptLib.SetGroupVariableValue(context,"sandstorm_last_axis_remain_time",0)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Save_Time_Axis下次应开启下一段时间轴")
--记录存在时间轴存档状态为状态2下次进入下一段时间轴
ScriptLib.SetGroupVariableValue(context,"axis_saves_state",2)
end
end
--恢复剩余时间轴CD或沙尘暴的时间
function LF_Load_Time_Axis(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Load_Time_Axis开始恢复当前时间轴状态")
local axis_saves_state = ScriptLib.GetGroupVariableValue(context,"axis_saves_state")
--保底防止多触发产生问题直接返回
if axis_saves_state == 0 then
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Load_Time_Axis已完成恢复 或 没有存档,无事发生")
return
end
--玩家生涯首次触发先默认开一段CD
if axis_saves_state == -1 then
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Load_Time_Axis这是玩家生涯首次进入沙尘暴区域")
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Load_Time_Axis圈内有人允许开启")
--生涯首次触发默认先开一段CD
LF_Set_Time_Axis(context,"SANDSTORM_CD_AXIS",{save_prefix = "sandstorm"})
--开一个沙尘暴预告的时间轴
LF_Set_Time_Axis(context,"SANDSTORM_FORECAST_AXIS")
--重置一下记录的时间轴状态
ScriptLib.SetGroupVariableValue(context,"axis_saves_state",0)
else
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Load_Time_Axis圈内没有人无事发生延后到有人enter region后再开启")
end
end
if axis_saves_state == 1 then
local remain_time = ScriptLib.GetGroupVariableValue(context,"sandstorm_last_axis_remain_time")
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Load_Time_Axis状态1恢复之前的时间轴剩余时间为"..remain_time)
local time_axis_name
if LF_Is_In_Sandstorm_State(context) then
time_axis_name = "SANDSTORM_TIME_AXIS"
else
time_axis_name = "SANDSTORM_CD_AXIS"
end
LF_Set_Time_Axis(context,time_axis_name,{save_prefix = "sandstorm", target_time = remain_time})
--开一个沙尘暴预告的时间轴
LF_Set_Time_Axis(context,"SANDSTORM_FORECAST_AXIS",{target_time = remain_time})
--重置一下记录的时间轴状态
ScriptLib.SetGroupVariableValue(context,"axis_saves_state",0)
return
end
if axis_saves_state == 2 then
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Load_Time_Axis状态1准备开启下一段时间轴")
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Load_Time_Axis圈内有人允许开启")
--如果之前是沙尘暴状态则转到CD状态
if LF_Is_In_Sandstorm_State(context) then
LF_Set_Time_Axis(context,"SANDSTORM_CD_AXIS",{save_prefix = "sandstorm"})
LF_On_Sandstorm_Stop(context)
--开一个沙尘暴预告的时间轴
LF_Set_Time_Axis(context,"SANDSTORM_FORECAST_AXIS")
else
--如果之前是CD状态则转到沙尘暴状态
LF_Set_Time_Axis(context,"SANDSTORM_TIME_AXIS",{save_prefix = "sandstorm"})
LF_On_Sandstorm_Start(context)
end
--重置一下记录的时间轴状态
ScriptLib.SetGroupVariableValue(context,"axis_saves_state",0)
else
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Load_Time_Axis圈内没有人无事发生延后到有人enter region后再开启")
end
return
end
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Set_Sandstorm_Weather(context,is_on)
if is_on then
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Set_Sandstorm_Weather设置沙尘暴天气为开启")
ScriptLib.SetWeatherAreaState(context, weather_region_config["SandStorm_InnerRegion"].weather, 1)
ScriptLib.SetWeatherAreaState(context, weather_region_config["SandStorm_MiddleRegion"].weather, 1)
ScriptLib.SetWeatherAreaState(context, weather_region_config["SandStorm_OuterRegion"].weather, 1)
else
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Set_Sandstorm_Weather设置沙尘暴天气为关闭")
ScriptLib.SetWeatherAreaState(context, weather_region_config["SandStorm_InnerRegion"].weather, 0)
ScriptLib.SetWeatherAreaState(context, weather_region_config["SandStorm_MiddleRegion"].weather, 0)
ScriptLib.SetWeatherAreaState(context, weather_region_config["SandStorm_OuterRegion"].weather, 0)
end
end
function LF_Skip_Current_Sandstorm(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl]LF_Skip_Current_Sandstorm强制跳过当前的沙尘暴阶段")
if LF_Is_In_Sandstorm_State(context) then
--如果现在是沙尘暴阶段则直接强制跳过
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.PrintContextLog(context,"## [SandstormControl]LF_Skip_Current_Sandstorm有玩家在沙尘暴区域做一次强制跳过")
ScriptLib.EndTimeAxis(context, "STORM_TIME_AXIS")
LF_On_Sandstorm_Stop(context)
LF_Set_Time_Axis(context,"SANDSTORM_CD_AXIS",{save_prefix = "sandstorm"})
--开一个沙尘暴预告的时间轴
LF_Set_Time_Axis(context,"SANDSTORM_FORECAST_AXIS")
else
ScriptLib.PrintContextLog(context,"## [SandstormControl]LF_Skip_Current_Sandstorm没有玩家在沙尘暴区域直接结束当前沙尘暴并存档")
ScriptLib.EndTimeAxis(context, "STORM_TIME_AXIS")
LF_On_Sandstorm_Stop(context)
--手动修改一次之前存的当前时间轴时间确保下次进入区域时可以加载一个正确的时间轴
local current_time = ScriptLib.GetServerTime(context)
local last_start_time = ScriptLib.GetGroupVariableValue(context,"sandstorm_last_axis_start_time")
ScriptLib.SetGroupVariableValue(context,"sandstorm_last_axis_last_time", current_time - last_start_time)
LF_Save_Time_Axis(context)
end
else
--当前就是CD阶段无事发生
ScriptLib.PrintContextLog(context,"## [SandstormControl]LF_Skip_Current_Sandstorm当前就是CD阶段无事发生")
end
return 0
end
function LF_Start_Sanstorm(context)
if not LF_Is_In_Sandstorm_State(context) then
--如果现在不是沙尘暴阶段则直接强制开启
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.PrintContextLog(context,"## [SandstormControl]LF_Skip_Current_Sandstorm有玩家在沙尘暴区域强制开启沙尘暴")
ScriptLib.EndTimeAxis(context, "SANDSTORM_CD_AXIS")
LF_On_Sandstorm_Start(context)
LF_Set_Time_Axis(context,"SANDSTORM_TIME_AXIS",{save_prefix = "sandstorm"})
else
ScriptLib.PrintContextLog(context,"## [SandstormControl]LF_Skip_Current_Sandstorm没有玩家在沙尘暴区域无视发生")
end
else
--当前就是CD阶段无事发生
ScriptLib.PrintContextLog(context,"## [SandstormControl]LF_Skip_Current_Sandstorm当前就是CD阶段无事发生")
end
return 0
end
function LF_Change_Team_SGV(context,uid,key,delta)
local v = ScriptLib.GetTeamServerGlobalValue(context,uid,key)
ScriptLib.SetTeamServerGlobalValue(context,uid,key,v+delta)
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
-----------------------------------------------------------------------
--沙尘暴状态相关
--直接设置沙尘暴状态
function LF_Set_Sandstorm_State_By_Id(context,state)
ScriptLib.SetGroupVariableValue(context,"sandstorm_state",state)
end
--设置沙尘暴状态
function LF_Set_Sandstorm_State_By_Name(context,state_name)
if state_name == "IN_STORM" then
ScriptLib.SetGroupVariableValue(context,"sandstorm_state",1)
return
end
if state_name == "IN_CD" then
ScriptLib.SetGroupVariableValue(context,"sandstorm_state",2)
return
end
ScriptLib.PrintGroupWarning(context,"## [Warning] [SandstormControl] LF_Set_Sandstorm_State_By_Id传入非法沙尘暴状态名"..state_name)
end
--返回当前是否处于沙尘暴状态中
function LF_Is_In_Sandstorm_State(context)
return ScriptLib.GetGroupVariableValue(context,"sandstorm_state") == 1
end
-----------------------------------------------------------------------
--时间轴相关
--根据时间轴配置生成一个随机时间进行返回
function LF_Get_Axis_Config_By_Time_Config(context,name,type)
local GM_time_scale_down = ScriptLib.GetGroupVariableValue(context,"GM_Time_Scale_Down")
local GM_time_scale_up = ScriptLib.GetGroupVariableValue(context,"GM_Time_Scale_Up")
local min = time_configs[type][name].min
local max = time_configs[type][name].max
local rtime = math.ceil(math.random(min,max) / GM_time_scale_down * GM_time_scale_up)
if rtime <= 0 then
rtime = 1
end
--rtime至少为1且不能是float否则dev服务器会直接core掉
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Get_Axis_Config_By_Time_Config本次生成时间名为"..type..",时间为"..rtime)
return {rtime}
end
--根据time_config设置一个时间轴支持多种模式
--axis_name时间轴名与time_config中的列名保持一致
--save_prefix如果填了会在开启时间轴时记录一个当前时间轴的开始时间和预计持续时间方便存档这个时间轴
--target_time如果填了会根据传入的target_time来决定时间轴的长度而不是随机一个时间轴
function LF_Set_Time_Axis(context,axis_name,params)
local axis = {}
local target_time
local save_prefix
if params ~= nil then
target_time = params.target_time
save_prefix = params.save_prefix
end
if axis_name == "SANDSTORM_FORECAST_AXIS" then
local remain_time = 0
if target_time == nil then
remain_time = ScriptLib.GetGroupVariableValue(context,"sandstorm_last_axis_last_time")
else
remain_time = target_time
end
if remain_time - local_defs.forecast_time > 0 then
--开一个沙尘暴预告的时间轴
ScriptLib.InitTimeAxis(context,"SANDSTORM_FORECAST_TIME_AXIS",{remain_time-local_defs.forecast_time},false)
end
return
end
if target_time == nil then
local current_region = LF_Get_Legal_Player_Region_In_SandStorm_Region(context)
if current_region ~= "SandStorm_Outside" then
axis = LF_Get_Axis_Config_By_Time_Config(context,current_region,axis_name)
else
ScriptLib.PrintGroupWarning(context,"## [Warning] [SandstormControl] LF_Set_Time_Axis玩家不在沙尘暴区域内无法获得合法的时间轴数据")
return
end
else
axis = {target_time}
end
ScriptLib.InitTimeAxis(context,axis_name,axis,false)
if save_prefix ~= "" and save_prefix ~= nil then
--记录一下时间轴开启的时间
ScriptLib.SetGroupVariableValue(context,save_prefix.."_last_axis_start_time",ScriptLib.GetServerTime(context))
--记录一下本次时间轴持续的时间
ScriptLib.SetGroupVariableValue(context,save_prefix.."_last_axis_last_time",axis[1])
end
return axis[1]
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
function SLC_Reset_Weather_Wizard_Forecast_State(context)
local host = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.SetTeamServerGlobalValue(context, host, "SGV_Is_Sandstorm_Coming", 0)
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| GM指令功能 ||
|| ||
-----------------------------------------------------------------]]--
function action_GM_variable_change(context,evt)
--立刻跳过当前的天气阶段简单起见只考虑玩家在圈内的情况
if evt.source_name == "GM_Skip_Current_Weather" and evt.param1 == 1 then
ScriptLib.PrintContextLog(context,"## [GM]action_GM_variable_changeGM-跳过当前天气阶段")
if LF_Is_In_Sandstorm_State(context) then
--跳过沙尘暴阶段开启CD阶段
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.EndTimeAxis(context, "SANDSTORM_TIME_AXIS")
LF_On_Sandstorm_Stop(context)
LF_Set_Time_Axis(context,"SANDSTORM_CD_AXIS",{save_prefix = "sandstorm"})
--开一个沙尘暴预告的时间轴
LF_Set_Time_Axis(context,"SANDSTORM_FORECAST_AXIS")
else
ScriptLib.PrintContextLog(context,"## [GM]action_GM_variable_changeGM-注意这个GM只适用于圈内有玩家的情况。")
end
else
--跳过CD阶段开启沙尘暴阶段
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.EndTimeAxis(context, "SANDSTORM_CD_AXIS")
LF_On_Sandstorm_Start(context)
LF_Set_Time_Axis(context,"SANDSTORM_TIME_AXIS",{save_prefix = "sandstorm"})
else
ScriptLib.PrintContextLog(context,"## [GM]action_GM_variable_changeGM-注意这个GM只适用于圈内有玩家的情况。")
end
end
ScriptLib.SetGroupVariableValue(context,"GM_Skip_Current_Weather",0)
end
--强制开启一个全新的沙尘暴阶段简单起见只考虑玩家在圈内的情况
if evt.source_name == "GM_Force_Start_Sandstorm" and evt.param1 == 1 then
ScriptLib.PrintContextLog(context,"## [GM]action_GM_variable_changeGM-强制开启一段新的沙尘暴天气")
if LF_Is_In_Sandstorm_State(context) then
--如果现在是沙尘暴阶段先强制结束一次然后再开启一次新的沙尘暴
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.EndTimeAxis(context, "SANDSTORM_TIME_AXIS")
LF_On_Sandstorm_Stop(context)
LF_On_Sandstorm_Start(context)
LF_Set_Time_Axis(context,"SANDSTORM_TIME_AXIS",{save_prefix = "sandstorm"})
else
ScriptLib.PrintContextLog(context,"## [GM]action_GM_variable_changeGM-注意这个GM只适用于圈内有玩家的情况。")
end
else
--跳过CD阶段开启沙尘暴阶段
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.EndTimeAxis(context, "SANDSTORM_CD_AXIS")
LF_On_Sandstorm_Start(context)
LF_Set_Time_Axis(context,"SANDSTORM_TIME_AXIS",{save_prefix = "sandstorm"})
else
ScriptLib.PrintContextLog(context,"## [GM]action_GM_variable_changeGM-注意这个GM只适用于圈内有玩家的情况。")
end
end
ScriptLib.SetGroupVariableValue(context,"GM_Force_Start_Sandstorm",0)
end
--强制开启一个全新的沙尘暴CD阶段简单起见只考虑玩家在圈内的情况
if evt.source_name == "GM_Force_Start_Sandstorm_CD" and evt.param1 == 1 then
ScriptLib.PrintContextLog(context,"## [GM]action_GM_variable_changeGM-强制开启一段新的沙尘暴CD时间段")
if LF_Is_In_Sandstorm_State(context) then
--如果现在是沙尘暴阶段先强制结束一次然后再开启一次新的沙尘暴
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.EndTimeAxis(context, "STORM_TIME_AXIS")
LF_On_Sandstorm_Stop(context)
LF_Set_Time_Axis(context,"SANDSTORM_CD_AXIS",{save_prefix = "sandstorm"})
--开一个沙尘暴预告的时间轴
LF_Set_Time_Axis(context,"SANDSTORM_FORECAST_AXIS")
else
ScriptLib.PrintContextLog(context,"## [GM]action_GM_variable_changeGM-注意这个GM只适用于圈内有玩家的情况。")
end
else
--跳过CD阶段开启沙尘暴阶段
if LF_Is_Any_Player_In_SandStorm_Region(context) then
ScriptLib.EndTimeAxis(context, "SANDSTORM_CD_AXIS")
LF_On_Sandstorm_Start(context)
LF_On_Sandstorm_Stop(context)
LF_Set_Time_Axis(context,"SANDSTORM_CD_AXIS",{save_prefix = "sandstorm"})
--开一个沙尘暴预告的时间轴
LF_Set_Time_Axis(context,"SANDSTORM_FORECAST_AXIS")
else
ScriptLib.PrintContextLog(context,"## [GM]action_GM_variable_changeGM-注意这个GM只适用于圈内有玩家的情况。")
end
end
ScriptLib.SetGroupVariableValue(context,"GM_Force_Start_Sandstorm_CD",0)
end
return 0
end
------------------------------------------------------------------
sandstorm_Initialize()

View File

@@ -0,0 +1,286 @@
--[[======================================
|| filename:
|| owner: luyao.huang
|| description:
|| LogName:
|| Protection:
=======================================]]--
local defs =
{
sandworm_id = 1030,
direct_sandworm_id = 1031,
alert_max_value = 1000
}
----
--
local local_defs = {
request_list_capacity = 3,
--占据90010000后的若干字段不要占用这些字段的var
array_base_offset = 90010000,
}
local sandworm_state =
{
waiting = 0,
attacking = 1
}
local business_type_defs =
{
--大世界
--目标玩家为沙虫区域内的一个随机合法玩家
bigworld = 0,
--挑战
--目标玩家为主机
challenge = 1,
--指定地点直接召唤
--没有目标玩家但要找一组指定地点
direct = 2,
}
local sandworm_default_params =
{
business_type = business_type_defs.bigworld,
sandworm_params_config_id = 0,
target_pos_x = 0,
target_pos_y = 0,
target_pos_z = 0
}
local Tri = {
[1] = { name = "variable_change_alert", config_id = 10020001, event = EventType.EVENT_VARIABLE_CHANGE, source = "alert_value", condition = "", action = "action_variable_change_alert", trigger_count = 0},
[2] = { name = "group_will_unload_alert", config_id = 10020002, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_alert", 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 = 90000001, name = "alert_value", value = 0})
--沙虫状态
table.insert(variables,{ config_id = 90000002, name = "sandworm_state", value = 0})
table.insert(variables,{ config_id = 90000110, name = "start_sandworm_attack_count", value = 0})
table.insert(variables,{ config_id = 90000111, name = "sandworm_attack_count_target_group", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--沙虫警戒值变化
function action_variable_change_alert(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] variable_change: 当前沙虫警戒值为"..evt.param1)
if evt.param1 >= defs.alert_max_value then
if not LF_Sandworm_Is_Attacking(context) then
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] variable_change: 沙虫警戒度超过最大值,召唤沙虫")
local current_request = LF_Get_Max_Priority_Request(context)
local origin_group_id = current_request.group_id
LF_Create_Sandworm(context,origin_group_id)
LF_Set_Sandworm_State(context,sandworm_state.attacking)
end
end
if evt.param1 <= 0 then
LF_Remove_Sandworm(context)
end
return 0
end
function action_group_will_unload_alert(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] group即将卸载重置警戒值以及其他参数")
ScriptLib.SetGroupVariableValue(context,"sandworm_state",sandworm_state.waiting)
ScriptLib.SetGroupVariableValue(context,"alert_value",0)
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.sandworm_id)
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫管理 ||
|| ||
-----------------------------------------------------------------]]--
--在指定玩家身边生成一只沙虫
--需要传入参数请求依赖的groupid
function LF_Create_Sandworm(context,origin_group_id)
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] LF_Create_Sandworm: 创生沙虫")
--先确保取参数的目标group活着否则参数是
--if ScriptLib.IsGroupRegisteredInCurScene(context,origin_group_id) then
local business_type = ScriptLib.GetGroupVariableValueByGroup(context,"business_type",origin_group_id)
if business_type == business_type_defs.direct then
local pos_x = ScriptLib.GetGroupVariableValueByGroup(context,"target_pos_x",origin_group_id)
local pos_y = ScriptLib.GetGroupVariableValueByGroup(context,"target_pos_y",origin_group_id)
local pos_z = ScriptLib.GetGroupVariableValueByGroup(context,"target_pos_z",origin_group_id)
ScriptLib.CreateGadgetByParamTable(context,{config_id = defs.direct_sandworm_id,pos = {x=pos_x,y=pos_y+1.5,z=pos_z}, rot = {x=0,y=0,z=0}})
--这种调用都是一次性的召出沙虫后立刻清理掉这次参数防止被其他地方反复召唤
local index = LF_Get_Request_Index_From_List_By_Request_Id(context,origin_group_id)
if index == -1 then
return -1
end
LF_Remove_Request_From_List_By_Index(context,index)
else
local sandworm_params_config_id = ScriptLib.GetGroupVariableValueByGroup(context,"sandworm_params_config_id",origin_group_id)
local sandworm_params = sandworm_dynamic_params[sandworm_params_config_id]
local range = sandworm_static_params.range
local ambush_times = sandworm_params.ambush_times
local attack_times = sandworm_params.attack_times
local target_uid = 0
if business_type == business_type_defs.bigworld then
target_uid = LF_Get_Legal_Player_Uid_In_Legal_Sandworm_Region(context)
elseif business_type == business_type_defs.challenge then
target_uid = ScriptLib.GetSceneOwnerUid(context)
end
local owner_eid = ScriptLib.GetAvatarEntityIdByUid(context,target_uid)
local pos = ScriptLib.GetPosByEntityId(context,owner_eid)
local rpos = LF_Get_Random_Neighbour(context,pos,range[1],range[2])
ScriptLib.CreateGadgetByParamTable(context,{config_id = defs.sandworm_id,pos = {x=rpos.x,y=rpos.y+1.5,z=rpos.z}, rot = {x=0,y=0,z=0},
sgv_key = {"SGV_Ambush_Times","SGV_Attack_Times"}, sgv_value = {ambush_times,attack_times}})
end
--end
end
--客户端通知沙虫攻击完成
--服务端流程强依赖客户端沙虫攻击完成的SLC否则直接卡死需要考虑保底
function SLC_Sandworm_Attack_Finish(context)
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] SLC_Sandworm_Attack_Finish: 客户端通知,沙虫攻击完成")
LF_Set_Sandworm_State(context,sandworm_state.waiting)
LF_Set_Alert_Value(context,0)
return 0
end
--清除沙虫gadget但不影响沙虫警戒值
function LF_Remove_Sandworm(context)
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] LF_Remove_Sandworm: 移除沙虫并恢复沙虫等待状态")
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.sandworm_id)
LF_Set_Sandworm_State(context,sandworm_state.waiting)
end
--由别的group请求清除主动沙虫通常是由于出界引起的
--需要校验请求的id与当前堆顶的参数请求来源id是否一致如果不一致直接无视
function LF_Request_Remove_Sandworm(context,prev_context,origin_group_id)
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] LF_Request_Remove_Sandworm: 请求移除沙虫请求id为"..origin_group_id)
local current_request = LF_Get_Max_Priority_Request(context)
if current_request.group_id == origin_group_id then
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] LF_Request_Remove_Sandworm: 与当前堆顶id一致移除沙虫")
LF_Remove_Sandworm(context)
return 0
else
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] LF_Request_Remove_Sandworm: 与当前堆顶id不一致移除失败")
return -1
end
end
function LF_Set_Sandworm_State(context,state)
ScriptLib.SetGroupVariableValue(context,"sandworm_state",state)
end
function LF_Get_Sandworm_State(context)
return ScriptLib.GetGroupVariableValue(context,"sandworm_state")
end
function LF_Sandworm_Is_Attacking(context)
return LF_Get_Sandworm_State(context) == sandworm_state.attacking
end
--[[-----------------------------------------------------------------
|| ||
|| 警戒值控制 ||
|| ||
-----------------------------------------------------------------]]--
--外部请求修改警戒值
function LF_Request_Change_Alert_Value(context,prev_context,delta)
return LF_Change_Alert_Value(context,delta)
end
--外部请求修改警戒值
function LF_Request_Set_Alert_Value(context,prev_context,target_value)
return LF_Set_Alert_Value(context,target_value)
end
function LF_Change_Alert_Value(context,delta)
--沙虫攻击时锁警戒值变动
if not LF_Sandworm_Is_Attacking(context) then
ScriptLib.ChangeGroupVariableValue(context,"alert_value",delta)
return 0
end
return -1
end
function LF_Set_Alert_Value(context,target_value)
--沙虫攻击时锁警戒值变动
if not LF_Sandworm_Is_Attacking(context) then
ScriptLib.SetGroupVariableValue(context,"alert_value",target_value)
return 0
end
return -1
end
function LF_Get_Alert_Value(context)
return ScriptLib.GetGroupVariableValue(context,"alert_value")
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
--获取指定位置的随机近邻位置分布在min_r~max_r为半径的环上
function LF_Get_Random_Neighbour(context,pos,min_r,max_r)
local random_r = math.random(min_r,max_r)
local random_a = math.random()*math.pi*2
local rpos_x = pos.x + random_r * math.cos(random_a)
local rpos_z = pos.z + random_r * math.sin(random_a)
local rpos = {x = rpos_x,y = pos.y,z = rpos_z}
return rpos
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
function SLC_Request_Remove_Current_Sandworm(context)
ScriptLib.PrintContextLog(context,"## [SandwormAlertControl] SLC_Request_Remove_Current_Sandworm: 物件层请求移除沙虫")
local index = ScriptLib.GetGroupVariableValue(context,"max_priority_request_index")
LF_Remove_Request_From_List_By_Index(context,index)
LF_Remove_Sandworm(context)
return 0
end
--沙虫攻击计数
--注意这套计数的开关没有互斥和队列的逻辑只要有人要求就会开有人要求就会关因此调用的时候确保环境干净
function SLC_Sandworm_Attack_Success_Count(context)
local is_started = ScriptLib.GetGroupVariableValue(context,"start_sandworm_attack_count") == 1
if is_started then
local target_group = ScriptLib.GetGroupVariableValue(context,"sandworm_attack_count_target_group")
ScriptLib.ChangeGroupVariableValueByGroup(context,"sandworm_attack_count",1,target_group)
end
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,275 @@
--[[======================================
|| filename: SandwormBigworldControl
|| owner: luyao.huang
|| description:
|| LogName: SandwormBigworldControl
|| Protection:
=======================================]]--
local business_type = "bigworld"
local priority = 1
local local_defs =
{
sandworm_manager_group = 133314001,
alert_max_value = 1000,
outof_attack_region_delay = 3
}
local bigworld_Tri = {
[1] = { name = "variable_change_bigworld_sandworm", config_id = 100010001, event = EventType.EVENT_VARIABLE_CHANGE, source = "alert_value", condition = "", action = "action_variable_change_bigworld_sandworm", trigger_count = 0},
[2] = { name = "group_will_unload_bigworld_sandworm", config_id = 100010002, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_bigworld_sandworm", trigger_count = 0},
[3] = { name = "enter_region_bigworld_sandworm", config_id = 100010003, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region_bigworld_sandworm", trigger_count = 0},
[4] = { name = "leave_region_bigworld_sandworm", config_id = 100010004, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region_bigworld_sandworm", trigger_count = 0},
[5] = { name = "time_axis_pass_bigworld_sandworm", config_id = 100010005, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass_bigworld_sandworm", trigger_count = 0},
}
function bigworld_Initialize()
for k,v in pairs(bigworld_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--警戒值
table.insert(variables,{ config_id = 100010001, name = "alert_value", value = 0})
--沙虫攻击状态时要锁警戒值变动
table.insert(variables,{ config_id = 100010002, name = "is_alert_locked", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--沙虫警戒值变化
function action_variable_change_bigworld_sandworm(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl] variable_change: 当前沙虫警戒值为"..evt.param1)
if evt.param1 >= local_defs.alert_max_value then
ScriptLib.PrintContextLog(context,"## [SandwormAleSandwormBigworldControlrtControl] variable_change: 沙虫警戒度超过最大值,召唤沙虫")
local target_uid = LF_Get_Target_Uid(context)
--在攻击圈外移动圈内召唤巡游沙虫
if ScriptLib.IsInRegion(context,target_uid,defs.move_region) and not ScriptLib.IsInRegion(context,target_uid,defs.attack_region) then
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl] variable_change: 位于攻击圈外演出圈内,召唤巡游沙虫")
LF_Summon_Move_Sandworm(context,defs.attack_times)
ScriptLib.InitTimeAxis(context,"move_sandworm_life_axis",{defs.move_sandworm_lifetime},false)
end
--在攻击圈内命令沙虫进行一次进攻
if ScriptLib.IsInRegion(context,target_uid,defs.attack_region) then
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl] variable_change: 位于攻击圈内,命令沙虫开始攻击")
LF_Command_Move_Sandworm_Attack(context,defs.attack_times)
end
end
return 0
end
function action_group_will_unload_bigworld_sandworm(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl] group即将卸载重置警戒值以及其他参数")
LF_Remove_All_Sandworm(context)
LF_Set_Alert_Lock(context,false)
LF_Set_Alert_Value(context,0)
ScriptLib.EndTimeAxis(context,"sandworm_alert_axis")
ScriptLib.EndTimeAxis(context,"move_sandworm_life_axis")
return 0
end
function action_enter_region_bigworld_sandworm(context,evt)
--从外侧进入演出圈
--开一个时间轴
if evt.param1 == defs.move_region then
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl] action_enter_region_bigworld_sandworm从外侧进入演出圈")
ScriptLib.InitTimeAxis(context,"sandworm_alert_axis",{1},true)
end
--从演出圈进入攻击圈
--命令沙虫进行一次进攻
if evt.param1 == defs.attack_region then
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl] action_enter_region_bigworld_sandworm从演出圈进入攻击圈")
local alert_value = ScriptLib.GetGroupVariableValue(context,"alert_value")
if alert_value >= local_defs.alert_max_value then
--清理一下移动沙虫的生命时间轴
ScriptLib.EndTimeAxis(context,"move_sandworm_life_axis")
LF_Command_Move_Sandworm_Attack(context,defs.attack_times)
end
end
return 0
end
function action_leave_region_bigworld_sandworm(context,evt)
--离开演出圈到外侧
--关掉时间轴并清理掉所有沙虫
if evt.param1 == defs.move_region then
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl] action_leave_region_bigworld_sandworm从演出圈离开到外侧")
ScriptLib.EndTimeAxis(context,"sandworm_alert_axis")
ScriptLib.EndTimeAxis(context,"move_sandworm_life_axis")
LF_Remove_All_Sandworm(context)
end
--离开攻击圈进入演出圈
--清理掉攻击沙虫
if evt.param1 == defs.attack_region and ScriptLib.IsInRegion(context,evt.uid,defs.move_region) then
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl] action_leave_region_bigworld_sandworm从攻击圈离开到演出圈")
LF_Remove_All_Sandworm(context)
LF_Set_Alert_Lock(context,false)
--这里其实是在做一个延时X秒的操作但为了防止时间轴导致的时序问题全部转化成警戒值的操作
local sandstorm_state = ScriptLib.GetGroupVariableValueByGroup(context,"sandstorm_state",local_defs.sandworm_manager_group)
local alert_by_tick = 0
if sandstorm_state == 1 then
alert_by_tick = math.floor((region_config.alert_by_tick_normal[1] + region_config.alert_by_tick_normal[2])/2)
else
alert_by_tick = math.floor((region_config.alert_by_tick_sandstorm[1] + region_config.alert_by_tick_sandstorm[2])/2)
end
local target_alert_value = math.ceil(local_defs.alert_max_value - alert_by_tick * local_defs.outof_attack_region_delay)
if target_alert_value <= 0 then
target_alert_value = 0
end
LF_Set_Alert_Value(context, target_alert_value)
end
return 0
end
function action_time_axis_pass_bigworld_sandworm(context,evt)
if (evt.source_name == "sandworm_alert_axis") then
local region_config = LF_Get_Current_Region_Config(context)
if region_config ~= nil then
local alert_by_tick = {}
local sandstorm_state = ScriptLib.GetGroupVariableValueByGroup(context,"sandstorm_state",local_defs.sandworm_manager_group)
if sandstorm_state == 1 then
alert_by_tick = region_config.alert_by_tick_normal
else
alert_by_tick = region_config.alert_by_tick_sandstorm
end
local delta = math.random(alert_by_tick[1],alert_by_tick[2])
LF_Change_Alert_Value(context,delta)
end
end
if (evt.source_name == "move_sandworm_life_axis") then
LF_Remove_All_Sandworm(context)
LF_On_Attack_Finish(context)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫控制回调 ||
|| ||
-----------------------------------------------------------------]]--
--沙虫控制回调创建沙虫成功
function LF_On_Create_Sandworm_Success(context)
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl]LF_On_Create_Sandworm_Success: 沙虫控制回调:创建沙虫成功")
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl]LF_On_Create_Sandworm_Success: 锁定警戒值变化")
LF_Set_Alert_Lock(context,true)
end
--沙虫控制回调创建沙虫失败
function LF_On_Create_Sandworm_Fail(context)
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl]LF_On_Create_Sandworm_Success: 沙虫控制回调:创建沙虫失败")
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl]LF_On_Create_Sandworm_Success: 解锁警戒值变化")
LF_Set_Alert_Value(context,0)
LF_Set_Alert_Lock(context,false)
end
--沙虫控制回调移除沙虫
function LF_On_Remove_Sandworm(context)
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl]LF_On_Create_Sandworm_Success: 沙虫控制回调:清除沙虫")
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl]LF_On_Create_Sandworm_Success: 解锁警戒值变化")
LF_Set_Alert_Lock(context,false)
end
--沙虫控制回调沙虫攻击完成
function LF_On_Attack_Finish(context)
ScriptLib.PrintContextLog(context,"## [SandwormBigworldControl]LF_On_Attack_Finish: 沙虫控制回调:攻击完成,警戒值清零")
LF_Set_Alert_Value(context,0)
end
--沙虫控制回调击中玩家
function LF_On_Attack_Hit_Avatar(context)
end
--[[-----------------------------------------------------------------
|| ||
|| 警戒值控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Change_Alert_Value(context,delta)
if not LF_Is_Alert_Locked(context) then
ScriptLib.ChangeGroupVariableValue(context,"alert_value",delta)
end
end
function LF_Set_Alert_Value(context,target_value)
if not LF_Is_Alert_Locked(context) then
ScriptLib.SetGroupVariableValue(context,"alert_value",target_value)
end
end
function LF_Get_Alert_Value(context)
return ScriptLib.GetGroupVariableValue(context,"alert_value")
end
function LF_Set_Alert_Lock(context,is_locked)
if is_locked then
ScriptLib.SetGroupVariableValue(context,"is_alert_locked",1)
else
ScriptLib.SetGroupVariableValue(context,"is_alert_locked",0)
end
end
function LF_Is_Alert_Locked(context)
return ScriptLib.GetGroupVariableValue(context,"is_alert_locked") == 1
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Get_Target_Uid(context)
return ScriptLib.GetSceneOwnerUid(context)
end
function LF_Get_Current_Region_Config(context)
return region_config
end
--获取指定位置的随机近邻位置分布在min_r~max_r为半径的环上
function LF_Get_Random_Neighbour(context,pos,min_r,max_r)
local random_r = math.random(min_r,max_r)
local random_a = math.random()*math.pi*2
local rpos_x = pos.x + random_r * math.cos(random_a)
local rpos_z = pos.z + random_r * math.sin(random_a)
local rpos = {x = rpos_x,y = pos.y,z = rpos_z}
return rpos
end
------------------------------------------------------------------
bigworld_Initialize()

View File

@@ -0,0 +1,215 @@
--[[======================================
|| filename: SandwormchallengeControl
|| owner: luyao.huang
|| description:
|| LogName: SandwormchallengeControl
|| Protection:
=======================================]]--
local business_type = "challenge"
local priority = 2
local local_defs =
{
sandworm_manager_group = 133314001,
challenge_option = 177,
time_axis_name = "challenge_sandworm_tick_axis"
}
local challenge_Tri = {
[1] = { name = "select_option_challenge_sandworm", config_id = 100010001, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option_challenge_sandworm", trigger_count = 0},
[2] = { name = "challenge_success_challenge_sandworm", config_id = 100010002, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success_challenge_sandworm", trigger_count = 0},
[3] = { name = "challenge_fail_challenge_sandworm", config_id = 100010003, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail_challenge_sandworm", trigger_count = 0},
[10] = { name = "enter_region_challenge_sandworm", config_id = 100010011, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region_challenge_sandworm", trigger_count = 0},
[11] = { name = "leave_region_challenge_sandworm", config_id = 100010012, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region_challenge_sandworm", trigger_count = 0},
[12] = { name = "time_axis_pass_challenge_sandworm", config_id = 100010013, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass_challenge_sandworm", trigger_count = 0},
[13] = { name = "group_will_unload_challenge_sandworm", config_id = 100010014, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_challenge_sandworm", trigger_count = 0},
[20] = { name = "variable_change_challenge_sandworm", config_id = 100010021, event = EventType.EVENT_VARIABLE_CHANGE, source = "attack_count", condition = "condition_variable_change_challenge_sandworm", action = "action_variable_change_challenge_sandworm", trigger_count = 0,tag = "1"},
}
function challenge_Initialize()
for k,v in pairs(challenge_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--沙虫攻击次数计数开关打开后才会开始计数
table.insert(variables,{ config_id = 100010001, name = "is_attack_count", value = 0})
--沙虫攻击次数计数
table.insert(variables,{ config_id = 100010002, name = "attack_count", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_select_option_challenge_sandworm(context,evt)
if evt.param2 == local_defs.challenge_option then
LF_On_Challenge_Start(context)
end
return 0
end
function action_challenge_success_challenge_sandworm(context,evt)
if evt.param1 == defs.challenge_id then
LF_On_Challenge_Finish(context,true)
end
return 0
end
function action_challenge_fail_challenge_sandworm(context,evt)
if evt.param1 == defs.challenge_id then
LF_On_Challenge_Finish(context,false)
end
return 0
end
function action_group_will_unload_challenge_sandworm(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl] group即将卸载")
LF_Remove_All_Sandworm(context)
ScriptLib.EndTimeAxis(context,local_defs.time_axis_name)
return 0
end
function action_enter_region_challenge_sandworm(context,evt)
if ScriptLib.IsChallengeStartedByChallengeId(context, defs.challenge_id) then
if evt.param1 == defs.sandworm_region then
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]enter_region: 玩家进入挑战沙虫区域")
ScriptLib.ContinueTimeAxis(context,local_defs.time_axis_name)
end
end
return 0
end
function action_leave_region_challenge_sandworm(context,evt)
if ScriptLib.IsChallengeStartedByChallengeId(context, defs.challenge_id) then
if evt.param1 == defs.sandworm_region then
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]leave_region: 玩家离开挑战沙虫区域,清除沙虫")
LF_Remove_All_Sandworm(context)
ScriptLib.PauseTimeAxis(context,local_defs.time_axis_name)
end
end
return 0
end
function action_time_axis_pass_challenge_sandworm(context,evt)
if ScriptLib.IsChallengeStartedByChallengeId(context, defs.challenge_id) then
if (evt.source_name == local_defs.time_axis_name) then
local uid = ScriptLib.GetSceneOwnerUid(context)
LF_Summon_Direct_Sandworm_By_Avatar(context,uid,defs.attack_times)
end
end
return 0
end
function condition_variable_change_challenge_sandworm(context,evt)
--过滤掉清零的导致的触发
if evt.param1 ~= 0 then
return true
end
return false
end
function action_variable_change_challenge_sandworm(context,evt)
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 挑战控制回调 ||
|| ||
-----------------------------------------------------------------]]--
function LF_On_Challenge_Start(context)
LF_Reset_Attack_Count(context)
ScriptLib.InitTimeAxis(context,local_defs.time_axis_name,{defs.attack_interval},true)
end
function LF_On_Challenge_Finish(context,is_success)
LF_Remove_All_Sandworm(context)
ScriptLib.EndTimeAxis(context,local_defs.time_axis_name)
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫控制回调 ||
|| ||
-----------------------------------------------------------------]]--
--沙虫控制回调创建沙虫成功
function LF_On_Create_Sandworm_Success(context)
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]LF_On_Create_Sandworm_Success: 沙虫控制回调:创建沙虫成功")
end
--沙虫控制回调创建沙虫失败
function LF_On_Create_Sandworm_Fail(context)
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]LF_On_Create_Sandworm_Success: 沙虫控制回调:创建沙虫失败")
end
--沙虫控制回调移除沙虫
function LF_On_Remove_Sandworm(context)
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]LF_On_Create_Sandworm_Success: 沙虫控制回调:清除沙虫")
end
--沙虫控制回调沙虫攻击完成
function LF_On_Attack_Finish(context)
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]LF_On_Attack_Finish: 沙虫控制回调:攻击完成")
end
--沙虫控制回调沙虫攻击命中玩家
function LF_On_Attack_Hit_Avatar(context)
if LF_Is_Attack_Count(context) then
ScriptLib.ChangeGroupVariableValue(context,"attack_count",1)
end
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫攻击计数 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Reset_Attack_Count(context)
ScriptLib.SetGroupVariableValue(context,"attack_count",0)
end
function LF_Start_Attack_Count(context)
ScriptLib.SetGroupVariableValue(context,"is_attack_count",1)
end
function LF_Stop_Attack_Count(context)
ScriptLib.SetGroupVariableValue(context,"is_attack_count",0)
end
function LF_Is_Attack_Count(context)
return ScriptLib.GetGroupVariableValue(context,"is_attack_count")
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
------------------------------------------------------------------
challenge_Initialize()

View File

@@ -0,0 +1,193 @@
--[[======================================
|| filename: SandwormChallenge_DodgeChallenge
|| owner: luyao.huang
|| description: 主要是用于管理沙虫躲避挑战里面的父子挑战结构和沙虫没有太多联系
|| LogName: SandwormChallenge_DodgeChallenge
|| Protection:
=======================================]]--
local local_defs =
{
challenge_index = 666,
challenge_id = 2012004,
live_challenge_index = 667,
live_challenge_id = 2012003,
dodge_challenge_index = 668,
dodge_challenge_id = 2012002,
challenge_option = 177,
}
local challenge_Tri = {
[1] = { name = "select_option_dodge_challenge", config_id = 200010001, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option_dodge_challenge", trigger_count = 0},
[2] = { name = "group_load_dodge_challenge", config_id = 200010002, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load_dodge_challenge", trigger_count = 0},
[3] = { name = "challenge_fail_dodge_challenge", config_id = 200010003, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail_dodge_challenge", trigger_count = 0},
[4] = { name = "challenge_success_dodge_challenge", config_id = 200010004, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success_dodge_challenge", trigger_count = 0},
[6] = { name = "gadget_state_change_dodge_challenge", config_id = 200010006, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change_dodge_challenge", trigger_count = 0},
}
function dodge_challenge_Initialize()
for k,v in pairs(challenge_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id = 200010001, name = "is_success", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_gadget_state_change_dodge_challenge(context,evt)
if evt.param2 == defs.worktop_id then
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] gadget_state_change操作台状态变化")
if evt.param1 == 0 then
--恢复选项
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] gadget_state_change操作台到0状态恢复选项")
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.worktop_id, {local_defs.challenge_option})
end
if evt.param1 == 201 or evt.param1 == 202 then
--清选项
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] gadget_state_change操作台到非0状态清理选项")
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.worktop_id, local_defs.challenge_option)
end
end
return 0
end
function action_select_option_dodge_challenge(context,evt)
if evt.param2 == local_defs.challenge_option then
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] select_option选择选项开启挑战")
--开挑战
--ScriptLib.ActiveChallenge(context, local_defs.challenge_index, local_defs.challenge_id, defs.challenge_time, defs.max_hit_times, 0, 0)
local uid = ScriptLib.GetSceneOwnerUid(context)
ScriptLib.CreateFatherChallenge(context, local_defs.challenge_index, local_defs.challenge_id, defs.challenge_time, {success = 10, fail = 5, fail_on_wipe = true})
ScriptLib.StartFatherChallenge(context, local_defs.challenge_index)
ScriptLib.AttachChildChallenge(context, local_defs.challenge_index, local_defs.dodge_challenge_index, local_defs.dodge_challenge_id,
{3,1,defs.max_hit_times,0,0},{},{success=10, fail=5})
ScriptLib.AttachChildChallenge(context, local_defs.challenge_index, local_defs.live_challenge_index, local_defs.live_challenge_id,
{defs.challenge_time},{},{success=10, fail=5})
--转操作台状态
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.GearStart)
--开启挑战时立刻召一次沙虫
local uid = ScriptLib.GetSceneOwnerUid(context)
LF_Summon_Direct_Sandworm_By_Avatar(context,uid,defs.attack_times)
--开启玩法杂项
LF_Start_Play(context)
end
return 0
end
function action_challenge_success_dodge_challenge(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] challenge_success挑战成功挑战id为"..evt.param1)
if evt.param1 == local_defs.live_challenge_id then
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] challenge_success挑战成功")
ScriptLib.StopChallenge(context,local_defs.challenge_index,1)
--记一个变量方便下次恢复
ScriptLib.SetGroupVariableValue(context, "is_success", 1)
--创建宝箱
ScriptLib.CreateGadget(context, { config_id = defs.chest_id })
--转操作台状态到完成
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.GearStop)
--清理玩法杂项
LF_Clear_Play(context)
end
return 0
end
function action_challenge_fail_dodge_challenge(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] challenge_success挑战失败挑战id为"..evt.param1)
if evt.param1 == local_defs.live_challenge_id then
ScriptLib.StopChallenge(context,local_defs.challenge_index,1)
--记一个变量方便下次恢复
ScriptLib.SetGroupVariableValue(context, "is_success", 1)
--创建宝箱
ScriptLib.CreateGadget(context, { config_id = defs.chest_id })
--转操作台状态到完成
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.GearStop)
--清理玩法杂项
LF_Clear_Play(context)
end
if evt.param1 == local_defs.dodge_challenge_id then
ScriptLib.StopChallenge(context,local_defs.challenge_index,0)
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] challenge_fail挑战失败")
--转操作台状态到初始
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.Default)
--清理玩法杂项
LF_Clear_Play(context)
end
return 0
end
function action_group_load_dodge_challenge(context,evt)
local is_success = ScriptLib.GetGroupVariableValue(context,"is_success") == 1
if is_success then
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] group_loadgroup加载之前已成功")
--如果之前已成功将操作台直接转到完成状态
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.GearStop)
else
ScriptLib.PrintContextLog(context,"## [SandwormChallenge_DodgeChallenge] group_loadgroup加载之前未成功")
--如果之前未成功则正常给操作台上选项
ScriptLib.SetGadgetStateByConfigId(context, defs.worktop_id, GadgetState.Default)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.worktop_id, {local_defs.challenge_option})
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Start_Play(context)
--开空气墙
ScriptLib.CreateGadget(context, { config_id = defs.airwall_id })
--打开沙虫计数开关
ScriptLib.SetGroupVariableValue(context, "is_attack_count", 1)
end
function LF_Clear_Play(context)
--清掉空气墙
ScriptLib.KillEntityByConfigId(context, { config_id = defs.airwall_id })
--关掉计数
ScriptLib.SetGroupVariableValue(context, "is_attack_count", 0)
end
------------------------------------------------------------------
dodge_challenge_Initialize()

View File

@@ -0,0 +1,351 @@
--[[======================================
|| filename: SandwormControl
|| owner: luyao.huang
|| description: 3.3沙尘爆发沙虫控制白盒
|| LogName: SandwormControl
|| Protection:
=======================================]]--
local sandworm_config =
{
sandworm_id = 1030,
min_raidus = 10,
max_radius = 20,
}
------
local local_defs = {
}
local Tri = {
[1] = { name = "time_axis_pass_sandworm", config_id = 10001001, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass_sandworm", trigger_count = 0},
[2] = { name = "variable_change_sandworm", config_id = 10001002, event = EventType.EVENT_VARIABLE_CHANGE, source = "sandworm_state", condition = "", action = "action_variable_change_sandworm", trigger_count = 0},
[3] = { name = "enter_region_sandworm", config_id = 10001003, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region_sandworm", trigger_count = 0},
[4] = { name = "leave_region_sandworm", config_id = 10001004, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region_sandworm", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--沙虫状态
-- 0未开启
-- 1初始CD中
-- 2CD中
-- 3攻击中
table.insert(variables,{ config_id = 20001001, name = "sandworm_state", value = -1})
--目标玩家
--每次有玩家进圈和出圈只要沙虫不处于攻击状态就会重新调整一次目标玩家
--沙虫创生后会通过SLC通知一次lua调整ability层自己选择的目标玩家
table.insert(variables,{ config_id = 20001002, name = "target_uid", value = -1})
--是否有沙虫时间轴存档
table.insert(variables,{ config_id = 20001003, name = "has_sandworm_axis_saves", value = -1})
--存档的沙虫时间轴剩余时间
table.insert(variables,{ config_id = 20001004, name = "sandworm_last_axis_remain_time", value = -1})
--存档的沙虫时间轴剩余时间
table.insert(variables,{ config_id = 20001005, name = "sandworm_last_axis_start_time", value = -1})
--存档的沙虫时间轴剩余时间
table.insert(variables,{ config_id = 20001006, name = "sandworm_last_axis_last_time", value = -1})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_time_axis_pass_sandworm(context,evt)
if (evt.source_name == "SANDWORM_START_CD_AXIS") then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_time_axis_pass第一次沙虫攻击CD时间结束开始沙虫攻击")
if LF_Is_In_Legal_Sandworm_Region(context,LF_Get_Target_Uid(context)) then
LF_Start_Sandworm_Attack(context)
else
ScriptLib.PrintGroupWarning(context,"## [Warning] [SandstormControl] action_time_axis_pass_sandworm目标玩家不在沙虫区域内且没有切换到合法的目标异常情况")
end
end
if (evt.source_name == "SANDWORM_CD_AXIS") then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_time_axis_pass沙虫攻击CD结束开始沙虫攻击")
if LF_Is_In_Legal_Sandworm_Region(context,LF_Get_Target_Uid(context)) then
LF_Start_Sandworm_Attack(context)
else
ScriptLib.PrintGroupWarning(context,"## [Warning] [SandstormControl] action_time_axis_pass_sandworm目标玩家不在沙虫区域内且没有切换到合法的目标异常情况")
end
end
return 0
end
function action_variable_change_sandworm(context,evt)
return 0
end
function action_enter_region_sandworm(context,evt)
if LF_Is_Region_Specific_Region(context,"SandwormRegion",evt.param1) then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_enter_region_sandworm玩家进入沙虫区域")
if LF_Is_In_Sandstorm_State(context) then
local players_in_region = LF_Get_All_Legal_Player_Uid_In_Legal_Sandworm_Region(context)
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_enter_region_sandworm当前沙虫区域内玩家数为"..#players_in_region)
if #players_in_region <= 1 then
--如果当前玩家是第一个进入沙虫区域的玩家将沙虫的目标锁定为该玩家
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_enter_region_sandworm玩家"..players_in_region[1].."为当前沙尘暴中第一个进入沙虫区域的,将其设为目标")
LF_Set_Target_Uid(context,players_in_region[1])
end
--如果没有存档说明是当前沙尘暴第一次进入沙虫区域开启第一个CD阶段
if not LF_Has_Sandworm_Axis_Saves(context) then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_enter_region_sandworm没有存档开始初始化第一次沙虫攻击CD阶段")
LF_Set_Time_Axis(context,"SANDWORM_START_CD_AXIS",{save_prefix = "sandworm"})
LF_Set_Sandworm_State(context,1)
else
--如果有存档直接加载存档
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_enter_region_sandworm有存档开始加载存档时间轴")
LF_Load_Sandworm_Saves(context)
end
end
end
return 0
end
function action_leave_region_sandworm(context,evt)
if LF_Is_Region_Specific_Region(context,"SandwormRegion",evt.param1) then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_leave_region_sandworm玩家离开沙虫区域")
if LF_Is_In_Sandstorm_State(context) then
--先停止当前的沙虫攻击
if LF_Get_Sandworm_State(context) == 3 then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_leave_region_sandworm停止当前沙虫攻击")
LF_Stop_Sandworm_Attack(context)
end
local players_in_region = LF_Get_All_Legal_Player_Uid_In_Legal_Sandworm_Region(context)
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_leave_region_sandworm当前沙虫区域内玩家数为"..#players_in_region)
if #players_in_region >= 1 and evt.uid == LF_Get_Target_Uid(context) then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_leave_region_sandworm有玩家离开区域重新设置沙虫目标为"..players_in_region[1])
LF_Set_Target_Uid(context,players_in_region[1])
elseif #players_in_region <= 0 then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_leave_region_sandworm所有玩家全部离开沙虫区域存档时间轴")
local sandworm_state = ScriptLib.GetGroupVariableValue(context,"sandworm_state")
if sandworm_state == 1 then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_leave_region_sandworm当前为初始CD状态存档时间轴")
ScriptLib.EndTimeAxis(context,"SANDWORM_START_CD_AXIS")
LF_Save_Sandworm_Saves(context)
elseif sandworm_state == 2 then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_leave_region_sandworm当前为常规CD状态存档时间轴")
ScriptLib.EndTimeAxis(context,"SANDWORM_CD_AXIS")
LF_Save_Sandworm_Saves(context)
elseif sandworm_state == 3 then
ScriptLib.PrintContextLog(context,"## [SandwormControl] action_leave_region_sandworm当前为沙虫攻击状态什么都不需要存。下次加载时直接开始CD即可")
end
end
end
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫存档 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Save_Sandworm_Saves(context)
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Save_Sandworm_State开始存储当前时间轴状态")
local current_time = ScriptLib.GetServerTime(context)
local last_start_time = ScriptLib.GetGroupVariableValue(context,"sandworm_last_axis_start_time")
local last_last_time = ScriptLib.GetGroupVariableValue(context,"sandworm_last_axis_last_time")
local remain_time = last_last_time - (current_time - last_start_time)
ScriptLib.PrintContextLog(context,"## [SandwormControl] LF_Save_Sandworm_State剩余时间为"..remain_time)
ScriptLib.SetGroupVariableValue(context,"sandworm_last_axis_remain_time",remain_time)
ScriptLib.SetGroupVariableValue(context,"has_sandworm_axis_saves", 1)
end
function LF_Load_Sandworm_Saves(context)
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Load_Sandworm_State开始恢复时间轴状态")
local remain_time = ScriptLib.GetGroupVariableValue(context,"sandworm_last_axis_remain_time")
local sandworm_state = ScriptLib.GetGroupVariableValue(context,"sandworm_state")
if sandworm_state == 1 then
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Load_Sandworm_State之前处于起始CD状态恢复起始CD剩余时间"..remain_time.."秒")
LF_Set_Time_Axis(context,"SANDWORM_START_CD_AXIS",{save_prefix = "sandworm", target_time = remain_time})
elseif sandworm_state == 2 then
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Load_Sandworm_State之前处于CD状态恢复CD剩余时间"..remain_time.."秒")
LF_Set_Time_Axis(context,"SANDWORM_CD_AXIS",{save_prefix = "sandworm", target_time = remain_time})
elseif sandworm_state == 3 then
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Load_Sandworm_State之前处于沙虫攻击状态加载时直接进入CD阶段")
LF_Set_Time_Axis(context,"SANDWORM_CD_AXIS",{save_prefix = "sandworm"})
LF_Set_Sandworm_State(context,2)
end
end
function LF_Has_Sandworm_Axis_Saves(context)
return ScriptLib.GetGroupVariableValue(context,"has_sandworm_axis_saves") == 1
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫流程 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Start_Sandworm_Phase(context)
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Start_Sandworm_Phase=====================================================")
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Start_Sandworm_Phase沙尘暴开始开始准备沙虫攻击相关逻辑")
local players_in_region = LF_Get_All_Legal_Player_Uid_In_Legal_Sandworm_Region(context)
if #players_in_region <= 0 then
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Start_Sandworm_Phase沙虫区域没有玩家等玩家enter region时再开始沙虫攻击")
else
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Start_Sandworm_Phase沙虫区域内有玩家"..players_in_region[1].."初始化第一次沙虫攻击CD")
LF_Set_Target_Uid(context,players_in_region[1])
LF_Set_Time_Axis(context,"SANDWORM_START_CD_AXIS",{save_prefix = "sandworm"})
LF_Set_Sandworm_State(context,1)
end
end
function LF_Stop_Sandworm_Phase(context)
LF_Stop_Sandworm_Attack(context)
ScriptLib.SetGroupVariableValue(context,"has_sandworm_axis_saves",0)
ScriptLib.EndTimeAxis(context,"SANDWORM_START_CD_AXIS")
ScriptLib.EndTimeAxis(context,"SANDWORM_CD_AXIS")
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Start_Sandworm_Phase沙尘暴结束清理沙虫攻击相关逻辑")
ScriptLib.PrintContextLog(context,"## [SandwormControl]LF_Start_Sandworm_Phase=====================================================")
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫控制 ||
|| ||
-----------------------------------------------------------------]]--
--开启一次沙虫攻击
function LF_Start_Sandworm_Attack(context)
local target_uid = LF_Get_Target_Uid(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Start_Sandworm_Attack在玩家"..target_uid.."附近开启一次沙虫袭击")
LF_Create_Sandworm(context,target_uid)
LF_Set_Sandworm_State(context,3)
end
--关闭当前的沙虫攻击
function LF_Stop_Sandworm_Attack(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Start_Sandworm_Attack沙虫袭击结束")
LF_Remove_Sandworm(context)
end
--在指定玩家身边生成一只沙虫
function LF_Create_Sandworm(context,target_uid)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Create_Sandworm在玩家"..target_uid.."附近创建沙虫")
local owner_eid = ScriptLib.GetAvatarEntityIdByUid(context,target_uid)
local pos = ScriptLib.GetPosByEntityId(context,owner_eid)
local rpos = LF_Get_Random_Neighbour(context,pos,sandworm_config.min_raidus,sandworm_config.max_radius)
ScriptLib.CreateGadgetByConfigIdByPos(context,sandworm_config.sandworm_id,{x=rpos.x,y=rpos.y+1.5,z=rpos.z}, {x=0,y=0,z=0})
end
--清理当前生成的沙虫有且只有一只
function LF_Remove_Sandworm(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] LF_Remove_Sandworm移除当前沙虫")
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, sandworm_config.sandworm_id)
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
--获取指定位置的随机近邻位置分布在min_r~max_r为半径的环上
function LF_Get_Random_Neighbour(context,pos,min_r,max_r)
local random_r = math.random(min_r,max_r)
local random_a = math.random()*math.pi*2
local rpos_x = pos.x + random_r * math.cos(random_a)
local rpos_z = pos.z + random_r * math.sin(random_a)
local rpos = {x = rpos_x,y = pos.y,z = rpos_z}
return rpos
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
--设置沙虫状态
function LF_Set_Sandworm_State(context,state)
ScriptLib.SetGroupVariableValue(context,"sandworm_state",state)
end
--获取沙虫状态
function LF_Get_Sandworm_State(context)
return ScriptLib.GetGroupVariableValue(context,"sandworm_state")
end
--设置目标玩家uid
function LF_Set_Target_Uid(context,uid)
ScriptLib.SetGroupVariableValue(context,"target_uid",uid)
end
--获取目标玩家uid
function LF_Get_Target_Uid(context)
return ScriptLib.GetGroupVariableValue(context,"target_uid")
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
--客户端通知沙虫攻击完成
function SLC_Sandworm_Attack_Finish(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] SLC_Sandworm_Attack_Finish沙虫攻击完成SLC")
LF_Stop_Sandworm_Attack(context)
if LF_Is_In_Sandstorm_State(context) then
LF_Set_Time_Axis(context,"SANDWORM_CD_AXIS",{save_prefix = "sandworm"})
LF_Set_Sandworm_State(context,2)
end
return 0
end
--沙虫上给player的modifier它会通过SLC来同步服务端自己所选择的目标玩家uid
function SLC_Sandworm_Set_Target_Player(context)
ScriptLib.PrintContextLog(context,"## [SandstormControl] SLC_Sandworm_Set_Target_Player沙虫设置自己的目标player")
LF_Set_Target_Uid(context,context.uid)
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,182 @@
--[[======================================
|| filename: SandwormControlToolkit
|| owner: luyao.huang
|| description: 整合了各类沙虫控制方法可以直接调用或通过tpl调用
|| LogName: SandwormControlToolkit
|| Protection:
=======================================]]--
local business_type = 3
local sandworm_params_config_id = 0
local business_type_defs =
{
--大世界
--目标玩家为沙虫区域内的一个随机合法玩家
bigworld = 0,
--挑战
--目标玩家为主机
challenge = 1,
--指定地点直接召唤
--没有目标玩家但要找一组指定地点
direct = 2,
}
--玩法业务类型到优先级
--不一定非要用这个
local business_type_to_priority =
{
[business_type_defs.bigworld] = 1,
[business_type_defs.challenge] = 2,
[business_type_defs.direct] = 3
}
local_defs =
{
sandworm_control_group = 133314001,
alert_max_value = 1000,
direct_sandworm_config_id = 100
}
function Initialize()
table.insert(variables,{ config_id = 50000100, name = "business_type", value = business_type})
table.insert(variables,{ config_id = 50000101, name = "sandworm_params_config_id", value = sandworm_params_config_id})
table.insert(variables,{ config_id = 50000102, name = "target_pos_x", value = 0})
table.insert(variables,{ config_id = 50000103, name = "target_pos_y", value = 0})
table.insert(variables,{ config_id = 50000104, name = "target_pos_z", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 修改警戒值 ||
|| ||
-----------------------------------------------------------------]]--
--设置全局的沙虫警戒值
function LF_Set_Sandworm_Alert_Value(context,target_value)
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Set_Alert_Value",{target_value})
end
--修改全局的沙虫警戒值
function LF_Set_Sandworm_Alert_Value(context,delta)
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Change_Alert_Value",{delta})
end
--[[-----------------------------------------------------------------
|| ||
|| 创生沙虫 ||
|| ||
-----------------------------------------------------------------]]--
--请求新增一组沙虫参数注意这个方法与是否召唤沙虫无关沙虫仍然跟随警戒值逻辑进行计算
function LF_Create_Sandworm_Params(context,priority)
local group_id = base_info.group_id
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Create_Sandworm_Params",{group_id,priority})
end
--立刻在玩家身边召唤一只沙虫如果希望召出来的是指定的参数则需要填入一个极高的优先级
--本质是直接填满沙虫警戒值
function LF_Create_Normal_Sandworm_Immediately(context,priority)
local group_id = base_info.group_id
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Create_Sandworm_Params",{group_id,priority})
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Set_Alert_Value",{local_defs.alert_max_value+1})
end
--根据玩法的业务类型创生一只沙虫遵循玩法业务类型的优先级
function LF_Create_Normal_Sandworm_By_Play_Business(context)
local priority = business_type_to_priority[business_type]
LF_Create_Normal_Sandworm_Immediately(context,priority)
end
--强制在玩家身边召唤一只沙虫这个操作带有极高的优先级注意尽量保证使用的时候环境是干净的
function LF_Force_Create_Normal_Sandworm_Immediately(context)
local priority = 99999
LF_Create_Normal_Sandworm_Immediately(context,priority)
end
--立刻在指定位置召唤一只沙虫如果希望召出来的是指定的参数则需要填入一个极高的优先级
--本质是直接填满沙虫警戒值
function LF_Create_Direct_Sandworm_Immediately(context,priority,pos_x,pos_y,pos_z)
local group_id = base_info.group_id
ScriptLib.SetGroupVariableValue(context,"target_pos_x",pos_x)
ScriptLib.SetGroupVariableValue(context,"target_pos_y",pos_y)
ScriptLib.SetGroupVariableValue(context,"target_pos_z",pos_z)
--申请一个直接攻击沙虫的参数
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Create_Sandworm_Params",{group_id,priority})
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Set_Alert_Value",{local_defs.alert_max_value+1})
end
--根据玩法的业务类型在指定位置直接召唤一只沙虫遵循玩法业务类型的优先级
function LF_Create_Normal_Sandworm_By_Play_Business(context,pos_x,pos_y,pos_z)
local priority = business_type_to_priority[business_type]
LF_Create_Direct_Sandworm_Immediately(context,priority,pos_x,pos_y,pos_z)
end
--强制在指定位置召唤一只沙虫这个操作带有极高的优先级会占用当前其他区域/挑战召出来的沙虫参数
--这个行为是一次性的召唤完成后会清理掉当前的沙虫参数
function LF_Force_Direct_Sandworm_Immediately(context,pos_x,pos_y,pos_z)
local priority = 99999
LF_Create_Direct_Sandworm_Immediately(context,priority,pos_x,pos_y,pos_z)
end
--[[-----------------------------------------------------------------
|| ||
|| 清除沙虫 ||
|| ||
-----------------------------------------------------------------]]--
--移除当前group正在使用的沙虫参数
--通常用于玩法结束出界等情况
function LF_Remove_Sandworm_Params(context)
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm_Params",{base_info.group_id})
end
--清掉当前的沙虫以及当前group申请的沙虫参数
--通常可以干净的清理掉一个group申请的沙虫以及相关参数
function LF_Remove_Sandworm(context)
--清掉当前的沙虫
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm",{base_info.group_id})
--清掉当前在占用的参数
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_control_group,"LF_Request_Remove_Sandworm_Params",{base_info.group_id})
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫攻击计数相关 ||
|| ||
-----------------------------------------------------------------]]--
--开启沙虫成功攻击计数的开关
--会将自己的group设置为target_group当沙虫攻击成功时会发送给target_group
function LF_Start_Sandworm_Attack_Count(context)
ScriptLib.SetGroupVariableValueByGroup(context,"start_sandworm_attack_count",1,local_defs.sandworm_control_group)
ScriptLib.SetGroupVariableValueByGroup(context,"sandworm_attack_count_target_group",base_info.group_id,local_defs.sandworm_control_group)
end
--关闭沙虫成功攻击计数的开关同时清掉当前的沙虫攻击计数因此关掉之前务必先把值取出来
function LF_Stop_Sandworm_Attack_Count(context)
ScriptLib.SetGroupVariableValueByGroup(context,"start_sandworm_attack_count",0,local_defs.sandworm_control_group)
ScriptLib.SetGroupVariableValueByGroup(context,"sandworm_attack_count_target_group",0,local_defs.sandworm_control_group)
ScriptLib.SetGroupVariableValue(context,"sandworm_attack_count",0)
end
--查询当前记录的沙虫攻击成功的次数
function LF_Get_Sandworm_Attack_Count(context)
return ScriptLib.GetGroupVariableValue(context,"sandworm_attack_count",0)
end
--------------------------------------------------------------------------------------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,275 @@
--[[======================================
|| filename:
|| owner: luyao.huang
|| description:
|| LogName:
|| Protection:
=======================================]]--
------
local local_defs = {
request_list_capacity = 3,
--占据90010000后的若干字段不要占用这些字段的var
array_base_offset = 90010000
}
local request_struct =
{
group_id = "group_id",
priority = "priority",
}
--所有数组定义
--结构为[数组名] = 最大容量
local arrays =
{
[request_struct.group_id] = {capacity = local_defs.request_list_capacity},
[request_struct.priority] = {capacity = local_defs.request_list_capacity},
}
local Tri = {
[1] = { name = "group_will_unload_sandworm_control_V2", config_id = 10030001, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_sandworm_control_V2", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
local current_offset = local_defs.array_base_offset
for k,v in pairs(arrays) do
local array_name = k
local array_capacity = v.capacity
for i = 1, array_capacity do
local var_id = current_offset + i
table.insert(variables,{ config_id = var_id, name = array_name.."_"..tostring(i), value = -1})
end
current_offset = current_offset + array_capacity
end
table.insert(variables,{ config_id = 80010001, name = "max_priority_request_index", value = -1})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_group_will_unload_sandworm_control_V2(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] Group_will_unload: group即将卸载清空指令列表")
for i = 1, local_defs.request_list_capacity do
LF_Remove_Request_From_List_By_Index(context,i)
end
ScriptLib.SetGroupVariableValue(context,"max_priority_request_index",-1)
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
--请求新增沙虫参数
function LF_Request_Create_Sandworm_Params(context,prev_context,group_id,priority)
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] LF_Request_Create_Sandworm_Timeaxis: 外部请求:请求新增沙虫参数")
local create_request =
{
group_id = group_id,
priority = priority,
}
local ret = LF_Insert_Request_To_List(context,create_request)
return ret
end
--请求清除沙虫参数
function LF_Request_Remove_Sandworm_Params(context,prev_context,destroy_request_id)
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] LF_Request_Create_Sandworm_Timeaxis: 外部请求:请求清除沙虫参数")
local index = LF_Get_Request_Index_From_List_By_Request_Id(context,destroy_request_id)
if index == -1 then
return -1
end
LF_Remove_Request_From_List_By_Index(context,index)
return 0
end
--将一个请求置入请求列表
function LF_Insert_Request_To_List(context,request)
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] LF_Insert_Request_To_List: 将请求置入请求列表")
local i = LF_Array_Get_First_Empty_I(context,request_struct.group_id)
if i == -1 then
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] LF_Insert_Request_To_List: 请求列表没有空位了!!")
return -1
end
local group_id = request.group_id
local priority = request.priority
LF_Array_Set_I(context,request_struct.group_id,i,group_id)
LF_Array_Set_I(context,request_struct.priority,i,priority)
--如果当前请求优先级大于当前列表内的最大请求优先级更新最大优先级
if priority > LF_Get_Max_Priority_Request(context).priority then
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] LF_Insert_Request_To_List: 输入请求高于当前最大优先级,进行更新")
LF_Update_Max_Priority_Index(context,i)
end
return 0
end
--根据index清除一个列表中的请求
function LF_Remove_Request_From_List_By_Index(context,i)
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] LF_Insert_Request_To_List: 将请求从请求列表移除")
LF_Array_Set_I(context,request_struct.group_id,i,-1)
LF_Array_Set_I(context,request_struct.priority,i,-1)
if i == ScriptLib.GetGroupVariableValue(context,"max_priority_request_index") then
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] LF_Remove_Request_From_List_By_Index: 更新当前最大优先级请求")
LF_Calc_Max_Priority_Request_Index(context)
end
return 0
end
--更新当前最大优先级
function LF_Update_Max_Priority_Index(context,index)
ScriptLib.SetGroupVariableValue(context,"max_priority_request_index",index)
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] LF_Update_Max_Priority_Index: 更新最大优先级请求idid为"..index)
end
--计算当前列表中最大优先级的请求的index
function LF_Calc_Max_Priority_Request_Index(context)
local max_priority = -999
local max_priority_index = -1
for i = 1, arrays[request_struct.priority].capacity do
local priority = LF_Array_Get_I(context,request_struct.priority,i)
if priority > max_priority then
max_priority = priority
max_priority_index = i
end
end
ScriptLib.SetGroupVariableValue(context,"max_priority_request_index",max_priority_index)
end
--从请求列表中获取一个请求的indexrequestid查询只查到第一个
function LF_Get_Request_Index_From_List_By_Request_Id(context,request_id)
for i = 1, arrays[request_struct.group_id].capacity do
if LF_Array_Get_I(context,request_struct.group_id,i) == request_id then
return i
end
end
return -1
end
--从请求列表中获取一个请求id查询
function LF_Get_Request_From_List_By_Index(context,i)
local ret_request =
{
group_id = LF_Array_Get_I(context,request_struct.group_id,i),
priority = LF_Array_Get_I(context,request_struct.priority,i),
sandworm_params_config_id = LF_Array_Get_I(context,request_struct.sandworm_params_config_id,i)
}
return ret_request
end
--获取最大优先级的请求也是现在沙虫使用的参数
function LF_Get_Max_Priority_Request(context)
local index = ScriptLib.GetGroupVariableValue(context,"max_priority_request_index")
return LF_Get_Request_From_List_By_Index(context,index)
end
--获取请求列表当前非空元素的个数
function LF_Get_Request_List_Count(context)
local count = 0
for i = 1, arrays[request_struct.group_id].capacity do
local group_id = LF_Array_Get_I(context,request_struct.group_id,i)
if group_id > 0 then
count = count + 1
end
end
return count
end
--[[-----------------------------------------------------------------
|| ||
|| 数组方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Array_Get_I(context,array_name,i)
return ScriptLib.GetGroupVariableValue(context,array_name.."_"..tostring(i))
end
function LF_Array_Set_I(context,array_name,i,v)
ScriptLib.SetGroupVariableValue(context,array_name.."_"..tostring(i),v)
end
--返回数组中第一个非空值
function LF_Array_Get_First_Empty_I(context,array_name)
for i = 1, arrays[array_name].capacity do
if LF_Array_Get_I(context,array_name,i) == -1 then
return i
end
end
return -1
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Print_Table(context,print_table)
for k,v in pairs(print_table) do
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] "..k.." : "..v)
end
end
function LF_Print_Current_Request_List(context)
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] ==================")
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] 开始打印当前请求列表")
for i = 1, local_defs.request_list_capacity do
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] group_id: ")
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] group_id: "..i)
for k,v in pairs(arrays) do
local value = LF_Array_Get_I(context,k,i)
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] "..k.." : "..value)
end
end
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] 打印结束")
ScriptLib.PrintContextLog(context,"## [SandwormControlV2] ==================")
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,106 @@
--[[======================================
|| filename: SandwormManager
|| owner: luyao.huang
|| description:
|| LogName: SandwormManager
|| Protection:
=======================================]]--
------
local manager_Tri = {
[1] = { name = "group_will_unload_sandworm_manager", config_id = 100000001, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload_sandworm_manager", trigger_count = 0},
}
function manager_Initialize()
for k,v in pairs(manager_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id = 100000001, name = "current_sandworm_origin_group", value = -1})
table.insert(variables,{ config_id = 100000002, name = "current_sandworm_priority", value = -1})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_group_will_unload_sandworm_manager(context,evt)
ScriptLib.PrintContextLog(context,"## [SandwormManager] Group_will_unload: group即将卸载清空当前沙虫占用信息")
ScriptLib.SetGroupVariableValue(context,"current_sandworm_origin_group",-1)
ScriptLib.SetGroupVariableValue(context,"current_sandworm_priority",-1)
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Request_Create_Sandworm(context,prev_context,origin_group,priority)
ScriptLib.PrintContextLog(context,"## [SandwormManager] LF_Request_Create_Sandworm: 请求创建沙虫来源group为"..origin_group..",优先级为"..priority)
local current_sandworm_priority = ScriptLib.GetGroupVariableValue(context,"current_sandworm_priority")
local current_sandworm_origin_group = ScriptLib.GetGroupVariableValue(context,"current_sandworm_origin_group")
if current_sandworm_origin_group == -1 and current_sandworm_priority == -1 then
ScriptLib.PrintContextLog(context,"## [SandwormManager] LF_Request_Create_Sandworm: 当前占用列表为空,允许创建")
ScriptLib.SetGroupVariableValue(context,"current_sandworm_origin_group",origin_group)
ScriptLib.SetGroupVariableValue(context,"current_sandworm_priority",priority)
return 0
end
if priority <= current_sandworm_priority then
ScriptLib.PrintContextLog(context,"## [SandwormManager] LF_Request_Create_Sandworm: 低于当前占用的优先级,不允许创建")
ScriptLib.PrintContextLog(context,"## [SandwormManager] LF_Request_Create_Sandworm: 当前的占用来源group为"..current_sandworm_origin_group..",优先级为"..current_sandworm_priority)
return -1
else
ScriptLib.PrintContextLog(context,"## [SandwormManager] LF_Request_Create_Sandworm: 高于当前占用的优先级,允许创建")
ScriptLib.PrintContextLog(context,"## [SandwormManager] LF_Request_Create_Sandworm: 当前的占用来源group为"..current_sandworm_origin_group..",优先级为"..current_sandworm_priority)
ScriptLib.ExecuteGroupLua(context,current_sandworm_origin_group,"LF_Request_Remove_Sandworm_From_Manager",{})
ScriptLib.SetGroupVariableValue(context,"current_sandworm_origin_group",origin_group)
ScriptLib.SetGroupVariableValue(context,"current_sandworm_priority",priority)
return 0
end
end
function LF_Request_Clear_Occupation(context,prev_context,origin_group)
ScriptLib.PrintContextLog(context,"## [SandwormManager] LF_Request_Clear_Occupation: 请求清除沙虫占用来源group为"..origin_group)
local current_sandworm_origin_group = ScriptLib.GetGroupVariableValue(context,"current_sandworm_origin_group")
if current_sandworm_origin_group == origin_group then
ScriptLib.PrintContextLog(context,"## [SandwormManager] LF_Request_Clear_Occupation: 与当前的占用group匹配")
ScriptLib.SetGroupVariableValue(context,"current_sandworm_origin_group",-1)
ScriptLib.SetGroupVariableValue(context,"current_sandworm_priority",-1)
return 0
end
return -1
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
------------------------------------------------------------------
manager_Initialize()

View File

@@ -0,0 +1,103 @@
--[[======================================
|| filename: SandwormPlayControl
|| owner: luyao.huang
|| description:
|| LogName: SandwormPlayControl
|| Protection:
=======================================]]--
local business_type = "direct"
local priority = 3
local local_defs =
{
sandworm_manager_group = 133314001,
}
local challenge_Tri = {
}
function challenge_Initialize()
for k,v in pairs(challenge_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--沙虫攻击次数计数开关打开后才会开始计数
table.insert(variables,{ config_id = 100010001, name = "is_attack_count", value = 0})
--沙虫攻击次数计数
table.insert(variables,{ config_id = 100010002, name = "attack_count", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| 沙虫控制回调 ||
|| ||
-----------------------------------------------------------------]]--
--沙虫控制回调创建沙虫成功
function LF_On_Create_Sandworm_Success(context)
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]LF_On_Create_Sandworm_Success: 沙虫控制回调:创建沙虫成功")
end
--沙虫控制回调创建沙虫失败
function LF_On_Create_Sandworm_Fail(context)
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]LF_On_Create_Sandworm_Success: 沙虫控制回调:创建沙虫失败")
end
--沙虫控制回调移除沙虫
function LF_On_Remove_Sandworm(context)
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]LF_On_Create_Sandworm_Success: 沙虫控制回调:清除沙虫")
end
--沙虫控制回调沙虫攻击完成
function LF_On_Attack_Finish(context)
ScriptLib.PrintContextLog(context,"## [SandwormchallengeControl]LF_On_Attack_Finish: 沙虫控制回调:攻击完成")
if LF_Is_Attack_Count(context) then
ScriptLib.ChangeGroupVariableValue(context,"attack_count",1)
end
end
--沙虫控制回调沙虫攻击命中玩家
function LF_On_Attack_Hit_Avatar(context)
if LF_Is_Attack_Count(context) then
ScriptLib.ChangeGroupVariableValue(context,"attack_count",1)
end
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫攻击计数 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Start_Attack_Count(context)
ScriptLib.SetGroupVariableValue(context,"is_attack_count",1)
end
function LF_Stop_Attack_Count(context)
ScriptLib.SetGroupVariableValue(context,"is_attack_count",0)
end
function LF_Is_Attack_Count(context)
return ScriptLib.GetGroupVariableValue(context,"is_attack_count")
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
------------------------------------------------------------------
challenge_Initialize()

View File

@@ -0,0 +1,371 @@
--[[======================================
|| filename: SandwormToolkit
|| owner: luyao.huang
|| description: 整合了各类沙虫控制方法可以直接调用或通过tpl调用
|| LogName: SandwormToolkit
|| Protection:
=======================================]]--
--local defs = {
-- alert_max_value = 1000,
-- normal_sandworm_id = 1030,
-- direct_sandworm_id = 1035,
-- business_type = "bigworld"
--}
local local_defs =
{
sandworm_manager_group = 133314001,
}
local toolkit_Tri = {
[1] = { name = "platform_arrival_toolkit", config_id = 900010001, event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_platform_arrival_toolkit", trigger_count = 0},
}
function toolkit_Initialize()
for k,v in pairs(toolkit_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id = 900020001, name = "is_sandworm_alive", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 创生沙虫 ||
|| ||
-----------------------------------------------------------------]]--
--能否创建沙虫
--比较当前优先级和当前占用沙虫的group的优先级如果优先级较高则允许这里创建并让另外一边的沙虫销毁否则无视这条请求不允许创建
function LF_Try_Create_Sandworm(context)
return ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_manager_group,"LF_Request_Create_Sandworm",{base_info.group_id,priority}) == 0
end
--召唤沙虫的对外接口
--召唤一只移动表演用沙虫
function LF_Summon_Move_Sandworm(context,attack_times)
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Move_Sandworm: 请求创生一个移动表演沙虫")
if defs.move_sandworm_id == nil then
ScriptLib.PrintGroupWarning(context,"## [SandwormToolkit] LF_Summon_Move_Sandworm: 请求失败,没有填写一个直接攻击沙虫!!")
return -1
end
if LF_Try_Create_Sandworm(context) then
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Move_Sandworm: 当前沙虫未被占用,开始创建")
LF_Create_Move_Sandworm(context,attack_times)
ScriptLib.SetGroupVariableValue(context,"is_sandworm_alive",1)
LF_On_Create_Sandworm_Success(context)
return 0
else
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Move_Sandworm: 当前沙虫被占用,创建失败")
LF_On_Create_Sandworm_Fail(context)
return -1
end
end
--命令巡游沙虫进行攻击
--如果巡游沙虫在场则直接命令这个gadget发动一次攻击
--如果不在场则直接在随机位置生成沙虫后向玩家攻击
function LF_Command_Move_Sandworm_Attack(context,attack_times)
local is_sandworm_alive = ScriptLib.GetGroupVariableValue(context,"is_sandworm_alive") == 1
if is_sandworm_alive then
--如果当前沙虫在场直接命令沙虫向玩家发动一次攻击
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.move_sandworm_id, "SGV_Shoot_Sandworm", 1)
else
--如果当前沙虫不在场召出沙虫以后再命令其向玩家发动一次攻击
if LF_Try_Create_Sandworm(context) then
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Command_Move_Sandworm_Attack: 当前沙虫未被占用,开始创建")
local point_list = {}
for i = 1, sandworm_point_array.max_point do
table.insert(point_list,i)
end
local point_info_list = LF_Get_Point_Info_List(context,sandworm_point_array.point_array,point_list)
local born_point = LF_Get_Random_Point(context,point_info_list,{})
local born_pos = born_point.pos
ScriptLib.CreateGadgetByParamTable(context,{config_id = defs.move_sandworm_id,pos = {x=born_pos.x,y=born_pos.y,z=born_pos.z}, rot = {x=0,y=0,z=0},
sgv_key = {"SGV_Attack_Times","SGV_Shoot_Sandworm"}, sgv_value = {attack_times,0}})
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.move_sandworm_id, "SGV_Shoot_Sandworm", 1)
LF_On_Create_Sandworm_Success(context)
else
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Command_Move_Sandworm_Attack: 当前沙虫被占用,创建失败")
LF_On_Create_Sandworm_Fail(context)
return -1
end
end
end
--在指定位置召唤一只直接攻击沙虫
function LF_Summon_Direct_Sandworm(context,pos,attack_times)
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Direct_Sandworm: 请求创生一只直接攻击沙虫")
if defs.direct_sandworm_id == nil then
ScriptLib.PrintGroupWarning(context,"## [SandwormToolkit] LF_Summon_Direct_Sandworm: 请求失败,没有填写一个直接攻击沙虫!!")
return -1
end
if LF_Try_Create_Sandworm(context) then
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Direct_Sandworm: 当前沙虫未被占用,开始创建")
LF_Create_Direct_Sandworm(context,pos,attack_times,1)
ScriptLib.SetGroupVariableValue(context,"is_sandworm_alive",2)
LF_On_Create_Sandworm_Success(context)
return 0
else
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Direct_Sandworm: 当前沙虫被占用,创建失败")
LF_On_Create_Sandworm_Fail(context)
return -1
end
end
--在玩家脚下召唤一只直接攻击沙虫
function LF_Summon_Direct_Sandworm_By_Avatar(context,uid,attack_times)
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Direct_Sandworm_By_Avatar: 在玩家脚下创生一只直接攻击沙虫")
local owner_eid = ScriptLib.GetAvatarEntityIdByUid(context,uid)
local pos = ScriptLib.GetPosByEntityId(context,owner_eid)
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Direct_Sandworm_By_Avatar: 请求创生在玩家脚下创生直接攻击沙虫")
if defs.direct_sandworm_id == nil then
ScriptLib.PrintGroupWarning(context,"## [SandwormToolkit] LF_Summon_Direct_Sandworm_By_Avatar: 请求失败,没有填写一个直接攻击沙虫!!")
return -1
end
if LF_Try_Create_Sandworm(context) then
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Direct_Sandworm_By_Avatar: 当前沙虫未被占用,开始创建")
LF_Create_Direct_Sandworm(context,pos,attack_times,1)
ScriptLib.SetGroupVariableValue(context,"is_sandworm_alive",1)
LF_On_Create_Sandworm_Success(context)
return 0
else
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Summon_Direct_Sandworm_By_Avatar: 当前沙虫被占用,创建失败")
LF_On_Create_Sandworm_Fail(context)
return -1
end
end
--------------------------------------------------------------------------------------------------------------------
--召唤沙虫的实现接口
--创建一只移动沙虫
function LF_Create_Move_Sandworm(context,attack_times)
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Create_Move_Sandworm: 创建一只移动表演用沙虫")
local point_list = {}
for i = 1, sandworm_point_array.max_point do
table.insert(point_list,i)
end
local point_info_list = LF_Get_Point_Info_List(context,sandworm_point_array.point_array,point_list)
local born_point = LF_Get_Random_Point(context,point_info_list,{})
local born_pos = born_point.pos
ScriptLib.CreateGadgetByParamTable(context,{config_id = defs.move_sandworm_id,pos = {x=born_pos.x,y=born_pos.y,z=born_pos.z}, rot = {x=0,y=0,z=0},
sgv_key = {"SGV_Attack_Times"}, sgv_value = {attack_times}})
local black_list = {born_point.point_id}
local target_point = LF_Get_Random_Point(context,point_info_list,black_list)
ScriptLib.SetPlatformPointArray(context,defs.move_sandworm_id, sandworm_point_array.point_array, {target_point.point_id}, { route_type = 0,turn_mode=false, record_mode = 2 })
end
function action_platform_arrival_toolkit(context,evt)
if evt.param1 == defs.move_sandworm_id then
local point_list = {}
for i = 1, sandworm_point_array.max_point do
table.insert(point_list,i)
end
local point_info_list = LF_Get_Point_Info_List(context,sandworm_point_array.point_array,point_list)
local target_point = LF_Get_Random_Point(context,point_info_list,{})
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] action_platform_arrival_sandworm移动沙虫目标点为"..target_point.point_id)
ScriptLib.SetPlatformPointArray(context,defs.move_sandworm_id, sandworm_point_array.point_array, {target_point.point_id}, { route_type = 0,turn_mode=false, record_mode = 2 })
end
return 0
end
--在指定地点创建一只直接攻击沙虫
function LF_Create_Direct_Sandworm(context,pos,attack_times,target_stragety)
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Create_Direct_Sandworm: 创建一只直接攻击用沙虫")
--ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Create_Direct_Sandworm: direct_sandworm_id参数为"..defs.direct_sandworm_id)
--ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Create_Direct_Sandworm: pos参数为"..pos.x..","..pos.y..","..pos.z)
--ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Create_Direct_Sandworm: attack_times参数为"..attack_times)
--ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Create_Direct_Sandworm: target_stragety参数为"..target_stragety)
local ret = ScriptLib.CreateGadgetByParamTable(context,{config_id = defs.direct_sandworm_id,pos = {x=pos.x,y=pos.y,z=pos.z}, rot = {x=0,y=0,z=0},
sgv_key = {"SGV_Attack_Times","SGV_Target_Stragety"}, sgv_value = {attack_times,target_stragety}})
--ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Create_Direct_Sandworm: 创建结果为"..ret)
end
--清理移动沙虫
function LF_Remove_Move_Sandworm(context)
if defs.move_sandworm_id ~= nil then
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Remove_Move_Sandworm: 清除移动沙虫")
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.move_sandworm_id)
--清除掉沙虫的占用
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_manager_group,"LF_Request_Clear_Occupation",{base_info.group_id})
ScriptLib.SetGroupVariableValue(context,"is_sandworm_alive",0)
LF_On_Remove_Sandworm(context)
end
end
--清理直接攻击沙虫
function LF_Remove_Direct_Sandworm(context)
if defs.direct_sandworm_id ~= nil then
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Remove_Direct_Sandworm: 清除直接攻击沙虫")
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.direct_sandworm_id)
--清除掉沙虫的占用
ScriptLib.ExecuteGroupLua(context,local_defs.sandworm_manager_group,"LF_Request_Clear_Occupation",{base_info.group_id})
ScriptLib.SetGroupVariableValue(context,"is_sandworm_alive",0)
LF_On_Remove_Sandworm(context)
end
end
--清除所有沙虫不管类型
function LF_Remove_All_Sandworm(context)
LF_Remove_Move_Sandworm(context)
LF_Remove_Direct_Sandworm(context)
end
--[[-----------------------------------------------------------------
|| ||
|| 外部调用 ||
|| ||
-----------------------------------------------------------------]]--
--外部调用请求清除当前group正在使用的沙虫
function LF_Request_Remove_Sandworm_From_Manager(context,prev_context)
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] LF_Request_Remove_Sandworm控制group请求移除当前沙虫")
LF_Remove_All_Sandworm(context)
return 0
end
--外部调用SLC返回沙虫攻击完毕
function SLC_Sandworm_Attack_Finish(context)
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] SLC_Sandworm_Attack_FinishSLC沙虫攻击完毕")
LF_Remove_All_Sandworm(context)
LF_On_Attack_Finish(context)
return 0
end
--外部调用SLC返回沙虫命中角色
function SLC_Sandworm_Attack_Hit_Avatar(context)
ScriptLib.PrintContextLog(context,"## [SandwormToolkit] SLC_Sandworm_Attack_Hit_Avatar沙虫攻击击中玩家")
LF_On_Attack_Hit_Avatar(context)
return 0
end
function SLC_Clear_Move_Sandworm_Command(context)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.move_sandworm_id, "SGV_Shoot_Sandworm", 0)
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 沙虫选点 ||
|| ||
-----------------------------------------------------------------]]--
--获取特定点阵的所有点信息
function LF_Get_Point_Info_List(context,point_array,point_list)
local point_info_list = {}
for i = 1, #point_list do
local ret,pos,rot=ScriptLib.GetPlatformArrayInfoByPointId(context,point_array, point_list[i])
local point_info = {point_id = point_list[i], pos = pos, rot = rot}
table.insert(point_info_list,point_info)
end
return point_info_list
end
--找到玩家附近最近的一个点可以剔除一些点
function LF_Get_Nearest_Point_By_Avatar(context,point_info_list,black_list)
local nearest_point = -1
local nearest_distance = 10000000
for k,v in pairs(point_info_list) do
if not LF_Is_In_Table(context,v.point_id,black_list) then
local uid = ScriptLib.GetSceneOwnerUid(context)
local distance = LF_Get_Point_Avatar_Distance(context,uid,v.pos)
if distance < nearest_distance then
nearest_distance = distance
nearest_point = v
end
end
end
return nearest_point
end
function LF_Get_Random_Point(context,point_info_list,black_list)
local target_point_info_list = {}
for k,v in pairs(point_info_list) do
if not LF_Is_In_Table(context,v.point_id,black_list) then
table.insert(target_point_info_list,v)
end
end
local r = math.random(#target_point_info_list)
return target_point_info_list[r]
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Get_Point_Avatar_Distance(context,uid,point_pos)
local owner_eid = ScriptLib.GetAvatarEntityIdByUid(context,uid)
local pos = ScriptLib.GetPosByEntityId(context,owner_eid)
return LF_Get_2D_Distance(context,pos,point_pos)
end
function LF_Get_2D_Distance(context,p1,p2)
return math.sqrt((p1.x-p2.x)*(p1.x-p2.x)+ (p1.z-p2.z)*(p1.z-p2.z))
end
--获取指定位置的随机近邻位置分布在min_r~max_r为半径的环上
function LF_Get_Random_Neighbour(context,pos,min_r,max_r)
local random_r = math.random(min_r,max_r)
local random_a = math.random()*math.pi*2
local rpos_x = pos.x + random_r * math.cos(random_a)
local rpos_z = pos.z + random_r * math.sin(random_a)
local rpos = {x = rpos_x,y = pos.y,z = rpos_z}
return rpos
end
function LF_Is_In_Table(context,v,t)
for i = 1, #t do
if t[i] == v then
return true
end
end
return false
end
------------------------------------------------------------------
toolkit_Initialize()

View File

@@ -0,0 +1,290 @@
--[[======================================
|| filename: ScarletKingFan
|| owner: luyao.huang
|| description: 赤王风扇玩法
|| LogName: ScarletKingFan
|| Protection:
=======================================]]--
------
local local_defs =
{
}
local options =
{
switch_open = 5000,
switch_close = 5001,
move_fan = 436,
}
local fan_state =
{
lock = 0,
move = 101,
dir1 = 201,
dir2 = 202,
dir3 = 203,
dir4 = 204
}
local shutter_state =
{
close = 0,
open = 201,
}
local shutter_switch_state =
{
close = 0,
open = 201,
}
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 = "gadget_state_change", config_id = 8000002, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
[3] = { name = "select_option", config_id = 8000003, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[4] = { name = "platform_arrival", config_id = 8000004, event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_platform_arrival", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--记录风扇的位置
for i = 1, #fans do
table.insert(variables,{config_id = 110000000+i, name = "fan_pos_"..fans[i], value = 1})
--用来暂存风扇移动前的状态移动后恢复到这个状态
table.insert(variables,{config_id = 120000000+i, name = "fan_pre_move_state_"..fans[i], value = 201})
end
end
------------------------------------------------------------------
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]action_group_loadgroup加载")
for i = 1, #fans do
if FanToPointArray[fans[i]] ~= nil then
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]action_group_load给风扇上选项")
LF_Set_Fan_Option(context,fans[i],true)
ScriptLib.SetGroupVariableValue(context,"fan_pos_"..fans[i],1)
ScriptLib.SetGroupVariableValue(context,"fan_pre_move_state_"..fans[i],201)
end
end
for i = 1, #shutter_switches do
LF_Set_Shutter_Switch_Option(context,shutter_switches[i])
end
return 0
end
--风扇转向百叶墙壁开关开关百叶墙壁开关
function action_gadget_state_change(context,evt)
if LF_Is_In_Table(context,evt.param2,fans) then
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]action_gadget_state_change风扇状态变化")
local state = evt.param1
local fan = evt.param2
if evt.param3 == fan_state.lock then
LF_Set_Fan_Option(context,fan,true)
end
if state == fan_state.dir1 or state == fan_state.dir2 or state == fan_state.dir3 or state == fan_state.dir4 then
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]action_gadget_state_change风扇转向更新沙堆状态")
LF_Update_Sandpile_State(context, fan)
end
end
if LF_Is_In_Table(context,evt.param2,shutter_switches) then
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]action_gadget_state_change百叶窗开关状态变化")
LF_Set_Shutter_Switch_Option(context,evt.param2)
end
return 0
end
function action_select_option(context,evt)
if LF_Is_In_Table(context,evt.param1,shutter_switches) then
if evt.param2 == options.switch_close then
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]action_select_option按下百叶窗"..evt.param1.."的关闭开关")
--按下开关改开关的状态
ScriptLib.SetGadgetStateByConfigId(context,evt.param1, shutter_switch_state.close)
--按下开关改开关连接的百叶墙壁的状态
ScriptLib.SetGadgetStateByConfigId(context,SwitchToShutter[evt.param1],shutter_state.close)
end
if evt.param2 == options.switch_open then
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]action_select_option按下百叶窗"..evt.param1.."的打开开关")
--按下开关改开关的状态
ScriptLib.SetGadgetStateByConfigId(context,evt.param1, shutter_switch_state.open)
--按下开关改开关连接的百叶墙壁的状态
ScriptLib.SetGadgetStateByConfigId(context,SwitchToShutter[evt.param1],shutter_state.open)
end
end
if LF_Is_In_Table(context,evt.param1,fans) then
if evt.param2 == options.move_fan then
local fan = evt.param1
local current_pos = ScriptLib.GetGroupVariableValue(context,"fan_pos_"..fan)
local pos = 3 - current_pos
local pre_move_state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,fan)
ScriptLib.SetGroupVariableValue(context,"fan_pre_move_state_"..fan,pre_move_state)
ScriptLib.SetGadgetStateByConfigId(context,fan, fan_state.move)
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]action_select_option移动风扇"..fan.."到点位"..pos)
if current_pos == 1 then
ScriptLib.SetPlatformPointArray(context,fan,FanToPointArray[fan], {1,2}, { route_type = 0,turn_mode=false, record_mode = 1 })
else
ScriptLib.SetPlatformPointArray(context,fan,FanToPointArray[fan], {2,1}, { route_type = 0,turn_mode=false, record_mode = 1 })
end
ScriptLib.StartPlatform(context,fan)
--移动时关闭选项
LF_Set_Fan_Option(context,fan,false)
end
end
return 0
end
function action_platform_arrival(context,evt)
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]action_platform_arrival风扇到达路点")
local fan = evt.param1
local point_id = evt.param3
local pos = ScriptLib.GetGroupVariableValue(context,"fan_pos_"..fan)
--和LD约定所有风扇只有两个端点因此pos只会为1或者2
local target_pos = 3 - pos
if point_id == target_pos then
--运动到端点时根据运动前的状态恢复gadgetState
local pre_move_state = ScriptLib.GetGroupVariableValue(context,"fan_pre_move_state_"..fan)
if pre_move_state ~= fan_state.dir1 and pre_move_state ~= fan_state.dir2 and pre_move_state ~= fan_state.dir3 and pre_move_state ~= fan_state.dir4 then
pre_move_state = fan_state.dir1
end
ScriptLib.SetGadgetStateByConfigId(context,fan, pre_move_state)
--ScriptLib.StopPlatform(context,fan)
ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,fan,{options.move_fan})
ScriptLib.SetGroupVariableValue(context,"fan_pos_"..fan,target_pos)
LF_Update_Sandpile_State(context, fan)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Update_Sandpile_State(context, fan)
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]LF_Update_Sandpile_State更新"..fan.."相关的沙堆状态")
for k,v in pairs(FanToSandpile) do
if v.fan == fan then
local pos = ScriptLib.GetGroupVariableValue(context,"fan_pos_"..fan)
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]LF_Update_Sandpile_State当前风扇位置为"..pos)
local dir_state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,fan)
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]LF_Update_Sandpile_State当前风扇方向状态为"..dir_state)
local fan_shutter_state
if v.shutter ~= nil then
fan_shutter_state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,v.shutter)
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]LF_Update_Sandpile_State当前风扇路径上的百叶窗状态为"..fan_shutter_state)
else
fan_shutter_state = shutter_state.open
end
if pos == v.pos and dir_state == v.dir_state and fan_shutter_state == shutter_state.open then
ScriptLib.PrintContextLog(context,"## [ScarletKingFan]LF_Update_Sandpile_State沙堆"..k.."目前符合吹风机的状态,销毁沙堆")
ScriptLib.SetGadgetStateByConfigId(context,k, 201)
--ScriptLib.KillEntityByConfigId(context, {config_id = k})
end
end
end
end
function LF_Set_Fan_Option(context,fan,enable)
local flag = false
if FanToPointArray ~= nil then
for k,v in pairs(FanToPointArray) do
if k == fan then
flag = true
end
end
end
if flag then
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,fan)
if state == 0 or state == 101 then
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,fan,options.move_fan)
else
if enable then
ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,fan,{options.move_fan})
else
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,fan,options.move_fan)
end
end
end
end
function LF_Set_Shutter_Switch_Option(context,switch)
local state = ScriptLib.GetGadgetStateByConfigId(context,base_info.group_id,switch)
if state == 0 then
ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,switch,{options.switch_open})
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,switch,options.switch_close)
elseif state == 201 then
ScriptLib.SetWorktopOptionsByGroupId(context,base_info.group_id,switch,{options.switch_close})
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id,switch,options.switch_open)
end
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Is_In_Table(context,v,t)
for i = 1, #t do
if t[i] == v then
return true
end
end
return false
end
function LF_Get_Index_In_Table(context,v,t)
for i = 1, #t do
if t[i] == v then
return i
end
end
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,202 @@
--[[======================================
|| filename: ShelterWorktopControl
|| owner: luyao.huang
|| description: 避难所精灵台座控制
|| LogName: ShelterWorktopControl
|| Protection:
=======================================]]--
--local defs =
--{
-- gadget_worktop_id = 100001,
--}
------
local local_defs = {
max_level = 6,
chain_id = 100005,
energy_level_1 = 2,
energy_amount_1 = 1,
energy_level_2 = 5,
energy_amount_2 = 3,
unlock_worktop_level = 4,
skip_sandstorm_option = 5100,
start_sandstorm_option = 5101,
sandstorm_state_leveltag = 21,
sandstorm_on = 59,
sandstorm_off = 60,
sandstorm_control_group = 133314001,
skip_teyvat_time = 8 * 60,
skip_time = 8
}
local Tri = {
[1] = { name = "group_load_shelter", config_id = 11000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load_shelter", trigger_count = 0},
[2] = { name = "select_option_shelter", config_id = 11000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option_shelter", trigger_count = 0},
[3] = { name = "time_axis_pass_shelter", config_id = 11000003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass_shelter", 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 = 110000001, name = "is_skipping_time", value = 0})
table.insert(variables,{config_id = 150000001, name = "GM_Upgrade_Chain_Level", value = 0})
table.insert(variables,{config_id = 150000002, name = "GM_Recover_Energy", value = 0})
table.insert(variables,{config_id = 150000003, name = "GM_Set_Chain_Level", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
--玩法加载初始化
function action_group_load_shelter(context,evt)
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_group_load_sheltergroup加载给精灵台座上选项")
return 0
end
function action_select_option_shelter(context,evt)
if evt.param2 == local_defs.skip_sandstorm_option then
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_select_option_shelter玩家选择选项跳过沙尘暴")
ScriptLib.SkipTeyvatTime(context,local_defs.skip_teyvat_time,1)
ScriptLib.InitTimeAxis(context,"SKIP_TYVAT_TIME_AXIS", {local_defs.skip_time}, false)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.skip_sandstorm_option)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.start_sandstorm_option)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.gadget_worktop_id, "SGV_Gear_Option", 1)
ScriptLib.SetGroupVariableValue(context,"is_skipping_time",1)
--调用沙尘暴控制group跳过当前沙尘暴
local sandstorm_state = ScriptLib.GetGroupVariableValueByGroup(context,"sandstorm_state",local_defs.sandstorm_control_group)
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_select_option_shelter当前沙尘暴状态为"..sandstorm_state)
if sandstorm_state == 1 then
local ret = ScriptLib.ExecuteGroupLua(context, local_defs.sandstorm_control_group, "LF_Skip_Current_Sandstorm", {})
if ret == -1 then
ScriptLib.PrintGroupWarning(context,"## [Warning] [ShelterWorktopControl] action_select_option_shelter调用控制group的跳过沙尘暴天气功能失败")
end
end
end
if evt.param2 == local_defs.start_sandstorm_option then
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_select_option_shelter玩家选择选项开启沙尘暴")
ScriptLib.SkipTeyvatTime(context,local_defs.skip_teyvat_time,1)
ScriptLib.InitTimeAxis(context,"SKIP_TYVAT_TIME_AXIS", {local_defs.skip_time}, false)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.skip_sandstorm_option)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.start_sandstorm_option)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.gadget_worktop_id, "SGV_Gear_Option", 2)
ScriptLib.SetGroupVariableValue(context,"is_skipping_time",1)
--调用沙尘暴控制group跳过当前沙尘暴
local sandstorm_state = ScriptLib.GetGroupVariableValueByGroup(context,"sandstorm_state",local_defs.sandstorm_control_group)
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_select_option_shelter当前沙尘暴状态为"..sandstorm_state)
if sandstorm_state == 2 then
local ret = ScriptLib.ExecuteGroupLua(context, local_defs.sandstorm_control_group, "LF_Start_Sanstorm", {})
if ret == -1 then
ScriptLib.PrintGroupWarning(context,"## [Warning] [ShelterWorktopControl] action_select_option_shelter调用控制group的开启沙尘暴天气功能失败")
end
end
end
return 0
end
function action_time_axis_pass_shelter(context,evt)
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_time_axis_pass_shelter时间轴tick给精灵台座恢复选项")
local chain_level = ScriptLib.GetChainLevel(context, ScriptLib.GetSceneOwnerUid(context), local_defs.chain_id)
if chain_level >= local_defs.unlock_worktop_level then
LF_Set_Worktop_Option(context)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.gadget_worktop_id, "SGV_Gear_Option", 0)
ScriptLib.SetGroupVariableValue(context,"is_skipping_time",0)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Set_Worktop_Option(context)
local chain_level = ScriptLib.GetChainLevel(context, ScriptLib.GetSceneOwnerUid(context), local_defs.chain_id)
if chain_level >= local_defs.unlock_worktop_level then
local sandstorm_state = ScriptLib.GetGroupVariableValueByGroup(context,"sandstorm_state",local_defs.sandstorm_control_group)
--在沙尘暴中
if sandstorm_state == 1 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.gadget_worktop_id, {local_defs.skip_sandstorm_option})
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.start_sandstorm_option)
end
if sandstorm_state == 2 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.gadget_worktop_id, {local_defs.start_sandstorm_option})
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.skip_sandstorm_option)
end
else
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.skip_sandstorm_option)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.start_sandstorm_option)
end
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
function SLC_Try_Set_Option(context)
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]SLC_Try_Set_Option玩家进入台座范围上选项")
if ScriptLib.GetGroupVariableValue(context,"is_skipping_time") ~= 1 then
LF_Set_Worktop_Option(context)
end
return 0
end
function SLC_Try_Remove_Option(context)
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]SLC_Try_Set_Option玩家进入台座范围没带天气精灵下选项选项")
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.skip_sandstorm_option)
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, defs.gadget_worktop_id, local_defs.start_sandstorm_option)
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,137 @@
--[[======================================
|| filename: WeatherWizardControl
|| owner: luyao.huang
|| description: 天气精灵控制后续会放到ability层处理
|| LogName: WeatherWizardControl
|| Protection:
=======================================]]--
--local defs =
--{
-- energy_worktop_id = 100001,
--}
------
local local_defs = {
max_level = 6,
chain_id = 100005,
energy_level_1 = 2,
energy_amount_1 = 1,
energy_level_2 = 5,
energy_amount_2 = 3,
unlock_worktop_level = 6,
worktop_option = 5000,
sandstorm_state_leveltag = 21,
sandstorm_on = 59,
sandstorm_off = 60,
sandstorm_control_group = 133314001,
skip_time = 8
}
local wizard_Tri = {
[10] = { name = "GM_variable_change_wizard", config_id = 35000001, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_GM_variable_change_wizard", trigger_count = 0},
}
function wizard_Initialize()
for k,v in pairs(wizard_Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{config_id = 110000001, name = "energy_level", value = 0})
table.insert(variables,{config_id = 150000001, name = "GM_Upgrade_Chain_Level", value = 0})
table.insert(variables,{config_id = 150000002, name = "GM_Recover_Energy", value = 0})
table.insert(variables,{config_id = 150000003, name = "GM_Set_Chain_Level", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_GM_variable_change_wizard(context,evt)
if evt.source_name == "GM_Upgrade_Chain_Level" then
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_variable_change_shelter升级天气精灵的等级")
local chain_level = ScriptLib.GetChainLevel(context, ScriptLib.GetSceneOwnerUid(context), local_defs.chain_id)
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_variable_change_shelter当前的等级为"..chain_level)
if chain_level < local_defs.max_level then
chain_level = chain_level + 1
end
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_variable_change_shelter升级后为"..chain_level)
ScriptLib.SetChainLevel(context, local_defs.chain_id, chain_level, true)
ScriptLib.SetTeamServerGlobalValue(context,ScriptLib.GetSceneOwnerUid(context),"SGV_Weather_Wizard_Chain_Level",chain_level)
ScriptLib.SetGroupVariableValue(context,"GM_Upgrade_Chain_Level",0)
end
if evt.source_name == "GM_Set_Chain_Level" then
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_variable_change_shelter修改天气精灵的等级")
local target_level = evt.param1
if evt.param1 > local_defs.max_level then
target_level = local_defs.max_level
end
if evt.param1 < 1 then
target_level = 1
end
ScriptLib.SetChainLevel(context, local_defs.chain_id, target_level, true)
ScriptLib.SetTeamServerGlobalValue(context,ScriptLib.GetSceneOwnerUid(context),"SGV_Weather_Wizard_Chain_Level",target_level)
end
if evt.source_name == "GM_Recover_Energy" then
ScriptLib.PrintContextLog(context,"## [ShelterWorktopControl]action_variable_change_shelter恢复天气精灵的能量")
SLC_Recover_Weather_Wizard_Energy(context)
ScriptLib.SetGroupVariableValue(context,"GM_Recover_Energy",0)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
function SLC_Update_Chain_Level(context)
local chain_level = ScriptLib.GetChainLevel(context, ScriptLib.GetSceneOwnerUid(context), local_defs.chain_id)
ScriptLib.SetTeamServerGlobalValue(context,ScriptLib.GetSceneOwnerUid(context),"SGV_Weather_Wizard_Chain_Level",chain_level)
return 0
end
------------------------------------------------------------------
wizard_Initialize()

View File

@@ -0,0 +1,292 @@
--[[======================================
|| filename: WindBall
|| owner: luyao.huang
|| description: 风球传递玩法
|| LogName: WindBall
|| Protection:
=======================================]]--
--local defs =
--{
-- gadget_worktop_id = 100001,
--}
------
local local_defs = {
get_windball_option = 7,
}
local state_defs =
{
lock = 0,
on_worktop = 201,
taken = 202,
ready_enshrine = 203,
unavailable = 204,
finish = 901,
}
local windball_state_defs =
{
on_worktop = 0,
on_team = 1,
}
local phase_defs =
{
lock = 0,
playing = 1,
finish = 2,
}
local Tri = {
[1] = { name = "select_option_windball", config_id = 11000001, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option_windball", trigger_count = 0},
[2] = { name = "group_load_windball", config_id = 11000002, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load_windball", trigger_count = 0},
[3] = { name = "gadget_state_change_windball", config_id = 11000003, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change_windball", trigger_count = 0},
[4] = { name = "enter_region_windball", config_id = 11000004, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region_windball", trigger_count = 0},
[5] = { name = "leave_region_windball", config_id = 11000005, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region_windball", 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 = 110000001, name = "play_phase", value = 0})
table.insert(variables,{config_id = 110000002, name = "current_worktop", value = 1})
table.insert(variables,{config_id = 110000003, name = "windball_state", value = 0})
end
--[[-----------------------------------------------------------------
|| ||
|| 触发器回调 ||
|| ||
-----------------------------------------------------------------]]--
function action_group_load_windball(context,evt)
ScriptLib.PrintContextLog(context,"## [WindBall]action_group_load_windballgroup加载")
local play_phase = ScriptLib.GetGroupVariableValue(context,"play_phase")
if play_phase == phase_defs.lock then
LF_Lock_Play(context)
end
if play_phase == phase_defs.playing then
LF_Unlock_Play(context)
end
if play_phase == phase_defs.finish then
LF_Finish_Play(context)
end
LF_Unlock_Play(context)
return 0
end
function action_gadget_state_change_windball(context,evt)
local new_state = evt.param1
local old_state = evt.param3
if new_state == state_defs.on_worktop then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, evt.param2, {local_defs.get_windball_option})
else
ScriptLib.DelWorktopOptionByGroupId(context,base_info.group_id, evt.param2, local_defs.get_windball_option)
end
--说明是风球被放到台座上了
if old_state == state_defs.ready_enshrine and new_state == state_defs.on_worktop then
ScriptLib.PrintContextLog(context,"## [WindBall]action_gadget_state_change_windball风球放置在台座:"..evt.param2)
LF_Current_Worktop_Increase(context)
LF_Set_All_Worktops_State(context)
--如果是最后一环的风球
if evt.param2 == windball_worktops[#windball_worktops] then
LF_Finish_Play(context)
end
end
--说明是风球被取走
if old_state == state_defs.ready_enshrine and new_state == state_defs.taken then
ScriptLib.PrintContextLog(context,"## [WindBall]action_gadget_state_change_windball风球从台座"..evt.param2.."被取走")
local current_index = LF_Get_Index_From_List(context,windball_worktops,evt.param2)
if current_index < #windball_worktops then
ScriptLib.PrintContextLog(context,"## [WindBall]action_gadget_state_change_windball第"..current_index.."个操作台")
local next_worktop = windball_worktops[current_index + 1]
local dir_index = LF_Get_Dir_Index(context,evt.param2,next_worktop)
ScriptLib.SetEntityServerGlobalValueByConfigId(context,evt.param2,"SGV_Dir_Light_On",dir_index)
end
end
--说明是出界或者到时间风球被还回去
if old_state == state_defs.taken and new_state == state_defs.on_worktop then
ScriptLib.PrintContextLog(context,"## [WindBall]action_gadget_state_change_windball风球被还回台座"..evt.param2)
LF_Set_All_Worktops_State(context)
end
return 0
end
function action_select_option_windball(context,evt)
if evt.param2 == local_defs.get_windball_option then
ScriptLib.PrintContextLog(context,"## [WindBall]action_select_option_windball玩家选择选项获取风球")
local target_worktop = evt.param1
ScriptLib.SetEntityServerGlobalValueByConfigId(context,target_worktop,"SGV_Message_Release_WindBall",1)
local current_index = LF_Get_Index_From_List(context,windball_worktops,target_worktop)
local worktop_eid = ScriptLib.GetEntityIdByConfigId(context, windball_worktops[current_index+1])
local pos = ScriptLib.GetPosByEntityId(context, worktop_eid)
ScriptLib.CreateGadgetByConfigIdByPos(context,defs.hint_gadget_id, {x=pos.x,y=pos.y,z=pos.z}, {x=0,y=0,z=0})
end
return 0
end
function action_enter_region_windball(context,evt)
if evt.param1 == defs.region_id then
end
return 0
end
function action_leave_region_windball(context,evt)
if evt.param1 == defs.region_id then
LF_Change_Team_SGV(context,evt.uid,"SGV_Message_Remove_Windball",1)
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 玩法流程控制 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Unlock_Play(context)
ScriptLib.PrintContextLog(context,"## [WindBall]LF_Unlock_Play设置玩法阶段进行中")
ScriptLib.SetGroupVariableValue(context,"play_phase",phase_defs.playing)
LF_Set_All_Worktops_State(context)
end
function LF_Lock_Play(context)
ScriptLib.PrintContextLog(context,"## [WindBall]LF_Unlock_Play设置玩法阶段锁定")
ScriptLib.SetGroupVariableValue(context,"play_phase",phase_defs.lock)
for i = 1, #windball_worktops do
ScriptLib.SetGadgetStateByConfigId(context,windball_worktops[i],state_defs.lock)
end
end
function LF_Finish_Play(context)
ScriptLib.PrintContextLog(context,"## [WindBall]LF_Unlock_Play设置玩法阶段完成")
ScriptLib.SetGroupVariableValue(context,"play_phase",phase_defs.finish)
for i = 1, #windball_worktops do
ScriptLib.SetGadgetStateByConfigId(context,windball_worktops[i],state_defs.finish)
end
local uid = ScriptLib.GetSceneOwnerUid(context)
LF_Change_Team_SGV(context,uid,"SGV_Message_Remove_Windball",1)
ScriptLib.CreateGadget(context,{config_id = defs.chest_id})
end
function LF_Set_All_Worktops_State(context)
local current_worktop = ScriptLib.GetGroupVariableValue(context,"current_worktop")
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.hint_gadget_id)
for i = 1, #windball_worktops do
ScriptLib.SetEntityServerGlobalValueByConfigId(context,windball_worktops[i],"SGV_Dir_Light_On",0)
if (i < current_worktop) or (i > current_worktop + 1) then
ScriptLib.SetGadgetStateByConfigId(context,windball_worktops[i],state_defs.unavailable)
end
if i == current_worktop then
ScriptLib.SetGadgetStateByConfigId(context,windball_worktops[i],state_defs.on_worktop)
end
if i == current_worktop + 1 then
ScriptLib.SetGadgetStateByConfigId(context,windball_worktops[i],state_defs.ready_enshrine)
end
end
end
function LF_Set_Current_Worktop(context,i)
ScriptLib.SetGroupVariableValue(context,"current_worktop",i)
end
function LF_Current_Worktop_Increase(context)
ScriptLib.ChangeGroupVariableValue(context,"current_worktop",1)
end
--[[-----------------------------------------------------------------
|| ||
|| CRUD方法 ||
|| ||
-----------------------------------------------------------------]]--
function LF_Get_Index_From_List(context,list,element)
for i = 1, #list do
if list[i] == element then
return i
end
end
return 0
end
--[[-----------------------------------------------------------------
|| ||
|| 杂项方法 ||
|| ||
-----------------------------------------------------------------]]--
--返回以gadget_1位基准对准gadget_2时应亮起的角标id
function LF_Get_Dir_Index(context,gadget_1,gadget_2)
local eid_1 = ScriptLib.GetEntityIdByConfigId(context, gadget_1)
local pos_1 = ScriptLib.GetPosByEntityId(context, eid_1)
local rot_1 = ScriptLib.GetRotationByEntityId(context, eid_1)
local eid_2 = ScriptLib.GetEntityIdByConfigId(context, gadget_2)
local pos_2 = ScriptLib.GetPosByEntityId(context, eid_2)
local world_angle = math.atan(pos_2.z-pos_1.z, pos_2.x-pos_1.x)
local local_angle = world_angle - rot_1.y
local index = math.ceil((local_angle + 45) / 90)
return index
end
function LF_Change_Team_SGV(context,uid,key,delta)
local v = ScriptLib.GetTeamServerGlobalValue(context,uid,key)
ScriptLib.SetTeamServerGlobalValue(context,uid,key,v+delta)
end
--[[-----------------------------------------------------------------
|| ||
|| server lua call ||
|| ||
-----------------------------------------------------------------]]--
function SLC_Remove_Team_Windball(context)
local uid = ScriptLib.GetSceneOwnerUid(context)
LF_Change_Team_SGV(context,uid,"SGV_Message_Remove_Windball",1)
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,62 @@
--[[======================================
|| filename: Activity_Fungi
|| owner: zhangchi.chen
|| description: 蕈兽战斗白盒
|| LogName: TD
|| Protection: [Protection]
=======================================]]
local extraTriggers =
{
--{ config_id = 40000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
--{ config_id = 40000002, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0 },
--{ config_id = 40000003, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0 },
}
------ Local Functions -----------
function LF_Initialize_Level()
--- TRIGGER
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
return 0
end
--蕈兽放技能
function SLC_MushroomMonsterAlertDoSkill(context)
PrintLog(context,"蕈兽开始释放技能")
local beast = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id })
ScriptLib.SetEntityServerGlobalValueByConfigId(context, beast, "SGV_Fungus_StartBurst_Immediately",1)
return 0
end
------ conditions & actions ------
--group加载
function SLC_Fungus1_Move(context)
ScriptLib.KillEntityByConfigId(context, { ScriptLib.GetGroupVariableValue(context, "fungi1"), entity_type=EntityType.MONSTER})
ScriptLib.CreateMonsterByConfigIdByPos(context, ScriptLib.GetGroupVariableValue(context, "fungi1"), point[LF_GetCloestPoint(context)].pos, {0,0,0})
return 0
end
function LF_GetCloestPoint(context)
local targetpos={0,0,0}
local uid=ScriptLib.GetSceneUidList(context)[1]
local avatarid=GetAvatarEntityIdByUid(context, uid)
local avatarpos=ScriptLib.GetPosByEntityId(context,avatarid)
local shortest_key=0
local shortest_path_square=10000000
for k,v in pairs(points) do
local pathlength_square=(v.pos.x-avatarpos.x)*(v.pos.x-avatarpos.x)+(v.pos.y-avatarpos.y)*(v.pos.y-avatarpos.y)+(v.pos.z-avatarpos.z)*(v.pos.z-avatarpos.z)
if pathlength_square<shortest_path_square then
shortest_key=k
end
end
return shortest_key
end
LF_Initialize_Level()

View File

@@ -0,0 +1,155 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by binghong.shen.
--- DateTime: 2022/9/21 16:33
---
--[[======================================
|| filename: Activity_PacMan
|| owner: binghong.shen
|| description: 3.5吃豆人活动
|| LogName: PacMan
|| Protection: [Protection]
=======================================]]
--[[
测试gm
dungeon 91
run_lua 251015001 function func(context) \n ScriptLib.StartGallery(context, 34001) \n end
]]
--miscs配置内容
--[[
defs.moveback_pointarray_id = 1
]]
defs.teleportPointRangeMap ={
[1]={3,20}
}
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 Tri = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "gadget_talk_done", config_id = 8000002, event = EventType.EVENT_GADGETTALK_DONE, source = "", condition = "", action = "action_gadget_talk_done", trigger_count = 0},
[3] = { name = "gallery_pre_start", config_id = 8000003, event = EventType.EVENT_GALLERY_PRE_START, source = "", condition = "", action = "action_gallery_pre_start", trigger_count = 0},
[4] = { name = "dungeon_settle", config_id = 8000004, event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_dungeon_settle", trigger_count = 0},
[5] = { name = "gallery_stop", config_id = 8000005, 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=50000003,name = "fever_ratio", value = 1})
end
------------------------------------------------------------------
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"PacMan groupLoad")
return 0
end
function action_gadget_talk_done(context,evt)
ScriptLib.PrintContextLog(context,"PacMan action_gadget_talk_done")
--
--local talkName = evt.source_name
--local talkID = evt.param2
--if talkID == 6800419 or talkName == 6800419 then
-- ScriptLib.CreateGadget(context, { config_id = defs.gadget_teleport })
--end
return 0
end
function action_gallery_pre_start(context,evt)
ScriptLib.PrintContextLog(context,"PacMan action_gallery_pre_start")
--local curGallery = evt.param1
--ScriptLib.SetGroupTempValue(context, "curGallery", curGallery, {})
--
--if defs then
-- if defs.gadget_bricks then
-- ScriptLib.CreateGadget(context, { config_id = defs.gadget_bricks })
-- end
-- if defs.gadget_airWall then
-- ScriptLib.CreateGadget(context, { config_id = defs.gadget_airWall })
-- end
--end
return 0
end
function action_dungeon_settle(context,evt)
ScriptLib.PrintContextLog(context,"PacMan action_dungeon_settle")
--
--local curGallery = ScriptLib.GetGroupTempValue(context, "curGallery", {})
--ScriptLib.StopGallery(context, curGallery, true)
return 0
end
function action_gallery_stop(context,evt)
ScriptLib.PrintContextLog(context,"PacMan action_gallery_stop")
--ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.gadget_bricks)
--ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.gadget_airWall)
return 0
end
function SLC_TeleportBack(context)
ScriptLib.PrintContextLog(context,"PacMan SLC_TeleportBack "..tostring(context.uid).." "..tostring(defs.moveback_pointarray_id))
local selectedPoint = LF_GetNearPoint(context)
if(selectedPoint~=-1)then
ScriptLib.PrintContextLog(context,"PacMan Move Back Point "..tostring(selectedPoint))
ScriptLib.MoveAvatarByPointArray(context, context.uid, defs.moveback_pointarray_id or 1, {selectedPoint,2,1}, {speed=10}, "{\"MarkType\":1,\"IgnoreCollisionWhenEnter\":true}")
end
return 0
end
function LF_GetNearPoint(context)
ScriptLib.PrintContextLog(context,"PacMan LF_GetNearPoint In")
local selectedPoint = -1
local avatarUid = context.uid
local avatarEntity = ScriptLib.GetAvatarEntityIdByUid(context, avatarUid)
if avatarEntity==0 then
return selectedPoint
end
local avatarPoint = ScriptLib.GetPosByEntityId(context, avatarEntity)
local pointRangeMin = defs.teleportPointRangeMap[defs.moveback_pointarray_id][1]
local pointRangeMax = defs.teleportPointRangeMap[defs.moveback_pointarray_id][2]
local curPointDistance = 100000
for i = pointRangeMin, pointRangeMax do
local arrayPointRet,arrayPointPos,arrayPointRot=ScriptLib.GetPlatformArrayInfoByPointId(context, defs.moveback_pointarray_id, i)
if(arrayPointRet~=-1)then
local deltaX = arrayPointPos.x - avatarPoint.x
local deltaY = arrayPointPos.y - avatarPoint.y
local deltaZ = arrayPointPos.z - avatarPoint.z
local distance = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ
if(distance<curPointDistance)then
selectedPoint = i
curPointDistance = distance
end
end
end
return selectedPoint
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,99 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
--======================================================================================================================
--|| Filename || CodedLock
--|| RelVersion || V3_4
--|| Owner || chao-jin
--|| Description ||
--|| LogName || ##[CodedLock]
--|| Protection || 3.6版本的能量开关
--======================================================================================================================
--Defs & Miscs
--[[
local defs = {
opt_id = 91004,
rotor_top = 91003,
rotor_mid = 91002,
rotor_bot = 91001,
reminder_success = 400112,
}
local rotor_map = {
[91001] = {init_state = 1, end_state = 3},
[91002] = {init_state = 3, end_state = 2},
[91003] = {init_state = 4, end_state = 4},
}
]]
local CodedLock_Triggers = {
[1] = { name = "group_load", config_id = 8001001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "select_option", config_id = 8001002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[3] = { name = "gadget_state_change", config_id = 8001003, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
}
function CodedLock_Initialize()
for k,v in pairs(CodedLock_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
end
--======================================================================================================================
--Events
function action_group_load(context, evt)
if 0 ~= ScriptLib.GetGroupVariableValue(context, "Finished") then
return 0
end
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.opt_id, {811,812,813})
for rotor_id,infos in pairs(rotor_map) do
ScriptLib.SetGadgetStateByConfigId(context, rotor_id, (infos.init_state-1))
for i=1,4 do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface0"..i, 0)
end
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface0"..infos.init_state, 1)
end
return 0
end
function action_select_option(context, evt)
if evt.param2 == 811 then
LF_RotateRotor(context, defs.rotor_top)
end
if evt.param2 == 812 then
LF_RotateRotor(context, defs.rotor_mid)
end
if evt.param2 == 813 then
LF_RotateRotor(context, defs.rotor_bot)
end
return 0
end
function action_gadget_state_change(context, evt)
if rotor_map[defs.rotor_top].end_state-1 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.rotor_top) and
rotor_map[defs.rotor_mid].end_state-1 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.rotor_mid) and
rotor_map[defs.rotor_bot].end_state-1 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.rotor_bot) then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.opt_id, {})
ScriptLib.ShowReminder(context, defs.reminder_success)
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
end
return 0
end
--======================================================================================================================
--LevelFunctions
--旋转转子
function LF_RotateRotor(context, rotor_id)
for i=1,4 do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface0"..i, 0)
end
local rotor_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, rotor_id)
if rotor_state < 3 then
ScriptLib.SetGadgetStateByConfigId(context, rotor_id, rotor_state+1)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface0"..(rotor_state+2), 1)
else
ScriptLib.SetGadgetStateByConfigId(context, rotor_id, 0)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, rotor_id, "SGV_Surface01", 1)
end
end
CodedLock_Initialize()

View File

@@ -0,0 +1,134 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
--======================================================================================================================
--|| Filename || DrumRegexp
--|| RelVersion || V3_4
--|| Owner || chao-jin
--|| Description ||
--|| LogName || ##[DrumRegexp]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs
local defs = {
drum = 800001,
reminder_success = 400112,
reminder_fail = 400113,
}
--local music_list = {"100110100101","110101011101","101010011101"}
local music_list = {"11001","11101"}
local music_len = 5
--======================================================================================================================
--Events
local DrumRegexp_Triggers = {
[1] = { name = "group_load", config_id = 8002001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
}
function DrumRegexp_Initialize()
for k,v in pairs(DrumRegexp_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
DrumRegexp_Initialize()
--加载Group时的操作
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:加载敲鼓玩法Group")
LF_ResetBeatMark(context)
return 0
end
--======================================================================================================================
--LevelFunctions
--玩家攻击敲鼓的SLC
function SLC_DrumPercussReg(context, beat_time)
--[[
if 0 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.drum) then
ScriptLib.PrintContextLog(context, "##[DrumRegexp]: 已经完成了")
return 0
end
]]
if beat_time > 1 then
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:在一个区间内敲击了多次,直接失败")
LF_RegexpPlayFail(context)
return 0
end
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:敲鼓SLC,敲鼓次数"..beat_time)
local reg_dec = ScriptLib.GetGroupTempValue(context, "RegDec", {})
local reg_bin = LF_DecToBinStr(reg_dec)
reg_bin = reg_bin..(math.ceil(beat_time))
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:当前谱"..reg_bin)
if string.len(reg_bin) == 5 then
for i=1,2 do
if music_list[i] == reg_bin then
LF_RegexpPlaySuccess(context)
return 0
end
end
LF_RegexpPlayFail(context)
return 0
end
ScriptLib.SetGroupTempValue(context, "RegDec", LF_BinStrToDec(reg_bin), {})
return 0
end
--玩家长时间未敲鼓的SLC
function SLC_DrumPercussRegEnd(context)
--[[
if 0 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.drum) then
ScriptLib.PrintContextLog(context, "##[DrumRegexp]: 已经完成了")
return 0
end
]]
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:超时未敲鼓,失败")
LF_RegexpPlayFail(context)
return 0
end
--初始化鼓的敲击标记
function LF_ResetBeatMark(context)
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:初始化节拍监听变量")
ScriptLib.SetGroupTempValue(context, "RegDec", 1, {}) --记录当前匹配到的列表
end
--演奏成功
function LF_RegexpPlaySuccess(context)
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:演奏成功")
LF_ResetBeatMark(context)
ScriptLib.SetGadgetStateByConfigId(context, defs.drum, 201)
ScriptLib.ShowReminder(context, defs.reminder_success)
end
--演奏失败
function LF_RegexpPlayFail(context)
ScriptLib.PrintContextLog(context, "##[DrumRegexp]:演奏失败")
LF_ResetBeatMark(context)
ScriptLib.ShowReminder(context, defs.reminder_fail)
end
--把信息从十进制转成二进制的字符串
function LF_DecToBinStr(dec_num)
--转进制字符的长度做一定的限制
local bin_str = ""
dec_num = math.ceil(dec_num)
for i=1,16 do
if dec_num ~= 0 then
bin_str = bin_str..(dec_num%2)
dec_num = math.floor(dec_num/2)
else
return string.reverse(bin_str)
end
end
end
--把二进制字符串变成十进制
function LF_BinStrToDec(bin_str)
local len = string.len(bin_str)
local dec_num = 0
for i=1,len do
dec_num = dec_num + (2^(len-i))*tonumber(string.sub(bin_str,i,i))
end
return dec_num
end

View File

@@ -0,0 +1,197 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
--======================================================================================================================
--|| Filename || DrumSingle
--|| RelVersion || V3_4
--|| Owner || chao-jin
--|| Description || 对应Gadget 70900431
--|| LogName || ##[DrumSingle]
--|| Protection ||
--======================================================================================================================
--[[Defs & Miscs
local defs = {
drum = 77001, --鼓的ConfigID
interval = 2, --敲鼓的节奏间隔
reminder_success = 400112,
reminder_fail = 400113,
}
--敲鼓的节奏 0 1普攻 2下落 70900431鼓ID
local music_staff = {0,1,0,1, 1,0,1,0, 0,1,0,1}
]]
local OPTION = {
SINGLE = 809,
REGEXP = 810,
}
--======================================================================================================================
--Events
local DrumSingle_Triggers = {
[1] = { name = "group_load", config_id = 8001001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_single_group_load", trigger_count = 0},
[2] = { name = "select_option", config_id = 8001002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_single_select_option", trigger_count = 0},
[3] = { name = "time_axis_pass", config_id = 8001003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_single_time_axis_pass", trigger_count = 0},
[4] = { name = "enter_region", config_id = 8001004, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0},
[5] = { name = "leave_region", config_id = 8001005, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0},
}
function DrumSingle_Initialize()
for k,v in pairs(DrumSingle_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
end
DrumSingle_Initialize()
--加载Group时的操作
function action_single_group_load(context, evt)
ScriptLib.PrintContextLog(context, "##[DrumSingle]:加载敲鼓玩法Group")
LF_ResetBeatMark(context)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.drum, {OPTION.SINGLE})
return 0
end
function action_enter_region(context,evt)
return 0
end
function action_leave_region(context,evt)
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_Drum_Play_Start", 0)
return 0
end
--玩家交互开始敲鼓玩法
function action_single_select_option(context, evt)
--单曲模式
if evt.param2 == OPTION.SINGLE then
ScriptLib.PrintContextLog(context, "##[DrumSingle]:敲鼓玩法,单曲演奏模式")
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_Drum_Play_Start", 1)
ScriptLib.SetGroupTempValue(context, "PlayMode", OPTION.SINGLE, {})
if music_staff[1] ~= nil then
--同步每个区间是否可以敲击
ScriptLib.PrintContextLog(context, "##[DrumSingle]:更新鼓状态,可以敲击")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.drum, "SGV_DrumAxis", 1)
end
ScriptLib.InitTimeAxis(context, "MusicPlay", {defs.interval}, true)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.drum, {})
end
return 0
end
--检测敲击的时间轴
function action_single_time_axis_pass(context, evt)
if evt.source_name == "MusicPlay" then
--处理单曲模式
-- if OPTION.SINGLE == ScriptLib.GetGroupTempValue(context, "PlayMode", {}) then
local pre_beat_index = ScriptLib.GetGroupTempValue(context, "BeatIndex", {})
ScriptLib.PrintContextLog(context, "##[DrumSingle]:上一个节拍"..pre_beat_index)
--处理上一个节拍是否错过,如果错过了就直接处理失败
if music_staff[pre_beat_index] ~= nil then
if music_staff[pre_beat_index] ~= ScriptLib.GetGroupTempValue(context, "LastBeatType", {}) then
ScriptLib.PrintContextLog(context, "##[DrumSingle]: 上一个节拍 MISS")
LF_SinglePlayFail(context)
return 0
end
end
--初始化下一个时间段内的记录变量更新鼓的状态
ScriptLib.SetGroupTempValue(context, "BeatPercussed", 0, {})
ScriptLib.SetGroupTempValue(context, "LastBeatType", 0, {})
if music_staff[pre_beat_index+1] ~= nil then
--同步下一个区间可以敲击
ScriptLib.PrintContextLog(context, "##[DrumSingle]:更新鼓状态,可以敲击")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.drum, "SGV_DrumAxis", pre_beat_index+1)
else
ScriptLib.PrintContextLog(context, "##[DrumSingle]:没有下一个节拍了,成功")
LF_SinglePlaySuccess(context)
end
-- end
ScriptLib.PrintContextLog(context, "##[DrumSingle]:节拍+1")
ScriptLib.ChangeGroupTempValue(context, "BeatIndex", 1, {})
end
return 0
end
--======================================================================================================================
--LevelFunctions
--玩家攻击敲鼓的SLC
function SLC_DrumPercussSingle(context, beat_timing, beat_type)
local play_mode = ScriptLib.GetGroupTempValue(context, "PlayMode", {})
if play_mode == 0 then
ScriptLib.PrintContextLog(context, "##[DrumSingle]:演奏未开始,不处理敲击事件")
return 0
end
ScriptLib.PrintContextLog(context, "##[DrumSingle]:[SLC]敲鼓")
--获取是否进行过敲击
local has_percussed = ScriptLib.GetGroupTempValue(context, "BeatPercussed", {})
if 0 ~= ScriptLib.GetGroupTempValue(context, "BeatPercussed", {}) then
ScriptLib.PrintContextLog(context, "##[DrumSingle]:当前节拍重复敲击,失败")
LF_SinglePlayFail(context)
return 0
end
ScriptLib.SetGroupTempValue(context, "LastBeatType", beat_type, {})
--获取当前的敲击序列
local staff_index = ScriptLib.GetGroupTempValue(context, "BeatIndex", {})
--单曲模式校验
if play_mode == OPTION.SINGLE then
if music_staff[staff_index] ~= 0 then
if beat_timing == 0 then
ScriptLib.PrintContextLog(context, "##[DrumSingle]:未在敲击区间内敲击,失败")
LF_SinglePlayFail(context)
return 0
else
if music_staff[staff_index] ~= beat_type then
ScriptLib.PrintContextLog(context, "##[DrumSingle]:敲击方式错误,失败"..beat_type)
LF_SinglePlayFail(context)
return 0
end
--最后一个节拍敲完
if staff_index >= #music_staff then
ScriptLib.PrintContextLog(context, "##[DrumSingle]:全部节拍完成")
LF_SinglePlaySuccess(context)
return 0
end
end
else
ScriptLib.PrintContextLog(context, "##[DrumSingle]:在非敲击节拍上进行敲击,失败处理")
LF_SinglePlayFail(context)
return 0
end
end
--标记进行过敲击
ScriptLib.SetGroupTempValue(context, "BeatPercussed", 1, {})
return 0
end
--初始化鼓的敲击标记
function LF_ResetBeatMark(context)
ScriptLib.PrintContextLog(context, "##[DrumSingle]:初始化节拍监听变量")
ScriptLib.SetGroupTempValue(context, "BeatIndex", 1, {}) --记录当前需要查询的节拍
ScriptLib.SetGroupTempValue(context, "BeatPercussed", 0, {}) --当前节拍是否敲击过(同一个节拍只能敲击一次)
ScriptLib.SetGroupTempValue(context, "PlayMode", 0, {}) --当前的敲击模式是哪一种
ScriptLib.SetGroupTempValue(context, "LastBeatType", 0, {})
--设置鼓的SGV
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.drum, "SGV_DrumAxis", 0)
end
--演奏成功
function LF_SinglePlaySuccess(context)
ScriptLib.PrintContextLog(context, "##[DrumSingle]:演奏成功")
ScriptLib.EndTimeAxis(context, "MusicPlay")
LF_ResetBeatMark(context)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.drum, {OPTION.SINGLE})
ScriptLib.ShowReminder(context, defs.reminder_success)
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
end
--演奏失败
function LF_SinglePlayFail(context)
ScriptLib.PrintContextLog(context, "##[DrumSingle]:演奏失败")
ScriptLib.EndTimeAxis(context, "MusicPlay")
ScriptLib.SetTeamServerGlobalValue(context, context.uid, "SGV_Drum_Play_Start", 0)
LF_ResetBeatMark(context)
--失败则初始化操作台
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.drum, {OPTION.SINGLE})
ScriptLib.ShowReminder(context, defs.reminder_fail)
end

View File

@@ -0,0 +1,205 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
--======================================================================================================================
--|| Filename || EnergyPillar
--|| RelVersion || V3_4
--|| Owner || chao-jin
--|| Description ||
--|| LogName || ##[EnergyPillar]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs
local defs = {
pillar_top = 90003,
pillar_mid = 90002,
pillar_bot = 90001,
operator_1 = 90004,
operator_2 = 90005,
operator_3 = 90006,
}
local pillar_decals = {
[90001] = {"E","F","F"},
[90002] = {"C","D","C"},
[90003] = {"A","B","A"},
}
local pillar_answers = {
[1] = "FCA",
[2] = "ECB",
[3] = "FDA",
}
local pillar_state_map = {
[90004] ={ {state = 0, sgv = "SGV_Surface01"}, {state = 1, sgv = "SGV_Surface02"},{state = 2, sgv = "SGV_Surface03"}},
[90005] ={ {state = 0, sgv = "SGV_Surface02"}, {state = 1, sgv = "SGV_Surface03"},{state = 2, sgv = "SGV_Surface01"}},
[90006] ={ {state = 0, sgv = "SGV_Surface03"}, {state = 1, sgv = "SGV_Surface01"},{state = 2, sgv = "SGV_Surface02"}},
}
local OPTION = {
TOP = 811,
MID = 812,
BOT = 813,
}
--======================================================================================================================
local EP_Triggers = {
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ name = "select_option", config_id = 8000102, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
}
--Events
function action_group_load(context, evt)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.operator_1, {811,812,813})
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.operator_2, {811,812,813})
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.operator_3, {811,812,813})
return 0
end
function action_select_option(context, evt)
--处理电源的开关
if evt.param2 == OPTION.TOP then
LF_TurnPillar(context, defs.pillar_top)
LF_CheckCombine(context)
end
if evt.param2 == OPTION.MID then
LF_TurnPillar(context, defs.pillar_mid)
LF_CheckCombine(context)
end
if evt.param2 == OPTION.BOT then
LF_TurnPillar(context, defs.pillar_bot)
LF_CheckCombine(context)
end
return 0
end
function action_gadget_state_change(context, evt)
return 0
end
--======================================================================================================================
--LevelFunctions
function LF_TurnPillar(context, pillar_id)
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, pillar_id)
if gadget_state == 0 then
ScriptLib.SetGadgetStateByConfigId(context, pillar_id, 1)
return 0
end
if gadget_state == 1 then
ScriptLib.SetGadgetStateByConfigId(context, pillar_id, 2)
return 0
end
if gadget_state == 2 then
ScriptLib.SetGadgetStateByConfigId(context, pillar_id, 0)
return 0
end
end
--通过gadgetstate来拿一个转子的排列顺序以State0的初始方向为基准
function LF_GetPillarDecalSeq(context, pillar_id)
local state_pillar = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, pillar_id)
if state_pillar == 0 then
return {
{decal = pillar_decals[pillar_id][1], sgv_key = "SGV_Surface01", p_id = pillar_id},
{decal = pillar_decals[pillar_id][2], sgv_key = "SGV_Surface02", p_id = pillar_id},
{decal = pillar_decals[pillar_id][3], sgv_key = "SGV_Surface03", p_id = pillar_id},
}
end
if state_pillar == 1 then
return {
{decal = pillar_decals[pillar_id][2], sgv_key = "SGV_Surface02", p_id = pillar_id},
{decal = pillar_decals[pillar_id][3], sgv_key = "SGV_Surface03", p_id = pillar_id},
{decal = pillar_decals[pillar_id][1], sgv_key = "SGV_Surface01", p_id = pillar_id},
}
end
if state_pillar == 2 then
return {
{decal = pillar_decals[pillar_id][3], sgv_key = "SGV_Surface03", p_id = pillar_id},
{decal = pillar_decals[pillar_id][1], sgv_key = "SGV_Surface01", p_id = pillar_id},
{decal = pillar_decals[pillar_id][2], sgv_key = "SGV_Surface02", p_id = pillar_id},
}
end
end
function LF_CheckCombine(context)
--先把所有的面全部重置为0
for pillar_id,v in pairs(pillar_decals) do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface01", 0)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface02", 0)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface03", 0)
end
--拿到每个转子的状态
local pillar_map = {}
for pillar_id, decal_str in pairs(pillar_decals) do
table.insert( pillar_map, LF_GetPillarDecalSeq(context, pillar_id))
end
--[[
local pillar_map = {
[1] = { --转子1
{decal = a, sgv_key = 1, p_id = 1},
{decal = b, sgv_key = 2, p_id = 1},
{decal = a, sgv_key = 3, p_id = 1},
},
[2] = { --转子2
{decal = c, sgv_key = 1, p_id = 2},
{decal = d, sgv_key = 2, p_id = 2},
{decal = c, sgv_key = 3, p_id = 2},
},
[3] = { --转子3
{decal = e, sgv_key = 1, p_id = 3},
{decal = f, sgv_key = 2, p_id = 3},
{decal = f, sgv_key = 3, p_id = 3},
},
}
]]
--把三个转子的纵向面连接起来做一个StringList
local pillar_combines = {}
for i=1,3 do
pillar_combines[i] = pillar_map[1][i].decal..pillar_map[2][i].decal..pillar_map[3][i].decal
end
local right_indexs = {}
--每个StringList去和解做比较符合解就把这组压到答案组里
for i=1,3 do
for j=1,3 do
if pillar_combines[i] == pillar_answers[j] then
table.insert(right_indexs, i)
end
end
end
--没有匹配的返回
if #right_indexs == 0 then
return 0
else
--有匹配的就会去找对应的面
if #right_indexs < 3 then
for i=1,#right_indexs do
local idx = right_indexs[i]
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_map[1][idx].p_id, pillar_map[1][idx].sgv_key, 1)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_map[2][idx].p_id, pillar_map[2][idx].sgv_key, 1)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_map[3][idx].p_id, pillar_map[3][idx].sgv_key, 1)
end
end
if #right_indexs == 3 then
for pillar_id,v in pairs(pillar_decals) do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface01", 1)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface02", 1)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, pillar_id, "SGV_Surface03", 1)
end
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
end
end
end
--初始化
function EP_Initialize()
for k,v in pairs(EP_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
end
EP_Initialize()

View File

@@ -0,0 +1,825 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
--======================================================================================================================
--|| Filename || EnergyTransform
--|| RelVersion || V3_4
--|| Owner || chao-jin
--|| Description || 重构的能量传递Require
--|| LogName || ##[EnergyTrans]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs
--[[
local DIR = {Up = 0,Right = 1,Down = 2,Left = 3,None = 4,}
--转换器的列表1表示可移动
local defs = {
pointarray_id = 110200028, --点阵ID
graph_num = 1,
len_x = 7, --长度
len_z = 9, --高度
rot_y = 0, --偏转角
reminder_push_warning = 400095, --无法推动的reminder
}
local converter_infos = {[71017] = 2,[71022] = 1,[71039] = 1,[71040] = 1}
--0->断路 |-1 电源| 1-> 可停留节点| 1.5 -> 可能存在结晶的节点| 2 -> 电线 | 2.5-> 结晶块 |
--3-> 接收器 | 4 -> 中继器 | 4.5 -> 对位中继器输入
local connected_graph = {
[9] = { 1, 2, 2, 2, 1, 2, 1},
[8] = { 0, 0, 0, 0, 0, 0, 2},
[7] = { 1, 2, 3, 0, -1, 0, 1},
[6] = { 2, 0, 0, 0, 2, 0, 2},
[5] = { 1, 2, 1, 2, 1, 2, 1},
[4] = { 0, 0, 2, 0, 0, 0, 2},
[3] = { 1, 2, 1, 2,2.5, 2, 1},
[2] = { 2, 0, 0, 0, 0, 0, 2},
[1] = { 3, 0, 0, 0, 0, 0,-1},
}
--与节点图一一对应点阵中 点的位置
local waypoint_graph = {
[9] = {10, 0, 0, 0, 6, 0, 5},
[8] = { 0, 0, 0, 0, 0, 0, 0},
[7] = {11, 0, 0, 0, 0, 0, 4},
[6] = { 0, 0, 0, 0, 0, 0, 0},
[5] = {12, 0, 9, 0, 7, 0, 3},
[4] = { 0, 0, 0, 0, 0, 0, 0},
[3] = {13, 0, 8, 0, 5, 0, 2},
[2] = { 0, 0, 0, 0, 0, 0, 0},
[1] = { 0, 0, 0, 0, 0, 0, 1},
}
local gadget_graph ={
[9] = { 71035, 71024, 71024, 71024, 71028, 71006, 71027},
[8] = { 0, 0, 0, 0, 0, 0, 71005},
[7] = { 71029, 71013, 71019, 0, 71021, 0, 71036},
[6] = { 71014, 0, 0, 0, 71020, 0, 71004},
[5] = { 71030, 71012, 71031, 71011, 71034, 71010, 71026},
[4] = { 0, 0, 71023, 0, 0, 0, 71003},
[3] = { 71033, 71015, 71032, 71008, 71009, 71007, 71025},
[2] = { 71016, 0, 0, 0, 0, 0, 71002},
[1] = { 71018, 0, 0, 0, 0, 0, 71001},
}
--点阵和每个点的POS,用来在恢复的时候创建Gadget
local waypoint_pos = {
[1] = {x=1996.51245, y=197.46463, z=-1265.03467},
[2] = {x=2000.27747, y=197.637466, z=-1269.03479},
[3] = {x=2004.44043, y=197.682251, z=-1273.08423},
[4] = {x=2008.35669, y=198.132111, z=-1276.61426},
[5] = {x=2011.79822, y=198.469543, z=-1280.75232},
[6] = {x=2016.40918, y=198.902481, z=-1275.91077},
[7] = {x=2008.25366, y=198.260834, z=-1268.04431},
[8] = {x=2008.5968, y=198.515762, z=-1260.09985},
[9] = {x=2012.65173, y=198.5158, z=-1264.41284},
[10] = {x=2025.0188, y=199.691757, z=-1267.24316},
[11] = {x=2020.85693, y=198.902466, z=-1263.183},
[12] = {x=2017.17883, y=198.681519, z=-1260.414},
[13] = {x=2013.269, y=198.889435, z=-1255.92017},
}
--定义左下角原点X轴Z轴正方向的点通过向量计算位置关系
local axis_O = {x = 2009, z = -1252}
local axis_Z = {x = 2013, z = -1256}
local axis_X = {x = 2003, z = -1258}
--发射器的位置以及朝向,发射器的状态
local emitter_infos = {
[71001] = {z = 1, x = 7, dir = DIR.Up},
[71021] = {z = 7, x = 5, dir = DIR.Down},
}
local receiver_infos = {
[71018] = {r_type = "Rec", connect_gadget = {71037} },
[71019] = {r_type = "Rec", connect_gadget = {71038} },
}
]]
--======================================================================================================================
--全局变量不需要LD处理,仅在Require内部使用
local _G_pipe_route = {} --电路的流向合集
local _G_pipe_state= {}
local _G_ec_dir = 0 --电流的方向每次递归计算的时候会用
local _G_recur_counter = 0 --递归计数器
local _G_cvt_graph = {} --在递归时建立的临时表减少遍历次数
local OPTION = {ROTATE = 31,START = 7,STOP = 72,PUSH = 193,}
--0->断路 |-1 电源| 1-> 可停留节点| 1.5 -> 可能存在结晶的节点| 2 -> 电线 | 2.5-> 结晶块 |
--3-> 接收器 | 4 -> 中继器 | 4.5 -> 对位中继器输入
local NODE = {Off = 0,Power = -1,N_Node = 1,C_Node = 1.5, N_Pipe = 2, Crystal = 2.5, N_Rec = 3,C_Rec = 3.5,Sy_P_Node = 4,Sy_R_Node = 4.5}
--======================================================================================================================
--Events
local ET_Triggers = {
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ name = "select_option", config_id = 8000102, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
{ name = "time_axis_pass", config_id = 8000103, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
{ name = "platform_reach",config_id = 8000104, event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_platform_arrival", trigger_count = 0 },
}
--初始化
function ET_Initialize()
for k,v in pairs(ET_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
--Events
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:Group 加载完毕")
--确认每个电源的状态修改按键信息,1代表物件结晶化,物件需要在加载完成的时候同步一次状态
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:打开电源操作台操作")
for emitter_id,infos in pairs(emitter_infos) do
--物件没有结晶化给选项
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, emitter_id, "GV_TMHY_CRYSTAL") then
if 0 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, emitter_id) then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, emitter_id, {OPTION.STOP})
ScriptLib.SetGroupTempValue(context, "GenState"..emitter_id, 1, {base_info.group_id})
end
if 201 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, emitter_id) then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, emitter_id, {OPTION.START})
ScriptLib.SetGroupTempValue(context, "GenState"..emitter_id, 0, {base_info.group_id})
end
else
--物件结晶化了选项关掉
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, emitter_id, {})
ScriptLib.SetGroupTempValue(context, "GenState"..emitter_id, 0, {base_info.group_id})
end
end
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:开始创建转换器")
local _cvt_graph = LF_RefreshGlobalConverterList(context)
for cvt_id,cvt_info in pairs(_cvt_graph) do
local waypoint = waypoint_graph[cvt_info.z][cvt_info.x]
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:转换器"..cvt_id.."对应路点"..waypoint)
--创建转换器设置方向
ScriptLib.CreateGadgetByConfigIdByPos(context, cvt_id, waypoint_pos[waypoint], {x = 0, y = defs.rot_y, z = 0})
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:创建转换器"..cvt_id)
ScriptLib.SetGadgetStateByConfigId(context, cvt_id, cvt_info.dir)
--可移动的转换器
if cvt_info.cvt_type == 1 then
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, cvt_id, "GV_TMHY_CRYSTAL") then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {OPTION.ROTATE, OPTION.PUSH})
end
end
--不可移动的转换器
if cvt_info.cvt_type == 2 then
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, cvt_id, "GV_TMHY_CRYSTAL") then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {OPTION.ROTATE})
end
end
end
LF_CheckConnection(context)
return 0
end
function action_select_option(context, evt)
--处理电源的开关
if emitter_infos[evt.param1] ~= nil and evt.param2 == OPTION.START then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:打开电源")
-- ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_PowerOn", 1)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, evt.param1, {OPTION.STOP})
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 201)
ScriptLib.SetGroupTempValue(context, "GenState"..evt.param1, 1, {base_info.group_id})
LF_CheckConnection(context)
end
if emitter_infos[evt.param1] ~= nil and evt.param2 == OPTION.STOP then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:关闭电源")
-- ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_PowerOn", 0)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, evt.param1, {OPTION.START})
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 0)
ScriptLib.SetGroupTempValue(context, "GenState"..evt.param1, 0, {base_info.group_id})
LF_CheckConnection(context)
end
--处理中继器的旋转
if converter_infos[evt.param1] ~= nil and evt.param2 == OPTION.ROTATE then
--判断结晶化
if 1 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, evt.param1, "GV_TMHY_CRYSTAL") then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:电桩结晶化了,不能旋转")
ScriptLib.ShowReminder(context, defs.reminder_push_warning)
end
local rotate_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, evt.param1)
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:旋转中继器,旋转前方向"..rotate_state)
if rotate_state == 3 then
rotate_state = 0
else
rotate_state = rotate_state + 1
end
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:旋转中继器,更新方向"..rotate_state)
--更新当前电桩的朝向
LF_LockConverterOperations(context, true)
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, rotate_state)
LF_SetConverterData(context, evt.param1, "Gadget_State", rotate_state)
ScriptLib.InitTimeAxis(context, tostring(evt.param1), {1}, false)
end
--处理推动电桩,只有类型1的电桩才会推动
if converter_infos[evt.param1] ~= nil and converter_infos[evt.param1] == 1 and evt.param2 == OPTION.PUSH then
if 1 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, evt.param1, "GV_TMHY_CRYSTAL") then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:电桩结晶化了,不能移动")
ScriptLib.ShowReminder(context, defs.reminder_push_warning)
end
--按照玩家和电桩的相对位置推动电桩
local push_dir = LF_CalcDirection(context, context.uid, evt.param1)
local path = LF_GetMovePath(context, evt.param1, push_dir)
if path ~= 0 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:推动中继器"..path[1].."to"..path[2])
ScriptLib.SetPlatformPointArray(context, evt.param1, defs.pointarray_id, path, { route_type = 0})
else
ScriptLib.ShowReminder(context, defs.reminder_push_warning)
end
LF_LockConverterOperations(context, true)
ScriptLib.InitTimeAxis(context, tostring(evt.param1), {1}, false)
end
return 0
end
--电桩旋转过程完成检测电路连通和恢复电桩操作
function action_time_axis_pass(context, evt)
LF_CheckConnection(context)
LF_LockConverterOperations(context, false)
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:操作时点完成TimeAxis结束")
return 0
end
--电桩到达目标位置
function action_platform_arrival( context, evt)
--到达的柱子是这组Group里的
if nil == converter_infos[evt.param1] then
return -1
end
--到的不是目标点
if evt.param3 ~= ScriptLib.GetGroupTempValue(context, "Move_Target_Point", {}) then
return -1
end
local pos = LF_GetWaypointPos(evt.param3)
--更新当前电桩的信息
LF_SetConverterData( context, evt.param1, "Gadget_Pos", {pos_z = pos[1] ,pos_x = pos[2]})
LF_CheckConnection(context)
return 0
end
--======================================================================================================================
--ServerLuaCalls
--电桩从结晶化恢复时通知Group恢复操作
function SLC_CVTCrystallizeOff(context)
local cvt_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
if converter_infos[cvt_cfg_id] == 1 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {OPTION.PUSH, OPTION.ROTATE})
end
if converter_infos[cvt_cfg_id] == 2 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {OPTION.ROTATE})
end
LF_CheckConnection(context)
return 0
end
--电桩结晶化通知Group关闭操作
function SLC_CVTCrystallizeOn(context)
local cvt_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {})
LF_CheckConnection(context)
return 0
end
--电源结晶相关SLC
function SLC_GeneratorCrystalStateChange(context, is_crystallized)
local gen_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
--结晶化时关掉开关的选项
if 1 == is_crystallized then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电源SLC]电源结晶")
ScriptLib.SetGroupTempValue(context, "GenState"..gen_cfg_id, 0, {base_info.group_id})
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gen_cfg_id, {})
if 201 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, gen_cfg_id) then
--相当于关闭电源走一遍遍历
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电源SLC]关闭电路")
LF_CheckConnection(context)
end
end
if 0 == is_crystallized then
--电源没打开仍然是断路
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电源SLC]电源结晶解除")
if 0 == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, gen_cfg_id) then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gen_cfg_id, { OPTION.START })
else
--相当于电源打开了重新连通
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电源SLC]打开电路")
ScriptLib.SetGroupTempValue(context, "GenState"..gen_cfg_id, 1, {base_info.group_id})
LF_CheckConnection(context)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gen_cfg_id, { OPTION.STOP })
end
end
return 0
end
--电桩结晶相关SLC
function SLC_ConverterCrystalStateChange(context, is_crystallized)
local cvt_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
--结晶化时关掉旋转的选项
if 1 == is_crystallized then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[中继器]中继器结晶")
LF_CheckConnection(context)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {})
end
if 0 == is_crystallized then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[中继器]中继器解除结晶")
LF_CheckConnection(context)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_cfg_id, {OPTION.ROTATE})
end
return 0
end
--接收器相关SLC结晶和结晶化解除时都要发
function SLC_ReceiverCrystalStateChange(context, is_crystallized)
--结晶化时关掉旋转的选项
LF_CheckConnection(context)
return 0
end
--对位中继器相关SLC结晶和结晶化解除时都要发
function SLC_ReceiverCrystalStateChange(context, is_crystallized)
local sync_cfg_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
LF_CheckConnection(context)
return 0
end
--======================================================================================================================
--LevelFunctions
--更新所有转换器的位置信息使用一个全局表处理每次使用时需要重置此表
function LF_RefreshGlobalConverterList(context)
local _cvt_graph = {}
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]创建电桩列表")
for config_id,cvt_type in pairs(converter_infos) do
_cvt_graph[config_id] = LF_GetConverterData(context, config_id)
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:转换器"..config_id.."z".._cvt_graph[config_id].z.."x".._cvt_graph[config_id].x)
end
return _cvt_graph
end
--开关全部的电桩选项
function LF_LockConverterOperations(context, is_lock)
if is_lock then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]关闭全部中转器操作")
for cvt_id,info in pairs(converter_infos) do
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {})
end
else
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]打开全部中转器操作")
for cvt_id,info in pairs(converter_infos) do
--校验结晶化
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, cvt_id, "GV_TMHY_CRYSTAL") then
if info == 1 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {OPTION.ROTATE, OPTION.PUSH})
end
if info == 2 then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, cvt_id, {OPTION.ROTATE})
end
end
end
end
end
--======================================================================================================================
--电桩移动相关
--获取电桩的移动路点列表
function LF_GetMovePath(context, cvt_id, push_dir)
local _cvt_graph = LF_RefreshGlobalConverterList(context)
local pos_z = _cvt_graph[cvt_id].z
local pos_x = _cvt_graph[cvt_id].x
local cur_point = waypoint_graph[pos_z][pos_x]
--走到下一个可以停留的点为止
for i=1,defs.len_x do
if push_dir == DIR.Up then
pos_z = pos_z + 1
end
if push_dir == DIR.Down then
pos_z = pos_z - 1
end
if push_dir == DIR.Left then
pos_x = pos_x - 1
end
if push_dir == DIR.Right then
pos_x = pos_x + 1
end
--检查是否越界,越界则直接返回
if pos_z < 1 or pos_z > defs.len_z then
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]Z坐标越界")
return 0
end
if pos_x < 1 or pos_x > defs.len_x then
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]X坐标越界")
return 0
end
--找到下一个去的点信息
if connected_graph[pos_z][pos_x] == NODE.Off or connected_graph[pos_z][pos_x] == NODE.Power or
connected_graph[pos_z][pos_x] == NODE.N_Rec or connected_graph[pos_z][pos_x] == NODE.C_Rec or
connected_graph[pos_z][pos_x] == NODE.Sy_P_Node or connected_graph[pos_z][pos_x] == NODE.Sy_R_Node then
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]前方是短路/终点/起点,停止检查")
return 0
end
if connected_graph[pos_z][pos_x] == NODE.N_Pipe then
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]可以移动到中间点".."Z_"..pos_z.."X_"..pos_x)
end
if connected_graph[pos_z][pos_x] == NODE.Crystal then
if LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]检查中间有结晶挡住")
return 0
else
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]检查中间没有结晶挡住")
end
end
--节点检测
if connected_graph[pos_z][pos_x] == NODE.C_Node or connected_graph[pos_z][pos_x] == NODE.N_Node then
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]可以移动到停留点".."Z_"..pos_z.."X_"..pos_x)
if not LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
for k,v in pairs(_cvt_graph) do
if v.z == pos_z and v.x == pos_x then
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电桩]目标点有一个电桩了,不移动")
return 0
end
end
--记录一下目标点
ScriptLib.SetGroupTempValue(context, "Move_Target_Point", waypoint_graph[pos_z][pos_x], {})
return {cur_point, waypoint_graph[pos_z][pos_x]}
else
return 0
end
end
end
end
--根据点的位置获取xz坐标
function LF_GetWaypointPos(point_id)
for z = 1,defs.len_z do
for x = 1,defs.len_x do
if waypoint_graph[z][x] == point_id then
return {z,x}
end
end
end
end
--======================================================================================================================
--全量检查当前电路的连接情况
function LF_CheckConnection(context)
--每个电源都走一个递归检测逻辑
--递归次数清零
local _cvt_graph = LF_RefreshGlobalConverterList(context)
--建立一个每个电线的状态表,记为0 关闭
for z = 1, defs.len_z do
_G_pipe_state[z] = {}
for x = 1, defs.len_x do
_G_pipe_state[z][x] = 0
end
end
for emt_id,emt_pos in pairs(emitter_infos) do
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]检查电路连通,起点"..emt_id)
--更新电流方向
_G_ec_dir = emt_pos.dir
_G_recur_counter = 0
--检测一下电源的状态
if LF_IsGeneratorOn(context, emt_id) then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]开始打开电线")
LF_RunEC(context, emt_pos, true, _cvt_graph)
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]检查完成")
else
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]开始关闭电线")
LF_RunEC(context, emt_pos, false, _cvt_graph)
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]检查完成")
end
end
--刷新所有电线状态
for z=1,defs.len_z do
for x=1,defs.len_x do
if gadget_graph[z][x] ~= 0 then
if connected_graph[z][x] == NODE.N_Pipe or connected_graph[z][x] == NODE.N_Node then
if _G_pipe_state[z][x] > 0 then
ScriptLib.SetGadgetStateByConfigId(context, gadget_graph[z][x], 201)
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[检查连接]刷新物件状态"..gadget_graph[z][x])
else
ScriptLib.SetGadgetStateByConfigId(context, gadget_graph[z][x], 0)
end
end
end
end
end
end
--从一个点出发更新电流信息,递归处理
function LF_RunEC(context, ec_pos, is_on, _cvt_graph)
_G_recur_counter = _G_recur_counter + 1
if _G_recur_counter >= defs.len_x*defs.len_z then
return false
end
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]步长".._G_recur_counter.."电流方向".._G_ec_dir.."当前位置z"..ec_pos.z.."当前位置x"..ec_pos.x)
for cfg_id,cvt_pos in pairs(_cvt_graph) do
--找有没有对应的转接器
if cvt_pos.x == ec_pos.x and cvt_pos.z == ec_pos.z then
--判断电桩有没有结晶化
if 0 ~= ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, cfg_id, "GV_TMHY_CRYSTAL") then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]走到了一个结晶化的电桩")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, cfg_id, "SGV_PowerOn", 0)
return false
end
--更新一下电流方向
_G_ec_dir = cvt_pos.dir
--更新电桩状态
if is_on then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, cfg_id, "SGV_PowerOn", 1)
else
ScriptLib.SetEntityServerGlobalValueByConfigId(context, cfg_id, "SGV_PowerOn", 0)
end
end
end
--获取电流的所在节点
local pos_x = ec_pos.x
local pos_z = ec_pos.z
--根据方向流动电流
if _G_ec_dir == DIR.Up then
pos_z = pos_z + 1
end
if _G_ec_dir == DIR.Down then
pos_z = pos_z - 1
end
if _G_ec_dir == DIR.Left then
pos_x = pos_x - 1
end
if _G_ec_dir == DIR.Right then
pos_x = pos_x + 1
end
--检查是否越界,越界检查尝试转弯
if pos_z < 1 or pos_z > defs.len_z or pos_x < 1 or pos_x > defs.len_x then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]走到了尽头,尝试拐弯")
local try_turn_ec = LF_TurnEcDir(context, ec_pos)
if try_turn_ec.dir == DIR.None then
return false
else
_G_ec_dir = try_turn_ec.dir
return LF_RunEC(context, ec_pos, is_on, _cvt_graph)
end
end
--下一个点的信息判断
if connected_graph[pos_z][pos_x] == NODE.Off then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]走到了断路,尝试拐弯")
local try_turn_ec = LF_TurnEcDir(context, ec_pos)
if try_turn_ec.dir == DIR.None then
return false
else
_G_ec_dir = try_turn_ec.dir
return LF_RunEC(context, ec_pos, is_on, _cvt_graph)
end
end
if connected_graph[pos_z][pos_x] == NODE.Power then
return false
end
if connected_graph[pos_z][pos_x] == NODE.N_Pipe then
if is_on then
_G_pipe_state[pos_z][pos_x] = _G_pipe_state[pos_z][pos_x] + 1
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]记录电线打开"..gadget_graph[pos_z][pos_x])
end
return LF_RunEC(context, {z = pos_z,x = pos_x}, is_on, _cvt_graph)
end
if connected_graph[pos_z][pos_x] == NODE.C_Node or connected_graph[pos_z][pos_x] == NODE.N_Node then
--确认节点有没有结晶化
if LF_IsGadgetCrystal(context,gadget_graph[pos_z][pos_x]) then
--如果是打开就给这个位置的标记+1
if is_on then
_G_pipe_state[pos_z][pos_x] = _G_pipe_state[pos_z][pos_x] + 1
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]记录节点打开")
end
end
return LF_RunEC(context, {z = pos_z,x = pos_x}, is_on, _cvt_graph)
end
if connected_graph[pos_z][pos_x] == NODE.Crystal then
if LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]走到了结晶")
return false
else
LF_RunEC(context, {z = pos_z,x = pos_x}, is_on, _cvt_graph)
end
end
--到达了接收器
if connected_graph[pos_z][pos_x] == NODE.N_Rec or connected_graph[pos_z][pos_x] == NODE.C_Rec then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]到达终点")
if LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]到达终点,终点被结晶化,连接失败")
return false
else
if is_on then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]接收器打开")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, gadget_graph[pos_z][pos_x], "SGV_PowerOn", 1)
ScriptLib.SetGadgetStateByConfigId(context, gadget_graph[pos_z][pos_x], 201)
else
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]接收器关闭")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, gadget_graph[pos_z][pos_x], "SGV_PowerOn", 0)
ScriptLib.SetGadgetStateByConfigId(context, gadget_graph[pos_z][pos_x], 0)
end
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]连接完毕")
return true
end
end
if connected_graph[pos_z][pos_x] == NODE.Sy_P_Node or connected_graph[pos_z][pos_x] == NODE.Sy_C_Node then
-- ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]到达终点")
if LF_IsGadgetCrystal(context, gadget_graph[pos_z][pos_x]) then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]到达终点,终点被结晶化,连接失败")
return false
else
if is_on then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, gadget_graph[pos_z][pos_x], "SGV_PowerOn", 1)
else
ScriptLib.SetEntityServerGlobalValueByConfigId(context, gadget_graph[pos_z][pos_x], "SGV_PowerOn", 0)
end
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电路]连接完毕")
return true
end
end
end
--电流在走到头时自动检测是否转向
function LF_TurnEcDir(context, cur_pos)
--原来的电流是上下的尝试左右移动
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]尝试扭转电流")
local can_turn_dir = 0
if _G_ec_dir == DIR.Up or _G_ec_dir == DIR.Down then
--尝试向右转动电流
if (cur_pos.x + 1) <= defs.len_x and (cur_pos.x + 1) >= 1 then
if connected_graph[cur_pos.z][cur_pos.x + 1] >= 1 then
can_turn_dir = can_turn_dir + 1
end
end
--尝试向左转动电流
if (cur_pos.x - 1) >= 1 and (cur_pos.x - 1) <= defs.len_x then
if connected_graph[cur_pos.z][cur_pos.x - 1] >= 1 then
can_turn_dir = can_turn_dir + 10
end
end
--电流上下都没法转或者都能转
if can_turn_dir == 11 or can_turn_dir == 0 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]不转")
return {dir = DIR.None,z = cur_pos.z, x = cur_pos.x}
else
if can_turn_dir == 1 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]右转")
return {dir = DIR.Right,z = cur_pos.z,x = cur_pos.x + 1}
end
if can_turn_dir == 10 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]左转")
return {dir = DIR.Left,z = cur_pos.z,x = cur_pos.x - 1}
end
end
end
if _G_ec_dir == DIR.Left or _G_ec_dir == DIR.Right then
--尝试向上转动电流
if (cur_pos.z + 1) <= defs.len_z and (cur_pos.z + 1) >= 1 then
if connected_graph[cur_pos.z+1][cur_pos.x] >= 1 then
can_turn_dir = can_turn_dir + 1
end
end
--尝试向下转动电流
if (cur_pos.z - 1) >= 1 and (cur_pos.z - 1) <= defs.len_z then
if connected_graph[cur_pos.z-1][cur_pos.x] >= 1 then
can_turn_dir = can_turn_dir + 10
end
end
--电流上下都没法转或者都能转
if can_turn_dir == 11 or can_turn_dir == 0 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]不转")
return {dir = DIR.None, z = cur_pos.z, x = cur_pos.x }
else
if can_turn_dir == 1 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]上转")
return {dir = DIR.Up,z = cur_pos.z + 1,x = cur_pos.x }
end
if can_turn_dir == 10 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:[电流]下转")
return {dir = DIR.Down,z = cur_pos.z - 1,x = cur_pos.x }
end
end
end
end
--判断一个节点或者电源是否被结晶化
function LF_IsGadgetCrystal(context, gadget_cid)
if 0 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, gadget_cid, "GV_TMHY_CRYSTAL") then
return false
else
return true
end
end
--判断电源是否通电,201为电源打开GV为0时非结晶化
function LF_IsGeneratorOn(context, gen_id)
if 0 == ScriptLib.GetGroupTempValue(context, "GenState"..gen_id, {base_info.group_id}) then
return false
else
return true
end
end
--======================================================================================================================
--======================================================================================================================
--计算玩家和电桩的相对位置
--根据玩家和电桩的坐标获取对应的夹角计算出电桩移动的位置
function LF_CalcDirection(context, uid, cvt_id)
local avatar_pos = LF_GetEntityPos(context, context.uid, 0)
local conver_pos = LF_GetEntityPos(context, 0, cvt_id)
local vec_axis_OZ = {x = (axis_Z.x - axis_O.x), z = (axis_Z.z - axis_O.z)}
local vec_axis_OX = {x = (axis_X.x - axis_O.x), z = (axis_X.z - axis_O.z)}
local vec_cvt2avt = {x = (avatar_pos.x - conver_pos.x), z = (avatar_pos.z - conver_pos.z)}
local deg_avt2OZ = LF_ClacAngle(vec_axis_OZ, vec_cvt2avt)
local deg_avt2OX = LF_ClacAngle(vec_axis_OX, vec_cvt2avt)
if 0 <= deg_avt2OZ and deg_avt2OZ <= 45 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:向后推动")
return DIR.Down
end
if 45 < deg_avt2OZ and deg_avt2OZ < 135 then
if 0 <= deg_avt2OX and deg_avt2OX <= 45 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:向左推动")
return DIR.Left
end
if 135 <= deg_avt2OX and deg_avt2OX <= 180 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:向右推动")
return DIR.Right
end
end
if 135 <= deg_avt2OZ and deg_avt2OZ <= 180 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:向前推动")
return DIR.Up
end
end
--计算向量夹角
function LF_ClacAngle(vec1, vec2)
local vec_cos = (vec1.x*vec2.x + vec1.z*vec2.z)/(math.sqrt( vec1.x^2 + vec1.z^2 )*math.sqrt( vec2.x^2 + vec2.z^2))
return (math.acos(vec_cos)/math.pi*180)
end
--拿到实体位置
function LF_GetEntityPos(context, uid, cid)
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:获取坐标")
local _eid = 0
--转译entityId
if uid ~= 0 then
_eid = ScriptLib.GetAvatarEntityIdByUid(context, uid)
elseif cid ~= 0 then
_eid = ScriptLib.GetEntityIdByConfigId(context, cid)
end
--返回安全值,印象中直接返回_array时table里不干净
local _array = ScriptLib.GetPosByEntityId(context, _eid)
local _res = {}
if _array.x == 0 and _array.y == 0 and _array.z == 0 then
ScriptLib.PrintContextLog(context, "##[EnergyTrans]:获取坐标失败,报错")
_res.error = 1
return _res
end
_res.x = _array.x
_res.y = _array.y
_res.z = _array.z
return _res
end
--======================================================================================================================
--切分和储存电桩数据
--|移动类型 1|GadgetState 1|Pos_Z 2|Pos_X 2|
--|1移动 2固定|State 0 1 2 3代表朝向
--切分储存的数据
function LF_GetConverterData(context, config_id)
local cvt_archive_int = ScriptLib.GetGroupVariableValue(context, "converter_"..tostring(config_id))
local cvt_archive_str = tostring(math.ceil(cvt_archive_int))
return { cvt_type = tonumber(string.sub(cvt_archive_str,1,1)),
dir = tonumber(string.sub(cvt_archive_str,2,2)),
z = tonumber(string.sub(cvt_archive_str,3,4)),
x = tonumber(string.sub(cvt_archive_str,5,6))}
end
--数据储存
function LF_SetConverterData( context, config_id, data_type, data_info)
local cvt_archive_int = ScriptLib.GetGroupVariableValue(context, "converter_"..tostring(config_id))
local cvt_archive_str = tostring(math.ceil(cvt_archive_int))
local cvt_new_archive_str = ""
if data_type == "Gadget_State" then
cvt_new_archive_str = table.concat({string.sub(cvt_archive_str,1,1), tostring(data_info), string.sub(cvt_archive_str,3,6)})
ScriptLib.SetGroupVariableValue(context, "converter_"..config_id, math.ceil( tonumber(cvt_new_archive_str)) )
end
if data_type == "Gadget_Pos" then
local cvt_pos_new_z = ""
local cvt_pos_new_x = ""
if data_info.pos_z < 10 then
cvt_pos_new_z = "0"..tostring(data_info.pos_z)
else
cvt_pos_new_z = tostring(data_info.pos_z)
end
if data_info.pos_x < 10 then
cvt_pos_new_x = "0"..tostring(data_info.pos_x)
else
cvt_pos_new_x = tostring(data_info.pos_x)
end
cvt_new_archive_str = table.concat({string.sub(cvt_archive_str,1,2), cvt_pos_new_z, cvt_pos_new_x})
ScriptLib.SetGroupVariableValue(context, "converter_"..config_id, math.ceil( tonumber(cvt_new_archive_str)) )
end
end
--======================================================================================================================
ET_Initialize()

View File

@@ -0,0 +1,110 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
--======================================================================================================================
--|| Filename || PB_ChaseFeather
--|| RelVersion || V3_6
--|| Owner || chao-jin
--|| Description || 追逐草神羽毛的玩法
--|| LogName || ##[PB_ChaseFeather]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
local defs = {
feather = 108001, --草神羽毛的ID
pointarray_id = 110200030, --草神羽毛移动的点阵ID
target_pos = 6, --最后的目标点
end_suite = 2, --
}
--======================================================================================================================
--Events || Group内EVENT事件,记得初始化和return 0
local CF_Triggers = {
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ name = "platform_arrival", config_id = 8000102, event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_platform_arrival", trigger_count = 0 },
{ name = "any_gadget_die", config_id = 8000103, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0 },
}
function CF_Initialize()
for k,v in pairs(CF_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
CF_Initialize()
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:追逐羽毛Group加载初始化")
ScriptLib.SetGroupTempValue(context, "CurrentPos", 1, {base_info.group_id})
ScriptLib.SetGroupTempValue(context, "TargetPos", 2, {base_info.group_id})
ScriptLib.SetGroupTempValue(context, "ChaseStarted", 0, {base_info.group_id})
return 0
end
--羽毛到达目标点
function action_platform_arrival(context, evt)
if evt.param1 ~= defs.feather then
return 0
end
if evt.param3 ~= ScriptLib.GetGroupTempValue(context, "TargetPos", {base_info.group_id}) then
return 0
end
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:羽毛到达目标点,更新位置信息"..evt.param3)
if evt.param3 == defs.target_pos then
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:羽毛到达目标点,更新羽毛状态为可以拾取")
ScriptLib.SetGadgetStateByConfigId(context, defs.feather, 201)
return 0
end
ScriptLib.SetGroupTempValue(context, "CurrentPos", evt.param3, {base_info.group_id})
ScriptLib.SetGroupTempValue(context, "ChaseStarted", 0, {base_info.group_id})
return 0
end
--羽毛从201状态死亡完成玩法
function action_any_gadget_die(context, evt)
if evt.param1 == defs.feather then
ScriptLib.ShowReminder(context, 400112)
-- ScriptLib.GoToGroupSuite(context, base_info.group_id, defs.end_suite)
end
return 0
end
--======================================================================================================================
--ServerLuaCalls || 物件SLC,记得return 0
--羽毛被追逐
function SLC_BeChased(context)
if 0 ~= ScriptLib.GetGroupTempValue(context, "ChaseStarted", {base_info.group_id}) then
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:羽毛正在移动")
return 0
end
if 0 ~= ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.feather) then
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:羽毛移动完成")
return 0
end
local cur_pos = ScriptLib.GetGroupTempValue(context, "CurrentPos", {base_info.group_id})
if cur_pos == 1 then
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:追逐开始,闪现到目标点")
ScriptLib.SetGroupTempValue(context, "CurrentPos", 2, {base_info.group_id})
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.feather)
local _ret,R_pos,R_rot = ScriptLib.GetPlatformArrayInfoByPointId(context, defs.pointarray_id, 2)
local blink_pos = {x = R_pos.x, y = R_pos.y, z = R_pos.z}
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.feather, blink_pos, {x = 0, y = 0, z = 0})
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:闪现结束".._ret)
return 0
end
ScriptLib.SetGroupTempValue(context, "ChaseStarted", 1, {base_info.group_id})
ScriptLib.SetGroupTempValue(context, "TargetPos", cur_pos+1, {base_info.group_id})
ScriptLib.PrintContextLog(context, "##[PB_ChaseFeather.lua]:追逐开始"..cur_pos.."to"..(cur_pos+1))
ScriptLib.SetPlatformPointArray(context, defs.feather, defs.pointarray_id, {cur_pos, cur_pos+1}, {route_type = 0})
ScriptLib.StartPlatform(context, defs.feather)
return 0
end
--======================================================================================================================
--LevelFunctions || 自定义函数

View File

@@ -0,0 +1,87 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
--======================================================================================================================
--|| Filename || PB_CollectFeatherOrb
--|| RelVersion || V3_6
--|| Owner || chao-jin
--|| Description || 3.6 收集草神羽毛碎片的玩法
--|| LogName || ##[PB_CollectFeatherOrb]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
--Suite1 配置羽毛 Suite2 配置微粒
--[[
local defs = {
time_limit = 20,
feather = 106001, --羽毛的ConfigID
orb_gadget_id = 70290729,
orb_nums = 5,
end_suite = 3,
}
]]
--======================================================================================================================
--Events || Group内EVENT事件,记得初始化和return 0
local CFO_Triggers = {
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ name = "time_axis_pass", config_id = 8000102, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
{ name = "any_gadget_die", config_id = 8000103, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0 },
}
function CFO_Initialize()
for k,v in pairs(CFO_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
CFO_Initialize()
--Group加载的时候初始化值
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:Group加载记录死亡的微粒数量")
ScriptLib.SetGroupTempValue(context, "OrbsCollectNums", 0, {base_info.group_id})
return 0
end
--收集微粒的时间轴
function action_time_axis_pass(context, evt)
--时间轴期间没有收集完毕微粒玩法重置
if evt.source_name == "CollectOrbs" then
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:时间限制内没有收集完成全部微粒,玩法重置")
ScriptLib.SetGroupTempValue(context, "OrbsCollectNums", 0, {base_info.group_id})
ScriptLib.ShowReminder(context, 400113)
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 1})
end
return 0
end
--检测微粒死亡
function action_any_gadget_die(context, evt)
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:草神羽毛微粒死亡,计数+1")
local orb_killed_num = ScriptLib.GetGroupTempValue(context, "OrbsCollectNums", {base_info.group_id})
ScriptLib.ChangeGroupTempValue(context, "OrbsCollectNums", 1, {base_info.group_id})
if orb_killed_num + 1 == defs.orb_nums then
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:草神羽毛全部死亡,完成玩法")
-- ScriptLib.GoToGroupSuite(context, base_info.group_id, defs.end_suite)
ScriptLib.ShowReminder(context, 400112)
ScriptLib.EndTimeAxis(context, "CollectOrbs")
end
return 0
end
--======================================================================================================================
--ServerLuaCalls || 物件SLC,记得return 0
--靠近羽毛之后羽毛散开创生需要收集的结晶
function SLC_CollectStart(context)
ScriptLib.PrintContextLog(context, "##[PB_CollectFeatherOrb.lua]:靠近草神羽毛,玩法开始")
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, defs.feather)
ScriptLib.InitTimeAxis(context, "CollectOrbs", {defs.time_limit}, false)
return 0
end
--======================================================================================================================
--LevelFunctions || 自定义函数

View File

@@ -0,0 +1,49 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
--======================================================================================================================
--|| Filename || PB_CrystalMonster
--|| RelVersion || V3_6
--|| Owner || chao-jin
--|| Description ||
--|| LogName || ##[PB_CrystalMonster]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
--[[
local crystal_to_monster = {
[126002] = 126001,
[126003] = 126004,
}
]]
--======================================================================================================================
--Events || Group内EVENT事件,记得初始化和return 0
local CM_Triggers ={
{ name = "gadget_state_change", config_id = 8000102, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
}
function CM_Initialize()
for k,v in pairs(CM_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
-- table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
end
CM_Initialize()
function action_gadget_state_change(context, evt)
if crystal_to_monster[evt.param2] ~= nil then
if evt.param1 == 201 then
ScriptLib.CreateMonster(context, { config_id = crystal_to_monster[evt.param2], delay_time = 0 })
end
end
return 0
end
--======================================================================================================================
--ServerLuaCalls || 物件SLC,记得return 0
--======================================================================================================================
--LevelFunctions || 自定义函数

View File

@@ -0,0 +1,78 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
--======================================================================================================================
--|| Filename || PB_ElfFlower
--|| RelVersion || V3_6
--|| Owner || chao-jin
--|| Description || 精灵花朵收集玩法
--|| LogName || ##[PB_ElfFlower]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
--[[
local defs = {
flower_gadget_id = 70290733,
}
local elf_flowers = {}
]]
--======================================================================================================================
--Events || Group内EVENT事件,记得初始化和return 0
local EF_Triggers ={
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ name = "gadget_state_change", config_id = 8000102, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
{ name = "time_axis_pass", config_id = 8000103, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
}
function EF_Initialize()
for k,v in pairs(EF_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
end
EF_Initialize()
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "##[PB_ElfFlower]:精灵花朵玩法加载")
ScriptLib.SetGroupTempValue(context, "FlowerBloomed", 0, {base_info.group_id})
return 0
end
--监听花朵状态
function action_gadget_state_change(context, evt)
if gadgets[evt.param2].gadget_id == 70290733 and evt.param1 == 201 then
ScriptLib.PrintContextLog(context, "##[PB_ElfFlower]: 精灵花朵状态变化")
if #elf_flowers == ScriptLib.GetGroupTempValue(context, "FlowerBloomed", {base_info.group_id}) then
ScriptLib.EndTimeAxis(context, "FlowerBloomTrail")
ScriptLib.PrintContextLog(context, "##[PB_ElfFlower]:挑战完成")
for i=1,#elf_flowers do
ScriptLib.SetGadgetStateByConfigId(context, elf_flowers[i], 202)
end
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
return 0
end
ScriptLib.EndTimeAxis(context, "FlowerBloomTrail")
ScriptLib.InitTimeAxis(context, "FlowerBloomTrail", {defs.time_limit}, false)
ScriptLib.ChangeGroupTempValue(context, "FlowerBloomed", 1, {base_info.group_id})
end
return 0
end
function action_time_axis_pass(context, evt)
if evt.source_name == "FlowerBloomTrail" then
ScriptLib.PrintContextLog(context, "##[PB_ElfFlower]:时间结束重置Group")
ScriptLib.SetGroupTempValue(context, "FlowerBloomed", 0, {base_info.group_id})
for i=1,#elf_flowers do
ScriptLib.SetGadgetStateByConfigId(context, elf_flowers[i], 0)
end
end
return 0
end
--======================================================================================================================
--ServerLuaCalls || 物件SLC,记得return 0
--======================================================================================================================
--LevelFunctions || 自定义函数

View File

@@ -0,0 +1,85 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
--======================================================================================================================
--|| Filename || PB_FireTrail
--|| RelVersion || V3_6
--|| Owner || chao-jin
--|| Description ||
--|| LogName || ##[PB_FireTrail]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
--[[
local defs = {
fire_seed = 110001,
time_limit = 5,
}
local pillars = {110002,110003,110004,110005,110006}
]]
--======================================================================================================================
--Events || Group内EVENT事件,记得初始化和return 0
local FT_Triggers ={
{ name = "group_load", config_id = 8000101, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ name = "gadget_state_change", config_id = 8000102, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
{ name = "time_axis_pass", config_id = 8000103, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
}
function FT_Initialize()
for k,v in pairs(FT_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001,name = "Finished", value = 0, no_refresh = true})
end
FT_Initialize()
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:火传导加载")
ScriptLib.SetGroupTempValue(context, "PillarChanged", 0, {base_info.group_id})
return 0
end
function action_gadget_state_change(context, evt)
if evt.param2 == defs.fire_seed and evt.param1 == 201 then
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:火种状态变化,开启时间轴")
ScriptLib.InitTimeAxis(context, "FireTrail", {defs.time_limit}, false)
return 0
else
if gadgets[evt.param2].gadget_id == 70800422 and evt.param1 == 201 then
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:传导柱状态变化,更新数量")
if #pillars == ScriptLib.GetGroupTempValue(context, "PillarChanged", {base_info.group_id}) then
ScriptLib.EndTimeAxis(context, "FireTrail")
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:挑战完成")
ScriptLib.SetGroupVariableValue(context, "Finished", 1)
return 0
end
ScriptLib.EndTimeAxis(context, "FireTrail")
ScriptLib.InitTimeAxis(context, "FireTrail", {defs.time_limit}, false)
ScriptLib.ChangeGroupTempValue(context, "PillarChanged", 1, {base_info.group_id})
end
end
return 0
end
function action_time_axis_pass(context, evt)
if evt.source_name == "FireTrail" then
ScriptLib.PrintContextLog(context, "##[PB_FireTrail.lua]:火种监听的时间结束重置Group")
ScriptLib.SetGroupTempValue(context, "PillarChanged", 0, {base_info.group_id})
ScriptLib.SetGadgetStateByConfigId(context, defs.fire_seed, 0)
for i=1,#pillars do
ScriptLib.SetGadgetStateByConfigId(context, pillars[i], 0)
end
end
return 0
end
--======================================================================================================================
--ServerLuaCalls || 物件SLC,记得return 0
--======================================================================================================================
--LevelFunctions || 自定义函数

View File

@@ -0,0 +1,70 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
--======================================================================================================================
--|| Filename || PB_FlowerInStone
--|| RelVersion || V3_6
--|| Owner || chao-jin
--|| Description ||
--|| LogName || ##[PB_FlowerInStone]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
--[[
local defs = {
bloom_time = 10,
}
local flower_core = {
[flower_cfg_id] = core_cfg_id,
}
]]
--======================================================================================================================
--Events || Group内EVENT事件,记得初始化和return 0
local FIS_Triggers = {
{ name = "gadget_state_change", config_id = 8000101, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
{ name = "time_axis_pass", config_id = 8000102, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
}
function FIS_Initialize()
for k,v in pairs(FIS_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
FIS_Initialize()
--石中花的状态变化创建和移除采集物
function action_gadget_state_change(context, evt)
if flower_core[evt.param2] ~= nil then
if evt.param1 == 0 then
ScriptLib.PrintContextLog(context, "##[PB_FlowerInStone.lua]:石中花关闭,移除采集物")
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, flower_core[evt.param2])
return 0
end
if evt.param1 == 201 then
ScriptLib.PrintContextLog(context, "##[PB_FlowerInStone.lua]:石中花打开,创建采集物")
ScriptLib.CreateGadget(context, {config_id = flower_core[evt.param2]})
ScriptLib.InitTimeAxis(context, tostring(evt.param2), {defs.bloom_time}, false)
return 0
end
end
return 0
end
--开花后一段时间闭合
function action_time_axis_pass(context, evt)
local flower_id = tonumber(evt.source_name)
if flower_id ~= nil then
ScriptLib.SetGadgetStateByConfigId(context, flower_id, 0)
end
return 0
end
--======================================================================================================================
--ServerLuaCalls || 物件SLC,记得return 0
--======================================================================================================================
--LevelFunctions || 自定义函数

View File

@@ -0,0 +1,36 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
--======================================================================================================================
--|| Filename || PB_LeafPlatform
--|| RelVersion || V3_6
--|| Owner || chao-jin
--|| Description || 叶片平台用于在状态改变时创生钩锁点
--|| LogName || ##[PB_LeafPlatform]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
--[[
local hook_map = {
[] = ,
}
]]
--======================================================================================================================
--ServerLuaCalls || 物件SLC,记得return 0
--平台关闭
function SLC_PlatformOff(context)
local config_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
if hook_map[config_id] ~= nil then
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, hook_map[config_id])
end
return 0
end
--平台打开
function SLC_PlatformOn(context)
local config_id = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
if hook_map[config_id] ~= nil then
ScriptLib.CreateGadget(context, {config_id = hook_map[config_id] })
end
return 0
end

View File

@@ -0,0 +1,86 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_4]
--======================================================================================================================
--|| Filename || ResidualBright
--|| RelVersion || V3_4
--|| Owner || chao-jin
--|| Description ||
--|| LogName || ##[ResidualBright]
--|| Protection ||
--======================================================================================================================
--Defs & Miscs
--[[
local defs = {
reset_region = 82001,
gadget_id_bright = 70310498,
}
]]
--======================================================================================================================
--Triggers&Init
local BrightTriggers={
{ config_id = 8000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 8000002,name = "leave_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_reset_region", forbid_guest = false, trigger_count = 0 },
-- { config_id = 8000003, name = "gadget_state_change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#BrightTriggers do
table.insert(triggers, BrightTriggers[i])
table.insert(suites[init_config.suite].triggers,BrightTriggers[i].name)
end
table.insert(variables,{ config_id = 50000001, name = "successed", value = 0, no_refresh = true})
--初始化
end
LF_Initialize_Group(triggers, suites)
--======================================================================================================================
--Events
--加载判定物件状态
function action_group_load(context, evt)
if ScriptLib.GetGroupVariableValue(context, "successed")==1 then
LF_RemoveAllRepeater(context)
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 3)
for i=1,#gadgets do
if gadgets[i].gadget_id == defs.gadget_id_bright then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, gadgets[i].config_id, 901)
end
end
return 0
end
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
return 0
end
--退出区域关闭挑战
function action_leave_reset_region(context, evt)
if evt.param1 ~= defs.reset_region then
return 0
end
if ScriptLib.GetGroupVariableValue(context, "successed")==1 then
LF_RemoveAllRepeater(context)
return 0
end
ScriptLib.RefreshGroup(context,{group_id=base_info.group_id,suite=1})
ScriptLib.AddExtraGroupSuite(context, base_info.group_id, 2)
return 0
end
--======================================================================================================================
--LevelFunctions
function LF_RemoveAllRepeater(context)
ScriptLib.PrintContextLog(context, "##[ResidualBright]:移除所有的残念")
for i=1,#gadgets do
if gadgets[i].gadget_id == defs.gadget_id_bright then
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.GADGET, gadgets[i].config_id)
end
end
return 0
end

View File

@@ -0,0 +1,213 @@
--ServerUploadTool Save to [/root/env/data/lua/common/V3_6]
--======================================================================================================================
--|| Filename || WQ_ElfFollow
--|| RelVersion || V3_6
--|| Owner || chao-jin
--|| Description || 用来给WQ任务中小精灵伴飞的Require处理
--|| LogName || ##[WQ_ElfFollow]
--|| Protection || 玩法失败refresh到suite1中间不存档
--======================================================================================================================
--Defs & Miscs || 需要LD配置的内容
--[[
local defs = {
elf_config_id = 75001,
pointarray_id = 110200031, --使用的点阵ID
dis_fail_limit = 15, --跟随的最大距离限制
dis_warning_limit = 6, --超出报警的距离
time_fail_limit = 8, --超出最大距离限制判的上限时间
time_warning_cd = 5, --提示玩家跟随的CD
slusha_type = 3, --司露莎载具状态
reminder_follow = 400094, --提示跟随
reminder_fail = 400113,
reminder_success = 400112,
point_target = 15, --最终到达的终点ID
end_suite = 2
}
--小精灵到达对应的Point时短暂停留播放动画播的动画ID
local elf_actions = {
[1] = {wait_time = 0,action_id = 0, next_point = 4}, --目标点在点阵内的PointID 到达点阵时播放的动画ID,没有则填0
[4] = {wait_time = 2,action_id = 0, next_point = 8},
[8] = {wait_time = 2,action_id = 0, next_point = 12},
[12] = {wait_time = 2,action_id = 0, next_point = 15},
[15] = {wait_time = 2,action_id = 0, next_point = 0},
}
]]
--======================================================================================================================
--Events || Group内EVENT事件,记得初始化和return 0
local ElfFollow_Triggers = {
{ name = "gadget_state_change", config_id = 8000101, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
{ name = "time_axis_pass", config_id = 8000102, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
{ name = "platform_arrival", config_id = 8000103, event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_platform_arrival", trigger_count = 0 }
}
function ElfFollow_Initialize()
for k,v in pairs(ElfFollow_Triggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
ElfFollow_Initialize()
--监听小精灵Gadget的状态切到201的时候开始玩法
function action_gadget_state_change(context, evt)
if evt.param2 == defs.elf_config_id and evt.param1 == 201 then
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:小精灵状态改变,开始飞行玩法")
LF_StartFollowPlay(context)
end
return 0
end
--定时检测距离
function action_time_axis_pass(context, evt)
-- ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:触发TimeAxis")
--提示跟随
if evt.source_name == "WARNING_CD" then
ScriptLib.SetGroupTempValue(context, "IS_WARNING_CD", 0, {})
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:提示CD结束")
end
--检查玩家和小精灵距离
if evt.source_name == "CHECK_DISTANCE" then
LF_CalcDist(context)
end
--检查玩家是否上了载具
if evt.source_name == "CHECK_PLAYER_VEHICLE" then
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:检查玩家是否上载具")
local _host_uid = ScriptLib.GetSceneOwnerUid(context)
if defs.slusha_type ~= ScriptLib.GetPlayerVehicleType(context, _host_uid) then
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:玩家没有上载具")
LF_FollowPlayFail(context)
end
end
--小精灵继续飞行
if evt.source_name == "ELF_FLY_AFTER_WAIT" then
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:小精灵继续飞行")
ScriptLib.SetPlatformPointArray(context, defs.elf_config_id, defs.pointarray_id, LF_GetFlyPath(context), {route_type = 0,turn_mode = false})
end
return 0
end
--到达停留点
function action_platform_arrival( context, evt)
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:小精灵到达点"..evt.param3)
--到达终点
if evt.param3 == defs.point_target then
LF_FollowPlaySuccess(context)
return 0
end
if elf_actions[evt.param3] ~= nil then
--小精灵播动画
if elf_actions[evt.param3].action_id ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, defs.elf_config_id, elf_actions[evt.param3].action_id)
end
--更新当前的点
if evt.param3 ~= ScriptLib.GetGroupTempValue(context, "ELF_CUR_POINT", {base_info.group_id}) then
ScriptLib.SetGroupTempValue(context, "ELF_CUR_POINT", evt.param3, {})
end
--等待一段时间后继续飞行
if elf_actions[evt.param3].wait_time ~= 0 then
ScriptLib.InitTimeAxis(context, "ELF_FLY_AFTER_WAIT", {elf_actions[evt.param3].wait_time}, false)
else
ScriptLib.SetPlatformPointArray(context, defs.elf_config_id, defs.pointarray_id, LF_GetFlyPath(context), {route_type = 0,turn_mode = false})
end
end
return 0
end
--======================================================================================================================
--LevelFunctions || 自定义函数
--开始小精灵跟随玩法
function LF_StartFollowPlay(context)
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:跟随玩法开始")
--记录离开距离过远的次数
ScriptLib.SetGroupTempValue(context, "TIME_TOO_FAR", 0, {})
--记录是否在提示冷却中
ScriptLib.SetGroupTempValue(context, "IS_WARNING_CD", 0, {})
--记录小精灵移动平台当前在哪个点
ScriptLib.SetGroupTempValue(context, "ELF_CUR_POINT", 1, {})
--创建一个时间轴检查规定时间内是否处于载具状态
ScriptLib.InitTimeAxis(context, "CHECK_PLAYER_VEHICLE", {8}, false)
--创建一个时间轴定期计算玩家和小精灵的距离
ScriptLib.InitTimeAxis(context, "CHECK_DISTANCE", {1}, true)
ScriptLib.SetPlatformPointArray(context, defs.elf_config_id, defs.pointarray_id, LF_GetFlyPath(context), {route_type = 0,turn_mode = false})
end
--检查玩家和小精灵的距离
function LF_CalcDist(context)
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:处理玩家和小精灵之间的距离")
--计算玩家和小精灵的距离
local dis_h2e = 100
local uid_list = ScriptLib.GetSceneUidList(context)
if uid_list ~= nil then
local _host_uid = ScriptLib.GetSceneOwnerUid(context)
local _avatar_eid = ScriptLib.GetAvatarEntityIdByUid(context, _host_uid)
local _avatar_pos = ScriptLib.GetPosByEntityId(context, _avatar_eid)
local _elf_eid = ScriptLib.GetEntityIdByConfigId(context, defs.elf_config_id)
local _elf_pos = ScriptLib.GetPosByEntityId(context, _elf_eid)
dis_h2e = math.sqrt( (_avatar_pos.x - _elf_pos.x)^2 + (_avatar_pos.y - _elf_pos.y)^2 +(_avatar_pos.z - _elf_pos.z)^2 )
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:距离"..dis_h2e)
end
--超出提示距离
if dis_h2e > defs.dis_warning_limit then
if 0 == ScriptLib.GetGroupTempValue(context, "IS_WARNING_CD", {}) then
ScriptLib.ShowReminder(context, defs.reminder_follow)
ScriptLib.SetGroupTempValue(context, "IS_WARNING_CD", 1, {})
ScriptLib.InitTimeAxis(context, "WARNING_CD", {defs.time_waring_cd}, false)
end
end
--处理超出限制距离
if dis_h2e > defs.dis_fail_limit then
--更新超出距离的次数
ScriptLib.ChangeGroupTempValue(context, "TIME_TOO_FAR", 1, {})
--计算一下
if defs.time_fail_limit < ScriptLib.GetGroupTempValue(context, "TIME_TOO_FAR", {}) then
LF_FollowPlayFail(context)
return 0
end
else
--靠近后累计时间清零
ScriptLib.SetGroupTempValue(context, "TIME_TOO_FAR", 0, {})
end
end
--关闭所有时间轴
function LF_EndAllTimeAxis(context)
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:停止所有时间轴")
ScriptLib.EndTimeAxis(context, "IS_WARNING_CD")
ScriptLib.EndTimeAxis(context, "CHECK_PLAYER_VEHICLE")
ScriptLib.EndTimeAxis(context, "CHECK_DISTANCE")
end
--跟随玩法失败
function LF_FollowPlayFail(context)
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:玩法失败")
LF_EndAllTimeAxis(context)
ScriptLib.ShowReminder(context, defs.reminder_fail)
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite=1})
end
--跟随玩法成功
function LF_FollowPlaySuccess(context)
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:玩法成功")
ScriptLib.ShowReminder(context, defs.reminder_success)
LF_EndAllTimeAxis(context)
ScriptLib.GoToGroupSuite(context, base_info.group_id, defs.end_suite)
end
--根据当前点生成飞行的路径
function LF_GetFlyPath(context)
ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:生成飞行路径")
local cur_point = ScriptLib.GetGroupTempValue(context, "ELF_CUR_POINT", {})
local fly_path = {}
if cur_point < defs.point_target then
local target_point = elf_actions[cur_point].next_point
for i=cur_point,target_point do
table.insert(fly_path, i)
-- ScriptLib.PrintContextLog(context, "##[WQ_ElfFollow]:路径"..i)
end
end
return fly_path
end