增加自动检测周围物品回收召唤小精灵
This commit is contained in:
parent
31b22a7390
commit
2c00b3bc95
9 changed files with 130892 additions and 130498 deletions
|
|
@ -184,6 +184,7 @@ VarCfg.sys.TL.int["
|
|||
----* 定时器编号
|
||||
VarCfg.Timer = {}
|
||||
VarCfg.Timer["攻沙定时器"] = 20
|
||||
VarCfg.Timer["ʰȡ¾«ÁéѲ¼ì"] = 21
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ BOSSqueryOBJ:reloadBossCache()
|
|||
---* 客户端请求入口(由 Message.dispatch 自动调用)
|
||||
---@param actor any 玩家对象
|
||||
function BOSSqueryOBJ:main(actor)
|
||||
if getflagstatus(actor, VarCfg.Falg_tequan) == 0 then
|
||||
Func.sendmsg9(actor, "[BOSS查询]:#70|开通王者特权后才可使用!")
|
||||
return
|
||||
end
|
||||
-- 首次调用时缓存可能为空,立即刷新一次
|
||||
if not self.bossCache or #self.bossCache == 0 then
|
||||
self:reloadBossCache()
|
||||
|
|
|
|||
|
|
@ -452,12 +452,12 @@ ClickOnItem.cfg = {
|
|||
---* 拾取精灵:嗷嗷虎
|
||||
["拾取精灵:嗷嗷虎"] = function(actor, ...)
|
||||
if getflagstatus(actor, VarCfg.Falg_shiqujinlin) == 1 then
|
||||
OntimerOBJ:startPickupSpriteTimer(actor)
|
||||
Func.sendmsg9(actor, "[嗷嗷虎]:#70|拾取精灵已激活,无需重复使用!")
|
||||
return false
|
||||
end
|
||||
setflagstatus(actor, VarCfg.Falg_shiqujinlin, 1)
|
||||
createsprite(actor, "ŕťŕťť˘")
|
||||
pickupitems(actor, 3, 8, 500)
|
||||
OntimerOBJ:startPickupSpriteTimer(actor)
|
||||
Func.sendmsg9(actor, "[嗷嗷虎]:#70|拾取精灵已激活,10格范围自动拾取开启!")
|
||||
return true
|
||||
end,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,64 @@
|
|||
OntimerOBJ = {}
|
||||
function OntimerOBJ:hasPickupDrop(actor)
|
||||
local mapid = getbaseinfo(actor, ConstCfg.gbase.mapid)
|
||||
local x = getbaseinfo(actor, ConstCfg.gbase.x)
|
||||
local y = getbaseinfo(actor, ConstCfg.gbase.y)
|
||||
if not mapid or mapid == "" or not x or not y then
|
||||
return false
|
||||
end
|
||||
|
||||
local items = getobjectinmap(mapid, x, y, 10, 8)
|
||||
return items and next(items) ~= nil
|
||||
end
|
||||
|
||||
function OntimerOBJ:refreshPickupSprite(actor)
|
||||
local timerId = VarCfg.Timer["ʰȡ¾«ÁéѲ¼ì"]
|
||||
|
||||
if getflagstatus(actor, VarCfg.Falg_shiqujinlin) ~= 1 then
|
||||
pickupitems(actor, -1)
|
||||
releasesprite(actor)
|
||||
setofftimer(actor, timerId)
|
||||
return
|
||||
end
|
||||
|
||||
local hasDrop = self:hasPickupDrop(actor)
|
||||
local hasSprite = checkspritelevel(actor, "à»à»»¢")
|
||||
|
||||
if hasDrop then
|
||||
if not hasSprite then
|
||||
createsprite(actor, "à»à»»¢")
|
||||
pickupitems(actor, 3, 10, 1000)
|
||||
end
|
||||
else
|
||||
if hasSprite then
|
||||
pickupitems(actor, -1)
|
||||
releasesprite(actor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function OntimerOBJ:startPickupSpriteTimer(actor)
|
||||
local timerId = VarCfg.Timer["ʰȡ¾«ÁéѲ¼ì"]
|
||||
if getflagstatus(actor, VarCfg.Falg_shiqujinlin) ~= 1 then
|
||||
self:stopPickupSpriteTimer(actor)
|
||||
return
|
||||
end
|
||||
|
||||
if not hastimer(actor, timerId) then
|
||||
setontimer(actor, timerId, 3, 0)
|
||||
end
|
||||
self:refreshPickupSprite(actor)
|
||||
end
|
||||
|
||||
function OntimerOBJ:stopPickupSpriteTimer(actor)
|
||||
local timerId = VarCfg.Timer["ʰȡ¾«ÁéѲ¼ì"]
|
||||
if hastimer(actor, timerId) then
|
||||
setofftimer(actor, timerId)
|
||||
end
|
||||
pickupitems(actor, -1)
|
||||
releasesprite(actor)
|
||||
end
|
||||
|
||||
|
||||
|
||||
OntimerOBJ.ontimer = {
|
||||
|
|
@ -33,6 +93,10 @@ OntimerOBJ.ontimer = {
|
|||
local _min = Player.getTLint(actor, VarCfg.Player.TL.int["攻城区域计秒"]) or 0
|
||||
Player.setTLint(actor, VarCfg.Player.TL.int["攻城区域计秒"], _min + 1)
|
||||
LOGDump("攻城区域计秒: " .. _min)
|
||||
end,
|
||||
|
||||
[21] = function(actor)
|
||||
OntimerOBJ:refreshPickupSprite(actor)
|
||||
end
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +112,9 @@ OntimerOBJ.ontimer = {
|
|||
|
||||
for i, v in pairs(VarCfg.Timer or {}) do
|
||||
_G["ontimer" .. v] = function(actor)
|
||||
OntimerOBJ.ontimer[v](actor)
|
||||
if OntimerOBJ.ontimer[v] then
|
||||
OntimerOBJ.ontimer[v](actor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -56,4 +122,9 @@ end
|
|||
|
||||
|
||||
|
||||
GameEvent.add(EventCfg.onExitGame, function(actor)
|
||||
OntimerOBJ:stopPickupSpriteTimer(actor)
|
||||
end, OntimerOBJ)
|
||||
|
||||
|
||||
return OntimerOBJ
|
||||
|
|
|
|||
|
|
@ -113,8 +113,7 @@ function PlayerLogin:Login(actor)
|
|||
|
||||
---* ¼¤»îʰȡ¾«Áé
|
||||
if getflagstatus(actor, VarCfg.Falg_shiqujinlin) == 1 then
|
||||
createsprite(actor, "ŕťŕťť˘")
|
||||
pickupitems(actor, 3, 10, 1000)
|
||||
OntimerOBJ:startPickupSpriteTimer(actor)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -34,3 +34,5 @@ $HUMAN(STR_
|
|||
$HUMAN(INT_攻城区域计秒)
|
||||
$HUMAN(INT_月卡)
|
||||
$HUMAN(INT_自动苹果)
|
||||
$HUMAN(STR_À۳佱Àø)
|
||||
$HUMAN(INT_ÀۼƳäÖµ½ð¶î)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ function YueKaOBJ:updata()
|
|||
RedDotMgr.detachDot(self.ui.buy_btn)
|
||||
local yuanbaoNum = tonumber(SL:Get_MONEY(ssrConstCfg.Money["元宝"])) or 0
|
||||
if not isOpen and yuanbaoNum >= (tonumber(self.cfg.price) or 680) then
|
||||
RedDotMgr.attachDot(self.ui.buy_btn, { x = 168, y = 48 })
|
||||
RedDotMgr.attachDot(self.ui.buy_btn, { x = 80, y = 38 })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -100,6 +100,11 @@ function YueKaOBJ:EventBind()
|
|||
end
|
||||
end
|
||||
SL:RegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname, YueKaOBJ_Var_Change)
|
||||
SL:RegisterLUAEvent(LUA_EVENT_MONEY_CHANGE, self.__cname, function()
|
||||
if GUI:Win_IsNotNull(self._parent) then
|
||||
self:updata()
|
||||
end
|
||||
end)
|
||||
|
||||
SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname, function(widgetName)
|
||||
self:OnClose(widgetName)
|
||||
|
|
@ -114,6 +119,7 @@ end
|
|||
|
||||
function YueKaOBJ:UnRegisterEvent()
|
||||
SL:UnRegisterLUAEvent(LUA_EVENT_SERVER_VALUE_CHANGE, self.__cname)
|
||||
SL:UnRegisterLUAEvent(LUA_EVENT_MONEY_CHANGE, self.__cname)
|
||||
SL:UnRegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.__cname)
|
||||
end
|
||||
|
||||
|
|
@ -125,6 +131,7 @@ if RedDotMgr and RedDotMgr.register then
|
|||
return nil
|
||||
end,
|
||||
watchKeys = { "HUMAN(INT_月卡)" },
|
||||
watchMoney = true,
|
||||
check = function()
|
||||
local expireTime = 0
|
||||
if SL and SL.GetMetaValue then
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ RedDotMgr._nodes = RedDotMgr._nodes or {} --key -> conf
|
|||
RedDotMgr._watchKey2Keys = RedDotMgr._watchKey2Keys or {} --服务器变量 key -> { redKey1, ... }
|
||||
RedDotMgr._watchLevelKeys = RedDotMgr._watchLevelKeys or {} --监听等级变化的 key 集合
|
||||
RedDotMgr._watchBagKeys = RedDotMgr._watchBagKeys or {} --监听背包变化的 key 集合
|
||||
RedDotMgr._watchMoneyKeys = RedDotMgr._watchMoneyKeys or {} --监听货币变化的 key 集合
|
||||
RedDotMgr._watchTitleKeys = RedDotMgr._watchTitleKeys or {} --监听称号变化的 key 集合
|
||||
RedDotMgr._parent2Children = RedDotMgr._parent2Children or {} --parent -> { childKey1, ... }
|
||||
RedDotMgr._owner2Keys = RedDotMgr._owner2Keys or {} --owner(业务模块 __cname) -> { redKey1, ... }
|
||||
|
|
@ -24,6 +25,7 @@ RedDotMgr.DEFAULT_EFFECT_ID = 50378 --全局默认特效 ID;nil 则回退为
|
|||
-- watchKeys : { "{8}", "HUMAN(STR_xx)" } 监听的服务器变量
|
||||
-- watchLevel : true|false 是否监听等级 / 转生
|
||||
-- watchBag : true|false 是否监听背包物品变化
|
||||
-- watchMoney : true|false 是否监听货币变化
|
||||
-- watchTitle : true|false 是否监听称号变化(LUA_EVENT_TITLE_REFRESH)
|
||||
-- parent : "TopIcon_5" 父 key(子亮则父跟着亮)
|
||||
-- offset : { x=5, y=5 } 红点偏移;省略时取 DEFAULT_OFFSET
|
||||
|
|
@ -55,6 +57,9 @@ function RedDotMgr:register(key, conf)
|
|||
if conf.watchBag then
|
||||
self._watchBagKeys[key] = true
|
||||
end
|
||||
if conf.watchMoney then
|
||||
self._watchMoneyKeys[key] = true
|
||||
end
|
||||
if conf.watchTitle then
|
||||
self._watchTitleKeys[key] = true
|
||||
end
|
||||
|
|
@ -103,6 +108,7 @@ function RedDotMgr:unregister(key)
|
|||
end
|
||||
self._watchLevelKeys[key] = nil
|
||||
self._watchBagKeys[key] = nil
|
||||
self._watchMoneyKeys[key] = nil
|
||||
self._watchTitleKeys[key] = nil
|
||||
if conf.parent then
|
||||
local list = self._parent2Children[conf.parent]
|
||||
|
|
@ -306,6 +312,16 @@ function RedDotMgr:_initListener()
|
|||
end
|
||||
end)
|
||||
|
||||
SL:RegisterLUAEvent(LUA_EVENT_MONEY_CHANGE, "RedDotMgr", function()
|
||||
local snapshot = {}
|
||||
for k in pairs(self._watchMoneyKeys) do
|
||||
table.insert(snapshot, k)
|
||||
end
|
||||
for _, k in ipairs(snapshot) do
|
||||
self:refresh(k)
|
||||
end
|
||||
end)
|
||||
|
||||
--称号变化(获得 / 失去称号):只刷明确声明了 watchTitle = true 的节点
|
||||
--谁需要谁自己勾选,不做全量 refreshAll,避免不相干红点被误触
|
||||
SL:RegisterLUAEvent(LUA_EVENT_TITLE_REFRESH, "RedDotMgr", function()
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue