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

Update lua 3.2 Common

This commit is contained in:
Akbar Yahya 2022-11-01 12:52:11 +08:00
parent ee839c0ce4
commit 4c2cabd85d
No known key found for this signature in database
GPG Key ID: 0C9985FEC5C018C9
30 changed files with 8191 additions and 10 deletions

View File

@ -19,7 +19,7 @@ local gid = defs.group_id or 0
local interval = defs.timer or 15
--雪山营地B
function Initialize_Group()
table.insert(variables, {name = "wave", value = 0})
table.insert(variables, {config_id=54000001,name = "wave", value = 0})
for k,v in pairs(triggers_lib) do
table.insert(triggers, v)
end

View File

@ -9,7 +9,7 @@ function LF_Initialize_Group(triggers, suites)
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 })
table.insert(variables, { config_id=51100001,name = "Created", value = 0,no_refresh = true })
end

View File

@ -1,6 +1,6 @@
function LF_Initialize_Group(triggers, suites)
table.insert(variables, { config_id=50000001,name = "DropRockAbyssBulletTrigger", value = 0,no_refresh = false})
table.insert(variables, { config_id=51200001,name = "DropRockAbyssBulletTrigger", value = 0,no_refresh = false})
end

View File

@ -563,11 +563,11 @@ local Rogue_Cell = {
local temp_Variables_Rogue_Cell = {
{ config_id=50000001,name = "gm_EVENT_ROGUE_OPEN_ACCESS", value = 0, no_refresh = false },
{ config_id=50000002,name = "gm_EVENT_ROGUE_CREAGE_REPAIR_GADGET", value = 0, no_refresh = false },
{ config_id=50000003,name = "gm_EVENT_ROGUE_CREAGE_FIGHT_GADGET", value = 0, no_refresh = false },
{ config_id=50000004,name = "gm_EVENT_ROGUE_START_FIGHT", value = 0, no_refresh = false },
{ config_id=50000005,name = "gm_poolid", value = 0, no_refresh = false },
{ config_id=51110001,name = "gm_EVENT_ROGUE_OPEN_ACCESS", value = 0, no_refresh = false },
{ config_id=51110002,name = "gm_EVENT_ROGUE_CREAGE_REPAIR_GADGET", value = 0, no_refresh = false },
{ config_id=51110003,name = "gm_EVENT_ROGUE_CREAGE_FIGHT_GADGET", value = 0, no_refresh = false },
{ config_id=51110004,name = "gm_EVENT_ROGUE_START_FIGHT", value = 0, no_refresh = false },
{ config_id=51110005,name = "gm_poolid", value = 0, no_refresh = false },
}
local temp_Tirgger_Rogue_Cell = {
{event = EventType.EVENT_CHALLENGE_SUCCESS,source = "",condition="",action="action_EVENT_CHALLENGE_SUCCESS",trigger_count=0},

View File

@ -55,7 +55,7 @@ function Pool_Initialize()
table.insert(gadgets,pool_gadget_config)
end
table.insert(variables,{config_id = 150000000+k, name = "pool_top_"..k, value = 1})
table.insert(variables,{config_id = 150000000+k+1, name = "pool_max_"..k, value = pool_max})
table.insert(variables,{config_id = 150000000+k+ #pool_object_gadget_id +1, name = "pool_max_"..k, value = pool_max})
end
end
end

View File

@ -100,7 +100,7 @@ function Initialize()
--记录一个最近触发的路点事件,用于识别可能存在的丢掉路点事件的问题
table.insert(variables,{ name = "last_route_point", value = 0})
table.insert(variables,{ config_id = 50000015,name = "last_route_point", value = 0})
end
--[[-----------------------------------------------------------------

View File

@ -0,0 +1,212 @@
--[[======================================
|| filename: Activity_BattleMushroomMonster
|| owner: chen.chen
|| description:
|| LogName: TD
|| Protection: [Protection]
=======================================]]
local battleStartConsole = 1001
local beastSkillConsole={
[1]=1033,
[2]=1034,
[3]=1035,
[4]=1036,
}
local gearOptionInfo=
{
summonBeastInfo=
{
[906]=1023,
[907]=1024,
[908]=1025,
[909]=1026,
[910]=1027,
[911]=1028,
[912]=1029,
[913]=1030,
[914]=1031,
[915]=1032,
},
challengeInfo=
{
attackChallenge=900,
defenseChallenge=901
},
beastSillInfo=
{
[1]=902,
[2]=903,
[3]=904,
[4]=905,
}
}
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_BattleMushroomMonster] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ config_id = 40000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 40000002, name = "select_option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_EVENT_SELECT_OPTION", trigger_count = 0 },
{ config_id = 40000003, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0 },
}
------ Local Functions -----------
function LF_Initialize_Level()
--- TRIGGER
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggers) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
for i=1,#beastSkillConsole do
table.insert(variables,{ config_id=50000000+i,name = beastSkillConsole[i].."BeastConfigId", value = 0})
end
table.insert(variables,{ config_id=51000000,name = "wave", value = 1})
table.insert(variables,{ config_id=51000001,name = "strategy", value = 1})
table.insert(variables,{ config_id=51000002,name = "index", value = 1})
return 0
end
function LF_StartAttackChanllenge(context)
PrintLog(context, "测试关卡开启")
local wave=ScriptLib.GetGroupVariableValue(context,"wave")
local strategy=ScriptLib.GetGroupVariableValue(context,"strategy")
local index=ScriptLib.GetGroupVariableValue(context,"index")
local waveInfo=random_strategy_info[strategy][wave][index]
--零时测试数据
ScriptLib.ActiveChallenge(context, 1, 1, 0, waveInfo.total_count, 0, 0)
ScriptLib.AutoPoolMonsterTide(context, 1, base_info.group_id, waveInfo.monster_package,0, {}, {}, {total_count=waveInfo.total_count, min_count=waveInfo.min_count, max_count=waveInfo.max_count,fill_time=0,fill_count=0,is_ordered = true})
--ScriptLib.AutoMonsterTide(context, 100, 251009001, {1037,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048}, 100, 2, 5)
return 0
end
------ Server Lua Call Functions -----------
--怪物cd重置
function SLC_MushroomMonsterAlertRefreshSkill(context)
PrintLog(context,"蕈兽技能CD重置")
--进入惊吓状态
local beast = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id })
--local beast = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.SetEntityServerGlobalValueByConfigId(context, beast, "SGV_Fungus_StartBurst_Immediately",0)
for k,v in pairs(beastSkillConsole) do
if ScriptLib.GetGroupVariableValue(context, v.."BeastConfigId")==beast then
ScriptLib.AssignPlayerShowTemplateReminder(context, 200, {param_vec={k},param_uid_vec={},uid_vec={context.owner_uid}})
end
end
return 0
end
--蕈兽放技能
function SLC_MushroomMonsterAlertDoSkill(context)
PrintLog(context,"蕈兽开始释放技能")
local beast = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id })
ScriptLib.SetEntityServerGlobalValueByConfigId(context, beast, "SGV_Fungus_StartBurst_Immediately",1)
return 0
end
------ conditions & actions ------
--group加载
function action_EVENT_GROUP_LOAD(context, evt)
PrintLog(context, "group load")
--variable重置
for i=1,#beastSkillConsole do
ScriptLib.SetGroupVariableValue(context, beastSkillConsole[i].."BeastConfigId", 0)
end
--开启挑战台子增加按钮
ScriptLib.SetWorktopOptionsByGroupId(context, 0, battleStartConsole, {gearOptionInfo.challengeInfo.attackChallenge,gearOptionInfo.challengeInfo.defenseChallenge})
--给四个台子增加创建蕈兽的按钮
local insertTableValue=function(input)
local output={}
for k,v in pairs(input) do
table.insert(output,k)
end
return output
end
local tempTbl=insertTableValue(gearOptionInfo.summonBeastInfo)
for i=1,#beastSkillConsole do
ScriptLib.SetWorktopOptionsByGroupId(context, 0, beastSkillConsole[i], tempTbl)
end
return 0
end
function action_EVENT_SELECT_OPTION(context, evt)
PrintLog(context, "select option")
--先看看是不是开启挑战
if evt.param1 == battleStartConsole then
if evt.param2 == gearOptionInfo.challengeInfo.attackChallenge then
PrintLog(context, "开启挑战关")
ScriptLib.AddExtraGroupSuite(context, 0, 2)
LF_StartAttackChanllenge(context)
elseif evt.param2 == gearOptionInfo.challengeInfo.defenseChallenge then
PrintLog(context, "开启防守关")
ScriptLib.AddExtraGroupSuite(context, 0, 3)
else
PrintLog(context, "挑战台上了错误的按钮")
end
return 0
end
--看看是不是召唤蕈兽
for k,v in pairs(gearOptionInfo.summonBeastInfo) do
if k==evt.param2 then
monsterConfigId=gearOptionInfo.summonBeastInfo[evt.param2]
--先把自己的按钮只换了
for a,b in pairs(beastSkillConsole) do
if evt.param1==b then
ScriptLib.SetWorktopOptionsByGroupId(context, 0, b, {gearOptionInfo.beastSillInfo[a]})
else
--其他几个操作台删掉对应按钮
ScriptLib.DelWorktopOptionByGroupId(context, 0, b, evt.param2)
end
end
--然后把怪物创建出来
if -1==ScriptLib.CreateMonster(context, { config_id = monsterConfigId,delay_time = 0,server_global_value={["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}}) then
PrintLog(context, "怪物创建失败")
else
PrintLog(context, "怪物创建成功configID:"..monsterConfigId)
end
--最近记录下怪物和操作台的绑定关系
ScriptLib.SetGroupVariableValue(context, evt.param1.."BeastConfigId",monsterConfigId)
return 0
end
end
--看看是不是要放蕈兽技能
for k,v in pairs(gearOptionInfo.beastSillInfo) do
if v==evt.param2 then
local consoleId=beastSkillConsole[k]
local monsterId=ScriptLib.GetGroupVariableValue(context, consoleId.."BeastConfigId")
ScriptLib.SetEntityServerGlobalValueByConfigId(context, monsterId, "SGV_Fungus_StartBurst_Immediately", 1)
--起一个时间轴给它设回来这个先改成用词缀加SLC做
return 0
end
end
--如果无事发生
PrintLog(context, "按钮配置有误,未触发任何逻辑")
return 0
end
function action_EVENT_ANY_MONSTER_DIE(context, evt)
for i=1,#beastSkillConsole do
if ScriptLib.GetGroupVariableValue(context, beastSkillConsole[i].."BeastConfigId") == evt.param1 then
PrintLog(context, "蕈兽死亡:"..evt.param1)
ScriptLib.SetGroupVariableValue(context, beastSkillConsole[i].."BeastConfigId",0)
end
end
return 0
end
LF_Initialize_Level()

View File

@ -0,0 +1,472 @@
--[[======================================
|| filename: Activity_BattleMushroomMonster_BattleGroup
|| owner: chen.chen
|| description:
|| LogName: TD
|| Protection: [Protection]
=======================================]]
--[[
local custom_level={
[81013]={max_count=5}
}
]]--
local global_info=
{
attackLevel={groupId=247101001,galleryId=28021,max_wave=3},
defenseLevel={groupId=247102001,galleryId=28022,max_wave=1},
--最大技能使用次数
max_skill_count=6,
--三个吃球buff的持续时间
awardball_skillone_effecttime=18,
awardball_skilltwo_effecttime=18,
awardball_skillthree_effecttime=18,
awardball_refresh_time=10,
awardball_gadget_id=70290663,
maxEffectNum=3,
phase_two_time=90,
phase_two_awardball_cd=10,
}
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_BattleMushroomMonster_BattleGroup] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ config_id = 40000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 40000002, name = "fungus_select_done", event = EventType.EVENT_TRAINING_FUNGUS_SELECT_DONE, source = "", condition = "", action = "action_EVENT_TRAINING_FUNGUS_SELECT_DONE", trigger_count = 0 },
{ config_id = 40000003, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0 },
{ config_id = 40000004, name = "time_axis_pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_EVENT_TIME_AXIS_PASS", trigger_count = 0},
{ config_id = 40000005, name = "monster_before_leave_scene", event = EventType.EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE,source = "", condition = "", action = "action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE", trigger_count = 0},
{ config_id = 40000006, name = "gadget_die", event = EventType.EVENT_ANY_GADGET_DIE,source = "", condition = "", action = "action_EVENT_ANY_GADGET_DIE", trigger_count = 0},
{ config_id = 40000007, name = "gallery_stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_EVENT_GALLERY_STOP", trigger_count = 0},
{ config_id = 40000008, name = "dungeon_settle", event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_EVENT_DUNGEON_SETTLE", trigger_count = 0},
{ config_id = 40000009, name = "dungeon_all_avatar_die", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_EVENT_DUNGEON_ALL_AVATAR_DIE", trigger_count = 0},
{ config_id = 40000010, name = "gadget_create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_EVENT_GADGET_CREATE", trigger_count = 0},
}
------ Local Functions -----------
function LF_Initialize_Level()
--- TRIGGER
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggers) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
table.insert(variables,{ config_id=51000000,name = "killedMonsters", value = 0,no_refresh = true})
table.insert(variables,{ config_id=51000001,name = "index", value = 0,no_refresh = true})
table.insert(variables,{ config_id=51000002,name = "waveIndex", value = 0,no_refresh = true})
table.insert(variables,{ config_id=51000003,name = "phaseTwoStart", value = 0,no_refresh = false})
table.insert(variables,{ config_id=51000004,name = "phaseTwoSet", value = 0,no_refresh = false})
return 0
end
function LF_GetWaveNumber(context)
if base_info.group_id==global_info.attackLevel.groupId then
return global_info.attackLevel.max_wave
elseif base_info.group_id==global_info.defenseLevel.groupId then
return global_info.defenseLevel.max_wave
end
PrintLog(context, "战斗总波次获取失败")
return 0
end
--1.dungeonid 2.round 3.randindex
function LF_SetRandomResult(context)
local fungusFighterTrainingParams=ScriptLib.GetCurFungusFighterTrainingParams(context)
if #fungusFighterTrainingParams<3 then
PrintLog(context, "地城ID获取失败")
return 0
end
if fungus_strategy_info[fungusFighterTrainingParams[1]]==nil then
PrintLog(context, "地城ID获取失败")
end
local dungeonId=fungusFighterTrainingParams[1]
if fungusFighterTrainingParams[2]==1 then
local upLoadPool={}
local index=0
local waveIndex=0
local waveNumber=LF_GetWaveNumber(context)
for i=1,waveNumber do
index=LF_Random(context,#fungus_strategy_info[dungeonId])
waveIndex=LF_Random(context,#fungus_strategy_info[dungeonId][index][i])
table.insert(upLoadPool,fungus_strategy_info[dungeonId][index][i][waveIndex].monster_package[1])
if i==1 then
ScriptLib.SetGroupVariableValue(context, "index",index)
ScriptLib.SetGroupVariableValue(context, "waveIndex",waveIndex)
PrintLog(context, "第一波上传记录结果")
end
end
if 0 ~= ScriptLib.SetCurFungusFighterTrainingParams(context, {rand_index=999,monster_pool_list=upLoadPool}) then
PrintLog(context, "随机结果上传失败")
end
end
--[[
if fungusFighterTrainingParams[3]==0 then
local dungeonId=fungusFighterTrainingParams[1]
local curRound=fungusFighterTrainingParams[2]
local index=LF_Random(context,#fungus_strategy_info[dungeonId])
local waveIndex=LF_Random(context,#fungus_strategy_info[dungeonId][index][curRound])
if curRound==1 then
ScriptLib.SetGroupVariableValue(context, "index",index)
ScriptLib.SetGroupVariableValue(context, "waveIndex",waveIndex)
PrintLog(context, "第一波上传记录结果")
end
ScriptLib.SetCurFungusFighterTrainingParams(context, {rand_index=100*index+waveIndex,monster_pool_list=fungus_strategy_info[dungeonId][index][curRound][waveIndex].monster_package})
end
]]--
return 0
end
function LF_GetGalleryId(context)
if base_info.group_id==global_info.attackLevel.groupId then
return global_info.attackLevel.galleryId
elseif base_info.group_id==global_info.defenseLevel.groupId then
return global_info.defenseLevel.galleryId
end
PrintLog(context, "galleryid获取失败")
return 0
end
function LF_GetMonsterConfig(context)
local fungusFighterTrainingParams=ScriptLib.GetCurFungusFighterTrainingParams(context)
if #fungusFighterTrainingParams<3 then
PrintLog(context, "地城ID获取失败")
return 0
end
local curRound=fungusFighterTrainingParams[2]
local waveIndex=0
local index=0
if fungusFighterTrainingParams[2] == 1 then
waveIndex=ScriptLib.GetGroupVariableValue(context, "waveIndex")
index=ScriptLib.GetGroupVariableValue(context, "index")
return fungus_strategy_info[fungusFighterTrainingParams[1]][index][curRound][waveIndex]
elseif fungusFighterTrainingParams[2] > 1 then
local pool=fungusFighterTrainingParams[3+curRound]
PrintLog(context, "获取pool:"..pool)
return monsterPoolReverseTable[pool]
--local multiIndex=fungusFighterTrainingParams[3]
--waveIndex=multiIndex%100
--index=(multiIndex-waveIndex)/100
end
PrintLog(context, "MonsterConfig获取失败")
return 0
end
function LF_Random(context,num)
math.randomseed(ScriptLib.GetServerTime(context))
local ret=math.random(num)
PrintLog(context, "随机结果为"..ret)
return ret
end
function LF_UpdateRestSkillCount(context, prev_context, param1, param2, param3)
local bindSGV=ScriptLib.GetTeamServerGlobalValue(context, ScriptLib.GetSceneOwnerUid(context),"SGV_Fungus_Burst_Count")
ScriptLib.AddTeamServerGlobalValue(context, context.owner_uid, "SGV_Fungus_Burst_Count", -1)
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {rest_skill_count=bindSGV-1})
return 0
end
function LF_ResetDungeon(context)
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 1})
LF_RefreshVariables(context)
ScriptLib.ExecuteGroupLua(context, defs.fungus_group, "LF_ResetVariables", {})
return 0
end
function LF_RefreshVariables(context)
ScriptLib.SetGroupVariableValue(context, "killedMonsters",0)
ScriptLib.SetGroupVariableValue(context, "index",0)
ScriptLib.SetGroupVariableValue(context, "waveIndex",0)
ScriptLib.SetGroupVariableValue(context, "phaseTwoStart",0)
ScriptLib.SetGroupVariableValue(context, "phaseTwoSet",0)
return 0
end
------ Server Lua Call Functions -----------
function SLC_AwardBall_Catch(context)
PrintLog(context, "玩家吃球")
ScriptLib.MarkGroupLuaAction(context, "FungusFighter_6",ScriptLib.GetGalleryTransaction(context, LF_GetGalleryId(context)) , {})
local index=LF_Random(context,global_info.maxEffectNum)
local monsterList=ScriptLib.GetGroupAliveMonsterList(context, base_info.group_id)
--迭代逻辑如果场上的怪物小于三只就不会刷到效果2
if #monsterList<3 then
--如果随到2就要重随一次
if index==2 then
local tmpIndex=LF_Random(context,global_info.maxEffectNum-1)
if tmpIndex>=2 then
tmpIndex=tmpIndex+1
end
index=tmpIndex
end
end
--8.15迭代,只加次数
if true then
local bindSGV=ScriptLib.GetTeamServerGlobalValue(context, ScriptLib.GetSceneOwnerUid(context),"SGV_Fungus_Burst_Count")
if bindSGV<global_info.max_skill_count then
ScriptLib.AddTeamServerGlobalValue(context, context.owner_uid, "SGV_Fungus_Burst_Count", 1)
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {rest_skill_count=bindSGV+1})
end
return 0
end
--增加主动技能伤害
if index==1 then
ScriptLib.InitTimeAxis(context,"AwardBallSkillOne",{global_info.awardball_skillone_effecttime},false)
ScriptLib.SetGroupVariableValueByGroup(context, "AttackUp", 1, defs.fungus_group)
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {["buff_id"]=1,["buff_last_time"]=global_info.awardball_skillone_effecttime})
ScriptLib.ShowReminder(context, 400213)
--标记怪物
elseif index==2 then
ScriptLib.InitTimeAxis(context,"AwardBallSkillTwo",{global_info.awardball_skilltwo_effecttime},false)
--修改物件状态
ScriptLib.SetGadgetStateByConfigId(context, defs.call_entity, 201)
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {["buff_id"]=2,["buff_last_time"]=global_info.awardball_skilltwo_effecttime})
ScriptLib.ShowReminder(context, 400214)
--下一次释放技能不消耗次数
elseif index==3 then
ScriptLib.InitTimeAxis(context,"AwardBallSkillThree",{global_info.awardball_skillthree_effecttime},false)
ScriptLib.SetGroupVariableValueByGroup(context, "FreeUseSkill", 1, defs.fungus_group)
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {["buff_id"]=3,["buff_last_time"]=global_info.awardball_skillthree_effecttime})
ScriptLib.ShowReminder(context, 400215)
else
PrintLog(context, "吃球随机结果错误")
end
return 0
end
function SLC_EnemyMonsterReviveSkill(context,param1)
PrintLog(context, "点名怪物"..param1)
local beast = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id })
ScriptLib.SetEntityServerGlobalValueByConfigId(context, beast, "SGV_Revive_Skill_Flag", param1)
return 0
end
------ conditions & actions ------
--group加载
function action_EVENT_GROUP_LOAD(context, evt)
PrintLog(context, "group load")
LF_RefreshVariables(context)
LF_SetRandomResult(context)
return 0
end
--蕈兽选择完毕,开启挑战
--1.dungeonid 2.round 3.randindex
function action_EVENT_TRAINING_FUNGUS_SELECT_DONE(context, evt)
PrintLog(context, "已选择蕈兽")
PrintLog(context, "准备开启gallery:"..LF_GetGalleryId(context))
if not ScriptLib.IsGalleryStart(context,LF_GetGalleryId(context)) then
local bindSGV=ScriptLib.GetTeamServerGlobalValue(context, ScriptLib.GetSceneOwnerUid(context),"SGV_Fungus_Burst_Count")
local monsterConfig=LF_GetMonsterConfig(context)
ScriptLib.SetPlayerStartGallery(context, LF_GetGalleryId(context), {ScriptLib.GetSceneOwnerUid(context)})
ScriptLib.SetGadgetStateByConfigId(context, defs.start_gear, 202)
PrintLog(context, "gallery已开启")
local fungusFighterTrainingParams=ScriptLib.GetCurFungusFighterTrainingParams(context)
if #fungusFighterTrainingParams<3 then
PrintLog(context, "地城ID获取失败")
return 0
end
--如果不是第一间,要创建开局奖励球
if fungusFighterTrainingParams[2]>1 and defs.start_awardball~=nil then
for k,v in pairs(defs.start_awardball) do
ScriptLib.CreateGadget(context, { config_id = v })
end
end
--刷怪
if custom_level~=nil and custom_level[10*fungusFighterTrainingParams[1]+fungusFighterTrainingParams[2]]~=nil then
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {["max_monster_count"]=custom_level[10*fungusFighterTrainingParams[1]+fungusFighterTrainingParams[2]].max_count,
["killed_monster_count"]=0,rest_skill_count=bindSGV,max_skill_count=global_info.max_skill_count})
ScriptLib.SetGroupTempValue(context,tostring(10*fungusFighterTrainingParams[1]+fungusFighterTrainingParams[2]),1,{})
else
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {["max_monster_count"]=monsterConfig.total_count,
["killed_monster_count"]=0,rest_skill_count=bindSGV,max_skill_count=global_info.max_skill_count})
if -1==ScriptLib.AutoPoolMonsterTide(context, 1, base_info.group_id, monsterConfig.monster_package,0, {}, {}, {sgv_map = {SGV_Revive_Skill_Flag = 0},total_count=monsterConfig.total_count, min_count=monsterConfig.min_count, max_count=monsterConfig.max_count,fill_time=monsterConfig.fill_time or 0,fill_count=monsterConfig.fill_count or 0,is_tag_bit_match=true,is_ordered = true}) then
PrintLog(context, "怪物潮初始化失败"..monsterConfig.monster_package[1])
else
PrintLog(context, "怪物潮开启"..monsterConfig.monster_package[1])
end
end
--准备产球时间轴
if monsterConfig.awardball_thinkinterval ~=nil and monsterConfig.awardball_thinkinterval>0 then
--8.15迭代球效果,后删
--ScriptLib.InitTimeAxis(context,"AwardBallGenerate",{global_info.awardball_refresh_time},true)
ScriptLib.InitTimeAxis(context,"AwardBallGenerate",{monsterConfig.awardball_thinkinterval},true)
--起一个时间轴记录到二阶段的时间
ScriptLib.InitTimeAxis(context,"PhaseTwoStart",{global_info.phase_two_time},false)
end
--如果是防守关,还需要加防守物件
if LF_GetGalleryId(context)==global_info.defenseLevel.galleryId then
ScriptLib.CreateGadget(context, { config_id = defs.defense_logicentity })
ScriptLib.CreateGadget(context, { config_id = defs.defense_viewentity })
end
--最后要开镜头
ScriptLib.CreateGadget(context, { config_id = defs.camGadget })
else
PrintLog(context, "gallery重复开启检查配置")
end
return 0
end
--怪物死亡增加gallery计数
function action_EVENT_ANY_MONSTER_DIE(context, evt)
PrintLog(context, "怪物死亡")
if not ScriptLib.IsGalleryStart(context,LF_GetGalleryId(context)) then
PrintLog(context, "怪物死亡,gallery未开启")
return 0
end
local killMonsters=ScriptLib.GetGroupVariableValue(context, "killedMonsters")
killMonsters=killMonsters+1
ScriptLib.SetGroupVariableValue(context, "killedMonsters",killMonsters)
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {["killed_monster_count"]=killMonsters})
local fungusFighterTrainingParams=ScriptLib.GetCurFungusFighterTrainingParams(context)
if custom_level~=nil and custom_level[10*fungusFighterTrainingParams[1]+fungusFighterTrainingParams[2]]~=nil then
if killMonsters>=custom_level[10*fungusFighterTrainingParams[1]+fungusFighterTrainingParams[2]].max_count then
ScriptLib.StopGallery(context,LF_GetGalleryId(context),false)
end
else
local monsterConfig=LF_GetMonsterConfig(context)
if killMonsters>=monsterConfig.total_count then
ScriptLib.StopGallery(context,LF_GetGalleryId(context),false)
end
end
return 0
end
--产球
function action_EVENT_TIME_AXIS_PASS(context, evt)
PrintLog(context, "时间轴触发"..evt.source_name)
if evt.source_name=="PhaseTwoStart" then
ScriptLib.SetGroupVariableValue(context, "phaseTwoStart",1)
return 0
end
if evt.source_name=="AwardBallGenerate" then
if defs.awardball_configid ~= nil then
if awardBallGeneratePosition ~= nil then
local index=LF_Random(context,#awardBallGeneratePosition)
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.awardball_configid, awardBallGeneratePosition[index], {x=0,y=0,z=0})
end
end
if ScriptLib.GetGroupVariableValue(context, "phaseTwoStart")==1 and ScriptLib.GetGroupVariableValue(context, "phaseTwoSet")==0 then
ScriptLib.EndTimeAxis(context, "AwardBallGenerate")
ScriptLib.InitTimeAxis(context,"AwardBallGenerate",{global_info.phase_two_awardball_cd},true)
ScriptLib.SetGroupVariableValue(context, "phaseTwoSet",1)
end
end
if evt.source_name=="AwardBallSkillThree" then
ScriptLib.SetGroupVariableValueByGroup(context, "FreeUseSkill", 0, defs.fungus_group)
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {["buff_id"]=0,["buff_last_time"]=0})
end
if evt.source_name=="AwardBallSkillOne" then
ScriptLib.SetGroupVariableValueByGroup(context, "AttackUp", 0, defs.fungus_group)
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {["buff_id"]=0,["buff_last_time"]=0})
end
if evt.source_name=="AwardBallSkillTwo" then
ScriptLib.UpdatePlayerGalleryScore(context, LF_GetGalleryId(context), {["buff_id"]=0,["buff_last_time"]=0})
end
return 0
end
--死亡退场看看是否要加技能使用次数
function action_EVENT_MONSTER_DIE_BEFORE_LEAVE_SCENE(context, evt)
if ScriptLib.GetMonsterAbilityFloatValue(context, base_info.group_id, evt.param1, "SGV_Revive_Skill_Flag") == 1 then
if ScriptLib.GetTeamServerGlobalValue(context, context.owner_uid, "SGV_Fungus_Burst_Count") < global_info.max_skill_count then
ScriptLib.AddTeamServerGlobalValue(context, context.owner_uid, "SGV_Fungus_Burst_Count", 1)
end
end
return 0
end
function action_EVENT_ANY_GADGET_DIE(context, evt)
if evt.param1==defs.defense_logicentity then
ScriptLib.KillGroupEntity(context, { group_id = base_info.group_id, gadgets = {defs.defense_viewentity} })
ScriptLib.StopGallery(context,LF_GetGalleryId(context),true)
return 0
else
--如果死亡的是球
local containsKey=false
for k,v in pairs(defs.start_awardball) do
if v==evt.param1 then
containsKey=true
end
end
if containsKey==true or evt.param1==defs.awardball_configid then
PrintLog(context, "助威球死亡")
local awardballNum=ScriptLib.CheckRemainGadgetCountByGroupId(context, {group_id = base_info.group_id,gadget_id={global_info.awardball_gadget_id}})
PrintLog(context, "剩余助威球数量"..awardballNum)
if awardballNum==0 then
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.RevokePlayerShowTemplateReminder(context, 212, {hostUid})
ScriptLib.SetGroupTempValue(context,"templateReminderShow",0,{})
end
end
end
return 0
end
--gallery结束恢复逻辑
function action_EVENT_GALLERY_STOP(context, evt)
PrintLog(context, "event gallery stop")
--关时间轴
ScriptLib.EndTimeAxis(context,"AwardBallGenerate")
--回收reminder
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.RevokePlayerShowTemplateReminder(context, 212, {hostUid})
ScriptLib.SetGroupTempValue(context,"templateReminderShow",0,{})
LF_ResetDungeon(context)
return 0
end
--地城失败回收逻辑
function action_EVENT_DUNGEON_SETTLE(context, evt)
--为玩家手动退出地城加个保底回收
if evt.param1==0 then
--如果gallery开着要关一下
if ScriptLib.IsGalleryStart(context,LF_GetGalleryId(context)) then
ScriptLib.StopGallery(context,LF_GetGalleryId(context),true)
else
LF_ResetDungeon(context)
end
end
return 0
end
--玩家意外死亡保底逻辑
function action_EVENT_DUNGEON_ALL_AVATAR_DIE(context, evt)
if ScriptLib.IsGalleryStart(context,LF_GetGalleryId(context)) then
ScriptLib.StopGallery(context,LF_GetGalleryId(context),true)
else
LF_ResetDungeon(context)
end
--地城失败
ScriptLib.CauseDungeonFail(context)
return 0
end
--处理积分球的reminder显示
function action_EVENT_GADGET_CREATE(context, evt)
if evt.param2 == global_info.awardball_gadget_id then
PrintLog(context, "GADGET_CREATE_助威球创建")
local awardballNum=ScriptLib.CheckRemainGadgetCountByGroupId(context, {group_id = base_info.group_id,gadget_id={global_info.awardball_gadget_id}})
PrintLog(context, "剩余助威球数量"..awardballNum)
if awardballNum>0 and ScriptLib.GetGroupTempValue(context,"templateReminderShow",{})==0 then
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.AssignPlayerShowTemplateReminder(context,212,{is_need_cache=true, param_uid_vec={},param_vec={},uid_vec={hostUid}})
ScriptLib.SetGroupTempValue(context,"templateReminderShow",1,{})
end
end
return 0
end
LF_Initialize_Level()

