添加配置表

This commit is contained in:
flswld
2022-11-30 00:00:20 +08:00
parent f70a890338
commit d7f3f3b866
33382 changed files with 8476601 additions and 0 deletions

View File

@@ -0,0 +1,372 @@
--[[
local defs = {
box_gadget_id = 1,
point_array_id = 1,
option_id = 1,
reminder_level_boarder = 1,
reminder_array_boarder = 1,
reminder_box_conflict = 1,
}
--地形信息0-墙面,1-地面,2-空气墙
local level_map = {
{0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0},
{0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,0,0},
{1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1},
{0,0,0,0,0,0,0,0,2,1,0,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,2,1,0,1,1,1,1,1,1}
}
--点阵id信息
local point_map = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 0, 9,10,11,12, 0, 0},
{13,14,15,16,17,18,19,20,21,22, 0,23, 0,24,25,26,27},
{ 0, 0, 0, 0, 0, 0, 0, 0, 2,28, 0,29,30,31,32,33,34},
{ 0, 0, 0, 0, 0, 0, 0, 0, 2,35, 0,36,37,38,39,40,41}
}
--箱子起始信息
local box_config = {
[1] = {config_id = 1001, pos = {x=8,z=3}},
[2] = {config_id = 1002, pos = {x=11,z=1}},
[3] = {config_id = 1003, pos = {x=12,z=2}},
[4] = {config_id = 1004, pos = {x=13,z=2}}
}
--]]
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local Tri = {
{ name = "Group_Load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ name = "Gadget_Create", config_id = 8000002, event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
{ name = "Select_Option", config_id = 8000003, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
{ name = "Platform_Reach_Point", config_id = 8000004, event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_platform_reach_point", trigger_count = 0 },
{ name = "Group_Refresh", config_id = 8000005, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0 },
--{ name = "Avatar_Near_Platform", config_id = 8000006, event = EventType.EVENT_AVATAR_NEAR_PLATFORM, source = "", condition = "", action = "action_avatar_near_platform", trigger_count = 0 }
{ name = "Time_Axis_Pass", config_id = 8000006, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 }
}
function Initialize()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
--table.insert(suites[init_config.suite].triggers, v.name)
--根据2.4需求,只要注册进suite 3即可
table.insert(suites[3].triggers, v.name)
end
end
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function LF_Notify(context, r_id)
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Notify | reminder_id="..r_id)
ScriptLib.ShowReminder(context, r_id)
end
--初始化所有box的位置
function LF_Init_Level(context)
ScriptLib.SetGroupTempValue(context, "next_point_x", 0, {})
ScriptLib.SetGroupTempValue(context, "next_point_z", 0, {})
for i,v in ipairs(box_config) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v.config_id)
local _ret,R_pos,R_rot = ScriptLib.GetPlatformArrayInfoByPointId(context, defs.point_array_id, point_map[v.pos.z][v.pos.x])
local _pos = {x=R_pos.x,y=R_pos.y,z=R_pos.z}
local _rot = {x=0,y=0,z=0}
ScriptLib.CreateGadgetByConfigIdByPos(context, v.config_id, _pos, _rot)
ScriptLib.SetPlatformPointArray(context, v.config_id, defs.point_array_id, {point_map[v.pos.z][v.pos.x]}, {})
ScriptLib.SetGroupTempValue(context, "box_pos_x_"..i, v.pos.x, {})
ScriptLib.SetGroupTempValue(context, "box_pos_z_"..i, v.pos.z, {})
end
end
function LF_Get_Entity_Pos(context, uid, cid)
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Get_Entity_Pos")
local _eid = 0
--转译entityId
if uid ~= 0 then
_eid = ScriptLib.GetAvatarEntityIdByUid(context, uid)
elseif cid ~= 0 then
_eid = ScriptLib.GetEntityIdByConfigId(context, cid)
end
--返回安全值,印象中直接返回_array时table里不干净
local _array = ScriptLib.GetPosByEntityId(context, _eid)
local _res = {}
if _array.x == 0 and _array.y == 0 and _array.z == 0 then
ScriptLib.PrintContextLog(context, "## BoxPusher : Get Pos Fail !!! | uid="..uid.." | cid="..cid)
_res.error = 1
return _res
end
_res.x = _array.x
_res.y = _array.y
_res.z = _array.z
return _res
end
function LF_Get_Push_Direction(context, avatar, target)
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Get_Push_Direction")
local _direction = {x=0,y=0,z=0}
_direction.x = target.x - avatar.x
_direction.y = target.y - avatar.y
_direction.z = target.z - avatar.z
local _direct = ""
local _angle = 0
--世界坐标系正X为up,正Z为left
if _direction.x == 0 then
if _direction.z >= 0 then
_direct = "left"
else _direct = "right"
end
else
_angle = math.deg(math.atan(_direction.z/_direction.x))
if math.abs(_angle) <= 45 then
if _direction.x > 0 then
_direct = "up"
else _direct = "down"
end
else
if _direction.z > 0 then
_direct = "left"
else _direct = "right"
end
end
end
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Get_Entity_Pos | _direct = ".._direct)
return _direct
end
function LF_Try_Push_Box(context, config_id, direction)
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Try_Push_Box | config_id = "..config_id.." | direction = "..direction)
local _box = ScriptLib.GetPlatformPointArray(context, config_id)
local _box_point = _box[2]
local _is_found = false
--以i,j获取当前的坐标
for _j,_list in ipairs(point_map) do
if _is_found == true then
break
end
for _i,point in ipairs(_list) do
if point == _box_point then
--检测地图连通性
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Try_Push_Box | Point_Map_Pos | x=".._i.." | z=".._j)
local _connection = LF_Check_Target_Position(context, _i, _j, direction)
if #_connection == 2 then
--执行箱子移动
LF_Execute_Box_Move(context, config_id, {_i,_j}, _connection)
end
_is_found = true
break
end
end
end
end
function LF_Check_Target_Position(context, x, z, forward)
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Check_Target_Position | x="..x.."|z="..z.."|forward="..forward)
local res = {}
local _x = x
local _z = z
if forward == "up" then
_z = _z - 1
elseif forward == "down" then
_z = _z + 1
elseif forward == "right" then
_x = _x + 1
elseif forward == "left" then
_x = _x - 1
else
ScriptLib.PrintContextLog(context, "## BoxPusher : Invalid Box Direction !!! | forward="..forward)
return res
end
--判地图边界
if _x < 1 or _x > #level_map[z] or _z < 1 or _z > #level_map then
LF_Notify(context, defs.reminder_level_boarder)
return res
end
--判路点边界
if point_map[_z][_x] == 0 then
LF_Notify(context, defs.reminder_array_boarder)
return res
end
--判有无箱子
for _box,_pos in ipairs(box_config) do
if ScriptLib.GetGroupTempValue(context, "box_pos_x_".._box, {}) == _x and ScriptLib.GetGroupTempValue(context, "box_pos_z_".._box, {}) == _z then
LF_Notify(context, defs.reminder_box_conflict)
return res
end
end
res[1] = _x
res[2] = _z
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Check_Target_Position |_x=".._x.."|_z=".._z)
return res
end
function LF_Execute_Box_Move(context, config_id, source, vector)
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Execute_Box_Move | config_id="..config_id)
--下option锁推箱子操作
LF_Lock_Operation(context, true)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, config_id, 201)
ScriptLib.SetGroupTempValue(context, "next_point_x", vector[1], {})
ScriptLib.SetGroupTempValue(context, "next_point_z", vector[2], {})
ScriptLib.SetPlatformPointArray(context, config_id, defs.point_array_id, {point_map[source[2]][source[1]] ,point_map[vector[2]][vector[1]]}, {})
--增加一个时间轴保底
ScriptLib.InitTimeAxis(context, tostring(config_id), {10}, true)
end
function LF_Lock_Operation(context, is_locked)
if is_locked == true then
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Lock_Operation | is_locked = true")
for i,v in ipairs(box_config) do
ScriptLib.DelWorktopOptionByGroupId(context, 0, v.config_id, defs.option_id)
end
elseif is_locked == false then
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Lock_Operation | is_locked = false")
for id,box in ipairs(box_config) do
ScriptLib.SetWorktopOptionsByGroupId(context, 0, box.config_id, {defs.option_id})
--停止时间轴
ScriptLib.EndTimeAxis(context, tostring(box.config_id))
--清空目标点cache
ScriptLib.SetGroupTempValue(context, "next_point_x", 0, {})
ScriptLib.SetGroupTempValue(context, "next_point_z", 0, {})
end
end
end
function LF_Level_Finish(context)
ScriptLib.PrintContextLog(context, "## BoxPusher : LF_Level_Finish")
if init_config.end_suite ~= 0 then
ScriptLib.GoToGroupSuite(context, 0, init_config.end_suite)
end
end
--=====================================
function action_group_load(context, evt)
local cur_suite = ScriptLib.GetGroupSuite(context, 0)
if cur_suite ~= init_config.end_suite then
LF_Init_Level(context)
end
return 0
end
function action_group_refresh(context, evt)
local cur_suite = ScriptLib.GetGroupSuite(context, 0)
if cur_suite ~= init_config.end_suite then
LF_Init_Level(context)
end
return 0
end
function action_gadget_create(context, evt)
if gadgets[evt.param1].gadget_id == defs.box_gadget_id then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, evt.param1, {defs.option_id})
return 0
end
return -1
end
function action_select_option(context, evt)
if evt.param2 ~= defs.option_id then
return -1
end
--获取玩家位置与箱子位置
local _avatar_pos = LF_Get_Entity_Pos(context, context.uid, 0)
local _box_pos = LF_Get_Entity_Pos(context, 0, evt.param1)
if _avatar_pos.error == 1 or _box_pos.error == 1 then
ScriptLib.PrintContextLog(context, "BoxPusher : Invalid entity pos !!!!")
return -1
end
--计算推动方向
local _dir = LF_Get_Push_Direction(context, _avatar_pos, _box_pos)
LF_Try_Push_Box(context, evt.param1, _dir)
return 0
end
function action_platform_reach_point(context, evt)
--记录下个理论点位
local _x = ScriptLib.GetGroupTempValue(context, "next_point_x", {})
local _z = ScriptLib.GetGroupTempValue(context, "next_point_z", {})
if _x == 0 or _z == 0 then
return -1
end
if point_map[_z][_x] == evt.param3 then
ScriptLib.PrintContextLog(context, "## BoxPusher : reach point ".._x.."|".._z)
for idx,box in ipairs(box_config) do
if box.config_id == evt.param1 then
ScriptLib.SetGroupTempValue(context, "box_pos_x_"..idx, _x, {})
ScriptLib.SetGroupTempValue(context, "box_pos_z_"..idx, _z, {})
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 0)
LF_Lock_Operation(context, false)
return 0
end
end
end
--[[
--以i,j获取当前的坐标
for _j,_list in ipairs(point_map) do
for _i,point in ipairs(_list) do
if point == evt.param3 then
for m,n in ipairs(box_config) do
if n.config_id == evt.param1 then
--更新对应箱子信息,恢复交互与表现
ScriptLib.SetGroupTempValue(context, "box_pos_x_"..m, _i, {})
ScriptLib.SetGroupTempValue(context, "box_pos_z_"..m, _j, {})
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 0)
--#############
--正统推箱子此处要重新判断是否所有箱子抵达目标点队列
--LF_Check_Result()
--#############
LF_Lock_Operation(context, false)
return 0
end
end
--非box移动的异常情况
return -1
end
end
end]]
--非法路点的异常情况
return -1
end
--[[
function action_avatar_near_platform(context, evt)
for i,v in ipairs(box_config) do
if v.config_id == evt.param1 then
if ScriptLib.GetGadgetStateByConfigId(context, 0, evt.param1) == 201 then
ScriptLib.PrintContextLog(context, "## BoxPusher : Reconect Error Reset")
LF_Lock_Operation(context, false)
return 0
end
end
end
return -1
end
]]
function action_time_axis_pass(context, evt)
ScriptLib.PrintContextLog(context, "## BoxPusher : TimeAxisPass -> "..evt.source_name)
if ScriptLib.GetGadgetStateByConfigId(context, 0, tonumber(evt.source_name)) ~= 201 then
ScriptLib.PrintContextLog(context, "## BoxPusher : T.A.P fail by state")
return -1
end
local _x = 0
local _z = 0
for m,n in ipairs(box_config) do
if tostring(n.config_id) == evt.source_name then
_x = ScriptLib.GetGroupTempValue(context, "box_pos_x_"..m, {})
_z = ScriptLib.GetGroupTempValue(context, "box_pos_z_"..m, {})
break
end
end
ScriptLib.PrintContextLog(context, "## BoxPusher : Get Box Protected")
local _ret,R_pos,R_rot = ScriptLib.GetPlatformArrayInfoByPointId(context, defs.point_array_id, point_map[_z][_x])
local _eid = ScriptLib.GetEntityIdByConfigId(context, tonumber(evt.source_name))
local _pos = ScriptLib.GetPosByEntityId(context, _eid)
ScriptLib.PrintContextLog(context, "## BoxPusher : Get Box Real Pos | ".._pos.x.." | ".._pos.z)
ScriptLib.PrintContextLog(context, "## BoxPusher : Get Box Theory Pos | "..R_pos.x.." | "..R_pos.z)
if math.ceil(_pos.x) ~= math.ceil(R_pos.x) or math.ceil(_pos.z) ~= math.ceil(R_pos.z) then
ScriptLib.PrintContextLog(context, "## BoxPusher : T.A.P fail by pos")
return -1
end
ScriptLib.PrintContextLog(context, "## BoxPusher : T.A.P success")
LF_Lock_Operation(context, false)
return 0
end
Initialize()

View File

