添加示例项目
This commit is contained in:
11
示例项目/物品回收UI/Proj.ifo
Normal file
11
示例项目/物品回收UI/Proj.ifo
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ProjectName": "物品回收UI",
|
||||
"ProjectDescribe": "需启动器支持或者dll支持,否则物品无法放入回收箱,根据放入的物品获取对应的奖励,",
|
||||
"ProjectAuthor": "南瓜",
|
||||
"ProjectVersion": 1.0,
|
||||
"ProjectConfig": "物品回收UI配置_Nangua.json",
|
||||
"ProjectFiles": [
|
||||
"物品回收UI.nut"
|
||||
],
|
||||
"ProjectRunFunc": "_Dps_RecycleItemUI_Main_"
|
||||
}
|
||||
330
示例项目/物品回收UI/物品回收UI.nut
Normal file
330
示例项目/物品回收UI/物品回收UI.nut
Normal file
@@ -0,0 +1,330 @@
|
||||
function _Dps_RecycleItemUI_Main_() {
|
||||
// 跳过指定道具ID原逻辑1
|
||||
Cb_UseLimitCube_Check_Error_Leave_Func.crossoverByNangua <- function(args) {
|
||||
local Config = GlobalConfig.Get("物品回收UI配置_Nangua.json");
|
||||
local ItemObj = Item(args[5]);
|
||||
local ItemId = ItemObj.GetIndex();
|
||||
if (ItemId == Config["回收箱道具ID"]) {
|
||||
return 17;
|
||||
}
|
||||
}
|
||||
|
||||
// 回收逻辑
|
||||
Cb_UseLimitCube_Process_Leave_Func.crossoverByNangua <- function(args) {
|
||||
local Config = GlobalConfig.Get("物品回收UI配置_Nangua.json");
|
||||
local SUser = User(args[1]);
|
||||
local msg_base = args[2];
|
||||
if (msg_base) {
|
||||
local slot = NativePointer(msg_base).add(13).readShort();
|
||||
local boxslot = NativePointer(msg_base).add(19).readShort();
|
||||
local InvenObj = SUser.GetInven();
|
||||
local boxobj = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, boxslot);
|
||||
local box_index = boxobj.GetIndex();
|
||||
local ItemObj = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, slot);
|
||||
local Item_Id = ItemObj.GetIndex();
|
||||
if (!ItemObj) return;
|
||||
if (box_index == Config["回收箱道具ID"]) {
|
||||
local Recycleitem_name = PvfItem.GetNameById(Item_Id);
|
||||
local CheckItemLock = Sq_CallFunc(S_Ptr("0x8646942"), "int", ["pointer", "int", "int"], SUser.C_Object, 1, slot);
|
||||
if (CheckItemLock) {
|
||||
return;
|
||||
}
|
||||
// 检查装备是否在排除列表中
|
||||
if ("指定装备ID不参与回收" in Config["回收配置"] && Config["回收配置"]["指定装备ID不参与回收"].len() > 0) {
|
||||
local isExcluded = false;
|
||||
foreach (excludeId in Config["回收配置"]["指定装备ID不参与回收"]) {
|
||||
if (excludeId == Item_Id) {
|
||||
isExcluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isExcluded) {
|
||||
_RecycleItemUI_nangua.RecycleError(SUser, format(Config["回收失败信息"], Recycleitem_name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
local PvfItemObj = PvfItem.GetPvfItemById(Item_Id);
|
||||
local Item_type = PvfItemObj.IsStackable();
|
||||
local Item_Count = ItemObj.GetAdd_Info();
|
||||
local rarity = PvfItemObj.GetRarity();
|
||||
local level = PvfItemObj.GetUsableLevel();
|
||||
local allRewards = [];
|
||||
local foundValidItem = false;
|
||||
|
||||
// 检查指定装备回收配置
|
||||
foreach(item in Config["回收配置"]["指定装备回收"]) {
|
||||
if(item[0] == Item_Id) {
|
||||
local Rewarditem = item[1];
|
||||
local minCount = item[2];
|
||||
local maxCount = item[3];
|
||||
local Rewarditem_name = PvfItem.GetNameById(Rewarditem);
|
||||
local RewardItemObj = PvfItem.GetPvfItemById(Rewarditem);
|
||||
local item_upgrade = ItemObj.GetUpgrade();
|
||||
if (item_upgrade > 0) {
|
||||
Recycleitem_name = "+" + item_upgrade + Recycleitem_name;
|
||||
}
|
||||
local count = 0;
|
||||
if (Item_type == 1 && Item_Count > 1) {
|
||||
for (local i = 0; i < Item_Count; i++) {
|
||||
count += MathClass.Rand(minCount, maxCount + 1);
|
||||
}
|
||||
Recycleitem_name = Recycleitem_name + "x" + Item_Count;
|
||||
} else {
|
||||
count = MathClass.Rand(minCount, maxCount + 1);
|
||||
}
|
||||
|
||||
if (Rewarditem == 0) {
|
||||
SUser.RechargeCera(count);
|
||||
_RecycleItemUI_nangua.sendRewardMessageForCera(SUser, Recycleitem_name, ItemObj, count, Item_Id);
|
||||
} else {
|
||||
local equ_type = NativePointer(RewardItemObj.C_Object).add(141 * 4).readU32();
|
||||
if (equ_type > 0) {
|
||||
count = 1;
|
||||
}
|
||||
allRewards.append([Rewarditem, count]);
|
||||
_RecycleItemUI_nangua.sendRewardMessageForItem(SUser, Recycleitem_name, ItemObj, Rewarditem_name, count, equ_type, Item_Id, Rewarditem);
|
||||
}
|
||||
|
||||
_RecycleItemUI_nangua.DeleteAndUpdate(SUser, ItemObj, slot);
|
||||
|
||||
foundValidItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有找到指定装备配置,尝试品级回收
|
||||
if (!foundValidItem && Config["品级回收配置"]["开启品级以及装备等级的回收(true开启/false关闭)"]) {
|
||||
foreach(cfg in Config["品级回收配置"]["配置列表"]) {
|
||||
if (cfg["装备品级"] == rarity && cfg["装备等级"] == level) {
|
||||
local reward = cfg["奖励"][0];
|
||||
local count = MathClass.Rand(reward[1], reward[2] + 1);
|
||||
if (reward[0] == 0) {
|
||||
SUser.RechargeCera(count);
|
||||
_RecycleItemUI_nangua.sendRewardMessageForCera(SUser, Recycleitem_name, ItemObj, count, Item_Id);
|
||||
} else {
|
||||
local Rewarditem_name = PvfItem.GetNameById(reward[0]);
|
||||
local RewardItemObj = PvfItem.GetPvfItemById(reward[0]);
|
||||
local equ_type = NativePointer(RewardItemObj.C_Object).add(141 * 4).readU32();
|
||||
if (equ_type > 0) {
|
||||
count = 1;
|
||||
}
|
||||
allRewards.append([reward[0], count]);
|
||||
_RecycleItemUI_nangua.sendRewardMessageForItem(SUser, Recycleitem_name, ItemObj, Rewarditem_name, count, equ_type, Item_Id, reward[0]);
|
||||
}
|
||||
_RecycleItemUI_nangua.DeleteAndUpdate(SUser, ItemObj, slot);
|
||||
foundValidItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理回收结果
|
||||
if (foundValidItem) {
|
||||
if (allRewards.len() > 0) {
|
||||
_RecycleItemUI_nangua.api_CUser_Add_Item_list(SUser, allRewards);
|
||||
_RecycleItemUI_nangua.SendItemWindowNotification(SUser, allRewards);
|
||||
if(Config["回收成功是否扣除回收券道具(true扣除/false不扣除)"]){
|
||||
InvenObj.DeleteItemCount(box_index, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 如果没有匹配到任何回收配置
|
||||
_RecycleItemUI_nangua.RecycleError(SUser, format(Config["回收失败信息"], Recycleitem_name));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _RecycleItemUI_nangua {
|
||||
// 删除道具并更新客户端
|
||||
function DeleteAndUpdate(SUser, ItemObj, slot) {
|
||||
ItemObj.Delete();
|
||||
SUser.SendUpdateItemList(1, 0, slot);
|
||||
}
|
||||
|
||||
// 回收失败
|
||||
function RecycleError(SUser, msg) {
|
||||
local Config = GlobalConfig.Get("物品回收UI配置_Nangua.json");
|
||||
if(Config["信息提示窗口提示(true开启/false关闭)"]) {
|
||||
SUser.SendNotiBox(msg, 1);
|
||||
} else {
|
||||
SUser.SendNotiPacketMessage(msg, Config["信息播报发送位置"]);
|
||||
}
|
||||
}
|
||||
|
||||
// 发送点券奖励消息
|
||||
function sendRewardMessageForCera(SUser, Recycleitem_name, ItemObj, count, Item_Id) {
|
||||
local Config = GlobalConfig.Get("物品回收UI配置_Nangua.json");
|
||||
local AdMsgObj = AdMsg();
|
||||
AdMsgObj.PutType(Config["信息播报发送位置"]);
|
||||
if (Config["信息播报发送位置"] != 14){
|
||||
AdMsgObj.PutString(" ");
|
||||
}
|
||||
AdMsgObj.PutImoticon(Config["表情ID"]);
|
||||
AdMsgObj.PutString(Config["成功回收"]["标题"]);
|
||||
AdMsgObj.PutEquipment("[" + Recycleitem_name + "]", ItemObj, _RecycleItemUI_nangua.RarityColor(Item_Id));
|
||||
AdMsgObj.PutString(Config["成功回收"]["奖励提示"]);
|
||||
AdMsgObj.PutColorString("[" + count + "]", [255, 20, 0]);
|
||||
AdMsgObj.PutString("点券");
|
||||
AdMsgObj.Finalize();
|
||||
SUser.Send(AdMsgObj.MakePack());
|
||||
AdMsgObj.Delete();
|
||||
}
|
||||
|
||||
// 发送道具奖励消息
|
||||
function sendRewardMessageForItem(SUser, Recycleitem_name, ItemObj, Rewarditem_name, count, equ_type, Item_Id, Rewarditem) {
|
||||
local Config = GlobalConfig.Get("物品回收UI配置_Nangua.json");
|
||||
local AdMsgObj = AdMsg();
|
||||
AdMsgObj.PutType(Config["信息播报发送位置"]);
|
||||
if (Config["信息播报发送位置"] != 14){
|
||||
AdMsgObj.PutString(" ");
|
||||
}
|
||||
AdMsgObj.PutImoticon(Config["表情ID"]);
|
||||
AdMsgObj.PutString(Config["成功回收"]["标题"]);
|
||||
AdMsgObj.PutEquipment("[" + Recycleitem_name + "]", ItemObj, _RecycleItemUI_nangua.RarityColor(Item_Id));
|
||||
AdMsgObj.PutString(Config["成功回收"]["奖励提示"]);
|
||||
if (equ_type > 0) {
|
||||
AdMsgObj.PutEquipment(Rewarditem);
|
||||
} else {
|
||||
AdMsgObj.PutColorString("[" + count + "]", [255, 20, 0]);
|
||||
AdMsgObj.PutString(Config["成功回收"]["单位"]);
|
||||
AdMsgObj.PutEquipment(Rewarditem);
|
||||
}
|
||||
AdMsgObj.Finalize();
|
||||
SUser.Send(AdMsgObj.MakePack());
|
||||
AdMsgObj.Delete();
|
||||
}
|
||||
function RarityColor(item_id) {
|
||||
local PvfItemObj = PvfItem.GetPvfItemById(item_id);
|
||||
if (PvfItemObj == null) {
|
||||
return;
|
||||
}
|
||||
local CItem_get_rarity = PvfItemObj.GetRarity(); // 装备品级
|
||||
return _RecycleItemUI_nangua.rarityColorMap[(CItem_get_rarity).tostring()];
|
||||
}
|
||||
//品级对应的RGB
|
||||
rarityColorMap = {
|
||||
"0": [255, 255, 255], // 普通
|
||||
"1": [104, 213, 237], // 高级
|
||||
"2": [179, 107, 255], // 稀有
|
||||
"3": [255, 0, 255], // 神器
|
||||
"4": [255, 180, 0], // 史诗
|
||||
"5": [255, 102, 102], // 勇者
|
||||
"6": [255, 20, 147], // 深粉红色
|
||||
"7": [255, 215, 0] // 金色
|
||||
};
|
||||
function api_CUser_Add_Item_list(SUser, item_list) {
|
||||
for (local i = 0; i < item_list.len(); i++) {
|
||||
local item_id = item_list[i][0]; // 道具代码
|
||||
local quantity = item_list[i][1]; // 道具数量
|
||||
local InvenObj = SUser.GetInven();
|
||||
// 获取道具对象
|
||||
local PvfItemObj = PvfItem.GetPvfItemById(item_id);
|
||||
// 获取道具类型
|
||||
local equ_type = NativePointer(PvfItemObj.C_Object).add(141 * 4).readU32();
|
||||
// 获取最大堆叠数量
|
||||
local maxStack = Sq_CallFunc(S_Ptr("0x0822C9FC"), "int", ["pointer"], PvfItemObj.C_Object);
|
||||
|
||||
// 如果是装备,直接检查空格并处理
|
||||
if (equ_type > 0) {
|
||||
local cnt = _RecycleItemUI_nangua.checkInventorySlot(SUser, item_id);
|
||||
if (cnt == 1) {
|
||||
SUser.GiveItem(item_id, quantity);
|
||||
} else {
|
||||
local RewardItems = [];
|
||||
RewardItems.append([item_id, quantity]);
|
||||
local title = "GM";
|
||||
local Text = "由于背包空间不足,已通过邮件发送,请查收!";
|
||||
SUser.ReqDBSendMultiMail(title, Text, 0, RewardItems);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取道具在背包中的槽位
|
||||
local slot = InvenObj.GetSlotById(item_id);
|
||||
if (slot != -1) {
|
||||
// 获取槽位中的道具对象
|
||||
local ItemObj = InvenObj.GetSlot(1, slot);
|
||||
// 获取当前堆叠数量
|
||||
local currentCount = Sq_CallFunc(S_Ptr("0x80F783A"), "int", ["pointer"], ItemObj.C_Object);
|
||||
|
||||
// 如果当前堆叠未满,计算可以添加的数量
|
||||
if (currentCount < maxStack) {
|
||||
local canAdd = maxStack - currentCount;
|
||||
if (quantity <= canAdd) {
|
||||
// 如果奖励数量小于等于可添加数量,直接添加
|
||||
Sq_CallFunc(S_Ptr("0x80CB884"), "int", ["pointer", "int"], ItemObj.C_Object, currentCount + quantity);
|
||||
// 刷新背包显示
|
||||
SUser.SendUpdateItemList(1, 0, slot);
|
||||
} else {
|
||||
// 如果奖励数量大于可添加数量
|
||||
// 先将当前堆叠设置为最大
|
||||
Sq_CallFunc(S_Ptr("0x80CB884"), "int", ["pointer", "int"], ItemObj.C_Object, maxStack);
|
||||
SUser.SendUpdateItemList(1, 0, slot);
|
||||
// 将剩余数量通过邮件发送
|
||||
local remaining = quantity - canAdd;
|
||||
local RewardItems = [];
|
||||
RewardItems.append([item_id, remaining]);
|
||||
local title = "GM";
|
||||
local Text = "由于背包堆叠已满,部分道具已通过邮件发送,请查收!";
|
||||
SUser.ReqDBSendMultiMail(title, Text, 0, RewardItems);
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
local RewardItems = [];
|
||||
RewardItems.append([item_id, quantity]);
|
||||
local title = "GM";
|
||||
local Text = "由于背包堆叠已满,已通过邮件发送,请查收!";
|
||||
SUser.ReqDBSendMultiMail(title, Text, 0, RewardItems);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果道具不在背包中,检查空格
|
||||
local cnt = _RecycleItemUI_nangua.checkInventorySlot(SUser, item_id);
|
||||
if (cnt == 1) {
|
||||
// 如果道具有空格,直接添加到背包
|
||||
SUser.GiveItem(item_id, quantity);
|
||||
} else {
|
||||
// 如果背包空间不足,通过邮件发送
|
||||
local RewardItems = [];
|
||||
RewardItems.append([item_id, quantity]);
|
||||
local title = "GM";
|
||||
local Text = "由于背包空间不足,已通过邮件发送,请查收!";
|
||||
SUser.ReqDBSendMultiMail(title, Text, 0, RewardItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
function SendItemWindowNotification(SUser, item_list) {
|
||||
local Pack = Packet();
|
||||
Pack.Put_Header(1, 163); //协议
|
||||
Pack.Put_Byte(1); //默认1
|
||||
Pack.Put_Short(0); //槽位id 填入0即可
|
||||
Pack.Put_Int(0); //未知 0以上即可
|
||||
Pack.Put_Short(item_list.len()); //道具组数
|
||||
//写入道具代码和道具数量
|
||||
for (local i = 0; i < item_list.len(); i++) {
|
||||
Pack.Put_Int(item_list[i][0]); //道具代码
|
||||
Pack.Put_Int(item_list[i][1]); //道具数量 装备/时装时 任意均可
|
||||
}
|
||||
Pack.Finalize(true); //确定发包内容
|
||||
SUser.Send(Pack); //发包
|
||||
Pack.Delete(); //清空buff区
|
||||
}
|
||||
/**
|
||||
* 根据道具类型背包空格数量
|
||||
* @param {pointer} SUser - 用户
|
||||
* @param {int} item_id - 需要查找的道具ID
|
||||
* @returns {int} - 空格数量1
|
||||
*/
|
||||
function checkInventorySlot(SUser, itemid) {
|
||||
local InvenObj = SUser.GetInven();
|
||||
local type = Sq_CallFunc(S_Ptr("0x085018D2"), "int", ["pointer", "int"], InvenObj.C_Object, itemid);
|
||||
local cnt = Sq_CallFunc(S_Ptr("0x08504F64"), "int", ["pointer", "int", "int"], InvenObj.C_Object, type, 1);
|
||||
|
||||
return cnt;
|
||||
}
|
||||
}
|
||||
84
示例项目/物品回收UI/物品回收UI配置_Nangua.json
Normal file
84
示例项目/物品回收UI/物品回收UI配置_Nangua.json
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"回收箱道具ID":7942,
|
||||
"回收箱固定三个道具ID<7953,7942,690000274>更改其他道具ID无效":"",
|
||||
"且此功能需要登录器支持或者dll支持目前已知入梦启动器以及长虹启动器支持":"",
|
||||
"如果非要使用,那么到PVF里把需要回收的物品全部写入PVF该道具里,否则物品无法拖入回收箱":"",
|
||||
"回收配置": {
|
||||
"指定装备回收": [
|
||||
[27098, 3340, 1, 10],
|
||||
[27102, 0, 1, 10],
|
||||
[2711001, 3038, 1, 10],
|
||||
[3340, 3038, 1, 2]
|
||||
],
|
||||
"指定装备ID不参与回收": [27100, 27101],
|
||||
"提示1":"[回收装备的ID,奖励道具的ID(0代表点券),数量最小值,数量最大值]",
|
||||
"提示2":"如果指定装备回收和品级回收都命中的情况下,优先以指定装备回收为准",
|
||||
"提示3":"排除装备ID中的装备不会参与回收,即使它们符合其他回收条件"
|
||||
},
|
||||
"品级回收配置": {
|
||||
"开启品级以及装备等级的回收(true开启/false关闭)": true,
|
||||
"奖励说明": "奖励[道具ID(0代表点券),数量最小值,数量最大值]",
|
||||
"品级说明":"0代表白装,1蓝装,2紫装,3粉装,4史诗,5勇者",
|
||||
"配置列表": [{
|
||||
"装备品级": 2,
|
||||
"装备等级": 55,
|
||||
"奖励": [
|
||||
[3037, 10, 20]
|
||||
]
|
||||
},
|
||||
{
|
||||
"装备品级": 3,
|
||||
"装备等级": 55,
|
||||
"奖励": [
|
||||
[7421, 10, 20]
|
||||
]
|
||||
},
|
||||
{
|
||||
"装备品级": 4,
|
||||
"装备等级": 50,
|
||||
"奖励": [
|
||||
[3037, 10, 20]
|
||||
]
|
||||
},
|
||||
{
|
||||
"装备品级": 4,
|
||||
"装备等级": 55,
|
||||
"奖励": [
|
||||
[3037, 10, 20]
|
||||
]
|
||||
},
|
||||
{
|
||||
"装备品级": 4,
|
||||
"装备等级": 60,
|
||||
"奖励": [
|
||||
[3037, 10, 20]
|
||||
]
|
||||
},
|
||||
{
|
||||
"装备品级": 4,
|
||||
"装备等级": 65,
|
||||
"奖励": [
|
||||
[3037, 10, 20]
|
||||
]
|
||||
},
|
||||
{
|
||||
"装备品级": 4,
|
||||
"装备等级": 70,
|
||||
"奖励": [
|
||||
[3037, 10, 20]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"回收失败信息": " 装备回收失败\n[%s]无法回收",
|
||||
"信息播报发送位置": 37,
|
||||
"信息提示窗口提示(true开启/false关闭)": false,
|
||||
"提示":"开启弹窗提示需在群文件下载 <客户端消息框233.dll> 插件,否则会导致游戏崩溃",
|
||||
"回收成功是否扣除回收券道具(true扣除/false不扣除)":true,
|
||||
"表情ID": 59,
|
||||
"成功回收": {
|
||||
"标题": " 成功回收",
|
||||
"奖励提示":"奖励",
|
||||
"单位": "个"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user