feat: 添加攻击内存数据编解码功能及相关攻击信息操作
实现EncodeAttackMemoryData函数用于攻击内存数据的编解码 添加sq_GetCurrentAttackInfoBonusRate获取攻击奖励率 添加sq_GetCurrentAttackInfoChangeStatus和sq_SetCurrentAttackInfoChangeStatus用于获取和设置攻击状态变更信息
This commit is contained in:
parent
17792f354f
commit
be0725b52a
|
|
@ -81,6 +81,38 @@ function sq_SetObjectAbilityFloatWithDecrypt(obj, ObjectAddressOffset, Value) {
|
|||
// print(DATK(AtkC, 0x8C).readInt());
|
||||
|
||||
|
||||
function EncodeAttackMemoryData(AtkC, Offset) {
|
||||
// 读取 ObjectId
|
||||
local ObjectIdPtr = NativePointer(AtkC + Offset);
|
||||
local ObjectId = ObjectIdPtr.readInt();
|
||||
// 读取 base1 (全局表)
|
||||
local base1Ptr = NativePointer(0x1AF8D78);
|
||||
local base1 = base1Ptr.readInt();
|
||||
// 计算并读取二级表
|
||||
local offset_high = 4 * ((ObjectId >> 16) & 0xFFFF);
|
||||
local addr1 = base1 + offset_high + 0x24;
|
||||
local base2Ptr = NativePointer(addr1);
|
||||
local base2 = base2Ptr.readInt();
|
||||
// 计算并读取 verifyValue
|
||||
local offset_low = 4 * (ObjectId & 0xFFFF);
|
||||
local addr2 = base2 + offset_low + 0x2114;
|
||||
local verifyValuePtr = NativePointer(addr2);
|
||||
local verifyValue = verifyValuePtr.readInt();
|
||||
// 读取输入值
|
||||
local inputAddr = AtkC + Offset + 0x8;
|
||||
local inputPtr = NativePointer(inputAddr);
|
||||
local inputValue = inputPtr.readInt();
|
||||
// 解密
|
||||
local lowWord = verifyValue & 0xFFFF;
|
||||
local expanded = (lowWord << 16) | lowWord;
|
||||
local decrypted = inputValue ^ expanded;
|
||||
|
||||
local Res = Memory.alloc(4);
|
||||
Res.writeInt(decrypted);
|
||||
return Res;
|
||||
}
|
||||
|
||||
|
||||
function sq_GetCurrentAttackInfoDamage(attackInfo) {
|
||||
local AtkC = L_sq_P2I(attackInfo["__ot"][28259608]);
|
||||
local Res = MemoryTool.DecodeMemoryData(AtkC + 0x0);
|
||||
|
|
@ -109,4 +141,37 @@ function sq_SetCurrentAttackInfoAbsoluteDamage(attackInfo, damage)
|
|||
{
|
||||
local AtkC = L_sq_P2I(attackInfo["__ot"][28259608]);
|
||||
MemoryTool.EncodeMemoryData(AtkC + 0x18, damage);
|
||||
}
|
||||
|
||||
function sq_GetCurrentAttackInfoBonusRate(attackInfo)
|
||||
{
|
||||
local AtkC = L_sq_P2I(attackInfo["__ot"][28259608]);
|
||||
local Res = MemoryTool.DecodeMemoryData(AtkC + 0x24);
|
||||
return Res;
|
||||
}
|
||||
// print(DATK(AtkC, 0x1c8).readFloat());
|
||||
// print(DATK(AtkC, 0x1ec).readInt());
|
||||
// print(DATK(AtkC, 0x234).readInt());
|
||||
function sq_GetCurrentAttackInfoChangeStatus(attackInfo)
|
||||
{
|
||||
local AtkC = L_sq_P2I(attackInfo["__ot"][28259608]);
|
||||
local Info = [EncodeAttackMemoryData(AtkC, 0x1c8).readFloat(), EncodeAttackMemoryData(AtkC, 0x1ec).readInt(), EncodeAttackMemoryData(AtkC, 0x234).readInt()];
|
||||
return Info;
|
||||
}
|
||||
|
||||
function sq_SetCurrentAttackInfoChangeStatus(attackInfo, Data1, Data2, Data3)
|
||||
{
|
||||
local AtkC = L_sq_P2I(attackInfo["__ot"][28259608]);
|
||||
local B = blob();
|
||||
B.writen(Data1, 'f');
|
||||
B.seek(0);
|
||||
MemoryTool.EncodeMemoryData(AtkC + 0x1c8, B.readn('i'));
|
||||
B.seek(0);
|
||||
B.writen(Data2, 'i');
|
||||
B.seek(0);
|
||||
MemoryTool.EncodeMemoryData(AtkC + 0x1ec, B.readn('i'));
|
||||
B.seek(0);
|
||||
B.writen(Data3, 'i');
|
||||
B.seek(0);
|
||||
MemoryTool.EncodeMemoryData(AtkC + 0x234, B.readn('i'));
|
||||
}
|
||||
Loading…
Reference in New Issue