更新配置表

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,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()