This commit is contained in:
aixianling
2024-12-16 13:51:31 +08:00
commit 00ee9dd8ea
1884 changed files with 817815 additions and 0 deletions

View File

@@ -0,0 +1,232 @@
module("FubenType1", package.seeall)
--[[
刷怪进度通关副本
个人数据ActorData[fbId]
{
}
全局缓存Cache[fbId]
{
[pFuben] =
{
wave, 当前波数
phase, 当前阶段 0无 1创建 2开始 3进行中 4结算 5结束
scenId, 副本当前场景
}
}
全局数据GlobalData[fbId]
{
}
]]--
--副本类型
local FubenType = 1
--对应的副本配置
local FubenConfig = FubenType1Conf
if FubenConfig == nil then
assert(false)
end
local EnterCheckType =
{
Activity = 1, --检查活动开启param1=活动id
Level = 2, --检查等级达到param1=等级param2=转生
}
local PhaseType =
{
Create = 1, --创建
Start = 2, --开始
Running = 3, --进行中
Finish = 4, --完成
}
--------------------------------------------------------------------
-- 详细逻辑
--------------------------------------------------------------------
function getCacheDataByHandle(fbHandle)
local pFuben = Fuben.getFubenPtrByHandle(fbHandle)
return Fuben.getDyanmicVar(pFuben)
end
--广播进度
function BroadSchedule(pFuben)
local fbId = Fuben.getFubenIdByPtr(pFuben)
local fbHandle = Fuben.getFubenHandle(pFuben)
local sceneId = Fuben.getSceneId(fbHandle)
local scenHandle = Fuben.getSceneHandleById(sceneId,fbHandle)
--分配一个广播包
local npack = FubenDispatcher.AllocPacketEx(enFubenSystemID, sFubenSchedule)
--副本数据
local thisdata = FubenDispatcher.GetCacheData(pFuben)
local curWave = thisdata.wave or 1 --当前波数
local totalWave = #FubenConfig[fbId].fbRefresh --总波数
local leftCount = Fuben.getLiveMonsterCount(scenHandle,0) --剩余怪物数量
DataPack.writeByte(npack, curWave)
DataPack.writeByte(npack, totalWave)
DataPack.writeByte(npack, leftCount)
--广播当前场景
DataPack.broadcastScene(npack,fbHandle,sceneId)
--释放广播包
ActivityDispatcher.FreePacketEx(npack)
return npack
end
--玩家进入副本
function OnActorEnter(fbId, fbEnterType, pFuben, scenId, pActor)
local fbHandle = Fuben.getFubenHandle(pFuben)
local scenHandle = Fuben.getSceneHandleById(scenId,fbHandle)
--单人副本
if fbEnterType == FubenEnterType.Single then
local thisdata = FubenDispatcher.GetCacheData(pFuben)
thisdata.wave = 0
thisdata.phase = PhaseType.Start
thisdata.scenId = scenId
--组队副本
elseif fbEnterType == FubenEnterType.Team then
--多人副本
elseif fbEnterType == FubenEnterType.All then
end
end
--检查波数刷怪
function OnCheckWave(fbId, fbEnterType, pFuben, curTime)
local thisdata = FubenDispatcher.GetCacheData(pFuben)
local fbHandle = Fuben.getFubenHandle(pFuben)
local scenHandle = Fuben.getSceneHandleById(thisdata.scenId,fbHandle)
-- 刷第一波怪
if thisdata.phase == PhaseType.Start then
--清空当前副本内所有的怪物
-- Fuben.clearSceneEntity(scenHandle, 1);
thisdata.phase = PhaseType.Running
thisdata.wave = 1
local fresh = FubenConfig[fbId].fbRefresh
if fresh and fresh[1] then
local wave = fresh[1]
Fuben.createMonstersInRange(scenHandle, wave.entityid, wave.x-wave.range, wave.y-wave.range, wave.x+wave.range, wave.y+wave.range, wave.count, 0)
end
BroadSchedule(pFuben)
-- 刷怪检测
elseif thisdata.phase == PhaseType.Running then
local fresh = FubenConfig[fbId].fbRefresh
if fresh and fresh[thisdata.wave] then
local wave = fresh[thisdata.wave]
local leftCount = Fuben.getLiveMonsterCount(scenHandle,wave.entityid) --剩余怪物数量
if leftCount <= 0 then
if fresh[thisdata.wave + 1] then
thisdata.wave = thisdata.wave + 1
wave = fresh[thisdata.wave]
Fuben.createMonstersInRange(scenHandle, wave.entityid, wave.x-wave.range, wave.y-wave.range, wave.x+wave.range, wave.y+wave.range, wave.count, 0)
else
thisdata.phase = PhaseType.Finish
FubenDispatcher.SetResult(pFuben,1)
BroadSchedule(pFuben)
end
end
else
thisdata.phase = PhaseType.Finish
FubenDispatcher.SetResult(pFuben,1)
BroadSchedule(pFuben)
end
-- 结束
elseif thisdata.phase == PhaseType.Finish then
FubenDispatcher.SetResult(pFuben,1)
thisdata.phase = nil
end
end
--------------------------------------------------------------------
-- 副本 回调注册
--------------------------------------------------------------------
-- 检查玩家进入
function OnCheckEnter(fbId, fbEnterType, pActor)
local Conf = FubenConfig[fbId]
if Conf == nil then
return false
end
-- 这个进入条件需要全部满足
if Conf.fbEnterLimit then
for i,cond in ipairs(Conf.fbEnterLimit) do
if cond.type == EnterCheckType.Activity then
if Actor.isActivityRunning(pActor, cond.param1) == false then
Actor.sendTipmsg(pActor, "活动:"..cond.param1.." 并未开启!", tstUI)
return false
end
elseif cond.type == EnterCheckType.Level then
if Actor.checkActorLevel(pActor, cond.param1, (cond.param2 or 0)) == false then
Actor.sendTipmsg(pActor, "等级转生不满足:"..cond.param1.."级别"..(cond.param2 or 0).."转!", tstUI)
return false
end
end
end
end
-- 这个进入条件满足一条即可
if Conf.fbEnterPass then
for i,cond in ipairs(Conf.fbEnterPass) do
if cond.type == EnterCheckType.Activity then
if Actor.isActivityRunning(pActor, cond.param1) then
return true
end
elseif cond.type == EnterCheckType.Level then
if Actor.checkActorLevel(pActor, cond.param1, (cond.param2 or 0)) then
return true
end
end
end
return false
end
return true
end
-- 副本创建
function OnCreate(fbId, fbEnterType, pFuben)
local thisdata = FubenDispatcher.GetCacheData(pFuben)
-- 重置数据
thisdata.wave = 0
thisdata.phase = PhaseType.Create
thisdata.scenId = 0
end
-- 副本内实体进入
function OnEnter(fbId, fbEnterType, pFuben, scenId, pEntity)
if Actor.getEntityType(pEntity) == enActor then
OnActorEnter(fbId, fbEnterType, pFuben, scenId, pEntity)
end
end
-- 副本帧更新
function OnUpdate(fbId, fbEnterType, pFuben, curTime)
--检查波数刷怪
OnCheckWave(fbId, fbEnterType, pFuben, curTime)
end
-- 实体死亡
function OnDeath(fbId, fbEnterType, pFuben, scenId, pEntity)
if Actor.getEntityType(pEntity) == enMonster then
BroadSchedule(pFuben)
end
end
FubenDispatcher.Reg(FubenEvent.OnCheckEnter, FubenType, OnCheckEnter, "FubenType1.lua")
FubenDispatcher.Reg(FubenEvent.OnCreate, FubenType, OnCreate, "FubenType1.lua")
FubenDispatcher.Reg(FubenEvent.OnEnter, FubenType, OnEnter, "FubenType1.lua")
FubenDispatcher.Reg(FubenEvent.OnUpdate, FubenType, OnUpdate, "FubenType1.lua")
FubenDispatcher.Reg(FubenEvent.OnDeath, FubenType, OnDeath, "FubenType1.lua")

View File

@@ -0,0 +1,174 @@
module("FubenType2", package.seeall)
--[[
PVP副本带刷守卫
个人数据ActorData[fbId]
{
}
全局缓存Cache[fbId]
{
[pFuben] =
{
curSceneId : 副本的当前场景id
nextCheckGuard: 下一次检测守卫生成的时间戳
guardCount = {[i] = num}
}
}
全局数据GlobalData[fbId]
{
}
]]--
--副本类型
local FubenType = 2
--对应的副本配置
local FubenConfig = FubenType2Conf
if FubenConfig == nil then
assert(false)
end
local EnterCheckType =
{
Activity = 1, --检查活动开启param1=活动id
Level = 2, --检查等级达到param1=等级param2=转生
}
--------------------------------------------------------------------
-- 详细逻辑
--------------------------------------------------------------------
--检查刷守卫怪
function OnCheckGuard(fbId, pFuben, curTime)
local thisdata = FubenDispatcher.GetCacheData(pFuben)
if (thisdata.nextCheckGuard or 0) < curTime then
local fbHandle = Fuben.getFubenHandle(pFuben)
local scenHandle = Fuben.getSceneHandleById(thisdata.curSceneId,fbHandle)
local freshConf = FubenConfig[fbId].fbRefresh
thisdata.nextCheckGuard = (thisdata.nextCheckGuard or 0) + 10
for i,info in ipairs(freshConf) do
if thisdata.guardCount == nil then
thisdata.guardCount = {}
end
if (thisdata.guardCount[i] or 0) <= 0 then
local pMonster = Fuben.createOneMonsters(scenHandle, info.entityid, info.x, info.y, 1, 0)
if pMonster then
thisdata.guardCount[i] = (thisdata.guardCount[i] or 0) + 1
Actor.setMonsterProperty(pMonster, PROP_MONSTER_BORNPOINT, i)
end
end
end
end
end
--------------------------------------------------------------------
-- 副本 回调注册
--------------------------------------------------------------------
-- 检查玩家进入
function OnCheckEnter(fbId, fbEnterType, pActor)
local Conf = FubenConfig[fbId]
if Conf == nil then
return false
end
-- 这个进入条件需要全部满足
if Conf.fbEnterLimit then
for i,cond in ipairs(Conf.fbEnterLimit) do
if cond.type == EnterCheckType.Activity then
if Actor.isActivityRunning(pActor, cond.param1) == false then
Actor.sendTipmsg(pActor, "活动:"..cond.param1.." 并未开启!", tstUI)
return false
end
elseif cond.type == EnterCheckType.Level then
if Actor.checkActorLevel(pActor, cond.param1, (cond.param2 or 0)) == false then
--Actor.sendTipmsg(pActor, "等级转生不满足:"..cond.param1.."级"..(cond.param2 or 0).."转!", tstUI)
Actor.sendTipmsgWithId(pActor, tmLevelLimited, tstUI)
return false
end
end
end
end
-- 这个进入条件满足一条即可
if Conf.fbEnterPass then
for i,cond in ipairs(Conf.fbEnterPass) do
if cond.type == EnterCheckType.Activity then
if Actor.isActivityRunning(pActor, cond.param1) then
return true
end
elseif cond.type == EnterCheckType.Level then
if Actor.checkActorLevel(pActor, cond.param1, (cond.param2 or 0)) then
return true
end
end
end
return false
end
return true
end
-- 副本创建
function OnCreate(fbId, fbEnterType, pFuben)
local curSceneId = 0
curSceneId = StaticFubens[fbId].defSceneID
if curSceneId == nil then
curSceneId = StaticFubens[fbId].scenes[1]
end
local thisdata = FubenDispatcher.GetCacheData(pFuben)
thisdata.curSceneId = curSceneId
end
-- 副本内实体进入
function OnEnter(fbId, fbEnterType, pFuben, scenId, pEntity)
if Actor.getEntityType(pEntity) == enActor then
--回血回蓝
local maxhp = Actor.getIntProperty(pEntity,PROP_CREATURE_MAXHP)
Actor.changeHp(pEntity, maxhp)
local maxmp = Actor.getIntProperty(pEntity,PROP_CREATURE_MAXMP)
Actor.changeMp(pEntity, maxmp)
Actor.removePet(pEntity)
end
--单人PVP副本
if fbEnterType == FubenEnterType.Single then
--组队PVP副本
elseif fbEnterType == FubenEnterType.Team then
--多人PVP副本
elseif fbEnterType == FubenEnterType.All then
end
end
-- 副本帧更新
function OnUpdate(fbId, fbEnterType, pFuben, curTime)
--检测守卫怪
OnCheckGuard(fbId, pFuben, curTime)
end
-- 副本内实体死亡
function OnDeath(fbId, fbEnterType, pFuben, scenId, pEntity)
local killerHandle = Actor.getKillHandle(pEntity)
local pKiller = Actor.getEntity(killerHandle)
if Actor.getEntityType(pEntity) == enMonster then
local thisdata = FubenDispatcher.GetCacheData(pFuben)
if thisdata.guardCount == nil then
thisdata.guardCount = {}
end
local i = Actor.getIntProperty(pEntity, PROP_MONSTER_BORNPOINT)
local freshConf = FubenConfig[fbId].fbRefresh
if freshConf and freshConf[i] then
thisdata.guardCount[i] = thisdata.guardCount[i] - 1
end
end
end
FubenDispatcher.Reg(FubenEvent.OnCheckEnter, FubenType, OnCheckEnter, "FubenType2.lua")
FubenDispatcher.Reg(FubenEvent.OnCreate, FubenType, OnCreate, "FubenType2.lua")
FubenDispatcher.Reg(FubenEvent.OnEnter, FubenType, OnEnter, "FubenType2.lua")
FubenDispatcher.Reg(FubenEvent.OnUpdate, FubenType, OnUpdate, "FubenType2.lua")
FubenDispatcher.Reg(FubenEvent.OnDeath, FubenType, OnDeath, "FubenType2.lua")

