更新哥布林袖珍罐

This commit is contained in:
Lenheart 2026-02-13 20:17:21 +08:00
parent a98bfaef48
commit f4abe5d1eb
2 changed files with 140 additions and 42 deletions

View File

@ -57,6 +57,18 @@
"CSBase/Interface.nut"
],
"ProjectScript": {
"黄金哥布林袖珍罐": {
"Private": true,
"Script": [
"Project/TreasureGoblin/TreasureGoblin.nut"
],
"info": {
"ProjectAuthor": "官方 (期限:月)",
"ProjectVersion": "1.0.0",
"ProjectDescribe": "黄金哥布林袖珍罐",
"ImageMini": "http://49.234.27.222:8651/dps/download2/Image:chengjiu.png"
}
},
"异界装备升级": {
"Private": true,
"Script": [

View File

@ -9,11 +9,10 @@ class TreasureGoblinC extends LenheartNewUI_Windows {
// DeBugMode = true;
//不是窗口
// NoWindow = true;
NoWindow = true;
//是否可见
// Visible = false;
Visible = false;
BaseImg = Rindro_Image("interface2/rindro_reward.img");
MainImg = Rindro_Image("treasuregoblin/main.img");
@ -21,10 +20,13 @@ class TreasureGoblinC extends LenheartNewUI_Windows {
//窗口名称
WindowTitle = "普通宝藏哥布林的宝箱";
//关闭按钮
CloseButton = null;
//搜索时间Flag
SearchTimeFlag = 0;
//搜索时间品级对应表
SearchTimeGradeTable = [1000, 1500, 2000, 2500, 3000, 3500];
SearchTimeGradeTable = [1500, 1500, 2000, 2500, 3000, 3500, 3500, 3500, 3500, 3500, 3500];
//奖励包
RewardPackage = null;
@ -32,47 +34,67 @@ class TreasureGoblinC extends LenheartNewUI_Windows {
//动画队列
AniQueue = null;
//哥布林配置表 ID -> 名字
GoldGoblinConfig = null;
//当前哥布林ID
CurrentGoblinId = 690000226;
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
Childrens = [];
AniQueue = QuestQueue();;
AniQueue = QuestQueue();
//注册控件
RegisterWidget();
//初始化哥布林配置
InitGoldGoblinConfig();
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
local RewList = [3037, 3038, 3039, 26058];
local RewList = [7422, 7422, 7422, 7422, 7422, 2682154, 2682154, 2682154, 2682154, 2682154, 10007482, 10007482, 10007482, 10007482, 10007482, 10007483, 10007483, 10007483, 10007483, 10007483, 10007484, 10007484, 10007484, 10007484, 10007484, 10092470, 10092470, 10092470, 10092470, 10092470, 490701711, 490701711, 490701711, 490701711, 490701711, 490701712, 490701712, 490701712, 490701712, 490701712, 2660671, 2660671, 2660671, 2660671, 2660671, 2660672, 2660672, 2660672, 2660672, 2660672, 7163, 1298, 2682833, 7163, 1298, 2682833, 7163, 1298, 2682833, 2682834, 2682835, 10007249, 10007250, 10007251, 10015164, 10015165, 10015166, 10015167, 10015168, 10015169, 10015170, 10015171, 10015172, 10015173, 10015174, 490001458, 490001942, 490001937, 490001941, 490002485, 490001940, 490001956, 490001693, 490011087, 490703966, 490702732, 490702941, 490700168, 10008064, 10008065, 10008066, 10008067, 10008068, 10008069, 10008070, 10008071, 10008072, 10008073, 10008074, 10008075, 10008076, 10008077, 10008078, 10008079, 10008080, 10008081, 10008082, 10008083, 10008084, 10008085, 10008086, 10008087, 10008088, 10008089, 10008090, 10008091, 10008092, 10008093, 10008094, 10008095, 10008096, 10008097, 10008098, 10008099, 10008100, 10008101, 10008102, 10008103, 10008104, 10008105, 10008106, 10008107, 10008910, 10008911, 8381, 2681176, 2681177, 2681178, 2681179, 2681180, 2681181, 2681182, 2681183, 2681184, 2681185, 2681186, 2681187, 2681482, 2681483, 2681486, 2681487, 2747554, 2747555, 2747556, 2747557, 2747558, 2747559, 2747560, 2747561, 20210112, 20210113];
// RewardPackage = [];
// for (local i = 0; i< sq_getRandom(5, 8); i++) {
// local T = {};
// T.ItemId <- RewList[sq_getRandom(0, RewList.len() - 1)];
// T.ItemCount <- sq_getRandom(1, 5);
// T.IsSearch <- false; //是否已经搜索
// // T.Grade <- L_sq_RA(L_sq_GetItem(T.ItemId) + 0xF4); //到时候品级由服务端决定下发
// // T.Grade <- L_sq_RA(L_sq_GetItem(T.ItemId) + 0xF4);
// T.Grade <- 4;
// RewardPackage.append(T);
// }
// Visible = true;
// SetCurrentGoblinId(1);
// CloseButton.Visible = false;
RewardPackage = [];
for (local i = 0; i< sq_getRandom(5, 16); i++) {
local T = {};
T.ItemId <- RewList[sq_getRandom(0, RewList.len() - 1)];
T.Count <- sq_getRandom(1, 5);
T.IsSearch <- false; //是否已经搜索
// T.Grade <- L_sq_RA(L_sq_GetItem(T.ItemId) + 0xF4); //到时候品级由服务端决定下发
// T.Grade <- L_sq_RA(L_sq_GetItem(T.ItemId) + 0xF4);
T.Grade <- sq_getRandom(4, 5);
RewardPackage.append(T);
}
Pack_Control.rawset(21014002, function (Chunk)
{
local Jso = Json.Decode(Chunk);
RewardPackage = Jso.RewardPackage;
foreach (obj in RewardPackage) {
obj.IsSearch<- false;
}
Visible = true;
CloseButton.Visible = false;
SetCurrentGoblinId(Jso.BoxId);
}.bindenv(this));
}
function RegisterWidget() {
//关闭按钮
local CloseButton = LenheartNewUI_BaseButton(303, 6, 11, 12, "interface/lenheartwindowcommon.img", 276);
CloseButton = LenheartNewUI_BaseButton(303, 6, 11, 12, "interface/lenheartwindowcommon.img", 276);
CloseButton.OnClick = function() {
this.Visible = false;
}.bindenv(this);
Childrens.append(CloseButton);
local PickAllButton = LenheartNewUI_ButtonText(108, 341, 45, "全部拾取");
PickAllButton.SetTextOffset(9, 1);
PickAllButton.OnClick = function() {
}.bindenv(this);
AddChild(PickAllButton);
}
//绘制主界面
@ -84,7 +106,7 @@ class TreasureGoblinC extends LenheartNewUI_Windows {
L_sq_DrawCode(WindowTitle, X + 158 - LenheartTextClass.GetStringLength(WindowTitle) / 2, Y + 7, sq_RGBA(230, 200, 155, 255), 0, 1);
//绘制窗口
DrawNineBox(X, Y + 23, 316, 350, "interface/lenheartwindowcommon.img", 213); //背景框
DrawNineBox(X, Y + 23, 316, 317, "interface/lenheartwindowcommon.img", 213); //背景框
//绘制内嵌窗口
DrawNineBox(X + 8, Y + 32, 299, 299, "interface/lenheartwindowcommon.img", 204); //背景框
@ -92,24 +114,31 @@ class TreasureGoblinC extends LenheartNewUI_Windows {
//绘制分割线
MainImg.DrawExPng(0, X + 10, Y + 34, 0, sq_RGBA(127, 132, 142, 250), 1.0, 1.0);
if (RewardPackage) {
foreach(Index, Info in RewardPackage) {
local XPos = X + 11 + ((Index % 8) * 37);
local YPos = Y + ((Index / 8).tointeger() * 37) + 35;
local XPos = X + 24 + ((Index % 6) * 47);
local YPos = Y + ((Index / 6).tointeger() * 47) + 46;
if (Info.IsSearch) {
BaseImg.DrawPng(Info.Grade, XPos, YPos);
DrawItemBase(XPos + 3, YPos + 3, Info.ItemId, Info.Count);
// BaseImg.DrawPng(Info.Grade, XPos, YPos);
DrawItemBase(XPos + 3, YPos + 3, Info.ItemId, Info.ItemCount);
} else {
MainImg.DrawPng(1, XPos + 10, YPos + 10);
MainImg.DrawPng(1, XPos + 9, YPos + 9);
}
}
//绘制无道具的遮挡槽
for (local i = 0 ; i< 36; i++) {
if (i >= RewardPackage.len()) {
MainImg.DrawPng(2, X + 26 + ((i % 6) * 47), Y + ((i / 6).tointeger() * 47) + 48);
}
}
local AllSearchFinish = true;
foreach(Index, Info in RewardPackage) {
local XPos = X + 11 + ((Index % 8) * 37);
local YPos = Y + ((Index / 8).tointeger() * 37) + 35;
local XPos = 24 + ((Index % 6) * 47);
local YPos =((Index / 6).tointeger() * 47) + 46;
//如果是没有搜索状态
if (!Info.IsSearch) {
AllSearchFinish = false;
//还没有开始计时
if (!Info.rawin("SeachTimer")) {
Info.SeachTimer <- 0;
@ -117,17 +146,23 @@ class TreasureGoblinC extends LenheartNewUI_Windows {
if (Duration< 100) Info.SeachTimer += Duration;
if (Info.SeachTimer< SearchTimeGradeTable[Info.Grade]) {
local T = GetClockwiseCirclePoint(Info.SeachTimer / 1300.0, 0, 0, 6);
Rindro_Image_GlobalMap["lenheartui"].DrawPng(159, XPos + 12 + T.x, YPos + 12 + T.y);
Rindro_Image_GlobalMap["lenheartui"].DrawPng(159, X + XPos + 12 + T.x, Y + YPos + 12 + T.y);
} else {
Info.IsSearch = true;
R_Utils.PlaySound("ICON_KEY");
local SoundGrade = "ITEM_PICK";
if (Info.Grade == 2 || Info.Grade == 3) SoundGrade = "GoblinBox2";
if (Info.Grade >= 4) SoundGrade = "GoblinBox1";
R_Utils.PlaySound(SoundGrade);
SendPackEx({
op = 21014003
})
AniQueue.AddQuest("搜索完成动画" + Info.Grade, function(Name, Time, Grade, XPos, YPos) {
local AniPath = "common/item_effect/custom_2option_setting.ani";
if (Grade == 3) AniPath = "common/item_effect/custom_3option.ani";
if (Grade == 5) AniPath = "common/item_effect/custom_4option.ani";
if (Grade == 4) AniPath = "common/item_effect/custom_honor_4option.ani";
local Ani = DrawAniEx(XPos, YPos, AniPath);
local AniPath = "common/item_effect/custom_3option.ani";
if (Grade == 2 || Grade == 3) AniPath = "common/item_effect/custom_4option.ani";
if (Grade >= 4) AniPath = "common/item_effect/custom_honor_4option.ani";
local Ani = DrawAniEx(X + XPos, Y + YPos, AniPath);
if (sq_GetAnimationFrameIndex(Ani) == 14) {
sq_Rewind(Ani);
AniQueue.RemoveQuest(Name);
@ -137,6 +172,10 @@ class TreasureGoblinC extends LenheartNewUI_Windows {
break;
}
}
if (AllSearchFinish) {
CloseButton.Visible = true;
}
}
}
@ -146,12 +185,14 @@ class TreasureGoblinC extends LenheartNewUI_Windows {
LenheartNewUI_Windows.Show(obj);
}
//逻辑入口
function Proc(obj) {
LenheartNewUI_Windows.SyncPos(X, Y);
IsFocus = true;
}
function GetClockwiseCirclePoint(dt, centerX, centerY, radius) {
// 将dt映射到角度(0到2π弧度),并反转方向实现顺时针
local angle = 2 * 3.1415926535 * (1.0 - dt);
@ -166,6 +207,46 @@ class TreasureGoblinC extends LenheartNewUI_Windows {
y = centerY + offsetY
};
}
//读取哥布林配置
function InitGoldGoblinConfig() {
GoldGoblinConfig = {};
Rindro_Script.GetFileData("etc/rindro/goldgoblin/goldgoblin.lst", function(ConfigTable, Data) {
while (!Data.Eof()) {
local Index = Data.Get();
local Path = "etc/" + Data.Get();
local GoblinInfo = Rindro_Script.GetFileData(Path, function(InfoTable, InfoData) {
while (!InfoData.Eof()) {
local Fragment = InfoData.Get();
if (Fragment == "[name]") {
InfoTable.Name <- Sq_ConvertWideChar(InfoData.Get(), "big5");
} else if (Fragment == "[trigger]") {
InfoTable.TriggerId <- InfoData.Get();
}
}
}.bindenv(this));
if (GoblinInfo.rawin("TriggerId") && GoblinInfo.rawin("Name")) {
GoldGoblinConfig[GoblinInfo.TriggerId] <- GoblinInfo.Name;
}
}
}.bindenv(this));
}
//根据ID获取哥布林名字
function GetGoblinNameById(goblinId) {
if (GoldGoblinConfig && GoldGoblinConfig.rawin(goblinId)) {
return GoldGoblinConfig[goblinId];
}
return "宝藏哥布林的宝箱";
}
//设置当前哥布林ID并更新窗口标题
function SetCurrentGoblinId(goblinId) {
CurrentGoblinId = goblinId;
WindowTitle = GetGoblinNameById(goblinId);
}
}
getroottable().rawdelete("TreasureGoblin_Obj");
@ -173,7 +254,7 @@ function Lenheart_TreasureGoblin_Fun(obj) {
local RootTab = getroottable();
if (!RootTab.rawin("TreasureGoblin_Obj")) {
RootTab.rawset("TreasureGoblin_Obj", true);
LenheartNewUI_CreateWindow(TreasureGoblinC, "宝藏哥布林的宝箱窗口", ((getroottable().Rindro_Scr_Width - 317) / 2).tointeger(), 80, 317, 370, 26);
LenheartNewUI_CreateWindow(TreasureGoblinC, "宝藏哥布林的宝箱窗口", ((getroottable().Rindro_Scr_Width - 317) / 2).tointeger(), 80, 317, 335, 26);
}
}
@ -187,4 +268,9 @@ getroottable().rawdelete("LenheartPluginsInitFlag");
getroottable().rawdelete("EventList_Obj")
getroottable().rawdelete("TreasureGoblin_Obj");
// L_sq_GoDungeon(3709);
// L_sq_GoDungeon(3709);
// local Objss = L_Sq_ObjectAddressToSqrObject(L_sq_RA(0x1AB7CDC), "CNSquirrelPassiveObject", 0);
// print(Objss);
// print(Objss.isObjectType(OBJECTTYPE_CHARACTER));