Rindro-Sqr/Project/MonsterEx/MonsterEx.nut

106 lines
3.3 KiB
Plaintext

/*
文件名:MonsterEx.nut
路径:Project/MonsterEx/MonsterEx.nut
创建日期:2025-02-07 11:46
文件用途:怪物扩展
*/
Rindro_Monster_Ex_Name_Map <- {};
function L_Rindro_MonsterEXControl_Face(ObjectAddress, Xpos, Ypos) {
if (getroottable().rawin("MonsterFaceImage")) {
local ret = MonsterFaceImage(L_Sq_ObjectAddressToSqrObject(ObjectAddress, "IRDMonster", 0));
if (ret) {
L_sq_DrawImg(ret.img, ret.index, Xpos, Ypos);
return false;
}
}
return true;
}
function L_Rindro_MonsterEXControl_Race(ObjectAddress, Xpos, Ypos) {
local v4 = L_sq_RA(ObjectAddress + 88);
local Count = (L_sq_RA(ObjectAddress + 92) - v4) >> 2;
local RaceArr = [];
for (local i = 0; i< Count; i++) {
RaceArr.append(L_sq_RA(v4 + 4 * i));
}
//调用种族拓展
local Monobj = L_Sq_ObjectAddressToSqrObject(L_sq_RA(ObjectAddress + 0x8), "IRDMonster", 0)
if (getroottable().rawin("MonsterCategory")) {
local Ret = MonsterCategory(Monobj, RaceArr, Xpos, Ypos);
if (Ret) RaceArr = Ret;
}
local XposBuffer = Xpos;
foreach(Pos, Index in RaceArr) {
if (Pos > 0) XposBuffer += 33;
L_sq_DrawImg("common/etc/category.img", Index, XposBuffer, Ypos);
}
if (!Monobj.isDead() && Rindro_Monster_Ex_Name_Map.rawin(sq_GetObjectId(Monobj))) {
local Color = sq_RGBA(255, 255, 255, 255);
if(sq_GetMonsterRank(Monobj) == 1) Color = sq_RGBA(179, 107, 255, 255);
if(sq_GetMonsterRank(Monobj) == 3 || sq_GetMonsterRank(Monobj) == 5) Color = sq_RGBA(255, 0, 240 255);
L_sq_DrawCode("Lv" + sq_GetMonsterLevel(Monobj) + " " + Rindro_Monster_Ex_Name_Map[sq_GetObjectId(Monobj)], XposBuffer + (RaceArr.len() > 0 ? 33 : 0) + 2, Ypos + 3, Color, 0, 1);
return -5000;
}
return XposBuffer + (RaceArr.len() > 0 ? 33 : 0);
}
//获取怪物等级
function sq_GetMonsterLevel(Object) {
return L_Sq_GetObjectDeInfo(L_Sq_GetObjectAddress(Object), 0x1A4C, true);
}
//设置怪物等级
function sq_SetMonsterLevel(Object, Level) {
L_Sq_SetObjectDeInfo(L_Sq_GetObjectAddress(Object), 0x1A4C, true, Level);
}
//获取怪物名字
function sq_GetMonsterName(Object) {
return L_Sq_GetObjectName(Object);
}
//设置怪物名字
function sq_SetMonsterName(Object, Name) {
L_Sq_DeleteObjectName(Object);
Rindro_Monster_Ex_Name_Map.rawset(sq_GetObjectId(Object), Name);
}
//获取怪物阶级
function sq_GetMonsterRank(Object) {
if (sq_IsNamed(Object)) return 4;
switch (L_sq_RA(L_Sq_GetObjectAddress(Object) + 0x3658)) {
case 0:
case 4:
case 5:
return 0;
case 1:
case 6:
return 1;
case 2:
case 7:
return 3;
case 3:
case 8:
return 5;
}
return -1;
}
//设置怪物阶级
function sq_SetMonsterRank(Object, Type) {
L_sq_WA(L_Sq_GetObjectAddress(Object) + 0x3658, Type);
}
//怪物头像回调 返回空 或者不返回则为不修改 返回 {img,index} 则为修改
function MonsterFaceImage(obj) {
}
//怪物种族回调 返回空 或者不返回则为不修改 返回修改后的RaceArr数组 则为修改
function MonsterCategory(obj, RaceArr, Xpos, Ypos) {
for (local i = 0; i< 14; i++) {
RaceArr.append(i + 1);
}
return RaceArr;
}