@@ -0,0 +1,214 @@
local Tri = {
{ name = "leave_battle_region", config_id = 8000002,event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_battle_region", trigger_count = 0, forbid_guest = false },
{ name = "enter_battle_region", config_id = 8000003,event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_battle_region", trigger_count = 0 , forbid_guest = false },
{ name = "leave_optimization_region", config_id = 8000004,event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_optimization_region", trigger_count = 0, forbid_guest = false },
{ name = "enter_optimization_region", config_id = 8000005,event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_optimization_region", trigger_count = 0 , forbid_guest = false },
{ name = "monster_battle",config_id = 8000006, event = EventType.EVENT_MONSTER_BATTLE, source = "", condition = "", action = "action_monster_battle", trigger_count = 0 },
{ name = "group_will_unload",config_id = 8000007, 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)
end
for i = 1, #suites do
for k,v in pairs(Tri) do
table.insert(suites[i].triggers, v.name)
end
end
end
-----------------------------------------------------------------------------------------------
--处理玩家出战斗圈转移authority
function action_leave_battle_region(context, evt)
if evt.param1 ~= defs.battle_regionID then
return 0
end
--玩家出圈清除context.uid的eyePoint视野锚点区域
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 玩家出战斗圈"..context.uid)
--尝试转移config_id的authority, 当uid和config_id的authority不一致时尝试转移到region_config_id里的玩家。
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 尝试重新分配authority")
local ret1 = ScriptLib.TryReallocateEntityAuthority(context, context.uid, defs.monster_1, evt.param1)
local ret2 = ScriptLib.TryReallocateEntityAuthority(context, context.uid, defs.monster_2, evt.param1)
return 0
end
--战斗期间入圈,让怪物强制入战
function action_enter_battle_region(context, evt)
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 玩家进战斗圈")
if evt.param1 ~= defs.battle_regionID then
return 0
end
--玩家进圈时先查询入战region范围内是否存在玩家
--如果存在说明该玩家不是第一个进入region的那么圈内其他玩家中一定有authority因为出圈会强制重新分配入圈的时候会强制分配
--如果不存在说明该玩家是第一个进入region的将authority分配给他
local no_avatar_in_region = true
local uidlist = ScriptLib.GetSceneUidList(context)
if uidlist == -1 or uidlist == nil or #uidlist == 0 then
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 没有取到uidlist认为是上线触发region的情况强制把authority刷给进圈的玩家")
--将Authority强行设置为进圈的玩家
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.monster_1, context.uid)
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.monster_2, context.uid)
return 0
end
for i = 1, #uidlist do
if (LF_Avatar_is_in_region(context,uidlist[i],defs.battle_regionID) and uidlist[i] ~= context.uid) then
no_avatar_in_region = false
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 圈内存在玩家:"..uidlist[i].."不分配authortiy")
break
end
end
if (no_avatar_in_region) then
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 第一个进入region的玩家"..context.uid.."分配authortiy")
--将Authority强行设置为进圈的玩家
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.monster_1, context.uid)
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.monster_2, context.uid)
end
local ret1 = ScriptLib.SetMonsterBattleByGroup(context, defs.monster_1, 155005095)
local ret2 = ScriptLib.SetMonsterBattleByGroup(context, defs.monster_2, 155005095)
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 设置怪物入战的结果为"..ret1)
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 设置怪物入战的结果为"..ret2)
return 0
end
--玩家进入视野优化圈将visiontype强制设定为50050006boss group的visiontype
function action_enter_optimization_region(context, evt)
if evt.param1 ~= defs.optimize_regionID then
return 0
end
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 玩家进优化圈将视野锁在当前group上")
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {defs.vision_type1,defs.vision_type2})
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
return 0
end
--玩家出视野优化圈恢复visiontype
function action_leave_optimization_region(context, evt)
if evt.param1 ~= defs.optimize_regionID then
return 0
end
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 玩家离开优化圈恢复常规visiontype逻辑")
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
ScriptLib.RevertPlayerRegionVision(context, context.uid)
return 0
end
--group will unload时保护确保visiontype恢复
function action_group_will_unload(context,evt)
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: group即将卸载保底恢复玩家的visiontype")
--VisionType恢复
local uidList = ScriptLib.GetSceneUidList(context)
for k,v in pairs(uidList) do
ScriptLib.SetPlayerGroupVisionType(context, {v}, {1})
ScriptLib.RevertPlayerRegionVision(context, v)
end
return 0
end
--触发战斗
function action_monster_battle(context, evt)
if evt.param1 ~= defs.monster_1 and evt.param1 ~= defs.mosnter_2 then
return 0
end
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 水龙蜥boss入战")
--开战时强制将墙壁刷出来一遍防止墙跟着refreshid走导致墙被打掉刷不出来的问题
ScriptLib.CreateGadget(context,{config_id = defs.wall_1})
ScriptLib.CreateGadget(context,{config_id = defs.wall_2})
ScriptLib.CreateGadget(context,{config_id = defs.wall_3})
return 0
end
-----------------------------------------------------------------------------------------------
function SLC_Deny_Lock_On(context,isOn)
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 深海龙蜥循环boss将墙壁的DenyLockOn设置为"..isOn)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.wall_1, "SGV_deny_lock_on" ,isOn)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.wall_2, "SGV_deny_lock_on" ,isOn)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.wall_3, "SGV_deny_lock_on" ,isOn)
return 0
end
--龙蜥向group通知脱战直接重置boss
function SLC_Reset_Battle(context)
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 深海龙蜥脱战server lua call销毁并重新创建龙蜥")
--移除掉两只水龙蜥
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.MONSTER, defs.monster_1)
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.MONSTER, defs.monster_2)
--再重新创建出来
ScriptLib.CreateMonster(context, { config_id = defs.monster_1, delay_time = 0 })
ScriptLib.CreateMonster(context, { config_id = defs.monster_2, delay_time = 0 })
--龙蜥试图脱战重刷时会先尝试找圈内合法的玩家作为authority。如果此时圈内没有玩家再随缘给authority
local uidlist = ScriptLib.GetSceneUidList(context)
local has_avatar_in_region = false
for i = 1, #uidlist do
if LF_Avatar_is_in_region(context,uidlist[i],defs.battle_regionID) then
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 龙蜥重置尝试将Authority设置给圈内玩家"..uidlist[i])
--将Authority强行设置为进圈的玩家
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.monster_1, uidlist[i])
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.monster_2, uidlist[i])
has_avatar_in_region = true
end
end
if (has_avatar_in_region) then
local ret1 = ScriptLib.SetMonsterBattleByGroup(context, defs.monster_1, 155005095)
local ret2 = ScriptLib.SetMonsterBattleByGroup(context, defs.monster_2, 155005095)
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 设置怪物入战的结果为"..ret1)
ScriptLib.PrintContextLog(context,"DeepseaDrakeBoss: 设置怪物入战的结果为"..ret2)
end
ScriptLib.CreateGadget(context,{config_id = defs.wall_1})
ScriptLib.CreateGadget(context,{config_id = defs.wall_2})
ScriptLib.CreateGadget(context,{config_id = defs.wall_3})
--ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
return 0
end
function LF_Avatar_is_in_region(context,uid,region_id)
local avatar_id = ScriptLib.GetAvatarEntityIdByUid(context, uid)
local pos1 = ScriptLib.GetPosByEntityId(context, avatar_id)
local region = {}
for i = 1, #regions do
if regions[i].config_id == region_id then
region = regions[i]
end
end
local X = pos1.x - region.pos.x
local Y = pos1.y - region.pos.y
local Z = pos1.z - region.pos.z
if region.shape == RegionShape.SPHERE then
if math.sqrt(X*X+Y*Y+Z*Z) <= region.radius then
return true
else
return false
end
elseif region.shape == RegionShape.CUBIC then
if math.abs(X) > region.size.x/2 or math.abs(Y) > region.size.y/2 or math.abs(Z) > region.size.z/2 then
return false
else
return true
end
end
end
-----------------------------------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,347 @@
--2.4昼夜group
--miscs
----昼夜group下控制的所有昼夜gadget
--local EnvControlGadgets =
--{
-- 10001,
-- 10002,
-- 10003
--
--}
--
----仅在白天出现的gadget夜晚会默认销毁
--local DayAppearGadgets =
--{
-- 20001,
-- 20002
--}
--
----仅在夜晚出现的gadget白天会默认销毁
--local NightAppearGadgets =
--{
-- 30001,
-- 30002
--}
--local TriggerInsertWhitelist = {2,3}
----------------------------------
local Tri = {
[1] = { name = "group_load_daynight", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load_daynight", trigger_count = 0},
[2] = { name = "level_tag_change_daynight", config_id = 8000002, event = EventType.EVENT_LEVEL_TAG_CHANGE, source = "", condition = "", action = "action_level_tag_change_daynight", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
end
local hasTriggerInsertWhitelist = not (TriggerInsertWhitelist==nil or #TriggerInsertWhitelist<=0)
if (hasTriggerInsertWhitelist) then
--存在白名单设置走白名单的trigger注入流程
if (init_config.io_type ~= 1) then
--常规group注入。trigger注入白名单定义的suite list
for i = 1, #TriggerInsertWhitelist do
for k,v in pairs(Tri) do
if (TriggerInsertWhitelist[i]<=#suites) then
table.insert(suites[TriggerInsertWhitelist[i]].triggers, v.name)
end
end
end
table.insert(variables,{ config_id=50000001,name = "is_daynight_finish", value = 0, no_refresh = true})
else
table.insert(variables,{ config_id=50000001,name = "is_daynight_finish", value = 0, no_refresh = true})
--flow group注入。trigger注入白名单定义的suite list
for i = 1, #TriggerInsertWhitelist do
for k,v in pairs(Tri) do
if (TriggerInsertWhitelist[i]<=#suite_disk) then
table.insert(suite_disk[TriggerInsertWhitelist[i]].triggers, v.name)
end
end
table.insert(suite_disk[TriggerInsertWhitelist[i]].variables,{ config_id=50000001,name = "is_daynight_finish", value = 0, no_refresh = true})
end
end
else
--不存在白名单设置走常规的trigger注入流程
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(Tri) do
table.insert(suites[i].triggers, v.name)
end
end
table.insert(variables,{ config_id=50000001,name = "is_daynight_finish", value = 0, no_refresh = true})
else
table.insert(variables,{ config_id=50000001,name = "is_daynight_finish", value = 0, no_refresh = true})
for i = 1, #suite_disk do
for k,v in pairs(Tri) do
table.insert(suite_disk[i].triggers, v.name)
end
table.insert(suite_disk[i].variables,{ config_id=50000001,name = "is_daynight_finish", value = 0, no_refresh = true})
end
end
end
end
------------------------------------------------------------------
--group load时主动取一下LevelTag将物件设置为正确的昼夜表现
function action_group_load_daynight(context,evt)
ScriptLib.PrintContextLog(context,"EnvState: Group加载修正物件的昼夜状态")
local current_env_state = LF_Get_Current_Day_Night(context)
ScriptLib.PrintContextLog(context,"EnvState: 当前昼夜状态为: "..ScriptLib.GetLevelTagNameById(context,current_env_state))
LF_Change_Day_Night(context,current_env_state)
return 0
end
function action_level_tag_change_daynight(context,evt)
--改之后的昼夜状态
local target_env_state_id = evt.param2
local target_env_state = ScriptLib.GetLevelTagNameById(context, target_env_state_id)
ScriptLib.PrintContextLog(context,"EnvState: 昼夜切换开始切换昼夜物件状态到LevelTag "..target_env_state)
LF_Change_Day_Night(context,target_env_state_id)
return 0
end
------------------------------------------------------------------
function LF_Get_Current_Day_Night(context)
local current_env_state_id = ScriptLib.GetCurrentLevelTagVec(context, 1)[1]
return current_env_state_id
end
function LF_Change_Day_Night(context,target_env_state)
--LD漏填了昼夜切换的物件列表直接返回
if #EnvControlGadgets <= 0 and #DayAppearGadgets <= 0 and #NightAppearGadgets<=0 then
ScriptLib.PrintContextLog(context,"EnvState: 没有填写昼夜切换的gadget list")
return 0
end
--处理昼夜转换型物件的昼夜状态
for i = 1, #EnvControlGadgets do
LF_Change_State_Day_Night(context,EnvControlGadgets[i],target_env_state)
end
local is_daynight_finish = ScriptLib.GetGroupVariableValue(context, "is_daynight_finish")
if (is_daynight_finish ~= 1) then
--当没有进入完成态时,处理昼夜出现/消失型物件的出现和消失
if (ScriptLib.GetLevelTagNameById(context,target_env_state) == "2_4_Day") then
if ( DayAppearGadgets ~= nil) then
for i = 1, #DayAppearGadgets do
ScriptLib.PrintContextLog(context,"EnvState: 正在将DayOnly物件 "..DayAppearGadgets[i].." 加载")
ScriptLib.CreateGadget(context,{config_id = DayAppearGadgets[i]})
end
end
if ( NightAppearGadgets ~= nil) then
for i = 1, #NightAppearGadgets do
ScriptLib.PrintContextLog(context,"EnvState: 正在将NightOnly物件 "..NightAppearGadgets[i].." 移除")
ScriptLib.RemoveEntityByConfigId(context,0,EntityType.GADGET,NightAppearGadgets[i])
end
end
elseif (ScriptLib.GetLevelTagNameById(context,target_env_state) == "2_4_Night") then
if ( NightAppearGadgets ~= nil) then
for i = 1, #NightAppearGadgets do
ScriptLib.PrintContextLog(context,"EnvState: 正在将NightOnly物件 "..NightAppearGadgets[i].." 加载")
ScriptLib.CreateGadget(context,{config_id = NightAppearGadgets[i]})
end
end
if ( DayAppearGadgets ~= nil) then
for i = 1, #DayAppearGadgets do
ScriptLib.PrintContextLog(context,"EnvState: 正在将DayOnly物件 "..DayAppearGadgets[i].." 移除")
ScriptLib.RemoveEntityByConfigId(context,0,EntityType.GADGET,DayAppearGadgets[i])
end
end
end
end
end
--输入一个gadget将其转到对应的昼夜状态
function LF_Change_State_Day_Night(context, gadget, target_env_state_id)
local target_env_state = ScriptLib.GetLevelTagNameById(context,target_env_state_id)
ScriptLib.PrintContextLog(context,"EnvState: 正在将物件 "..gadget.." 的昼夜状态切换至 "..target_env_state)
local current_state = ScriptLib.GetGadgetStateByConfigId(context,0,gadget)
local current_phase = current_state % 10
local target_gadgetState = 0
ScriptLib.PrintContextLog(context,"EnvState: 物件 "..gadget.." 的当前阶段为 "..current_phase)
--夜转昼
if (target_env_state == "2_4_Day") then
target_gadgetState = 200+current_phase
end
--昼转夜
if (target_env_state == "2_4_Night") then
target_gadgetState = 300+current_phase
end
--如果目标状态和当前状态一致,说明没有要转的,提前返回
--if (target_gadgetState == current_state) then
-- return 0
--end
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, gadget, target_gadgetState)
ScriptLib.PrintContextLog(context,"EnvState: 物件 "..gadget.." 切换至 "..target_gadgetState.." 成功")
end
function LF_Is_Gadget_DayNight(context,gadget_id)
for i = 1 ,#EnvControlGadgets do
if gadget_id == EnvControlGadgets[i] then
return true
end
end
return false
end
------------------------------------------------------------------
--lua层调用将指定gadget转到一个合适的昼夜锁状态
function DayNight_Gadget_Lock(context,gadget_id)
ScriptLib.PrintContextLog(context,"EnvState: 将昼夜物件"..gadget_id.."锁定")
if (not LF_Is_Gadget_DayNight(context,gadget_id)) then
ScriptLib.PrintContextLog(context,"EnvState: 错误的传入了一个不在昼夜列表中的物件!!!")
return -1
end
local current_env_state_id = LF_Get_Current_Day_Night(context)
local current_env_state = ScriptLib.GetLevelTagNameById(context,current_env_state_id)
if (current_env_state == "2_4_Day") then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0,gadget_id,200)
end
if (current_env_state == "2_4_Night") then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0,gadget_id,300)
end
return 0
end
--lua层调用将指定gadget转到一个合适的昼夜激活状态
function DayNight_Gadget_Unlock(context,gadget_id)
ScriptLib.PrintContextLog(context,"EnvState: 将昼夜物件"..gadget_id.."解锁")
if (not LF_Is_Gadget_DayNight(context,gadget_id)) then
ScriptLib.PrintContextLog(context,"EnvState: 错误的传入了一个不在昼夜列表中的物件!!!")
return -1
end
local current_env_state_id = LF_Get_Current_Day_Night(context)
local current_env_state = ScriptLib.GetLevelTagNameById(context,current_env_state_id)
ScriptLib.PrintContextLog(context,"EnvState: 当前昼夜为"..current_env_state)
if (current_env_state == "2_4_Day") then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0,gadget_id,202)
ScriptLib.PrintContextLog(context,"EnvState: 将物件状态设置为"..202)
end
if (current_env_state == "2_4_Night") then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0,gadget_id,302)
ScriptLib.PrintContextLog(context,"EnvState: 将物件状态设置为"..302)
end
return 0
end
--lua层调用将指定gadget重置到当前的昼夜基态
function DayNight_Gadget_Reset(context,gadget_id)
ScriptLib.PrintContextLog(context,"EnvState: 将昼夜物件"..gadget_id.."重置")
if (not LF_Is_Gadget_DayNight(context,gadget_id)) then
ScriptLib.PrintContextLog(context,"EnvState: 错误的传入了一个不在昼夜列表中的物件!!!")
return -1
end
local current_env_state_id = LF_Get_Current_Day_Night(context)
local current_env_state = ScriptLib.GetLevelTagNameById(context,current_env_state_id)
local current_state = ScriptLib.GetGadgetStateByConfigId(context,0,gadget_id)
local current_phase = current_state % 10
if (current_env_state == "2_4_Day") then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0,gadget_id,200+current_phase)
end
if (current_env_state == "2_4_Night") then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0,gadget_id,300+current_phase)
end
return 0
end
--lua层调用将指定gadget转到一个合适的昼夜关闭状态
function DayNight_Gadget_Finish(context,gadget_id)
ScriptLib.PrintContextLog(context,"EnvState: 将昼夜物件"..gadget_id.."设置到完成")
if (not LF_Is_Gadget_DayNight(context,gadget_id)) then
ScriptLib.PrintContextLog(context,"EnvState: 错误的传入了一个不在昼夜列表中的物件!!!")
return -1
end
local current_env_state_id = LF_Get_Current_Day_Night(context)
local current_env_state = ScriptLib.GetLevelTagNameById(context,current_env_state_id)
if (current_env_state == "2_4_Day") then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0,gadget_id,201)
end
if (current_env_state == "2_4_Night") then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0,gadget_id,301)
end
return 0
end
------------------------------------------------------------------
--s1329127 运营埋点,与封能台座交互
function SLC_Mark_Energy_Source_Interaction(context)
ScriptLib.PrintContextLog(context,"EnvState: source entity id为"..context.source_entity_id)
local current_env_state = LF_Get_Current_Day_Night(context)
local entity_id = context.source_entity_id
local gadget_id = ScriptLib.GetGadgetIdByEntityId(context, entity_id)
local configId = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
ScriptLib.PrintContextLog(context,"EnvState: config id为"..configId)
ScriptLib.PrintContextLog(context,"EnvState: 运营打点:封能台座-参数:".."daynight_state = "..current_env_state.."config_id = "..configId.."gadget_id = "..gadget_id)
ScriptLib.MarkGroupLuaAction(context, "EnergySource_1","",{["daynight_state"]=current_env_state,["config_id"]=configId,["gadget_id"]=gadget_id})
return 0
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,207 @@
--2.4昼夜转换机关
--defs
--local Controllers = {
-- 500000,
-- 500001
--}
----------------------------------
--212:转到夜晚
--312:转到白天
local states = {212,312}
local options = {500,501}
local Tri = {
[1] = { name = "select_option_control", config_id = 10000001, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option_control", trigger_count = 0},
[2] = { name = "group_load_control", config_id = 10000002, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load_control", 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_control", config_id = 10000004, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change_control", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
end
for i = 1, #suites do
for k,v in pairs(Tri) do
table.insert(suites[i].triggers, v.name)
end
end
end
------------------------------------------------------------------
--group load后加载操作台选项
function action_group_load_control(context,evt)
ScriptLib.PrintContextLog(context,"EnvStateControl: Group加载修正昼夜转换机关的option状态")
local is_daynight_finish = ScriptLib.GetGroupVariableValue(context, "is_daynight_finish")
if (is_daynight_finish == 1) then
ScriptLib.PrintContextLog(context,"EnvStateControl: 该group处于完成状态不再受到昼夜管理")
return 0
end
local current_env_state = LF_Get_Current_Day_Night(context)
ScriptLib.PrintContextLog(context,"EnvStateControl: 当前昼夜状态为: "..ScriptLib.GetLevelTagNameById(context,current_env_state))
if (ScriptLib.GetLevelTagNameById(context,current_env_state) == "2_4_Day") then
for i = 1, #Controllers do
LF_Set_Option(context,Controllers[i],options[1])
end
elseif (ScriptLib.GetLevelTagNameById(context,current_env_state) == "2_4_Night") then
for i = 1, #Controllers do
LF_Set_Option(context,Controllers[i],options[2])
end
end
return 0
end
--当昼夜转换机关被解锁时,要挂上选项
function action_gadget_state_change_control(context,evt)
local prestate = evt.param3
local state = evt.param1
local gadget = evt.param2
local is_controller = false
for i = 1,#Controllers do
if (gadget == Controllers[i]) then
is_controller = true
break
end
end
if (is_controller) then
if (prestate == 202 and state == 302) then
ScriptLib.PrintContextLog(context,"EnvStateControl: 被别的昼夜转换机关切换到夜晚,需要重新设置选项")
for i = 1, #Controllers do
ScriptLib.DelWorktopOptionByGroupId(context,0,Controllers[i],options[1])
LF_Set_Option(context,Controllers[i],options[2])
end
end
if (prestate == 302 and state == 202) then
ScriptLib.PrintContextLog(context,"EnvStateControl: 被别的昼夜转换机关切换到白天,需要重新设置选项")
for i = 1, #Controllers do
ScriptLib.DelWorktopOptionByGroupId(context,0,Controllers[i],options[2])
LF_Set_Option(context,Controllers[i],options[1])
end
end
if prestate~=200 and prestate~=300 then
ScriptLib.PrintContextLog(context,"EnvStateControl: 不是昼夜转换机关的解锁触发,直接返回")
return 0
end
local is_daynight_finish = ScriptLib.GetGroupVariableValue(context, "is_daynight_finish")
if (is_daynight_finish == 1) then
ScriptLib.PrintContextLog(context,"EnvStateControl: 该group处于完成状态不再受到昼夜管理")
return 0
end
ScriptLib.PrintContextLog(context,"EnvStateControl: 昼夜转换机关被解锁,上选项")
if ((prestate == 200 or prestate == 300) and state == 202) then
LF_Set_Option(context,gadget,options[1])
end
if ((prestate == 200 or prestate == 300) and state == 302) then
LF_Set_Option(context,gadget,options[2])
end
end
return 0
end
--按下昼夜切换机关时若不在level tag转换的cd内
--1、拉起cutscene
--2、拉起level tag转换延迟。延迟结束后转换level tag
--3、拉起level tag cdcd结束后将选项还回去
function action_select_option_control(context,evt)
ScriptLib.PrintContextLog(context,"EnvStateControl: 玩家按下选项删除当前选项并切换LevelTag")
local is_in_cd = ScriptLib.IsLevelTagChangeInCD(context, 1)
if (not is_in_cd) then
--s1329121 运营埋点,与昼夜转换机关交互
local current_env_state = LF_Get_Current_Day_Night(context)
local gadget_id = ScriptLib.GetGadgetIdByEntityId(context,evt.source_eid)
ScriptLib.PrintContextLog(context,"EnvState: 运营打点:昼夜转换机关-参数:".."op_type = "..current_env_state.."config_id = "..evt.param1.."gadget_id = "..gadget_id)
ScriptLib.MarkGroupLuaAction(context, "CircleConsole_1","",{["op_type"]=current_env_state,["config_id"]=evt.param1,["gadget_id"]=gadget_id})
--播放昼夜切换cutscene并启动时间轴在短暂延迟后开始转昼夜
if (ScriptLib.GetLevelTagNameById(context,LF_Get_Current_Day_Night(context)) == "2_4_Day") then
ScriptLib.PrintContextLog(context,"EnvStateControl: 播放白天转夜晚cutscene")
ScriptLib.PlayCutScene(context,500501302,0)
else
ScriptLib.PrintContextLog(context,"EnvStateControl: 播放夜晚转白天cutscene")
ScriptLib.PlayCutScene(context,500501301,0)
end
ScriptLib.InitTimeAxis(context, "level_tag_change_delay", {1}, false)
ScriptLib.InitTimeAxis(context, "level_tag_change_cd", {10}, false)
--昼转夜
if (evt.param2 == options[1]) then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, states[2])
for i = 1, #Controllers do
ScriptLib.DelWorktopOptionByGroupId(context,0,Controllers[i],options[1])
end
--夜转昼
elseif (evt.param2 == options[2]) then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, states[1])
for i = 1, #Controllers do
ScriptLib.DelWorktopOptionByGroupId(context,0,Controllers[i],options[2])
end
end
end
return 0
end
--时间轴触发
--level_tag_change_delay为level tag转换的延迟触发
--level_tag_change_cd为level tag转换的cd。cd完成后才会将选项还回去
function action_time_axis_pass(context,evt)
if (evt.source_name == "level_tag_change_delay") then
local current_env_state_id = ScriptLib.GetCurrentLevelTagVec(context, 1)[1]
local env_state = 3-current_env_state_id
ScriptLib.PrintContextLog(context,"EnvStateControl: 当前的envstate为"..env_state)
ScriptLib.ChangeToTargetLevelTag(context,env_state)
ScriptLib.PrintContextLog(context,"EnvStateControl: -------------------------开始昼夜转换---------------------")
ScriptLib.PrintContextLog(context,"EnvStateControl: 昼夜转换为 "..ScriptLib.GetLevelTagNameById(context, env_state))
end
if (evt.source_name == "level_tag_change_cd") then
ScriptLib.PrintContextLog(context,"EnvStateControl: 昼夜转换完成,恢复选项")
if (ScriptLib.GetLevelTagNameById(context,LF_Get_Current_Day_Night(context)) == "2_4_Day") then
for i = 1, #Controllers do
LF_Set_Option(context,Controllers[i],options[1])
end
else
for i = 1, #Controllers do
LF_Set_Option(context,Controllers[i],options[2])
end
end
end
return 0
end
-----------------------------------------------------------------
function LF_Get_Current_Day_Night(context)
local current_env_state_id = ScriptLib.GetCurrentLevelTagVec(context, 1)[1]
return current_env_state_id
end
--输入控制台gadget、option判断gadget是否处于可以上option的状态下
function LF_Set_Option(context,controller,option_id)
local state = ScriptLib.GetGadgetStateByConfigId(context,0,controller)
if (state == 202 or state == 302 or state == 212 or state == 312) then
local ret = ScriptLib.SetWorktopOptionsByGroupId(context,0,controller,{option_id})
end
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,102 @@
--2.4环境昼夜主控(白盒)
--miscs
--昼夜主控group控制的所有group
--local EnvControlGroups = {}
----------------------------------
--local local_defs = {
--}
--
--
--local Tri = {
-- [1] = { name = "variable_change", config_id = 8000001, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", trigger_count = 0},
-- [2] = { name = "group_load", config_id = 8000002, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
--
--}
--
--function Initialize()
-- for k,v in pairs(Tri) do
-- table.insert(triggers, v)
-- table.insert(suites[1].triggers, v.name)
-- end
--
-- --昼夜
-- --白天 = 1
-- --黑夜 = 2
-- table.insert(variables,{ name = "env_state", value = 1})
--end
--
--------------------------------------------------------------------
--
----主控group的env_state被修改时认为玩家改了昼夜则修改下属所有group的env_state
--function action_variable_change(context,evt)
--
-- if (evt.source_name == "env_state") then
--
-- ScriptLib.PrintContextLog(context,"EnvState: 主控group昼夜状态修改修改下属group状态")
-- local new_value = evt.param1
-- if new_value == 1 then
-- ScriptLib.AddQuestProgress(context, "OnChangeDay")
-- elseif new_value == 2 then
-- ScriptLib.AddQuestProgress(context, "OnChangeNight")
-- end
-- for i = 1, #EnvControlGroups do
-- ScriptLib.PrintContextLog(context,"EnvState: 将下属group "..EnvControlGroups[i].."昼夜状态修改为 "..new_value)
-- ScriptLib.SetGroupVariableValueByGroup(context, "env_state", new_value, EnvControlGroups[i])
-- end
-- LF_Get_Env_State(context)
-- end
-- return 0
--end
--
----group load时主动取team上取一下sgv防止出现特殊情况没有同步到
--function action_group_load(context,evt)
--
-- ScriptLib.PrintContextLog(context,"EnvState: 主控group加载尝试从team上获取最新的env_state")
-- local env_state = LF_Get_Env_State(context)
-- if (env_state == -1) then
-- ScriptLib.PrintContextLog(context,"EnvState: 读取uid list失败")
-- ScriptLib.SetGroupVariableValue(context, "env_state", 1)
-- return 0
-- end
-- if env_state == 0 then
-- ScriptLib.PrintContextLog(context,"EnvState: 读取uid list失败")
-- ScriptLib.SetGroupVariableValue(context, "env_state", 1)
-- return 0
-- end
-- ScriptLib.SetGroupVariableValue(context, "env_state", env_state)
-- return 0
--end
--
--------------------------------------------------------------------
--function LF_Get_Env_State(context)
--
-- local uid_list = ScriptLib.GetSceneUidList(context)
-- if #uid_list<=0 then return -1 end
-- local env_state = ScriptLib.GetTeamServerGlobalValue(context,uid_list[1],"SGV_env_state")
-- if (env_state == nil) then
--
-- ScriptLib.PrintContextLog(context,"EnvState: 获取当前team的env state失败")
-- return 0
-- end
-- ScriptLib.PrintContextLog(context,"EnvState: 当前team的env state为 "..env_state)
--
-- return env_state
--end
-------------------------------------------------------------------
--
----从机关的modifier上调用调整主控group记录的昼夜状态并修改team上的状态
--function SLC_Change_Env_State(context,env_state)
--
-- local uid_list = ScriptLib.GetSceneUidList(context)
-- ScriptLib.PrintContextLog(context,"EnvState: 昼夜转化机关尝试将昼夜状态转换为:"..env_state)
-- ScriptLib.SetGroupVariableValue(context, "env_state", env_state)
-- return 0
--end
--
--------------------------------------------------------------------
--Initialize()

View File

@@ -0,0 +1,180 @@
--2.4昼夜机关(白盒)
--defs
--local Worktops = {
-- 500000,
-- 500001,
--}
----------------------------------
local option = 502
local Tri = {
[1] = { name = "select_option_worktop", config_id = 9000001, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option_worktop", trigger_count = 0},
[2] = { name = "group_load_worktop", config_id = 9000002, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load_worktop", trigger_count = 0},
[3] = { name = "gadget_state_change_worktop", config_id = 9000003, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change_worktop", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
end
if (init_config.io_type ~= 1) then
for i = 1, #suites do
for k,v in pairs(Tri) do
table.insert(suites[i].triggers, v.name)
end
end
else
for i = 1, #suite_disk do
for k,v in pairs(Tri) do
table.insert(suite_disk[i].triggers, v.name)
end
end
end
end
------------------------------------------------------------------
--group load后加载操作台选项
function action_group_load_worktop(context,evt)
ScriptLib.PrintContextLog(context,"EnvStateWorktop: Group加载修正昼夜操作台选项")
local is_daynight_finish = ScriptLib.GetGroupVariableValue(context, "is_daynight_finish")
if (is_daynight_finish == 1) then
ScriptLib.PrintContextLog(context,"EnvState: 该group处于完成状态不再受到昼夜管理")
return 0
end
for i = 1, #Worktops do
LF_Set_DayNight_Worktop_Option(context,Worktops[i])
end
return 0
end
--按下昼夜切换机关时,处理这个昼夜机关的状态切换和删除选项
function action_select_option_worktop(context,evt)
if (evt.param2 == option) then
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 玩家按下选项删除当前选项并切换操作台gadgetState")
local worktop = evt.param1
local entity_id = ScriptLib.GetEntityIdByConfigId(context,worktop)
local gadget_id = ScriptLib.GetGadgetIdByEntityId(context, entity_id)
--如果是白天操作台按下按键后转到212
if (gadget_id == 70360311) then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 212)
ScriptLib.DelWorktopOptionByGroupId(context,0,evt.param1,option)
--如果是夜晚操作台按下按键后转到312
elseif (gadget_id == 70360312) then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, evt.param1, 312)
ScriptLib.DelWorktopOptionByGroupId(context,0,evt.param1,option)
end
end
return 0
end
--当昼夜切换机关状态切换时,判断当前状态上下选项
function action_gadget_state_change_worktop(context,evt)
local worktop = evt.param2
local is_daynight_worktop = false
for i = 1,#Worktops do
if worktop == Worktops[i] then
is_daynight_worktop = true
end
end
if (is_daynight_worktop) then
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台 "..worktop.."状态变化,判断选项上下")
LF_Set_DayNight_Worktop_Option(context,worktop)
end
return 0
end
-----------------------------------------------------------------
--输入一个操作台的config_id根据当前昼夜以及操作台当前状态判断此时上或下选项
function LF_Set_DayNight_Worktop_Option(context,worktop)
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台 "..worktop.."状态变化,开始设置选项")
--判断操作台gadget id如果不对提前返回
local entity_id = ScriptLib.GetEntityIdByConfigId(context,worktop)
local gadget_id = ScriptLib.GetGadgetIdByEntityId(context, entity_id)
if (gadget_id ~= 70360311 and gadget_id ~= 70360312) then
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 目标gadget id = "..gadget_id.."不是昼夜操作台,提前返回")
return 0
end
local current_env_state_id = LF_Get_Current_Day_Night(context)
local current_env_state = ScriptLib.GetLevelTagNameById(context,current_env_state_id)
if (current_env_state == "2_4_Day") then
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 当前是白天")
--如果是白天操作台且状态为202则上选项否则下选项
if (gadget_id == 70360311) then
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台(白天)处理选项")
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context,0,worktop)
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台(白天)当前状态为"..gadget_state)
if (gadget_state == 202) then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, worktop, {option})
else
ScriptLib.DelWorktopOptionByGroupId(context,0,worktop,option)
end
end
--如果是夜晚操作台且状态为302则上选项否则下选项
if (gadget_id == 70360312) then
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台(夜晚)处理选项")
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context,0,worktop)
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台(夜晚)当前状态为"..gadget_state)
if (gadget_state == 302) then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, worktop, {option})
else
ScriptLib.DelWorktopOptionByGroupId(context,0,worktop,option)
end
end
elseif (current_env_state == "2_4_Night") then
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 当前是夜晚")
--如果是夜晚操作台且状态为302则上选项否则下选项
if (gadget_id == 70360312) then
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台(夜晚)处理选项")
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context,0,worktop)
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台(夜晚)当前状态为"..gadget_state)
if (gadget_state == 302) then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, worktop, {option})
else
ScriptLib.DelWorktopOptionByGroupId(context,0,worktop,option)
end
end
--如果是白天操作台且状态为202则上选项否则下选项
if (gadget_id == 70360311) then
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台(夜晚)处理选项")
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context,0,worktop)
ScriptLib.PrintContextLog(context,"EnvStateWorktop: 昼夜操作台(夜晚)当前状态为"..gadget_state)
if (gadget_state == 202) then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, worktop, {option})
else
ScriptLib.DelWorktopOptionByGroupId(context,0,worktop,option)
end
end
end
end
function LF_Get_Current_Day_Night(context)
local current_env_state_id = ScriptLib.GetCurrentLevelTagVec(context, 1)[1]
return current_env_state_id
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,237 @@
local FirecrackerChest_ID = 70800056
local option_id = 68
local watcherCountDownTime_1 = 150 --多少秒内完成
local watcherCountDownTime_2 = 120 --多少秒内完成
local challenge_index_list = { --埋点用
[133108233]=2200,
[133108234]=2200,
[133108235]=2200,
[133108246]=2210,
[133108247]=2210,
[133108252]=2210,
[133108236]=2200,
[133108237]=2200,
[133108238]=2200,
[133108239]=2200,
[133108248]=2210,
[133108249]=2210,
[133108250]=2210,
[133108251]=2210,
[133108198]=1,
[133108227]=2040,
[133108228]=2040,
[133108232]=2040,
[133108225]=2040,
[133108226]=2040,
[133108229]=2040,
[133108230]=2040,
[133108231]=2040,
}
local temp_Variables = {
{ config_id=50000001,name = "Variable_EndGame", value = 0, no_refresh = false },
{ config_id=50000002,name = "Variable_StartWatcherCountDown", value = 0, no_refresh = false },
}
local temp_Tirgger = {
--正式trigger
{event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION",trigger_count = 0},
{event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_EVENT_VARIABLE_CHANGE",trigger_count = 0},
{event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_EVENT_TIME_AXIS_PASS",trigger_count = 0},
{event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_EVENT_CHALLENGE_SUCCESS",trigger_count = 0},
}
function action_EVENT_CHALLENGE_SUCCESS(context,evt)
ScriptLib.PrintContextLog(context,"[action_EVENT_CHALLENGE_SUCCESS]")
--F4 BOSS group的watcher处理
local uid_list = ScriptLib.GetSceneUidList(context)
if ScriptLib.GetContextGroupId(context) == 133108198 then
ScriptLib.PrintContextLog(context,"[GetContextGroupId]=133108198")
--完成挑战
ScriptLib.AddExhibitionAccumulableData(context,uid_list[1],"Activity_SalvageBoss_watcher_1",1)
--剩余[watcherCountDownTime_1]秒完成挑战
if ScriptLib.GetGroupTempValue(context,"WatcherTimeOut_1",{}) == 0 then
ScriptLib.AddExhibitionAccumulableData(context,uid_list[1],"Activity_SalvageBoss_watcher_2",1)
end
--剩余[watcherCountDownTime_2]秒完成挑战
if ScriptLib.GetGroupTempValue(context,"WatcherTimeOut_2",{}) == 0 then
ScriptLib.AddExhibitionAccumulableData(context,uid_list[1],"Activity_SalvageBoss_watcher_3",1)
end
end
return 0
end
function action_EVENT_TIME_AXIS_PASS(context,evt)
ScriptLib.PrintContextLog(context,"[action_EVENT_TIME_AXIS_PASS]")
if evt.source_name == "WatcherCountDown_1" then
ScriptLib.SetGroupTempValue(context,"WatcherTimeOut_1",1,{})
end
if evt.source_name == "WatcherCountDown_2" then
ScriptLib.SetGroupTempValue(context,"WatcherTimeOut_2",1,{})
end
return 0
end
function action_EVENT_VARIABLE_CHANGE(context,evt)
if evt.source_name == "Variable_EndGame" then
local uid_list = ScriptLib.GetSceneUidList(context)
--挑战结束 关掉所有箱子交互
for k,v in pairs(gadgets) do
if v.gadget_id == FirecrackerChest_ID then
local group_id = ScriptLib.GetContextGroupId(context)
ScriptLib.DelWorktopOptionByGroupId(context, group_id, v.config_id, option_id)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v.config_id, "SGV_Show_Mark", 0)
end
end
--挑战结束后不再接收slc
ScriptLib.SetGroupTempValue(context,"Enable_SLC",0,{})
--关闭T技能
ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid_list[1]}, "AVATAR_Firecracker_Play", 0)
end
if evt.source_name == "Variable_StartWatcherCountDown" then
--F4 BOSS group的watcher处理初始化
if ScriptLib.GetContextGroupId(context) == 133108198 then
ScriptLib.InitTimeAxis(context, "WatcherCountDown_1", {watcherCountDownTime_1}, false)
ScriptLib.InitTimeAxis(context, "WatcherCountDown_2", {watcherCountDownTime_2}, false)
ScriptLib.SetGroupTempValue(context,"WatcherTimeOut_1",0,{})
ScriptLib.SetGroupTempValue(context,"WatcherTimeOut_2",0,{})
end
--挑战开始 补满箱子加option
local group_id = ScriptLib.GetContextGroupId(context)
for k,v in pairs(gadgets) do
if v.gadget_id == FirecrackerChest_ID then
ScriptLib.SetGroupGadgetStateByConfigId(context, group_id, v.config_id, 0)
ScriptLib.SetWorktopOptionsByGroupId(context, group_id, v.config_id, {option_id})
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v.config_id, "SGV_Show_Mark", 1)
end
end
--通知manager(任务group除外)
if group_id ~= 133108196 and group_id ~= 133108197 then
SeaLamp_Challenge_Manager_Start(context)
end
end
return 0
end
function action_EVENT_SELECT_OPTION(context,evt)
ScriptLib.PrintContextLog(context,"[action_EVENT_SELECT_OPTION]")
--爆竹箱交互后逻辑
if ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid) ~= FirecrackerChest_ID then return 0 end
--如果身上已经有T技能则reminder提示。
uid = ScriptLib.GetSceneUidList(context)
local key = ScriptLib.GetTeamAbilityFloatValue(context, context.uid, "AVATAR_Firecracker_Play")
if key == 1 then
ScriptLib.AssignPlayerShowTemplateReminder(context, 154, {param_vec={},param_uid_vec={},uid_vec={context.uid}})
return 0
end
--否则加上T技能
ScriptLib.SetTeamEntityGlobalFloatValue(context, {context.uid}, "AVATAR_Firecracker_Play", 1)
--等待T技能的slc
ScriptLib.SetGroupTempValue(context,"Enable_SLC",1,{})
--使该爆竹箱 爆竹数量减少
action_Reduce_Firecracker(context,evt.param1)
local group_id = ScriptLib.GetContextGroupId(context)
local trans
if challenge_index_list[group_id] ~=nil then
trans = ScriptLib.GetChallengeTransaction(context, challenge_index_list[group_id])
else
trans = ""
end
ScriptLib.MarkGroupLuaAction(context, "LanternRite_1", trans , {[""] = 0,})
return 0
end
function action_Reduce_Firecracker(context,config_id)
local group_id = ScriptLib.GetContextGroupId(context)
local nowState = ScriptLib.GetGadgetStateByConfigId(context, group_id, config_id)
--使被交互的这个数量-1
if nowState == 0 then ScriptLib.SetGroupGadgetStateByConfigId(context, group_id, config_id, 101)
elseif nowState == 101 then ScriptLib.SetGroupGadgetStateByConfigId(context, group_id, config_id, 102)
elseif nowState == 102 then ScriptLib.SetGroupGadgetStateByConfigId(context, group_id, config_id, 103)
elseif nowState == 103 then ScriptLib.SetGroupGadgetStateByConfigId(context, group_id, config_id, 104)
elseif nowState == 104 then ScriptLib.SetGroupGadgetStateByConfigId(context, group_id, config_id, 105)
end
--使所有交互禁用
for k,v in pairs(gadgets) do
if v.gadget_id == FirecrackerChest_ID then
ScriptLib.DelWorktopOptionByGroupId(context, group_id, v.config_id, option_id)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v.config_id, "SGV_Show_Mark", 0)
end
end
return 0
end
function SLC_Firecracker_Used(context)--使用T技能后
if ScriptLib.GetGroupTempValue(context,"Enable_SLC",{}) ~=1 then return 0 end--防call到错误group
ScriptLib.PrintContextLog(context,"[SLC_Firecracker_Used]")
--SLC等待标记重置
ScriptLib.SetGroupTempValue(context,"Enable_SLC",0,{})
local group_id = ScriptLib.GetContextGroupId(context)
--给能捡的箱子恢复交互选项
for k,v in pairs(gadgets) do
if v.gadget_id == FirecrackerChest_ID then
if ScriptLib.GetGadgetStateByConfigId(context, group_id, v.config_id) ~= 105 then
ScriptLib.SetWorktopOptionsByGroupId(context, group_id, v.config_id, {option_id})
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v.config_id, "SGV_Show_Mark", 1)
end
end
end
local trans
if challenge_index_list[group_id] ~=nil then
trans = ScriptLib.GetChallengeTransaction(context, challenge_index_list[group_id])
else
trans = ""
end
ScriptLib.MarkGroupLuaAction(context, "LanternRite_2", trans , {[""] = 0,})
return 0
end
--已作废
function SLC_watcher_hit3(context)
return 0
end
--已作废
function SLC_AttackLanded_Avatar(context)
return 0
end
--已作废
function SLC_Buff_Dispel_Monster(context)
return 0
end
--专项补丁开始性能优化圈。仅当LD配置了defs.eyepoint时生效
function Insert_EyePoint_Trigger() --专用trigger
if defs ~= nil then
if defs.eyepoint ~= nil then
table.insert(temp_Tirgger,{event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_SetEyePoint",trigger_count = 0})
table.insert(temp_Tirgger,{event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_ClearEyePoint",trigger_count = 0})
end
end
return 0
end
Insert_EyePoint_Trigger()
function action_SetEyePoint(context,evt)
ScriptLib.PrintContextLog(context,"[action_EVENT_ENTER_REGION]")
if evt.param1 == defs.eyepoint then
ScriptLib.SetPlayerEyePoint(context, defs.eyepoint, defs.eyepoint)
end
return 0
end
function action_ClearEyePoint(context,evt)
ScriptLib.PrintContextLog(context,"[action_EVENT_LEAVE_REGION]")
if evt.param1 == defs.eyepoint then
ScriptLib.ClearPlayerEyePoint(context, defs.eyepoint)
end
return 0
end
function Initialize()
--加触发器
for k,v in pairs(temp_Tirgger) do
v.name = k..""
v.config_id = 9000000 + k
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
--加变量
for k,v in pairs(temp_Variables) do
table.insert(variables,v)
end
return 0
end
Initialize()

View File

@@ -0,0 +1,644 @@
--[[local defs = {
group_id = xxx,
gadget_prison_list = {1,2,3,4},
gadget_guide = {1,2,3},
bait_list = {
[1] = {1,2,3},
[2] = {4,5,6},
[3] = {7,8,9},
},
duration = 240,
rampage_time = 40,
gadget_energy = 1,
}--]]
--[[local energy_info = {
[1] = { time = 80, points = {1,2,3,4,5,6}},
[2] = { time = 160, points = {1,2,3,4,5,6}}
}--]]
--初始化给的state,V2开始全部由SGV实现
local HS_State = {
["Play"] = { name = "SGV_HideAndSeek_PlayerState_Play", value = 3 },
["Visible"] = { name = "SGV_HideAndSeek_PlayerState_Visible", value = 0 },
["OnMap"] = { name = "SGV_HideAndSeek_PlayerState_OnMap", value = 0 },
["Moveable"] = { name = "SGV_HideAndSeek_PlayerState_Moveable", value = 0 },
["Transfer"] = { name = "SGV_HideAndSeek_PlayerState_Transfer", value = 0 },
["TransferCache"] = { name = "SGV_HideAndSeek_PlayerState_TransferCache", value = 0},
["UltraMark"] = { name = "SGV_Is_In_UltraMark", value = 0 },
["GlobalSight"] = { name = "SGV_Is_In_GlobalSight", value = 0 },
["SuperPrison"] = { name = "SGV_Is_In_SuperPrison", value = 0 },
["Rampage"] = { name = "SGV_Is_In_Rampage", value = 0 },
["Dead"] = { name = "SGV_HideAndSeek_PlayerState_Dead", value = 0},
["Is_Detected"] = { name = "SGV_HideAndSeek_PlayerState_Is_Detected", value = 0},
}
local skill_info = {
["HideAndSeek_Skill_CatchPrey"] = { radius = 4 },
["HideAndSeek_Skill_Guide"] = { radius = 500 },
["HideAndSeek_Skill_Detect_F"] = { radius = 10 },
["HideAndSeek_Skill_UltraMark"] = { radius = 500, duration = 60 },
["HideAndSeek_Skill_GlobalSight"] = { radius = 500, duration = 20 },
["HideAndSeek_Skill_SuperPrison"] = { radius = 500, duration = 40 },
}
local hunter_win_by_EX = 30
local hunter_win_in_time = 120
local hunter_catch_by_guide = 10
local final_time = 180 --抓捕阶段第180秒后为决胜时间猎手在该时间内抓两人记录翻牌
local map_info = {
--一期
[1001003] = { name = "QingCe", list = {1,2,3} },
[1001022] = { name = "QingQuan", list = {4,5} },
[1001004] = { name = "WuWang", list = {4,8} },
[1001002] = { name = "JiuZhuang", list = {7,8} },
[1001023] = { name = "XueShan", list = {4,8} },
--二期地图
[1001006] = { name = "test_1", list = {1,2,3} },--轻策庄二期
[1001007] = { name = "test_2", list = {4,8} },
[1001008] = { name = "test_3", list = {4,8} },
[1001009] = { name = "test_4", list = {19,17,18,20} },--离岛
[1001010] = { name = "test_5", list = {4,8} },
[1001011] = { name = "test_6", list = {11,12,13} },--神里
[1001012] = { name = "test_7", list = {14,11,15} },--绯木
[1001013] = { name = "test_8", list = {16,17,18} },--九条
[1001014] = { name = "test_9", list = {4,8} },
[1001015] = { name = "test_10", list = {4,8} },
[1001015] = { name = "test_11", list = {4,21} },--初始林地
[1001016] = { name = "test_12", list = {4,8} },
[1001017] = { name = "test_13", list = {4,8} },
[1001018] = { name = "test_14", list = {4,8} },
[1001019] = { name = "test_15", list = {4,21,22} },--璃月遗迹
[1001020] = { name = "test_16", list = {4,8} },
[1001021] = { name = "test_17", list = {4,8} },
[1001026] = { name = "test_18", list = {7,8,23} },--酒庄
}
--玩法中开启的天气
local weather_id_list = {3151}
local Tri = {
[1]={ name = "gallery_stop", config_id = 8000001, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
[2]={ name = "challenge_success", config_id = 8000003, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
[3]={ name = "challenge_fail", config_id = 8000004, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
[4]={ name = "variable_change", config_id = 8000005, event = EventType.EVENT_VARIABLE_CHANGE, source = "catch_sum", condition = "", action = "action_variable_change", trigger_count = 0, tag = "9012"},
[5]={ name = "time_axis_pass", config_id = 8000006, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[6]={ name = "enter_region", config_id = 8000007, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false},
[7]={ name = "GM_Debug", config_id = 8000008, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_GM_Debug", trigger_count = 0 },
[8]={ name = "multistage_end", config_id = 8000009, event = EventType.EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END, source = "", condition = "", action = "action_multistage_end", trigger_count = 0 },
[9]={ name = "group_load", config_id = 8000010, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
[10]={name = "avatar_die", config_id = 8000011, event = EventType.EVENT_AVATAR_DIE, source = "", condition = "", action = "action_avatar_die", trigger_count = 0 },
[11]={name = "player_quit", config_id = 8000012, event = EventType.EVENT_HIDE_AND_SEEK_PLAYER_QUIT, source = "", condition = "", action = "action_player_quit", trigger_count = 0 },
[12]={name = "leave_region", config_id = 8000013, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0, forbid_guest = false},
[13]={name = "group_will_unload", config_id = 8000014, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0 },
}
local Var = {
{ config_id=50000001,name = "catch_sum", value = 0, no_refresh = false},
{ config_id=50000002,name = "GM_stage", value = 0, no_refresh = false},
--
}
function Initialize_Base()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for i,v in ipairs(Var) do
table.insert(variables, v)
end
end
---------------------------------------
function action_group_load(context, evt)
--根据LD铺设随机生成障碍物
LF_Bake_Random_Scene(context)
return 0
end
function action_gallery_stop(context, evt)
ScriptLib.PrintContextLog(context, "## H&S_LOG : Gallery Stop")
--实际gameplay仍在进行时玩法停止,则走意外终止流程
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 3)
end
return 0
end
function action_multistage_end(context, evt)
ScriptLib.PrintContextLog(context, "## H&S_LOG : Multistage End : "..evt.param2.." | is_succ : "..evt.param3)
if evt.param3 == 0 then
--异常终结玩法
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 3)
end
return 0
end
if evt.param2 == 2 then
--LF_Bake_Random_Scene(context)
elseif evt.param2 == 3 then
--进入逃跑阶段
ScriptLib.SetGroupTempValue(context, "in_escape", 1, {})
LF_Assign_Character_Card(context)
elseif evt.param2 == 4 then
--进入抓捕阶段
ScriptLib.SetGroupTempValue(context, "in_escape", 0, {})
LF_Start_Hide_And_Seek(context)
elseif evt.param2 == 5 then
--由于关卡流终止时说明游侠未全灭,判胜
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 2)
end
end
return 0
end
function action_challenge_success(context, evt)
ScriptLib.PrintContextLog(context, "## HS_Log : challenge_success -> "..evt.param1)
--猎手完成了抓人的挑战,判胜
if evt.source_name == "9012" then
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 1)
end
end
return 0
end
function action_challenge_fail(context, evt)
ScriptLib.PrintContextLog(context, "## HS_Log : challenge_fail -> "..evt.param1)
--猎手未能完成抓人的挑战,判负
if evt.source_name == "9011" then
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_play", {}) then
LF_Stop_Hide_And_Seek(context, 2)
end
end
return 0
end
function action_variable_change(context, evt)
if evt.param1 == evt.param2 + 1 then
---[[这段没什么用
if 1 == ScriptLib.GetGroupTempValue(context, "in_escape", {}) then
if evt.param1 == ScriptLib.GetGroupTempValue(context, "prey_sum", {}) then
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
ScriptLib.EndSceneMultiStagePlayStage(context, _index, "null", true)
end
end
--]]
return 0
else
return -1
end
end
function action_enter_region(context, evt)
if evt.param1 ~= defs.eye_point then
return -1
end
--开启视野锚点优化
ScriptLib.SetPlayerEyePointStream(context, evt.param1, evt.param1, false)
ScriptLib.PrintContextLog(context, "SetPlayerEyePointStream")
return 0
end
function action_leave_region(context, evt)
if evt.param1 ~= defs.eye_point then
return -1
end
--关闭视野锚点优化
ScriptLib.ClearPlayerEyePoint(context, evt.param1)
ScriptLib.PrintContextLog(context, "ClearPlayerEyePoint")
return 0
end
function action_group_will_unload(context, evt)
--提前关闭性能圈保证关闭视野锚点优化
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.REGION, defs.eye_point)
return 0
end
function action_time_axis_pass(context, evt)
ScriptLib.PrintContextLog(context, "## H&S_LOG : time_axis "..evt.source_name.." -> "..evt.param1)
if evt.source_name == "rampage" then
--触发猎手暴走阶段
HideAndSeek_Hunter_Rampage(context)
elseif evt.source_name == "energy" then
--刷新一个能量球
ScriptLib.KillEntityByConfigId(context, {config_id = defs.gadget_energy, entity_type = EntityType.GADGET})
--随机选择位置创建能量球
local p_list = energy_info[evt.param1].points
math.randomseed(ScriptLib.GetServerTime(context))
local ret = p_list[math.random(#p_list)]
local p_pos = {}
local p_rot = {}
for k,v in ipairs(points) do
if v.config_id == ret then
p_pos = v.pos
p_rot = v.rot
break
end
end
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.gadget_energy, p_pos, p_rot)
local uid_list = ScriptLib.GetSceneUidList(context)
--通知全体掉能量球
ScriptLib.AssignPlayerUidOpNotify(context, {param_index = 12,param_list={},param_uid_list={},duration=3,target_uid_list=uid_list})
elseif evt.source_name == "hunter_win_by_EX" or evt.source_name == "hunter_win_in_time" or evt.source_name == "hunter_catch_by_guide" then
--相关陈列室统计
ScriptLib.SetGroupTempValue(context, evt.source_name, 0, {})
elseif evt.source_name == "final_time" then
--抓捕阶段第180秒后为决胜时间猎手在该时间内抓两人记录翻牌
ScriptLib.SetGroupTempValue(context,"is_in_final_time",1,{})
else
--终止游侠被捕阶段并转为真死亡
for i=1,3 do
local _uid = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
ScriptLib.PrintContextLog(context,"realDie = "..tostring(_uid))
if evt.source_name == tostring(_uid) then
ScriptLib.AssignPlayerShowTemplateReminder(context, 138, {param_vec={},param_uid_vec={},uid_vec={_uid}})
LF_Set_Player_State_Value(context, _uid, HS_State.Dead.name, 1)
return 0
end
end
end
return 0
end
function action_avatar_die(context, evt)
--multistage内触发的死亡回调
local char = ScriptLib.GetGroupTempValue(context, HS_State.Play.name.."_"..context.uid, {})
ScriptLib.PrintContextLog(context, "## H&S_LOG : avatar_die "..context.uid.." | character = "..char)
--首先排除玩家死在玩法外的情况
if ScriptLib.GetGroupTempValue(context, "is_in_play", {}) == 0 then
ScriptLib.PrintContextLog(context, "## H&S_LOG : is_in_play = 0")
return -1
end
if char == 0 then
--hunter死亡判负
ScriptLib.StopChallenge(context, 9012, 0)
elseif char == 1 then
--prey死亡算被抓
LF_Set_Prey_Die(context, context.uid)
elseif char == 3 then
for i = 1,3 do
local prey = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
if prey == context.uid then
--prey提前死亡不参与游戏
LF_Set_Prey_Die(context, context.uid)
return 0
end
end
--hunter提前死亡直接结算prey胜利
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
ScriptLib.EndSceneMultiStagePlayStage(context, _index, "null", true)
LF_Stop_Hide_And_Seek(context, 2)
end
return 0
end
function action_player_quit(context, evt)
--由multistage触发回调玩家离场
for j=1,3 do
if context.uid == ScriptLib.GetGroupTempValue(context, "prey_"..j, {}) then
ScriptLib.PrintContextLog(context, "## H&S_LOG : Running Player_Quit : "..context.uid)
--进行中玩家离场视为hunter抓住了一个
ScriptLib.ChangeGroupVariableValue(context, "catch_sum", 1)
return 0
end
end
ScriptLib.PrintContextLog(context, "## H&S_LOG : Free Player_Quit : "..context.uid)
return 0
end
function action_GM_Debug(context, evt)
ScriptLib.PrintContextLog(context, "## H&S_LOG : variable_change "..evt.source_name.." "..evt.param2.." -> "..evt.param1)
if evt.param1 == evt.param2 then
return -1
end
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
--处理玩家隐身显形
if evt.source_name == HS_State.OnMap.name.."_"..v then
LF_Notify_Player_Visible(context)
return -1
end
end
if evt.source_name == "catch_sum" then
return -1
end
if evt.source_name == "GM_stage" then
if evt.param1 == 1 then
LF_Bake_Random_Scene(context)
elseif evt.param1 == 2 then
LF_Assign_Character_Card(context)
elseif evt.param1 == 3 then
LF_Start_Hide_And_Seek(context)
end
end
return 0
end
---------------------------------------
function LF_Start_Hide_And_Seek(context)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Start_Hide_And_Seek")
local uid_list = ScriptLib.GetSceneUidList(context)
LF_Start_Comp_Challenge(context)
end
function LF_Stop_Hide_And_Seek(context, value)
--1为hunter胜2为游侠胜3为意外中断
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Stop_Hide_And_Seek | value -> "..value)
ScriptLib.SetGroupTempValue(context, "is_in_play", 0, {})
ScriptLib.EndTimeAxis(context, "rampage")
ScriptLib.EndTimeAxis(context, "energy")
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
--还未进入幽灵状态的,不用进了,所以关掉时间轴(已经结束)
for i=1,3 do
local _uid = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
ScriptLib.EndTimeAxis(context, tostring(_uid))
end
--这个watcher比较特殊需要在胜利时检测prey的state所以要写在还原state之前。
if value == 2 then
for i = 1 , 3 do
local _prey = ScriptLib.GetGroupTempValue(context, "prey_"..i, {})
local _const = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
if _const ~= 0 then
--存活的prey
if _prey ~= 0 then
local logvalue = ScriptLib.GetGroupTempValue(context, HS_State.Transfer.name.."_".._const, {})
ScriptLib.PrintContextLog(context,"uid:".._const.."的Transfer值为:"..logvalue)
--统计:胜利的时候处于变身状态
if ScriptLib.GetGroupTempValue(context, HS_State.Transfer.name.."_".._const, {}) > 0 then
ScriptLib.PrintContextLog(context,"统计:胜利的时候处于变身状态 uid:".._const)
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_win_in_transfer", 1)
end
end
end
end
end
--还原玩家所有State
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
LF_Init_Player_State(context, v)
end
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {1})
for i,v in ipairs(defs.bait_list) do
for m,n in ipairs(v) do
ScriptLib.KillEntityByConfigId(context, {config_id = n, entity_type = EntityType.GADGET})
end
end
if value == 3 then
--人数不足导致异常处理
ScriptLib.StopChallenge(context, 9011, 0)
return -1
end
local _gallery = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
-------
local catch_sum = ScriptLib.GetGroupVariableValue(context, "catch_sum")
--统计:抓捕总数
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_catch_sum", catch_sum)
--无论胜败都发的牌:
--“是猎人”牌
ScriptLib.AddExhibitionReplaceableData(context, hunter, "is_hunter", 1)
--“是游侠”牌
for i=1,3 do
local _prey = ScriptLib.GetGroupTempValue(context, "prey_"..i, {})
ScriptLib.AddExhibitionReplaceableData(context, _prey, "is_hunter", 2)
end
--hunter胜利
if value == 1 then
--统计:清扫时刻
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_miss_none", 1)
--统计:迅捷攻势
if 1 == ScriptLib.GetGroupTempValue(context, "hunter_win_by_EX", {}) then
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_win_by_EX", 1)
end
--统计:终场倒计时
if 1 == ScriptLib.GetGroupTempValue(context, "hunter_win_in_time", {}) then
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_win_in_time", 1)
end
ScriptLib.UpdatePlayerGalleryScore(context, _gallery, {["update_type"]="updateGalleryResult", ["is_hunter_win"]=true})
--prey胜利
elseif value == 2 then
LF_Handle_Exhibition_Prey_Win(context)
ScriptLib.UpdatePlayerGalleryScore(context, _gallery, {["update_type"]="updateGalleryResult", ["is_hunter_win"]=false})
end
LF_Clear_Random_Scene(context)
end
function LF_Assign_Character_Card(context)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Assign_Character_Card")
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
local _gallery = ScriptLib.GetHideAndSeekPlayGalleryId(context, _index)
ScriptLib.SetGroupTempValue(context, "gallery_id", _gallery, {})
ScriptLib.SetGroupTempValue(context, "is_in_play", 1, {})
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {0})
--分配局内身份信息
local hunter = 0
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
hunter = ScriptLib.GetHideAndSeekHunter(context, _index)
ScriptLib.PrintContextLog(context, "## HS_Log : hunter_uid = "..hunter)
ScriptLib.SetGroupTempValue(context, "hunter", hunter, {})
local cnt = 1
for i,v in ipairs(uid_list) do
if v ~= hunter then
ScriptLib.SetGroupTempValue(context, "prey_"..cnt, v, {})
ScriptLib.SetGroupTempValue(context, "const_prey_"..cnt, v, {})
cnt = cnt + 1
end
end
--追加一次游侠统计,防止在这个阶段取不到值,考虑到不是很靠谱,四阶段重新计算一次
ScriptLib.SetGroupTempValue(context, "prey_sum", #uid_list-1, {})
--关闭牢笼
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.gadget_prison_list[1], 0)
ScriptLib.PrintContextLog(context, "## H&S_LOG : player_sum = "..#uid_list)
--按选择初始化技能列表
for i,v in ipairs(uid_list) do
LF_Init_Player_Skill(context, v, i)
LF_Init_Player_State(context, v)
if v == hunter then
ScriptLib.AssignPlayerUidOpNotify(context, {param_index = 16,param_list={},param_uid_list={},duration=5,target_uid_list={v}})
else
ScriptLib.AssignPlayerUidOpNotify(context, {param_index = 17,param_list={},param_uid_list={},duration=5,target_uid_list={v}})
end
end
end
function LF_Init_Player_Skill(context, uid, u_ptr)
ScriptLib.PrintContextLog(context, "## H&S_LOG : LF_Init_Player_Skill : "..uid)
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
local _gallery = ScriptLib.GetHideAndSeekPlayGalleryId(context, _index)
local skill_list = ScriptLib.GetHideAndSeekPlayerSkillList(context, _index, uid)
for p,q in ipairs(skill_list) do
ScriptLib.AttachGalleryAbilityGroup(context, {uid}, _gallery, q)
end
end
function LF_Start_Comp_Challenge(context)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Start_Comp_Challenge")
ScriptLib.CreateFatherChallenge(context, 9011, 9011, defs.duration, {success=10,fail=10})
local uid_list = ScriptLib.GetSceneUidList(context)
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.gadget_prison_list[1], hunter)
--prey_sum这里统计就太晚了需要三阶段开始先统计一次
local prey_sum = 0
for i,v in ipairs(uid_list) do
if v == hunter then
LF_Set_Player_State_Value(context, v, HS_State.Play.name, 0)
else
local idx = 0
for j = 1,3 do
if v == ScriptLib.GetGroupTempValue(context, "prey_"..j, {}) then
idx = j
break
end
end
--只有非死亡状态的游侠才继续游戏
if ScriptLib.GetGroupTempValue(context, HS_State.Play.name.."_"..v, {}) == 3 then
LF_Set_Player_State_Value(context, v, HS_State.Play.name, 1)
ScriptLib.AttachChildChallenge(context, 9011, idx*math.pow(10,5)+9013,9013,{defs.group_id,10},{v},{success=1,fail=1})
prey_sum = prey_sum + 1
end
end
end
if prey_sum == 0 then
LF_Stop_Hide_And_Seek(context, 1)
end
--获取到正确的游侠数量
ScriptLib.AttachChildChallenge(context, 9011, 9012, 9012, {0,3,9012,prey_sum}, {hunter},{success=10,fail=10})
--启动组合挑战
ScriptLib.StartFatherChallenge(context, 9011)
ScriptLib.InitTimeAxis(context, "rampage", {defs.duration - defs.rampage_time}, false)
--处理两个抓捕结算的初始化
ScriptLib.InitTimeAxis(context, "hunter_win_in_time", {hunter_win_in_time}, false)
ScriptLib.SetGroupTempValue(context, "hunter_win_in_time", 1, {})
--新增翻牌用计时器 抓捕阶段第180秒后为决胜时间猎手在该时间内抓两人记录翻牌
ScriptLib.InitTimeAxis(context, "final_time", {final_time}, false)
--处理能量球计时
LF_Set_Energy(context)
--解除hunter限制
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.gadget_prison_list[1], 201)
end
function LF_Set_Energy(context)
--出能量球的时间有略微偏移
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Set_Energy")
math.randomseed(ScriptLib.GetServerTime(context))
local energy_list = {}
for i,v in ipairs(energy_info) do
table.insert(energy_list, v.time + math.random(energy_info[i].step[1],energy_info[i].step[2]))
end
ScriptLib.InitTimeAxis(context, "energy", energy_list, false)
end
function LF_Bake_Random_Scene(context)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Bake_Random_Scene")
--根据ld需求进行调整
--开启天气
for i = 1 , #weather_id_list do
ScriptLib.SetWeatherAreaState(context, weather_id_list[i], 1)
end
--suite 2按权重随机创建
if suites[2] ~= nil then
math.randomseed(ScriptLib.GetServerTime(context))
for i,v in ipairs(suites[2].gadgets) do
if math.random(100) > 50 then
ScriptLib.CreateGadget(context, {config_id = v})
end
end
end
--suite 3创建基本空气墙
if suites[3] ~= nil then
ScriptLib.AddExtraGroupSuite(context, 0, 3)
end
end
function LF_Clear_Random_Scene(context)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Clear_Random_Scene")
--根据需求清理数据
ScriptLib.EndTimeAxis(context, "hunter_win_by_EX")
ScriptLib.EndTimeAxis(context, "hunter_win_in_time")
ScriptLib.EndTimeAxis(context, "hunter_catch_by_guide")
ScriptLib.RemoveExtraGroupSuite(context, 0, 3)
ScriptLib.RemoveExtraGroupSuite(context, 0, 4)
--清理诱饵防止local的残留
ScriptLib.KillEntityByConfigId(context, {config_id = defs.gadget_energy, entity_type = EntityType.GADGET})
for i,v in ipairs(defs.bait_list) do
for m,n in ipairs(v) do
ScriptLib.KillEntityByConfigId(context, {config_id = n, entity_type = EntityType.GADGET})
end
end
for i,v in ipairs(defs.gadget_prison_list) do
ScriptLib.KillEntityByConfigId(context, {config_id = v, entity_type = EntityType.GADGET})
end
--关闭天气
for i = 1 , #weather_id_list do
ScriptLib.SetWeatherAreaState(context, weather_id_list[i], 0)
end
end
function LF_Init_Player_State(context, uid)
ScriptLib.PrintContextLog(context, "## H&S_LOG Init_Player_State : "..uid)
for m,n in pairs(HS_State) do
LF_Set_Player_State_Value(context, uid, n.name, n.value)
end
end
--用于集中处理hunter失败的结算
function LF_Handle_Exhibition_Prey_Win(context)
ScriptLib.PrintContextLog(context, "## H&S_LOG : LF_Handle_Exhibition_Prey_Win")
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
local prey_sum = ScriptLib.GetGroupTempValue(context, "prey_sum", {})
local catch_sum = ScriptLib.GetGroupVariableValue(context, "catch_sum")
--剩余人数结算
local prey_alive = prey_sum - catch_sum
if prey_alive == 1 then
--统计:猎手的惜败
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_miss_one", 1)
for i=1,3 do
local _prey = ScriptLib.GetGroupTempValue(context, "prey_"..i, {})
if _prey ~= 0 then
--统计:最后的火种
ScriptLib.AddExhibitionReplaceableData(context, _prey, "prey_alive_only", 1)
break
end
end
elseif prey_alive == 2 then
--统计:猎手的失误
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_miss_two", 1)
end
if catch_sum == 0 then
--统计:无从复命
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_miss_all", 1)
end
for i=1,3 do
local _prey = ScriptLib.GetGroupTempValue(context, "prey_"..i, {})
local _const = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
if _const ~= 0 then
--存活的prey
if _prey ~= 0 then
--统计:抗争到底
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_alive_win", 1)
--统计:全身而退
local guide_time = ScriptLib.GetGroupTempValue(context, "prey_win_by_guide", {})
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_win_by_guide", guide_time)
--统计:灯下取巧
local detect_time = ScriptLib.GetGroupTempValue(context, "prey_win_by_detect_".._prey, {})
ScriptLib.AddExhibitionReplaceableData(context, _prey, "prey_win_by_detect", detect_time)
--统计:无技能胜利,要反转统计一次
if 0 == ScriptLib.GetGroupTempValue(context, "prey_win_without_skill_".._const, {}) then
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_win_without_skill", 1)
end
elseif _prey == 0 then
--统计:默契之力
ScriptLib.AddExhibitionReplaceableData(context, _const, "prey_dead_win", 1)
end
end
end
end
---------------------------------------
Initialize_Base()

View File

@@ -0,0 +1,698 @@
local _radius = "radius"
------------------------------------------
--通用函数区
--获取球形范围内的u_list
function LF_Get_Uid_Around(context, radius)
local list = {}
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
if 1 == ScriptLib.GetGroupTempValue(context, HS_State.Play.name.."_"..v, {}) then
if radius >= LF_Get_Player_Distance_To_Player(context, context.uid, v) then
table.insert(list, v)
end
end
end
return list
end
--获取圆柱范围内的u_list
function LF_Get_Uid_Cylinder(context, radius)
local list = {}
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
if 1 == ScriptLib.GetGroupTempValue(context, HS_State.Play.name.."_"..v, {}) then
--if radius >= LF_Get_Player_Distance_To_Player(context, context.uid, v) then
if radius >= LF_Get_Player_Distance_To_Player_2D(context, context.uid, v) then
table.insert(list, v)
end
end
end
return list
end
function LF_Get_Baits_Around(context, radius)
local list = {}
for i,v in ipairs(defs.bait_list) do
for m,n in ipairs(v) do
if ScriptLib.CheckIsInGroup(context, 0, n) == true then
local eid = ScriptLib.GetEntityIdByConfigId(context, n)
if radius >= LF_Get_Player_Distance_To_Entity(context, context.uid, eid) then
table.insert(list, n)
end
end
end
end
return list
end
--判断3D距离
function LF_Get_Player_Distance_To_Player(context, uid_1, uid_2)
local eid_1 = ScriptLib.GetAvatarEntityIdByUid(context, uid_1)
local eid_2 = ScriptLib.GetAvatarEntityIdByUid(context, uid_2)
return LF_Get_Distance_By_EntityId(context, eid_1, eid_2)
end
--判断2D距离
function LF_Get_Player_Distance_To_Player_2D(context, uid_1, uid_2)
local eid_1 = ScriptLib.GetAvatarEntityIdByUid(context, uid_1)
local eid_2 = ScriptLib.GetAvatarEntityIdByUid(context, uid_2)
return LF_Get_Distance_By_EntityId_2D(context, eid_1, eid_2)
end
function LF_Get_Player_Distance_To_Entity(context, uid_1, eid_2)
local eid_1 = ScriptLib.GetAvatarEntityIdByUid(context, uid_1)
return LF_Get_Distance_By_EntityId(context, eid_1, eid_2)
end
function LF_Get_Distance_By_EntityId(context, eid_1, eid_2)
local pos_1 = ScriptLib.GetPosByEntityId(context, eid_1)
local pos_2 = ScriptLib.GetPosByEntityId(context, eid_2)
local X = pos_1.x - pos_2.x
local Y = pos_1.y - pos_2.y
local Z = pos_1.z - pos_2.z
return math.sqrt(X*X+Y*Y+Z*Z)
end
function LF_Get_Distance_By_EntityId_2D(context, eid_1, eid_2)
local pos_1 = ScriptLib.GetPosByEntityId(context, eid_1)
local pos_2 = ScriptLib.GetPosByEntityId(context, eid_2)
local X = pos_1.x - pos_2.x
local Z = pos_1.z - pos_2.z
return math.sqrt(X*X+Z*Z)
end
function LF_Get_Skill_Info(context, skill, info)
if skill_info[skill][info] ~= nil then
return skill_info[skill][info]
end
ScriptLib.PrintContextLog(context, "## H&S_WARNING : Invalid Skill_Info : skill -> "..skill.." | key -> "..info)
return 0
end
------------------------------------------
function HideAndSeek_Skill_Init(context)
local skill = "HideAndSeek_Skill_Init"
LF_Handle_Skill(context, skill, context.uid, 0)
return 0
end
--hunter技能响应
--抓捕
function HideAndSeek_Skill_CatchPrey(context)
local skill = "HideAndSeek_Skill_CatchPrey"
ScriptLib.PrintContextLog(context, "## catch_debug | skill = "..skill)
local radius = LF_Get_Skill_Info(context, skill, _radius)
ScriptLib.PrintContextLog(context, "## catch_debug | radius = "..radius)
--诱饵队列
local bait_list = LF_Get_Baits_Around(context, radius)
ScriptLib.PrintContextLog(context, "## catch_debug | #bait = "..#bait_list)
if #bait_list ~= 0 then
for i,v in ipairs(bait_list) do
LF_Handle_Skill(context, skill, 0, v)
end
--通知hunter被致盲
ScriptLib.AddTeamEntityGlobalFloatValue(context, {context.uid}, "HideAndSeek_Get_Blind", 1)
end
--玩家队列
local prey_list = LF_Get_Uid_Around(context, radius)
ScriptLib.PrintContextLog(context, "## catch_debug | #prey = "..#prey_list)
if #prey_list ~= 0 then
for i,v in ipairs(prey_list) do
--catch_speedup_prey 翻牌
if ScriptLib.GetGroupTempValue(context, "prey_is_in_sprint_"..v, {}) == 1 then
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "catch_speedup_prey", 1)
end
--catch_invisible_prey 翻牌
if ScriptLib.GetGroupTempValue(context, HS_State.Visible.name.."_"..v, {}) == 1 then
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "catch_invisible_prey", 1)
end
--catch_2_disguise_prey 翻牌
if ScriptLib.GetGroupTempValue(context, HS_State.Transfer.name.."_"..v, {}) > 0 then
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "catch_2_disguise_prey", 1)
end
--is_in_final_time 最后60秒抓住的玩家数 翻牌
if ScriptLib.GetGroupTempValue(context,"is_in_final_time",{}) == 1 then
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "catch_2_prey_in_60", 1)
end
LF_Handle_Skill(context, skill, v, 0)
--Debug用↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
ScriptLib.InitTimeAxis(context,"Debug_Check_Catched_Prey_State_"..v ,{5},false)
--Debug用↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
end
end
return 0
end
--方向引导
function HideAndSeek_Skill_Guide(context)
local skill = "HideAndSeek_Skill_Guide"
LF_Handle_Skill(context, skill, context.uid, 0)
return 0
end
--方向引导
function FireDirection(context)
local skill = "FireDirection"
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
LF_Handle_Skill(context, skill, hunter, 0)
return 0
end
--为侦测到诱饵
function HideAndSeek_Skill_Detect_F(context)
local skill = "HideAndSeek_Skill_Detect_F"
local radius = LF_Get_Skill_Info(context, skill, _radius)
--玩家队列
--local prey_list = LF_Get_Uid_Around(context, radius)
local prey_list = LF_Get_Uid_Cylinder(context, radius)
if #prey_list > 0 then
LF_Handle_Skill(context, skill, context.uid, 1)
--统计:感应光环成功数
ScriptLib.AddExhibitionAccumulableData(context, context.uid, "hunter_detect_prey", #prey_list)
for i,v in ipairs(prey_list) do
--记录被探查的次数
LF_Change_Temp_Value(context, "prey_win_by_detect_"..v, 1)
LF_Set_Player_State_Value(context, v, HS_State.Is_Detected.name, 1)
end
else
LF_Handle_Skill(context, skill, context.uid, -1)
end
return 0
end
--重置上面的技能
function HideAndSeek_Skill_Detect_F_Reset(context)
local skill = "HideAndSeek_Skill_Detect_F"
LF_Handle_Skill(context, skill, context.uid, 0)
return 0
end
--无敌定位
function HideAndSeek_Skill_UltraMark(context)
local skill = "HideAndSeek_Skill_UltraMark"
local radius = LF_Get_Skill_Info(context, skill, _radius)
--玩家队列
local prey_list = LF_Get_Uid_Around(context, radius)
if #prey_list ~= 0 then
math.randomseed(ScriptLib.GetServerTime(context))
local ran = math.random(#prey_list)
LF_Handle_Skill(context, skill, prey_list[ran], 0)
LF_Notify_Skill_Info(context, skill, context.uid, prey_list[ran])
end
return 0
end
--无敌定位结束
function HideAndSeek_Out_UltraMark(context)
local skill = "HideAndSeek_Out_UltraMark"
LF_Handle_Skill(context, skill, context.uid, 0)
return 0
end
--全部出来
function HideAndSeek_Skill_GlobalSight(context)
local skill = "HideAndSeek_Skill_GlobalSight"
local radius = LF_Get_Skill_Info(context, skill, _radius)
local prey_list = LF_Get_Uid_Around(context, radius)
--V2新增以前在Action里修改gv现改为由lua修改
LF_Set_Player_State_Value(context, context.uid, HS_State.GlobalSight.name, 0)
--V2新增结束
for i,v in ipairs(prey_list) do
LF_Handle_Skill(context, skill, v, 0)
end
LF_Notify_Skill_Info(context, skill, context.uid, 0)
return 0
end
--全不出来
function HideAndSeek_Out_GlobalSight(context)
local skill = "HideAndSeek_Out_GlobalSight"
LF_Handle_Skill(context, skill, context.uid, 0)
return 0
end
--超级锁定
function HideAndSeek_Skill_SuperPrison(context)
local skill = "HideAndSeek_Skill_SuperPrison"
local radius = LF_Get_Skill_Info(context, skill, _radius)
--玩家队列
local prey_list = LF_Get_Uid_Around(context, radius)
if #prey_list ~= 0 then
math.randomseed(ScriptLib.GetServerTime(context))
local ran = math.random(#prey_list)
LF_Handle_Skill(context, skill, prey_list[ran], 0)
LF_Notify_Skill_Info(context, skill, context.uid, prey_list[ran])
end
return 0
end
--锁定过期
function HideAndSeek_Out_SuperPrison(context)
local skill = "HideAndSeek_Out_SuperPrison"
LF_Handle_Skill(context, skill, context.uid, 0)
return 0
end
--猎人暴走
function HideAndSeek_Hunter_Rampage(context)
local skill = "HideAndSeek_Hunter_Rampage"
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
LF_Handle_Skill(context, skill, hunter, 0)
LF_Notify_Skill_Info(context, skill, hunter, 0)
return 0
end
--隐身
function HideAndSeek_Skill_SelfInvisible(context)
--服务器校验,幽灵状态不允许使用
local _State_Play = ScriptLib.GetGroupTempValue(context,HS_State.Play.name.."_"..context.uid,{})
if _State_Play == 2 then
ScriptLib.PrintContextLog(context, context.uid .."尝试使用隐身技能失败:服务器校验,幽灵状态不允许使用")
return 0
end
--校验结束
local skill = "HideAndSeek_Skill_SelfInvisible"
LF_Handle_Skill(context, skill, context.uid, 0)
--LF_Change_Temp_Value(context, "prey_win_without_skill_"..context.uid, 1)
return 0
end
--诱饵放置
function HideAndSeek_Skill_PlaceBait(context)
local skill = "HideAndSeek_Skill_PlaceBait"
LF_Handle_Skill(context, skill, context.uid, 0)
--LF_Change_Temp_Value(context, "prey_win_without_skill_"..context.uid, 1)
return 0
end
--伪装
function HideAndSeek_Skill_Transfer(context)
--服务器校验,超级标记状态不允许使用
local _temp = ScriptLib.GetGroupTempValue(context,HS_State.UltraMark.name.."_"..context.uid,{})
if _temp == 1 then
ScriptLib.PrintContextLog(context, context.uid .."尝试使用变身技能失败:服务器校验,超级标记状态不允许使用")
return 0
end
--服务器校验,被洞察状态不允许使用
local _temp = ScriptLib.GetGroupTempValue(context,HS_State.GlobalSight.name.."_"..context.uid,{})
if _temp == 1 then
ScriptLib.PrintContextLog(context, context.uid .."尝试使用变身技能失败:服务器校验,被洞察状态不允许使用")
return 0
end
--服务器校验,幽灵状态不允许使用
local _temp = ScriptLib.GetGroupTempValue(context,HS_State.Play.name.."_"..context.uid,{})
if _temp == 2 then
ScriptLib.PrintContextLog(context, context.uid .."尝试使用变身技能失败:服务器校验,幽灵状态不允许使用")
return 0
end
--校验结束
local skill = "HideAndSeek_Skill_Transfer"
LF_Handle_Skill(context, skill, context.uid, 0)
LF_Change_Temp_Value(context, "prey_win_without_skill_"..context.uid, 1)
return 0
end
--解除伪装
function HideAndSeek_Skill_Transfer_Quit(context)
local skill = "HideAndSeek_Skill_Transfer_Quit"
LF_Handle_Skill(context, skill, context.uid, 0)
return 0
end
--获取能量
function HideAndSeek_Skill_Get_Energy(context)
local skill = "HideAndSeek_Skill_Get_Energy"
--统计:眷顾之能
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "player_get_energy", 1)
LF_Notify_Skill_Info(context, skill, context.uid, 0)
return 0
end
--疾跑
function HideAndSeek_Skill_Sprint(context)
local skill = "HideAndSeek_Skill_Sprint"
LF_Notify_Skill_Info(context, skill, context.uid, 0)
--翻牌 局内变量 是否处于疾跑状态
ScriptLib.SetGroupTempValue(context, "prey_is_in_sprint_"..context.uid, 1, {})
ScriptLib.PrintContextLog(context, "## H&S_LOG : 翻牌:prey_is_in_sprint_"..context.uid .." = 1")
--统计:正义的加护
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "extra_skill_user", 1)
return 0
end
--疾跑结束
function HideAndSeek_Skill_Sprint_Quit(context)
local skill = "HideAndSeek_Skill_Sprint_Quit"
LF_Notify_Skill_Info(context, skill, context.uid, 0)
--翻牌 局内变量 是否处于疾跑状态
ScriptLib.SetGroupTempValue(context, "prey_is_in_sprint_"..context.uid, 0, {})
ScriptLib.PrintContextLog(context, "## H&S_LOG : 翻牌:prey_is_in_sprint_"..context.uid .." = 0")
return 0
end
--致盲
function HideAndSeek_Skill_Blind(context, config_id)
ScriptLib.PrintContextLog(context, "## H&S_LOG : skill_debug : blind cid = "..config_id)
for i,v in ipairs(defs.bait_list) do
for p,q in ipairs(v) do
if q == config_id then
local _prey = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
ScriptLib.AddExhibitionReplaceableData(context, _prey, "prey_cheat_hunter", 1)
ScriptLib.AddExhibitionAccumulableData(context, _prey, "prey_cheat_hunter", 1)
return 0
end
end
end
return -1
end
--退出被侦测状态(当被抓方被扫描后,进行移动时调用;或者被侦测状态时间到)
function HideAndSeek_Skill_Is_Detected_Quit(context)
local skill = "HideAndSeek_Skill_Is_Detected_Quit"
LF_Handle_Skill(context, skill, context.uid, 0)
return 0
end
function LF_Change_Temp_Value(context, key, delta)
local cnt = ScriptLib.GetGroupTempValue(context, key, {})
ScriptLib.SetGroupTempValue(context, key, cnt + delta, {})
end
--退出隐身状态游侠的5秒隐身
function HideAndSeek_Skill_SelfInvisible_Quit(context)
local skill = "HideAndSeek_Skill_SelfInvisible_Quit"
LF_Handle_Skill(context,skill,context.uid,0)
return 0
end
-------------------------------------------
--技能分发管理器
function LF_Handle_Skill(context, skill, uid, cid)
ScriptLib.PrintContextLog(context, "## H&S_WARNING : skill -> "..skill.." | uid -> "..uid.." | cid -> "..cid)
if skill == "HideAndSeek_Skill_Init" then
--先判断玩家有没有注册成功
local reg = 0
for i=1,3 do
if uid == ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {}) then
reg = 1
break
end
end
if uid == ScriptLib.GetGroupTempValue(context, "hunter", {}) then
ScriptLib.PrintContextLog(context, "## H&S_WARNING[准备阶段bug] : if uid == ScriptLib.GetGroupTempValue(context, , {}) then")
--服务器可能在忽悠我还是要处理hunter进的晚没有初始化的情况处理完强制结束
LF_Init_Player_State(context, uid)
if 1 ~= ScriptLib.GetGroupTempValue(context, "in_escape", {}) then
ScriptLib.PrintContextLog(context,"in_escape ~= 1")
LF_Set_Player_State_Value(context, uid, HS_State.Play.name, 0)
end
ScriptLib.SetPlayerGroupVisionType(context, {uid}, {0})
return 0
end
if reg == 0 then
ScriptLib.PrintContextLog(context, "## H&S_WARNING[准备阶段bug] : if reg == 0 then")
--处理未注册的玩家不可能是hunter
--初始化一次,然后更新阵营参数
LF_Init_Player_State(context, uid)
LF_Set_Player_State_Value(context, uid, HS_State.Play.name, 1)
ScriptLib.SetPlayerGroupVisionType(context, {uid}, {0})
else
ScriptLib.PrintContextLog(context, "## H&S_WARNING[准备阶段bug] : if reg == 0 then else!")
--对已经在入场的玩家还原客户端状态
for k,v in pairs(HS_State) do
local _temp = ScriptLib.GetGroupTempValue(context, v.name.."_"..uid, {})
--重连直接清隐身保平安
if k ~= "Visible" then
LF_Set_Player_State_Value(context, uid, v.name, _temp)
else
LF_Set_Player_State_Value(context, uid, v.name, 0)
end
end
ScriptLib.SetPlayerGroupVisionType(context, {uid}, {0})
end
elseif skill == "HideAndSeek_Skill_CatchPrey" then
if uid ~= 0 then
LF_Set_Prey_Die(context, uid)
elseif uid == 0 and cid ~= 0 then
ScriptLib.KillEntityByConfigId(context, {config_id = cid, entity_type = EntityType.GADGET})
HideAndSeek_Skill_Blind(context, cid)
end
elseif skill == "HideAndSeek_Skill_Guide" then
ScriptLib.SetGroupTempValue(context, "guide_cnt", 0, {})
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
local _playValue = ScriptLib.GetGroupTempValue(context, HS_State.Play.name.."_"..v, {})
ScriptLib.PrintContextLog(context, "## H&S_LOG : skill_debug "..skill.." | uid = "..v.." | key = "..HS_State.Play.name.." | value = ".._playValue)
if 1 == _playValue then
--创建guide gadget之前刷一下authority为猎人。
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.gadget_prison_list[1], hunter)
--对存活的玩家执行action
for j=1,3 do
if v == ScriptLib.GetGroupTempValue(context, "prey_"..j, {}) then
ScriptLib.KillEntityByConfigId(context, {config_id=defs.gadget_guide[j], entity_type=EntityType.GADGET})
local eid = ScriptLib.GetAvatarEntityIdByUid(context, v)
local pos = ScriptLib.GetPosByEntityId(context, eid)
ScriptLib.PrintContextLog(context, "## H&S_LOG : skill_debug "..skill.." | prey_"..j.." = "..v.." | cid = "..defs.gadget_guide[j])
local ret = ScriptLib.CreateGadgetByConfigIdByPos(context, defs.gadget_guide[j], {x=pos.x,y=pos.y,z=pos.z}, {x=0,y=0,z=0})
ScriptLib.PrintContextLog(context, "## H&S_LOG : Create_Gadget_Guide_"..j.." -> "..ret)
end
end
end
end
elseif skill == "FireDirection" then
ScriptLib.ChangeGroupTempValue(context, "guide_cnt", 1, {})
local guide_cnt = ScriptLib.GetGroupTempValue(context, "guide_cnt", {})
local catch_sum = ScriptLib.GetGroupVariableValue(context, "catch_sum")
local prey_sum = ScriptLib.GetGroupTempValue(context, "prey_sum", {})
ScriptLib.PrintContextLog(context, "## H&S_LOG : skill_debug : guide_cnt = "..guide_cnt.." | catch_sum = "..catch_sum.." | prey_sum = "..prey_sum)
if guide_cnt == prey_sum - catch_sum then
--这个状态不用存档所以不执行lf_set_player_state
ScriptLib.AddTeamEntityGlobalFloatValue(context, {uid}, "FireDirection", 1)
--guide后抓人统计
ScriptLib.InitTimeAxis(context, "hunter_catch_by_guide", {hunter_catch_by_guide}, false)
ScriptLib.SetGroupTempValue(context, "hunter_catch_by_guide", 1, {})
LF_Change_Temp_Value(context, "prey_win_by_guide", 1)
end
elseif skill == "HideAndSeek_Skill_Detect_F" then
LF_Set_Player_State_Value(context, uid, "SGV_HideAndSeek_Skill_Detect", cid)
elseif skill == "HideAndSeek_Skill_UltraMark" then
ScriptLib.InitTimeAxis(context, "hunter_win_by_EX", {hunter_win_by_EX}, false)
ScriptLib.SetGroupTempValue(context, "hunter_win_by_EX", 1, {})
LF_Set_Player_State_Value(context, uid, HS_State.OnMap.name, 1)
LF_Set_Player_State_Value(context, uid, HS_State.Transfer.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.UltraMark.name, 1)
--翻牌记录被globalsight过
ScriptLib.AddExhibitionReplaceableData(context,uid,"escape_after_ultraMark",1)
elseif skill == "HideAndSeek_Out_UltraMark" then
LF_Set_Player_State_Value(context, uid, HS_State.OnMap.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.UltraMark.name, 0)
elseif skill == "HideAndSeek_Skill_GlobalSight" then
ScriptLib.InitTimeAxis(context, "hunter_win_by_EX", {hunter_win_by_EX}, false)
ScriptLib.SetGroupTempValue(context, "hunter_win_by_EX", 1, {})
LF_Set_Player_State_Value(context, uid, HS_State.Transfer.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.OnMap.name, 1)
LF_Set_Player_State_Value(context, uid, HS_State.GlobalSight.name, 1)
--翻牌记录被globalsight过
ScriptLib.AddExhibitionReplaceableData(context,uid,"escape_after_globalsight",1)
elseif skill == "HideAndSeek_Out_GlobalSight" then
LF_Set_Player_State_Value(context, uid, HS_State.OnMap.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.GlobalSight.name, 0)
elseif skill == "HideAndSeek_Skill_SuperPrison" then
ScriptLib.InitTimeAxis(context, "hunter_win_by_EX", {hunter_win_by_EX}, false)
ScriptLib.SetGroupTempValue(context, "hunter_win_by_EX", 1, {})
LF_Set_Player_State_Value(context, uid, HS_State.Transfer.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.Moveable.name, 1)
LF_Set_Player_State_Value(context, uid, HS_State.SuperPrison.name, 1)
--翻牌记录被globalsight过
ScriptLib.AddExhibitionReplaceableData(context,uid,"escape_after_superprison",1)
elseif skill == "HideAndSeek_Out_SuperPrison" then
LF_Set_Player_State_Value(context, uid, HS_State.Moveable.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.SuperPrison.name, 0)
elseif skill == "HideAndSeek_Hunter_Rampage" then
LF_Set_Player_State_Value(context, uid, HS_State.Rampage.name, 1)
elseif skill == "HideAndSeek_Skill_SelfInvisible" then
LF_Set_Player_State_Value(context, uid, HS_State.Transfer.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.Visible.name, 1)
elseif skill == "HideAndSeek_Skill_PlaceBait" then
local eid = ScriptLib.GetAvatarEntityIdByUid(context, uid)
local pos = ScriptLib.GetPosByEntityId(context, eid)
local pos_table = { x = pos.x, y = pos.y, z = pos.z + 0.1 }
local rot_table = { x = 0, y = 0, z = 0 }
ScriptLib.PrintContextLog(context, "## bait_debug | stage_1 ")
for i=1,3 do
local player = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
if player == 0 then
break
end
if player == uid then
ScriptLib.PrintContextLog(context, "## bait_debug | player = "..player)
if 2 ~= ScriptLib.GetGroupTempValue(context, HS_State.Play.name.."_"..player, {}) then
--这里要处理一个人的复数bait序列问题
local bait_ptr = 1
--重定位诱饵ptr,遍历比3-8译码效率高
for j = 1,#defs.bait_list[i] do
if ScriptLib.CheckIsInGroup(context, 0, defs.bait_list[i][j]) == false then
bait_ptr = j
break
end
end
local bait = defs.bait_list[i][bait_ptr]
ScriptLib.KillEntityByConfigId(context, {config_id=bait, entity_type=EntityType.GADGET})
local _value = ScriptLib.GetGroupTempValue(context, HS_State.TransferCache.name.."_"..player, {})
--如果玩家未变身,就用第一个transfer处理
if _value == 0 then
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
local _map = ScriptLib.GetHideAndSeekMap(context, _index)
_value = map_info[_map].list[1]
end
ScriptLib.PrintContextLog(context, "## H&S_LOG : bait_detail_info : player = "..player.." | ptr = "..bait_ptr.." | bait = "..bait.." value = ".._value)
local ret = ScriptLib.CreateGadgetByParamTable(context, {config_id = bait, pos = pos_table, rot = rot_table, sgv_key = {"SGV_HideAndSeek_Bait_Transfer"}, sgv_value = {_value}})
ScriptLib.PrintContextLog(context, "## H&S_LOG : bait_detail_ret : "..ret)
break
end
end
end
elseif skill == "HideAndSeek_Skill_Transfer" then
--根据地图翻译next
--默认地图变身配置
local list = {0,1,2,3}
local _index = ScriptLib.GetHideAndSeekPlayIndex(context)
local _map = 1
_map = ScriptLib.GetHideAndSeekMap(context, _index)
ScriptLib.PrintContextLog(context, "## HS_LOG : Get_Map_Info : ".._map)
for k,v in pairs(map_info) do
if k == _map then
list = v.list
break
end
end
local t = ScriptLib.GetGroupTempValue(context, HS_State.TransferCache.name.."_"..uid, {})
ScriptLib.PrintContextLog(context, "## H&S_LOG : Get_Player_Transform_Info : uid="..uid.." | value = "..t)
--先处理transfer初始值带来的问题
local t_next = 1
if t ~= 0 then
for i,v in ipairs(list) do
if t == v then
t_next = i + 1
if t_next > #list then
t_next = 1
end
end
end
end
LF_Set_Player_State_Value(context, uid, HS_State.Visible.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.Transfer.name, list[t_next])
LF_Set_Player_State_Value(context, uid, HS_State.TransferCache.name, list[t_next])
elseif skill == "HideAndSeek_Skill_Transfer_Quit" then
--取消变身保留cache
LF_Set_Player_State_Value(context, uid, HS_State.Transfer.name, 0)
elseif skill == "HideAndSeek_Skill_Is_Detected_Quit" then
--游侠退出被侦测状态(被侦测状态时间到或移动时触发)
LF_Set_Player_State_Value(context, uid, HS_State.Is_Detected.name, 0)
elseif skill == "HideAndSeek_Skill_SelfInvisible_Quit" then
--游侠退出5秒隐身
LF_Set_Player_State_Value(context, uid, HS_State.Visible.name, 0)
end
return 0
end
function LF_Set_Player_State_Value(context, uid, key, value)
ScriptLib.PrintContextLog(context, "尝试设置sgv## H&S_LOG : Set_State_Value : uid = "..uid.." | key = "..key.." | value = "..value)
ScriptLib.SetGroupTempValue(context, key.."_"..uid, value, {})
--重要状态改为Team_SGV实现
--ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid}, key, value)
ScriptLib.SetTeamServerGlobalValue(context,uid, key, value)
end
function LF_Notify_Player_Visible(context)
ScriptLib.PrintContextLog(context, "## H&S_LOG : Modify_On_Map")
local list = {}
for i=1,3 do
local uid = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
if ScriptLib.GetGroupTempValue(context, HS_State.OnMap.name.."_"..uid, {}) == 1 then
table.insert(list, uid)
end
end
local _gallery = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
ScriptLib.PrintContextLog(context, "[b1315327]将玩家显示在地图上list数量"..#list)
ScriptLib.UpdatePlayerGalleryScore(context, _gallery, {["update_type"]="updateVisibleUidList", ["uid_list"] = list})
for i,v in ipairs(list) do
ScriptLib.PrintContextLog(context, "## OnMap_Debug : list["..i.."] = "..v)
end
end
function LF_Notify_Player_Die_Effect(context, uid)
ScriptLib.PrintContextLog(context, "## H&S_LOG : Prepare_Die_Effect : uid = "..uid)
ScriptLib.InitTimeAxis(context, tostring(uid), {3}, false)
end
function LF_Notify_Skill_Info(context, skill, uid_1, uid_2)
ScriptLib.PrintContextLog(context, "## H&S_LOG : LF_Notify_Skill_Info : skill -> "..skill)
local uid_list = ScriptLib.GetSceneUidList(context)
if skill == "HideAndSeek_Skill_UltraMark" then
ScriptLib.AssignPlayerShowTemplateReminder(context, 124, {param_vec={skill_info[skill].duration},param_uid_vec={uid_1,uid_2},uid_vec=uid_list})
elseif skill == "HideAndSeek_Skill_GlobalSight" then
ScriptLib.AssignPlayerShowTemplateReminder(context, 125, {param_vec={skill_info[skill].duration},param_uid_vec={uid_1},uid_vec=uid_list})
elseif skill == "HideAndSeek_Skill_SuperPrison" then
ScriptLib.AssignPlayerShowTemplateReminder(context, 126, {param_vec={skill_info[skill].duration},param_uid_vec={uid_1,uid_2},uid_vec=uid_list})
elseif skill == "HideAndSeek_Skill_CatchPrey" then
ScriptLib.AssignPlayerUidOpNotify(context, {param_index = 11,param_list={},param_uid_list={uid_1,uid_2},duration=3,target_uid_list=uid_list})
elseif skill == "HideAndSeek_Hunter_Rampage" then
ScriptLib.AssignPlayerUidOpNotify(context, {param_index = 13,param_list={},param_uid_list={uid_1},duration=3,target_uid_list=uid_list})
elseif skill == "HideAndSeek_Skill_Get_Energy" then
local notify_id = 15
if uid_1 == ScriptLib.GetGroupTempValue(context, "hunter", {}) then
notify_id = 14
end
ScriptLib.AssignPlayerUidOpNotify(context, {param_index = notify_id,param_list={},param_uid_list={uid_1},duration=3,target_uid_list=uid_list})
end
end
function LF_Set_Prey_Die(context, uid)
ScriptLib.PrintContextLog(context,"LF_Set_Prey_Die")
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
local _gallery = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
ScriptLib.UpdatePlayerGalleryScore(context, _gallery, {["update_type"]="updateCaughtUid", ["caught_uid"]=uid})
LF_Set_Player_State_Value(context, uid, HS_State.Transfer.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.Visible.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.OnMap.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.Moveable.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.Play.name, 2)
local catch_sum = ScriptLib.GetGroupVariableValue(context, "catch_sum")
local prey_sum = ScriptLib.GetGroupTempValue(context, "prey_sum", {})
--处理prey死亡的exhibition统计
if 1 == ScriptLib.GetGroupTempValue(context, "hunter_catch_by_guide", {}) then
--统计:神秘预感后捕获
ScriptLib.AddExhibitionReplaceableData(context, hunter, "hunter_catch_by_guide", 1)
end
if catch_sum == 0 then
--统计:强行侦察
ScriptLib.AddExhibitionReplaceableData(context, uid, "prey_dead_first", 1)
end
if catch_sum == 1 then
--统计:阵脚大乱
ScriptLib.AddExhibitionReplaceableData(context, uid, "prey_dead_second", 1)
end
if catch_sum == prey_sum - 1 then
--统计:功败垂成
ScriptLib.AddExhibitionReplaceableData(context, uid, "prey_dead_final", 1)
end
--处理玩家死亡表现
if catch_sum < prey_sum - 1 then
ScriptLib.PrintContextLog(context,"catch_sum = " .. catch_sum .."|prey_sum = ".. prey_sum)
LF_Notify_Skill_Info(context, "HideAndSeek_Skill_CatchPrey", hunter, uid)
LF_Notify_Player_Die_Effect(context, uid)
end
ScriptLib.ChangeGroupVariableValue(context, "catch_sum", 1)
--最后执行prey_清档比较安全
local idx = 0
for j = 1,3 do
if uid == ScriptLib.GetGroupTempValue(context, "prey_"..j, {}) then
idx = j
ScriptLib.SetGroupTempValue(context, "prey_"..j, 0, {})
break
end
end
ScriptLib.StopChallenge(context, idx*math.pow(10,5)+9013, 0)
end
-------------------------------------------

View File

@@ -0,0 +1,165 @@
local watcher_2_condition = defs.round
local watcher4time = defs.interval_time_1
local watcher5time = defs.interval_time_2
local watcher6time = defs.interval_time_3
local temp_Variables = {
{ config_id=50000001,name = "Finish_Game_Play", value = 0, no_refresh = false },
}
local temp_Tirgger = {
{event = EventType.EVENT_VARIABLE_CHANGE, source = "Finish_Game_Play", condition = "", action = "action_EVENT_VARIABLE_CHANGE",trigger_count = 0},
{event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_LIVE",trigger_count = 0},
{event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_EVENT_TIME_AXIS_PASS",trigger_count = 0},
{event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION",trigger_count = 0},
}
function action_EVENT_SELECT_OPTION(context,evt)
ScriptLib.PrintContextLog(context,"action_EVENT_SELECT_OPTION")
--各种temp变量初始化
ScriptLib.SetGroupTempValue(context,"watcher_4_countdown", 0,{})
ScriptLib.SetGroupTempValue(context,"watcher_5_countdown", 0,{})
ScriptLib.SetGroupTempValue(context,"watcher_6_countdown", 0,{})
ScriptLib.SetGroupTempValue(context,"watcher_4_complete",0,{})
ScriptLib.SetGroupTempValue(context,"watcher_5_complete",0,{})
ScriptLib.SetGroupTempValue(context,"watcher_6_complete",0,{})
ScriptLib.SetGroupTempValue(context,"round",0,{})
local uid_list = ScriptLib.GetSceneUidList(context)
for i = 1 , #uid_list do
ScriptLib.SetGroupTempValue(context,"watcher_3_attacked_"..uid_list[i],0,{})
end
return 0
end
function action_EVENT_TIME_AXIS_PASS(context,evt)
ScriptLib.PrintContextLog(context,"action_EVENT_TIME_AXIS_PASS")
if evt.source_name == "watcher_4_countdown" then ScriptLib.SetGroupTempValue(context,"watcher_4_countdown", 0,{}) end
if evt.source_name == "watcher_5_countdown" then ScriptLib.SetGroupTempValue(context,"watcher_5_countdown", 0,{}) end
if evt.source_name == "watcher_6_countdown" then ScriptLib.SetGroupTempValue(context,"watcher_6_countdown", 0,{}) end
return 0
end
function action_EVENT_ANY_MONSTER_LIVE(context,evt)
ScriptLib.PrintContextLog(context,"action_EVENT_ANY_MONSTER_LIVE".. "[evt.source_eid] = " .. evt.source_eid)
if ScriptLib.GetMonsterIdByEntityId(context, evt.source_eid) == 26080101 then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_Mini_Osial", 1)
end
return 0
end
function action_EVENT_VARIABLE_CHANGE(context,evt)
ScriptLib.PrintContextLog(context,"action_EVENT_VARIABLE_CHANGE".. "[evt.source_name] = " .. evt.source_name)
if evt.source_name == "Finish_Game_Play" then
local uid_list = ScriptLib.GetSceneUidList(context)
for i = 1 , #uid_list do
ScriptLib.AddExhibitionAccumulableData(context,uid_list[i],"Activity_MiniOsial_Watcher_1",1) --[[watcher1]]
ScriptLib.PrintContextLog(context,uid_list[i].. ":watcher1")
ScriptLib.AddExhibitionReplaceableData(context,uid_list[i],"Activity_MiniOsial_CARD_5",1) --[[card5]]
ScriptLib.PrintContextLog(context,uid_list[i].. ":card5")
end
LF_cal_watcher_2(context)
LF_cal_watcher_3(context)
LF_cal_watcher_456(context)
end
return 0
end
--ScriptLib.GetMonsterIdByEntityId(context, entity_id)根据实体ID获取怪物IDmonster_id)。
--========================以下为LF
function LF_cal_watcher_2(context)
local _round = ScriptLib.GetGroupTempValue(context,"round",{})
ScriptLib.PrintContextLog(context,"LF_cal_watcher_2[round]=".._round)
if _round < watcher_2_condition then
local uid_list = ScriptLib.GetSceneUidList(context)
for i = 1 , #uid_list do
ScriptLib.AddExhibitionAccumulableData(context,uid_list[i],"Activity_MiniOsial_Watcher_2",1) --[[watcher2]]
ScriptLib.PrintContextLog(context,uid_list[i].. ":watcher2")
end
end
return 0
end
function LF_cal_watcher_3(context)
ScriptLib.PrintContextLog(context,"LF_cal_watcher_3")
local uid_list = ScriptLib.GetSceneUidList(context)
for i = 1 , #uid_list do
if ScriptLib.GetGroupTempValue(context,"watcher_3_attacked_"..uid_list[i],{}) ~= 1 then
ScriptLib.AddExhibitionAccumulableData(context,uid_list[i],"Activity_MiniOsial_Watcher_3",1) --[[watcher3]]
ScriptLib.PrintContextLog(context,uid_list[i].. ":watcher3")
ScriptLib.AddExhibitionReplaceableData(context,uid_list[i],"Activity_MiniOsial_CARD_4",1) --[[card4]]
ScriptLib.PrintContextLog(context,uid_list[i].. ":card4")
end
end
return 0
end
function LF_cal_watcher_456(context)
ScriptLib.PrintContextLog(context,"LF_cal_watcher_456")
for key = 4,6 do
if ScriptLib.GetGroupTempValue(context,"watcher_".. key .. "_complete",{}) == 1 then
local uid_list = ScriptLib.GetSceneUidList(context)
for i = 1 , #uid_list do
ScriptLib.AddExhibitionAccumulableData(context,uid_list[i],"Activity_MiniOsial_Watcher_"..key,1) --[[watcher456]]
ScriptLib.PrintContextLog(context,uid_list[i].. ":watcher"..key)
end
end
end
return 0
end
--========================以下为SLC
function SLC_MiniOsial_Watcher_2(context)
ScriptLib.PrintContextLog(context,"SLC_MiniOsial_watcher_2[context.uid] = " .. context.uid)
ScriptLib.ChangeGroupTempValue(context,"round",1,{})
return 0
end
function SLC_MiniOsial_Water_Attack(context)--需要lua处理局终判断未被击中的uid
ScriptLib.PrintContextLog(context,"SLC_MiniOsial_Water_Attack[context.uid] = " .. context.uid)
ScriptLib.SetGroupTempValue(context,"watcher_3_attacked_".. context.uid,1,{})
return 0
end
function SLC_MiniOsial_Injury(context)
ScriptLib.PrintContextLog(context,"SLC_MiniOsial_Injury[context.uid] = " .. context.uid)
--watcher 4
if ScriptLib.GetGroupTempValue(context,"watcher_4_countdown",{}) == 1 then
ScriptLib.SetGroupTempValue(context,"watcher_4_complete",1,{})
else
ScriptLib.InitTimeAxis(context, "watcher_4_countdown", {watcher4time}, false)
ScriptLib.SetGroupTempValue(context,"watcher_4_countdown",1,{})
end
--watcher 5
if ScriptLib.GetGroupTempValue(context,"watcher_5_countdown",{}) == 1 then
ScriptLib.SetGroupTempValue(context,"watcher_5_complete",1,{})
else
ScriptLib.InitTimeAxis(context, "watcher_5_countdown", {watcher5time}, false)
ScriptLib.SetGroupTempValue(context,"watcher_5_countdown",1,{})
end
--watcher 6
if ScriptLib.GetGroupTempValue(context,"watcher_6_countdown",{}) == 1 then
ScriptLib.SetGroupTempValue(context,"watcher_6_complete",1,{})
else
ScriptLib.InitTimeAxis(context, "watcher_6_countdown", {watcher6time}, false)
ScriptLib.SetGroupTempValue(context,"watcher_6_countdown",1,{})
end
return 0
end
function SLC_MiniOsial_CARD_3(context)
ScriptLib.PrintContextLog(context,"SLC_MiniOsial_CARD_3[context.uid] = " .. context.uid)
ScriptLib.AddExhibitionReplaceableData(context,context.uid,"Activity_MiniOsial_CARD_3",1) --[[card3]]
ScriptLib.PrintContextLog(context,context.uid.. ":card3")
return 0
end
--[[ function SLC_MiniOsial_CARD_4(context)
ScriptLib.PrintContextLog(context,"SLC_MiniOsial_CARD_4[context.uid] = " .. context.uid)
ScriptLib.AddExhibitionReplaceableData(context,context.uid,"Activity_MiniOsial_CARD_4",1)
return 0
end ]]
--==========================================通用初始化:
function Initialize()
--加触发器
for k,v in pairs(temp_Tirgger) do
v.name = k..""
v.config_id = 9000000 + k
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
--加变量
for k,v in pairs(temp_Variables) do
table.insert(variables,v)
end
return 0
end
Initialize()

View File

@@ -0,0 +1,9 @@
--用于处理怪物脱战后的处理需要通知group重置。
function SLC_CombatEnd(context)
local g_id = ScriptLib.GetContextGroupId(context)
ScriptLib.RefreshGroup(context, {group_id = g_id, suite = 1})
return 0
end

View File

@@ -0,0 +1,46 @@
-- 基础框架
-- GroupLoad时触发
-- 将挂载Group以GroupRefresh的方式刷新同时修改其等级
-- 向Team传值当前关卡的部分数据
local tempTrigger = {
{ config_id = 2330001, name = "GroupLoad", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_GroupLoad", trigger_count = 0 },
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
for i = 1,#suites do
table.insert(suites[i].triggers, v.name)
end
end
return 0
end
--------事件函数----------
-- 装载Group时处理
function action_GroupLoad(context, evt)
-- 从服务器获取等级
local thisGroup = ScriptLib.GetContextGroupId(context)
local vector = ScriptLib.GetPotionDungeonAffixParams(context)
if vector == nil or #vector < 2 then
ScriptLib.PrintContextLog(context, "## vector不合法加载失败")
return -1
end
local targetUpLevel = vector[2]
local enterDungeonNum = vector[1]
ScriptLib.PrintContextLog(context, "## 魔药学地城加载触发:当前地城数第"..enterDungeonNum.."次。地城上手等级为" ..targetUpLevel.."")
-- 将挂载Group以GroupRefresh的方式刷新同时修改其等级
-- 如果targetUpLevel = 0 要跳过
if targetUpLevel>0 then
ScriptLib.RefreshGroup(context, { group_id = thisGroup, suite = 1, refresh_level_revise = targetUpLevel })
ScriptLib.PrintContextLog(context, "## 魔药学地城刷新对应Group成功")
end
-- 向Team传值当前关卡的部分数据
local uidList = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamServerGlobalValue(context, uidList[1], "SGV_EnterDungeonNum", enterDungeonNum)
return 0
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_4] ---

View File

@@ -0,0 +1,212 @@
local Debris_ID = 70800060
local Debris_Option_ID = 68
local temp_Variables = {
{ config_id=50000001,name = "GalleryStart", value = 0, no_refresh = false },
{ config_id=50000002,name = "GalleryFinish", value = 0, no_refresh = false },
{ config_id=50000003,name = "Try_Add_Box", value = 0, no_refresh = false },
{ config_id=50000004,name = "ADD_Gallery_monster_count", value = 0, no_refresh = false },
{ config_id=50000005,name = "ADD_Gallery_box_count", value = 0, no_refresh = false },
{ config_id=50000006,name = "Gallery_fail_reason", value = 0, no_refresh = false },
{ config_id=50000007,name = "GalleryStart_Success", value = 0, no_refresh = false },
{ config_id=50000008,name = "GalleryEnd", value = 0, no_refresh = false },
}
local temp_Tirgger = {
{event = EventType.EVENT_VARIABLE_CHANGE, source = "Try_Start_Challenge", condition = "", action = "action_Try_Start_Challenge",trigger_count = 0},
{event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION",trigger_count = 0},
{event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_EVENT_GADGET_CREATE",trigger_count = 0},
{event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_EVENT_VARIABLE_CHANGE",trigger_count = 0},
{event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_EVENT_GALLERY_STOP",trigger_count = 0},
{event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD",trigger_count = 0},
{event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_EVENT_GROUP_WILL_UNLOAD",trigger_count = 0},
}
function action_EVENT_GROUP_WILL_UNLOAD(context,evt)
LF_SetReason_UpdateParamTable_StopGallery(context,4)
ScriptLib.SetGroupVariableValue(context,"GalleryEnd",1)
return 0
end
function action_EVENT_GROUP_LOAD(context,evt)
ScriptLib.PrintContextLog(context,"action_EVENT_GROUP_LOAD")
--初始化变量
ScriptLib.SetGroupVariableValue(context,"GalleryStart_Success",0)
ScriptLib.SetGroupVariableValue(context,"GalleryStart",0)
ScriptLib.SetGroupVariableValue(context,"GalleryEnd",0)
return 0
end
function action_EVENT_GALLERY_STOP(context,evt)
ScriptLib.PrintContextLog(context,"action_EVENT_GALLERY_STOP[is_fail]="..evt.param2.."[reason]="..evt.param3)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context,"action_EVENT_GALLERY_STOP[uid_list[1]]="..uid_list[1])
local group_id = ScriptLib.GetContextGroupId(context)
ScriptLib.RefreshGroup(context, {group_id = group_id, suite = 1})
ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid_list[1]}, "Try_Reset_Box", 1)
return 0
end
function action_EVENT_VARIABLE_CHANGE(context,evt)
if evt.source_name == "GalleryStart" and evt.param1 == 1 then
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid_list[1]}, "Try_Mark_Skiff", 1) --向team发消息等SLC
end
if evt.source_name == "GalleryFinish" then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
if evt.source_name == "Try_Add_Box" then
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid_list[1]}, "Try_Add_Box", 1)
end
if evt.source_name == "ADD_Gallery_box_count" then
LF_AddBox_UpdateParamTable(context)
end
if evt.source_name == "ADD_Gallery_monster_count" then
LF_AddMonster_UpdateParamTable(context)
end
if evt.source_name == "Gallery_fail_reason" then
LF_SetReason_UpdateParamTable_StopGallery(context,evt.param1)
ScriptLib.SetGroupVariableValue(context,"GalleryEnd",1)
end
return 0
end
function action_EVENT_GADGET_CREATE(context,evt)
ScriptLib.PrintContextLog(context,"fuc[action_EVENT_GADGET_CREATE]1")
if evt.param2 ~= Debris_ID then return 0 end
ScriptLib.SetWorktopOptionsByGroupId(context, ScriptLib.GetContextGroupId(context), evt.param1, {Debris_Option_ID})
return 0
end
function action_EVENT_SELECT_OPTION(context,evt)
ScriptLib.PrintContextLog(context,"fuc[action_EVENT_SELECT_OPTION]")
if ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid) ~= Debris_ID then return 0 end --判断是否箱子
ScriptLib.PrintContextLog(context,"fuc[action_EVENT_SELECT_OPTION]suc")
--移除箱子
local group_id = ScriptLib.GetContextGroupId(context)
ScriptLib.DelWorktopOptionByGroupId(context, group_id, evt.param1, Debris_Option_ID)
ScriptLib.SetGroupGadgetStateByConfigId(context, group_id, evt.param1, 202)
return 0
end
function action_Try_Start_Challenge(context,evt)
ScriptLib.PrintContextLog(context,"fuc[action_Try_Start_Challenge]")
local uid = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid[1]}, "Try_Start_Challenge", 1)
return 0
end
function SLC_Skiff_Die(context)
ScriptLib.PrintContextLog(context,"fuc[SLC_Skiff_Die]")
LF_SetReason_UpdateParamTable_StopGallery(context,2)
ScriptLib.SetGroupVariableValue(context,"Gallery_fail_reason",2)
return 0
end
function SLC_Mark_Skiff_Suc(context)
ScriptLib.PrintContextLog(context,"fuc[SLC_Mark_Skiff_Suc]context.uid="..context.uid)
if ScriptLib.GetGroupVariableValue(context,"GalleryStart") == 1 then
--开始玩法重置paramtable
ScriptLib.SetGroupTempValue(context,"ParamTable_monster_count",0,{})
ScriptLib.SetGroupTempValue(context,"ParamTable_box_count",0,{})
ScriptLib.SetGroupTempValue(context,"ParamTable_fail_reason",0,{})
ScriptLib.SetPlayerStartGallery(context, defs.gallery_id,{context.uid})
LF_UpdateParamTable(context)
ScriptLib.SetGroupVariableValue(context, "GalleryStart_Success", 1)
ScriptLib.SetGroupVariableValue(context,"GalleryStart",0)
end
return 0
end
function SLC_Mark_Skiff_Fail(context)
ScriptLib.PrintContextLog(context,"fuc[SLC_Mark_Skiff_Fail]")
ScriptLib.SetGroupVariableValue(context,"GalleryStart",0)
return 0
end
--专项补丁:开始
--【【11.25修复】【2.4】【飞彩镌流年】押送挑战 性能较差的设备,开启挑战后怪物会比竹筏先创建】
--https://www.tapd.cn/22963631/bugtrace/bugs/view/1122963631001308277
--通过竹筏在客户端成功创建后进行ServerLuaCall来通知lua侧创建怪物
function SLC_Raft_Created(context)
local cfgid = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
ScriptLib.PrintContextLog(context,"fuc[SLC_Raft_Created] | cfgid = " .. cfgid)
if Raft_Monster_List ~= nil then
for k , v in pairs(Raft_Monster_List) do
if k == cfgid then
for i = 1 , #v do
ScriptLib.CreateMonster(context, {config_id = v[i], delay_time = 0})
end
end
end
end
return 0
end
function Set_Raft_SGV()
--使玩法内的竹筏自带sgv防止非玩法布设的竹筏也进行SLC
if Raft_Monster_List ~= nil then
for k,v in pairs(Raft_Monster_List) do
for k2,v2 in pairs(gadgets) do
if v2.config_id == k then
v2.server_global_value_config = {["SGV_Need_SLC"]= 1}
end
end
end
end
return 0
end
Set_Raft_SGV()
--专项补丁:结束
function LF_SetReason_UpdateParamTable_StopGallery(context,v)
ScriptLib.SetGroupTempValue(context,"ParamTable_fail_reason",v,{})
LF_UpdateParamTable(context)
ScriptLib.StopGallery(context, defs.gallery_id, true)
return 0
end
function LF_AddBox_UpdateParamTable(context)
local v = ScriptLib.GetGroupTempValue(context,"ParamTable_box_count",{})
v = v + 1
ScriptLib.SetGroupTempValue(context,"ParamTable_box_count",v,{})
LF_UpdateParamTable(context)
return 0
end
function LF_AddMonster_UpdateParamTable(context)
local v = ScriptLib.GetGroupTempValue(context,"ParamTable_monster_count",{})
v = v + 1
ScriptLib.SetGroupTempValue(context,"ParamTable_monster_count",v,{})
LF_UpdateParamTable(context)
return 0
end
function LF_UpdateParamTable(context)
local uid_list = ScriptLib.GetSceneUidList(context)
local monster_count = ScriptLib.GetGroupTempValue(context,"ParamTable_monster_count",{})
local box_count = ScriptLib.GetGroupTempValue(context,"ParamTable_box_count",{})
local fail_reason = ScriptLib.GetGroupTempValue(context,"ParamTable_fail_reason",{})
local paramTable = {
["uid"]=uid_list[1],
["monster_count"]=monster_count,
["box_count"]=box_count,
["fail_reason"]=fail_reason,
["monster_count_max"]=defs.monsterTarget,
["box_count_max"]=defs.debrisTarget,
}
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, paramTable)
return 0
end
function Initialize()
--加触发器
for k,v in pairs(temp_Tirgger) do
v.name = k..""
v.config_id = 9000000 + k
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
--加变量
for k,v in pairs(temp_Variables) do
table.insert(variables,v)
end
return 0
end
Initialize()

