添加示例项目
This commit is contained in:
11
示例项目/武器锻造券/Proj.ifo
Normal file
11
示例项目/武器锻造券/Proj.ifo
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ProjectName": "武器锻造券",
|
||||
"ProjectDescribe": "提升武器的锻造等级",
|
||||
"ProjectAuthor": "南瓜",
|
||||
"ProjectVersion": 1.0,
|
||||
"ProjectConfig": "武器锻造券配置_Nangua.json",
|
||||
"ProjectFiles": [
|
||||
"武器锻造券.nut"
|
||||
],
|
||||
"ProjectRunFunc": "_Dps_UpdateWeaponSeparate_Main_"
|
||||
}
|
||||
99
示例项目/武器锻造券/武器锻造券.nut
Normal file
99
示例项目/武器锻造券/武器锻造券.nut
Normal file
@@ -0,0 +1,99 @@
|
||||
function WeaponForgingBynangua(SUser, ItemId) {
|
||||
local Config = GlobalConfig.Get("武器锻造券配置_Nangua.json");
|
||||
local ItemIdStr = ItemId.tostring();
|
||||
|
||||
if (Config["武器锻造券配置"].rawin(ItemIdStr)) {
|
||||
local forgingConfig = Config["武器锻造券配置"][ItemIdStr];
|
||||
local Level = forgingConfig["锻造等级"];
|
||||
local SuccessRate = forgingConfig["成功率"];
|
||||
|
||||
// 获取玩家背包
|
||||
local InvenObj = SUser.GetInven();
|
||||
if (!InvenObj) return;
|
||||
|
||||
// 获取玩家背包类型1的第9个格子
|
||||
local ItemObj = InvenObj.GetSlot(1, 9);
|
||||
|
||||
// 判断装备是否存在
|
||||
if (ItemObj.IsEmpty) {
|
||||
_UpdateWeaponNotify.NotifyUserAndReturn(SUser, ItemId, Config["提示信息"]["装备不存在"]);
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取装备类型
|
||||
local ItemInfo = PvfItem.GetPvfItemById(ItemObj.GetIndex());
|
||||
local ItemType = NativePointer(ItemInfo.C_Object).add(141 * 4).readU32();
|
||||
if (ItemType != 10) {
|
||||
_UpdateWeaponNotify.NotifyUserAndReturn(SUser, ItemId, Config["提示信息"]["非武器装备"]);
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取原装备的锻造等级
|
||||
local OldLevel = ItemObj.GetForging();
|
||||
if (OldLevel >= Level) {
|
||||
_UpdateWeaponNotify.NotifyUserAndReturn(SUser, ItemId, Config["提示信息"]["锻造等级已达到"]);
|
||||
return;
|
||||
}
|
||||
|
||||
// 随机数生成
|
||||
local RandNum = MathClass.Rand(0, 101);
|
||||
if (RandNum <= SuccessRate) {
|
||||
// 设置装备的锻造等级
|
||||
ItemObj.SetForging(Level);
|
||||
ItemObj.Flush();
|
||||
SUser.SendUpdateItemList(1, 0, 9);
|
||||
|
||||
// 根据配置选择发送消息的方式
|
||||
if (Config["启用233发包(true/false)"]) {
|
||||
SUser.SendNotiBox(format(Config["提示信息"]["锻造成功"], Level), 1);
|
||||
} else {
|
||||
SUser.SendNotiPacketMessage(format(Config["提示信息"]["锻造成功"], Level), 8);
|
||||
}
|
||||
} else {
|
||||
// 根据配置选择发送消息的方式
|
||||
if (Config["启用233发包(true/false)"]) {
|
||||
SUser.SendNotiBox(Config["提示信息"]["锻造失败"], 1);
|
||||
} else {
|
||||
SUser.SendNotiPacketMessage(Config["提示信息"]["锻造失败"], 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class _UpdateWeaponNotify {
|
||||
function NotifyUserAndReturn(SUser, ItemId, message) {
|
||||
local Config = GlobalConfig.Get("武器锻造券配置_Nangua.json");
|
||||
|
||||
// 根据配置选择发送消息的方式
|
||||
if (Config["启用233发包(true/false)"]) {
|
||||
SUser.SendNotiBox(message, 1);
|
||||
} else {
|
||||
SUser.SendNotiPacketMessage(message, 8);
|
||||
}
|
||||
|
||||
SUser.GiveItem(ItemId, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//加载入口
|
||||
function _Dps_UpdateWeaponSeparate_Main_() {
|
||||
_Dps_WeaponForging_Logic_();
|
||||
}
|
||||
|
||||
//重载入口
|
||||
function _Dps_WeaponForging_Main_Reload_(OldConfig) {
|
||||
local Config = GlobalConfig.Get("武器锻造券配置_Nangua.json");
|
||||
// 删除旧的注册
|
||||
foreach(itemId, _ in OldConfig["武器锻造券配置"]) {
|
||||
Cb_Use_Item_Sp_Func.rawdelete(itemId.tointeger());
|
||||
}
|
||||
//重新注册
|
||||
_Dps_WeaponForging_Logic_();
|
||||
}
|
||||
|
||||
function _Dps_WeaponForging_Logic_() {
|
||||
local Config = GlobalConfig.Get("武器锻造券配置_Nangua.json");
|
||||
// 注册所有武器锻造券
|
||||
foreach(itemId, _ in Config["武器锻造券配置"]) {
|
||||
Cb_Use_Item_Sp_Func[itemId.tointeger()] <- WeaponForgingBynangua;
|
||||
}
|
||||
}
|
||||
41
示例项目/武器锻造券/武器锻造券配置_Nangua.json
Normal file
41
示例项目/武器锻造券/武器锻造券配置_Nangua.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"武器锻造券配置": {
|
||||
"123007": {
|
||||
"锻造等级": 4,
|
||||
"成功率": 100
|
||||
},
|
||||
"123008": {
|
||||
"锻造等级": 5,
|
||||
"成功率": 80
|
||||
},
|
||||
"123009": {
|
||||
"锻造等级": 6,
|
||||
"成功率": 60
|
||||
},
|
||||
"123010": {
|
||||
"锻造等级": 7,
|
||||
"成功率": 40
|
||||
},
|
||||
"123011": {
|
||||
"锻造等级": 8,
|
||||
"成功率": 20
|
||||
},
|
||||
"123012": {
|
||||
"锻造等级": 9,
|
||||
"成功率": 10
|
||||
},
|
||||
"123013": {
|
||||
"锻造等级": 10,
|
||||
"成功率": 5
|
||||
}
|
||||
},
|
||||
"提示信息": {
|
||||
"装备不存在": "请将需要锻造的武器放在背包第一排第一格",
|
||||
"非武器装备": "只能对武器进行锻造",
|
||||
"锻造等级已达到": "当前武器锻造等级已经达到或超过目标等级",
|
||||
"锻造成功": "恭喜!武器锻造成功,当前锻造等级:%d",
|
||||
"锻造失败": "很遗憾,锻造失败,请再次尝试"
|
||||
},
|
||||
"提示": "如果使用233发包需要客户端插件,在群文件搜索<客户端插件消息框233>下载使用,否则会导致游戏崩溃",
|
||||
"启用233发包(true/false)": true
|
||||
}
|
||||
Reference in New Issue
Block a user