上架装备跨界
This commit is contained in:
parent
ef2f161d36
commit
3bcc8e5323
|
|
@ -268,14 +268,9 @@ Gm_InputFunc_Handle["test"] <- function(SUser, CmdString) {
|
|||
|
||||
|
||||
|
||||
|
||||
Timer.SetTimeOut(function ()
|
||||
{
|
||||
|
||||
|
||||
Cb_dispatch_sig_Enter_Func["atts"] <- function (args)
|
||||
{
|
||||
print(123123);
|
||||
}
|
||||
}, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
装备跨界.nut
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
/*
|
||||
文件名:跨界石.nut
|
||||
路径:MyProject/跨界石/跨界石.nut
|
||||
创建日期:2025-12-14 21:32
|
||||
文件用途:
|
||||
*/
|
||||
|
||||
class ItemCrossoverC {
|
||||
|
||||
//配置表
|
||||
Info = null;
|
||||
|
||||
//用户状态表
|
||||
UserState = null;
|
||||
|
||||
//基础所需材料
|
||||
BasicMaterials = null;
|
||||
//等级倍率
|
||||
LevelRate = 1.0;
|
||||
//品级倍率
|
||||
RarityRate = 1.0;
|
||||
//禁止跨界Map
|
||||
BanEquipmentMap = null;
|
||||
//特殊装备Map
|
||||
SpecialEquipmentMap = null;
|
||||
//特殊材料组
|
||||
SpecialMaterialsGroup = null;
|
||||
|
||||
constructor() {
|
||||
Info = {};
|
||||
UserState = {};
|
||||
|
||||
//读取PVF
|
||||
InitPvf();
|
||||
|
||||
//注册客户端收包
|
||||
RegisterClient();
|
||||
}
|
||||
|
||||
|
||||
function RegisterClient() {
|
||||
ClientSocketPackFuncMap.rawset(21007001, function(SUser, Jso) {
|
||||
//获取背包
|
||||
local InvenObj = SUser.GetInven();
|
||||
//装备ID
|
||||
local Id = Jso.item.ItemId;
|
||||
//判断是否为不可跨界装备
|
||||
if (BanEquipmentMap.rawin(Id)) {
|
||||
SUser.SendJso({
|
||||
op = 21007002,
|
||||
error = 1
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
//判断装备是否为特殊跨界装备
|
||||
if (SpecialEquipmentMap.rawin(Id)) {
|
||||
//获取特殊跨界材料组
|
||||
local MaterialsGroup = SpecialMaterialsGroup[SpecialEquipmentMap[Id]];
|
||||
local MgArr = [];
|
||||
foreach(object in MaterialsGroup) {
|
||||
//查询自己有多少个道具
|
||||
MgArr.push({
|
||||
Item = object.Item,
|
||||
RealCount = InvenObj.GetCountById(object.Item),
|
||||
NeedCount = object.Count
|
||||
});
|
||||
}
|
||||
SUser.SendJso({
|
||||
op = 21007002,
|
||||
MgInfo = MgArr
|
||||
});
|
||||
}
|
||||
//普通跨界装备
|
||||
else {
|
||||
//读取装备品级
|
||||
local equ = PvfItem.GetPvfItemById(Id);
|
||||
local Rarity = equ.GetRarity();
|
||||
local Level = equ.GetUsableLevel();
|
||||
local RarityCalculateRate = Rarity * RarityRate;
|
||||
local LevelCalculateRate = Level * LevelRate;
|
||||
local MgArr = [];
|
||||
foreach(object in BasicMaterials) {
|
||||
//查询自己有多少个道具
|
||||
MgArr.push({
|
||||
Item = object.Item,
|
||||
RealCount = InvenObj.GetCountById(object.Item),
|
||||
NeedCount = (object.Count * RarityCalculateRate * LevelCalculateRate).tointeger()
|
||||
});
|
||||
}
|
||||
SUser.SendJso({
|
||||
op = 21007002,
|
||||
MgInfo = MgArr
|
||||
});
|
||||
}
|
||||
}.bindenv(this));
|
||||
|
||||
ClientSocketPackFuncMap.rawset(21007003, function(SUser, Jso) {
|
||||
//获取背包
|
||||
local InvenObj = SUser.GetInven();
|
||||
//装备ID
|
||||
local Id = Jso.item.ItemId;
|
||||
|
||||
//获取账号金库对象
|
||||
local CargoObj = SUser.GetAccountCargo();
|
||||
//获取账号金库中的一个空格子
|
||||
local EmptySlot = CargoObj.GetEmptySlot();
|
||||
|
||||
//如果没有空格子
|
||||
if (EmptySlot == -1) {
|
||||
SUser.SendNotiBox(" 跨界失败 账号金库没有剩余空位", 1);
|
||||
return;
|
||||
}
|
||||
|
||||
//获取对应槽位的装备
|
||||
local SlotItem = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, 9 + Jso.item.Pos);
|
||||
if (SlotItem.GetIndex() != Id) {
|
||||
SUser.SendNotiBox(" 跨界失败 跨界时请不要操作背包", 1);
|
||||
return;
|
||||
} else {
|
||||
local MgArr = [];
|
||||
//判断装备是否为特殊跨界装备
|
||||
if (SpecialEquipmentMap.rawin(Id)) {
|
||||
//获取特殊跨界材料组
|
||||
local MaterialsGroup = SpecialMaterialsGroup[SpecialEquipmentMap[Id]];
|
||||
foreach(object in MaterialsGroup) {
|
||||
//查询自己有多少个道具
|
||||
MgArr.push({
|
||||
Id = object.Item,
|
||||
Count = object.Count
|
||||
});
|
||||
}
|
||||
}
|
||||
//普通跨界装备
|
||||
else {
|
||||
//读取装备品级
|
||||
local equ = PvfItem.GetPvfItemById(Id);
|
||||
local Rarity = equ.GetRarity();
|
||||
local Level = equ.GetUsableLevel();
|
||||
local RarityCalculateRate = Rarity * RarityRate;
|
||||
local LevelCalculateRate = Level * LevelRate;
|
||||
foreach(object in BasicMaterials) {
|
||||
//查询自己有多少个道具
|
||||
MgArr.push({
|
||||
Id = object.Item,
|
||||
Count = (object.Count * RarityCalculateRate * LevelCalculateRate).tointeger()
|
||||
});
|
||||
}
|
||||
}
|
||||
local Flag = InvenObj.CheckArrItemCount(MgArr);
|
||||
if (!Flag) {
|
||||
print("扣除失败");
|
||||
SUser.SendNotiBox(" 跨界失败 跨界时请不要操作背包", 1);
|
||||
return;
|
||||
} else {
|
||||
InvenObj.DeleteArrItemCount(MgArr);
|
||||
//跨界
|
||||
local InsertFlag = CargoObj.InsertItem(SlotItem, EmptySlot);
|
||||
if (InsertFlag == -1) {
|
||||
SUser.SendNotiBox(" 跨界失败 发生错误请联系管理员", 1);
|
||||
} else {
|
||||
//销毁背包中的道具
|
||||
SlotItem.Delete();
|
||||
//刷新玩家背包列表
|
||||
SUser.SendUpdateItemList(1, 0, 9 + Jso.item.Pos);
|
||||
//刷新账号金库列表
|
||||
CargoObj.SendItemList();
|
||||
SUser.SendNotiBox(" 跨界成功", 1);
|
||||
SUser.SendJso({
|
||||
op = 21007004
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}.bindenv(this));
|
||||
};
|
||||
|
||||
function InitPvf() {
|
||||
// Script();
|
||||
ScriptData.GetFileData("etc/rindro/itemtool/itemcrossover/itemcrossover.etc", function(DataTable, Data) {
|
||||
while (!Data.Eof()) {
|
||||
local Fragment = Data.Get();
|
||||
if (Fragment == "[BASIC MATERIALS]") {
|
||||
BasicMaterials = [];
|
||||
while (true) {
|
||||
local Fbuf = Data.Get();
|
||||
if (Fbuf == "[/BASIC MATERIALS]") {
|
||||
break;
|
||||
}
|
||||
local T = {
|
||||
Item = Fbuf,
|
||||
Count = Data.Get()
|
||||
}
|
||||
BasicMaterials.push(T);
|
||||
}
|
||||
} else if (Fragment == "[LEVEL RATE]") {
|
||||
LevelRate = Data.Get()
|
||||
} else if (Fragment == "[RARITY RATE]") {
|
||||
RarityRate = Data.Get()
|
||||
} else if (Fragment == "[BAN EQUIPMENT]") {
|
||||
BanEquipmentMap = {};
|
||||
while (true) {
|
||||
local Fbuf = Data.Get();
|
||||
if (Fbuf == "[/BAN EQUIPMENT]") {
|
||||
break;
|
||||
}
|
||||
BanEquipmentMap.rawset(Fbuf, true);
|
||||
}
|
||||
} else if (Fragment == "[SPECIAL EQUIPMENT]") {
|
||||
SpecialEquipmentMap = {};
|
||||
while (true) {
|
||||
local Fbuf = Data.Get();
|
||||
if (Fbuf == "[/SPECIAL EQUIPMENT]") {
|
||||
break;
|
||||
}
|
||||
SpecialEquipmentMap.rawset(Fbuf, Data.Get());
|
||||
}
|
||||
} else if (Fragment == "[SPECIAL MATERIALS GROUP]") {
|
||||
SpecialMaterialsGroup = [];
|
||||
while (true) {
|
||||
local Fbuf = Data.Get();
|
||||
if (Fbuf == "[/SPECIAL MATERIALS GROUP]") {
|
||||
break;
|
||||
}
|
||||
if (Fbuf == "[ITEMS]") {
|
||||
local ItemList = [];
|
||||
while (true) {
|
||||
local FSbuf = Data.Get();
|
||||
if (FSbuf == "[/ITEMS]") {
|
||||
break;
|
||||
}
|
||||
local T = {
|
||||
Item = FSbuf,
|
||||
Count = Data.Get()
|
||||
}
|
||||
ItemList.push(T);
|
||||
}
|
||||
SpecialMaterialsGroup.push(ItemList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.bindenv(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Timer.SetTimeOut(function() {
|
||||
|
||||
getroottable()._ItemCrossover_ <- ItemCrossoverC();
|
||||
print("双端插件·装备跨界 - 已加载");
|
||||
}, 1);
|
||||
|
|
@ -190,4 +190,36 @@ class Inven extends Base_C_Object {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//获取背包中指定ID的道具数量
|
||||
function GetCountById(ItemId) {
|
||||
local num = 0;
|
||||
if (ItemId == 0) {
|
||||
num = GetMoney();
|
||||
} else {
|
||||
local SlotIdx = GetSlotById(ItemId);
|
||||
local SlotItem = GetSlot(1, SlotIdx);
|
||||
if (SlotItem != null && SlotItem.GetIndex() == ItemId) {
|
||||
local Count = 1;
|
||||
if (SlotItem.GetType() != "装备") {
|
||||
Count = SlotItem.GetAdd_Info();
|
||||
}
|
||||
return Count;
|
||||
}
|
||||
|
||||
for (local i = 0; i< 120; i++) {
|
||||
local ItemObj = GetSlot(3, i);
|
||||
if (ItemObj != null && ItemObj.GetIndex() == ItemId) {
|
||||
num++;
|
||||
}
|
||||
|
||||
ItemObj = GetSlot(2, i);
|
||||
if (ItemObj != null && ItemObj.GetIndex() == ItemId) {
|
||||
num++;
|
||||
}
|
||||
};
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
文件用途:服务端核心类
|
||||
*/
|
||||
Dps_Self_Ip <- "";
|
||||
|
||||
function removeBackslashes(str) {
|
||||
local result = "";
|
||||
local index = 0;
|
||||
|
|
@ -367,41 +368,41 @@ class ServerControl {
|
|||
if (SUser) {
|
||||
|
||||
|
||||
local InvenObj = SUser.GetInven();
|
||||
local InvenObj = SUser.GetInven();
|
||||
//获取背包对象
|
||||
if(ItemId == 0){
|
||||
if (ItemId == 0) {
|
||||
|
||||
num = InvenObj.GetMoney();
|
||||
num = InvenObj.GetMoney();
|
||||
|
||||
|
||||
}else{
|
||||
} else {
|
||||
|
||||
local SlotIdx = InvenObj.GetSlotById(ItemId);
|
||||
local SlotIdx = InvenObj.GetSlotById(ItemId);
|
||||
|
||||
local SlotItem = InvenObj.GetSlot(1, SlotIdx);
|
||||
if (SlotItem != null && SlotItem.GetIndex() == ItemId) {
|
||||
local Count = 1;
|
||||
if (SlotItem.GetType() != "装备") {
|
||||
Count = SlotItem.GetAdd_Info();
|
||||
local SlotItem = InvenObj.GetSlot(1, SlotIdx);
|
||||
if (SlotItem != null && SlotItem.GetIndex() == ItemId) {
|
||||
local Count = 1;
|
||||
if (SlotItem.GetType() != "装备") {
|
||||
Count = SlotItem.GetAdd_Info();
|
||||
}
|
||||
Jso.Count <- Count;
|
||||
Jso.op = Jso.realop;
|
||||
Socket.SendGateway(Jso);
|
||||
return;
|
||||
}
|
||||
Jso.Count <- Count;
|
||||
Jso.op = Jso.realop;
|
||||
Socket.SendGateway(Jso);
|
||||
return;
|
||||
|
||||
for (local i = 0; i< 120; i++) {
|
||||
local ItemObj = InvenObj.GetSlot(3, i);
|
||||
if (ItemObj != null && ItemObj.GetIndex() == ItemId) {
|
||||
num++;
|
||||
}
|
||||
|
||||
ItemObj = InvenObj.GetSlot(2, i);
|
||||
if (ItemObj != null && ItemObj.GetIndex() == ItemId) {
|
||||
num++;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
for (local i = 0; i< 120; i++) {
|
||||
local ItemObj = InvenObj.GetSlot(3, i);
|
||||
if (ItemObj != null && ItemObj.GetIndex() == ItemId) {
|
||||
num++;
|
||||
}
|
||||
|
||||
ItemObj = InvenObj.GetSlot(2, i);
|
||||
if (ItemObj != null && ItemObj.GetIndex() == ItemId) {
|
||||
num++;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Jso.Count <- num;
|
||||
|
|
|
|||
Loading…
Reference in New Issue