添加配置表

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
@@ -0,0 +1,77 @@
--[[
local defs = {
RegionID = 575001
}
--]]
-----------------------------------------
local tempTrigger = {
{ config_id = 2330000, name = "LEAVE_REGION_Arena", event = EventType.EVENT_LEAVE_REGION, source = "1",
condition = "", action = "action_LEAVE_REGION_Arena", trigger_count = 0},
{ config_id = 2330001, name = "ENTER_REGION_Arena", event = EventType.EVENT_ENTER_REGION, source = "1",
condition = "", action = "action_ENTER_REGION_Arena", trigger_count = 0},
{ config_id = 2330002, name = "GROUP_WILL_UNLOAD", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "",
condition = "", action = "action_GROUP_WILL_UNLOAD", trigger_count = 0 }
}
function action_GROUP_WILL_UNLOAD(context, evt)
ScriptLib.PrintContextLog(context, "action_Group_Will_Unload")
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.REGION, defs.RegionID)
return 0
end
function action_LEAVE_REGION_Arena(context, evt)
ScriptLib.PrintContextLog(context, "action_LEAVE_REGION_Arena")
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
ScriptLib.ClearPlayerEyePoint(context, defs.RegionID)
return 0
end
-- 触发操作
function action_ENTER_REGION_Arena(context, evt)
ScriptLib.PrintContextLog(context, "@@ ENTER_REGION_Arena")
TrySetPlayerEyePoint(context,regions[defs.RegionID],regions[defs.RegionID],1,{0})
return 0
end
--此方法在两个region坐标接近时调用比较合适
function TrySetPlayerEyePoint(context, small_region, big_region, opt_type, vision_type_list)
--opt_type为1表示需要setVisionType
local eid = ScriptLib.GetAvatarEntityIdByUid(context, context.uid)
local player_pos = ScriptLib.GetPosByEntityId(context, eid)
--在小圈内要处理入圈
if Is_In_Region(player_pos, small_region) == true then
ScriptLib.SetPlayerEyePoint(context, small_region.config_id, big_region.config_id)
if opt_type == 1 then
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, vision_type_list)
end
end
end
function Is_In_Region(pos1, region)
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
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Level()
@@ -0,0 +1,56 @@
--[[
local defs = {
RegionID = 575001
}
--]]
-----------------------------------------
local extraTriggers = {
{config_id = 9000001, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", forbid_guest = false,trigger_count = 0 },
{config_id = 9000002,name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
}
function Initialize_Group()
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--初始化
end
function action_EVENT_ENTER_REGION(context, evt)
if evt.param1~=defs.RegionID then
return 0
end
--设置视野锚点
ScriptLib.SetPlayerEyePoint(context, defs.RegionID, defs.RegionID)
ScriptLib.SetLimitOptimization(context, context.uid, true)
--环境小动物优化
ScriptLib.SwitchSceneEnvAnimal(context, 0)
--设置visiontype
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
--禁用visiontype变化
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 1, { group_id = defs.group_1})
ScriptLib.PrintContextLog(context, "## TD_Arena : Have Optimized")
return 0
end
function action_EVENT_LEAVE_REGION(context, evt)
if evt.param1~=defs.RegionID then
return 0
end
--启用visiontype变化
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 0, { group_id = defs.group_1})
--关闭视野锚点
ScriptLib.ClearPlayerEyePoint(context, defs.RegionID)
ScriptLib.SetLimitOptimization(context, context.uid, false)
--环境小动物优化
ScriptLib.SwitchSceneEnvAnimal(context, 2)
--重置visiontype
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
ScriptLib.PrintContextLog(context, "## TD_Arena : Over Optimized")
return 0
end
Initialize_Group()
--LF_Initialize_Level()
@@ -0,0 +1,27 @@
local extrTriggers = {
initialtrigger = {
["Monster_Die1"] = { config_id = 8000001, name = "Monster_Die1", event= EventType.EVENT_ANY_MONSTER_DIE, source = "Activity_EndoraGadgetSkill_BubbleTrigger", condition = "", action = "action_monster_die1", trigger_count = 0 },
["Monster_Die2"] = { config_id = 8000002, name = "Monster_Die2", event= EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_monster_die2", trigger_count = 0 }
}
}
function action_monster_die1( context,evt )
ScriptLib.AddRegionSearchProgress(context, regionsearch_region_id, 1)
return 0
end
function action_monster_die2( context,evt )
ScriptLib.AddRegionRecycleProgress(context, regionsearch_region_id, 1)
return 0
end
function LF_Initialize_Group()
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Group()
@@ -0,0 +1,761 @@
--[[
setmetatable(_ENV,{__index=function() return{} end})
local stage_def = {
[1] = {
--根据阶段创建的group,在阶段group中标记
[1] = {2,3,4,5},
[2] = {2,3,4,5},
[3] = {2,3,4,5},
[4] = {2,3,4,5}
},
[2] = {
[1] = {2,3,4,5},
[2] = {2,3,4,5},
[3] = {2,3,4,5},
[4] = {2,3,4,5}
},
[3] = {
[1] = {2,3,4,5},
[2] = {2,3,4,5},
[3] = {2,3,4,5},
[4] = {2,3,4,5}
},
}
--根据progress对应的monster_tide,配在主group中
local tide_defs = {
[1] = {
[0] = {suite={2,3,4,5},weight={20,20,20,20,20}},
[1] = {suite={2,3,4,5},weight={20,20,20,20,20}},
[2] = {suite={},weight={}},
[3] = {suite={2,3,4,5},weight={20,20,20,20,20}},
[4] = {suite={2,3,4,5},weight={20,20,20,20,20}}
},
[2] = {
[0] = {suite={2,3,4,5},weight={20,20,20,20,20}},
[1] = {suite={2,3,4,5},weight={20,20,20,20,20}},
[2] = {suite={},weight={}},
[3] = {suite={2,3,4,5},weight={20,20,20,20,20}},
[4] = {suite={2,3,4,5},weight={20,20,20,20,20}}
},
[3] = {
[0] = {suite={2,3,4,5},weight={20,20,20,20,20}},
[1] = {suite={2,3,4,5},weight={20,20,20,20,20}},
[2] = {suite={},weight={}},
[3] = {suite={2,3,4,5},weight={20,20,20,20,20}},
[4] = {suite={2,3,4,5},weight={20,20,20,20,20}}
},
}
--monster_tide的启动参数,配在主group中
local tide_suite_config = {
[2] = {total=10,min=2,max=4,next=3,delay=10},
[3] = {total=10,min=2,max=4,next=4,delay=10},
[4] = {total=10,min=2,max=4,next=5,delay=10},
[5] = {total=10,min=2,max=4,next=6,delay=10}
}
--配在及时group中
local timer_def = {
[1] = {
--根据时间创建的group
[1] = {2,3,4,5},
[2] = {2,3,4,5},
[3] = {2,3,4,5},
[4] = {2,3,4,5}
},
[2] = {
[1] = {2,3,4,5},
[2] = {2,3,4,5},
[3] = {2,3,4,5},
[4] = {2,3,4,5}
},
[3] = {
[1] = {2,3,4,5},
[2] = {2,3,4,5},
[3] = {2,3,4,5},
[4] = {2,3,4,5}
}
}
local progress_def = {
["normal"] = {0,1500,3000,4500,6500},
["hard"] = {0,1500,3000,4500,6500},
["nightmare"] = {0,1500,3000,4500,6500}
}
local defs = {
--group_main
gadget_aster = 413001,
gadget_reward = 123456,
score_ratio = {normal=1,hard=0.75,nightmare=0.5},
difficulty_weight = {normal=75,hard=20,nightmare=5},
--group_stage
--group_clear
aster_timer = {60,120,180,240,300},
clear_delay = 30
}--]]
local play = {
PlayType = 2,
PlayId = 2,
player_energy = "AVATAR_ASTER_SCORE", --global_value
radius = 10,
monster_tide = 426,
group_main = 133001413,
group_timer = 133001426,
group_stage = 133001427,
group_gadget = 133001498,
energy_str = "AVATAR_ASTER_SCORE", --uid_value
difficulty = "difficulty",
ratio_energy = {"ASTER_ENERGY_RATIO",2},
ratio_progress = {"ASTER_PROGRESS_RATIO",2},
op_radius = 10
}
local extra_triggers = {
[play.group_main] = {
--活动准备阶段
["Battle_State"] = { config_id = 8000001, name = "Battle_State", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_STATE, source = "", condition = "condition_battle_state", action = "action_battle_state", trigger_count = 0 },
--战斗结束
["Battle_Result"] = { config_id = 8000002, name = "Battle_Result", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_RESULT, source = "", condition = "", action = "action_battle_result", trigger_count = 0 },
--角色充能处理
["Monster_Die_Before_Leave_Scene"] = { config_id = 8000003, name = "Monster_Die_Before_Leave_Scene", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "condition_monster_die_before_leave_scene", action = "action_monster_die_before_leave_scene", trigger_count = 0 },
--战斗阶段响应
["Battle_State_Change"] = { config_id = 8000004, name = "Battle_State_Change", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_STAGE_CHANGE, source = "", condition = "", action = "action_battle_stage_change", trigger_count = 0 },
--怪物潮管理与切换
["Monster_Tide_Over"] = { config_id = 8000005, name = "Monster_Tide", event = EventType.EVENT_MONSTER_TIDE_OVER, source = "", condition = "", action = "action_monster_tide_over", trigger_count = 0 },
["Timer_Delay"] = { config_id = 8000006, name = "Timer_Delay", event = EventType.EVENT_TIMER_EVENT, source = "next_tide_delay", condition = "", action = "action_timer_delay", trigger_count = 0 },
["Battle_Interrupt"] = { config_id = 8000007, name = "Battle_Interrupt", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_INTERRUPT, source = "", condition = "", action = "action_battle_interrupt", trigger_count = 0},
--1.3版本修复内容
--处理1.1版本数据未清理的大陨石
["Group_Load"] = { config_id = 8000100, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 }
},
[play.group_timer] = {
--活动准备阶段
["Battle_State"] = { config_id = 8000008, name = "Battle_State", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_STATE, source = "", condition = "condition_battle_state", action = "action_battle_state", trigger_count = 0 },
--角色充能处理
["Monster_Die_Before_Leave_Scene"] = { config_id = 8000009, name = "Monster_Die_Before_Leave_Scene", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "condition_monster_die_before_leave_scene", action = "action_monster_die_before_leave_scene", trigger_count = 0 },
--战斗结束
["Battle_Result"] = { config_id = 8000010, name = "Battle_Result", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_RESULT, source = "", condition = "", action = "action_battle_result", trigger_count = 0 },
--计时处理
["Timer_Summon"] = { config_id = 8000011, name = "Timer_Summon", event = EventType.EVENT_TIMER_EVENT, source = "aster_timer", condition = "", action = "action_timer_summon", trigger_count = 0 }
},
[play.group_stage] = {
--角色充能处理
["Monster_Die_Before_Leave_Scene"] = { config_id = 8000012, name = "Monster_Die_Before_Leave_Scene", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "condition_monster_die_before_leave_scene", action = "action_monster_die_before_leave_scene", trigger_count = 0 },
--战斗结束
["Battle_Result"] = { config_id = 8000013, name = "Battle_Result", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_RESULT, source = "", condition = "", action = "action_battle_result", trigger_count = 0 },
["Any_Monster_Die"] = { config_id = 8000014, name = "Any_Monster_Die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "condition_any_monster_die", action = "action_any_monster_die", trigger_count = 0 }
}
}
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--1.3修复内容
function action_group_load(context, evt)
--1.6改为注册及之后,动态group不允许使用setDead,也不需要维持这段逻辑
--[[for i,v in ipairs(suites) do
ScriptLib.RemoveExtraGroupSuite(context, play.group_main, i)
end
ScriptLib.SetGroupDead(context, play.group_main)--]]
return 0
end
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function LF_Initialize_Group(triggers, suites, group_id)
--[[if group_id == play.group_main then
for k,v in pairs(extra_triggers[group_id]) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
else
for k,v in pairs(extra_triggers[group_id]) do
-- Triggers 是个数组,不是map
table.insert(triggers, v)
for p,q in pairs(suites) do
if p ~= init_config.suite or v.name ~= "Any_Monster_Die" then
table.insert(q.triggers, v.name)
end
end
-- 所以不能 triggers[k] = v
end
end--]]
for k,v in pairs(extra_triggers[group_id]) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
end
function UpdateAsterInterrupt(context)
local u_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(u_list) do
if v == context.uid then
ScriptLib.ScenePlayBattleUidOp(context, play.group_main, defs.gadget_aster, {v}, 0, "random_buff_aster", {}, {}, 6, 0)
return 0
end
end
end
function UpdateAsterProgress(context)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
local D = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, play.difficulty)
ratio = LF_Get_Extra_Energy_Ratio(context, host)
--获取玩家当前能量
local uid = context.uid
local energy = ScriptLib.GetTeamAbilityFloatValue(context, uid, play.energy_str)
local progress = math.ceil(energy * ratio)
--将当前能量写入uid_value
local old_progress = ScriptLib.GetScenePlayBattleUidValue(context, 0, uid, play.energy_str)
ScriptLib.PrintContextLog(context, "## uid:"..uid.." | energy:"..progress.." | old_energy:"..old_progress)
ScriptLib.SetScenePlayBattleUidValue(context, 0, uid, play.energy_str, old_progress + progress)
--通知ability可以清掉自己的能量计数
--ScriptLib.GadgetPlayUidOp(context, 0, 0, {uid}, 1, "clear_energy", {})
ScriptLib.AddTeamEntityGlobalFloatValue(context, {uid}, play.player_energy, -1*energy)
--增加玩法总进度
ScriptLib.AddScenePlayBattleProgress(context, 133001413, progress * LF_Get_Extra_Progress_Ratio(context, host))
return 0
end
function LF_Get_Extra_Energy_Ratio(context, host)
local ratio_ = 1
--if true == LF_Is_Near_Op_Uid(context, host, play.ratio_energy[1]) then
if 1 == ScriptLib.GetTeamAbilityFloatValue(context, context.source_entity_id, play.ratio_energy[1]) then
ratio_ = play.ratio_energy[2]
end
ScriptLib.PrintContextLog(context, "## ASTER_LOG : Extra_Energy_Ratio -> "..ratio_)
return ratio_
end
function LF_Get_Extra_Progress_Ratio(context, host)
local ratio_ = 1
--if true == LF_Is_Near_Op_Uid(context, host, play.ratio_progress[1]) then
if 1 == ScriptLib.GetTeamAbilityFloatValue(context, context.source_entity_id, play.ratio_progress[1]) then
ratio_ = play.ratio_progress[2]
end
ScriptLib.PrintContextLog(context, "## ASTER_LOG : Extra_Progress_Ratio -> "..ratio_)
return ratio_
end
function LF_Is_Near_Op_Uid(context, host, str)
local target = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "Op_Uid")
if target == 0 or 0 == ScriptLib.GetTeamAbilityFloatValue(context, target, str)then
return false
end
local target_Eid = ScriptLib.GetAvatarEntityIdByUid(context, target)
if target_Eid == 0 then
return false
end
--本人的直接返回
if target_Eid == context.source_entity_id then
return true
end
local pos1 = ScriptLib.GetPosByEntityId(context, target_Eid)
local pos2 = ScriptLib.GetPosByEntityId(context, context.source_entity_id)
if play.op_radius < LF_Calculate_Distance(context, pos1, pos2) then
return false
end
return true
end
function LF_Calculate_Distance(context, pos1, pos2)
local distance = math.sqrt(math.pow(pos1.x-pos2.x,2)+math.pow(pos1.y-pos2.y,2)+math.pow(pos1.z-pos2.z,2))
ScriptLib.PrintContextLog(context, "## ASTER_LOG : op_distance -> "..distance)
return distance
end
-------------------------------------------------
function condition_battle_state(context, evt)
if defs.group_id == play.group_main then
ScriptLib.PrintContextLog(context, "## ASTER_LOG: battle_state : param1->"..evt.param1.." | param2->"..evt.param2.." | param3->"..evt.param3)
end
if evt.param1 == play.PlayType and evt.param2 == play.PlayId then
return true
end
return false
end
function action_battle_state(context, evt)
--BATTLE_PREPARE
if evt.param3 == 2 and defs.group_id == play.group_main then
LF_Battle_Prepare(context, evt)
--BATTLE_READY
elseif evt.param3 == 3 and defs.group_id == play.group_main then
LF_Battle_Ready(context, evt)
--BATTLE_PRESTART
elseif evt.param3 == 4 and defs.group_id == play.group_main then
LF_Battle_Prestart(context, evt)
--BATTLE_START
elseif evt.param3 == 5 then
LF_Battle_Start(context, evt)
--[[--BATTLE_STOP
elseif evt.param3 == 6 then
LF_Battle_Stop(context, evt)--]]
elseif defs.group_id == play.group_main then
ScriptLib.PrintContextLog(context, "## ASTER_ERR : Invalid Battle State")
return -1
end
return 0
end
function action_battle_stage_change(context, evt)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : battle_stage_change : old_stage->"..evt.param1.." | cur_stage->"..evt.param2.." | final_stage->"..evt.param3)
if evt.param2 == evt.param3 then
return 0
end
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "stage_ptr", evt.param2)
LF_Uid_Op(context, evt.param2)
--阶段转换时一定要停当前tide
LF_Modify_Gadget_Group(context, evt.param2)
local r = ScriptLib.KillMonsterTide(context, play.group_main, play.monster_tide)
ScriptLib.CancelGroupTimerEvent(context, play.group_main, "next_tide_delay")
local s = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "tide_ptr")
ScriptLib.PrintContextLog(context, "## ASTER_LOG : remove_suite_over_stage -> "..s.." | kill_tide_result -> "..r)
--清理tide_monster
if s ~= 0 then
ScriptLib.RemoveExtraGroupSuite(context, play.group_main, s)
end
--清理stage_monster
local prev_stage_suite = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "prev_stage_suite")
if prev_stage_suite ~= 0 then
ScriptLib.RemoveExtraGroupSuite(context, play.group_stage, prev_stage_suite)
end
ScriptLib.ExecuteGroupLua(context, play.group_stage, "LF_Find_Stage_Suite", {evt.param2,host})
return 0
end
function action_battle_result(context, evt)
if evt.param3 == 1 then
LF_Battle_Win(context, evt)
elseif evt.param3 == 0 then
LF_Battle_Lose(context, evt)
end
return 0
end
function condition_monster_die_before_leave_scene(context, evt)
--如果monster没有分就return了
if monsters[evt.param1].kill_score > 0 then
return true
end
return false
end
function action_monster_die_before_leave_scene(context, evt)
--判断附近玩家,并增加对应分数
--local uid_list = ScriptLib.GetSurroundUidList(context, evt.param1, play.radius)
local uid_list = ScriptLib.GetSceneUidList(context)
if #uid_list == 0 then
ScriptLib.PrintContextLog(context, "## ASTER_ERR : None Near Players")
return -1
end
--通知客户端执行加分,考虑到客户端可能断线,这个分数服务器自己不记录
local score_ = monsters[evt.param1].kill_score
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
local ratio_ = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "ratio_ptr")
ScriptLib.PrintContextLog(context, "## ASTER_LOG : monster->"..evt.param1.." | score->"..score_.." | ratio->"..ratio_)
ScriptLib.AddTeamEntityGlobalFloatValue(context, uid_list, play.player_energy, score_ * ratio_)
return 0
end
function action_timer_summon(context, evt)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
local D = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, play.difficulty)
local timer_ptr = ScriptLib.GetScenePlayBattleUidValue(context, 0, host,"timer_ptr")
ScriptLib.PrintContextLog(context, "## ASTER_LOG : timer_event \"aster_timer\" -> "..defs.aster_timer[timer_ptr])
ScriptLib.PrintContextLog(context, "## ASTER_LOG : cur_timer_ptr -> "..timer_ptr)
math.randomseed(ScriptLib.GetServerTime(context) + timer_ptr)
local Timer = timer_def[D][timer_ptr][math.random(1,#timer_def[D][timer_ptr])]
if #suites[Timer].monsters > 0 then
ScriptLib.ShowTemplateReminder(context, 110, {0,0})
end
if defs.aster_timer[timer_ptr+1] == nil then
ScriptLib.PrintContextLog(context, "## ASTER_LOG : aster_timer_end")
return -1
end
--设置下一招怪阶段
ScriptLib.CreateGroupTimerEvent(context, play.group_timer, "aster_timer", defs.aster_timer[timer_ptr+1] - defs.aster_timer[timer_ptr])
--ScriptLib.CreateGroupTimerEvent(context, play.group_timer, "clear_delay", defs.clear_delay)
--召唤当前波次的怪物
--ScriptLib.PauseAutoMonsterTide(context, play.group_main, play.monster_tide)
--ScriptLib.RefreshGroup(context, {group_id = play.group_timer, suite = timer_def[D][timer_ptr][math.random(1,#timer_def[D][timer_ptr])]})
ScriptLib.AddExtraGroupSuite(context, play.group_timer, Timer)
ScriptLib.SetScenePlayBattleUidValue(context, 0, host,"timer_ptr", timer_ptr + 1)
--ScriptLib.SetScenePlayBattleUidValue(context, 0, host,"prev_timer_suite", Timer)
return 0
end
function action_monster_tide_over(context, evt)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : Monster_Tide_Over : tide_index->"..evt.source_name.." | status->"..evt.param2)
local tide_ptr = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "tide_ptr")
--自动结束,计算下一个tide,如果只有一个会选自己
local new_tide_ptr = tide_suite_config[tide_ptr].next
if new_tide_ptr == nil then
ScriptLib.PrintContextLog(context, "## ASTER_ERR : INVALID_CIRCLE_TIDE_PTR -> "..tide_ptr)
return -1
end
ScriptLib.CreateGroupTimerEvent(context, play.group_main, "next_tide_delay", tide_suite_config[tide_ptr].delay)
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "tide_ptr", new_tide_ptr)
return 0
end
function action_timer_delay(context, evt)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
--继续创建下个tide
local tide_ptr = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "tide_ptr")
ScriptLib.PrintContextLog(context, "## ASTER_LOG : timer_delay_tide -> "..tide_ptr)
ScriptLib.AutoMonsterTide(context, play.monster_tide, play.group_main, suites[tide_ptr].monsters, tide_suite_config[tide_ptr].total, tide_suite_config[tide_ptr].min, tide_suite_config[tide_ptr].max)
return 0
end
function action_battle_interrupt(context, evt)
ScriptLib.SetGadgetEnableInteract(context, play.group_main, defs.gadget_aster, true)
return 0
end
function condition_any_monster_die(context, evt)
if 0 == ScriptLib.GetGroupMonsterCount(context) then
return true
end
return false
end
function action_any_monster_die(context, evt)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
local stage = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "stage_ptr")
ScriptLib.ExecuteGroupLua(context, play.group_main, "LF_Modify_Monster_Tide", {stage,host})
return 0
end
---------------------------------------
--/*************************************/
---------------------------------------
function LF_Battle_Prepare(context, evt)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : LF_Battle_Prepare")
ScriptLib.PrintLog("================VERSION 76=========================")
--关闭大陨石交互
ScriptLib.SetGadgetEnableInteract(context, play.group_main, defs.gadget_aster, false)
return 0
end
function LF_Battle_Ready(context, evt)
--ScriptLib.PrintContextLog(context, "## ASTER_LOG : LF_Battle_Ready")
--随机难度
local D_str = LF_Random_Play_Difficulty(context, evt)
local D_num = 0
if D_str == "normal" then
D_num = 1
elseif D_str == "hard" then
D_num = 2
elseif D_str == "nightmare" then
D_num = 3
elseif D_str == "easy" then
D_num = 4
end
--启用playEntity
LF_Attach_Ability(context, evt, D_num, D_str)
--开启大陨石玩法
ScriptLib.PrestartScenePlayBattle(context, {duration = 600,start_cd = 10,progress_stage = progress_def[D_str], group_id = play.group_main, mode = D_num + 200})
--写入难度
LF_Set_Battle_Difficulty(context, evt, D_num)
--生成Buff序列
LF_Init_Uid_Op_Buff(context, evt)--]]
return 0
end
function LF_Battle_Prestart(context, evt)
--3秒倒计时提醒
ScriptLib.PrintContextLog(context, "## ASTER_LOG : LF_Battle_Prestart")
--[[--随机难度
LF_Random_Play_Difficulty(context, evt)
--生成Buff序列
LF_Init_Uid_Op_Buff(context, evt)--]]
return 0
end
function LF_Battle_Start(context, evt)
--ScriptLib.PrintContextLog(context, "## ASTER_LOG : LF_Battle_Start")
--正式开始
if defs.group_id == play.group_main then
--启动起始tide
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
LF_Modify_Gadget_Group(context, 0)
LF_Modify_Monster_Tide(context, context, 0, host, 0)
elseif defs.group_id == play.group_timer then
--启动timer_group计时器
LF_Set_Timer(context, evt)
end
return 0
end
--[[function LF_Battle_Stop(context, evt)
--结束
ScriptLib.PrintContextLog(context, "## ASTER_LOG : LF_Battle_Stop")
return 0
end--]]
function LF_Battle_Win(context, evt)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : LF_Battle_Win")
if defs.group_id == play.group_main then
ScriptLib.KillMonsterTide(context, play.group_main, play.monster_tide)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
local circle = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "circle_ptr")
ScriptLib.KillExtraGroupSuite(context, play.group_gadget, circle)
ScriptLib.CancelGroupTimerEvent(context, play.group_main, "next_tide_delay")
local s = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "tide_ptr")
ScriptLib.RemoveExtraGroupSuite(context, play.group_main, s)
ScriptLib.CreateScenePlayGeneralRewardGadget(context, {group_id = play.group_main, config_id = defs.gadget_reward})
ScriptLib.SetGadgetEnableInteract(context, play.group_main, defs.gadget_aster, true)
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_aster, 0)
elseif defs.group_id == play.group_stage then
ScriptLib.RefreshGroup(context, {group_id = defs.group_id, suite = 1})
elseif defs.group_id == play.group_timer then
ScriptLib.RefreshGroup(context, {group_id = defs.group_id, suite = 1})
ScriptLib.CancelGroupTimerEvent(context, play.group_timer, "aster_timer")
--ScriptLib.CancelGroupTimerEvent(context, play.group_timer, "clear_delay")
end
return 0
end
function LF_Battle_Lose(context, evt)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : LF_Battle_Lose")
if defs.group_id == play.group_main then
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
local circle = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "circle_ptr")
ScriptLib.KillExtraGroupSuite(context, play.group_gadget, circle)
ScriptLib.CancelGroupTimerEvent(context, play.group_main, "next_tide_delay")
ScriptLib.KillMonsterTide(context, play.group_main, play.monster_tide)
local s = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "tide_ptr")
ScriptLib.RemoveExtraGroupSuite(context, play.group_main, s)
ScriptLib.SetGadgetEnableInteract(context, play.group_main, defs.gadget_aster, true)
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_aster, 0)
elseif defs.group_id == play.group_stage then
ScriptLib.RefreshGroup(context, {group_id = defs.group_id, suite = 1})
elseif defs.group_id == play.group_timer then
ScriptLib.RefreshGroup(context, {group_id = defs.group_id, suite = 1})
ScriptLib.CancelGroupTimerEvent(context, play.group_timer, "aster_timer")
--ScriptLib.CancelGroupTimerEvent(context, play.group_timer, "clear_delay")
end
return 0
end
function LF_Find_Stage_Suite(context, prev_context, param1, param2, param3)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : Find_Stage_Suite : stage->"..param1.." | host->"..param2)
local stage = param1
local host = param2
local D = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, play.difficulty)
--用于定义阶段转换,影响stage对应group的逻辑
local stage_suite_arr = stage_def[D][stage]
if stage_suite_arr == nil or #stage_suite_arr == 0 then
ScriptLib.PrintContextLog(context, "## ASTER_LOG : None Stage Suite")
ScriptLib.ExecuteGroupLua(context, play.group_main, "LF_Modify_Monster_Tide", {stage,host})
return 0
else
math.randomseed(ScriptLib.GetServerTime(context) + stage)
local stage_suite = stage_suite_arr[math.random(1,#stage_suite_arr)]
ScriptLib.ExecuteGroupLua(context, play.group_main, "LF_Handle_Stage_Change", {stage,stage_suite})
end
return 0
end
function LF_Modify_Monster_Tide(context, prev_context, param1, param2, param3)
local stage = param1
local host = param2
ScriptLib.PrintContextLog(context, "## ASTER_LOG : modify_monster_tide : cur_stage->"..stage)
local D = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, play.difficulty)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : show difficulty ->"..D)
if #tide_defs[D][stage].suite == 0 then
ScriptLib.PrintContextLog(context, "## ASTER_ERR : no_monster_tide_begin")
return -1
elseif #tide_defs[D][stage].suite ~= #tide_defs[D][stage].weight then
ScriptLib.PrintContextLog(context, "## ASTER_ERR : Invalid Monster Tide Config")
return -1
end
local tide_ptr = LF_Handle_Random_Weight(context, stage, tide_defs[D], "suite")
--根据tide预设值创建tide
if tide_ptr > 0 then
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "tide_ptr", tide_ptr)
ScriptLib.AutoMonsterTide(context, play.monster_tide, play.group_main, suites[tide_ptr].monsters, tide_suite_config[tide_ptr].total, tide_suite_config[tide_ptr].min, tide_suite_config[tide_ptr].max)
else
return -1
end
return 0
end
function LF_Handle_Random_Weight(context, stage, table, name)
math.randomseed(ScriptLib.GetServerTime(context) + stage)
local weight_sum = 0
for i,v in ipairs(table[stage].weight) do
weight_sum = weight_sum + v
end
if weight_sum == 0 then
ScriptLib.PrintContextLog(context, "## ASTER_ERR : Weight Is Zero")
return -1
end
local weight_ran = math.random(1,weight_sum)
for i,v in ipairs(table[stage].weight) do
weight_ran = weight_ran - v
if weight_ran <= 0 then
return table[stage][name][i]
end
end
return -1
end
function LF_Attach_Ability(context, evt, num, str)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : LF_Attach_Ability")
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
ScriptLib.SetScenePlayBattlePlayTeamEntityGadgetId(context, play.group_main, 70370000 + num)
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "ratio_ptr", defs.score_ratio[str])
return 0
end
function LF_Random_Play_Difficulty(context, evt)
---[[
local M = ScriptLib.GetGroupVariableValue(context, "GM_Mode")
if M == 1 then
return "normal"
elseif M == 2 then
return "hard"
elseif M == 3 then
return "nightmare"
elseif M == 4 then
return "easy"
end
--]]
if 1 == ScriptLib.GetScenePlayBattleType(context, play.group_main) then
return "easy"
end
local max_difficulty = 0
for k,v in pairs(defs.difficulty_weight) do
max_difficulty = max_difficulty + v
end
math.randomseed(ScriptLib.GetServerTime(context) + evt.param1 + evt.param2)
local ran_difficulty = math.random(1,max_difficulty)
for k,v in pairs(defs.difficulty_weight) do
ran_difficulty = ran_difficulty - v
if ran_difficulty <= 0 then
return k
end
end
return 0
end
function LF_Set_Battle_Difficulty(context, evt, difficulty)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
ScriptLib.PrintContextLog(context, "## ASTER_LOG Set_Initial_Difficulty->"..difficulty)
--ScriptLib.ShowTemplateReminder(context, 100 + difficulty, {0,0})
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, play.difficulty, difficulty)
return 0
end
function LF_Handle_Stage_Change(context, prev_context, param1, param2, param3)
local stage = param1
local suite = param2
ScriptLib.PrintContextLog(context, "## ASTER_LOG : handle_stage_change : stage->"..stage.." | suite->"..suite)
--处理progress阶段转换的逻辑
if #suites[suite].monsters == 0 then
ScriptLib.PrintContextLog(context, "## ASTER_ERR : Invalid Monster Suite->"..suite)
return -1
end
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
ScriptLib.AddExtraGroupSuite(context, play.group_stage, suite)
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "prev_stage_suite", suite)
--ScriptLib.ShowTemplateReminder(context, 109, {0,0})
return 0
end
function LF_Uid_Op(context, stage)
--用于处理点名逻辑
local buff_type = LF_Get_Uid_Op_Buff(context, stage)
local uid_list = LF_Get_Uid_Op_Target(context, buff_type)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
--[[if #uid_list == 0 then
ScriptLib.PrintContextLog(context, "## ASTER_ERR : Invalid Op Uid List")
return -1
end--]]
ScriptLib.PrintContextLog(context, "## ASTER_LOG : random_buff -> "..buff_type)
if buff_type == 3 or buff_type == 5 then
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "Op_Uid", uid_list[1])
else
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "Op_Uid", 0)
end
ScriptLib.ScenePlayBattleUidOp(context, play.group_main, defs.gadget_aster, uid_list, buff_type, "random_buff_aster", {}, {}, buff_type, 30)
return 0
end
function LF_Init_Uid_Op_Buff(context, evt)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
local D = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, play.difficulty)
--初始化点名buff栈,栈的深度要掐头去尾
local buff_stack = 0
for i,v in ipairs(buff_def[D]) do
local buff_ = LF_Handle_Random_Weight(context, i, buff_def[D], "buff")
buff_stack = buff_stack + math.pow(10,i-1)*buff_
end
if buff_stack > 0 then
ScriptLib.PrintContextLog(context, "## ASTER_LOG : buff_stack -> "..buff_stack)
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "buff_stack", buff_stack)
else
ScriptLib.PrintContextLog(context, "## ASTER_ERR : buff_stack_error")
end
return 0
end
function LF_Get_Uid_Op_Buff(context, stage)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
local buff_stack = ScriptLib.GetScenePlayBattleUidValue(context, 0, host,"buff_stack")
return buff_stack//math.pow(10,stage-1)%10
end
function LF_Get_Uid_Op_Target(context, buff_type)
--点名返回的目标
local user = ScriptLib.GetSceneUidList(context)
local list = {}
math.randomseed(ScriptLib.GetServerTime(context) + buff_type)
--if buff_type == 1 or buff_type == 2 then
list[1] = user[math.random(1,#user)]
ScriptLib.PrintContextLog(context, "## ASTER_LOG : uid_op_target -> "..list[1])
--end
return list
end
function LF_Set_Timer(context, evt)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : set_timer \"aster_timer\"-> "..defs.aster_timer[1])
ScriptLib.CreateGroupTimerEvent(context, play.group_timer, "aster_timer", defs.aster_timer[1])
ScriptLib.SetScenePlayBattleUidValue(context, 0, host,"timer_ptr", 1)
return 0
end
function LF_Modify_Gadget_Group(context, stage)
ScriptLib.PrintContextLog(context, "## ASTER_LOG : modify_gadget_group | stage -> "..stage)
local host = ScriptLib.GetScenePlayBattleHostUid(context, 0)
local D = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, play.difficulty)
if circle_type_defs[D] == 1 then
--交分台锁位置
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_aster, 202)
elseif circle_type_defs[D] == 2 then
--交分台换位置
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_aster, 201)
end
if stage == 0 then
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "circle_ptr", tide_defs[D][stage].circle)
ScriptLib.AddExtraGroupSuite(context, play.group_gadget, tide_defs[D][stage].circle)
elseif circle_type_defs[D] == 1 then
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "circle_ptr", tide_defs[D][stage].circle)
local prev_stage = ScriptLib.GetScenePlayBattleUidValue(context, 0, host, "prev_stage")
ScriptLib.KillExtraGroupSuite(context, play.group_gadget, tide_defs[D][prev_stage].circle)
ScriptLib.AddExtraGroupSuite(context, play.group_gadget, tide_defs[D][stage].circle)
end
ScriptLib.SetScenePlayBattleUidValue(context, 0, host, "prev_stage", stage)
return 0
end
LF_Initialize_Group(triggers, suites, defs.group_id)
@@ -0,0 +1,17 @@
local t = { config_id = 8000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0}
function Initialize()
table.insert(triggers,t)
table.insert(suites[1].triggers, t.name)
end
Initialize()
function action_group_load(context, evt)
if ScriptLib.GetGroupVariableValue(context, "isDone") ~= 1 then
ScriptLib.CreateGadget(context, { config_id = defs.gadget_id })
end
return 0
end
@@ -0,0 +1,88 @@
--------初始参数----------
local Enum ={
CatchKey = "catchKey",
}
local tempTrigger = {
{ config_id = 68886, name = "VARIABLE_CHANGE_68886", event = EventType.EVENT_VARIABLE_CHANGE,
source = Enum.CatchKey, condition = "condition_Check_Score", action = "",
trigger_count = 0 , tag = "666" }
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
local var = { config_id=50000001,name = Enum.CatchKey, value = 0, no_refresh = false }
variables[var.name] = var
return 0
end
--------逻辑函数----------
function condition_Check_Score(context, evt)
ScriptLib.PrintContextLog(context, "## TD_AttachChildChallenge : Trigger" .. evt.param1)
if evt.param1 == evt.param2 then return false end
if evt.param1<=0 then
return false
end
return true
end
--------可调用函数--------
-- 定义父挑战信息
function DefineFatherIndex(context, prev_context, fatherIndex)
ScriptLib.SetGroupTempValue(context, "ChildChallenge_FatherIndex", fatherIndex, {})
ScriptLib.PrintContextLog(context, "## TD_AttachChildChallenge : fatherIndex" .. fatherIndex)
return 0
end
-- 定义子挑战的成功失败分数
function DefineChildChallengeScore(context, prev_context, success, fail)
ScriptLib.SetGroupTempValue(context, "ChildChallenge_Success", success, {})
ScriptLib.SetGroupTempValue(context, "ChildChallenge_Fail", fail, {})
ScriptLib.PrintContextLog(context, "## TD_AttachChildChallenge : success" .. success)
ScriptLib.PrintContextLog(context, "## TD_AttachChildChallenge : fail" .. fail)
return 0
end
--从其它Group调用该方法,可以为该Group创建对应参数。使用前请保证父挑战已经启动
function AttachChildChallengeFromDiffGroup(context, prev_context, childIndex, challengeId, targetCount)
--在特定时间内触发特定Trigger,paramTable => {time, 3, 666, targetCount} scoreTable => {success=1,fail=0}
local fatherIndex = ScriptLib.GetGroupTempValue(context, "ChildChallenge_FatherIndex",{})
local _success = ScriptLib.GetGroupTempValue(context, "ChildChallenge_Success",{})
local _fail = ScriptLib.GetGroupTempValue(context, "ChildChallenge_Fail",{})
ScriptLib.PrintContextLog(context, "## TD_AttachChildChallenge : fatherIndex/success/fail" .. fatherIndex .."/".. _success .."/".. _fail .."/")
if fatherIndex == 0 then
ScriptLib.PrintContextLog(context, "## TD_AttachChildChallenge : Need DefineFatherIndex")
return -1
end
local paramTable = {3, 666, targetCount, 1}
local scoreTable = {success = _success,fail = _fail}
ScriptLib.SetGroupVariableValue(context, Enum.CatchKey, 0)
ScriptLib.AttachChildChallenge(context, fatherIndex, childIndex, challengeId, paramTable,{}, scoreTable)
return 0
end
--挑战加分
function AddChildChallengeScore(context, prev_context, score)
local currentScore = ScriptLib.GetGroupVariableValue(context, Enum.CatchKey)
ScriptLib.SetGroupVariableValue(context, Enum.CatchKey, currentScore + score)
return 0
end
--终止特定子挑战
function StopChildChallengeFromDiffGroup(context, prev_context, childIndex, isWin)
-- isWin = 0 (失败) 1(完成)
ScriptLib.StopChallenge(context, childIndex, isWin)
return 0
end
LF_Initialize_Level()
@@ -0,0 +1,92 @@
--[[
电桩玩法 黑盒
]]--
local extraTriggers={
{ config_id = 8000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 8000003,name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
--{ config_id = 8000004, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0,forbid_guest = false }
{config_id = 8000005, name = "GadgetStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Gadget_State_Change", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "successed", value = 0, no_refresh = true})
--初始化
end
function action_Gadget_State_Change(context, evt)
ScriptLib.PrintContextLog(context, "物件状态发生变化"..evt.param1..evt.param2)
if evt.param2==defs.gadget_1 and evt.param1==202 and ScriptLib.GetGroupVariableValue(context, "successed")~=1 then
ScriptLib.PrintContextLog(context, "挑战已经完成")
ScriptLib.SetGroupVariableValue(context, "successed", 1)
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 3)
end
return 0
end
function action_group_load(context, evt)
if ScriptLib.GetGroupVariableValue(context, "successed")==1 then
RemoveAllRepeater(context)
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 3)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_ID, defs.gadget_1, 202)
for i=1,#gadgets do
if gadgets[i].gadget_id == 70950068 then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_ID, gadgets[i].config_id, 901)
end
end
return 0
end
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
return 0
end
--拾取时给按钮充能
function action_EVENT_SELECT_OPTION(context, evt)
for i=1,#defs.relayPost do
ScriptLib.PrintContextLog(context, "成功触发交互"..context.uid..defs.relayPost[i]..evt.param1)
if evt.param1==defs.relayPost[i] then
if evt.param2==57 then
ScriptLib.PrintContextLog(context, "成功触发交互中继器"..context.uid)
ScriptLib.AddTeamEntityGlobalFloatValue(context, {context.uid},"AVATAR_Electric_Stake_Play", 1)
end
return 0
end
end
return 0
end
--退出区域关闭挑战
function action_EVENT_LEAVE_REGION(context, evt)
if evt.param1 ~= defs.trigger_playRegion then
return 0
end
if ScriptLib.GetGroupVariableValue(context, "successed")==1 then
RemoveAllRepeater(context)
return 0
end
ScriptLib.RefreshGroup(context,{group_id=defs.group_Id,suite=1})
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
return 0
end
function RemoveAllRepeater(context)
for i=1,#gadgets do
if gadgets[i].gadget_id == 70950069 then
ScriptLib.RemoveEntityByConfigId(context, defs.group_ID, EntityType.GADGET, gadgets[i].config_id)
end
end
return 0
end
function Electric_Stake_Explain(context)
ScriptLib.MarkPlayerAction(context, 7003, 3, 1)
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,251 @@
---
--- Generated by Luanalysis
--- Created by binghong.shen.
--- DateTime: 2022/5/6 15:52
---
--[[======================================
|| filename: DesertEnergySpark
|| owner: binghong.shen
|| description: 元能火种
|| LogName: DesertEnergySpark
|| Protection: [Protection]
=======================================]]
local fireTable = {
[1]={fireID = defs.gadget_fire1,fireBaseID = defs.gadget_fireBase1},
[2]={fireID = defs.gadget_fire2,fireBaseID = defs.gadget_fireBase2},
[3]={fireID = defs.gadget_fire3,fireBaseID = defs.gadget_fireBase3},
[4]={fireID = defs.gadget_fire4,fireBaseID = defs.gadget_fireBase4},
}
local extraTriggers={
{ config_id = 8000002, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_SelectOption", trigger_count = 0 },
{ config_id = 8000003, name = "Fire_Reach_Point", event= EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_PlatReachPoint", trigger_count = 0 },
{ config_id = 8000004, name = "Gadget_Create", event= EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_OnGadgetCreate", trigger_count = 0 },
{ config_id = 8000005, name = "Gadget_Die", event= EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_OnAnyGadgetDie", trigger_count = 0 },
{ config_id = 8000006, name = "Avatar_Near_Platform", event= EventType.EVENT_AVATAR_NEAR_PLATFORM, source = "", condition = "", action = "action_AvatarNearPlatform", trigger_count = 0 },
{ config_id = 8000007, name = "GadgetStateChange", event= EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_GadgetStateChange", trigger_count = 0 },
{ config_id = 8000008, name = "OnGroupLoad", event= EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_OnGroupLoad", trigger_count = 0 },
}
function action_OnGroupLoad(context)
for _,v in pairs(fireTable) do
if(v.fireID and v.fireID~=0)then
ScriptLib.KillEntityByConfigId(context, { config_id = v.fireID })
end
end
local moveIndex = ScriptLib.GetGroupVariableValue(context, "recordMoveIndex")
for k,v in pairs(fireTable) do
if(v.fireBaseID and v.fireBaseID~=0)then
local baseState = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, v.fireBaseID)
if(baseState == 0 or baseState == 201)then
if(k==moveIndex)then
ScriptLib.SetGadgetStateByConfigId(context,v.fireBaseID , 201)
else
ScriptLib.SetGadgetStateByConfigId(context,v.fireBaseID , 0)
end
end
end
end
return 0
end
function SLC_EngineerMark( context )
local eid = context.source_entity_id
ScriptLib.MarkGroupLuaAction(context, "getengineer", "", {group_id = base_info.group_id ,config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = eid }) })
return 0
end
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--初始化
table.insert(variables,{ config_id=50000001,name = "recordMoveIndex", value = 1 , no_refresh = true})
end
--初始化一些按键
function action_OnGadgetCreate(context,evt )
-- 设置操作台选项
local isFireBase = false
local gadgetID = evt.param1
for _,v in pairs(fireTable) do
if(v.fireBaseID==gadgetID)then
isFireBase = true
break
end
end
if(isFireBase == false)then
return -1
end
if GadgetState.GearStart == ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, gadgetID) then
ScriptLib.PrintContextLog(context, "@@ DesertEnergySpark : energySpark SetOption")
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gadgetID, {defs.interactOptionID})
else
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gadgetID, {})
end
return 0
end
--基座状态改变需要增删按钮
function action_GadgetStateChange( context,evt )
local isFireBase = false
local gadgetState = evt.param1
local gadgetID = evt.param2
for _,v in pairs(fireTable) do
if(v.fireBaseID==gadgetID)then
isFireBase = true
break
end
end
if(isFireBase == false)then
return -1
end
if GadgetState.GearStart == gadgetState then
ScriptLib.PrintContextLog(context, "@@ DesertEnergySpark : energySpark SetOption")
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gadgetID, {defs.interactOptionID})
else
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gadgetID, {})
end
return 0
end
--按下按键召唤火种
function action_SelectOption( context,evt )
local gadgetID = evt.param1
local optionID = evt.param2
if(optionID ~= defs.interactOptionID)then
return -1
end
local moveIndex = 1
for k,v in ipairs(fireTable)do
if(v.fireBaseID==gadgetID)then
moveIndex = k
break
end
end
local nextIndex = moveIndex + 1
local nextFireBase = 0
if(fireTable[nextIndex]~=nil and fireTable[nextIndex].fireBaseID~=0)then
nextFireBase = fireTable[nextIndex].fireBaseID
local entityID = ScriptLib.GetEntityIdByConfigId(context, nextFireBase)
if ScriptLib.GetGadgetIdByEntityId(context, entityID) == 70330313 then
local nextGadgetState = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, nextFireBase)
if nextGadgetState == 204 then
ScriptLib.ShowReminder(context, 33010249)
return 0
end
end
end
--ScriptLib.SetGroupTempValue(context, "CurMoveIndex", moveIndex, {})
ScriptLib.SetGadgetStateByConfigId(context, fireTable[moveIndex].fireBaseID, 0)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, gadgetID, {})
ScriptLib.CreateGadget(context, { config_id = fireTable[moveIndex].fireID })
return 0
end
--角色靠近火种能推动它
function action_AvatarNearPlatform( context,evt )
local gadgetID = evt.param1
--判断是否是火种
local moveIndex = -1
for k,v in ipairs(fireTable)do
if(v.fireID==gadgetID)then
moveIndex = k
break
end
end
if(moveIndex==-1)then
return -1
end
ScriptLib.StartPlatform(context, gadgetID)
return 0
end
--火种被风扇吹散
function action_OnAnyGadgetDie( context,evt )
local gadgetID = evt.param1
--判断是否是火种
local moveIndex = -1
for k,v in ipairs(fireTable)do
if(v.fireID==gadgetID)then
moveIndex = k
break
end
end
if(moveIndex==-1)then
return -1
end
local nextIndex = moveIndex + 1
local nextFireBase = 0
if(fireTable[nextIndex]==nil or fireTable[nextIndex].fireBaseID==0)then
nextFireBase = defs.gadget_fireTorch
else
nextFireBase = fireTable[nextIndex].fireBaseID
end
local gadgetState = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, nextFireBase)
--下一个gadget还没被点亮,所以是被风吹灭的,需要把上一个基座恢复
if(gadgetState==0)then
ScriptLib.SetGadgetStateByConfigId(context, fireTable[moveIndex].fireBaseID, 201)
end
return 0
end
--火种到达目的地
function action_PlatReachPoint( context,evt )
local gadgetID = evt.param1
local moveIndex = -1
for k,v in ipairs(fireTable)do
if(v.fireID==gadgetID)then
moveIndex = k
break
end
end
if(moveIndex==-1)then
return -1
end
local nextIndex = moveIndex+1
if(fireTable[nextIndex]==nil or fireTable[nextIndex].fireBaseID==0)then
--到达了终点
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_fireTorch, 201)
ScriptLib.SetGadgetStateByConfigId(context,gadgetID , 201)
else
ScriptLib.SetGadgetStateByConfigId(context,fireTable[nextIndex].fireBaseID , 201)
ScriptLib.KillEntityByConfigId(context, { config_id = gadgetID })
end
ScriptLib.SetGroupVariableValue(context, "recordMoveIndex", nextIndex)
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,212 @@
--[[
一笔画固定5x5版本
]]--
local matrix =
{
{defs.gadget_11,defs.gadget_12,defs.gadget_13,defs.gadget_14,defs.gadget_15},
{defs.gadget_21,defs.gadget_22,defs.gadget_23,defs.gadget_24,defs.gadget_25},
{defs.gadget_31,defs.gadget_32,defs.gadget_33,defs.gadget_34,defs.gadget_35},
{defs.gadget_41,defs.gadget_42,defs.gadget_43,defs.gadget_44,defs.gadget_45},
{defs.gadget_51,defs.gadget_52,defs.gadget_53,defs.gadget_54,defs.gadget_55}}
local extraTriggers={
{config_id = 8000001, name = "GadgetStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Gadget_State_Change", trigger_count = 0 },
{config_id = 8000002,name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
--{ config_id = 8000003, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
{ config_id = 8000004, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "successed", value = 0, no_refresh = true})
--challenge_state 0-等待开始 1-正在进行 2-完成 3-失败流程中
table.insert(variables,{ config_id=50000002,name = "challenge_state", value = 0})
table.insert(variables,{ config_id=50000003,name = "current_stone", value = 0})
--这个GV用于GadgetLua
table.insert(variables,{ config_id=50000004,name = "starter_id", value = 0})
--初始化
end
function action_group_load(context, evt)
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
ScriptLib.SetGroupVariableValue(context, "starter_id",defs.gadget_starter)
return 0
end
--处理失败逻辑
function FaildProcess(context,str)
--Faild process start
ScriptLib.PrintContextLog(context,"Faild Process Start : "..str)
ScriptLib.SetGroupVariableValue(context, "challenge_state", 3)
for k,v in pairs(matrix) do
for ik,iv in pairs(v) do
local tempGadgeState = ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, iv)
--除了禁用格和起始格,全部格子下降
if tempGadgeState ~= 903 then
if iv ~= defs.gadget_starter then
ScriptLib.SetGadgetStateByConfigId(context, iv, 102)
else
ScriptLib.SetGadgetStateByConfigId(context, iv, 201)
end
end
end
end
ScriptLib.PrintContextLog(context,"Faild Process End : "..str)
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
end
function LuaCallFail(context)
--物件调用
--如果踩到禁用格,且正在挑战中,则走一下失败流程
if ScriptLib.GetGroupVariableValue(context, "challenge_state")==1 then
FaildProcess(context,"踩到空方块")
end
return 0
end
function action_Gadget_State_Change(context, evt)
if evt.param1==202 and evt.param3==204 and ScriptLib.GetGroupVariableValue(context, "challenge_state")==1 then
--先检查是不是从相邻的格子踩进终点格
CheckTwoGadgetIsAdjacent(context,ScriptLib.GetGroupVariableValue(context, "current_stone"),evt.param2)
--再算分
CheckIsSuccess(context)
if ScriptLib.GetGroupVariableValue(context, "successed")~=1 then
FaildProcess(context,"提前踩到终点")
end
return 0
end
--如果挑战状态是未开始(challenge_state=0),且被交互的是起始格,则开始挑战
if ScriptLib.GetGroupVariableValue(context, "challenge_state")==0 and
evt.param1==202 and evt.param2== defs.gadget_starter then
ScriptLib.PrintContextLog(context,"StartChallenge ")
ScriptLib.SetGroupVariableValue(context, "challenge_state", 1)
--先把终点格子切到State 204
if defs.gadget_ender==0 then
ScriptLib.PrintContextLog(context,"一笔画终点石板没配,使用自由模式")
else
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_ender, 204)
end
--然后除了禁用格、起始格、终点格,全部格子升起
for i=1,#matrix do
for j=1,#matrix[i] do
if ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, matrix[i][j]) ~= 903 then
if matrix[i][j] ~= defs.gadget_starter and matrix[i][j] ~= defs.gadget_ender then
ScriptLib.SetGadgetStateByConfigId(context, matrix[i][j], 101)
end
end
--设置当前在哪个方块
if matrix[i][j]==evt.param2 then
ScriptLib.SetGroupVariableValue(context, "current_stone", i*10+j)
end
end
end
return 0
end
--如果挑战状态是已开始(challenge_state=1),则检查格子有效性
if ScriptLib.GetGroupVariableValue(context, "challenge_state")==1 then
if evt.param1==202 then
CheckTwoGadgetIsAdjacent(context,ScriptLib.GetGroupVariableValue(context, "current_stone"),evt.param2)
end
if evt.param1==201 and evt.param3==202 then
local current_idx=ScriptLib.GetGroupVariableValue(context, "current_stone")
local config_one=matrix[math.floor(current_idx/10)][current_idx%10]
if config_one==evt.param2 then
ScriptLib.SetGadgetStateByConfigId(context, evt.param2, 202)
else
FaildProcess(context,"踩错")
end
end
CheckIsSuccess(context)
return 0
end
return 0
end
function action_EVENT_LEAVE_REGION(context, evt)
--解谜成功、解谜未开始 不算出圈
if evt.param1~=defs.trigger_boarder or
ScriptLib.GetGroupVariableValue(context, "successed")==1 or
ScriptLib.GetGroupVariableValue(context, "challenge_state")==0 then
ScriptLib.PrintContextLog(context, "Safe LEAVE REGION")
return 0
else
FaildProcess(context,"出圈")
end
return 0
end
--检测玩法是否成功
function CheckIsSuccess(context)
local score=0
local state=nil
for i=1,#matrix do
for j=1,#matrix[i] do
state=ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID,matrix[i][j])
if state==202 or state==903 then
score=score+1
end
end
end
if score>=25 then
for i=1,#matrix do
for j=1,#matrix[i] do
if ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID,matrix[i][j]) ~= 903 then
ScriptLib.SetGadgetStateByConfigId(context, matrix[i][j], 901)
end
end
end
ScriptLib.SetGroupVariableValue(context, "challenge_state", 2)
ScriptLib.GoToGroupSuite(context, defs.group_ID, 3)
ScriptLib.SetGroupVariableValue(context, "successed", 1)
end
return 0
end
--检测两个方块是否是相邻方块
function CheckTwoGadgetIsAdjacent(context,current_idx,config_two)
local x=math.floor(current_idx/10)
local y=current_idx%10
if matrix[x][y]==config_two then
return 0
end
if y>1 then
if matrix[x][y-1]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", x*10+y-1)
return 0
end
end
if y< #matrix[x] then
if matrix[x][y+1]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", x*10+y+1)
return 0
end
end
if x>1 then
if matrix[x-1][y]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", (x-1)*10+y)
return 0
end
end
if x < #matrix then
if matrix[x+1][y]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", (x+1)*10+y)
return 0
end
end
FaildProcess(context,"踩错")
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,201 @@
--[[
一笔画黑盒 适用性优化版本
1.LD布设时只需要将起点格设成GearStart,禁用格、终点格等特殊格子不需要设GadgetState
2.矩阵只要保证是矩形即可,原黑盒是固定5*5
]]--
local extraTriggers={
{config_id = 8000001, name = "GadgetStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Gadget_State_Change", trigger_count = 0 },
{config_id = 8000002,name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
--{ config_id = 8000003, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
{ config_id = 8000004, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "successed", value = 0, no_refresh = true})
--challenge_state 0-等待开始 1-正在进行 2-完成 3-失败流程中
table.insert(variables,{ config_id=50000002,name = "challenge_state", value = 0})
table.insert(variables,{ config_id=50000003,name = "current_stone", value = 0})
--这个GV用于GadgetLua
table.insert(variables,{ config_id=50000004,name = "starter_id", value = 0})
--初始化
end
function action_group_load(context, evt)
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
ScriptLib.SetGroupVariableValue(context, "starter_id",defs.gadget_starter)
return 0
end
--处理失败逻辑
function FaildProcess(context,str)
--Faild process start
ScriptLib.PrintContextLog(context,"Faild Process Start : "..str)
ScriptLib.SetGroupVariableValue(context, "challenge_state", 3)
for k,v in pairs(matrix) do
for ik,iv in pairs(v) do
local tempGadgeState = ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, iv)
--除了禁用格和起始格,全部格子下降
if tempGadgeState ~= 903 then
if iv ~= defs.gadget_starter then
ScriptLib.SetGadgetStateByConfigId(context, iv, 102)
else
ScriptLib.SetGadgetStateByConfigId(context, iv, 201)
end
end
end
end
ScriptLib.PrintContextLog(context,"Faild Process End : "..str)
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
end
function LuaCallFail(context)
--物件调用
--如果踩到禁用格,且正在挑战中,则走一下失败流程
if ScriptLib.GetGroupVariableValue(context, "challenge_state")==1 then
FaildProcess(context,"踩到空方块")
end
return 0
end
function action_Gadget_State_Change(context, evt)
if evt.param1==202 and evt.param3==204 and ScriptLib.GetGroupVariableValue(context, "challenge_state")==1 then
--先检查是不是从相邻的格子踩进终点格
CheckTwoGadgetIsAdjacent(context,ScriptLib.GetGroupVariableValue(context, "current_stone"),evt.param2)
--再算分
CheckIsSuccess(context)
if ScriptLib.GetGroupVariableValue(context, "successed")~=1 then
FaildProcess(context,"提前踩到终点")
end
return 0
end
--如果挑战状态是未开始(challenge_state=0),且被交互的是起始格,则开始挑战
if ScriptLib.GetGroupVariableValue(context, "challenge_state")==0 and
evt.param1==202 and evt.param2== defs.gadget_starter then
ScriptLib.SetGroupVariableValue(context, "challenge_state", 1)
--先把终点格子切到State 204
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_ender, 204)
--然后除了禁用格、起始格、终点格,全部格子升起
for i=1,#matrix do
for j=1,#matrix[i] do
if ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, matrix[i][j]) ~= 903 then
if matrix[i][j] ~= defs.gadget_starter and matrix[i][j] ~= defs.gadget_ender then
ScriptLib.SetGadgetStateByConfigId(context, matrix[i][j], 101)
end
end
--设置当前在哪个方块
if matrix[i][j]==evt.param2 then
ScriptLib.SetGroupVariableValue(context, "current_stone", i*10+j)
end
end
end
return 0
end
--如果挑战状态是已开始(challenge_state=1),则检查格子有效性
if ScriptLib.GetGroupVariableValue(context, "challenge_state")==1 then
if evt.param1==202 then
CheckTwoGadgetIsAdjacent(context,ScriptLib.GetGroupVariableValue(context, "current_stone"),evt.param2)
end
if evt.param1==201 and evt.param3==202 then
local current_idx=ScriptLib.GetGroupVariableValue(context, "current_stone")
local config_one=matrix[math.floor(current_idx/10)][current_idx%10]
if config_one==evt.param2 then
ScriptLib.SetGadgetStateByConfigId(context, evt.param2, 202)
else
FaildProcess(context,"踩错")
end
end
CheckIsSuccess(context)
return 0
end
return 0
end
function action_EVENT_LEAVE_REGION(context, evt)
--解谜成功、解谜未开始 不算出圈
if evt.param1~=defs.trigger_boarder or
ScriptLib.GetGroupVariableValue(context, "successed")==1 or
ScriptLib.GetGroupVariableValue(context, "challenge_state")==0 then
ScriptLib.PrintContextLog(context, "Safe LEAVE REGION")
return 0
else
FaildProcess(context,"出圈")
end
return 0
end
--检测玩法是否成功
function CheckIsSuccess(context)
local score=0
local state=nil
local maxscore = #matrix * #matrix[1]
for i=1,#matrix do
for j=1,#matrix[i] do
state=ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID,matrix[i][j])
if state==202 or state==903 then
score=score+1
end
end
end
if score>= maxscore then
for i=1,#matrix do
for j=1,#matrix[i] do
if ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID,matrix[i][j]) ~= 903 then
ScriptLib.SetGadgetStateByConfigId(context, matrix[i][j], 901)
end
end
end
ScriptLib.SetGroupVariableValue(context, "challenge_state", 2)
--ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 3)
ScriptLib.GoToGroupSuite(context, defs.group_ID, 3)
ScriptLib.SetGroupVariableValue(context, "successed", 1)
end
return 0
end
--检测两个方块是否是相邻方块
function CheckTwoGadgetIsAdjacent(context,current_idx,config_two)
local x=math.floor(current_idx/10)
local y=current_idx%10
if matrix[x][y]==config_two then
return 0
end
if y>1 then
if matrix[x][y-1]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", x*10+y-1)
return 0
end
end
if y< #matrix[x] then
if matrix[x][y+1]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", x*10+y+1)
return 0
end
end
if x>1 then
if matrix[x-1][y]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", (x-1)*10+y)
return 0
end
end
if x < #matrix then
if matrix[x+1][y]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", (x+1)*10+y)
return 0
end
end
FaildProcess(context,"踩错")
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,147 @@
--[[
雷导立方
ServerUploadTool Save to [/root/env/data/lua/common/BlackBoxPlay]
square={
[1]={config_id=115001,rotation=0},
[2]={config_id=115002,rotation=90},
[3]={config_id=115003,rotation=180},
[4]={config_id=115004,rotation=270},
[5]={config_id=115005,rotation=0},
}
]]--
local stateChain={
{101,102,103,104},
{201,202,203,204},
{301,302,303,304},
}
local extraTriggers={
--{ config_id = 8000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
--{ config_id = 8000002, name = "PLATFORM_REACH_POINT", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_EVENT_PLATFORM_REACH_POINT", trigger_count = 0 },
{ config_id = 8000003, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
{ config_id = 8000004, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0,forbid_guest = false },
{ config_id = 8000005, name = "Gadget_State_Change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_GADGET_STATE_CHANGE", trigger_count = 0}
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
for i=1,#defs.repeater do
local time_trigger={ config_id = 8000000+defs.repeater[i], name = tostring(defs.repeater[i]), event = EventType.EVENT_TIMER_EVENT, source = tostring(defs.repeater[i]), condition = "", action = "action_Time_Event", trigger_count = 0}
table.insert(triggers, time_trigger)
table.insert(suites[1].triggers, time_trigger.name)
end
table.insert(variables, { config_id=50000001,name = "ShootTrigger", value = 0})
--初始化
end
function action_Time_Event(context,evt)
ScriptLib.PrintContextLog(context, "##反射装置TimeEvent"..defs.groupID.."|"..evt.source_name.."|"..evt.param3)
local temp_id=tonumber(evt.source_name)
ScriptLib.PrintContextLog(context, "temp_id##"..temp_id)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.groupID, temp_id, {54,55})
return 0
end
function action_GADGET_STATE_CHANGE(context,evt)
for i=1,#defs.repeater do
if evt.param2==defs.repeater[i] then
if evt.param3==0 and evt.param1~=0 then
ScriptLib.CreateGroupTimerEvent(context, defs.groupID, tostring(evt.param2), 3)
end
return 0
end
end
return 0
end
function action_gadget_create(context, evt)
for i=1,#defs.repeater do
if evt.param1==defs.repeater[i] then
if ScriptLib.GetGadgetStateByConfigId(context, defs.groupID, evt.param1) ~= 0 then
ScriptLib.CreateGroupTimerEvent(context, defs.groupID, tostring(evt.param1), 3)
end
return 0
end
end
return 0
end
--54转向 55仰角
function action_EVENT_SELECT_OPTION(context, evt)
for i=1,#defs.repeater do
if evt.param1==defs.repeater[i] then
if evt.param2==54 then
ChangeGadgetState(context,evt.param1,54)
ScriptLib.DelWorktopOptionByGroupId(context, defs.groupID, evt.param1, 54)
ScriptLib.DelWorktopOptionByGroupId(context, defs.groupID, evt.param1, 55)
ScriptLib.CreateGroupTimerEvent(context, defs.groupID, tostring(evt.param1), 3)
elseif evt.param2==55 then
ChangeGadgetState(context,evt.param1,55)
ScriptLib.DelWorktopOptionByGroupId(context, defs.groupID, evt.param1, 54)
ScriptLib.DelWorktopOptionByGroupId(context, defs.groupID, evt.param1, 55)
ScriptLib.CreateGroupTimerEvent(context, defs.groupID, tostring(evt.param1), 3)
end
return 0
end
end
return 0
end
function ChangeGadgetState(context,config_id,option_id)
local stateID=ScriptLib.GetGadgetStateByConfigId(context, defs.groupID, config_id)
for i=1,#stateChain do
for j=1,#stateChain[i] do
if stateID==stateChain[i][j] then
if option_id==54 then
if j==#stateChain[i] then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.groupID, config_id, stateChain[i][1])
return 0
else
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.groupID, config_id, stateChain[i][j+1])
return 0
end
end
if option_id==55 then
if i==#stateChain then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.groupID, config_id, stateChain[1][j])
return 0
else
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.groupID, config_id, stateChain[i+1][j])
return 0
end
end
end
end
end
return 0
end
function CutSceneTrigger(context)
local variable=ScriptLib.GetGroupVariableValue(context, "ShootTrigger")
variable=variable+1
ScriptLib.SetGroupVariableValue(context, "ShootTrigger", variable)
return 0
end
function CheckOroSealDie(context)
if CheckSuccess02(context)==true then
for i=1,#gadgets do
if gadgets[i].gadget_id==70900385 or gadgets[i].gadget_id==70950143 then
ScriptLib.PrintContextLog(context, "找到摧毁物了"..gadgets[i].config_id)
ScriptLib.KillEntityByConfigId(context, { config_id = gadgets[i].config_id })
end
end
else
ScriptLib.PrintContextLog(context, "成功与否判断没过")
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,130 @@
--[[
雷共鸣石黑河玩法
]]--
local light_stones_initial={
[1]=defs.gadget_1,
[2]=defs.gadget_2,
[3]=defs.gadget_3,
[4]=defs.gadget_4,
[5]=defs.gadget_5
}
local extraTriggers={
{ config_id = 8000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "successed", value = 0, no_refresh = true})
--初始化
end
function action_group_load(context, evt)
if ScriptLib.GetGroupVariableValue(context,"successed")~=0 then
for i=1,#light_stones_initial do
if light_stones_initial[i] ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, light_stones_initial[i], GadgetState.GearAction2)
end
end
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
return 0
end
return 0
end
function Generate_Table(light_stones_initial)
local outTable={}
for i=1,#light_stones_initial do
if light_stones_initial[i]~=0 then
table.insert(outTable,light_stones_initial[i])
end
end
return outTable
end
function Stone_Behit(context)
local light_stones=Generate_Table(light_stones_initial)
ScriptLib.PrintContextLog(context, "target_entity_id="..context.target_entity_id.." source_entity_id="..context.source_entity_id)
if ScriptLib.GetGroupVariableValue(context,"successed") ~=0 then
return 0
end
for i=1,#light_stones do
if context.target_entity_id==ScriptLib.GetEntityIdByConfigId(context,light_stones[i]) then
gadget_level_change(context,light_stones[i])
--非循环模式
if defs.loop_mode==0 then
if i-1>=1 then
gadget_level_change(context,light_stones[i-1])
end
if i+1 <= #light_stones then
gadget_level_change(context,light_stones[i+1])
end
end
--循环模式
if defs.loop_mode==1 then
if i-1<1 then
gadget_level_change(context,light_stones[#light_stones])
else
gadget_level_change(context,light_stones[i-1])
end
if i+1 > #light_stones then
gadget_level_change(context,light_stones[1])
else
gadget_level_change(context,light_stones[i+1])
end
end
break
end
end
if check_success(context,light_stones)==true then
for i=1,#light_stones do
if GadgetState.Action01 == ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, light_stones[i]) then
ScriptLib.SetGadgetStateByConfigId(context, light_stones[i], 9010)
elseif GadgetState.Action02 == ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, light_stones[i]) then
ScriptLib.SetGadgetStateByConfigId(context, light_stones[i], 9020)
elseif GadgetState.Action03 == ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, light_stones[i]) then
ScriptLib.SetGadgetStateByConfigId(context, light_stones[i], 9030)
end
end
ScriptLib.SetGroupVariableValue(context, "successed",1)
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
end
return 0
end
--检测是否达成目标
function check_success(context,light_stones)
if #light_stones<=1 then
return true
end
for i=1,#light_stones-1 do
if ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, light_stones[i])~=ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, light_stones[i+1]) then
return false
end
end
return true
end
--处理共鸣石的状态变化
function gadget_level_change(context,config_id)
if config_id==nil then
return 0
end
ScriptLib.PrintContextLog(context, "##config_id is "..config_id)
if GadgetState.Default == ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, config_id) then
ScriptLib.SetGadgetStateByConfigId(context, config_id, GadgetState.Action01)
elseif GadgetState.Action01 == ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, config_id) then
ScriptLib.SetGadgetStateByConfigId(context, config_id, GadgetState.Action02)
elseif GadgetState.Action02 == ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, config_id) then
ScriptLib.SetGadgetStateByConfigId(context, config_id, GadgetState.Action03)
elseif GadgetState.Action03 == ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, config_id) then
ScriptLib.SetGadgetStateByConfigId(context, config_id, GadgetState.Action01)
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,225 @@
--[[
雷导立方
square={
[1]={config_id=115001,rotation=0},
[2]={config_id=115002,rotation=90},
[3]={config_id=115003,rotation=180},
[4]={config_id=115004,rotation=270},
[5]={config_id=115005,rotation=0},
}
]]--
local square={
{config_id=defs.gadget_1,rotation=defs.rotation_1},
{config_id=defs.gadget_2,rotation=defs.rotation_2},
{config_id=defs.gadget_3,rotation=defs.rotation_3},
{config_id=defs.gadget_4,rotation=defs.rotation_4},
{config_id=defs.gadget_5,rotation=defs.rotation_5},
}
local connectRelation={
[defs.gadget_1]=defs.gadget_connect1,
[defs.gadget_2]=defs.gadget_connect2,
[defs.gadget_3]=defs.gadget_connect3,
[defs.gadget_4]=defs.gadget_connect4,
[defs.gadget_5]=defs.gadget_connect5,
}
local extraTriggers={
{ config_id = 8000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 8000002, name = "PLATFORM_REACH_POINT", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_EVENT_PLATFORM_REACH_POINT", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "successed", value = 0, no_refresh = true})
for i=1,#square do
if square[i].config_id ~= 0 then
table.insert(variables,{ config_id=50000000+square[i].config_id,name = square[i].config_id.."isrotating", value = 0})
table.insert(variables,{ config_id=51000000+square[i].config_id,name = square[i].config_id.."rotation", value = square[i].rotation})
end
end
--初始化
end
function SquareBeHit(context)
if ScriptLib.GetGroupVariableValue(context,"successed")~=0 then
return 0
end
for i=1,#square do
if square[i].config_id ~= 0 then
if context.target_entity_id == ScriptLib.GetEntityIdByConfigId(context, square[i].config_id) or context.source_entity_id== ScriptLib.GetEntityIdByConfigId(context, square[i].config_id) then
if CheckAllRotationDone(context) then
--if ScriptLib.GetGroupVariableValue(context,square[i].config_id.."isrotating") ==0 then
--ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 1)
--ScriptLib.SetPlatformPointArray(context, square[i].config_id, 322000031, { 1 }, { route_type = 0,turn_mode=true })
--local angle=ScriptLib.GetGroupVariableValue(context,square[i].config_id.."rotation")
--angle=(angle+90)%360
--ScriptLib.SetGroupVariableValue(context, square[i].config_id.."rotation",angle)
RotateGadget(context,square[i].config_id)
for j=1,#connectRelation[square[i].config_id] do
RotateGadget(context,connectRelation[square[i].config_id][j])
end
end
end
end
end
return 0
end
function RotateGadget(context,config_id)
ScriptLib.SetGroupVariableValue(context, config_id.."isrotating", 1)
ScriptLib.SetPlatformPointArray(context, config_id, 322000031, { 1 }, { route_type = 0,turn_mode=true })
local angle=ScriptLib.GetGroupVariableValue(context,config_id.."rotation")
angle=(angle+90)%360
ScriptLib.SetGroupVariableValue(context, config_id.."rotation",angle)
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201) -- gadget旋转过程特效
return 0
end
-- 底座物件表现
function RootGadgetEffect(context)
for i=1,#gadgets do
if ScriptLib.GetEntityIdByConfigId(context,gadgets[i].config_id) == 70330084 then
ScriptLib.SetGadgetStateByConfigId(context, gadgets[i].config_id, 201)
end
end
return 0
end
function CheckAllRotationDone(context)
for i=1,#square do
if ScriptLib.GetGroupVariableValue(context,square[i].config_id.."isrotating") ~=0 then
return false
end
end
return true
end
function action_EVENT_PLATFORM_REACH_POINT(context,evt)
ScriptLib.SetGroupVariableValue(context, evt.param1.."isrotating", 0)
CheckIsSuccess(context)
return 0
end
function action_group_load(context,evt)
if ScriptLib.GetGroupVariableValue(context,"successed")~=0 then
for i=1,#square do
if square[i].config_id ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, square[i].config_id, 901)
end
end
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
return 0
end
--groupload重置variable
for i=1,#square do
if square[i].config_id ~= 0 then
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."rotation", square[i].rotation)
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 0)
end
end
for i=1,#square do
if square[i].config_id ~= 0 then
if square[i].rotation==90 then
ScriptLib.SetPlatformPointArray(context, square[i].config_id, 322000031, { 1 }, { route_type = 0,turn_mode=true })
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 1)
end
if square[i].rotation==180 then
ScriptLib.SetPlatformPointArray(context, square[i].config_id, 322000031, { 2 }, { route_type = 0,turn_mode=true })
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 1)
end
if square[i].rotation==270 then
ScriptLib.SetPlatformPointArray(context, square[i].config_id, 322000031, { 3 }, { route_type = 0,turn_mode=true })
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 1)
end
end
end
return 0
end
function CheckIsSuccess(context)
local table0={}
local table90={}
local table180={}
local table270={}
local angle=999
local exitCount=0
for i=1,#square do
if square[i].config_id ~= 0 then
exitCount=exitCount+1
angle=ScriptLib.GetGroupVariableValue(context,square[i].config_id.."rotation")
if angle==0 then
table.insert(table0,square[i].config_id)
elseif angle==90 then
table.insert(table90,square[i].config_id)
elseif angle==180 then
table.insert(table180,square[i].config_id)
elseif angle==270 then
table.insert(table270,square[i].config_id)
end
end
end
if #table0>=exitCount or #table90>=exitCount or #table180>=exitCount or #table270>=exitCount then
for i=1,#square do
if square[i].config_id ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, square[i].config_id, 901)
end
end
ScriptLib.SetGroupVariableValue(context, "successed", 1)
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
RootGadgetEffect(context)
return 0
end
if #table0>1 then
for i=1,#table0 do
ScriptLib.SetGadgetStateByConfigId(context, table0[i], 902)
end
else
for i=1,#table0 do
ScriptLib.SetGadgetStateByConfigId(context, table0[i], 0)
end
end
if #table90>1 then
for i=1,#table90 do
ScriptLib.SetGadgetStateByConfigId(context, table90[i], 902)
end
else
for i=1,#table90 do
ScriptLib.SetGadgetStateByConfigId(context, table90[i], 0)
end
end
if #table180>1 then
for i=1,#table180 do
ScriptLib.SetGadgetStateByConfigId(context, table180[i], 902)
end
else
for i=1,#table180 do
ScriptLib.SetGadgetStateByConfigId(context, table180[i], 0)
end
end
if #table270>1 then
for i=1,#table270 do
ScriptLib.SetGadgetStateByConfigId(context, table270[i], 902)
end
else
for i=1,#table270 do
ScriptLib.SetGadgetStateByConfigId(context, table270[i], 0)
end
end
return 0
end
--local square=InitialData()
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,225 @@
--[[
雷导立方
square={
[1]={config_id=115001,rotation=0},
[2]={config_id=115002,rotation=90},
[3]={config_id=115003,rotation=180},
[4]={config_id=115004,rotation=270},
[5]={config_id=115005,rotation=0},
}
]]--
local square={
{config_id=defs.gadget_1,rotation=defs.rotation_1},
{config_id=defs.gadget_2,rotation=defs.rotation_2},
{config_id=defs.gadget_3,rotation=defs.rotation_3},
{config_id=defs.gadget_4,rotation=defs.rotation_4},
{config_id=defs.gadget_5,rotation=defs.rotation_5},
}
local connectRelation={
[defs.gadget_1]=defs.gadget_connect1,
[defs.gadget_2]=defs.gadget_connect2,
[defs.gadget_3]=defs.gadget_connect3,
[defs.gadget_4]=defs.gadget_connect4,
[defs.gadget_5]=defs.gadget_connect5,
}
local extraTriggers={
{ config_id = 8000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 8000002, name = "PLATFORM_REACH_POINT", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_EVENT_PLATFORM_REACH_POINT", trigger_count = 0 },
{ config_id = 8000003, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_EVENT_GADGET_CREATE", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "successed", value = 0, no_refresh = true})
for i=1,#square do
if square[i].config_id ~= 0 then
table.insert(variables,{ config_id=50000000+square[i].config_id,name = square[i].config_id.."isrotating", value = 0})
table.insert(variables,{ config_id=51000000+square[i].config_id,name = square[i].config_id.."rotation", value = square[i].rotation})
end
end
--初始化
end
function SquareBeHit(context)
if ScriptLib.GetGroupVariableValue(context,"successed")~=0 then
return 0
end
for i=1,#square do
if square[i].config_id ~= 0 then
if context.target_entity_id == ScriptLib.GetEntityIdByConfigId(context, square[i].config_id) or context.source_entity_id== ScriptLib.GetEntityIdByConfigId(context, square[i].config_id) then
if CheckAllRotationDone(context) then
RotateGadget(context,square[i].config_id)
for j=1,#connectRelation[square[i].config_id] do
RotateGadget(context,connectRelation[square[i].config_id][j])
end
end
end
end
end
return 0
end
function RotateGadget(context,config_id)
ScriptLib.SetGroupVariableValue(context, config_id.."isrotating", 1)
ScriptLib.SetPlatformPointArray(context, config_id, 322000031, { 1 }, { route_type = 0,turn_mode=true })
local angle=ScriptLib.GetGroupVariableValue(context,config_id.."rotation")
angle=(angle+90)%360
ScriptLib.SetGroupVariableValue(context, config_id.."rotation",angle)
ScriptLib.SetGadgetStateByConfigId(context, config_id, 201) -- gadget旋转过程特效
return 0
end
-- 底座物件表现
function RootGadgetEffect(context)
for i=1,#gadgets do
if ScriptLib.GetEntityIdByConfigId(context,gadgets[i].config_id) == 70330084 then
ScriptLib.SetGadgetStateByConfigId(context, gadgets[i].config_id, 201)
end
end
return 0
end
function CheckAllRotationDone(context)
for i=1,#square do
if ScriptLib.GetGroupVariableValue(context,square[i].config_id.."isrotating") ~=0 then
return false
end
end
return true
end
function action_EVENT_PLATFORM_REACH_POINT(context,evt)
ScriptLib.SetGroupVariableValue(context, evt.param1.."isrotating", 0)
CheckIsSuccess(context)
return 0
end
function action_group_load(context,evt)
if ScriptLib.GetGroupVariableValue(context,"successed")~=0 then
for i=1,#square do
if square[i].config_id ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, square[i].config_id, 901)
end
end
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
return 0
end
--groupload重置variable
for i=1,#square do
if square[i].config_id ~= 0 then
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."rotation", square[i].rotation)
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 0)
end
end
return 0
end
function action_EVENT_GADGET_CREATE(context,evt)
for i=1,#square do
if square[i].config_id==evt.param1 then
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 0)
if square[i].rotation==90 then
ScriptLib.SetPlatformPointArray(context, square[i].config_id, 322000031, { 1 }, { route_type = 0,turn_mode=true })
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 1)
end
if square[i].rotation==180 then
ScriptLib.SetPlatformPointArray(context, square[i].config_id, 322000031, { 2 }, { route_type = 0,turn_mode=true })
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 1)
end
if square[i].rotation==270 then
ScriptLib.SetPlatformPointArray(context, square[i].config_id, 322000031, { 3 }, { route_type = 0,turn_mode=true })
ScriptLib.SetGroupVariableValue(context, square[i].config_id.."isrotating", 1)
end
end
end
return 0
end
function CheckIsSuccess(context)
local table0={}
local table90={}
local table180={}
local table270={}
local angle=999
local exitCount=0
for i=1,#square do
if square[i].config_id ~= 0 then
exitCount=exitCount+1
angle=ScriptLib.GetGroupVariableValue(context,square[i].config_id.."rotation")
if angle==0 then
table.insert(table0,square[i].config_id)
elseif angle==90 then
table.insert(table90,square[i].config_id)
elseif angle==180 then
table.insert(table180,square[i].config_id)
elseif angle==270 then
table.insert(table270,square[i].config_id)
end
end
end
if #table0>=exitCount or #table90>=exitCount or #table180>=exitCount or #table270>=exitCount then
for i=1,#square do
if square[i].config_id ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, square[i].config_id, 901)
end
end
ScriptLib.SetGroupVariableValue(context, "successed", 1)
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
RootGadgetEffect(context)
return 0
end
if #table0>1 then
for i=1,#table0 do
ScriptLib.SetGadgetStateByConfigId(context, table0[i], 902)
end
else
for i=1,#table0 do
ScriptLib.SetGadgetStateByConfigId(context, table0[i], 0)
end
end
if #table90>1 then
for i=1,#table90 do
ScriptLib.SetGadgetStateByConfigId(context, table90[i], 902)
end
else
for i=1,#table90 do
ScriptLib.SetGadgetStateByConfigId(context, table90[i], 0)
end
end
if #table180>1 then
for i=1,#table180 do
ScriptLib.SetGadgetStateByConfigId(context, table180[i], 902)
end
else
for i=1,#table180 do
ScriptLib.SetGadgetStateByConfigId(context, table180[i], 0)
end
end
if #table270>1 then
for i=1,#table270 do
ScriptLib.SetGadgetStateByConfigId(context, table270[i], 902)
end
else
for i=1,#table270 do
ScriptLib.SetGadgetStateByConfigId(context, table270[i], 0)
end
end
return 0
end
--local square=InitialData()
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,108 @@
--[[
磁力机关 黑盒
ServerUploadTool Save to [/root/env/data/lua/common/BlackBoxPlay]
]]--
local fundations={
[1]=defs.gadget_fundation01,
[2]=defs.gadget_fundation02,
[3]=defs.gadget_fundation03,
[4]=defs.gadget_fundation04,
[5]=defs.gadget_fundation05,
}
local hands={
[1]=defs.gadget_hand01,
[2]=defs.gadget_hand02,
[3]=defs.gadget_hand03,
[4]=defs.gadget_hand04,
[5]=defs.gadget_hand05,
}
local extraTriggers={
{ config_id = 8000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 8000002, name = "TIME_AXIS", event = EventType.EVENT_TIME_AXIS_PASS, source = "checkSuccess", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "successed", value = 0, no_refresh = true})
--初始化
end
function NormalizationAngles(input)
local output=input
return math.abs(180-(180-output)%360)
end
function action_group_load(context, evt)
if ScriptLib.GetGroupVariableValue(context, "successed")~=1 then
ScriptLib.InitTimeAxis(context, "checkSuccess", {1}, true)
return 0
end
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
--ScriptLib.PrintContextLog(context, "挑战已经完成")
local pos={}
local rot={}
for i=1,5 do
if hands[i] ~= 0 then
ScriptLib.RemoveEntityByConfigId(context, defs.group_ID, EntityType.GADGET, hands[i])
for j=1,#gadgets do
if gadgets[j].config_id==hands[i] then
pos=gadgets[j].pos
end
if gadgets[j].config_id==fundations[i] then
rot=gadgets[j].rot
end
end
--ScriptLib.PrintContextLog(context, "位置"..pos.x.." "..pos.y.." "..pos.z.." "..rot.x.." "..rot.y.." "..rot.z)
ScriptLib.CreateGadgetByConfigIdByPos(context, hands[i], pos, rot)
ScriptLib.SetGadgetStateByConfigId(context, hands[i], 201)
ScriptLib.SetGadgetStateByConfigId(context, fundations[i], 201)
end
end
return 0
end
function action_time_axis_pass(context, evt)
local count=0
local y1=0
local y2=0
for i=1,5 do
if fundations[i]~=0 then
y1=ScriptLib.GetRotationByEntityId(context, ScriptLib.GetEntityIdByConfigId(context, fundations[i])).y
y2=ScriptLib.GetRotationByEntityId(context, ScriptLib.GetEntityIdByConfigId(context, hands[i])).y
if y1<0 or y1>360 or y2<0 or y2>360 then
return 0
end
end
if fundations[i]==0 then
count=count+1
elseif NormalizationAngles(y1-y2) <= defs.minDiscrapancy then
count=count+1
ScriptLib.SetGadgetStateByConfigId(context, fundations[i], 201)
else
ScriptLib.SetGadgetStateByConfigId(context, fundations[i], 0)
end
end
--ScriptLib.PrintContextLog(context, "count is "..count)
if count>=5 then
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
for i=1,5 do
if hands[i] ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, hands[i], 201)
end
end
ScriptLib.PauseTimeAxis(context, "checkSuccess")
ScriptLib.SetGroupVariableValue(context, "successed", 1)
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,394 @@
--[[
对位传送门 黑盒
]]--
local extraTriggers={
{ config_id = 1154013, name = "GROUP_LOAD_154013", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD_154013", trigger_count = 0 },
{ config_id = 1154014, name = "SELECT_OPTION_154014", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "condition_EVENT_SELECT_OPTION_154014", action = "action_EVENT_SELECT_OPTION_154014", trigger_count = 0 },
{ config_id = 1154015, name = "PLATFORM_REACH_POINT_154015", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "condition_EVENT_PLATFORM_REACH_POINT_154015", action = "action_EVENT_PLATFORM_REACH_POINT_154015", trigger_count = 0 },
{ config_id = 1154016, name = "TIME_AXIS_PASS_15016", event = EventType.EVENT_TIME_AXIS_PASS, source = "InitialEnding", condition = "", action = "action_EVENT_TIME_AXIS_PASS_15016", trigger_count = 0 }
}
local extralVariables={
{ config_id=50000001,name = "gadget_Teleport_1_isActive", value = 0, no_refresh = true },
{ config_id=50000002,name = "gadget_Teleport_2_isActive", value = 0, no_refresh = true },
{ config_id=50000003,name = "gadget_Teleport_3_isActive", value = 0, no_refresh = true },
{ config_id=50000004,name = "gadget_Teleport_4_isActive", value = 0, no_refresh = true },
{ config_id=50000005,name = "gadget_Teleport_1_state", value = 0, no_refresh = true },
{ config_id=50000006,name = "gadget_Teleport_2_state", value = 0, no_refresh = true },
{ config_id=50000007,name = "gadget_Teleport_3_state", value = 0, no_refresh = true },
{ config_id=50000008,name = "gadget_Teleport_4_state", value = 0, no_refresh = true },
{ config_id=50000009,name = "isInitial", value = 1, no_refresh = false }
}
function LF_Initialize_Group(triggers,suites,variables)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
for i=1,#extralVariables do
table.insert(variables, extralVariables[i])
end
--初始化
end
----Misc----
TeleportOwnerShip =
{
{defs.gadget_TeleportOperator_1, defs.gadget_Teleport_1},
{defs.gadget_TeleportOperator_2, defs.gadget_Teleport_2},
{defs.gadget_TeleportOperator_3, defs.gadget_Teleport_3},
{defs.gadget_TeleportOperator_4, defs.gadget_Teleport_4}
}
staticForwardSet = {1,2,3,4,5,6,7,8,9,10}
staticBackwardSet = {10,9,8,7,6,5,4,3,2,1}
function GetTeleportNameByConfigID(context, config_id)
for k,v in pairs(defs) do
if v == config_id then
return k
end
end
end
function InitialTeleportRotationY(context)
local rot
local name
local localtarget
ScriptLib.PrintLog("Initial starting...")
ScriptLib.SetGroupVariableValue(context,"isInitial",1)
for i=1,4 do
localtarget = TeleportOwnerShip[i][2]
if isTeleportValid(context,localtarget)==true then
ScriptLib.PrintLog("Initial localtarget = "..localtarget)
if localtarget ~= 0 then
name = GetTeleportNameByConfigID(context,localtarget).."_state"
rot = ScriptLib.GetGroupVariableValue(context,name)
ScriptLib.PrintLog("Initial gadgetName = "..name .. " , Rot = "..rot)
if rot == 90 then
ScriptLib.SetPlatformPointArray(context, localtarget, defs.pointarray_Rotate, { 1 }, { route_type = 0,turn_mode=true })
elseif rot == 180 then
ScriptLib.SetPlatformPointArray(context, localtarget, defs.pointarray_Rotate, { 2 }, { route_type = 0,turn_mode=true })
elseif rot == 270 then
ScriptLib.SetPlatformPointArray(context, localtarget, defs.pointarray_Rotate, { 3 }, { route_type = 0,turn_mode=true })
end
end
end
end
ScriptLib.PrintLog("Initial ending...")
end
function InitialTeleportState(context)
local tempname
local localtarget
for i=1,4 do
tempname = "gadget_Teleport_"..i.."_isActive"
localtarget = TeleportOwnerShip[i][2]
if isTeleportValid(context,localtarget)==true then
if ScriptLib.GetGroupVariableValue(context,tempname) == 1 then
ScriptLib.SetGadgetStateByConfigId(context, TeleportOwnerShip[i][2], GadgetState.GearStart)
else
ScriptLib.SetGadgetStateByConfigId(context, TeleportOwnerShip[i][2], GadgetState.Default)
end
end
end
end
function isTeleportValid(context,teleportID)
local result = false
local state = ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, teleportID)
if state ~= -1 then
result = true
end
--[[ local suiteindex = ScriptLib.GetGroupSuite(context, defs.group_ID)
for i=1, #suites[suiteindex].gadgets do
if teleportID == suites[suiteindex].gadgets[i] then
result = true
return result
end
end ]]
return result
end
function CheckIsConnected(context,teleport_aID,teleport_bID)
if not (isTeleportValid(context,teleport_aID)) or not (isTeleportValid(context,teleport_bID)) then
return false
end
--获取角度
ScriptLib.PrintLog("CheckConnected from "..teleport_aID .. " to "..teleport_bID)
local yrotation_a = ScriptLib.GetRotationByEntityId(context, ScriptLib.GetEntityIdByConfigId(context,teleport_aID)).y
local yrotation_b = ScriptLib.GetRotationByEntityId(context, ScriptLib.GetEntityIdByConfigId(context,teleport_bID)).y
ScriptLib.PrintLog("yrotation_a = "..yrotation_a .. "| yrotation_a = "..yrotation_b)
--转换为弧度
local yrad_a = math.rad(yrotation_a)
local yrad_b = math.rad(yrotation_b)
ScriptLib.PrintLog("yrad_a = "..yrad_a .. "| yrad_b = "..yrad_b)
--编辑器中的XZ和运行下的对应关系是反的,所以这里XZ左边调换了一下
local dir_a = {x = math.sin(yrad_a), y = 0, z = math.cos(yrad_a)}
local dir_b = {x = math.sin(yrad_b), y = 0, z = math.cos(yrad_b)}
ScriptLib.PrintLog("dir_a : x = "..dir_a.x.." , y = "..dir_a.y.." , z = "..dir_a.z)
ScriptLib.PrintLog("dir_b : x = "..dir_b.x.." , y = "..dir_b.y.." , z = "..dir_b.z)
--获取两个点位置
local pos_a = ScriptLib.GetPosByEntityId(context, ScriptLib.GetEntityIdByConfigId(context,teleport_aID))
ScriptLib.PrintLog("pos_a : x = "..pos_a.x.." , y = "..pos_a.y.." , z = "..pos_a.z)
local pos_b = ScriptLib.GetPosByEntityId(context, ScriptLib.GetEntityIdByConfigId(context,teleport_bID))
ScriptLib.PrintLog("pos_b : x = "..pos_b.x.." , y = "..pos_b.y.." , z = "..pos_b.z)
--计算两个点之间的方向,并且Normalize
local diratob = {x = pos_b.x - pos_a.x,y = 0,z = pos_b.z - pos_a.z}
local norDirAtoB = Normalize({x = pos_b.x - pos_a.x,y = 0,z = pos_b.z - pos_a.z})
ScriptLib.PrintLog("norDirAtoB : x = "..norDirAtoB.x.." , y = "..norDirAtoB.y.." , z = "..norDirAtoB.z)
local dirbtoa = {x = pos_a.x - pos_b.x,y = 0,z = pos_a.z - pos_b.z}
local norDirBtoA = Normalize({x = pos_a.x - pos_b.x,y = 0,z = pos_a.z - pos_b.z})
ScriptLib.PrintLog("norDirBtoA : x = "..norDirBtoA.x.." , y = "..norDirBtoA.y.." , z = "..norDirBtoA.z)
--计算两个点的点乘结果
local dotvalue_a = dir_a.x * norDirAtoB.x + dir_a.y * norDirAtoB.y + dir_a.z * norDirAtoB.z
local dotvalue_b = dir_b.x * norDirBtoA.x + dir_b.y * norDirBtoA.y + dir_b.z * norDirBtoA.z
ScriptLib.PrintLog("dotvalue_a "..dotvalue_a)
ScriptLib.PrintLog("dotvalue_b "..dotvalue_b)
--判断点乘结果是否大于0.5,也就是正负 45度范围
if dotvalue_a >= 0.5 and dotvalue_b >= 0.5 then
return true
end
ScriptLib.PrintLog("invalid cos = ".. dotvalue_a)
return false
end
--获取所有关联的传送点
function FindRelatedTargets(context,teleport_ID)
local relatedtarget ={}
for i=1,#connectInfo do
if connectInfo[i][1] == teleport_ID or connectInfo[i][2] == teleport_ID then
if connectInfo[i][1] == teleport_ID then
--链接的Gadget ID, 对应的点阵ID, 点阵的indexArray, 速度
table.insert(relatedtarget,{connectInfo[i][2],connectInfo[i][3],staticForwardSet,connectInfo[i][4]})
elseif connectInfo[i][2] == teleport_ID then
table.insert(relatedtarget,{connectInfo[i][1],connectInfo[i][3],staticBackwardSet,connectInfo[i][4]})
end
end
end
return relatedtarget
end
--在所有关联传送点中找到激活链接的,如果没有则返回nil
function GetConnectedTeleport(context,teleport_id)
local related
related = FindRelatedTargets(context,teleport_id)
for i=1,#related do
if CheckIsConnected(context,teleport_id,related[i][1]) == true then
return related[i]
end
end
return nil
end
--数学计算归一化
function Normalize(vet)
local magnitude = math.sqrt(vet.x * vet.x + vet.y * vet.y + vet.z * vet.z)
local newvect = {x = vet.x/magnitude, y = vet.y / magnitude, z = vet.z / magnitude}
return newvect
end
--更新所有传送门的状态表现
function UpdateTeleportState(context)
local teleportname
for i=1,4 do
local connect = GetConnectedTeleport(context,TeleportOwnerShip[i][2])
if connect == nil then
ScriptLib.SetGadgetStateByConfigId(context, TeleportOwnerShip[i][2], GadgetState.Default)
teleportname = GetTeleportNameByConfigID(context, TeleportOwnerShip[i][2])
teleportname = teleportname.."_isActive"
ScriptLib.SetGroupVariableValue(context, teleportname, 0)
ScriptLib.PrintLog("connect nothing : "..i)
else
--ScriptLib.PrintLog("connect count = "..#connect)
--ScriptLib.PrintLog("connect{"..connect[1].." , "..connect[2].." , "..connect[3].."}")
ScriptLib.SetGadgetStateByConfigId(context, TeleportOwnerShip[i][2], GadgetState.GearStart)
teleportname = GetTeleportNameByConfigID(context, TeleportOwnerShip[i][2])
teleportname = teleportname.."_isActive"
ScriptLib.SetGroupVariableValue(context, teleportname, 1)
ScriptLib.PrintLog("connect something = "..i)
end
end
end
--传送玩家, 只要给到对应的Teleportid就可以
function TeleportAction(context,teleport_id)
local related = FindRelatedTargets(context, teleport_id)
for i=1,#related do
if CheckIsConnected(context,teleport_id,related[i][1]) == true then
ScriptLib.MoveAvatarByPointArray(context, context.uid, related[i][2], related[i][3], {speed=related[i][4]}, "{\"MarkType\":1}")
return 0
end
end
end
----ActionFunction---
function action_EVENT_GROUP_LOAD_154013(context, evt)
InitialTeleportRotationY(context)
InitialTeleportState(context)
ScriptLib.InitTimeAxis(context, "InitialEnding", {1}, false)
return 0
end
function action_EVENT_TIME_AXIS_PASS_15016(context, evt)
UpdateTeleportState(context)
if defs.gadget_TeleportOperator_1 ~= 0 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_1, {31})
end
if defs.gadget_TeleportOperator_2 ~= 0 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_2, {31})
end
if defs.gadget_TeleportOperator_3 ~= 0 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_3, {31})
end
if defs.gadget_TeleportOperator_4 ~= 0 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_4, {31})
end
return 0
end
function condition_EVENT_SELECT_OPTION_154014(context, evt)
-- 判断是gadgetid 124006 option_id 31
if defs.gadget_TeleportOperator_1 ~= evt.param1 and
defs.gadget_TeleportOperator_2 ~= evt.param1 and
defs.gadget_TeleportOperator_3 ~= evt.param1 and
defs.gadget_TeleportOperator_4 ~= evt.param1 then
return false
end
if 31 ~= evt.param2 then
return false
end
return true
end
-- 触发操作
function action_EVENT_SELECT_OPTION_154014(context, evt)
local localtarget
local localoption
for i=1,4 do
if TeleportOwnerShip[i][1] == evt.param1 then
localtarget = TeleportOwnerShip[i][2]
localoption = TeleportOwnerShip[i][1]
end
end
--旋转时取消所有的Option
if defs.gadget_TeleportOperator_1 ~= 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_1, 31)
end
if defs.gadget_TeleportOperator_2 ~= 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_2, 31)
end
if defs.gadget_TeleportOperator_3 ~= 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_3, 31)
end
if defs.gadget_TeleportOperator_4 ~= 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_4, 31)
end
ScriptLib.SetGroupVariableValue(context,"isInitial",0)
ScriptLib.PrintLog("evt.gadgetid = "..evt.param1)
ScriptLib.PrintLog("localtarget = "..localtarget)
ScriptLib.SetPlatformPointArray(context, localtarget, defs.pointarray_Rotate, { 1 }, { route_type = 0,turn_mode=true })
ScriptLib.MarkPlayerAction(context, 7004, 3, 1)
return 0
end
function condition_EVENT_PLATFORM_REACH_POINT_154015(context, evt)
-- 判断是gadgetid 124006 option_id 31
ScriptLib.PrintLog("Reachpoint_condition : "..evt.param1)
if defs.gadget_Teleport_1 ~= evt.param1 and
defs.gadget_Teleport_2 ~= evt.param1 and
defs.gadget_Teleport_3 ~= evt.param1 and
defs.gadget_Teleport_4 ~= evt.param1 then
return false
end
if ScriptLib.GetGroupVariableValue(context,"isInitial") ~= 0 then
return false
end
return true
end
-- 触发操作
function action_EVENT_PLATFORM_REACH_POINT_154015(context, evt)
-- 判断是gadgetid 124006 option_id 31
ScriptLib.PrintLog("Reachpoint_action : "..evt.param1)
--旋转完成后再重新加回所有的Option
if defs.gadget_TeleportOperator_1 ~= 0 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_1, {31})
end
if defs.gadget_TeleportOperator_2 ~= 0 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_2, {31})
end
if defs.gadget_TeleportOperator_3 ~= 0 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_3, {31})
end
if defs.gadget_TeleportOperator_4 ~= 0 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_ID, defs.gadget_TeleportOperator_4, {31})
end
UpdateTeleportState(context)
-- set teleprot rotation and save to group variable
local name = GetTeleportNameByConfigID(context,evt.param1).."_state"
ScriptLib.PrintLog("gadgetname = "..name)
local prerot = ScriptLib.GetGroupVariableValue(context,name)
ScriptLib.PrintLog("prerot = ".. prerot)
prerot = prerot + defs.rotStep
if prerot >= 360 then
prerot = 0
end
ScriptLib.PrintLog("prerot ++ = ".. prerot)
ScriptLib.SetGroupVariableValue(context,name,prerot)
return 0
end
LF_Initialize_Group(triggers, suites, variables)
@@ -0,0 +1,385 @@
local extrTriggers = {
initialtrigger = {
--["Group_Load"] = { config_id = 8000001, name = "Group_Load", event= EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_on_group_load", trigger_count = 0 },
["TimeAxis_Event"] = { config_id = 6000001, name = "TimeAxis_Event", event= EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_trigger_timeacis", trigger_count = 0 },
["Gallery_Stop"] = {name = "gallery_stop", config_id = 6000002, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
--["Open_Door"] = {name = "open_door", config_id = 6000003, event = EventType.EVENT_TIMER_EVENT, source = "opendoordelay", condition = "", action = "action_open_door_delay", trigger_count = 0},
["Player_Destination"] = { config_id = 6000004, name = "player_destination", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_player_destination", action = "action_player_destination", forbid_guest = false, trigger_count = 0 },
["Rrandom_Flora1"] = { config_id = 6000005, name = "random_flora1", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_random_flora1", action = "action_random_flora1", forbid_guest = false },
["Rrandom_Flora2"] = { config_id = 6000006, name = "random_flora2", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_random_flora2", action = "action_random_flora2", forbid_guest = false },
["Rrandom_Flora3"] = { config_id = 6000007, name = "random_flora3", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_random_flora3", action = "action_random_flora3", forbid_guest = false },
["Rrandom_Flora4"] = { config_id = 6000008, name = "random_flora4", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_random_flora4", action = "action_random_flora4", forbid_guest = false }
}
}
local openDoorAxis = {5, 8, bubble_delay_sec, 17}
-- function action_on_group_load( context, evt )
-- -- 初始化计数变量
-- ScriptLib.SetGroupTempValue(context, "Times", 1, {})
-- ScriptLib.SetGroupTempValue(context, "BubbleSequence", 1, {})
-- end
function StartGallery( context, prev_context, activeStage )
-- 开启小游戏玩法
ScriptLib.AddExtraGroupSuite(context, BubbleGroupID, 2)
if BubbleStep[activeStage].BubbleSpSuite ~=0 then
ScriptLib.PrintContextLog(context, "Extra BubbleSpSuite Is ->"..BubbleStep[activeStage].BubbleSpSuite)
ScriptLib.AddExtraGroupSuite(context, BubbleGroupID, BubbleStep[activeStage].BubbleSpSuite)
end
ScriptLib.SetGroupTempValue(context, "Times", 1, {})
ScriptLib.SetGroupTempValue(context, "BubbleSequence", 1, {})
ScriptLib.SetGroupTempValue(context, "Player_In_Des", 0, {})
ScriptLib.SetGroupTempValue(context, "activeStage", activeStage, {})
--初始化一个时间轴
ScriptLib.PrintContextLog(context, "BubbleGame Start")
--延时开门
ScriptLib.InitTimeAxis(context, "opendoordelay", openDoorAxis, false)
ScriptLib.ShowReminder(context, 358000001)
ScriptLib.InitTimeAxis(context, "BubbleGameTimmer", TimeAxis, false)
-- 开启gallery
ScriptLib.StartGallery(context, galleryID)
return 0
end
function condition_random_flora1( context,evt )
if evt.param1 ~= flower_region_id[1] then return false end
-- 判断角色数量不少于1
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
return false
end
return true
end
function condition_random_flora2( context,evt )
if evt.param1 ~= flower_region_id[2] then return false end
-- 判断角色数量不少于1
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
return false
end
return true
end
function condition_random_flora3( context,evt )
if evt.param1 ~= flower_region_id[3] then return false end
-- 判断角色数量不少于1
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
return false
end
return true
end
function condition_random_flora4( context,evt )
if evt.param1 ~= flower_region_id[4] then return false end
-- 判断角色数量不少于1
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
return false
end
return true
end
function condition_player_destination( context,evt )
if evt.param1 ~= RegionID then return false end
-- 判断角色数量不少于1
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
return false
end
return true
end
function action_random_flora1( context,evt)
local GadgetList = {}
for i,v in ipairs(suites[flower_suite_index[1]].gadgets) do
table.insert(GadgetList,v)
end
RandomFlora(context,random_flower_sum.min, random_flower_sum.max, GadgetList)
return 1
end
function action_random_flora2( context,evt)
local GadgetList = {}
for i,v in ipairs(suites[flower_suite_index[2]].gadgets) do
table.insert(GadgetList,v)
end
RandomFlora(context,random_flower_sum.min, random_flower_sum.max, GadgetList)
return 1
end
function action_random_flora3( context,evt)
local GadgetList = {}
for i,v in ipairs(suites[flower_suite_index[3]].gadgets) do
table.insert(GadgetList,v)
end
RandomFlora(context,random_flower_sum.min, random_flower_sum.max, GadgetList)
return 1
end
function action_random_flora4( context,evt)
local GadgetList = {}
for i,v in ipairs(suites[flower_suite_index[4]].gadgets) do
table.insert(GadgetList,v)
end
RandomFlora(context,random_flower_sum.min, random_flower_sum.max, GadgetList)
return 1
end
function RandomFlora( context, minNum, maxNum, GadgetList )
-- 随机抽取suit中的蓝色风之花创建
math.randomseed(ScriptLib.GetServerTime(context))
randomNum = math.random(minNum, maxNum)
for i=1,randomNum do
local configIndex = math.random(#GadgetList)
ScriptLib.CreateGadget(context, { config_id = GadgetList[configIndex] })
table.remove(GadgetList,configIndex)
end
return 0
end
function action_player_destination( context,evt)
if ScriptLib.GetGroupTempValue(context, "Player_In_Des"..context.uid, {}) == 1 then
return 0
end
local GameStartTime = ScriptLib.GetGroupTempValue(context, "GameStartTime", {})
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, "get_destination_bubblegame", context.uid, ScriptLib.GetServerTime(context) - GameStartTime)
ScriptLib.PrintContextLog(context, "##WINDFLORA_LOG: PLAYER GET DESTINATION UID IS->"..context.uid)
ScriptLib.ChangeGroupTempValue(context, "Player_In_Des", 1, {})
ScriptLib.SetGroupTempValue(context, "Player_In_Des"..context.uid, 1, {})
local Player_In_Des = ScriptLib.GetGroupTempValue(context, "Player_In_Des", {})
local UidList = ScriptLib.GetSceneUidList(context)
if Player_In_Des >= #UidList then
ScriptLib.StopGallery(context, galleryID, false)
else
ScriptLib.FinishFleurFairGalleryStageByUid(context, 235800001, 1, context.uid, false)
end
return 0
end
function action_open_door_delay( context,evt )
end
function action_gallery_stop( context,evt )
-- 游廊结束时,判断是否超时
ScriptLib.PrintContextLog(context, "BubbleGame Stop!!!!!")
for i=2,#suites do
ScriptLib.RemoveExtraGroupSuite(context, BubbleGroupID, i)
end
Achivment(context)
if evt.param2 == 0 then
ScriptLib.ExecuteGroupLua(context, 235800001, "EndPlayStage", {0,BubbleGroupID})
else
ScriptLib.ExecuteGroupLua(context, 235800001, "EndPlayStage", {1,BubbleGroupID})
end
return 0
end
function Achivment( context )
--根据玩家行为进行结算
local UidList = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(UidList) do
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, collect_energy, v, 5 * ScriptLib.GetSceneMultiStagePlayUidValue(context,235800001, 1, "get_random_flora", v))
if ScriptLib.GetSceneMultiStagePlayUidValue(context,235800001, 1, "get_destination_bubblegame", v) > 0 then
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, "get_destination_bubblegame", v, ScriptLib.GetSceneMultiStagePlayUidValue(context,235800001, 1, "get_destination_bubblegame", v))
ScriptLib.AddFleurFairMultistagePlayBuffEnergy(context, 235800001, 1, v, Bubble_TimeScore)
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, complete_timelimit_challenge, v, Bubble_TimeScore )
ScriptLib.PrintContextLog(context, "##WINDFLORA_LOG: PLAYER GET DESTINATION ENERGY UID IS->"..v)
--watcher结算
ScriptLib.SetSceneMultiStagePlayUidValue(context, 235800001, 1, "watcher_hit_by_bubble", v, ScriptLib.GetSceneMultiStagePlayUidValue(context,235800001, 1, "hit_by_bubble", v))
if ScriptLib.GetSceneMultiStagePlayUidValue(context,235800001, 1, "hit_by_bubble", v) == 0 then
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, perfect_complete_timelimit_challenge, v, Bubble_PerfectScore )
ScriptLib.AddFleurFairMultistagePlayBuffEnergy(context, 235800001, 1, v, Bubble_PerfectScore)
end
else
--watcher结算
ScriptLib.SetSceneMultiStagePlayUidValue(context, 235800001, 1, "watcher_hit_by_bubble", v, -1)
--未完成挑战强行设置泡泡命中参数
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, "hit_by_bubble", v, -1)
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, "get_destination_bubblegame", v, 100)
ScriptLib.AddFleurFairMultistagePlayBuffEnergy(context, 235800001, 1, v, Bubble_TimeOutScore)
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, defeated_timelimit_challenge, v, Bubble_TimeOutScore )
end
end
return 0
end
function action_trigger_timeacis( context, evt)
-- 触发泡泡发射
local activeStage = ScriptLib.GetGroupTempValue(context, "activeStage", {})
if evt.source_name == "opendoordelay" and evt.param1 == 1 then
ScriptLib.ShowReminder(context, 358000002)
elseif evt.source_name == "opendoordelay" and evt.param1 == 2 then
ScriptLib.ShowReminder(context, 358000003)
elseif evt.source_name == "opendoordelay" and evt.param1 == 3 then
ScriptLib.SetGroupTempValue(context, "GameStartTime", ScriptLib.GetServerTime(context), {})
ScriptLib.SetGroupGadgetStateByConfigId(context, BubbleGroupID, BubbleWallID, 201)
elseif evt.source_name == "opendoordelay" and evt.param1 == 4 and BubbleStep[activeStage].BubbleSpSuite ==21 then
ScriptLib.ShowReminder(context, 358000012)
elseif evt.source_name == "opendoordelay" and evt.param1 == 4 and BubbleStep[activeStage].BubbleSpSuite ~=21 then
ScriptLib.ShowReminder(context, 358000011)
end
if evt.source_name == "BubbleGameTimmer" then
local bubbleWeightList = BubbleStep[activeStage].list
RandomBubbleNum(context,bubbleWeightList)
end
-- if evt.param1%3 == 0 then
-- RandomFlora(context,random_flower_sum.min, random_flower_sum.max)
-- end
return 0
end
function RandomBubbleNum(context,bubbleWeightList)
math.randomseed(ScriptLib.GetServerTime(context))
local Times = ScriptLib.GetGroupTempValue(context, "Times", {})
--ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : Time Is -> "..Times)
randomWeight = math.random(100)
local CurNum = 0
for i,v in ipairs(bubbleWeightList[Times]) do
if v.weight >= randomWeight then
CurNum = v.Num
break
end
randomWeight = randomWeight - v.weight
end
ScriptLib.ChangeGroupTempValue(context, "Times", 1, {})
Times = ScriptLib.GetGroupTempValue(context, "Times", {})
if Times > #bubbleWeightList then
ScriptLib.SetGroupTempValue(context, "Times", 1, {})
end
--ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : Bubble Num Is -> "..CurNum)
RandomBubbleCP(context,CurNum)
return 0
end
function RandomBubbleCP(context, Num)
math.randomseed(ScriptLib.GetServerTime(context))
local BubbleSequence = ScriptLib.GetGroupTempValue(context, "BubbleSequence", {})
--ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : BubbleSequence Is -> "..BubbleSequence)
local TempBubbles = {}
for i,v in ipairs(Bubbles) do
table.insert(TempBubbles,v)
end
for i=1,Num do
randomIndex = math.random(#TempBubbles)
ScriptLib.SetGroupGadgetStateByConfigId(context, BubbleGroupID, TempBubbles[randomIndex], 901)
--ScriptLib.CreateGadget(context, { config_id = TempBubbles[randomIndex] })
--ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : Bubble ConfigID Is -> "..TempBubbles[randomIndex])
table.remove(TempBubbles, randomIndex)
end
ScriptLib.ChangeGroupTempValue(context, "BubbleSequence", 1, {})
BubbleSequence = ScriptLib.GetGroupTempValue(context, "BubbleSequence", {})
-- if BubbleSequence > #Bubbles then
-- ScriptLib.SetGroupTempValue(context, "BubbleSequence", 1, {})
-- end
return 0
end
function LF_Initialize_Group()
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Group()
@@ -0,0 +1,68 @@
function BubblePlatform(context)
math.randomseed(ScriptLib.GetServerTime(context))
local WindFloraCreator = { [1] =2035, [2] =2036, [3] =2037,}
local WindFloraCreatorDev = 0
local randomNum = math.random(1,100)
--WindFloraCreatorDev = ScriptLib.GetGroupVariableValueByGroup(context, "WindFloraNum", 250041002) * 3
WindFloraCreatorDev = ScriptLib.GetGroupVariableValue(context, "WindFloraNum") * 3
ScriptLib.PrintContextLog(context, "##001 WindFloraCreatorDev = "..WindFloraCreatorDev)
--ScriptLib.ChangeGroupVariableValueByGroup(context, "WindFloraNum", 1, 250041002)
ScriptLib.ChangeGroupVariableValue(context, "WindFloraNum", 1)
if WindFloraCreatorDev <= 30 then
WindFloraCreator[1] = WindFloraCreator[1] + WindFloraCreatorDev
WindFloraCreator[2] = WindFloraCreator[2] + WindFloraCreatorDev
WindFloraCreator[3] = WindFloraCreator[3] + WindFloraCreatorDev
end
--WindFloraCreatorDev = ScriptLib.GetGroupVariableValueByGroup(context, "WindFloraNum", 250041002)
WindFloraCreatorDev = ScriptLib.GetGroupVariableValue(context, "WindFloraNum")
ScriptLib.PrintContextLog(context, "##001 WindFloraCreatorDev = "..WindFloraCreatorDev)
if randomNum<30 then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[1] })
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[2] })
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[3] })
elseif randomNum<40 then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[1] })
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[2] })
elseif randomNum<50 then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[1] })
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[3] })
elseif randomNum<60 then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[2] })
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[3] })
elseif randomNum<70 then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[1] })
elseif randomNum<80 then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[2] })
elseif randomNum<90 then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[3] })
else
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[1] })
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[3] })
end
--[[if (bit.band(randomNum, 1) > 0) then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[1] })
ScriptLib.StartPlatform(context, WindFloraCreator[1])
--end
--if (bit.band(randomNum, 2) > 0) then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[2] })
ScriptLib.StartPlatform(context, WindFloraCreator[2])
--end
--if (bit.band(randomNum, 4) > 0) then
ScriptLib.CreateGadget(context, { config_id = WindFloraCreator[3] })
ScriptLib.StartPlatform(context, WindFloraCreator[3])
--end]]
end
@@ -0,0 +1,184 @@
local extrTriggers = {
initialtrigger = {
--["Group_Load"] = { config_id = 8000001, name = "Group_Load", event= EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_on_group_load", trigger_count = 0 },
["TimeAxis_Event"] = { config_id = 7000001, name = "TimeAxis_Event", event= EventType.EVENT_TIME_AXIS_PASS, source = "BulletGameTimmer", condition = "", action = "action_trigger_timeacis", trigger_count = 0 },
["Flora_LifeTime"] = {name = "Flora_LifeTime", config_id = 7000002, event = EventType.EVENT_TIMER_EVENT, source = "floralifetime", condition = "", action = "action_flora_life_time", trigger_count = 0},
["Gallery_Stop"] = {name = "gallery_stop", config_id = 7000003, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0}
}
}
function StartGallery( context, prev_context, activeStage )
-- 开启小游戏玩法
ScriptLib.AddExtraGroupSuite(context, GroupId, 2)
ScriptLib.SetGroupTempValue(context, "Times", 1, {})
--初始化一个时间轴
ScriptLib.PrintContextLog(context, "BulletGame Start")
ScriptLib.InitTimeAxis(context, "BulletGameTimmer", TimeAxis, false)
ScriptLib.SetGroupTempValue(context, "activeStage", activeStage, {})
ScriptLib.SetGroupGadgetStateByConfigId(context, 235800009, BulletConfigId, 201)
-- 开启gallery
ScriptLib.StartGallery(context, 6005)
return 0
end
--创建弹幕机关
function CreateBulletController( context, prev_context )
ScriptLib.CreateGadgetWithGlobalValue(context, BulletConfigId, { ["SGV_BulletType"]= 0})
return 0
end
function HitByBullet( context)
ScriptLib.UpdatePlayerGalleryScore(context, 6005,{["add_hit_count"] = 1})
return 0
end
function action_gallery_stop( context,evt )
-- 游廊结束时,判断是否超时
ScriptLib.PrintContextLog(context, "BulletGame Stop!!!!!!!!!")
ScriptLib.SetGroupGadgetStateByConfigId(context, 235800009, BulletConfigId, 0)
Achivement(context)
for i=2,#suites do
ScriptLib.RemoveExtraGroupSuite(context, 235800009, i)
end
if evt.param2 == 0 then
ScriptLib.ExecuteGroupLua(context, 235800001, "EndPlayStage", {0,GroupId})
else
ScriptLib.ExecuteGroupLua(context, 235800001, "EndPlayStage", {1,GroupId})
end
return 0
end
function Achivement( context )
-- 结算,被命中N次以下的玩家获得加分
local UidList = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(UidList) do
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, "collect_energy_6005", v, 5 * ScriptLib.GetSceneMultiStagePlayUidValue(context,235800001, 1, "get_random_flora", v))
if ScriptLib.GetSceneMultiStagePlayUidValue(context, 235800001, 1, "hit_by_bullet", v) < Bullet_PerfectScore_count then
ScriptLib.AddFleurFairMultistagePlayBuffEnergy(context, 235800001, 1, v, Bullet_PerfectScore)
ScriptLib.SetSceneMultiStagePlayUidValue(context,235800001, 1, "hit_counts_lessthan_5_6005", v, Bullet_PerfectScore)
end
if ScriptLib.GetSceneMultiStagePlayUidValue(context, 235800001, 1, "hit_by_bullet", v) == 0 then
--watcher结算
ScriptLib.SetSceneMultiStagePlayUidValue(context, 235800001, 1, "watcher_hit_by_bullet", v, 0)
else
--watcher结算
ScriptLib.SetSceneMultiStagePlayUidValue(context, 235800001, 1, "watcher_hit_by_bullet", v, -1)
end
end
return 0
end
function action_trigger_timeacis( context,evt)
-- 触发时间轴
ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : TIMER IS TRIGGERED")
local activeStage = ScriptLib.GetGroupTempValue(context, "activeStage", {})
local bulletTypeList = BulletStep[activeStage].list
ChangeBulletType(context, bulletTypeList)
RandomFlora(context,random_flower_sum.min, random_flower_sum.max)
return 0
end
function RandomFlora( context, minNum, maxNum )
-- 随机抽取suit中的蓝色风之花创建
ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : RandomFlora IS Create")
local GadgetList = {}
for i,v in ipairs(suites[flower_suite_index].gadgets) do
table.insert(GadgetList,v)
end
math.randomseed(ScriptLib.GetServerTime(context))
randomNum = math.random(minNum, maxNum)
for i=1,randomNum do
local configIndex = math.random(#GadgetList)
ScriptLib.CreateGadget(context, { config_id = GadgetList[configIndex] })
table.remove(GadgetList,configIndex)
end
ScriptLib.CreateGroupTimerEvent(context, 235800009, "floralifetime", flower_life_time)
return 0
end
function action_flora_life_time( context,evt )
-- 蓝色风之花生命周期
ScriptLib.KillExtraGroupSuite(context, 235800009, flower_suite_index)
return 0
end
function ChangeBulletType(context, bulletTypeList)
math.randomseed(ScriptLib.GetServerTime(context))
randomWeight = math.random(100)
local TargetType = 0
local Times = ScriptLib.GetGroupTempValue(context, "Times", {})
--ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : Times Is -> "..Times)
for i,v in ipairs(bulletTypeList[Times]) do
if v.weight >= randomWeight then
TargetType = v.gadgetstate
break
end
randomWeight = randomWeight - v.weight
end
ScriptLib.ChangeGroupTempValue(context, "Times", 1, {})
Times = ScriptLib.GetGroupTempValue(context, "Times", {})
if Times > #bulletTypeList then
ScriptLib.SetGroupTempValue(context, "Times", 1, {})
end
ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : Bullet GadgetState Is -> "..TargetType)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, BulletConfigId, "SGV_BulletType", TargetType)
-- local CurType =ScriptLib.GetGadgetAbilityFloatValue(context, GroupId, BulletConfigId, "WINDFLORA_BULLETTYPE")
-- local DeltType = TargetType - CurType
-- ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : Bullet DeltType Is -> "..math.ceil(DeltType))
-- ScriptLib.PrintContextLog(context, "## WINDFLORA_LOG : SET BULLETTYPE ALREADY ->"..ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {BulletConfigId}, "WINDFLORA_BULLETTYPE", math.ceil(DeltType)))
return 0
end
function LF_Initialize_Group()
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Group()
@@ -0,0 +1,32 @@
-- 该Lua为范例,需要使用的时候依赖TD自行处理,仅做示例
local callTDRequireTrigger = {
{ config_id = 7770001, name = "EVENT_VARIABLE_CHANGE_A", event = EventType.EVENT_VARIABLE_CHANGE, source = "SelfActionName",condition = "", action = "action_VARIABLE_CHANGE_A", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(callTDRequireTrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
-------处理函数-------
function action_VARIABLE_CHANGE_A(context, evt)
local actionName = evt.source_name
if 1 == evt.param1 - evt.param2 then
local functionParam1 = ScriptLib.GetGroupTempValue(context,actionName .. "Param1",{})
local functionParam2 = ScriptLib.GetGroupTempValue(context,actionName .. "Param2",{})
local functionParam3 = ScriptLib.GetGroupTempValue(context,actionName .. "Param3",{})
local functionParam4 = ScriptLib.GetGroupTempValue(context,actionName .. "Param4",{})
SelfActionName(context,functionParam1,functionParam2,functionParam3,functionParam4)
end
return 0
end
function SelfActionName(context,param1,param2,param3,param4)
--对应自己的Action
end
LF_Initialize_Level()
@@ -0,0 +1,55 @@
--[[======================================
|| filename: CheckPoint_Handler
|| owner: weiwei.sun
|| description: 通用复活点控制器
|| LogName: CheckPoint_Handler
|| Protection: [Protection]
=======================================]]
--需求misc
--[[
--key填regionid
--value为pointid
local Check_Point_List = {
[1] = 1,
[1] = 1,
[1] = 1,
}
]]
local temp_Tirgger = {
{event = EventType.EVENT_ENTER_REGION, source = "", action = "action_EVENT_ENTER_REGION"},
}
function action_EVENT_ENTER_REGION(context,evt)
ScriptLib.PrintContextLog(context,"##[CheckPoint_Handler] action_EVENT_ENTER_REGION:evt.param1="..evt.param1)
for k , v in pairs(Check_Point_List) do
if k == evt.param1 then
ScriptLib.PrintContextLog(context,"##[CheckPoint_Handler] action_EVENT_ENTER_REGION: ActivateDungeonCheckPoint = "..v)
ScriptLib.ActivateDungeonCheckPoint(context,v)
end
end
return 0
end
--初始化
function Initialize()
--加触发器
if temp_Tirgger ~= nil then
for k,v in pairs(temp_Tirgger) do
v.name = "temp_Trigger_"..k
v.config_id = 40000000 + k
v.trigger_count = 0
v.condition = ""
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
end
--加变量
if temp_Variables ~= nil then
for k,v in pairs(temp_Variables) do
table.insert(variables,v)
end
end
return 0
end
Initialize()
@@ -0,0 +1,196 @@
local triggers_lib = {
["Group_Load"] = { config_id = 8000001, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
["Load_Protect"] = { config_id = 8000002, name = "Load_Protect", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_load_protect", trigger_count = 0},
["Gadget_Create"] = { config_id = 8000003, name = "Gadget_Create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0},
["Group_Refresh"] = { config_id = 8000004, name = "Group_Refresh", event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0},
["Blossom_Chest_Die"] = { config_id = 8000005, name = "Blossom_Chest_Die", event = EventType.EVENT_BLOSSOM_CHEST_DIE, source = "", condition = "", action = "action_blossom_chest_die", trigger_count = 0},
["Select_Option"] = { config_id = 8000006, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
["Blossom_Progress_Finish"] = { config_id = 8000007, name = "Blossom_Progress_Finish", event = EventType.EVENT_BLOSSOM_PROGRESS_FINISH, source = "", condition = "", action = "action_blossom_progress_finish", trigger_count = 0},
["Challenge_Success"] = { config_id = 8000008, name = "Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
["Challenge_Fail"] = { config_id = 8000009, name = "Challenge_Fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
["Any_Monster_Die_1"] = { config_id = 8000010, name = "Any_Monster_Die_1", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die_1", trigger_count = 0},
["Any_Monster_Die_2"] = { config_id = 8000011, name = "Any_Monster_Die_2", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die_2", trigger_count = 0},
["Any_Monster_Die_3"] = { config_id = 8000012, name = "Any_Monster_Die_3", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die_3", trigger_count = 0},
["Any_Gadget_Die"] = { config_id = 8000013, name = "Any_Gadget_Die", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0 }
}
local gid = defs.group_id or 0
--雪山营地A
function Initialize_Group()
for k,v in pairs(triggers_lib) do
table.insert(triggers, v)
end
for i=1,6 do
if i == 1 then
table.insert(suites[i].triggers, "Group_Load")
elseif i == 2 then
table.insert(suites[i].triggers, "Load_Protect")
table.insert(suites[i].triggers, "Gadget_Create")
table.insert(suites[i].triggers, "Group_Refresh")
table.insert(suites[i].triggers, "Blossom_Chest_Die")
table.insert(suites[i].triggers, "Select_Option")
table.insert(suites[i].triggers, "Blossom_Progress_Finish")
table.insert(suites[i].triggers, "Challenge_Success")
table.insert(suites[i].triggers, "Challenge_Fail")
elseif i == 3 then
table.insert(suites[i].triggers, "Any_Monster_Die_1")
elseif i == 4 then
table.insert(suites[i].triggers, "Any_Gadget_Die")
table.insert(suites[i].triggers, "Gadget_Create")
elseif i == 5 then
table.insert(suites[i].triggers, "Any_Monster_Die_2")
elseif i == 6 then
table.insert(suites[i].triggers, "Any_Monster_Die_3")
end
end
end
Initialize_Group()
----------------------------------------------
--[[
local defs = {
operator = 431009,
blossom_chest = 431010,
ice_storm = 431011,
gadget_list = {
{s = 431015, t = 431012},
{s = 431016, t = 431013},
{s = 431017, t = 431014}
},
reminder_pos = {x=1480,y=268,z=-736},
challenge = {
{id = 58, weight = 40, temp_r = 110 },
{id = 58, weight = 40, temp_r = 110 },
{id = 58, weight = 40, temp_r = 110 }
}
}
--]]
function LF_Active_Challenge(context)
local max = 0
for i,v in ipairs(defs.challenge) do
max = max + v.weight
end
math.randomseed(ScriptLib.GetServerTime(context))
local ran = math.random(max)
for i,v in ipairs(defs.challenge) do
ran = ran - v.weight
if ran <= 0 then
local sum = #suites[3].monsters + #suites[5].monsters + #suites[6].monsters
ScriptLib.ActiveChallenge(context, 1, v.id, 0, sum, 0, 0)
ScriptLib.ShowTemplateReminder(context, v.temp_r, {0,0})
break
end
end
end
---------------------------------------------
function action_group_load(context, evt)
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 2, exclude_prev = true })
return 0
end
function action_load_protect(context, evt)
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 2, exclude_prev = true })
return 0
end
function action_gadget_create(context, evt)
--创建操作台
if defs.operator == evt.param1 then
if 0 == ScriptLib.GetGadgetStateByConfigId(context, 0, evt.param1) then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, evt.param1, {37})
ScriptLib.RefreshBlossomDropRewardByGroupId(context, 0)
end
elseif defs.ice_storm == evt.param1 then
ScriptLib.ShowReminderRadius(context, 400010, defs.reminder_pos, 50)
end
return 0
end
function action_group_refresh(context, evt)
ScriptLib.CreateGadget(context, { config_id = defs.operator })
ScriptLib.SetBlossomScheduleStateByGroupId(context, 0, 1)
ScriptLib.RefreshBlossomDropRewardByGroupId(context, 0)
return 0
end
function action_blossom_chest_die(context, evt)
if evt.param1 == defs.blossom_chest then
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 2, exclude_prev = true })
end
return 0
end
function action_select_option(context, evt)
if evt.param1 == defs.operator and evt.param2 == 37 then
LF_Active_Challenge(context)
ScriptLib.AddExtraGroupSuite(context, 0, 3)
ScriptLib.AddExtraGroupSuite(context, 0, 4)
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.operator, 37)
ScriptLib.SetGadgetStateByConfigId(context, defs.operator, GadgetState.GearStart)
ScriptLib.SetBlossomScheduleStateByGroupId(context, 0, 2)
ScriptLib.RefreshBlossomDropRewardByGroupId(context, 0)
end
return 0
end
function action_blossom_progress_finish(context, evt)
ScriptLib.CreateBlossomChestByGroupId(context, 0, defs.blossom_chest)
ScriptLib.SetBlossomScheduleStateByGroupId(context, 0, 3)
ScriptLib.SetGroupVariableValue(context, "GroupCompletion", 1)
return 0
end
function action_challenge_success(context, evt)
for i,v in ipairs(defs.gadget_list) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v.s)
end
ScriptLib.AddBlossomScheduleProgressByGroupId(context, 0)
return 0
end
function action_challenge_fail(context, evt)
ScriptLib.RefreshGroup(context, { group_id = 0, suite = 2 })
return 0
end
function action_any_monster_die_1(context, evt)
ScriptLib.PrintContextLog(context, "## monster_die_1")
if ScriptLib.GetGroupMonsterCountByGroupId(context, gid) == 0 then
ScriptLib.RemoveExtraGroupSuite(context, 0, 3)
ScriptLib.AddExtraGroupSuite(context, 0, 5)
ScriptLib.ShowReminderRadius(context, 400002, defs.reminder_pos, 50)
end
return 0
end
function action_any_monster_die_2(context, evt)
ScriptLib.PrintContextLog(context, "## monster_die_2")
if ScriptLib.GetGroupMonsterCountByGroupId(context, gid) == 0 then
ScriptLib.RemoveExtraGroupSuite(context, 0, 5)
ScriptLib.AddExtraGroupSuite(context, 0, 6)
ScriptLib.ShowReminderRadius(context, 400003, defs.reminder_pos, 50)
end
return 0
end
function action_any_monster_die_3(context, evt)
ScriptLib.PrintContextLog(context, "## monster_die_3")
if ScriptLib.GetGroupMonsterCountByGroupId(context, gid) == 0 then
ScriptLib.SetGadgetStateByConfigId(context, defs.ice_storm, GadgetState.GearStop)
ScriptLib.KillEntityByConfigId(context, { config_id = 431011 })
ScriptLib.RemoveExtraGroupSuite(context, 0, 6)
end
return 0
end
function action_any_gadget_die(context, evt)
for i,v in ipairs(defs.gadget_list) do
if evt.param1 == v.s then
ScriptLib.SetGadgetStateByConfigId(context, v.t, GadgetState.Default)
ScriptLib.ChangeGroupVariableValue(context, "remainingHeat", -1)
end
end
return 0
end
@@ -0,0 +1,236 @@
local triggers_lib = {
["Group_Load"] = { config_id = 8000001, name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
["Load_Protect"] = { config_id = 8000002, name = "Load_Protect", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_load_protect", trigger_count = 0},
["Gadget_Create"] = { config_id = 8000003, name = "Gadget_Create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0},
["Group_Refresh"] = { config_id = 8000004, name = "Group_Refresh", event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0},
["Blossom_Chest_Die"] = { config_id = 8000005, name = "Blossom_Chest_Die", event = EventType.EVENT_BLOSSOM_CHEST_DIE, source = "", condition = "", action = "action_blossom_chest_die", trigger_count = 0},
["Select_Option"] = { config_id = 8000006, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
["Blossom_Progress_Finish"] = { config_id = 8000007, name = "Blossom_Progress_Finish", event = EventType.EVENT_BLOSSOM_PROGRESS_FINISH, source = "", condition = "", action = "action_blossom_progress_finish", trigger_count = 0},
["Challenge_Success"] = { config_id = 8000008, name = "Challenge_Success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
["Challenge_Fail"] = { config_id = 8000009, name = "Challenge_Fail", event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
["Any_Monster_Die_1"] = { config_id = 8000010, name = "Any_Monster_Die_1", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die_1", trigger_count = 0},
["Any_Monster_Die_2"] = { config_id = 8000011, name = "Any_Monster_Die_2", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die_2", trigger_count = 0},
["Any_Monster_Die_3"] = { config_id = 8000012, name = "Any_Monster_Die_3", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die_3", trigger_count = 0},
["Platform_Reach_Point"] = { config_id = 8000013, name = "Platform_Reach_Point", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_platform_reach_point", trigger_count = 0 },
["Timer_Event"] = { config_id = 8000014, name ="Timer_Event", event = EventType.EVENT_TIMER_EVENT, source = "timer", condition = "", action = "action_timer_event", trigger_count = 0 }
}
local gid = defs.group_id or 0
local interval = defs.timer or 15
--雪山营地B
function Initialize_Group()
table.insert(variables, {config_id=54000001,name = "wave", value = 0})
for k,v in pairs(triggers_lib) do
table.insert(triggers, v)
end
for i=1,6 do
if i == 1 then
table.insert(suites[i].triggers, "Group_Load")
elseif i == 2 then
table.insert(suites[i].triggers, "Load_Protect")
table.insert(suites[i].triggers, "Gadget_Create")
table.insert(suites[i].triggers, "Group_Refresh")
table.insert(suites[i].triggers, "Blossom_Chest_Die")
table.insert(suites[i].triggers, "Select_Option")
table.insert(suites[i].triggers, "Blossom_Progress_Finish")
table.insert(suites[i].triggers, "Challenge_Success")
table.insert(suites[i].triggers, "Challenge_Fail")
table.insert(suites[i].triggers, "Platform_Reach_Point")
table.insert(suites[i].triggers, "Timer_Event")
elseif i == 3 then
table.insert(suites[i].triggers, "Any_Monster_Die_1")
elseif i == 4 then
table.insert(suites[i].triggers, "Gadget_Create")
elseif i == 5 then
table.insert(suites[i].triggers, "Any_Monster_Die_2")
elseif i == 6 then
table.insert(suites[i].triggers, "Any_Monster_Die_3")
end
end
end
Initialize_Group()
----------------------------------------------
--[[
local defs = {
operator = 422010,
blossom_chest = 422011,
platform = 422013
ice_storm = 422012,
route_info = {
{route_id = 300800099, point_id = 4, gadget = 422009},
{route_id = 300800099, point_id = 6, gagdet = 422033},
},
final_info = {route_id = 300800100, point_id = 2},
seelie_base = 422014
reminder_pos = {x=1480,y=268,z=-736},
challenge = {
{id = 58, weight = 40, temp_r = 110 },
{id = 58, weight = 40, temp_r = 110 },
{id = 58, weight = 40, temp_r = 110 }
}
}
--]]
function LF_Active_Challenge(context)
local max = 0
for i,v in ipairs(defs.challenge) do
max = max + v.weight
end
math.randomseed(ScriptLib.GetServerTime(context))
local ran = math.random(max)
--ScriptLib.PrintContextLog(context, "## random = "..ran)
for i,v in ipairs(defs.challenge) do
ran = ran - v.weight
if ran <= 0 then
local sum = #suites[3].monsters + #suites[5].monsters + #suites[6].monsters
ScriptLib.ActiveChallenge(context, 1, v.id, 0, sum, 0, 0)
ScriptLib.ShowTemplateReminder(context, v.temp_r, {0,0})
--ScriptLib.PrintContextLog(context, "## i = "..i)
break
end
end
end
---------------------------------------------
function action_group_load(context, evt)
--ScriptLib.PrintLog("====================== faq 5 ===========================")
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 2, exclude_prev = true })
return 0
end
function action_gadget_create(context, evt)
--创建操作台
if defs.operator == evt.param1 then
if 0 == ScriptLib.GetGadgetStateByConfigId(context, 0, evt.param1) then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, evt.param1, {37})
ScriptLib.RefreshBlossomDropRewardByGroupId(context, 0)
end
elseif defs.ice_storm == evt.param1 then
ScriptLib.ShowReminderRadius(context, 400010, defs.reminder_pos, 50)
end
return 0
end
function action_load_protect(context, evt)
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 2, exclude_prev = true })
return 0
end
function action_group_refresh(context, evt)
ScriptLib.CreateGadget(context, { config_id = defs.operator })
ScriptLib.SetBlossomScheduleStateByGroupId(context, 0, 1)
ScriptLib.RefreshBlossomDropRewardByGroupId(context, 0)
return 0
end
function action_blossom_chest_die(context, evt)
if evt.param1 == defs.blossom_chest then
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 2, exclude_prev = true })
end
return 0
end
function action_select_option(context, evt)
if evt.param1 == defs.operator and evt.param2 == 37 then
LF_Active_Challenge(context)
ScriptLib.AddExtraGroupSuite(context, 0, 3)
ScriptLib.AddExtraGroupSuite(context, 0, 4)
ScriptLib.DelWorktopOptionByGroupId(context, 0, defs.operator, 37)
ScriptLib.SetGadgetStateByConfigId(context, defs.operator, GadgetState.GearStart)
ScriptLib.SetPlatformRouteId(context, defs.platform, defs.route_info[1].route_id)
ScriptLib.StartPlatform(context, defs.platform)
ScriptLib.SetBlossomScheduleStateByGroupId(context, 0, 2)
ScriptLib.RefreshBlossomDropRewardByGroupId(context, 0)
ScriptLib.SetGroupVariableValue(context, "wave", 1)
ScriptLib.CreateGroupTimerEvent(context, ScriptLib.GetContextGroupId(context), "timer", interval)
end
return 0
end
function action_blossom_progress_finish(context, evt)
ScriptLib.CreateBlossomChestByGroupId(context, 0, defs.blossom_chest)
ScriptLib.SetBlossomScheduleStateByGroupId(context, 0, 3)
ScriptLib.SetGroupVariableValue(context, "GroupCompletion", 1)
return 0
end
function action_challenge_success(context, evt)
ScriptLib.AddBlossomScheduleProgressByGroupId(context, 0)
return 0
end
function action_challenge_fail(context, evt)
ScriptLib.CancelGroupTimerEvent(context, ScriptLib.GetContextGroupId(context), "timer")
ScriptLib.RefreshGroup(context, { group_id = 0, suite = 2 })
return 0
end
function action_any_monster_die_1(context, evt)
if ScriptLib.GetGroupMonsterCountByGroupId(context, gid) == 0 then
ScriptLib.RemoveExtraGroupSuite(context, 0, 3)
ScriptLib.AddExtraGroupSuite(context, 0, 5)
ScriptLib.ShowReminderRadius(context, 400002, defs.reminder_pos, 50)
ScriptLib.SetPlatformRouteId(context, defs.platform, defs.route_info[2].route_id)
ScriptLib.StartPlatform(context, defs.platform)
ScriptLib.SetGroupVariableValue(context, "wave", 2)
end
return 0
end
function action_any_monster_die_2(context, evt)
if ScriptLib.GetGroupMonsterCountByGroupId(context, gid) == 0 then
ScriptLib.RemoveExtraGroupSuite(context, 0, 5)
ScriptLib.AddExtraGroupSuite(context, 0, 6)
ScriptLib.ShowReminderRadius(context, 400003, defs.reminder_pos, 50)
ScriptLib.SetPlatformRouteId(context, defs.platform, defs.route_info[3].route_id)
ScriptLib.StartPlatform(context, defs.platform)
ScriptLib.SetGroupVariableValue(context, "wave", 3)
end
return 0
end
function action_any_monster_die_3(context, evt)
if ScriptLib.GetGroupMonsterCountByGroupId(context, gid) == 0 then
ScriptLib.SetPlatformRouteId(context, defs.platform, defs.final_info.route_id)
ScriptLib.StartPlatform(context, defs.platform)
ScriptLib.SetGadgetStateByConfigId(context, defs.ice_storm, GadgetState.GearStop)
ScriptLib.KillEntityByConfigId(context, { config_id = defs.ice_storm })
end
return 0
end
function action_platform_reach_point(context, evt)
if evt.param1 == defs.platform then
if evt.param2 == defs.final_info.route_id and evt.param3 == defs.final_info.point_id then
ScriptLib.SetGadgetStateByConfigId(context, defs.seelie_base, GadgetState.GearStart)
ScriptLib.CancelGroupTimerEvent(context, ScriptLib.GetContextGroupId(context), "timer")
ScriptLib.StopPlatform(context, defs.platform)
ScriptLib.KillEntityByConfigId(context, { config_id = defs.platform })
return 0
end
for i,v in ipairs(defs.route_info) do
local wave = ScriptLib.GetGroupVariableValue(context, "wave")
if evt.param2 == v.route_id and evt.param3 == v.point_id then
if i >= wave then
ScriptLib.StopPlatform(context, defs.platform)
end
ScriptLib.CreateGadget(context, { config_id = v.gadget })
break
end
end
end
return 0
end
function action_timer_event(context, evt)
if defs.timedOre == nil then
return -1
end
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.timedOre)
local eid = ScriptLib.GetEntityIdByConfigId(context, defs.platform)
local pos = ScriptLib.GetPosByEntityId(context, eid)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.timedOre, {x=pos.x,y=pos.y,z=pos.z}, {x=0,y=0,z=0})
ScriptLib.CreateGroupTimerEvent(context, ScriptLib.GetContextGroupId(context), "timer", interval)
return 0
end
@@ -0,0 +1,124 @@
local play={
}
local extraTriggers={
{config_id = 8000001,name = "Group_Load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{config_id = 8000002,name = "Boss_Die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_boss_die", trigger_count = 0 },
{config_id = 8000003,name = "Gadget_Create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
{config_id = 8000004, name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "condition_EVENT_LEAVE_REGION", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
{config_id = 8000005, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION", action = "action_EVENT_ENTER_REGION", forbid_guest = false, trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "boss_exist", value = 1 })
end
function condition_EVENT_ENTER_REGION(context, evt)
if evt.param1 ~= 640012 then
return false
end
return true
end
function action_EVENT_ENTER_REGION(context, evt)
if context.uid~=0 then
local small_region={}
local big_region={}
for i=1,#regions do
if regions[i].config_id==640012 then
small_region=regions[i]
end
if regions[i].config_id==640020 then
big_region=regions[i]
end
end
TrySetPlayerEyePoint(context, small_region, big_region, 1, {0})
end
return 0
end
function condition_EVENT_LEAVE_REGION(context, evt)
if evt.param1 ~= 640020 then
return false
end
return true
end
function action_EVENT_LEAVE_REGION(context, evt)
if context.uid~=0 then
--local small_region={}
--local big_region={}
--for i=1,#regions do
--if regions[i].config_id==640012 then
--small_region=regions[i]
--end
--if regions[i].config_id==640020 then
--big_region=regions[i]
--end
--end
--TrySetPlayerEyePoint(context, small_region, big_region, 1, {1})
ScriptLib.ClearPlayerEyePoint(context, 640012)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
end
return 0
end
--刷新时加载怪物
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "DrakePrimoRockBossGroupLoad")
math.randomseed(ScriptLib.GetServerTime(context))
local newIdx=math.random(#monsters)
if ScriptLib.GetGroupVariableValue(context, "current_idx") == 0 then
ScriptLib.SetGroupVariableValue(context, "current_idx", newIdx)
--ScriptLib.CreateMonster(context, { config_id = monster[newIdx].config_id, delay_time = 0 })
ScriptLib.CreateMonsterByConfigIdByPos(context, monsters[newIdx].config_id, monsters[newIdx].pos, monsters[newIdx].rot)
return 0
end
if ScriptLib.GetGroupVariableValue(context, "killed") ~= 0 and evt.param1 ~=1 then
return 0
end
if ScriptLib.GetGroupVariableValue(context, "killed") ~= 0 and evt.param1 ==1 then
ScriptLib.CreateMonster(context, { config_id = monsters[newIdx].config_id, delay_time = 0 })
ScriptLib.SetGroupVariableValue(context, "current_idx", newIdx)
ScriptLib.SetGroupVariableValue(context, "killed", 0)
return 0
end
if ScriptLib.GetGroupVariableValue(context, "killed") == 0 then
ScriptLib.CreateMonster(context, { config_id = monsters[ScriptLib.GetGroupVariableValue(context, "current_idx")].config_id, delay_time = 0 })
return 0
end
return 0
end
--boss死亡创建领奖点
function action_boss_die(context, evt)
ScriptLib.SetGroupVariableValue(context, "killed", 1)
ScriptLib.SetGroupVariableValue(context, "boss_exist", 0)
ScriptLib.CreateGadget(context, { config_id = 640007 })
return 0
end
function action_gadget_create(context, evt)
if evt.param1~=640007 then
return 0
end
if ScriptLib.GetGroupVariableValue(context, "current_idx") == 1 then
ScriptLib.CreateGadget(context, { config_id = 640008 })
elseif ScriptLib.GetGroupVariableValue(context, "current_idx") == 2 then
ScriptLib.CreateGadget(context, { config_id = 640009 })
elseif ScriptLib.GetGroupVariableValue(context, "current_idx") == 3 then
ScriptLib.CreateGadget(context, { config_id = 640010 })
elseif ScriptLib.GetGroupVariableValue(context, "current_idx") == 4 then
ScriptLib.CreateGadget(context, { config_id = 640011 })
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,43 @@
local extraTriggers = {
{ name = "fishing_start", config_id = 8000001, event = EventType.EVENT_FISHING_START, source = "", condition = "", action = "action_fishing_start", trigger_count = 0},
{ name = "fishing_stop", config_id = 8000002, event = EventType.EVENT_FISHING_STOP, source = "", condition = "", action = "action_fishing_stop", trigger_count = 0},
{ name = "fishing_qte_finish", config_id = 8000003, event = EventType.EVENT_FISHING_QTE_FINISH, source = "", condition = "", action = "action_fishing_qte_finish", trigger_count = 0},
{ name = "group_load", config_id = 8000004, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 }
}
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "[fishing] fishing Groupload")
return 0
end
function Initialize()
--print("[fishing] fishing Initialize")
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
return 0
end
function action_fishing_start(context, evt)
ScriptLib.PrintContextLog(context, "[fishing] action_fishing_start")
return 0
end
--处理钓鱼结束
function action_fishing_stop(context, evt)
ScriptLib.PrintContextLog(context, "[fishing] action_fishing_stop")
return 0
end
--每次退出钓鱼QTE状态时触发
--evt.param1 鱼id
--evt.param2 0-失败 1-成功
--evt.param3 0-未进包(即背包满/到达活动要求的获取上限)1-进包
function action_fishing_qte_finish(context, evt)
ScriptLib.PrintContextLog(context, "[fishing] action_fishing_qte_finish. FishID@"..evt.param1.." EID@"..evt.source_eid.." isSucc@"..evt.param2.." isGetInBag@"..evt.param3)
return 0
end
Initialize()
@@ -0,0 +1,231 @@
--[[
local defs = {
gallery_id = 1,
gadget_entry = 1,
balloon_clear_state = 202,
suite_clear_index = 10,
random_time_axis = {10,20,30},
random_clear_time_axis = {7,17,27,37},
static_start_suite = 2,
static_suite_list = {3,4,5},
static_time_axis = {10,20,30},
static_clear_time_axis = {7,17,27,37},
}
local balloon_config = {
{ gadget_id = xxx, min = xxx, max = xxx},
{ gadget_id = xxx, min = xxx, max = xxx}
}
local point_array_defs = {
[1] = {point_array_id = 1, point_id_list = {}, route_type = 2},
[2] = {point_array_id = 2, point_id_list = {}, route_type = 1}
}
--]]
-----------------------
local Tri = {
{name = "time_axis_pass", config_id = 800001, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
{name = "gallery_start", config_id = 800002, event = EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_gallery_start", trigger_count = 0},
{name = "gallery_stop", config_id = 800003, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
{name = "group_will_unload", config_id = 800004, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
{name = "enter_region", config_id = 800005,event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false }
}
local Var = {
--{name = "is_in_gallery", value = 0, no_refresh = false}
}
function Initialize()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
local suite_sum = #suites
suites[suite_sum+1] = {monsters={},gadgets={},regions={},triggers={},rand_weight=0}
for i=1,balloon_config[1].max do
local temp_gadget = {config_id = 1000000+i, gadget_id=balloon_config[1].gadget_id, level=1, pos = gadgets[defs.gadget_entry].pos, rot = gadgets[defs.gadget_entry].rot, area_id = gadgets[defs.gadget_entry].area_id}
gadgets[temp_gadget.config_id] = temp_gadget
table.insert(suites[suite_sum+1].gadgets, temp_gadget.config_id)
end
suites[suite_sum+2] = {monsters={},gadgets={},regions={},triggers={},rand_weight=0}
for i=1,balloon_config[2].max do
local temp_gadget = {config_id = 1000000+balloon_config[1].max+i, gadget_id=balloon_config[2].gadget_id, level=1, pos = gadgets[defs.gadget_entry].pos, rot = gadgets[defs.gadget_entry].rot, area_id = gadgets[defs.gadget_entry].area_id}
gadgets[temp_gadget.config_id] = temp_gadget
table.insert(suites[suite_sum+2].gadgets, temp_gadget.config_id)
end
local garbages = {gadgets={}}
for i=1,10 do
garbages.gadgets[i] = {config_id=100000+i}
end
end
function action_time_axis_pass(context, evt)
if evt.source_name == "static" then
LF_CREATE_NEXT_STATIC_BALLOON(context, evt.param1)
elseif evt.source_name == "random" then
LF_CREATE_NEXT_RANDOM_BALLOON(context, evt.param1)
elseif evt.source_name == "random_clear" then
LF_CLEAR_CUR_RANDOM_BALLOON(context, evt.param1)
elseif evt.source_name == "static_clear" then
LF_CLEAR_CUR_STATIC_BALLOON(context, evt.param1)
end
return 0
end
function action_gallery_start(context, evt)
ScriptLib.PrintContextLog(context, "------------- version 8 --------------")
--ScriptLib.GetGroupVariableValue(context, "timer_ptr")
if evt.param1 ~= defs.gallery_id then
return -1
end
ScriptLib.SetGroupTempValue(context, "is_in_gallery", 1, {})
local act_time = ScriptLib.GetActivityOpenAndCloseTimeByScheduleId(context, 2003001)
local cur_time = ScriptLib.GetServerTime(context)
if cur_time >= act_time[1] and cur_time < act_time[2] - 86400*7 then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.operator_group_id, defs.gadget_operator, 901)
end
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {0})
LF_CREATE_NEXT_RANDOM_BALLOON(context, 0)
LF_CREATE_NEXT_STATIC_BALLOON(context, 0)
ScriptLib.InitTimeAxis(context, "random", defs.random_time_axis, false)
ScriptLib.InitTimeAxis(context, "random_clear", defs.random_clear_time_axis, false)
ScriptLib.InitTimeAxis(context, "static", defs.static_time_axis, false)
ScriptLib.InitTimeAxis(context, "static_clear", defs.static_clear_time_axis, false)
return 0
end
function action_gallery_stop(context, evt)
if evt.param1 ~= defs.gallery_id then
return -1
end
ScriptLib.SetGroupTempValue(context, "is_in_gallery", 0, {})
local act_time = ScriptLib.GetActivityOpenAndCloseTimeByScheduleId(context, 2003001)
local cur_time = ScriptLib.GetServerTime(context)
if cur_time >= act_time[1] and cur_time < act_time[2] - 86400*7 then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.operator_group_id, defs.gadget_operator, 0)
end
ScriptLib.EndTimeAxis(context, "random")
ScriptLib.EndTimeAxis(context, "random_clear")
ScriptLib.EndTimeAxis(context, "static")
ScriptLib.EndTimeAxis(context, "random_clear")
ScriptLib.RemoveExtraGroupSuite(context, 0, defs.suite_clear_index)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {1})
return 0
end
function action_group_will_unload(context, evt)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {1})
return 0
end
function action_enter_region(context, evt)
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_gallery", {}) then
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {0})
end
return 0
end
-----------------------------------
function LF_CREATE_NEXT_STATIC_BALLOON(context, wave)
ScriptLib.PrintContextLog(context, "## balloon_log : wave="..wave)
local balloons = {}
if wave == 0 then
balloons = suites[defs.static_start_suite].gadgets
ScriptLib.AddExtraGroupSuite(context, 0, defs.static_start_suite)
else
balloons = suites[defs.static_suite_list[wave]].gadgets
--防止策划配错,强制移除
ScriptLib.RemoveExtraGroupSuite(context, 0, defs.static_suite_list[wave])
ScriptLib.AddExtraGroupSuite(context, 0, defs.static_suite_list[wave])
end
ScriptLib.PrintContextLog(context, "## balloon_log : #balloons="..#balloons)
--调整蛋道
for i,v in ipairs(balloons) do
if point_array_defs[v] ~= nil then
local ret = ScriptLib.SetPlatformPointArray(context, v, point_array_defs[v].point_array_id, point_array_defs[v].point_id_list, {route_type = point_array_defs[v].route_type})
ScriptLib.PrintContextLog(context, "## balloon_log : i->"..i.." | ret->"..ret)
end
end
end
function LF_CREATE_NEXT_RANDOM_BALLOON(context, wave)
local balloons = {}
math.randomseed(ScriptLib.GetServerTime(context)+wave)
local g1_r = math.random(balloon_config[1].min, balloon_config[1].max)
local g2_r = math.random(balloon_config[2].min, balloon_config[2].max)
ScriptLib.PrintContextLog(context, "## balloon_log : g1_r="..g1_r.." | g2_r="..g2_r)
for i=1,g1_r do
table.insert(balloons, suites[#suites-1].gadgets[i])
end
for i=1,g2_r do
table.insert(balloons, suites[#suites].gadgets[i])
end
ScriptLib.PrintContextLog(context, "## balloon_log : #balloons="..#balloons)
--随机选一组points作为气球创建点
local random_points = {}
for k,v in pairs(points) do
if v.isRandom == 1 then
table.insert(random_points, k)
end
end
ScriptLib.PrintContextLog(context, "## balloon_log : #random_points="..#random_points)
local uid_list = ScriptLib.GetSceneUidList(context)
local host_uid = uid_list[1]
local seed = ScriptLib.GetServerTime(context)%host_uid
ScriptLib.PrintContextLog(context, "## balloon_log : seed="..seed)
for k,v in pairs(balloons) do
local temp = seed%#random_points + 1
ScriptLib.PrintContextLog(context, "## balloon_log : temp="..temp)
ScriptLib.PrintContextLog(context, "## balloon_log : v="..v.." | random_points="..random_points[temp])
ScriptLib.CreateGadgetByConfigIdByPos(context, v, points[random_points[temp]].pos, points[random_points[temp]].rot)
table.remove(random_points, temp)
end
end
function LF_CLEAR_CUR_STATIC_BALLOON(context, wave)
if wave == 1 then
for i,v in ipairs(suites[defs.static_start_suite].gadgets) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, defs.balloon_clear_state)
end
else
for i,v in ipairs(suites[defs.static_suite_list[wave - 1]].gadgets) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, defs.balloon_clear_state)
end
end
end
function LF_CLEAR_CUR_RANDOM_BALLOON(context, wave)
for i,v in ipairs(suites[#suites-1].gadgets) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, defs.balloon_clear_state)
end
for i,v in ipairs(suites[#suites].gadgets) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, defs.balloon_clear_state)
end
end
---------------------------------
function ShootBalloonHighScore(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70350174})
return 0
end
function ShootBalloonLowScore(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70350173})
return 0
end
function ShootBalloonSubScore(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70350175})
return 0
end
function ShootBalloonBombScore(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70350172})
return 0
end
---------------------------------
Initialize()
@@ -0,0 +1,236 @@
--[[
local defs = {
gallery_id = 1,
option_1 = 7,
option_2 = 2905,
gadget_final = 453012,
gadget_operator = 453001,
group_list = {133004454,133004455,133004456,133004457,133004458},
trans_pos = {x=2771,y=436,z=12},
top = 453009,
bottom = 453004,
region_list = {453004,453006,453007,453008,453009}
}
--]]
-----------------------
local Tri = {
--{ config_id = 8000001, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
{ config_id = 8000002, name = "enter_region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false },
{ config_id = 8000003, name = "leave_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "condition_leave_region", action = "action_leave_region", trigger_count = 0, forbid_guest = false },
{ config_id = 8000004, name = "gadget_create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "condition_gadget_create", action = "action_gadget_create", trigger_count = 0 },
{ config_id = 8000005, name = "gallery_start", event = EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_gallery_start", trigger_count = 0},
{ config_id = 8000006, name = "gallery_stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
{ config_id = 8000007, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0}
}
local Var = {
--{name = "timer_ptr", value = 0, no_refresh = false}
}
function Initialize()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
if v.name == "enter_region" or v.name == "leave_region" then
table.insert(suites[2].triggers, v.name)
else
table.insert(suites[1].triggers, v.name)
end
end
end
--[[function action_select_option(context, evt)
if evt.param1 ~= defs.gadget_operator then
return -1
end
if evt.param2 == defs.option_1 then
ScriptLib.StartGallery(context, defs.gallery_id)
return 0
elseif evt.param2 == defs.option_2 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
return 0
end--]]
function action_enter_region(context, evt)
if context.uid == 0 then
return -1
end
local position = ScriptLib.GetPosByEntityId(context, context.target_entity_id)
for i,v in ipairs(regions) do
if math.abs(v.pos.y - position.y) <= v.size.y/2 then
return LF_SET_VISION_TYPE(context, v.config_id)
end
end
return -1
end
function condition_leave_region(context, evt)
if context.uid == 0 then
return false
end
local position = ScriptLib.GetPosByEntityId(context, context.target_entity_id)
local bottom = 0
local top = 0
for i,v in ipairs(regions) do
if v.config_id == defs.bottom then
bottom = i
end
if v.config_id == defs.top then
top = i
end
end
if position.y <= regions[bottom].pos.y - regions[bottom].size.y/2 then
return true
elseif position.y >= regions[top].pos.y + regions[top].size.y/2 then
return true
elseif math.abs(position.x - regions[top].pos.x) >= regions[top].size.x/2 then
return true
elseif math.abs(position.z - regions[bottom].pos.z) >= regions[bottom].size.z/2 then
return true
end
return false
end
function action_leave_region(context, evt)
-- 将玩家的GroupVisionType设为1
if 0 ~= ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1}) then
return -1
end
return 0
end
function condition_gadget_create(context, evt)
if evt.param1 ~= defs.gadget_operator then
return false
end
return true
end
function action_gadget_create(context, evt)
--ScriptLib.SetGadgetEnableInteract(context, 0, defs.gadget_operator, true)
return 0
end
function action_gallery_start(context, evt)
if evt.param1 ~= defs.gallery_id then
return -1
end
local act_time = ScriptLib.GetActivityOpenAndCloseTimeByScheduleId(context, 2003001)
local cur_time = ScriptLib.GetServerTime(context)
if cur_time >= act_time[1] and cur_time < act_time[2] - 86400*7 then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.operator_group_id, defs.gadget_operator, 901)
end
LF_GALLERY_START(context, evt)
return 0
end
function action_gallery_stop(context, evt)
local act_time = ScriptLib.GetActivityOpenAndCloseTimeByScheduleId(context, 2003001)
local cur_time = ScriptLib.GetServerTime(context)
if cur_time >= act_time[1] and cur_time < act_time[2] - 86400*7 then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.operator_group_id, defs.gadget_operator, 0)
end
LF_GALLERY_STOP(context, evt)
return 0
end
function action_group_load(context, evt)
ScriptLib.CreateGadget(context, {config_id = defs.gadget_airwall})
--ScriptLib.SetGadgetEnableInteract(context, 0, defs.gadget_operator, true)
return 0
end
--------------------------
function LF_SET_VISION_TYPE(context, cid)
local layer = 0
for i,v in ipairs(defs.region_list) do
if v == cid then
layer = i
break
end
end
if layer < 1 or layer > #defs.region_list then
return -1
end
local array = {}
--[[
--常规的区间分布
for i=-1,0,1 do
if layer+i >= 1 and layer+i <= #defs.region_list then
table.insert(array,layer+i+10)
end
end
for i,v in ipairs(array) do
ScriptLib.PrintContextLog(context, "## uid = "..context.uid.." | vision = "..v)
end
--]]
if layer == 1 then
array = {11}
elseif layer >= 2 and layer < #defs.region_list then
array = {9+layer,10+layer}
elseif layer == #defs.region_list then
array = {16}
end
return ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, array)
end
function LF_GALLERY_START(context, evt)
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.gadget_airwall)
--local uid_arr = ScriptLib.GetSceneUidList(context)
--ScriptLib.TransPlayerToPos(context, {uid_list=uid_arr, pos = defs.trans_pos, rot = {x=0,y=0,z=0}})
--ScriptLib.SetGadgetEnableInteract(context, 0, defs.gadget_operator, false)
ScriptLib.AddExtraGroupSuite(context, 0, 2)
-- 启动移动平台
if 0 ~= ScriptLib.StartPlatform(context, defs.gadget_final) then
return -1
end
for i,v in ipairs(defs.group_list) do
ScriptLib.AddExtraGroupSuite(context, v, 2)
end
end
function LF_GALLERY_STOP(context, evt)
ScriptLib.CreateGadget(context, {config_id = defs.gadget_airwall})
--ScriptLib.SetGadgetEnableInteract(context, 0, defs.gadget_operator, true)
ScriptLib.RemoveExtraGroupSuite(context, 0, 2)
for i,v in ipairs(defs.group_list) do
ScriptLib.RemoveExtraGroupSuite(context, v, 2)
end
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, uid_list, {1})
end
-------------------------------------------
function FlyBalloonDestinationScore(context)
ScriptLib.PrintContextLog(context, "## FlyBalloonDestinationScore | uid -> "..context.uid.." | source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
--ScriptLib.AddTeamEntityGlobalFloatValue(context, {context.uid}, "has_end_game", 1)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70360139,["has_end_game"]=true})
return 0
end
function FlyBalloonHighScore(context)
ScriptLib.PrintContextLog(context, "## FlyBalloonHighScore | uid -> "..context.uid.." | source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70360138})
return 0
end
function FlyBalloonLowScore(context)
ScriptLib.PrintContextLog(context, "## FlyBalloonLowScore | uid -> "..context.uid.." | source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["trigger_gadget_id"]=70360137})
return 0
end
function FlyBalloonLanding(context)
ScriptLib.PrintContextLog(context, "## FlyBalloonLanding | uid -> "..context.uid.." | source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local eid = ScriptLib.GetAvatarEntityIdByUid(context, context.uid)
local pos = ScriptLib.GetPosByEntityId(context, eid)
if defs.landing_Y == nil or pos.y <= defs.landing_Y then
--ScriptLib.AddTeamEntityGlobalFloatValue(context, {context.uid}, "has_end_game", 1)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["has_end_game"]=true})
return 0
end
return -1
end
-------------------------------------------
Initialize()
@@ -0,0 +1,3 @@
function ChallengeFail(context)
ScriptLib.StopChallenge(context,2008 ,0)
end
@@ -0,0 +1,288 @@
--[[local defs = {
gadget_operator = xxx,
group_id = xxx,
gadget_prison_list = {1,2,3,4}
}--]]
local play_param = {
prepare_time = 20,
duration = 240,
hunter_skill = {9013,9014,9017},
prey_skill = {9015,9016,9018}
}
local Tri = {
{ name = "gadget_create", config_id = 8000001, event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0},
{ name = "select_option", config_id = 8000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
{ name = "challenge_success", config_id = 8000003, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
{ name = "challenge_fail", config_id = 8000004, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_counter = 0},
{ name = "variable_change", config_id = 8000005, event = EventType.EVENT_VARIABLE_CHANGE, source = "catch_sum", condition = "", action = "action_variable_change", trigger_count = 0, tag = "9012"},
{ name = "time_axis_pass", config_id = 8000006, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
{ name = "enter_region", config_id = 8000007, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false}
}
local Var = {
{ config_id=50000001,name = "catch_sum", value = 0, no_refresh = false}
}
function Initialize()
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_gadget_create(context, evt)
if evt.param1 == defs.gadget_operator then
ScriptLib.PrintContextLog(context, "--------------- version 21 ---------------------")
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, evt.param1, {2902})
end
return 0
end
function action_select_option(context, evt)
if evt.param1 == defs.gadget_operator and evt.param2 == 2902 then
ScriptLib.KillEntityByConfigId(context, { group_id = defs.group_id, config_id = defs.gadget_operator, entity_type = EntityType.GADGET })
LF_Start_Hide_And_Seek(context)
end
return 0
end
function action_challenge_success(context, evt)
ScriptLib.PrintContextLog(context, "## HS_Log : challenge_success -> "..evt.param1)
if evt.param1 == 9011 then
LF_Stop_Hide_And_Seek(context, 1)
end
return 0
end
function action_challenge_fail(context, evt)
ScriptLib.PrintContextLog(context, "## HS_Log : challenge_fail -> "..evt.param1)
if evt.param1 == 9011 then
LF_Stop_Hide_And_Seek(context, 2)
end
return 0
end
function action_variable_change(context, evt)
if evt.param1 == evt.param2 + 1 then
return 0
else
return -1
end
end
function action_time_axis_pass(context, evt)
if evt.source_name == "prepare" then
LF_Start_Comp_Challenge(context)
end
return 0
end
function action_enter_region(context, evt)
if evt.param1 ~= 471011 then
return -1
end
local uid_list = ScriptLib.GetSceneUidList(context)
if ScriptLib.GetRegionEntityCount(context, {region_eid = evt.source_eid, entity_type = EntityType.AVATAR}) == #uid_list then
if 1 == ScriptLib.GetGroupTempValue(context, "in_prepare", {}) then
LF_Prepare_Comp_Challenge(context)
ScriptLib.SetGroupTempValue(context, "in_prepare", 0, {})
end
end
return 0
end
---------------------------------------
function LF_Start_Hide_And_Seek(context)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Start_Hide_And_Seek")
ScriptLib.SetGroupTempValue(context, "in_prepare", 1, {})
LF_Assign_Character_Card(context)
end
function LF_Stop_Hide_And_Seek(context, value)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Stop_Hide_And_Seek")
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, {uid_list}, {1})
-------
if value == 1 then
--hunter胜利
ScriptLib.ShowTemplateReminder(context, 125, {0})
elseif value == 2 then
--prey胜利
ScriptLib.ShowTemplateReminder(context, 126, {0})
end
ScriptLib.CreateGadget(context, {config_id = defs.gadget_operator})
--玩法结束,恢复UI面板
ScriptLib.SetPlayerInteractOption(context, "HideAndSeek_Stop")
ScriptLib.RemoveExtraGroupSuite(context, 0,3)
end
function LF_Assign_Character_Card(context)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Assign_Character_Card")
--分配hunter人员
local uid_list = ScriptLib.GetSceneUidList(context)
math.randomseed(ScriptLib.GetServerTime(context))
local choice = math.random(#uid_list)
local hunter = uid_list[choice]
ScriptLib.PrintContextLog(context, "## HS_Log : hunter_uid = "..hunter)
ScriptLib.ShowTemplateReminder(context, 124, {choice})
ScriptLib.SetGroupTempValue(context, "hunter", hunter, {})
for i,v in ipairs(defs.gadget_prison_list) do
if i == choice then
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, v, 0)
else
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, v, 201)
end
end
for i,v in ipairs(uid_list) do
for m,n in ipairs(points) do
if n.config_id == defs.trans_point_list[i] then
ScriptLib.TransPlayerToPos(context, {uid_list={v}, pos=n.pos, radius=0, rot=n.rot})
end
end
end
LF_Bake_Random_Scene(context)
end
function LF_Prepare_Comp_Challenge(context)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Prepare_Comp_Challenge")
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetPlayerGroupVisionType(context, {uid_list}, {0})
ScriptLib.CreateFatherChallenge(context, 9011, 9011, play_param.prepare_time, {success=10,fail=10})
ScriptLib.AttachChildChallenge(context,9011,9019,9019,{defs.group_id,10},{},{success=1,fail=1})
ScriptLib.InitTimeAxis(context, "prepare", {play_param.prepare_time - 1}, false)
ScriptLib.StartFatherChallenge(context, 9011)
--玩法准备阶段,禁用小地图,禁用普攻与技能
ScriptLib.SetPlayerInteractOption(context, "HideAndSeek_Prepare")
end
function LF_Start_Comp_Challenge(context)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Start_Comp_Challenge")
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.StopChallenge(context, 9019, 1)
ScriptLib.ModifyFatherChallengeProperty(context, 9011, FatherChallengeProperty.DURATION, play_param.duration)
ScriptLib.AttachChildChallenge(context, 9011, 9012, 9012, {0,3,9012,#uid_list-1}, {},{success=10,fail=1})
--解除hunter限制
for i,v in ipairs(defs.gadget_prison_list) do
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, v, 201)
end
local hunter = ScriptLib.GetGroupTempValue(context, "hunter", {})
ScriptLib.PrintContextLog(context, "## hunter_uid = "..hunter)
for i,v in ipairs(uid_list) do
ScriptLib.PrintContextLog(context, "## compare_uid = "..v)
if v == hunter then
for m,n in ipairs(play_param.hunter_skill) do
ScriptLib.AttachChildChallenge(context,9011,n*math.pow(10,10)+v,n,{defs.group_id,10},{v},{success=1,fail=1})
end
else
for m,n in ipairs(play_param.prey_skill) do
ScriptLib.AttachChildChallenge(context,9011,n*math.pow(10,10)+v,n,{defs.group_id,10},{v},{success=1,fail=1})
end
end
end
--玩法开始,禁用小地图,还原技能面板
ScriptLib.SetPlayerInteractOption(context, "HideAndSeek_Start")
end
function LF_Bake_Random_Scene(context)
if #suites >= 3 then
math.randomseed(ScriptLib.GetServerTime(context))
for i,v in ipairs(suites[3].gadgets) do
if math.random(100) > 50 then
ScriptLib.CreateGadget(context, {config_id = v})
end
end
end
end
---------------------------------------
local skill_info = {
[1] = { name = "HideSeek_Skill_DisguiseRevealing", key = "Disguise_Forbid", radius = 3 },
[2] = { name = "HideSeek_Skill_Hunting", key = "Play_Forbid", radius = 3 },
[3] = { name = "HideSeek_Skill_Struggle_Succ", key = "Disguise_Forbid"}
}
function HideSeek_Skill_DisguiseRevealing(context)
ScriptLib.PrintContextLog(context, "## HS_Log : HideSeek_Skill_DisguiseRevealing")
local skill_name = "HideSeek_Skill_DisguiseRevealing"
LF_Handle_Skill(context, skill_name)
return 0
end
function HideSeek_Skill_Hunting(context)
ScriptLib.PrintContextLog(context, "## HS_Log : HideSeek_Skill_Hunting")
local skill_name = "HideSeek_Skill_Hunting"
LF_Handle_Skill(context, skill_name)
return 0
end
---------------------------------------
function LF_Handle_Skill(context, skill_name)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Handle_Skill")
ScriptLib.PrintContextLog(context, "## HS_Log : uid = "..context.uid)
local hunter_eid = ScriptLib.GetAvatarEntityIdByUid(context, context.uid)
ScriptLib.PrintContextLog(context, "## HS_Log : ueid ="..hunter_eid)
local hunter_pos = ScriptLib.GetPosByEntityId(context, hunter_eid)
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
ScriptLib.PrintContextLog(context, "## HS_Log : get uid_list to "..v)
if v ~= context.uid then
local prey_eid = ScriptLib.GetAvatarEntityIdByUid(context, v)
local prey_pos = ScriptLib.GetPosByEntityId(context, prey_eid)
local info_ = LF_Get_Skill_Info(context, skill_name)
ScriptLib.PrintContextLog(context, "## HS_Log : radius = "..info_.radius.." | uid = "..v)
if LF_Get_Distance(context, hunter_pos, prey_pos) <= info_.radius then
local value_ = ScriptLib.GetTeamAbilityFloatValue(context, v, info_.key)
ScriptLib.PrintContextLog(context, "## HS_Log : value_ = "..value_)
if value_ == 1 then
ScriptLib.AddTeamEntityGlobalFloatValue(context, {v}, info_.key, -1)
end
LF_Handle_Progress(context, skill_name, v)
end
end
end
end
function LF_Get_Distance(context, pos1, pos2)
local X = pos1.x - pos2.x
local Y = pos1.y - pos2.y
local Z = pos1.z - pos2.z
ScriptLib.PrintContextLog(context, "## HS_Log : X = "..X.." | Y = "..Y.." | Z = "..Z)
return math.sqrt(math.pow(X,2)+math.pow(Y,2)+math.pow(Z,2))
end
function LF_Get_Skill_Info(context, name)
for i,v in ipairs(skill_info) do
if v.name == name then
ScriptLib.PrintContextLog(context, "## HS_Log : skill_name = "..name)
return v
end
end
return -1
end
function LF_Handle_Progress(context, skill_name, uid)
ScriptLib.PrintContextLog(context, "## HS_Log : LF_Handle_Progress")
ScriptLib.PrintContextLog(context, "## HS_Log : skill = "..skill_name.." | uid = "..uid)
if skill_name == "HideSeek_Skill_Hunting" then
if 0 == ScriptLib.GetTeamAbilityFloatValue(context, uid, "Play_Forbid") then
ScriptLib.AddTeamEntityGlobalFloatValue(context, {uid}, "Play_Forbid", 1)
ScriptLib.ChangeGroupVariableValue(context, "catch_sum", 1)
local uid_list = ScriptLib.GetSceneUidList(context)
local idx = 0
for i,v in ipairs(uid_list) do
if uid == v then
idx = i
break
end
end
ScriptLib.PrintContextLog(context, "## HS_Log : idx = "..idx)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.gadget_prison_list[idx], 0)
ScriptLib.TransPlayerToPos(context, {uid_list={uid},pos=gadgets[defs.gadget_prison_list[idx]].pos,radius=0,rot=gadgets[defs.gadget_prison_list[idx]].rot})
end
end
end
----------------------------------------
Initialize()
@@ -0,0 +1,672 @@
local play={
group_bigworld = 133002418,
group_quest = 133002415,
PlayType = 3,
PlayId = 3
}
local extraTriggers={
{config_id = 8000001,name = "Any_IceSquare_Die", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "condition_any_gadget_die", action = "action_any_gadget_die", trigger_count = 0 },
{config_id = 8000002,name = "Any_Specialice_Die", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "condition_any_specialice_die", action = "action_any_specialice_die", trigger_count = 0 },
{config_id = 8000003,name = "Monster_Die_Before_Leave_Scene", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "condition_monster_die_before_leave_scene", action = "action_monster_die_before_leave_scene", trigger_count = 0 },
{ config_id = 8000004,name = "Battle_State", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_STATE, source = "", condition = "condition_battle_state", action = "action_battle_state", trigger_count = 0 },
{ config_id = 8000005,name = "Battle_Result", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_RESULT, source = "", condition = "", action = "action_battle_result", trigger_count = 0 },
{ config_id = 8000006,name = "TIMER_EVENT_TRANSFORM", event = EventType.EVENT_TIMER_EVENT, source = "transform", condition = "", action = "action_TIMER_EVENT_TRANSFORM", trigger_count = 0 },
{config_id = 8000007,name = "First_Monster_Die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "condition_first_monster_die", action = "action_first_monster_die", trigger_count = 1 },
{config_id = 8000008,name = "Ice_Square_Create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "condition_ice_square_create", action = "action_ice_square_create", trigger_count = 0 },
{ config_id = 8000009,name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "condition_EVENT_LEAVE_REGION", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
{config_id = 8000010,name = "Any_Player_Die", event = EventType.EVENT_SCENE_MP_PLAY_ALL_AVATAR_DIE, source = "", condition = "condition_EVENT_AVATAR_DIE", action = "action_EVENT_LEAVE_REGION", trigger_count = 0 },
{config_id = 8000011,name = "Reset_Gadget_State", event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "condition_Reset_Gadget_State", action = "action_Reset_Gadget_State", trigger_count = 0 },
{config_id = 8000012,name = "Gadget_Create_Check", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_Gadget_Create_Log", trigger_count = 0 },
{config_id = 8000013,name = "Gadget_Die_Check", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_Gadget_Die_Log", trigger_count = 0 },
{config_id = 8000014,name = "Gadget_State_Change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Gadget_State_Log", trigger_count = 0 },
{config_id = 8000015,name = "MP_PLAY_BATTLE_INTERRUPT", event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_INTERRUPT, source = "", condition = "", action = "action_SCENE_MP_PLAY_BATTLE_INTERRUPT", trigger_count = 0 },
{ config_id = 8000016,name = "TIMER_EVENT_PHASECHECKONE", event = EventType.EVENT_TIMER_EVENT, source = "phaseonecheck", condition = "", action = "action_PHASE_ONE_CHECK", trigger_count = 0 },
{ config_id = 8000017,name = "TIMER_EVENT_PHASECHECKTWO", event = EventType.EVENT_TIMER_EVENT, source = "phasetwocheck", condition = "", action = "action_PHASE_TWO_CHECK", trigger_count = 0 },
{ config_id = 8000019,name = "LEAVE_REGION2", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "condition_EVENT_LEAVE_REGION2", action = "action_EVENT_LEAVE_REGION2", forbid_guest = false, trigger_count = 0 },
{ config_id = 8000020,name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_EVENT_ENTER_REGION", action = "action_EVENT_ENTER_REGION", forbid_guest = false, trigger_count = 0 },
}
local repairTriggers={
{ config_id = 8000018,name = "Boss_Refresh", event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "", action = "action_BOSS_REFRESH", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
if defs.groupId==133002415 then
for i=1,#extraTriggers do
--table.insert(triggers, extraTriggers[i])
table.insert(suites[1].triggers,extraTriggers[i].name)
end
end
if defs.groupId==133002418 then
table.insert(variables, { config_id=50000001,name = "phaseOneIceRevert", value = 0})
for i=1,#repairTriggers do
table.insert(triggers, repairTriggers[i])
--table.insert(triggers, extraTriggers[i])
table.insert(suites[2].triggers,repairTriggers[i].name)
end
end
end
function action_BOSS_REFRESH(context, evt)
if evt.param1==418001 then
ScriptLib.FailScenePlayBattle(context, defs.groupId)
end
return 0
end
function action_PHASE_ONE_CHECK(context, evt)
if ScriptLib.GetGroupVariableValue(context, "phaseonecheckvalue") ~= 1 then
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {defs.bossId}, "_SERVER_REGISVINE_ICE_ACTIVITY_FLAG_PHASE01", 1)
ScriptLib.CreateGroupTimerEvent(context, defs.groupId, "phaseonecheck", 1)
end
return 0
end
function action_PHASE_TWO_CHECK(context, evt)
if ScriptLib.GetGroupVariableValue(context, "phasetwocheckvalue") ~= 1 then
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {defs.bossId}, "_SERVER_REGISVINE_ICE_ACTIVITY_FLAG_PHASE02", 1)
ScriptLib.CreateGroupTimerEvent(context, defs.groupId, "phasetwocheck", 1)
end
return 0
end
function action_SCENE_MP_PLAY_BATTLE_INTERRUPT(context, evt)
ScriptLib.PrintContextLog(context, "MPPLAY INTERRUPT"..evt.param1.."->"..evt.param2.."->"..evt.param3)
ScriptLib.SetGadgetStateByConfigId(context,defs.iceStormId,GadgetState.GearStop)
if defs.inteeGadget ~= nil then
ScriptLib.SetGadgetStateByConfigId(context,defs.inteeGadget,GadgetState.Default)
end
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.iceStormId)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice1)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice2)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice3)
if defs.inteeGadget ~= nil then
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.inteeGadget)
end
ScriptLib.RefreshGroup(context,{group_id=defs.groupId,suite=1})
return 0
end
function action_Gadget_Create_Log(context, evt)
ScriptLib.PrintContextLog(context, "Gadget Created->"..evt.param1)
return 0
end
function action_Gadget_Die_Log(context, evt)
ScriptLib.PrintContextLog(context, "Gadget Dead->"..evt.param1)
return 0
end
function action_Gadget_State_Log(context, evt)
ScriptLib.PrintContextLog(context, "Gadget State Changed->"..evt.param2.." From "..evt.param3.." To "..evt.param1)
return 0
end
function condition_Reset_Gadget_State(context, evt)
if evt.param1 == 1 then
return true
end
return false
end
function action_Reset_Gadget_State(context, evt)
ScriptLib.CancelGroupTimerEvent(context, defs.groupId, "phaseonecheck")
ScriptLib.CancelGroupTimerEvent(context, defs.groupId, "phasetwocheck")
if defs.inteeGadget ~= nil then
ScriptLib.CreateGadget(context, { config_id = defs.inteeGadget })
end
ScriptLib.SetGadgetStateByConfigId(context,defs.specialice1,GadgetState.Default)
ScriptLib.SetGadgetStateByConfigId(context,defs.specialice2,GadgetState.Default)
ScriptLib.SetGadgetStateByConfigId(context,defs.specialice3,GadgetState.Default)
if defs.inteeGadget ~= nil then
ScriptLib.SetGadgetStateByConfigId(context,defs.inteeGadget,GadgetState.Default)
end
return 0
end
function condition_EVENT_LEAVE_REGION(context, evt)
if ScriptLib.GetGroupVariableValue(context, "isStarted") ~= 1 then
return false
end
if evt.param1 ~= defs.region then
return false
end
uidList=ScriptLib.GetSceneUidList(context)
local count=0
for i=1,#uidList do
if ScriptLib.IsPlayerAllAvatarDie(context, uidList[i]) or (calculateXZDistanceOfTwoEntity(context,ScriptLib.GetAvatarEntityIdByUid(context, uidList[i]),ScriptLib.GetEntityIdByConfigId(context, defs.bossId))>=25) then
count=count+1
end
end
if count >= (#uidList) then
return true
end
return false
end
function condition_EVENT_LEAVE_REGION2(context, evt)
if evt.param1 ~= 418036 then
return false
end
return true
end
function action_EVENT_LEAVE_REGION2(context, evt)
if context.uid~=0 then
ScriptLib.ClearPlayerEyePoint(context, 418067)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
end
return 0
end
function condition_EVENT_ENTER_REGION(context, evt)
if evt.param1 ~= 418067 then
return false
end
return true
end
function action_EVENT_ENTER_REGION(context, evt)
if context.uid~=0 then
local small_region={}
local big_region={}
for i=1,#regions do
if regions[i].config_id==418067 then
small_region=regions[i]
end
if regions[i].config_id==418036 then
big_region=regions[i]
end
end
TrySetPlayerEyePoint(context, small_region, big_region, 1, {0})
end
return 0
end
function condition_EVENT_AVATAR_DIE(context, evt)
if ScriptLib.GetGroupVariableValue(context, "isStarted") ~= 1 then
return false
end
uidList=ScriptLib.GetSceneUidList(context)
local count=0
for i=1,#uidList do
if ScriptLib.IsPlayerAllAvatarDie(context, uidList[i]) or (calculateXZDistanceOfTwoEntity(context,ScriptLib.GetAvatarEntityIdByUid(context, uidList[i]),ScriptLib.GetEntityIdByConfigId(context, defs.bossId))>=25) then
count=count+1
end
end
if count >= (#uidList) then
return true
end
return false
end
function calculateXZDistanceOfTwoEntity(context,entity1,entity2)
local pos1=ScriptLib.GetPosByEntityId(context, entity1)
local pos2=ScriptLib.GetPosByEntityId(context, entity2)
local distance=math.sqrt((pos1.x-pos2.x)*(pos1.x-pos2.x)+(pos1.z-pos2.z)*(pos1.z-pos2.z))
return distance
end
function action_EVENT_LEAVE_REGION(context, evt)
ScriptLib.FailScenePlayBattle(context, defs.groupId)
return 0
end
function condition_ice_square_create(context, evt)
if evt.param1 == defs.iceSquareId then
return true
end
return false
end
function action_ice_square_create(context, evt)
ScriptLib.ShowReminderRadius(context, 400017, {x=1080,y=285,z=-439}, 25)
return 0
end
function condition_first_monster_die(context, evt)
if defs.groupId == 133002418 then
return true
end
return false
end
function action_first_monster_die(context, evt)
ScriptLib.ShowReminderRadius(context, 400016, {x=1080,y=285,z=-439}, 25)
return 0
end
function action_TIMER_EVENT_TRANSFORM(context, evt)
ScriptLib.TransPlayerToPos(context, {uid_list =ScriptLib.GetSceneUidList(context), pos = {x=1121, y=286, z=-425}, radius = 2, rot = {x=0, y=180, z=0},is_skip_ui=true})
return 0
end
function action_battle_result(context, evt)
if evt.param3 == 1 then
LF_Battle_Win(context, evt)
elseif evt.param3 == 0 then
LF_Battle_Lose(context, evt)
--elseif evt.param3 == 2 then
--LF_Battle_Stop(context, evt)
end
return 0
end
function condition_battle_state(context, evt)
if defs.groupId == play.group_bigworld then
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_LOG: battle_state : param1->"..evt.param1.." | param2->"..evt.param2.." | param3->"..evt.param3)
end
if evt.param1 == play.PlayType and evt.param2 == play.PlayId then
return true
end
return false
end
function action_battle_state(context, evt)
--BATTLE_PREPARE
if evt.param3 == 2 then
LF_Battle_Prepare(context, evt)
--BATTLE_READY
elseif evt.param3 == 3 then
LF_Battle_Ready(context, evt)
--BATTLE_PRESTART
elseif evt.param3 == 4 then
LF_Battle_Prestart(context, evt)
--BATTLE_START
elseif evt.param3 == 5 then
LF_Battle_Start(context, evt)
--[[--BATTLE_STOP
elseif evt.param3 == 6 then
LF_Battle_Stop(context, evt)--]]
elseif defs.groupId == play.group_bigworld then
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_ERR : Invalid Battle State")
return -1
end
return 0
end
--检测急冻树死亡
function condition_monster_die_before_leave_scene(context, evt)
if evt.param1 == defs.bossId then
return true
end
return false
end
function action_monster_die_before_leave_scene(context, evt)
local uid=context.uid
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_LOG : action_monster_die_before_leave_scene uid:"..uid)
if uid~=0 and uid ~=nil then
ScriptLib.SetScenePlayBattleUidValue(context, 0, uid, "AVATAR_BOSS_KILL", 1)
end
--增加玩法总进度
ScriptLib.AddScenePlayBattleProgress(context, defs.groupId, 301)
return 0
end
function condition_any_gadget_die(context, evt)
if evt.param1 ~= defs.iceSquareId then
return false
end
return true
end
--冰立方死亡创建屏障
function action_any_gadget_die(context, evt)
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_LOG : AVATAR_ICESHIELD_KILL UID:"..context.uid)
ScriptLib.SetGroupVariableValue(context, "iceCubeAlive", 0)
if ScriptLib.GetGroupVariableValue(context, "notCreateIceShieldActivated") ~= 1 then
if context.uid ~= 0 then
local uid = context.uid
local oldCount = ScriptLib.GetScenePlayBattleUidValue(context, 0, uid, "AVATAR_ICESHIELD_KILL_COUNT")
ScriptLib.SetScenePlayBattleUidValue(context, 0, uid, "AVATAR_ICESHIELD_KILL_COUNT", oldCount+1)
end
ScriptLib.KillEntityByConfigId(context, { config_id = defs.targetId })
local idx=ScriptLib.GetGroupVariableValue(context, "positionIdx")
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.iceShieldId, gadgets[idx].pos,gadgets[idx].rot)
end
ScriptLib.SetGroupVariableValue(context, "notCreateIceShieldActivated", 0)
return 0
end
--特殊冰死亡
function condition_any_specialice_die(context, evt)
if evt.param1 == defs.specialice1 then
return true
end
if evt.param1 == defs.specialice2 then
return true
end
if evt.param1 == defs.specialice3 then
return true
end
return false
end
--特殊冰死亡加uidvalue
function action_any_specialice_die(context, evt)
local configId = evt.param1
local uidValue = configId.."_Hit_Uid"
local uid = ScriptLib.GetGroupVariableValue(context, uidValue)
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_LOG : action_any_specialice_die uid:"..uid)
if uid ~= 0 and uid ~=nil then
local oldCount = ScriptLib.GetScenePlayBattleUidValue(context, 0, uid, "AVATAR_SPECIALICE_KILL_COUNT")
ScriptLib.SetScenePlayBattleUidValue(context, 0, uid, "AVATAR_SPECIALICE_KILL_COUNT", oldCount+1)
end
if ScriptLib.GetGroupVariableValue(context, "phaseOneIceRevert") ~= 1 then
ScriptLib.CreateGadget(context, { config_id = evt.param1 })
end
return 0
end
--------------------------------------------
--------------------------------------------
function LF_Battle_Prepare(context, evt)
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_LOG : LF_Battle_Prepare")
--ScriptLib.PrintLog("================VERSION 76=========================")
--关闭大陨石交互
--ScriptLib.SetGadgetEnableInteract(context, defs.groupId, defs.inteeGadget, false)
if defs.inteeGadget ~= nil then
ScriptLib.KillGroupEntity(context,{group_id=defs.groupId,gadgets={defs.inteeGadget}})
end
--ScriptLib.SetGroupGadgetStateByConfigId(context, defs.groupId, defs.inteeGadget, GadgetState.GearStart)
return 0
end
function LF_Battle_Ready(context, evt)
--ScriptLib.PrintContextLog(context, "## ASTER_LOG : LF_Battle_Ready")
--随机难度
--[[
local D_str = LF_Random_Play_Difficulty(context, evt)
local D_num = 0
if D_str == "normal" then
D_num = 1
elseif D_str == "hard" then
D_num = 2
elseif D_str == "nightmare" then
D_num = 3
elseif D_str == "easy" then
D_num = 4
end
--启用playEntity
LF_Attach_Ability(context, evt, D_num, D_str)
]]--
--开启主玩法
ScriptLib.PrestartScenePlayBattle(context, {duration = 600,start_cd = 5,progress_stage = {0,100,200,300}, group_id = defs.groupId, mode = 200})
ScriptLib.CreateGadget(context, { config_id = 418020 })
ScriptLib.CreateGadget(context, { config_id = 418026 })
ScriptLib.CreateGadget(context, { config_id = 418062 })
--写入难度
--LF_Set_Battle_Difficulty(context, evt, D_num)
--生成Buff序列
--LF_Init_Uid_Op_Buff(context, evt)--]]
return 0
end
function LF_Battle_Prestart(context, evt)
--3秒倒计时提醒
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_LOG : LF_Battle_Prestart")
ScriptLib.SetGroupVariableValue(context, "phaseOneIceRevert", 1)
--[[--随机难度
LF_Random_Play_Difficulty(context, evt)
--生成Buff序列
LF_Init_Uid_Op_Buff(context, evt)--]]
return 0
end
function LF_Battle_Start(context, evt)
ScriptLib.SetGroupVariableValue(context, "isStarted", 1)
--正式开始
if ScriptLib.GetScenePlayBattleType(context, defs.groupId) ==1 then
ScriptLib.AutoMonsterTide(context, 1, defs.groupId, defs.monsterTideOne, 999, 3, 3)
elseif ScriptLib.GetScenePlayBattleType(context, defs.groupId) ==2 then
ScriptLib.AutoMonsterTide(context, 2, defs.groupId, defs.monsterTideTwo, 999, 3, 3)
end
--ScriptLib.AutoMonsterTide(context, 1, defs.groupId, {defs.monsterOne,defs.monsterTwo}, 999, 1, 1)
ScriptLib.SetGadgetStateByConfigId(context,defs.specialice1,GadgetState.GearStart)
ScriptLib.SetGadgetStateByConfigId(context,defs.specialice2,GadgetState.GearStart)
ScriptLib.SetGadgetStateByConfigId(context,defs.specialice3,GadgetState.GearStart)
ScriptLib.AddExtraGroupSuite(context, defs.groupId, 2)
ScriptLib.SetGroupVariableValue(context, "MonsterTideCheck", 0)
--怪物转阶段
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {418001}, "_SERVER_REGISVINE_ICE_ACTIVITY_FLAG_PHASE01", 1)
ScriptLib.CreateGroupTimerEvent(context, defs.groupId, "phaseonecheck", 1)
return 0
end
function LF_Battle_Win(context, evt)
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_LOG : LF_Battle_Win")
ScriptLib.SetGadgetStateByConfigId(context,defs.iceStormId,GadgetState.GearStop)
if defs.inteeGadget ~= nil then
ScriptLib.SetGadgetStateByConfigId(context,defs.inteeGadget,GadgetState.Default)
end
--ScriptLib.KillGroupEntity(context,{group_id=defs.groupId,monsters={defs.monsterOne,defs.monsterTwo,defs.monsterThree,defs.monsterFour},gadgets={defs.iceStormId,defs.specialice1,defs.specialice2,defs.specialice3,defs.inteeGadget}})
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.iceStormId)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice1)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice2)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice3)
if defs.inteeGadget ~= nil then
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.inteeGadget)
end
ScriptLib.RefreshGroup(context,{group_id=defs.groupId,suite=1})
ScriptLib.CreateScenePlayGeneralRewardGadget(context, {group_id = defs.groupId, config_id = defs.rewardGadget})
--ScriptLib.CreateGadget(context,{config_id=defs.rewardGadget})
ScriptLib.CreateGroupTimerEvent(context, defs.groupId, "transform", 3)
--ScriptLib.TransPlayerToPos(context, {uid_list =ScriptLib.GetSceneUidList(context), pos = {x=1121, y=286, z=-425}, radius = 2, rot = {x=0, y=180, z=0},is_skip_ui=true})
--ScriptLib.SetGadgetEnableInteract(context, defs.groupId, defs.inteeGadget, true)
return 0
end
function LF_Battle_Lose(context, evt)
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_LOG : LF_Battle_Lose")
ScriptLib.SetGadgetStateByConfigId(context,defs.iceStormId,GadgetState.GearStop)
if defs.inteeGadget ~= nil then
ScriptLib.SetGadgetStateByConfigId(context,defs.inteeGadget,GadgetState.Default)
end
--ScriptLib.KillGroupEntity(context,{group_id=defs.groupId,monsters={defs.monsterOne,defs.monsterTwo,defs.monsterThree,defs.monsterFour},gadgets={defs.iceStormId,defs.specialice1,defs.specialice2,defs.specialice3,defs.inteeGadget}})
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.iceStormId)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice1)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice2)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice3)
if defs.inteeGadget ~= nil then
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.inteeGadget)
end
--ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.MONSTER, defs.bossId)
ScriptLib.RefreshGroup(context,{group_id=defs.groupId,suite=1})
ScriptLib.CreateGroupTimerEvent(context, defs.groupId, "transform", 3)
--ScriptLib.TransPlayerToPos(context, {uid_list =ScriptLib.GetSceneUidList(context), pos = {x=1121, y=286, z=-425}, radius = 2, rot = {x=0, y=180, z=0},is_skip_ui=true})
--ScriptLib.SetGadgetEnableInteract(context, defs.groupId, defs.inteeGadget, true)
return 0
end
function LF_Battle_Stop(context, evt)
ScriptLib.PrintContextLog(context, "## ICEFLOWERBOSS_LOG : LF_Battle_Stop")
ScriptLib.SetGadgetStateByConfigId(context,defs.iceStormId,GadgetState.GearStop)
if defs.inteeGadget ~= nil then
ScriptLib.SetGadgetStateByConfigId(context,defs.inteeGadget,GadgetState.Default)
end
--ScriptLib.KillGroupEntity(context,{group_id=defs.groupId,monsters={defs.monsterOne,defs.monsterTwo,defs.monsterThree,defs.monsterFour},gadgets={defs.iceStormId,defs.specialice1,defs.specialice2,defs.specialice3,defs.inteeGadget}})
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.iceStormId)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice1)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice2)
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.specialice3)
if defs.inteeGadget ~= nil then
ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.GADGET, defs.inteeGadget)
end
--ScriptLib.RemoveEntityByConfigId(context, defs.groupId, EntityType.MONSTER, defs.bossId)
ScriptLib.RefreshGroup(context,{group_id=defs.groupId,suite=1})
--ScriptLib.CreateGroupTimerEvent(context, defs.groupId, "transform", 3)
ScriptLib.TransPlayerToPos(context, {uid_list =ScriptLib.GetSceneUidList(context), pos = {x=1121, y=286, z=-425}, radius = 2, rot = {x=0, y=180, z=0},is_skip_ui=false})
--ScriptLib.TransPlayerToPos(context, {uid_list =ScriptLib.GetSceneUidList(context), pos = {x=1121, y=286, z=-425}, radius = 2, rot = {x=0, y=180, z=0},is_skip_ui=true})
--ScriptLib.SetGadgetEnableInteract(context, defs.groupId, defs.inteeGadget, true)
return 0
end
--创建冰立方时同时创建龙血结晶生成器
function CreateDulinsOreGenerators(context,idx)
math.randomseed(ScriptLib.GetServerTime(context))
local count=math.random(2,3)
for i=1,count do
ScriptLib.CreateGadget(context, { config_id = defs.bloodOrePositions[idx][i] })
end
return 0
end
--随机创建冰立方
function CreateIceShield(context)
ScriptLib.SetGroupVariableValue(context, "notCreateIceShieldActivated", 0)
alive=ScriptLib.GetGroupVariableValue(context, "iceCubeAlive")
if alive ~=1 then
local newIdx=1
math.randomseed(ScriptLib.GetServerTime(context))
newIdx=math.random(#defs.randomPositions)
for i=1,#gadgets do
if gadgets[i].config_id==defs.randomPositions[newIdx] then
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.iceSquareId, gadgets[i].pos,gadgets[i].rot)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.targetId, gadgets[i].pos,gadgets[i].rot)
ScriptLib.SetGroupVariableValue(context, "positionIdx", i)
ScriptLib.SetGroupVariableValue(context, "iceCubeAlive", 1)
end
end
local count=math.random(2,3)
for j=1,count do
ScriptLib.CreateGadget(context, { config_id = defs.bloodOrePositions[newIdx][j] })
end
--CreateDulinsOreGenerators(context,newIdx)
end
return 0
end
--[[
--创建离BOSS正面最近的冰立方
function CreateNearestIceShield(context)
alive=ScriptLib.GetGroupVariableValue(context, "iceCubeAlive")
if alive ~=1 then
local minOne={angle=180,idx=-1}
local vector={}
local monsterRotate=ScriptLib.GetRotationByEntityId(context, 24001).y
local monsterForward=CalculateMonsterForward(monsterRotate)
local monsterPosition=monsters[1].pos
for i=1,#defs.randomPositions do
for j=1,#gadgets do
if gadgets[j].config_id==defs.randomPositions[i] then
vector.x=gadgets[j].pos.z-monsterPosition.z
vector.y=gadgets[j].pos.x-monsterPosition.x
local angle=CalculateRotate(monsterForward.x,monsterForward.y,vector.x,vector.y)
if angle<minOne.angle then
minOne.angle=angle
minOne.idx=j
end
end
end
end
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.iceSquareId, gadgets[minOne.idx].pos,gadgets[minOne.idx].rot)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.targetId, gadgets[minOne.idx].pos,gadgets[minOne.idx].rot)
ScriptLib.SetGroupVariableValue(context, "positionIdx", minOne.idx)
ScriptLib.SetGroupVariableValue(context, "iceCubeAlive", 1)
CreateDulinsOreGenerators(minOne.idx)
end
end
function CalculateMonsterForward(monsterRotate)
local monsterForward={}
monsterForward.x=math.cos(math.rad(monsterRotate))
monsterForward.y=math.sin(math.rad(monsterRotate))
return monsterForward
end
]]--
function CalculateRotate(x1,y1,x2,y2)
local cos=(x1*x2+y1*y2)/(math.sqrt(x1*x1+y1*y1)*math.sqrt(x2*x2+y2*y2))
local rotate=math.deg(math.acos(cos))
return rotate
end
function DestoryIceShieldActivated(context)
ScriptLib.KillEntityByConfigId(context, { config_id = defs.iceShieldId })
return 0
end
--销毁冰立方,不触发屏障
function DistoryIceShield(context)
ScriptLib.SetGroupVariableValue(context, "notCreateIceShieldActivated", 1)
ScriptLib.KillEntityByConfigId(context, { config_id = defs.iceSquareId })
ScriptLib.KillEntityByConfigId(context, { config_id = defs.targetId })
return 0
end
function CreateIceStorm(context)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.groupId, defs.iceStormId, GadgetState.Default)
return 0
end
function DestoryIceStorm(context)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.groupId, defs.iceStormId, GadgetState.GearStop)
return 0
end
function MonsterPhaseOneCheck(context)
ScriptLib.SetGroupVariableValue(context, "phaseonecheckvalue", 1)
return 0
end
function MonsterPhaseTwoCheck(context)
ScriptLib.SetGroupVariableValue(context, "phasetwocheckvalue", 1)
return 0
end
function StartMonsterTide(context)
if ScriptLib.GetGroupVariableValue(context, "MonsterTideCheck") ==0 then
if ScriptLib.GetScenePlayBattleType(context, defs.groupId) ==1 then
ScriptLib.KillMonsterTide(context, defs.groupId, 1)
ScriptLib.AutoMonsterTide(context, 3, defs.groupId, defs.monsterTideOne, 999, 1, 1)
elseif ScriptLib.GetScenePlayBattleType(context, defs.groupId) ==2 then
ScriptLib.KillMonsterTide(context, defs.groupId, 2)
ScriptLib.AutoMonsterTide(context, 3, defs.groupId, defs.monsterTideTwo, 999, 1, 1)
elseif defs.groupId==133002415 then
ScriptLib.AutoMonsterTide(context, 3, defs.groupId, defs.monsterTideOne, 999, 1, 1)
end
ScriptLib.SetGroupVariableValue(context, "MonsterTideCheck", 1)
else
ScriptLib.ContinueAutoMonster(context, defs.groupId, 3)
end
return 0
end
function PauseMonsterTide(context)
ScriptLib.PauseAutoMonsterTide(context, defs.groupId, 3)
return 0
end
function KillAllMonsters(context)
ScriptLib.PauseAutoMonsterTide(context, defs.groupId, 3)
--[[for i=1,#monsters do
if monsters[i].monster_id~=26020102 then
ScriptLib.KillEntityByConfigId(context, { config_id = monsters[i].config_id })
end
end]]--
ScriptLib.KillGroupEntity(context,{group_id=defs.groupId,monsters=defs.monsterTideOne})
ScriptLib.KillGroupEntity(context,{group_id=defs.groupId,monsters=defs.monsterTideTwo})
return 0
end
function UpdateDulinsBloodPickCount(context)
if context.uid~=nil or context.uid~=0 then
local uid = context.uid
local oldCount = ScriptLib.GetScenePlayBattleUidValue(context, 0, uid, "AVATAR_OREDULINSBLOOD_PICK_COUNT")
ScriptLib.SetScenePlayBattleUidValue(context, 0, uid, "AVATAR_OREDULINSBLOOD_PICK_COUNT", oldCount+1)
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,20 @@
--去重随机
function LR_ChangeSuitsGadgetState(context, suite , gadgetState)
local gadgets = suite.gadgets
for i,v in ipairs(gadgets) do
if 0 ~= ScriptLib.SetGadgetStateByConfigId(context, v, gadgetState) then
ScriptLib.PrintContextLog(context, "## TD_ERROR_LOG : v -> " .. v .. "//gadgetState ->" .. gadgetState)
return -1
end
end
end
-- 调试代码 --
-- LR_ChangeSuitsGadgetState(context, suites[1],201)
@@ -0,0 +1,21 @@
--[[
=====================================================================================================================
|| Filename || MonsterQuickDeath 怪物快速死亡引用脚本
|| RelVersion || 2.5
|| Owner || chao.jin
|| Description || 2.5版本,封装的怪物快速死亡引用
|| LogName ||
|| Protection || 防止找不到Affix是否判断,如果没有affix则手动插入一个
===================================================================================================================]]
function CITE_Monster_quick_death()
for config_id,infos in pairs(monsters) do
if infos.affix ~= nil then
table.insert(infos.affix, 9009)
else
infos["affix"] = {9009}
end
end
end
CITE_Monster_quick_death()
@@ -0,0 +1,459 @@
local relevant_group = {
[1] = 133102769
}
local play = {
PlayType = 4,
PlayId = 4,
board = 70
}
local Tri = {
{ name = "variable_change", config_id = 8000001, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", 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 = "group_will_unload", config_id = 8000004, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0 },
{ name = "time_axis_pass", config_id = 8000005, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
{ name = "group_load", config_id = 8000006, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ name = "any_monster_die", config_id = 8000007, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0 },
{ name = "auth_change", config_id = 8000008, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_auth_change", trigger_count = 0, forbid_guest = false },
{ name = "battle_state", config_id = 8000009, event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_STATE, source = "", condition = "condition_battle_state", action = "action_battle_state", trigger_count = 0 },
{ name = "battle_result", config_id = 8000010, event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_RESULT, source = "", condition = "", action = "action_battle_result", trigger_count = 0 },
{ name = "battle_interrupt", config_id = 8000011, event = EventType.EVENT_SCENE_MP_PLAY_BATTLE_INTERRUPT, source = "", condition = "", action = "action_battle_interrupt", trigger_count = 0},
{ name = "any_player_die", config_id = 8000012, event = EventType.EVENT_SCENE_MP_PLAY_ALL_AVATAR_DIE, source = "", condition = "", action = "action_any_player_die", trigger_count = 0 }
}
local other_Tri = {
[1] = { name = "enter_region", config_id = 7000001, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", forbid_guest = false, trigger_count = 0 }
}
function Initialize()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(triggers, other_Tri[1])
table.insert(suites[11].triggers, other_Tri[1].name)
end
-----------------------------------
function condition_battle_state(context, evt)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG: battle_state : param1->"..evt.param1.." | param2->"..evt.param2.." | param3->"..evt.param3)
if evt.param1 == play.PlayType and evt.param2 == play.PlayId then
return true
end
return false
end
function action_battle_state(context, evt)
--BATTLE_PREPARE
if evt.param3 == 2 then
ScriptLib.SetGadgetEnableInteract(context, 133102112, defs.gadget_operator, false)
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.gadget_operator_list[1], uid_list[1])
LF_Manage_OceanId_Replacement(context, 1)
--BATTLE_READY
elseif evt.param3 == 3 then
ScriptLib.PrestartScenePlayBattle(context, {duration = 600,start_cd = 3,progress_stage = {1}, group_id = 133102112})
ScriptLib.SetGroupTempValue(context, "is_in_battle", 1, {})
--BATTLE_START
elseif evt.param3 == 5 then
LF_Battle_Start(context, evt)
end
return 0
end
function action_battle_result(context, evt)
if evt.param3 == 1 then
LF_Battle_Win(context, evt)
elseif evt.param3 == 0 then
LF_Battle_Lose(context, evt)
end
return 0
end
function action_battle_interrupt(context, evt)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : battle_interrupt")
LF_Battle_Lose(context, evt)
--LF_Manage_OceanId_Replacement(context, 0)
ScriptLib.SetGadgetEnableInteract(context, 133102112, defs.gadget_operator, true)
return 0
end
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "-------------- version 19 ------------------")
--加载中心操作台
if 0 == ScriptLib.GetGroupVariableValue(context, "is_in_replacement") then
ScriptLib.AddExtraGroupSuite(context, 0, 7)
end
return 0
end
function action_variable_change(context, evt)
if evt.param1 == evt.param2 then
return -1
end
ScriptLib.PrintContextLog(context, "## ## ACT_OCEANID_LOG : variable change | "..evt.source_name.." "..evt.param2.." -> "..evt.param1)
--竞争处理
if evt.source_name == "is_in_replacement" then
if evt.param1 == 1 then
--清理战场
LF_Clear_Battle_Arena(context)
elseif evt.param1 == 0 then
--还原启动装置
ScriptLib.AddExtraGroupSuite(context, 0, 7)
end
return 0
elseif evt.source_name == "SummonStep" then
if evt.param1 == 1111 then
ScriptLib.EndTimeAxis(context, "summon")
end
end
return -1
end
--[[function action_gadget_create(context, evt)
--补充开启选项
if evt.param1 == defs.gadget_operator then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, evt.param1, {2902})
end
return 0
end--]]
function action_group_will_unload(context, evt)
ScriptLib.FailScenePlayBattle(context, 133102112)
return 0
end
function action_time_axis_pass(context, evt)
ScriptLib.PrintContextLog(context, "## time axis pass : "..evt.source_name.." | param1 = "..evt.param1)
--依次召唤阶段的处理逻辑
if evt.source_name == "summon" then
local SummonStep_ = ScriptLib.GetGroupTempValue(context, "SummonStep", {})
for i=2,4 do
local temp_ = SummonStep_
if temp_%math.pow(10,i)//math.pow(10,i-1) == 0 then
LF_Summon_Action(context, i+1)
break
end
end
elseif evt.source_name == "summon_delay" then
SLC_Summon_Start(context)
elseif evt.source_name == "stage_1" then
local stage = ScriptLib.GetGroupTempValue(context, "Oceanid_State", {})
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : stage = "..stage)
if 1 == stage then
SLC_Stage_To_2(context)
end
elseif evt.source_name == "shuffle_loop" then
LF_Random_Attack_Platform(context)
end
return 0
end
function action_enter_region(context, evt)
for i,v in ipairs(defs.summon_region_list) do
if v == evt.param1 then
--提前踩出怪,重新计时
LF_Summon_In_Advance(context)
LF_Summon_Action(context, i+2)
break
end
end
return 0
end
function action_any_monster_die(context, evt)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : monster_die = "..evt.param1)
if evt.param1 == defs.monster_boss then
ScriptLib.AddScenePlayBattleProgress(context, 133102112, 1)
else
for k,v in ipairs(defs.stage_monster_list) do
if evt.param1 == v then
--怪死了立即召唤下一只
local temp_ = ScriptLib.GetGroupTempValue(context, "SummonStep", {})
for i=2,4 do
if temp_ == 0 then
break
end
if temp_%math.pow(10,i)//math.pow(10,i-1) ~= 1 then
LF_Summon_Action(context, i+1)
break
end
end
ScriptLib.ChangeGroupTempValue(context, "Oceanid_HP", -10, {})
local hp_ = ScriptLib.GetGroupTempValue(context, "Oceanid_HP", {})
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : boss_cur_hp = "..hp_)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.monster_boss, "SGV_Oceanid_HP", hp_)
--血量40则进入3阶段
if hp_ <= 40 then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.monster_boss, "SGV_Oceanid_State", 3)
ScriptLib.SetGroupTempValue(context, "Oceanid_State", 3, {})
ScriptLib.RemoveExtraGroupSuite(context, 0, 11)
LF_Random_Attack_Platform(context)
ScriptLib.InitTimeAxis(context, "shuffle_loop", {25}, true)
end
break
end
end
end
return 0
end
function action_auth_change(context, evt)
---[[
if evt.param1 == 112009 then
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : uid = "..context.uid)
local ret = ScriptLib.TryReallocateEntityAuthority(context, context.uid, defs.gadget_operator_list[1], evt.param1)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : auth_change_result = "..ret)
if -1 == ret then
if 1 == ScriptLib.GetGroupTempValue(context, "is_in_battle", {}) then
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : Force_End_Battle_With_Failure")
ScriptLib.FailScenePlayBattle(context, 133102112)
end
end
end
--]]
return 0
end
function action_any_player_die(context, evt)
local uid_list=ScriptLib.GetSceneUidList(context)
local cnt = 0
for i,v in ipairs(uid_list) do
if ScriptLib.IsPlayerAllAvatarDie(context, v) or LF_Get_Distance(context, v, defs.gadget_operator) >= play.board then
cnt = cnt + 1
end
end
if cnt < #uid_list then
return -1
end
ScriptLib.FailScenePlayBattle(context, 133102112)
return 0
end
---------------------------------------
function LF_Get_Distance(context, uid, config_id)
local eid = ScriptLib.GetAvatarEntityIdByUid(context, uid)
local pos1 = ScriptLib.GetPosByEntityId(context, eid)
local pos2 = gadgets[config_id].pos
local X = pos1.x - pos2.x
local Y = pos1.y - pos2.y
local Z = pos1.z - pos2.z
return math.sqrt(X*X+Y*Y+Z*Z)
end
function LF_Battle_Start(context, evt)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : LF_Battle_Start")
ScriptLib.SetWeatherAreaState(context, 2021, 1)
local uid_list = ScriptLib.GetSceneUidList(context)
LF_Create_Boss(context)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, defs.gadget_operator, 201)
LF_Check_Avatar_Near_Boss(context)
--ScriptLib.RemoveExtraGroupSuite(context, 0, 7)
return 0
end
function LF_Battle_Win(context, evt)
ScriptLib.SetWeatherAreaState(context, 2021, 0)
LF_Clear_Battle_Arena(context)
ScriptLib.AddExtraGroupSuite(context, 0, 7)
ScriptLib.CreateScenePlayGeneralRewardGadget(context, {group_id = 133102112, config_id = defs.gadget_reward})
return 0
end
function LF_Battle_Lose(context, evt)
ScriptLib.SetWeatherAreaState(context, 2021, 0)
LF_Clear_Battle_Arena(context)
ScriptLib.AddExtraGroupSuite(context, 0, 7)
return 0
end
function LF_Manage_OceanId_Replacement(context, manage_type)
if manage_type == 1 then
for i,v in ipairs(relevant_group) do
ScriptLib.SetGroupVariableValueByGroup(context, "is_in_replacement", 1, v)
end
elseif manage_type == 0 then
for i,v in ipairs(relevant_group) do
ScriptLib.SetGroupVariableValueByGroup(context, "is_in_replacement", 0, v)
end
end
end
function LF_Clear_Battle_Arena(context)
ScriptLib.PrintContextLog(context, "##ACT_OCEANID_LOG : Clear_Battle_Arena")
ScriptLib.SetGroupTempValue(context, "is_in_battle", 0, {})
ScriptLib.SetGroupTempValue(context, "SummonStep", 0, {})
LF_Manage_OceanId_Replacement(context, 0)
ScriptLib.EndTimeAxis(context, "stage_1")
ScriptLib.EndTimeAxis(context, "summon_delay")
ScriptLib.EndTimeAxis(context, "summon")
ScriptLib.EndTimeAxis(context, "shuffle_loop")
ScriptLib.KillEntityByConfigId(context, { config_id = defs.monster_boss, entity_type=EntityType.MONSTER})
ScriptLib.SetGadgetEnableInteract(context, 133102112, defs.gadget_operator, true)
for i=2,12 do
ScriptLib.KillExtraGroupSuite(context, 0, i)
end
end
function LF_Create_Boss(context)
ScriptLib.RemoveExtraGroupSuite(context, 0, 12)
ScriptLib.CreateMonsterWithGlobalValue(context, defs.monster_boss, {["SGV_Oceanid_State"] = 1, ["SGV_Oceanid_HP"] = 100})
ScriptLib.InitTimeAxis(context, "stage_1", {120}, false)
ScriptLib.SetGroupTempValue(context, "Oceanid_State", 1, {})
ScriptLib.PrintContextLog(context, "## Oceanid_Log : init time axis 120")
end
function LF_Random_Attack_Platform(context)
math.randomseed(ScriptLib.GetServerTime(context))
local p={0,0,0}
local array = {1,2,3,4,5,6,7,8,9}
for j=1,3 do
local ran = math.random(#array)
for k,v in pairs(array) do
if ran == k then
p[j] = array[k]
table.remove(array, k)
break
end
end
end
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : p1 = "..p[1].." | p2 = "..p[2].." | p3 = "..p[3])
for i,v in ipairs(defs.gadget_operator_list) do
if i == p[1] or i == p[2] or i == p[3] then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 201)
else
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
--ScriptLib.SetGroupTempValue(context, "safe", v, {})
end
end
end
function LF_Summon_Action(context, idx)
--根据召唤的suite自行换算行为
ScriptLib.AddExtraGroupSuite(context, 0, idx)
ScriptLib.RemoveExtraGroupSuite(context, 0, idx+5)
local value = ScriptLib.GetGroupTempValue(context, "SummonStep", {})
value = value - value%math.pow(10,idx-1) + value%math.pow(10,idx-2) + math.pow(10,idx-2)
ScriptLib.SetGroupTempValue(context, "SummonStep", value, {})
if value ~= 1111 then
ScriptLib.InitTimeAxis(context, "summon", {defs.summon_interval}, true)
end
end
function LF_Check_Avatar_Near_Boss(context)
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
if 45 >= LF_Get_Distance(context, v, defs.gadget_operator) then
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.gadget_operator_list[1], v)
return 0
end
end
ScriptLib.FailScenePlayBattle(context, 133102112)
return -1
end
--[[
function LF_Summon_Crabs(context)
local position = {x=0,y=0,z=0}
local rotation = {x=0,y=0,z=0}
local ran = ScriptLib.GetGroupTempValue(context, "safe", {})
local X = gadgets[defs.gadget_operator_list[ran] ].pos.x
local Y = gadgets[defs.gadget_operator_list[ran] ].pos.y
local Z = gadgets[defs.gadget_operator_list[ran] ].pos.z
local born_radius = 5
math.randomseed(ScriptLib.GetServerTime(context))
for i,v in ipairs(suites[6].monsters) do
position.x = X + (2*math.random()-1)*born_radius
position.y = Y
position.z = Z + (2*math.random()-1)*born_radius
local x0 = X - position.x
local z0 = Z - position.z
if z0 == 0 then
z0 = 0.01
end
if z0 > 0 then
rotation.y = math.deg(math.atan(x0/z0))
else
rotation.y = math.deg(math.atan(x0/z0)) + 180
end
ScriptLib.CreateMonsterByConfigIdByPos(context, config_id, position, rotation)
end
end
--]]
---------------------------------------
function SLC_Stage_To_2(context)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : SLC_Stage_To_2")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.monster_boss, "SGV_Oceanid_State", 2)
ScriptLib.SetGroupTempValue(context, "Oceanid_State", 2, {})
ScriptLib.EndTimeAxis(context, "stage_1")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.monster_boss, "SGV_Oceanid_HP", 80)
ScriptLib.SetGroupTempValue(context, "Oceanid_HP", 80, {})
ScriptLib.SetGroupTempValue(context, "SummonStep", 0, {})
ScriptLib.InitTimeAxis(context, "summon_delay", {10}, false)
ScriptLib.SetGroupTempValue(context, "summon_lock", 0, {})
return 0
end
function SLC_Summon_Start(context)
if 1 ~= ScriptLib.GetGroupTempValue(context, "summon_lock", {}) then
ScriptLib.SetGroupTempValue(context, "summon_lock", 1, {})
else
return -1
end
ScriptLib.EndTimeAxis(context, "summon_delay")
ScriptLib.InitTimeAxis(context, "summon", {defs.summon_interval}, true)
--0001b为第一只怪的标识
ScriptLib.AddExtraGroupSuite(context, 0, 2)
ScriptLib.AddExtraGroupSuite(context, 0, 8)
ScriptLib.AddExtraGroupSuite(context, 0, 9)
ScriptLib.AddExtraGroupSuite(context, 0, 10)
ScriptLib.AddExtraGroupSuite(context, 0, 11)
ScriptLib.SetGroupTempValue(context, "SummonStep", 1, {})
return 0
end
function SLC_Platform_Shuffle(context)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : SLC_Shuffle")
--LF_Summon_Crabs(context)
LF_Random_Attack_Platform(context)
return 0
end
function SLC_Boss_Escape(context)
ScriptLib.FailScenePlayBattle(context, 133102112)
return 0
end
---------------------------------------
Initialize()
---------------------------------------
--uidValue判定区
--下落攻击命中螃蟹的次数
function SLC_FallingAttack_Crab(context)
local cnt = ScriptLib.GetScenePlayBattleUidValue(context, 133102112, context.uid, "ACT_OCEANID_FallingAttack_Crab")
ScriptLib.SetScenePlayBattleUidValue(context, 133102112, context.uid, "ACT_OCEANID_FallingAttack_Crab", cnt+1)
return 0
end
--上电梯的次数
function SLC_Use_Lift(context)
local cnt = ScriptLib.GetScenePlayBattleUidValue(context, 133102112, context.uid, "ACT_OCEANID_Use_Lift")
ScriptLib.SetScenePlayBattleUidValue(context, 133102112, context.uid, "ACT_OCEANID_Use_Lift", cnt+1)
return 0
end
--承受boss大招次数
function SLC_Endure_Boss_EX_Skill(context)
local cnt = ScriptLib.GetScenePlayBattleUidValue(context, 133102112, context.uid, "ACT_OCEANID_Endure_Boss_EX_Skill")
ScriptLib.SetScenePlayBattleUidValue(context, 133102112, context.uid, "ACT_OCEANID_Endure_Boss_EX_Skill", cnt+1)
return 0
end
--提前踩出小怪次数
function LF_Summon_In_Advance(context)
local cnt = ScriptLib.GetScenePlayBattleUidValue(context, 133102112, context.uid, "ACT_OCEANID_Summon_In_Advance")
ScriptLib.SetScenePlayBattleUidValue(context, 133102112, context.uid, "ACT_OCEANID_Summon_In_Advance", cnt+1)
if 1 == ScriptLib.GetScenePlayBattleUidValue(context, 0, context.uid, "ACT_OCEANID_Summon_In_Advance") then
ScriptLib.MarkPlayerAction(context, 20050102, 1, 1)
end
end
@@ -0,0 +1,72 @@
local gadget_list = {70350099,70350100,70350101,70350102,70350103,70350108,70350111}
local var = {
[1] = {config_id=50000001,name="SGV_TDLevel",value=1,no_refresh=true},
[2] = {config_id=54000002,name="SGV_TDCanDoAttack",value=1,no_refresh=true},
[3] = {config_id=54000003,name="SGV_TDUpGrade_Special",value=0,no_refresh=true},
[4] = {config_id=54000004,name="SGV_TDAttackDamage_A",value=0,no_refresh=true},
[5] = {config_id=54000005,name="SGV_TDAttackSpeed_A",value=0,no_refresh=true},
[6] = {config_id=54000006,name="SGV_TDAttackRange_A",value=0,no_refresh=true},
[7] = {config_id=54000007,name="SGV_TDAttackDamage_B",value=0,no_refresh=true},
[8] = {config_id=54000008,name="SGV_TDAttackSpeed_B",value=0,no_refresh=true},
[9] = {config_id=54000009,name="SGV_TDAttackRange_B",value=0,no_refresh=true},
[10]= {config_id=54000010,name="SGV_TDAttackSpeed_C",value=0,no_refresh=true},
[11]= {config_id=54000011,name="SGV_TDAttackMastery",value=0,no_refresh=true}
}
local tri = {
[1] = {config_id=10000, name="group_load", event=EventType.EVENT_GROUP_LOAD, source="", condition="", action="action_group_load", trigger_count=0},
[2] = {config_id=10001, name="group_refresh", event=EventType.EVENT_GROUP_REFRESH, source="", condition="", action="action_group_load", trigger_count=0},
[3] = {config_id=10002, name="variable_change", event=EventType.EVENT_VARIABLE_CHANGE, source="", condition="", action="action_variable_change", trigger_count=0}
}
function Initialize()
for i,v in ipairs(points) do
if i > #gadget_list then
break
end
if points[i] == nil then
break
end
temp_gadget = {config_id = 8000+i, gadget_id = gadget_list[i], pos = points[i].pos, rot = points[i].rot, level = 1}
table.insert(gadgets, temp_gadget)
--table.insert(suites[1].gadgets, temp_gadget.config_id)
end
------------
for i,v in ipairs(var) do
table.insert(variables, v)
end
-------------
for i,v in ipairs(tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
function action_group_load(context, evt)
ScriptLib.PrintLog("--------------- v4 -----------------")
local SGV_table = {}
for i,v in ipairs(var) do
local str = v.name
SGV_table[str] = v.value
end
for k,v in pairs(SGV_table) do
ScriptLib.PrintContextLog(context, "k="..k.." | v="..v)
end
for i,v in ipairs(gadget_list) do
ScriptLib.CreateGadgetWithGlobalValue(context, 8000+i, SGV_table)
end
return 0
end
function action_variable_change(context, evt)
--local value = ScriptLib.GetGroupVariableValue(context, evt.source_name)
for i,v in ipairs(gadget_list) do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, 8000+i, evt.source_name, evt.param1)
end
return 0
end
Initialize()
@@ -0,0 +1,118 @@
local extrTriggers = {
initialtrigger = {
["Challenge_Fail"] = { config_id = 8000001, name = "Challenge_Fail", event= EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0 },
["ALL_PLAYER_DIE"] = { config_id = 8000005, name = "ALL_PLAYER_DIE", event= EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_all_avatar_die", trigger_count = 0 },
["Group_Load"] = { config_id = 8000006, name = "Group_Load", event= EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
}
}
function action_group_load( context, evt )
ScriptLib.SetGroupTempValue(context, "WarmFloor", 0, {})
return 0
end
--去重随机
function RandomArea(context, mode)
math.randomseed(ScriptLib.GetServerTime(context))
--根据模式不同随机一套冷板、暖板数量
local randomCold = 0
local randomWarm = 0
if mode == 0 then
randomCold = math.random(2,3)
randomWarm = 1
end
if mode == 1 then
randomCold = math.random(2,3)
randomWarm = math.random(0,1)
end
if randomWarm == 0 then
ScriptLib.ChangeGroupTempValue(context, "WarmFloor", 1, {})
ScriptLib.PrintContextLog(context, "## SN_LOG : WarmFloor == "..ScriptLib.GetGroupTempValue(context, "WarmFloor", {}))
elseif randomWarm == 1 then
ScriptLib.SetGroupTempValue(context, "WarmFloor", 0, {})
ScriptLib.PrintContextLog(context, "## SN_LOG : WarmFloor == "..ScriptLib.GetGroupTempValue(context, "WarmFloor", {}))
end
if ScriptLib.GetGroupTempValue(context, "WarmFloor", {}) == 3 then
ScriptLib.PrintContextLog(context, "## SN_LOG : BAODI !")
randomWarm =1
ScriptLib.SetGroupTempValue(context, "WarmFloor", 0, {})
end
local PlatformTable = {11003,11004,11005,11006,11007,11008,11009,11010,11011}
local randomIdx= 0
--初始化所有场
for i=1,9 do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, PlatformTable[i], 0)
end
--抽取3个冰场
for i=0,randomCold do
randomIdx = math.random(9-i)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, PlatformTable[randomIdx], 202)
--使用后移除该字段
table.remove(PlatformTable, randomIdx)
end
--抽取0-1个暖场
if randomWarm == 1 then
randomIdx = math.random(8-randomCold)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, PlatformTable[randomIdx], 201)
end
return 0
end
function action_challenge_fail( context,evt )
local PlatformTable = {11003,11004,11005,11006,11007,11008,11009,11010,11011}
for i,v in ipairs(PlatformTable) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
end
ScriptLib.CancelGroupTimerEvent(context, GroupID, "Snow_Timer")
return 0
end
function action_all_avatar_die( context,evt )
local PlatformTable = {11003,11004,11005,11006,11007,11008,11009,11010,11011}
-- 所有角色死亡
local UidList = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(UidList) do
if ScriptLib.IsPlayerAllAvatarDie(context, v) == false then
return 0
end
end
for i,v in ipairs(PlatformTable) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
end
ScriptLib.CancelGroupTimerEvent(context, GroupID, "Snow_Timer")
return 0
end
function LF_Initialize_Group()
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Group()
@@ -0,0 +1,40 @@
--此方法在两个region坐标接近时调用比较合适
function TrySetPlayerEyePoint(context, small_region, big_region, opt_type, vision_type_list)
--opt_type为1表示需要setVisionType
local eid = ScriptLib.GetAvatarEntityIdByUid(context, context.uid)
local player_pos = ScriptLib.GetPosByEntityId(context, eid)
local small_pos = small_region.pos
local big_pos = big_region.pos
--在小圈内要处理入圈
if Is_In_Region(player_pos, small_region) == true then
ScriptLib.SetPlayerEyePoint(context, small_region.config_id,big_region.config_id)
if opt_type == 1 then
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, vision_type_list)
end
--在大圈外要处理出圈
elseif Is_In_Region(player_pos, big_region) == false then
ScriptLib.ClearPlayerEyePoint(context, small_region.config_id)
if opt_type == 1 then
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
end
end
end
function Is_In_Region(pos1, region)
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
@@ -0,0 +1,537 @@
--[[
tide_group_defs ={
[1] = {group = 250030010, delay = 60, next_group = 2, buff = {1,2,3},enter={},exit={},enter_id={},exit_id={}},
[2] = {group = 250030010, delay = 60, next_group = 3, buff = {1,2,3}},
[3] = {group = 250030010, delay = 60, next_group = 4, buff = {1,2,3}},
[4] = {group = 250030010, delay = 60, next_group = 5, buff = {1,2,3}},
[5] = {group = 250030010, delay = 60, next_group = 0, buff = {1,2,3}},
}
enter_pool={}
exit_pool={}
--]]
function LF_Init_Challenge_Group()
--g1 = { config_id = 1, gadget_id = 70360002, pos = points[1].pos, rot = points[1].rot, level = 1 }
--table.insert(gadgets, g1)
--table.insert(suites[1].gadgets, g1.config_id)
--创建路径指引
--guide_point_pool={}
--for i=1,100 do
--table.insert(gadgets, { config_id = 10000+i, gadget_id = 70350159, pos = { x = 63.257, y = 14.676, z = -27.624 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1, is_use_point_array = true })
--table.insert{guide_point_pool,10000+i}
--end
t1 = { config_id = 8000001, name = "gadget_create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 }
t2 = { config_id = 8000002, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 }
t3 = { config_id = 8000003, name = "challenge_success", event = EventType.EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END, source = "", condition = "", action = "action_EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END", trigger_count = 0}
t4 = { config_id = 8000004, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 }
t5 = { config_id = 8000005, name = "timer_event", event = EventType.EVENT_TIMER_EVENT, source = "route_points_delay", condition = "", action = "action_add_route_points", trigger_count = 0}
t6 = { config_id = 8000006, name = "point_arrive", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_REACH_POINT", trigger_count = 0 }
t7 = { config_id = 8000007, name = "end_stage_request", event = EventType.EVENT_SCENE_MULTISTAGE_PLAY_END_STAGE_REQ, source = "", condition = "", action = "action_END_STAGE", trigger_count = 0 }
t8 = { config_id = 8000008, name = "pick_card_event", event = EventType.EVENT_MECHANICUS_PICKED_CARD, source = "", condition = "", action = "action_PICK_CARD", trigger_count = 0 }
t9 = { config_id = 8000009,name = "TIMER_EVENT_DELAY", event = EventType.EVENT_TIMER_EVENT, source = "delay", condition = "", action = "action_END_DELAY", trigger_count = 0 }
t10 = { config_id = 8000010,name = "TIMER_EVENT_START_REMINDER", event = EventType.EVENT_TIMER_EVENT, source = "reminder", condition = "", action = "action_START_REMINDER", trigger_count = 0 }
t11 = { config_id = 8000011,name = "ALL_AVATAR_DIE", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_ALL_AVATAR_DIE", trigger_count = 0 }
for i,v in ipairs(suites) do
table.insert(v.triggers, t1.name)
table.insert(v.triggers, t2.name)
table.insert(v.triggers, t3.name)
table.insert(v.triggers, t4.name)
table.insert(v.triggers, t5.name)
table.insert(v.triggers, t6.name)
table.insert(v.triggers, t7.name)
table.insert(v.triggers, t8.name)
table.insert(v.triggers, t9.name)
table.insert(v.triggers, t10.name)
table.insert(v.triggers, t11.name)
end
table.insert(triggers, t1)
table.insert(triggers, t2)
table.insert(triggers, t3)
table.insert(triggers, t4)
table.insert(triggers, t5)
table.insert(triggers, t6)
table.insert(triggers, t7)
table.insert(triggers, t8)
table.insert(triggers, t9)
table.insert(triggers, t10)
table.insert(triggers, t11)
table.insert(variables, { config_id=50000001,name = "wave_ptr", value = 0})
table.insert(variables, { config_id=50000002,name = "special_challenge", value = 0})
table.insert(variables, { config_id=50000003,name = "left_monsters", value = 0})
table.insert(variables, { config_id=50000004,name = "max_escapable_monsters", value = 10})
table.insert(variables, { config_id=50000005,name = "escaped_monsters", value = 0})
table.insert(variables, { config_id=50000006,name = "route_guide_points_index", value = 1,no_refresh = true})
--怪物对地脉镇石造成额外伤害
table.insert(variables, { config_id=50000007,name = "monster_double_damage", value = 0})
--挑战逃出的怪物不超过一个
table.insert(variables, { config_id=50000008,name = "challenge_8", value = 0})
table.insert(variables, { config_id=50000009,name = "challenge_10", value = 0})
table.insert(variables, { config_id=50000010,name = "challenge_11", value = 0})
table.insert(variables, { config_id=50000011,name = "GM_Ignore_Monster_Escape", value = 0})
table.insert(variables, { config_id=50000012,name = "challenge_65", value = 0})
table.insert(variables, { config_id=50000013,name = "challenge_66", value = 0})
table.insert(variables, { config_id=50000014,name = "challenge_67", value = 0})
table.insert(variables, { config_id=50000015,name = "challenge_68", value = 0})
table.insert(variables, { config_id=50000016,name = "challenge_69", value = 0})
table.insert(variables, { config_id=50000017,name = "challenge_70", value = 0})
table.insert(variables, { config_id=50000018,name = "challenge_71", value = 0})
table.insert(variables, { config_id=50000019,name = "challenge_72", value = 0})
table.insert(variables, { config_id=50000020,name = "challenge_73", value = 0})
table.insert(variables, { config_id=50000021,name = "challenge_74", value = 0})
table.insert(variables, { config_id=50000022,name = "challenge_75", value = 0})
table.insert(variables, { config_id=50000023,name = "challenge_76", value = 0})
end
--------------------------------------
function action_ALL_AVATAR_DIE(context, evt)
local uidList=ScriptLib.GetSceneUidList(context)
local count=0
for i=1,#uidList do
if ScriptLib.IsPlayerAllAvatarDie(context, uidList[i]) then
count=count+1
end
end
if count >= (#uidList) then
ScriptLib.EndSceneMultiStagePlay(context, 999, false)
return 0
end
return 0
end
function action_END_STAGE(context, evt)
if evt.param2==Multistage.MechanicusBuild then
ScriptLib.EndSceneMultiStagePlayStage(context, 999,"build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"), true)
end
return 0
end
--翻牌子
function action_PICK_CARD(context, evt)
--诅咒效果
--逃脱的魔物不能超过一个
if evt.param2==83 then
ScriptLib.SetGroupVariableValue(context, "challenge_8", evt.param3)
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 83, MechanicusChallenge.OnGoing)
end
--角色无法进行攻击,持续1轮
if evt.param2==85 then
ScriptLib.SetGroupVariableValue(context, "challenge_10", evt.param3)
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 85, MechanicusChallenge.OnGoing)
--ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.attack_forbid_gadget, GadgetState.GearStart)
--ScriptLib.SetIsAllowUseSkill(context, 0)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "can_use_skill", 0, true)
end
--角色的移动速度降低,持续1轮
if evt.param2==86 then
ScriptLib.SetGroupVariableValue(context, "challenge_11", evt.param3)
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 86, MechanicusChallenge.OnGoing)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.speed_down_gadget, GadgetState.GearStart)
end
--牌子效果
--配置功能冷却降低
if evt.param3==33 then
if trap_group~=nil then
for i=1,#trap_group do
ScriptLib.ExecuteGroupLua(context, trap_group[i], "SetColdTownDiscount", {0})
end
end
return 0
end
--配置机关所需奇术点降低
if evt.param3==34 then
if trap_group~=nil then
for i=1,#trap_group do
ScriptLib.ExecuteGroupLua(context, trap_group[i], "SetDiscount", {0})
end
end
--ScriptLib.ExecuteGroupLua(context, defs.trap_group_id, "SetDiscount", {0})
return 0
end
--立即获得250点奇术点
if evt.param3==44 then
--ScriptLib.AddMechanicusBuildingPoints(context,defs.group_id ,999, evt.uid, 50)
return 0
end
--立即回复地脉镇石5点耐久度
if evt.param3==45 then
local hp=ScriptLib.GetGroupVariableValue(context, "escaped_monsters")
hp=hp-5
if hp<0 then
hp=0
end
ScriptLib.SetGroupVariableValue(context, "escaped_monsters", hp)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "escaped_monsters",hp, true)
return 0
end
--额外出现一架遗迹守卫
if evt.param3==65 then
ScriptLib.SetGroupVariableValue(context, "challenge_65", 1)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "extra_monster_65", {defs.group_id})
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 65, MechanicusChallenge.OnGoing)
return 0
end
--额外出现一架遗迹猎者
if evt.param3==66 then
ScriptLib.SetGroupVariableValue(context, "challenge_66", 1)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "extra_monster_66", {defs.group_id})
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 66, MechanicusChallenge.OnGoing)
return 0
end
--额外出现一架遗迹重机
if evt.param3==67 then
ScriptLib.SetGroupVariableValue(context, "challenge_67", 1)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "extra_monster_67", {defs.group_id})
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 67, MechanicusChallenge.OnGoing)
return 0
end
--额外出现丘丘岩盔王
if evt.param3==68 then
ScriptLib.SetGroupVariableValue(context, "challenge_68", 1)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "extra_monster_68", {defs.group_id})
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 68, MechanicusChallenge.OnGoing)
return 0
end
--额外出现丘丘霜盔王
if evt.param3==69 then
ScriptLib.SetGroupVariableValue(context, "challenge_69", 1)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "extra_monster_69", {defs.group_id})
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 69, MechanicusChallenge.OnGoing)
return 0
end
--额外出现奔跑的丘丘暴徒
if evt.param3==70 then
ScriptLib.SetGroupVariableValue(context, "challenge_70", 1)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "extra_monster_70", {defs.group_id})
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 70, MechanicusChallenge.OnGoing)
return 0
end
--魔物对地脉镇石造成额外1点伤害
if evt.param3==71 then
ScriptLib.SetGroupVariableValue(context, "challenge_71", 1)
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 71, MechanicusChallenge.OnGoing)
ScriptLib.SetGroupVariableValue(context, "monster_double_damage", 1)
return 0
end
--所有魔物血量提升xxx
if evt.param3==72 then
ScriptLib.SetGroupVariableValue(context, "challenge_72", 1)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "buff_monster_4112", {defs.group_id})
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 72, MechanicusChallenge.OnGoing)
return 0
end
--所有魔物防御提升xxx
if evt.param3==73 then
ScriptLib.SetGroupVariableValue(context, "challenge_73", 1)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "buff_monster_4113", {defs.group_id})
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 73, MechanicusChallenge.OnGoing)
return 0
end
--击败魔物分降低
if evt.param3==74 then
ScriptLib.SetGroupVariableValue(context, "challenge_74", 1)
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 74, MechanicusChallenge.OnGoing)
return 0
end
--建造机关分变高
if evt.param3==75 then
ScriptLib.SetGroupVariableValue(context, "challenge_75", 1)
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, evt.param3, 75, MechanicusChallenge.OnGoing)
return 0
end
return 0
end
function Reset_Cards_Effect(context)
--local challenge_83=ScriptLib.GetGroupVariableValue(context, "challenge_8")
local challenge_85=ScriptLib.GetGroupVariableValue(context, "challenge_10")
local challenge_86=ScriptLib.GetGroupVariableValue(context, "challenge_11")
--if challenge_83~=0 then
--ScriptLib.PrintContextLog(context, "## TD_LOG : CHALLENGE 83 CARD ID"..challenge_83)
--ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, challenge_83, 83,MechanicusChallenge.Success)
--end
if challenge_85~=0 then
ScriptLib.PrintContextLog(context, "## TD_LOG : CHALLENGE 85 CARD ID"..challenge_85)
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, challenge_85, 85,MechanicusChallenge.Success)
--ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.attack_forbid_gadget, GadgetState.Default)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "can_use_skill", 1, true)
--ScriptLib.SetIsAllowUseSkill(context, 1)
end
if challenge_86~=0 then
ScriptLib.PrintContextLog(context, "## TD_LOG : CHALLENGE 86 CARD ID"..challenge_86)
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, challenge_86, 86,MechanicusChallenge.Success)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.speed_down_gadget, GadgetState.GearStop)
end
--ScriptLib.SetGroupVariableValue(context, "challenge_8", 0)
ScriptLib.SetGroupVariableValue(context, "challenge_10", 0)
ScriptLib.SetGroupVariableValue(context, "challenge_11", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_65")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 65, 65,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_65", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_66")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 66, 66,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_66", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_67")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 67, 67,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_67", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_68")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 68, 68,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_68", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_69")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 69, 69,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_69", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_70")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 70, 70,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_70", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_71")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 71, 71,MechanicusChallenge.Success)
ScriptLib.SetGroupVariableValue(context, "monster_double_damage", 0)
end
ScriptLib.SetGroupVariableValue(context, "challenge_71", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_72")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 72, 72,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_72", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_73")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 73, 73,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_73", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_74")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 74, 74,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_74", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_75")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 75, 75,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_75", 0)
return 0
end
function CreateDoors(context,wave)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "clear_all_points",1, true)
if wave>1 then
ScriptLib.KillGroupEntity(context,{group_id=defs.group_id,gadgets=tide_group_defs[wave-1].enter})
ScriptLib.KillGroupEntity(context,{group_id=defs.group_id,gadgets=tide_group_defs[wave-1].exit})
end
for i=1,#tide_group_defs[wave].enter do
ScriptLib.CreateGadget(context, { config_id =tide_group_defs[wave].enter[i] })
end
for i=1,#tide_group_defs[wave].exit do
ScriptLib.CreateGadget(context, { config_id =tide_group_defs[wave].exit[i] })
end
for i=1,#tide_group_defs[wave].enter_id do
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "add_entrance_point",tide_group_defs[wave].enter_id[i], true)
end
for i=1,#tide_group_defs[wave].exit_id do
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "add_exit_point",tide_group_defs[wave].exit_id[i], true)
end
return 0
end
function action_group_load(context, evt)
if defs.max_escapable_monsters~= nil then
ScriptLib.SetGroupVariableValue(context, "max_escapable_monsters", defs.max_escapable_monsters)
end
ScriptLib.InitSceneMultistagePlay(context, 999, MultistagePlayType.Mechanicus, {rounds = #tide_group_defs, init_building_points = defs.init_building_points or 200},ScriptLib.GetSceneUidList(context))
CreateDoors(context,1)
ScriptLib.SetGroupVariableValue(context, "wave_ptr", 1)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "set_monster_number_req", {defs.group_id})
ScriptLib.ExecuteGroupLua(context, tide_group_defs[1].group, "set_monster_preview", {defs.group_id})
ScriptLib.SetSceneMultiStagePlayValues(context, 999, {round=ScriptLib.GetGroupVariableValue(context, "wave_ptr"),rounds=#tide_group_defs,left_monsters=ScriptLib.GetGroupVariableValue(context, "left_monsters"),max_escapable_monsters=ScriptLib.GetGroupVariableValue(context, "max_escapable_monsters"),escaped_monsters=ScriptLib.GetGroupVariableValue(context, "escaped_monsters"),stage_bonus_building_points=0}, true)
ScriptLib.StartSceneMultiStagePlayStage(context, 999, defs.build_time or 78, Multistage.MechanicusBuild,"build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
ScriptLib.ExecuteGroupLua(context, defs.gear_group_id, "Initialize_Fundations", {0})
add_route_guide_points(context)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "reminder",5)
return 0
end
function action_START_REMINDER(context, evt)
ScriptLib.ShowReminder(context, 400025)
return 0
end
function action_add_route_points(context, evt)
add_route_guide_points(context)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "route_points_delay", defs.route_guide_timer)
return 0
end
function add_route_guide_points(context)
local curwave=ScriptLib.GetGroupVariableValue(context, "wave_ptr")
if tide_group_defs[curwave].guide_routes ==nil then
ScriptLib.PrintContextLog(context, "## TD_LOG : Guide Routes Is Nil")
return 0
end
for i=1,#tide_group_defs[curwave].guide_routes do
--tide_group_defs[curwave].guide_routes[i]
local idx=ScriptLib.GetGroupVariableValue(context, "route_guide_points_index")
if -2==ScriptLib.CreateGadgetByConfigIdByPos(context, guide_point_pool[idx], routes_start_point[tide_group_defs[curwave].guide_routes[i]].start_point, { x = 0.000, y = 0.000, z = 0.000 }) then
ScriptLib.PrintContextLog(context, "## TD_LOG : Guide Points Not Enough")
return 0
end
ScriptLib.SetPlatformPointArray(context, guide_point_pool[idx], tide_group_defs[curwave].guide_routes[i],routes_start_point[tide_group_defs[curwave].guide_routes[i]].points, { route_type = 0 })
if idx >= #guide_point_pool then
idx=1
else
idx=idx+1
end
ScriptLib.SetGroupVariableValue(context, "route_guide_points_index", idx)
end
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "route_points_delay", defs.route_guide_timer)
return 0
end
function stop_route_guide_points(context)
ScriptLib.CancelGroupTimerEvent(context, defs.group_id, "route_points_delay")
ScriptLib.KillGroupEntity(context,{group_id=defs.group_id,gadgets=guide_point_pool})
return 0
end
function action_REACH_POINT(context,evt)
--ScriptLib.KillEntityByConfigId(context, { config_id = evt.param1 })
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, evt.param1, GadgetState.GearStart)
return 0
end
function action_gadget_create(context, evt)
if evt.param1 == 1 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, evt.param1, {2902})
end
return 0
end
function action_select_option(context, evt)
if evt.param1 == 1 and evt.param2 == 2902 then
--ScriptLib.ExecuteGroupLua(context, tide_group_defs[1].group, "start_tide", {defs.group_id})
ScriptLib.InitSceneMultistagePlay(context, 999, MultistagePlayType.Mechanicus, {rounds = #tide_defs, init_building_points = defs.init_building_points or 2000},ScriptLib.GetSceneUidList(context))
ScriptLib.StartSceneMultiStagePlayStage(context, 999, 30, Multistage.MechanicusBuild,"test",{})
ScriptLib.SetGroupVariableValue(context, "wave_ptr", 1)
ScriptLib.DelWorktopOption(context, evt.param2)
end
return 0
end
function del_monster_number(context, prev_context, param1, param2, param3)
local new_num=ScriptLib.GetGroupVariableValue(context, "left_monsters")
if new_num==0 then
return 0
end
new_num=new_num-1
ScriptLib.SetGroupVariableValue(context, "left_monsters", new_num)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "left_monsters",new_num, true)
return 0
end
function set_monster_number(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "left_monsters", param1)
return 0
end
--某group结束,进下一阶段
function tide_done(context, prev_context, param1, param2, param3)
ScriptLib.EndSceneMultiStagePlayStage(context, 999,"battle"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"), true)
local wave = ScriptLib.GetGroupVariableValue(context, "wave_ptr")
wave=wave+1
ScriptLib.SetGroupVariableValue(context, "wave_ptr", wave)
ScriptLib.PrintContextLog(context, "## wave = "..wave)
if wave > #tide_group_defs then
if ScriptLib.GetGroupVariableValue(context, "challenge_71")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 71, 71,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_71", 0)
if ScriptLib.GetGroupVariableValue(context, "challenge_75")~=0 then
ScriptLib.SetMechanicusChallengeState(context,defs.group_id, 999, 75, 75,MechanicusChallenge.Success)
end
ScriptLib.SetGroupVariableValue(context, "challenge_75", 0)
ScriptLib.EndSceneMultiStagePlay(context, 999, true)
ScriptLib.PrintContextLog(context, "## TD_LOG : All Wave Done")
--ScriptLib.CauseDungeonFail(context)
return 0
end
ScriptLib.ExecuteGroupLua(context, tide_group_defs[wave].group, "set_monster_preview", {defs.group_id})
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "delay", 3)
Reset_Cards_Effect(context)
--ScriptLib.StartSceneMultiStagePlayStage(context, 999, 30, Multistage.MechanicusFlipCard,"card"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
return 0
end
function action_END_DELAY(context, evt)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "building_stage_seconds",defs.build_time or 78, true)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "round",ScriptLib.GetGroupVariableValue(context, "wave_ptr"), true)
ScriptLib.StartSceneMultiStagePlayStage(context, 999, 30, Multistage.MechanicusFlipCard,"card"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
CreateDoors(context,ScriptLib.GetGroupVariableValue(context, "wave_ptr"))
return 0
end
--怪物到达终点,涨分
function monster_escaped(context, prev_context, param1, param2, param3)
if ScriptLib.GetGroupVariableValue(context, "GM_Ignore_Monster_Escape") ~=0 then
return 0
end
local max_escapable_monsters=ScriptLib.GetGroupVariableValue(context, "max_escapable_monsters")
local escaped_monsters=ScriptLib.GetGroupVariableValue(context, "escaped_monsters")
if ScriptLib.GetGroupVariableValue(context, "monster_double_damage") ==0 then
escaped_monsters=escaped_monsters+1
elseif ScriptLib.GetGroupVariableValue(context, "monster_double_damage") ==1 then
escaped_monsters=escaped_monsters+2
end
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "escaped_monsters",escaped_monsters, true)
if ScriptLib.GetGroupVariableValue(context, "challenge_8") ~=0 then
ScriptLib.EndSceneMultiStagePlay(context, 999, false)
--ScriptLib.CauseDungeonFail(context)
return 0
end
if escaped_monsters>=max_escapable_monsters then
ScriptLib.EndSceneMultiStagePlay(context, 999, false)
--ScriptLib.CauseDungeonFail(context)
return 0
end
ScriptLib.SetGroupVariableValue(context, "escaped_monsters", escaped_monsters)
return 0
end
function action_EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END(context, evt)
if evt.param2==Multistage.MechanicusBuild then
stop_route_guide_points(context)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "start_tide", {defs.group_id})
--ScriptLib.SetSceneMultiStagePlayValues(context, 999, {round=ScriptLib.GetGroupVariableValue(context, "wave_ptr"),rounds=#tide_group_defs,left_monsters=ScriptLib.GetGroupVariableValue(context, "left_monsters"),max_escapable_monsters=ScriptLib.GetGroupVariableValue(context, "max_escapable_monsters"),escaped_monsters=ScriptLib.GetGroupVariableValue(context, "escaped_monsters"),stage_bonus_building_points=0}, true)
ScriptLib.StartSceneMultiStagePlayStage(context, 999, 0, Multistage.MechanicusKill,"battle"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
end
if evt.param2==Multistage.MechanicusFlipCard then
add_route_guide_points(context)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group, "set_monster_number_req", {defs.group_id})
ScriptLib.SetSceneMultiStagePlayValues(context, 999, {round=ScriptLib.GetGroupVariableValue(context, "wave_ptr"),rounds=#tide_group_defs,left_monsters=ScriptLib.GetGroupVariableValue(context, "left_monsters"),max_escapable_monsters=ScriptLib.GetGroupVariableValue(context, "max_escapable_monsters"),escaped_monsters=ScriptLib.GetGroupVariableValue(context, "escaped_monsters"),stage_bonus_building_points=0}, true)
ScriptLib.StartSceneMultiStagePlayStage(context, 999, defs.build_time or 78, Multistage.MechanicusBuild,"build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
end
return 0
end
--tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group
LF_Init_Challenge_Group()
@@ -0,0 +1,115 @@
--[[
setmetatable(_ENV,{__index=function() return {} end })
--]]
local define = {
group_id = defs.group_id or 250030001,
gear_list = --[[defs.gear_list or]] {70350107,70350099,70350100,70350101,70350102,70350103,70350129,70350111,70350108},
option_list = --[[defs.option_list or]] {41,42,43,44,45,48,49,50,46},
option_revert = 46,
option_points = --[[defs.option_points or]] {20,20,20,20,20,20,20,20,20},
monster_points = defs.monster_points or 10,
max_points = defs.max_points or 100
}
local extraTriggers={
{ config_id = 8000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0},
{ config_id = 8000002, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_GADGET_CREATE", trigger_count = 0},
{ config_id = 8000003, name = "GADGET_DIE", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_GADGET_DIE", trigger_count = 0},
{ config_id = 8000004, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0,forbid_guest = false },
{ config_id = 8000005,name = "TIMER_EVENT_CD", event = EventType.EVENT_TIMER_EVENT, source = "cd", condition = "", action = "action_USE_CD", trigger_count = 0 }
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables, { config_id=50000001,name = "gateway_one", value = 0})
table.insert(variables, { config_id=50000002,name = "gateway_two", value = 0})
table.insert(variables, { config_id=50000003, name = "use_cd", value = 0})
end
function action_USE_CD(context, evt)
ScriptLib.SetGroupVariableValue(context, "use_cd", 0)
return 0
end
function action_GADGET_CREATE(context, evt)
if evt.param2 == 70330045 then
if ScriptLib.GetGroupVariableValue(context, "gateway_one")==0 then
ScriptLib.SetGroupVariableValue(context, "gateway_one", evt.param1)
ScriptLib.SetWorktopOptionsByGroupId(context, 0, evt.param1, {4005})
return 0
elseif ScriptLib.GetGroupVariableValue(context, "gateway_two")==0 then
ScriptLib.SetGroupVariableValue(context, "gateway_two", evt.param1)
ScriptLib.SetWorktopOptionsByGroupId(context, 0, evt.param1, {4005})
return 0
end
end
return 0
end
function action_EVENT_SELECT_OPTION(context, evt)
if ScriptLib.GetGroupVariableValue(context, "use_cd")==1 then
ScriptLib.ShowReminder(context, 400027)
return 0
end
if evt.param1==ScriptLib.GetGroupVariableValue(context, "gateway_one") then
if (ScriptLib.GetGroupVariableValue(context, "gateway_one")==0) or (ScriptLib.GetGroupVariableValue(context, "gateway_two")==0) then
return 0
end
for i=1,#points do
if points[i].config_id==ScriptLib.GetGroupVariableValue(context, "gateway_two") then
ScriptLib.TransPlayerToPos(context, {uid_list ={context.uid}, pos = points[i].pos, radius = 2, rot = points[i].rot,is_skip_ui=false})
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, evt.param1, GadgetState.GearStart)
ScriptLib.SetGroupVariableValue(context, "use_cd", 1)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "cd", 5)
return 0
end
end
elseif evt.param1==ScriptLib.GetGroupVariableValue(context, "gateway_two") then
if (ScriptLib.GetGroupVariableValue(context, "gateway_one")==0) or (ScriptLib.GetGroupVariableValue(context, "gateway_two")==0) then
return 0
end
for i=1,#points do
if points[i].config_id==ScriptLib.GetGroupVariableValue(context, "gateway_one") then
ScriptLib.TransPlayerToPos(context, {uid_list ={context.uid}, pos = points[i].pos, radius = 2, rot = points[i].rot,is_skip_ui=false})
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, evt.param1, GadgetState.GearStart)
ScriptLib.SetGroupVariableValue(context, "use_cd", 1)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "cd", 5)
return 0
end
end
end
return 0
end
function action_GADGET_DIE(context, evt)
if evt.param1==ScriptLib.GetGroupVariableValue(context, "gateway_one") then
ScriptLib.SetGroupVariableValue(context, "gateway_one", 0)
return 0
elseif evt.param1==ScriptLib.GetGroupVariableValue(context, "gateway_two") then
ScriptLib.SetGroupVariableValue(context, "gateway_two", 0)
return 0
end
return 0
end
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "## ================ INITIALIZE FUNDATIONS ==============")
--Initialize_Fundations(context, evt)
return 0
end
function Initialize_Fundations(context, prev_context, param1, param2, param3)
local uidList=ScriptLib.GetSceneUidList(context)
for i=1,math.min(#gadgets,#points) do
if gadgets[i].gadget_id == defs.fundation_id then
ScriptLib.CreateFoundation(context, uidList, gadgets[i].config_id, points[i].config_id,defs.challange_group_id,999)
end
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,115 @@
--s1为空,s2往后自动引用为怪物潮
--[[
tide_defs = {
[1] = { sum = 40, min = 8, max = 12},
[2] = { sum = 40, min = 8, max = 12},
[3] = { sum = 40, min = 8, max = 12},
}
local guide_point_list=
{
[1]={1006,1007,1008,1009,1010,1011},
[2]={1012,1013,1014,1015,1016,1017},
}
local monster_tide_defs={
[1]={{monster_package={1001,1002,1003},route={1,2,2},route_points={{1,2,3,4},{1,2,3},{1,2,3,4,5}},speed={1,1,2},tags={1,2,3},count=100,max=6,min=5},{monster_package={1001,1002,1003},route={1,2,3},route_points={{1,2,3,4},{1,2,3},{1,2,3,4,5}},speed={1,1,2},tags={1,2,3},count=100,max=6,min=5}},
[2]={{monster_package={1001,1002,1003},route={1,2,2},route_points={{1,2,3,4},{1,2,3},{1,2,3,4,5}},speed={1,1,2},tags={1,2,3},count=100,max=6,min=5},{monster_package={1001,1002,1003},route={1,2,3},route_points={{1,2,3,4},{1,2,3},{1,2,3,4,5}},speed={1,1,2},tags={1,2,3},count=100,max=6,min=5}},
[3]={{monster_package={1001,1002,1003},route={1,2,2},route_points={{1,2,3,4},{1,2,3},{1,2,3,4,5}},speed={1,1,2},tags={1,2,3},count=100,max=6,min=5},{monster_package={1001,1002,1003},route={1,2,3},route_points={{1,2,3,4},{1,2,3},{1,2,3,4,5}},speed={1,1,2},tags={1,2,3},count=100,max=6,min=5}},
[4]={{monster_package={1001,1002,1003},route={1,2,2},route_points={{1,2,3,4},{1,2,3},{1,2,3,4,5}},speed={1,1,2},tags={1,2,3},count=100,max=6,min=5},{monster_package={1001,1002,1003},route={1,2,3},route_points={{1,2,3,4},{1,2,3},{1,2,3,4,5}},speed={1,1,2},tags={1,2,3},count=100,max=6,min=5}}
}
]]--
function LF_Init_Monster_Group()
t1 = { config_id = 8000001, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_monster_die", trigger_count = 0 }
-- t2 = { config_id = 8000002, name = "monster_tide_over", event = EventType.EVENT_MONSTER_TIDE_OVER, source = "", condition = "", action = "action_monster_tide_over", trigger_count = 0}
for i,v in ipairs(suites) do
table.insert(v.triggers, t1.name)
-- table.insert(v.triggers, t2.name)
end
table.insert(triggers, t1)
-- table.insert(triggers, t2)
table.insert(variables, { config_id=50000001,name = "tide_ptr", value = 0})
table.insert(variables, { config_id=50000002,name = "challenge_group", value = 0})
local leftMonsters=0
for i=1,#tide_defs do
for j=1,#tide_defs[i] do
leftMonsters=leftMonsters+tide_defs[i][j].sum
end
end
table.insert(variables, { config_id=50000003, name = "left_monsters", value = leftMonsters})
end
local gear_group_id = defs.gear_group_id or 0
function action_monster_die(context, evt)
--ScriptLib.PrintContextLog(context, "--------------- award_points ------------")
--ScriptLib.ExecuteGroupLua(context, gear_group_id, "award_points", {monsters[evt.param1].kill_score or 10})
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "del_monster_number", {0})
if ScriptLib.GetGroupMonsterCount(context) == 0 then
monster_tide_over(context)
end
return 0
end
function MonsterArrive(context)
local entityId=context.target_entity_id
ScriptLib.PrintContextLog(context, "TowerDefenseMonsterArrive"..context.target_entity_id)
for k,v in pairs(monsters) do
if ScriptLib.GetEntityIdByConfigId(context, v.config_id)==entityId then
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.MONSTER, v.config_id)
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "monster_escaped", {0})
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "del_monster_number", {0})
if ScriptLib.GetGroupMonsterCount(context) == 0 then
monster_tide_over(context)
end
return 0
end
end
return 0
end
--启动此group的初始怪物潮
function start_tide(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "tide_ptr", 1)
ScriptLib.SetGroupVariableValue(context, "challenge_group", param1)
local monstersLeft=ScriptLib.GetGroupVariableValue(context, "left_monsters")
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "set_monster_number", {monstersLeft})
for i=1,#tide_defs[1] do
ScriptLib.AutoMonsterTide(context, 100+i, defs.group_id, suites[tide_defs[1][i].suite].monsters, tide_defs[1][i].sum , tide_defs[1][i].min , tide_defs[1][i].max )
end
--ScriptLib.AutoMonsterTide(context, 100, defs.group_id, suites[2].monsters, tide_defs[2].sum or tide_defs[1].sum, tide_defs[2].min or tide_defs[1].min, tide_defs[2].max or tide_defs[1].max)
return 0
end
function monster_tide_over(context)
ScriptLib.PrintContextLog(context, "## monster_tide_over")
local tide = ScriptLib.GetGroupVariableValue(context, "tide_ptr")
if tide >= #tide_defs then
local challenge_group = ScriptLib.GetGroupVariableValue(context, "challenge_group")
ScriptLib.PrintContextLog(context, "## challenge_group = "..challenge_group)
ScriptLib.ExecuteGroupLua(context, challenge_group, "tide_done", {0})
ScriptLib.PrintContextLog(context, "## TD_LOG : Group Monster Tide End -> "..defs.group_id)
return 0
end
--tide自然结束,开启下一tide
--if evt.param1 == 0 then
tide = tide+1
for i=1,#tide_defs[tide] do
ScriptLib.AutoMonsterTide(context, 100*tide+i, defs.group_id, suites[tide_defs[tide][i].suite].monsters, tide_defs[tide][i].sum , tide_defs[tide][i].min , tide_defs[tide][i].max )
end
--ScriptLib.AutoMonsterTide(context, 100, defs.group_id, suites[tide].monsters, tide_defs[tide].sum or tide_defs[1].sum, tide_defs[tide].min or tide_defs[1].min, tide_defs[tide].max or tide_defs[1].max)
ScriptLib.SetGroupVariableValue(context, "tide_ptr", tide)
return 0
--else ScriptLib.PrintContextLog(context, "## TD_LOG : Group Monster Tide Force Stop -> "..defs.group_id.." | tide_id = "..tide)
--end
--return 0
end
function fix_gear(context, prev_context, param1, param2, param3)
ScriptLib.ExecuteGroupLua(context, defs.gear_group_id, "fix_gear", {param1})
end
LF_Init_Monster_Group()
@@ -0,0 +1,284 @@
--s1为空,s2往后自动引用为怪物潮
--[[
tide_defs = {
[1] = { sum = 40, min = 8, max = 12},
[2] = { sum = 40, min = 8, max = 12},
[3] = { sum = 40, min = 8, max = 12},
}
local guide_point_list=
{
[1]={1006,1007,1008,1009,1010,1011},
[2]={1012,1013,1014,1015,1016,1017},
}
package_tide_defs={
[1]={{monster_package={2001,2002,2003},route=1,route_points={1,2,3,4,5,6,7,8},tags=1,count=100,max=6,min=5,fill_time=2,fill_count=2},{monster_package={2001,2002,2003},route=2,route_points={1,2,3,4,5,6,7,8,9,10},tags=2,count=20,max=6,min=5}},
[2]={{monster_package={2001,2002,2003},route=1,route_points={1,2,3,4,5,6,7,8},tags=1,count=100,max=6,min=5},{monster_package={2001,2002,2003},route=2,route_points={1,2,3,4,5,6,7,8,9,10},tags=2,count=20,max=6,min=5}},
[3]={{monster_package={2001,2002,2003},route=1,route_points={1,2,3,4,5,6,7,8},tags=1,count=100,max=6,min=5},{monster_package={2001,2002,2003},route=2,route_points={1,2,3,4,5,6,7,8,9,10},tags=2,count=20,max=6,min=5}},
[4]={{monster_package={2001,2002,2003},route=1,route_points={1,2,3,4,5,6,7,8},tags=1,count=100,max=6,min=5},{monster_package={2001,2002,2003},route=2,route_points={1,2,3,4,5,6,7,8,9,10},tags=2,count=20,max=6,min=5}},
}
]]--
function LF_Init_Monster_Group()
t1 = { config_id = 8000001, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_monster_die", trigger_count = 0 }
t2 = { config_id = 8000002,name = "TIMER_EVENT_DELAY", event = EventType.EVENT_TIMER_EVENT, source = "delay", condition = "", action = "action_END_DELAY", trigger_count = 0 }
for i,v in ipairs(suites) do
table.insert(v.triggers, t1.name)
table.insert(v.triggers, t2.name)
end
table.insert(triggers, t1)
table.insert(triggers, t2)
table.insert(variables, { config_id=50000001,name = "tide_ptr", value = 0})
table.insert(variables, { config_id=50000002,name = "challenge_group", value = 0})
local leftMonsters=0
for i=1,#package_tide_defs do
for j=1,#package_tide_defs[i] do
leftMonsters=leftMonsters+package_tide_defs[i][j].count
end
end
table.insert(variables, { config_id=50000003,name = "left_monsters", value = leftMonsters})
table.insert(variables, { config_id=50000004,name = "monster_tide_index", value = 1})
table.insert(variables, { config_id=50000005,name = "extra_monster_65", value = 0})
table.insert(variables, { config_id=50000006,name = "extra_monster_66", value = 0})
table.insert(variables, { config_id=50000007,name = "extra_monster_67", value = 0})
table.insert(variables, { config_id=50000008,name = "extra_monster_68", value = 0})
table.insert(variables, { config_id=50000009,name = "extra_monster_69", value = 0})
table.insert(variables, { config_id=50000010,name = "extra_monster_70", value = 0})
table.insert(variables, { config_id=50000011,name = "buff_monster_4112", value = 0})
table.insert(variables, { config_id=50000012,name = "buff_monster_4113", value = 0})
table.insert(variables, { config_id=50000013,name = "monster_kill_count", value = 0})
end
local gear_group_id = defs.gear_group_id or 0
--挑战开始时额外创建怪物
function extra_monster_65(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "extra_monster_65", 1)
return 0
end
function extra_monster_66(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "extra_monster_66", 1)
return 0
end
function extra_monster_67(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "extra_monster_67", 1)
return 0
end
function extra_monster_68(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "extra_monster_68", 1)
return 0
end
function extra_monster_69(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "extra_monster_69", 1)
return 0
end
function extra_monster_70(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "extra_monster_70", 1)
return 0
end
--创建的怪物附带词缀
function buff_monster_4112(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "buff_monster_4112", 1)
return 0
end
function buff_monster_4113(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "buff_monster_4113", 1)
return 0
end
function action_monster_die(context, evt)
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "del_monster_number", {0})
local monster_kill_count=ScriptLib.GetGroupVariableValue(context, "monster_kill_count")
monster_kill_count=monster_kill_count+1
if monster_kill_count >= ScriptLib.GetGroupVariableValue(context, "left_monsters") then
monster_tide_over(context)
end
ScriptLib.SetGroupVariableValue(context, "monster_kill_count", monster_kill_count)
return 0
end
function MonsterArrive(context)
local entityId=context.target_entity_id
ScriptLib.PrintContextLog(context, "TowerDefenseMonsterArrive"..context.target_entity_id)
for k,v in pairs(points) do
if ScriptLib.GetEntityIdByConfigId(context, v.config_id)==entityId then
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.MONSTER, v.config_id)
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "monster_escaped", {0})
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "del_monster_number", {0})
local monster_kill_count=ScriptLib.GetGroupVariableValue(context, "monster_kill_count")
monster_kill_count=monster_kill_count+1
if monster_kill_count >= ScriptLib.GetGroupVariableValue(context, "left_monsters") then
monster_tide_over(context)
end
ScriptLib.SetGroupVariableValue(context, "monster_kill_count", monster_kill_count)
return 0
end
end
return 0
end
function set_monster_number_req(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "challenge_group", param1)
local monstersLeft=ScriptLib.GetGroupVariableValue(context, "left_monsters")
if ScriptLib.GetGroupVariableValue(context, "extra_monster_65")==1 then
monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_66")==1 then
monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_67")==1 then
monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_68")==1 then
monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_69")==1 then
monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_70")==1 then
monstersLeft=monstersLeft+1
end
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "set_monster_number", {monstersLeft})
ScriptLib.SetGroupVariableValue(context, "left_monsters", monstersLeft)
return 0
end
--启动此group的初始怪物潮
function start_tide(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "challenge_group", param1)
math.randomseed(ScriptLib.GetServerTime(context))
local monster_pool_table=ScriptLib.GetMechanicusMonsterPoolVec(context,ScriptLib.GetGroupVariableValue(context, "challenge_group"),999)
local affix={}
if ScriptLib.GetGroupVariableValue(context, "buff_monster_4112")==1 then
table.insert(affix,4112)
end
if ScriptLib.GetGroupVariableValue(context, "buff_monster_4113")==1 then
table.insert(affix,4113)
end
ScriptLib.SetGroupVariableValue(context, "tide_ptr", 1)
for i=1,#affix do
ScriptLib.PrintContextLog(context, "## TD_LOG : AFFIX TABLE"..affix[i])
end
--local monstersLeft=ScriptLib.GetGroupVariableValue(context, "left_monsters")
local index= ScriptLib.GetGroupVariableValue(context, "monster_tide_index")
for i=1,#package_tide_defs[1] do
ScriptLib.AutoPoolMonsterTide(context, index, defs.group_id, {monster_pool_table[index]},package_tide_defs[1][i].route, package_tide_defs[1][i].route_points, affix, {total_count=package_tide_defs[1][i].count, min_count=package_tide_defs[1][i].min, max_count=package_tide_defs[1][i].max, tag=package_tide_defs[1][i].tags,fill_time=package_tide_defs[1][i].fill_time or 5,fill_count=package_tide_defs[1][i].fill_count or 5})
index=index+1
end
--创建翻牌子的怪物
if ScriptLib.GetGroupVariableValue(context, "extra_monster_65")==1 then
local create_route=math.random(#package_tide_defs[1])
ScriptLib.AutoPoolMonsterTide(context, 65, defs.group_id, {12040},package_tide_defs[1][create_route].route, package_tide_defs[1][create_route].route_points, affix, {total_count=1, min_count=1, max_count=1, tag=package_tide_defs[1][create_route].tags,fill_time=package_tide_defs[1][create_route].fill_time or 5,fill_count=package_tide_defs[1][create_route].fill_count or 2})
--monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_66")==1 then
local create_route=math.random(#package_tide_defs[1])
ScriptLib.AutoPoolMonsterTide(context, 66, defs.group_id, {12041},package_tide_defs[1][create_route].route, package_tide_defs[1][create_route].route_points, affix, {total_count=1, min_count=1, max_count=1, tag=package_tide_defs[1][create_route].tags,fill_time=package_tide_defs[1][create_route].fill_time or 5,fill_count=package_tide_defs[1][create_route].fill_count or 2})
--monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_67")==1 then
local create_route=math.random(#package_tide_defs[1])
ScriptLib.AutoPoolMonsterTide(context, 67, defs.group_id, {12050},package_tide_defs[1][create_route].route, package_tide_defs[1][create_route].route_points,affix, {total_count=1, min_count=1, max_count=1, tag=package_tide_defs[1][create_route].tags,fill_time=package_tide_defs[1][create_route].fill_time or 5,fill_count=package_tide_defs[1][create_route].fill_count or 2})
--monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_68")==1 then
local create_route=math.random(#package_tide_defs[1])
ScriptLib.AutoPoolMonsterTide(context, 68, defs.group_id, {12051},package_tide_defs[1][create_route].route, package_tide_defs[1][create_route].route_points, affix, {total_count=1, min_count=1, max_count=1, tag=package_tide_defs[1][create_route].tags,fill_time=package_tide_defs[1][create_route].fill_time or 5,fill_count=package_tide_defs[1][create_route].fill_count or 2})
--monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_69")==1 then
local create_route=math.random(#package_tide_defs[1])
ScriptLib.AutoPoolMonsterTide(context, 69, defs.group_id, {12052},package_tide_defs[1][create_route].route, package_tide_defs[1][create_route].route_points, affix, {total_count=1, min_count=1, max_count=1, tag=package_tide_defs[1][create_route].tags,fill_time=package_tide_defs[1][create_route].fill_time or 5,fill_count=package_tide_defs[1][create_route].fill_count or 2})
--monstersLeft=monstersLeft+1
end
if ScriptLib.GetGroupVariableValue(context, "extra_monster_70")==1 then
local create_route=math.random(#package_tide_defs[1])
ScriptLib.AutoPoolMonsterTide(context, 70, defs.group_id, {12053},package_tide_defs[1][create_route].route, package_tide_defs[1][create_route].route_points, affix, {total_count=1, min_count=1, max_count=1, tag=package_tide_defs[1][create_route].tags,fill_time=package_tide_defs[1][create_route].fill_time or 5,fill_count=package_tide_defs[1][create_route].fill_count or 2})
--monstersLeft=monstersLeft+1
end
ScriptLib.SetGroupVariableValue(context, "monster_tide_index", index)
return 0
end
--推送给主控怪物预览信息
function set_monster_preview(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "challenge_group", param1)
math.randomseed(ScriptLib.GetServerTime(context))
local randomidx=0
local monster_preview_table={}
for i=1,#package_tide_defs do
for j=1,#package_tide_defs[i] do
randomidx=math.random(#package_tide_defs[i][j].monster_package)
table.insert(monster_preview_table,package_tide_defs[i][j].monster_package[randomidx])
end
end
ScriptLib.SetMechanicusMonsterPoolVec(context,ScriptLib.GetGroupVariableValue(context, "challenge_group"),999,monster_preview_table)
return 0
end
function action_END_DELAY(context, evt)
local challenge_group = ScriptLib.GetGroupVariableValue(context, "challenge_group")
ScriptLib.PrintContextLog(context, "## challenge_group = "..challenge_group)
ScriptLib.ExecuteGroupLua(context, challenge_group, "tide_done", {0})
ScriptLib.PrintContextLog(context, "## TD_LOG : Group Monster Tide End -> "..defs.group_id)
return 0
end
function monster_tide_over(context)
ScriptLib.PrintContextLog(context, "## monster_tide_over")
local tide = ScriptLib.GetGroupVariableValue(context, "tide_ptr")
if tide >= #package_tide_defs then
local challenge_group = ScriptLib.GetGroupVariableValue(context, "challenge_group")
ScriptLib.PrintContextLog(context, "## challenge_group = "..challenge_group)
ScriptLib.ExecuteGroupLua(context, challenge_group, "tide_done", {0})
ScriptLib.PrintContextLog(context, "## TD_LOG : Group Monster Tide End -> "..defs.group_id)
return 0
end
--tide自然结束,开启下一tide
--if evt.param1 == 0 then
tide = tide+1
local index=ScriptLib.GetGroupVariableValue(context, "monster_tide_index")
local monster_pool_table=ScriptLib.GetMechanicusMonsterPoolVec(context,ScriptLib.GetGroupVariableValue(context, "challenge_group"),999)
local affix={}
if ScriptLib.GetGroupVariableValue(context, "buff_monster_4112")==1 then
table.insert(affix,4112)
end
if ScriptLib.GetGroupVariableValue(context, "buff_monster_4113")==1 then
table.insert(affix,4113)
end
for i=1,#package_tide_defs[tide] do
ScriptLib.AutoPoolMonsterTide(context, index, defs.group_id, {monster_pool_table[index]},package_tide_defs[tide][i].route, package_tide_defs[tide][i].route_points, affix, {total_count=package_tide_defs[tide][i].count, min_count=package_tide_defs[tide][i].min, max_count=package_tide_defs[tide][i].max, tag=package_tide_defs[tide][i].tags,fill_time=package_tide_defs[tide][i].fill_time or 5,fill_count=package_tide_defs[tide][i].fill_count or 2})
index=index+1
--ScriptLib.AutoMonsterTide(context, 100*tide+i, defs.group_id, suites[tide_defs[tide][i].suite].monsters, tide_defs[tide][i].sum , tide_defs[tide][i].min , tide_defs[tide][i].max )
end
ScriptLib.SetGroupVariableValue(context, "monster_tide_index", index)
--ScriptLib.AutoMonsterTide(context, 100, defs.group_id, suites[tide].monsters, tide_defs[tide].sum or tide_defs[1].sum, tide_defs[tide].min or tide_defs[1].min, tide_defs[tide].max or tide_defs[1].max)
ScriptLib.SetGroupVariableValue(context, "tide_ptr", tide)
return 0
--else ScriptLib.PrintContextLog(context, "## TD_LOG : Group Monster Tide Force Stop -> "..defs.group_id.." | tide_id = "..tide)
--end
--return 0
end
function fix_gear(context, prev_context, param1, param2, param3)
ScriptLib.ExecuteGroupLua(context, defs.gear_group_id, "fix_gear", {param1})
end
LF_Init_Monster_Group()
@@ -0,0 +1,144 @@
--[[
tide_group_defs ={
[1] = {group = 250030010, delay = 60, next_group = 2, buff = {1,2,3}},
[2] = {group = 250030010, delay = 60, next_group = 3, buff = {1,2,3}},
[3] = {group = 250030010, delay = 60, next_group = 4, buff = {1,2,3}},
[4] = {group = 250030010, delay = 60, next_group = 5, buff = {1,2,3}},
[5] = {group = 250030010, delay = 60, next_group = 0, buff = {1,2,3}},
}
--]]
function LF_Init_Challenge_Group()
g1 = { config_id = 1, gadget_id = 70360002, pos = points[1].pos, rot = points[1].rot, level = 1 }
g2 = { config_id = 2, gadget_id = 70360002, pos = points[1].pos, rot = points[1].rot, level = 1 }
g3 = { config_id = 3, gadget_id = 70360002, pos = points[1].pos, rot = points[1].rot, level = 1 }
table.insert(gadgets, g1)
table.insert(gadgets, g2)
table.insert(gadgets, g3)
table.insert(suites[1].gadgets, g1.config_id)
t1 = { config_id = 8000001, name = "gadget_create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 }
t2 = { config_id = 8000002, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 }
--t3 = { config_id = 8000003, name = "timer_event", event = EventType.EVENT_TIMER_EVENT, source = "wave_delay", condition = "", action = "action_timer_event", trigger_count = 0}
t3 = { config_id = 8000003, name = "challenge_success", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "1", condition = "", action = "action_challenge_success", trigger_count = 0}
for i,v in ipairs(suites) do
table.insert(v.triggers, t1.name)
table.insert(v.triggers, t2.name)
table.insert(v.triggers, t3.name)
end
table.insert(triggers, t1)
table.insert(triggers, t2)
table.insert(triggers, t3)
table.insert(variables, { config_id=50000001,name = "wave_ptr", value = 0})
table.insert(variables, { config_id=50000002,name = "special_challenge", value = 0})
end
--------------------------------------
function action_gadget_create(context, evt)
if evt.param1 == 1 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, evt.param1, {2902})
elseif evt.param1 == 2 or evt.param1 == 3 then
--[[
local array = {}
for i,v in ipairs(tide_group_defs[wave].buff) do
array[i] = v
end
--]]
local wave = ScriptLib.GetGroupVariableValue(context, "wave_ptr")
ScriptLib.PrintContextLog(context, "## tide_wave = "..wave)
local buff = {}
for i,v in ipairs(tide_group_defs[wave].buff) do
buff[i] = 3000 + v
end
ScriptLib.PrintContextLog(context, "## evt.param1="..evt.param1)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, evt.param1, buff)
end
return 0
end
function action_select_option(context, evt)
if evt.param1 == 1 and evt.param2 == 2902 then
ScriptLib.ExecuteGroupLua(context, tide_group_defs[1].group, "start_tide", {defs.group_id})
ScriptLib.SetGroupVariableValue(context, "wave_ptr", 1)
ScriptLib.DelWorktopOption(context, evt.param2)
elseif evt.param1 == 2 or evt.param1 == 3 then
local uid_list = ScriptLib.GetSceneUidList(context)
if uid_list[evt.param1 - 1] ~= context.uid then
ScriptLib.ShowTemplateReminder(context, 123, {evt.param1 - 1})
return -1
end
--根据option发起对应的globalValue
ScriptLib.PrintContextLog(context, "## TD_LOG : Uid_"..context.uid.." select_option = "..evt.param2)
ScriptLib.ShowTemplateReminder(context, evt.param2-3000+117, {evt.param1 - 1})
---[[
local wave = ScriptLib.GetGroupVariableValue(context, "wave_ptr")
local next_wave = tide_group_defs[wave].next_group
if evt.param2 ~= 3004 then
--不知道gear的group,先转发给monster,再转发给gear升级用
ScriptLib.ExecuteGroupLua(context, tide_group_defs[next_wave].group, "fix_gear", {evt.param2})
elseif evt.param2 == 3004 then
--下一波额外添加一个挑战
ScriptLib.SetGroupVariableValue(context, "special_challenge", 1)
end
--]]
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.GADGET, evt.param1)
end
return 0
end
--某group结束,进下一阶段
function tide_done(context, prev_context, param1, param2, param3)
local wave = ScriptLib.GetGroupVariableValue(context, "wave_ptr")
ScriptLib.PrintContextLog(context, "## wave = "..wave)
if tide_group_defs[wave].next_group == 0 then
ScriptLib.PrintContextLog(context, "## TD_LOG : All Wave Done")
ScriptLib.CauseDungeonFail(context)
return 0
end
--限时击杀
--ScriptLib.ActiveChallenge(context, 1, 4, defs.group_id, 1, tide_group_defs[tide_group_defs[wave].next_group].delay, 1)
ScriptLib.ActiveChallenge(context, 1, 3, tide_group_defs[tide_group_defs[wave].next_group].delay, 1, 0, 0)
--ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "wave_delay", tide_group_defs[tide_group_defs[wave].next_group].delay)
ScriptLib.StopChallenge(context, 2, 1)
LF_Buff_Choice(context, wave)
return 0
end
function action_challenge_success(context, evt)
if evt.source_name == "1" then
local wave = ScriptLib.GetGroupVariableValue(context, "wave_ptr")
local next_wave = tide_group_defs[wave].next_group
ScriptLib.SetGroupVariableValue(context, "wave_ptr", next_wave)
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.GADGET, 2)
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.GADGET, 3)
ScriptLib.ExecuteGroupLua(context, tide_group_defs[next_wave].group, "start_tide", {defs.group_id})
if 0 ~= ScriptLib.GetGroupVariableValue(context, "special_challenge") then
ScriptLib.ActiveChallenge(context, 2, 3, 999, 1, 0, 0)
end
elseif evt.source_name == "2" then
ScriptLib.SetGroupVariableValue(context, "special_challenge", 0)
end
return 0
end
function LF_Buff_Choice(context, wave)
--[[
math.randomseed(ScriptLib.GetServerTime(context)+wave)
local buff = {}
for i=1,2 do
local index = math.random(#array)
buff[i] = index + 3000
table.remove(array, index)
end
]]
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
if i <= 2 then
local eid = ScriptLib.GetAvatarEntityIdByUid(context, v)
local pos = ScriptLib.GetPosByEntityId(context, eid)
ScriptLib.CreateGadgetByConfigIdByPos(context, i+1, {x=pos.x,y=pos.y,z=pos.z}, {x=0,y=0,z=0})
ScriptLib.PrintContextLog(context, "## TD_LOG : operator of "..i.."P")
--ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, i+1, array)
end
end
end
LF_Init_Challenge_Group()
@@ -0,0 +1,249 @@
--[[
setmetatable(_ENV,{__index=function() return {} end })
--]]
local define = {
group_id = defs.group_id or 250030001,
gear_list = --[[defs.gear_list or]] {70350107,70350112,70350113,70350114,70350115,70350116,70350129,70350111,70350143},
option_list = --[[defs.option_list or]] {41,42,43,44,45,48,49,50,46},
option_revert = 46,
option_points = --[[defs.option_points or]] {20,20,20,20,20,20,20,20,20},
monster_points = defs.monster_points or 10,
max_points = defs.max_points or 100
}
function LF_Initialize_Level()
--ScriptLib.PrintLog("================ INITIALIZE 33 ==============")
for i=1,#points do --初始化每个点
for j=1,#define.gear_list do --每个点上做机关序列化
gadgets[i*1000+j] = { config_id = 1000*i+j, gadget_id = define.gear_list[j], pos = points[i].pos, rot = points[i].rot, level = 1}
if j%10 == 1 then
table.insert(suites[1].gadgets, i*1000+1)
end
end
var1 = { config_id=51000000+i,name = "gear_info_"..i, value = 0 }
var4 = { config_id=52000000+i,name = "gear_belong_"..i, value = 0 }
table.insert(variables, var1)
table.insert(variables, var4)
--[[if suites[1].gadgets[i] ~= nil then
ScriptLib.PrintLog("## suite[1] add gadget -> "..suites[1].gadgets[i])
else ScriptLib.PrintLog("## null suites[] -> "..i)
end--]]
end
var2 = { config_id=50000001,name = "cur_points_1", value = 0 }
var3 = { config_id=50000002,name = "cur_points_2", value = 0 }
var5 = { config_id=50000003,name = "buff", value = 0}
table.insert(variables, var2)
table.insert(variables, var3)
table.insert(variables, var5)
t1 = { config_id = 8000001, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "condition_EVENT_GADGET_CREATE", action = "action_EVENT_GADGET_CREATE", trigger_count = 0 }
t2 = { config_id = 8000002, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0 }
t3 = { config_id = 8000003, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0}
table.insert(triggers, t1)
table.insert(triggers, t2)
table.insert(triggers, t3)
table.insert(suites[1].triggers, t1.name)
table.insert(suites[1].triggers, t2.name)
table.insert(suites[1].triggers, t3.name)
--ScriptLib.PrintLog("## suite.gadgets.size() -> "..#suites[1].gadgets)
return 0
end
function condition_EVENT_GADGET_CREATE(context, evt)
if evt.param1%1000 == 1 then
return true
end
return false
end
function action_EVENT_GADGET_CREATE(context, evt)
--ScriptLib.CreateGadget(context, { config_id = evt.param1 + 1})
--ScriptLib.PrintContextLog(context, "## operator_create : "..evt.param1)
local op_list = {}
for i,v in ipairs(define.option_list) do
op_list[i] = v
end
table.remove(op_list, #op_list)
ScriptLib.SetWorktopOptionsByGroupId(context, define.group_id, evt.param1, op_list)
return 0
end
function action_EVENT_SELECT_OPTION(context, evt)
ScriptLib.PrintContextLog(context, "## select_option : param1 -> "..evt.param1.." | param2 -> "..evt.param2.." uid -> "..context.uid)
--处理联机的情况
local uid_list = ScriptLib.GetSceneUidList(context)
local cid = evt.param1//1000
local belong = ScriptLib.GetGroupVariableValue(context, "gear_belong_"..cid)
--定位玩家序号
local u_index = 0
for i,v in ipairs(uid_list) do
if v == context.uid then
u_index = i
break
end
end
if belong ~= 0 then
if belong ~= u_index then
ScriptLib.ShowTemplateReminder(context, 123, {(belong-3)*-1})
return -1
end
else ScriptLib.SetGroupVariableValue(context, "gear_belong_"..cid, u_index)
end
--允许建造机关
local uid_list = ScriptLib.GetSceneUidList(context)
local player = 0
for i,v in ipairs(uid_list) do
if v == context.uid then
player = i
break
end
end
--确定option序列
local create_gear = 0
local o_id = 0
for i,v in ipairs(define.option_list) do
if v == evt.param2 then
create_gear = evt.param1 + i
o_id = i
break
end
end
local result = LF_Enough_Points(context, o_id, player)
if 1 == result then
local p_o_id = ScriptLib.GetGroupVariableValue(context, "gear_info_"..(evt.param1//1000))
ScriptLib.PrintContextLog(context, "## -----------------get_variable : gear_info_"..(evt.param1//1000).."->"..p_o_id)
ScriptLib.CreateGadget(context, { config_id = create_gear })
--================================================================
local buff_cache = ScriptLib.GetGroupVariableValue(context, "buff")
if buff_cache ~= 500 then
if buff_cache//100 > 0 then
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {create_gear}, "TOWEDEFENCE_HITRANGE", buff_cache//100)
end
if (buff_cache%100)//10 > 0 then
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {create_gear}, "TOWEDEFENCE_DAMAGE", (buff_cache%100)//10)
end
if buff_cache%10 > 0 then
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {create_gear}, "TOWEDEFENCE_HITINTERVAL", buff_cache%10)
end
else ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {create_gear}, "TOWEDEFENCE_HITRANGE", 5)
end
--==================================================================
ScriptLib.PrintContextLog(context, "$$ create_cid = "..create_gear.." | option = "..evt.param2.." | gid = "..gadgets[create_gear].gadget_id)
local new_option_list = {}
local j = 1
for i=1,#define.option_list-1 do
if define.option_list[i] ~= evt.param2 then
new_option_list[j] = define.option_list[i]
j = j + 1
end
end
if p_o_id ~= 0 then
local remove_gear = evt.param1 + p_o_id
--ScriptLib.PrintContextLog(context, "$$ remove gear -> "..remove_gear)
ScriptLib.RemoveEntityByConfigId(context, define.group_id, EntityType.GADGET, remove_gear )
LF_Return_Points(context, p_o_id, player)
end
table.insert(new_option_list, define.option_revert)
ScriptLib.SetWorktopOptionsByGroupId(context, define.group_id, evt.param1, new_option_list)
ScriptLib.SetGroupVariableValue(context, "gear_info_"..(evt.param1//1000), o_id)
ScriptLib.PrintContextLog(context, "## -----------------set_variable : gear_info_"..(evt.param1//1000).."->"..o_id)
local cur_p = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
ScriptLib.ShowTemplateReminder(context, 115, {player, cur_p, define.max_points})
elseif -1 == result then
local cur_p = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
ScriptLib.ShowTemplateReminder(context, 116, {player, cur_p, define.max_points})
return -1
elseif 0 == result then
--返回建造点数并重置机关
local p_o_id = ScriptLib.GetGroupVariableValue(context, "gear_info_"..(evt.param1//1000))
local remove_gear = evt.param1 + p_o_id
--ScriptLib.PrintContextLog(context, "$$ remove gear -> "..remove_gear)
ScriptLib.RemoveEntityByConfigId(context, define.group_id, EntityType.GADGET, remove_gear )
LF_Return_Points(context, p_o_id, player)
ScriptLib.SetWorktopOptionsByGroupId(context, define.group_id, evt.param1, define.option_list)
ScriptLib.SetGroupVariableValue(context, "gear_info_"..(evt.param1//1000), 0)
ScriptLib.PrintContextLog(context, "## -----------------set_variable : gear_info_"..(evt.param1//1000).."->"..p_o_id)
local cur_p = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
ScriptLib.ShowTemplateReminder(context, 115, {player, cur_p, define.max_points})
end
return 0
end
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "## ================ INITIALIZE 61 ==============")
ScriptLib.SetGroupVariableValue(context, "cur_points_1", define.max_points)
ScriptLib.SetGroupVariableValue(context, "cur_points_2", define.max_points)
return 0
end
function award_points(context, prev_context, param1, param2, param3)
local uid_list = ScriptLib.GetSceneUidList(context)
local new_points = 0
for i,v in ipairs(uid_list) do
local cur_points = ScriptLib.GetGroupVariableValue(context, "cur_points_"..i)
new_points = cur_points + param1
if new_points > define.max_points then
new_points = define.max_points
end
ScriptLib.SetGroupVariableValue(context, "cur_points_"..i, new_points)
--ScriptLib.PrintContextLog(context, "$$ player -> "..i.." | points -> "..new_points)
end
ScriptLib.ShowTemplateReminder(context, 117, {param1})
return 0
end
function LF_Return_Points(context, index, player)
if index > 0 then
local cur_points = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
local new_points = cur_points + define.option_points[index]
if new_points > define.max_points then
new_points = define.max_points
end
ScriptLib.SetGroupVariableValue(context, "cur_points_"..player, new_points)
else
return -1
end
return 0
end
function LF_Enough_Points(context, index, player)
--选到46号后恢复原始状态
if index == #define.option_list then
return 0
end
--使用点数建造对应机关
local cur_points = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
if cur_points >= define.option_points[index] then
ScriptLib.ChangeGroupVariableValue(context, "cur_points_"..player, -define.option_points[index])
return 1
else
--点数不够
return -1
end
end
function fix_gear(context, prev_context, param1, param2, param3)
for i,v in ipairs(points) do
local cid = ScriptLib.GetGroupVariableValue(context, "gear_info_"..i)
if cid ~= 0 then
cid = 1000*i+cid+1
ScriptLib.PrintContextLog(context, "## TD_LOG : cid -> "..cid.." | buff -> "..param1)
if param1 == 3001 then
ScriptLib.ChangeGroupVariableValue(context, "buff", 1)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {cid}, "TOWEDEFENCE_HITRANGE", 1)
elseif param1 == 3002 then
ScriptLib.ChangeGroupVariableValue(context, "buff", 10)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {cid}, "TOWEDEFENCE_DAMAGE", 1)
elseif param1 == 3003 then
ScriptLib.ChangeGroupVariableValue(context, "buff", 100)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {cid}, "TOWEDEFENCE_HITINTERVAL", 1)
elseif param1 == 3004 then
ScriptLib.SetGroupVariableValue(context, "buff", 500)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {cid}, "TOWEDEFENCE_HITRANGE", 5)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {cid}, "TOWEDEFENCE_DAMAGE", -5)
ScriptLib.AddEntityGlobalFloatValueByConfigId(context, {cid}, "TOWEDEFENCE_HITINTERVAL", -5)
end
end
end
end
LF_Initialize_Level()
@@ -0,0 +1,66 @@
--s1为空,s2往后自动引用为怪物潮
--[[
tide_defs = {
[1] = { sum = 40, min = 8, max = 12},
[2] = { sum = 40, min = 8, max = 12},
[3] = { sum = 40, min = 8, max = 12},
}
--]]
function LF_Init_Monster_Group()
t1 = { config_id = 8000001, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_monster_die", trigger_count = 0 }
-- t2 = { config_id = 8000002, name = "monster_tide_over", event = EventType.EVENT_MONSTER_TIDE_OVER, source = "", condition = "", action = "action_monster_tide_over", trigger_count = 0}
for i,v in ipairs(suites) do
table.insert(v.triggers, t1.name)
-- table.insert(v.triggers, t2.name)
end
table.insert(triggers, t1)
-- table.insert(triggers, t2)
table.insert(variables, { config_id=50000001,name = "tide_ptr", value = 0})
table.insert(variables, { config_id=50000002,name = "challenge_group", value = 0})
end
local gear_group_id = defs.gear_group_id or 0
function action_monster_die(context, evt)
--ScriptLib.PrintContextLog(context, "--------------- award_points ------------")
ScriptLib.ExecuteGroupLua(context, gear_group_id, "award_points", {monsters[evt.param1].kill_score or 10})
if ScriptLib.GetGroupMonsterCount(context) == 0 then
monster_tide_over(context)
end
return 0
end
--启动此group的初始怪物潮
function start_tide(context, prev_context, param1,param2,param3)
ScriptLib.SetGroupVariableValue(context, "tide_ptr", 2)
ScriptLib.SetGroupVariableValue(context, "challenge_group", param1)
ScriptLib.AutoMonsterTide(context, 100, defs.group_id, suites[2].monsters, tide_defs[2].sum or tide_defs[1].sum, tide_defs[2].min or tide_defs[1].min, tide_defs[2].max or tide_defs[1].max)
end
function monster_tide_over(context)
ScriptLib.PrintContextLog(context, "## monster_tide_over")
local tide = ScriptLib.GetGroupVariableValue(context, "tide_ptr")
if tide >= #tide_defs then
local challenge_group = ScriptLib.GetGroupVariableValue(context, "challenge_group")
ScriptLib.PrintContextLog(context, "## challenge_group = "..challenge_group)
ScriptLib.ExecuteGroupLua(context, challenge_group, "tide_done", {0})
ScriptLib.PrintContextLog(context, "## TD_LOG : Group Monster Tide End -> "..defs.group_id)
return 0
end
--tide自然结束,开启下一tide
--if evt.param1 == 0 then
tide = tide+1
ScriptLib.AutoMonsterTide(context, 100, defs.group_id, suites[tide].monsters, tide_defs[tide].sum or tide_defs[1].sum, tide_defs[tide].min or tide_defs[1].min, tide_defs[tide].max or tide_defs[1].max)
ScriptLib.SetGroupVariableValue(context, "tide_ptr", tide)
return 0
--else ScriptLib.PrintContextLog(context, "## TD_LOG : Group Monster Tide Force Stop -> "..defs.group_id.." | tide_id = "..tide)
--end
--return 0
end
function fix_gear(context, prev_context, param1, param2, param3)
ScriptLib.ExecuteGroupLua(context, defs.gear_group_id, "fix_gear", {param1})
end
LF_Init_Monster_Group()
@@ -0,0 +1,171 @@
--[[
setmetatable(_ENV,{__index=function() return {} end })
--]]
local define = {
group_id = defs.group_id or 250030001,
gear_list = --[[defs.gear_list or]] {70350107,70350099,70350100,70350101,70350102,70350103},
option_list = --[[defs.option_list or]] {41,42,43,44,45},
option_revert = 46,
option_points = --[[defs.option_points or]] {20,20,20,20,20},
monster_points = defs.monster_points or 10,
max_points = defs.max_points or 100
}
function LF_Initialize_Level()
--ScriptLib.PrintLog("================ INITIALIZE 33 ==============")
for i=1,#points do --初始化每个点
for j=1,#define.gear_list do --每个点上做机关序列化
gadgets[i*1000+j] = { config_id = 1000*i+j, gadget_id = define.gear_list[j], pos = points[i].pos, rot = points[i].rot, level = 1}
if j%10 == 1 then
table.insert(suites[1].gadgets, i*1000+1)
end
end
var1 = { config_id=51000000+i,name = "gear_info_"..i, value = 0 }
table.insert(variables, var1)
--[[if suites[1].gadgets[i] ~= nil then
ScriptLib.PrintLog("## suite[1] add gadget -> "..suites[1].gadgets[i])
else ScriptLib.PrintLog("## null suites[] -> "..i)
end--]]
end
var2 = { config_id=50000001,name = "cur_points_1", value = 0 }
var3 = { config_id=50000002,name = "cur_points_2", value = 0 }
table.insert(variables, var2)
table.insert(variables, var3)
t1 = { config_id = 8000001, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "condition_EVENT_GADGET_CREATE", action = "action_EVENT_GADGET_CREATE", trigger_count = 0 }
t2 = { config_id = 8000002, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0 }
t3 = { config_id = 8000003, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0}
table.insert(triggers, t1)
table.insert(triggers, t2)
table.insert(triggers, t3)
table.insert(suites[1].triggers, t1.name)
table.insert(suites[1].triggers, t2.name)
table.insert(suites[1].triggers, t3.name)
--ScriptLib.PrintLog("## suite.gadgets.size() -> "..#suites[1].gadgets)
return 0
end
function condition_EVENT_GADGET_CREATE(context, evt)
if evt.param1%1000 == 1 then
return true
end
return false
end
function action_EVENT_GADGET_CREATE(context, evt)
--ScriptLib.CreateGadget(context, { config_id = evt.param1 + 1})
--ScriptLib.PrintContextLog(context, "## operator_create : "..evt.param1)
ScriptLib.SetWorktopOptionsByGroupId(context, define.group_id, evt.param1, define.option_list)
return 0
end
function action_EVENT_SELECT_OPTION(context, evt)
ScriptLib.PrintContextLog(context, "## select_option : param1 -> "..evt.param1.." | param2 -> "..evt.param2.." uid -> "..context.uid)
local uid_list = ScriptLib.GetSceneUidList(context)
local player = 0
for i,v in ipairs(uid_list) do
if v == context.uid then
player = i
break
end
end
local result = LF_Enough_Points(context, evt.param2%10, player)
if 1 == result then
local prev_option = ScriptLib.GetGroupVariableValue(context, "gear_info_"..(evt.param1//1000))
ScriptLib.PrintContextLog(context, "## -----------------get_variable : gear_info_"..(evt.param1//1000).."->"..prev_option)
local create_gear = evt.param1 + evt.param2%10
ScriptLib.CreateGadget(context, { config_id = create_gear })
ScriptLib.PrintContextLog(context, "$$ create_cid = "..create_gear.." | option = "..evt.param2.." | gid = "..gadgets[create_gear].gadget_id)
local new_option_list = {}
local j = 1
for i=1,#define.option_list do
if define.option_list[i] ~= evt.param2 then
new_option_list[j] = define.option_list[i]
j = j + 1
end
end
if prev_option ~= 0 then
local remove_gear = evt.param1 + prev_option%10
--ScriptLib.PrintContextLog(context, "$$ remove gear -> "..remove_gear)
ScriptLib.RemoveEntityByConfigId(context, define.group_id, EntityType.GADGET, remove_gear )
LF_Return_Points(context, prev_option%10, player)
end
table.insert(new_option_list, define.option_revert)
ScriptLib.SetWorktopOptionsByGroupId(context, define.group_id, evt.param1, new_option_list)
ScriptLib.SetGroupVariableValue(context, "gear_info_"..(evt.param1//1000), evt.param2%10)
ScriptLib.PrintContextLog(context, "## -----------------set_variable : gear_info_"..(evt.param1//1000).."->"..(evt.param2%10))
local cur_p = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
ScriptLib.ShowTemplateReminder(context, 115, {player, cur_p, define.max_points})
elseif -1 == result then
local cur_p = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
ScriptLib.ShowTemplateReminder(context, 116, {player, cur_p, define.max_points})
return -1
elseif 0 == result then
--返回建造点数并重置机关
local prev_option = ScriptLib.GetGroupVariableValue(context, "gear_info_"..(evt.param1//1000))
local remove_gear = evt.param1 + prev_option%10
--ScriptLib.PrintContextLog(context, "$$ remove gear -> "..remove_gear)
ScriptLib.RemoveEntityByConfigId(context, define.group_id, EntityType.GADGET, remove_gear )
LF_Return_Points(context, prev_option%10, player)
ScriptLib.SetWorktopOptionsByGroupId(context, define.group_id, evt.param1, define.option_list)
ScriptLib.SetGroupVariableValue(context, "gear_info_"..(evt.param1//1000), 0)
ScriptLib.PrintContextLog(context, "## -----------------set_variable : gear_info_"..(evt.param1//1000).."->"..(evt.param2%10))
local cur_p = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
ScriptLib.ShowTemplateReminder(context, 115, {player, cur_p, define.max_points})
end
return 0
end
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "================ INITIALIZE 38 ==============")
ScriptLib.SetGroupVariableValue(context, "cur_points_1", define.max_points)
ScriptLib.SetGroupVariableValue(context, "cur_points_2", define.max_points)
return 0
end
function award_points(context, prev_context, param1, param2, param3)
local uid_list = ScriptLib.GetSceneUidList(context)
local new_points = 0
for i,v in ipairs(uid_list) do
local cur_points = ScriptLib.GetGroupVariableValue(context, "cur_points_"..i)
new_points = cur_points + define.monster_points
if new_points > define.max_points then
new_points = define.max_points
end
ScriptLib.SetGroupVariableValue(context, "cur_points_"..i, new_points)
--ScriptLib.PrintContextLog(context, "$$ player -> "..i.." | points -> "..new_points)
end
ScriptLib.ShowTemplateReminder(context, 117, {define.monster_points})
return 0
end
function LF_Return_Points(context, index, player)
if index > 0 then
local cur_points = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
local new_points = cur_points + define.option_points[index%10]
if new_points > define.max_points then
new_points = define.max_points
end
ScriptLib.SetGroupVariableValue(context, "cur_points_"..player, new_points)
else
return -1
end
return 0
end
function LF_Enough_Points(context, index, player)
--选到46号后恢复原始状态
if index == define.option_revert%10 then
return 0
end
--使用点数建造对应机关
local cur_points = ScriptLib.GetGroupVariableValue(context, "cur_points_"..player)
if cur_points >= define.option_points[index] then
ScriptLib.ChangeGroupVariableValue(context, "cur_points_"..player, -define.option_points[index])
return 1
else
--点数不够
return -1
end
end
LF_Initialize_Level()
@@ -0,0 +1,17 @@
function LF_Init_Monster_Group()
for i,v in ipairs(suites) do
temp_trigger = { config_id = 8000001, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_monster_die", trigger_count = 0 }
table.insert(v.triggers, temp_trigger.name)
end
table.insert(triggers, temp_trigger)
end
local gear_group_id = defs.gear_group_id or 250030001
function action_monster_die(context, evt)
ScriptLib.PrintContextLog(context, "--------------- award_points ------------")
ScriptLib.ExecuteGroupLua(context, gear_group_id, "award_points", {0})
return 0
end
LF_Init_Monster_Group()
@@ -0,0 +1,286 @@
--[[
setmetatable(_ENV,{__index=function() return {} end })
defs.group_id
defs.timer
--光桥机关
local light_bridge={
{operator_id=8001,effect_id=8002,gadget_id={8003}}
}
local wind_field={
{operator_id=8001,effect_id=8002,gadget_id={8003}}
}
--]]
function LF_Initialize_Trap()
table.insert(variables,{ config_id=50000001,name = "hasDiscount", value = 0 })
table.insert(variables,{ config_id=50000002,name = "hasColdDownDiscount", value = 0 })
t1 = { config_id = 8000001, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "condition_EVENT_GADGET_CREATE", action = "action_EVENT_GADGET_CREATE", trigger_count = 0 }
t2 = { config_id = 8000002, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0,forbid_guest = false }
t3 = { config_id = 8000003, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0}
t4 = { config_id = 8000004, name = "Variable_Change", event = EventType.EVENT_VARIABLE_CHANGE, source = "hasDiscount", condition = "", action = "action_VARIABLE_CHANGE", trigger_count = 0}
t5 = { config_id = 8000005, name = "Gadget_State_Change", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_GADGET_STATE_CHANGE", trigger_count = 0}
table.insert(triggers, t1)
table.insert(triggers, t2)
table.insert(triggers, t3)
table.insert(triggers, t4)
table.insert(triggers, t5)
table.insert(suites[1].triggers, t1.name)
table.insert(suites[1].triggers, t2.name)
table.insert(suites[1].triggers, t3.name)
table.insert(suites[1].triggers, t4.name)
table.insert(suites[1].triggers, t5.name)
--ScriptLib.PrintLog("## suite.gadgets.size() -> "..#suites[1].gadgets)
--[[
for i=1,#light_bridge do
local trigger={ config_id = 8000000+light_bridge[i].operator_id,name = tostring(light_bridge[i].operator_id), event = EventType.EVENT_TIMER_EVENT, source = tostring(light_bridge[i].operator_id), condition = "", action = "action_Light_Bridge_Revert", trigger_count = 0 }
end
]]--
for i=1,#wind_field do
table.insert(variables,{ config_id=51000000+i,name = tostring(wind_field[i].operator_id).."wind", value = 0 })
local wind_field_trigger={ config_id = 8000000+wind_field[i].operator_id,name = tostring(wind_field[i].operator_id), event = EventType.EVENT_TIMER_EVENT, source = tostring(wind_field[i].operator_id), condition = "", action = "action_Trap_Revert", trigger_count = 0 }
table.insert(triggers, wind_field_trigger)
table.insert(suites[1].triggers, wind_field_trigger.name)
end
for i=1,#light_bridge do
table.insert(variables,{ config_id=52000000+i,name = tostring(light_bridge[i].operator_id).."bridge", value = 0 })
local light_bridge_trigger={ config_id = 8000000+light_bridge[i].operator_id,name = tostring(light_bridge[i].operator_id), event = EventType.EVENT_TIMER_EVENT, source = tostring(light_bridge[i].operator_id), condition = "", action = "action_Trap_Revert", trigger_count = 0 }
table.insert(triggers, light_bridge_trigger)
table.insert(suites[1].triggers, light_bridge_trigger.name)
end
return 0
end
function LF_Initial_Options(context)
if ScriptLib.GetGroupVariableValue(context, "hasDiscount") == 0 then
for i=1,#light_bridge do
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, light_bridge[i].operator_id, {4001})
end
for i=1,#wind_field do
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, wind_field[i].operator_id, {4003})
end
elseif ScriptLib.GetGroupVariableValue(context, "hasDiscount") == 1 then
for i=1,#light_bridge do
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, light_bridge[i].operator_id, {4002})
end
for i=1,#wind_field do
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, wind_field[i].operator_id, {4004})
end
end
return 0
end
function action_GADGET_STATE_CHANGE(context,evt)
--[[
if evt.param1 == GadgetState.GearStart then
for i=1,#light_bridge do
if evt.param2 == light_bridge[i].operator_id then
ScriptLib.SetGadgetEnableInteract(context, defs.group_id, light_bridge[i].operator_id, false)
end
end
for j=1,#wind_field do
if evt.param2 == wind_field[i].operator_id then
ScriptLib.SetGadgetEnableInteract(context, defs.group_id, wind_field[i].operator_id, false)
end
end
return 0
end
]]--
if evt.param1 == GadgetState.Default then
for i=1,#light_bridge do
if evt.param2 == light_bridge[i].operator_id then
ScriptLib.ShowReminder(context, 400024)
ScriptLib.SetGroupVariableValue(context, tostring(light_bridge[i].operator_id).."bridge", 0)
if ScriptLib.GetGroupVariableValue(context, "hasDiscount") == 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, light_bridge[i].operator_id, 4001)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, light_bridge[i].operator_id, 4002)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, light_bridge[i].operator_id, {4001})
elseif ScriptLib.GetGroupVariableValue(context, "hasDiscount") == 1 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, light_bridge[i].operator_id, 4001)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, light_bridge[i].operator_id, 4002)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, light_bridge[i].operator_id, {4002})
end
--ScriptLib.SetGadgetEnableInteract(context, defs.group_id, light_bridge[i].operator_id, true)
ScriptLib.CreateGadget(context, { config_id = light_bridge[i].effect_id })
end
end
for j=1,#wind_field do
if evt.param2 == wind_field[j].operator_id then
ScriptLib.ShowReminder(context, 400024)
ScriptLib.SetGroupVariableValue(context, tostring( wind_field[j].operator_id).."wind", 0)
if ScriptLib.GetGroupVariableValue(context, "hasDiscount") == 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, wind_field[j].operator_id, 4003)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, wind_field[j].operator_id, 4004)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, wind_field[j].operator_id, {4003})
elseif ScriptLib.GetGroupVariableValue(context, "hasDiscount") == 1 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, wind_field[j].operator_id, 4003)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, wind_field[j].operator_id, 4004)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, wind_field[j].operator_id, {4004})
end
--ScriptLib.SetGadgetEnableInteract(context, defs.group_id, wind_field[j].operator_id, true)
for k=1,#wind_field[j].gadget_id do
ScriptLib.KillEntityByConfigId(context, { config_id = wind_field[j].gadget_id[k] })
end
ScriptLib.CreateGadget(context, { config_id = wind_field[j].effect_id })
end
end
return 0
end
return 0
end
function action_VARIABLE_CHANGE(context, evt)
if evt.param1 ==0 then
for i=1,#light_bridge do
if ScriptLib.GetGroupVariableValue(context, tostring(light_bridge[i].operator_id).."bridge") == 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, light_bridge[i].operator_id, 4001)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, light_bridge[i].operator_id, 4002)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, light_bridge[i].operator_id, {4001})
end
end
for i=1,#wind_field do
if ScriptLib.GetGroupVariableValue(context, tostring(wind_field[i].operator_id).."wind") == 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, wind_field[i].operator_id, 4003)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, wind_field[i].operator_id, 4004)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, wind_field[i].operator_id, {4003})
end
end
return 0
end
if evt.param1 ==1 then
for i=1,#light_bridge do
if ScriptLib.GetGroupVariableValue(context, tostring(light_bridge[i].operator_id).."bridge") == 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, light_bridge[i].operator_id, 4001)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, light_bridge[i].operator_id, 4002)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, light_bridge[i].operator_id, {4002})
end
end
for i=1,#wind_field do
if ScriptLib.GetGroupVariableValue(context, tostring(wind_field[i].operator_id).."wind") == 0 then
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, wind_field[i].operator_id, 4003)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, wind_field[i].operator_id, 4004)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, wind_field[i].operator_id, {4004})
end
end
return 0
end
return 0
end
function SetDiscount(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "hasDiscount", 1)
return 0
end
function SetColdTownDiscount(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "hasColdDownDiscount", 1)
return 0
end
function action_Trap_Revert(context, evt)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, tonumber(evt.source_name), GadgetState.Default)
return 0
end
function condition_EVENT_GADGET_CREATE(context, evt)
return false
end
function action_EVENT_GADGET_CREATE(context, evt)
return 0
end
function action_EVENT_SELECT_OPTION(context, evt)
if (evt.param2 == 4001) or (evt.param2==4002) then
ScriptLib.PrintContextLog(context, "## TD_LOG : 4001 or 4002 UID:"..context.uid.." CLICKED")
if evt.param2==4001 then
if ScriptLib.GetMechanicusBuildingPoints(context,defs.challange_group_id ,999, context.uid)<40 then
ScriptLib.ShowReminder(context, 400026)
return 0
else
ScriptLib.AddMechanicusBuildingPoints(context, defs.challange_group_id,999, context.uid, -40)
end
elseif evt.param2==4002 then
if ScriptLib.GetMechanicusBuildingPoints(context,defs.challange_group_id ,999, context.uid)<20 then
ScriptLib.ShowReminder(context, 400026)
return 0
else
ScriptLib.AddMechanicusBuildingPoints(context, defs.challange_group_id,999, context.uid, -20)
end
end
ScriptLib.PrintContextLog(context, "## TD_LOG : 4001 or 4002 clicked")
for i=1,#light_bridge do
if light_bridge[i].operator_id==evt.param1 then
ScriptLib.PrintContextLog(context, "## TD_LOG : 4001 or 4002 matched")
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, light_bridge[i].operator_id, GadgetState.GearStart)
if ScriptLib.GetGroupVariableValue(context, "hasColdDownDiscount") ~= 0 then
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, tostring(light_bridge[i].operator_id), defs.timer)
end
if evt.param2 == 4001 then
ScriptLib.DelWorktopOption(context, 4001)
else
ScriptLib.DelWorktopOption(context, 4002)
end
--去除指引特效
ScriptLib.KillEntityByConfigId(context, { config_id = light_bridge[i].effect_id })
--将光桥状态设为Default
for j=1,#light_bridge[i].gadget_id do
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, light_bridge[i].gadget_id[j], GadgetState.Default)
end
ScriptLib.SetGroupVariableValue(context, tostring(light_bridge[i].operator_id).."bridge", 1)
--ScriptLib.CreateGroupTimerEvent(context, defs.group_id, tostring(evt.param1), defs.timer)
end
end
return 0
end
if (evt.param2 == 4003) or (evt.param2==4004) then
ScriptLib.PrintContextLog(context, "## TD_LOG : 4003 or 4004 UID:"..context.uid.." CLICKED")
if evt.param2==4003 then
if ScriptLib.GetMechanicusBuildingPoints(context,defs.challange_group_id ,999, context.uid)<40 then
ScriptLib.ShowReminder(context, 400026)
return 0
else
ScriptLib.AddMechanicusBuildingPoints(context, defs.challange_group_id,999, context.uid, -40)
end
elseif evt.param2==4004 then
if ScriptLib.GetMechanicusBuildingPoints(context,defs.challange_group_id ,999, context.uid)<20 then
ScriptLib.ShowReminder(context, 400026)
return 0
else
ScriptLib.AddMechanicusBuildingPoints(context, defs.challange_group_id,999, context.uid, -20)
end
end
ScriptLib.PrintContextLog(context, "## TD_LOG : 4003 or 4004 clicked")
for i=1,#wind_field do
if wind_field[i].operator_id==evt.param1 then
ScriptLib.PrintContextLog(context, "## TD_LOG : 4003 or 4004 matched")
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, wind_field[i].operator_id, GadgetState.GearStart)
if ScriptLib.GetGroupVariableValue(context, "hasColdDownDiscount") ~= 0 then
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, tostring(wind_field[i].operator_id), defs.timer)
end
if evt.param2 ==4003 then
ScriptLib.DelWorktopOption(context, 4003)
else
ScriptLib.DelWorktopOption(context, 4004)
end
ScriptLib.KillEntityByConfigId(context, { config_id = wind_field[i].effect_id })
--创建风场
for j=1,#wind_field[i].gadget_id do
ScriptLib.CreateGadget(context, { config_id = wind_field[i].gadget_id[j] })
end
ScriptLib.SetGroupVariableValue(context, tostring(wind_field[i].operator_id).."wind", 1)
end
end
return 0
end
return 0
end
function action_EVENT_GROUP_LOAD(context, evt)
LF_Initial_Options(context)
ScriptLib.SetGroupVariableValue(context, "hasDiscount", 0)
return 0
end
LF_Initialize_Trap()
@@ -0,0 +1,32 @@
local extraTriggers={
{ config_id = 8000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 8000002, name = "GENERAL_REWARD_TAKEN", event = EventType.EVENT_GENERAL_REWARD_TAKEN, source = "", condition = "", action = "action_EVENT_GENERAL_REWARD_TAKEN", trigger_count = 0 }
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables, { config_id=50000001,name = "Created", value = 0,no_refresh = true })
end
function action_EVENT_GROUP_LOAD(context, evt)
if ScriptLib.GetGroupVariableValue(context, "Created") == 0 then
for i=1,#gadgets do
if gadgets[i].gadget_id == 70220042 then
ScriptLib.CreateTreasureMapSpotRewardGadget(context, gadgets[i].config_id)
end
end
end
return 0
end
function action_EVENT_GENERAL_REWARD_TAKEN(context, evt)
ScriptLib.SetGroupVariableValue(context, "Created", 1)
return ScriptLib.CreateMonstersFromMonsterPool(context,"盗宝团")
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,36 @@
local tempTrigger = {
{ config_id = 2330001, name = "Challenge_Enter_Region", event = EventType.EVENT_ENTER_REGION, source = "",
condition = "", action = "action_Challenge_Enter_Region", trigger_count = 0},
{ config_id = 2330002, name = "Challenge_LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "",
condition = "", action = "action_Challenge_LEAVE_REGION", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(regions) do
v.radius = 20
end
return 0
end
--------监听函数----------
function action_Challenge_Enter_Region(context, evt)
ScriptLib.SetPlayerEyePoint(context, evt.param1, evt.param1)
return 0
end
function action_Challenge_LEAVE_REGION(context, evt)
ScriptLib.ClearPlayerEyePoint(context, evt.param1)
return 0
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V1_5] ---
@@ -0,0 +1,570 @@
--[[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
local HS_State = {
["Play"] = { name = "HideAndSeek_PlayerState_Play", value = 3 },
["Visible"] = { name = "HideAndSeek_PlayerState_Visible", value = 1 },
["OnMap"] = { name = "HideAndSeek_PlayerState_OnMap", value = 0 },
["Moveable"] = { name = "HideAndSeek_PlayerState_Moveable", value = 1 },
["Transfer"] = { name = "HideAndSeek_PlayerState_Transfer", value = 0 },
["TransferCache"] = { name = "HideAndSeek_PlayerState_TransferCache", value = 0},
["UltraMark"] = { name = "Is_In_UltraMark", value = 0 },
["GlobalSight"] = { name = "Is_In_GlobalSight", value = 0 },
["SuperPrison"] = { name = "Is_In_SuperPrison", value = 0 },
["Rampage"] = { name = "Is_In_Rampage", value = 0 },
["Dead"] = { name = "HideAndSeek_PlayerState_Dead", value = 0},
["Is_Detected"] = { name = "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 map_info = {
--一期
[1001003] = { name = "QingCe", list = {1,2,3} },
[1001001] = { name = "QingQuan", list = {4,5} },
[1001004] = { name = "WuWang", list = {4,8} },
[1001002] = { name = "JiuZhuang", list = {7,8} },
[1001005] = { 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 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)
LF_Bake_Random_Scene(context)
return 0
end
function action_gallery_stop(context, evt)
ScriptLib.PrintContextLog(context, "## H&S_LOG : Gallery Stop")
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
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)
return 0
end
function action_leave_region(context, evt)
if evt.param1 ~= defs.eye_point then
return -1
end
--关闭视野锚点优化
ScriptLib.ClearPlayerEyePoint(context, evt.param1)
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, {})
else
for i=1,3 do
local _uid = ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {})
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)
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)
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, v)
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)
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
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)
--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.SetGroupTempValue(context, "prey_sum", prey_sum, {})
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, {})
--处理能量球计时
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需求进行调整
--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
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()
@@ -0,0 +1,603 @@
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
LF_Handle_Skill(context, skill, v, 0)
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_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)
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 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 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)
--LF_Change_Temp_Value(context, "prey_win_without_skill_"..context.uid, 1)
--统计:正义的加护
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "extra_skill_user", 1)
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
-------------------------------------------
--技能分发管理器
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
--服务器可能在忽悠我,还是要处理hunter进的晚没有初始化的情况,处理完强制结束
LF_Init_Player_State(context, uid)
LF_Set_Player_State_Value(context, uid, HS_State.Play.name, 0)
ScriptLib.SetPlayerGroupVisionType(context, {uid}, {0})
return 0
end
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
--对已经在入场的玩家还原客户端状态
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, 1)
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
--对存活的玩家执行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, "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)
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)
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, 0)
LF_Set_Player_State_Value(context, uid, HS_State.SuperPrison.name, 1)
elseif skill == "HideAndSeek_Out_SuperPrison" then
LF_Set_Player_State_Value(context, uid, HS_State.Moveable.name, 1)
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, 0)
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, 1)
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)
end
return 0
end
function LF_Set_Player_State_Value(context, uid, key, value)
--ScriptLib.PrintContextLog(context, "## H&S_LOG : Set_State_Value : uid = "..uid.." | key = "..key.." | value = "..value)
ScriptLib.SetGroupTempValue(context, key.."_"..uid, value, {})
ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid}, key, value)
end
function LF_Notify_Player_Visible(context, uid)
ScriptLib.PrintContextLog(context, "## H&S_LOG : Modify_On_Map : uid = "..uid)
local list = {}
for i=1,3 do
if uid == ScriptLib.GetGroupTempValue(context, "const_prey_"..i, {}) then
if ScriptLib.GetGroupTempValue(context, HS_State.OnMap.name.."_"..uid, {}) == 1 then
table.insert(list, uid)
break
end
end
end
local _gallery = ScriptLib.GetGroupTempValue(context, "gallery_id", {})
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)
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, 1)
LF_Set_Player_State_Value(context, uid, HS_State.OnMap.name, 0)
LF_Set_Player_State_Value(context, uid, HS_State.Moveable.name, 1)
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
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
-------------------------------------------
@@ -0,0 +1,196 @@
--[[
local defs = {
timer_region = 1,
challenge_region = 2,
monster_hilichurl = 3,
exist_hour = {0,6},
}
--]]
local Tri = {
[1] = { name = "enter_region", config_id = 8000001, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false },
[2] = { name = "leave_region", config_id = 8000002, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0, forbid_guest = false },
[3] = { name = "hilichurl_die", config_id = 8000003, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_hilichurl_die", trigger_count = 0, tag = "950" },
[4] = { name = "time_axis_pass", config_id = 8000004, event = EventType.EVENT_TIME_AXIS_PASS, source = "Loop", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
[5] = { name = "variable_change", config_id = 8000005, event = EventType.EVENT_VARIABLE_CHANGE, source = "hili_die", condition = "", action = "action_variable_change", trigger_count = 0 },
[6] = { name = "set_game_time", config_id = 8000006, event = EventType.EVENT_SET_GAME_TIME, source = "", condition = "", action = "action_set_game_time", trigger_count = 0 },
[7] = { name = "group_load", config_id = 8000007, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
[8] = { name = "group_will_unload", config_id = 8000008, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
[9] = { name = "hp_change", config_id = 8000009, event = EventType.EVENT_SPECIFIC_MONSTER_HP_CHANGE, source = tostring(defs.monster_hilichurl), condition = "", action = "action_hp_change", trigger_count = 0 },
--[10]= { name = "var_print", config_id = 8000010, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_var_print", trigger_count = 0 }
}
local Var = {
[1] = { config_id=50000001,name = "hili_die", value = 0, no_refresh = false }
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables, Var[1])
end
---------------------------------
function action_enter_region(context, evt)
if evt.param1 == defs.challenge_region then
--做一个challenge唯一的保护
if ScriptLib.GetGroupTempValue(context, "in_challenge", {}) == 0 then
local ret = ScriptLib.ActiveChallenge(context, 234, 234, 1, 950, 1, 0)
ScriptLib.PrintContextLog(context, "## Hilichurl : hili challenge ret = "..ret)
ScriptLib.SetGroupTempValue(context, "in_challenge", 1, {})
end
elseif evt.param1 == defs.timer_region then
ScriptLib.InitTimeAxis(context, "Loop", {5}, true)
end
return 0
end
function action_leave_region(context, evt)
if evt.param1 == defs.challenge_region then
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) == 0 then
ScriptLib.SetGroupTempValue(context, "in_challenge", 0, {})
ScriptLib.StopChallenge(context, 234, 0)
end
elseif evt.param1 == defs.timer_region then
ScriptLib.EndTimeAxis(context, "Loop")
end
return 0
end
function action_hilichurl_die(context, evt)
if evt.param1 ~= defs.monster_hilichurl then
return -1
end
ScriptLib.PrintContextLog(context, "## Hilichurl : boss_die_type = "..evt.param2)
--仅大伟丘正常死亡才计数
if evt.param2 == 0 then
ScriptLib.SetGroupTempValue(context, "in_challenge", 0, {})
local ret = ScriptLib.ChangeGroupVariableValue(context, "hili_die", 1)
ScriptLib.PrintContextLog(context, "## Hilichurl : die_count_result = "..ret)
ScriptLib.RemoveExtraGroupSuite(context, 0, 2)
ScriptLib.RemoveExtraGroupSuite(context, 0, 3)
return 0
elseif evt.param2 == 2 then
--大伟丘逃跑的处理
ScriptLib.SetGroupTempValue(context, "Exist", 0, {})
ScriptLib.SetGroupTempValue(context, "in_challenge", 0, {})
ScriptLib.StopChallenge(context, 234, 0)
ScriptLib.RemoveExtraGroupSuite(context, 0, 2)
ScriptLib.RemoveExtraGroupSuite(context, 0, 3)
end
return -1
end
function action_time_axis_pass(context, evt)
local time = ScriptLib.GetGameHour(context)
ScriptLib.PrintContextLog(context, "## Hilichurl : game hour = "..time)
LF_Handle_Monster_Hilichurl(context)
return 0
end
--通过变量通知挑战是否完成
function action_variable_change(context, evt)
if evt.param1 == evt.param2 + 1 then
ScriptLib.FinishFindHilichurlLevel(context)
ScriptLib.EndTimeAxis(context, "Loop")
return 0
end
return -1
end
--调时间后立即做一次判定
function action_set_game_time(context, evt)
LF_Handle_Monster_Hilichurl(context)
return 0
end
function action_group_load(context, evt)
--使用unload做清理,暂时不用load
return 0
end
function action_group_will_unload(context ,evt)
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.MONSTER, defs.monster_hilichurl)
ScriptLib.RemoveExtraGroupSuite(context, 0, 2)
ScriptLib.RemoveExtraGroupSuite(context, 0, 3)
ScriptLib.EndTimeAxis(context, "Loop")
return 0
end
function action_hp_change(context, evt)
if evt.param3 == 0 then
return -1
elseif evt.param3 <= 50 then
if ScriptLib.GetGroupTempValue(context, "hp_50", {}) == 1 then
return -1
end
ScriptLib.ShowReminder(context, 1110236)
ScriptLib.AddExtraGroupSuite(context, 0, 3)
ScriptLib.SetGroupTempValue(context, "hp_50", 1, {})
elseif evt.param3 <= 90 then
if ScriptLib.GetGroupTempValue(context, "hp_90", {}) == 1 then
return -1
end
ScriptLib.ShowReminder(context, 1110236)
ScriptLib.AddExtraGroupSuite(context, 0, 2)
ScriptLib.SetGroupTempValue(context, "hp_90", 1, {})
end
return 0
end
function action_var_print(context, evt)
ScriptLib.PrintContextLog(context, "## Hilichurl : var_change : "..evt.source_name.." "..evt.param2.." -> "..evt.param1)
return 0
end
----------------------------------------------
function LF_Handle_Monster_Hilichurl(context)
local time = ScriptLib.GetGameHour(context)
if defs.exist_hour[2] == 24 then
if time == 0 then
time = 24
end
end
--先校验时间符合区间
if time < defs.exist_hour[1] then
LF_Try_Remove_Hilichurl(context)
return -1
end
--需要处理超出时间是否强制脱战
if time >= defs.exist_hour[2] then
LF_Try_Remove_Hilichurl(context)
return -1
end
LF_Try_Summon_Hilichurl(context)
end
function LF_Try_Remove_Hilichurl(context)
ScriptLib.PrintContextLog(context, "## Hilichurl : Try_Remove_Hilichurl")
--如果怪不存在则简化处理
if 1 ~= ScriptLib.GetGroupTempValue(context, "Exist", {}) then
return 0
end
if 1 ~= ScriptLib.GetMonsterAbilityFloatValue(context, 0, defs.monster_hilichurl, "_IS_IN_BATTLE") then
local ret = ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.MONSTER, defs.monster_hilichurl)
ScriptLib.PrintContextLog(context, "## Hilichurl : Remove Monster Result = "..ret)
ScriptLib.SetGroupTempValue(context, "Exist", 0, {})
end
end
function LF_Try_Summon_Hilichurl(context)
ScriptLib.PrintContextLog(context, "## Hilichurl : Try_Summon_Hilichurl")
if 1 == ScriptLib.GetGroupTempValue(context, "Exist", {}) then
return 0
end
ScriptLib.PrintContextLog(context, "## Hilichurl : Create Monster")
local ret = ScriptLib.CreateMonster(context, {config_id = defs.monster_hilichurl, delay_time = 0})
ScriptLib.PrintContextLog(context, "## Hilichurl : Create Monster Result = "..ret)
if ret == 0 then
ScriptLib.SetGroupTempValue(context, "Exist", 1, {})
ScriptLib.SetGroupTempValue(context, "hp_50", 0, {})
ScriptLib.SetGroupTempValue(context, "hp_90", 0, {})
end
end
----------------------------------------------
Initialize()
@@ -0,0 +1,257 @@
--[[
local defs = {
need_kill_hint = true,
group_id = 144001108, --对应的GroupID
gadget_init = {108013, 108014}, --defs.gadget_init里按顺序填入 开启挑战机关ConfigID、 限时终点ConfigID
challenge_time = 181, --挑战持续的时间
gadget_suites = {
[4] = {108015,108023}, --suites每波需要销毁的指示路点和光柱,结构为[suite_id] = {gadget1,gadget2},id从4开始
[5] = {108017,108024},
[6] = {108019,108025},
},
--怪物死亡时刷新对应的Suites里的纹章,结构为[configid] = suiteid,
suites_heraldry_loot = {
[108075] = 7,
[108077] = 8,
},
gadget_heraldry_count = 15, --收集的激流纹章数量
gadget_heraldry_id = 70350256, --激流纹章ID
suites_chain = {4,5,6,2}, --suite的刷新顺序
}
]]--
local Triggers_Start = {
[1] = { name = "challenge_success", config_id = 9000001, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "",condition = "",action = "action_challenge_success",trigger_count= 0},
[2] = { name = "challenge_fail", config_id = 9000002, event = EventType.EVENT_CHALLENGE_FAIL, source = "",condition = "",action = "action_challenge_fail",trigger_count= 0},
[3] = { name = "select_option", config_id = 9000003, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
[4] = { name = "gadget_create", config_id = 9000004, event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
[5] = { name = "gadget_die_count",config_id = 9000005, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "condition_gadget_die_count", action = "", trigger_count = 0, tag = "888" },
[6] = { name = "any_monster_die", config_id = 9000006, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0 },
[7] = { name = "enter_region_action", config_id = 9000007, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0 },
[8] = { name = "group_will_unload", config_id = 9000008, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0 },
[9] = { name = "group_unload", config_id = 9000009, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
}
local Triggers_Final = {
[1] = { config_id=50000001,name = "enter_final_region",config_id = 9000010, event = EventType.EVENT_ENTER_REGION, source = "", condition = "condition_enter_final_region", action = "", trigger_count = 0, tag = "666" },
}
--挑战机关初始化
function action_gadget_create(context, evt)
-- 设置操作台选项
if defs.gadget_init[1] == evt.param1 then
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, defs.gadget_init[1], {175})
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : create_open_gadget")
end
return 0
end
--机关开启条件及开启处理
function action_select_option(context, evt)
if defs.gadget_init[1] ~= evt.param1 or 175 ~= evt.param2 then
return -1
end
--弹出Reminder提示玩家不处于要求的状态下,状态ID为2代表玩家处于开船状态
if 2 ~= ScriptLib.GetPlayerVehicleType(context,context.uid) then
ScriptLib.ShowReminder(context, 400041)
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : not_in_boat")
return -1
end
if true == ScriptLib.CheckIsInMpMode(context) then
ScriptLib.ShowReminder(context, 400053)
return -1
end
if 0 ~= ScriptLib.GetGroupTempValue(context, "flagHasStarted", {}) then
ScriptLib.ShowReminder(context, 400046)
return -1
end
local boat_groups = {144002049,144001130,144004065,144001127,144004063,144001108}
for k,grp_id in pairs(boat_groups) do
ScriptLib.SetGroupTempValue(context, "flagHasStarted", 1, {group_id = grp_id})
end
-- 新建一个波次的全局变量 从1开始,suites的刷新顺序按suites_chain的顺序刷新
local ret = ScriptLib.SetGroupTempValue(context, "wave", 1, {})
--创建编号为888(该挑战的识别id),挑战内容为127的区域挑战,具体参数填写方式,见DungeonChallengeData表中的注释,所有填写的值都必须是int类型
ScriptLib.CreateFatherChallenge(context, 2011, 2011, defs.challenge_time, {success = 10, fail = 5})
ScriptLib.AttachChildChallenge(context, 2011, 2012, 2012,{0,4, 666,1},{},{success = 10,fail = 5}) --限时到达
ScriptLib.AttachChildChallenge(context, 2011, 2013, 2013,{0,2, 888, defs.gadget_heraldry_count},{},{success = 1,fail = 0}) --收集纹章
if defs.need_kill_hint == true then
local hints = 0
for k,v in pairs(defs.suites_heraldry_loot) do
hints = hints+1
end
ScriptLib.AttachChildChallenge(context, 2011, 2014, 2014,{180, defs.group_id, hints, 0},{},{success = 1,fail = 0}) --收集纹章
end
ScriptLib.StartFatherChallenge(context, 2011)
ScriptLib.SetChallengeEventMark(context, 2011, ChallengeEventMarkType.SUMMER_TIME_SPRINT_BOAT_TIME)
ScriptLib.SetChallengeEventMark(context, 2013, ChallengeEventMarkType.SUMMER_TIME_SPRINT_BOAT_GATHER_POINT)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, defs.gadget_init[1], 175)
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : del_work_options_by_group_configId")
-- 添加suite4的新内容
ScriptLib.AddExtraGroupSuite(context, defs.group_id, defs.suites_chain[1])
--处理关卡6刷怪时会卡住
if defs.group_id == 144002049 then
ScriptLib.AddExtraGroupSuite(context, defs.group_id, 10)
end
-- 将configid为 defs.gadget_init[1] 的物件更改为状态 GadgetState.GearStart
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_init[1], GadgetState.GearStart)
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : set_gadget_state_GearStart")
return 0
end
-- 处理成功
function action_challenge_success(context, evt)
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : success_process_start")
if evt.param1 ~= 2011 then
return -1
end
for i=1,#defs.gadget_init do
ScriptLib.KillEntityByConfigId(context, { config_id = defs.gadget_init[i] })
end
for i= 2, #suites do
ScriptLib.KillExtraGroupSuite(context, defs.group_id, i)
end
local boat_groups = {144002049,144001130,144004065,144001127,144004063,144001108}
for k,grp_id in pairs(boat_groups) do
ScriptLib.SetGroupTempValue(context, "flagHasStarted", 0, {group_id = grp_id})
end
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : success_kill_all_entity")
ScriptLib.RefreshGroup(context, { group_id = defs.group_id, suite = 1 })
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : success_process_end")
return 0
end
-- 处理失败
function action_challenge_fail(context, evt)
if evt.param1 ~= 2011 then
return -1
end
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : fail_process_start")
-- 将本组内变量名为 "hasStarted" 的变量设置为 0
ScriptLib.SetGroupVariableValue(context, "hasStarted", 0)
--标记挑战结束
local boat_groups = {144002049,144001130,144004065,144001127,144004063,144001108}
for k,grp_id in pairs(boat_groups) do
ScriptLib.SetGroupTempValue(context, "flagHasStarted", 0, {group_id = grp_id})
end
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : set_groupVariable")
-- 设置操作台选项
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, defs.gadget_init[1], {175})
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : set_wok_options_by_configid")
for i= 2, #suites do --目前第三组为空,从第四组开始
ScriptLib.RemoveExtraGroupSuite(context, defs.group_id, i)
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : remove_groupsuites")
end
-- 将configid为 defs.gadget_init[1] 的物件更改为状态 GadgetState.Default
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_init[1], GadgetState.Default)
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : set_gadget_state_dafault_to_Starter")
-- 永久关闭CongfigId的Gadget,需要和Groups的RefreshWithBlock标签搭配
ScriptLib.KillEntityByConfigId(context, { config_id = defs.gadget_init[2] })
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : kill_entity_by_configId")
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : fail_process_end")
return 0
end
--统计激流纹章数量,
function condition_gadget_die_count(context, evt)
local death_config_id = evt.param1
if gadgets[death_config_id].gadget_id == defs.gadget_heraldry_id then
return true
end
return false
end
-- 进入最终区域,suite2
function condition_enter_final_region(context, evt)
-- 判断角色数量不少于1
if evt.param1 ~= suites[2].regions[1] then
return false
end
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
return false
end
return true
end
-- 进入每个Suite触发区域时移除终点指示器并刷新下一个Suite,移除上一个Suite
function action_enter_region(context, evt)
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : EnterRegionToNext")
local wave = ScriptLib.GetGroupTempValue(context, "wave", {})
if wave > #defs.suites_chain then --防止访问不存在的wave
return -1
end
local suite_seq = defs.suites_chain[wave]
-- 判断角色数量不少于1
if evt.param1 ~= suites[suite_seq].regions[1] then
return -1
end
if ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
return -1
end
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : Enter"..suite_seq)
-- 关闭该Suite中的提示光柱和路点
if wave < #defs.suites_chain then
ScriptLib.KillEntityByConfigId(context, { config_id = defs.gadget_suites[suite_seq][1] })
ScriptLib.KillEntityByConfigId(context, { config_id = defs.gadget_suites[suite_seq][2] })
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : Kill Tip Gadgets when enter and this wave is"..suite_seq)
end
if wave == 1 then
ScriptLib.AddExtraGroupSuite(context, defs.group_id, defs.suites_chain[wave+1])
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : Refresh_Next_Group"..(defs.suites_chain[wave+1]))
elseif wave == #defs.suites_chain then
ScriptLib.RemoveExtraGroupSuite(context, defs.group_id, defs.suites_chain[wave-1])
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : Remove_last_Group"..(defs.suites_chain[wave-1]))
elseif wave > 1 and wave < #defs.suites_chain then
ScriptLib.AddExtraGroupSuite(context, defs.group_id, defs.suites_chain[wave+1])
ScriptLib.RemoveExtraGroupSuite(context, defs.group_id, defs.suites_chain[wave-1])
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : Refresh_Next_Group_And_Remove_last_Group"..(defs.suites_chain[wave]))
end
ScriptLib.SetGroupTempValue(context, "wave", wave+1, {})
return 0
end
--根据死亡的怪物对应刷新含有纹章的Suite
function action_any_monster_die(context, evt)
if defs.suites_heraldry_loot[evt.param1] == nil then
return -1
else
ScriptLib.AddExtraGroupSuite(context, defs.group_id, defs.suites_heraldry_loot[evt.param1])
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : Kill_Monster_And_Add_heraldry")
end
return 0
end
--处理Group重新加载时操作台的问题
function action_group_load( context,evt )
ScriptLib.RefreshGroup(context, { group_id = defs.group_id, suite = 1 })
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, defs.gadget_init[1], {175})
return 0
end
--处理Group未正确卸载的情况
function action_group_will_unload( context,evt )
local boat_groups = {144002049,144001130,144004065,144001127,144004063,144001108}
for k,grp_id in pairs(boat_groups) do
ScriptLib.SetGroupTempValue(context, "flagHasStarted", 0, {group_id = grp_id})
end
return 0
end
--给每个suite塞触发器
function Initialize()
for k,v in pairs(Triggers_Start) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(triggers, Triggers_Final[1])
table.insert(suites[2].triggers, Triggers_Final[1].name)
return 0
end
Initialize()
@@ -0,0 +1,52 @@
-- local extrTriggers = {
-- initialtrigger = {
-- --["General_Die"] = { config_id = 8000001, name = "General_Die", event= EventType.EVENT_MONSTER_BATTLE, source = "", condition = "", action = "action_whern_general_inbattle", trigger_count = 0 },
-- }
-- }
-- function HitByShadow( context )
-- ScriptLib.AddExhibitionReplaceableData(context, context.uid, "GeneralBattle_HitByShadow", 1)
-- return 0
-- end
-- function HitByDoubleAttack( context )
-- ScriptLib.AddExhibitionReplaceableData(context, context.uid, "GeneralBattle_HitByDoubleAttack", 1)
-- return 0
-- end
-- function ExecuteInTuant( context )
-- local UidList = ScriptLib.GetSceneUidList(context)
-- for i,v in ipairs(UidList) do
-- ScriptLib.AddExhibitionReplaceableData(context, v, "GeneralBattle_ExecuteInTaunt", 1)
-- end
-- return 0
-- end
-- function action_whern_general_inbattle( context, evt )
-- if evt.param1 ~= MonsterID then
-- return 0
-- end
-- local UidList = ScriptLib.GetSceneUidList(context)
-- for i,v in ipairs(UidList) do
-- ScriptLib.AddExhibitionReplaceableData(context, v, "GeneralBattle_HitByShadow", 0)
-- ScriptLib.AddExhibitionReplaceableData(context, v, "GeneralBattle_HitByDoubleAttack", 0)
-- end
-- return 0
-- end
-- function LF_Initialize_Group(triggers, suites)
-- for k,v in pairs(extrTriggers.initialtrigger) do
-- table.insert(triggers, v)
-- table.insert(suites[init_config.suite].triggers, v.name)
-- end
-- return 0
-- end
--LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,100 @@
--[[
local defs = {
group_id = xxx,
tide_sum = 25,
tide_max = 8,
tide_min = 8
}
--suites[2]为monsterTide
--suites[3]为装饰gadget
--]]
local Tri = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
[2] = { name = "group_refresh", config_id = 8000002, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0 },
[3] = { name = "any_monster_die", config_id = 8000003, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0 },
[4] = { name = "blossom_progress_finish", config_id = 8000004, event = EventType.EVENT_BLOSSOM_PROGRESS_FINISH, source = "", condition = "", action = "action_blossom_progress_finish", trigger_count = 0}
}
local Var = {
[1] = { config_id=50000001,name = "in_battle", value = 0, no_refresh = true },
[2] = { config_id=50000002,name = "BombTypeA", value = 0, no_refresh = false },
[3] = { config_id=50000003,name = "BombTypeB", value = 0, no_refresh = false },
[4] = { config_id=50000004,name = "BombTypeC", value = 0, no_refresh = false },
[5] = { config_id=50000005,name = "wave", value = 0, no_refresh = false }
}
local Reg = {
[1] = { config_id = 7000001, shape = RegionShape.SPHERE, radius = 40, pos = points[1].pos, area_id = monsters[1].area_id, ability_group_list = {"ActivityAbility_LudiHarpastum_Bomb_Mark"} }
}
------------------------------
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(Var) do
table.insert(variables, v)
end
for k,v in pairs(Reg) do
table.insert(regions, v)
table.insert(suites[1].regions, v.config_id)
end
end
-------------------------------
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "## KeleeBomb : action_group_load")
ScriptLib.AddExtraGroupSuite(context, 0, 3)
if 0 == ScriptLib.GetGroupVariableValue(context, "in_battle") then
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 1, exclude_prev = true, is_delay_unload = true })
end
return 0
end
function action_group_refresh(context, evt)
ScriptLib.PrintContextLog(context, "## KeleeBomb : action_group_refresh")
LF_Group_Init(context)
return 0
end
function action_any_monster_die(context, evt)
ScriptLib.PrintContextLog(context, "## KeleeBomb : monster_die : source = "..evt.source_name)
if evt.source_name == "ActivityAbility_LudiHarpastumGadgetSkill_BombTypeA" then
ScriptLib.ChangeGroupVariableValue(context, "BombTypeA", 1)
elseif evt.source_name == "ActivityAbility_LudiHarpastumGadgetSkill_BombTypeB" then
ScriptLib.ChangeGroupVariableValue(context, "BombTypeB", 1)
elseif evt.source_name == "ActivityAbility_LudiHarpastumGadgetSkill_BombTypeC" then
ScriptLib.ChangeGroupVariableValue(context, "BombTypeC", 1)
end
ScriptLib.AddBlossomScheduleProgressByGroupId(context, defs.group_id)
if 0 == ScriptLib.GetGroupMonsterCount(context) then
local _wave = ScriptLib.GetGroupVariableValue(context, "wave")
if _wave+4 <= #suites then
ScriptLib.ShowReminderRadius(context, 400004, points[1].pos, 40)
ScriptLib.AddExtraGroupSuite(context, 0, _wave+4)
ScriptLib.ChangeGroupVariableValue(context, "wave", 1)
end
end
return 0
end
function action_blossom_progress_finish(context, evt)
ScriptLib.PrintContextLog(context, "## KeleeBomb : blossom_finish")
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.REGION, 70000001)
ScriptLib.SetGroupVariableValue(context, "in_battle", 0)
ScriptLib.SetGroupVariableValue(context, "wave", 0)
ScriptLib.SetBlossomScheduleStateByGroupId(context, defs.group_id, 3)
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 1, exclude_prev = true, is_delay_unload = true })
return 0
end
------------------------------
function LF_Group_Init(context)
ScriptLib.PrintContextLog(context, "## KeleeBomb : group_init")
ScriptLib.SetBlossomScheduleStateByGroupId(context, defs.group_id, 2)
ScriptLib.AddExtraGroupSuite(context, 0, 3)
ScriptLib.SetGroupVariableValue(context, "in_battle", 1)
ScriptLib.SetGroupVariableValue(context, "wave", 1)
ScriptLib.AddExtraGroupSuite(context, 0, 4)
end
------------------------------
Initialize()
@@ -0,0 +1,731 @@
local GroupID = 144003005
local smallRegion = 5039
local bigRegion = 5040
--自定义函数部分
local extrTriggers = {
initialtrigger = {
["Start_Gallery"] = { config_id = 8000001, name = "Start_Gallery", event= EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_whern_gallery_start", trigger_count = 0 },
["MultiStage_End"] = { config_id = 8000002, name = "MultiStage_End", event= EventType.EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END, source = "", condition = "", action = "action_multistage_end", trigger_count = 0 },
["Shooter_Die"] = { config_id = 8000003, name = "Shooter_Die", event= EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_whern_shooter_die", trigger_count = 0 },
["Group_Ready"] = { config_id = 8000004, name = "Group_Ready", event= EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_ready", trigger_count = 0 },
["MultiStage_Start"] = { config_id = 8000005, name = "MultiStage_Start", event= EventType.EVENT_SCENE_MULTISTAGE_PLAY_STAGE_START, source = "", condition = "", action = "action_multistage_start", trigger_count = 0 },
--["GadgetSate_Change"] = { config_id = 8000006, name = "GadgetSate_Change", event= EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadgetstate_change", trigger_count = 0 },
["Gallery_Stop"] = { config_id = 8000007, name = "Gallery_Stop", event= EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_whern_gallery_stop", trigger_count = 0 },
["Random_Buff"] = { config_id = 8000008, name = "Random_Buff", event= EventType.EVENT_TIME_AXIS_PASS, source = "randombuff", condition = "", action = "action_timeaxis_randombuff", trigger_count = 0 },
["Shooter_Reborn"] = { config_id = 8000009, name = "Shooter_Reborn", event= EventType.EVENT_TIMER_EVENT, source = "shooterreborn", condition = "", action = "action_timer_shooterreborn", trigger_count = 0 },
["Group_Unload"] = {name = "Group_Unload", config_id = 8000010, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
["Small_Region"] = { config_id = 9000001, name = "Small_Region", event= EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "player_in_optimizationRegion", trigger_count = 0, forbid_guest = false },
["Big_Region"] = { config_id = 9000002, name = "Big_Region", event= EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "player_leave_optimizationRegion", trigger_count = 0, forbid_guest = false }
}
}
local extrSuites = {
{
monsters = { },
gadgets = { },
regions = {smallRegion, bigRegion },
triggers = { "Small_Region","Big_Region"},
rand_weight = 100
}
}
function FeverStart( context )
ScriptLib.PrintContextLog(context, "##BD LOG : Fever Start")
-- Fever状态开始
ScriptLib.SetGroupTempValue(context, "ISFEVERSTAGE", 1, {})
ScriptLib.EndSceneMultiStagePlayStage(context, 1, "NormalRound", true)
return 0
end
function FeverEnd( context )
ScriptLib.PrintContextLog(context, "##BD LOG : Fever End")
-- Fever状态结束
ScriptLib.EndSceneMultiStagePlayStage(context, 1, "FeverRound", true)
return 0
end
function GetRandomType(context, randomList, isFerver)
local MaxNum = #randomList
local CurStage = ScriptLib.GetGroupTempValue(context, "StageCount", {})
math.randomseed(ScriptLib.GetServerTime(context))
if CurStage > MaxNum then
CurStage = MaxNum
end
return randomList[CurStage][math.random(#randomList[CurStage])]
end
function CurveBallCount( context )
-- 曲线球计数
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."CurveBallCount ++")
ScriptLib.AddExhibitionAccumulableData(context, context.uid, "Activity_BD_CurveCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 1)
return 0
end
function IceBallCount( context )
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."IceBallCount ++")
-- 冰冻球计数
ScriptLib.AddExhibitionAccumulableData(context, context.uid, "Activity_BD_IceCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 1)
return 0
end
function SpeedBallCount( context )
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."SpeedBallCount ++")
-- 高速球计数
ScriptLib.AddExhibitionAccumulableData(context, context.uid, "Activity_BD_SpeedCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 1)
--高速球翻牌子计数
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_BD_SpeedValue", 1)
return 0
end
function SoilBallCount( context )
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."SoilBallCount ++")
-- 岩土球计数
ScriptLib.AddExhibitionAccumulableData(context, context.uid, "Activity_BD_SoilCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 1)
return 0
end
function TimeLimitedShieldDieCount( context )
-- 限时内护盾被击破翻牌子计数
local UidList = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(UidList) do
ScriptLib.AddExhibitionReplaceableData(context, v, "Activity_BD_ShieldDestroy", 1)
end
return 0
end
function ShieldDieCount( context)
-- 护盾击破计数
local UidList = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(UidList) do
ScriptLib.PrintContextLog(context, "##BD LOG : ShieldDieCount +1 for uid"..v)
ScriptLib.AddExhibitionAccumulableData(context, v, "Activity_BD_ShieldDieCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 1)
end
return 0
end
function AutoReturnCount( context )
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."AutoReturnCount ++")
-- 自动回球计数
ScriptLib.AddExhibitionAccumulableData(context, context.uid, "Activity_BD_AutoReturnCount", 1)
return 0
end
function GoldPAPACount( context )
-- 黄金球拍计数
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
ScriptLib.UpdatePlayerGalleryScore(context, GalleryIDList[GalleryStage], {["catch_gadget_id"] = 70350257 ,["add_score"] = 0, ["add_destroyed_machine_count"] = 0, ["add_damage"] = 0,["add_normal_hit_count"] = 0,["add_perfect_hit_count"] = 0, ["add_fever_count"] = 0} )
return 0
end
function PepperBuffCount( context )
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."PepperBuffCount ++")
-- 绝云辣椒计数
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
ScriptLib.UpdatePlayerGalleryScore(context, GalleryIDList[GalleryStage], {["catch_gadget_id"] = 70350252 ,["add_score"] = 0, ["add_destroyed_machine_count"] = 0, ["add_damage"] = 0,["add_normal_hit_count"] = 0,["add_perfect_hit_count"] = 0, ["add_fever_count"] = 0} )
ScriptLib.AddExhibitionAccumulableData(context, context.uid, "Activity_BD_PepperCount", 1)
return 0
end
function SpeedBuffCount( context )
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."SpeedBuffCount ++")
-- 黄金鞋计数
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
ScriptLib.UpdatePlayerGalleryScore(context, GalleryIDList[GalleryStage], {["catch_gadget_id"] = 70350248 ,["add_score"] = 0, ["add_destroyed_machine_count"] = 0, ["add_damage"] = 0,["add_normal_hit_count"] = 0,["add_perfect_hit_count"] = 0, ["add_fever_count"] = 0} )
ScriptLib.AddExhibitionAccumulableData(context, context.uid, "Activity_BD_ShoesCount", 1)
return 0
end
function BeingForzen( context )
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."BeingForzen ++")
-- 冻结计数
ScriptLib.SetGroupTempValue(context, "NoFrozenCount"..context.uid, 1, {})
return 0
end
function BeingDirty( context )
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."BeingDirty ++")
-- 脏脏球计数
ScriptLib.SetGroupTempValue(context, "NoDirtyCount"..context.uid, 1, {})
return 0
end
function HitByBall( context )
ScriptLib.PrintContextLog(context, "##BD LOG : player "..context.uid.."HitByBall ++")
-- 被球命中翻牌子计数
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_BD_NoSufferHit", 1)
return 0
end
function AddScore( context, damage, isPerfect, ballType )
-- 计算分数
ScriptLib.PrintContextLog(context, "##BD LOG : Score Damage == "..damage.." UID == "..context.uid)
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
if isPerfect == 1 then
ScriptLib.PrintContextLog(context, "##BD LOG : updatePlayerScore PERFECT BALL")
--完美球翻牌子计数
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_BD_PerfectValue", 1)
--完美球陈列室累计计数
ScriptLib.AddExhibitionAccumulableData(context, context.uid, "Activity_BD_PerfectCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 1)
--伤害翻牌子计数
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_BD_DamageValue", -1*damage)
--伤害实时显示
ScriptLib.UpdatePlayerGalleryScore(context, GalleryIDList[GalleryStage], {["add_score"] = -1*damage*PerDamageScore, ["add_destroyed_machine_count"] = 0, ["add_damage"] = -1*damage,["add_normal_hit_count"] = 0,["add_perfect_hit_count"] = 1, ["add_fever_count"] = 0} )
else
ScriptLib.PrintContextLog(context, "##BD LOG : updatePlayerScore NORMAL BALL ")
--伤害翻牌子计数
ScriptLib.AddExhibitionReplaceableData(context, context.uid, "Activity_BD_DamageValue", -1*damage)
--伤害实时显示
ScriptLib.UpdatePlayerGalleryScore(context, GalleryIDList[GalleryStage], {["add_score"] = -1*damage*PerDamageScore, ["add_destroyed_machine_count"] = 0, ["add_damage"] = -1*damage,["add_normal_hit_count"] = 1,["add_perfect_hit_count"] = 0, ["add_fever_count"] = 0} )
end
return 0
end
function SetGadgetStateByGalleryStage(context)
local Stage = ScriptLib.GetGroupTempValue(context, "GalleryStage", {})
ScriptLib.SetGroupGadgetStateByConfigId(context, GroupID, ShooterConfigID, 200+Stage)
return 0
end
--自定义函数部分结束
--evt调用部分
function player_leave_optimizationRegion( context, evt )
ScriptLib.PrintContextLog(context, "##BD LOG : optimization Stop~~~~~ regionID == "..evt.param1)
if evt.param1 ~= bigRegion then
return 0
end
--优化结束
ScriptLib.PrintContextLog(context, "##BD LOG : optimization Stop!!!!!!!! uid == "..context.uid)
ScriptLib.ClearPlayerEyePoint(context, smallRegion)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
ScriptLib.SetLimitOptimization(context, context.uid, false)
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 0, { group_id = 144002077})
return 0
end
function player_in_optimizationRegion( context, evt )
if evt.param1 ~= smallRegion then
return 0
end
ScriptLib.PrintContextLog(context, "##BD LOG : optimization Start uid == "..context.uid)
--优化部分
ScriptLib.SetPlayerEyePoint(context, smallRegion, bigRegion)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
ScriptLib.SetLimitOptimization(context, context.uid, true)
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 1, { group_id = 144002077})
return 0
end
function action_group_will_unload( context, evt )
--优化suite卸载
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
if GalleryStage == 0 then
return 0
end
ScriptLib.PrintContextLog(context, "##BD LOG : GroupWillUnLoad gallerStage == "..GalleryStage)
ScriptLib.PrintContextLog(context, "##BD LOG : GroupWillUnLoad gallerID == "..GalleryIDList[GalleryStage])
ScriptLib.StopGallery(context, GalleryIDList[GalleryStage], false)
ScriptLib.RemoveEntityByConfigId(context, GroupID, EntityType.REGION, bigRegion)
return 0
end
function action_gadgetstate_change(context,evt )
-- ScriptLib.PrintContextLog(context, "##BD LOG : GadgetState Change")
-- if evt.param2 ~= TextEnterConfigID then
-- return 0
-- end
-- if evt.param1 == 203 then
-- ScriptLib.PrintContextLog(context, "##BD LOG : GadgetState Change GameStart")
-- ScriptLib.StartGallery(context, GalleryID)
-- elseif evt.param1 == 204 then
-- local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
-- ScriptLib.StopGallery(context, GalleryIDList[GalleryStage], false)
-- end
return 0
end
function action_timeaxis_randombuff( context, evt )
math.randomseed(ScriptLib.GetServerTime(context))
local MaxNum = 0
local CurBuffList = 0
if ScriptLib.GetGroupTempValue(context, "GalleryStage", {})==1 then
CurBuffList = BUffList
elseif ScriptLib.GetGroupTempValue(context, "GalleryStage", {})==2 then
CurBuffList = BUffList2
else
CurBuffList = BUffList3
end
for i,v in ipairs(CurBuffList) do
MaxNum = MaxNum + v.buffWeight
end
local randomWeight = math.random(MaxNum)
local CurBuffConfigID = 0
for i,v in ipairs(CurBuffList) do
if v.buffWeight >= randomWeight then
CurBuffConfigID = v.buffConfigID
break
else
randomWeight = randomWeight - v.buffWeight
end
end
local regionPos = regions[BuffRegionID].pos
local regionSize = regions[BuffRegionID].size
ScriptLib.PrintContextLog(context, "##BD simple pos.x = "..regions[BuffRegionID].pos.x.." Size.x = "..regions[BuffRegionID].size.x)
local pos_table = { x = math.random(math.ceil(regionPos.x - (regionSize.x/2)), math.ceil(regionPos.x + (regionSize.x/2))),
y = regionPos.y,
z = math.random(math.ceil(regionPos.z - (regionSize.z/2)), math.ceil(regionPos.z + (regionSize.z/2)))
}
ScriptLib.PrintContextLog(context, "##BD BUFF CONFIGID = "..CurBuffConfigID)
ScriptLib.CreateGadgetByConfigIdByPos(context, CurBuffConfigID, pos_table, {x=0,y=0,z=0})
return 0
end
function action_group_ready( context, evt )
ScriptLib.PrintContextLog(context, "##BD LOG : Group Load")
return 0
end
function action_whern_gallery_start(context, evt )
local UidList = ScriptLib.GetSceneUidList(context)
--加载岩创杀手
ScriptLib.CreateGadget(context, { config_id = 5030 })
ScriptLib.CreateGadget(context, { config_id = 5037 })
ScriptLib.SetGroupTempValue(context, "GalleryID", evt.param1, {})
--取出当前的阶段
for i,v in ipairs(GalleryIDList) do
if v == evt.param1 then
ScriptLib.SetGroupTempValue(context, "GalleryStage", i, {})
break
end
end
--初始化冰冻、岩土计数
for i,v in ipairs(UidList) do
ScriptLib.SetGroupTempValue(context, "NoFrozenCount"..v, 0, {})
ScriptLib.SetGroupTempValue(context, "NoDirtyCount"..v, 0, {})
ScriptLib.AddExhibitionReplaceableData(context, v, "Activity_BD_NoFrozenCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 0)
ScriptLib.AddExhibitionReplaceableData(context, v, "Activity_BD_NoDirtyCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 0)
end
--优化suite开启
ScriptLib.AddExtraGroupSuite(context, GroupID, #suites)
ScriptLib.SetGroupTempValue(context, "ShooterAlive", 1, {})
ScriptLib.SetGroupTempValue(context, "GalleryOn", 1, {})
math.randomseed(ScriptLib.GetServerTime(context))
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
if evt.param1 ~= GalleryIDList[GalleryStage] then
return 0
end
ScriptLib.SetGroupTempValue(context, "StageCount", 1, {})
ScriptLib.SetGroupTempValue(context, "FeverCount", 0, {})
--初始化BUFF时间轴
ScriptLib.InitTimeAxis(context, "randombuff", RandomBuffTimeAxis[math.random(#RandomBuffTimeAxis)], true)
ScriptLib.SetGroupTempValue(context, "PlayerNum", #UidList, {})
-- 创建一个发射器
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
if ScriptLib.GetGroupTempValue(context, "PlayerNum", {}) == 1 then
ScriptLib.SetGroupTempValue(context, "RandomType", GetRandomType(context, NormalRandomList[GalleryStage], false),{})
ScriptLib.SetGroupTempValue(context, "FeverRandomType", GetRandomType(context, FeverRandomList[GalleryStage], true),{})
else
ScriptLib.SetGroupTempValue(context, "RandomType", GetRandomType(context, NormalRandomList2[GalleryStage], false),{})
ScriptLib.SetGroupTempValue(context, "FeverRandomType", GetRandomType(context, FeverRandomList2[GalleryStage], true),{})
end
--ScriptLib.CreateGadgetWithGlobalValue(context, ShooterConfigID, { ["SGV_BDShootType"]= RandomType})
ScriptLib.SetEntityServerGlobalValueByConfigId(context, ShooterConfigID, "SGV_BDShootType", ScriptLib.GetGroupTempValue(context, "RandomType",{}))
SetGadgetStateByGalleryStage(context)
-- 初始化一个多阶段玩法
ScriptLib.InitSceneMultistagePlay(context, 1, MultistagePlayType.BounceConjuring, {}, UidList)
ScriptLib.SetGroupTempValue(context, "ISFEVERSTAGE", 0, {})
--启动一个8秒时间的等待阶段
ScriptLib.StartSceneMultiStagePlayStage(context, 1, 8, Multistage.Idle, "WaitRound",{})
return 0
end
function action_whern_gallery_stop( context,evt )
ScriptLib.SetGroupTempValue(context, "GalleryOn", 0, {})
local UidList = ScriptLib.GetSceneUidList(context)
local FeverCount = ScriptLib.GetGroupTempValue(context, "FeverCount", {})
--游戏时间结束
if evt.param3 == 1 then
ScriptLib.PrintContextLog(context, "##BD LOG : TimeoUT Stop")
for i,v in ipairs(UidList) do
if ScriptLib.GetGroupTempValue(context, "NoFrozenCount"..v, {}) == 0 then
--设置每个玩家的冰冻球次数
ScriptLib.PrintContextLog(context, "##BD LOG : TimeoUT SET FROZENNUM")
ScriptLib.AddExhibitionReplaceableData(context, v, "Activity_BD_NoFrozenCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 1 )
end
if ScriptLib.GetGroupTempValue(context, "NoDirtyCount"..v, {}) == 0 then
--设置每个玩家的脏脏球次数
ScriptLib.AddExhibitionReplaceableData(context, v, "Activity_BD_NoDirtyCount"..ScriptLib.GetGroupTempValue(context, "GalleryID", {}), 1 )
end
end
end
--移除岩创杀手
ScriptLib.RemoveEntityByConfigId(context, GroupID, EntityType.GADGET, 5030)
ScriptLib.RemoveEntityByConfigId(context, GroupID, EntityType.GADGET, 5037)
--移除多余的BUFF
for i,v in ipairs(BUffList) do
ScriptLib.RemoveEntityByConfigId(context, GroupID, EntityType.GADGET, v.buffConfigID)
end
--优化suite卸载
ScriptLib.RemoveEntityByConfigId(context, GroupID, EntityType.REGION, bigRegion)
ScriptLib.EndSceneMultiStagePlay(context, 1, true)
ScriptLib.EndTimeAxis(context, "randombuff")
ScriptLib.EndTimeAxis(context, "shooterreborn")
local UidList = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(UidList) do
--设置本局Fever次数
ScriptLib.AddExhibitionReplaceableData(context, v, "Activity_BD_FeverCount", FeverCount)
end
ScriptLib.RefreshGroup(context, { group_id = GroupID, suite = 1 })
ScriptLib.SetEntityServerGlobalValueByConfigId(context, ShooterConfigID, "SGV_BDShootType", 0)
-- if ScriptLib.GetGroupTempValue(context, "ShooterAlive", {})==1 then
-- ScriptLib.SetEntityServerGlobalValueByConfigId(context, ShooterConfigID, "SGV_BDShootType", 0)
-- ScriptLib.SetGroupGadgetStateByConfigId(context, GroupID, ShooterConfigID, 0)
-- else
-- ScriptLib.CreateGadgetWithGlobalValue(context, ShooterConfigID, { ["SGV_BDShootType"]= 0})
-- end
return 0
end
function action_multistage_start(context, evt )
-- 阶段开始,设置gadgetSGV
ScriptLib.PrintContextLog(context, "##BD LOG : MultiStage Start")
local UidList = ScriptLib.GetSceneUidList(context)
math.randomseed(ScriptLib.GetServerTime(context))
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
if evt.source_name == "NormalRound" then
--从基础库里挑一个随机
ScriptLib.SetEntityServerGlobalValueByConfigId(context, ShooterConfigID, "SGV_BDShootType", ScriptLib.GetGroupTempValue(context, "RandomType",{}))
ScriptLib.PrintContextLog(context, "##BD LOG : Nromal RandomType == "..ScriptLib.GetGroupTempValue(context, "RandomType",{}))
elseif evt.source_name == "FeverRound" then
--进入Fever次数翻牌子计数
for i,v in ipairs(UidList) do
ScriptLib.PrintContextLog(context, "##BD LOG : Feverount +1 for uid"..v)
ScriptLib.AddExhibitionReplaceableData(context, v, "Activity_BD_FeverValue", 1)
end
--从Fever库里挑一个随机
local UidList = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(UidList) do
ScriptLib.PrintContextLog(context, "##BD LOG : updatePlayerScore Fever ")
ScriptLib.UpdatePlayerGalleryScore(context, GalleryIDList[GalleryStage], {["add_score"] = 0, ["add_destroyed_machine_count"] = 0, ["add_damage"] = 0,["add_normal_hit_count"] = 0,["add_perfect_hit_count"] = 0, ["add_fever_count"] = 1,["uid"] = v} )
end
ScriptLib.ChangeGroupTempValue(context, "FeverCount", 1, {})
ScriptLib.SetEntityServerGlobalValueByConfigId(context, ShooterConfigID, "SGV_BDShootType", ScriptLib.GetGroupTempValue(context, "FeverRandomType",{}))
ScriptLib.PrintContextLog(context, "##BD LOG : Fever RandomType == "..ScriptLib.GetGroupTempValue(context, "FeverRandomType",{}))
end
return 0
end
function action_multistage_end(context, evt )
if ScriptLib.GetGroupTempValue(context, "GalleryOn", {}) ~= 1 then
return 0
end
-- 结束一个阶段后开启下一个阶段
if evt.source_name == "FeverRound" then
ScriptLib.SetGroupTempValue(context, "ISFEVERSTAGE", 0, {})
end
if ScriptLib.GetGroupTempValue(context, "ISFEVERSTAGE", {})==0 then
ScriptLib.PrintContextLog(context, "##BD LOG : Start Normal Round")
ScriptLib.StartSceneMultiStagePlayStage(context, 1, 0, Multistage.Idle, "NormalRound",{})
else
ScriptLib.PrintContextLog(context, "##BD LOG : Start Fever Round")
ScriptLib.StartSceneMultiStagePlayStage(context, 1, 0, Multistage.Idle, "FeverRound",{})
end
return 0
end
function action_whern_shooter_die(context, evt )
if evt.param1 ~= ShooterConfigID then
return 0
end
ScriptLib.SetGroupTempValue(context, "ShooterAlive", 0, {})
local UidList = ScriptLib.GetSceneUidList(context)
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
for i,v in ipairs(UidList) do
ScriptLib.PrintContextLog(context, "##BD LOG : add_destroyed_machine_count")
ScriptLib.AddExhibitionAccumulableData(context, v, "Activity_BD_ShooterDieCount", 1)
ScriptLib.UpdatePlayerGalleryScore(context, GalleryIDList[GalleryStage], {["add_score"] = 0, ["add_destroyed_machine_count"] = 1, ["add_damage"] = 0,["add_normal_hit_count"] = 0,["add_perfect_hit_count"] = 0, ["add_fever_count"] = 0,["uid"] = v} )
end
ScriptLib.PrintContextLog(context, "##BD LOG : ShooterDie Uid == "..UidList[1])
ScriptLib.UpdatePlayerGalleryScore(context, GalleryIDList[GalleryStage], {["add_score"] = PerShooterScore, ["add_destroyed_machine_count"] = 0, ["add_damage"] = 0,["add_normal_hit_count"] = 0,["add_perfect_hit_count"] = 0, ["add_fever_count"] = 0, ["uid"] = UidList[1] } )
ScriptLib.ChangeGroupTempValue(context, "StageCount", 1, {})
ScriptLib.PrintContextLog(context, "##BD LOG : Shooter Die Stage Change")
-- 前一个gadget被打死,立刻切阶段
if ScriptLib.GetGroupTempValue(context, "ISFEVERSTAGE", {})==0 then
ScriptLib.EndSceneMultiStagePlayStage(context, 1, "NormalRound", true)
else
ScriptLib.EndSceneMultiStagePlayStage(context, 1, "FeverRound", true)
--Fever期间内装置摧毁翻牌子计数
for i,v in ipairs(UidList) do
ScriptLib.PrintContextLog(context, "##BD LOG : FeverShooterDieCount +1 for uid"..v)
ScriptLib.AddExhibitionReplaceableData(context, v, "Activity_BD_FeverDestroy", 1)
end
end
-- 延时创建一个新的发射器
ScriptLib.CreateGroupTimerEvent(context, GroupID, "shooterreborn", 1.5)
return 0
end
function action_timer_shooterreborn(context, evt)
ScriptLib.SetGroupTempValue(context, "ShooterAlive", 1, {})
local GalleryStage = ScriptLib.GetGroupTempValue(context, "GalleryStage",{})
if ScriptLib.GetGroupTempValue(context, "PlayerNum", {}) == 1 then
ScriptLib.SetGroupTempValue(context, "RandomType", GetRandomType(context, NormalRandomList[GalleryStage], false),{})
ScriptLib.SetGroupTempValue(context, "FeverRandomType", GetRandomType(context, FeverRandomList[GalleryStage], true),{})
else
ScriptLib.SetGroupTempValue(context, "RandomType", GetRandomType(context, NormalRandomList2[GalleryStage], false),{})
ScriptLib.SetGroupTempValue(context, "FeverRandomType", GetRandomType(context, FeverRandomList2[GalleryStage], true),{})
end
if ScriptLib.GetGroupTempValue(context, "GalleryOn", {}) == 1 then
ScriptLib.PrintContextLog(context, "##BD LOG : Die Change RandomType == "..ScriptLib.GetGroupTempValue(context, "RandomType",{}))
ScriptLib.CreateGadgetWithGlobalValue(context, ShooterConfigID, { ["SGV_BDShootType"]= ScriptLib.GetGroupTempValue(context, "RandomType",{})})
SetGadgetStateByGalleryStage(context)
else
ScriptLib.PrintContextLog(context, "##BD LOG : Die Change RandomType But GalleryStop")
ScriptLib.CreateGadgetWithGlobalValue(context, ShooterConfigID, { ["SGV_BDShootType"]= 0 })
end
return 0
end
function LF_Initialize_Group(triggers, suites)
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
for i,v in ipairs(extrSuites) do
table.insert(suites, v)
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,261 @@
--[[
local defs = {
monster_boss = xxx,
summon_region_list = {1,2,3}, --region出怪的list
summon_interval = 15, --自动出怪时间
gadget_operator_list = {1,2,3....9} --9个锚点
}
--]]
local Tri = {
{ name = "variable_change", config_id = 8000001, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", trigger_count = 0 },
{ name = "time_axis_pass", config_id = 8000002, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
{ name = "any_monster_die", config_id = 8000003, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0 },
}
local other_Tri = {
[1] = { name = "enter_region", config_id = 8000010, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", forbid_guest = false, trigger_count = 0 }
}
function Initialize()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
table.insert(suites[2].triggers, v.name)
end
table.insert(triggers, other_Tri[1])
table.insert(suites[10].triggers, other_Tri[1].name)
end
-----------------------------------
--处理召唤进度,需要保留
function action_variable_change(context, evt)
if evt.param1 == evt.param2 then
return -1
end
ScriptLib.PrintContextLog(context, "## ## BossDungeon : variable change | "..evt.source_name.." "..evt.param2.." -> "..evt.param1)
--竞争处理
if evt.source_name == "SummonStep" then
if evt.param1 == 1111 then
ScriptLib.EndTimeAxis(context, "summon")
end
end
return -1
end
--处理局内计时,需要保留
function action_time_axis_pass(context, evt)
ScriptLib.PrintContextLog(context, "## BossDungeon : time axis pass : "..evt.source_name.." | param1 = "..evt.param1)
--依次召唤阶段的处理逻辑
if evt.source_name == "summon" then
local SummonStep_ = ScriptLib.GetGroupTempValue(context, "SummonStep", {})
for i=2,4 do
local temp_ = SummonStep_
if temp_%math.pow(10,i)//math.pow(10,i-1) == 0 then
LF_Summon_Action(context, i)
break
end
end
elseif evt.source_name == "summon_delay" then
SLC_Summon_Start(context)
elseif evt.source_name == "stage_1" then
local stage = ScriptLib.GetGroupTempValue(context, "Oceanid_State", {})
ScriptLib.PrintContextLog(context, "## BossDungeon : stage = "..stage)
if 1 == stage then
SLC_Stage_To_2(context)
end
elseif evt.source_name == "shuffle_loop" then
LF_Random_Attack_Platform(context)
end
return 0
end
--处理踩怪,需要保留
function action_enter_region(context, evt)
for i,v in ipairs(defs.summon_region_list) do
if v == evt.param1 then
--提前踩出怪,重新计时
LF_Summon_Action(context, i+1)
break
end
end
return 0
end
function action_any_monster_die(context, evt)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : monster_die = "..evt.param1)
if evt.param1 == defs.monster_boss then
LF_Clear_Battle_Arena(context)
else
--根据召唤的suite自行换算行为
local noob = ScriptLib.GetMonsterAbilityFloatValue(context, 0, defs.monster_boss, "_MONSTERAFFIX_OCEANID_02_ANIMALSELECT")
local noob_suite = noob + 4
for k,v in ipairs(suites[noob_suite].monsters) do
if evt.param1 == v then
--怪死了立即召唤下一只
local temp_ = ScriptLib.GetGroupTempValue(context, "SummonStep", {})
for i=2,4 do
if temp_ == 0 then
break
end
if temp_%math.pow(10,i)//math.pow(10,i-1) ~= 1 then
LF_Summon_Action(context, i)
break
end
end
ScriptLib.ChangeGroupTempValue(context, "Oceanid_HP", -10, {})
local hp_ = ScriptLib.GetGroupTempValue(context, "Oceanid_HP", {})
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : boss_cur_hp = "..hp_)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.monster_boss, "SGV_Oceanid_HP", hp_)
--血量40则进入3阶段
if hp_ <= 40 then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.monster_boss, "SGV_Oceanid_State", 3)
ScriptLib.SetGroupTempValue(context, "Oceanid_State", 3, {})
--ScriptLib.RemoveExtraGroupSuite(context, 0, 11)
LF_Random_Attack_Platform(context)
ScriptLib.InitTimeAxis(context, "shuffle_loop", {25}, true)
end
break
end
end
end
return 0
end
---------------------------------------
function LF_Get_Distance(context, uid, config_id)
local eid = ScriptLib.GetAvatarEntityIdByUid(context, uid)
local pos1 = ScriptLib.GetPosByEntityId(context, eid)
local pos2 = gadgets[config_id].pos
local X = pos1.x - pos2.x
local Y = pos1.y - pos2.y
local Z = pos1.z - pos2.z
return math.sqrt(X*X+Y*Y+Z*Z)
end
function LF_Clear_Battle_Arena(context)
ScriptLib.PrintContextLog(context, "##ACT_OCEANID_LOG : Clear_Battle_Arena")
ScriptLib.SetGroupTempValue(context, "is_in_battle", 0, {})
ScriptLib.SetGroupTempValue(context, "SummonStep", 0, {})
ScriptLib.EndTimeAxis(context, "stage_1")
ScriptLib.EndTimeAxis(context, "summon_delay")
ScriptLib.EndTimeAxis(context, "summon")
ScriptLib.EndTimeAxis(context, "shuffle_loop")
for i=2,10 do
ScriptLib.KillExtraGroupSuite(context, 0, i)
end
--变量转给group内部
end
function LF_Create_Boss(context)
--调资源包接口
ScriptLib.InitTimeAxis(context, "stage_1", {120}, false)
ScriptLib.SetGroupTempValue(context, "Oceanid_State", 1, {})
ScriptLib.AddExtraGroupSuite(context, 0, 2)
end
function LF_Random_Attack_Platform(context)
math.randomseed(ScriptLib.GetServerTime(context))
local p={}
local array = {1,2,3,4,5,6,7,8,9}
local _max = 3
if 0 ~= ScriptLib.GetMonsterAbilityFloatValue(context, 0, defs.monster_boss, "_MONSTERAFFIX_OCEANID_02_PLATFORMDAMAGE_SUM_UP") then
_max = 5
end
for j=1,_max do
local ran = math.random(#array)
for k,v in pairs(array) do
if ran == k then
p[j] = array[k]
table.remove(array, k)
break
end
end
end
ScriptLib.PrintContextLog(context, "## BossDungeon : Platform_Sum = "..#p)
for i,v in ipairs(defs.gadget_operator_list) do
local is_match = false
for m,n in ipairs(p) do
if i == n then
is_match = true
break
end
end
if is_match == true then
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 201)
else
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
end
end
end
function LF_Summon_Action(context, idx)
--根据召唤的suite自行换算行为
local noob = ScriptLib.GetMonsterAbilityFloatValue(context, 0, defs.monster_boss, "_MONSTERAFFIX_OCEANID_02_ANIMALSELECT")
local noob_suite = noob + 4
local noob_heal = ScriptLib.GetMonsterAbilityFloatValue(context, 0, defs.monster_boss, "_MONSTERAFFIX_OCEANID_02_ANIMALHEAL_UP")
local noob_bomb = ScriptLib.GetMonsterAbilityFloatValue(context, 0, defs.monster_boss, "_MONSTERAFFIX_OCEANID_02_ANIMAL_DEATHEXPLODE")
local noob_level = ScriptLib.GetEffigyChallengeMonsterLevel(context) + 1
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : noob = "..noob.." | noob_heal = "..noob_heal)
ScriptLib.CreateMonster(context, {config_id=suites[noob_suite].monsters[idx], level=noob_level, delay_time=0, server_global_value={["SGV_MONSTERAFFIX_OCEANID_02_ANIMALHEAL_UP"]=noob_heal,["SGV_MONSTERAFFIX_OCEANID_02_ANIMAL_DEATHEXPLODE"]=noob_bomb}})
--remove相应的region
if idx ~= 1 then
ScriptLib.RemoveExtraGroupSuite(context, 0, idx+5)
end
local value = ScriptLib.GetGroupTempValue(context, "SummonStep", {})
value = value - value%math.pow(10,idx) + value%math.pow(10,idx-1) + math.pow(10,idx-1)
ScriptLib.SetGroupTempValue(context, "SummonStep", value, {})
if value ~= 1111 then
ScriptLib.InitTimeAxis(context, "summon", {defs.summon_interval}, true)
end
end
---------------------------------------
function SLC_Stage_To_2(context)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : SLC_Stage_To_2")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.monster_boss, "SGV_Oceanid_State", 2)
ScriptLib.SetGroupTempValue(context, "Oceanid_State", 2, {})
ScriptLib.EndTimeAxis(context, "stage_1")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.monster_boss, "SGV_Oceanid_HP", 80)
ScriptLib.SetGroupTempValue(context, "Oceanid_HP", 80, {})
ScriptLib.SetGroupTempValue(context, "SummonStep", 0, {})
ScriptLib.InitTimeAxis(context, "summon_delay", {10}, false)
ScriptLib.SetGroupTempValue(context, "summon_lock", 0, {})
return 0
end
function SLC_Summon_Start(context)
if 1 ~= ScriptLib.GetGroupTempValue(context, "summon_lock", {}) then
ScriptLib.SetGroupTempValue(context, "summon_lock", 1, {})
else
return -1
end
ScriptLib.EndTimeAxis(context, "summon_delay")
ScriptLib.InitTimeAxis(context, "summon", {defs.summon_interval}, true)
--0001b为第一只怪的标识
local noob = ScriptLib.GetMonsterAbilityFloatValue(context, 0, defs.monster_boss, "_MONSTERAFFIX_OCEANID_02_ANIMALSELECT")
local noob_suite = noob + 4
local noob_heal = ScriptLib.GetMonsterAbilityFloatValue(context, 0, defs.monster_boss, "_MONSTERAFFIX_OCEANID_02_ANIMALHEAL_UP")
local noob_bomb = ScriptLib.GetMonsterAbilityFloatValue(context, 0, defs.monster_boss, "_MONSTERAFFIX_OCEANID_02_ANIMAL_DEATHEXPLODE")
local noob_level = ScriptLib.GetEffigyChallengeMonsterLevel(context) + 1
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : noob = "..noob.." | noob_heal = "..noob_heal)
ScriptLib.CreateMonster(context, {config_id=suites[noob_suite].monsters[1], level=noob_level, delay_time=0, server_global_value={["SGV_MONSTERAFFIX_OCEANID_02_ANIMALHEAL_UP"]=noob_heal,["SGV_MONSTERAFFIX_OCEANID_02_ANIMAL_DEATHEXPLODE"]=noob_bomb}})
ScriptLib.AddExtraGroupSuite(context, 0, 7)
ScriptLib.AddExtraGroupSuite(context, 0, 8)
ScriptLib.AddExtraGroupSuite(context, 0, 9)
ScriptLib.AddExtraGroupSuite(context, 0, 10)
ScriptLib.SetGroupTempValue(context, "SummonStep", 1, {})
return 0
end
function SLC_Platform_Shuffle(context)
ScriptLib.PrintContextLog(context, "## ACT_OCEANID_LOG : SLC_Shuffle")
LF_Random_Attack_Platform(context)
return 0
end
function SLC_Boss_Escape(context)
ScriptLib.PrintContextLog(context, "## oceanid escape")
return 0
end
---------------------------------------
Initialize()
---------------------------------------
@@ -0,0 +1,100 @@
--[[
local vision_def = {
[1] = { enter = 100, leave = 101 },
[2] = { enter = 102, leave = 103 },
}
--]]
local Tri = {
{ name = "enter_region", config_id = 8000001, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false },
{ name = "leave_region", config_id = 8000002, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0, forbid_guest = false },
{ name = "variable_change", config_id = 8000003, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", trigger_count = 0 }
}
function Initialize()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
-----------------------------------------------------
function action_enter_region(context, evt)
local opt = ScriptLib.GetGroupTempValue(context, "optimize_"..context.uid, {})
if opt ~= 1 then
if opt == -1 then
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 0, {})
end
for k,v in pairs(vision_def) do
if evt.param1 == v.enter then
ScriptLib.AddPlayerGroupVisionType(context, {context.uid}, {k})
break
end
end
end
return 0
end
function action_leave_region(context, evt)
local opt = ScriptLib.GetGroupTempValue(context, "optimize_"..context.uid, {})
if opt ~= 1 then
if opt == -1 then
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 0, {})
end
for k,v in pairs(vision_def) do
if evt.param1 == v.leave then
ScriptLib.DelPlayerGroupVisionType(context, {context.uid}, {k})
break
end
end
end
return 0
end
function action_variable_change(context, evt)
if evt.param2 == 1 and evt.param1 == 0 then
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
if "optimize_"..v == evt.source_name then
LF_ReCalculate_VisionType(context, v)
end
end
end
return 0
end
function LF_ReCalculate_VisionType(context, uid)
local eid = ScriptLib.GetAvatarEntityIdByUid(context, uid)
local pos = ScriptLib.GetPosByEntityId(context, eid)
local vision = {1}
for k,v in pairs(vision_def) do
if LF_Check_Avatar_In_Region(context, pos, regions[v.leave]) == true then
table.insert(vision, k)
end
end
ScriptLib.SetPlayerGroupVisionType(context, {uid}, vision)
end
function LF_Check_Avatar_In_Region(context, pos, region)
ScriptLib.PrintContextLog(context, "## optimization : region_id = "..region.config_id)
if region.shape == RegionShape.SPHERE then
local X = pos.x - region.pos.x
local Y = pos.y - region.pos.y
local Z = pos.z - region.pos.z
if math.sqrt(X*X+Y*Y+Z*Z) > region.radius then
return false
else return true
end
elseif region.shape == RegionShape.CUBIC then
if math.abs(pos.x-region.pos.x) > region.size.x/2 then
return false
elseif math.abs(pos.y-region.pos.y) > region.size.y/2 then
return false
elseif math.abs(pos.z-region.pos.z) > region.size.z/2 then
return false
end
return true
end
return false
end
---------------------------------
Initialize()
@@ -0,0 +1,359 @@
-- local ProgressTable = {0,10,100}
-- local GalleryID = 0
-- -- local SubScoreTimeAxis = {1}
-- local GroupID = 144004004
--misc
--自定义函数部分
local extrTriggers = {
initialtrigger = {
["Start_Gallery"] = { config_id = 8000001, name = "Start_Gallery", event= EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_whern_gallery_start", trigger_count = 0 },
--["GadgetSate_Change"] = { config_id = 8000002, name = "GadgetSate_Change", event= EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadgetstate_change", trigger_count = 0 },
["Progress_Pass"] = { config_id = 8000003, name = "Progress_Pass", event= EventType.EVENT_GALLERY_PROGRESS_PASS, source = "", condition = "", action = "action_progress_pass", trigger_count = 0 },
["TimeAxis_Event"] = { config_id = 8000004, name = "TimeAxis_Event", event= EventType.EVENT_TIME_AXIS_PASS, source = "SubScoreTimeAxis", condition = "", action = "action_trigger_timeaxis", trigger_count = 0 },
["Monster_Die"] = { config_id = 8000005, name = "Monster_Die", event= EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die", trigger_count = 0 },
--["Const_Target"] = { config_id = 8000006, name = "Const_Target", event= EventType.EVENT_TIME_AXIS_PASS, source = "consttarget", condition = "", action = "action_timeaxis_consttarget", trigger_count = 0 },
["Random_Target"] = { config_id = 8000007, name = "Random_Target", event= EventType.EVENT_TIME_AXIS_PASS, source = "randomtarget", condition = "", action = "action_timeaxis_randomtarget", trigger_count = 0 },
--["Gadget_Die"] = { config_id = 8000006, name = "Gadget_Die", event= EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_gadget_die", trigger_count = 0 },
["Stop_Gallery"] = { config_id = 8000008, name = "Stop_Gallery", event= EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_whern_gallery_stop", trigger_count = 0 },
["Group_Unload"] = {name = "Group_Unload", config_id = 8000009, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
["Small_Region"] = { config_id = 9000001, name = "Small_Region", event= EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "player_in_optimizationRegion", trigger_count = 0, forbid_guest = false },
["Big_Region"] = { config_id = 9000002, name = "Big_Region", event= EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "player_leave_optimizationRegion", trigger_count = 0, forbid_guest = false },
}
}
local extrSuites = {
{
monsters = { },
gadgets = { },
regions = {smallRegion, bigRegion },
triggers = { "Small_Region","Big_Region"},
rand_weight = 100
}
}
--自定义函数部分
function MonsterAddScore(context)
-- 杀怪进度
ScriptLib.AddGalleryProgressScore(context, "ScoreProgress", GalleryID, 10)
--杀怪加分
ScriptLib.UpdatePlayerGalleryScore(context, GalleryID, {["monster_id"]=70350175, ["target_id"]=0})
return 0
end
function TargetAddScore(context)
local UidList = ScriptLib.GetSceneUidList(context)
-- 杀靶标进度
ScriptLib.AddGalleryProgressScore(context, "ScoreProgress", GalleryID, GadgetTargetScore)
--杀靶标加分
ScriptLib.PrintContextLog(context, "##SC LOG : uid == "..UidList[1])
ScriptLib.UpdatePlayerGalleryScore(context, GalleryID, {["uid"] = UidList[1], ["monster_id"]=0, ["target_id"]= 70350253})
return 0
end
function DeduplicationRandom( context, configIDList, randomNum )
math.randomseed(ScriptLib.GetServerTime(context))
local TempList = {}
for i,v in ipairs(configIDList) do
table.insert(TempList, v)
end
for i=1,randomNum do
local TempNum = math.random(#TempList)
ScriptLib.CreateGadget(context, { config_id = TempList[TempNum] })
table.remove(TempList, TempNum)
end
ScriptLib.ShowReminder(context, 600038)
return 0
end
--Event调用部分
function player_leave_optimizationRegion( context, evt )
ScriptLib.PrintContextLog(context, "##BD LOG : optimization Stop~~~~~ regionID == "..evt.param1)
if evt.param1 ~= bigRegion then
return 0
end
--优化结束
ScriptLib.PrintContextLog(context, "##BD LOG : optimization Stop!!!!!!!! uid == "..context.uid)
ScriptLib.ClearPlayerEyePoint(context, smallRegion)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
ScriptLib.SetLimitOptimization(context, context.uid, false)
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 0, { group_id = 144002077})
return 0
end
function player_in_optimizationRegion( context, evt )
if evt.param1 ~= smallRegion then
return 0
end
ScriptLib.PrintContextLog(context, "##BD LOG : optimization Start uid == "..context.uid)
--优化部分
ScriptLib.SetPlayerEyePoint(context, smallRegion, bigRegion)
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
ScriptLib.SetLimitOptimization(context, context.uid, true)
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 1, { group_id = 144002077})
return 0
end
function action_timeaxis_randomtarget( context,evt )
math.randomseed(ScriptLib.GetServerTime(context))
local TargetConfigID = RandomTargetConfigID[math.random(#RandomTargetConfigID)]
ScriptLib.PrintContextLog(context, "##SC LOG : random target configID == "..TargetConfigID)
ScriptLib.ShowReminder(context, 600038)
ScriptLib.CreateGadget(context, { config_id = TargetConfigID })
return 0
end
function action_timeaxis_consttarget( context,evt )
math.randomseed(ScriptLib.GetServerTime(context))
local TempList = {}
for i,v in ipairs(ConstTargetConfigID) do
table.insert(TempList, v)
end
for i=1,2 do
local TempNum = math.random(#TempList)
ScriptLib.CreateGadget(context, { config_id = TempList[TempNum] })
table.remove(TempList, TempNum)
end
return 0
end
function action_monster_die( context,evt )
-- body
local UidList = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context, "##SC LOG : monster entityID == "..evt.source_eid)
local MonsterID = ScriptLib.GetMonsterIdByEntityId(context, evt.source_eid)
ScriptLib.PrintContextLog(context, "##SC LOG : monsterID == "..MonsterID)
-- 杀怪进度
local MonsterScore = 0
for i,v in ipairs(MonsterTargetScore) do
if v.monsterID == MonsterID then
MonsterScore = v.score
break
end
end
ScriptLib.AddGalleryProgressScore(context, "ScoreProgress", GalleryID, MonsterScore)
--杀怪加分
ScriptLib.PrintContextLog(context, "##SC LOG : uid == "..UidList[1])
ScriptLib.UpdatePlayerGalleryScore(context, GalleryID, {["uid"] = UidList[1], ["monster_id"] = MonsterID, ["target_id"]=0})
return 0
end
function action_gadget_die( context,evt )
-- body
local UidList = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context, "##SC LOG : gadget entityID == "..evt.source_eid)
-- 杀怪进度
ScriptLib.AddGalleryProgressScore(context, "ScoreProgress", GalleryID, 10)
--杀怪加分
ScriptLib.PrintContextLog(context, "##SC LOG : uid == "..UidList[1])
ScriptLib.UpdatePlayerGalleryScore(context, GalleryID, {["uid"] = UidList[1], ["monster_id"]=0, ["target_id"]= ScriptLib.GetGadgetIdByEntityId(context, evt.source_eid)})
return 0
end
function action_whern_gallery_start( context,evt )
ScriptLib.PrintContextLog(context, "##SC LOG : Gallery Start")
math.randomseed(ScriptLib.GetServerTime(context))
--优化suite开启
ScriptLib.AddExtraGroupSuite(context, GroupID, #suites)
--初始化扣分数值
ScriptLib.SetGroupTempValue(context, "SubNum", PerSecondSubScore[1], {})
--初始化两个靶标时间轴
--ScriptLib.InitTimeAxis(context, "consttarget", ConstTimeAxis, true)
ScriptLib.InitTimeAxis(context, "randomtarget", RandomTimeAxis[math.random(#RandomTimeAxis)], true)
--初始化一个热度条
ScriptLib.InitGalleryProgressScore(context, "ScoreProgress", GalleryID, ProgressTable, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_BUOYANT_COMBAT)
ScriptLib.AttachGalleryAbilityGroup(context, {}, GalleryID, 0)
if GalleryID == 8002 then
ScriptLib.SetGroupTempValue(context, "_phase", 0, {})
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, "BuoyantCombat_Water_Level", 0.5)
end
--初始化一个定时器扣分
ScriptLib.InitTimeAxis(context, "SubScoreTimeAxis", SubScoreTimeAxis, true)
return 0
end
function action_whern_gallery_stop( context, evt )
if GalleryID == 8002 then
ScriptLib.SetGroupTempValue(context, "_phase", 0, {})
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, "BuoyantCombat_Water_Level", 0.5)
end
--优化suite卸载
ScriptLib.RemoveEntityByConfigId(context, GroupID, EntityType.REGION, bigRegion)
ScriptLib.EndTimeAxis(context, "randomtarget")
ScriptLib.EndTimeAxis(context, "SubScoreTimeAxis")
ScriptLib.RefreshGroup(context, { group_id = GroupID, suite = 1 })
return 0
end
function action_group_will_unload( context, evt )
ScriptLib.PrintContextLog(context, "##SC LOG : optimization Group will unload")
--优化suite卸载
ScriptLib.RemoveEntityByConfigId(context, GroupID, EntityType.REGION, bigRegion)
ScriptLib.StopGallery(context, GalleryID, false)
return 0
end
function action_gadgetstate_change( context,evt )
-- if evt.param2 ~= TestEnterConfigID or evt.param1 ~= 201 then
-- return 0
-- end
-- ScriptLib.PrintContextLog(context, "##SC LOG : GadgetState Change GameStart")
-- --GM手段进入玩法
-- ScriptLib.StartGallery(context, GalleryID)
return 0
end
function action_progress_pass( context,evt )
-- 阶段变更后
local LastPhase = evt.param3+1
local CurPhase = evt.param1+1
ScriptLib.PrintContextLog(context, "##SC LOG : param1 =="..evt.param1.."param3 =="..evt.param3)
if CurPhase > #PerSecondSubScore then
CurPhase = #PerSecondSubScore
end
ScriptLib.SetGroupTempValue(context, "SubNum", PerSecondSubScore[CurPhase], {})
--水元素有bug,换一种新的做法,不替换abilityGroup,直接改GlobalValue
if GalleryID ~= 8002 then
if evt.param2 == 1 then
--阶段上升
for i= LastPhase+1, CurPhase do
ScriptLib.AttachGalleryAbilityGroup(context, {}, GalleryID, i-1)
end
ScriptLib.ShowReminder(context, 600034+CurPhase-1)
else
--阶段下降
for i= LastPhase-1, CurPhase do
ScriptLib.DelGalleryAbilityGroup(context, {}, GalleryID, i)
end
end
elseif GalleryID == 8002 then
ScriptLib.SetGroupTempValue(context, "_phase", evt.param1, {})
local ratio = 0.5
ScriptLib.PrintContextLog(context, "##SC LOG : Gallery is 8002")
if evt.param1 == 1 then
ratio = 1
elseif evt.param1 == 2 then
ratio = 2
elseif evt.param1 == 3 then
ratio = 4.5
end
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, "BuoyantCombat_Water_Level", ratio)
end
return 0
end
function action_trigger_timeaxis( context,evt )
-- 扣分
local SubNum = ScriptLib.GetGroupTempValue(context, "SubNum", {})
ScriptLib.AddGalleryProgressScore(context, "ScoreProgress", GalleryID, SubNum)
return 0
end
function LF_Initialize_Group(triggers, suites)
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
for i,v in ipairs(extrSuites) do
table.insert(suites, v)
end
return 0
end
--水元素断线重连有风险,要slc辅助恢复
function SLC_Recover_BuoyantCombat_Water_Level(context)
local _p = ScriptLib.GetGroupTempValue(context, "_phase", {})
local ratio = 0.5
ScriptLib.PrintContextLog(context, "##SC LOG : SLC_Recover_BuoyantCombat_Water_Level | phase = ".._p)
if _p == 1 then
ratio = 1
elseif _p == 2 then
ratio = 2
elseif _p == 3 then
ratio = 4.5
end
ScriptLib.SetTeamEntityGlobalFloatValue(context, {context.uid}, "BuoyantCombat_Water_Level", ratio)
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,148 @@
--[[
local defs = {
gadget_up = 1, --向上压板
gadget_down = 2, --向下压板
gadget_water = 7001, --水片
point_array = 400100010,
point_list = {1,2,3,4,5},
gadget_list = {1,2,3,4,5}, --刻痕
point_xz = {x=100,z=100}, --point坐标
point_y = {100,110,120,130,140}, --point坐标
start_level = 3, --初始水位
is_abnormal = 0,
abnormal_height = 90, --上涨高度
}
--]]
-------------------
local Tri = {
[1] = { name = "gadget_state_change", config_id = 8000001, event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
[2] = { name = "platform_reach_point", config_id = 8000002, event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_platform_reach_point", trigger_count = 0 },
[3] = { name = "group_load", config_id = 8000003, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
[4] = { name = "group_refresh", config_id = 8000004, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0 },
[5] = { name = "variable_change", config_id = 8000005, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", trigger_count = 0 }
}
local Var = {
[1] = { config_id=50000001,name = "Water_Level", value = 0, no_refresh = true },
[2] = { config_id=50000002,name = "tune", value = 0, no_refresh = true },
[3] = { config_id=50000003,name = "first_play", value = 1, no_refresh = true },
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(Var) do
table.insert(variables, v)
end
end
--------------------------------------
function action_gadget_state_change(context, evt)
ScriptLib.PrintContextLog(context, "## TuneStone : State_Change : "..evt.param2.." | "..evt.param3.." -> "..evt.param1)
if evt.param1 == 201 and evt.param3 == 0 then
local water = ScriptLib.GetGroupVariableValue(context, "Water_Level")
if evt.param2 == defs.gadget_up then
if water < #defs.point_list and 0 == ScriptLib.GetGroupTempValue(context, "motion", {}) then
LF_Modify_Water(context, water, 1)
end
elseif evt.param2 == defs.gadget_down and 0 == ScriptLib.GetGroupTempValue(context, "motion", {}) then
if water > 1 then
LF_Modify_Water(context, water, -1)
end
end
--elseif evt.param1 == 0 and evt.param3 == 201 then
-- if evt.param2 == defs.gadget_up or evt.param2 == defs.gadget_down then
-- LF_Check_Water_To_Motion(context, evt)
-- end
end
return 0
end
function action_platform_reach_point(context, evt)
ScriptLib.PrintContextLog(context, "## TuneStone : Reach_Point | "..evt.param1.." | "..evt.param2)
local water = ScriptLib.GetGroupVariableValue(context, "Water_Level")
ScriptLib.ScenePlaySound(context, {play_pos = defs.audio_xyz, sound_name = defs.audio_list[water], play_type=1, is_broadcast=true})
ScriptLib.SetGroupTempValue(context, "motion", 0, {})
--if evt.param1 == defs.gadget_water then
-- LF_Check_Water_To_Motion(context, evt)
--end
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_list[water], 201)
ScriptLib.SetGroupVariableValue(context, "tune", water)
return 0
end
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context, "## TuneStone : Group_Load")
LF_Init_Water(context, evt)
return 0
end
function action_group_refresh(context, evt)
ScriptLib.PrintContextLog(context, "## TuneStone : Group_Refresh")
LF_Init_Water(context, evt)
return 0
end
function action_variable_change(context, evt)
if evt.param1 == evt.param2 then
return -1
end
ScriptLib.PrintContextLog(context, "## TuneStone : Variable : "..evt.source_name.." : "..evt.param2.." -> "..evt.param1)
return 0
end
function LF_Init_Water(context, evt)
ScriptLib.PrintContextLog(context, "## TuneStone : LF_Init_Water")
--根据存档还原水位
local water = ScriptLib.GetGroupVariableValue(context, "Water_Level")
local pos = defs.point_xz
if defs.is_abnormal == 1 and 1 == ScriptLib.GetGroupVariableValue(context, "first_play") then
pos.y = defs.abnormal_height
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.gadget_water, pos, {x=0,y=0,z=0})
ScriptLib.SetGroupTempValue(context, "motion", 1, {})
ScriptLib.SetPlatformPointArray(context, defs.gadget_water, defs.point_array, {defs.point_list[defs.start_level]}, {route_type = 0, turn_mode = false})
ScriptLib.SetGroupVariableValue(context, "first_play", 0)
ScriptLib.SetGroupVariableValue(context, "Water_Level", defs.start_level)
return 0
end
if water == 0 then
water = defs.start_level
end
ScriptLib.SetGroupVariableValue(context, "Water_Level", water)
ScriptLib.SetGroupVariableValue(context, "tune", water)
pos.y = defs.point_y[water]
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.gadget_water, pos, {x=0,y=0,z=0})
ScriptLib.SetGroupTempValue(context, "motion", 0, {})
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_list[water], 201)
return 0
end
function LF_Modify_Water(context, water, delta)
ScriptLib.PrintContextLog(context, "## TuneStone : LF_Modify_Water : level = "..water.." | delta = "..delta)
ScriptLib.SetGroupTempValue(context, "motion", 1, {})
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_list[water], 0)
--ScriptLib.ScenePlaySound(context, {play_pos = defs.audio_xyz, sound_name = defs.audio_list[water], play_type=2, is_broadcast=true})
local _water = water + delta
ScriptLib.SetGroupVariableValue(context, "Water_Level", _water)
ScriptLib.SetPlatformPointArray(context, defs.gadget_water, defs.point_array, {defs.point_list[_water]}, {route_type = 0, turn_mode = false})
end
function LF_Check_Water_To_Motion(context, evt)
local up_state = ScriptLib.GetGadgetStateByConfigId(context, 0, defs.gadget_up)
local down_state = ScriptLib.GetGadgetStateByConfigId(context, 0, defs.gadget_down)
local water = ScriptLib.GetGroupVariableValue(context, "Water_Level")
if up_state == 201 and down_state == 201 then
--跳过
elseif up_state == 201 and water < #defs.point_list then
LF_Modify_Water(context, water, 1)
water = water + 1
elseif down_state == 201 and water > 1 then
LF_Modify_Water(context, water, -1)
water = water - 1
end
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_list[water], 201)
ScriptLib.SetGroupVariableValue(context, "tune", water)
end
--------------------------------------
Initialize()
@@ -0,0 +1,105 @@
--[[
local defs = {
group_id = xxx ,
monster_shaman = 1,
gadget_barrier = {1,2,3,4,5},
TowerBridges = {{3,4},{3,5}}
}
--]]
local Tri = {
[1] = { name = "any_monster_die", config_id = 8000001, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0 },
--[2] = { name = "blossom_progress_finish", config_id = 8000002, event = EventType.EVENT_BLOSSOM_PROGRESS_FINISH, source = "", condition= "", action = "action_blossom_progress_finish", trigger_count = 0 },
[3] = { name = "any_gadget_die", config_id = 8000003, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0 },
[4] = { name = "group_load", config_id = 8000004, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
[5] = { name = "group_refresh", config_id = 8000005, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0 }
}
local Var = {
{ config_id=50000001,name = "in_battle", value = 0, no_refresh = true },
{ config_id=50000002,name = "wave", value = 0, no_refresh = true }
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(Var) do
table.insert(variables, v)
end
end
----------------------------------
function action_any_monster_die(context, evt)
ScriptLib.AddBlossomScheduleProgressByGroupId(context, defs.group_id)
if evt.param1 == defs.monster_shaman then
for i,v in ipairs(defs.gadget_barrier) do
ScriptLib.KillEntityByConfigId(context, { config_id = v, entity_type = EntityType.GADGET})
end
end
if ScriptLib.GetGroupMonsterCountByGroupId(context, 0) ~= 0 then
return -1
end
local wave = ScriptLib.GetGroupVariableValue(context, "wave")
ScriptLib.PrintContextLog(context, "## VehicleBattle : wave = "..wave)
if wave == #suites - 1 then
ScriptLib.PrintContextLog(context, "## VehicleBattle : this is final wave ")
ScriptLib.SetBlossomScheduleStateByGroupId(context, defs.group_id, 3)
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 1, exclude_prev = true, is_delay_unload = true})
ScriptLib.SetGroupVariableValue(context, "in_battle", 0)
else
ScriptLib.PrintContextLog(context, "## VehicleBattle : this is suite "..wave+2)
ScriptLib.AddExtraGroupSuite(context, 0, wave + 2)
ScriptLib.SetGroupVariableValue(context, "wave", wave + 1)
end
if #suites == 4 then
if wave == 1 then
ScriptLib.ShowReminderRadius(context, 400002, defs.point, 80)
elseif wave == 2 then
ScriptLib.ShowReminderRadius(context, 400003, defs.point, 80)
end
elseif #suites == 3 and wave == 1 then
ScriptLib.ShowReminderRadius(context, 400004, defs.point, 80)
end
return 0
end
function action_group_load(context, evt)
if 1 ~= ScriptLib.GetGroupVariableValue(context, "in_battle") then
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 1, exclude_prev = true, is_delay_unload = true })
end
--LF_Init_Blossom_Group(context)
return 0
end
function action_group_refresh(context, evt)
LF_Init_Blossom_Group(context)
--ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 1, exclude_prev = true })
return 0
end
function action_any_gadget_die(context, evt)
if #defs.TowerBridges == 0 then
return -1
end
for i,v in ipairs(defs.TowerBridges) do
if evt.param1 == v[1] then
ScriptLib.KillEntityByConfigId(context, { config_id = v[2], entity_type = EntityType.GADGET})
end
end
return 0
end
function LF_Init_Blossom_Group(context)
ScriptLib.SetGroupVariableValue(context, "in_battle", 1)
ScriptLib.SetBlossomScheduleStateByGroupId(context, defs.group_id, 2)
for i=2,#suites do
ScriptLib.RemoveExtraGroupSuite(context, 0, i)
end
local ret = ScriptLib.SetGroupVariableValue(context, "wave", 1)
ScriptLib.PrintContextLog(context, "## VehicleBattle : set wave 1 ret = "..ret)
ScriptLib.AddExtraGroupSuite(context, 0, 2)
end
----------------------------------
Initialize()
@@ -0,0 +1,69 @@
--对“天选之人”释放“强力技”时攻击弱点瘫痪boss
function SLC_Activity_BlitzRush_Enhanced_WeakTrigger (context)
local varName = "SLC_Activity_BlitzRush_Enhanced_WeakTrigger"
local uid = context.uid
AddPlayerTempValue(context, uid, varName)
return 0
end
--通过攻击弱点瘫痪过X次怪物
function SLC_Activity_BlitzRush_WeakTrigger (context)
local varName = "SLC_Activity_BlitzRush_WeakTrigger"
local uid = context.uid
AddPlayerTempValue(context, uid, varName)
return 0
end
--对X个“天选之人”造成最后一击
function SLC_Activity_BlitzRush_Enhanced_Killed(context)
local varName = "SLC_Activity_BlitzRush_Enhanced_Killed"
local uid = context.uid
AddPlayerTempValue(context, uid, varName)
return 0
end
--未受到过任何“强力技”伤害击败boss
function SLC_Activity_BlitzRush_AttackTagTrigger(context)
local varName = "SLC_Activity_BlitzRush_AttackTagTrigger"
local uid = context.uid
AddPlayerTempValue(context, uid, varName)
return 0
end
--用3电桩冲击波造成伤害
function SLC_RoleElectricPowerSource_AttackSum(context)
local uid_list = ScriptLib.GetSceneUidList(context)
local varName = "SLC_RoleElectricPowerSource_AttackSum_S4"
ScriptLib.PrintContextLog(context, "##BiltzRush LOG : Activity_BlitzRush_Call_RoleElectricPowerSource")
for k,uid in pairs(uid_list) do
AddPlayerTempValue(context, uid, varName)
end
return 0
end
--挑战中雷暴石发动攻击
function SLC_RoleElectricBomb_AttackSum(context)
local uid_list = ScriptLib.GetSceneUidList(context)
local varName = "SLC_RoleElectricBomb_AttackSum_S4"
ScriptLib.PrintContextLog(context, "##BiltzRush LOG : Activity_BlitzRush_Call_RoleElectricBomb")
for k,uid in pairs(uid_list) do
AddPlayerTempValue(context, uid, varName)
end
return 0
end
--雷暴石的不需要处理的SLC
function SLC_RoleElectricBomb_MultiAttack(context)
return 0
end
--给玩家的tempValue+1
function AddPlayerTempValue(context, uid, varName)
local value = ScriptLib.GetGroupTempValue(context, varName..uid, {})
value = value + 1
ScriptLib.SetGroupTempValue(context, varName..uid, value, {})
ScriptLib.AddExhibitionReplaceableData(context, uid, varName, 1)
ScriptLib.PrintContextLog(context, "##BiltzRush LOG : player add "..uid..varName..value)
return 0
end
@@ -0,0 +1,28 @@
local define = {
linkCount = "RoleElectricPowerSourceConnectCount", --连线时,玩家被上的global_value
}
local extraTriggers={
{ config_id = 8000001, name = "EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE", trigger_count = 0 }
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables, { config_id=50000001,name = "linkedKillNum", value = 0, no_refresh = true})
end
function action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE(context, evt)
--检查击杀者是否带2个以上连线
if evt.param2 ~= 0 then
if ScriptLib.GetTeamAbilityFloatValue(context, evt.param2, define.linkCount) >= 2 then
--增加GlobalVar计数
ScriptLib.ChangeGroupVariableValue(context, "linkedKillNum", 1)
end
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,203 @@
--地脉花循环营地模板
--local defs = {
-- group_id = xxx ,
-- monster_waves = 4,
-- chest_id = xxx,
-- operator1_id = xxx,
-- operator2_id = xxx
--}
local Tri = {
[1] = { name = "any_monster_die", config_id = 8000001, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0 },
[2] = { name = "blossom_progress_finish", config_id = 8000002, event = EventType.EVENT_BLOSSOM_PROGRESS_FINISH, source = "", condition= "", action = "action_blossom_progress_finish", trigger_count = 0 },
[4] = { name = "group_load", config_id = 8000004, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
[5] = { name = "group_refresh", config_id = 8000005, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0 },
--[6] = { name = "chest_die", config_id = 8000006, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0 },
[7] = { name = "select_option", config_id = 8000007, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
[8] = { name = "blossom_chest_die", config_id = 8000008, event = EventType.EVENT_BLOSSOM_CHEST_DIE, source = "", condition = "", action = "action_blossom_chest_die", trigger_count = 0 },
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--注入一个blossom的标志位。下次groupload时如果为1,说明玩法已经开始了,不再走一次init
table.insert(variables,{ config_id=50000001,name = "HasStarted", value = 0, no_refresh = true})
table.insert(variables,{ config_id=50000002,name = "wave", value = 0, no_refresh = true})
end
----------------------------------
function action_any_monster_die(context, evt)
--当怪物死的时候,增加循环营地进度
ScriptLib.AddBlossomScheduleProgressByGroupId(context, 0)
--如果还有怪物活着,无事发生
if ScriptLib.GetGroupMonsterCountByGroupId(context, 0) ~= 0 then
return -1
end
--当前波次怪物死光了,则加载下一波怪物
LF_Create_Next_Monster_Wave(context)
return 0
end
function action_group_load(context, evt)
--group加载时,刷新循环营地
ScriptLib.PrintContextLog(context,"BG: Group has been loaded!")
ScriptLib.SetGroupVariableValue(context,"GroupCompletion",0)
--group load时判定一下这个group是否已经开启,如果已经开启则无事发生
local has_started = ScriptLib.GetGroupVariableValue(context,"HasStarted")
if (has_started == 1) then
ScriptLib.PrintContextLog(context,"BG: Group has been started, refresh failed!")
return 0
end
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 1, exclude_prev = true, is_delay_unload = true })
LF_Init_Blossom_Group(context)
return 0
end
function action_group_refresh(context, evt)
ScriptLib.PrintContextLog(context,"BG: Group has been refreshed!")
--group load时判定一下这个group是否已经开启,如果已经开启则无事发生
local has_started = ScriptLib.GetGroupVariableValue(context,"HasStarted")
if (has_started == 1) then
ScriptLib.PrintContextLog(context,"BG: Group has been started, refresh failed!")
return 0
end
--group刷新时,初始化整个group
LF_Init_Blossom_Group(context)
return 0
end
function action_blossom_chest_die(context,evt)
--领取完奖励后,刷新循环营地
if evt.param1 == defs.chest then
ScriptLib.PrintContextLog(context,"BG: blossom has been opened. Refreh the next blossom group")
--group重置为没有开始的状态
ScriptLib.SetGroupVariableValue(context,"HasStarted",0)
ScriptLib.SetGroupVariableValue(context,"wave",0)
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 1, exclude_prev = true })
end
return 0
end
function action_select_option(context,evt)
--玩家选择选项后,隐藏地脉淤积gadget,清除gadget上的选项,激活第一波怪物
ScriptLib.PrintContextLog(context,"BG: Option has been selected! Monster waves start!")
ScriptLib.SetGadgetStateByConfigId(context, LF_Get_Blossom_Operator(context), 201)
ScriptLib.DelWorktopOptionByGroupId(context,0,LF_Get_Blossom_Operator(context),187)
--所有东西成功刷出来了,将group设置为已开始状态
ScriptLib.SetGroupVariableValue(context,"HasStarted",1)
LF_Start_Monster_Wave(context)
return 0
end
function action_blossom_progress_finish(context,evt)
--进度打满以后,创建奖励
LF_Create_Reward(context)
ScriptLib.SetGroupVariableValue(context,"GroupCompletion",1)
return 0
end
----------------------------------
function LF_Create_Reward(context)
--创建循环营地奖励方法,并将循环营地进度置到reward
ScriptLib.PrintContextLog(context,"BG: Monster wave has ended, creating blossom group reward")
ScriptLib.SetBlossomScheduleStateByGroupId(context,0,3)
ScriptLib.PrintContextLog(context,"BG: Creaing blossom chest!!")
ScriptLib.CreateBlossomChestByGroupId(context,0,defs.chest)
end
function LF_Create_Next_Monster_Wave(context)
--更新下一波怪物潮的方法,如果已经到了最后一波,则不刷新(此时理论上来说打完应该直接触发blossom group finish
local wave = ScriptLib.GetGroupVariableValue(context,"wave")
--local wave = ScriptLib.GetGroupTempValue(context, "wave", {})
local nextWave = wave + 1
if nextWave+1 > #suites then
ScriptLib.PrintContextLog(context, "BG: This is final wave ")
else
ScriptLib.PrintContextLog(context,"BG: Creating monster wave: "..nextWave)
ScriptLib.AddExtraGroupSuite(context, 0, nextWave+1)
ScriptLib.PrintContextLog(context,"BG: We are trying to load suite : "..nextWave+1)
ScriptLib.SetGroupVariableValue(context,"wave",nextWave)
--ScriptLib.SetGroupTempValue(context, "wave", nextWave, {})
end
end
function LF_Start_Monster_Wave(context)
--启动怪物潮,进入打怪阶段
ScriptLib.SetBlossomScheduleStateByGroupId(context, 0, 2)
ScriptLib.SetGroupVariableValue(context,"wave",0)
--ScriptLib.SetGroupTempValue(context, "wave", 0, {})
--加载第一波怪物
LF_Create_Next_Monster_Wave(context)
end
function LF_Init_Blossom_Group(context)
--初始化循环营地方法,移除全部的怪物group,并刷新地脉淤积操作台
ScriptLib.PrintContextLog(context,"BG: Blossom group is initiating")
--初始化时,先移除掉所有怪物的suite
for i = 2, #suites do
ScriptLib.RemoveExtraGroupSuite(context,0,i)
end
if (LF_Get_Blossom_Operator(context) == -1) then
return -1
end
ScriptLib.PrintContextLog(context,"BG: Current operator config id is: "..LF_Get_Blossom_Operator(context))
--加载地脉淤积的gadget
local ret = ScriptLib.CreateGadget(context, {config_id = LF_Get_Blossom_Operator(context)})
ScriptLib.PrintContextLog(context,"BG: Create worktop result: "..ret)
--给地脉淤积的gadget增加操作选项
ScriptLib.SetWorktopOptionsByGroupId(context,0,LF_Get_Blossom_Operator(context),{187})
return 0
end
function LF_Get_Blossom_Operator(context)
--获取当前BlossomGroup的地脉淤积操作台的方法,根据当前的刷新类型,返回不同的操作台
local operator = {[1]=defs.operator_1,[2]=nil,[3]=defs.operator_2}
local refreshType = ScriptLib.GetBlossomRefreshTypeByGroupId(context, 0)
if not (refreshType == 1 or refreshType == 3) then
return -1
end
ScriptLib.PrintContextLog(context,"BG: Current blossom group refresh type: "..refreshType)
return operator[refreshType]
end
----------------------------------
Initialize()
@@ -0,0 +1,275 @@
--[[
藏宝图特殊藏宝点的一笔画玩法
]]--
local matrix =
{
{defs.gadget_11,defs.gadget_12,defs.gadget_13},
{defs.gadget_21,defs.gadget_22,defs.gadget_23},
{defs.gadget_31,defs.gadget_32,defs.gadget_33}
}
local extraTriggers={
{config_id = 9000001, name = "GadgetStateChange", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_Gadget_State_Change", trigger_count = 0 },
{config_id = 9000002,name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
{ config_id = 9000003, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0 },
{ config_id = 9000004, name = "group_load_DOL", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 9000005, name = "general_award_taken_DOL", event = EventType.EVENT_GENERAL_REWARD_TAKEN, source = "", condition = "", action = "action_general_reward_taken", trigger_count = 0 },
}
function Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "digged", value = 0, no_refresh = true})
table.insert(variables,{ config_id=50000002,name = "successed", value = 0, no_refresh = true})
table.insert(variables,{ config_id=50000003,name = "challenge_state", value = 0})
table.insert(variables,{ config_id=50000004,name = "current_stone", value = 0})
--初始化
end
function action_general_reward_taken(context,evt)
--挖掘点被挖掉的时候触发
ScriptLib.PrintContextLog(context,"DOL: Group has been digged, load the first brick!!!")
--发一个reminder
ScriptLib.ShowReminder(context, 600043)
local targetSolution
--向服务器申请获得当前group的解法列(某些情况下可能没走group load,做个保险)
targetSolution = ScriptLib.GetBonusTreasureMapSolution(context, defs.group_ID)
ScriptLib.PrintContextLog(context,"DOL: Target Solution is: ")
for i = 1,#targetSolution do
ScriptLib.PrintContextLog(context,"DOL :"..targetSolution[i])
end
--如果因为任何原因没有拿到解法,立刻返回,不加载石板,防止后续报错
if (#targetSolution == 0) then
return 0
end
--创建起始方块
ScriptLib.CreateGadget(context, { config_id = defs.gadget_starter })
ScriptLib.SetGroupVariableValue(context,"digged",1)
return 0
end
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context,"DOL: Draw One Line Group Loaded ")
local targetSolution
--向服务器申请获得当前group的解法列
targetSolution = ScriptLib.GetBonusTreasureMapSolution(context, defs.group_ID)
ScriptLib.PrintContextLog(context,"DOL: Target Solution is: ")
for i = 1,#targetSolution do
ScriptLib.PrintContextLog(context,"DOL :"..targetSolution[i])
end
--如果因为任何原因没有拿到解法,立刻返回,不加载石板,防止后续报错
if (#targetSolution == 0) then
return 0
end
--group load时,如果没有胜利,则强制加载第一块石板
if ScriptLib.GetGroupVariableValue(context, "successed")~=1 and ScriptLib.GetGroupVariableValue(context,"digged") == 1 then
ScriptLib.PrintContextLog(context,"DOL: Reloading from the start!! ")
--重置一下挑战状态
ScriptLib.SetGroupVariableValue(context,"challenge_state",0)
local ret = ScriptLib.CreateGadget(context, { config_id = defs.gadget_starter })
ScriptLib.PrintContextLog(context,"DOL: Building the first brick result: "..ret)
end
return 0
end
--处理失败逻辑
function FaildProcess(context,str)
--Fiald process start
ScriptLib.PrintContextLog(context,"Fiald Process Start : "..str)
ScriptLib.SetGroupVariableValue(context, "isProcessFaild", 1)
ScriptLib.PrintContextLog(context,str.." Set isPrecessFaild = 1")
for k,v in pairs(matrix) do
for ik,iv in pairs(v) do
ScriptLib.PrintContextLog(context,str.." Loop ".. iv)
local tempGadgeState = ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, iv)
ScriptLib.PrintContextLog(context,str.." tempGadgetState = ".. tempGadgeState)
if tempGadgeState ~= 903 then
if iv ~= defs.gadget_starter then
ScriptLib.SetGadgetStateByConfigId(context, iv, 102)
else
ScriptLib.SetGadgetStateByConfigId(context, iv, 201)
end
end
end
end
ScriptLib.StopChallenge(context,233,0)
--ScriptLib.SetGroupVariableValue(context, "activeCount", 0)
ScriptLib.PrintContextLog(context,"DOL: Fiald Process End : "..str)
--Fiald process End
ScriptLib.RemoveExtraGroupSuite(context, defs.group_ID, 2)
ScriptLib.SetGroupVariableValue(context, "challenge_state", 0)
ScriptLib.CreateGadget(context, { config_id = defs.gadget_starter })
end
function LuaCallFail(context)
FaildProcess(context,"踩到空方块")
return 0
end
function action_gadget_create(context, evt)
ScriptLib.PrintContextLog(context,"DOL: Changed gadget id is: "..evt.param2)
ScriptLib.PrintContextLog(context,"DOL: Changed gadget config id is: "..evt.param1)
if evt.param2==70900304 then
ScriptLib.PrintContextLog(context," DOLBuild First Brick")
--if ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID, evt.param1)==0 then
local ret = ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 101)
ScriptLib.PrintContextLog(context,"DOL: First brick change state result: "..ret)
--end
end
return 0
end
function action_Gadget_State_Change(context, evt)
--未开始挑战,并将一个石板踩亮:说明挑战开始,加载剩余的所有石板、并将challenge_state设置为1(挑战进行中)
if ScriptLib.GetGroupVariableValue(context, "challenge_state")==0 and evt.param1==202 then
--生成第一块石板的时候,同时开启挑战
local ret = ScriptLib.StartChallenge(context,233,defs.challenge,{0,defs.challenge,1})
ScriptLib.PrintContextLog(context,"DOL: Challenge active result "..ret)
ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 2)
ScriptLib.SetGroupVariableValue(context, "challenge_state", 1)
for i=1,#matrix do
for j=1,#matrix[i] do
if matrix[i][j]==evt.param2 then
ScriptLib.SetGroupVariableValue(context, "current_stone", i*10+j)
end
end
end
return 0
end
--挑战中踩到石板
--如果是成功踩亮,则检测踩到的是否和current_stone邻接
--如果是将石板踩灭,确认是否是重复踩了一块石板
if ScriptLib.GetGroupVariableValue(context, "challenge_state")==1 then
local current_stone_id = ScriptLib.GetGroupVariableValue(context, "current_stone")
--ScriptLib.PrintContextLog(context,"DOL:current stone id: "..current_stone_id)
if evt.param1==202 then
ScriptLib.PrintContextLog(context,"DOL:step on an DEFAULT stone")
CheckTwoGadgetIsAdjacent(context,ScriptLib.GetGroupVariableValue(context, "current_stone"),evt.param2)
end
if evt.param1==201 and evt.param3==202 then
CheckTwoGadgetIsAdjacent(context,ScriptLib.GetGroupVariableValue(context, "current_stone"),evt.param2)
local current_idx=ScriptLib.GetGroupVariableValue(context, "current_stone")
local config_one=matrix[math.floor(current_idx/10)][current_idx%10]
if config_one==evt.param2 then
ScriptLib.PrintContextLog(context,"DOL:step on the SAME stone")
--ScriptLib.SetGadgetStateByConfigId(context, evt.param2, 202)
else
ScriptLib.PrintContextLog(context,"DOL:step on a ACTIVITED stone")
end
end
--每次石板状态变化,都要检查一次是否成功
CheckIsSuccess(context)
return 0
end
return 0
end
function action_EVENT_LEAVE_REGION(context, evt)
if evt.param1~=defs.trigger_boarder or ScriptLib.GetGroupVariableValue(context, "successed")==1 then
return 0
end
FaildProcess(context,"出圈")
return 0
end
--检测玩法是否成功
function CheckIsSuccess(context)
--用到的时候再找服务端要,防止服务器清数据
local targetSolution = ScriptLib.GetBonusTreasureMapSolution(context, defs.group_ID)
--校验一下是否拿到数据,如果没拿到直接返回失败
if (#targetSolution == 0) then
return 0
end
local score=0
local state=nil
local isSuccess = true
for i=1,#matrix do
for j=1,#matrix[i] do
state=ScriptLib.GetGadgetStateByConfigId(context, defs.group_ID,matrix[i][j])
--石板激活,但目标解法不为1,说明该次判定失败,直接返回失败
ScriptLib.PrintContextLog(context,"DOL : Brick ["..i..","..j.."] is "..state-201)
ScriptLib.PrintContextLog(context,"DOL : target index is "..(i-1)*#matrix+j)
if (state-201) ~= targetSolution[(i-1)*#matrix+j] and (state-101) ~= targetSolution[(i-1)*#matrix+j] then
isSuccess = false
break
end
end
end
if (isSuccess == false) then
return 0
end
if isSuccess then
ScriptLib.PrintContextLog(context,"DOL:SUCCESS!")
for i=1,#matrix do
for j=1,#matrix[i] do
ScriptLib.SetGadgetStateByConfigId(context, matrix[i][j], 901)
end
end
ScriptLib.SetGroupVariableValue(context, "challenge_state", 2)
--ScriptLib.AddExtraGroupSuite(context, defs.group_ID, 3)
ScriptLib.SetGroupVariableValue(context, "successed", 1)
ScriptLib.StopChallenge(context,233,1)
end
return 0
end
--检测两个方块是否是相邻方块
function CheckTwoGadgetIsAdjacent(context,current_idx,config_two)
local x=math.floor(current_idx/10)
local y=current_idx%10
if matrix[x][y]==config_two then
return 0
end
if y>1 then
if matrix[x][y-1]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", x*10+y-1)
return 0
end
end
if y< #matrix[x] then
if matrix[x][y+1]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", x*10+y+1)
return 0
end
end
if x>1 then
if matrix[x-1][y]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", (x-1)*10+y)
return 0
end
end
if x < #matrix then
if matrix[x+1][y]==config_two then
ScriptLib.SetGroupVariableValue(context, "current_stone", (x+1)*10+y)
return 0
end
end
FaildProcess(context,"踩错")
return 0
end
Initialize_Group(triggers, suites)
@@ -0,0 +1,26 @@
function LF_Initialize_Group(triggers, suites)
local id=8100001
for i=1,#gadgets do
if gadgets[i].gadget_id == 70900380 then
local configId=gadgets[i].config_id
local insertRegion={ config_id = id, shape = RegionShape.SPHERE, radius = 14.5, pos=gadgets[i].pos, area_id = gadgets[i].area_id,ability_group_list = { "Fly_Electric_Core_Play" } }
table.insert(regions,insertRegion)
for j=1,#suites do
for k=1,#suites[j].gadgets do
if suites[j].gadgets[k]==configId then
table.insert(suites[j].regions,id)
end
end
end
id=id+1
end
end
--初始化
end
function Electric_Core_Explain(context)
ScriptLib.MarkPlayerAction(context, 7002, 3, 1)
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,26 @@
function LF_Initialize_Group(triggers, suites)
local id=8100001
for i=1,#gadgets do
if gadgets[i].gadget_id == 70290154 then
local configId=gadgets[i].config_id
local insertRegion={ config_id = id, shape = RegionShape.SPHERE, radius = 8.0, pos=gadgets[i].pos, area_id = gadgets[i].area_id,ability_group_list = { "Fly_Electric_Core_Play_Challenge" } }
table.insert(regions,insertRegion)
for j=1,#suites do
for k=1,#suites[j].gadgets do
if suites[j].gadgets[k]==configId then
table.insert(suites[j].regions,id)
end
end
end
id=id+1
end
end
--初始化
end
function Electric_Core_Explain(context)
ScriptLib.MarkPlayerAction(context, 7002, 3, 1)
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,148 @@
--自定义函数部分
local extrTriggers = {
initialtrigger = {
["Gadget_State_Change"] = { config_id = 8000001, name = "Gadget_State_Change", event= EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "gadget_state_change", trigger_count = 0 },
["Random_Floor"] = { config_id = 8000002, name = "Random_Floor", event= EventType.EVENT_TIME_AXIS_PASS, source = "triggerElementFloor", condition = "", action = "action_timeaxis_randomfloor", trigger_count = 0 },
["Challenge_Fail"] = { config_id = 8000003, name = "Challenge_Fail", event= EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0 },
["ALL_PLAYER_DIE"] = { config_id = 8000004, name = "ALL_PLAYER_DIE", event= EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_all_avatar_die", trigger_count = 0 },
["Challenge_Success"] = { config_id = 8000005, name = "Challenge_Success", event= EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0 },
}
}
function DeduplicationRandom( context, configIDList, randomNum )
math.randomseed(ScriptLib.GetServerTime(context))
local TempList = {}
local ReturnList = {}
for i,v in ipairs(configIDList) do
table.insert(TempList, v)
end
for i=1,randomNum do
local TempNum = math.random(#TempList)
table.insert(ReturnList, TempList[TempNum] )
table.remove(TempList, TempNum)
end
return ReturnList
end
function gadget_state_change( context, evt )
-- 监听玩法开始
if evt.param2 ~= EnterConfigID then
return 0
end
if evt.param1 == 202 then
ScriptLib.PrintContextLog(context, "##EF LOG : Start Play")
ScriptLib.InitTimeAxis(context, "triggerElementFloor", elemenFloorTimer, true)
local CurList = DeduplicationRandom(context, floorList, 2)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, CurList[1], 201)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, CurList[2], 202)
end
return 0
end
function action_timeaxis_randomfloor( context, evt )
ScriptLib.PrintContextLog(context, "##EF LOG : Random Floor")
-- 每次随机一套地板
for i,v in ipairs(floorList) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
end
local CurList = DeduplicationRandom(context, floorList, 2)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, CurList[1], 201)
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, CurList[2], 202)
return 0
end
function action_challenge_fail( context,evt )
ScriptLib.PrintContextLog(context, "##EF LOG : End Play")
ScriptLib.EndTimeAxis(context, "triggerElementFloor")
for i,v in ipairs(floorList) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
end
return 0
end
function action_challenge_success( context,evt )
ScriptLib.PrintContextLog(context, "##EF LOG : End Play")
ScriptLib.EndTimeAxis(context, "triggerElementFloor")
for i,v in ipairs(floorList) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
end
return 0
end
function action_all_avatar_die( context,evt )
-- 所有角色死亡
local UidList = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(UidList) do
if ScriptLib.IsPlayerAllAvatarDie(context, v) == false then
return 0
end
end
ScriptLib.PrintContextLog(context, "##EF LOG : End Play")
ScriptLib.EndTimeAxis(context, "triggerElementFloor")
for i,v in ipairs(floorList) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
end
return 0
end
function LF_Initialize_Group()
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Group()
@@ -0,0 +1,17 @@
--雷暴石单次命中3个怪
function SLC_RoleElectricBomb_MultiAttack(context)
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
ScriptLib.AddExhibitionAccumulableData(context, v, "SLC_RoleElectricBomb_MultiAttack", 1)
end
return 0
end
--挑战中雷暴石发动攻击
function SLC_RoleElectricBomb_AttackSum(context)
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
ScriptLib.AddExhibitionAccumulableData(context, v, "SLC_RoleElectricBomb_AttackSum", 1)
end
return 0
end
@@ -0,0 +1,33 @@
local tri = {
{ name = "any_monster_die", config_id = 8000100, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0 }
}
function Init()
table.insert(triggers, tri[1])
for i,v in ipairs(suites) do
table.insert(v.triggers, tri[1].name)
end
end
--连接双电桩时击杀怪物
function action_any_monster_die(context, evt)
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
if 2 <= ScriptLib.GetTeamAbilityFloatValue(context, v, "RoleElectricPowerSourceConnectCount") then
ScriptLib.AddExhibitionAccumulableData(context, v, "SLC_RoleElectricPowerSource_MultiConnect", 1)
end
end
return 0
end
--用3电桩冲击波造成伤害
function SLC_RoleElectricPowerSource_AttackSum(context)
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
ScriptLib.AddExhibitionAccumulableData(context, v, "SLC_RoleElectricPowerSource_AttackSum", 1)
end
return 0
end
Init()
@@ -0,0 +1,141 @@
--[[
local vision_def = {
{ vision_id = 11, enter = 100, leave = 101 },
{ vision_id = 22, enter = 102, leave = 103 },
}
local vision_mutex = {
{11,12}
}
--]]
local Tri = {
{ name = "enter_region", config_id = 8000001, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0, forbid_guest = false },
{ name = "leave_region", config_id = 8000002, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0, forbid_guest = false },
{ name = "variable_change", config_id = 8000003, event = EventType.EVENT_VARIABLE_CHANGE, source = "", condition = "", action = "action_variable_change", trigger_count = 0 }
}
function Initialize()
for i,v in ipairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
--如果服务器上不好修的话,要考虑自己维护一个次数的tempValueTable
end
-----------------------------------------------------
function action_enter_region(context, evt)
local opt = ScriptLib.GetGroupTempValue(context, "optimize_"..context.uid, {})
if opt ~= 1 then
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 10, {})
for k,v in pairs(vision_def) do
if evt.param1 == v.enter then
local result = 1
--用于处理高炉内外视野互斥的问题
for p,q in ipairs(vision_mutex) do
for m,n in ipairs(q) do
if q[1] == v.vision_id then
ScriptLib.PrintContextLog(context, "## opt_log1: add vision "..q[1])
ScriptLib.AddPlayerGroupVisionType(context, {context.uid}, {q[1]})
ScriptLib.DelPlayerGroupVisionType(context, {context.uid}, {q[2]})
result = 0
end
if q[2] == v.vision_id then
local eid = ScriptLib.GetAvatarEntityIdByUid(context, context.uid)
local pos = ScriptLib.GetPosByEntityId(context, eid)
for each,vision in pairs(vision_def) do
if vision.vision_id == q[1] then
if LF_Check_Avatar_In_Region(context, pos, regions[vision.enter]) == false then
ScriptLib.PrintContextLog(context, "## opt_log2: add vision "..q[2])
ScriptLib.AddPlayerGroupVisionType(context, {context.uid}, {q[2]})
else
ScriptLib.PrintContextLog(context, "## opt_log2: del vision "..q[2])
ScriptLib.DelPlayerGroupVisionType(context, {context.uid}, {q[2]})
end
result = 0
end
end
end
end
end
if result == 1 then
ScriptLib.PrintContextLog(context, "## opt_log: add vision "..v.vision_id)
ScriptLib.AddPlayerGroupVisionType(context, {context.uid}, {v.vision_id})
end
break
end
end
end
return 0
end
function action_leave_region(context, evt)
local opt = ScriptLib.GetGroupTempValue(context, "optimize_"..context.uid, {})
if opt ~= 1 then
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 10, {})
LF_ReCalculate_VisionType(context, context.uid)
end
return 0
end
function action_variable_change(context, evt)
if evt.param1 == 0 then
local uid_list = ScriptLib.GetSceneUidList(context)
for i,v in ipairs(uid_list) do
if "optimize_"..v == evt.source_name then
LF_ReCalculate_VisionType(context, v)
end
end
end
return 0
end
function LF_ReCalculate_VisionType(context, uid)
local eid = ScriptLib.GetAvatarEntityIdByUid(context, uid)
local pos = ScriptLib.GetPosByEntityId(context, eid)
local vision = {1}
for k,v in pairs(vision_def) do
if LF_Check_Avatar_In_Region(context, pos, regions[v.leave]) == true then
table.insert(vision, v.vision_id)
end
end
--重算一次vision互斥,以每个互斥二元组中第一个查到的为准
for i,v in ipairs(vision) do
for m,n in ipairs(vision_mutex) do
if n[1] == v then
for p,q in ipairs(vision) do
if q == n[2] then
table.remove(vision, p)
end
end
end
end
end
ScriptLib.SetPlayerGroupVisionType(context, {uid}, vision)
end
function LF_Check_Avatar_In_Region(context, pos, region)
if region.shape == RegionShape.SPHERE then
local X = pos.x - region.pos.x
local Y = pos.y - region.pos.y
local Z = pos.z - region.pos.z
if math.sqrt(X*X+Y*Y+Z*Z) > region.radius then
return false
else
ScriptLib.PrintContextLog(context, "## opt_log: in region "..region.config_id)
return true
end
elseif region.shape == RegionShape.CUBIC then
if math.abs(pos.x-region.pos.x) > region.size.x/2 then
return false
elseif math.abs(pos.y-region.pos.y) > region.size.y/2 then
return false
elseif math.abs(pos.z-region.pos.z) > region.size.z/2 then
return false
end
ScriptLib.PrintContextLog(context, "## opt_log: in region "..region.config_id)
return true
end
return false
end
---------------------------------
Initialize()
@@ -0,0 +1,85 @@
--魔晶矿循环营地模板
local Tri1 = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
}
local Tri2 = {
[1] = { name = "group_refresh", config_id = 8000002, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0 },
[2] = { name = "any_gadget_die", config_id = 8000003, event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_any_gadget_die", trigger_count = 0 },
[3] = { name = "blossom_progress_finish", config_id = 8000004, event = EventType.EVENT_BLOSSOM_PROGRESS_FINISH, source = "", condition= "", action = "action_blossom_progress_finish", trigger_count = 0 },
}
function Initialize()
for k,v in pairs(Tri1) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(Tri2) do
table.insert(triggers, v)
table.insert(suites[2].triggers, v.name)
end
--注入一个blossom的标志位。下次groupload时如果为1,说明
table.insert(variables,{ config_id=50000001,name = "HasStarted", value = 0, no_refresh = true})
end
----------------------------------
--group加载时,直接把suite2的trigger刷出来
function action_group_load(context, evt)
ScriptLib.PrintContextLog(context,"OreBG: Group has been loaded!")
ScriptLib.SetGroupVariableValue(context,"GroupCompletion",0)
--group load时判定一下这个group是否已经开启,如果已经开启则无事发生
local has_started = ScriptLib.GetGroupVariableValue(context,"HasStarted")
if (has_started == 1) then
ScriptLib.PrintContextLog(context,"BG: Group has been started, refresh failed!")
return 0
end
ScriptLib.RefreshBlossomGroup(context, { group_id = 0, suite = 2, exclude_prev = true, is_delay_unload = true })
return 0
end
--group刷新时,加载suite3的魔晶矿,并重置blossom group计数
function action_group_refresh(context, evt)
ScriptLib.PrintContextLog(context,"OreBG: Group has been refreshed!")
--将循环营地进度置为2(循环营地进行中)
ScriptLib.SetBlossomScheduleStateByGroupId(context,0,2)
--加载suite3的魔晶矿
ScriptLib.AddExtraGroupSuite(context,0,3)
--group重置为没有开始的状态
ScriptLib.SetGroupVariableValue(context,"HasStarted",1)
return 0
end
--魔晶矿被挖掉的时候,增加循环营地进度
function action_any_gadget_die(context,evt)
ScriptLib.PrintContextLog(context,"OreBG: Player get 1 ore!")
ScriptLib.AddBlossomScheduleProgressByGroupId(context, 0)
return 0
end
--循环营地打满后,刷新循环营地状态,并将GroupCompletion置为1
function action_blossom_progress_finish(context,evt)
ScriptLib.PrintContextLog(context,"OreBG: This ore blossom group has been finished!")
--将循环营地进度置为3(循环营地完成)
ScriptLib.SetBlossomScheduleStateByGroupId(context,0,3)
ScriptLib.SetGroupVariableValue(context,"GroupCompletion",1)
--group重置为没有开始的状态
ScriptLib.SetGroupVariableValue(context,"HasStarted",0)
return 0
end
----------------------------------
Initialize()
@@ -0,0 +1,18 @@
function LF_Initialize_Group(triggers, suites)
table.insert(variables,{ config_id=50000001,name = "takedConfigID", value = 0, no_refresh = true})
table.insert(variables,{ config_id=50000002,name = "takeCount", value = 0})
--初始化
end
function PhotoTakenSuccessfully(context)
local entityID=0
ScriptLib.ChangeGroupVariableValue(context, "takeCount", 1)
for i=1,#gadgets do
entityID=ScriptLib.GetEntityIdByConfigId(context, gadgets[i].config_id)
if entityID==context.target_entity_id or entityID==context.source_entity_id then
ScriptLib.SetGroupVariableValue(context, "takedConfigID", gadgets[i].config_id)
end
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,319 @@
--[[
雷共鸣石黑河玩法
ServerUploadTool Save to [/root/env/data/lua/common/V2_0]
]]--
local RaioPillars={181006,181007,181008,181009,181010}
local extraTriggers={
{ config_id = 8000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 },
{ config_id = 8000002, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
{ config_id = 8000003, name = "VARIBLE_CHANGE", event = EventType.EVENT_VARIABLE_CHANGE, source = "step", condition = "", action = "action_step_change", trigger_count = 0 },
{ config_id = 8000004, name = "MONSTRE_DIE", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_monster_die", trigger_count = 0 },
{ config_id = 8000005, name = "GADGET_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
{ config_id = 8000006, name = "AXIS_SUCCESS", event = EventType.EVENT_TIME_AXIS_PASS, source = "checkSuccess", condition = "", action = "action_axis_success", trigger_count = 0 },
{ config_id = 8000007, name = "AXIS_FAIL", event = EventType.EVENT_TIME_AXIS_PASS, source = "checkFail", condition = "", action = "action_axis_fail", trigger_count = 0 },
{ config_id = 8000008, name = "GROUP_REFRESH", event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0 },
{ config_id = 8000009,name = "group_will_unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0 },
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[2].triggers,extraTriggers[i].name)
end
table.insert(variables,{ config_id=50000001,name = "step", value = 0, no_refresh = false})
table.insert(variables,{ config_id=50000002,name = "killMonster", value = 0, no_refresh = false})
table.insert(variables,{ config_id=50000003,name = "RaioCotterDoLaserSkill", value = 0, no_refresh = false})
--初始化
end
function DeleteLaserSkill(context)
ScriptLib.KillEntityByConfigId(context, { config_id = 181027 })
return 0
end
function RaioCotterDoLaserSkill(context)
local RaioCotterDoLaserSkill = ScriptLib.GetGroupVariableValue(context, "RaioCotterDoLaserSkill")
RaioCotterDoLaserSkill=RaioCotterDoLaserSkill+1
ScriptLib.SetGroupVariableValue(context, "RaioCotterDoLaserSkill", RaioCotterDoLaserSkill)
ScriptLib.CreateGadget(context, { config_id = 181027 })
ScriptLib.SetGadgetStateByConfigId(context, 181001, 901)
return 0
end
--把所有雷桩的状态重置
function ResetAllGadgets(context)
ScriptLib.SetGadgetStateByConfigId(context, 181006, GadgetState.Default)
ScriptLib.SetGadgetStateByConfigId(context, 181007, GadgetState.Default)
ScriptLib.SetGadgetStateByConfigId(context, 181008, GadgetState.Default)
ScriptLib.SetGadgetStateByConfigId(context, 181009, GadgetState.Default)
ScriptLib.SetGadgetStateByConfigId(context, 181010, GadgetState.Default)
return 0
end
function SetAllOptions(context)
ScriptLib.SetGadgetStateByConfigId(context, 181006, 201)
ScriptLib.SetWorktopOptionsByGroupId(context, 133220181, 181006, {80})
ScriptLib.SetWorktopOptionsByGroupId(context, 133220181, 181007, {79})
ScriptLib.SetWorktopOptionsByGroupId(context, 133220181, 181008, {79})
ScriptLib.SetWorktopOptionsByGroupId(context, 133220181, 181009, {79})
ScriptLib.SetWorktopOptionsByGroupId(context, 133220181, 181010, {79})
return 0
end
function RemoveAllOptions(context)
ScriptLib.DelWorktopOptionByGroupId(context, 133220181, 181006, 80)
ScriptLib.DelWorktopOptionByGroupId(context, 133220181, 181007, 79)
ScriptLib.DelWorktopOptionByGroupId(context, 133220181, 181008, 79)
ScriptLib.DelWorktopOptionByGroupId(context, 133220181, 181009, 79)
ScriptLib.DelWorktopOptionByGroupId(context, 133220181, 181010, 79)
return 0
end
function CheckConnectPhaseOne(context)
if 203 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181007) then
return false
end
if 204 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181008) then
return false
end
if 902 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181009) then
return false
end
if 901 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181010) then
return false
end
return true
end
function CheckConnectPhaseTwo(context)
if 901 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181007) then
return false
end
if 902 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181008) then
return false
end
if 204 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181009) then
return false
end
if 203 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181010) then
return false
end
return true
end
function CheckConnectPhaseThree(context)
if 203 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181007) then
return false
end
if 204 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181008) then
return false
end
if 204 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181009) then
return false
end
if 203 ~= ScriptLib.GetGadgetStateByConfigId(context, 133220181, 181010) then
return false
end
return true
end
--triggers
function action_group_will_unload(context, evt)
ScriptLib.RemoveEntityByConfigId(context, 133220181, EntityType.MONSTER, 181011)
ScriptLib.RemoveEntityByConfigId(context, 133220181, EntityType.MONSTER, 181088)
ScriptLib.RemoveEntityByConfigId(context, 133220181, EntityType.MONSTER, 181058)
ScriptLib.RemoveEntityByConfigId(context, 133220181, EntityType.MONSTER, 181003)
return 0
end
function action_gadget_state_change(context, evt)
if evt.param2==181001 and evt.param1==0 then
local step=ScriptLib.GetGroupVariableValue(context, "step")
if step == 3 then
ScriptLib.ShowReminder(context, 7210504)
ScriptLib.CreateMonster(context, { config_id = 181088, delay_time = 5 })
end
if step==5 then
ScriptLib.ShowReminder(context, 7210505)
ScriptLib.CreateMonster(context, { config_id = 181058, delay_time = 5 })
ScriptLib.CreateMonster(context, { config_id = 181003, delay_time = 5 })
end
end
return 0
end
--处理对应的阶段创建出对应的解图案
function action_step_change(context, evt)
if evt.param1==2 then
ScriptLib.AddExtraGroupSuite(context, 133220181, 8)
end
if evt.param1==4 then
ScriptLib.AddExtraGroupSuite(context, 133220181, 9)
end
if evt.param1==6 then
ScriptLib.AddExtraGroupSuite(context, 133220181, 10)
end
return 0
end
function action_monster_die(context, evt)
--[[
if 0==ScriptLib.GetGroupMonsterCount(context) then
--根据死的是哪个怪物来推进玩法进度
if evt.param1==181011 then
ScriptLib.SetGroupVariableValue(context, "step",2)
end
if evt.param1==181088 then
ScriptLib.SetGroupVariableValue(context, "step", 4)
end
if (evt.param1==181058) or (evt.param1==181003) then
ScriptLib.SetGroupVariableValue(context, "step", 6)
end
--打开所有雷桩的按钮
SetAllOptions(context)
else
ScriptLib.PrintContextLog(context, "剩余怪物"..ScriptLib.GetGroupMonsterCount(context))
end
]]--
if evt.param1==181011 then
ScriptLib.SetGroupVariableValue(context, "step",2)
SetAllOptions(context)
end
if evt.param1==181088 then
ScriptLib.SetGroupVariableValue(context, "step", 4)
SetAllOptions(context)
end
if (evt.param1==181058) or (evt.param1==181003) then
if ScriptLib.GetGroupVariableValue(context, "killMonster")==1 then
ScriptLib.SetGroupVariableValue(context, "step", 6)
SetAllOptions(context)
else
ScriptLib.SetGroupVariableValue(context, "killMonster", 1)
end
end
return 0
end
--刷到suite2时,初始化关卡
function action_group_refresh(context, evt)
if evt.param1==2 then
ScriptLib.SetGroupVariableValue(context, "step", 1)
ScriptLib.CreateMonster(context, { config_id = 181011, delay_time = 0 })
ScriptLib.SetGroupVariableValue(context, "killMonster", 0)
end
return 0
end
function action_group_load(context, evt)
ScriptLib.SetGroupVariableValue(context, "step", 1)
ScriptLib.CreateMonster(context, { config_id = 181011, delay_time = 0 })
ScriptLib.SetGroupVariableValue(context, "killMonster", 0)
return 0
end
--判定成功
function action_axis_success(context, evt)
ScriptLib.SetGadgetStateByConfigId(context, 181001, GadgetState.GearStart)
ResetAllGadgets(context)
local step=ScriptLib.GetGroupVariableValue(context, "step")
if step == 2 then
ScriptLib.KillExtraGroupSuite(context, 133220181, 8)
ScriptLib.SetGroupVariableValue(context, "step",3)
ScriptLib.ShowReminder(context, 7210503)
end
if step==4 then
ScriptLib.KillExtraGroupSuite(context, 133220181, 9)
ScriptLib.SetGroupVariableValue(context, "step",5)
end
if step==6 then
ScriptLib.KillExtraGroupSuite(context, 133220181, 10)
ScriptLib.SetGroupVariableValue(context, "step",7)
end
return 0
end
--判定失败
function action_axis_fail(context, evt)
--归还按钮
SetAllOptions(context)
ResetAllGadgets(context)
return 0
end
function action_select_option(context, evt)
if evt.param2==79 then
local _gadgetStateList = {203,204,901,902}
local _key = 0
for k,v in pairs(_gadgetStateList) do
if v == ScriptLib.GetGadgetStateByConfigId(context, 133220181, evt.param1) then
_key = k
break
end
end
if 0 == _key then
ScriptLib.SetGroupGadgetStateByConfigId(context, 133220181, evt.param1, _gadgetStateList[1])
return 0
end
_key = _key + 1
_key = _key%#_gadgetStateList
if 0 == _key then
_key = #_gadgetStateList
end
if 0 ~= ScriptLib.SetGroupGadgetStateByConfigId(context, 133220181, evt.param1, _gadgetStateList[_key]) then
ScriptLib.PrintContextLog(context, "@@ LUA_WARNING : set_gadget_state_by_IndexStep")
return -1
end
end
if evt.param2==80 then
ScriptLib.SetGadgetStateByConfigId(context, 181006, GadgetState.GearStop)
RemoveAllOptions(context)
local step=ScriptLib.GetGroupVariableValue(context, "step")
if step == 2 then
if CheckConnectPhaseOne(context)==true then
ScriptLib.InitTimeAxis(context, "checkSuccess", {3}, false)
else
ScriptLib.InitTimeAxis(context, "checkFail", {3}, false)
end
end
if step==4 then
if CheckConnectPhaseTwo(context)==true then
ScriptLib.InitTimeAxis(context, "checkSuccess", {3}, false)
else
ScriptLib.InitTimeAxis(context, "checkFail", {3}, false)
end
end
if step==6 then
if CheckConnectPhaseThree(context)==true then
ScriptLib.InitTimeAxis(context, "checkSuccess", {3}, false)
else
ScriptLib.InitTimeAxis(context, "checkFail", {3}, false)
end
end
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,49 @@
--[[
使用region进行性能优化
]]--
local extraTriggers={
{config_id = 9000001, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", forbid_guest = false,trigger_count = 0 },
{config_id = 9000002,name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
}
function Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[1].triggers,extraTriggers[i].name)
end
--初始化
end
function action_EVENT_ENTER_REGION(context, evt)
if evt.param1~=defs.inner_region then
return 0
end
--设置视野锚点
ScriptLib.SetPlayerEyePoint(context, defs.inner_region, defs.related_region)
ScriptLib.SetLimitOptimization(context, context.uid, true)
--环境小动物优化
ScriptLib.SwitchSceneEnvAnimal(context, 0)
--设置visiontype
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
--禁用visiontype变化
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 1, { group_id = 133213025})
return 0
end
function action_EVENT_LEAVE_REGION(context, evt)
if evt.param1~=defs.outer_region then
return 0
end
--关闭视野锚点
ScriptLib.ClearPlayerEyePoint(context, defs.inner_region)
ScriptLib.SetLimitOptimization(context, context.uid, false)
--环境小动物优化
ScriptLib.SwitchSceneEnvAnimal(context, 2)
--重置visiontype
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 0, { group_id = 133213025})
return 0
end
Initialize_Group(triggers, suites)
@@ -0,0 +1,77 @@
--[[
使用region进行性能优化
]]--
local whiteList={
133220037,
133210237,
}
local extraTriggers={
{config_id = 9000001, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", forbid_guest = false,trigger_count = 0 },
{config_id = 9000002,name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
}
function Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--初始化
end
function action_EVENT_ENTER_REGION(context, evt)
if evt.param1~=defs.inner_region then
return 0
end
--设置视野锚点
local isInWhiteList=0
local curGroup=ScriptLib.GetContextGroupId(context)
for i=1,#whiteList do
if whiteList[i]==curGroup then
isInWhiteList=isInWhiteList+1
end
end
if isInWhiteList>=1 then
ScriptLib.SetPlayerEyePointStream(context, defs.inner_region, defs.related_region, false)
else
ScriptLib.SetPlayerEyePointStream(context, defs.inner_region, defs.related_region, true)
end
ScriptLib.SetLimitOptimization(context, context.uid, true)
--环境小动物优化
ScriptLib.SwitchSceneEnvAnimal(context, 0)
if defs.bossRegionSpecialOptimization==nil then
--设置visiontype
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
else
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {30010001})
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
end
--禁用visiontype变化
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 1, { group_id = 133213025})
return 0
end
function action_EVENT_LEAVE_REGION(context, evt)
if evt.param1~=defs.outer_region then
return 0
end
--关闭视野锚点
ScriptLib.ClearPlayerEyePoint(context, defs.inner_region)
ScriptLib.SetLimitOptimization(context, context.uid, false)
--环境小动物优化
ScriptLib.SwitchSceneEnvAnimal(context, 2)
--重置visiontype
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
if defs.bossRegionSpecialOptimization~=nil then
ScriptLib.RevertPlayerRegionVision(context, context.uid)
end
--重置visiontype
ScriptLib.SetGroupTempValue(context, "optimize_"..context.uid, 0, { group_id = 133213025})
return 0
end
Initialize_Group(triggers, suites)
@@ -0,0 +1,77 @@
--[[
使用region进行性能优化
]]--
local whiteList={
133220037,
133210237,
}
local extraTriggers={
{config_id = 9000001, name = "ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", forbid_guest = false,trigger_count = 0 },
{config_id = 9000002,name = "LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", forbid_guest = false, trigger_count = 0 },
}
function Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
--初始化
end
function action_EVENT_ENTER_REGION(context, evt)
if evt.param1~=defs.inner_region then
return 0
end
--设置视野锚点
local isInWhiteList=0
local curGroup=ScriptLib.GetContextGroupId(context)
for i=1,#whiteList do
if whiteList[i]==curGroup then
isInWhiteList=isInWhiteList+1
end
end
if isInWhiteList>=1 then
ScriptLib.SetPlayerEyePointStream(context, defs.inner_region, defs.related_region, false)
else
ScriptLib.SetPlayerEyePointStream(context, defs.inner_region, defs.related_region, true)
end
ScriptLib.SetLimitOptimization(context, context.uid, true)
--环境小动物优化
ScriptLib.SwitchSceneEnvAnimal(context, 0)
if defs.bossRegionSpecialOptimization==nil then
--设置visiontype
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {0})
else
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {30010001})
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
end
--禁用LD配置的visiontype变化
ScriptLib.ForbidPlayerRegionVision(context, context.uid)
return 0
end
function action_EVENT_LEAVE_REGION(context, evt)
if evt.param1~=defs.outer_region then
return 0
end
--关闭视野锚点
ScriptLib.ClearPlayerEyePoint(context, defs.inner_region)
ScriptLib.SetLimitOptimization(context, context.uid, false)
--环境小动物优化
ScriptLib.SwitchSceneEnvAnimal(context, 2)
--重置visiontype
ScriptLib.SetPlayerGroupVisionType(context, {context.uid}, {1})
if defs.bossRegionSpecialOptimization~=nil then
ScriptLib.RevertPlayerRegionVision(context, context.uid)
end
--还原LD配置的visiontype变化
ScriptLib.RevertPlayerRegionVision(context, context.uid)
return 0
end
Initialize_Group(triggers, suites)
@@ -0,0 +1,96 @@
local gadget_list = {{key="water",id=70350281},{key="fire",id=70350282},{key="ice",id=70350283},{key="wind",id=70350284},{key="electric",id=70350285},{key="none",id=70350286}}
local var = {
["common"] = {"SGV_AttackDamageLevel","SGV_ElementMasteryLevel","SGV_AttackSpeedLevel","SGV_RangeLevel"},
["water"] = {"SGV_Bubble","SGV_WaterImpulse","SGV_Evaporate","SGV_Wet","SGV_TargetAOE","SGV_Dot"},
["fire"] = {"SGV_Aoe","SGV_Enbreak","SGV_FireImpulse","SGV_Melt","SGV_Defensedown","SGV_FireArea","SGV_Missile"},
["ice"] = {"SGV_Explosion","SGV_Slowdown","SGV_IceImpulse","SGV_Frozen","SGV_Resistancedown","SGV_TDSpecialGrade_Ice","SGV_Ice_Fog"},
["wind"] = {"SGV_UpgradeRepulse","SGV_TowUnits","SGV_WindImpulse","SGV_ReduceWindResistance","SGV_ExtraDamageByHp","SGV_ShootBullet","SGV_CanCharge"},
["electric"] = {"SGV_ExtraTargets","SGV_Confine","SGV_ElectricImpulse","SGV_UpgradeElectricRecation","SGV_FurySwipe","SGV_ExtraThunder","SGV_UpgradeNormalAttack"},
["none"] = {"SGV_HitExplosion","SGV_ReducePhysicalResistance","SGV_DamageByTime","SGV_WantedSign","SGV_EnergyBallAttack"},
}
local tri = {
[1] = {config_id=10000, name="group_load", event=EventType.EVENT_GROUP_LOAD, source="", condition="", action="action_group_load", trigger_count=0},
[2] = {config_id=10001, name="group_refresh", event=EventType.EVENT_GROUP_REFRESH, source="", condition="", action="action_group_load", trigger_count=0},
[3] = {config_id=10002, name="variable_change", event=EventType.EVENT_VARIABLE_CHANGE, source="", condition="", action="action_variable_change", trigger_count=0}
}
function Initialize()
for i,v in ipairs(points) do
if i > #gadget_list then
break
end
if points[i] == nil then
break
end
temp_gadget = {config_id = 8000+i, gadget_id = gadget_list[i].id, pos = points[i].pos, rot = points[i].rot, level = 1}
table.insert(gadgets, temp_gadget)
--table.insert(suites[1].gadgets, temp_gadget.config_id)
end
------------
for k,v in pairs(var) do
for m,n in ipairs(v) do
local _var = { name = n, value = 0, no_refresh = true }
table.insert(variables, _var)
end
end
-------------
for i,v in ipairs(tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
function action_group_load(context, evt)
ScriptLib.PrintLog("--------------- v4 -----------------")
for i,v in ipairs(gadget_list) do
local SGV_table = {}
for p,q in ipairs(var.common) do
SGV_table[q] = 0
end
for m,n in ipairs(var) do
if m == v.key then
for p,q in ipairs(n) do
SGV_table[q] = 0
end
end
end
--[[
for k,v in pairs(SGV_table) do
ScriptLib.PrintContextLog(context, "k="..k.." | v="..v)
end
--]]
--ScriptLib.CreateGadgetWithGlobalValue(context, 8000+i, SGV_table)
ScriptLib.CreateGadgetWithGlobalValue(context, 8000+i, {})
end
return 0
end
function action_variable_change(context, evt)
--local value = ScriptLib.GetGroupVariableValue(context, evt.source_name)
for k,v in pairs(var) do
for p,q in ipairs(v) do
if q == evt.source_name then
if k == "common" then
for m,n in ipairs(gadget_list) do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, 8000+m, evt.source_name, evt.param1)
end
return 0
else
for m,n in ipairs(gadget_list) do
if n.key == k then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, 8000+m, evt.source_name, evt.param1)
end
end
return 0
end
end
end
end
return 0
end
Initialize()
@@ -0,0 +1,672 @@
--2.0奥博伦派对玩法
--local defs = {
-- group_id = 111101122 ,
-- tamari_gadget_id = defs.temari_gadget_id,
-- host_option_id = 184,
-- guset_option_id = 185,
-- host_chest_id = 122001,
--}
local tempDefs = {
pre_quest = 7217605,
host_option = 2351,
guest_option = 2350,
find_ball_challenge_offline = 244,
hide_ball_challenge = 236,
find_ball_challenge = 235,
father_hide_ball_challenge = 242,
father_find_ball_challenge = 243,
challenge_time = 30
}
local chests = {}
local temari_gadgets = {}
local Tri1 = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "quest_finish", config_id = 8000002, event = EventType.EVENT_QUEST_FINISH, source = "",condition = "",action = "action_quest_finish",trigger_count= 0},
}
local Tri2 = {
[1] = { name = "quest_start", config_id = 8000003, event = EventType.EVENT_QUEST_START, source = "",condition = "",action = "action_quest_start",trigger_count= 0},
[2] = { name = "challenge_success", config_id = 8000004, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "",condition = "",action = "action_challenge_success",trigger_count= 0},
[3] = { name = "challenge_fail", config_id = 8000005, event = EventType.EVENT_CHALLENGE_FAIL, source = "",condition = "",action = "action_challenge_fail",trigger_count= 0},
[4] = { name = "select_option", config_id = 8000006, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0, forbid_guest = false },
[5] = { name = "group_refresh", config_id = 8000007, event = EventType.EVENT_GROUP_REFRESH, source = "", condition = "", action = "action_group_refresh", trigger_count = 0},
[6] = { name = "gadget_create", config_id = 8000008, event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_gadget_create", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri1) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
for k,v in pairs(Tri2) do
table.insert(triggers, v)
table.insert(suites[2].triggers, v.name)
end
table.insert(chests,defs.chest_1)
table.insert(chests,defs.chest_2)
table.insert(chests,defs.chest_3)
--table.insert(chests,defs.chest_online)
table.insert(temari_gadgets,defs.temari_1)
table.insert(temari_gadgets,defs.temari_2)
table.insert(temari_gadgets,defs.temari_3)
table.insert(temari_gadgets,defs.temari_online)
table.insert(variables,{ config_id=50000001,name = "has_hidden", value = 0,no_refresh = true})
--记录uid的低四位
table.insert(variables,{ config_id=50000002,name = "challenger_uid1", value = 0})
--记录uid的高位,challenger_uid2*10000+challenger_uid就是最后正确的uid
table.insert(variables,{ config_id=50000003,name = "challenger_uid2", value = 0})
--记录放球的小数位
table.insert(variables,{ config_id=50000004,name = "pos_x1", value = 0})
table.insert(variables,{ config_id=50000005,name = "pos_z1", value = 0})
end
--------------------------------------------------------------------
--group load时,无事发生
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"TMR: Group Load!")
LF_Initiate_Play(context)
return 0
end
--group refresh时,重置group状态,回到第一关
function action_group_refresh(context,evt)
ScriptLib.PrintContextLog(context,"TMR: Group Refresh!")
LF_Reset_Group(context)
return 0
end
--任务开始时,加载下一关(单机挑战)
function action_quest_start(context,evt)
ScriptLib.PrintContextLog(context,"TMR: Player has triggered some quest!!")
--校验一下任务id,确保是奥博伦任务触发的任务开始
if string.sub(evt.param1,1,5) == tostring(defs.FatherQuest) then
ScriptLib.PrintContextLog(context,"TMR: Triggered quest is :"..evt.param1)
LF_Set_Challenge_State(context,1)
LF_Load_Next_Level(context)
LF_Start_Challenge(context,0)
end
return 0
end
--操作台创建时,直接挂选项
function action_gadget_create(context,evt)
if (evt.param1 == defs.temari_gadget_id) then
LF_Set_Gadget_Option(context)
end
return 0
end
function action_quest_finish(context,evt)
ScriptLib.PrintContextLog(context,"TMR: pre quest has been finished, load the second suite!!")
if (evt.param1 == tempDefs.pre_quest) then
LF_Initiate_Play(context)
end
return 0
end
--选择了选项,根据当前主客机,触发不同的挑战(联机挑战)
function action_select_option(context,evt)
--试图开启主机藏球挑战
if evt.param2 == tempDefs.host_option then
--藏球挑战
if LF_Is_Host(context) then
if LF_Get_Challenge_State(context) == 10 or LF_Get_Challenge_State(context) == 12 then
--仅在联机玩法初始化以及主机已完成藏球的情况下,可以开启藏球挑战
ScriptLib.PrintContextLog(context,"TMR: !!!!!!!!!!!!Hide ball challenge starts!!!!!!!")
LF_Load_Online_Level(context,1)
LF_Set_Challenge_State(context,11)
LF_Start_Challenge(context,1)
ScriptLib.DelWorktopOptionByGroupId(context,defs.group_id,defs.temari_gadget_id,tempDefs.host_option)
elseif LF_Get_Challenge_State(context) == 11 then
--主机在藏球挑战中再次交互,试图开启藏球挑战(理论上不存在这种情况)
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!! Cannot start duplicated challenges!!!")
elseif LF_Get_Challenge_State(context) == 13 then
--客机正在找球,不允许主机开启藏球挑战
ScriptLib.SendServerMessageByLuaKey(context, "GUEST_CHALLENGING", {context.uid})
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!! Guest is challenging!!!")
end
else
--客机不能开启主机的藏球挑战
ScriptLib.SendServerMessageByLuaKey(context, "HOST_ONLY_CHALLENGE", {context.uid})
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Guest cannot hide ball!")
end
end
if evt.param2 == tempDefs.guest_option then
--找球挑战(允许主机也开启挑战,因此这里不做主客机的区分)
if LF_Get_Challenge_State(context)==12 then
--主机已完成藏球,可以开始挑战
ScriptLib.PrintContextLog(context,"TMR: !!!!!!!!!!!Find ball challenge starts!!!!!!!!!!!!")
LF_Load_Online_Level(context,2)
local ret = LF_Start_Challenge(context,2)
if (ret == -1) then
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Same gallery is activating!")
LF_Online_Hide_Level(context)
return 0
end
LF_Set_Challenge_State(context,13)
ScriptLib.DelWorktopOptionByGroupId(context,defs.group_id,defs.temari_gadget_id,tempDefs.guest_option)
elseif LF_Get_Challenge_State(context)== 10 then
--主机没有藏球,不能挑战
ScriptLib.SendServerMessageByLuaKey(context, "LEVEL_NOT_SETTLED", {context.uid})
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Host hasn't hide the ball!")
elseif LF_Get_Challenge_State(context)== 11 then
--主机正在藏球,不能挑战
ScriptLib.SendServerMessageByLuaKey(context, "LEVEL_SETTLING", {context.uid})
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Host is hiding the ball!")
elseif LF_Get_Challenge_State(context)== 13 then
--挑战中试图再开启一个找球挑战,理论上不存在这种情况
ScriptLib.PrintContextLog(context,"TMR: CHALLENGE FAILS!!!! Cannot start duplicated challenges!!!")
end
end
return 0
end
--分别处理单机玩法和联机玩法挑战失败的情况
function action_challenge_fail(context,evt)
if LF_Get_Play_Phase(context) == 1 then
if evt.param1 == tempDefs.find_ball_challenge_offline then
ScriptLib.PrintContextLog(context,"TMR: Offline Challenge fails!")
LF_Stop_Temari_Gallery(context)
LF_Update_Quest_State(context,false)
end
else
--联机挑战阶段挑战失败
if evt.param1 == tempDefs.father_hide_ball_challenge then
--藏球失败
ScriptLib.PrintContextLog(context,"TMR: Host Challenge fails!")
--创建一个藏球宝箱 5.27需求,不需要联机奖励宝箱了
--ScriptLib.CreateGadget(context,{config_id=chests[#chests]})
--修改挑战状态。如果玩家至少藏过一次球,则即使失败,也将状态置为12(即藏过球),否则置为10,认为没有藏球
if (LF_Has_Hidden_Ball(context)) then
LF_Set_Challenge_State(context,12)
else
LF_Set_Challenge_State(context,10)
end
LF_Set_Gadget_Option(context)
--移除掉联机用的关卡布设
LF_Online_Hide_Level(context)
--LF_Teleport_Player(context)
end
if evt.param1 == tempDefs.father_find_ball_challenge then
--客机找球挑战失败
ScriptLib.PrintContextLog(context,"TMR: Guest Challenge fails!")
LF_Set_Challenge_State(context,12)
--移除掉联机用的关卡布设
LF_Online_Hide_Level(context)
LF_Set_Gadget_Option(context)
LF_Stop_Temari_Gallery(context)
end
end
return 0
end
--分别处理单机玩法和联机玩法挑战成功的情况
function action_challenge_success(context,evt)
ScriptLib.PrintContextLog(context,"TMR: Some challenge has been finished!!!")
if LF_Get_Play_Phase(context) == 1 then
if evt.param1 == tempDefs.find_ball_challenge_offline then
ScriptLib.PrintContextLog(context,"TMR: Offline Challenge success!")
LF_Stop_Temari_Gallery(context)
LF_Update_Quest_State(context,true)
--创建一个单机找球挑战宝箱,仅单机挑战的最后一关给一个宝箱
if (LF_Get_OfflineChallenge_Level(context)-2 == 3) then
ScriptLib.CreateGadget(context,{config_id=chests[LF_Get_OfflineChallenge_Level(context)-2]})
end
end
else
--联机挑战阶段挑战成功
if evt.param1 == tempDefs.father_hide_ball_challenge then
--藏球挑战成功
ScriptLib.PrintContextLog(context,"TMR: Host Challenge finishes!")
--创建一个藏球宝箱 5.27需求,不需要联机奖励宝箱了
--ScriptLib.CreateGadget(context,{config_id=chests[#chests]})
--修改挑战状态
LF_Set_Challenge_State(context,12)
LF_Set_Gadget_Option(context)
LF_Teleport_Player(context)
end
if evt.param1 == tempDefs.father_find_ball_challenge then
--找球挑战成功,挑战状态回到12
ScriptLib.PrintContextLog(context,"TMR: Guest Challenge success!")
LF_Set_Challenge_State(context,12)
--移除掉联机用的关卡布设
LF_Online_Hide_Level(context)
LF_Set_Gadget_Option(context)
LF_Stop_Temari_Gallery(context)
end
end
return 0
end
--------------------------------------------------------------------
--辅助方法-----------------------------------------------------------
--------------------------------------------------------------------
--关卡相关方法---------------------------------------------------
--初始化整个玩法的方法,仅当groupload时调用
function LF_Initiate_Play(context)
local uidList = ScriptLib.GetSceneUidList(context)
--上线的时候如果同时group load,可能找不到uidlist,做一个保护
if (uidList == nil or #uidList == 0) then
return 0
end
local avatar_entity = ScriptLib.GetAvatarEntityIdByUid(context, uidList[1])
local quest_state = ScriptLib.GetQuestState(context, avatar_entity, tempDefs.pre_quest)
ScriptLib.PrintContextLog(context,"TMR: Prequest state is: "..quest_state)
if ScriptLib.GetQuestState(context, avatar_entity, tempDefs.pre_quest) == QuestState.FINISHED then
ScriptLib.PrintContextLog(context,"TMR: pre quest has been finished, group load!!")
local ret = ScriptLib.GoToGroupSuite(context,defs.group_id,2)
--将当前suite切换到2,确保下一次从suite3开始加载
LF_Set_OfflineChallenge_Level(context,2)
ScriptLib.PrintContextLog(context,"TMR: The result of loading suite 2 : "..ret)
end
end
--加载单机挑战的下一个关卡
function LF_Load_Next_Level(context)
local curLevel = LF_Get_OfflineChallenge_Level(context)
curLevel = curLevel + 1
ScriptLib.PrintContextLog(context,"TMR: Ready to load SUITE: "..curLevel)
LF_Set_OfflineChallenge_Level(context,curLevel)
ScriptLib.AddExtraGroupSuite(context,defs.group_id,curLevel)
end
--初始化联机玩法
function LF_Initiate_Online_Challenge(context)
--把交互用的奥博伦球创建出来
ScriptLib.CreateGadget(context,{config_id = defs.temari_gadget_id})
--给奥博伦交互球设置选项
LF_Set_Gadget_Option(context)
end
--加载联机挑战的关卡
--phase = 1:主机藏球挑战;phase = 2:客机找球挑战
function LF_Load_Online_Level(context,phase)
if ( phase == 1 ) then
--加载最后一组suite(和LD约定最后一组suite为联机关卡)
ScriptLib.AddExtraGroupSuite(context,0,#suites)
--去掉场景内现在藏着的球
ScriptLib.KillEntityByConfigId(context,{config_id = defs.temari_online})
else
--加载最后一组suite(和LD约定最后一组suite为联机关卡)
ScriptLib.AddExtraGroupSuite(context,0,#suites)
--把存储的球的位置加载出来
local pos = LF_Load_Online_Temari_Pos(context)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.temari_online, {x=pos.x,y=pos.y,z=pos.z}, {x=0,y=0,z=0})
end
end
--重置整个group的方法,将group还原至最初的状态
function LF_Reset_Group(context)
if LF_Get_Play_Phase(context) == 1 then
LF_Set_OfflineChallenge_Level(context,2)
LF_Set_Challenge_State(context,0)
else
--移除掉联机用的关卡布设
ScriptLib.RemoveExtraGroupSuite(context,0,#suites)
ScriptLib.KillEntityByConfigId(context,{config_id = defs.temari_online})
LF_Set_Challenge_State(context,10)
LF_Set_Gadget_Option(context)
end
end
--gallery/challenge/quest相关方法--------------------------------------------------
--启动挑战的方法,对于联机挑战,需要把启动的子挑战挂在父挑战上一起启动。
--target:0:单机找球;1:联机藏球;2:联机找球
function LF_Start_Challenge(context,target)
if LF_Get_Play_Phase(context) == 1 then
--要求开启挑战,因为是单机的,直接开就可以了
ScriptLib.ActiveChallenge(context,tempDefs.find_ball_challenge_offline,tempDefs.find_ball_challenge_offline,tempDefs.challenge_time, 0, tempDefs.find_ball_challenge_offline, 1)
LF_Start_Temari_Gallery(context)
else
if (target == 2) then
local ret = LF_Start_Temari_Gallery(context)
--如果gallery没有开出来,说明同scene下已经有一个同名gallery了,整个玩法都不允许开启
if (ret == -1) then
return -1
end
--开启挑战的时候,存一下开启挑战者的uid
LF_Save_Challenger(context)
end
--联机状态下,要把子挑战挂给父挑战后再开启
local challenge = 0
local father_challenge = 0
if (target == 1) then
challenge = tempDefs.hide_ball_challenge
father_challenge = tempDefs.father_hide_ball_challenge
elseif target == 2 then
challenge = tempDefs.find_ball_challenge_offline
father_challenge = tempDefs.father_find_ball_challenge
end
local child_challenge_param_table = {tempDefs.challenge_time,0,challenge,1}
ScriptLib.CreateFatherChallenge(context, father_challenge, father_challenge, tempDefs.challenge_time, {success=2, fail=1})
ScriptLib.AttachChildChallenge(context, father_challenge, challenge, challenge, child_challenge_param_table, {context.uid},{success=1, fail=1})
ScriptLib.StartFatherChallenge(context,father_challenge)
end
return 0
end
--终止挑战的方法,challenge:目标的挑战ID
--target: 0:单机挑战;1:联机藏球;2:联机找球
--resulttrue=1false=0
function LF_Stop_Challenge(context,target,result)
if LF_Get_Play_Phase(context) == 1 then
--单机的直接关掉即可
ScriptLib.PrintContextLog(context,"TMR: Stop offline challenge here!!!")
ScriptLib.StopChallenge(context,tempDefs.find_ball_challenge_offline,result)
else
if (target == 1) then
--结束联机藏球挑战
ScriptLib.PrintContextLog(context,"TMR: Stop hide ball challenge with result: "..result)
ScriptLib.StopChallenge(context,tempDefs.father_hide_ball_challenge,result)
elseif (target == 2) then
--结束联机找球挑战
ScriptLib.PrintContextLog(context,"TMR: Stop find ball challenge with result: "..result)
ScriptLib.StopChallenge(context,tempDefs.father_find_ball_challenge,result)
end
end
end
--启动藏球的方向指示gallery
function LF_Start_Temari_Gallery(context)
local ret = ScriptLib.SetPlayerStartGallery(context, 9001, {context.uid})
--如果gallery没有开出来,说明同scene下已经有一个同名gallery了,整个玩法都不允许开启
if (ret == -1) then
return -1
end
local temari_pos = LF_Get_Temari_Pos(context)
ScriptLib.SetHandballGalleryBallPosAndRot(context, 9001, {x=temari_pos.x,y=temari_pos.y,z=temari_pos.z}, {x=0,y=0,z=0})
end
--关闭藏球的方向指示gallery
function LF_Stop_Temari_Gallery(context)
ScriptLib.StopGallery(context, 9001, true)
end
--根据参数更新单机挑战的任务状态,传入true为成功、false为失败
function LF_Update_Quest_State(context, questState)
local curLevel = LF_Get_OfflineChallenge_Level(context)
local quest_level = curLevel-2
local quest_suffix = "01"
if (questState) then
quest_suffix = "01"
else
quest_suffix = "02"
end
local quest_param = defs.group_id.."0"..quest_level..quest_suffix
local ret = ScriptLib.AddQuestProgress(context,quest_param)
ScriptLib.PrintContextLog(context,"TMR: quest param is "..quest_param)
ScriptLib.PrintContextLog(context,"TMR: The result of Adding quest progress is "..ret)
--不论挑战是否胜利,都要移除掉当前加载的关卡
ScriptLib.PrintContextLog(context,"TMR: The removed suite is "..curLevel)
ScriptLib.RemoveExtraGroupSuite(context,defs.group_id,curLevel)
--如果胜利,且是单机挑战的最后一个suite,胜利后直接进入联机玩法状态
if (questState) then
if (curLevel+1>=#suites) then
ScriptLib.PrintContextLog(context,"TMR:!!!!!!!!!!!!!!!!!Offline challenge has finished!!!!!!!!!!!!!!!!")
LF_Set_Challenge_State(context,10)
LF_Initiate_Online_Challenge(context)
end
end
--如果挑战失败,要将当前的关卡向前回滚一关,这样下次开启任务才能再次开启当前关卡
if (not questState) then
LF_Set_OfflineChallenge_Level(context,curLevel-1)
end
end
--通用类方法-----------------------------------------------------------
--将玩家传送回奥博伦球控制台附近
function LF_Teleport_Player(context)
local temari_worktop_id = ScriptLib.GetEntityIdByConfigId(context,defs.temari_gadget_id)
local temari_pos = ScriptLib.GetPosByEntityId(context, temari_worktop_id)
local uidlist = ScriptLib.GetSceneUidList(context)
ScriptLib.PrintContextLog(context,"TMR: Current host player is :"..uidlist[1])
ScriptLib.PrintContextLog(context,"TMR: The context uid is: "..context.uid)
if (LF_Is_Host(context)) then
ScriptLib.TransPlayerToPos(context, {uid_list = {uidlist[1]}, pos = {x=temari_pos.x,y=temari_pos.y,z=temari_pos.z}, radius = 1, rot = {x=0, y=0, z=1},is_skip_ui=false} )
else
ScriptLib.TransPlayerToPos(context, {uid_list = {context.uid}, pos = {x=temari_pos.x,y=temari_pos.y,z=temari_pos.z}, radius = 1, rot = {x=0, y=0, z=1},is_skip_ui=false} )
end
end
--给奥博伦球gadget设置选项
function LF_Set_Gadget_Option(context)
ScriptLib.SetWorktopOptionsByGroupId(context,defs.group_id,defs.temari_gadget_id,{tempDefs.guest_option,tempDefs.host_option})
end
--联机玩法中,隐藏关卡配置的方法,调用后隐藏掉当前的关卡配置以及放着的球
function LF_Online_Hide_Level(context)
--干掉藏起来的球
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.temari_online)
--干掉放置用关卡
ScriptLib.RemoveExtraGroupSuite(context,0,#suites)
end
--通用的放球方法,把球放下来并记录其位置
function LF_Hide_Ball(context)
local uid_list = ScriptLib.GetSceneUidList(context)
local avatar_id = ScriptLib.GetAvatarEntityIdByUid(context, uid_list[1])
local pos = ScriptLib.GetPosByEntityId(context, avatar_id)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.temari_online, {x=pos.x+1,y=pos.y+1.5,z=pos.z}, {x=0,y=0,z=0})
--存一下球的位置,马上要销毁掉
LF_Save_Online_Temari_Pos(context)
LF_Online_Hide_Level(context)
end
--挑战开启时,将挑战者记录下来
function LF_Save_Challenger(context)
ScriptLib.PrintContextLog(context,"TMR: Save challenger uid: "..context.uid)
--拆一下uid存下来,防止位数超了
local uid1 = context.uid % 10000 --低位
local uid2 = math.floor(context.uid / 10000) --高位
ScriptLib.SetGroupVariableValue(context,"challenger_uid1",uid1)
ScriptLib.SetGroupVariableValue(context,"challenger_uid2",uid2)
ScriptLib.PrintContextLog(context,"TMR: Saving uid2"..uid2)
ScriptLib.PrintContextLog(context,"TMR: Saving uid1"..uid1)
end
function LF_Is_Same_Challenger(context)
local uid1 = ScriptLib.GetGroupVariableValue(context,"challenger_uid1")
local uid2 = ScriptLib.GetGroupVariableValue(context,"challenger_uid2")
local uid = uid2 * 10000 + uid1
ScriptLib.PrintContextLog(context,"TMR: Player touching ball is: "..context.uid.." and the player set ball is "..uid)
return context.uid == uid
end
-----CRUD类方法-----------------------------------------------------------
--改变当前玩法状态
--0:group初始化状态,完全没有开始
--1:单机挑战进行中(用level参数确定当前正在进行的单机关卡数)
--10:已完成单机挑战,联机挑战未开启
--11:主机进行藏球挑战
--12:主机已完成藏球
--13:客机进行找球挑战
function LF_Set_Challenge_State(context,target_state)
ScriptLib.PrintContextLog(context,"TMR: Changing play state to: "..target_state)
ScriptLib.SetGroupVariableValue(context,"ChallengeState",target_state)
end
--获取当前玩法状态
--0:group初始化状态,完全没有开始
--1:单机挑战进行中(用level参数确定当前正在进行的单机关卡数)
--10:已完成单机挑战,联机挑战未开启
--11:主机进行藏球挑战
--12:主机已完成藏球
--13:客机进行找球挑战
function LF_Get_Challenge_State(context)
return ScriptLib.GetGroupVariableValue(context,"ChallengeState")
end
--设置单机挑战的当前关卡
function LF_Set_OfflineChallenge_Level(context,targetLevel)
ScriptLib.SetGroupVariableValue(context,"ChallengeLevel",targetLevel)
end
--读取单机挑战的当前关卡
function LF_Get_OfflineChallenge_Level(context)
return ScriptLib.GetGroupVariableValue(context,"ChallengeLevel")
end
--返回当前关卡的手鞠球位置
function LF_Get_Temari_Pos(context)
if (LF_Get_Play_Phase(context) == 1) then
--一阶段获取手鞠球的位置
local curLevel = LF_Get_OfflineChallenge_Level(context)
local temari_entity_id = ScriptLib.GetEntityIdByConfigId(context,temari_gadgets[curLevel-2])
local temari_pos = ScriptLib.GetPosByEntityId(context, temari_entity_id)
ScriptLib.PrintContextLog(context,"TMR: Temari pos: "..temari_pos.x..","..temari_pos.y..","..temari_pos.z)
return temari_pos
else
--二阶段获取手鞠球的位置
local temari_entity_id = ScriptLib.GetEntityIdByConfigId(context,defs.temari_online)
local temari_pos = ScriptLib.GetPosByEntityId(context, temari_entity_id)
ScriptLib.PrintContextLog(context,"TMR: Temari pos: "..temari_pos.x..","..temari_pos.y..","..temari_pos.z)
return temari_pos
end
end
--存储联机玩法中当前球的位置
function LF_Save_Online_Temari_Pos(context)
local pos = LF_Get_Temari_Pos(context)
ScriptLib.PrintContextLog(context,"TMR: Save Temari pos: "..pos.x..","..pos.y..","..pos.z)
local ret = ScriptLib.SetGroupVariableValue(context,"pos_x",math.floor(pos.x))
ScriptLib.SetGroupVariableValue(context,"pos_y",math.ceil(pos.y))
ScriptLib.SetGroupVariableValue(context,"pos_z",math.floor(pos.z))
ScriptLib.SetGroupVariableValue(context,"pos_x1",math.floor((pos.x-math.floor(pos.x))*10))
ScriptLib.SetGroupVariableValue(context,"pos_z1",math.floor((pos.z-math.floor(pos.z))*10))
ScriptLib.PrintContextLog(context,"TMR: set pos ret = "..ret)
end
--读取联机玩法中当前球的位置
function LF_Load_Online_Temari_Pos(context)
local pos_x = ScriptLib.GetGroupVariableValue(context,"pos_x")
local pos_y = ScriptLib.GetGroupVariableValue(context,"pos_y")
local pos_z = ScriptLib.GetGroupVariableValue(context,"pos_z")
local pos_x1 = ScriptLib.GetGroupVariableValue(context,"pos_x1")/10
local pos_z1 = ScriptLib.GetGroupVariableValue(context,"pos_z1")/10
ScriptLib.PrintContextLog(context,"TMR: Load Temari pos: "..pos_x+pos_x1..","..pos_y..","..pos_z+pos_z1)
local pos = {x=pos_x+pos_x1,y=pos_y,z=pos_z+pos_z1}
return pos
end
--返回玩家是否至少藏了一次球
function LF_Has_Hidden_Ball(context)
if ScriptLib.GetGroupVariableValue(context,"has_hidden")==1 then
return true
else
return false
end
end
--返回当前整体玩法进度
--phase1:单机挑战阶段
--phase2:联机挑战阶段(phase 2下刷新group不会再回到phase 1
function LF_Get_Play_Phase(context)
if (LF_Get_Challenge_State(context)<10) then
return 1
else
return 2
end
end
--返回当前(触发事件)的玩家是否是主机
function LF_Is_Host(context)
local uid_List = ScriptLib.GetSceneUidList(context)
local host_id = uid_List[1]
ScriptLib.PrintContextLog(context,"TMR: Current user id is "..context.uid)
ScriptLib.PrintContextLog(context,"TMR: Host user id is "..host_id)
return (host_id==context.uid) or (context.uid == 0)
end
--------------------------------------------------------------------
--server lua call---------------------------------------------------
--找球胜利,通过球自身的ability调用(调用时需要判定当前玩家主客机,如果是主机则无事发生)
function SLC_Find_Ball(context)
if LF_Get_Play_Phase(context) == 1 then
ScriptLib.PrintContextLog(context,"TMR: Player has found the ball!")
local curLevel = LF_Get_OfflineChallenge_Level(context)
ScriptLib.KillEntityByConfigId(context,{config_id = temari_gadgets[curLevel-2]})
LF_Stop_Challenge(context,0,1)
else
--联机情况下,判断挑战开启者和碰到球的是否是一个人,如果不是则无事发生
if (LF_Is_Same_Challenger(context)) then
ScriptLib.PrintContextLog(context,"TMR: Guest has found the ball!")
ScriptLib.KillEntityByConfigId(context,{config_id = defs.temari_online})
--成就相关,如果当前完成的玩家并不是主机,则发送一次成就完成的消息
if (not LF_Is_Host(context)) then
ScriptLib.MarkPlayerAction(context, 6018 , 3 , 1)
end
LF_Stop_Challenge(context,2,1)
end
end
return 0
end
--放球的server lua call,被主机的E技能键调用
function SLC_Hide_Ball(context)
local avatar_id = ScriptLib.GetAvatarEntityIdByUid(context, context.uid)
local pos = ScriptLib.GetPosByEntityId(context, avatar_id)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.temari_online, {x=pos.x,y=pos.y+1,z=pos.z}, {x=0,y=0,z=0})
----存一下球的位置,马上要销毁掉
LF_Save_Online_Temari_Pos(context)
LF_Stop_Challenge(context,1,1)
LF_Online_Hide_Level(context)
--藏球后,将藏球的标志置为1(说明玩家至少藏了一次球)
ScriptLib.SetGroupVariableValue(context,"has_hidden",1)
return 0
end
--------------------------------------------------------------------
Initialize()
@@ -0,0 +1,72 @@
--2.0奥博伦派对-前置WQ,用于启动奥博伦的方向指示gallery
local Tri = {
[1] = { name = "quest_start", config_id = 8000001, event = EventType.EVENT_QUEST_START, source = "7217604", condition = "", action = "action_quest_start", trigger_count = 0},
[2] = { name = "challenge_success", config_id = 8000002, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "",condition = "",action = "action_challenge_success",trigger_count= 0},
[3] = { name = "challenge_fail", config_id = 8000003, event = EventType.EVENT_CHALLENGE_FAIL, source = "",condition = "",action = "action_challenge_fail",trigger_count= 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
--------------------------------------------------------------------
--奥博伦前置任务启动的时候,起一个gallery
function action_quest_start(context,evt)
ScriptLib.PrintContextLog(context,"TMRPre: Quest start!")
LF_Start_Temari_Gallery(context)
return 0
end
--奥博伦前置任务启动的时候,起一个gallery
function action_challenge_success(context,evt)
ScriptLib.PrintContextLog(context,"TMRPre: challenge stops!")
LF_Stop_Temari_Gallery(context)
return 0
end
--奥博伦前置任务启动的时候,起一个gallery
function action_challenge_fail(context,evt)
ScriptLib.PrintContextLog(context,"TMRPre: challenge stops!")
LF_Stop_Temari_Gallery(context)
return 0
end
--------------------------------------------------------------------
--启动藏球的方向指示gallery
function LF_Start_Temari_Gallery(context)
local temari_pos = LF_Get_Temari_Pos(context)
ScriptLib.SetPlayerStartGallery(context, 9001, {context.uid})
ScriptLib.SetHandballGalleryBallPosAndRot(context, 9001, {x=temari_pos.x,y=temari_pos.y,z=temari_pos.z}, {x=0,y=0,z=0})
end
--关闭藏球的方向指示gallery
function LF_Stop_Temari_Gallery(context)
ScriptLib.StopGallery(context, 9001, true)
end
--返回当前关卡的手鞠球位置
function LF_Get_Temari_Pos(context)
local temari_entity_id = ScriptLib.GetEntityIdByConfigId(context,defs.temari_id)
local temari_pos = ScriptLib.GetPosByEntityId(context, temari_entity_id)
ScriptLib.PrintContextLog(context,"TMR: Temari pos: "..temari_pos.x..","..temari_pos.y..","..temari_pos.z)
return temari_pos
end
--server lua call---------------------------------------------------
--找球胜利,通过球自身的ability调用(调用时需要判定当前玩家主客机,如果是主机则无事发生)
function SLC_Find_Ball(context)
ScriptLib.PrintContextLog(context,"TMR: Player has found the ball!")
--不管任务是否成功,都要手动kill一次球确保特效触发正确
ScriptLib.KillEntityByConfigId(context,{config_id = defs.temari_id})
ScriptLib.StopChallenge(context,235,1)
return 0
end
--------------------------------------------------------------------
Initialize()
@@ -0,0 +1,121 @@
--自定义函数部分
local extrTriggers = {
initialtrigger = {
["Enter_Region"] = { config_id = 8000001, name = "Enter_Region", event= EventType.EVENT_ENTER_REGION, source = "1", condition = "", action = "player_in_region", trigger_count = 0, forbid_guest = false },
["Random_Floor"] = { config_id = 8000002, name = "Random_Floor", event= EventType.EVENT_TIME_AXIS_PASS, source = "triggerThunderFloor", condition = "", action = "action_timeaxis_randomfloor", trigger_count = 0 },
}
}
function DeduplicationRandom( context, configIDList, randomNum )
math.randomseed(ScriptLib.GetServerTime(context))
local TempList = {}
local ReturnList = {}
for i,v in ipairs(configIDList) do
table.insert(TempList, v)
end
for i=1,randomNum do
local TempNum = math.random(#TempList)
table.insert(ReturnList, TempList[TempNum] )
table.remove(TempList, TempNum)
end
ScriptLib.PrintContextLog(context, "##TF LOG : return random lsit")
return ReturnList
end
function player_in_region( context, evt )
-- 监听玩法开始
if evt.param1 ~= EnterConfigID then
return 0
end
ScriptLib.PrintContextLog(context, "##TF LOG : player in region")
ScriptLib.InitTimeAxis(context, "triggerThunderFloor", thunderFloorTimer, true)
math.randomseed(ScriptLib.GetServerTime(context))
local randomNum = math.random(randomNumMin, randomNumMax)
local CurList = DeduplicationRandom(context, floorList, randomNum)
for i,v in ipairs(CurList) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 201)
end
-- ScriptLib.EndTimeAxis(context, "triggerThunderFloor")
-- for i,v in ipairs(floorList) do
-- ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
-- end
return 0
end
function action_timeaxis_randomfloor( context, evt )
-- 每次随机一套地板
if randomNumMax > #floorList then
ScriptLib.PrintContextLog(context, "##TF LOG : randomNumMax is bigger than Listlength")
return 0
elseif randomNumMin > randomNumMax then
ScriptLib.PrintContextLog(context, "##TF LOG : randomNumMin is bigger than randomNumMax")
return 0
end
for i,v in ipairs(floorList) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 0)
end
math.randomseed(ScriptLib.GetServerTime(context))
local randomNum = math.random(randomNumMin, randomNumMax)
local CurList = DeduplicationRandom(context, floorList, randomNum)
for i,v in ipairs(CurList) do
ScriptLib.SetGroupGadgetStateByConfigId(context, 0, v, 201)
end
return 0
end
function LF_Initialize_Group(triggers, suites)
for k,v in pairs(extrTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,152 @@
--雷元素溢出洞口
--需求:
--1. 同group内的溢出洞口,每经过时间randomTime,发一次球
--2. 每次randomCount个洞口会发球
--[[
local defs = {
--GroupID
group_id = 240950005,
--控制挑战开始的操作机关configID
--starter_configID = ,
--随机时间轴。每个轴上数字间隔8~15秒,请人力随机
RandomTimeAxis = {
{2,18,38,56,81,99,115,133,148,165,180,196,211,235,257,276,300,315,330,349,367,383,400,416,431,449,471,487},
{1,17,36,53,69,89,109,134,158,173,197,213,231,249,264,289,305,324,347,362,385,407,429,453,473,491},
{2,19,42,61,85,104,128,146,167,190,209,232,255,271,288,307,327,348,368,393,412,430,455,477,500},
},
--配置每次几个洞口发球
random_thunderhole_sum = {
min = 1,
max = 3,
},
}
]]--
local define = {
gadgetList = {},
groupID = defs.group_id,
starter_configID = defs.starter_configID,
RandomTimeAxis = defs.RandomTimeAxis,
random_thunderhole_sum = defs.random_thunderhole_sum,
}
local extraTriggers={
initialtrigger =
{
--["Select_Option"] = { config_id = 8000001, name = "Select_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0 },
["TimeAxis_Event"] = { config_id = 8000002, name = "TimeAxis_Event", event= EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_trigger_timeaxis", trigger_count = 0 },
--["Challenge_Fail"] = { config_id = 8000003, name = "Challenge_Fail", event= EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0 },
["GroupVariable_Change"] = { config_id = 8000003, name = "GroupVariable_Change", event= EventType.EVENT_VARIABLE_CHANGE, source = "challenge", condition = "", action = "action_group_variable_change", trigger_count = 0 },
--["GadgetState_Change"] = { config_id = 8000004, name = "GadgetState_Change", event= EventType.EVENT_GADGET_STATE_CHANGE, source = "", condition = "", action = "action_gadget_state_change", trigger_count = 0 },
--["Challenge_Success"] = { config_id = 8000005, name = "Challenge_Success", event= EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0 },
}
}
function LF_Initialize_Group(triggers, suites)
for k,v in pairs(extraTriggers.initialtrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
GetThunderHoleGadget(context)
return 0
end
--取得所有的溢出洞口
function GetThunderHoleGadget(context)
for k,v in pairs(gadgets) do
if v.gadget_id == 70330086 then
table.insert(define.gadgetList,v.config_id)
end
end
return 0
end
--[[function action_select_option(context, evt)
-- 判断是gadgetid starter_configID option_id 7
if evt.param1 == define.starter_configID then
if evt.param2 == 7 then
--所有溢出洞口物件切状态
for k,v in pairs(define.gadgetList) do
ScriptLib.SetGadgetStateByConfigId(context, v, 201)
end
--初始化时间轴
ScriptLib.InitTimeAxis(context, "shoot", define.RandomTimeAxis[math.random(#define.RandomTimeAxis)], true)
end
end
return 0
end
]]--
function action_trigger_timeaxis(context, evt)
RandomThunderHole(context, define.random_thunderhole_sum.min, define.random_thunderhole_sum.max)
return 0
end
-- 在suit中随机抽取randomCount个幸运物件,让它们发球
function RandomThunderHole(context, minNum, maxNum)
math.randomseed(ScriptLib.GetServerTime(context))
randomNum = math.random(minNum, maxNum)
for i=1,randomNum do
if ScriptLib.GetGadgetStateByConfigId(context, define.groupID, define.gadgetList[i]) ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, define.gadgetList[i], 202)--物件切202发球后会自己切回201
end
end
return 0
end
--[[function action_gadget_state_change(context, evt)
if evt.param2 == define.starter_configID and evt.param1 == 0 then
--停止时间轴
ScriptLib.EndTimeAxis(context, "shoot")
--关闭未关闭的溢出洞口
StopAllGear(context)
else
--检查是不是关卡把洞口物件关了,如果关卡给关了,把时间轴停下
CheckThunderHoleState(context)
end
return 0
end]]--
function action_group_variable_change(context, evt)
--如果是开启挑战
if evt.param1 == 0 and evt.param2 == 1 then
--停止时间轴
ScriptLib.EndTimeAxis(context, "shoot")
--关闭未关闭的溢出洞口
StopAllGear(context)
end
--如果是结束挑战
if evt.param1 == 1 and evt.param2 == 0 then
--所有溢出洞口物件切状态
for k,v in pairs(define.gadgetList) do
ScriptLib.SetGadgetStateByConfigId(context, v, 201)
end
--初始化时间轴
ScriptLib.InitTimeAxis(context, "shoot", define.RandomTimeAxis[math.random(#define.RandomTimeAxis)], true)
end
return 0
end
function StopAllGear(context)
--所有溢出洞口物件停
for k,v in pairs(define.gadgetList) do
if ScriptLib.GetGadgetStateByConfigId(context, define.groupID, v) ~= 0 then
ScriptLib.SetGadgetStateByConfigId(context, v, 0)
end
end
return 0
end
function CheckThunderHoleState(context)
for i=1,#define.gadgetList do
if ScriptLib.GetGadgetStateByConfigId(context, define.groupID, define.gadgetList[i]) == 0 then
ScriptLib.EndTimeAxis(context, "shoot")
break
end
end
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,434 @@
--[[
--delay改为默认配置,读不到就使用默认值
--group和nextgroup改为默认配置
--buff没有用到,删除
--主控
--默认建造时间
local delay=30
local challenge_programme={
[1]=tide_defs_01,
[2]=tide_defs_02,
[3]=tide_defs_03
}
--怪物group的ID
local monster_group=245001003
local tide_defs_01 ={
--自适应配置项,delay
--[1] = {delay = 30,guide_routes={1,2},enter={1001,1003},exit={1004},enter_id={7,8},exit_id={9}},
[1] = {guide_routes={1,2}},
[2] = {guide_routes={1,2}},
[3] = {guide_routes={1,2}},
[4] = {guide_routes={1,2}},
[5] = {guide_routes={1,2}},
},
local tide_defs_02 ={
[1] = {guide_routes={1,2}},
[2] = {guide_routes={1,2}},
[3] = {guide_routes={1,2}},
[4] = {guide_routes={1,2}},
[5] = {guide_routes={1,2}},
},
local tide_defs_03 ={
[1] = {guide_routes={1,2}},
[2] = {guide_routes={1,2}},
[3] = {guide_routes={1,2}},
[4] = {guide_routes={1,2}},
[5] = {guide_routes={1,2}},
}
local routes_start_point={
[1]={start_point={x=77.129,y=4.623077,z=-50.57449},points={1,2,3,4,5,6,7,8}},
[2]={start_point={x=64.96883,y=0.5410852,z=-16.04972},points={1,2,3,4,5,6,7,8,9,10}},
}
local guide_point_pool={1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040}
--]]
function LF_Init_Challenge_Group()
GM1 ={ config_id = 8100001, name = "GM", event = EventType.EVENT_VARIABLE_CHANGE, source = "GM_VALUE", condition = "", action = "action_GM_Action", trigger_count = 0}
t3 = { config_id = 8000003, name = "challenge_success", event = EventType.EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END, source = "", condition = "", action = "action_EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END", trigger_count = 0}
t4 = { config_id = 8000004, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0 }
t5 = { config_id = 8000005, name = "timer_event", event = EventType.EVENT_TIMER_EVENT, source = "route_points_delay", condition = "", action = "action_add_route_points", trigger_count = 0}
t6 = { config_id = 8000006, name = "point_arrive", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "", condition = "", action = "action_REACH_POINT", trigger_count = 0 }
t7 = { config_id = 8000007, name = "end_stage_request", event = EventType.EVENT_SCENE_MULTISTAGE_PLAY_END_STAGE_REQ, source = "", condition = "", action = "action_END_STAGE", trigger_count = 0 }
t8 = { config_id = 8000008, name = "pick_card_event", event = EventType.EVENT_MECHANICUS_PICKED_CARD, source = "", condition = "", action = "action_PICK_CARD", trigger_count = 0 }
t9 = { config_id = 8000009,name = "TIMER_EVENT_DELAY", event = EventType.EVENT_TIMER_EVENT, source = "delay", condition = "", action = "action_END_DELAY", trigger_count = 0 }
t10 = { config_id = 8000010,name = "TIMER_EVENT_START_REMINDER", event = EventType.EVENT_TIMER_EVENT, source = "reminder", condition = "", action = "action_START_REMINDER", trigger_count = 0 }
t11 = { config_id = 8000011,name = "ALL_AVATAR_DIE", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_ALL_AVATAR_DIE", trigger_count = 0 }
for i,v in ipairs(suites) do
table.insert(v.triggers, GM1.name)
table.insert(v.triggers, t3.name)
table.insert(v.triggers, t4.name)
table.insert(v.triggers, t5.name)
table.insert(v.triggers, t6.name)
table.insert(v.triggers, t7.name)
table.insert(v.triggers, t8.name)
table.insert(v.triggers, t9.name)
table.insert(v.triggers, t10.name)
table.insert(v.triggers, t11.name)
end
table.insert(triggers, GM1)
table.insert(triggers, t3)
table.insert(triggers, t4)
table.insert(triggers, t5)
table.insert(triggers, t6)
table.insert(triggers, t7)
table.insert(triggers, t8)
table.insert(triggers, t9)
table.insert(triggers, t10)
table.insert(triggers, t11)
table.insert(variables, { config_id=50000001,name = "GM_VALUE", value = 0})
table.insert(variables, { config_id=50000002,name = "wave_ptr", value = 0})
table.insert(variables, { config_id=50000003,name = "special_challenge", value = 0})
table.insert(variables, { config_id=50000004,name = "left_monsters", value = 0})
table.insert(variables, { config_id=50000005,name = "max_escapable_monsters", value = 10})
table.insert(variables, { config_id=50000006,name = "escaped_monsters", value = 0})
table.insert(variables, { config_id=50000007,name = "route_guide_points_index", value = 1,no_refresh = true})
--怪物对地脉镇石造成额外伤害
table.insert(variables, { config_id=50000008,name = "monster_double_damage", value = 0})
--挑战逃出的怪物不超过一个
table.insert(variables, { config_id=50000009,name = "GM_Ignore_Monster_Escape", value = 0})
table.insert(variables, { config_id=50000010,name = "challenge_93", value = 0})
table.insert(variables, { config_id=50000011,name = "challenge_94", value = 0})
table.insert(variables, { config_id=50000012,name = "challenge_95", value = 0})
table.insert(variables, { config_id=50000013,name = "challenge_active_93", value = 0})
table.insert(variables, { config_id=50000014,name = "challenge_active_94", value = 0})
table.insert(variables, { config_id=50000015,name = "challenge_active_95", value = 0})
table.insert(variables, { config_id=50000016,name = "planNum", value = 1,no_refresh = true})
table.insert(variables, { config_id=50000017,name = "ban_tag_1", value = 999})
table.insert(variables, { config_id=50000018,name = "ban_tag_2", value = 999})
table.insert(variables, { config_id=50000019,name = "ban_tag_3", value = 999})
end
--------------------------------------
function action_GM_Action(context, evt)
if evt.source_name ~="GM_VALUE" then
return 0
end
if defs.max_escapable_monsters~= nil then
ScriptLib.SetGroupVariableValue(context, "max_escapable_monsters", defs.max_escapable_monsters)
end
ScriptLib.SetGroupVariableValue(context, "wave_ptr", 1)
--使用GM来随
local planNum=evt.param1
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 随到的方案是:"..planNum)
ScriptLib.SetGroupVariableValue(context, "planNum", planNum)
--请求ban_tag_list
ScriptLib.ExecuteGroupLua(context, monster_group, "req_ban_tag", {planNum,defs.group_id})
local tag=ScriptLib.GetGroupVariableValue(context, "ban_tag_1")
local ban_list={}
if tag<999 then
ban_list[1]=tag
end
tag=ScriptLib.GetGroupVariableValue(context, "ban_tag_2")
if tag<999 then
ban_list[2]=tag
end
tag=ScriptLib.GetGroupVariableValue(context, "ban_tag_3")
if tag<999 then
ban_list[3]=tag
end
if 0~=ScriptLib.InitSceneMultistagePlay(context, 999, MultistagePlayType.Chess, {rounds = #challenge_programme[planNum], init_building_points = defs.init_building_points or 200},ScriptLib.GetSceneUidList(context)) then
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : muitistage初始化失败")
else
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功设置muitistage|rounds="..#challenge_programme[planNum])
end
--迭代项
ScriptLib.ExecuteGroupLua(context, monster_group, "set_monster_preview", {defs.group_id,planNum})
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功设置怪物预览")
--设置怪物总数量
ScriptLib.ExecuteGroupLua(context, monster_group, "set_monster_number_req", {ScriptLib.GetGroupVariableValue(context, "wave_ptr")})
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功设置剩余怪物")
ScriptLib.SetSceneMultiStagePlayValues(context, 999, {round=ScriptLib.GetGroupVariableValue(context, "wave_ptr"),rounds=#challenge_programme[planNum],left_monsters=ScriptLib.GetGroupVariableValue(context, "left_monsters"),max_escapable_monsters=ScriptLib.GetGroupVariableValue(context, "max_escapable_monsters"),escaped_monsters=ScriptLib.GetGroupVariableValue(context, "escaped_monsters"),stage_bonus_building_points=0}, true)
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功设置显示参数|rounds="..#challenge_programme[planNum].."|left_monsters="..ScriptLib.GetGroupVariableValue(context, "left_monsters"))
ScriptLib.StartSceneMultiStagePlayStage(context, 999, defs.build_time or 123, Multistage.ChessBuild,"build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功开始挑战")
ScriptLib.ExecuteGroupLua(context, defs.gear_group_id, "Initialize_Fundations", {0})
add_route_guide_points(context)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "reminder",5)
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : grouploadsuccess")
return 0
end
function action_ALL_AVATAR_DIE(context, evt)
local uidList=ScriptLib.GetSceneUidList(context)
local count=0
for i=1,#uidList do
if ScriptLib.IsPlayerAllAvatarDie(context, uidList[i]) then
count=count+1
end
end
if count >= (#uidList) then
ScriptLib.EndSceneMultiStagePlay(context, 999, false)
return 0
end
return 0
end
function action_END_STAGE(context, evt)
if evt.param2==Multistage.ChessBuild then
ScriptLib.EndSceneMultiStagePlayStage(context, 999,"build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"), true)
end
return 0
end
--翻牌子
function action_PICK_CARD(context, evt)
--牌子效果
--立即回复地脉镇石5点耐久度
if evt.param2==77 then
local hp=ScriptLib.GetGroupVariableValue(context, "escaped_monsters")
hp=hp-5
if hp<0 then
hp=0
end
ScriptLib.SetGroupVariableValue(context, "escaped_monsters", hp)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "escaped_monsters",hp, true)
return 0
end
--每翻一次,下个战斗阶段敌人的血量提升10%
if evt.param2==92 then
local pickCount=ScriptLib.GetGroupVariableValue(context, "challenge_93")
pickCount=pickCount+1
ScriptLib.SetGroupVariableValue(context, "challenge_93", pickCount)
end
--每翻一次,下个战斗阶段敌人的防御提升2%
if evt.param2==93 then
local pickCount=ScriptLib.GetGroupVariableValue(context, "challenge_94")
pickCount=pickCount+1
ScriptLib.SetGroupVariableValue(context, "challenge_94", pickCount)
end
--每翻一次,下个战斗阶段怪物逃逸值加1
if evt.param2==94 then
local pickCount=ScriptLib.GetGroupVariableValue(context, "challenge_95")
pickCount=pickCount+1
ScriptLib.SetGroupVariableValue(context, "challenge_95", pickCount)
end
return 0
end
--设置卡牌效果
function Set_Cards_Effect(context)
--重置选中次数,获取上轮的选中次数
local pickCount=ScriptLib.GetGroupVariableValue(context, "challenge_93")
ScriptLib.SetGroupVariableValue(context, "challenge_active_93", pickCount)
ScriptLib.SetGroupVariableValue(context, "challenge_93", 0)
pickCount=ScriptLib.GetGroupVariableValue(context, "challenge_94")
ScriptLib.SetGroupVariableValue(context, "challenge_active_94", pickCount)
ScriptLib.SetGroupVariableValue(context, "challenge_94", 0)
pickCount=ScriptLib.GetGroupVariableValue(context, "challenge_95")
ScriptLib.SetGroupVariableValue(context, "challenge_active_95", pickCount)
ScriptLib.SetGroupVariableValue(context, "challenge_95", 0)
end
--重置卡牌效果
function Reset_Cards_Effect(context)
return 0
end
function add_ban_tag(context, prev_context, param1, param2, param3)
if param1<999 then
ScriptLib.SetGroupVariableValue(context, "ban_tag_1", param1)
end
if param2<999 then
ScriptLib.SetGroupVariableValue(context, "ban_tag_2", param2)
end
if param3<999 then
ScriptLib.SetGroupVariableValue(context, "ban_tag_3", param3)
end
return 0
end
function action_group_load(context, evt)
if defs.testMode==1 then
return 0
end
if defs.max_escapable_monsters~= nil then
ScriptLib.SetGroupVariableValue(context, "max_escapable_monsters", defs.max_escapable_monsters)
end
ScriptLib.SetGroupVariableValue(context, "wave_ptr", 1)
--随一套方案出来
math.randomseed(ScriptLib.GetServerTime(context))
local planNum=math.random(#challenge_programme)
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 随到的方案是:"..planNum)
ScriptLib.SetGroupVariableValue(context, "planNum", planNum)
--请求ban_tag_list
ScriptLib.ExecuteGroupLua(context, monster_group, "req_ban_tag", {planNum,defs.group_id})
local tag=ScriptLib.GetGroupVariableValue(context, "ban_tag_1")
local ban_list={}
if tag<999 then
ban_list[1]=tag
end
tag=ScriptLib.GetGroupVariableValue(context, "ban_tag_2")
if tag<999 then
ban_list[2]=tag
end
tag=ScriptLib.GetGroupVariableValue(context, "ban_tag_3")
if tag<999 then
ban_list[3]=tag
end
if 0~=ScriptLib.InitSceneMultistagePlay(context, 999, MultistagePlayType.Chess, {ban_card_tag_list=ban_list,rounds = #challenge_programme[planNum], init_building_points = defs.init_building_points or 200},ScriptLib.GetSceneUidList(context)) then
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : muitistage初始化失败")
else
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功设置muitistage|rounds="..#challenge_programme[planNum])
end
--迭代项
ScriptLib.ExecuteGroupLua(context, monster_group, "set_monster_preview", {defs.group_id,planNum})
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功设置怪物预览")
--设置怪物总数量
ScriptLib.ExecuteGroupLua(context, monster_group, "set_monster_number_req", {ScriptLib.GetGroupVariableValue(context, "wave_ptr")})
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功设置剩余怪物")
ScriptLib.SetSceneMultiStagePlayValues(context, 999, {round=ScriptLib.GetGroupVariableValue(context, "wave_ptr"),rounds=#challenge_programme[planNum],left_monsters=ScriptLib.GetGroupVariableValue(context, "left_monsters"),max_escapable_monsters=ScriptLib.GetGroupVariableValue(context, "max_escapable_monsters"),escaped_monsters=ScriptLib.GetGroupVariableValue(context, "escaped_monsters"),stage_bonus_building_points=0}, true)
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功设置显示参数|rounds="..#challenge_programme[planNum].."|left_monsters="..ScriptLib.GetGroupVariableValue(context, "left_monsters"))
ScriptLib.StartSceneMultiStagePlayStage(context, 999, defs.build_time or 123, Multistage.ChessBuild,"build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 成功开始挑战")
ScriptLib.ExecuteGroupLua(context, defs.gear_group_id, "Initialize_Fundations", {0})
add_route_guide_points(context)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "reminder",5)
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : grouploadsuccess")
return 0
end
function action_START_REMINDER(context, evt)
ScriptLib.ShowReminder(context, 400025)
return 0
end
function action_add_route_points(context, evt)
add_route_guide_points(context)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "route_points_delay", defs.route_guide_timer)
return 0
end
function add_route_guide_points(context)
local curPlanNumber=ScriptLib.GetGroupVariableValue(context, "planNum")
local curwave=ScriptLib.GetGroupVariableValue(context, "wave_ptr")
if challenge_programme[curPlanNumber][curwave].guide_routes ==nil then
ScriptLib.PrintContextLog(context, "## TD_LOG : Guide Routes Is Nil")
return 0
end
for i=1,#challenge_programme[curPlanNumber][curwave].guide_routes do
local idx=ScriptLib.GetGroupVariableValue(context, "route_guide_points_index")
if -2==ScriptLib.CreateGadgetByConfigIdByPos(context, guide_point_pool[idx], routes_start_point[challenge_programme[curPlanNumber][curwave].guide_routes[i]].start_point, { x = 0.000, y = 0.000, z = 0.000 }) then
ScriptLib.PrintContextLog(context, "## TD_LOG : Guide Points Not Enough")
return 0
end
ScriptLib.SetPlatformPointArray(context, guide_point_pool[idx], challenge_programme[curPlanNumber][curwave].guide_routes[i],routes_start_point[challenge_programme[curPlanNumber][curwave].guide_routes[i]].points, { route_type = 0 })
if idx >= #guide_point_pool then
idx=1
else
idx=idx+1
end
ScriptLib.SetGroupVariableValue(context, "route_guide_points_index", idx)
end
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "route_points_delay", defs.route_guide_timer)
return 0
end
function stop_route_guide_points(context)
ScriptLib.CancelGroupTimerEvent(context, defs.group_id, "route_points_delay")
ScriptLib.KillGroupEntity(context,{group_id=defs.group_id,gadgets=guide_point_pool})
return 0
end
function action_REACH_POINT(context,evt)
--ScriptLib.KillEntityByConfigId(context, { config_id = evt.param1 })
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, evt.param1, GadgetState.GearStart)
return 0
end
function del_monster_number(context, prev_context, param1, param2, param3)
local new_num=ScriptLib.GetGroupVariableValue(context, "left_monsters")
if new_num==0 then
return 0
end
new_num=new_num-1
ScriptLib.SetGroupVariableValue(context, "left_monsters", new_num)
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "left_monsters",new_num, true)
return 0
end
function set_monster_number(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "left_monsters", param1)
return 0
end
--某group结束,进下一阶段
function tide_done(context, prev_context, param1, param2, param3)
local curPlanNumber=ScriptLib.GetGroupVariableValue(context, "planNum")
ScriptLib.EndSceneMultiStagePlayStage(context, 999,"battle"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"), true)
local wave = ScriptLib.GetGroupVariableValue(context, "wave_ptr")
wave=wave+1
ScriptLib.SetGroupVariableValue(context, "wave_ptr", wave)
ScriptLib.PrintContextLog(context, "## wave = "..wave)
if wave > #challenge_programme[curPlanNumber] then
ScriptLib.EndSceneMultiStagePlay(context, 999, true)
ScriptLib.PrintContextLog(context, "## TD_LOG : All Wave Done")
--ScriptLib.CauseDungeonFail(context)
return 0
end
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "delay", 3)
Reset_Cards_Effect(context)
--ScriptLib.StartSceneMultiStagePlayStage(context, 999, 30, Multistage.MechanicusFlipCard,"card"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
return 0
end
function action_END_DELAY(context, evt)
--ScriptLib.SetSceneMultiStagePlayValue(context, 999, "building_stage_seconds",defs.build_time or 123, true)
Set_Cards_Effect(context)
ScriptLib.ExecuteGroupLua(context, monster_group, "synchronization_card_num", {ScriptLib.GetGroupVariableValue(context, "challenge_active_93"),ScriptLib.GetGroupVariableValue(context, "challenge_active_94")})
--ScriptLib.SetSceneMultiStagePlayValue(context, 999, "round",ScriptLib.GetGroupVariableValue(context, "wave_ptr"), true)
add_route_guide_points(context)
ScriptLib.ExecuteGroupLua(context, monster_group, "set_monster_number_req", {ScriptLib.GetGroupVariableValue(context, "wave_ptr")})
ScriptLib.SetSceneMultiStagePlayValues(context, 999, {round=ScriptLib.GetGroupVariableValue(context, "wave_ptr"),rounds=#challenge_programme[ScriptLib.GetGroupVariableValue(context, "planNum")],left_monsters=ScriptLib.GetGroupVariableValue(context, "left_monsters"),max_escapable_monsters=ScriptLib.GetGroupVariableValue(context, "max_escapable_monsters"),escaped_monsters=ScriptLib.GetGroupVariableValue(context, "escaped_monsters"),stage_bonus_building_points=0}, true)
ScriptLib.StartSceneMultiStagePlayStage(context, 999, defs.build_time or 123, Multistage.ChessBuild,"build"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
if defs.trapGroups~=nil then
for i=1,#defs.trapGroups do
ScriptLib.RefreshGroup(context, { group_id = defs.trapGroups[i], suite = 1, refresh_level_revise = 0, is_force_random_suite = false})
end
end
return 0
end
--怪物到达终点,涨分
function monster_escaped(context, prev_context, param1, param2, param3)
if ScriptLib.GetGroupVariableValue(context, "GM_Ignore_Monster_Escape") ~=0 then
return 0
end
local max_escapable_monsters=ScriptLib.GetGroupVariableValue(context, "max_escapable_monsters")
local escaped_monsters=ScriptLib.GetGroupVariableValue(context, "escaped_monsters")
if param1==1 then
escaped_monsters=escaped_monsters+1
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "escaped_monsters",escaped_monsters, true)
if escaped_monsters>=max_escapable_monsters then
ScriptLib.EndSceneMultiStagePlay(context, 999, false)
return 0
end
ScriptLib.SetGroupVariableValue(context, "escaped_monsters", escaped_monsters)
return 0
end
escaped_monsters=escaped_monsters+1
escaped_monsters=escaped_monsters+ScriptLib.GetGroupVariableValue(context, "challenge_active_95")
ScriptLib.SetSceneMultiStagePlayValue(context, 999, "escaped_monsters",escaped_monsters, true)
if escaped_monsters>=max_escapable_monsters then
ScriptLib.EndSceneMultiStagePlay(context, 999, false)
return 0
end
ScriptLib.SetGroupVariableValue(context, "escaped_monsters", escaped_monsters)
return 0
end
function action_EVENT_SCENE_MULTISTAGE_PLAY_STAGE_END(context, evt)
if evt.param2==Multistage.ChessBuild then
stop_route_guide_points(context)
ScriptLib.ExecuteGroupLua(context, monster_group, "start_tide", {defs.group_id,ScriptLib.GetGroupVariableValue(context, "wave_ptr")})
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : 战斗阶段开始:"..ScriptLib.GetGroupVariableValue(context, "wave_ptr").."monstergroup="..monster_group)
ScriptLib.StartSceneMultiStagePlayStage(context, 999, 0, Multistage.ChessKill,"battle"..ScriptLib.GetGroupVariableValue(context, "wave_ptr"),{})
end
return 0
end
--tide_group_defs[ScriptLib.GetGroupVariableValue(context, "wave_ptr")].group
LF_Init_Challenge_Group()
@@ -0,0 +1,118 @@
--[[
setmetatable(_ENV,{__index=function() return {} end })
--]]
local define = {
group_id = defs.group_id or 250030001,
gear_list = --[[defs.gear_list or]] {70350107,70350099,70350100,70350101,70350102,70350103,70350129,70350111,70350108},
option_list = --[[defs.option_list or]] {41,42,43,44,45,48,49,50,46},
option_revert = 46,
option_points = --[[defs.option_points or]] {20,20,20,20,20,20,20,20,20},
monster_points = defs.monster_points or 10,
max_points = defs.max_points or 100
}
local extraTriggers={
{ config_id = 8000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0},
{ config_id = 8000002, name = "GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_GADGET_CREATE", trigger_count = 0},
{ config_id = 8000003, name = "GADGET_DIE", event = EventType.EVENT_ANY_GADGET_DIE, source = "", condition = "", action = "action_GADGET_DIE", trigger_count = 0},
{ config_id = 8000004, name = "SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0,forbid_guest = false },
{ config_id = 8000005,name = "TIMER_EVENT_CD", event = EventType.EVENT_TIMER_EVENT, source = "cd", condition = "", action = "action_USE_CD", trigger_count = 0 }
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables, { config_id=50000001,name = "gateway_one", value = 0})
table.insert(variables, { config_id=50000002,name = "gateway_two", value = 0})
table.insert(variables, { config_id=50000003,name = "use_cd", value = 0})
end
function action_USE_CD(context, evt)
ScriptLib.SetGroupVariableValue(context, "use_cd", 0)
return 0
end
function action_GADGET_CREATE(context, evt)
if evt.param2 == 70330045 then
if ScriptLib.GetGroupVariableValue(context, "gateway_one")==0 then
ScriptLib.SetGroupVariableValue(context, "gateway_one", evt.param1)
ScriptLib.SetWorktopOptionsByGroupId(context, 0, evt.param1, {4005})
return 0
elseif ScriptLib.GetGroupVariableValue(context, "gateway_two")==0 then
ScriptLib.SetGroupVariableValue(context, "gateway_two", evt.param1)
ScriptLib.SetWorktopOptionsByGroupId(context, 0, evt.param1, {4005})
return 0
end
end
return 0
end
function action_EVENT_SELECT_OPTION(context, evt)
if ScriptLib.GetGroupVariableValue(context, "use_cd")==1 then
ScriptLib.ShowReminder(context, 400027)
return 0
end
if evt.param1==ScriptLib.GetGroupVariableValue(context, "gateway_one") then
if (ScriptLib.GetGroupVariableValue(context, "gateway_one")==0) or (ScriptLib.GetGroupVariableValue(context, "gateway_two")==0) then
return 0
end
for i=1,#points do
if points[i].config_id==ScriptLib.GetGroupVariableValue(context, "gateway_two") then
ScriptLib.TransPlayerToPos(context, {uid_list ={context.uid}, pos = points[i].pos, radius = 2, rot = points[i].rot,is_skip_ui=false})
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, evt.param1, GadgetState.GearStart)
ScriptLib.SetGroupVariableValue(context, "use_cd", 1)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "cd", 5)
return 0
end
end
elseif evt.param1==ScriptLib.GetGroupVariableValue(context, "gateway_two") then
if (ScriptLib.GetGroupVariableValue(context, "gateway_one")==0) or (ScriptLib.GetGroupVariableValue(context, "gateway_two")==0) then
return 0
end
for i=1,#points do
if points[i].config_id==ScriptLib.GetGroupVariableValue(context, "gateway_one") then
ScriptLib.TransPlayerToPos(context, {uid_list ={context.uid}, pos = points[i].pos, radius = 2, rot = points[i].rot,is_skip_ui=false})
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, evt.param1, GadgetState.GearStart)
ScriptLib.SetGroupVariableValue(context, "use_cd", 1)
ScriptLib.CreateGroupTimerEvent(context, defs.group_id, "cd", 5)
return 0
end
end
end
return 0
end
function action_GADGET_DIE(context, evt)
if evt.param1==ScriptLib.GetGroupVariableValue(context, "gateway_one") then
ScriptLib.SetGroupVariableValue(context, "gateway_one", 0)
return 0
elseif evt.param1==ScriptLib.GetGroupVariableValue(context, "gateway_two") then
ScriptLib.SetGroupVariableValue(context, "gateway_two", 0)
return 0
end
return 0
end
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.PrintContextLog(context, "## ================ INITIALIZE FUNDATIONS ==============")
--Initialize_Fundations(context, evt)
return 0
end
function Initialize_Fundations(context, prev_context, param1, param2, param3)
local fundationTable={}
local uidList=ScriptLib.GetSceneUidList(context)
for i=1,math.min(#gadgets,#points) do
if gadgets[i].gadget_id == defs.fundation_id then
fundationTable[gadgets[i].config_id]=points[i].config_id
end
end
--ScriptLib.CreateFoundations(context, gadgets[i].config_id, points[i].config_id,defs.challange_group_id,999)
ScriptLib.CreateFoundations(context, fundationTable ,defs.challange_group_id,999)
return 0
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,962 @@
-----------------------
-----------------------
-------阵容配置---------
---------单路----------
-----------------------
-----------------------
--第一波
-----无属性阵容
wave01_noelement_oneway={
[1]={{monster_package={16001,16002,16003},count=30,max=5,min=5,route={1}}},
}
--第二波
-----无属性阵容
wave02_noelement_oneway={
[1]={{monster_package={16011},count=20,max=5,min=5,route={1}}},
}
-----冰属性阵容
wave02_ice_oneway={
[1]={{monster_package={16020},count=30,max=5,min=5,route={1}}},
}
-----火属性阵容
wave02_fire_oneway={
[1]={{monster_package={16017},count=10,max=5,min=5,route={1}}},
}
-----雷属性阵容
wave02_electricity_oneway={
[1]={{monster_package={16021},count=30,max=5,min=5,route={1}}},
}
--第三波
-----无属性阵容
wave03_noelement_oneway={
[1]={{monster_package={16033,16034,16035},count=20,max=5,min=5,route={1}}},
}
-----冰属性阵容
wave03_ice_oneway={
[1]={{monster_package={16031},count=30,max=5,min=5,route={1}}},
}
-----火属性阵容
wave03_fire_oneway={
[1]={{monster_package={16030},count=30,max=5,min=5,route={1}}},
}
-----雷属性阵容
wave03_electricity_oneway={
[1]={{monster_package={16032},count=30,max=5,min=5,route={1}}},
}
--第四波
-----无属性阵容
wave04_noelement_oneway={
[1]={{monster_package={16044,16045},count=30,max=5,min=5,route={1}}},
}
-----小宝
wave04_defender_oneway={
[1]={{monster_package={16043},count=3,max=1,min=1,route={1}}},
}
-----冰属性阵容
wave04_ice_oneway={
[1]={{monster_package={16042},count=30,max=5,min=5,route={1}}},
}
-----火属性阵容
wave04_fire_oneway={
[1]={{monster_package={16040},count=30,max=5,min=5,route={1}}},
}
-----雷属性阵容
wave04_electricity_oneway={
[1]={{monster_package={16041},count=30,max=5,min=5,route={1}}},
}
--第五波
--小宝:输出校验,几乎百搭所有炮台build
wave05_boss_defender_oneway={
[1]={{monster_package={16050},count=3,max=1,min=1,route={1}}},
}
--龙蜥:远程炮台,需要玩家提升炮台射程
wave05_boss_dragon_oneway={
[1]={{monster_package={16051},count=3,max=1,min=1,route={1}}},
}
--追猎者:需要玩家提升控制炮台的能力
wave05_boss_hunter_oneway={
[1]={{monster_package={16052},count=3,max=1,min=1,route={1}}},
}
--霜铠王:需要玩家提升对冰能力
wave05_boss_iceking_oneway={
[1]={{monster_package={16053},count=3,max=1,min=1,route={1}}},
}
--岩盔王:需要玩家提升对火能力、破岩能力
wave05_boss_rockking_oneway={
[1]={{monster_package={16054},count=3,max=1,min=1,route={1}}},
}
--雷暴王:需要玩家提升对雷能力
wave05_boss_electricking_oneway={
[1]={{monster_package={16055},count=3,max=1,min=1,route={1}}},
}
-----------------------
---------单路----------
-----------------------
-----无属性小宝阵容
local stage_defender_oneway={
[1]=wave01_noelement_oneway,
[2]=wave02_noelement_oneway,
[3]=wave03_noelement_oneway,
[4]=wave04_defender_oneway,
}
-----无属性龙蜥阵容
local stage_dragon_oneway={
[1]=wave01_noelement_oneway,
[2]=wave02_noelement_oneway,
[3]=wave03_noelement_oneway,
[4]=wave04_noelement_oneway,
[5]=wave05_boss_dragon_oneway,
}
-----无属性猎者阵容
local stage_hunter_oneway={
[1]=wave01_noelement_oneway,
[2]=wave02_noelement_oneway,
[3]=wave03_noelement_oneway,
[4]=wave04_noelement_oneway,
[5]=wave05_boss_hunter_oneway,
}
-----冰属性阵容
local stage_iceking_oneway={
[1]=wave01_noelement_oneway,
[2]=wave02_ice_oneway,
[3]=wave03_ice_oneway,
[4]=wave04_ice_oneway,
[5]=wave05_boss_iceking_oneway,
}
-----火属性阵容
local stage_rockking_oneway={
[1]=wave01_noelement_oneway,
[2]=wave02_fire_oneway,
[3]=wave03_fire_oneway,
[4]=wave04_fire_oneway,
[5]=wave05_boss_rockking_oneway,
}
-----雷属性阵容
local stage_electricking_oneway={
[1]=wave01_noelement_oneway,
[2]=wave02_electricity_oneway,
[3]=wave03_electricity_oneway,
[4]=wave04_electricity_oneway,
[5]=wave05_boss_electricking_oneway,
}
-----教学
local stage_teachstage_oneway={
[1]=wave01_noelement_oneway,
[2]=wave02_fire_oneway,
}
-----------------------
-----------------------
-------阵容配置---------
---------双路----------
-----------------------
-----------------------
--第一波
-----无属性阵容
wave01_noelement_twoway={
[1]={{monster_package={16001,16002,16003},count=15,max=5,min=5,route={1,2}}},
}
--第二波
-----无属性阵容
wave02_noelement_twoway={
[1]={{monster_package={16010,16011,16012,16013,16014,16015},count=15,max=5,min=5,route={1,2}}},
}
-----冰属性阵容
wave02_ice_twoway={
[1]={{monster_package={16020},count=15,max=5,min=5,route={1,2}}},
}
-----火属性阵容
wave02_fire_twoway={
[1]={{monster_package={16017},count=15,max=5,min=5,route={1,2}}},
}
-----雷属性阵容
wave02_electricity_twoway={
[1]={{monster_package={16021},count=15,max=5,min=5,route={1,2}}},
}
--第三波
-----无属性阵容
wave03_noelement_twoway={
[1]={{monster_package={16033,16034,16035},count=15,max=5,min=5,route={1,2}}},
}
-----冰属性阵容
wave03_ice_twoway={
[1]={{monster_package={16031},count=15,max=5,min=5,route={1,2}}},
}
-----火属性阵容
wave03_fire_twoway={
[1]={{monster_package={16030},count=15,max=5,min=5,route={1,2}}},
}
-----雷属性阵容
wave03_electricity_twoway={
[1]={{monster_package={16032},count=15,max=5,min=5,route={1,2}}},
}
-----[双色]雷属性阵容+冰属性阵容
wave03_electricity_ice_twoway={
[1]={{monster_package={16032},count=15,max=5,min=5,route={1}},{monster_package={16031},count=15,max=5,min=5,route={2} }},
}
-----[双色]雷属性阵容+火属性阵容
wave03_electricity_fire_twoway={
[1]={{monster_package={16032},count=15,max=5,min=5,route={1}},{monster_package={16030},count=15,max=5,min=5,route={2} }},
}
-----[双色]冰属性阵容+火属性阵容
wave03_ice_fire_twoway={
[1]={{monster_package={16031},count=15,max=5,min=5,route={1}},{monster_package={16030},count=15,max=5,min=5,route={2} }},
}
--第四波
-----无属性阵容
wave04_noelement_twoway={
[1]={{monster_package={16044,16045},count=15,max=5,min=5,route={1,2}}},
}
-----无属性阵容
wave04_defender_twoway={
[1]={{monster_package={16043},count=3,max=1,min=1,route={1,2}}},
}
-----冰属性阵容
wave04_ice_twoway={
[1]={{monster_package={16042},count=15,max=5,min=5,route={1,2}}},
}
-----火属性阵容
wave04_fire_twoway={
[1]={{monster_package={16040},count=15,max=5,min=5,route={1,2}}},
}
-----雷属性阵容
wave04_electricity_twoway={
[1]={{monster_package={16041},count=15,max=5,min=5,route={1,2}}},
}
-----[双色]雷属性阵容+冰属性阵容
wave04_electricity_ice_twoway={
[1]={{monster_package={16041},count=15,max=5,min=5,route={1}},{monster_package={16042},count=15,max=5,min=5,route={2} }},
}
-----[双色]雷属性阵容+火属性阵容
wave04_electricity_fire_twoway={
[1]={{monster_package={16041},count=15,max=5,min=5,route={1}},{monster_package={16040},count=15,max=5,min=5,route={2} }},
}
-----[双色]冰属性阵容+火属性阵容
wave04_ice_fire_twoway={
[1]={{monster_package={16042},count=15,max=5,min=5,route={1}},{monster_package={16040},count=15,max=5,min=5,route={2} }},
}
--第五波
--小宝:输出校验,几乎百搭所有炮台build
wave05_boss_defender_twoway={
[1]={{monster_package={16050},count=3,max=1,min=1,route={1,2}}},
}
--龙蜥:远程炮台,需要玩家提升炮台射程
wave05_boss_dragon_twoway={
[1]={{monster_package={16051},count=3,max=1,min=1,route={1,2}}},
}
--追猎者:需要玩家提升控制炮台的能力
wave05_boss_hunter_twoway={
[1]={{monster_package={16052},count=3,max=1,min=1,route={1,2}}},
}
--霜铠王:需要玩家提升对冰能力
wave05_boss_iceking_twoway={
[1]={{monster_package={16053},count=3,max=1,min=1,route={1,2}}},
}
--岩盔王:需要玩家提升对火能力、破岩能力
wave05_boss_rockking_twoway={
[1]={{monster_package={16054},count=3,max=1,min=1,route={1,2}}},
}
--雷暴王:需要玩家提升对雷能力
wave05_boss_electricking_twoway={
[1]={{monster_package={16055},count=3,max=1,min=1,route={1,2}}},
}
--[双色]雷暴王+霜铠王
wave05_boss_electricking_iceking_twoway={
[1]={{monster_package={16055},count=3,max=1,min=1,route={1}},{monster_package={16053},count=3,max=1,min=1,route={2}}},
}
--[双色]雷暴王+岩盔王
wave05_boss_electricking_rockking_twoway={
[1]={{monster_package={16055},count=3,max=1,min=1,route={1}},{monster_package={16054},count=3,max=1,min=1,route={2}}},
}
--[双色]霜铠王+岩盔王
wave05_boss_iceking_rockking_twoway={
[1]={{monster_package={16053},count=3,max=1,min=1,route={1}},{monster_package={16054},count=3,max=1,min=1,route={2}}},
}
--暴徒
wave05_boss_thug_twoway={
[1]={{monster_package={16056},count=15,max=5,min=5,route={1,2}}},
}
--雷暴王+小怪
wave05_boss_electricking_hil_twoway={
[1]={{monster_package={16057},count=10,max=5,min=5,route={1,2}}},
}
--岩盔王+小怪
wave05_boss_rockking_hil_twoway={
[1]={{monster_package={16058},count=10,max=5,min=5,route={1,2}}},
}
--霜铠王+小怪
wave05_boss_iceking_hil_twoway={
[1]={{monster_package={16059},count=10,max=5,min=5,route={1,2}}},
}
-----------------------
---------双路----------
-----------------------
-----无属性小宝阵容
local stage_defender_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_noelement_twoway,
[4]=wave04_defender_twoway,
[5]=wave05_boss_defender_twoway,
ban_card_tag_list={6,7},
}
-----无属性龙蜥阵容
local stage_dragon_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_noelement_twoway,
[4]=wave04_noelement_twoway,
[5]=wave05_boss_dragon_twoway,
ban_card_tag_list={1,4},
}
-----无属性猎者阵容
local stage_hunter_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_noelement_twoway,
[4]=wave04_noelement_twoway,
[5]=wave05_boss_hunter_twoway,
ban_card_tag_list={4,6},
}
-----冰属性阵容
local stage_iceking_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_ice_twoway,
[3]=wave03_ice_twoway,
[4]=wave04_ice_twoway,
[5]=wave05_boss_iceking_twoway,
ban_card_tag_list={1,3},
}
-----火属性阵容
local stage_rockking_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_fire_twoway,
[3]=wave03_fire_twoway,
[4]=wave04_fire_twoway,
[5]=wave05_boss_rockking_twoway,
ban_card_tag_list={2,5},
}
-----雷属性阵容
local stage_electricking_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_electricity_twoway,
[3]=wave03_electricity_twoway,
[4]=wave04_electricity_twoway,
[5]=wave05_boss_electricking_twoway,
ban_card_tag_list={1,5},
}
-----[双色]雷+冰属性阵容
local stage_electricking_iceking_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_electricity_ice_twoway,
[4]=wave04_electricity_ice_twoway,
[5]=wave05_boss_electricking_iceking_twoway,
ban_card_tag_list={1,4},
}
-----[双色]雷+火属性阵容
local stage_electricking_rockking_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_electricity_fire_twoway,
[4]=wave04_electricity_fire_twoway,
[5]=wave05_boss_electricking_rockking_twoway,
ban_card_tag_list={4,6},
}
-----[双色]冰+火属性阵容
local stage_iceking_rockking_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_ice_fire_twoway,
[4]=wave04_ice_fire_twoway,
[5]=wave05_boss_iceking_rockking_twoway,
ban_card_tag_list={5,6},
}
-----无属性暴徒阵容
local stage_thug_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_noelement_twoway,
[4]=wave04_noelement_twoway,
[5]=wave05_boss_thug_twoway,
ban_card_tag_list={1,5},
}
-----嘲讽雷暴王+小怪阵容
local stage_electricking_hil_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_noelement_twoway,
[4]=wave04_noelement_twoway,
[5]=wave05_boss_electricking_hil_twoway,
ban_card_tag_list={3,6},
}
-----嘲讽岩盔王+小怪阵容
local stage_rockking_hil_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_noelement_twoway,
[4]=wave04_noelement_twoway,
[5]=wave05_boss_rockking_hil_twoway,
ban_card_tag_list={1,4},
}
-----嘲讽霜铠王+小怪阵容
local stage_iceking_hil_twoway={
[1]=wave01_noelement_twoway,
[2]=wave02_noelement_twoway,
[3]=wave03_noelement_twoway,
[4]=wave04_noelement_twoway,
[5]=wave05_boss_iceking_hil_twoway,
ban_card_tag_list={1,3},
}
-----------------------
-----------------------
-------阵容配置---------
---------三路----------
-----------------------
-----------------------
--第一波
-----无属性阵容
wave01_noelement_threeway={
[1]={{monster_package={16001,16002,16003},count=10,max=5,min=5,route={1,2,3}}},
}
--第二波
-----无属性阵容
wave02_noelement_threeway={
[1]={{monster_package={16010,16011,16012,16013,16014,16015},count=10,max=5,min=5,route={1,2,3}}},
}
-----冰属性阵容
wave02_ice_threeway={
[1]={{monster_package={16020},count=10,max=5,min=5,route={1,2,3}}},
}
-----火属性阵容
wave02_fire_threeway={
[1]={{monster_package={16017},count=10,max=5,min=5,route={1,2,3}}},
}
-----雷属性阵容
wave02_electricity_threeway={
[1]={{monster_package={16021},count=10,max=5,min=5,route={1,2,3}}},
}
--第三波
-----无属性阵容
wave03_noelement_threeway={
[1]={{monster_package={16033,16034,16035},count=10,max=5,min=5,route={1,2,3}}},
}
-----冰属性阵容
wave03_ice_threeway={
[1]={{monster_package={16031},count=10,max=5,min=5,route={1,2,3}}},
}
-----火属性阵容
wave03_fire_threeway={
[1]={{monster_package={16030},count=10,max=5,min=5,route={1,2,3}}},
}
-----雷属性阵容
wave03_electricity_threeway={
[1]={{monster_package={16032},count=10,max=5,min=5,route={1,2,3}}},
}
--第四波
-----无属性阵容
wave04_noelement_threeway={
[1]={{monster_package={16044,16045},count=10,max=5,min=5,route={1,2,3}}},
}
-----无属性阵容
wave04_defender_threeway={
[1]={{monster_package={16043},count=2,max=1,min=1,route={1,2}},{monster_package={16043},count=2,max=1,min=1,route={3}}},
}
-----冰属性阵容
wave04_ice_threeway={
[1]={{monster_package={16042},count=10,max=5,min=5,route={1,2,3}}},
}
-----火属性阵容
wave04_fire_threeway={
[1]={{monster_package={16040},count=10,max=5,min=5,route={1,2,3}}},
}
-----雷属性阵容
wave04_electricity_threeway={
[1]={{monster_package={16041},count=10,max=5,min=5,route={1,2,3}}},
}
--第五波
--小宝:输出校验,几乎百搭所有炮台build
wave05_boss_defender_threeway={
[1]={{monster_package={16050},count=2,max=1,min=1,route={1,2,3}}},
}
--龙蜥:远程炮台,需要玩家提升炮台射程
wave05_boss_dragon_threeway={
[1]={{monster_package={16051},count=2,max=1,min=1,route={1,2,3}}},
}
--追猎者:需要玩家提升控制炮台的能力
wave05_boss_hunter_threeway={
[1]={{monster_package={16052},count=2,max=1,min=1,route={1,2,3}}},
}
--霜铠王:需要玩家提升对冰能力
wave05_boss_iceking_threeway={
[1]={{monster_package={16053},count=2,max=1,min=1,route={1,2,3}}},
}
--岩盔王:需要玩家提升对火能力、破岩能力
wave05_boss_rockking_threeway={
[1]={{monster_package={16054},count=2,max=1,min=1,route={1,2,3}}},
}
--雷暴王:需要玩家提升对雷能力
wave05_boss_electricking_threeway={
[1]={{monster_package={16055},count=2,max=1,min=1,route={1,2,3}}},
}
--[二色]霜铠王+雷暴王
wave05_boss_rockking_iceking_threeway={
[1]={{monster_package={16054},count=2,max=1,min=1,route={1}},{monster_package={16053},count=2,max=1,min=1,route={2}},{monster_package={16053},count=2,max=1,min=1,route={3}}},
}
--暴徒
wave05_boss_thug_threeway={
[1]={{monster_package={16056},count=10,max=5,min=5,route={1,2,3}}},
}
--雷暴王+小怪
wave05_boss_electricking_hil_threeway={
[1]={{monster_package={16057},count=6,max=4,min=4,route={1,2,3}}},
}
--岩盔王+小怪
wave05_boss_rockking_hil_threeway={
[1]={{monster_package={16058},count=6,max=4,min=4,route={1,2,3}}},
}
--霜铠王+小怪
wave05_boss_iceking_hil_threeway={
[1]={{monster_package={16059},count=6,max=4,min=4,route={1,2,3}}},
}
-----------------------
---------三路----------
-----------------------
-----无属性小宝阵容
local stage_defender_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_noelement_threeway,
[3]=wave03_noelement_threeway,
[4]=wave04_defender_threeway,
[5]=wave05_boss_defender_threeway,
ban_card_tag_list={6,7},
}
-----无属性龙蜥阵容
local stage_dragon_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_noelement_threeway,
[3]=wave03_noelement_threeway,
[4]=wave04_noelement_threeway,
[5]=wave05_boss_dragon_threeway,
ban_card_tag_list={1,4},
}
-----无属性猎者阵容
local stage_hunter_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_noelement_threeway,
[3]=wave03_noelement_threeway,
[4]=wave04_noelement_threeway,
[5]=wave05_boss_hunter_threeway,
ban_card_tag_list={4,6},
}
-----冰属性阵容
local stage_iceking_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_ice_threeway,
[3]=wave03_ice_threeway,
[4]=wave04_ice_threeway,
[5]=wave05_boss_iceking_threeway,
ban_card_tag_list={1,3},
}
-----火属性阵容
local stage_rockking_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_fire_threeway,
[3]=wave03_fire_threeway,
[4]=wave04_fire_threeway,
[5]=wave05_boss_rockking_threeway,
ban_card_tag_list={2,5},
}
-----雷属性阵容
local stage_electricking_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_electricity_threeway,
[3]=wave03_electricity_threeway,
[4]=wave04_electricity_threeway,
[5]=wave05_boss_electricking_threeway,
ban_card_tag_list={1,5},
}
-----[三色]火+冰属性阵容
local stage_iceking_rockking_electricking_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_noelement_threeway,
[3]=wave03_noelement_threeway,
[4]=wave04_noelement_threeway,
[5]=wave05_boss_rockking_iceking_threeway,
ban_card_tag_list={1,4},
}
-----无属性暴徒阵容
local stage_thug_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_noelement_threeway,
[3]=wave03_noelement_threeway,
[4]=wave04_noelement_threeway,
[5]=wave05_boss_thug_threeway,
ban_card_tag_list={1,5},
}
-----嘲讽雷暴王+小怪阵容
local stage_electricking_hil_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_noelement_threeway,
[3]=wave03_noelement_threeway,
[4]=wave04_noelement_threeway,
[5]=wave05_boss_electricking_hil_threeway,
ban_card_tag_list={3,6},
}
-----嘲讽岩盔王+小怪阵容
local stage_rockking_hil_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_noelement_threeway,
[3]=wave03_noelement_threeway,
[4]=wave04_noelement_threeway,
[5]=wave05_boss_rockking_hil_threeway,
ban_card_tag_list={1,4},
}
-----嘲讽霜铠王+小怪阵容
local stage_iceking_hil_threeway={
[1]=wave01_noelement_threeway,
[2]=wave02_noelement_threeway,
[3]=wave03_noelement_threeway,
[4]=wave04_noelement_threeway,
[5]=wave05_boss_iceking_hil_threeway,
ban_card_tag_list={1,3},
}
-----------------------
-----------------------
-------阵容配置---------
---------四路----------
-----------------------
-----------------------
--第一波
-----无属性阵容
wave01_noelement_fourway={
[1]={{monster_package={16001,16002,16003},count=10,max=5,min=5,route={1,2}},{monster_package={16001,16002,16003},count=5,max=2,min=2,route={3,4}}},
}
--第二波
-----无属性阵容
wave02_noelement_fourway={
[1]={{monster_package={16010,16011,16012,16013,16014,16015},count=10,max=5,min=5,route={1,2}},{monster_package={16010,16011,16012,16013,16014,16015},count=5,max=2,min=2,route={3,4}}},
}
-----冰属性阵容
wave02_ice_fourway={
[1]={{monster_package={16020},count=10,max=5,min=5,route={1,2}},{monster_package={16020},count=5,max=2,min=2,route={3,4}}},
}
-----火属性阵容
wave02_fire_fourway={
[1]={{monster_package={16017},count=10,max=5,min=5,route={1,2}},{monster_package={16017},count=5,max=2,min=2,route={3,4}}},
}
-----雷属性阵容
wave02_electricity_fourway={
[1]={{monster_package={16021},count=10,max=5,min=5,route={1,2}},{monster_package={16021},count=5,max=2,min=2,route={3,4}}},
}
-----[四色]冰+火属性阵容
wave02_ice_fire_fourway={
[1]={{monster_package={16020},count=10,max=5,min=5,route={1,2}},{monster_package={16017},count=5,max=2,min=2,route={3,4}}},
}
--第三波
-----无属性阵容
wave03_noelement_fourway={
[1]={{monster_package={16033,16034,16035},count=10,max=5,min=5,route={1,2}},{monster_package={16033,16034,16035},count=5,max=2,min=2,route={3,4}}},
}
-----冰属性阵容
wave03_ice_fourway={
[1]={{monster_package={16031},count=10,max=5,min=5,route={1,2}},{monster_package={16031},count=5,max=2,min=2,route={3,4}}},
}
-----火属性阵容
wave03_fire_fourway={
[1]={{monster_package={16030},count=10,max=5,min=5,route={1,2}},{monster_package={16030},count=5,max=2,min=2,route={3,4}}},
}
-----雷属性阵容
wave03_electricity_fourway={
[1]={{monster_package={16032},count=10,max=5,min=5,route={1,2}},{monster_package={16032},count=5,max=2,min=2,route={3,4}}},
}
-----[四色]冰+火属性阵容
wave03_ice_fire_fourway={
[1]={{monster_package={16031},count=10,max=5,min=5,route={1,2}},{monster_package={16030},count=5,max=2,min=2,route={3,4}}},
}
--第四波
-----无属性阵容
wave04_noelement_fourway={
[1]={{monster_package={16044,16045},count=10,max=5,min=5,route={1,2}},{monster_package={16044,16045},count=5,max=2,min=2,route={3,4}}},
}
-----无属性阵容
wave04_defender_fourway={
[1]={{monster_package={16043},count=2,max=1,min=1,route={1,2}},{monster_package={16043},count=2,max=1,min=1,route={3,4}}},
}
-----冰属性阵容
wave04_ice_fourway={
[1]={{monster_package={16042},count=10,max=5,min=5,route={1,2}},{monster_package={16042},count=5,max=2,min=2,route={3,4}}},
}
-----火属性阵容
wave04_fire_fourway={
[1]={{monster_package={16040},count=10,max=5,min=5,route={1,2}},{monster_package={16040},count=5,max=2,min=2,route={3,4}}},
}
-----雷属性阵容
wave04_electricity_fourway={
[1]={{monster_package={16041},count=10,max=5,min=5,route={1,2}},{monster_package={16041},count=5,max=2,min=2,route={3,4}}},
}
-----[四色]冰+火属性阵容
wave04_ice_fire_fourway={
[1]={{monster_package={16042},count=10,max=5,min=5,route={1,2}},{monster_package={16040},count=5,max=2,min=2,route={3,4}}},
}
--第五波
--小宝:输出校验,几乎百搭所有炮台build
wave05_boss_defender_fourway={
[1]={{monster_package={16050},count=2,max=1,min=1,route={1,2}},{monster_package={16050},count=2,max=1,min=1,route={3,4}}},
}
--龙蜥:远程炮台,需要玩家提升炮台射程
wave05_boss_dragon_fourway={
[1]={{monster_package={16051},count=2,max=1,min=1,route={1,2}},{monster_package={16051},count=2,max=1,min=1,route={3,4}}},
}
--追猎者:需要玩家提升控制炮台的能力
wave05_boss_hunter_fourway={
[1]={{monster_package={16052},count=2,max=1,min=1,route={1,2}},{monster_package={16052},count=2,max=1,min=1,route={3,4}}},
}
--霜铠王:需要玩家提升对冰能力
wave05_boss_iceking_fourway={
[1]={{monster_package={16053},count=2,max=1,min=1,route={1,2}},{monster_package={16053},count=2,max=1,min=1,route={3,4}}},
}
--岩盔王:需要玩家提升对火能力、破岩能力
wave05_boss_rockking_fourway={
[1]={{monster_package={16054},count=2,max=1,min=1,route={1,2}},{monster_package={16054},count=2,max=1,min=1,route={3,4}}},
}
--雷暴王:需要玩家提升对雷能力
wave05_boss_electricking_fourway={
[1]={{monster_package={16055},count=2,max=1,min=1,route={1,2}},{monster_package={16055},count=2,max=1,min=1,route={3,4}}},
}
-----[四色]霜铠王+岩盔王
wave05_boss_iceking_rockking_fourway={
[1]={{monster_package={16053},count=2,max=1,min=1,route={1,2}},{monster_package={16054},count=2,max=1,min=1,route={3,4}}},
}
-----------------------
---------四路----------
-----------------------
-----无属性小宝阵容
local stage_defender_fourway={
[1]=wave01_noelement_fourway,
[2]=wave02_noelement_fourway,
[3]=wave03_noelement_fourway,
[4]=wave04_defender_fourway,
[5]=wave05_boss_defender_fourway,
ban_card_tag_list={6,7},
}
-----无属性龙蜥阵容
local stage_dragon_fourway={
[1]=wave01_noelement_fourway,
[2]=wave02_noelement_fourway,
[3]=wave03_noelement_fourway,
[4]=wave04_noelement_fourway,
[5]=wave05_boss_dragon_fourway,
ban_card_tag_list={1,4},
}
-----无属性猎者阵容
local stage_hunter_fourway={
[1]=wave01_noelement_fourway,
[2]=wave02_noelement_fourway,
[3]=wave03_noelement_fourway,
[4]=wave04_noelement_fourway,
[5]=wave05_boss_hunter_fourway,
ban_card_tag_list={4,6},
}
-----冰属性阵容
local stage_iceking_fourway={
[1]=wave01_noelement_fourway,
[2]=wave02_ice_fourway,
[3]=wave03_ice_fourway,
[4]=wave04_ice_fourway,
[5]=wave05_boss_iceking_fourway,
ban_card_tag_list={1,3},
}
-----火属性阵容
local stage_rockking_fourway={
[1]=wave01_noelement_fourway,
[2]=wave02_fire_fourway,
[3]=wave03_fire_fourway,
[4]=wave04_fire_fourway,
[5]=wave05_boss_rockking_fourway,
ban_card_tag_list={2,5},
}
-----雷属性阵容
local stage_electricking_fourway={
[1]=wave01_noelement_fourway,
[2]=wave02_electricity_fourway,
[3]=wave03_electricity_fourway,
[4]=wave04_electricity_fourway,
[5]=wave05_boss_electricking_fourway,
ban_card_tag_list={1,5},
}
-----[四色]冰+火属性阵容
local stage_iceking_rockking_fourway={
[1]=wave01_noelement_fourway,
[2]=wave02_ice_fire_fourway,
[3]=wave03_ice_fire_fourway,
[4]=wave04_ice_fire_fourway,
[5]=wave05_boss_iceking_rockking_fourway,
ban_card_tag_list={4,5}
}
@@ -0,0 +1,330 @@
--s1为空,s2往后自动引用为怪物潮
--[[
--怪物
--route_points配置默认值
--路径点的默认配置
local route_map={
[1]={route_points={1,2,3,4,5,6,7,8},tags=2},
[2]={route_points={1,2,3,4,5,6,7,8,9,10},tags=4}
}
local entrance_point_map={
[1]=2,
[2]=7,
[3]=8,
}
local entrance_map={
[2]=8,
[4]=9,
[8]=9
}
local exit_point_list={4,5}
--对应的刷怪策略
local monster_programme={
[1]=stage_defs_01,
[2]=stage_defs_02,
[3]=stage_defs_03,
}
--刷怪阶段对应的怪物波次
local stage_defs_01={
[1]=wave_01,
[2]=wave_05,
[3]=wave_06,
[4]=wave_02,
},
local stage_defs_02={
[1]=wave_01,
[2]=wave_02,
[3]=wave_03,
[4]=wave_04,
},
local stage_defs_03={
[1]=wave_01,
[2]=wave_02,
[3]=wave_03,
[4]=wave_04,
},
--每个波次的配置
local wave_01={
--[1]={monster_package={16002},route=1,route_points={1,2,3,4,5,6,7,8},tags=2,count=12,max=5,min=5}
--自定义配置项,route_points,tags
[1]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[2]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[3]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[4]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
},
local wave_02={
[1]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[2]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[3]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[4]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
},
local wave_03={
[1]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[2]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[3]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[4]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
},
local wave_04={
[1]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[2]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[3]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
[4]={{monster_package=slime_package,count=12,route={1,2}},{monster_package=hili_package,route={1}}},
},
--史莱姆
slime_package={monster_package={16002,16004},max=5,min=5}
hili_package={monster_package={16002,16004},max=5,min=5}
]]--
function LF_Init_Monster_Group()
t1 = { config_id = 8000001, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_monster_die", trigger_count = 0 }
t2 = { config_id = 8000002,name = "TIMER_EVENT_DELAY", event = EventType.EVENT_TIMER_EVENT, source = "delay", condition = "", action = "action_END_DELAY", trigger_count = 0 }
t3 = { config_id = 8000003,name = "MONSTER_WILL_LEAVE_SCENE", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_MONSTER_DIE_BEFORE_LEAVE_SCENE", trigger_count = 0 }
t4 = { config_id = 8000004,name = "EVENT_ANY_MONSTER_LIVE", event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "", action = "action_ANY_MONSTER_LIVE", trigger_count = 0 }
for i,v in ipairs(suites) do
table.insert(v.triggers, t1.name)
table.insert(v.triggers, t2.name)
table.insert(v.triggers, t3.name)
table.insert(v.triggers, t4.name)
end
table.insert(triggers, t1)
table.insert(triggers, t2)
table.insert(triggers, t3)
table.insert(triggers, t4)
table.insert(variables, { config_id=50000001,name = "tide_ptr", value = 0})
table.insert(variables, { config_id=50000002,name = "challenge_group", value = 0})
table.insert(variables, { config_id=50000003,name = "left_monsters", value = 0})
table.insert(variables, { config_id=50000004,name = "monster_tide_index", value = 1})
table.insert(variables, { config_id=50000005,name = "monster_kill_count", value = 0})
table.insert(variables, { config_id=50000006,name = "planNum", value = 1,no_refresh = true})
table.insert(variables, { config_id=50000007,name = "monster_wave_ptr", value = 1})
table.insert(variables, { config_id=50000008,name = "challenge_active_93", value = 0})
table.insert(variables, { config_id=50000009,name = "challenge_active_94", value = 0})
end
local gear_group_id = defs.gear_group_id or 0
function action_monster_die(context, evt)
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "del_monster_number", {0})
local monster_kill_count=ScriptLib.GetGroupVariableValue(context, "monster_kill_count")
monster_kill_count=monster_kill_count+1
if monster_kill_count >= ScriptLib.GetGroupVariableValue(context, "left_monsters") then
monster_tide_over(context)
end
ScriptLib.SetGroupVariableValue(context, "monster_kill_count", monster_kill_count)
return 0
end
function action_ANY_MONSTER_LIVE(context, evt)
ScriptLib.SetEntityServerGlobalValueByConfigId(context,evt.param1, "SGV_TD_AdditionalHP_Layers", ScriptLib.GetGroupVariableValue(context, "challenge_active_93"))
ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_TD_AdditionalDefence_Layers", ScriptLib.GetGroupVariableValue(context, "challenge_active_94"))
return 0
end
function action_MONSTER_DIE_BEFORE_LEAVE_SCENE(context, evt)
local challenge_group=ScriptLib.GetGroupVariableValue(context, "challenge_group")
local stepValue = ScriptLib.GetMonsterAbilityFloatValue(context, defs.group_id, evt.param1, "GV_ExtraBuildPoint")
local stepValueMark = ScriptLib.GetMonsterAbilityFloatValue(context, defs.group_id, evt.param1, "GV_ExtraMarkBuildPoint")
local stepValueSum = stepValue + stepValueMark
if stepValueSum > 0 then
local uidList=ScriptLib.GetSceneUidList(context)
--local addScore=math.ceil(stepValue/#uidList)
for i=1,#uidList do
ScriptLib.AddChessBuildingPoints(context, challenge_group, 999, uidList[i], stepValueSum)
end
end
return 0
end
function MonsterArrive(context)
local entityId=context.target_entity_id
ScriptLib.PrintContextLog(context, "TowerDefenseMonsterArrive"..context.target_entity_id)
for k,v in pairs(points) do
if ScriptLib.GetEntityIdByConfigId(context, v.config_id)==entityId then
local affixList=ScriptLib.GetMonsterAffixListByConfigId(context,defs.group_id, v.config_id)
for i=1,#affixList do
if affixList[i]==4130 then
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "monster_escaped", {1})
break
end
end
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "monster_escaped", {0})
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "del_monster_number", {0})
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.MONSTER, v.config_id)
local monster_kill_count=ScriptLib.GetGroupVariableValue(context, "monster_kill_count")
monster_kill_count=monster_kill_count+1
if monster_kill_count >= ScriptLib.GetGroupVariableValue(context, "left_monsters") then
monster_tide_over(context)
end
ScriptLib.SetGroupVariableValue(context, "monster_kill_count", monster_kill_count)
return 0
end
end
return 0
end
function set_monster_number_req(context, prev_context, param1, param2, param3)
local wave_ptr=param1
local monstersLeft=0
local planNumber=ScriptLib.GetGroupVariableValue(context, "planNum")
for i=1,#monster_programme[planNumber][wave_ptr] do
for j=1,#monster_programme[planNumber][wave_ptr][i] do
monstersLeft=monstersLeft+(monster_programme[planNumber][wave_ptr][i][j].count*#monster_programme[planNumber][wave_ptr][i][j].route)
end
end
ScriptLib.ExecuteGroupLua(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), "set_monster_number", {monstersLeft})
ScriptLib.SetGroupVariableValue(context, "left_monsters", monstersLeft)
return 0
end
function synchronization_card_num(context, prev_context, param1, param2, param3)
ScriptLib.SetGroupVariableValue(context, "challenge_active_93", param1)
ScriptLib.SetGroupVariableValue(context, "challenge_active_94", param2)
return 0
end
--启动此波的初始怪物潮
function start_tide(context, prev_context, param1, param2, param3)
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : start_tide"..param1.."|"..param2)
ScriptLib.SetGroupVariableValue(context, "monster_kill_count", 0)
ScriptLib.SetGroupVariableValue(context, "challenge_group", param1)
ScriptLib.SetGroupVariableValue(context, "monster_wave_ptr", param2)
local monster_pool_table=ScriptLib.GetChessMonsterPoolIdVecByRound(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), 999, ScriptLib.GetGroupVariableValue(context, "monster_wave_ptr"))
if #monster_pool_table==0 or monster_pool_table==nil then
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : monster_pool_table没取到")
else
for i=1,#monster_pool_table do
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : monster_pool_table="..monster_pool_table[i])
end
end
local affix={}
ScriptLib.SetGroupVariableValue(context, "tide_ptr", 1)
for i=1,#affix do
ScriptLib.PrintContextLog(context, "## TD_LOG : AFFIX TABLE"..affix[i])
end
local index=1
local curPlanNum=ScriptLib.GetGroupVariableValue(context, "planNum")
for i=1,#monster_programme[curPlanNum][param2][1] do
for j=1,#monster_programme[curPlanNum][param2][1][i].route do
ScriptLib.AutoPoolMonsterTide(context, index, defs.group_id, {monster_pool_table[index]},monster_programme[curPlanNum][param2][1][i].route[j], route_map[monster_programme[curPlanNum][param2][1][i].route[j]].route_points, affix, {total_count=monster_programme[curPlanNum][param2][1][i].count, min_count=monster_programme[curPlanNum][param2][1][i].min, max_count=monster_programme[curPlanNum][param2][1][i].max, tag=route_map[monster_programme[curPlanNum][param2][1][i].route[j]].tags,fill_time=5,fill_count=5})
index=index+1
end
end
ScriptLib.SetGroupVariableValue(context, "monster_tide_index", index)
return 0
end
--给主控提供ban_tag_list
function req_ban_tag(context, prev_context, param1, param2, param3)
local tag1=999
local tag2=999
local tag3=999
if monster_programme[param1].ban_card_tag_list~=nil then
if monster_programme[param1].ban_card_tag_list[1]~=nil then
tag1=monster_programme[param1].ban_card_tag_list[1]
end
if monster_programme[param1].ban_card_tag_list[2]~=nil then
tag2=monster_programme[param1].ban_card_tag_list[2]
end
if monster_programme[param1].ban_card_tag_list[3]~=nil then
tag3=monster_programme[param1].ban_card_tag_list[3]
end
end
ScriptLib.ExecuteGroupLua(context, param2, "add_ban_tag", {tag1,tag2,tag3})
return 0
end
--推送给主控怪物预览信息
function set_monster_preview(context, prev_context, param1, param2, param3)
--设置方案
ScriptLib.SetGroupVariableValue(context, "planNum", param2)
--设置挑战groupid
ScriptLib.SetGroupVariableValue(context, "challenge_group", param1)
math.randomseed(ScriptLib.GetServerTime(context))
local randomidx=0
local monster_preview_table={}
monster_preview_table.entrance_point_map=entrance_point_map
monster_preview_table.exit_point_id_list=exit_point_list
monster_preview_table.entrance_detail_list={}
--monster_preview_table.ban_card_tag_list={}
--if monster_programme[param2].ban_card_tag_list~=nil then
--monster_preview_table.ban_card_tag_list=monster_programme[param2].ban_card_tag_list
--end
--i,总阶段数,j,每个阶段怪物波次数,k每一波的路数
for i=1,#monster_programme[param2] do
local currentRoundDetailList={round=i,pool_info_list={}}
for j=1,#monster_programme[param2][i] do
for k=1,#monster_programme[param2][i][j] do
randomidx=math.random(#monster_programme[param2][i][j][k].monster_package)
for n=1,#monster_programme[param2][i][j][k].route do
local tempTbl={pool_id=monster_programme[param2][i][j][k].monster_package[randomidx],entrance_point_id=entrance_map[route_map[monster_programme[param2][i][j][k].route[n]].tags]}
table.insert(currentRoundDetailList.pool_info_list,tempTbl)
end
end
end
table.insert(monster_preview_table.entrance_detail_list,currentRoundDetailList)
end
if 0~=ScriptLib.SetChessMystery(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), 999, monster_preview_table) then
ScriptLib.PrintContextLog(context, "## TD2.0_LOG : monster_pool_table设置失败:"..monster_preview_table.entrance_detail_list[1].round.."|"..monster_preview_table.entrance_detail_list[1].pool_info_list[1].pool_id.."|"..monster_preview_table.entrance_detail_list[1].pool_info_list[1].entrance_point_id)
end
return 0
end
function action_END_DELAY(context, evt)
local challenge_group = ScriptLib.GetGroupVariableValue(context, "challenge_group")
ScriptLib.PrintContextLog(context, "## challenge_group = "..challenge_group)
ScriptLib.ExecuteGroupLua(context, challenge_group, "tide_done", {0})
ScriptLib.PrintContextLog(context, "## TD_LOG : Group Monster Tide End -> "..defs.group_id)
return 0
end
function monster_tide_over(context)
local curPlanNum=ScriptLib.GetGroupVariableValue(context, "planNum")
local param2=ScriptLib.GetGroupVariableValue(context, "monster_wave_ptr")
ScriptLib.PrintContextLog(context, "## monster_tide_over")
local tide = ScriptLib.GetGroupVariableValue(context, "tide_ptr")
if tide >= #monster_programme[curPlanNum][param2] then
local challenge_group = ScriptLib.GetGroupVariableValue(context, "challenge_group")
ScriptLib.PrintContextLog(context, "## challenge_group = "..challenge_group)
ScriptLib.ExecuteGroupLua(context, challenge_group, "tide_done", {0})
ScriptLib.PrintContextLog(context, "## TD_LOG : Group Monster Tide End -> "..defs.group_id)
return 0
end
--tide自然结束,开启下一tide
tide = tide+1
local index=ScriptLib.GetGroupVariableValue(context, "monster_tide_index")
local monster_pool_table=ScriptLib.GetChessMonsterPoolIdVecByRound(context, ScriptLib.GetGroupVariableValue(context, "challenge_group"), 999, ScriptLib.GetGroupVariableValue(context, "monster_wave_ptr"))
local affix={}
for i=1,#monster_programme[curPlanNum][param2][tide] do
for j=1,#monster_programme[curPlanNum][param2][tide][i].route do
ScriptLib.AutoPoolMonsterTide(context, index, defs.group_id, {monster_pool_table[index]},monster_programme[curPlanNum][param2][tide][i].route[j], route_map[monster_programme[curPlanNum][param2][tide][i].route[j]].route_points, affix, {total_count=monster_programme[curPlanNum][param2][tide][i].count, min_count=monster_programme[curPlanNum][param2][tide][i].min, max_count=monster_programme[curPlanNum][param2][tide][i].max, tag=route_map[monster_programme[curPlanNum][param2][tide][i].route[j]].tags,fill_time=5,fill_count=5})
index=index+1
end
end
ScriptLib.SetGroupVariableValue(context, "monster_tide_index", index)
ScriptLib.SetGroupVariableValue(context, "tide_ptr", tide)
return 0
end
function fix_gear(context, prev_context, param1, param2, param3)
ScriptLib.ExecuteGroupLua(context, defs.gear_group_id, "fix_gear", {param1})
end
LF_Init_Monster_Group()
@@ -0,0 +1,35 @@
local extraTriggers={
{ config_id = 8000001, name = "GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 8000002, name = "GENERAL_REWARD_TAKEN", event = EventType.EVENT_GENERAL_REWARD_TAKEN, source = "", condition = "", action = "action_EVENT_GENERAL_REWARD_TAKEN", trigger_count = 0 }
}
function LF_Initialize_Group(triggers, suites)
for i=1,#extraTriggers do
table.insert(triggers, extraTriggers[i])
table.insert(suites[init_config.suite].triggers,extraTriggers[i].name)
end
table.insert(variables, { config_id=51100001,name = "Created", value = 0,no_refresh = true })
end
function action_EVENT_GROUP_LOAD(context, evt)
if ScriptLib.GetGroupVariableValue(context, "Created") == 0 then
ScriptLib.PrintContextLog(context,"DIG: DIG POINT GROUP LOADED")
for i=1,#gadgets do
if gadgets[i].gadget_id == 70220069 then
ScriptLib.CreateTreasureMapSpotRewardGadget(context, gadgets[i].config_id)
end
end
end
return 0
end
function action_EVENT_GENERAL_REWARD_TAKEN(context, evt)
ScriptLib.SetGroupVariableValue(context, "Created", 1)
ScriptLib.PrintContextLog(context,"DIG: AWARD HAS BEEN TAKEN")
return ScriptLib.CreateMonstersFromMonsterPool(context,"盗宝团")
end
LF_Initialize_Group(triggers, suites)
@@ -0,0 +1,119 @@
-- Trigger变量
---[[
local screenGadgetID = { 70310076, 70310077}
local transPos =
{
[1] = { x = 1.5, y = 0.147, z = -15 },
[2] = { x = -1.5, y = 0.147, z = -15 },
[3] = { x = 4.5, y = 0.147, z = -15 },
[4] = { x = -4.5, y = 0.147, z = -15 },
}
local bossConfigID = 1004
--]]
--------Boss女士-------------
local tempTrigger = {
{ config_id = 2330001, name = "TIME_AXIS_MovieEventSolo", event = EventType.EVENT_TIME_AXIS_PASS, source = "MovieEventSolo",
condition = "", action = "action_TIME_AXIS_MovieEventSolo", trigger_count = 0},
{ config_id = 2330002, name = "TIME_AXIS_MovieEvent", event = EventType.EVENT_TIME_AXIS_PASS, source = "MovieEvent",
condition = "", action = "action_TIME_AXIS_MovieEvent", trigger_count = 0},
{ config_id = 2330003, name = "ANY_MONSTER_DIE_ThirdBoss", event = EventType.EVENT_ANY_MONSTER_DIE, source = "",
condition = "", action = "action_ANY_MONSTER_DIE_ThirdBoss", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
local var = { config_id=50000001,name = "PhaseStep", value = 0, no_refresh = false } --阶段数据
variables[var.name] = var
return 0
end
--------公用函数----------
function PlayCutScene(context)
ScriptLib.PrintContextLog(context, "-------------- INITIALIZE 1 ------------------")
--播CS前直接切当前气候为自然气候
ScriptLib.ModifyClimatePolygonParamTable(context, 1, {climate_type=0,meter_inherit_ratio=0})
ScriptLib.PrintContextLog(context, "## TD LaSignora Boss1已死亡,气候重置,等待创生Boss切换新气候")
local uidList=ScriptLib.GetSceneUidList(context)
if #uidList < 2 then
ScriptLib.PlayCutScene(context, defs.cutSceneID, 0)
ScriptLib.InitTimeAxis(context, "MovieEventSolo",{2}, false)
ScriptLib.PrintContextLog(context, "## TD LaSignora 单机下:开启Cs事件 Send Time Axis")
else
if #uidList <=4 then
for i=1,#uidList do
ScriptLib.TransPlayerToPos(context, {uid_list ={uidList[i]}, pos = transPos[i], radius = 2, rot = {x=0, y=0, z=0}})
end
end
ScriptLib.InitTimeAxis(context, "MovieEvent",{1}, false)
ScriptLib.PrintContextLog(context, "## TD LaSignora 联网下:开启Cs事件 Send Time Axis")
end
return 0
end
function CallPhaseChange(context,phaseNum)
ScriptLib.PrintContextLog(context, "## TD LaSignora 战斗脚本通知阶段改变,当前阶段为阶段" .. phaseNum)
ScriptLib.SetGroupVariableValue(context, "PhaseStep", phaseNum)
end
-- 切换Climate为HotMonster(ModifyClimatePolygonParamTable)
function ChangeClimateToHotMonster(context)
-- 该功能仅用于女士地城
ScriptLib.ModifyClimatePolygonParamTable(context, 1, {climate_type=4,meter_inherit_ratio=0})
ScriptLib.PrintContextLog(context, "## TD LaSignora :当前气候已切换为HotMonster")
return 0
end
--------事件函数----------
function action_TIME_AXIS_MovieEventSolo(context)
local uidList=ScriptLib.GetSceneUidList(context)
ScriptLib.CreateMonster(context, { config_id = 1004, delay_time = 0.5 })
for k,v in pairs(gadgets) do
if IsGadgetScreen(v.config_id) then
ScriptLib.PrintContextLog(context, "## TD LaSignora Config_id == " .. v.config_id)
ScriptLib.RemoveEntityByConfigId(context, defs.groupID, EntityType.GADGET, v.config_id )
end
end
ScriptLib.TransPlayerToPos(context, {uid_list = {uidList[1]}, pos = transPos[1], radius = 2, rot = {x=0, y=0, z=0},is_skip_ui = true})
return 0
end
function action_TIME_AXIS_MovieEvent(context)
-- 创建怪
ScriptLib.CreateMonster(context, { config_id = 1004, delay_time = 0 })
-- 移除Gadget
for k,v in pairs(gadgets) do
if IsGadgetScreen(v.config_id) then
ScriptLib.PrintContextLog(context, "## TD LaSignora Config_id == " .. v.config_id)
ScriptLib.RemoveEntityByConfigId(context, defs.groupID, EntityType.GADGET, v.config_id )
end
end
return 0
end
function action_ANY_MONSTER_DIE_ThirdBoss(context,evt)
if evt.param1 == bossConfigID then
ScriptLib.ModifyClimatePolygonParamTable(context, 1, {climate_type=0,meter_inherit_ratio=0})
ScriptLib.PrintContextLog(context, "## TD LaSignora :战斗结束,天气切换回默认")
end
return 0
end
--------私有函数----------
-- 是否为屏风Gadget
function IsGadgetScreen(config_id)
local gadgetId = gadgets[config_id].gadget_id
for i = 1, #screenGadgetID, 1 do
if(screenGadgetID[i] == gadgetId) then
return true
end
end
return false
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---
@@ -0,0 +1,122 @@
--[[======================================
|| filename: Boss_Raijin
|| owner: zijun.ma
|| description: 雷音权现Boss战专用
|| LogName: ##[TD_Raijin]
|| Protection:
=======================================]]--
-- Trigger变量
--[[
local defs = {
BossConfigID = 181001,
regionID = 181005,
}
--]]
--------Boss女士-------------
local tempTrigger = {
{ config_id = 2330001, name = "EVENT_ENTER_REGION", event = EventType.EVENT_ENTER_REGION, source = "",
condition = "", action = "action_BattleStart", trigger_count = 0,forbid_guest = false },
{ config_id = 2330002, name = "EVENT_LEAVE_REGION", event = EventType.EVENT_LEAVE_REGION, source = "",
condition = "", action = "action_LeaveRegion", trigger_count = 0,forbid_guest = false},
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
end
--------公用函数----------
-- 入圈时ForceRefreshAuthorityByConfigId
-- 离圈时TryReallocateEntityAuthority
-- 入战时强制将Authority刷新到主机
function action_BattleStart(context,evt)
if evt.param1 ~= defs.regionID then
return 0
end
ScriptLib.PrintContextLog(context,"##TD_Raijin: 玩家"..context.uid.. "进战斗圈")
-- 入战时,尽可能分配Hosthost在圈里分给host、host不在分给任意圈内玩家)
local no_avatar_in_region = true
local uidlist = ScriptLib.GetSceneUidList(context)
if uidlist == -1 or uidlist == nil or #uidlist == 0 then
ScriptLib.PrintContextLog(context,"##TD_Raijin: 没有取到uidlist,上限触发region,强制锁Auth为入圈者")
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.BossConfigID, context.uid)
return 0
end
for i = 1, #uidlist do
if (LF_Avatar_is_in_region(context,uidlist[i],defs.regionID) and uidlist[i] ~= context.uid) then
no_avatar_in_region = false
ScriptLib.PrintContextLog(context,"##TD_Raijin: 圈内存在玩家:"..uidlist[i]..",不分配authortiy")
break
end
end
if (no_avatar_in_region) then
ScriptLib.PrintContextLog(context,"##TD_Raijin: 第一个进入region的玩家"..context.uid..",分配authortiy")
--将Authority强行设置为进圈的玩家
ScriptLib.ForceRefreshAuthorityByConfigId(context, defs.BossConfigID, context.uid)
end
return 0
end
-- 切阶段二环境
function action_LeaveRegion(context,evt)
if evt.param1 ~= defs.regionID then
return 0
end
ScriptLib.PrintContextLog(context, "## TD_Raijin : 离开的玩家uid = "..context.uid)
local ret = ScriptLib.TryReallocateEntityAuthority(context, context.uid, defs.BossConfigID, evt.param1)
ScriptLib.PrintContextLog(context, "## TD_Raijin : 返回值为 "..ret)
return 0
end
function LF_Avatar_is_in_region(context,uid,region_id)
local avatar_id = ScriptLib.GetAvatarEntityIdByUid(context, uid)
local pos1 = ScriptLib.GetPosByEntityId(context, avatar_id)
local region = {}
for i = 1, #regions do
if regions[i].config_id == region_id then
region = regions[i]
end
end
local X = pos1.x - region.pos.x
local Y = pos1.y - region.pos.y
local Z = pos1.z - region.pos.z
if region.shape == RegionShape.SPHERE then
ScriptLib.PrintContextLog(context, "## TD_Raijin : LF_Avatar_is_in_region 距离为 = "..math.sqrt(X*X+Y*Y+Z*Z))
ScriptLib.PrintContextLog(context, "## TD_Raijin : LF_Avatar_is_in_region Radius为 = "..region.radius)
if math.sqrt(X*X+Y*Y+Z*Z) <= region.radius then
return true
else
return false
end
elseif region.shape == RegionShape.CUBIC then
ScriptLib.PrintContextLog(context, "## TD_Raijin : LF_Avatar_is_in_region 距离为 = "..math.sqrt(X*X+Y*Y+Z*Z))
ScriptLib.PrintContextLog(context, "## TD_Raijin : LF_Avatar_is_in_region size为 = "..region.size.z/2)
if math.abs(X) > region.size.x/2 or math.abs(Y) > region.size.y/2 or math.abs(Z) > region.size.z/2 then
return false
else
return true
end
end
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---
@@ -0,0 +1,114 @@
-- Trigger变量
--[[
local defs = {
BossConfigID = 1002,
EnvConfigID = 1001,
GroupID = 220117001,
}
--]]
--------Boss女士-------------
local tempTrigger = {
--[[
{ config_id = 2330001, name = "EVENT_QUEST_START", event = EventType.EVENT_QUEST_START, source = "202010",
condition = "", action = "action_NoticeMonsterEnterPhaseSecond", trigger_count = 0},
--]]
{ config_id = 2330002, name = "VARIABLE_CHANGE_DebugTest", event = EventType.EVENT_VARIABLE_CHANGE, source = "DebugPhase",
condition = "", action = "action_DebugTest", trigger_count = 0},
{ config_id = 2330003, name = "TIME_AXIS_MovieEvent1", event = EventType.EVENT_TIME_AXIS_PASS, source = "PhaseAxis1",
condition = "", action = "action_TIME_AXIS_MovieEvent1", trigger_count = 0},
{ config_id = 2330004, name = "TIME_AXIS_MovieEvent2", event = EventType.EVENT_TIME_AXIS_PASS, source = "PhaseAxis2",
condition = "", action = "action_TIME_AXIS_MovieEvent2", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
local var = { config_id=50000001,name = "PhaseStep", value = 1, no_refresh = false } --阶段计数器
variables[var.name] = var
var = { config_id=50000002,name = "DebugPhase", value = 1, no_refresh = false } -- Debug用阶段计数器
variables[var.name] = var
return 0
end
--------公用函数----------
-- 通知关卡播CS
function SLC_PlayCutScene(context)
ScriptLib.PrintContextLog(context, "-------------- INITIALIZE 1 ------------------")
ScriptLib.AddQuestProgress(context, "202010")
ScriptLib.PrintContextLog(context, "## TD Shougun 通知任务202010进度增加")
action_NoticeMonsterEnterPhaseSecond(context)
return 0
end
-- 关卡通知怪物 (EVENT_CUTSCENE_END//_MONSTER_SHOUGUN_STAGE_) GROUP GET_TRIGGER 220117001 EVENT_QUEST_START
function action_NoticeMonsterEnterPhaseSecond(context)
ScriptLib.PrintContextLog(context, "## TD Shougun CutScene已播完,开始进入二阶段")
-- 传送
ScriptLib.InitTimeAxis(context, "PhaseAxis1",{1}, false)
return 0
end
-- 切阶段二环境
function action_TIME_AXIS_MovieEvent1(context,evt)
ScriptLib.PrintContextLog(context, "## TD Shougun CutScene已播完,延迟1秒转阶段")
--将环境GadgetState切至201
ScriptLib.SetGadgetStateByConfigId(context, defs.EnvConfigID, 201)
--关卡通知怪物 _MONSTER_SHOUGUN_TACHI_
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.BossConfigID, "SGV_MONSTER_SHOUGUN_CHANGETOTACHI", 2)
--阶段计数为2
-- GROUP GETVAR 220117001 PhaseStep
ScriptLib.SetGroupVariableValue(context, "PhaseStep", 2)
return 0
end
-- 怪物通知关卡进入阶段三
function SLC_EnterPhaseThird(context)
ScriptLib.PrintContextLog(context, "## TD Shougun 开始进入三阶段")
--将环境GadgetState切至202
ScriptLib.SetGadgetStateByConfigId(context, defs.EnvConfigID, 202)
ScriptLib.InitTimeAxis(context, "PhaseAxis2",{1}, false)
return 0
end
-- 切阶段三环境
function action_TIME_AXIS_MovieEvent2(context,evt)
ScriptLib.PrintContextLog(context, "## TD Shougun 延迟1秒,切环境")
--阶段计数为3
ScriptLib.SetGroupVariableValue(context, "PhaseStep", 3)
return 0
end
--------事件函数----------
--------私有函数----------
function action_TIME_AXIS_MovieEvent(context,evt)
-- 传送
ScriptLib.TransPlayerToPos(context, {uid_list =ScriptLib.GetSceneUidList(context), pos = { x = 502.498, y = 100.542, z = 498.351}, radius = 2, rot = {x=0, y=220, z=0}})
return 0
end
function action_DebugTest(context,evt)
-- Dungeon 1122
-- GROUP SETVAR 220117001 DebugPhase 1
if 1 == evt.param1 then
SLC_PlayCutScene(context)
return 0
end
if 2 == evt.param1 then
SLC_EnterPhaseThird(context)
return 0
end
return 0
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---
@@ -0,0 +1,92 @@
-- Trigger变量
--[[
local defs = {
BossConfigID = 1002,
EnvConfigID = 1001,
GroupID = 220117001,
}
--]]
--------Boss女士-------------
local tempTrigger = {
{ config_id = 2330002, name = "VARIABLE_CHANGE_DebugTest", event = EventType.EVENT_VARIABLE_CHANGE, source = "DebugPhase",
condition = "", action = "action_DebugTest", trigger_count = 0},
{ config_id = 2330003, name = "TIME_AXIS_MovieEvent1", event = EventType.EVENT_TIME_AXIS_PASS, source = "PhaseAxis1",
condition = "", action = "action_TIME_AXIS_MovieEvent1", trigger_count = 0},
{ config_id = 2330004, name = "TIME_AXIS_MovieEvent2", event = EventType.EVENT_TIME_AXIS_PASS, source = "PhaseAxis2",
condition = "", action = "action_TIME_AXIS_MovieEvent2", trigger_count = 0},
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
local var = { config_id=50000001,name = "PhaseStep", value = 1, no_refresh = false } --阶段计数器
variables[var.name] = var
var = { config_id=50000002,name = "DebugPhase", value = 1, no_refresh = false } -- Debug用阶段计数器
variables[var.name] = var
return 0
end
--------公用函数----------
-- 通知关卡播CS
function SLC_PlayCutScene(context)
ScriptLib.PrintContextLog(context, "-------------- INITIALIZE 1 ------------------")
ScriptLib.PrintContextLog(context, "Beta用测试流程")
--1秒后通知怪物变化动
ScriptLib.InitTimeAxis(context, "PhaseAxis1",{1}, false)
return 0
end
-- 切阶段二环境
function action_TIME_AXIS_MovieEvent1(context,evt)
ScriptLib.PrintContextLog(context, "## TD Shougun CutScene已播完,开始进入二阶段")
-- 通知将军切换状态
ScriptLib.SetEntityServerGlobalValueByConfigId(context, defs.BossConfigID, "SGV_MONSTER_SHOUGUN_CHANGETOTACHI", 2)
--阶段计数为2
-- GROUP GETVAR 220117001 PhaseStep
ScriptLib.SetGroupVariableValue(context, "PhaseStep", 2)
return 0
end
-- 怪物通知关卡进入阶段三
function SLC_EnterPhaseThird(context)
ScriptLib.PrintContextLog(context, "## TD Shougun 开始进入三阶段")
ScriptLib.InitTimeAxis(context, "PhaseAxis2",{1}, false)
return 0
end
-- 切阶段三环境
function action_TIME_AXIS_MovieEvent2(context,evt)
ScriptLib.PrintContextLog(context, "## TD Shougun 延迟1秒,切环境")
--阶段计数为3
ScriptLib.SetGroupVariableValue(context, "PhaseStep", 3)
return 0
end
--------事件函数----------
--------私有函数----------
function action_DebugTest(context,evt)
-- Dungeon 1122
-- GROUP SETVAR 220117001 DebugPhase 1
if 1 == evt.param1 then
SLC_PlayCutScene(context)
return 0
end
if 2 == evt.param1 then
SLC_EnterPhaseThird(context)
return 0
end
return 0
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---
@@ -0,0 +1,549 @@
--2.1换人挑战玩法
--miscs
----fever进度升级节点
--local fever_progress_table = {
-- 0,50,100,200,300,500
--}
----各等级fever的下降速率
--local fever_attenuation = {
-- -1,-2,-3,-4,-5
--}
--
--local monster_tide = {
-- [1] = {2001,2002,2003,2004,2005,2006,2007},
-- [2] = {2008,2009,2010,2011,2012,2013,2014}
--}
--
--local elite = {
-- 2015,2016,2017,2018,2019,2020,2021
--}
--
--local elite_born_points = {
-- 3001,3002,3003,3004,3005,3006,3007
--}
------
--local defs = {
-- group_id = 235801002,
-- worktop_id = 123,
-- minion_fever = 5,
-- game_time = 360,
-- minion_interval = 120,
-- elite_interval = 30,
-- elite_fever = 50,
-- min_monster_count = 5,
-- max_monster_count = 5,
-- environment_suite = 4,
--}
local local_defs = {
worktop_option = 30110,
progress_key = 1,
team_global_value = "FEVER_LEVEL",
team_noswitch_pubishment = "NOSWITCH_PUNISHMENT",
team_has_switch = "HAS_SWITCHED_TEAM",
burn_effect_level = 2,
environment_change_level = 1,
base_upgrade_reminder = 358010102,
team_noswitch_pubishment_reminder = 144,
}
local time_axis = {
--小怪潮替换时间轴,每次触发时替换小怪潮
minion_tide_axis = {defs.minion_tide_interval},
--精英怪潮替换时间轴,每次触发时替换精英怪潮
elite_tide_axis = {defs.elite_tide_interval},
--精英怪时间轴,每次触发时刷新一只精英怪
elite_axis = {defs.elite_interval},
--扣分时间轴,每秒掉一定的分数
fever_axis = {1},
noswitch_punishment_axis = {defs.noswitch_punishment_interval}
}
local Tri = {
[1] = { name = "group_load", config_id = 8000001, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "select_option", config_id = 8000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[3] = { name = "time_axis_pass", config_id = 8000003, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0},
[4] = { name = "gallery_progress_pass", config_id = 8000004, event = EventType.EVENT_GALLERY_PROGRESS_PASS, source = "", condition = "", action = "action_gallery_progress_pass", trigger_count = 0},
[5] = { name = "monster_tide_die", config_id = 8000005, event = EventType.EVENT_MONSTER_TIDE_DIE, source = "", condition = "", action = "action_monster_tide_die", trigger_count = 0},
[6] = { name = "monster_die_before_leave_scene", config_id = 8000006, event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE, source = "", condition = "", action = "action_monster_die_before_leave_scene", trigger_count = 0},
[7] = { name = "gallery_stop", config_id = 8000007, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
[8] = { name = "sumo_switch_team", config_id = 8000008, event = EventType.EVENT_SUMO_SWITCH_TEAM_EVENT, source = "", condition = "", action = "action_sumo_switch_team", trigger_count = 0},
[9] = { name = "dungeon_all_avatar_die", config_id = 8000009, event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_dungeon_all_avatar_die", trigger_count = 0},
[10] = { name = "dungeon_settle", config_id = 8000010, event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_dungeon_settle", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id=50000001,name = "current_monster_tide", value = 0})
table.insert(variables,{ config_id=50000002,name = "current_elite", value = 1})
table.insert(variables,{ config_id=50000003,name = "fever_ratio", value = 1})
--用于记录当前是否开启不换队惩罚,用于客户端断线重连时恢复状态
table.insert(variables,{ config_id=50000004,name = "is_noswitch_punishment", value = 0})
--用于记录当前精英是否在场,精英在场时,怪物潮不做刷新
table.insert(variables,{ config_id=50000005,name = "is_elite_on_ground", value = 0})
--用于记录当前怪物潮是否结束,当精英死亡时判断当前怪物潮是否处于结束状态,如果是,则直接加载下一波怪物潮
table.insert(variables,{ config_id=50000006,name = "is_current_minion_tide_end", value = 0})
end
------------------------------------------------------------------
--group load后,加载操作台选项
function action_group_load(context,evt)
ScriptLib.SetWorktopOptionsByGroupId(context, defs.group_id, defs.worktop_id, {local_defs.worktop_option})
--开场就直接加载氛围物件,不要等玩家开启挑战
--加载环境氛围物件
ScriptLib.AddExtraGroupSuite(context,defs.group_id,defs.environment_suite)
--启动第一个地城天气
--local ret = ScriptLib.SetWeatherAreaState(context, DungeonWeather[1],1)
--ScriptLib.PrintContextLog(context,"FS: The result of starting weather".. DungeonWeather[1].."is "..ret)
--ret = ScriptLib.EnterWeatherArea(context, DungeonWeather[1])
--ScriptLib.PrintContextLog(context,"FS: The result of entering weather".. DungeonWeather[1].."is "..ret)
return 0
end
--按下操作台按键,启动玩法
function action_select_option(context,evt)
ScriptLib.DelWorktopOptionByGroupId(context, defs.group_id, defs.worktop_id, local_defs.worktop_option)
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, defs.worktop_id, GadgetState.GearStop)
LF_Start_Play(context)
return 0
end
--时间轴tick事件,根据tick的时间轴不同处理不同逻辑
function action_time_axis_pass(context,evt)
--小怪时间轴tick,将小怪潮的index指向下一位(修改group variable
if (evt.source_name == "MINION_TIDE_AXIS") then
ScriptLib.PrintContextLog(context,"FS: MINION_TIDE_AXIS tick!")
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
LF_Set_Current_Monster_Tide(context,current_monster_tide+1)
end
--精英波次时间轴tick,将精英怪的index指向下一位
if (evt.source_name == "ELITE_TIDE_AXIS") then
ScriptLib.PrintContextLog(context,"FS: ELITE_TIDE_AXIS tick!")
local current_elite_index = LF_Get_Current_Elite_Index(context)
LF_Set_Current_Elite_Index(context,current_elite_index+1)
end
--精英时间轴tick,刷新下一只精英
if (evt.source_name == "ELITE_AXIS") then
ScriptLib.PrintContextLog(context,"FS: ELITE_AXIS tick!")
local current_elite_index = LF_Get_Current_Elite_Index(context)
LF_Create_Elite_Monster(context,current_elite_index)
--性能优化:刷出精英怪时,暂停怪物潮
ScriptLib.PrintContextLog(context,"FS: elite created. Stop monster tide ["..LF_Get_Current_Tide_Num(context).."]")
ScriptLib.SetGroupVariableValue(context,"is_elite_on_ground",1)
ScriptLib.PauseAutoMonsterTide(context, defs.group_id, LF_Get_Current_Tide_Num(context))
end
--fever条tick,扣分
if (evt.source_name == "FEVER_AXIS") then
LF_Update_Fever(context,LF_Get_Fever_Subnum(context))
end
--不换队tick,如果长时间不换队则将设置惩罚gv
if (evt.source_name == "NOSWITCH_PUNISHMENT_AXIS") then
--ScriptLib.PrintContextLog(context,"FS: Showing reminder "..local_defs.team_noswitch_pubishment_reminder)
ScriptLib.ShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {0})
--ScriptLib.ShowReminder(context, local_defs.team_noswitch_pubishment_reminder)
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",1)
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,1)
end
return 0
end
--fever升级时,给team挂global value,并激活场景氛围物件
function action_gallery_progress_pass(context,evt)
local fever_level = evt.param1
ScriptLib.PrintContextLog(context,"FS: Fever uprade to level "..fever_level)
ScriptLib.ShowReminder(context, local_defs.base_upgrade_reminder+fever_level)
LF_Set_Team_Global_Value(context,local_defs.team_global_value,fever_level)
LF_Activate_Environment_Gadget(context,fever_level)
return 0
end
function action_gallery_stop(context,evt)
LF_Stop_Play(context)
return 0
end
--当前的怪物潮刷完的时候,重置当前的怪物潮
function action_monster_tide_die(context,evt)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
--如果当前怪物潮已经被杀完了,且精英怪不在场
if (evt.param1 >= #monster_tide[current_monster_tide]) then
--记录一下当前怪物潮结束,精英怪死亡时需要手动打开一次
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",1)
local is_elite_on_ground = ScriptLib.GetGroupVariableValue(context,"is_elite_on_ground")
ScriptLib.PrintContextLog(context,"FS: Current tide ends, is elite on ground?? "..is_elite_on_ground)
if (is_elite_on_ground == 0) then
--精英不在场,才能开一个新的怪物潮
ScriptLib.PrintContextLog(context,"FS: No elite on ground. Create a new monster tide!")
ScriptLib.KillMonsterTide(context, defs.group_id, LF_Get_Current_Tide_Num(context))
LF_Create_Monster_Tide(context,current_monster_tide)
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",0)
end
end
return 0
end
--有怪死亡时,计分,并更新fever条
function action_monster_die_before_leave_scene(context,evt)
local monster_eid = evt.source_eid
local monster_cid = evt.param1
local is_elite = LF_Is_Elite(context,monster_cid)
local fever_ratio = ScriptLib.GetGroupVariableValue(context,"fever_ratio")
if (not is_elite) then
LF_Update_Fever(context,defs.minion_fever*fever_ratio)
else
LF_Update_Fever(context,defs.elite_fever*fever_ratio)
--精英死亡时,重新开始计时
ScriptLib.EndTimeAxis(context,"ELITE_AXIS")
ScriptLib.InitTimeAxis(context,"ELITE_AXIS",time_axis.elite_axis,false)
ScriptLib.SetGroupVariableValue(context,"is_elite_on_ground",0)
local is_current_minion_tide_end = ScriptLib.GetGroupVariableValue(context,"is_current_minion_tide_end")
if (is_current_minion_tide_end == 0) then
--当前怪物潮没有结束,则恢复怪物潮即可
ScriptLib.PrintContextLog(context,"FS: elite died. Restart monster tide")
--性能优化:精英怪死亡时,恢复怪物潮
ScriptLib.ContinueAutoMonster(context, defs.group_id, LF_Get_Current_Tide_Num(context))
else
--当前怪物潮已经结束了,但因为精英在场所以被卡住了。精英死亡时,手动开启新的怪物潮
ScriptLib.PrintContextLog(context,"FS: elite died but current tide is dead. Start a new tide!")
ScriptLib.KillMonsterTide(context, defs.group_id, LF_Get_Current_Tide_Num(context))
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
LF_Create_Monster_Tide(context,current_monster_tide)
ScriptLib.SetGroupVariableValue(context,"is_current_minion_tide_end",0)
end
end
LF_Update_Score(context,monster_eid)
return 0
end
--玩家换队时触发,启动一个一定时间的时间轴,时间轴tick时修改global value给玩家挂debuff
function action_sumo_switch_team(context,evt)
--刚刚换队,先清掉team上的换队惩罚global value,并开始计时,如果tick时没有换队,则挂上惩罚标记gv
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.EndTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS")
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
--换队增加热情值
LF_Update_Fever(context,defs.switch_team_fever)
--换队的时候给服务端发送消息,让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
--清除当前显示的换队惩罚的reminder
local uid_list = ScriptLib.GetSceneUidList(context)
local ret = ScriptLib.RevokePlayerShowTemplateReminder(context, local_defs.team_noswitch_pubishment_reminder, {})
ScriptLib.PrintContextLog(context,"FS: Clear reminder result"..ret)
--换队的时候修改team的gv,重新刷一下新的avatar身上的加成效果
--ScriptLib.PrintContextLog(context,"FS: team has changed, team_has_change = 1")
LF_Set_Team_Global_Value(context,local_defs.team_has_switch,1)
ScriptLib.SetGroupVariableValue(context,"is_noswitch_punishment",0)
return 0
end
--团灭触发,直接结束玩法
function action_dungeon_all_avatar_die(context,evt)
LF_Stop_Play(context)
return 0
end
function action_dungeon_settle(context,evt)
LF_Stop_Play(context)
return 0
end
------------------------------------------------------------------
--辅助方法---------------------------------------------------------
------------------------------------------------------------------
--关卡相关方法-----------------------------------------------------
--启动玩法方法,初始化各种东西
function LF_Start_Play(context)
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.InitGalleryProgressScore(context, "fever", defs.gallery_id, fever_progress_table, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_SUMO_STAGE, GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NO_DEGRADE)
ScriptLib.InitTimeAxis(context,"FEVER_AXIS",time_axis.fever_axis,true)
ScriptLib.InitTimeAxis(context,"MINION_TIDE_AXIS",time_axis.minion_tide_axis,true)
ScriptLib.InitTimeAxis(context,"ELITE_TIDE_AXIS",time_axis.elite_tide_axis,true)
ScriptLib.InitTimeAxis(context,"ELITE_AXIS",time_axis.elite_axis,false)
LF_Set_Current_Tide_Num(context,0)
LF_Set_Current_Monster_Tide(context,1)
LF_Set_Current_Elite_Index(context,1)
LF_Create_Monster_Tide(context,1)
--启动玩法时给第一队挂一下gv,防止一开始就受到惩罚;并开启时间轴开始计时
LF_Set_Team_Global_Value(context,local_defs.team_noswitch_pubishment,0)
ScriptLib.InitTimeAxis(context,"NOSWITCH_PUNISHMENT_AXIS",time_axis.noswitch_punishment_axis,false)
--玩法开始的时候给服务端发送消息,让客户端显示惩罚倒计时UI
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["noswitch_time"] = defs.noswitch_punishment_interval})
--加载空气墙
ScriptLib.CreateGadget(context,{config_id = defs.airwall})
end
--终止玩法方法,关掉各种东西
function LF_Stop_Play(context)
local current_monster_tide = LF_Get_Current_Monster_Tide(context)
--清理一下空气墙,防止其他问题
ScriptLib.RemoveEntityByConfigId(context, defs.group_id, EntityType.GADGET, defs.airwall)
--玩法结束,清理掉当前的怪物潮
ScriptLib.KillMonsterTide(context, defs.group_id, current_monster_tide)
ScriptLib.StopGallery(context, defs.gallery_id,true)
ScriptLib.EndTimeAxis(context,"FEVER_AXIS")
ScriptLib.EndTimeAxis(context,"MINION_TIDE_AXIS")
ScriptLib.EndTimeAxis(context,"ELITE_AXIS")
ScriptLib.EndTimeAxis(context,"ELITE_TIDE_AXIS")
--关闭一下地城,以正确触发重新挑战
ScriptLib.CauseDungeonFail(context)
end
--启动一波指定ID的怪物潮,需要传入该波怪物潮的ID(具体配置在miscs中定义)
function LF_Create_Monster_Tide(context,monster_tide_index)
ScriptLib.PrintContextLog(context,"FS: Creating monster tide ["..monster_tide_index.."]")
local monster_config_id_list = monster_tide[monster_tide_index]
--增加怪物潮的计数,下一次开启时index会+1,防止索引到同一波怪物潮
local tide_num = LF_Get_Current_Tide_Num(context)
LF_Set_Current_Tide_Num(context,tide_num+1)
ScriptLib.AutoMonsterTide(context, tide_num+1, defs.group_id, monster_config_id_list, #monster_config_id_list, defs.min_monster_count,defs.max_monster_count)
end
--在指定的point,召唤一个指定ID的精英怪
function LF_Create_Elite_Monster(context,elite_index)
local elite_config_id = elite[elite_index]
local elite_born = LF_Get_Point(context,elite_born_points[elite_index])
ScriptLib.PrintContextLog(context,"FS: Creating elite ["..elite_index.."] at point "..elite_born.pos.x..","..elite_born.pos.y..","..elite_born.pos.z)
ScriptLib.CreateMonsterByConfigIdByPos(context, elite_config_id, elite_born.pos, elite_born.rot)
end
--通用类方法-------------------------------------------------------
--切换场上的场景氛围物件状态
function LF_Activate_Environment_Gadget(context,fever_level)
ScriptLib.PrintContextLog(context,"FS: Activate environment gadgets!")
--根据当前的fever等级,改变天气
if (fever_level>local_defs.environment_change_level) then
--ScriptLib.PrintContextLog(context,"FS: Changing environment weather!")
local ret = ScriptLib.SetWeatherAreaState(context, DungeonWeather[fever_level],1)
--ScriptLib.PrintContextLog(context,"FS: The result of starting weather ".. DungeonWeather[fever_level].."is "..ret)
local ret = ScriptLib.EnterWeatherArea(context, DungeonWeather[fever_level])
--ScriptLib.PrintContextLog(context,"FS: The result of changing weather".. DungeonWeather[fever_level].."is "..ret)
end
--切换场上所有的物件的状态
for i = 1, #suites[defs.environment_suite].gadgets do
local config_id = suites[defs.environment_suite].gadgets[i]
local gadget_id = LF_Get_Gadget_Id_By_Config_Id(context,config_id)
--大小火盆
if (gadget_id == 70350306 or gadget_id == 70350307) then
if (fever_level<local_defs.burn_effect_level) then
--点燃小火
--ScriptLib.PrintContextLog(context,"FS: Burn little fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 101)
end
if (fever_level<#fever_progress_table-2 and fever_level>=local_defs.burn_effect_level) then
--喷大火,5秒后转回小火
--ScriptLib.PrintContextLog(context,"FS: Burn middle fire!")
local ret = ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
if (fever_level >= #fever_progress_table-2) then
--持续喷大火
--ScriptLib.PrintContextLog(context,"FS: Burn super fire!")
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 202)
end
end
--挂灯
if (gadget_id == 70350308) then
if (fever_level>=local_defs.burn_effect_level) then
--点燃小火
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 201)
end
end
--场景氛围
if (gadget_id == 70350309) then
--转到对应的gadgetStatedefault-0、phase1-201、phase2-202、phase3-203、phase4-204
ScriptLib.SetGroupGadgetStateByConfigId(context, defs.group_id, config_id, 200+fever_level)
end
end
end
--给team挂global value,角色处理各种特殊效果
function LF_Set_Team_Global_Value(context,gv_name,value)
--ScriptLib.PrintContextLog(context,"FS: Sending global values to team!")
local uid_list = ScriptLib.GetSceneUidList(context)
ScriptLib.SetTeamEntityGlobalFloatValue(context, uid_list, gv_name, value)
end
-----CRUD类方法----------------------------------------------------
--更新fever条,fever_delta为fever条改变值
function LF_Update_Fever(context,fever_delta)
ScriptLib.AddGalleryProgressScore(context, "fever", defs.gallery_id, fever_delta)
end
--更新积分,需要传入目标monster的entity id
function LF_Update_Score(context,monster_eid)
local uid_list = ScriptLib.GetSceneUidList(context)
local monster_id = ScriptLib.GetMonsterIdByEntityId(context,monster_eid)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["uid"] = uid_list[1], ["monster_id"] = monster_id})
end
--返回当前等级下的积分衰减速率
function LF_Get_Fever_Subnum(context)
local fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
for i = 1, #fever_progress_table-1 do
local lower_bound = fever_progress_table[i]
local higher_bound = fever_progress_table[i+1]
if fever>=lower_bound and fever<higher_bound then
return fever_attenuation[i]
end
end
return -1
end
--设置当前怪物潮的波次数(注意不等于怪物潮的index)。每次创建怪物潮会使波次数+1,方便索引新的怪物潮
function LF_Set_Current_Tide_Num(context,value)
ScriptLib.SetGroupTempValue(context, "MinionTide", value, {})
end
--获取当前怪物潮的波次数(注意不等于怪物潮的index)。每次创建怪物潮会使波次数+1,方便索引新的怪物潮
function LF_Get_Current_Tide_Num(context)
return ScriptLib.GetGroupTempValue(context, "MinionTide", {})
end
--设置当前大怪的进度index
function LF_Set_Current_Elite_Index(context,index)
ScriptLib.SetGroupVariableValue(context,"current_elite",index)
end
--获取当前大怪的进度index
function LF_Get_Current_Elite_Index(context)
local elite_index = ScriptLib.GetGroupVariableValue(context,"current_elite")
return elite_index
end
--设置当前怪物潮波次的index
function LF_Set_Current_Monster_Tide(context,index)
ScriptLib.SetGroupVariableValue(context,"current_monster_tide",index)
end
--获取当前怪物潮波次的index
function LF_Get_Current_Monster_Tide(context)
local monster_tide = ScriptLib.GetGroupVariableValue(context,"current_monster_tide")
return monster_tide
end
--根据config id 返回一个点位
function LF_Get_Point(context,point_cid)
for i = 1,#points do
if (points[i].config_id == point_cid) then
return points[i]
end
end
return -1
end
--根据gadget的config_id查询gadget_id
function LF_Get_Gadget_Id_By_Config_Id(context, config_id)
for i = 1,#gadgets do
if (gadgets[i].config_id == config_id) then
return gadgets[i].gadget_id
end
end
return 0
end
--返回一个指定configid的怪物是否是大怪
function LF_Is_Elite(context,monster_cid)
for i = 1,#elite do
if monster_cid == elite[i] then
return true
end
end
return false
end
------------------------------------------------------------------
--server lua call-------------------------------------------------
function SLC_Update_Fever_Ratio(context,new_fever_ratio)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Changing fever ratio to: "..new_fever_ratio)
ScriptLib.SetGroupVariableValue(context,"fever_ratio",new_fever_ratio)
return 0
end
--向客户端下发当前的惩罚状态和fever值,用于客户端重连时请求
function SLC_Refresh_Team_State(context)
ScriptLib.PrintContextLog(context,"FS: SERVER_LUA_CALL: Request for refresh punishment state: ")
local is_noswitch_punishment = ScriptLib.GetGroupVariableValue(context,"is_noswitch_punishment")
LF_Set_Team_Global_Value(context,"NOSWITCH_PUNISHMENT",is_noswitch_punishment)
local fever = ScriptLib.GetGalleryProgressScore(context, "fever", defs.gallery_id)
LF_Set_Team_Global_Value(context,"fever",fever)
return 0
end
------------------------------------------------------------------
Initialize()
@@ -0,0 +1,284 @@
-- gallery+challenge。保持challenge和gallery生命周期同步
-- 挑战无达成目标,只是借用侧边栏
--钓鱼开启:如果当前没有在挑战,则开Gallery,开挑战
--挑战倒计时结束:关Gallery,停止钓鱼
--另外处理Gallery意外先结束,同步退出钓鱼-停挑战
-- local defs = {
-- --对应GalleryID
-- gallery_id = 11001,
-- --GroupID
-- group_id = 100000000,
-- --挑战方式 0-指定ID的鱼钓起计数 1-记录指定ID的鱼最大连续成功数
-- fishing_type = 0,
-- --这个Group对应的挑战ID
-- challenge_id = 0,
-- --本挑战中,算作计数目标的鱼IDs 鱼ID在FishData表
-- target_fish_id =
-- {1,2,3,4,5},
-- }
--2021.7.14迭代:部分挑战时长改为2分钟,其余为3分钟
local shortChallenges = {
111178,
111180
}
local extraTriggers = {
--检测挑战结束了的情况
{ name = "challenge_success", config_id = 8000001, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
{ name = "challenge_fail", config_id = 8000002, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
--Gallery结束时关挑战
{ name = "gallery_stop", config_id = 800003, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
--钓鱼开始开Gallery,开挑战
{ name = "fishing_start", config_id = 8000004, event = EventType.EVENT_FISHING_START, source = "", condition = "", action = "action_fishing_start", trigger_count = 0},
{ name = "fishing_timeout_flee", config_id = 8000005, event = EventType.EVENT_FISHING_TIMEOUT_FLEE, source = "", condition = "", action = "action_fishing_timeout_flee", trigger_count = 0},
{ name = "fishing_qte_finish", config_id = 8000006, event = EventType.EVENT_FISHING_QTE_FINISH, source = "", condition = "", action = "action_fishing_qte_finish", trigger_count = 0},
{ name = "fishing_score_change", config_id = 8000007, event = EventType.EVENT_VARIABLE_CHANGE, source = "challenge_score", condition = "", action = "", trigger_count = 0, tag = "1000"},
{ name = "leave_region", config_id = 8000008, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0}
}
function Initialize()
for i,v in ipairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
--挑战计数进度
table.insert(variables,{ config_id=50000001,name = "challenge_score", value = 0})
return 0
end
function action_fishing_start(context, evt)
ScriptLib.PrintContextLog(context, "[fishing] action_fishing_start.")
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 0 then
local timeLimit = 180 --默认挑战时长
--重置计分
ScriptLib.SetGroupTempValue(context, "tempScore", 0, {})
ScriptLib.SetGroupTempValue(context, "tempUnmissScore", 0, {})
--设置uid
ScriptLib.SetGroupTempValue(context,"fisher_uid", context.uid, {})
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 1, {})
--开启钓鱼活动Gallery
ScriptLib.PrintContextLog(context, "[fishing] Starting Gallery @"..defs.gallery_id)
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.SetGroupTempValue(context,"gallery_state", 1, {})
--开启挑战
ScriptLib.PrintContextLog(context, "[fishing] Starting Challenge ChallengeID@"..defs.challenge_id.." GroupID@"..defs.group_id)
if CheckIsInTable(context, defs.challenge_id, shortChallenges) then
timeLimit = 120
end
----ScriptLib.ActiveChallenge(context,创建的区域挑战的识别id,DungeonChallengeData里的id,限定的时间,Event_Type所在枚举的序号,Trigger的tag字段值,触发几次)
ScriptLib.ActiveChallenge(context,defs.challenge_id, defs.challenge_id, timeLimit, 3, 1000, 999)
ScriptLib.SetGroupTempValue(context,"challenge_state", 1, {})
end
return 0
end
--处理Gallery万一比挑战先结束
function action_gallery_stop(context, evt)
ScriptLib.SetGroupTempValue(context, "gallery_state", 0, {})
--正常应该Gallery结束控制Challenge结束
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
--停挑战
ScriptLib.StopChallenge(context, defs.challenge_id, 1)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.PrintContextLog(context, "[fishing] Gallery stopped while fishing. StopFishing UID@"..fisher_uid)
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--处理挑战结束
function action_challenge_fail(context, evt)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停止Gallery false失败 true成功。这里需要填false
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
ScriptLib.PrintContextLog(context, "[fishing] Gallery stopped by challenge end.")
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--兜底,处理挑战万一以成功结束
function action_challenge_success(context, evt)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停止Gallery false失败 true成功
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--如果触发了超时逃走,直接按一次QTE失败处理
function action_fishing_timeout_flee(context, evt)
--if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
if defs.fishing_type == 1 then
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
end
--end
return 0
end
--每次退出钓鱼QTE状态时触发
--evt.param1 鱼id
--evt.param2 0-失败 1-成功
--evt.param3 0-未进包(即背包满/到达活动要求的获取上限)1-进包
--evt.param4 本次QTE中,bonus最长持续时间
function action_fishing_qte_finish(context, evt)
local target_fish = evt.param1
local score = 0
local fishing_score = {}
ScriptLib.PrintContextLog(context, "[fishing] fishing_qte_finish. target_fish is @"..target_fish.." is_Free @".. evt.param3)
------计分模式0:钓鱼成功直接计数
if defs.fishing_type == 0 then
--若成功钓起
if evt.param2 == 1 then
--如果是目标鱼,加分
if CheckIsInTable(context,target_fish,defs.target_fish_id) then
--单局计数+1
ScriptLib.ChangeGroupTempValue(context, "tempScore", 1, {})
--["fishing_score"]:{钓鱼个数, 最大连续数, 最大Bonus时长} 单目标挑战传单元素就行
score = ScriptLib.GetGroupTempValue(context, "tempScore", {})
fishing_score = {score}
--触发挑战计数Trigger
ScriptLib.SetGroupVariableValue(context, "challenge_score", score)
--如果不是目标鱼,不加分,但还是要UpdateGallery,非目标鱼也要算上
else
score = ScriptLib.GetGroupTempValue(context, "tempScore", {})
fishing_score = {score}
end
--处理是否放生
local is_free = false
if evt.param3 ~= 1 then
is_free = true
end
--更新Gallery分数
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["fishing_score"] = fishing_score, ["fish_id"] = evt.param1, ["is_free"] = is_free})
end
return 0
end
------计分模式1:记录最大连续成功数
if defs.fishing_type == 1 then
--若成功钓起...
if evt.param2 == 1 then
--单局计数+1
ScriptLib.ChangeGroupTempValue(context, "tempScore", 1, {})
local tempUnmissScore = ScriptLib.GetGroupTempValue(context, "tempUnmissScore", {})
local tempScore = ScriptLib.GetGroupTempValue(context, "tempScore", {})
--检查是不是该刷新最大连续记录
if tempUnmissScore < tempScore then
--若是,则连续挑战计分更新
ScriptLib.SetGroupTempValue(context,"tempUnmissScore", tempScore, {})
--触发挑战计数Trigger
ScriptLib.SetGroupVariableValue(context, "challenge_score", score)
end
--更新Gallery分数
--["fishing_score"]:{钓鱼个数, 最大连续数, 最大Bonus时长} 单目标挑战传单元素就行
local score = ScriptLib.GetGroupTempValue(context, "tempUnmissScore", {})
fishing_score = {score}
local is_free = false
if evt.param3 ~= 1 then
is_free = true
end
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["fishing_score"] = fishing_score, ["fish_id"] = evt.param1, ["is_free"] =is_free})
--若失败逃逸..
else
ScriptLib.PrintContextLog(context, "[fishing] Type 1: tempScore reset")
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
end
return 0
end
return 0
end
function action_leave_region(context, evt)
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停挑战
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
ScriptLib.StopChallenge(context, defs.challenge_id, 1)
end
--停Gallery false失败 true成功
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.PrintContextLog(context, "[fishing] Leave challenge region. StopFishing UID@"..fisher_uid)
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--用于检查value是否在目标table中
function CheckIsInTable(context,value,table)
for k, v in pairs(table) do
if v == value then
return true
end
end
return false
end
Initialize()
@@ -0,0 +1,310 @@
-- gallery+challenge。保持challenge和gallery生命周期同步
-- 挑战无达成目标,只是借用侧边栏
--钓鱼开启:如果当前没有在挑战,则开Gallery,开挑战
--挑战倒计时结束:关Gallery,停止钓鱼
--另外处理Gallery意外先结束,同步退出钓鱼-停挑战
-- local defs = {
-- --GroupID
-- group_id = 100000000,
-- --对应的GalleryID
-- gallery_id = 11005,
---本挑战中,算作计数目标的鱼IDs 鱼ID在FishData表
-- target_fish_id = 19
-- }
local cfg = {
--父挑战ID
father_id = 111181,
--子挑战ID - 钓鱼总数
child_total = 111186,
--子挑战ID - 连续
child_unmiss= 111187,
--子挑战ID - 尽量呆在Bonus区域
child_bonus= 111188
}
local extraTriggers = {
--检测挑战结束
{ name = "challenge_success", config_id = 8000001, event = EventType.EVENT_CHALLENGE_SUCCESS, source = "", condition = "", action = "action_challenge_success", trigger_count = 0},
{ name = "challenge_fail", config_id = 8000002, event = EventType.EVENT_CHALLENGE_FAIL, source = "", condition = "", action = "action_challenge_fail", trigger_count = 0},
--Gallery结束时关挑战
{ name = "gallery_stop", config_id = 800003, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
--钓鱼开始开Gallery,开挑战
{ name = "fishing_start", config_id = 8000004, event = EventType.EVENT_FISHING_START, source = "", condition = "", action = "action_fishing_start", trigger_count = 0},
{ name = "fishing_qte_finish", config_id = 8000005, event = EventType.EVENT_FISHING_QTE_FINISH, source = "", condition = "", action = "action_fishing_qte_finish", trigger_count = 0},
{ name = "fishing_timeout_flee", config_id = 8000010, event = EventType.EVENT_FISHING_TIMEOUT_FLEE, source = "", condition = "", action = "action_fishing_timeout_flee", trigger_count = 0},
--挑战计数用Trigger
{ name = "score_change_total", config_id = 8000006, event = EventType.EVENT_VARIABLE_CHANGE, source = "score_total", condition = "", action = "", trigger_count = 0, tag = "1000"},
{ name = "score_change_unmiss", config_id = 8000007, event = EventType.EVENT_VARIABLE_CHANGE, source = "score_unmiss", condition = "", action = "", trigger_count = 0, tag = "1001"},
{ name = "score_change_bonus", config_id = 8000008, event = EventType.EVENT_VARIABLE_CHANGE, source = "bonus_time", condition = "", action = "", trigger_count = 0, tag = "1002"},
{ name = "leave_region", config_id = 8000009, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0}
}
function Initialize()
for i,v in ipairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
--挑战计数进度-总数
table.insert(variables,{ config_id=50000001,name = "score_total", value = 0})
--挑战计数进度-连续上钩
table.insert(variables,{ config_id=50000002,name = "score_unmiss", value = 0})
--挑战计数进度-最大Bonus时长
table.insert(variables,{ config_id=50000003,name = "bonus_time", value = 0})
--隐藏任务用标志 0-未满足任务条件 1-已满足条件,可触发任务
--这个标志不做no_refresh,因为任务那边希望每次都触发
table.insert(variables,{ config_id=50000004,name = "quest_mark", value = 0})
return 0
end
function action_fishing_start(context, evt)
ScriptLib.PrintContextLog(context, "[fishing] action_fishing_start")
--检查钓鱼状态标记
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 0 then
--重置计分
ScriptLib.SetGroupTempValue(context, "tempScore", 0, {})--连续成功计数器
ScriptLib.SetGroupTempValue(context, "tempUnmissScore", 0, {})--最大连续成功数
ScriptLib.SetGroupTempValue(context, "bonusTime", 0, {})--最大Bonus时长
ScriptLib.SetGroupTempValue(context, "totalCount", 0, {}) --钓起目标鱼总数
--设置uid
ScriptLib.SetGroupTempValue(context,"fisher_uid", context.uid, {})
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 1, {})
--开启钓鱼活动Gallery
ScriptLib.PrintContextLog(context, "[fishing] Starting Gallery @"..defs.gallery_id)
ScriptLib.StartGallery(context, defs.gallery_id)
ScriptLib.SetGroupTempValue(context,"gallery_state", 1, {})
--组合挑战
ScriptLib.PrintContextLog(context, "[fishing] Creating Challenge Father ID@"..cfg.father_id)
--创建父挑战
ScriptLib.CreateFatherChallenge(context, cfg.father_id, cfg.father_id, 180, {success=1, fail=1})
ScriptLib.StartFatherChallenge(context, cfg.father_id)
--添加子挑战-总数cfg.child_total
ScriptLib.AttachChildChallenge(context,cfg.father_id,cfg.child_total,cfg.child_total, {3,1000,99}, {context.uid},{success=1, fail=1})
--添加子挑战-连续cfg.child_unmiss
ScriptLib.AttachChildChallenge(context,cfg.father_id,cfg.child_unmiss,cfg.child_unmiss, {3,1001,99}, {context.uid},{success=1, fail=1})
--添加子挑战-bonus cfg.child_bonus
ScriptLib.AttachChildChallenge(context,cfg.father_id,cfg.child_bonus,cfg.child_bonus, {3,1002,99}, {context.uid},{success=1, fail=1})
ScriptLib.SetGroupTempValue(context,"challenge_state", 1, {})
end
return 0
end
--处理Gallery结束
function action_gallery_stop(context, evt)
ScriptLib.SetGroupTempValue(context, "gallery_state", 0, {})
--检查是否要触发隐藏任务
if ScriptLib.GetGroupVariableValue(context, "quest_mark") == 1 then
--ScriptLib.SetGroupVariableValue(context, "quest_mark", 2)
ScriptLib.AddQuestProgress(context, "7266801")
end
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
--停挑战
ScriptLib.EndFatherChallenge(context, cfg.father_id)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--处理挑战自己失败结束
function action_challenge_fail(context, evt)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停止Gallery false失败 true成功。这里需要填false
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
ScriptLib.PrintContextLog(context, "[fishing] Gallery stopped by challenge end.")
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--处理挑战万一成功结束
function action_challenge_success(context, evt)
ScriptLib.SetGroupTempValue(context, "challenge_state", 0, {})
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停止Gallery false失败 true成功
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
--如果触发了超时逃走,直接按一次QTE失败处理
function action_fishing_timeout_flee(context, evt)
--if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
ScriptLib.PrintContextLog(context, "[fishing] action_fishing_timeout_flee.")
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
--end
return 0
end
--每次退出钓鱼QTE状态时触发
--evt.param1 鱼id
--evt.param2 0-失败 1-成功
--evt.param3 0-未进包(即背包满/到达活动要求的获取上限)1-进包
--evt.param4 本次QTE中,bonus最长持续时间
function action_fishing_qte_finish(context, evt)
--QTE失败/钓到其他鱼 都算打断连续记录
--若成功钓起
if evt.param2 == 1 then
--拿到当前连续成功数
local tempScore = ScriptLib.GetGroupTempValue(context, "tempScore", {})
local tempUnmissScore = ScriptLib.GetGroupTempValue(context, "tempUnmissScore", {})
--看是不是目标鱼
if evt.param1 == defs.target_fish_id then
---------处理隐藏任务
if ScriptLib.GetGroupVariableValue(context, "quest_mark") == 0 then
ScriptLib.SetGroupVariableValue(context, "quest_mark", 1)
end
---------处理总数
--单局计数+1
ScriptLib.ChangeGroupTempValue(context, "totalCount", 1, {})
ScriptLib.ChangeGroupTempValue(context, "tempScore", 1, {})
tempScore = ScriptLib.GetGroupTempValue(context, "tempScore", {})
--触发总数挑战的计数Trigger
ScriptLib.SetGroupVariableValue(context, "score_total", tempScore)
--------处理连续成功
--检查是不是该刷新最大连续记录
if tempUnmissScore < tempScore then
--若是,则连续挑战计分更新
ScriptLib.SetGroupTempValue(context,"tempUnmissScore", tempScore, {})
--触发连续成功挑战计数Trigger
ScriptLib.SetGroupVariableValue(context, "score_unmiss", tempScore)
end
--------处理Bonus时间
--检查是不是该刷新最大bonus时间记录,evt里发过来是整数,还是取一下floor保险
ScriptLib.PrintContextLog(context, "This BonusTime@"..evt.param4)
local diff = 0
--不大于180秒,正常算差
if evt.param4 <= 180 then
diff = math.floor(evt.param4 - ScriptLib.GetGroupTempValue(context, "bonusTime", {}))
--大于180秒,按180秒算差
else
diff = math.floor(180 - ScriptLib.GetGroupTempValue(context, "bonusTime", {}))
end
--差值是几,就触发几次Trigger
if diff > 0 then
ScriptLib.SetGroupTempValue(context,"bonusTime", evt.param4, {})
UpdateBonusTimeForChallenge(context,diff)
end
--如果不是目标鱼,也要更新Gallery
else
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
end
--------更新Gallery分数
--["fishing_score"]:{钓鱼个数, 最大连续数, 最大Bonus时长} 单目标挑战传单元素就行
tempUnmissScore = ScriptLib.GetGroupTempValue(context, "tempUnmissScore", {})
local totalCount = ScriptLib.GetGroupTempValue(context, "totalCount", {})
local bonusTime = ScriptLib.GetGroupTempValue(context, "bonusTime", {})
local fishing_score = {totalCount, tempUnmissScore, bonusTime}
local is_free = false
if evt.param3 ~= 1 then
is_free = true
end
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["fishing_score"] = fishing_score, ["fish_id"] = evt.param1, ["is_free"] = is_free})
ScriptLib.PrintContextLog(context, "[fishing] Gallery Score updated. score_total@"..totalCount.." score_unmiss@"..tempUnmissScore.." MaxBounesTime@"..bonusTime)
--若失败逃逸
else
ScriptLib.PrintContextLog(context, "[fishing] Moonfin: tempScore reset")
--单轮计数重置
ScriptLib.SetGroupTempValue(context,"tempScore", 0, {})
end
return 0
end
function UpdateBonusTimeForChallenge(context, count)
for i = 1, count do
ScriptLib.ChangeGroupVariableValue(context, "bonus_time", 1)
end
return 0
end
function action_leave_region(context, evt)
if ScriptLib.GetGroupTempValue(context, "fishing_state", {}) == 1 then
--设置挑战状态标记
ScriptLib.SetGroupTempValue(context, "fishing_state", 0, {})
--停挑战
if ScriptLib.GetGroupTempValue(context, "challenge_state", {}) == 1 then
--停挑战
ScriptLib.EndFatherChallenge(context, cfg.father_id)
end
--停Gallery false失败 true成功
if ScriptLib.GetGroupTempValue(context, "gallery_state", {}) == 1 then
ScriptLib.StopGallery(context, defs.gallery_id, false)
end
--退出钓鱼
local fisher_uid = ScriptLib.GetGroupTempValue(context, "fisher_uid", {})
ScriptLib.PrintContextLog(context, "[fishing] Leave challenge region. StopFishing UID@"..fisher_uid)
ScriptLib.StopFishing(context,fisher_uid)
end
return 0
end
Initialize()
@@ -0,0 +1,312 @@
-- Trigger变量
--[[
local defs = {
PotConfigIDA =148004,
PotConfigIDB =148005,
PotConfigIDC =148006,
targetColdTime = 10,
targetHeatTime = 10,
BeHitByFireTemp = 10,
BeHitByIceWaterTemp = -10
}
--]]
---------------------
local tempTrigger = {
--监听GadgetState变化
--监听值变化
{ config_id = 2330001, name = "EVENT_VARIABLE_CHANGE_A", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenATemp",
condition = "", action = "action_VARIABLE_CHANGE_A", trigger_count = 0},
{ config_id = 2330002, name = "EVENT_VARIABLE_CHANGE_B", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenBTemp",
condition = "", action = "action_VARIABLE_CHANGE_B", trigger_count = 0},
{ config_id = 2330003, name = "EVENT_VARIABLE_CHANGE_C", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenCTemp",
condition = "", action = "action_VARIABLE_CHANGE_C", trigger_count = 0},
{ config_id = 2330004, name = "TIME_AXIS_PotOverColdA", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdA",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330005, name = "TIME_AXIS_PotOverColdB", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdB",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330006, name = "TIME_AXIS_PotOverColdC", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdC",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330007, name = "TIME_AXIS_PotOverHeatA", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatA",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330008, name = "TIME_AXIS_PotOverHeatB", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatB",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330009, name = "TIME_AXIS_PotOverHeatC", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatC",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330010, name = "EVENT_VARIABLE_CHANGE_StartPotTaunt", event = EventType.EVENT_TIME_AXIS_PASS, source = "StartPotTaunt",
condition = "", action = "action_StartPotTaunt", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
return 0
end
--------公用函数----------
function action_VARIABLE_CHANGE_A(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDA,evt.param1)
return 0
end
function action_VARIABLE_CHANGE_B(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDB,evt.param1)
return 0
end
function action_VARIABLE_CHANGE_C(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDC,evt.param1)
return 0
end
-- 过冷过热双检查
function action_PotOverState(context, evt)
local state = GetKeyWord(evt.source_name) -- 返回值为 “Cold" or "Heat"
local characterState = GetCharacterKeyWord(state)[1] -- 返回值为 冷 or 热
local overStateValue = GetCharacterKeyWord(state)[2] -- 返回值为 203 or 202
local targetConfigID = GetTargetConfigID(context,evt.source_name)
if (targetConfigID == 0) then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : source_name = ".. evt.source_name .. "非法")
return 0
end
local targetPotName = GetPotName(context,targetConfigID)
local tickTimeKey = "Over".. state .."Time"..targetPotName
local timeAxisKey = "PotOver" ..state.. targetPotName
local targetTime = defs.targetColdTime
local currentTime = ScriptLib.GetGroupTempValue(context, tickTimeKey, {}) + 1 --增加1秒计时
if 201 ~= ScriptLib.GetGadgetStateByConfigId(context, 0, targetConfigID) then
-- 如果锅子已经切进其它状态,关闭当前TimeAxis
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉"..targetPotName .. " 强制结束时间轴")
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
end
-- 已超时
if currentTime >= targetTime then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 过".. characterState .."超时,关闭锅炉" .. targetPotName)
-- 锅子切冷炸
ScriptLib.SetGadgetStateByConfigId(context, targetConfigID, overStateValue)
-- 时间轴结束/计时清空
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
else
local IsOverState = false
if state == "Cold" then
IsOverState = IsOverCold(context,targetConfigID)
end
if state == "Heat" then
IsOverState = IsOverHeat(context,targetConfigID)
end
if false == IsOverState then
-- 已炸锅
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉".. targetPotName .. " 结束过".. characterState) --描述切换
-- 时间轴结束/计时清空
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
else
-- 锅子异常中
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉".. targetPotName .. " 持续过".. characterState ..",已经过" .. currentTime .."") --描述切换
-- 计时累加
ScriptLib.SetGroupTempValue(context, tickTimeKey, currentTime, {})
return 0
end
end
end
-- 侦测LD调用
function action_StartPotTaunt(context, evt)
local actionName = evt.source_name
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 嘲讽开启判定 actionName = "..actionName .. " tempValue = " .. evt.param1 - evt.param2)
if 1 == evt.param1 - evt.param2 then
local functionParam1 = ScriptLib.GetGroupTempValue(context,actionName .. "Param1",{})
local functionParam2 = ScriptLib.GetGroupTempValue(context,actionName .. "Param2",{})
StartPotTaunt(context,functionParam1,functionParam2)
end
return 0
end
-- serverLuaCall 锅子挨火打
function BeHitByFire(context, evt)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨火打| source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local configId = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
local targetPotName = GetPotName(context,configId)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
ScriptLib.SetGroupVariableValue(context,tempKey,tempValue+defs.BeHitByFireTemp)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨火打| Change "..tempKey.." from" .. tempValue ..
" to ".. tempValue+defs.BeHitByFireTemp)
return 0
end
-- serverLuaCall 锅子挨冰水打
function BeHitByIceWater(context, evt)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨冰水打| source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local configId = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
local targetPotName = GetPotName(context,configId)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
ScriptLib.SetGroupVariableValue(context,tempKey,tempValue+defs.BeHitByIceWaterTemp)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨冰水打| Change "..tempKey.." from" .. tempValue ..
" to ".. tempValue+defs.BeHitByIceWaterTemp)
return 0
end
------------设置仙人锅开启嘲讽---------
function StartPotTaunt(context,configId,startTaunt)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : configId = "..configId .. " startTaunt = " .. startTaunt)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, configId, "SGV_Is_Taunting", startTaunt)
return 0
end
--------私有函数----------
function Pot_Pipeline(context,config_id,value)
-- 即时更新SGV_Thermometer_Value
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : configId = ".. config_id .. " SGV_Thermometer_Value= " .. value)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_Thermometer_Value", value)
-- 确认是否进入炸锅倒计时
Pot_OverColdPipeline(context,config_id)
Pot_OverHeatPipeline(context,config_id)
return 0
end
function Pot_OverColdPipeline(context,config_id)
local targetPotName = GetPotName(context,config_id)
local tempKey = "PotOverCold".. targetPotName
local tickTimeKey = "OverColdTime"..targetPotName
if IsOverCold(context,config_id) and 1 ~= ScriptLib.GetGroupTempValue(context, tempKey, {}) then
-- 过冷状态且没有开启独立时间轴时
local coldTimeAxis = {}
local timeValue = 1
local targetColdTime = math.ceil(defs.targetColdTime/timeValue)
-- 解析时间轴数组
for i = 1, targetColdTime, 1 do
coldTimeAxis[i] = timeValue
timeValue = timeValue + 1
end
-- tempKey依赖时间轴结束自己关闭
ScriptLib.SetGroupTempValue(context, tickTimeKey, 0, {})
ScriptLib.SetGroupTempValue(context, tempKey, 1, {})
-- 开启一个每秒Tick的时间轴
ScriptLib.InitTimeAxis(context, tempKey, coldTimeAxis, false)
ScriptLib.ShowReminder(context, 400066)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 开启OverCold观测 Send Time Axis")
end
return 0
end
function Pot_OverHeatPipeline(context,config_id)
local targetPotName = GetPotName(context,config_id)
local tempKey = "PotOverHeat".. targetPotName
local tickTimeKey = "OverHeatTime"..targetPotName
if IsOverHeat(context,config_id) and 1 ~= ScriptLib.GetGroupTempValue(context, tempKey, {}) then
-- 过冷状态且没有开启独立时间轴时
local heatTimeAxis = {}
local timeValue = 1
local targetColdTime = math.ceil(defs.targetHeatTime/timeValue)
-- 解析时间轴数组
for i = 1, targetColdTime, 1 do
heatTimeAxis[i] = timeValue
timeValue = timeValue + 1
end
-- tempKey依赖时间轴结束自己关闭
ScriptLib.SetGroupTempValue(context, tickTimeKey, 0, {})
ScriptLib.SetGroupTempValue(context, tempKey, 1, {})
-- 开启一个每秒Tick的时间轴
ScriptLib.InitTimeAxis(context, tempKey, heatTimeAxis, false)
ScriptLib.ShowReminder(context, 400066)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 开启OverHeat观测 Send Time Axis")
end
return 0
end
-- 返回当前ConfigID是否过冷
function IsOverCold(context,config_id)
if config_id == nil then
return true
end
local safeFrom = gadgets[config_id].server_global_value_config["SGV_Thermometer_SafeFrom"] * 100
local targetPotName = GetPotName(context,config_id)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
return tempValue<=safeFrom
end
-- 返回当前ConfigID是否过热
function IsOverHeat(context,config_id)
if config_id == nil then
return true
end
local safeTo = gadgets[config_id].server_global_value_config["SGV_Thermometer_SafeTo"] * 100
local targetPotName = GetPotName(context,config_id)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
return tempValue>=safeTo
end
--根据ConfigID,获取对应锅关键词
function GetPotName(context,config_id)
if config_id == defs.PotConfigIDA then
return "A"
end
if config_id == defs.PotConfigIDB then
return "B"
end
if config_id == defs.PotConfigIDC then
return "C"
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : Error! Config_id = ".. config_id)
return 0
end
--根据时间轴关键词,获取对应锅ConfigID
function GetTargetConfigID(context,keyName)
if keyName == "PotOverHeatA" or keyName == "PotOverColdA" then
return defs.PotConfigIDA
end
if keyName == "PotOverHeatB" or keyName == "PotOverColdB" then
return defs.PotConfigIDB
end
if keyName == "PotOverHeatC" or keyName == "PotOverColdC" then
return defs.PotConfigIDC
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : Error! KeyName = ".. keyName)
return 0
end
--根据时间轴关键词,获取冷还是热
function GetKeyWord(keyName)
if keyName == "PotOverColdA" or keyName == "PotOverColdB" or keyName == "PotOverColdC" then
return "Cold"
end
if keyName == "PotOverHeatA" or keyName == "PotOverHeatB" or keyName == "PotOverHeatC" then
return "Heat"
end
return 0
end
--根据冷还是热,返回相关汉字 以及 GadgetState
function GetCharacterKeyWord(keyName)
if keyName == "Cold" then
return {"",203}
end
if keyName == "Heat"then
return {"",202}
end
return { "",0 }
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---
--ScriptLib.SetGroupVariableValue(context,"ovenATemp",85)
--Pot_Pipeline(context,148004,85)
@@ -0,0 +1,622 @@
-- Trigger变量
--[[
local defs = {
ButtonLeftConfig = 51001,
ButtonRightConfig = 51002,
StoveConfig = 51003,
PotConfigIDA =51004,
PotConfigIDB =51005,
PotConfigIDC =51006,
targetColdTime = 14,
targetHeatTime = 14,
BeHitByFireTemp = 5,
BeHitByIceWaterTemp = -5,
SecondTempChange = { 7, -3}, -- 每秒对应上升或下降的温度变化
StartTemp = {50,35,56}, -- ABC三壶的初始温度
PlatFormRoute ={ -- 定义各个Route的功能,只需对应Log修改数据即可
[300100395] = {curPos = 2,reachPos = 2,tempDirs = {2,1,2},log = "从中间移动到中间,在中间徘徊"},
[300100396] = {curPos = 1,reachPos = 2,tempDirs = {2,1,2},log = "从左边移动到中间"},
[300100397] = {curPos = 2,reachPos = 3,tempDirs = {2,2,1},log = "从中间移动到右边"},
[300100398] = {curPos = 3,reachPos = 2,tempDirs = {2,1,2},log = "从右边移动到中间"},
[300100399] = {curPos = 2,reachPos = 1,tempDirs = {1,2,2},log = "从中间移动到左边"}
}
}
local challengeParam = {
90, -- Time
72, -- 72//EVENT_TIME_AXIS_PASS
666,-- TAG
1 -- 触发次数
}
--]]
---------------------
local tempTrigger = {
--监听GadgetState变化
--监听值变化
{ config_id = 2330001, name = "EVENT_VARIABLE_CHANGE_A", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenATemp",
condition = "", action = "action_VARIABLE_CHANGE_A", trigger_count = 0},
{ config_id = 2330002, name = "EVENT_VARIABLE_CHANGE_B", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenBTemp",
condition = "", action = "action_VARIABLE_CHANGE_B", trigger_count = 0},
{ config_id = 2330003, name = "EVENT_VARIABLE_CHANGE_C", event = EventType.EVENT_VARIABLE_CHANGE, source = "ovenCTemp",
condition = "", action = "action_VARIABLE_CHANGE_C", trigger_count = 0},
{ config_id = 2330004, name = "TIME_AXIS_PotOverColdA", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdA",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330005, name = "TIME_AXIS_PotOverColdB", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdB",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330006, name = "TIME_AXIS_PotOverColdC", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverColdC",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330007, name = "TIME_AXIS_PotOverHeatA", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatA",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330008, name = "TIME_AXIS_PotOverHeatB", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatB",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330009, name = "TIME_AXIS_PotOverHeatC", event = EventType.EVENT_TIME_AXIS_PASS, source = "PotOverHeatC",
condition = "", action = "action_PotOverState", trigger_count = 0},
{ config_id = 2330010, name = "EVENT_VARIABLE_CHANGE_StartPotTaunt", event = EventType.EVENT_TIME_AXIS_PASS, source = "StartPotTaunt",
condition = "", action = "action_StartPotTaunt", trigger_count = 0},
{ config_id = 2330011, name = "EVENT_VARIABLE_CHANGE_ChallengeStart", event = EventType.EVENT_VARIABLE_CHANGE, source = "startOrNot",
condition = "", action = "action_CHALLENGESTART", trigger_count = 0},
{ config_id = 2330012, name = "TIME_AXIS_TempControl", event = EventType.EVENT_TIME_AXIS_PASS, source = "TempControl",
condition = "", action = "action_TEMPCONTROL", trigger_count = 0},
{ config_id = 2330013, name = "PLATFORM_REACH_POINT_STOVE", event = EventType.EVENT_PLATFORM_REACH_POINT, source = "",
condition = "", action = "action_PLATFORM_REACH_POINT_STOVE", trigger_count = 0},
{ config_id = 2330014, name = "BUTTON_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "",
condition = "", action = "action_BUTTON_STATE_CHANGE", trigger_count = 0},
{ config_id = 2330015, name = "POT_STATE_CHANGE", event = EventType.EVENT_GADGET_STATE_CHANGE, source = "",
condition = "", action = "action_POT_STATE_CHANGE", trigger_count = 0},
{ config_id = 2330016, name = "TIME_AXIS_ChallengeTimer", event = EventType.EVENT_TIME_AXIS_PASS, source = "ChallengeTimer",
condition = "", action = "", trigger_count = 0,tag = tostring(challengeParam[3])},
{ config_id = 2330017, name = "EVENT_CHALLENGE_SUCCESS_LevelChange", event = EventType.EVENT_CHALLENGE_SUCCESS, source = "888",
condition = "", action = "action_CHALLENGE_SUCCESS_LevelChange", trigger_count = 0},
{ config_id = 2330018, name = "EVENT_CHALLENGE_FAIL_LevelChange", event = EventType.EVENT_CHALLENGE_FAIL, source = "888",
condition = "", action = "action_CHALLENGE_FAIL_LevelChange", trigger_count = 0},
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
gadgets[defs.PotConfigIDA].server_global_value_config["SGV_Thermometer_Value"] = defs.StartTemp[1]
gadgets[defs.PotConfigIDB].server_global_value_config["SGV_Thermometer_Value"] = defs.StartTemp[2]
gadgets[defs.PotConfigIDC].server_global_value_config["SGV_Thermometer_Value"] = defs.StartTemp[3]
return 0
end
--------公用函数----------
-- 当startOrNot被设置为1时,挑战开始启动
function action_CHALLENGESTART(context,evt)
if 1 ~= evt.param1 then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : startOrNot被设置为" .. evt.param1 ..",无视之。" )
return 0
end
--GadgetState初始化
ScriptLib.SetGadgetStateByConfigId(context,defs.StoveConfig, 201)
ScriptLib.SetGadgetStateByConfigId(context,defs.PotConfigIDA, 201)
ScriptLib.SetGadgetStateByConfigId(context,defs.PotConfigIDB, 201)
ScriptLib.SetGadgetStateByConfigId(context,defs.PotConfigIDC, 201)
-- 因为初始位置一定在中间
ScriptLib.SetGroupVariableValue(context, "ovenATempDirection", 2)
ScriptLib.SetGroupVariableValue(context, "ovenBTempDirection", 1)
ScriptLib.SetGroupVariableValue(context, "ovenCTempDirection", 2)
--开启挑战
local challengeTime = challengeParam[1]
ScriptLib.StartChallenge(context, 888, 245, challengeParam)
-- 每秒统计温度计时器
ScriptLib.InitTimeAxis(context, "TempControl", {1}, true)
-- 挑战胜利计时器
ScriptLib.InitTimeAxis(context, "ChallengeTimer", {challengeTime-0.5}, false)
-- 挑战后控制第一波移动
StoveMoveByButtonState(context)
return 0
end
-- 挑战开始后启动的时间轴,每秒结算温度变化
function action_TEMPCONTROL(context,evt)
-- 计算温度变化
CalculateOvenTemp(context,"ovenA")
CalculateOvenTemp(context,"ovenB")
CalculateOvenTemp(context,"ovenC")
return 0
end
-- 检测炉子抵达的地点,用来处理是否要将其运往下一站
function action_PLATFORM_REACH_POINT_STOVE(context, evt)
if 1 ~= evt.param3 then
return 0
end
if defs.StoveConfig ~= evt.param1 then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 检测到无关的移动,其ConfigID为" .. evt.param1 )
return 0
end
local routeID = evt.param2
local tempDirs = defs.PlatFormRoute[routeID].tempDirs
local reachPos = defs.PlatFormRoute[routeID].reachPos
local fireDirection = ScriptLib.GetGroupVariableValue(context, "fireDirection")
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 炉子移动到" .. reachPos .. "。fireDirection为".. fireDirection..",当前各炉子温度方向为" .. arrayToString(tempDirs))
ScriptLib.SetGroupVariableValue(context, "curPos", reachPos)
-- 尝试移动炉子
local moveState = StoveMove(context,reachPos,fireDirection)
-- 炉子无法移动 或者 玩家已经离开按钮时 需要重新计算温度变化
if -1 == moveState or 0 == fireDirection then
-- 到底指定地点温度变化
ScriptLib.SetGroupVariableValue(context, "ovenATempDirection", tempDirs[1])
ScriptLib.SetGroupVariableValue(context, "ovenBTempDirection", tempDirs[2])
ScriptLib.SetGroupVariableValue(context, "ovenCTempDirection", tempDirs[3])
end
return 0
end
-- 按钮的状态变化,检测后用来控制炉子位移
function action_BUTTON_STATE_CHANGE(context, evt)
if evt.param2 ~= defs.ButtonLeftConfig and evt.param2 ~= defs.ButtonRightConfig then
return 0
end
local startOrNot = ScriptLib.GetGroupVariableValue(context, "startOrNot")
if startOrNot == 0 then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 挑战没开的场合,无法移动炉子")
return 0
end
StoveMoveByButtonState(context)
return 0
end
-- 锅子状态侦测,一旦某个锅子爆炸了,立刻重置挑战并处理挑战存档
function action_POT_STATE_CHANGE(context,evt)
-- Gadget是锅子且爆了,开始处理逻辑
local potName = GetPotName(context,evt.param2)
if 0 ~= potName and (202 == evt.param1 or 203 == evt.param1) then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 锅子" .. potName .. "炸了,关卡开始设置状态")
-- 切挑战失败
ScriptLib.StopChallenge(context, 888, 0)
end
return 0
end
-- 计时器结束时,关闭锅子全部状态
function action_CHALLENGE_SUCCESS_LevelChange(context,evt)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 挑战胜利,设置关卡状态")
local potList = {defs.PotConfigIDA,defs.PotConfigIDB,defs.PotConfigIDC}
for i = 1,#potList do
local targetPot = potList[i]
-- 全部锅子进入状态 0
ScriptLib.SetGadgetStateByConfigId(context,targetPot, 901)
-- 关闭全锅子的嘲讽
StartPotTaunt(context,targetPot,0)
end
RecoverLevel(context)
return 0
end
function action_CHALLENGE_FAIL_LevelChange(context,evt)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 挑战失败,重置关卡状态")
local potList = {defs.PotConfigIDA,defs.PotConfigIDB,defs.PotConfigIDC}
-- 切其它锅子进入State0
for i = 1,#potList do
local targetPot = potList[i]
-- 只要锅子不是处于202或203
local targetPotState = ScriptLib.GetGadgetStateByConfigId(context, 0, targetPot)
if 202 ~= targetPotState and 203 ~= targetPotState then
ScriptLib.SetGadgetStateByConfigId(context,targetPot, 0)
end
-- 关闭关卡计时器
ScriptLib.EndTimeAxis(context, "ChallengeTimer")
-- 关闭全锅子的嘲讽
StartPotTaunt(context,targetPot,0)
end
RecoverLevel(context)
return 0
end
-- 关卡回复逻辑
function RecoverLevel(context)
-- 关闭炉子火焰
ScriptLib.SetGadgetStateByConfigId(context,defs.StoveConfig, 0)
-- 方向停止
ScriptLib.SetGroupVariableValue(context, "fireDirection", 0)
-- 设置温度变化为0
ScriptLib.SetGroupVariableValue(context, "ovenATempDirection", 0)
ScriptLib.SetGroupVariableValue(context, "ovenBTempDirection", 0)
ScriptLib.SetGroupVariableValue(context, "ovenCTempDirection", 0)
-- 停止温度运作
ScriptLib.SetGroupVariableValue(context, "startOrNot", 0)
-- 关闭计时器
ScriptLib.EndTimeAxis(context, "TempControl")
-- 温度初始化
ScriptLib.SetGroupVariableValue(context, "ovenATemp", defs.StartTemp[1])
ScriptLib.SetGroupVariableValue(context, "ovenBTemp", defs.StartTemp[2])
ScriptLib.SetGroupVariableValue(context, "ovenCTemp", defs.StartTemp[3])
-- 让炉子回到中间
local curPos = ScriptLib.GetGroupVariableValue(context, "curPos")
local fireDirection = 2 - curPos
ScriptLib.StopPlatform(context, defs.StoveConfig)
StoveMove(context,curPos,fireDirection)
ScriptLib.SetGroupVariableValue(context, "curPos", 2)
end
-- 侦测温度值变化
function action_VARIABLE_CHANGE_A(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDA,evt.param1)
return 0
end
-- 侦测温度值变化
function action_VARIABLE_CHANGE_B(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDB,evt.param1)
return 0
end
-- 侦测温度值变化
function action_VARIABLE_CHANGE_C(context, evt)
--将值同步给对应锅子,仅在201状态处理
Pot_Pipeline(context,defs.PotConfigIDC,evt.param1)
return 0
end
-- 过冷过热双检查
function action_PotOverState(context, evt)
local state = GetKeyWord(evt.source_name) -- 返回值为 “Cold" or "Heat"
local characterState = GetCharacterKeyWord(state)[1] -- 返回值为 冷 or 热
local overStateValue = GetCharacterKeyWord(state)[2] -- 返回值为 203 or 202
local targetConfigID = GetTargetConfigID(context,evt.source_name)
if (targetConfigID == 0) then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : source_name = ".. evt.source_name .. "非法")
return 0
end
local targetPotName = GetPotName(context,targetConfigID)
local tickTimeKey = "Over".. state .."Time"..targetPotName
local timeAxisKey = "PotOver" ..state.. targetPotName
local targetTime = defs.targetColdTime
local currentTime = ScriptLib.GetGroupTempValue(context, tickTimeKey, {}) + 1 --增加1秒计时
if 201 ~= ScriptLib.GetGadgetStateByConfigId(context, 0, targetConfigID) then
-- 如果锅子已经切进其它状态,关闭当前TimeAxis
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉"..targetPotName .. " 强制结束时间轴")
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
end
-- 已超时
if currentTime >= targetTime then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 过".. characterState .."超时,关闭锅炉" .. targetPotName)
-- 锅子切冷炸
ScriptLib.SetGadgetStateByConfigId(context, targetConfigID, overStateValue)
-- 时间轴结束/计时清空
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
else
local IsOverState = false
if state == "Cold" then
IsOverState = IsOverCold(context,targetConfigID)
end
if state == "Heat" then
IsOverState = IsOverHeat(context,targetConfigID)
end
if false == IsOverState then
-- 已炸锅
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉".. targetPotName .. " 结束过".. characterState) --描述切换
-- 时间轴结束/计时清空
ScriptLib.SetGroupTempValue(context, timeAxisKey, 0, {})
ScriptLib.EndTimeAxis(context, timeAxisKey)
return 0
else
-- 锅子异常中
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 锅炉".. targetPotName .. " 持续过".. characterState ..",已经过" .. currentTime .."") --描述切换
-- 计时累加
ScriptLib.SetGroupTempValue(context, tickTimeKey, currentTime, {})
return 0
end
end
return 0
end
-- 侦测LD调用
function action_StartPotTaunt(context, evt)
local actionName = evt.source_name
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 嘲讽开启判定 actionName = "..actionName .. " tempValue = " .. evt.param1 - evt.param2)
if 1 == evt.param1 - evt.param2 then
local functionParam1 = ScriptLib.GetGroupTempValue(context,actionName .. "Param1",{})
local functionParam2 = ScriptLib.GetGroupTempValue(context,actionName .. "Param2",{})
StartPotTaunt(context,functionParam1,functionParam2)
end
return 0
end
-- serverLuaCall 锅子挨火打
function BeHitByFire(context, evt)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨火打| source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local configId = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
local targetPotName = GetPotName(context,configId)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
ScriptLib.SetGroupVariableValue(context,tempKey,tempValue+defs.BeHitByFireTemp)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨火打| Change "..tempKey.." from" .. tempValue ..
" to ".. tempValue+defs.BeHitByFireTemp)
return 0
end
-- serverLuaCall 锅子挨冰水打
function BeHitByIceWater(context, evt)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨冰水打| source -> "..context.source_entity_id.." | target -> "..context.target_entity_id)
local configId = ScriptLib.GetGadgetConfigId(context, {gadget_eid = context.source_entity_id})
local targetPotName = GetPotName(context,configId)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
ScriptLib.SetGroupVariableValue(context,tempKey,tempValue+defs.BeHitByIceWaterTemp)
ScriptLib.PrintContextLog(context, "## Immortal 锅子挨冰水打| Change "..tempKey.." from" .. tempValue ..
" to ".. tempValue+defs.BeHitByIceWaterTemp)
return 0
end
------------设置仙人锅开启嘲讽---------
-- 控制锅子是否开启嘲讽
function StartPotTaunt(context,configId,startTaunt)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : configId = "..configId .. " startTaunt = " .. startTaunt)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, configId, "SGV_Is_Taunting", startTaunt)
return 0
end
--------私有函数----------
-- 温度管理管线
function Pot_Pipeline(context,config_id,value)
-- 即时更新SGV_Thermometer_Value
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : configId = ".. config_id .. " SGV_Thermometer_Value= " .. value)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_Thermometer_Value", value)
-- 确认是否进入炸锅倒计时
Pot_OverColdPipeline(context,config_id)
Pot_OverHeatPipeline(context,config_id)
return 0
end
-- 过冷检测管线
function Pot_OverColdPipeline(context,config_id)
local targetPotName = GetPotName(context,config_id)
local tempKey = "PotOverCold".. targetPotName
local tickTimeKey = "OverColdTime"..targetPotName
if IsOverCold(context,config_id) and 1 ~= ScriptLib.GetGroupTempValue(context, tempKey, {}) then
-- 过冷状态且没有开启独立时间轴时
local coldTimeAxis = {}
local timeValue = 1
local targetColdTime = math.ceil(defs.targetColdTime/timeValue)
-- 解析时间轴数组
for i = 1, targetColdTime, 1 do
coldTimeAxis[i] = timeValue
timeValue = timeValue + 1
end
-- tempKey依赖时间轴结束自己关闭
ScriptLib.SetGroupTempValue(context, tickTimeKey, 0, {})
ScriptLib.SetGroupTempValue(context, tempKey, 1, {})
-- 开启一个每秒Tick的时间轴
ScriptLib.InitTimeAxis(context, tempKey, coldTimeAxis, false)
ScriptLib.ShowReminder(context, 400066)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 开启OverCold观测 Send Time Axis")
end
return 0
end
-- 过热检测管线
function Pot_OverHeatPipeline(context,config_id)
local targetPotName = GetPotName(context,config_id)
local tempKey = "PotOverHeat".. targetPotName
local tickTimeKey = "OverHeatTime"..targetPotName
if IsOverHeat(context,config_id) and 1 ~= ScriptLib.GetGroupTempValue(context, tempKey, {}) then
-- 过冷状态且没有开启独立时间轴时
local heatTimeAxis = {}
local timeValue = 1
local targetColdTime = math.ceil(defs.targetHeatTime/timeValue)
-- 解析时间轴数组
for i = 1, targetColdTime, 1 do
heatTimeAxis[i] = timeValue
timeValue = timeValue + 1
end
-- tempKey依赖时间轴结束自己关闭
ScriptLib.SetGroupTempValue(context, tickTimeKey, 0, {})
ScriptLib.SetGroupTempValue(context, tempKey, 1, {})
-- 开启一个每秒Tick的时间轴
ScriptLib.InitTimeAxis(context, tempKey, heatTimeAxis, false)
ScriptLib.ShowReminder(context, 400066)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot 开启OverHeat观测 Send Time Axis")
end
return 0
end
-- 返回当前ConfigID是否过冷
function IsOverCold(context,config_id)
if config_id == nil then
return true
end
local safeFrom = gadgets[config_id].server_global_value_config["SGV_Thermometer_SafeFrom"] * 100
local targetPotName = GetPotName(context,config_id)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
return tempValue<=safeFrom
end
-- 返回当前ConfigID是否过热
function IsOverHeat(context,config_id)
if config_id == nil then
return true
end
local safeTo = gadgets[config_id].server_global_value_config["SGV_Thermometer_SafeTo"] * 100
local targetPotName = GetPotName(context,config_id)
local tempKey = "oven".. targetPotName .. "Temp"
local tempValue = ScriptLib.GetGroupVariableValue(context, tempKey)
return tempValue>=safeTo
end
-- 根据锅炉当前为加热或降温设置锅子温度
function CalculateOvenTemp(context,potName)
local tempDir = ScriptLib.GetGroupVariableValue(context, potName.."TempDirection")
local temp = ScriptLib.GetGroupVariableValue(context, potName.."Temp")
if tempDir > 2 or tempDir < 1 then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 锅子".. potName .."方向不合法,值为" .. tempDir)
end
temp = temp + defs.SecondTempChange[tempDir]
temp = math.max(math.min(temp,100),0)
ScriptLib.SetGroupVariableValue(context, potName.."Temp", temp)
return 0
end
--根据ConfigID或Pos信息,获取对应锅关键词
function GetPotName(context,keyName)
if keyName == defs.PotConfigIDA or keyName == 1 then
return "A"
end
if keyName == defs.PotConfigIDB or keyName == 2 then
return "B"
end
if keyName == defs.PotConfigIDC or keyName == 3 then
return "C"
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : GetPotName Error! KeyName = ".. keyName)
return 0
end
--根据时间轴关键词,获取对应锅ConfigID
function GetTargetConfigID(context,keyName)
if keyName == "PotOverHeatA" or keyName == "PotOverColdA" then
return defs.PotConfigIDA
end
if keyName == "PotOverHeatB" or keyName == "PotOverColdB" then
return defs.PotConfigIDB
end
if keyName == "PotOverHeatC" or keyName == "PotOverColdC" then
return defs.PotConfigIDC
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : GetTargetConfigID Error! KeyName = ".. keyName)
return 0
end
-- 根据当前踏板状态控制锅炉移动
function StoveMoveByButtonState(context)
local leftState = ScriptLib.GetGadgetStateByConfigId(context, 0, defs.ButtonLeftConfig)
local rightState = ScriptLib.GetGadgetStateByConfigId(context, 0, defs.ButtonRightConfig)
local curPos = ScriptLib.GetGroupVariableValue(context, "curPos")
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : LeftState" .. leftState .. "RightState" .. rightState)
local fireDirection = 0
if 201 == leftState and 0 == rightState then
fireDirection = -1
ScriptLib.SetGroupVariableValue(context, "fireDirection", fireDirection)
StoveMove(context,curPos,fireDirection)
return 0
end
if 0 == leftState and 201 == rightState then
fireDirection = 1
ScriptLib.SetGroupVariableValue(context, "fireDirection", fireDirection)
StoveMove(context,curPos,fireDirection)
return 0
end
if 201 == leftState and 201 == rightState then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 左右按钮已全部开启,暂时维持之前方向")
ScriptLib.SetGroupVariableValue(context, "fireDirection", 0)
return 0
end
if 0 == leftState and 0 == rightState then
ScriptLib.SetGroupVariableValue(context, "fireDirection", 0)
return 0
end
return 0
end
-- 管理炉子移动的方法
function StoveMove(context,curPos,fireDirection)
local targetPos = curPos + fireDirection
local routeID = GetRouteID(curPos,targetPos)
if 0 == routeID then
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : StoveMove 不成功,参数为 curPos =" .. curPos .. ",fireDirection =" .. fireDirection )
return -1
end
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 炉子开始移动," .. defs.PlatFormRoute[routeID].log)
ScriptLib.SetPlatformRouteId(context, defs.StoveConfig, routeID)
ScriptLib.StartPlatform(context, defs.StoveConfig)
local potName = GetPotName(context,curPos)
local targetPotTempDirection = "oven"..potName.."TempDirection"
ScriptLib.SetGroupVariableValue(context, targetPotTempDirection, 2)
ScriptLib.PrintContextLog(context, "## TD ImmortalPot : 因为炉子移开,设置锅子" .. potName .. '进入降温状态')
return 0
end
--根据时间轴关键词,获取冷还是热
function GetKeyWord(keyName)
if keyName == "PotOverColdA" or keyName == "PotOverColdB" or keyName == "PotOverColdC" then
return "Cold"
end
if keyName == "PotOverHeatA" or keyName == "PotOverHeatB" or keyName == "PotOverHeatC" then
return "Heat"
end
return 0
end
--根据冷还是热,返回相关汉字 以及 GadgetState
function GetCharacterKeyWord(keyName)
if keyName == "Cold" then
return {"",203}
end
if keyName == "Heat"then
return {"",202}
end
return { "",0 }
end
-- 计算对应的RouteID
function GetRouteID(curPos,targetPos)
for k,v in pairs(defs.PlatFormRoute) do
if curPos == v.curPos and targetPos == v.reachPos then
return k
end
end
return 0
end
-- 简单拆分一个数组
function arrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---
@@ -0,0 +1,76 @@
--[[local test_config = {
[2] = { sum = 10, max = 5, min = 3 },
}--]]
local tri = {
{ name = "GM_Debug", config_id = 8000001, event = EventType.EVENT_VARIABLE_CHANGE, source = "test", condition = "", action = "action_GM_Debug", trigger_count = 0 }
}
local var = {
{ config_id=50000001,name = "sum", value = 0, no_refresh = true },
{ config_id=50000002,name = "max", value = 0, no_refresh = true },
{ config_id=50000003,name = "min", value = 0, no_refresh = true },
{ config_id=50000004,name = "suite", value = 0, no_refresh = true },
{ config_id=50000005,name = "test", value = 0, no_refresh = true }
}
function Initialize()
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_GM_Debug(context, evt)
ScriptLib.PrintContextLog(context, "## tide_test: "..evt.source_name.." | "..evt.param2.." -> "..evt.param1)
if evt.param1 == evt.param2 then
return -1
end
if evt.source_name == "test" then
if evt.param1== 1 then
local _sum = ScriptLib.GetGroupVariableValue(context, "sum")
local _max = ScriptLib.GetGroupVariableValue(context, "max")
local _min = ScriptLib.GetGroupVariableValue(context, "min")
local _suite = ScriptLib.GetGroupVariableValue(context, "suite")
handle_tide(context, _sum, _max, _min, _suite)
elseif evt.param1 == 2 then
local _suite = ScriptLib.GetGroupVariableValue(context, "suite")
if test_config[_suite] ~= nil then
local _sum = test_config[_suite].sum
local _max = test_config[_suite].max
local _min = test_config[_suite].min
handle_tide(context, _sum, _max, _min, _suite)
else
ScriptLib.PrintContextLog(context, "## tide_error : invalid default suite config")
return -1
end
elseif evt.param1 == 0 then
local gid = ScriptLib.GetContextGroupId(context)
ScriptLib.KillMonsterTide(context, gid, 1001)
end
end
return 0
end
function handle_tide(context, _sum, _max, _min, _suite)
if _max > _sum or _max < _min then
ScriptLib.PrintContextLog(context, "## tide_error : invalid _max")
return -1
end
if _min <= 0 then
ScriptLib.PrintContextLog(context, "## tide_error : invalid _min")
return -1
end
if _max >= #suites[_suite].monsters then
ScriptLib.PrintContextLog(context, "## tide_error : invalid _suite")
return -1
end
local gid = ScriptLib.GetContextGroupId(context)
ScriptLib.AutoMonsterTide(context, 1001, gid, suites[_suite].monsters, _sum, _min, _max)
return 0
end
Initialize()
@@ -0,0 +1,225 @@
--[[
local defs = {
-- 进入指定Region获得对应AbilityGroup
-- AG:AbilityGroup
GroupID = 133003041,
AGRegionConfigID = 41012,
AGName = "ActivityAbility_ToMoon_FoodChallenge_Part1", --AbilityGroupName
AGKey = "_Activity_ToMoon_Part1_Level", --AbilityGroupValueKey
-- 进入指定Region时开启对应挑战
ChallengeRegionConfigID = 41012,
ChallengeID = 111168,
TriggerTag = 41013,
TargetTriggerTime = 1,
-- 供奉时对应响应,通知Team修改GlobalValue ScriptLib.SetTeamEntityGlobalFloatValue(context, {uid}, key, value)
AreaID = 1, -- 1璃月 2蒙德 3雪山
-- 挑战成功时,创生宝箱(考虑灵活性,挑战成功时逻辑交给LD处理)
-- 当LD觉得应当结束Bundle时,将OverKey修改为1
OverKey = "OverKey",
WatchKey = "save",
RewardSuit = 7,
}
local Phase ={
[1] = {3,4},
[2] = {3,4,5},
[3] = {7},
}
--]]
---------------------
local tempTrigger = {
{ config_id = 2230001, name = "ENTER_REGION_Challenge", event = EventType.EVENT_ENTER_REGION, source = "1",
condition = "", action = "action_ENTER_REGION_Challenge", trigger_count = 0},
{ config_id = 2230002, name = "LEAVE_REGION_Challenge", event = EventType.EVENT_LEAVE_REGION, source = "1",
condition = "", action = "action_LEAVE_REGION_Challenge", trigger_count = 0},
{ config_id = 2230003, name = "LUNA_RITE_SACRIFICE", event = EventType.EVENT_LUNA_RITE_SACRIFICE, source = "",
condition = "", action = "action_LUNA_RITE_SACRIFICE", trigger_count = 0},
{ config_id = 2230004, name = "VARIABLE_CHANGE_End", event = EventType.EVENT_VARIABLE_CHANGE, source = defs.WatchKey,
condition = "", action = "", trigger_count = 0, tag = tostring(defs.TriggerTag) },
{ config_id = 2330005, name = "VARIABLE_CHANGE_BundleEnd", event = EventType.EVENT_VARIABLE_CHANGE, source = defs.OverKey,
condition = "", action = "action_VARIABLE_CHANGE_BundleEnd", trigger_count = 0},
{ config_id = 2330006, name = "ChallengeEndCheckWin", event = EventType.EVENT_CHALLENGE_SUCCESS, source = tostring(10*defs.ChallengeID), condition = "", action = "action_ChallengeWin" },
{ config_id = 2330007, name = "ChallengeEndCheckLose", event = EventType.EVENT_CHALLENGE_FAIL, source = tostring(10*defs.ChallengeID), condition = "", action = "action_ChallengeLose" },
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
-- 给指定region挂AbilityGroup
regions[defs.AGRegionConfigID].team_ability_group_list = {defs.AGName}
return 0
end
--------公用函数----------
-- 进入Region后触发对应挑战
function action_ENTER_REGION_Challenge(context, evt)
if evt.param1 ~= defs.ChallengeRegionConfigID or ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 非对应挑战Region触发 ")
return 0
end
-- 新手教程相关
StartNewbie(context)
-- 防止连续启挑战
if -1 == CheckChallenge(context) then return 0 end
-- 检查WatcherKey是否合法
local startVariable = ScriptLib.GetGroupVariableValue(context,defs.WatchKey)
if 0 ~= CheckWatcherKey(context,startVariable) then
return 0
end
-- ☆开启挑战
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 准备开启挑战, 挑战内容是 = "..defs.ChallengeRegionConfigID
.." tag是 "..defs.TriggerTag.." 目标触发次数是 "..defs.TargetTriggerTime.." 继承次数为 "..startVariable)
ScriptLib.StartChallenge(context, 10*defs.ChallengeID, defs.ChallengeID, {3, defs.TriggerTag, defs.TargetTriggerTime, 1, startVariable})
ScriptLib.SetGroupTempValue(context, "haveStartChallenge", 1, {})
RefreshAllSacrificeNum(context)
-- 根据阶段刷新,为Phase设置保底
RefreshPhaseSuit(context)
return 0
end
-- 挑战结束将值还原
function action_ChallengeWin(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战成功,关闭Region ")
ScriptLib.SetGroupTempValue(context, "haveStartChallenge", 2, {})
ScriptLib.RemoveEntityByConfigId(context, defs.GroupID, EntityType.REGION, defs.ChallengeRegionConfigID)
return 0
end
function action_ChallengeLose(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战失败,关闭并刷新Region ")
ScriptLib.RemoveEntityByConfigId(context, defs.GroupID, EntityType.REGION, defs.ChallengeRegionConfigID)
ScriptLib.RefreshGroup(context, { group_id = defs.GroupID, suite = 1 })
ScriptLib.SetGroupTempValue(context, "haveStartChallenge", 0, {})
return 0
end
-- 离开指定区域且区域内人员为零时挑战失败
function action_LEAVE_REGION_Challenge(context, evt)
if evt.param1 == defs.ChallengeRegionConfigID and ScriptLib.GetRegionEntityCount(context, { region_eid = evt.source_eid, entity_type = EntityType.AVATAR }) < 1 then
ScriptLib.StopChallenge(context, 10*defs.ChallengeID, 0)
end
return 0
end
-- 逐月节食物供奉改变时
function action_LUNA_RITE_SACRIFICE(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 玩家触发了供奉 ")
RefreshAllSacrificeNum(context)
return 0
end
-- 结束Bundle
function action_VARIABLE_CHANGE_BundleEnd(context, evt)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : LD触发了指定数值操作 ")
ScriptLib.RemoveEntityByConfigId(context, defs.GroupID, EntityType.REGION, defs.ChallengeRegionConfigID)
ScriptLib.FinishGroupLinkBundle(context, defs.GroupID)
return 0
end
--------私有函数----------
-- 刷新供奉数量,用于为AbilityGroup提供支持
function RefreshAllSacrificeNum(context)
local uid_list = ScriptLib.GetSceneUidList(context)
local sacrificeNum = ScriptLib.GetLunaRiteSacrificeNum(context, defs.AreaID);
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp 触发供奉 : UID_List为:".. arrayToString(uid_list).." //AreaID为 " .. defs.AreaID .." //当前供奉数为 " .. sacrificeNum)
ScriptLib.SetTeamEntityGlobalFloatValue(context,uid_list, defs.AGKey, sacrificeNum)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp 触发供奉: UID_List为:"..arrayToString(uid_list).." //其AbilityGroup的Key刷新了 ")
return 0
end
-- 刷新供奉数量,用于为AbilityGroup提供支持
function RefreshSacrificeNum(context)
local tempUid = context.uid
local sacrificeNum = ScriptLib.GetLunaRiteSacrificeNum(context, defs.AreaID);
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp ABGroup挂起: 对应UID为:".. tempUid.." //AreaID为 " .. defs.AreaID .." //当前供奉数为 " .. sacrificeNum)
ScriptLib.SetTeamEntityGlobalFloatValue(context,{ tempUid }, defs.AGKey, sacrificeNum)
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp ABGroup挂起: 对应UID为:"..tempUid.." //其AbilityGroup的Key刷新了 ")
return 0
end
function StartNewbie(context)
local UidList = ScriptLib.GetSceneUidList(context)
local ownerUid = UidList[1]
local havePlayed = ScriptLib.GetExhibitionAccumulableData(context,ownerUid,10501001)
if 0 == havePlayed then
ScriptLib.ShowClientTutorial(context,910,{ownerUid})
ScriptLib.AddExhibitionAccumulableData(context,ownerUid,"MoonlitCamp_HavePlayed",1)
end
return 0
end
function CheckChallenge(context)
local haveStartChallenge = ScriptLib.GetGroupTempValue(context, "haveStartChallenge",{})
if 1 == haveStartChallenge then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战已触发,不再重复触发 ")
return -1
end
if 2 == haveStartChallenge then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战已结束,不再触发 ")
return -1
end
return 0
end
function CheckWatcherKey(context,startVariable)
if startVariable < defs.TargetTriggerTime then
return 0
end
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : 挑战应已完成,请检查进入原因 ")
return -1
end
function RefreshPhaseSuit(context)
local stage = ScriptLib.GetGroupVariableValue(context, "stage")
if nil == Phase then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : Group: " .. defs.GroupID .. "没有对应Phase")
return 0
end
if stage > #Phase then
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : stage超过Phase界限,stage = " .. stage)
return 0
end
local needRefreshSuit = Phase[stage]
ScriptLib.PrintContextLog(context, "## TD_MoonlitCamp : PhaseStage= " .. stage .. "需要刷新的suit为:" .. arrayToString(needRefreshSuit))
for k,v in ipairs(needRefreshSuit) do
ScriptLib.AddExtraGroupSuite(context, defs.GroupID, v)
end
return 0
end
---自骏ToolBox:数组转字符串函数---
function arrayToString(array)
local s = "{"
for k,v in pairs(array) do
if k < #array then
s = s .. v ..","
else
s = s .. v
end
end
s = s .."}"
return s
end
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---
@@ -0,0 +1,141 @@
--[[
local connection = {
[194001] = {194004,1,194003,0},
[194002] = {194001,1,194004,0},
[194003] = {194004,1}
...
...
}
--]]
--key为操作的config_idv[1] v[2]为关联的config_id和是否同向转动(1同向,0反向);v[3]v[4]同理,最多关联两个物件
-----------------------------------------
local PirateHelmGadgetID = {
70360180,
70360181,
70360182,
70360183,
}
local OPTION_LEFT = 210
local OPTION_RIGHT = 211
local temp_Variables = {
{ config_id=50000001,name = "IsFinished", value = 0, no_refresh = true }, --用于标识是否已完成,初始0,完成时LD需要设置成1,使得机关不可转动
}
local tempTrigger = {
{ config_id = 9000001, name = "EVENT_GADGET_CREATE", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_SetOption", trigger_count = 0},--创建
{ config_id = 9000002, name = "EVENT_SELECT_OPTION", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_SelectOption", trigger_count = 0},
{ config_id = 9000003, name = "EVENT_GROUP_LOAD", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_GroupLoadShowVersion", trigger_count = 0},
{ config_id = 9000004, name = "EVENT_TIME_AXIS_PASS", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_RemoveCoolDown", trigger_count = 0},
{ config_id = 9000005, name = "EVENT_VARIABLE_CHANGE", event = EventType.EVENT_VARIABLE_CHANGE, source = "IsFinished", condition = "", action = "action_IsFinished", trigger_count = 0},
}
function action_IsFinished(context,evt)
if evt.param1 == 1 then
local group_id = ScriptLib.GetContextGroupId(context)
for k,v in pairs(gadgets) do
if isPirateHelm(v.gadget_id) then
ScriptLib.DelWorktopOptionByGroupId(context, group_id, v.config_id, OPTION_LEFT)
ScriptLib.DelWorktopOptionByGroupId(context, group_id, v.config_id, OPTION_RIGHT)
end
end
end
return 0
end
function action_GroupLoadShowVersion(context,evt)
ScriptLib.PrintContextLog(context,"version:2021_7_1_105017")
return 0
end
function action_RemoveCoolDown(context,evt)
if evt.source_name == "CD" then ScriptLib.SetGroupTempValue(context,"disableInteract",0,{}) end
return 0
end
function action_SelectOption(context,evt)
if ScriptLib.GetGroupTempValue(context, "disableInteract",{}) == 0 then
if evt.param2 == OPTION_LEFT then
turnLeft(context,evt.param1)
if connection ~= nil then
for k,v in pairs(connection) do--key为操作的config_idv[1] v[2]为关联的config_id和是否同向转动(1同向,0反向);v[3]v[4]同理,最多关联两个物件
if evt.param1 == k then
if v[2] ~=nil then
if v[2] == 1 then turnLeft(context,v[1]) end
if v[2] == 0 then turnRight(context,v[1]) end
end
if v[4] ~=nil then
if v[4] == 1 then turnLeft(context,v[3]) end
if v[4] == 0 then turnRight(context,v[3]) end
end
end
end
end
ScriptLib.SetGroupTempValue(context,"disableInteract",1,{})
ScriptLib.InitTimeAxis(context, "CD", {1}, false)
end
if evt.param2 == OPTION_RIGHT then
turnRight(context,evt.param1)
if connection ~= nil then
for k,v in pairs(connection) do--key为操作的config_idv[1] v[2]为关联的config_id和是否同向转动(1同向,0反向);v[3]v[4]同理,最多关联两个物件
if evt.param1 == k then
if v[2] ~=nil then
if v[2] == 1 then turnRight(context,v[1]) end
if v[2] == 0 then turnLeft(context,v[1]) end
end
if v[4] ~=nil then
if v[4] == 1 then turnRight(context,v[3]) end
if v[4] == 0 then turnLeft(context,v[3]) end
end
end
end
end
ScriptLib.SetGroupTempValue(context,"disableInteract",1,{})
ScriptLib.InitTimeAxis(context, "CD", {1}, false)
end
end
return 0
end
function action_SetOption(context,evt)
if isPirateHelm(evt.param2) then
ScriptLib.SetWorktopOptions(context, {OPTION_LEFT,OPTION_RIGHT})
end
return 0
end
function isPirateHelm(gadgetID)
local result = false
for k,v in pairs(PirateHelmGadgetID) do
if gadgetID == v then result = true end
end
return result
end
function turnLeft(context,config_id)
local groupID = ScriptLib.GetContextGroupId(context)
local nowState = ScriptLib.GetGadgetStateByConfigId(context, groupID, config_id)
if nowState ==0 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 201) end
if nowState ==201 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 202) end
if nowState ==202 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 203) end
if nowState ==203 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 0) end
return 0
end
function turnRight(context,config_id)
local groupID = ScriptLib.GetContextGroupId(context)
local nowState = ScriptLib.GetGadgetStateByConfigId(context, groupID, config_id)
if nowState ==0 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 203) end
if nowState ==201 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 0) end
if nowState ==202 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 201) end
if nowState ==203 then ScriptLib.SetGroupGadgetStateByConfigId(context, groupID, config_id, 202) end
return 0
end
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
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
LF_Initialize_Level()
@@ -0,0 +1,111 @@
--- 只要在海盗门的Group中放置Require即可
---------------------
local tempTrigger = {
{ config_id = 2460001, name = "PirateShojiOption", event = EventType.EVENT_GADGET_CREATE,
source = "",condition = "", action = "action_PirateShojiOption", trigger_count = 0},
{ config_id = 2460002, name = "PirateShojiSelectOption", event = EventType.EVENT_SELECT_OPTION,
source = "",condition = "", action = "action_PirateShojiSelectOption", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
local firstConfigID = 2450001
for k,v in ipairs(door) do
local gadgetConfig = gadgets[v]
gadgets[firstConfigID + 1000] = { config_id = firstConfigID + 1000, gadget_id = 70360001,pos = gadgetConfig.pos,
rot = gadgetConfig.rot, level = 1, area_id = gadgetConfig.area_id, chainConfigID = v }
gadgets[v].operatorConfigID = firstConfigID + 1000
local singleTrigger = { config_id = firstConfigID, name = "PirateShojiStateChange" .. v, event = EventType.EVENT_GADGET_STATE_CHANGE,
source = tostring(v),condition = "", action = "action_PirateShojiStateChange", trigger_count = 0}
table.insert(triggers, singleTrigger)
table.insert(suites[init_config.suite].gadgets, firstConfigID + 1000)
table.insert(suites[init_config.suite].triggers, singleTrigger.name)
firstConfigID = firstConfigID + 1
end
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
return 0
end
--------公用函数----------
------------响应地板玩法开始--------
-- 任意Gadget创建进入,为海盗门的上操作台
function action_PirateShojiOption(context,evt)
ScriptLib.PrintContextLog(context, "##TD Gadget".. evt.param2 .."ConfigID为".. evt.param1 .. "创生了")
if 70360001 == evt.param2 then
local operatorConfigID = evt.param1
local doorConfigID = gadgets[operatorConfigID].chainConfigID
local gadgetState = ScriptLib.GetGadgetStateByConfigId(context, 0, doorConfigID)
if 0 == gadgetState or 202 == gadgetState then
local groupID = ScriptLib.GetContextGroupId(context)
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .."的gadgetState为"..gadgetState.. ",直接挂起操作台")
ScriptLib.SetWorktopOptionsByGroupId(context, groupID, operatorConfigID, {1})
return 0
end
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "的gadgetState为"..gadgetState.."无需响应")
end
return 0
end
-- 对应entity被改变时,重上操作台
function action_PirateShojiStateChange(context,evt)
local doorConfigID = evt.param2
local operatorConfigID = gadgets[doorConfigID].operatorConfigID
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "被检查切换到State" .. evt.param1 )
if 0 == evt.param1 or 202 == evt.param1 then
local groupID = ScriptLib.GetContextGroupId(context)
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "state合法,被挂起操作台")
ScriptLib.DelWorktopOptionByGroupId(context, groupID, operatorConfigID, 1)
ScriptLib.SetWorktopOptionsByGroupId(context, groupID, operatorConfigID, {1})
return 0
end
if 201 == evt.param1 then
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "门已开启,不响应")
return 0
end
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "state不匹配,不响应")
return 0
end
-- 任意操作台被交互时进入,与操作台交互时控制操作台
function action_PirateShojiSelectOption(context, evt)
local operatorConfigID = evt.param1
local doorConfigID = gadgets[operatorConfigID].chainConfigID
local uid = evt.uid
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. " 操作台被玩家".. uid.. "尝试使用开关为" .. evt.param2)
if 1 == evt.param2 and 70360169 == gadgets[doorConfigID].gadget_id then
local groupID = ScriptLib.GetContextGroupId(context)
local gadgetID = ScriptLib.GetGadgetStateByConfigId(context, 0, doorConfigID)
if 0 == gadgetID then
local isLock = ScriptLib.GetTeamAbilityFloatValue(context, uid, "_SCENEOBJ_PirateShoji_IsOpen")
if isLock < 1 then
-- 提示不能开门
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. " 无法被玩家".. uid.. "开启")
ScriptLib.ShowReminder(context, 321715301)
else
-- 打开门
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID .. "被玩家".. uid.. "开启")
ScriptLib.SetGadgetStateByConfigId(context, doorConfigID, 201)
ScriptLib.DelWorktopOptionByGroupId(context, groupID, operatorConfigID, 1)
end
end
if 202 == gadgetID then
ScriptLib.PrintContextLog(context, "##TD 海盗门".. doorConfigID.. " 已解锁,无视方向直接开启")
ScriptLib.SetGadgetStateByConfigId(context, doorConfigID, 201)
ScriptLib.DelWorktopOptionByGroupId(context, groupID, operatorConfigID, 1)
end
end
return 0
end
--------私有函数----------
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---
@@ -0,0 +1,74 @@
--[[
local statueConfig =
{
["Statue_Rotated1"] = {config_id = 121001,valueName = "Statue_Rotate1"},
["Statue_Rotated2"] = {config_id = 121001,valueName = "Statue_Rotate2"},
["Statue_Rotated3"] = {config_id = 121001,valueName = "Statue_Rotate3"}
}
--]]
local tempTrigger = {
{ config_id = 233001, name = "VARIABLE_CHANGE_233001", event = EventType.EVENT_VARIABLE_CHANGE,
source = "Statue_Rotated1", condition = "", action = "action_VARIABLE_CHANGE_Special", trigger_count = 0},
{ config_id = 233002, name = "VARIABLE_CHANGE_233002", event = EventType.EVENT_VARIABLE_CHANGE,
source = "Statue_Rotated2", condition = "", action = "action_VARIABLE_CHANGE_Special", trigger_count = 0},
{ config_id = 233003, name = "VARIABLE_CHANGE_233003", event = EventType.EVENT_VARIABLE_CHANGE,
source = "Statue_Rotated3", condition = "", action = "action_VARIABLE_CHANGE_Special", trigger_count = 0}
}
--------初始化----------
function LF_Initialize_Level()
for k,v in pairs(tempTrigger) do
table.insert(triggers, v)
for i = 1,#suite_disk do
table.insert(suite_disk[i].triggers, v.name)
end
end
local tempStatueConfig = statueConfig["Statue_Rotated1"]
gadgets[tempStatueConfig.config_id].server_global_value_config = {["SGV_SeaGodStatue_RotationState"] = 0}
tempStatueConfig = statueConfig["Statue_Rotated2"]
gadgets[tempStatueConfig.config_id].server_global_value_config = {["SGV_SeaGodStatue_RotationState"] = 0}
tempStatueConfig = statueConfig["Statue_Rotated3"]
gadgets[tempStatueConfig.config_id].server_global_value_config = {["SGV_SeaGodStatue_RotationState"] = 0}
return 0
end
--------事件函数----------
function action_VARIABLE_CHANGE_Special(context, evt)
-- 如果值为1则处理
if(1 == evt.param1) then
ScriptLib.PrintContextLog(context, "## TD SeaGodStatue : 尝试转动雕像")
TrySetSeaGodStatueRotation(context,evt.source_name)
return 0
end
return 0
end
--------公用函数----------
------------设置海神雕像转动---------
function SetSeaGodStatueRotation(context,configId,rot)
ScriptLib.PrintContextLog(context, "## TD SeaGodStatue : configId = "..configId .. " rot= " .. rot)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, configId, "SGV_SeaGodStatue_RotationState", rot)
return 0
end
------------尝试转动海神雕像---------
function TrySetSeaGodStatueRotation(context,eventName)
local configId = statueConfig[eventName].config_id
local valueName = statueConfig[eventName].valueName
-- 获取物件状态
local gadgetState = ScriptLib.GetGadgetStateByConfigId(context, 0, configId)
if( 201 == gadgetState) then
local currentRot = ScriptLib.GetGroupVariableValue(context, valueName) + 90
if (360 <=currentRot) then currentRot = 0 end
ScriptLib.SetGroupVariableValue(context, valueName, currentRot)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, configId, "SGV_SeaGodStatue_RotationState", currentRot)
ScriptLib.PrintContextLog(context, "## TD SeaGodStatue : 尝试转动成功 configId = "..configId .. " gadgetState= " .. gadgetState .. "rot" .. currentRot)
else
ScriptLib.PrintContextLog(context, "## TD SeaGodStatue : 尝试转动未成功 configId = "..configId .. " gadgetState= " .. gadgetState)
end
-- 事件处理后归零
ScriptLib.SetGroupVariableValue(context, eventName, 0)
return 0
end
--------检测函数----------
LF_Initialize_Level()
--- ServerUploadTool Save to [/root/env/data/lua/common/V2_1] ---

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