View File

@ -0,0 +1,45 @@
fungus_monsters={
--战斗用
{ config_id = 1023, monster_id = 36090190, pos = { x = 7.693, y = 100.000, z = -8.942 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1, server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
{ config_id = 1024, monster_id = 36090290, pos = { x = 7.438, y = 100.000, z = -12.740 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1,server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
{ config_id = 1025, monster_id = 36090390, pos = { x = 7.670, y = 100.000, z = -16.200 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1,server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
{ config_id = 1026, monster_id = 36090490, pos = { x = 8.488, y = 100.000, z = -11.108 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1,server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
{ config_id = 1027, monster_id = 36090590, pos = { x = 8.922, y = 100.000, z = -14.768 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1,server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
{ config_id = 1028, monster_id = 36090690, pos = { x = 6.094, y = 100.000, z = -15.113 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level =1,server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
{ config_id = 1029, monster_id = 36090790, pos = { x = 5.823, y = 100.000, z = -11.924 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1,server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
{ config_id = 1030, monster_id = 36090890, pos = { x = 9.308, y = 100.000, z = -12.806 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1,server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
{ config_id = 1031, monster_id = 36090990, pos = { x = 6.149, y = 100.000, z = -9.820 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1,server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
{ config_id = 1032, monster_id = 36091090, pos = { x = 5.544, y = 100.000, z = -13.396 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1,server_global_value_config = { ["SGV_Burst_Attack_Up"]=0,["SGV_Fungus_StartBurst_Immediately"]=0,["SGV_Fungus_StartBurst_WaitForStandby"]=0}, affix = { 5213 }, isPartner = true },
--剧情用敌对蕈兽
--飞行水
{ config_id = 1033, monster_id = 26090190, pos = { x = 7.693, y = 100.000, z = -8.942 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1 },
--飞行草
{ config_id = 1034, monster_id = 26090290, pos = { x = 7.438, y = 100.000, z = -12.740 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1},
--飞行风
{ config_id = 1035, monster_id = 26090390, pos = { x = 7.670, y = 100.000, z = -16.200 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1},
--旋转雷
{ config_id = 1036, monster_id = 26090490, pos = { x = 8.488, y = 100.000, z = -11.108 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1 },
--旋转冰
{ config_id = 1037, monster_id = 26090590, pos = { x = 8.922, y = 100.000, z = -14.768 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1},
--旋转火
{ config_id = 1038, monster_id = 26090690, pos = { x = 6.094, y = 100.000, z = -15.113 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level =1},
--伸展火
{ config_id = 1039, monster_id = 26090790, pos = { x = 5.823, y = 100.000, z = -11.924 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1 },
--伸展风
{ config_id = 1040, monster_id = 26090890, pos = { x = 9.308, y = 100.000, z = -12.806 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1 },
--伸展岩
{ config_id = 1041, monster_id = 26090990, pos = { x = 6.149, y = 100.000, z = -9.820 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1 },
--伸展雷
{ config_id = 1042, monster_id = 26091090, pos = { x = 5.544, y = 100.000, z = -13.396 }, rot = { x = 0.000, y = 0.000, z = 0.000 }, level = 1},
}
--10000000+
function LF_Initialize_Fungus()
for k,v in pairs(fungus_monsters) do
v.config_id=v.config_id+10000000
table.insert(monsters,v)
end
return 0
end
LF_Initialize_Fungus()

View File

@ -0,0 +1,142 @@
--[[======================================
|| filename: Activity_BattleMushroomMonster_FungusGroup
|| owner: chen.chen
|| description: group
|| LogName: TD
|| Protection: [Protection]
=======================================]]
global_info=
{
attackLevel={groupId=247101002,galleryId=28021,max_wave=3},
defenseLevel={groupId=247102002,galleryId=28022,max_wave=1}
}
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_BattleMushroomMonster_FungusGroup] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ config_id = 40000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 40000002, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0 },
{ config_id = 40000003, name = "monster_alive", event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_LIVE", trigger_count = 0 },
{ config_id = 40000004, name = "variable_change", event = EventType.EVENT_VARIABLE_CHANGE, source = "AttackUp", condition = "", action = "action_EVENT_VARIABLE_CHANGE", trigger_count = 0 },
}
------ Local Functions -----------
function LF_Initialize_Level()
--- TRIGGER
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggers) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
table.insert(variables,{ config_id=51000000,name = "AttackUp", value = 0,no_refresh = true})
table.insert(variables,{ config_id=51000001,name = "FreeUseSkill", value = 0,no_refresh = true})
table.insert(variables,{ config_id=51000002,name = "RebornGearUsed", value = 0,no_refresh = true})
return 0
end
--获取gallery_id
function LF_GetGalleryId(context)
if base_info.group_id==global_info.attackLevel.groupId then
return global_info.attackLevel.galleryId
elseif base_info.group_id==global_info.defenseLevel.groupId then
return global_info.defenseLevel.galleryId
end
PrintLog(context, "galleryid获取失败")
return 0
end
function LF_ResetVariables(context)
ScriptLib.SetGroupVariableValue(context, "AttackUp",0)
ScriptLib.SetGroupVariableValue(context, "FreeUseSkill",0)
ScriptLib.SetGroupVariableValue(context, "RebornGearUsed",0)
--无脑设
if defs.reborn_gear ~= nil then
ScriptLib.SetGadgetStateByConfigId(context, defs.reborn_gear, 0)
end
return 0
end
------ Server Lua Call Functions -----------
--怪物cd重置
function SLC_MushroomMonsterAlertRefreshSkill(context)
PrintLog(context,"蕈兽技能CD重置")
local beast = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id })
ScriptLib.SetEntityServerGlobalValueByConfigId(context, beast, "SGV_Fungus_StartBurst_Immediately",0)
return 0
end
--蕈兽放技能
function SLC_MushroomMonsterAlertDoSkill(context)
PrintLog(context,"蕈兽开始释放技能")
if ScriptLib.GetTeamServerGlobalValue(context, context.owner_uid, "SGV_Fungus_Burst_Count")>0 or defs.isFungusQuestGroup==1 then
local beast = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id })
local fungusMonsterId=ScriptLib.GetMonsterIdByEntityId(context, context.source_entity_id)
--埋点
if defs.isFungusQuestGroup~=1 then
ScriptLib.MarkGroupLuaAction(context, "FungusFighter_5",ScriptLib.GetGalleryTransaction(context, LF_GetGalleryId(context)) , {["monster_id"] = fungusMonsterId})
end
ScriptLib.SetEntityServerGlobalValueByConfigId(context, beast, "SGV_Fungus_StartBurst_Immediately",1)
--非任务group就通知主流程group处理
if ScriptLib.GetGroupVariableValue(context, "FreeUseSkill")==0 and defs.isFungusQuestGroup~=1 then
ScriptLib.ExecuteGroupLua(context, defs.battle_group, "LF_UpdateRestSkillCount", {})
end
--任务group就直接扣
if ScriptLib.GetGroupVariableValue(context, "FreeUseSkill")==0 and defs.isFungusQuestGroup==1 then
ScriptLib.AddTeamServerGlobalValue(context, context.owner_uid, "SGV_Fungus_Burst_Count", -1)
end
end
return 0
end
------ conditions & actions ------
--group加载
function action_EVENT_GROUP_LOAD(context, evt)
PrintLog(context, "group load")
LF_ResetVariables(context)
return 0
end
function action_EVENT_ANY_MONSTER_DIE(context, evt)
PrintLog(context, "蕈兽死亡")
--如果本房间没开过复活机关,开一个
if ScriptLib.GetGroupVariableValue(context, "RebornGearUsed")==0 then
local backupFungusList = ScriptLib.GetCurFungusFighterTrainingValidBackupFungusIdList(context)
if #backupFungusList >0 then
if defs.reborn_gear ~= nil then
ScriptLib.SetGadgetStateByConfigId(context, defs.reborn_gear, 201)
end
end
ScriptLib.SetGroupVariableValue(context, "RebornGearUsed",1)
end
return 0
end
function action_EVENT_VARIABLE_CHANGE(context, evt)
local monsterList=ScriptLib.GetGroupAliveMonsterList(context, base_info.group_id)
for _,v in pairs(monsterList) do
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_Burst_Attack_Up",evt.param1)
end
return 0
end
function action_EVENT_ANY_MONSTER_LIVE(context, evt)
PrintLog(context, "蕈兽创生")
--无脑设
if defs.reborn_gear ~= nil then
ScriptLib.SetGadgetStateByConfigId(context, defs.reborn_gear, 0)
end
--看看要不要加攻击
if ScriptLib.GetGroupVariableValue(context, "AttackUp")==1 then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_Burst_Attack_Up",1)
end
return 0
end
LF_Initialize_Level()

View File

@ -0,0 +1,280 @@
--misc
--[[
--每个group里配的表示这个group里每个随机策略对应的怪物配置存档为1-4的随机值
local random_strategy_info={
[1]=random_strategy_01,
[2]=random_strategy_02,
[3]=random_strategy_03,
[4]=random_strategy_04
}
]]
--config
--每一波具体使用的资源包,数值等
local wave_01={ monster_package={36001}, total_count=14, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_02={ monster_package={36002}, total_count=5, min_count=2, max_count=3, fill_time=60, fill_count=3, is_ordered = true , awardball_thinkinterval=12 }
local wave_03={ monster_package={36003}, total_count=6, min_count=2, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_04={ monster_package={36004}, total_count=5, min_count=2, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_05={ monster_package={36005}, total_count=8, min_count=2, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_06={ monster_package={36006}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_07={ monster_package={36007}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_08={ monster_package={36008}, total_count=8, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12}
local wave_09={ monster_package={36009}, total_count=9, min_count=2, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_10={ monster_package={36010}, total_count=10, min_count=2, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_11={ monster_package={36011}, total_count=12, min_count=4, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12}
local wave_12={ monster_package={36012}, total_count=12, min_count=4, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_13={ monster_package={36013}, total_count=12, min_count=4, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_14={ monster_package={36014}, total_count=12, min_count=4, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_15={ monster_package={36015}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_16={ monster_package={36016}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_17={ monster_package={36017}, total_count=16, min_count=2, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_18={ monster_package={36018}, total_count=16, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_19={ monster_package={36019}, total_count=9, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_20={ monster_package={36020}, total_count=9, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_21={ monster_package={36021}, total_count=14, min_count=4, max_count=5, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_22={ monster_package={36022}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_23={ monster_package={36023}, total_count=14, min_count=4, max_count=5, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_24={ monster_package={36024}, total_count=2, min_count=2, max_count=2, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_25={ monster_package={36025}, total_count=12, min_count=1, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_26={ monster_package={36026}, total_count=8, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_27={ monster_package={36027}, total_count=3, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_28={ monster_package={36028}, total_count=3, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_29={ monster_package={36029}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_30={ monster_package={36030}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_31={ monster_package={36031}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_32={ monster_package={36032}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_33={ monster_package={36033}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_34={ monster_package={36034}, total_count=7, min_count=2, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_35={ monster_package={36035}, total_count=7, min_count=2, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_36={ monster_package={36036}, total_count=9, min_count=1, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_37={ monster_package={36037}, total_count=9, min_count=1, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_38={ monster_package={36038}, total_count=12, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_39={ monster_package={36039}, total_count=12, min_count=1, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_40={ monster_package={36040}, total_count=10, min_count=2, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_41={ monster_package={36041}, total_count=4, min_count=2, max_count=2, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_42={ monster_package={36042}, total_count=4, min_count=2, max_count=2, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_43={ monster_package={36043}, total_count=3, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_44={ monster_package={36044}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_45={ monster_package={36045}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_46={ monster_package={36046}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_47={ monster_package={36047}, total_count=16, min_count=1, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_48={ monster_package={36048}, total_count=7, min_count=1, max_count=3, fill_time=40, fill_count=3, is_ordered = true , awardball_thinkinterval=12 }
local wave_49={ monster_package={36049}, total_count=7, min_count=2, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_50={ monster_package={36050}, total_count=1, min_count=1, max_count=1, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_51={ monster_package={36051}, total_count=3, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=10 }
local wave_52={ monster_package={36052}, total_count=12, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_53={ monster_package={36053}, total_count=12, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_54={ monster_package={36054}, total_count=12, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_55={ monster_package={36055}, total_count=6, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_56={ monster_package={36056}, total_count=6, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_57={ monster_package={36057}, total_count=6, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_58={ monster_package={36058}, total_count=14, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_59={ monster_package={36059}, total_count=12, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
local wave_60={ monster_package={36060}, total_count=12, min_count=3, max_count=4, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=12 }
--假的怪物预览
local wave_61={ monster_package={36061}, total_count=9, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=15 }
local wave_62={ monster_package={36062}, total_count=9, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=20 }
local wave_63={ monster_package={36063}, total_count=9, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=20 }
local wave_64={ monster_package={36064}, total_count=9, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=20 }
local wave_65={ monster_package={36065}, total_count=9, min_count=3, max_count=3, fill_time=0, fill_count=0, is_ordered = true , awardball_thinkinterval=20 }
--反查表
local monsterPoolReverseTable=
{
[36001]=wave_01,[36002]=wave_02,[36003]=wave_03,[36004]=wave_04,[36005]=wave_05,[36006]=wave_06,[36007]=wave_07,[36008]=wave_08,[36009]=wave_09,
[36010]=wave_10,[36011]=wave_11,[36012]=wave_12,[36013]=wave_13,[36014]=wave_14,[36015]=wave_15,[36016]=wave_16,[36017]=wave_17,[36018]=wave_18,[36019]=wave_19,
[36020]=wave_20,[36021]=wave_21,[36022]=wave_22,[36023]=wave_23,[36024]=wave_24,[36025]=wave_25,[36026]=wave_26,[36027]=wave_27,[36028]=wave_28,[36029]=wave_29,
[36030]=wave_30,[36031]=wave_31,[36032]=wave_32,[36033]=wave_33,[36034]=wave_34,[36035]=wave_35,[36036]=wave_36,[36037]=wave_37,[36038]=wave_38,[36039]=wave_39,
[36040]=wave_40,[36041]=wave_41,[36042]=wave_42,[36043]=wave_43,[36044]=wave_44,[36045]=wave_45,[36046]=wave_46,[36047]=wave_47,[36048]=wave_48,[36049]=wave_49,
[36050]=wave_50,[36051]=wave_51,[36052]=wave_52,[36053]=wave_53,[36054]=wave_54,[36055]=wave_55,[36056]=wave_56,[36057]=wave_57,[36058]=wave_58,[36059]=wave_59,
[36060]=wave_60,[36061]=wave_61,[36062]=wave_62,[36063]=wave_63,[36064]=wave_64,[36065]=wave_65
}
--表示该策略下的三波怪物分别对应的怪物配置
-- day1
local random_strategy_01={
[1]={wave_01},
[2]={wave_61},
[3]={wave_06},
}
--day2
local random_strategy_02={
[1]={wave_08},
[2]={wave_09},
[3]={wave_46},
}
--day3
local random_strategy_03={
[1]={wave_18},
[2]={wave_26},
[3]={wave_63},
}
--day4
local random_strategy_04={
[1]={wave_11,wave_12,wave_13,wave_14},
[2]={wave_27,wave_28,wave_51},
[3]={wave_15,wave_16,wave_44,wave_45},
}
--day5
local random_strategy_05={
[1]={wave_07},
[2]={wave_34,wave_35,wave_49},
[3]={wave_50,wave_22,wave_29,wave_33,wave_31},
}
--防守1
local random_strategy_06={
[1]={wave_25},
}
--防守2
local random_strategy_07={
[1]={wave_37},
}
--防守3
local random_strategy_08={
[1]={wave_38},
}
--防守4
local random_strategy_09={
[1]={wave_39},
}
--防守5
local random_strategy_10={
[1]={wave_40},
}
local fungus_strategy_info={
[8101]=
{
[1]=random_strategy_01
},
[8102]=
{
[1]=random_strategy_02
},
[8103]=
{
[1]=random_strategy_03
},
[8104]=
{
[1]=random_strategy_04
},
[8105]=
{
[1]=random_strategy_05
},
[8106]=
{
[1]=random_strategy_06
},
[8107]=
{
[1]=random_strategy_07
},
[8108]=
{
[1]=random_strategy_08
},
[8109]=
{
[1]=random_strategy_09
},
[8110]=
{
[1]=random_strategy_10
}
}

View File

@ -0,0 +1,356 @@
--[[======================================
|| filename: Activity_BattleMushroomMonster_QuestGroup
|| owner: chen.chen
|| description:
|| LogName: TD
|| Protection: [Protection]
=======================================]]
--[[
--参考配置
local create_partner_fungus=
{
[4008206]={},
[4008206]=
{
[1]={config_id=1023},
},
}
local create_enemy_fungus=
{
[4008206]=
{
[1]={config_id=1033},
[2]={config_id=1034},
[3]={config_id=1035},
[4]={config_id=1036,affix={5223}},
}
}
]]--
local global_infotwo=
{
awardball_cd=10,
max_skill_count=6,
awardball_gadget_id=70290663,
}
-- 打印日志
function PrintLog_Quest(context, content)
local log = "## [Activity_BattleMushroomMonster_QuestGroup] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggersQuest =
{
{ config_id = 41000001, name = "group_load_quest", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD_QUEST", trigger_count = 0 },
{ config_id = 41000002, name = "quest_finish", event = EventType.EVENT_QUEST_FINISH, source = "", condition = "", action = "action_EVENT_QUEST_FINISH", trigger_count = 0 },
{ config_id = 41000003, name = "quest_start", event = EventType.EVENT_QUEST_START, source = "", condition = "", action = "action_EVENT_QUEST_START", trigger_count = 0 },
{ config_id = 41000004, name = "monster_die_quest", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE_QUEST", trigger_count = 0 },
{ config_id = 41000005, name = "monster_hp_change", event = EventType.EVENT_SPECIFIC_MONSTER_HP_CHANGE, source = tostring(10001023), condition = "", action = "action_EVENT_SPECIFIC_MONSTER_HP_CHANGE", trigger_count = 0 },
{ config_id = 41000006, name = "time_axis_pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_EVENT_TIME_AXIS_PASS", trigger_count = 0},
{ config_id = 41000007, name = "gadget_create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_EVENT_GADGET_CREATE", trigger_count = 0},
{ config_id = 41000008, name = "gadget_die", event = EventType.EVENT_ANY_GADGET_DIE,source = "", condition = "", action = "action_EVENT_ANY_GADGET_DIE", trigger_count = 0},
{ config_id = 41000009, name = "dungeon_all_avatar_die", event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "", action = "action_EVENT_DUNGEON_ALL_AVATAR_DIE", trigger_count = 0},
{ config_id = 41000010, name = "dungeon_avatar_slip_die", event = EventType.EVENT_DUNGEON_AVATAR_SLIP_DIE, source = "", condition = "", action = "action_EVENT_DUNGEON_AVATAR_SLIP_DIE", trigger_count = 0},
}
------ Local Functions -----------
function LF_Initialize_QuestLevel()
--- TRIGGER
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggersQuest) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggersQuest) do
table.insert(triggers, _trigger)
end
table.insert(variables,{ config_id=51100000,name = "enemyCount", value = 0})
table.insert(variables,{ config_id=51100001,name = "partnerCount", value = 0})
table.insert(variables,{ config_id=51100002,name = "currentQuest", value = 0})
return 0
end
function LF_GetPointConfig(configId)
for i=1,#points do
if points[i].config_id==configId then
return points[i]
end
end
PrintLog_Quest(context, "出生点位未找到:"..configId)
return 0
end
function LF_ContainsKey(table,key)
for i=1,#table do
if table[i]==key then
return true
end
end
return false
end
function LF_GetPartnerBornPointConfig(index,table,questId)
if LF_ContainsKey(table,questId) then
return LF_GetPointConfig(partner_fungus_born_points_two[index])
else
return LF_GetPointConfig(partner_fungus_born_points[index])
end
end
function LF_ResetAllTeamGlobalValueFlags(context)
PrintLog_Quest(context, "LF_ResetAllTeamGlobalValueFlags")
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_OnHalfHP_Sent_Mark_", 0)
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_OnUnionBurst_Sent_Mark_", 0)
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_OnHeroUnionBurst_Sent_Mark_", 0)
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_OnHeroInCrisis_Sent_Mark_", 0)
return 0
end
function LF_Random(context,num)
math.randomseed(ScriptLib.GetServerTime(context))
local ret=math.random(num)
PrintLog_Quest(context, "随机结果为"..ret)
return ret
end
------ Server Lua Call Functions -----------
function SLC_Sent_Mark(context,param1)
PrintLog_Quest(context, "SLC_Sent_Mark")
if param1==1 then
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_OnHeroUnionBurst_Sent_Mark_", 1)
elseif param1==2 then
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_OnHeroInCrisis_Sent_Mark_", 1)
elseif param1==3 then
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_OnHalfHP_Sent_Mark_", 1)
elseif param1==4 then
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_OnUnionBurst_Sent_Mark_", 1)
end
return 0
end
function SLC_AwardBall_Catch(context)
PrintLog_Quest(context, "玩家吃球")
--8.15迭代,只加次数
local bindSGV=ScriptLib.GetTeamServerGlobalValue(context, ScriptLib.GetSceneOwnerUid(context),"SGV_Fungus_Burst_Count")
if bindSGV<global_infotwo.max_skill_count then
ScriptLib.AddTeamServerGlobalValue(context, context.owner_uid, "SGV_Fungus_Burst_Count", 1)
end
return 0
end
------ conditions & actions ------
--group加载
function action_EVENT_GROUP_LOAD_QUEST(context, evt)
PrintLog_Quest(context, "group load")
ScriptLib.SetGroupVariableValue(context, "enemyCount", 0)
ScriptLib.SetGroupVariableValue(context, "partnerCount", 0)
ScriptLib.SetGroupVariableValue(context, "currentQuest", 0)
return 0
end
function action_EVENT_SPECIFIC_MONSTER_HP_CHANGE(context, evt)
--如果不是最后一关的话,不处理
if ScriptLib.GetGroupVariableValue(context, "currentQuest") ~= 4008514 then
return 0
end
if evt.param3<10 then
ScriptLib.AddQuestProgress(context, "Q"..tonumber(4008514).."1")
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 1})
end
return 0
end
function action_EVENT_QUEST_FINISH(context, evt)
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 1})
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.RevokePlayerShowTemplateReminder(context, 212, {hostUid})
ScriptLib.EndTimeAxis(context,"AwardBallGenerate")
ScriptLib.EndTimeAxis(context,"FungusWaterDie")
if create_partner_fungus[evt.param1]==nil and create_enemy_fungus[evt.param1]==nil then
return 0
end
--不管成功失败都要清场
local monsterList=ScriptLib.GetGroupAliveMonsterList(context, base_info.group_id)
for k,v in pairs(monsterList) do
ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.MONSTER, v)
end
PrintLog_Quest(context, "quest finish:"..evt.param1)
return 0
end
function action_EVENT_DUNGEON_ALL_AVATAR_DIE(context, evt)
--地城失败
ScriptLib.CauseDungeonFail(context)
return 0
end
function action_EVENT_QUEST_START(context, evt)
PrintLog_Quest(context, "quest start:"..evt.param1)
--重置team上的GV值
LF_ResetAllTeamGlobalValueFlags(context)
if 0==ScriptLib.GetGroupVariableValue(context, "currentQuest") then
--创建友方的蕈兽
if create_partner_fungus[evt.param1]==nil then
return 0
else
ScriptLib.SetGroupVariableValue(context, "currentQuest",evt.param1)
--设置team的SGV
ScriptLib.SetTeamServerGlobalValue(context, context.owner_uid, "SGV_Fungus_Burst_Count", global_infotwo.max_skill_count)
local pointConfig={}
--按照选择结果创怪
if create_partner_fungus[evt.param1][1]==nil then
local fungusList=ScriptLib.GetCurFungusFighterPlotConfigIdList(context)
ScriptLib.SetGroupVariableValue(context, "partnerCount",#fungusList)
for i=1,#fungusList do
pointConfig=LF_GetPartnerBornPointConfig(i,room_two_quests,evt.param1)
if fungusList[i]==10001023 then
if evt.param1==4008514 then
ScriptLib.CreateMonster(context, {config_id=fungusList[i], delay_time=0, pos=pointConfig.pos,rot=pointConfig.rot,affix_list={5213,5237,5254,5253}})
--补一个团灭时间
ScriptLib.InitTimeAxis(context,"FungusWaterDie",{20},false)
else
ScriptLib.CreateMonster(context, {config_id=fungusList[i], delay_time=0, pos=pointConfig.pos,rot=pointConfig.rot,affix_list={5213,5238,5253}})
end
else
ScriptLib.CreateMonster(context, {config_id=fungusList[i], delay_time=0, pos=pointConfig.pos,rot=pointConfig.rot,affix_list={5213,5253}})
end
end
--按照配置创怪
else
ScriptLib.SetGroupVariableValue(context, "partnerCount",#create_partner_fungus[evt.param1])
for i=1,#create_partner_fungus[evt.param1] do
pointConfig=LF_GetPartnerBornPointConfig(i,room_two_quests,evt.param1)
if create_partner_fungus[evt.param1][i].config_id+10000000==10001023 then
if evt.param1==4008514 then
ScriptLib.CreateMonster(context, {config_id=create_partner_fungus[evt.param1][i].config_id+10000000, delay_time=0, pos=pointConfig.pos,rot=pointConfig.rot,affix_list={5213,5237,5254,5253}})
--补一个团灭时间
ScriptLib.InitTimeAxis(context,"FungusWaterDie",{20},false)
else
ScriptLib.CreateMonster(context, {config_id=create_partner_fungus[evt.param1][i].config_id+10000000, delay_time=0, pos=pointConfig.pos,rot=pointConfig.rot,affix_list={5213,5238,5253}})
end
else
ScriptLib.CreateMonster(context, {config_id=create_partner_fungus[evt.param1][i].config_id+10000000, delay_time=0, pos=pointConfig.pos,rot=pointConfig.rot,affix_list={5213,5253}})
end
end
end
--最后开产球时间轴
ScriptLib.InitTimeAxis(context,"AwardBallGenerate",{global_infotwo.awardball_cd},true)
end
--创建敌方的蕈兽
if create_enemy_fungus[evt.param1]==nil then
return 0
else
if create_enemy_fungus[evt.param1][1]==nil then
--说明要刷愚人众了
ScriptLib.SetGroupVariableValue(context, "enemyCount",defs.total_count)
ScriptLib.AutoMonsterTide(context, 1,base_info.group_id , defs.monster_tide, defs.total_count, defs.min_count, defs.max_count)
else
--普通刷怪
local enemyPointConfig={}
ScriptLib.SetGroupVariableValue(context, "enemyCount",#create_enemy_fungus[evt.param1])
for i=1,#create_enemy_fungus[evt.param1] do
if LF_ContainsKey(room_two_quests,evt.param1) then
enemyPointConfig=LF_GetPointConfig(enemy_fungus_born_points_two[i])
else
enemyPointConfig=LF_GetPointConfig(enemy_fungus_born_points[i])
end
ScriptLib.CreateMonster(context, {config_id=create_enemy_fungus[evt.param1][i].config_id+10000000, delay_time=0, pos=enemyPointConfig.pos,rot=enemyPointConfig.rot,affix_list=create_enemy_fungus[evt.param1][i].affix or {}})
end
end
end
end
--最后要开镜头
for k,v in pairs(defs.camGadget) do
ScriptLib.CreateGadget(context, { config_id = v })
end
return 0
end
function action_EVENT_ANY_MONSTER_DIE_QUEST(context, evt)
local currentQuest=ScriptLib.GetGroupVariableValue(context, "currentQuest")
if evt.param4==6 then
local left_partner=ScriptLib.GetGroupVariableValue(context, "partnerCount")
left_partner=left_partner-1
ScriptLib.SetGroupVariableValue(context, "partnerCount",left_partner)
if left_partner==0 then
PrintLog_Quest(context, "发任务消息:".."Q"..currentQuest.."0")
ScriptLib.AddQuestProgress(context, "Q"..currentQuest.."0")
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 1})
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.RevokePlayerShowTemplateReminder(context, 212, {hostUid})
ScriptLib.EndTimeAxis(context,"AwardBallGenerate")
ScriptLib.EndTimeAxis(context,"FungusWaterDie")
end
else
local left_enemy=ScriptLib.GetGroupVariableValue(context, "enemyCount")
left_enemy=left_enemy-1
ScriptLib.SetGroupVariableValue(context, "enemyCount",left_enemy)
if left_enemy==0 then
PrintLog_Quest(context, "发任务消息:".."Q"..currentQuest.."1")
ScriptLib.AddQuestProgress(context, "Q"..currentQuest.."1")
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 1})
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.RevokePlayerShowTemplateReminder(context, 212, {hostUid})
ScriptLib.EndTimeAxis(context,"AwardBallGenerate")
ScriptLib.EndTimeAxis(context,"FungusWaterDie")
end
end
return 0
end
--产球
function action_EVENT_TIME_AXIS_PASS(context, evt)
PrintLog_Quest(context, "时间轴触发"..evt.source_name)
if evt.source_name=="AwardBallGenerate" then
local currentQuest=ScriptLib.GetGroupVariableValue(context, "currentQuest")
if LF_ContainsKey(room_two_quests,currentQuest) then
if awardball_room_two~=nil then
local index=LF_Random(context,#awardball_room_two)
local pointConfig=LF_GetPointConfig(awardball_room_two[index])
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.awardball_configid, pointConfig.pos, {x=0,y=0,z=0})
end
else
if awardball_room_one~=nil then
local index=LF_Random(context,#awardball_room_one)
local pointConfig=LF_GetPointConfig(awardball_room_one[index])
ScriptLib.CreateGadgetByConfigIdByPos(context, defs.awardball_configid, pointConfig.pos, {x=0,y=0,z=0})
end
end
end
if evt.source_name=="FungusWaterDie" then
ScriptLib.AddQuestProgress(context, "Q"..tonumber(4008514).."1")
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 1})
end
return 0
end
function action_EVENT_GADGET_CREATE(context, evt)
if evt.param2 == global_infotwo.awardball_gadget_id then
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.AssignPlayerShowTemplateReminder(context,212,{is_need_cache=true, param_uid_vec={},param_vec={},uid_vec={hostUid}})
end
return 0
end
function action_EVENT_ANY_GADGET_DIE(context, evt)
if evt.param1==defs.awardball_configid then
PrintLog_Quest(context, "助威球死亡")
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.RevokePlayerShowTemplateReminder(context, 212, {hostUid})
end
return 0
end
function action_EVENT_DUNGEON_AVATAR_SLIP_DIE(context, evt)
if ScriptLib.GetGroupVariableValue(context, "currentQuest") ~= 0 then
--地城失败 20220922先不改。beta观察一下
--ScriptLib.CauseDungeonFail(context)
end
return 0
end
LF_Initialize_QuestLevel()

View File

@ -0,0 +1,594 @@
--[[======================================
|| filename: Activity_CatchMushroomMonster
|| owner: chen.chen
|| description:
|| LogName: TD
|| Protection: [Protection]
=======================================]]
--[[
local mushroomBeastInfo =
{
[1]={configId=85006,maxProgress=300,normal=10,active=20,dieOut=30,patrolRoute={1,2,3,4,5,6}},
[2]={configId=85007,maxProgress=300,normal=10,active=20,dieOut=30,patrolRoute={7,8,9,10,11,12,13}}
}
local groupInfo =
{
pointArrayId = 110200025,
}
]]
local globalInfo =
{
maxProgress=1200,
empiricalParamOne=0,
empiricalParamTwo=1,
fungustype={
air={26090191,26090291,26090292,26090391},
ground={26090491,26090591,26090691},
stretch={26090791,26090891,26090991,26091091},
}
}
-- 打印日志
function PrintLog(context, content)
local log = "## [Activity_CatchMushroomMonster] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ config_id = 40000001, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
{ config_id = 40000002, name = "enter_region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", trigger_count = 0 },
{ config_id = 40000003, name = "leave_region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_EVENT_LEAVE_REGION", trigger_count = 0 },
{ config_id = 40000004, name = "platform_arrival", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_EVENT_PLATFORM_ARRIVAL", trigger_count = 0 },
{ config_id = 40000005, name = "time_axis_pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_EVENT_TIME_AXIS_PASS", trigger_count = 0},
{ config_id = 40000006, name = "gallery_start", event = EventType.EVENT_GALLERY_START, source = "", condition = "", action = "action_EVENT_GALLERY_START", trigger_count = 0},
{ config_id = 40000007, name = "gallery_stop", event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_EVENT_GALLERY_STOP", trigger_count = 0},
{ config_id = 40000008, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0},
{ config_id = 40000009, name = "group_will_unload", event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_EVENT_GROUP_WILL_UNLOAD", trigger_count = 0},
}
------ Local Functions -----------
function LF_Initialize_Level()
--- TRIGGER
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggers) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
for k,v in pairs(mushroomBeastInfo) do
--标记蕈兽是否正在受到惊吓状态
table.insert(variables,{ config_id=50000000+v.configId,name = v.configId.."isAlert", value = 0})
--标记蕈兽当前的移动目标位置
table.insert(variables,{ config_id=52000000+v.configId,name = v.configId.."targetPoint", value = 0})
--标记蕈兽移动过程的出发位置
table.insert(variables,{ config_id=53000000+v.configId,name = v.configId.."startPoint", value = 0})
end
table.insert(variables,{ config_id=51000000,name = "has_succeeded", value = 0, no_refresh = true})
return 0
end
--判断是那种类型的蕈兽
function LF_GetFungusType(context,monsterId)
for i=1,#globalInfo.fungustype.air do
if globalInfo.fungustype.air[i]==monsterId then
return 1
end
end
for i=1,#globalInfo.fungustype.ground do
if globalInfo.fungustype.ground[i]==monsterId then
return 2
end
end
for i=1,#globalInfo.fungustype.stretch do
if globalInfo.fungustype.stretch[i]==monsterId then
return 3
end
end
return 0
end
--设置蕈兽路径
function LF_SetFungusRoute(context,fungusConfigId,pointArrayId,routePoints,route_type)
local fungusEntityId=ScriptLib.GetEntityIdByConfigId(context, fungusConfigId)
local fungusMonsterId=ScriptLib.GetMonsterIdByEntityId(context, fungusEntityId)
local fungusType=LF_GetFungusType(context,fungusMonsterId)
if fungusType==0 then
PrintLog(context, "蕈兽怪物id不在任何分类中")
elseif fungusType==1 then
ScriptLib.SetPlatformPointArray(context, fungusConfigId, pointArrayId, routePoints, { route_type = route_type,speed_level=2 })
elseif fungusType==2 then
ScriptLib.SetPlatformPointArray(context, fungusConfigId, pointArrayId, routePoints, { route_type = route_type,speed_level=1 })
elseif fungusType==3 then
ScriptLib.SetPlatformPointArray(context, fungusConfigId, pointArrayId, routePoints, { route_type = route_type })
end
return 0
end
--设置逃跑目标点
function LF_SetAlertBeastTarget(context,inputConfigId)
for k,v in pairs(mushroomBeastInfo) do
if v.configId==inputConfigId then
ScriptLib.SetGroupVariableValue(context, inputConfigId.."isAlert",1)
local avatarEntity=ScriptLib.GetAvatarEntityIdByUid(context,context.owner_uid)
PrintLog(context,"avatar entity"..avatarEntity)
local monsterEid = ScriptLib.GetEntityIdByConfigId(context, inputConfigId)
local maxDistance=0
local targetPoint=0
for a,b in pairs(v.patrolRoute) do
local tempScore=globalInfo.empiricalParamOne*LF_CalculateXZDistance(context,avatarEntity,b)+globalInfo.empiricalParamTwo*LF_CalculateIntersectionAngle(context,monsterEid,b)
if tempScore>maxDistance and LF_CheckPointIsValid(context,b,v.configId) then
maxDistance=tempScore
targetPoint=b
end
end
if targetPoint~=0 then
PrintLog(context,"逃逸目标点"..targetPoint)
if ScriptLib.GetGroupVariableValue(context, v.configId.."targetPoint") ~= targetPoint then
LF_SetFungusRoute(context,inputConfigId,groupInfo.pointArrayId,{targetPoint},0)
ScriptLib.SetGroupVariableValue(context, v.configId.."targetPoint",targetPoint)
end
end
end
end
return 0
end
--检测点是否合法
--1.目标点距离蕈兽位置必须有一定距离暂定大于5
--2.目标点距离玩家位置也需要有一定距离暂定大于7
function LF_CheckPointIsValid(context,pointId,fungusConfigId)
local isValid=true
if ScriptLib.GetGroupVariableValue(context, fungusConfigId.."startPoint") == pointId then
isValid=false
end
if ScriptLib.GetGroupVariableValue(context, fungusConfigId.."targetPoint") ~= 0 then
return isValid
end
local fungusEntityId = ScriptLib.GetEntityIdByConfigId(context, fungusConfigId)
local avatarEntity=ScriptLib.GetAvatarEntityIdByUid(context,ScriptLib.GetSceneOwnerUid(context))
if LF_CalculateXZDistance(context,fungusEntityId,pointId) <= 5 then
isValid=false
end
if LF_CalculateXZDistance(context,avatarEntity,pointId) <= 7 then
isValid=false
end
return isValid
end
--规划一条新路径
function LF_CreateNewRoute(context,inputConfigId,inputPoint)
for k,v in pairs(mushroomBeastInfo) do
if v.configId==inputConfigId then
for i=1, #v.patrolRoute do
if v.patrolRoute[i]==inputPoint then
local newRoute={}
for j=i+1,#v.patrolRoute do
table.insert(newRoute, v.patrolRoute[j])
end
for k=1,i do
table.insert(newRoute, v.patrolRoute[k])
end
LF_SetFungusRoute(context,inputConfigId,groupInfo.pointArrayId,newRoute,2)
break
end
end
end
end
return 0
end
--计算两entity的XZ平面距离
function LF_CalculateXZDistance(context,entityId,pointId,entityIdTwo)
local pos1=ScriptLib.GetPosByEntityId(context, entityId)
local pos2={}
if pointId~=0 then
local arrayPointRet,arrayPointPos,arrayPointRot=ScriptLib.GetPlatformArrayInfoByPointId(context, groupInfo.pointArrayId, pointId)
pos2={x=arrayPointPos.x,y=arrayPointPos.y,z=arrayPointPos.z}
else
pos2=ScriptLib.GetPosByEntityId(context, entityIdTwo)
end
local distance=math.sqrt((pos1.x-pos2.x)*(pos1.x-pos2.x)+(pos1.z-pos2.z)*(pos1.z-pos2.z))
return distance
end
--计算蕈兽指向玩家向量和指向路点向量的夹角
function LF_CalculateIntersectionAngle(context,fungusEntityId,pointId)
local angle=0
local avatarEntityId=ScriptLib.GetAvatarEntityIdByUid(context,ScriptLib.GetSceneOwnerUid(context))
local fungusPos=ScriptLib.GetPosByEntityId(context, fungusEntityId)
local avatarPos=ScriptLib.GetPosByEntityId(context, avatarEntityId)
local arrayPointRet,arrayPointPos,arrayPointRot=ScriptLib.GetPlatformArrayInfoByPointId(context, groupInfo.pointArrayId, pointId)
local pointPos={x=arrayPointPos.x,y=arrayPointPos.y,z=arrayPointPos.z}
--蕈兽指向玩家
local vectorOne={x=avatarPos.x-fungusPos.x,y=avatarPos.y-fungusPos.y,z=avatarPos.z-fungusPos.z}
--蕈兽指向目标点
local vectorTwo={x=pointPos.x-fungusPos.x,y=pointPos.y-fungusPos.y,z=pointPos.z-fungusPos.z}
return LF_CalculateXZRotate(context,vectorOne.x,vectorOne.y,vectorTwo.x,vectorTwo.y)
end
--计算XZ平面上两个向量的夹角
function LF_CalculateXZRotate(context,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))
local output=math.abs(180-(180-rotate)%360)
--PrintLog(context, "计算夹角"..output)
return output
end
--蕈兽是否存活
function LF_MonsterIsAlive(context,configId)
local monsterList=ScriptLib.GetGroupAliveMonsterList(context, base_info.group_id)
--PrintLog(context,"存活怪物数量:"..#monsterList)
for _,v in pairs(monsterList) do
if v==configId then
return true
end
end
return false
end
--判断蕈兽是否在圈内
function LF_IsFungusInRegion(context,configId,regionId)
local region={}
for i = 1, #regions do
if regions[i].config_id == regionId then
region = regions[i]
break
end
end
local monster_eid = ScriptLib.GetEntityIdByConfigId(context, configId)
local pos1 = ScriptLib.GetPosByEntityId(context, monster_eid)
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
PrintLog(context, "蕈兽出圈判定逻辑错误")
return false
end
--获取蕈兽的monsterid
function LF_GetFungusMonsterId(context,configId)
for k,v in pairs(monsters) do
if v.config_id==configId then
return v.monster_id
end
end
return 0
end
--初始化蕈兽行为
function LF_InitFungusBehaviour(context,v)
local fungusMonsterId=LF_GetFungusMonsterId(context,v.configId)
local isCaptured=ScriptLib.IsFungusCaptured(context, ScriptLib.GetSceneOwnerUid(context) ,fungusMonsterId)
PrintLog(context, "查询蕈兽捕捉情况:"..v.configId.."|"..tostring(isCaptured))
if isCaptured==0 then
--ScriptLib.KillEntityByConfigId(context, { config_id = v.configId,entity_type=EntityType.MONSTER })
ScriptLib.CreateMonster(context, {config_id=v.configId, delay_time=0, server_global_value={["SGV_MushroomMonster_Alert"]=0}})
elseif isCaptured==-1 then
PrintLog(context,"查询蕈兽捕捉失败:"..v.configId)
end
if LF_MonsterIsAlive(context,v.configId) then
ScriptLib.SetGroupVariableValue(context, v.configId.."isAlert",0)
ScriptLib.SetGroupVariableValue(context, v.configId.."targetPoint",0)
ScriptLib.SetGroupVariableValue(context, v.configId.."startPoint",0)
--7.28迭代,不寻路
--LF_SetFungusRoute(context,v.configId,groupInfo.pointArrayId,v.patrolRoute,2)
end
return 0
end
--判断是否所有蕈兽都已被捕捉
function LF_AFungusCatched(context)
local allBeastsDead=true
for k,v in pairs(mushroomBeastInfo) do
if LF_MonsterIsAlive(context,v.configId) then
allBeastsDead=false
break
end
end
return allBeastsDead
end
function LF_GallerySuccess(context)
ScriptLib.StopGallery(context,defs.gallery_id,false)
ScriptLib.SetGroupVariableValue(context, "has_succeeded",1)
--20220916时序问题交给服务器处理了
--ScriptLib.FinishGroupLinkBundle(context, base_info.group_id)
return 0
end
------ Server Lua Call Functions -----------
--使用E技能的SLC埋点用
function SLC_AvatarUseCatchWidget(context)
--埋点
ScriptLib.MarkGroupLuaAction(context, "FungusFighter_4",ScriptLib.GetGalleryTransaction(context, defs.gallery_id) , {})
return 0
end
--怪物受惊通知group开始逃跑
function SLC_MushroomMonsterAlert(context)
PrintLog(context,"蕈兽受到惊吓")
--进入惊吓状态
local beast = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id })
--local beast = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
ScriptLib.SetEntityServerGlobalValueByConfigId(context, beast, "SGV_MushroomMonster_Alert", 1)
LF_SetAlertBeastTarget(context,beast)
return 0
end
--怪物被打到,通知加分
function SLC_MushroomMonsterCatch(context,param1)
PrintLog(context,"蕈兽被命中")
local beast = ScriptLib.GetMonsterConfigId(context, { monster_eid = context.source_entity_id })
--local beast = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
--ScriptLib.ChangeGroupVariableValue(context, beast.."progress", 100)
local maxProgress=globalInfo.maxProgress
local addProgress=-1
local monsterId=ScriptLib.GetMonsterIdByEntityId(context, context.source_entity_id)
--埋点
local isFinished=0
if monsterId~=nil then
PrintLog(context,"蕈兽monsterid"..monsterId)
else
PrintLog(context,"蕈兽monsterid为空")
end
local curProgress=ScriptLib.GetGalleryProgressScore(context,tostring(monsterId),defs.gallery_id)
--数据校验
if curProgress==-1 then
PrintLog(context,"蕈兽抓捕值获取失败")
return 0
end
for k,v in pairs(mushroomBeastInfo) do
if v.configId==beast then
if param1==0 then
addProgress=v.normal
elseif param1==1 then
addProgress=v.active
elseif param1==2 then
addProgress=v.dieOut
else
PrintLog(context,"蕈兽三态获取失败")
end
break
end
end
--尝试结算gallery
if curProgress+addProgress >= maxProgress then
if ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["group_id"]=base_info.group_id,["config_id"]=beast})==0 then
PrintLog(context,"蕈兽抓捕结果成功")
ScriptLib.AddGalleryProgressScore(context, tostring(monsterId), defs.gallery_id, addProgress)
ScriptLib.KillEntityByConfigId(context, { config_id = beast,entity_type=EntityType.MONSTER })
PrintLog(context,"kill蕈兽成功")
--看下是不是所有蕈兽都抓住了
if LF_AFungusCatched(context) then
isFinished=1
--埋点
ScriptLib.MarkGroupLuaAction(context, "FungusFighter_2",ScriptLib.GetGalleryTransaction(context, defs.gallery_id) , {["monster_id"] = monsterId,["cur_progress"]=curProgress+addProgress,["total_progress"]=maxProgress,["is_finish"]=isFinished})
LF_GallerySuccess(context)
return 0
end
--埋点
ScriptLib.MarkGroupLuaAction(context, "FungusFighter_2",ScriptLib.GetGalleryTransaction(context, defs.gallery_id) , {["monster_id"] = monsterId,["cur_progress"]=curProgress+addProgress,["total_progress"]=maxProgress,["is_finish"]=isFinished})
return 0
else
PrintLog(context,"蕈兽抓捕结果上传失败")
end
else
ScriptLib.AddGalleryProgressScore(context, tostring(monsterId), defs.gallery_id, addProgress)
PrintLog(context,"分值"..curProgress+addProgress.."/"..maxProgress)
--埋点
ScriptLib.MarkGroupLuaAction(context, "FungusFighter_2",ScriptLib.GetGalleryTransaction(context, defs.gallery_id) , {["monster_id"] = monsterId,["cur_progress"]=curProgress+addProgress,["total_progress"]=maxProgress,["is_finish"]=isFinished})
return 0
end
return 0
end
------ conditions & actions ------
--活动结束保底
function action_EVENT_GROUP_WILL_UNLOAD(context, evt)
if ScriptLib.IsGalleryStart(context,defs.gallery_id) then
ScriptLib.StopGalleryByReason(context,defs.gallery_id,5)
end
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.EndTimeAxis(context,"itemCheck")
ScriptLib.SetGroupTempValue(context,"templateReminderShow",0,{})
ScriptLib.RevokePlayerShowTemplateReminder(context, 204, {hostUid})
return 0
end
--group加载
function action_EVENT_GROUP_LOAD(context, evt)
PrintLog(context, "group load")
if ScriptLib.CheckIsInMpMode(context) or ScriptLib.GetGroupVariableValue(context, "has_succeeded") == 1 then
PrintLog(context,"联机模式或玩法已完成,玩法不做初始化")
return 0
else
for k,v in pairs(mushroomBeastInfo) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.MONSTER, v.configId)
LF_InitFungusBehaviour(context,v)
end
end
ScriptLib.SetGroupTempValue(context,"templateReminderShow",0,{})
--把region加起来
ScriptLib.AddExtraGroupSuite(context, 0, 2)
--保护逻辑,检测蕈兽出圈刷新,同时也处理蕈兽的寻路目标问题
ScriptLib.InitTimeAxis(context,"fungusCheck",{1},true)
return 0
end
--玩家进入玩法区域
function action_EVENT_ENTER_REGION(context, evt)
PrintLog(context, "enter play region")
if evt.param1 ~= defs.play_region then
return 0
end
if ScriptLib.CheckIsInMpMode(context) then
PrintLog(context,"联机模式下进圈不开gallery")
ScriptLib.ShowReminder(context, 400211)
return 0
end
--进圈的不是主机,就啥也不干
if context.uid~=ScriptLib.GetSceneOwnerUid(context) then
return 0
end
--增补,如果玩法已完成,则不再开启玩法
if ScriptLib.GetGroupVariableValue(context, "has_succeeded") == 1 then
PrintLog(context,"玩法已完成,玩法不做初始化")
return 0
end
--主机进圈开gallery
if not ScriptLib.IsGalleryStart(context,defs.gallery_id) then
if (ScriptLib.SetPlayerStartGallery(context, defs.gallery_id, {ScriptLib.GetSceneOwnerUid(context)}) ~= 0) then
return 0
end
for k,v in pairs(mushroomBeastInfo) do
local monsterId=LF_GetFungusMonsterId(context,v.configId)
if LF_MonsterIsAlive(context,v.configId)==false then
ScriptLib.InitGalleryProgressWithScore(context, tostring(monsterId), defs.gallery_id, {0,globalInfo.maxProgress},globalInfo.maxProgress, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_DIG,GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NONE)
PrintLog(context, "怪物:"..v.configId.."已捕获")
else
ScriptLib.InitGalleryProgressWithScore(context, tostring(monsterId), defs.gallery_id, {0,globalInfo.maxProgress},0, GalleryProgressScoreUIType.GALLERY_PROGRESS_SCORE_UI_TYPE_DIG,GalleryProgressScoreType.GALLERY_PROGRESS_SCORE_NONE)
PrintLog(context, "怪物:"..v.configId.."未捕获")
end
end
end
--看下是不是所有蕈兽都抓住了,是的话刷新一次结算
if LF_AFungusCatched(context) then
LF_GallerySuccess(context)
end
return 0
end
--玩家离开玩法区域
function action_EVENT_LEAVE_REGION(context, evt)
if evt.param1 ~= defs.exit_region then
return 0
end
PrintLog(context, "leave play region")
--出圈的不是主机,就啥也不干
if context.uid~=ScriptLib.GetSceneOwnerUid(context) then
return 0
end
if ScriptLib.GetGroupVariableValue(context, "has_succeeded") ~= 1 then
--埋点
ScriptLib.MarkGroupLuaAction(context, "FungusFighter_3",ScriptLib.GetGalleryTransaction(context, defs.gallery_id) , {})
end
if ScriptLib.IsGalleryStart(context,defs.gallery_id) then
ScriptLib.StopGalleryByReason(context,defs.gallery_id,5)
end
return 0
end
--蕈兽到达路点 evt.param3:点阵的点
function action_EVENT_PLATFORM_ARRIVAL(context, evt)
PrintLog(context, "platform arrival")
if ScriptLib.GetGroupVariableValue(context, evt.param1.."isAlert") == 1 then
ScriptLib.SetGroupVariableValue(context, evt.param1.."isAlert",0)
ScriptLib.SetGroupVariableValue(context, evt.param1.."startPoint",ScriptLib.GetGroupVariableValue(context, evt.param1.."targetPoint"))
ScriptLib.SetGroupVariableValue(context, evt.param1.."targetPoint",0)
ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_MushroomMonster_Alert", 0)
--分配新路径,7.28迭代,暂不分配新路径
--LF_CreateNewRoute(context,evt.param1,evt.param3)
end
return 0
end
--时间轴处理tick逻辑
function action_EVENT_TIME_AXIS_PASS(context, evt)
if evt.source_name=="itemCheck" then
local hostUid=ScriptLib.GetSceneOwnerUid(context)
--如果没装小道具且没显示,提示
if (not ScriptLib.IsWidgetEquipped(context, hostUid, 220073)) and ScriptLib.GetGroupTempValue(context,"templateReminderShow",{})==0 then
PrintLog(context, "提示装小道具")
ScriptLib.AssignPlayerShowTemplateReminder(context,204,{param_uid_vec={},param_vec={},uid_vec={hostUid}})
ScriptLib.SetGroupTempValue(context,"templateReminderShow",1,{})
end
--如果装了小道具且正在显示,去掉提示
if ScriptLib.IsWidgetEquipped(context, hostUid, 220073) and ScriptLib.GetGroupTempValue(context,"templateReminderShow",{})==1 then
PrintLog(context, "下掉提示装小道具")
ScriptLib.RevokePlayerShowTemplateReminder(context, 204, {hostUid})
ScriptLib.SetGroupTempValue(context,"templateReminderShow",0,{})
end
end
--检测蕈兽是否出圈
if evt.source_name=="fungusCheck" then
--检测受惊蕈兽的逃跑目标点
for k,v in pairs(mushroomBeastInfo) do
if ScriptLib.GetGroupVariableValue(context, v.configId.."isAlert") == 1 then
local fungusEntityId = ScriptLib.GetEntityIdByConfigId(context, v.configId)
local avatarEntity=ScriptLib.GetAvatarEntityIdByUid(context,ScriptLib.GetSceneOwnerUid(context))
--只有周围有人的时候才尝试修改位置
if LF_CalculateXZDistance(context,fungusEntityId,0,avatarEntity) <= 5 then
LF_SetAlertBeastTarget(context,v.configId)
end
end
end
--检测蕈兽出界
for k,v in pairs(mushroomBeastInfo) do
if LF_MonsterIsAlive(context,v.configId) then
if LF_IsFungusInRegion(context,v.configId,defs.play_region)==false then
PrintLog(context, "蕈兽出界重置:"..v.configId)
--ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.MONSTER, v.configId)
--LF_InitFungusBehaviour(context,v)
ScriptLib.KillEntityByConfigId(context, { config_id = v.configId,entity_type=EntityType.MONSTER })
end
end
end
end
return 0
end
function action_EVENT_GALLERY_START(context, evt)
PrintLog(context, "event gallery start")
--埋点
ScriptLib.MarkGroupLuaAction(context, "FungusFighter_1",ScriptLib.GetGalleryTransaction(context, defs.gallery_id) , {})
--起提醒用的时间轴
ScriptLib.InitTimeAxis(context,"itemCheck",{1},true)
return 0
end
function action_EVENT_GALLERY_STOP(context, evt)
PrintLog(context, "event gallery stop")
--关时间轴
local hostUid=ScriptLib.GetSceneOwnerUid(context)
ScriptLib.EndTimeAxis(context,"itemCheck")
ScriptLib.SetGroupTempValue(context,"templateReminderShow",0,{})
ScriptLib.RevokePlayerShowTemplateReminder(context, 204, {hostUid})
return 0
end
function action_EVENT_ANY_MONSTER_DIE(context, evt)
PrintLog(context, "monster die")
--如果蕈兽意外死亡,重置一下
for k,v in pairs(mushroomBeastInfo) do
if v.configId==evt.param1 then
LF_InitFungusBehaviour(context,v)
end
end
return 0
end
LF_Initialize_Level()

View File

@ -0,0 +1,157 @@
--[[======================================
|| filename: Boss_Battle_Process_Scaramouche
|| owner: chen.chen
|| description: BOSS战流程
|| LogName: TD
|| Protection: [Protection]
=======================================]]
local bossMonsterId=
{
29070101,
29070102,
29070103,
29070104,
29070105
}
-- 打印日志
function PrintLog(context, content)
local log = "## [Boss_Battle_Process_Scaramouche] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ config_id = 40000001, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0 },
{ config_id = 40000002, name = "time_axis_pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_EVENT_TIME_AXIS_PASS", trigger_count = 0},
{ config_id = 40000003, name = "monster_alive", event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_LIVE", trigger_count = 0 },
{ config_id = 40000004, name = "monster_battle", event = EventType.EVENT_MONSTER_BATTLE, source = "", condition = "", action = "action_EVENT_MONSTER_BATTLE", trigger_count = 0 },
{ config_id = 40000005, name = "enter_region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_EVENT_ENTER_REGION", forbid_guest = false,trigger_count = 0 },
}
------ Local Functions -----------
function LF_Initialize_Level()
--- TRIGGER
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggers) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
return 0
end
function LF_IsBossMonster(context,monsterId)
for k,v in pairs(bossMonsterId) do
if v==monsterId then
return true
end
end
return false
end
------ Server Lua Call Functions -----------
------ conditions & actions ------
--时间轴触发传送
function action_EVENT_TIME_AXIS_PASS(context, evt)
if evt.source_name=="PlayCutScene" then
for k,v in pairs(points) do
if v.config_id==defs.transTarget then
ScriptLib.TransPlayerToPos(context, {uid_list = ScriptLib.GetSceneUidList(context), pos = v.pos, radius = 2, rot = v.rot})
ScriptLib.DelSceneTag(context, 20154, 1179)
ScriptLib.AddSceneTag(context, 20154 ,1180)
end
end
ScriptLib.InitTimeAxis(context,"YAxisCheck",{5},true)
PrintLog(context, "没找到传送目标点")
end
if evt.source_name=="ShowReminder" then
local uidList=ScriptLib.GetSceneUidList(context)
local transUid={}
for k,v in pairs(uidList) do
if ScriptLib.IsInRegion(context, v, defs.phaseOneRegion)==false then
table.insert(transUid,v)
end
end
for a,b in pairs(points) do
if b.config_id==defs.bossBattleTransPoint then
if #transUid>0 then
ScriptLib.TransPlayerToPos(context, {uid_list = transUid, pos = b.pos, radius = 2, rot = b.rot})
end
end
end
end
if evt.source_name=="YAxisCheck" then
local uidList=ScriptLib.GetSceneUidList(context)
for a,b in pairs(uidList) do
local entity=ScriptLib.GetAvatarEntityIdByUid(context, b)
local pos=ScriptLib.GetPosByEntityId(context, entity)
if pos.y>= 0 then
for k,v in pairs(points) do
if v.config_id==defs.transTarget then
ScriptLib.TransPlayerToPos(context, {uid_list = {b}, pos = v.pos, radius = 2, rot = v.rot})
end
end
end
end
end
return 0
end
function action_EVENT_MONSTER_BATTLE(context, evt)
if evt.param1==defs.phaseOneBoss then
--起提示
local uidList=ScriptLib.GetSceneUidList(context)
for k,v in pairs(uidList) do
if ScriptLib.IsInRegion(context, v, defs.phaseOneRegion)==false then
ScriptLib.AssignPlayerShowTemplateReminder(context,214,{param_uid_vec={},param_vec={},uid_vec={v}})
end
end
--起时间轴
ScriptLib.InitTimeAxis(context,"ShowReminder",{10},true)
end
return 0
end
function action_EVENT_ENTER_REGION(context, evt)
ScriptLib.RevokePlayerShowTemplateReminder(context, 214, {context.uid})
return 0
end
function action_EVENT_ANY_MONSTER_LIVE(context, evt)
--进入方法的log
PrintLog(context, "monster alive:"..evt.param1)
local monsterEntityId=ScriptLib.GetEntityIdByConfigId(context, evt.param1)
local monsterId=ScriptLib.GetMonsterIdByEntityId(context, monsterEntityId)
if LF_IsBossMonster(context,monsterId) then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_MONSTER_NADA", 1)
end
return 0
end
--boss一阶段死亡传到下面去
function action_EVENT_ANY_MONSTER_DIE(context, evt)
if evt.param1==defs.phaseOneBoss then
local uidList=ScriptLib.GetSceneUidList(context)
if #uidList<=1 then
ScriptLib.PlayCutScene(context, 201520002, 0)
end
ScriptLib.InitTimeAxis(context,"PlayCutScene",{2},false)
--回收一阶段的时间轴
ScriptLib.EndTimeAxis(context,"ShowReminder")
--回收所有的reminder
for k,v in pairs(uidList) do
ScriptLib.RevokePlayerShowTemplateReminder(context, 214, {v})
end
end
return 0
end
LF_Initialize_Level()

View File

@ -0,0 +1,169 @@
--[[======================================
|| filename: Boss_Battle_Process_Scaramouche_Quest
|| owner: chen.chen
|| description: BOSS战流程-
|| LogName: TD
|| Protection: [Protection]
=======================================]]
local bossMonsterId=
{
29070101,
29070102,
29070103,
29070104,
29070105
}
-- 打印日志
function PrintLog(context, content)
local log = "## [Boss_Battle_Process_Scaramouche_Quest] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ config_id = 40000001, name = "monster_die", event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_DIE", trigger_count = 0 },
{ config_id = 40000002, name = "quest_finish", event = EventType.EVENT_QUEST_FINISH, source = "", condition = "", action = "action_EVENT_QUEST_FINISH", trigger_count = 0 },
{ config_id = 40000003, name = "quest_start", event = EventType.EVENT_QUEST_START, source = "", condition = "", action = "action_EVENT_QUEST_START", trigger_count = 0 },
{ config_id = 40000004, name = "monster_alive", event = EventType.EVENT_ANY_MONSTER_LIVE, source = "", condition = "", action = "action_EVENT_ANY_MONSTER_LIVE", trigger_count = 0 },
{ config_id = 40000005, name = "time_axis_pass", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_EVENT_TIME_AXIS_PASS", trigger_count = 0},
{ config_id = 40000006, name = "group_load", event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_EVENT_GROUP_LOAD", trigger_count = 0 },
}
------ Local Functions -----------
function LF_Initialize_Level()
--- TRIGGER
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggers) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
table.insert(variables,{ config_id=51000000,name = "bossCreated", value = 0, no_refresh = true})
return 0
end
function LF_IsBossMonster(context,monsterId)
for k,v in pairs(bossMonsterId) do
if v==monsterId then
return true
end
end
return false
end
------ Server Lua Call Functions -----------
function SLC_Scaramouche_All_Avatar_Die(context)
ScriptLib.AddQuestProgress(context, "302808")
return 0
end
function SLC_Scaramouche_All_Avatar_Die_Stage01(context)
ScriptLib.PlayCutScene(context, 201520001, 0)
ScriptLib.InitTimeAxis(context,"PlayCutScene",{2},false)
return 0
end
------ conditions & actions ------
--group加载时重置variable
function action_EVENT_GROUP_LOAD(context, evt)
ScriptLib.CreateGadget(context, { config_id = defs.gadget_music_change })
ScriptLib.SetGroupVariableValue(context, "bossCreated",0)
return 0
end
--时间轴触发传送
function action_EVENT_TIME_AXIS_PASS(context, evt)
if evt.source_name=="PlayCutScene" then
ScriptLib.AddQuestProgress(context, "302825")
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 2})
ScriptLib.CreateMonster(context, {config_id=defs.phaseTwoBoss or 0 , delay_time=0})
for k,v in pairs(points) do
if v.config_id==defs.transTarget then
ScriptLib.TransPlayerToPos(context, {uid_list = ScriptLib.GetSceneUidList(context), pos = v.pos, radius = 2, rot = v.rot})
ScriptLib.DelSceneTag(context, 20168, 1201)
ScriptLib.AddSceneTag(context, 20168 ,1202)
end
end
PrintLog(context, "没找到传送目标点")
ScriptLib.InitTimeAxis(context,"YAxisCheck",{5},true)
end
if evt.source_name=="YAxisCheck" then
local uidList=ScriptLib.GetSceneUidList(context)
for a,b in pairs(uidList) do
local entity=ScriptLib.GetAvatarEntityIdByUid(context, b)
local pos=ScriptLib.GetPosByEntityId(context, entity)
if pos.y>= 0 then
for k,v in pairs(points) do
if v.config_id==defs.transTarget then
ScriptLib.TransPlayerToPos(context, {uid_list = {b}, pos = v.pos, radius = 2, rot = v.rot})
end
end
end
end
end
return 0
end
--boss一阶段死亡传到下面去
function action_EVENT_ANY_MONSTER_DIE(context, evt)
if evt.param1==defs.phaseOneBoss then
ScriptLib.PlayCutScene(context, 201520001, 0)
ScriptLib.InitTimeAxis(context,"PlayCutScene",{2},false)
ScriptLib.SetGroupVariableValue(context, "bossCreated",1)
return 0
end
if evt.param1==defs.phaseThreeBoss then
ScriptLib.AddQuestProgress(context, "302810")
return 0
end
return 0
end
function action_EVENT_ANY_MONSTER_LIVE(context, evt)
--进入方法的log
PrintLog(context, "monster alive:"..evt.param1)
local monsterEntityId=ScriptLib.GetEntityIdByConfigId(context, evt.param1)
local monsterId=ScriptLib.GetMonsterIdByEntityId(context, monsterEntityId)
if LF_IsBossMonster(context,monsterId) then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, evt.param1, "SGV_MONSTER_NADA", 1)
end
return 0
end
function action_EVENT_QUEST_FINISH(context, evt)
--进入方法的log
PrintLog(context, "quest finish:"..evt.param1)
return 0
end
function action_EVENT_QUEST_START(context, evt)
--进入方法的log
PrintLog(context, "quest start:"..evt.param1)
--根据任务ID来决定做什么处理
--一开始隐藏一阶段boss听任务的创
if evt.param1==defs.questBossAppear then
if ScriptLib.GetGroupVariableValue(context,"bossCreated") == 0 then
ScriptLib.CreateMonster(context, {config_id=defs.phaseOneBoss or 0 , delay_time=0})
end
--团灭桥段时暂时remove二阶段boss
elseif evt.param1==defs.questAllAvatarDie then
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_music_change, 202)
--ScriptLib.RemoveEntityByConfigId(context, base_info.group_id, EntityType.MONSTER, defs.phaseTwoBoss)
--再开流程把二阶段boss再加回来
elseif evt.param1==defs.questAvatarRevive then
ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = 2})
ScriptLib.CreateMonster(context, {config_id=defs.phaseThreeBoss or 0 , delay_time=0})
ScriptLib.SetGadgetStateByConfigId(context, defs.gadget_music_change, 201)
end
return 0
end
LF_Initialize_Level()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,380 @@
--[[======================================
|| filename: HypostasisChallenge
|| owner: zhangchi.chen
|| description: 3.2
|| LogName: HypostasisChallenge
|| Protection:
=======================================]]--
local local_defs = {
worktop_option = 175,
}
local Tri = {
[1] = { name = "group_load", config_id = 40000000, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[2] = { name = "select_option", config_id = 40000001, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[3] = { name = "dungeon_all_avatar_die", config_id = 40000002, event = EventType.EVENT_DUNGEON_ALL_AVATAR_DIE, source = "", condition = "condition_dungeon_all_avatar_die", action = "action_dungeon_all_avatar_die", trigger_count = 0},
[4] = { name = "dungeon_any_monster_die", config_id = 40000003, event = EventType.EVENT_ANY_MONSTER_DIE, source = "", condition = "", action = "action_any_monster_die", trigger_count = 0},
[5] = { name = "leave_region", config_id = 40000004, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0},
[6] = { name = "tri_dungeon_settle", config_id = 40000005, event = EventType.EVENT_DUNGEON_SETTLE, source = "", condition = "", action = "action_dungeon_settle", trigger_count = 0},
[8] = { name = "time_axis_pass", config_id = 40000007, event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_time_axis_pass", trigger_count = 0 },
[11] = { name = "variable_change", config_id = 40000010, event = EventType.EVENT_VARIABLE_CHANGE, source = "GALLERY_STATE", condition = "", action = "action_variable_change", trigger_count = 0 },
}
local Reminder_Map = {
[1] = 470410101,
[2] = 470410102,
[3] = 470410103,
[4] = 470410104,
[5] = 470410105,
[6] = 470410106,
[7] = 470410107,
[8] = 470410108,
[9] = 470410109,
[10] = 470410110,
[11] = 470410111,
[12] = 470410112,
[13] = 470410113,
[14] = 470410114
}
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 = "seed_self_destroy", value = 0, no_refresh = true})
--table.insert(variables,{ config_id=50000002,name = "slime_self_destroy", value = 0, no_refresh = true})
end
------------------------------------------------------------------
--group load后根据当前玩法状态恢复物件表现
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] action_group_loadgroup加载恢复玩法状态")
LF_Init_Play(context)
return 0
end
--判断是否所有玩家都死了
function condition_dungeon_all_avatar_die(context,evt)
local uid_list = ScriptLib.GetSceneUidList(context)
local ret = 0
for i,v in ipairs(uid_list) do
local is_all_dead = ScriptLib.IsPlayerAllAvatarDie(context, v)
if true ~= is_all_dead then
ret = -1
break
end
end
if ret ~= 0 then
return false
end
return true
end
--主动退出地城
function action_dungeon_settle(context,evt)
if ScriptLib.IsGalleryStart(context, defs.gallery_id) then
if 0 ~= ScriptLib.StopGalleryByReason(context,defs.gallery_id,4) then
ScriptLib.PrintContextLog(context,"Stop Gallery失败")
else
ScriptLib.PrintContextLog(context,"Stop Gallery成功")
LF_Unload_Group(context)
end
end
--LF_Stop_Play(context, false)
return 0
end
function action_dungeon_all_avatar_die(context,evt)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] action_dungeon_all_avatar_die: 所有玩家的所有角色都死掉")
LF_Stop_Play(context,false)
return 0
end
function action_any_monster_die(context,evt)
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["kill_monster_cnt"] = 1})
return 0
end
--玩家与选项交互,开启挑战
function action_select_option(context,evt)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] action_select_option: 玩家与选项交互")
LF_Set_InitGadgets(context,false)
return 0
end
function action_variable_change(context,evt)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 设置参数")
ScriptLib.PrintContextLog(context,tostring(evt.param1))
if evt.param1 == 1 then
LF_Start_Play(context)
elseif evt.param1 == 2 then
LF_Stop_Play(context, true)
elseif evt.param1 == 3 then
LF_Stop_Play(context, false)
end
return 0
end
function action_leave_region(context,evt)--标记
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] leave region")
if (ScriptLib.IsGalleryStart(context, defs.gallery_id) and #ScriptLib.GetSceneUidList(context)==1 and evt.param1==defs.battle_region_id)then
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 准备传送")
ScriptLib.StopGalleryByReason(context,defs.gallery_id,2)
LF_Unload_Group(context)
end
return 0
end
function action_time_axis_pass(context,evt)
if evt.source_name == "teleport" then
--加载其他组
ScriptLib.ExecuteGroupLua(context, defs.next_group_id, "LF_Set_InitedByOtherGroup", {})
for k,v in pairs(suites) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, k)
end
end
return 0
end
------------------------------------------------------------------
------------------------流程相关----------------------------------
--初始化玩法
--加载操作台并上选项
function LF_Init_Play(context)
--操作台激活
if defs.is_first_group == true then
LF_Set_InitGadgets(context,true)
end
return 0
end
--开启玩法
function LF_Start_Play(context)
--先尝试启动gallery如果未成功则直接返回
if (ScriptLib.SetPlayerStartGallery(context, defs.gallery_id, ScriptLib.GetSceneUidList(context)) ~= 0) then
return 0
end
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 开启gallery")
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["total_kill_cnt"] = defs.monster_num})
return 0
end
function LF_Stop_Play(context, is_success)
if (is_success) then
--成功通关
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 成功通关小关")
ScriptLib.StopGalleryByReason(context,defs.gallery_id,3)
if defs.next_group_id ~=nil then
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 传送开始加入新一轮的suite")
if ScriptLib.GetSceneUidList(context)[1] then
ScriptLib.TransPlayerToPos(context, {uid_list ={ScriptLib.GetSceneUidList(context)[1]}, pos = {x=LF_GetPointPos(context, defs.trans_p1).x-1,y=LF_GetPointPos(context, defs.trans_p1).y,z=LF_GetPointPos(context, defs.trans_p1).z}, radius = 0, rot = LF_GetPointRot(context, defs.trans_p1)})
end
if ScriptLib.GetSceneUidList(context)[2] then
ScriptLib.TransPlayerToPos(context, {uid_list ={ScriptLib.GetSceneUidList(context)[2]}, pos = {x=LF_GetPointPos(context, defs.trans_p2).x-1,y=LF_GetPointPos(context, defs.trans_p2).y,z=LF_GetPointPos(context, defs.trans_p2).z}, radius = 0, rot = LF_GetPointRot(context, defs.trans_p2)})
end
if ScriptLib.GetSceneUidList(context)[3] then
ScriptLib.TransPlayerToPos(context, {uid_list ={ScriptLib.GetSceneUidList(context)[3]}, pos = {x=LF_GetPointPos(context, defs.trans_p3).x-1,y=LF_GetPointPos(context, defs.trans_p3).y,z=LF_GetPointPos(context, defs.trans_p3).z}, radius = 0, rot = LF_GetPointRot(context, defs.trans_p3)})
end
if ScriptLib.GetSceneUidList(context)[4] then
ScriptLib.TransPlayerToPos(context, {uid_list ={ScriptLib.GetSceneUidList(context)[4]}, pos = {x=LF_GetPointPos(context, defs.trans_p4).x-1,y=LF_GetPointPos(context, defs.trans_p4).y,z=LF_GetPointPos(context, defs.trans_p4).z}, radius = 0, rot = LF_GetPointRot(context, defs.trans_p4)})
end
ScriptLib.InitTimeAxis(context, "teleport", {1}, false)
else
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 成功通关大关")
ScriptLib.CauseDungeonSuccess(context)
end
else
--玩家死亡
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 失败")
ScriptLib.CauseDungeonFail(context)
end
return 0
end
------------------------group操作相关----------------------------------
--t键使用次数更新
function SLC_UpdateTRemainUseTime(context,remain_time,reminder_id)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] T键使用次数更新")
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["t_remain_use_time"] = remain_time})
ScriptLib.PrintContextLog(context,tostring(reminder_id))
ScriptLib.ShowReminderByUid(context,ScriptLib.GetSceneUidList(context), Reminder_Map[reminder_id])
return 0
end
--狂暴状态更新
function SLC_UpdateViolentLevel(context,violent_level)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] Boss狂暴等级更新")
ScriptLib.UpdatePlayerGalleryScore(context, defs.gallery_id, {["violent_level"] = violent_level})
return 0
end
--清理计数
function SLC_ClearSGV(context)
--清理火种子计数
ScriptLib.SetGroupVariableValue(context, "seed_self_destroy", 0)
--ScriptLib.SetGroupVariableValue(context, "slime_self_destroy", 0)
local uid = ScriptLib.GetSceneUidList(context)
if uid[1]~=nil then
ScriptLib.SetTeamServerGlobalValue(context, uid[1], "SGV_Team_HypostasisChallenge_Fire", 0)
end
--ScriptLib.SetTeamServerGlobalValue(context, uid[1], "SGV_Team_HypostasisChallenge_Water", 0)
return 0
end
--更新火挑战t键技能参数
function SLC_Fire_SeedDestroy(context)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 火种死亡")
if ScriptLib.GetGroupVariableValue(context, "seed_self_destroy")==0 then
local uid = ScriptLib.GetSceneUidList(context)
if uid[1]~=nil then
local value=ScriptLib.GetTeamServerGlobalValue(context,uid[1],"SGV_Team_HypostasisChallenge_Fire")
if value<=2 then
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 火种非自杀")
ScriptLib.SetTeamServerGlobalValue(context, uid[1], "SGV_Team_HypostasisChallenge_Fire", value+1)
end
end
else
ScriptLib.SetGroupVariableValue(context, "seed_self_destroy", ScriptLib.GetGroupVariableValue(context, "seed_self_destroy")-1)
end
--[[local uidprint = ScriptLib.GetSceneUidList(context)
if uidprint[1]~=nil then
ScriptLib.PrintContextLog(context,tostring(ScriptLib.GetTeamServerGlobalValue(context,uidprint[1],"SGV_Team_HypostasisChallenge_Fire")))
end]]
return 0
end
function SLC_Fire_SeedKillSelf(context)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 火种自杀")
ScriptLib.SetGroupVariableValue(context, "seed_self_destroy", ScriptLib.GetGroupVariableValue(context, "seed_self_destroy")+1)
return 0
end
--[[更新水挑战t键技能参数
function SLC_Water_SlimeDestroy(context)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 水史莱姆死亡")
if ScriptLib.GetGroupVariableValue(context, "slime_self_destroy")==0 then
local uid = ScriptLib.GetSceneUidList(context)
local value=ScriptLib.GetTeamServerGlobalValue(context,uid[1],"SGV_Team_HypostasisChallenge_Water")
ScriptLib.SetTeamServerGlobalValue(context, uid[1], "SGV_Team_HypostasisChallenge_Water", value+1)
else
ScriptLib.SetGroupVariableValue(context, "slime_self_destroy", ScriptLib.GetGroupVariableValue(context, "slime_self_destroy")-1)
end
return 0
end
function SLC_Water_SlimeKillSelf(context)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 水史莱姆自杀")
ScriptLib.SetGroupVariableValue(context, "slime_self_destroy", ScriptLib.GetGroupVariableValue(context, "slime_self_destroy")+1)
return 0
end]]
--更新草挑战t键技能参数
function SLC_Grass_AreaChange(context,seed_number)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 草场地变化")
ScriptLib.PrintContextLog(context,tostring(seed_number))
local uid = ScriptLib.GetSceneUidList(context)
if uid[1]~=nil then
ScriptLib.SetTeamServerGlobalValue(context, uid[1], "SGV_Team_HypostasisChallenge_Grass", seed_number)
ScriptLib.PrintContextLog(context,tostring(ScriptLib.GetTeamServerGlobalValue(context,uid[1],"SGV_Team_HypostasisChallenge_Grass")))
end
return 0
end
function LF_Set_InitedByOtherGroup(context, prev_context)
ScriptLib.AddExtraGroupSuite(context,base_info.group_id,2)
LF_Set_InitGadgets(context, true)
return 0
end
function LF_Unload_Group(context)
SLC_ClearSGV(context)
for k,v in pairs(suites) do
ScriptLib.RemoveExtraGroupSuite(context, base_info.group_id, k)
end
ScriptLib.SetGroupVariableValue(context, "GALLERY_STATE", 0)
if defs.is_first_group == true then
ScriptLib.RefreshGroup(context,{group_id=base_info.group_id})
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 第一关")
else
ScriptLib.RefreshGroup(context,{group_id=base_info.group_id})
ScriptLib.AddExtraGroupSuite(context,base_info.group_id,2)
ScriptLib.PrintContextLog(context,"## [HypostasisChallenge] 后面的关卡")
end
return 0
end
function LF_Set_InitGadgets(context, is_active)
ScriptLib.PrintContextLog(context, "## [HypostasisChallenge] 更新gadget信息")
if (is_active) then
ScriptLib.PrintContextLog(context, "## [HypostasisChallenge] show gadget")
if defs.cleaner_id~=nil then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.cleaner_id, 201)
end
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.worktop_id, {local_defs.worktop_option})
else
ScriptLib.PrintContextLog(context, "## [HypostasisChallenge] hide gadget")
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.worktop_id, 175)
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.worktop_id, 202)
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.recovergadget_id )
end
ScriptLib.PrintContextLog(context, "## [HypostasisChallenge] 更新gadget信息完毕")
return 0
end
function LF_GetPointPos(context,point_id)
for k,v in pairs(points) do
if v.config_id == point_id then
ScriptLib.PrintContextLog(context,tostring(v.pos))
return v.pos
end
end
return 0
end
function LF_GetPointRot(context,point_id)
for k,v in pairs(points) do
if v.config_id == point_id then
return v.rot
end
end
return 0
end
------------------------------------------------------------------
Initialize()

View File

@ -0,0 +1,538 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: MachineCarrier
|| owner: weiwei.sun
|| description: 3.2
|| LogName: ## [MachineCarrier]
|| Protection:
=======================================]]
--[[
local defs = {
option_turn = 613,
option_start = ,
option_stop = ,
play_region = ,
--岔路旋转State列表
turn_queue = {0,201,202,203},
point_array = 110200027,
--运输装置config_id
carrier_list = {},
switcher_control =
{--[操作台configID] = {被控岔路装置1, 被控岔路装置2},
[9017] = {9003},
},
--终点
end_point = ,
--几条路 注意是point_list有向的 倒数第二个点为岔路判定点
way_info =
{
--key为路径几 顺序无所谓
[1] =
{
point_list = {1},
spawn_point = 0,
gear_id = 0, --此判定点依据哪个岔路物件
dir = --岔路物件每个State通向哪
{ --GadgetState索引way_info ID
[0] = 7,
[201] = 0,
[202] = 0,
[204] = 0,
},
},
[2] =
{
point_list = {12,11,10,9,8,7,6,5,4,3},
spawn_point = 3,
gear_id = 0, --此判定点依据哪个岔路物件
dir = --岔路物件每个State通向哪
{ --GadgetState索引way_info ID
[0] = 0,
[201] = 5,
[202] = 0,
[203] = 0,
},
},
},
},
--每次任意车到达上车点时检查region内是否有玩家有则停车
station_region = ,
turn_point =
{
3
},
--停车点 到此点时会判断是否需要停车
stop_points =
{
7, 14
},
}
]]
local cfg =
{
--岔路旋转State列表
turn_queue = {0,201,202,203},
}
local extraTriggers = {
{ config_id = 8000001, name = "Select_Turn_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Select_Turn_Option", trigger_count = 0 },
{ config_id = 8000002, name = "Select_StartStop_Option", event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_Select_StartStop_Option", trigger_count = 0 },
{ config_id = 8000003, name = "Enter_Play_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Play_Region", trigger_count = 0 },
{ config_id = 8000004, name = "Leave_Play_Region", event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_Leave_Play_Region", trigger_count = 0 },
{ config_id = 8000005, name = "Point_Arrival", event = EventType.EVENT_PLATFORM_ARRIVAL, source = "", condition = "", action = "action_Point_Arrival", trigger_count = 0 },
{ config_id = 8000006, name = "Enter_Station_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Station_Region", trigger_count = 0 },
{ config_id = 8000007, name = "Create_Gadget", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_Create_Gadget", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
table.insert(suites[init_config.suite].triggers, v.name)
end
table.insert(variables,{ config_id = 50000001, name = "first_station", value = 0, no_refresh = true })
end
function action_Create_Gadget(context, evt)
--创建时 检查运输线状态
if 70320028 ~= evt.param2 then
return 0
end
if 0 ~= ScriptLib.GetGroupTempValue(context, "move_state", {}) then
return 0
end
ScriptLib.StopPlatform(context, evt.param1)
ScriptLib.PrintContextLog(context,"## [MachineCarrier] Spawned while move_state is 0. Stop platform. config_id@"..evt.param1)
return 0
end
function action_Select_Turn_Option(context, evt)
if defs.option_turn ~= evt.param2 then
return 0
end
if nil == defs.switcher_control[evt.param1] then
return 0
end
local turn_queue = cfg.turn_queue
if nil ~= defs.turn_queue then
turn_queue = defs.turn_queue
end
if nil == turn_queue[1] then
return 0
end
for i,v in ipairs(defs.switcher_control[evt.param1]) do
local gadget_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, v)
local state_index = GetIndexInTable(context, gadget_state, turn_queue)
if state_index >= #turn_queue then
ScriptLib.SetGadgetStateByConfigId(context, v, turn_queue[1])
ScriptLib.PrintContextLog(context,"## [MachineCarrier] action_Select_Turn_Option. config_id@"..v.." to state@".. turn_queue[1])
else
ScriptLib.SetGadgetStateByConfigId(context, v, turn_queue[state_index + 1])
ScriptLib.PrintContextLog(context,"## [MachineCarrier] action_Select_Turn_Option. config_id@"..v.." point@".. turn_queue[state_index + 1])
end
end
if 1 ~= move_state then
LF_ResumeMove(context)
end
return 0
end
function action_Select_StartStop_Option(context, evt)
if defs.option_start == evt.param2 then
LF_ResumeMove(context)
return 0
end
if defs.option_stop == evt.param2 then
--LF_PauseMove(context)--立即停下
ScriptLib.SetGroupTempValue(context, "is_toStop", 1, {})--按下停止按钮后当有任意一个车到上车点的时候 停下
return 0
end
return 0
end
function action_Enter_Play_Region(context, evt)
if nil == defs.play_region then
ScriptLib.PrintContextLog(context,"## [MachineCarrier] action_Enter_Play_Region. play_region is empty!")
return 0
end
if defs.play_region ~= evt.param1 then
return 0
end
if nil == defs.carrier_list[1] then
ScriptLib.PrintContextLog(context,"## [MachineCarrier] defs.carrier_list[1] is empty!")
return 0
end
LF_StartMove(context, defs.carrier_list[1])
return 0
end
function action_Leave_Play_Region(context, evt)
if nil == defs.play_region then
ScriptLib.PrintContextLog(context,"## [MachineCarrier] action_Leave_Play_Region. play_region is empty!")
return 0
end
if defs.play_region ~= evt.param1 then
return 0
end
--重置电车
for i,v in ipairs(defs.carrier_list) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v)
end
--恢复选项
LF_TrySetAllTurningOption(context)
if nil ~= defs.carrier_list[1] then
ScriptLib.CreateGadget(context, { config_id = defs.carrier_list[1] })
end
--ScriptLib.RefreshGroup(context, {group_id = base_info.group_id, suite = init_config.suite })
return 0
end
function action_Enter_Station_Region(context, evt)
--进入station_region时检查如果现在是停的且没有车处于停靠状态则启动
if defs.station_region ~= evt.param1 then
return 0
end
if 0 ~= ScriptLib.GetGroupTempValue(context, "move_state", {}) then
return 0
end
for i,v in ipairs(defs.carrier_list) do
if 1 == ScriptLib.GetGadgetAbilityFloatValue(context, base_info.group_id, v, "SGV_MachineCarrier_State") then
return 0
end
end
LF_ResumeMove(context)
return 0
end
function action_Point_Arrival(context, evt)
--PointIndex更新
ScriptLib.ChangeGroupTempValue(context, "point_"..evt.param1, 1, {})
local cur_way = ScriptLib.GetGroupTempValue(context, "way_"..evt.param1, {})
if nil == defs.way_info[cur_way] then
return 0
end
local length = #defs.way_info[cur_way].point_list
ScriptLib.PrintContextLog(context,"## [MachineCarrier] action_Point_Arrival. config_id@"..evt.param1.." cur_way@"..cur_way.." point@"..evt.param3.." check_point@"..defs.way_info[cur_way].point_list[length])
--是否为 选项恢复点
if nil ~= defs.recover_points then
if LF_CheckIsInTable(context, evt.param3, defs.recover_points) then
LF_TrySetAllTurningOption(context)
end
end
--是否为 自杀点
if nil ~= defs.end_point then
if LF_CheckIsInTable(context, evt.param3, defs.end_point) then
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, evt.param1)
ScriptLib.SetGroupTempValue(context, "way_"..evt.param1, 0, {})
return 0
end
end
--是否为 下车点
if nil ~= defs.leave_points then
if LF_CheckIsInTable(context, evt.param3, defs.leave_points) then
if 1 == LF_TryStopMoveAtStation(context, evt.param1) then
LF_TryTurnGadget(context, evt.param1, evt.param3)
return 0
end
end
end
--是否为 上车点
if nil ~= defs.stop_points then
if LF_CheckIsInTable(context, evt.param3, defs.stop_points) then
local region_eid = ScriptLib.GetEntityIdByConfigId(context, defs.station_region)
if 1 == ScriptLib.GetGroupTempValue(context, "is_toStop", {}) or 1 <= ScriptLib.GetRegionEntityCount(context, { region_eid = region_eid, entity_type = EntityType.AVATAR }) then
if 0 == ScriptLib.GetGroupVariableValue(context, "first_station") then
ScriptLib.SetGroupVariableValue(context, "first_station", 1)
end
LF_PauseMove(context)
LF_TryTurnGadget(context, evt.param1, evt.param3)
end
end
end
--是否为 当前路径上的岔路判定点
if nil ~= defs.way_info[cur_way].point_list[length] then
if defs.way_info[cur_way].point_list[length] == evt.param3 then
LF_HandleChangeDir(context, evt.param1, cur_way)
return 0
end
end
--是否为 当前路径上的Spawn点
if defs.way_info[cur_way].spawn_point == evt.param3 then
LF_TrySpawnCarrier(context)
end
return 0
end
--在路径判定点处,设置新点阵
function LF_HandleChangeDir(context, config_id, cur_way)
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_HandleChangeDir. config_id"..config_id.." cur_way@"..cur_way)
local switcher_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.way_info[cur_way].gear_id)
if nil == defs.way_info[cur_way].dir[switcher_state] then
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_HandleChangeDir. Empty switcher_state. gear_id@"..defs.way_info[cur_way].gear_id.." switcher_state@"..switcher_state)
return 0
end
local new_way = defs.way_info[cur_way].dir[switcher_state]
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_HandleChangeDir. Get new way cur_way@"..cur_way.." switcher_state@"..switcher_state.. " new_way@"..new_way)
--前方无路,停车 不隐藏转向按钮
if 0 == new_way then
LF_PauseMove(context)
return 0
end
--隐藏转向按钮
LF_DelAllTurningOption(context)
ScriptLib.SetGroupTempValue(context, "way_"..config_id, new_way, {})
ScriptLib.SetGroupTempValue(context, "point_"..config_id, 0, {})
ScriptLib.SetPlatformPointArray(context, config_id, defs.point_array, defs.way_info[new_way].point_list, { route_type = 0, record_mode = 0 })
return 0
end
--是否所有车都可移动
function LF_IsMoveable(context)
for i,v in pairs(defs.carrier_list) do
--取得之前停在哪里
local cur_way = ScriptLib.GetGroupTempValue(context, "way_"..v, {})
if 0 < cur_way and nil ~= defs.way_info[cur_way] then
local switcher_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, defs.way_info[cur_way].gear_id)
if nil ~= defs.way_info[cur_way].dir[switcher_state] then
local new_way = defs.way_info[cur_way].dir[switcher_state]
if 0 >= new_way then
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_IsMoveable. Is not movable. config_id@"..v.." cur_way@"..cur_way)
return 0
end
end
end
end
return 1
end
function LF_TryTurnGadget(context, config_id, point_id)
if LF_CheckIsInTable(context, point_id, defs.turn_point) then
ScriptLib.SetEntityServerGlobalValueByConfigId(context, config_id, "SGV_MachineCarrier_State", 1)
end
return 0
end
function LF_TrySpawnCarrier(context)
local carrier_num = ScriptLib.CheckRemainGadgetCountByGroupId(context, { group_id = base_info.group_id, gadget_id = { 70320026 }})
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_TrySpawnCarrier. carrier_num@"..carrier_num.." carrier_list@"..#defs.carrier_list)
if 0 > carrier_num then
return 0
end
if #defs.carrier_list > carrier_num then
for i,v in ipairs(defs.carrier_list) do
local ret = ScriptLib.CreateGadget(context, { config_id = v })
if 0 == ret then
LF_StartMove(context, v)
return 0
end
end
end
return 0
end
function LF_StartMove(context, config_id)
if nil == defs.way_info[1] then
return 0
end
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_StartMove. Try start config_id@"..config_id.." point_list@".. table.concat(defs.way_info[1].point_list, ", "))
local ret = ScriptLib.SetPlatformPointArray(context, config_id, defs.point_array, defs.way_info[1].point_list, { route_type = 0, record_mode = 0 })
if 0 == ret then
ScriptLib.SetGroupTempValue(context, "move_state", 1, {})
ScriptLib.SetGroupTempValue(context, "way_"..config_id, 1, {})
ScriptLib.SetGroupTempValue(context, "point_"..config_id, 0, {})
return 0
end
if nil ~= defs.option_gadget then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.option_gadget, { defs.option_stop })
end
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_StartMove. SetPlatformPointArray ret@"..ret)
return 0
end
function LF_ResumeMove(context)
if 0 == LF_IsMoveable(context) then
return 0
end
--启动
for i,v in ipairs(defs.carrier_list) do
--物件朝向恢复
ScriptLib.SetEntityServerGlobalValueByConfigId(context, v, "SGV_MachineCarrier_State", 0)
--取得之前停在哪里
local cur_way = ScriptLib.GetGroupTempValue(context, "way_"..v, {})
if 0 < cur_way then
local cur_point_index = ScriptLib.GetGroupTempValue(context, "point_"..v, {})
--是否是在终点停下
if #defs.way_info[cur_way].point_list <= cur_point_index then
LF_HandleChangeDir(context, v, cur_way)
end
local resume_point_list = {}
--设置点阵路径
--如果在起点
if 0 == cur_point_index then
ScriptLib.SetPlatformPointArray(context, v, defs.point_array, defs.way_info[cur_way].point_list, { route_type = 0, record_mode = 0 })
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_ResumeMove. config_id@"..v.." cur_way@"..cur_way.." point_list@".. table.concat(defs.way_info[1].point_list, ", "))
--一条路没走完继续走
elseif #defs.way_info[cur_way].point_list > cur_point_index then
for i = cur_point_index + 1, #defs.way_info[cur_way].point_list do
table.insert(resume_point_list, defs.way_info[cur_way].point_list[i])
end
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_ResumeMove. config_id@"..v.." cur_way@"..cur_way.." cur_point_index@"..cur_point_index.." point_list@".. table.concat(resume_point_list, ", "))
end
ScriptLib.SetPlatformPointArray(context, v, defs.point_array, resume_point_list, { route_type = 0, record_mode = 0 })
ScriptLib.SetGroupTempValue(context, "move_state", 1, {})
end
end
if nil ~= defs.option_gadget then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.option_gadget, { defs.option_stop })
end
return 0
end
function LF_PauseMove(context)
for i, v in ipairs(defs.carrier_list) do
ScriptLib.StopPlatform(context, v)
end
ScriptLib.SetGroupTempValue(context, "move_state", 0, {})
if nil ~= defs.option_gadget then
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.option_gadget, { defs.option_start })
end
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_PauseMove.")
return 0
end
function LF_TryStopMoveAtStation(context, config_id)
local carrier_state = ScriptLib.GetGadgetStateByConfigId(context, base_info.group_id, config_id)
ScriptLib.PrintContextLog(context,"## [MachineCarrier] LF_TryStopMoveAtStation. carrier_state@"..carrier_state)
if 201 == carrier_state then
LF_PauseMove(context)
return 1
end
return 0
end
--物件检测到玩家上车
function SLC_MachineCarrier_Player_In(context)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
--确保整个运输线只能有一个201
for k,v in pairs(defs.carrier_list) do
if v ~= config_id then
ScriptLib.SetGadgetStateByConfigId(context, v, 0)
end
end
local move_state = ScriptLib.GetGroupTempValue(context, "move_state", {})
local cur_way = ScriptLib.GetGroupTempValue(context, "way_"..config_id, {})
local cur_point_index = ScriptLib.GetGroupTempValue(context, "point_"..config_id, {})
ScriptLib.PrintContextLog(context,"## [MachineCarrier] SLC_MachineCarrier_Player_In. move_state@"..move_state.." config_id@"..config_id.." cur_point_index@"..cur_point_index)
if nil == defs.way_info[cur_way] then
return 0
end
local way_info = defs.way_info[cur_way]
if nil == way_info.point_list[cur_point_index] then
return 0
end
ScriptLib.PrintContextLog(context,"## [MachineCarrier] SLC_MachineCarrier_Player_In. move_state@"..move_state.." config_id@"..config_id.." cur_point@"..way_info.point_list[cur_point_index])
if false == LF_CheckIsInTable(context, way_info.point_list[cur_point_index], defs.stop_points) then
return 0
end
if 1 ~= move_state then
LF_ResumeMove(context)
end
return 0
end
function LF_DelAllTurningOption(context)
for k,v in pairs(defs.switcher_control) do
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, k, defs.option_turn )
end
ScriptLib.SetGroupTempValue(context, "option_deleted", 1, {})
return 0
end
function LF_TrySetAllTurningOption(context)
if 1 ~= ScriptLib.GetGroupTempValue(context, "option_deleted", {}) then
return 0
end
for k,v in pairs(defs.switcher_control) do
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, k, { defs.option_turn })
end
ScriptLib.SetGroupTempValue(context, "option_deleted", 0, {})
return 0
end
--用于检查value是否在目标table中
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
function GetIndexInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return i
end
end
return 0
end
LF_Initialize()

View File

@ -0,0 +1,199 @@
--[[======================================
|| filename: PhotographActivity_V2
|| owner: zhangchi.chen luyao.huang
|| description: 3.2
|| LogName: PhotographActivity
|| Protection:
=======================================]]--
------
--local defs = {
-- worktop_id = 10001,
-- gallery_id = 18001,
-- region_id = 20001,
-- client_judge_id = 1
--}
local local_defs = {
worktop_option = 190,
region_out_reminder = 600106,
region_warning_reminder = 600159,
begin_fail_reminder=600158,
}
local Tri = {
[1] = { name = "group_load", config_id = 40000000, event = EventType.EVENT_GROUP_LOAD, source = "", condition = "", action = "action_group_load", trigger_count = 0},
[3] = { name = "select_option", config_id = 40000002, event = EventType.EVENT_SELECT_OPTION, source = "", condition = "", action = "action_select_option", trigger_count = 0},
[4] = { name = "photo_finish", config_id = 40000003, event = EventType.EVENT_PHOTO_FINISH, source = "", condition = "", action = "action_photo_finish", trigger_count = 0},
[5] = { name = "leave_region", config_id = 40000004, event = EventType.EVENT_LEAVE_REGION, source = "", condition = "", action = "action_leave_region", trigger_count = 0},
[6] = { name = "group_will_unload", config_id = 40000005, event = EventType.EVENT_GROUP_WILL_UNLOAD, source = "", condition = "", action = "action_group_will_unload", trigger_count = 0},
[7] = { name = "gallery_stop", config_id = 40000006, event = EventType.EVENT_GALLERY_STOP, source = "", condition = "", action = "action_gallery_stop", trigger_count = 0},
[8] = { name = "enter_region", config_id = 40000007, event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_enter_region", trigger_count = 0},
}
function Initialize()
for k,v in pairs(Tri) do
table.insert(triggers, v)
table.insert(suites[1].triggers, v.name)
end
table.insert(variables,{ config_id=50000001,name = "trigger_count", value = 0, no_refresh = true})
end
------------------------------------------------------------------
--group load后根据当前玩法状态恢复物件表现
function action_group_load(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_group_loadgroup加载恢复玩法状态")
LF_Init_Play(context)
return 0
end
--玩家与选项交互,开启挑战
function action_select_option(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_select_option: 玩家与选项交互,尝试开启玩法")
if (ScriptLib.IsWidgetEquipped(context, ScriptLib.GetSceneOwnerUid(context), 220018) == true) or (ScriptLib.IsWidgetEquipped(context, ScriptLib.GetSceneOwnerUid(context), 220020) == true) or (ScriptLib.IsWidgetEquipped(context, ScriptLib.GetSceneOwnerUid(context), 220070) == true) then
LF_Start_Play(context)
else
ScriptLib.PrintContextLog(context,"## [PhotographActivity] 未装备【留影机】")
local uid = ScriptLib.GetSceneUidList(context)
if uid[1]~=nil then
ScriptLib.ShowReminderByUid(context,{uid[1]}, local_defs.begin_fail_reminder)
end
end
return 0
end
--挑战成功处理
--拍照成功以成功结束gallery并流转group状态
function action_photo_finish(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_photo_finish: 收到推送的拍照成功消息")
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_photo_finish: gallery id为"..evt.param1)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_photo_finish: 客户端逻辑id为"..evt.param2)
--对客户端推送的拍照成功消息做一次校验
if (evt.param1 == defs.gallery_id and evt.param2 == defs.client_judge_id) then
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_photo_finish: 拍照成功")
end
return 0
end
--挑战失败处理
--出警示圈和失败情况1玩家出圈
function action_leave_region(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_leave_region: 玩家出圈")
if (evt.param1 == defs.warning_region_id and ScriptLib.IsGalleryStart(context,defs.gallery_id)) then
local uid = ScriptLib.GetGalleryUidList(context,defs.gallery_id)
if uid[1]~=nil then
ScriptLib.ShowReminderByUid(context,{uid[1]}, local_defs.region_warning_reminder)
end
elseif (evt.param1 == defs.region_id and ScriptLib.IsGalleryStart(context,defs.gallery_id)) then
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_leave_region: 挑战失败并回滚group状态")
local uid = ScriptLib.GetGalleryUidList(context,defs.gallery_id)
if uid[1]~=nil then
ScriptLib.ShowReminderByUid(context,{uid[1]}, local_defs.region_out_reminder)
end
LF_Stop_Play(context,false)
end
return 0
end
--玩家首次进圈显示教程
function action_enter_region(context,evt)
if ScriptLib.GetGroupVariableValue(context,"trigger_count") == 0 then
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_enter_region: 玩家进圈")
ScriptLib.SetGroupVariableValue(context,"trigger_count",1)
if 0 ~= ScriptLib.AssignPlayerShowTemplateReminder(context,211,{param_uid_vec={},param_vec={},uid_vec={context.uid}}) then
return -1
end
end
return 0
end
--失败情况2group即将卸载
function action_group_will_unload(context,evt)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_group_will_unload: group即将卸载")
if (ScriptLib.IsGalleryStart(context,defs.gallery_id)) then
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_group_will_unload: 回退至初始状态作为保护")
LF_Stop_Play(context,false)
end
return 0
end
--失败情况3灭队
function action_gallery_stop(context,evt)
--关闭黄圈
ScriptLib.DeactivateGroupLinkBundle(context, base_info.group_id)
ScriptLib.PrintContextLog(context,"## [PhotographActivity] action_gallery_stop: 重新加载group")
LF_Init_Play(context)
return 0
end
------------------------------------------------------------------
------------------------流程相关----------------------------------
--初始化玩法
--加载操作台并上选项
function LF_Init_Play(context)
--操作台激活
LF_Set_Worktop(context,true)
--卸载打点suite
LF_Set_Photo_Point_Suite(context,false)
end
--开启玩法
function LF_Start_Play(context)
--先尝试启动gallery如果未成功则直接返回
if (ScriptLib.SetPlayerStartGallery(context, defs.gallery_id, {ScriptLib.GetSceneOwnerUid(context)}) ~= 0) then
return
end
--操作台转为未激活
LF_Set_Worktop(context,false)
--加载打点suite
LF_Set_Photo_Point_Suite(context,true)
--显示黄圈
ScriptLib.ActivateGroupLinkBundle(context, base_info.group_id)
end
function LF_Stop_Play(context, is_success)
--卸载打点suite
--LF_Set_Photo_Point_Suite(context,false)
if (is_success) then
ScriptLib.StopGallery(context,defs.gallery_id,false)
else
--lua里处理的都是出界StopGallery所以Reason直接都给5
ScriptLib.StopGalleryByReason(context,defs.gallery_id,5)
end
--重新做一次初始化的流程
LF_Init_Play(context)
end
------------------------group元素操作相关----------------------------------
--设置操作台状态包括设置gadgetState和上下选项
function LF_Set_Worktop(context, is_active)
if (is_active) then
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.worktop_id, 0)
ScriptLib.SetWorktopOptionsByGroupId(context, base_info.group_id, defs.worktop_id, {local_defs.worktop_option})
else
ScriptLib.SetGroupGadgetStateByConfigId(context, base_info.group_id, defs.worktop_id, 201)
ScriptLib.DelWorktopOptionByGroupId(context, base_info.group_id, defs.worktop_id, local_defs.worktop_option)
end
end
--加载/卸载打点用suite
function LF_Set_Photo_Point_Suite(context,is_active)
if (is_active) then
if #suites>=2 then
--如果有配置打点用物件,将其加载出来
ScriptLib.AddExtraGroupSuite(context,base_info.group_id,2)
end
else
if #suites>=2 then
--如果有配置打点用物件,清理加载出来的打点用物件
ScriptLib.RemoveExtraGroupSuite(context,base_info.group_id,2)
end
end
end
------------------------------------------------------------------
Initialize()

View File

@ -0,0 +1,49 @@
--[[======================================
|| filename: PubAnimal
|| owner: chen.chen
|| description:
|| LogName: TD
|| Protection: [Protection]
=======================================]]
-- 打印日志
function PrintLog(context, content)
local log = "## [PubAnimal] TD: "..content
ScriptLib.PrintContextLog(context, log)
end
local extraTriggers =
{
{ config_id = 40000001, name = "tavern_refresh", event = EventType.EVENT_GCG_TAVERN_SCENE_REFRESH, source = "", condition = "", action = "action_EVENT_GCG_TAVERN_SCENE_REFRESH", trigger_count = 0 },
}
------ Local Functions -----------
function LF_Initialize_Level()
--- TRIGGER
for i, _suite in ipairs(suites) do
for _, _trigger in pairs(extraTriggers) do
table.insert(_suite.triggers, _trigger.name)
end
end
for _, _trigger in pairs(extraTriggers) do
table.insert(triggers, _trigger)
end
return 0
end
------ conditions & actions ------
--任务进度改变刷一下按钮锁定状态
function action_EVENT_GCG_TAVERN_SCENE_REFRESH(context, evt)
--开始刷新NPC
PrintLog(context, "开始刷新小动物")
--执行刷新
ScriptLib.RefreshGroup(context, { group_id = 0, suite = evt.param1 })
return 0
end
LF_Initialize_Level()

View File

@ -0,0 +1,195 @@
--- ServerUploadTool Save to [/root/env/data/lua/common/V3_2] ---
--[[======================================
|| filename: TeleportHotSpot
|| owner: weiwei.sun
|| description: streaming热点处理
|| LogName: ## [TeleportHotSpot]
|| Protection:
=======================================]]
--[[
local defs = {
--传送起点
hot_spots =
{
--若teleport_gadget不为0则检查其state是否为201。 这个设定用于防止同一地点多个门创建多个hotpoint
[regionID] = { teleport_gadget = 0, hot_spot = 0},
},
--传送终点(废弃 改为SLC)
target_region =
{
-- enterRegion时移除hotSpot
region_1, region_2
}
}
]]
local extraTriggers = {
{ config_id = 8000001, name = "Enter_Teleport_Region", event = EventType.EVENT_ENTER_REGION, source = "", condition = "", action = "action_Enter_Teleport_Region", trigger_count = 0 },
{ config_id = 8000002, name = "Time_Axis_RemoveHotSpot", event = EventType.EVENT_TIME_AXIS_PASS, source = "", condition = "", action = "action_Time_Axis_RemoveHotSpot", trigger_count = 0 },
{ config_id = 8000004, name = "Gadget_Create", event = EventType.EVENT_GADGET_CREATE, source = "", condition = "", action = "action_Gadget_Create", trigger_count = 0 },
{ config_id = 8000005, name = "Quest_Notify_CreateHotSpot", event = EventType.EVENT_QUEST_START, source = "1301415", condition = "", action = "action_Quest_Notify_CreateHotSpot", trigger_count = 0 },
{ config_id = 8000006, name = "Quest_Notify_DelHotSpot", event = EventType.EVENT_QUEST_FINISH, source = "1301416", condition = "", action = "action_Quest_Notify_DelHotSpot", trigger_count = 0 },
}
function LF_Initialize()
for k,v in pairs(extraTriggers) do
table.insert(triggers, v)
if nil ~= suites[17] then
table.insert(suites[17].triggers, v.name)
end
end
end
function action_Enter_Teleport_Region(context, evt)
if nil == defs.hot_spots[evt.param1] then
return 0
end
LF_CreateHotSpot(context, evt.param1)
return 0
end
function action_Gadget_Create(context, evt)
if 70320041 ~= evt.param2 then
return 0
end
ScriptLib.SetGadgetStateByConfigId(context, evt.param1, 201)
--LD流程迭代后 不保证最新创生的即当前所需传送门,有可能出现创/删顺序错误已经将Region改成和各自传送门gadget在同一suite只用EnterREgion不再用GadgetCreate
--LF_CreateHotSpotByGadget(context, evt.param1)
return 0
end
function action_Quest_Notify_CreateHotSpot(context, evt)
if nil == defs.hotspot_cs then
return 0
end
--先清除
LF_ClearAllHotSpot(context)
--创建
local ret = ScriptLib.CreateGadget(context, { config_id = defs.hotspot_cs })
if 0 == ret then
ScriptLib.PrintContextLog(context,"## [TeleportHotSpot] action_Quest_Notify_CreateHotSpot.")
return 0
end
ScriptLib.PrintContextLog(context,"## [TeleportHotSpot] action_Quest_Notify_CreateHotSpot failed! ret@"..ret)
return 0
end
function action_Quest_Notify_DelHotSpot(context, evt)
if nil == defs.hotspot_cs then
return 0
end
LF_ClearAllHotSpot(context)
return 0
end
function SLC_TeleportHotSpot_NeedRemove(context)
local config_id = ScriptLib.GetGadgetConfigId(context, { gadget_eid = context.source_entity_id })
--校验来源
if 70320041 ~= gadgets[config_id].gadget_id then
return 0
end
for i, v in ipairs(defs.hot_spots) do
if v.teleport_gadget == config_id then
ScriptLib.InitTimeAxis(context, "remove_"..v.hot_spot, { 5 }, false)
return 0
end
end
return 0
end
function LF_CreateHotSpot(context, region_id)
--该region对应的hotSpot是否已经在场
if -1 ~= ScriptLib.GetGadgetStateByConfigId(context, 0, defs.hot_spots[region_id].hot_spot) then
return 0
end
--若有teleport_gadget配置则检查其是否存在 --不检查了 LF_ClearAllHotSpot确保每次场上只有一个就行
--[[if nil ~= defs.hot_spots[region_id].teleport_gadget and 0 < defs.hot_spots[region_id].teleport_gadget then
if -1 == ScriptLib.GetGadgetStateByConfigId(context, 0, defs.hot_spots[region_id].teleport_gadget) then
ScriptLib.PrintContextLog(context,"## [TeleportHotSpot] LF_CreateHotSpot. Denied. region@"..region_id.." teleport_gadget@"..defs.hot_spots[region_id].teleport_gadget.." is not placed.")
return 0
end
end]]
--先清除
LF_ClearAllHotSpot(context)
--创建
local ret = ScriptLib.CreateGadget(context, { config_id = defs.hot_spots[region_id].hot_spot })
if 0 == ret then
ScriptLib.PrintContextLog(context,"## [TeleportHotSpot] LF_CreateHotSpot. region_id@"..region_id.." Create spot@"..defs.hot_spots[region_id].hot_spot)
end
return 0
end
function LF_CreateHotSpotByGadget(context, config_id)
ScriptLib.PrintContextLog(context,"## [TeleportHotSpot] LF_CreateHotSpotByGadget. config_id@"..config_id)
for k,v in pairs(defs.hot_spots) do
if v.teleport_gadget == config_id then
--[[local region_eid = ScriptLib.GetEntityIdByConfigId(context, k)
ScriptLib.PrintContextLog(context,"## [TeleportHotSpot] LF_CreateHotSpotByGadget. region_eid@"..region_eid .. " configID@"..k)
if 1 <= ScriptLib.GetRegionEntityCount(context, { region_eid = region_eid, entity_type = EntityType.AVATAR }) then]]
LF_CreateHotSpot(context, k)
return 0
--end
end
end
ScriptLib.PrintContextLog(context,"## [TeleportHotSpot] LF_CreateHotSpotByGadget. Region not placed. config_id@"..config_id)
return 0
end
function LF_ClearAllHotSpot(context)
for k,v in pairs(defs.hot_spots) do
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, v.hot_spot)
end
if nil ~= defs.hotspot_cs then
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, defs.hotspot_cs)
end
return 0
end
function action_Time_Axis_RemoveHotSpot(context, evt)
local name = string.sub(evt.source_name, 1, 6)
if "remove" ~= name then
return 0
end
local div = string.find(evt.source_name, "_")
if nil == div then
return 0
end
local config_id = tonumber(string.sub(evt.source_name, div + 1, #evt.source_name))
if nil == config_id then
return 0
end
ScriptLib.PrintContextLog(context,"## [TeleportHotSpot] Remove hot spot timeaxis passed. config_id@"..config_id)
if nil == gadgets[config_id] then
return 0
end
ScriptLib.RemoveEntityByConfigId(context, 0, EntityType.GADGET, config_id)
return 0
end
--用于检查value是否在目标table中
function LF_CheckIsInTable(context, value, check_table)
for i = 1, #check_table do
if check_table[i] == value then
return true
end
end
return false
end
LF_Initialize()