From fe05643f72d43524ca8dc882c4a743a1399fa8f4 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Tue, 14 Apr 2026 13:20:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=81=B7=E7=AA=83=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=81=B7=E7=AA=83=E7=B3=BB=E7=BB=9F=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加偷窃系统配置文件及脚本入口 - 实现NPC交互菜单和偷窃功能逻辑 - 添加网络通信协议处理 - 初始化偷窃配置数据并注册NPC交互 - 完善偷窃解锁动画和状态管理 --- FileConfig.json | 12 +++++ Project/Steal/Steal.nut | 115 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 120 insertions(+), 7 deletions(-) diff --git a/FileConfig.json b/FileConfig.json index 7a94cfe..9f5f1df 100644 --- a/FileConfig.json +++ b/FileConfig.json @@ -128,6 +128,18 @@ "ImageMini": "http://49.234.27.222:8651/dps/download2/Image:chengjiu.png" } }, + "偷窃系统": { + "Private": true, + "Script": [ + "Project/Steal/Steal.nut" + ], + "info": { + "ProjectAuthor": "官方 (期限:月)", + "ProjectVersion": "1.0.0", + "ProjectDescribe": "偷窃系统", + "ImageMini": "http://49.234.27.222:8651/dps/download2/Image:chengjiu.png" + } + }, "异界装备升级": { "Private": true, "Enabled": false, diff --git a/Project/Steal/Steal.nut b/Project/Steal/Steal.nut index 225bcd4..3d1194a 100644 --- a/Project/Steal/Steal.nut +++ b/Project/Steal/Steal.nut @@ -152,7 +152,7 @@ class StealC extends LenheartNewUI_Windows { // NoWindow = true; //是否可见 - // Visible = false; + Visible = false; Img = Rindro_Image("steal/widget.img"); @@ -168,6 +168,9 @@ class StealC extends LenheartNewUI_Windows { UnlockAniFinished = false; UnlockFinalizeDone = false; UnlockAniFrameDelay = 60; + NPCList = null; + RequestNpcId = -1; + NpcEachRegistered = false; constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { Childrens = []; @@ -177,6 +180,19 @@ class StealC extends LenheartNewUI_Windows { LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); RefreshUnlockComplete(); + InitStealConfig(); + RegisterStealNpcEach(); + + RegisterPack(21017002, function(Chunk) { + local Jso = Json.Decode(Chunk); + if (Jso.rawin("ret") && Jso.ret == true) { + ResetStealSession(); + Visible = true; + ResetFocus(); + } else { + Visible = false; + } + }.bindenv(this)); } function RegisterWidget() { @@ -193,8 +209,87 @@ class StealC extends LenheartNewUI_Windows { } } - //绘制主界面 + function InitStealConfig() { + NPCList = []; + Rindro_Script.GetFileData("etc/steal.etc", function(DataTable, Data) { + while (!Data.Eof()) { + local Fragment = Data.Get(); + if (Fragment == "[npc list]") { + while (true) { + local Value = Data.Get(); + if (Value == "[/npc list]") { + break; + } + local NpcId = Value; + try { + NpcId = Value.tointeger(); + } catch (exception) {} + NPCList.append(NpcId); + } + } + } + }.bindenv(this)); + } + + function RegisterStealNpcEach() { + if (NpcEachRegistered) { + return; + } + if (!NPCList || NPCList.len() <= 0) { + return; + } + local RootTab = getroottable(); + local EachManager = null; + if (RootTab.rawin("L_Each_Obj")) { + EachManager = RootTab["L_Each_Obj"]; + } else if (RootTab.rawin("Lenheart_Get_EachObj")) { + EachManager = RootTab["Lenheart_Get_EachObj"](); + } + if (!EachManager) { + return; + } + + foreach(id in NPCList) { + EachManager.AddEachForNpc(id, function(SThis) { + local StealButton = LenheartNewUI_Each_BaseButton(0, 0, 100, 21, "interface2/popup_menu/popup_back.img", 3); + StealButton.Icon = "interface2/popup_menu/popup_icon_cn.img"; + StealButton.IconIdx = 27; + StealButton.Str = "偷窃"; + StealButton.OnClick = function(Button) { + local NpcId = Button.Parent.NPC_Index; + RequestNpcId = NpcId; + Button.Parent.CloseAllEach(); + Button.Parent.CloseWindow(); + SendPackEx({ + op = 21017001, + npcid = NpcId + }); + }.bindenv(this); + StealButton.SetCallBackFunc(function(Button) {}) + SThis.AddChild(StealButton); + }.bindenv(this)); + } + NpcEachRegistered = true; + } + + function ResetStealSession() { + UnlockComplete = 0.0; + CorrectLockedCount = 0; + AllUnlockedTriggered = false; + + UnlockAniPlaying = false; + UnlockAniFinished = false; + UnlockFinalizeDone = false; + UnlockSuccessAni = null; + + AniQueue = QuestQueue(); + + Childrens = []; + RegisterWidget(); + RefreshUnlockComplete(); + } + function GetLockTopY() { return Y + 268 + 60; } @@ -294,13 +389,17 @@ class StealC extends LenheartNewUI_Windows { } function SendStealUnlockPack() { - // TODO: fill op and fields when server protocol is finalized. - // SendPackEx({ op = xxxx }); + if (RequestNpcId == null || RequestNpcId <= 0) { + return; + } + SendPackEx({ + op = 21017003, + npcid = RequestNpcId + }); } function OnAllUnlockedInternal() { R_Utils.PlaySound("GAMBLE_RESULT_GOOD"); - print("Steal all unlocked: " + CorrectLockedCount); StartUnlockSuccessSequence(); } @@ -387,6 +486,9 @@ class StealC extends LenheartNewUI_Windows { //逻辑入口 function Proc(obj) { LenheartNewUI_Windows.SyncPos(X, Y); + if (!NpcEachRegistered) { + RegisterStealNpcEach(); + } CheckSpaceLock(); } @@ -402,7 +504,6 @@ getroottable().rawdelete("L_Each_Obj"); - function Lenheart_Steal_Fun(obj) { local RootTab = getroottable(); if (!RootTab.rawin("Steal_Obj")) { @@ -411,4 +512,4 @@ function Lenheart_Steal_Fun(obj) { } } -getroottable()["LenheartFuncTab"].rawset("StealFuncN", Lenheart_Steal_Fun); \ No newline at end of file +getroottable()["LenheartFuncTab"].rawset("StealFuncN", Lenheart_Steal_Fun);