View File

@@ -0,0 +1,165 @@
--score_per_monster_count = 100, --LD配置
--score_per_distance = 1, --LD配置
--gallery_id = 14001, --LD配置
local paramTable_temp={
distance = 0,
monster_count = 0,
final_score = 0,
fail_reason = 0, --[[0无原因 1挑战成功 2气球抵达终点 3主动放弃 4离开区域 5团灭 6离气球太远]]
}
local temp_Variables = {
{ config_id=50000001,name = "GalleryStart", value = 0, no_refresh = false },
{ config_id=50000002,name = "GalleryFinish", value = 0, no_refresh = false },
{ config_id=50000003,name = "ADD_Gallery_monster_count", value = 0, no_refresh = false },
{ config_id=50000004,name = "Gallery_fail_reason", value = 0, no_refresh = false },
{ config_id=50000005,name = "GalleryStart_Success", value = 0, no_refresh = false },
}
local temp_Tirgger = {
{event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_EVENT_VARIABLE_CHANGE",trigger_count = 0},
{event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_EVENT_GALLERY_STOP",trigger_count = 0},
{event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD",trigger_count = 0},
{event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_EVENT_GROUP_WILL_UNLOAD",trigger_count = 0},
}
function action_EVENT_GROUP_WILL_UNLOAD(context,evt)
ScriptLib.SetGroupTempValue(context,"fail_reason",3,{})
LF_updateScore(context)
ScriptLib.StopGallery(context, defs.gallery_id, true)
return 0
end
function action_EVENT_GROUP_LOAD(context,evt)
ScriptLib.PrintContextLog(context,"action_EVENT_GROUP_LOAD")
--初始化变量
ScriptLib.SetGroupVariableValue(context,"GalleryStart_Success",0)
ScriptLib.SetGroupVariableValue(context,"GalleryStart",0)
return 0
end
function action_EVENT_VARIABLE_CHANGE(context,evt)
if evt.source_name == "Gallery_fail_reason" then
ScriptLib.SetGroupTempValue(context,"fail_reason",evt.param1,{})
LF_updateScore(context)
ScriptLib.StopGallery(context, defs.gallery_id, true)
elseif evt.source_name == "GalleryStart" and evt.param1 == 1 then
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid_list[1]}, "Try_Detect_Skiff", 1) --向team发消息等SLC
--[[ ScriptLib.SetPlayerStartGallery(context, defs.gallery_id,{uid_list[1]})
ScriptLib.SetGroupTempValue(context,"distance",0,{})
ScriptLib.SetGroupTempValue(context,"monster_count",0,{})
ScriptLib.SetGroupTempValue(context,"final_score",0,{})
ScriptLib.SetGroupTempValue(context,"fail_reason",0,{}) ]]
elseif evt.source_name == "GalleryFinish" then
LF_updateScore(context)
ScriptLib.StopGallery(context, defs.gallery_id, false)
elseif evt.source_name == "ADD_Gallery_monster_count" then
ScriptLib.SetGroupTempValue(context,"monster_count", evt.param1 + ScriptLib.GetGroupTempValue(context,"monster_count",{}),{})
LF_updateScore(context)
end
return 0
end
function action_EVENT_GALLERY_STOP(context,evt)
ScriptLib.PrintContextLog(context,"action_EVENT_GALLERY_STOP[is_fail]="..evt.param2.."[reason]="..evt.param3)
local group_id = ScriptLib.GetContextGroupId(context)
ScriptLib.RefreshGroup(context, {group_id = group_id, suite = 1})
return 0
end
function LF_calculateScore(context)
local fs = ScriptLib.GetGroupTempValue(context,"distance",{}) * defs.score_per_distance + ScriptLib.GetGroupTempValue(context,"monster_count",{}) * defs.score_per_monster_count
ScriptLib.SetGroupTempValue(context,"final_score",fs,{})
return 0
end
function LF_updateScore(context)
local l_monster_count = ScriptLib.GetGroupTempValue(context,"monster_count",{})
local l_fail_reason = ScriptLib.GetGroupTempValue(context,"fail_reason",{})
ScriptLib.PrintContextLog(context,"LF_updateScore[monster_count]="..l_monster_count.."[fail_resion]="..l_fail_reason)
uid = ScriptLib.GetSceneUidList(context)
local paramTable = {
["uid"]=uid[1],
["monster_count"]=l_monster_count,
["fail_reason"]=l_fail_reason,
}
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, paramTable)
return 0
end
--以下为SLC
function SLC_Mark_Skiff_Suc(context)
ScriptLib.PrintContextLog(context,"fuc[SLC_Mark_Skiff_Suc]context.uid="..context.uid)
if ScriptLib.GetGroupVariableValue(context,"GalleryStart") == 1 then
--开始玩法重置计分tempValue
ScriptLib.SetPlayerStartGallery(context, defs.gallery_id,{context.uid})
ScriptLib.SetGroupTempValue(context,"distance",0,{})
ScriptLib.SetGroupTempValue(context,"monster_count",0,{})
ScriptLib.SetGroupTempValue(context,"final_score",0,{})
ScriptLib.SetGroupTempValue(context,"fail_reason",0,{})
--通知LD 玩法启动成功
ScriptLib.SetGroupVariableValue(context, "GalleryStart_Success", 1)
ScriptLib.SetGroupVariableValue(context,"GalleryStart",0)
end
return 0
end
function SLC_Mark_Skiff_Fail(context)
ScriptLib.PrintContextLog(context,"fuc[SLC_Mark_Skiff_Fail]")
ScriptLib.SetGroupVariableValue(context,"GalleryStart",0)
return 0
end
--专项补丁:开始
--【【11.25修复】【2.4】【飞彩镌流年】打气球挑战 性能较差的设备,开启挑战后怪物会比竹筏先创建】
--https://www.tapd.cn/22963631/bugtrace/bugs/view/1122963631001308274
--通过竹筏在客户端成功创建后进行ServerLuaCall来通知lua侧创建怪物
function SLC_Raft_Created(context)
local cfgid = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
ScriptLib.PrintContextLog(context,"fuc[SLC_Raft_Created] | cfgid = " .. cfgid)
if Raft_Monster_List ~= nil then
for k , v in pairs(Raft_Monster_List) do
if k == cfgid then
for i = 1 , #v do
ScriptLib.CreateMonster(context, {config_id = v[i], delay_time = 0})
end
end
end
end
return 0
end
function Set_Raft_SGV()
--使玩法内的竹筏自带sgv防止非玩法布设的竹筏也进行SLC
if Raft_Monster_List ~= nil then
for k,v in pairs(Raft_Monster_List) do
for k2,v2 in pairs(gadgets) do
if v2.config_id == k then
v2.server_global_value_config = {["SGV_Need_SLC"]= 1}
end
end
end
end
return 0
end
Set_Raft_SGV()
--专项补丁:结束
function Initialize()
--加触发器
for k,v in pairs(temp_Tirgger) do
v.name = k..""
v.config_id = 9000000 + k
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
--加变量
for k,v in pairs(temp_Variables) do
table.insert(variables,v)
end
return 0
end
Initialize()

View File

@@ -0,0 +1,53 @@
--用于管理所有海灯节活动group防止开启两个挑战。
--原则上不需要在玩法requir里增加任何代码只在该requir里监听但challenge的开启没法监听所以在Firecracker处有一行调用。
local temp_Tirgger2 = {
--正式trigger
{event = EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_Start",trigger_count = 0},
{event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_End",trigger_count = 0},
{event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_End",trigger_count = 0},
{event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_End",trigger_count = 0},
{event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_ChallengeManager_GROUP_WILL_UNLOAD",trigger_count = 0},
}
function action_Start(context,evt)
SeaLamp_Challenge_Manager_Start(context)
return 0
end
function action_End(context,evt)
SeaLamp_Challenge_Manager_End(context)
return 0
end
function action_ChallengeManager_GROUP_WILL_UNLOAD(context,evt)
ScriptLib.PrintContextLog(context,"action_ChallengeManager_GROUP_WILL_UNLOAD") --“Is_In_Gameplay”为group内tempValue记录是不是开了本group的玩法
if ScriptLib.GetGroupTempValue(context,"Is_In_Gameplay",{}) == 1 then --卸载前判断如果本group是开玩法的就关标记
ScriptLib.SetLanternRiteValue(context,0)
end
return 0
end
function SeaLamp_Challenge_Manager_Start(context)
ScriptLib.PrintContextLog(context,"SeaLamp_Challenge_Manager_Start") --开标记
ScriptLib.SetLanternRiteValue(context,1)
ScriptLib.SetGroupTempValue(context,"Is_In_Gameplay",1,{})
return 0
end
function SeaLamp_Challenge_Manager_End(context)
ScriptLib.PrintContextLog(context,"SeaLamp_Challenge_Manager_End") --关标记
ScriptLib.SetLanternRiteValue(context,0)
ScriptLib.SetGroupTempValue(context,"Is_In_Gameplay",0,{})
return 0
end
function Initialize2()
--加触发器
for k,v in pairs(temp_Tirgger2) do
v.name = "SeaLamp_Challenge_Manager_"..k
v.config_id = 8000000 + k
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
Initialize2()

View File

@@ -0,0 +1,287 @@
--2.4封印祭坛玩法
--defs = {
--}
--
----miscs
--
--SolutionList = {
-- {1,2,3,4,5},
-- {1,3,5},
-- {2,4},
-- {1,4,1}
--}
--
--Gates = {
-- 1000001,
-- 1000002,
-- 1000003,
-- 1000004,
-- 1000005
--}
----------------------------------
local Tri = {
[1] = { name = "group_load", config_id = 1500001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "gadget_state_change", config_id = 1500002, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
[3] = { name = "variable_change", config_id = 1500003, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", trigger_count = 0},
[4] = { name = "time_axis_pass", config_id = 1500004, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[5] = { name = "gadget_create", config_id = 1500005, event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0},
[6] = { name = "level_tag_change", config_id = 1500006, event = EventType.EVENT_LEVEL_TAG_CHANGE, source = "", condition = "", action = "action_level_tag_change", 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=70000001,name = "play_lock", value = 0, no_refresh = true})
--solution_state:记录当前各个解法的状态
--0 = 未开放、1 = 已开放、2 = 已完成、3 = 已领取
--solution_progress记录当前各个解法的完成进度取值为迄今为止正确的位数
for i = 1,#SolutionList do
table.insert(variables,{ config_id=71000000+i,name = "solution_state_"..i, value = 0, no_refresh = true})
table.insert(variables,{ config_id=72000000+i,name = "solution_progress_"..i, value = 0, no_refresh = true})
end
end
------------------------------------------------------------------
function action_group_load(context,evt)
LF_Reset_Play_State(context)
return 0
end
function action_gadget_create(context,evt)
if LF_Is_In_Table(context,Gates,evt.param1) then
local index = LF_Get_Index_In_Table(context,Gates,evt.param1)
LF_Reset_Gate_State(context,index)
end
return 0
end
function action_level_tag_change(context,evt)
if (evt.param2 == 1) then
LF_Reset_Play_State(context)
for i = 1,#Gates do
LF_Reset_Gate_State(context,i)
end
end
return 0
end
function action_gadget_state_change(context,evt)
local gadget = evt.param2
local gate_index = LF_Get_Index_In_Table(context,Gates,gadget)
--传送门被激活,且当前没有未被领取的奖励
if (gate_index ~= -1 and evt.param1 == 201 and not LF_Has_Unfinished_Chamber(context)) then
local uid_list = ScriptLib.GetSceneUidList(context)
local ret = ScriptLib.MoveAvatarByPointArray(context, uid_list[1], defs.pointarray_route, {6}, {speed=10}, "{\"MarkType\":2,\"IgnoreCollisionWhenEnter\":true}")
ScriptLib.PrintContextLog(context,"SealedAltar: 触发传送! 结果为 "..ret)
LF_Check_Solution(context,gate_index)
end
return 0
end
function action_variable_change(context,evt)
if (string.sub(evt.source_name,1,15) == "solution_state_") then
if evt.param1 == 3 then
LF_Reset_Play_State(context)
for i = 1,#Gates do
LF_Reset_Gate_State(context,i)
end
end
end
return 0
end
--延时处理门从101转回201的状态
function action_time_axis_pass(context,evt)
if (evt.source_name == "gate_wait_change_to_active") then
LF_Reset_Play_State(context)
for i = 1,#Gates do
LF_Reset_Gate_State(context,i)
end
end
return 0
end
------------------------------------------------------------------
------------------------玩法相关方法---------------------------
--重置玩法状态。solution进度重置
function LF_Reset_Play_State(context)
ScriptLib.PrintContextLog(context,"SealedAltar: 正在重置玩法进度状态")
for i = 1, #SolutionList do
ScriptLib.SetGroupVariableValue(context,"solution_progress_"..i,0)
end
end
--将特定门的状态重置,根据当前是否存在未领取的奖励,设置门的状态
--如果有未领取奖励将门设置到0或201根据这个门是否在未领取奖励的解法中并给门上锁
--如果没有未领取奖励则将门设置到0并给门去锁
function LF_Reset_Gate_State(context,gate_index)
ScriptLib.PrintContextLog(context,"SealedAltar: 正在重置各个门的状态")
if (LF_Has_Unfinished_Chamber(context)) then
ScriptLib.PrintContextLog(context,"SealedAltar: 存在未领取的玩法,将门设置到锁定状态")
LF_Set_Gate_Lock(context,gate_index,1)
local unfinished_chamber = LF_Get_Unfinished_Chamber(context)
local unfinished_solution = SolutionList[unfinished_chamber]
ScriptLib.PrintContextLog(context,"SealedAltar: 未领取的玩法id为"..unfinished_chamber)
--如果有未领取的chamber将该解法对应的门转到201提示玩家该门已经处于锁定的激活状态
if (LF_Is_In_Table(context,unfinished_solution,gate_index)) then
ScriptLib.PrintContextLog(context,"SealedAltar: 将门"..gate_index.."转到状态201")
ScriptLib.SetGroupGadgetStateByConfigId(context,0,Gates[gate_index],201)
end
else
ScriptLib.PrintContextLog(context,"SealedAltar: 不存在未领取的玩法,所有门和变量重置")
LF_Set_Gate_Lock(context,gate_index,0)
ScriptLib.SetGroupGadgetStateByConfigId(context,0,Gates[gate_index],0)
end
end
--输入当前触发的门index检查是否完成某个玩法
function LF_Check_Solution(context, current_index)
ScriptLib.PrintContextLog(context,"SealedAltar: -------------------------------------------")
ScriptLib.PrintContextLog(context,"SealedAltar: 当前触碰的门为 "..current_index)
ScriptLib.PrintContextLog(context,"SealedAltar: 正在检查当前解法是否匹配")
local has_correct = false
for i = 1, #SolutionList do
local target_solution = SolutionList[i]
local solution_progress = ScriptLib.GetGroupVariableValue(context,"solution_progress_"..i)
local solution_state = ScriptLib.GetGroupVariableValue(context,"solution_state_"..i)
ScriptLib.PrintContextLog(context,"SealedAltar: 目标解法"..i.." 进度为: "..solution_progress)
--玩法开启,且进度不为-1即不是已经失败的解法
if (solution_state == 1 and solution_progress ~= -1) then
local target_index = target_solution[solution_progress+1]
--当前位数匹配
if (target_index == current_index) then
--解法与当前答案匹配,进度前进,并记录进度
solution_progress = solution_progress+1
ScriptLib.SetGroupVariableValue(context,"solution_progress_"..i,solution_progress)
ScriptLib.PrintContextLog(context,"SealedAltar: 目标解法当前位数匹配")
--说明有匹配的,解答继续
has_correct = true
--如果已经匹配到了当前玩法的最终位,说明匹配成功
if (solution_progress>=#target_solution) then
ScriptLib.SetGroupVariableValue(context,"solution_state_"..i,2)
ScriptLib.PrintContextLog(context,"SealedAltar: 解法"..i.."匹配成功!!")
for i = 1,#target_solution do
local gate = Gates[target_solution[i]]
ScriptLib.SetGroupGadgetStateByConfigId(context,0,gate,101)
end
--延时重置整个玩法
ScriptLib.InitTimeAxis(context, "gate_wait_change_to_active", {5}, false)
--按照优先短匹配的原则,提前返回
return
end
else
ScriptLib.SetGroupVariableValue(context,"solution_progress_"..i,-1)
end
end
end
--当前已经没有匹配的解法了,玩法重置
if (not has_correct) then
ScriptLib.PrintContextLog(context,"SealedAltar: 当前解法全部匹配失败!!")
LF_Reset_Play_State(context)
for i = 1,#Gates do
LF_Reset_Gate_State(context,i)
end
end
ScriptLib.PrintContextLog(context,"SealedAltar: -------------------------------------------")
end
--对index的门上锁上锁了以后进入门不再触发状态变化gadget层
--lock_state = 1上锁 lock_state = 0开锁
function LF_Set_Gate_Lock(context,gate_index,lock_state)
ScriptLib.PrintContextLog(context,"SealedAltar: 将门"..gate_index.."设置为"..lock_state.."状态")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, Gates[gate_index], "SGV_Lock" ,lock_state)
end
--检查是否有solution_state处于状态2即玩法解开但奖励未领取
function LF_Has_Unfinished_Chamber(context)
for i = 1, #SolutionList do
local solution_state = ScriptLib.GetGroupVariableValue(context,"solution_state_"..i)
if (solution_state == 2) then
return true
end
end
return false
end
--返回Solution_state处于状态2的解法id。如果没有返回-1
function LF_Get_Unfinished_Chamber(context)
for i = 1, #SolutionList do
local solution_state = ScriptLib.GetGroupVariableValue(context,"solution_state_"..i)
if (solution_state == 2) then
return i
end
end
return -1
end
------------------------------------------------------------------
--------------------工具方法--------------------------------------
--打印table的方法用于debug
function LF_Print_Table(context,table_name,table)
ScriptLib.PrintContextLog(context,"WallMaze: ------------------------------")
ScriptLib.PrintContextLog(context,"WallMaze: 输出表 "..table_name.." 的元素 ")
for i = 1,#table do
ScriptLib.PrintContextLog(context,"WallMaze: "..table_name.."["..i.."] = "..table[i])
end
ScriptLib.PrintContextLog(context,"WallMaze: ------------------------------")
end
--判断元素是否属于表
function LF_Is_In_Table(context,t,key)
for i = 1,#t do
if (t[i] == key) then
return true
end
end
return false
end
--获取元素在表中的index
function LF_Get_Index_In_Table(context,t,key)
for i = 1,#t do
if (t[i] == key) then
return i
end
end
return -1
end
--从表中start位置开始截取子表包含start
function LF_Get_Table_Tail(context,t,start)
local tail = {}
for i = start,#t do
table.insert(tail,t[i])
end
return tail
end
------------------------------------------------------------------
Initialize()

View File

@@ -0,0 +1,537 @@
--2.4墙壁迷宫玩法
--miscs
--ControllerWallMap =
--{
-- {defs.gadget_controller_1,
-- {
-- {defs.gadget_wall_1,{2,7,12}},
-- {defs.gadget_wall_2,{1,6,11}}
-- }
-- },
-- {defs.gadget_controller_2,
-- {
-- {defs.gadget_wall_1,{12,7,2}},
-- {defs.gadget_wall_2,{11,6,1}}
-- }
-- },
-- {defs.gadget_controller_3,
-- {
-- {defs.gadget_wall_3,{8,9,10}},
-- {defs.gadget_wall_4,{3,4,5}}
-- }
-- },
-- {defs.gadget_controller_4,
-- {
-- {defs.gadget_wall_3,{10,9,8}},
-- {defs.gadget_wall_4,{5,4,3}}
-- }
-- }
--}
--
----初始wall+blocker表把所有的wall和block都填入
--StartWallMap =
--{
-- {defs.gadget_wall_1, 4},
-- {defs.gadget_wall_2, 6},
-- {defs.gadget_wall_3, 7},
-- {defs.gadget_wall_4, 9},
--}
--
--StartBlockerMap =
--{
-- {defs.blocker_1,1,201},
-- {defs.blocker_2,12,201}
--}
----------------------------------
local Tri = {
[1] = { name = "group_load_wall_maze", config_id = 1500001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "gadget_state_change_wall_maze", config_id = 1500002, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0},
[3] = { name = "platform_reach_point_wall_maze", config_id = 1500003, event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_platform_reach_point", trigger_count = 0},
[4] = { name = "time_axis_pass_maze", config_id = 1500004, event = EventType.EVENT_TIME_AXIS_PASS, source = "move_delay", condition = "", action = "action_time_axis_pass", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
end
for i = 1, #suites do
for k,v in pairs(Tri) do
table.insert(suites[i].triggers, v.name)
end
end
--记录每个wall和block位置的var形式为wall_i
for i = 1,#StartWallMap do
table.insert(variables,{ config_id=61000000+i,name = "wall_"..i, value = 0})
end
for i = 1,#StartBlockerMap do
table.insert(variables,{ config_id=62000000+i,name = "blocker_"..i, value = 0})
end
if (SpecialBlockerMap ~= nil) then
for i = 1,#SpecialBlockerMap do
for j = 1,#SpecialBlockerMap[i] do
table.insert(variables,{ config_id=63000000+1000*i+j,name = "special_blocker_"..i.."_"..j, value = 0})
end
end
end
table.insert(variables,{ config_id=64000001,name = "is_moving", value = 0, no_refresh = true})
table.insert(variables,{ config_id=64000002,name = "has_succeeded", value = 0, no_refresh = true})
end
------------------------------------------------------------------
function action_group_load(context,evt)
--group load时会将墙的位置设置为
ScriptLib.SetGroupVariableValue(context, "has_succeeded", 0)
--group load时要把isMoving重置否则特殊情况下如果group被unload会导致玩法卡死
ScriptLib.SetGroupVariableValue(context, "is_moving", 0)
for i = 1, #StartWallMap do
local wall = StartWallMap[i][1]
local index = StartWallMap[i][2]
ScriptLib.PrintContextLog(context,"WallMaze: group加载设置墙 "..wall.." 位置: "..index)
LF_Set_Block_Point(context,wall,index,1)
end
for i = 1, #StartBlockerMap do
local blocker = StartBlockerMap[i][1]
local index = StartBlockerMap[i][2]
local block_state = StartBlockerMap[i][3]
local state = ScriptLib.GetGadgetStateByConfigId(context, 0, blocker)
if (state == block_state) then
ScriptLib.PrintContextLog(context,"WallMaze: group加载设置blocker "..blocker.." 位置: "..index)
LF_Set_Block_Point(context,blocker,index,2)
else
LF_Set_Block_Point(context,blocker,-1,2)
end
end
return 0
end
function action_gadget_state_change(context,evt)
local controller = evt.param2
local gadget_state = evt.param1
local is_moving = ScriptLib.GetGroupVariableValue(context,"is_moving")
--没有墙处于移动状态
if (is_moving ~= 1) then
--触发的是控制器
if (LF_Is_Controller(context,controller)) then
if (gadget_state == 222 or gadget_state == 322) then
ScriptLib.PrintContextLog(context,"WallMaze: 震动机关激活,开始移动墙壁")
local wall_list = LF_Get_Controller_Wall(context,controller)
local block_table = LF_Get_Block_Table(context)
block_table = LF_Pre_Move(context,block_table,wall_list)
for i = 1, #wall_list do
local path_state = LF_Get_Path_State(context,block_table,controller,wall_list[i])
local next_point = LF_Get_Next_Point(context,path_state)
if (next_point == -1) then
ScriptLib.SetGroupGadgetStateByConfigId(context,0,wall_list[i],202)
end
if (next_point ~= -1) then
ScriptLib.SetGroupGadgetStateByConfigId(context,0,wall_list[i],201)
ScriptLib.SetPlatformPointArray(context, wall_list[i], defs.pointarray_route, {next_point}, { route_type = 0,turn_mode=false })
LF_Set_Block_Point(context,wall_list[i],next_point,1)
ScriptLib.SetGroupVariableValue(context, "is_moving", 1)
ScriptLib.InitTimeAxis(context,"move_delay",{5},false)
end
end
--移动后,检查是否成功
if (TargetSolution~=nil and LF_Check_Success(context)) then
ScriptLib.PrintContextLog(context,"WallMaze: 已成功")
ScriptLib.SetGroupVariableValue(context, "has_succeeded", 1)
return 0
else
ScriptLib.PrintContextLog(context,"WallMaze: 尚未成功")
ScriptLib.SetGroupVariableValue(context, "has_succeeded", 0)
end
end
end
end
return 0
end
function action_platform_reach_point(context,evt)
local wall = evt.param1
ScriptLib.SetGroupGadgetStateByConfigId(context,0,wall,0)
ScriptLib.SetGroupVariableValue(context, "is_moving", 0)
return 0
end
function action_time_axis_pass(context,evt)
ScriptLib.SetGroupVariableValue(context, "is_moving", 0)
return 0
end
------------------------------------------------------------------
------------------------迷宫内容查询---------------------------
--检查当前状态是否成功
function LF_Check_Success(context)
local wall_pos_list = {}
for i = 1, #StartWallMap do
local wall = StartWallMap[i][1]
local wall_pos = LF_Get_Wall_Pos(context,wall)
table.insert(wall_pos_list,wall_pos)
end
for i = 1,#TargetSolution do
if (wall_pos_list[i] ~= TargetSolution[i]) then
return false
end
end
return true
end
--输入一个blockerid返回该blocker的相关信息
function LF_Get_Blocker_Info(context,blocker_id)
for i = 1,#StartBlockerMap do
if (blocker_id == StartBlockerMap[i][1])then
return StartBlockerMap[i]
end
end
end
--输入一个wallid返回该wall的相关信息
function LF_Get_Wall_Info(context,wall_id)
for i = 1,#StartWallMap do
if (wall_id == StartWallMap[i][1])then
return StartWallMap[i]
end
end
end
function LF_Get_Controller_Info(context,controller_id)
for i = 1,#ControllerWallMap do
if (controller_id == ControllerWallMap[i][1])then
return ControllerWallMap[i][2]
end
end
end
--输入一个blockerId返回其是否处于阻塞状态
function LF_Is_In_Block_State(context,blocker_id)
local state = ScriptLib.GetGadgetStateByConfigId(context,0,blocker_id)
local blocker_info = LF_Get_Blocker_Info(context,blocker_id)
return blocker_info[3] == state
end
--输入一个blockerId返回其应当阻塞的位置
function LF_Get_Blocker_Pos(context,blocker_id)
for i = 1,#StartBlockerMap do
if (StartBlockerMap[i][1] == blocker_id) then
return StartBlockerMap[i][2]
end
end
end
--输入一个wallId返回其应当阻塞的位置
function LF_Get_Wall_Pos(context,wall_id)
local wall_index = LF_Get_Wall_Index(context,wall_id)
local wall_pos = ScriptLib.GetGroupVariableValue(context,"wall_"..wall_index)
return wall_pos
end
--输入一个speicla blocker Id返回其应当阻塞的位置
function LF_Get_Speical_Blocker_Pos_List(context,blocker_id)
local blocker_index = LF_Get_Sepcial_Blocker_Index(context,blocker_id)
local pos_list = {}
if (SpecialBlockerMap ~= nil) then
for i = 1, #SpecialBlockerMap[blocker_index][2] do
local pos = ScriptLib.GetGroupVariableValue(context,"special_blocker_"..blocker_index.."_"..i)
table.insert(pos_list,pos)
end
end
return pos_list
end
--输入一个controllerId返回其控制的墙列表
function LF_Get_Controller_Wall(context,controller_id)
local controller_info = LF_Get_Controller_Info(context,controller_id)
local walls = {}
for i = 1,#controller_info do
table.insert(walls,controller_info[i][1])
end
return walls
end
--输入一个controllerId和wallId返回其这个控制器下特定墙的移动路径
function LF_Get_Controller_Wall_Path(context,controller_id,wall_id)
local controller_info = LF_Get_Controller_Info(context,controller_id)
for i = 1,#controller_info do
if (controller_info[i][1] == wall_id) then
return controller_info[i][2]
end
end
end
--输入阻塞点和阻塞类型1-墙2-阻塞物3-特殊阻塞物),将特定点阻塞
--输入阻塞点 = -1时相当于将该阻塞物移出阻塞表
function LF_Set_Block_Point(context,blocker,point,type)
--墙
if (type == 1) then
local blocker_index = LF_Get_Wall_Index(context,blocker)
ScriptLib.PrintContextLog(context,"WallMaze: 墙壁"..blocker_index.."移动到位置"..point)
ScriptLib.SetGroupVariableValue(context, "wall_"..blocker_index, point)
end
--阻塞物
if (type == 2) then
local blocker_index = LF_Get_Blocker_Index(context,blocker)
ScriptLib.PrintContextLog(context,"WallMaze: 障碍物"..blocker_index.."在位置"..point.."进入阻挡状态")
ScriptLib.SetGroupVariableValue(context, "blocker_"..blocker_index, point)
end
if (type == 3) then
local blocker_index = LF_Get_Special_Blocker_Index(context,blocker)
for i = 1,#point do
ScriptLib.PrintContextLog(context,"WallMaze: 特殊障碍物"..blocker_index.."在位置"..point.."进入阻挡状态")
ScriptLib.SetGroupVariableValue(context, "special_blocker_"..blocker_index.."_"..i, point[i])
end
end
end
--输入一个路径点,返回该位置是否被阻塞
function LF_Is_Blocked(context,point)
local block_table = LF_Get_Block_Table(context)
return block_table[point] ~= 0
end
--输入一个blocker和想要将其设置的gadget state查询是否允许这样设置
function LF_Can_Block_State_Change(context,blocker,target_gadget_state)
local blocker_info = LF_Get_Blocker_Info(context,blocker)
local block_pos = LF_Get_Blocker_Pos(context,blocker)
local is_blocked = LF_Is_Blocked(context,block_pos)
if (not is_blocked) then
return true
else
if (target_gadget_state == blocker_info[3]) then
--尝试堵上
return false
else
--尝试撤销阻塞
return true
end
end
end
function LF_Set_Block_After_State_Change(context,blocker,target_gadge_state)
if (LF_Is_Blocker(context,blocker)) then
ScriptLib.PrintContextLog(context,"WallMaze: 障碍物状态变化")
local blocker_info = LF_Get_Blocker_Info(context,blocker)
--障碍物被转到阻塞状态
if (blocker_info[3] == target_gadge_state) then
ScriptLib.PrintContextLog(context,"WallMaze: 进入阻挡状态")
local pos = LF_Get_Blocker_Pos(context,blocker)
ScriptLib.PrintContextLog(context,"WallMaze: 即将阻塞的位置为"..pos)
LF_Set_Block_Point(context,blocker,pos,2)
--障碍物离开阻塞状态
else
ScriptLib.PrintContextLog(context,"WallMaze: 离开阻挡状态")
local pos = LF_Get_Blocker_Pos(context,blocker)
ScriptLib.PrintContextLog(context,"WallMaze: 离开阻塞的位置为"..pos)
LF_Set_Block_Point(context,blocker,-1,2)
end
end
end
------------------------------------------------------------------
--------------------墙壁移动算法--------------------------------------
--计算当前的block table
--其中0为可通行1为墙壁阻塞2为障碍物阻塞3为特殊障碍物阻塞
function LF_Get_Block_Table(context)
ScriptLib.PrintContextLog(context,"WallMaze 计算BlockTable……")
local Block_Table = {}
for i = 1, MaxSize do
table.insert(Block_Table,0)
end
for i = 1,#StartWallMap do
local wall_pos = LF_Get_Wall_Pos(context,StartWallMap[i][1])
Block_Table[wall_pos] = 1
end
for i = 1,#StartBlockerMap do
local blocker_pos = LF_Get_Blocker_Pos(context,StartBlockerMap[i][1])
if (LF_Is_In_Block_State(context,StartBlockerMap[i][1])) then
Block_Table[blocker_pos] = 2
end
end
if (SpecialBlockerMap ~= nil) then
for i = 1,#SpecialBlockerMap do
local special_block_pos_list = LF_Get_Speical_Blocker_Pos_List(context,SpecialBlockerMap[i])
for j = 1,#special_block_pos_list do
Block_Table[special_block_pos_list[j]] = 3
end
end
end
LF_Print_Table(context,"Block table", Block_Table)
return Block_Table
end
--移动计算前预处理将将要移动的墙壁移出block table
function LF_Pre_Move(context,block_table,wall_list)
ScriptLib.PrintContextLog(context,"WallMaze 计算PreMoveBlockTable……")
local pre_move_block_table = block_table
for i = 1, #wall_list do
local wall_pos = LF_Get_Wall_Pos(context,wall_list[i])
pre_move_block_table[wall_pos] = 0
end
LF_Print_Table(context,"Pre Move Block table", pre_move_block_table)
return pre_move_block_table
end
--获得特定墙壁当前的路径状态
function LF_Get_Path_State(context,block_table,controller,wall)
ScriptLib.PrintContextLog(context,"WallMaze 计算"..wall.."的path_state……")
local path = LF_Get_Controller_Wall_Path(context,controller,wall)
local path_state = {}
local wall_pos = LF_Get_Wall_Pos(context,wall)
local index = LF_Get_Index_In_Table(context,path,wall_pos)
for i = index+1, #path do
local state_vec = {}
table.insert(state_vec,path[i])
table.insert(state_vec,block_table[path[i]])
table.insert(path_state,state_vec)
LF_Print_Table(context,"path state vec"..i, state_vec)
end
return path_state
end
--输入一个path_state返回下一个可通行的点。如果没有则返回-1
function LF_Get_Next_Point(context,path_state)
if (#path_state == 0) then
return -1
end
if (path_state[1][2] == 0) then
ScriptLib.PrintContextLog(context,"WallMaze: 下一个移动的目标点为"..path_state[1][1])
return path_state[1][1]
else
ScriptLib.PrintContextLog(context,"WallMaze: 完全阻塞,无法移动")
return -1
end
end
------------------------------------------------------------------
--------------------工具方法--------------------------------------
--输入一个table返回其是一个描述wall的table还是一个描述blocker的table
function LF_Is_Wall_Data(context,t)
return #t == 2
end
--打印table的方法用于debug
function LF_Print_Table(context,table_name,table)
ScriptLib.PrintContextLog(context,"WallMaze: ------------------------------")
ScriptLib.PrintContextLog(context,"WallMaze: 输出表 "..table_name.." 的元素 ")
for i = 1,#table do
ScriptLib.PrintContextLog(context,"WallMaze: "..table_name.."["..i.."] = "..table[i])
end
ScriptLib.PrintContextLog(context,"WallMaze: ------------------------------")
end
--判断元素是否属于表
function LF_Is_In_Table(context,t,key)
for i = 1,#t do
if (t[i] == key) then
return true
end
end
return false
end
--获取元素在表中的index
function LF_Get_Index_In_Table(context,t,key)
for i = 1,#t do
if (t[i] == key) then
return i
end
end
return -1
end
--从表中start位置开始截取子表包含start
function LF_Get_Table_Tail(context,t,start)
local tail = {}
for i = start,#t do
table.insert(tail,t[i])
end
return tail
end
--判断一个gadget是否为控制器
function LF_Is_Controller(context,gadget)
for i = 1,#ControllerWallMap do
if (gadget == ControllerWallMap[i][1]) then
return true
end
end
return false
end
--判断一个gadget是否为blocker
function LF_Is_Blocker(context,gadget)
for i = 1,#StartBlockerMap do
if (gadget == StartBlockerMap[i][1]) then
return true
end
end
return false
end
function LF_Get_Wall_Index(context,wall)
for i = 1,#StartWallMap do
if (wall == StartWallMap[i][1]) then
return i
end
end
return -1
end
function LF_Get_Blocker_Index(context,blocker)
for i = 1,#StartBlockerMap do
if (blocker == StartBlockerMap[i][1]) then
return i
end
end
return -1
end
function LF_Get_Special_Blocker_Index(context,blocker)
local ret = {}
if (SpecialBlockerMap ~= nil) then
for i = 1,#SpecialBlockerMap do
if (blocker == SpecialBlockerMap[i][1]) then
return i
end
end
end
end
------------------------------------------------------------------
Initialize()