1505 lines
35 KiB
Lua
1505 lines
35 KiB
Lua
-- require("Envir/QuestDiary/config/VarCfg.lua")
|
||
-- require("Envir/Market_Def/denglujiemian.lua")
|
||
|
||
--获取玩家自定义数值变量
|
||
function getint(player,bianlian)
|
||
return GetInt(0,player,bianlian)
|
||
end
|
||
|
||
--获取玩家自定义字符变量
|
||
function getstr(player,bianlian)
|
||
return GetStr(0,player,bianlian)
|
||
end
|
||
|
||
--设置玩家自定义数值变量
|
||
function setint(player,bianlian,zhi)
|
||
SetInt(0,player,bianlian,zhi)
|
||
end
|
||
|
||
--设置玩家自定义字符变量
|
||
function setstr(player,bianlian,zhi)
|
||
SetStr(0,player,bianlian,zhi)
|
||
end
|
||
|
||
--获取自定义数值系统变量
|
||
function getsysint(bianlian)
|
||
return GetSysInt(bianlian)
|
||
end
|
||
|
||
--获取自定义字符系统变量
|
||
function getsysstr(bianlian)
|
||
return GetSysStr(bianlian)
|
||
end
|
||
|
||
--设置自定义数值系统变量
|
||
function setsysint(bianlian,value,itype)
|
||
if not itype then
|
||
itype = 0
|
||
end
|
||
|
||
if type(value) ~= "number" then
|
||
release_print("SetTempDBInt类型错误:" .. type(value))
|
||
return
|
||
end
|
||
|
||
SetSysInt(bianlian,value,itype)
|
||
end
|
||
|
||
--设置自定义字符系统变量
|
||
function setsysstr(bianlian,value,itype)
|
||
if not itype then
|
||
itype = 0
|
||
end
|
||
|
||
if type(value) ~= "string" then
|
||
release_print("SetDBStr类型错误:" .. type(value))
|
||
return
|
||
end
|
||
SetSysStr(bianlian,value,itype)
|
||
end
|
||
|
||
--设置全局临时I变量
|
||
function SetIVar(index, value, itype)
|
||
if not itype then
|
||
itype = 0
|
||
end
|
||
|
||
if index > 99 then
|
||
release_print("SetTempDBInt超出范围:" .. index)
|
||
return
|
||
end
|
||
|
||
if type(value) ~= "number" then
|
||
release_print("SetTempDBInt类型错误:" .. type(value))
|
||
return
|
||
end
|
||
|
||
SetSysInt("I" .. index, value, itype)
|
||
end
|
||
|
||
--获取全局临时I变量
|
||
function GetIVar(index)
|
||
if index > 99 then
|
||
release_print("GetTempDBInt超出范围:" .. index)
|
||
return
|
||
end
|
||
|
||
return GetSysStr("I" .. index)
|
||
end
|
||
|
||
--设置全局A变量
|
||
function SetAVar(index, value, itype)
|
||
if not itype then
|
||
itype = 0
|
||
end
|
||
|
||
if index > 499 then
|
||
release_print("SetDBStr超出范围:" .. index)
|
||
return
|
||
end
|
||
|
||
if type(value) ~= "string" then
|
||
release_print("SetDBStr类型错误:" .. type(value))
|
||
return
|
||
end
|
||
|
||
SetSysStr("A" .. index, value, itype)
|
||
end
|
||
|
||
--获取全局A变量
|
||
function GetAVar(index)
|
||
if index > 499 then
|
||
release_print("GetDBStr超出范围:" .. index)
|
||
return
|
||
end
|
||
return GetSysStr("A" .. index)
|
||
end
|
||
|
||
--设置全局G变量
|
||
function SetGVar(index, value, itype)
|
||
if not itype then
|
||
itype = 0
|
||
end
|
||
|
||
if index > 499 then
|
||
release_print("SetDBInt超出范围:" .. index)
|
||
return
|
||
end
|
||
|
||
if type(value) ~= "number" then
|
||
release_print("SetDBInt类型错误:" .. type(value))
|
||
return
|
||
end
|
||
SetSysStr("G" .. index, value, itype)
|
||
end
|
||
|
||
--获取全局G变量
|
||
function GetGVar(index)
|
||
if index > 499 then
|
||
release_print("GetDBInt超出范围:" .. index)
|
||
return
|
||
end
|
||
return GetSysStr("G" .. index)
|
||
end
|
||
|
||
--获取玩家数值型天变量
|
||
function getdayint(actor,bianliang)
|
||
local biao = {}
|
||
local s = GetStr(0,actor,"Z0")
|
||
local n = 0
|
||
if s ~= "" then
|
||
local z = json2tbl(s)
|
||
if not z then
|
||
SetStr(0,actor,"Z0","")
|
||
end
|
||
for k,v in pairs(z) do
|
||
if k == bianliang then
|
||
n = v
|
||
break
|
||
end
|
||
end
|
||
end
|
||
return n
|
||
end
|
||
--设置玩家数值型天变量
|
||
function setdayint(actor,bianliang,num)
|
||
if type(num) ~= "number" then
|
||
return
|
||
end
|
||
local biao = {}
|
||
local s = GetStr(0,actor,"Z0")
|
||
if s ~= "" then
|
||
biao = json2tbl(s)
|
||
end
|
||
biao[bianliang] = num
|
||
SetStr(0,actor,"Z0",tbl2json(biao))
|
||
end
|
||
|
||
--获取玩家字符型天变量
|
||
function getdaystr(actor,bianliang)
|
||
local biao = {}
|
||
local s = GetStr(0,actor,"Z1")
|
||
local n = ""
|
||
if s ~= "" then
|
||
local z = json2tbl(s)
|
||
if not z then
|
||
SetStr(0,actor,"Z1","")
|
||
end
|
||
for k,v in pairs(z) do
|
||
if k == bianliang then
|
||
n = v
|
||
break
|
||
end
|
||
end
|
||
end
|
||
return n
|
||
end
|
||
--设置玩家字符型天变量
|
||
function setdaystr(actor,bianliang,str)
|
||
if type(str) ~= "string" then
|
||
return
|
||
end
|
||
local biao = {}
|
||
local s = GetStr(0,actor,"Z1")
|
||
if s ~= "" then
|
||
biao = json2tbl(s)
|
||
end
|
||
biao[bianliang] = str
|
||
SetStr(0,actor,"Z1",tbl2json(biao))
|
||
end
|
||
|
||
--检查一个对象的范围
|
||
function FCheckRange(obj, x, y, range)
|
||
local cur_x, cur_y = getbaseinfo(obj, 4), getbaseinfo(obj, 5)
|
||
local min_x, max_x = x-range, x+range
|
||
local min_y, max_y = y-range, y+range
|
||
|
||
if (cur_x >= min_x) and (cur_x <= max_x) and (cur_y >= min_y) and (cur_y <= max_y) then
|
||
return true
|
||
end
|
||
return false
|
||
end
|
||
--带颜色的字符串
|
||
function sencolormsg(actor,idx,msg,co1,co2)
|
||
local x = getconst(actor,'$SCREENWIDTH') * 0.5
|
||
local y = getconst(actor,'$SCREENHEIGHT') * 0.65
|
||
sendcustommsg(actor,idx,msg,co1,co2,x,y)
|
||
end
|
||
--获取宠物宝宝列表
|
||
function getbaobaolist(actor)
|
||
local t = {}
|
||
local ncount=getbaseinfo(actor,38)
|
||
for i = 0 ,ncount-1 do
|
||
mon = getslavebyindex(actor, i)
|
||
table.insert(t,mon)
|
||
end
|
||
return t
|
||
end
|
||
--发送消息类型9
|
||
function sendmsg9(actor,msg,yanse,miaobian)
|
||
if yanse == nil then
|
||
yanse = "#FFFFFF"
|
||
end
|
||
if miaobian == nil then
|
||
if getispc(actor) then
|
||
miaobian = 1
|
||
else
|
||
miaobian = 0
|
||
end
|
||
end
|
||
sendmsg(actor,1,[[{"Msg":"<outline size=']].. miaobian ..[['> <font color=']].. yanse ..[['>]]..msg..[[</font> </outline>","Type":9,"Time":"1"}]])
|
||
end
|
||
--发送提示消息
|
||
function sendmsg6(actor,msg,yanse)
|
||
if yanse == nil then
|
||
yanse = "#ff0000"
|
||
end
|
||
callscriptex(actor, "SENDMSG", 6, "<font color=\'".. yanse .."\'>".. msg .."</font>")
|
||
end
|
||
--全区上部缩放系统公告
|
||
function sendmsg13(actor,msg)
|
||
sendmsg(actor,2,'{"Msg":"'.. msg ..'","FColor":255,"BColor":0,"Type":13,"Time":5}')
|
||
end
|
||
|
||
--全区聊天框系统公告
|
||
function sendmsg0(actor,msg,qianse,house)
|
||
qianse = qianse or 255 --前景色
|
||
house = house or 56 --背景色
|
||
sendmsg(actor,2,'{"Msg":"'.. msg ..'","FColor":'.. qianse ..',"BColor":'.. house ..',"Type":1}')
|
||
end
|
||
|
||
--获取对象名字
|
||
function getname(actor) --名字
|
||
return getbaseinfo(actor,1)
|
||
end
|
||
--获取对象地图id
|
||
function getmap(actor) --地图id
|
||
return getbaseinfo(actor,3)
|
||
end
|
||
--获取对象x坐标
|
||
function getx(actor) --x坐标
|
||
return getbaseinfo(actor,4)
|
||
end
|
||
--获取对象y坐标
|
||
function gety(actor) --y坐标
|
||
return getbaseinfo(actor,5)
|
||
end
|
||
--获取等级
|
||
function getlevel(actor) --等级
|
||
return getbaseinfo(actor,6)
|
||
end
|
||
--设置等级
|
||
function setlevel(actor,zhi) --等级
|
||
changelevel(actor,"=",zhi)
|
||
--setbaseinfo(actor,6,zhi)
|
||
end
|
||
--获取转生等级
|
||
function getzslevel(actor)
|
||
return getbaseinfo(actor,39)
|
||
end
|
||
--获取职业
|
||
function getjob(actor) --职业0 1 2 战法道
|
||
return getbaseinfo(actor,7)
|
||
end
|
||
--设置职业
|
||
function setjob(actor,zhi) --职业0 1 2 战法道
|
||
setbaseinfo(actor,7,zhi)
|
||
end
|
||
|
||
--获取性别
|
||
function getsex(actor) --性别0男1女
|
||
return getbaseinfo(actor,8)
|
||
end
|
||
--设置性别
|
||
function setsex(actor,zhi) --性别0男1女
|
||
setbaseinfo(actor,8,zhi)
|
||
end
|
||
|
||
--判断是否为PC还是手机
|
||
function getispc(actor) --获取是否电脑端
|
||
if getconst(actor,"<$CLIENTFLAG>") == "1" then
|
||
return true
|
||
else
|
||
return false
|
||
end
|
||
end
|
||
|
||
--获取什么方式进入h5
|
||
-- 1=横版
|
||
-- 2=PC竖版
|
||
-- 3=PCWEB 横版
|
||
-- 4=PCWEB 竖版
|
||
-- 5=ios手机网页 横板
|
||
-- 6=ios手机网页 竖版
|
||
-- 7=安卓手机网页 横板
|
||
-- 8=安卓手机网页 竖版
|
||
-- 9=微信ios 横板
|
||
-- 10=微信ios 竖版
|
||
-- 11=微信安卓 横板
|
||
-- 12=微信安卓 竖版
|
||
function geth5state(actor)
|
||
local state = tonumber(getconst(actor,"<$CLIENTFLAGH5>"))
|
||
return state
|
||
end
|
||
|
||
----屏幕大小
|
||
function getpingmusize(actor)
|
||
return tonumber(getconst(actor,"<$CLIENTFLAG>")),tonumber(getconst(actor,"<$SCREENHEIGHT>"))
|
||
end
|
||
|
||
--天数差
|
||
function getDateNum(timeNow, timeNext)
|
||
local ret = 0
|
||
if timeNow and timeNext then
|
||
local now = os.date("*t", timeNow)
|
||
local next = os.date("*t", timeNext)
|
||
|
||
if now and next then
|
||
local num1 = os.time({ year = now.year, month=now.month, day=now.day })
|
||
local num2 = os.time({ year = next.year, month=next.month, day=next.day })
|
||
if num1 and num2 then
|
||
ret = math.abs(num1 - num2) / (3600*24)
|
||
end
|
||
end
|
||
end
|
||
return ret
|
||
end
|
||
|
||
--获取开区天数
|
||
function getkaiquday()
|
||
local kqtime = getsysint("开区时间") --开区时间戳
|
||
if kqtime == 0 then
|
||
return 1
|
||
end
|
||
local curtime = os.time() --当前时间戳
|
||
return getDateNum(curtime,kqtime) + 1
|
||
end
|
||
--获取背包物品数量
|
||
function itemcount(actor,name)
|
||
local ncount=getbaseinfo(actor,34) --获取背包物品数量
|
||
local sl = 0
|
||
for i = 0 ,ncount-1 do
|
||
local item = getiteminfobyindex(actor, i) --根据索引返回对象
|
||
local itemid = getiteminfo(actor,item,2) --物品id
|
||
local iname = getstditeminfo(itemid,1)
|
||
if iname == name then
|
||
if getiteminfo(actor,item,5) == 0 then
|
||
sl = sl + 1
|
||
else
|
||
sl = sl + getiteminfo(actor,item,5) --叠加数量
|
||
end
|
||
end
|
||
end
|
||
return sl
|
||
end
|
||
--是否在背包
|
||
function isinbag(actor,item)
|
||
local ncount=getbaseinfo(actor,34) --获取背包物品数量
|
||
for i = 0 ,ncount-1 do
|
||
local item1 = getiteminfobyindex(actor, i) --根据索引返回对象
|
||
if item1 == item then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
--是否在装备栏
|
||
function isinrole(actor,makeid)
|
||
for i = 0 ,100 do
|
||
local item = linkbodyitem(actor,i)
|
||
if item ~= "0" and makeid == getiteminfo(actor,item,1) then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
--获取物品总幸运
|
||
function getluck(actor,item)
|
||
local itemid = getiteminfo(actor,item,2)
|
||
local jichuluck = getstditematt(itemid,39) --基础幸运
|
||
local addluck = getitemaddvalue(actor,item,1,5) --极品幸运
|
||
return jichuluck + addluck
|
||
end
|
||
|
||
--根据物品对象获取物品名称
|
||
function getitemname(actor,item,zidingyiname) --玩家 道具 自定义名字
|
||
if zidingyiname == 1 then
|
||
local jsonstr = getitemcustomabil(actor,item)
|
||
if jsonstr ~= "" then
|
||
local json_t = json2tbl(jsonstr)
|
||
if json_t["name"] ~= "" then
|
||
return json_t["name"]
|
||
end
|
||
end
|
||
end
|
||
local id = getiteminfo(actor,item,2)
|
||
return getstditeminfo(id,1)
|
||
end
|
||
--根据名字获取物品id
|
||
function getidbyname(name)
|
||
return getstditeminfo(name,0)
|
||
end
|
||
|
||
--获取背包物品对象列表
|
||
function getbaglist(actor)
|
||
local t = {}
|
||
local ncount=getbaseinfo(actor,34)
|
||
local str = ""
|
||
for i = 0 ,ncount-1 do
|
||
table.insert(t,getiteminfobyindex(actor, i))
|
||
end
|
||
return t
|
||
end
|
||
|
||
--获取人物装备列表
|
||
function getrolelist(actor)
|
||
local t = {}
|
||
for i = 0,100 do
|
||
local item = linkbodyitem(actor,i)
|
||
if item ~= "0" then
|
||
table.insert(t,item)
|
||
end
|
||
end
|
||
return t
|
||
end
|
||
|
||
-------物品标识使用段 标识范围0-31
|
||
--标识1 是否禁止捡取
|
||
function getisjianqu(actor,item) --是否禁止捡取
|
||
return getitemaddvalue(actor,item,3,1)
|
||
end
|
||
function setisjianqu(actor,item,zhi) --设置是否禁止捡取
|
||
setitemaddvalue(actor,item,3,1,zhi)
|
||
end
|
||
|
||
--标识2 是否捡取触发过
|
||
function getisjianquguo(actor,item) --是否禁止捡取
|
||
return getitemaddvalue(actor,item,3,2)
|
||
end
|
||
function setisjianquguo(actor,item,zhi) --设置是否禁止捡取
|
||
setitemaddvalue(actor,item,3,2,zhi)
|
||
end
|
||
|
||
--标识3 是否怪物爆
|
||
function getisguaibao(actor,item) --获取是否怪物爆出
|
||
return getitemaddvalue(actor,item,3,3)
|
||
end
|
||
function setisguaibao(actor,item,zhi) --设置是否怪物爆出
|
||
setitemaddvalue(actor,item,3,3,zhi)
|
||
end
|
||
|
||
|
||
|
||
-------
|
||
-----物品记录信息无效属性使用
|
||
--属性34 主属性
|
||
function getitem_sxzsx(actor,item) --升星主属性
|
||
return getitemaddvalue(actor,item,1,34)
|
||
end
|
||
function setitem_sxzsx(actor,item,zhi) --
|
||
setitemaddvalue(actor,item,1,34,zhi)
|
||
end
|
||
--属性35 防御
|
||
function getitem_sxfy(actor,item) --升星防御
|
||
return getitemaddvalue(actor,item,1,35)
|
||
end
|
||
function setitem_sxfy(actor,item,zhi) --
|
||
setitemaddvalue(actor,item,1,35,zhi)
|
||
end
|
||
--属性36 魔防
|
||
function getitem_sxmf(actor,item) --升星魔防
|
||
return getitemaddvalue(actor,item,1,36)
|
||
end
|
||
function setitem_sxmf(actor,item,zhi) --
|
||
setitemaddvalue(actor,item,1,36,zhi)
|
||
end
|
||
|
||
--属性37 祥运值
|
||
function getitem_zfz(actor,item) --祥运值
|
||
return getitemaddvalue(actor,item,1,37)
|
||
end
|
||
function setitem_zfz(actor,item,zhi) --
|
||
setitemaddvalue(actor,item,1,37,zhi)
|
||
end
|
||
|
||
--属性38 法宝融合编号
|
||
function getitem_fabaozhi(actor,item) --法宝融合编号
|
||
return getitemaddvalue(actor,item,1,38)
|
||
end
|
||
function setitem_fabaozhi(actor,item,zhi) --法宝融合编号
|
||
setitemaddvalue(actor,item,1,38,zhi)
|
||
end
|
||
|
||
--属性39 锻魂装备
|
||
function getitem_duanhun(actor,item)
|
||
return getitemaddvalue(actor,item,1,39)
|
||
end
|
||
function setitem_duanhun(actor,item,zhi)
|
||
setitemaddvalue(actor,item,1,39,zhi)
|
||
end
|
||
|
||
--属性40 武器神秘属性
|
||
function getitem_wqsmsx(actor,item)
|
||
return getitemaddvalue(actor,item,1,40)
|
||
end
|
||
function setitem_wqsmsx(actor,item,zhi)
|
||
setitemaddvalue(actor,item,1,40,zhi)
|
||
end
|
||
|
||
--属性39 武穆遗书等级
|
||
function getitem_wmyslv(actor,item) --武穆遗书等级
|
||
return getitemaddvalue(actor,item,1,39)
|
||
end
|
||
function setitem_wmyslv(actor,item,zhi) --武穆遗书等级
|
||
setitemaddvalue(actor,item,1,39,zhi)
|
||
end
|
||
|
||
--属性40 武穆遗书经验 和酒气值 共用属性 不冲突
|
||
function getitem_wmysjy(actor,item) --武穆遗书经验
|
||
return getitemaddvalue(actor,item,1,40)
|
||
end
|
||
function setitem_wmysjy(actor,item,zhi) --武穆遗书经验
|
||
setitemaddvalue(actor,item,1,40,zhi)
|
||
end
|
||
|
||
function getitem_jiuqizhi(actor,item) --酒气值
|
||
return getitemaddvalue(actor,item,1,40)
|
||
end
|
||
function setitem_jiuqizhi(actor,item,zhi) --酒气值
|
||
setitemaddvalue(actor,item,1,40,zhi)
|
||
end
|
||
|
||
function getitem_lhdyzlv(actor,item) --获取龙魂帝印珠等级
|
||
return getitemaddvalue(actor,item,1,39)
|
||
end
|
||
function setitem_lhdyzlv(actor,item,zhi) --设置龙魂帝印珠等级
|
||
setitemaddvalue(actor,item,1,39,zhi)
|
||
end
|
||
|
||
function getitem_lhdyztupolv(actor,item) --获取龙魂帝印珠突破等级
|
||
return getitemaddvalue(actor,item,1,40)
|
||
end
|
||
function setitem_lhdyztupolv(actor,item,zhi) --设置龙魂帝印珠突破等级
|
||
setitemaddvalue(actor,item,1,40,zhi)
|
||
end
|
||
|
||
function getitem_lhdyzlyxd(actor,item) --获取龙胤血盾上限
|
||
return getitemaddvalue(actor,item,1,41)
|
||
end
|
||
function setitem_lhdyzlyxd(actor,item,zhi) --设置龙胤血盾上限
|
||
setitemaddvalue(actor,item,1,41,zhi)
|
||
end
|
||
|
||
function getitem_lhdyzdxbl(actor,item) --获取抵消比例
|
||
return getitemaddvalue(actor,item,1,42)
|
||
end
|
||
function setitem_lhdyzdxbl(actor,item,zhi) --设置抵消比例
|
||
setitemaddvalue(actor,item,1,42,zhi)
|
||
end
|
||
|
||
function getitem_lhdyzxdcf(actor,item) --获取血盾触发上限
|
||
return getitemaddvalue(actor,item,1,43)
|
||
end
|
||
function setitem_lhdyzxdcf(actor,item,zhi) --设置血盾触发上限
|
||
setitemaddvalue(actor,item,1,43,zhi)
|
||
end
|
||
|
||
function getitem_lhdyzcurxd(actor,item) --获取当前龙胤血盾
|
||
return getitemaddvalue(actor,item,1,44)
|
||
end
|
||
function setitem_lhdyzcurxd(actor,item,zhi) --设置当前龙胤血盾
|
||
setitemaddvalue(actor,item,1,44,zhi)
|
||
end
|
||
|
||
function getitem_zhanqijy(actor,item) --神弧经验值
|
||
return getitemaddvalue(actor,item,1,40)
|
||
end
|
||
function setitem_zhanqijy(actor,item,zhi) --神弧经验值
|
||
setitemaddvalue(actor,item,1,40,zhi)
|
||
end
|
||
|
||
function getitem_zhanqilv(actor,item) --神弧等级
|
||
return getitemaddvalue(actor,item,1,39)
|
||
end
|
||
function setitem_zhanqilv(actor,item,zhi) --神弧等级
|
||
setitemaddvalue(actor,item,1,39,zhi)
|
||
end
|
||
|
||
--成长属性 神弧下限
|
||
function getitem_zhanqixiaxian(actor,item) --神弧下限
|
||
return getitemaddvalue(actor,item,2,9)
|
||
end
|
||
function setitem_zhanqixiaxian(actor,item,zhi) --神弧下限
|
||
setitemaddvalue(actor,item,2,9,zhi)
|
||
end
|
||
--成长属性 神弧上限
|
||
function getitem_zhanqishangxian(actor,item) --神弧上限
|
||
return getitemaddvalue(actor,item,2,10)
|
||
end
|
||
function setitem_zhanqishangxian(actor,item,zhi) --神弧上限
|
||
setitemaddvalue(actor,item,2,10,zhi)
|
||
end
|
||
|
||
-- 装备成长属性核心逻辑(修正版)
|
||
-- 参数说明:
|
||
-- actor - 玩家对象
|
||
-- item - 装备物品ID
|
||
-- reforgeCount - 当前重塑次数(从1开始,仅重塑模式有效)
|
||
-- isReforge - 是否为重塑模式(true=重塑,false=普通升级)
|
||
function givezqczattr(actor, item, reforgeCount, isReforge)
|
||
-- 1. 基础数据获取
|
||
local item_name = getitemname(actor, item)
|
||
local item_color = getstditeminfo(item_name, 13) -- 品质颜色:255,250,254,253,70,249
|
||
|
||
-- 职业属性ID映射:[职业] = {下限属性, 上限属性}
|
||
-- 明确对应关系:索引1=下限(3,5,7),索引2=上限(4,6,8)
|
||
local shuxingid_t = {
|
||
[0] = {3, 4}, -- 职业0:下限3,上限4
|
||
[1] = {5, 6}, -- 职业1:下限5,上限6
|
||
[2] = {7, 8} -- 职业2:下限7,上限8
|
||
}
|
||
local t = shuxingid_t[getjob(actor)] -- 当前职业的属性组
|
||
|
||
-- 当前上下限属性值
|
||
local currentLower = getitem_zhanqixiaxian(actor, item) -- 下限值(对应3,5,7)
|
||
local currentUpper = getitem_zhanqishangxian(actor, item) -- 上限值(对应4,6,8)
|
||
|
||
|
||
-- 2. 配置表:各品质的最大属性点和初始概率
|
||
local qualityConfig = {
|
||
[255] = { maxPoint = 15, initProb = 5 }, -- 白色
|
||
[250] = { maxPoint = 20, initProb = 15 }, -- 绿色
|
||
[254] = { maxPoint = 25, initProb = 25 }, -- 蓝色
|
||
[253] = { maxPoint = 30, initProb = 35 }, -- 紫色
|
||
[70] = { maxPoint = 30, initProb = 45 }, -- 橙色
|
||
[249] = { maxPoint = 30, initProb = 55 } -- 红色
|
||
}
|
||
local cfg = qualityConfig[item_color] or qualityConfig[255] -- 默认配置
|
||
|
||
|
||
-- 3. 检查是否已达最大属性点
|
||
local totalPoint = currentLower + currentUpper
|
||
if totalPoint >= cfg.maxPoint then
|
||
return false -- 已达上限,不再添加属性
|
||
end
|
||
|
||
|
||
-- 4. 计算属性添加概率(重塑模式动态递增)
|
||
local addProb = cfg.initProb -- 基础概率
|
||
if isReforge then
|
||
-- 各品质达到100%概率所需的重塑次数
|
||
local maxReforgeTimes = {
|
||
[255] = 30, [250] = 30, [254] = 30,
|
||
[253] = 40, [70] = 20, [249] = 10
|
||
}
|
||
local maxTimes = maxReforgeTimes[item_color] or 30
|
||
|
||
-- 概率随重塑次数递增(最高100%)
|
||
addProb = math.min(
|
||
cfg.initProb + (100 - cfg.initProb) * (reforgeCount / maxTimes),
|
||
100
|
||
)
|
||
end
|
||
|
||
|
||
-- 5. 判断是否触发属性添加
|
||
if math.random(1, 100) > addProb then
|
||
return false -- 未触发属性添加
|
||
end
|
||
|
||
|
||
-- 6. 计算上下限分配概率(重塑模式动态调整)
|
||
local upperProb -- 上限属性(4,6,8)的分配概率(%)
|
||
if isReforge then
|
||
-- 各品质的上限概率配置:{初始概率, 最大次数, 每次增长步长}
|
||
local upperRateConfig = {
|
||
[255] = {10, 100, 1}, -- 白色:10%起始,逐步增长
|
||
[250] = {20, 100, 1}, -- 绿色:20%起始,逐步增长
|
||
[254] = {30, 100, 1}, -- 蓝色:30%起始,逐步增长
|
||
[253] = {30, 40, 1.75}, -- 紫色:30%起始,40次满
|
||
[70] = {40, 20, 3}, -- 橙色:40%起始,20次满
|
||
[249] = {50, 10, 5} -- 红色:50%起始,10次满
|
||
}
|
||
local uCfg = upperRateConfig[item_color] or upperRateConfig[255]
|
||
|
||
-- 计算当前上限概率(不超过100%)
|
||
upperProb = math.min(
|
||
uCfg[1] + (reforgeCount - 1) * uCfg[3],
|
||
100
|
||
)
|
||
else
|
||
-- 普通升级模式:固定30%上限,70%下限
|
||
upperProb = 30
|
||
end
|
||
|
||
|
||
-- 7. 确定添加上限还是下限(关键修正:确保upperProb对应上限属性)
|
||
local attrType -- 1=上限属性(4,6,8),2=下限属性(3,5,7)
|
||
if math.random(1, 100) <= upperProb then
|
||
-- 命中上限概率:添加上限属性(4,6,8)
|
||
attrType = (currentUpper < cfg.maxPoint - currentLower) and 1 or 2
|
||
else
|
||
-- 未命中上限概率:添加下限属性(3,5,7)
|
||
attrType = (currentLower < cfg.maxPoint - currentUpper) and 2 or 1
|
||
end
|
||
|
||
|
||
-- 8. 执行属性更新(明确对应关系)
|
||
if attrType == 1 then
|
||
-- 添加上限属性(4,6,8)
|
||
setitem_zhanqishangxian(actor, item, currentUpper + 1)
|
||
else
|
||
-- 添加下限属性(3,5,7)
|
||
setitem_zhanqixiaxian(actor, item, currentLower + 1)
|
||
end
|
||
|
||
|
||
-- 9. 应用属性组(t[2]对应上限属性,t[1]对应下限属性)
|
||
local targetAttrId = (attrType == 1) and t[2] or t[1]
|
||
callscriptex(actor, "SETADDNEWABIL", 16, "+" ,"3#".. targetAttrId .."#1")
|
||
return true
|
||
end
|
||
|
||
|
||
-- 重塑成长属性流程(执行30次成长判断)
|
||
function reforgeZqczAttr(actor, item)
|
||
-- 重置当前上下限属性(重塑前清零)
|
||
setitem_zhanqixiaxian(actor, item, 0)
|
||
setitem_zhanqishangxian(actor, item, 0)
|
||
|
||
-- 执行30次重塑成长逻辑
|
||
for reforgeCount = 1, 30 do
|
||
givezqczattr(actor, item, reforgeCount, true)
|
||
end
|
||
|
||
return true
|
||
end
|
||
|
||
--神弧神秘属性重塑次数
|
||
function getitem_shenhusmsxchongsu(actor,item) --神弧神秘属性重塑次数
|
||
return getitemaddvalue(actor,item,1,41)
|
||
end
|
||
function setitem_shenhusmsxchongsu(actor,item,zhi) --神弧神秘属性重塑次数
|
||
setitemaddvalue(actor,item,1,41,zhi)
|
||
end
|
||
|
||
--神弧成长属性重塑次数
|
||
function getitem_shenhuczsxchongsu(actor,item) --神弧成长属性重塑次数
|
||
return getitemaddvalue(actor,item,1,42)
|
||
end
|
||
function setitem_shenhuczsxchongsu(actor,item,zhi) --神弧成长属性重塑次数
|
||
setitemaddvalue(actor,item,1,42,zhi)
|
||
end
|
||
|
||
--神秘属性 神弧神秘属性编号
|
||
function getitem_zhanqismsxbh(actor,item) --神弧神秘属性编号
|
||
return getitemaddvalue(actor,item,1,43)
|
||
end
|
||
function setitem_zhanqismsxbh(actor,item,zhi) --神弧神秘属性编号
|
||
setitemaddvalue(actor,item,1,43,zhi)
|
||
end
|
||
|
||
|
||
--属性2 8 项链洗练次数
|
||
function getitem_xlxlcs(actor,item) --项链洗练次数
|
||
return getitemaddvalue(actor,item,2,8)
|
||
end
|
||
function setitem_xlxlcs(actor,item,zhi) --项链洗练次数
|
||
setitemaddvalue(actor,item,2,8,zhi)
|
||
end
|
||
|
||
--属性2 7 到期时间
|
||
function getitem_daoqishijian(actor,item) --到期时间
|
||
return getitemaddvalue(actor,item,2,7)
|
||
end
|
||
function setitem_daoqishijian(actor,item,zhi) --到期时间
|
||
setitemaddvalue(actor,item,2,7,zhi)
|
||
end
|
||
|
||
--属性2 11 沙巴克标识
|
||
function getitem_shabake(actor,item) --沙巴克标识
|
||
return getitemaddvalue(actor,item,2,11)
|
||
end
|
||
function setitem_shabake(actor,item,zhi) --沙巴克标识
|
||
setitemaddvalue(actor,item,2,11,zhi)
|
||
end
|
||
|
||
-----
|
||
--是否绑定
|
||
function isbind(actor,item)
|
||
if getitemaddvalue(actor,item,2,1) == 0 then
|
||
return false
|
||
else
|
||
return true
|
||
end
|
||
end
|
||
|
||
-------货币操作
|
||
----获取金币绑金总数
|
||
function getbindgold(actor)
|
||
return getbindmoney(actor,"金币")
|
||
end
|
||
----扣除金币 优先扣除绑定金币
|
||
function subbindgold(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
if num > 0 then
|
||
post(actor,beizhu.."通用金币货币消耗*"..num)
|
||
end
|
||
consumebindmoney(actor,"金币",num)
|
||
end
|
||
--加绑定金币
|
||
function addbindgold(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,8,"+",num,beizhu,true)
|
||
end
|
||
---获取单获取金币
|
||
function getgold(actor)
|
||
return querymoney(actor,7)
|
||
end
|
||
|
||
---获取单获取绑定金币
|
||
function getbindjinbi(actor)
|
||
return querymoney(actor,8)
|
||
end
|
||
|
||
--加金币
|
||
function addgold(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,7,"+",num,beizhu,true)
|
||
end
|
||
--减金币
|
||
function subgold(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
if num > 0 then
|
||
post(actor,beizhu.."非绑定金币货币消耗*"..num)
|
||
end
|
||
return changemoney(actor,7,"-",num,beizhu,true)
|
||
end
|
||
|
||
----获取元宝绑元总数
|
||
function getbindyb(actor)
|
||
return getbindmoney(actor,"元宝")
|
||
end
|
||
----扣除元宝 优先扣除绑定元宝
|
||
function subbindyuanbao(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
if num > 0 then
|
||
-- post(actor,beizhu.."通用元宝货币消耗*"..num)
|
||
end
|
||
consumebindmoney(actor,"元宝",num)
|
||
end
|
||
--加绑定元宝
|
||
function addbindyuanbao(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,4,"+",num,beizhu,true)
|
||
end
|
||
---获取单获取元宝
|
||
function getyuanbao(actor)
|
||
return querymoney(actor,2)
|
||
end
|
||
|
||
---获取单获取绑定元宝
|
||
function getbindyuanbao(actor)
|
||
return querymoney(actor,4)
|
||
end
|
||
|
||
--加元宝
|
||
function addyuanbao(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,2,"+",num,beizhu,true)
|
||
end
|
||
--减元宝
|
||
function subyuanbao(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
if num > 0 then
|
||
post(actor,beizhu.."非绑定元宝货币消耗*"..num)
|
||
end
|
||
return changemoney(actor,2,"-",num,beizhu,true)
|
||
end
|
||
|
||
--获得军功数量
|
||
function getjungong(actor)
|
||
return querymoney(actor,20)
|
||
end
|
||
--加军功
|
||
function addjungong(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,20,"+",num,beizhu,true)
|
||
end
|
||
--减军功
|
||
function subjungong(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,20,"-",num,beizhu,true)
|
||
end
|
||
|
||
--获得声望数量
|
||
function getshengwang(actor)
|
||
return querymoney(actor,15)
|
||
end
|
||
--加声望
|
||
function addshengwang(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,15,"+",num,beizhu,true)
|
||
end
|
||
--减声望
|
||
function subshengwang(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,15,"-",num,beizhu,true)
|
||
end
|
||
|
||
--获得天赋点数量
|
||
function gettianfudian(actor)
|
||
return querymoney(actor,5)
|
||
end
|
||
--加天赋点
|
||
function addtianfudian(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,5,"+",num,beizhu,true)
|
||
end
|
||
--减天赋点
|
||
function subtianfudian(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,5,"-",num,beizhu,true)
|
||
end
|
||
|
||
--获得灵韵值数量
|
||
function getlingyunzhi(actor)
|
||
return querymoney(actor,10)
|
||
end
|
||
--加灵韵值
|
||
function addlingyunzhi(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,10,"+",num,beizhu,true)
|
||
end
|
||
--减灵韵值
|
||
function sublingyunzhi(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,10,"-",num,beizhu,true)
|
||
end
|
||
|
||
--获得猎魔值数量
|
||
function getliemozhi(actor)
|
||
return querymoney(actor,11)
|
||
end
|
||
--加猎魔值
|
||
function addliemozhi(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,11,"+",num,beizhu,true)
|
||
end
|
||
--减猎魔值
|
||
function subliemozhi(actor,num,beizhu)
|
||
if beizhu == nil then
|
||
beizhu = ""
|
||
end
|
||
return changemoney(actor,11,"-",num,beizhu,true)
|
||
end
|
||
|
||
|
||
--脚本总耗时
|
||
function haoshistart(actor)
|
||
callscriptex(actor, "PRINTUSETIME", 1)
|
||
end
|
||
function haoshiend(actor)
|
||
callscriptex(actor, "PRINTUSETIME", 2)
|
||
end
|
||
|
||
--删除物品
|
||
function delitem(actor,item,sl)
|
||
if sl == nil then
|
||
sl = getiteminfo(actor,item,5)
|
||
if sl == 0 then
|
||
sl = 1
|
||
end
|
||
end
|
||
return delitembymakeindex(actor,getiteminfo(actor,item,1),sl)
|
||
end
|
||
|
||
--获取已装备的全套装备的最低极品等级
|
||
local jipintaozhuangjisuant = {1,0,4,3,7,8,5,6,2,11,12,10,13,14}
|
||
function getjipintaozhuanglevel(actor)
|
||
local _List = {}
|
||
local t = jipintaozhuangjisuant
|
||
for i = 1, #t do
|
||
_List[i] = 0
|
||
local item = linkbodyitem(actor,t[i])
|
||
if item ~= "0" then
|
||
local val = getitemaddvalue(actor,item,1,2)
|
||
local val2 = getitemaddvalue(actor,item,1,3)
|
||
local val3 = getitemaddvalue(actor,item,1,4)
|
||
if val < val2 then
|
||
val = val2
|
||
end
|
||
if val < val3 then
|
||
val = val3
|
||
end
|
||
_List[i] = val
|
||
end
|
||
end
|
||
|
||
table.sort(_List, function(l, r)
|
||
return l > r
|
||
end)
|
||
|
||
return _List[10]
|
||
end
|
||
|
||
local taozhuanggeibuff_t = {
|
||
[0]=10100,[1]=10101,[2]=10102,[3]=10103,[4]=10104,[5]=10105,[6]=10106,[7]=10107,[8]=10108,[9]=10109,[10]=10110,
|
||
}
|
||
local jptzjieshao = {
|
||
"HP+3%",
|
||
"HP+6%",
|
||
"HP+9%",
|
||
"HP+12%",
|
||
"HP+15%,攻魔道+3%",
|
||
"HP+18%,攻魔道+6%",
|
||
"HP+20%,攻魔道+9%",
|
||
"HP+20%,攻魔道+12%",
|
||
"HP+20%,攻魔道+15%",
|
||
"HP+20%,攻魔道+15%,暴击+2%",
|
||
}
|
||
function jipintaozhuanggeibuff(actor)
|
||
local lev = getjipintaozhuanglevel(actor) --获取套装等级属性
|
||
--sendmsg6(actor,"套装等级"..lev)
|
||
if not hasbuff(actor,taozhuanggeibuff_t[lev]) then
|
||
addbuff(actor,taozhuanggeibuff_t[lev])
|
||
if lev > 0 then
|
||
sendmsg6(actor,"触发极品+".. lev .."套:"..jptzjieshao[lev])
|
||
end
|
||
end
|
||
|
||
end
|
||
|
||
--秒转时分秒 100 = 00:01:40
|
||
function ssrSecToHMS(sec)
|
||
sec = sec or 0
|
||
|
||
local h,m,s = 0,0,0
|
||
if sec > 3600 then
|
||
h = math.floor(sec/3600)
|
||
end
|
||
sec = sec % 3600
|
||
if sec > 60 then
|
||
m = math.floor(sec/60)
|
||
end
|
||
s = sec % 60
|
||
|
||
return string.format("%02d:%02d:%02d", h, m, s)
|
||
end
|
||
|
||
function huicheng(actor)
|
||
mapmove(actor,"3",330,330,6)
|
||
end
|
||
|
||
function getitemnamebymakeid(actor,makeid)
|
||
local item = getitembymakeindex(actor,makeid)
|
||
local name = getitemname(actor,item)
|
||
return name
|
||
end
|
||
|
||
function jianhuanum(num)
|
||
if num >= 100000000 then
|
||
local yi = num/100000000
|
||
local zhi = yi - yi%0.01
|
||
return zhi .. "亿"
|
||
end
|
||
if num >= 10000 then
|
||
local wan = num/10000
|
||
if wan >= 10 then
|
||
return math.floor(wan) .. "万"
|
||
end
|
||
|
||
local zhi = wan - wan%0.01
|
||
return zhi .. "万"
|
||
end
|
||
return num
|
||
end
|
||
|
||
function isyongyou(actor,iname,weizi) --装备名 位置
|
||
if itemcount(actor,iname) > 0 then
|
||
return true
|
||
end
|
||
local item = linkbodyitem(actor,weizi)
|
||
--sendmsg9(actor,item)
|
||
if item ~= "0" then
|
||
if getitemname(actor,item) == iname then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
-- 宝箱配置
|
||
local treasure_boxes = {0,30,60,120,180,255,}
|
||
function chengjiuhongdian(actor)
|
||
for i=1, #treasure_boxes do
|
||
local today_total = getdayint(actor, "成就_今日总点数")
|
||
local is_unlocked = today_total >= treasure_boxes[i]
|
||
local is_claimed = getdayint(actor, "宝箱_"..i.."_已领取") == 1
|
||
if is_unlocked and not is_claimed then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
local hongdianlv = {38,40,42,44,46,48,50,52,54,56,58,60}
|
||
function dengjihongdian(actor)
|
||
local rolelv = getlevel(actor)
|
||
for i = 1,#hongdianlv do
|
||
if rolelv < hongdianlv[i] then
|
||
break
|
||
end
|
||
if getint(actor,"升级奖励_"..hongdianlv[i]) == 0 then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
function cxxbhongdian(actor)
|
||
local chongzhi = getint(actor, "3合后累充")
|
||
if chongzhi < 10 then
|
||
return false
|
||
else
|
||
if getint(actor,"初心相伴领取") == 0 then
|
||
return true
|
||
else
|
||
return false
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
local hongdian_db = {38,88,188,288}
|
||
function dbflhongdian(actor)
|
||
for i = 1,#hongdian_db do
|
||
local current = getint(actor,"单笔返利_"..hongdian_db[i])
|
||
local yiling = getint(actor,"已领返利_"..hongdian_db[i])
|
||
|
||
if (current - yiling) > 0 then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
-- 累充档位配置(与你的leichong_t中的档位对应)
|
||
local leichong_t = {30, 50, 100, 200, 500, 2000} -- 按顺序对应各档位的累充金额
|
||
-- 累充红点判断函数:存在已达条件但未领取的档位时返回true(显示红点)
|
||
function leichongHongdian(actor)
|
||
local totalRecharge = getint(actor, "累计充值") -- 玩家累计充值总额
|
||
-- 遍历所有累充档位
|
||
for i = 1, #leichong_t do
|
||
local needRecharge = leichong_t[i] -- 该档位需要的累充金额
|
||
|
||
-- 若累计充值未达到该档位,后续档位无需判断(按档位顺序递增)
|
||
if totalRecharge < needRecharge then
|
||
break
|
||
end
|
||
-- 500档特殊处理(支持重复领取)
|
||
if needRecharge == 500 then
|
||
local receivedRounds = getint(actor, "累充500已领轮次") or 0 -- 已领轮次
|
||
local availableRounds = math.floor(totalRecharge / 500) -- 可领总轮次
|
||
-- 若有未领取的轮次,显示红点
|
||
if receivedRounds < availableRounds then
|
||
return true
|
||
end
|
||
else
|
||
-- 普通档位(一次性领取):判断是否未领取
|
||
if getint(actor, "累充奖励_"..needRecharge) == 0 then
|
||
return true
|
||
end
|
||
end
|
||
end
|
||
|
||
return false -- 无未领取的奖励,不显示红点
|
||
end
|
||
|
||
|
||
local richong_t = {300}
|
||
function meirileichonghd(actor)
|
||
local totalRecharge = getdayint(actor, "今日充值")
|
||
-- 遍历所有累充档位
|
||
for i = 1, #richong_t do
|
||
local needRecharge = richong_t[i] -- 该档位需要的累充金额
|
||
if totalRecharge < needRecharge then
|
||
break
|
||
end
|
||
if getdayint(actor, "日充奖励_"..needRecharge) == 0 then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
|
||
|
||
function isingongchengquyu(actor)
|
||
if castleinfo(5) and (getmap(actor) == "0150" or (getmap(actor) == "3" and getx(actor) >= 544 and gety(actor) <= 390 )) then
|
||
return true
|
||
end
|
||
return false
|
||
end
|
||
|
||
--获取经验值
|
||
function getjingyan(actor)
|
||
local jingyan = getstr(actor,"经验值")
|
||
return tonumber(jingyan) or 0
|
||
end
|
||
|
||
--存储经验值
|
||
function setjingyan(actor,zhi)
|
||
setstr(actor,"经验值",tostring(zhi))
|
||
zhuangtaijiemian(actor)
|
||
end
|
||
|
||
--post消息记录
|
||
function post(actor,xiaoxi)
|
||
local fuwuqiname = getconst(actor,"<$SERVERNAME>") --服务器名称
|
||
if fuwuqiname == "" then
|
||
fuwuqiname = "工具服"
|
||
end
|
||
local curtime = os.date("%Y-%m-%d %H:%M:%S", os.time())
|
||
end
|
||
|
||
--post1消息记录
|
||
function post1(actor,xiaoxi)
|
||
local fuwuqiname = getconst(actor,"<$SERVERNAME>") --服务器名称
|
||
if fuwuqiname == "" then
|
||
fuwuqiname = "工具服"
|
||
end
|
||
local curtime = os.date("%Y-%m-%d %H:%M:%S", os.time())
|
||
end
|
||
|
||
function getguaigongjitime(mon)
|
||
local zhi = getcurrent(mon,6)
|
||
if zhi == "" then
|
||
zhi = 0
|
||
end
|
||
return tonumber(zhi) or 0
|
||
end
|
||
|
||
function setguaigongjitime(mon,zhi)
|
||
setcurrent(mon,6,tostring(zhi))
|
||
end
|
||
|
||
function getdiaoluodata()
|
||
local t = {}
|
||
local str = getsysstr("掉落查询数据")
|
||
if str ~= "" then
|
||
t = json2tbl(str)
|
||
end
|
||
return t
|
||
end
|
||
|
||
-----功能公用函数----------------------------------------------------
|
||
|
||
function tongyonggoumai(actor,title,danjia,max,huobi)
|
||
if huobi == nil then
|
||
huobi = 2
|
||
end
|
||
local t = {
|
||
title = title,
|
||
danjia = danjia,
|
||
max = max,
|
||
huobi = huobi
|
||
}
|
||
sendluamsg(actor, 64000,0,0,0,tbl2json(t))
|
||
end
|
||
|
||
function tongyongxuanzediejia(actor,title,wyid)
|
||
local count = itemcount(actor, title)
|
||
local t = {
|
||
title = title,
|
||
max = count,
|
||
wyid=wyid,
|
||
}
|
||
sendluamsg(actor, 71000,5,0,0,tbl2json(t))
|
||
end
|
||
|
||
|
||
--检查一个对象的范围
|
||
function FCheckRange(obj, x, y, range)
|
||
local cur_x, cur_y = getbaseinfo(obj, 4), getbaseinfo(obj, 5)
|
||
local min_x, max_x = x-range, x+range
|
||
local min_y, max_y = y-range, y+range
|
||
|
||
if (cur_x >= min_x) and (cur_x <= max_x) and
|
||
(cur_y >= min_y) and (cur_y <= max_y) then
|
||
return true
|
||
end
|
||
|
||
return false
|
||
end
|
||
|
||
--检查自己与npc的距离
|
||
function FCheckNPCRange(actor, npcidx, range)
|
||
range = range or 15
|
||
local npcobj = getnpcbyindex(npcidx)
|
||
local npc_mapid = getbaseinfo(npcobj, 3)
|
||
local my_mapid = getbaseinfo(actor, 3)
|
||
if npc_mapid ~= my_mapid then return false end
|
||
|
||
local npc_x = getbaseinfo(npcobj, 4)
|
||
local npc_y = getbaseinfo(npcobj, 5)
|
||
return FCheckRange(actor, npc_x, npc_y, range)
|
||
end
|
||
|
||
--在gb2312编码下,计算字符串中中文字符的个数
|
||
function count_gb2312_chinese(str)
|
||
local count = 0
|
||
local i = 1 -- 索引从1开始(Lua字符串索引规则)
|
||
local str_len = string.len(str) -- 获取字符串总字节数(GB2312中文占2字节,ASCII占1字节)
|
||
|
||
while i <= str_len do
|
||
local byte1 = string.byte(str, i) -- 取当前字节(可能是中文高字节或ASCII)
|
||
|
||
-- 判断是否为GB2312中文的高字节
|
||
if byte1 >= 0xA1 and byte1 <= 0xF7 then
|
||
-- 是中文:需占用2字节,计数+1,索引跳2位
|
||
count = count + 1
|
||
i = i + 2
|
||
else
|
||
-- 不是中文(ASCII字符):仅占1字节,索引跳1位
|
||
i = i + 1
|
||
end
|
||
end
|
||
return count
|
||
end
|
||
|
||
|
||
function GetDate(iTime)
|
||
iTime = iTime or os.time()
|
||
return os.date("%Y-%m-%d %H:%M:%S", iTime)
|
||
end
|
||
|
||
function GetYear(iTime)
|
||
iTime = iTime or os.time()
|
||
local t = os.date("*t", iTime)
|
||
return t.year
|
||
end
|
||
|
||
function GetMonth(iTime)
|
||
iTime = iTime or os.time()
|
||
local t = os.date("*t", iTime)
|
||
return t.month
|
||
end
|
||
|
||
function GetDay(iTime)
|
||
iTime = iTime or os.time()
|
||
|
||
local t = os.date("*t", iTime)
|
||
return t.day
|
||
end
|
||
|
||
function GetHour(iTime)
|
||
iTime = iTime or os.time()
|
||
|
||
local t = os.date("*t", iTime)
|
||
return t.hour
|
||
end
|
||
|
||
function GetMin(iTime)
|
||
iTime = iTime or os.time()
|
||
local t = os.date("*t", iTime)
|
||
return t.min
|
||
end
|
||
|
||
function GetSec(iTime)
|
||
iTime = iTime or os.time()
|
||
local t = os.date("*t", iTime)
|
||
return t.sec
|
||
end
|
||
|
||
function GetWday(iTime)
|
||
iTime = iTime or os.time()
|
||
local t = os.date("*t", iTime)
|
||
--周日 t.wday = 1
|
||
if t.wday == 1 then
|
||
--周日
|
||
return 7
|
||
else
|
||
return t.wday - 1
|
||
end
|
||
end
|
||
|
||
--麻痹
|
||
function setMabi(actor, sec, gongjizhe)
|
||
makeposion(actor, 5, sec)
|
||
sendattackeff(actor, 131, 0, gongjizhe)
|
||
end
|
||
|
||
--冰冻
|
||
function setBingDong(actor, sec, gongjizhe)
|
||
makeposion(actor, 12, sec)
|
||
sendattackeff(actor, 132, 0, gongjizhe)
|
||
end
|
||
|
||
--蛛网
|
||
function setZhuWang(actor, sec)
|
||
makeposion(actor, 13, sec)
|
||
end
|
||
|
||
--居中显示公告
|
||
function sendCenterMsg(actor, msg, receiver, fColor, bColor, iTime, func)
|
||
--[[ actor object 否 玩家对象
|
||
FColor int 否 前景色
|
||
BColor int 否 背景色
|
||
Msg string 否 消息内容
|
||
flag string 否 发送对象:
|
||
0=发送给自己;
|
||
1=发送所有人物;
|
||
2=发送行会;
|
||
3=发送国家;
|
||
4=发送当前地图;
|
||
5=替换模式;
|
||
7=组队
|
||
time int 是 显示时间
|
||
func string 是 倒计时结束后跳转的脚本位置,对应脚本需要放QFunction脚本中,使用跳转时,消息文字提示中必须包含%d,用于显示倒计时时间 ]]
|
||
receiver = receiver or 0
|
||
fColor = fColor or 255
|
||
bColor = bColor or 0
|
||
iTime = iTime or 2
|
||
if func then
|
||
sendcentermsg(actor, fColor, bColor, msg, receiver, iTime, func)
|
||
else
|
||
sendcentermsg(actor, fColor, bColor, msg, receiver, iTime)
|
||
end
|
||
end |