View File

@@ -0,0 +1,197 @@
module("FubenType4", package.seeall)
--[[
刷怪进度通关副本,退出自动发放奖励(若没领取的话)
个人数据ActorData[fbId]
{
}
全局缓存Cache[fbId]
{
[pFuben] =
{
owner, 所有者玩家id若为0则是公共副本
wave, 当前波数
phase, 当前阶段 0无 1创建 2开始 3进行中 4结算 5结束
scenId, 副本当前场景
hasAwards, 是否可领取奖励
isGot, 是否已领取
}
}
全局数据GlobalData[fbId]
{
}
]]--
--副本类型
local FubenType = 4
--对应的副本配置
local FubenConfig = FubenType4Conf
if FubenConfig == nil then
assert(false)
end
local EnterCheckType =
{
Activity = 1, --检查活动开启param1=活动id
Level = 2, --检查等级达到param1=等级param2=转生
}
local PhaseType =
{
Create = 1, --创建
Start = 2, --开始
Running = 3, --进行中
Finish = 4, --完成
End = 5, --结束
}
--------------------------------------------------------------------
-- 详细逻辑
--------------------------------------------------------------------
function getCacheDataByHandle(fbHandle)
local pFuben = Fuben.getFubenPtrByHandle(fbHandle)
return Fuben.getDyanmicVar(pFuben)
end
--玩家进入副本
function OnActorEnter(fbId, fbEnterType, pFuben, scenId, pActor)
local fbHandle = Fuben.getFubenHandle(pFuben)
local scenHandle = Fuben.getSceneHandleById(scenId,fbHandle)
--单人副本
if fbEnterType == FubenEnterType.Single then
local thisdata = FubenDispatcher.GetCacheData(pFuben)
if thisdata.owner == 0 then
thisdata.owner = Actor.getActorId(pActor)
thisdata.wave = 0
thisdata.phase = PhaseType.Start
thisdata.hasAwards = false
thisdata.isGot = false
--设置副本时间
Fuben.setSceneTime(scenHandle, (FubenConfig[fbId].fbTime or 0))
end
thisdata.scenId = scenId
--组队副本
elseif fbEnterType == FubenEnterType.Team then
--多人副本
elseif fbEnterType == FubenEnterType.All then
end
end
--玩家死亡10秒后才能复活
function OnActorDeath(fbId, fbEnterType, pFuben, scenId, pActor)
--Actor.setReliveTimeOut(pActor, 10)
end
--------------------------------------------------------------------
-- 副本 回调注册
--------------------------------------------------------------------
-- 检查玩家进入
function OnCheckEnter(fbId, fbEnterType, pActor)
local Conf = FubenConfig[fbId]
if Conf == nil then
return false
end
-- 这个进入条件需要全部满足
if Conf.fbEnterLimit then
for i,cond in ipairs(Conf.fbEnterLimit) do
if cond.type == EnterCheckType.Activity then
if Actor.isActivityRunning(pActor, cond.param1) == false then
Actor.sendTipmsg(pActor, "活动:"..cond.param1.." 并未开启!", tstUI)
return false
end
elseif cond.type == EnterCheckType.Level then
if Actor.checkActorLevel(pActor, cond.param1, (cond.param2 or 0)) == false then
Actor.sendTipmsg(pActor, "等级转生不满足:"..cond.param1.."级别"..(cond.param2 or 0).."转!", tstUI)
return false
end
end
end
end
-- 这个进入条件满足一条即可
if Conf.fbEnterPass then
for i,cond in ipairs(Conf.fbEnterPass) do
if cond.type == EnterCheckType.Activity then
if Actor.isActivityRunning(pActor, cond.param1) then
return true
end
elseif cond.type == EnterCheckType.Level then
if Actor.checkActorLevel(pActor, cond.param1, cond.param2) then
return true
end
end
end
return false
end
return true
end
-- 副本创建
function OnCreate(fbId, fbEnterType, pFuben)
local thisdata = FubenDispatcher.GetCacheData(pFuben)
-- 重置数据
thisdata.owner = 0
thisdata.wave = 0
thisdata.phase = PhaseType.Create
thisdata.scenId = 0
end
-- 副本内实体进入
function OnEnter(fbId, fbEnterType, pFuben, scenId, pEntity)
if Actor.getEntityType(pEntity) == enActor then
OnActorEnter(fbId, fbEnterType, pFuben, scenId, pEntity)
end
end
-- 副本内实体退出
function OnExit(fbId, fbEnterType, pFuben, scenId, pEntity)
if Actor.getEntityType(pEntity) == enActor then
--OnGetAward(fbId, fbEnterType, pFuben, scenId, pEntity)
-- ActivityDispatcher.CheckExitFuben(ActivityType8.ActivityType, pEntity, pFuben)
end
end
-- 副本帧更新
function OnUpdate(fbId, fbEnterType, pFuben, curTime)
local thisdata = FubenDispatcher.GetCacheData(pFuben)
local fbHandle = Fuben.getFubenHandle(pFuben)
local scenHandle = Fuben.getSceneHandleById(thisdata.scenId,fbHandle)
end
-- 副本内实体死亡
function OnDeath(fbId, fbEnterType, pFuben, scenId, pEntity)
if Actor.getEntityType(pEntity) == enActor then
--OnActorDeath(fbId, fbEnterType, pFuben, scenId, pEntity)
end
end
-- 请求获取副本奖励
function OnGetAward(fbId, fbEnterType, pFuben, nSceneId, pActor)
end
FubenDispatcher.Reg(FubenEvent.OnCheckEnter, FubenType, OnCheckEnter, "FubenType4.lua")
FubenDispatcher.Reg(FubenEvent.OnCreate, FubenType, OnCreate, "FubenType4.lua")
FubenDispatcher.Reg(FubenEvent.OnEnter, FubenType, OnEnter, "FubenType4.lua")
FubenDispatcher.Reg(FubenEvent.OnExit, FubenType, OnExit, "FubenType4.lua")
FubenDispatcher.Reg(FubenEvent.OnUpdate, FubenType, OnUpdate, "FubenType4.lua")
FubenDispatcher.Reg(FubenEvent.OnDeath, FubenType, OnDeath, "FubenType4.lua")
FubenDispatcher.Reg(FubenEvent.OnGetAward, FubenType, OnGetAward, "FubenType4.lua")

View File

@@ -0,0 +1,3 @@
require("FuBen.FubenType1") --普通刷怪进度副本
require("FuBen.FubenType2") --PVP副本
require("FuBen.FubenType4") --简单副本,藏经峡谷,独闯天涯