local hk = {} hk.titlttbl = SL:GetMetaValue("TITLES") local function title_reload() hk.titlttbl = SL:GetMetaValue("TITLES") end SL:RegisterLUAEvent(LUA_EVENT_ROLE_PROPERTY_INITED, "称号刷新", title_reload) SL:RegisterLUAEvent(LUA_EVENT_PLAYER_TITLE_CHANGE, "称号刷新", title_reload) hk.att_score = SL:Require("scripts/game_config/cfg_att_score") -- 获取键值 ---* 参数1 变量 ---* 参数2 键名 function hk.getkeycount(var, key) local str = SL:Get_SERVER_VALUE(var) local data = str and SL:JsonDecode(str) or {} return data["J_" .. key] or nil end -- 获取键值返回键值表 ---* 参数1 玩家对象 ---* 参数2 变量 ---* return tbl function hk.getkeytbl(var) local str = SL:Get_SERVER_VALUE(var) local data = str and SL:JsonDecode(str) or {} local newData = {} for key, value in pairs(data or {}) do local new_key = key:gsub("J_", "") newData[tonumber(new_key) and tonumber(new_key) or new_key] = value end return newData end ---* 消耗横排自适应 ---* 参数一 父节点的快捷子控件组 ---* 参数二 父节点对象 ---* 参数三 消耗表 ---* 参数四 动画增长方式 1: 从上到下(从左到右)(多行从左上角), 2:中间到两边(多行从右上角), 3:从下到上(从右到左) ---* 参数五 1:垂直; 2: 水平; 3: 两者 ---* 参数六 多行列数(dir必须是3) ---* 参数七 interval:增长方式动画播放时间间隔, 不传值则不播放动画 ---* 参数八 背景图路径 ---* 参数九 间距 ---* 参数十 物品缩放比例 默认1 ---* 参数十一 物品数量显示 function hk.SettingXhShow(ui, parent, tbl, adddir, dir, colnum, interval, bgpic, gap, scale, numshow) bgpic = bgpic or "res/public/1900000651.png" for i, v in ipairs(tbl or {}) do local xh_img = "xh_img" .. i ui[xh_img] = GUI:Image_Create(parent, xh_img, 0.00, 5.00, bgpic) GUI:setTouchEnabled(ui[xh_img], false) GUI:setTag(ui[xh_img], -1) GUI:Win_SetParam(ui[xh_img], i) GUI:setChildrenCascadeOpacityEnabled(ui[xh_img], true) GUI:setScale(ui[xh_img], scale or 1) local setData = {} if type(v) == "table" then setData.index = SL:GetMetaValue("ITEM_INDEX_BY_NAME", v[1]) else setData.index = SL:GetMetaValue("ITEM_INDEX_BY_NAME", v) end local count = v[2] or 1 setData.look = true -- 是否显示tips setData.bgVisible = false -- 是否显示背景框 setData.count = not numshow and count or 1 -- 物品数量 local xh_item = "xh_item" .. i local bg_Size = GUI:getContentSize(ui[xh_img]) ui[xh_item] = GUI:ItemShow_Create(ui[xh_img], xh_item, bg_Size.width / 2, bg_Size.height / 2, setData) -- GUI:setScale(ui[xh_item], 0.8) if scale then GUI:setScale(ui[xh_item], scale) end GUI:setAnchorPoint(ui[xh_item], 0.50, 0.50) GUI:setChildrenCascadeOpacityEnabled(ui[xh_item], true) if numshow then local id_numshow = "bag_show_num_" .. i if GUI:Win_IsNotNull(parent[id_numshow]) then GUI:removeFromParent(parent[id_numshow]) end local bag_list = SL:GetMetaValue("ITEM_COUNT", setData.index) local text_color = "#ff0000" if bag_list >= count then text_color = "#00ff00" end parent[id_numshow] = GUI:Text_Create(ui[xh_img], id_numshow, bg_Size.width, 0, 12, text_color, string.format("%s/%s", SL:GetSimpleNumber(bag_list, 0), SL:GetSimpleNumber(count, 0))) GUI:setAnchorPoint(parent[id_numshow], 1, 0) GUI:Text_enableOutline(parent[id_numshow], "#000000", 2) end end if not adddir then adddir = 2 end if not dir then dir = 2 end if not colnum then colnum = 1 end if not interval then interval = 0.8 end if not gap then gap = 0 end GUI:UserUILayout(parent, { dir = dir, addDir = adddir, interval = interval, colnum = colnum, gap = { x = gap }, sortfunc = function(lists) table.sort(lists, function(a, b) return GUI:Win_GetParam(a) > GUI:Win_GetParam(b) end) end }) end ---* 更新物品框内容 ---* 父节点对象 parent ---* 物品名称 ItemName ---* 物品数量 ItemCount ---* 是否显示tips tips function hk.reloadItemShow(parent, ItemName, ItemCount, ItemData, tips, numshow) if tips == nil then tips = true end local setData = {} setData.index = SL:GetMetaValue("ITEM_INDEX_BY_NAME", ItemName) -- 物品Index setData.look = tips -- 是否显示tips setData.bgVisible = false -- 是否显示背景框 setData.count = not numshow and ItemCount or nil -- 物品数量 setData.starLv = true -- 是否显示星级 -- setData.onlyShowSFX = true -- 只显示道具特效其它都不显示 setData.showModelEffect = false -- 只显示内观特效不显示背包特效 if ItemData then setData.itemData = ItemData end GUI:ItemShow_updateItem(parent, setData) if numshow then local id_numshow = "bag_show_num" if GUI:Win_IsNotNull(parent[id_numshow]) then GUI:removeFromParent(parent[id_numshow]) end local bag_list = SL:GetMetaValue("ITEM_COUNT", ItemName) local text_color = "#ff0000" if bag_list >= ItemCount then text_color = "#00ff00" end parent[id_numshow] = GUI:Text_Create(parent, id_numshow, GUI:getContentSize(parent).width, 0, 12, text_color, string.format("%s/%s", SL:GetSimpleNumber(bag_list, 0), SL:GetSimpleNumber(ItemCount, 0))) GUI:setAnchorPoint(parent[id_numshow], 1, 0) GUI:Text_enableOutline(parent[id_numshow], "#000000", 2) end end ---* 获得玩家当前地图ID function hk.getmapid() return SL:GetMetaValue("MAP_ID") end ---* 发送sendmsg9 function hk.sendmsg(msg) if not msg then return end local part = SL:Split(msg, "|") local str = {} for i, v in ipairs(part) do local plist = {} if string.find(v, "#", 1, true) == nil then plist[1] = v plist[2] = "251" else plist = SL:Split(v, "#") end if not plist[2] then plist[2] = "251" end table.insert(str, "" .. plist[1] .. "") end local msg_data = {} msg_data.Type = 9 msg_data.Msg = table.concat(str) SL:ShowLocalNoticeByType(msg_data) -- body end local check_contrast = { ["等于"] = function(a, b) if a == b then return true else return false end end, ["大于"] = function(a, b) if a > b then return true else return false end end, ["小于"] = function(a, b) if a < b then return true else return false end end, ["大于等于"] = function(a, b) if a >= b then return true else return false end end, ["小于等于"] = function(a, b) if a <= b then return true else return false end end, ["不等于"] = function(a, b) if a ~= b then return true else return false end end, ["不小于"] = function(a, b) if a >= b then return true else return false end end, ["不大于"] = function(a, b) if a < b then return true else return false end end, } local check_cond_tbl = { ["检测等级"] = function(tbl) if SL:GetMetaValue("LEVEL") >= tbl[2] then return true else return false end end, ["检测转生"] = function(tbl) local func = check_contrast[tbl[2]] if func then if func(SL:GetMetaValue(ssrConstCfg.MetaValue.relevel), tbl[3]) then return true else return false end end end, ["检测键值数字"] = function(tbl) if not tbl then return false end local func = check_contrast[tbl[4]] if func then if func(hk.getkeycount(tbl[2], tbl[3]), tbl[5]) then return true else return false end end end, ["比较数字变量"] = function(tbl) local func = check_contrast[tbl[3]] if func then local key_value = tonumber(SL:GetMetaValue("SERVER_VALUE", tbl[2])) or 0 if func(key_value, tbl[4]) then return true else return false end end end, ["检测标识"] = function(tbl) if tonumber(SL:GetMetaValue("SERVER_VALUE", "{" .. tostring(tbl[2]) .. "}")) == tbl[3] then return true else return false end end, ["检测称号"] = function(tbl) -- SL:dump(tbl) if SL:GetMetaValue("TITLE_DATA_BY_ID", SL:GetMetaValue("ITEM_INDEX_BY_NAME", tbl[2])) ~= nil then return true else return false end end, ["检测无称号"] = function(tbl) local titleTbl = hk.titlttbl or SL:GetMetaValue("TITLES") for i, v in ipairs(titleTbl) do local title_name = SL:GetMetaValue("ITEM_NAME", v.id) if title_name == tbl[2] then return false end end return true end, ["检测货币"] = function(tbl) local money_num = 0 local money_idx = tonumber(SL:GetMetaValue("ITEM_INDEX_BY_NAME", tbl[2])) or 0 local duohuobi = 0 if not tbl[4] then duohuobi = 1 else duohuobi = tbl[4] end if duohuobi > 0 then money_num = tonumber(SL:GetMetaValue("MONEY_ASSOCIATED", money_idx)) or 0 else money_num = tonumber(SL:GetMetaValue("MONEY", money_idx)) or 0 end if money_num >= tbl[3] then return true end return false end, ["检测文本包含"] = function(tbl) if not tbl then return end local value = SL:GetMetaValue("SERVER_VALUE", tbl[2]) if string.match(value, tbl[3]) then return true end return false end, ["检测文本变量"] = function(tbl) local func = check_contrast[tbl[3]] if not tbl[4] then tbl[4] = "" end if func then if func(SL:GetMetaValue("SERVER_VALUE", tbl[2]), tbl[4]) then return true else return false end end end, ["检测物品"] = function(tbl) if not tbl then return end local item_num = tonumber(SL:GetMetaValue("ITEM_COUNT", tbl[2])) or 0 if item_num >= tbl[3] then return true else return false end end, ["检测日期区间"] = function(tbl) local function isDateInRange(startDate, endDate) local currentDate = os.date("%Y-%m-%d") return currentDate >= startDate and currentDate <= endDate end if isDateInRange(tbl[2], tbl[3]) then return true else return false end end, } ---* 批量判定条件 ---* 参数一 玩家对象 ---* 参数二 检查表 function hk.checkcontion(tbl) if tbl == nil then return true end -- SL:dump(tbl) local tbl_num = 0 for i, v in pairs(tbl) do local func = check_cond_tbl[v[1]] if func then if func(v) then tbl_num = tbl_num + 1 else break end end end if tbl_num == #tbl then return true else return false end end function hk.wenhao_tips(obj, parent, Tips_str, pos) local ext = { count = 12, speed = 100, loop = -1, finishhide = 0 } obj.frames2 = GUI:Frames_Create(obj[parent], "frames2", pos.x, pos.y, "res/custom/w/1_", ".png", 1, 12, ext) -- Create Layout obj.w_Layout = GUI:Layout_Create(obj[parent], "w_Layout", pos.x, pos.y, 70.00, 70.00, false) GUI:setTouchEnabled(obj.w_Layout, true) GUI:setTag(obj.w_Layout, -1) local str = table.concat(Tips_str, "\\") local param = { checkCallback = function(touchPos) if touchPos and GUI:isClippingParentContainsPoint(obj.w_Layout, touchPos) then return true end return false end } GUI:addMouseOverTips(obj.w_Layout, str, nil, nil, param) GUI:addOnClickEvent(obj.w_Layout, function() local data = { width = 1136, str = str, worldPos = GUI:getWorldPosition(obj.w_Layout), anchorPoint = { x = 0, y = 1 } } SL:OpenCommonDescTipsPop(data) end) end ---* 验证冷却时间 ---* 玩家对象 ---* 时间戳变量 ---* 间隔时间 function hk.check_cd(var, num) if var == nil then return true end if num == nil then return false end num = tonumber(num) local to_time = os.time() local _cd = tonumber(SL:GetMetaValue("SERVER_VALUE", var)) or 0 -- LOGPrint(to_time,_cd,num) if (to_time - _cd) >= num then return true else return false end end ---* 通用充值拉起窗口 function hk.changgeparent(parent, change_id, money_num, chang_msg) -- Create chang_Node local chang_Node = GUI:Node_Create(parent, "chang_Node", 0.00, 0.00) GUI:setTag(chang_Node, -1) GUI:setPosition(chang_Node, SL:GetMetaValue("SCREEN_WIDTH") / 2, SL:GetMetaValue("SCREEN_HEIGHT") / 2) GUI:setAnchorPoint(chang_Node, 0.50, 0.50) local chang_bg_close = GUI:Layout_Create(chang_Node, "chang_bg_close", 0.00, 0.00, SL:GetMetaValue("SCREEN_WIDTH"), SL:GetMetaValue("SCREEN_HEIGHT"), false) GUI:Layout_setBackGroundColorType(chang_bg_close, 1) GUI:Layout_setBackGroundColor(chang_bg_close, "#000000") GUI:Layout_setBackGroundColorOpacity(chang_bg_close, 60) GUI:setTouchEnabled(chang_bg_close, true) GUI:setTag(chang_bg_close, -1) GUI:setAnchorPoint(chang_bg_close, 0.50, 0.50) GUI:addOnClickEvent(chang_bg_close, function() ssrMessage:sendmsg(ssrNetMsgCfg.chongzhiZhongxin_claerT88) GUI:removeFromParent(chang_Node) end) -- Create change_img local change_img = GUI:Image_Create(chang_Node, "change_img", 0.00, 0.00, "res/public/1900000677.png") GUI:Image_setScale9Slice(change_img, 5, 5, 5, 5) GUI:setContentSize(change_img, 350, 150) GUI:setIgnoreContentAdaptWithSize(change_img, false) GUI:setAnchorPoint(change_img, 0.50, 0.50) GUI:setTouchEnabled(change_img, true) GUI:setTag(change_img, -1) GUI:setScaleX(change_img, 0.01) -- Create Text local Text = GUI:Text_Create(change_img, "Text", 177.00, 129.00, 16, "#ffffff", chang_msg) GUI:setAnchorPoint(Text, 0.50, 0.50) GUI:setTouchEnabled(Text, false) GUI:setTag(Text, -1) GUI:Text_enableOutline(Text, "#000000", 1) -- Create Text_1 local Text_1 = GUI:Text_Create(change_img, "Text_1", 105.00, 83.00, 16, "#ffff00", [[充值金额:]]) GUI:setTouchEnabled(Text_1, false) GUI:setTag(Text_1, -1) GUI:Text_enableOutline(Text_1, "#000000", 2) -- Create Text_1_1 local Text_1_1 = GUI:Text_Create(change_img, "Text_1_1", 179.00, 83.00, 16, "#00ff00", money_num .. [[元]]) GUI:setTouchEnabled(Text_1_1, false) GUI:setTag(Text_1_1, -1) GUI:Text_enableOutline(Text_1_1, "#000000", 2) -- Create Button local chang_Button_1 = GUI:Button_Create(change_img, "chang_Button_1", 23.00, 18.00, "res/private/powerful_secret/bg_czzya_05.png") GUI:Button_setTitleText(chang_Button_1, "") GUI:Button_setTitleColor(chang_Button_1, "#ffffff") GUI:Button_setTitleFontSize(chang_Button_1, 14) GUI:Button_titleEnableOutline(chang_Button_1, "#000000", 1) GUI:setTouchEnabled(chang_Button_1, true) GUI:setTag(chang_Button_1, -1) GUI:addOnClickEvent(chang_Button_1, function() SL:RequestPay(1, change_id, money_num, nil) end) -- Create Button_1 local chang_Button_2 = GUI:Button_Create(change_img, "chang_Button_2", 131.00, 18.00, "res/private/powerful_secret/bg_czzya_06.png") GUI:Button_setTitleText(chang_Button_2, "") GUI:Button_setTitleColor(chang_Button_2, "#ffffff") GUI:Button_setTitleFontSize(chang_Button_2, 14) GUI:Button_titleEnableOutline(chang_Button_2, "#000000", 1) GUI:setTouchEnabled(chang_Button_2, true) GUI:setTag(chang_Button_2, -1) GUI:addOnClickEvent(chang_Button_2, function() SL:RequestPay(2, change_id, money_num, nil) end) -- Create Button_1_1 local chang_Button_3 = GUI:Button_Create(change_img, "chang_Button_3", 239.00, 18.00, "res/private/powerful_secret/bg_czzya_04.png") GUI:Button_setTitleText(chang_Button_3, "") GUI:Button_setTitleColor(chang_Button_3, "#ffffff") GUI:Button_setTitleFontSize(chang_Button_3, 14) GUI:Button_titleEnableOutline(chang_Button_3, "#000000", 1) GUI:setTouchEnabled(chang_Button_3, true) GUI:setTag(chang_Button_3, -1) GUI:addOnClickEvent(chang_Button_3, function() SL:RequestPay(3, change_id, money_num, nil) end) local ScaleX = GUI:ActionScaleTo(0.2, 1.0, 1.0, 1.0) GUI:runAction(change_img, ScaleX) end ---* 测试区状态判定 function hk.sever_state() local sever_name = SL:GetMetaValue("SERVER_NAME") if string.find(sever_name, "测试", 1, true) ~= nil or string.find(sever_name, "工具服", 1, true) ~= nil or sever_name == "" then return true else return false end end ---* 获取玩家阵营 function hk.getzhongzu() local camp = SL:GetMetaValue("SERVER_VALUE", "T17") if camp == "" then return false end if camp == "神" then return 0 elseif camp == "魔" then return 1 end end ---* 前端引导窗口 function hk.guide(ui, dir, widget, _parent, text, func, isForce) local data = {} data.dir = dir -- 方向(1~8)从左按瞬时针 data.guideWidget = widget -- 当前节点 data.guideParent = _parent -- 父窗口 data.guideDesc = text -- 文本描述 data.clickCB = func data.isForce = isForce -- 强制引导 return SL:StartGuide(data) end ---* 获得装备 基础属性 ---* 参数一 属性值: 3#X#X|3#X#X ---返回table 属性名:+值 function hk.getequipAttribute(data) if not data then return nil end local attList = GUIFunction:ParseItemBaseAtt(data) -- 属性显示队列 local stringAtt = GUIFunction:GetAttDataShow(attList, nil, true) local attStr = {} for k, v in pairs(stringAtt or {}) do table.insert(attStr, string.format("<%s%s%s/FCOLOR=%s>", v.name, v.color and "+ " or "", v.value, v.color and v.color or "250")) end return attStr end ---* 合并消耗表 ---* 主表 ---* 次表 ---@param t1 any ---@param t2 any function hk.deep_merge(t1, t2) local new_t = {} for i, v in ipairs(t1) do local item1 = v[1] local found = false for t2_key, t2_v in ipairs(t2) do local item2 = t2_v[1] if item1 == item2 then found = true table.insert(new_t, { item1, t2_v[2] + v[2], v[3] }) end end if not found then table.insert(new_t, v) end end return new_t end ---* 获得变量 function hk.getvalue(param) local _value = SL:Get_SERVER_VALUE(param) return tonumber(_value) and tonumber(_value) or _value end return hk