init
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
--精英经验殿
|
||||
|
||||
local npcId = 103
|
||||
|
||||
NpcDialog[npcId] = {}
|
||||
local t = NpcDialog[npcId]
|
||||
|
||||
function t.main(sysarg)
|
||||
local str = "\\"
|
||||
local level = Actor.getIntProperty(sysarg, PROP_CREATURE_LEVEL)
|
||||
for i=1,#ExpMapConfig.LevelConfig do
|
||||
if level >= ExpMapConfig.LevelConfig[i].min and level <= ExpMapConfig.LevelConfig[i].max then
|
||||
str = str.."\\<#BL"..ExpMapConfig.LevelConfig[i].menu.."/@EnterExpMap,"..i..">"
|
||||
end
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function EnterExpMap(sysarg,idx)
|
||||
local level = Actor.getIntProperty(sysarg, PROP_CREATURE_LEVEL)
|
||||
local i = tonumber(idx)
|
||||
local cfg = ExpMapConfig.LevelConfig[i]
|
||||
if cfg then
|
||||
if level < cfg.min or level > cfg.max then
|
||||
Actor.sendTipmsg(sysarg,OldLang.Script.ExpMap001, ttFlyTip)
|
||||
return
|
||||
end
|
||||
Actor.enterScene(sysarg,cfg.SceneId, cfg.x, cfg.y)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
NpcFuncs = {}
|
||||
|
||||
local NpcConf = Npc
|
||||
local NpcFunctionsConf = NpcFunctions
|
||||
|
||||
if NpcConf==nil or NpcFunctionsConf==nil then
|
||||
assert(false, "NPC的功能分类配置找不到。")
|
||||
end
|
||||
|
||||
--#include "NpcShop.txt" once --npc商店
|
||||
--#include "NpcTeleport.txt" once --npc传送
|
||||
--#include "NpcUIFuncs.txt" once --npc传送
|
||||
|
||||
function OnNpcEvent(pActor, nNpcHandle, nNpcId, nFuncId, pDPack)
|
||||
|
||||
if NpcFunctionsConf[nFuncId] and NpcFunctionsConf[nFuncId].funcType then
|
||||
local funcType = NpcFunctionsConf[nFuncId].funcType
|
||||
local npcFunc = NpcFuncs[funcType]
|
||||
if npcFunc then
|
||||
print("[OnNpcEvent] nNpcHandle:" .. nNpcHandle .." nNpcId:"..nNpcId.." nFuncId:"..nFuncId.." funcType:"..funcType)
|
||||
print(npcFunc)
|
||||
return npcFunc(pActor, nNpcHandle, nNpcId, nFuncId, pDPack)
|
||||
else
|
||||
print("[ERROR][OnNpcEvent] 没有该功能的NPC实现; nNpcHandle:" .. nNpcHandle .." nNpcId:"..nNpcId.." nFuncId:"..nFuncId.." funcType:"..funcType)
|
||||
end
|
||||
else
|
||||
print("[ERROR][OnNpcEvent] 配置没有该功能ID; nNpcHandle:" .. nNpcHandle .." nNpcId:"..nNpcId.." nFuncId:"..nFuncId)
|
||||
end
|
||||
end
|
||||
|
||||
function OnNpcTimer(npcId, funcName, ... )
|
||||
local npcFunc = NpcDialog[npcId]
|
||||
if npcFunc then
|
||||
local realFunc = npcFunc[funcName]
|
||||
if realFunc then
|
||||
realFunc(unpack(arg))
|
||||
end
|
||||
end
|
||||
end
|
||||
35
server/cross/LogicServer/data/functions/NpcEvent/NpcShop.txt
Normal file
35
server/cross/LogicServer/data/functions/NpcEvent/NpcShop.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
-- 商店类NPC功能
|
||||
|
||||
local NpcFuncType = 1
|
||||
NpcFuncs[NpcFuncType] = {}
|
||||
|
||||
-- 主方法
|
||||
NpcFuncs[NpcFuncType] = function(pActor, nNpcHandle, nNpcId, nFuncId, pDPack)
|
||||
local thisNpcConf = NpcConf[nNpcId]
|
||||
local funcGroup = thisNpcConf.funcGroup
|
||||
-- 检查是否合法的请求NPC
|
||||
if funcGroup then
|
||||
for i,id in ipairs(funcGroup) do
|
||||
if id == nFuncId then
|
||||
local thisFunc = NpcFunctionsConf[id]
|
||||
if thisFunc and thisFunc.funcType and thisFunc.funcType==NpcFuncType then
|
||||
OnOpenStore(pActor, nNpcHandle, thisFunc.param1, thisFunc.param2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--打开商店
|
||||
function OnOpenStore(pActor, nNpcHandle, shoptype, Tabshop)
|
||||
if shoptype and Tabshop then
|
||||
local npack = DataPack.allocPacket(pActor, enStoreSystemID, sOpenStore)
|
||||
if npack then
|
||||
DataPack.writeChar(npack, shoptype)
|
||||
DataPack.writeChar(npack, Tabshop)
|
||||
DataPack.writeUint64(npack, nNpcHandle)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
231
server/cross/LogicServer/data/functions/NpcEvent/NpcTeleport.txt
Normal file
231
server/cross/LogicServer/data/functions/NpcEvent/NpcTeleport.txt
Normal file
@@ -0,0 +1,231 @@
|
||||
--传送类NPC
|
||||
|
||||
local NpcFuncType = 3
|
||||
NpcFuncs[NpcFuncType] = {}
|
||||
|
||||
local editionConf = editionConf
|
||||
local SuitConfig = SuitConfig
|
||||
local NpcTransConf = NpcTransConf
|
||||
|
||||
if NpcTransConf==nil then
|
||||
assert(false, "NPC的传送功能配置找不到。")
|
||||
end
|
||||
|
||||
-- 主方法
|
||||
NpcFuncs[NpcFuncType] = function(pActor, nNpcHandle, nNpcId, nFuncId, packet)
|
||||
-- 传送应该做这里的,带NPC距离检测的。但是已经加了协议,就算了。
|
||||
end
|
||||
|
||||
function inRange(numtmp, numsmall, numbig)
|
||||
num = numtmp - System.getToday()
|
||||
if num < numsmall then
|
||||
return false
|
||||
elseif num > numbig then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--注册消息协议
|
||||
if NetmsgDispatcher then
|
||||
function OnNpcTransform (actor, packet)
|
||||
local npcHandle = DataPack.readUint64(packet)
|
||||
local transId = DataPack.readShort(packet)
|
||||
|
||||
-- 检测NPC距离
|
||||
if transId and NpcTransConf[transId] then
|
||||
local config = NpcTransConf[transId]
|
||||
|
||||
--检测今日传送次数限制
|
||||
if config.limittimes then
|
||||
--检测参与次数
|
||||
local staticTypeKey = config.staticType
|
||||
local tranTimesLimit = config.limittimes
|
||||
if not Actor.checkNpcTranLimit(actor , staticTypeKey,tranTimesLimit) then
|
||||
--Actor.sendTipmsg(actor, "您已达到今日传送次数限制!", ttFlyTip)
|
||||
Actor.sendTipmsgWithId(actor, tmTelePortLimitActivity, ttFlyTip)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if config.activityRequirement then
|
||||
local ColorLv = Actor.GetMaxColorCardLevel(actor)
|
||||
--检测色卡等级限制
|
||||
if config.activityRequirement.CardLv then
|
||||
local ZuiDiLv = config.activityRequirement.CardLv
|
||||
if ColorLv < ZuiDiLv then
|
||||
Actor.sendTipmsg(actor, "特权等级不足 无法传送", ttFlyTip)
|
||||
--Actor.sendTipmsgWithId(actor, tmTelePortLimitActivity, ttFlyTip)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--检测是否在npc附近
|
||||
if config.activityRequirement.distanceLimit then
|
||||
if Actor.CheckDistanceByHandle(actor,npcHandle,config.activityRequirement.distanceLimit) ~= true then
|
||||
Actor.sendTipmsg(actor, "|C:0xf56f00&T:距离NPC太远,无法传送|", ttFlyTip)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--检测开放时间
|
||||
if config.activityRequirement.opentime then
|
||||
--检测开放时间
|
||||
local secondTimeNow = System.getCurrMiniTime()
|
||||
local openTimeflag = false
|
||||
for i, k in ipairs(config.activityRequirement.opentime) do
|
||||
if inRange(secondTimeNow,k.openMinute, k.closeMinute) then
|
||||
openTimeflag = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if openTimeflag~= true then
|
||||
--Actor.sendTipmsg(actor, "未到开放时间 无法进入!", ttFlyTip)
|
||||
Actor.sendTipmsgWithId(actor, tmTelePortTimeUnopen, ttFlyTip)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--检测杀怪个数
|
||||
if config.activityRequirement.activityId then
|
||||
local atvId = config.activityRequirement.activityId
|
||||
local actorData = ActivityDispatcher.GetActorData(actor,atvId)
|
||||
if actorData.monsterCount <10 then
|
||||
--if actorData.monsterCount <1 then
|
||||
--Actor.sendTipmsg(actor, tmKillMonsterNotEnouth, ttFlyTip)
|
||||
Actor.sendTipmsgWithId(actor, tmKillMonsterNotEnouth, ttFlyTip)
|
||||
--print("活动,杀怪不够,无法传送")
|
||||
return
|
||||
end
|
||||
end
|
||||
-- 狂暴
|
||||
if config.activityRequirement.isRageconst and Actor.checkKuangbao(actor, config.activityRequirement.isRageconst) ~= true then
|
||||
Actor.sendTipmsgWithId(actor, tmkuangbaolimir, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 神魔
|
||||
if config.activityRequirement.demonsconstLv then
|
||||
local num = Actor.getGhostSumLv(actor)
|
||||
if num < config.activityRequirement.demonsconstLv then
|
||||
Actor.sendTipmsgWithParams(actor, tmghostlimit, tstUI, config.activityRequirement.demonsconstLv)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 等级检测
|
||||
if config.nLevel and Actor.checkActorLevel(actor, config.nLevel, 0) ~= true then
|
||||
--local tips = string.format(Lang.TisMsg.xxx, config.nLevel)
|
||||
--Actor.sendTipmsg(actor, "等级不足!", ttFlyTip)
|
||||
return
|
||||
end
|
||||
|
||||
-- 检查转生
|
||||
local zs = config.zsLevel and Actor.checkActorLevel(actor, 0, config.zsLevel)
|
||||
--local tips = string.format(Lang.TisMsg.xxx, config.nLevel)
|
||||
--Actor.sendTipmsg(actor, "等级不足!", ttFlyTip)
|
||||
if editionConf.suit == System.getServerId() and config.suit then
|
||||
-- 检查套装
|
||||
local suit = SuitConfig[config.suit]
|
||||
if suit and suit.equip then
|
||||
local myJob = Actor.getIntProperty(actor, PROP_ACTOR_VOCATION)
|
||||
for _, v in pairs(suit.equip or {}) do -- 遍历套装配置
|
||||
if (not v.job or v.job and v.job == myJob) and false == Actor.hasEquiment(actor, v.id) then
|
||||
--Actor.sendTipmsg(actor, "未穿戴套装["..v.name.."]", tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if zs ~= true then return end
|
||||
end
|
||||
|
||||
-- 场景传送检测
|
||||
if not Actor.canTelport(actor, config.nSceneId) then
|
||||
Actor.sendTipmsg(actor, "该场景不给传送!", ttFlyTip)
|
||||
return
|
||||
end
|
||||
|
||||
--开服天数检测
|
||||
if config.openDay then
|
||||
if System.getDaysSinceOpenServer() < config.openDay then
|
||||
Actor.sendTipmsg(actor, "开服天数未到", ttFlyTip)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--充值检测
|
||||
if config.dayRecharge then
|
||||
--[[local userData = ActivityType10027.GetKu25UserData(actor)
|
||||
local todayRecharge = userData and userData.OneDayRechargesYBNum or -1
|
||||
if todayRecharge < config.dayRecharge then -- not Actor.checkRecharge(config.dayRecharge)
|
||||
--print("need dayRecharge="..config.dayRecharge..", today recharge="..todayRecharge..", error")
|
||||
Actor.sendTipmsg(actor, "充值条件不足", tstUI)
|
||||
return
|
||||
end]]
|
||||
--print("need dayRecharge="..config.dayRecharge..", today recharge="..todayRecharge..", ok")
|
||||
--色卡检测
|
||||
local ColorLv = Actor.GetMaxColorCardLevel(actor)
|
||||
--Actor.sendTipmsg(actor, "need CardLevel="..config.dayRecharge..", my CardLevel="..ColorLv, ttFlyTip)
|
||||
if ColorLv < config.dayRecharge then
|
||||
Actor.sendTipmsg(actor, "特权等级不足,无法传送", ttFlyTip)
|
||||
--Actor.sendTipmsgWithId(actor, tmTelePortLimitActivity, ttFlyTip)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 消耗检测
|
||||
local consumes = config.Consumelist
|
||||
if consumes then
|
||||
if CommonFunc.Consumes.Check(actor, consumes) ~= true then
|
||||
Actor.sendTipmsg(actor, "道具或金币元宝不足!", ttFlyTip)
|
||||
return
|
||||
end
|
||||
if CommonFunc.Consumes.Remove(actor, consumes, GameLog.Log_NPCTelep, "NPC传送") ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 传送
|
||||
Actor.enterScene(actor, config.nSceneId, config.nX, config.nY)
|
||||
-- 计入传送次数
|
||||
if config.limittimes then
|
||||
Actor.addNpcTranTimes(actor , config.staticType,1)
|
||||
end
|
||||
if config.activityRequirement then
|
||||
if config.activityRequirement.activityId then
|
||||
local atvId = config.activityRequirement.activityId
|
||||
local actorData = ActivityDispatcher.GetActorData(actor,atvId)
|
||||
actorData.monsterCount = 0
|
||||
end
|
||||
end
|
||||
|
||||
local mapGroup = 0
|
||||
local SceneData = Scenes[config.nSceneId]
|
||||
if SceneData then
|
||||
mapGroup = SceneData.mapGgroup;
|
||||
end
|
||||
if config.jiontime then
|
||||
Actor.SetNpcTeleport(actor, config.nSceneId,config.jiontime, mapGroup);
|
||||
end
|
||||
if config.jionmsg then
|
||||
local SceneData = Scenes[config.nSceneId]
|
||||
local name = Actor.getName(actor);
|
||||
if SceneData then
|
||||
local tips = string.format(config.jionmsg,name, SceneData.scencename)
|
||||
System.broadcastTipmsgLimitLev(tips, tstKillDrop)
|
||||
end
|
||||
end
|
||||
|
||||
local npack = DataPack.allocPacket(actor, enMoveSystemID, sNpcTransform)
|
||||
if npack then
|
||||
DataPack.writeInt(npack, (config.jiontime or 0))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enMoveSystemID, cNpcTransform or 6, OnNpcTransform)
|
||||
end
|
||||
146
server/cross/LogicServer/data/functions/NpcEvent/NpcUIFuncs.txt
Normal file
146
server/cross/LogicServer/data/functions/NpcEvent/NpcUIFuncs.txt
Normal file
@@ -0,0 +1,146 @@
|
||||
--UI展示功能类NPC
|
||||
|
||||
local NpcFuncType = 2
|
||||
NpcFuncs[NpcFuncType] = {}
|
||||
|
||||
local EnUIType = {
|
||||
RedName = 1, --洗红名
|
||||
}
|
||||
|
||||
-- 主方法
|
||||
NpcFuncs[NpcFuncType] = function(pActor, nNpcHandle, nNpcId, nFuncId, packet)
|
||||
local thisNpcConf = NpcConf[nNpcId]
|
||||
local funcGroup = thisNpcConf.funcGroup
|
||||
-- 检查是否合法的请求NPC
|
||||
if funcGroup then
|
||||
for i,id in ipairs(funcGroup) do
|
||||
if id == nFuncId then
|
||||
local thisFunc = NpcFunctionsConf[id]
|
||||
if thisFunc and thisFunc.funcType and thisFunc.funcType==NpcFuncType then
|
||||
OnUIFunctions(pActor, thisFunc, packet)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取NpcUIFuncs(UI展示功能类NPC的玩家数据)
|
||||
function GetUIFuncData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if var then
|
||||
if var.UIFunc == nil then
|
||||
var.UIFunc = {}
|
||||
end
|
||||
return var.UIFunc
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--UI功能
|
||||
function OnUIFunctions(pActor, thisFuncConf, packet)
|
||||
|
||||
if thisFuncConf.param2 == EnUIType.RedName then
|
||||
OnRedNameCmd(pActor,thisFuncConf,packet)--洗红名
|
||||
end
|
||||
end
|
||||
|
||||
--UI功能:清除红名PK值
|
||||
function OnRedNameCmd(pActor, thisFuncConf, packet)
|
||||
local useType = DataPack.readByte(packet)
|
||||
local conf = thisFuncConf.param3
|
||||
if conf and conf[useType+1] then
|
||||
conf = conf[useType+1]
|
||||
local data = GetUIFuncData(pActor)
|
||||
|
||||
-- PK值为0不处理
|
||||
local curPk = Actor.getIntProperty(pActor,PROP_ACTOR_PK_VALUE)
|
||||
if curPk <= 0 then
|
||||
Actor.sendTipmsg(pActor, "PK值已经为0", tstUI)
|
||||
return
|
||||
end
|
||||
-- 消耗检测
|
||||
local consumes = {}
|
||||
if conf.consume then
|
||||
table.insert( consumes, conf.consume )
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
Actor.sendTipmsg(pActor, "道具或金币元宝不足!", tstEcomeny)
|
||||
return
|
||||
end
|
||||
end
|
||||
-- 次数检测,并增加
|
||||
if conf.limitday and conf.limitday > 0 then
|
||||
if data then
|
||||
if data.PKLimit == nil then
|
||||
data.PKLimit = {}
|
||||
data.PKLimit[useType] = 0
|
||||
end
|
||||
if data.PKLimit[useType] then
|
||||
if data.PKLimit[useType] >= conf.limitday then
|
||||
Actor.sendTipmsg(pActor, "已超过今日次数!", tstUI)
|
||||
return
|
||||
end
|
||||
data.PKLimit[useType] = data.PKLimit[useType] + 1
|
||||
else
|
||||
data.PKLimit[useType] = 1
|
||||
end
|
||||
else
|
||||
assert("获取个人脚本数据出错")
|
||||
end
|
||||
end
|
||||
-- 消耗
|
||||
if CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_CleanRedName, "清除红名PK值") ~= true then
|
||||
return
|
||||
end
|
||||
-- 减PK值
|
||||
if curPk <= conf.pkval then
|
||||
Actor.sendTipmsg(pActor, "已减少"..curPk.."点pk值", tstEcomeny)
|
||||
curPk = 0
|
||||
else
|
||||
Actor.sendTipmsg(pActor, "已减少"..conf.pkval.."点pk值", tstEcomeny)
|
||||
curPk = curPk - conf.pkval
|
||||
end
|
||||
Actor.setUIntProperty(pActor,PROP_ACTOR_PK_VALUE,curPk)
|
||||
|
||||
-- 发送今天已洗红名次数
|
||||
local netPack = DataPack.allocPacket(pActor, enMiscSystemID, sSendPkValueWashCount)
|
||||
if netPack then
|
||||
local num = 0;
|
||||
if data.PKLimit then num = data.PKLimit[0] or 0 end;
|
||||
DataPack.writeChar(netPack, num or 0)
|
||||
DataPack.flush(netPack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function OnNPCUIFuncNewDay(pActor,args)
|
||||
local data = GetUIFuncData(pActor);
|
||||
if data and data.PKLimit then
|
||||
data.PKLimit = nil -- 清空洗PK值次数计数
|
||||
end
|
||||
|
||||
-- 发送今天已洗红名次数
|
||||
local netPack = DataPack.allocPacket(pActor, enMiscSystemID, sSendPkValueWashCount)
|
||||
if netPack then
|
||||
DataPack.writeChar(netPack, 0)
|
||||
DataPack.flush(netPack)
|
||||
end
|
||||
end
|
||||
|
||||
function OnNPCUIFuncLogin(pActor,args)
|
||||
-- 发送今天已洗红名次数
|
||||
local netPack = DataPack.allocPacket(pActor, enMiscSystemID, sSendPkValueWashCount)
|
||||
if netPack then
|
||||
local data = GetUIFuncData(pActor)
|
||||
if data and data.PKLimit then
|
||||
DataPack.writeChar(netPack, (data.PKLimit[0] or 0))
|
||||
--print("["..Actor.getName(pActor).."]剩余洗红名次数为:"..(data.PKLimit[0] or 0))
|
||||
else
|
||||
DataPack.writeChar(netPack, 0)
|
||||
--print("["..Actor.getName(pActor).."]剩余洗红名次数为:".. 0)
|
||||
end
|
||||
DataPack.flush(netPack)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive,OnNPCUIFuncNewDay,"NpcUIFuncs.txt")
|
||||
ActorEventDispatcher.Reg(aeUserLogin,OnNPCUIFuncLogin,"NpcUIFuncs.txt")
|
||||
Reference in New Issue
Block a user