/* 文件名:CombatRank.nut 路径:Project/CombatRank/CombatRank.nut 创建日期:2024-08-12 20:07 文件用途:战斗力系统 */ class CombatRankC extends LenheartNewUI_Windows { //调试模式 // DeBugMode = true; //默认显示状态需要是关闭 因为要通过收包打开 Visible = false; //排行榜显示的第几页 Page = 1; MaxPage = 1; //当前显示页面的数据对象 PageInfo = null; //我的数据 MyInfo = null; //殿堂模特数组 ShowCharacter = null; function GetRankInfo() { local T = { op = 20072003, page = Page } SendPackEx(T); } function GetRankInfoCallBack(Chunk) { PageInfo = null; local Jso = Json.Decode(Chunk); PageInfo = Jso.ranking; MyInfo = PageInfo.pop(); MyInfo.rank <- Jso.on; MaxPage = Jso.size; //如果是在第一页 才会有123名 if (Page == 1) { ShowCharacter = array(3); for (local i = 0; i< 3; i++) { local T = { op = 20069001, items = PageInfo[i].avaS, job = PageInfo[i].job.tointeger(), flag = i } SendPackEx(T); } } } //时装 帽子 头部 脸 上衣 下装 鞋子 胸部 腰部 皮肤 光环 AvatarInfoIdx = [0x3038, 0x3010, 0x3014, 0x3018, 0x301c, 0x3020, 0x3024, 0x3028, 0x302c, 0x3030, 0x3034]; creInfoIdx = [0x3068, 0x306C, 0x3070, 0x3074]; //更换装备事件回调 function PlayerChanageEquCallBack(Chunk) { local obj = sq_GetMyMasterCharacter(); if (!obj) return; local C_Object = L_sq_RA(0x1ab7cdc); //记录时装 local avataritemsbuf = []; foreach(offset in AvatarInfoIdx) { local AvatarEquiAddress = L_sq_RA(C_Object + offset); if (AvatarEquiAddress >= 0x400000) { local Ab = []; local NormalIndex = L_sq_RA(AvatarEquiAddress + 0x1c); local ExIndex = L_sq_RA(AvatarEquiAddress + 0x13E0); Ab.append(NormalIndex); Ab.append(ExIndex); avataritemsbuf.append(Ab); } else { local Ab = []; Ab.append(0); Ab.append(0); avataritemsbuf.append(Ab); } } //记录装备 local equiitemsbuf = []; local equiupbuf = []; for (local i = 1; i< 13; ++i) { //编号 local Index = L_sq_GetCharacterAttribute(0x1c, i); //强化 local Upvalue = L_sq_GetCharacterAttribute(0x1054, i) //是否有增幅属性 local IsZf = L_sq_GetCharacterAttribute(0x10A8, i) //锻造 local DsUpvalue = L_sq_GetCharacterAttribute(0x10E8, i); //附魔卡片 local Enchanting = L_sq_GetCharacterAttribute(0x1084, i); equiitemsbuf.append(Index); local Info = []; if (IsZf) { Info.append(0); Info.append(Upvalue); } else { Info.append(Upvalue); Info.append(0); } Info.append(DsUpvalue); Info.append(Enchanting); equiupbuf.append(Info); // print(i); // print(equiupbuf.len()); } //记录宠物 local creitemsbuf = []; foreach(offset in creInfoIdx) { local creEquiAddress = L_sq_RA(C_Object + offset); if (creEquiAddress >= 0x400000) { local NormalIndex = L_sq_RA(creEquiAddress + 0x1c); creitemsbuf.append(NormalIndex); } else { creitemsbuf.append(0); } } //记录四维三攻属强i local Attributes = 0; Attributes += L_sq_GetCharacterAttribute(0x2364); Attributes += L_sq_GetCharacterAttribute(0x2394); Attributes += L_sq_GetCharacterAttribute(0x237c); Attributes += L_sq_GetCharacterAttribute(0x23ac); local AttackValue = 0; AttackValue += L_sq_GetCharacterAttribute(0x1E54); AttackValue += L_sq_GetCharacterAttribute(0x1E84); AttackValue += L_sq_GetCharacterAttribute(0x22C8); local Enhancement = 0; //火冰光暗 大概 Enhancement += L_sq_GetCharacterAttribute(0x1b54); Enhancement += L_sq_GetCharacterAttribute(0x1b60); Enhancement += L_sq_GetCharacterAttribute(0x1b78); Enhancement += L_sq_GetCharacterAttribute(0x1b6c); local T = { op = 20072001, ava = avataritemsbuf, equ = equiitemsbuf, sw = Attributes, atk = AttackValue, ele = Enhancement, cre = creitemsbuf, job = sq_getJob(obj), exjob = sq_getGrowType(obj), name = L_Sq_GetObjectName(obj), equUp = equiupbuf } SendPackEx(T); } ChanageCombat = null; MyCombat = null; DrawAniTimeFlag = null; function PlayerCombatChanageCallBack(Chunk) { local Jso = Json.Decode(Chunk); //战斗力变动 绘制动画 if (Jso.Combat != 0) { ChanageCombat = Jso.Combat; MyCombat = Jso.zdlS; DrawAniTimeFlag = Clock(); } } constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { Childrens = []; //注册控件 RegisterWidget(); LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); Pack_Control.rawset(20069002, GetAvatarDrawInfoCallBack.bindenv(this)); Pack_Control.rawset(20072004, GetRankInfoCallBack.bindenv(this)); Pack_Control.rawset(20072002, PlayerCombatChanageCallBack.bindenv(this)); Pack_Control.rawset(20072102, PlayerChanageEquCallBack.bindenv(this)); //上传自身信息 PlayerChanageEquCallBack(1); //获取排行榜信息 GetRankInfo(); } function GetAvatarDrawInfoCallBack(Chunk) { local Jso = Json.Decode(Chunk); local ZlibStr = Jso.ZipS; Jso.ZipS = Json.Decode(L_sq_Dezlib(Jso.ZipS)); local DrawAniArr = []; foreach(DrawObj in Jso.ZipS.MoniPack) { local FrameArr = []; foreach(Buf in DrawObj.F) { local T = { ImgIndex = Buf[0], Delay = Buf[1], Pos = [Buf[2], Buf[3]] } FrameArr.append(T); } local Ani = Lenheart_Ani(DrawObj.B, FrameArr, [400, 400]); DrawAniArr.append(Ani); } ShowCharacter[Jso.ZipS.flag] = DrawAniArr; } chrobj = null; function GetAvatarDrawInfo(obj) { local C_Object = L_Sq_GetObjectAddress(obj); // 武器 帽子 头部 脸 上衣 下装 鞋子 胸部 腰部 皮肤 光环 local AvatarIdx = [0x3038, 0x3010, 0x3014, 0x3018, 0x301c, 0x3020, 0x3024, 0x3028, 0x302c, 0x3030, 0x3034]; local itemsbuf = []; foreach(offset in AvatarIdx) { local AvatarEquiAddress = L_sq_RA(C_Object + offset); if (AvatarEquiAddress >= 0x400000) { local Ab = []; local NormalIndex = L_sq_RA(AvatarEquiAddress + 0x1c); local ExIndex = L_sq_RA(AvatarEquiAddress + 0x13E0); Ab.append(NormalIndex); Ab.append(ExIndex); itemsbuf.append(Ab); } } } function RegisterWidget() { //关闭按钮 local CloseButton = LenheartNewUI_BaseButton(520, 2, 11, 12, "interface/lenheartwindowcommon.img", 276); CloseButton.OnClick = function() { this.Visible = false; }.bindenv(this); Childrens.append(CloseButton); //左按钮 local LeftButton = LenheartNewUI_BaseButton(236, 500, 12, 9, "interface/lenheartwindowcommon.img", 511); LeftButton.OnClick = function() { if (Page > 1) Page--; }.bindenv(this); Childrens.append(LeftButton); //关闭按钮 local RightButton = LenheartNewUI_BaseButton(304, 500, 12, 9, "interface/lenheartwindowcommon.img", 521); RightButton.OnClick = function() { if (Page< MaxPage) Page++; }.bindenv(this); Childrens.append(RightButton); } //绘制主界面 function DrawMain(obj) { if (!PageInfo) return; //窗口 L_sq_DrawImg("interface/rindro/new_rank.img", 0, X, Y); //排名图标 L_sq_DrawImg("interface2/hud/information_button/information_button_cn.img", 136, X + 5, Y + 295); for (local i = 0; i< PageInfo.len(); i++) { local StrBuf = (i + 1 + (Page - 1) * 10).tostring(); L_sq_DrawCode(StrBuf, X + 16 - LenheartTextClass.GetStringLength(StrBuf) / 2, Y + 318 + (i * 16), sq_RGBA(179, 169, 135, 255), 0, 1); } //职业 L_sq_DrawCode("职业", X + 58, Y + 299, sq_RGBA(179, 169, 135, 255), 0, 1); //角色名 L_sq_DrawCode("角色名", X + 152, Y + 299, sq_RGBA(179, 169, 135, 255), 0, 1); //公会名 L_sq_DrawCode("公会名", X + 280, Y + 299, sq_RGBA(179, 169, 135, 255), 0, 1); //战斗力 L_sq_DrawCode("战斗力", X + 438, Y + 299, sq_RGBA(179, 169, 135, 255), 0, 1); //绘制页数 local PageStr = (Page + "/" + MaxPage); L_sq_DrawCode(PageStr, X + 276 - LenheartTextClass.GetStringLength(PageStr) / 2, Y + 499, sq_RGBA(179, 169, 135, 255), 0, 1); foreach(Index, CharObj in PageInfo) { //绘制职业 L_sq_DrawCode(CharObj.jobname, X + 70 - LenheartTextClass.GetStringLength(CharObj.jobname) / 2, Y + 318 + (Index * 16), sq_RGBA(179, 169, 135, 255), 0, 1); //绘制角色名 L_sq_DrawCode(CharObj.name, X + 169 - LenheartTextClass.GetStringLength(CharObj.name) / 2, Y + 318 + (Index * 16), sq_RGBA(179, 169, 135, 255), 0, 1); local GuildName = "无公会"; //绘制公会名 if ("guildname" in CharObj) { GuildName = CharObj.guildname; } L_sq_DrawCode(GuildName, X + 298 - LenheartTextClass.GetStringLength(GuildName) / 2, Y + 318 + (Index * 16), sq_RGBA(179, 169, 135, 255), 0, 1); //绘制战斗力 L_sq_DrawCode(CharObj.zdlS, X + 456 - LenheartTextClass.GetStringLength(CharObj.zdlS) / 2, Y + 318 + (Index * 16), sq_RGBA(179, 169, 135, 255), 0, 1); } //绘制我自己 { local StrBuf = (MyInfo.rank).tostring(); L_sq_DrawCode(StrBuf, X + 16 - LenheartTextClass.GetStringLength(StrBuf) / 2, Y + 321 + 160, sq_RGBA(229, 180, 83, 255), 0, 1); //绘制职业 L_sq_DrawCode(MyInfo.jobname, X + 70 - LenheartTextClass.GetStringLength(MyInfo.jobname) / 2, Y + 321 + 160, sq_RGBA(229, 180, 83, 255), 0, 1); //绘制角色名 L_sq_DrawCode(MyInfo.name, X + 169 - LenheartTextClass.GetStringLength(MyInfo.name) / 2, Y + 321 + 160, sq_RGBA(229, 180, 83, 255), 0, 1); local GuildName = "无公会"; //绘制公会名 if ("guildname" in MyInfo) { GuildName = MyInfo.guildname; } L_sq_DrawCode(GuildName, X + 298 - LenheartTextClass.GetStringLength(GuildName) / 2, Y + 321 + 160, sq_RGBA(229, 180, 83, 255), 0, 1); //绘制战斗力 L_sq_DrawCode(MyInfo.zdlS, X + 456 - LenheartTextClass.GetStringLength(MyInfo.zdlS) / 2, Y + 321 + 160, sq_RGBA(229, 180, 83, 255), 0, 1); } if (ShowCharacter) { foreach(Index, AniDrawObj in ShowCharacter) { try { local OffsetX = 270; local OffsetY = 268; if (Index == 1) { OffsetX = 130; OffsetY = 268; } if (Index == 2) { OffsetX = 410; OffsetY = 268; } if (AniDrawObj) { foreach(AniObj in AniDrawObj) { AniObj.X = X + OffsetX; AniObj.Y = Y + OffsetY; AniObj.Show(Duration); } } } catch (exception) { } } } } AlphaValue = 1.0; function DrawImg(Path, Index, XPos, YPos, rate) { L_sq_DrawImg(Path, Index, XPos, YPos, 1, sq_RGBA(255, 255, 255, (250 * AlphaValue).tointeger()), rate, rate); } NormalNumOffset = [22, 11, 22, 21, 21, 21, 22, 19, 22, 21]; function DrawCombatNormal(Num) { local XLength = 0; foreach(ac in Num) { local Idx = (ac - 48).tointeger(); XLength += NormalNumOffset[Idx]; } local NumOffset = { X = ((getroottable().Rindro_Scr_Width - 55) / 2).tointeger(), Y = 473 }; NumOffset.X -= XLength; local Xoffset = 0; foreach(index, value in Num) { local Idx = (value - 48).tointeger(); DrawImg("interface/rindro/new_ranknum.img", 10 + Idx, NumOffset.X + Xoffset, NumOffset.Y, 1.0); Xoffset += (NormalNumOffset[Idx]); } } function DrawCombatChanage(Num, type) { DrawImg("interface/rindro/new_rank.img", type ? 4 : 3, ((getroottable().Rindro_Scr_Width - 55) / 2).tointeger() + 60, 478, 0.5); local NumOffset = { X = ((getroottable().Rindro_Scr_Width - 55) / 2).tointeger() + 80, Y = 473 }; local Xoffset = 0; local ImgType = 30; if (type) ImgType = 40; foreach(index, value in Num) { local Idx = (value - 48).tointeger(); DrawImg("interface/rindro/new_ranknum.img", ImgType + Idx, NumOffset.X + Xoffset, NumOffset.Y, 1.0); Xoffset += (NormalNumOffset[Idx]); } } function DrawCombat() { if (DrawAniTimeFlag) { local NowTime = Clock(); if ((NowTime - DrawAniTimeFlag) >= 2000) { ChanageCombat = null; MyCombat = null; DrawAniTimeFlag = null; return; } local PlayT = (NowTime - DrawAniTimeFlag); AlphaValue = sq_GetUniformVelocity(300, 30, PlayT, 2000).tofloat() / 100.0; if (AlphaValue > 1.0) AlphaValue = 1.0; local IconOffset = { X = ((getroottable().Rindro_Scr_Width - 55) / 2).tointeger(), Y = 450 }; L_sq_SetDrawImgModel(2, 0); L_sq_DrawImg("interface/rindro/new_rank.img", 2, IconOffset.X, IconOffset.Y, 1, sq_RGBA(255, 255, 255, (250 * AlphaValue).tointeger()), 0.5, 0.5); L_sq_ReleaseDrawImgModel(); L_sq_DrawImg("interface/rindro/new_rank.img", 1, IconOffset.X + 5, IconOffset.Y + 6, 1, sq_RGBA(255, 255, 255, (250 * AlphaValue).tointeger()), 0.5, 0.5); if (PlayT <= 300) { local Str = (MyCombat[0] - 48).tostring(); for (local i = 0; i< MyCombat.len(); i++) { if (i != 0) Str += (sq_getRandom(0, 9)); } DrawCombatNormal(Str); } else { DrawCombatNormal(MyCombat); } DrawCombatChanage(abs(ChanageCombat).tostring(), (ChanageCombat > 0) ? false : true); } } function Show(obj) { DrawMain(obj); LenheartNewUI_Windows.Show(obj); if (Visible) { DrawCombat(); } } //逻辑入口 function Proc(obj) { LenheartNewUI_Windows.SyncPos(X, Y); if (!Visible) { DrawCombat(); } MainState = Visible; } MainState = false; function OpenCallBack() { Visible = true; ResetFocus(); //上传自身信息 PlayerChanageEquCallBack(1); //获取排行榜信息 GetRankInfo(); } } getroottable().rawdelete("CombatRankC_Obj"); function Lenheart_CombatRank_New(obj) { local RootTab = getroottable(); if (!RootTab.rawin("CombatRankC_Obj")) { RootTab.rawset("CombatRankC_Obj", true); local Winobj = LenheartNewUI_CreateWindow(CombatRankC, "新战力排行榜窗口", ((getroottable().Rindro_Scr_Width - 542) / 2).tointeger(), 28, 542, 515, 28); EventList_Obj.AddEvent("荣誉殿堂", 136, Winobj, "interface2/hud/information_button/information_button_cn.img"); } } if (getroottable().rawin("LenheartFuncTab")) { getroottable()["LenheartFuncTab"].rawset("Lenheart_CombatRank_NewFunc", Lenheart_CombatRank_New); } else { local T = {}; T.rawset("Lenheart_CombatRank_NewFunc", Lenheart_CombatRank_New); getroottable().rawset("LenheartFuncTab", T); }