/**
* 整备分解
* @param user
*/
function decompose(user){
// 分解券
var index = 0;
// 检查副职业是否开启
var checkTag = CUserCharacInfo_GetCurCharacExpertJob(user);
if(checkTag == 0){
api_CUser_SendNotiPacketMessage(user,"注意: 副职业没有开启!",1);
return;
}
var inven = CUserCharacInfo_getCurCharacInvenW(user);
for (var i = 9; i <= 24; i++) {
var equ = CInventory_GetInvenRef(inven, INVENTORY_TYPE_ITEM, i);
if(Inven_Item_getKey(equ)){
// 分解装备
DisPatcher_DisJointItem_disjoint(user,i,ENUM_ITEMSPACE_INVENTORY,239,user,0xFFFF);
// 检查装备是否存在
equ = CInventory_GetInvenRef(inven, INVENTORY_TYPE_ITEM, i);
if(Inven_Item_getKey(equ)){
// 失败
}else{
// 成功
index++;
CUser_SendUpdateItemList(user, 1, 0, i);
}
}
}
if(index>0){
api_CUser_SendNotiPacketMessage(user,"恭喜: "+index+"件装备分解 成功!",0);
}else{
api_CUser_SendNotiPacketMessage(user,"注意: 装备分解 失败!",0);
}
}
/**
* 跨界石: 将装备栏的第一个格子的装备移入到账号金库,自动找空的格子,所以可以同时移入多件
* @param user
*/
function crossover(user){
// 跨界 将装备移入到账号金库
var accountCargo = CUser_GetAccountCargo(user);
console.log('accountCargo:'+accountCargo);
var emptyIndex = CAccountCargo_GetEmptySlot_NEW(accountCargo);
console.log('accountCargo emptyIndex:'+emptyIndex)
if(emptyIndex==-1){
api_CUser_SendNotiPacketMessage(user,"跨界失败:账号金库没有空的格子!!!",0);
}
var inven = CUserCharacInfo_getCurCharacInvenW(user);
var equ = CInventory_GetInvenRef(inven, INVENTORY_TYPE_ITEM, 9);
var itemId = Inven_Item_getKey(equ);
if(itemId){
var tag = CAccountCargo_InsertItem_NEW(accountCargo,equ,emptyIndex);
if(tag==-1){
console.log('fail!!!');
api_CUser_SendNotiPacketMessage(user,"跨界失败:移入装备error",0);
}else{
Inven_Item_reset(equ);
CUser_SendUpdateItemList(user, 1, 0, 9);
CAccountCargo_SendItemList_NEW(accountCargo);
console.log('success!!!');
api_CUser_SendNotiPacketMessage(user,"跨界成功:已存入第 "+(emptyIndex+1)+" 个格子!",0);
}
}
}
/**
* 重置异界次数
* @param user
* @param index
*/
function resetResetDimensionInout(user, index){
var dimensionInout = CDataManager_get_dimensionInout(G_CDataManager(), index);
CUserCharacInfo_setDemensionInoutValue(user, index, dimensionInout);
}
/**
* 装备继承 将粉色以上等级大于等于55的装备继承 强化 增幅 锻造 附魔, 原装备会归0
* 武器需要同源 即 太刀-》太刀
* 防具需要同类型 即皮甲上衣 -》板甲上衣
* @param user
*/
function equInherit(user){
var inven = CUserCharacInfo_getCurCharacInvenW(user);
var equ = CInventory_GetInvenRef(inven, INVENTORY_TYPE_ITEM, 9);
var itemId = Inven_Item_getKey(equ)
if(Inven_Item_getKey(equ)){
//读取装备强化等级
var upgrade_level = equ.add(6).readU8();
var itemData = CDataManager_find_item(G_CDataManager(),itemId);
var equ_type = itemData.add(141*4).readU32(); // 装备类型
var sub_type = CEquipItem_GetSubType(itemData);
var equRarity = CItem_GetRarity(itemData); // 稀有度 >=3 粉色以上
var needLevel = CItem_GetUsableLevel(itemData); //等级
console.log("equ_type :"+equ_type)
console.log("sub_type :"+sub_type)
var useJob = "";
for (var i = 60; i <=70; i++) {
useJob += itemData.add(i).readU8();
}
console.log(equ_type + " "+useJob);
if(equRarity < 3){
// 装备品级必须要求粉色以上,继承装备不满足要求
api_CUser_SendNotiPacketMessage(user,"继承失败:装备品级必须要求粉色以上,继承装备不满足要求",0);
return;
}
if(needLevel < 55){
// 装备等级要大于50级以上,继承装备不满足要求
api_CUser_SendNotiPacketMessage(user,"继承失败:装备等级要大于等于55级以上,继承装备不满足要求("+needLevel+")",0);
return;
}
var successTag = false;
for (var i = 10; i <=21; i++) {
var equIn = CInventory_GetInvenRef(inven, INVENTORY_TYPE_BODY, i);
if(Inven_Item_getKey(equIn)){
var inItemId = Inven_Item_getKey(equIn)
var inItemData = CDataManager_find_item(G_CDataManager(),inItemId);
var inEqu_type = inItemData.add(141*4).readU32(); // 装备类型
var inEquRarity = CItem_GetRarity(inItemData); // 稀有度 >=3 粉色以上
var inNeedLevel = CItem_GetUsableLevel(inItemData); //等级
console.log('equ_type a:'+equ_type+','+inEqu_type+','+inItemData.add(148).readU8())
if(inEqu_type==equ_type){
if(inEqu_type==10){
// 武器需要同职业
var useJob = "";
var inUseJob = "";
for (var i = 60; i <=70; i++) {
useJob += itemData.add(i).readU8();
inUseJob += inItemData.add(i).readU8();
}
if(useJob != inUseJob){
api_CUser_SendNotiPacketMessage(user,"继承失败:武器装备需要当前职业且同类型,穿戴装备不满足要求",0);
return;
}
var inSubType = CEquipItem_GetSubType(inItemData);
if(sub_type!=inSubType){
api_CUser_SendNotiPacketMessage(user,"继承失败:武器装备需要当前职业且同类型,穿戴装备不满足要求",0);
return;
}
}
// 类型一直 才能继承
if(inEquRarity<3){
// 继承失败:装备品级必须要求粉色以上,穿戴装备不满足要求
api_CUser_SendNotiPacketMessage(user,"继承失败:装备品级必须要求粉色以上,穿戴装备不满足要求",0);
return;
}
if(inNeedLevel < 55){
// 装备等级要大于50级以上,穿戴装备不满足要求
api_CUser_SendNotiPacketMessage(user,"继承失败:装备等级要大于等于55级以上,穿戴装备不满足要求",0);
return;
}
// 强化
var inUpgrade_level = equIn.add(6).readU8();
// 增幅
var zengfu = equ.add(17).readU16();
// 锻造
var duanzao = equ.add(51).readU8();
// 宝珠
var baozhu = equ.add(13).readU32();
if(inUpgrade_level <= upgrade_level){
//提升强化/增幅等级
equIn.add(6).writeU8(upgrade_level);
equIn.add(17).writeU16(zengfu);
equIn.add(51).writeU8(duanzao);
equIn.add(13).writeU32(baozhu);
// 将原装备清除
equ.add(6).writeU8(0);
equ.add(17).writeU16(0);
equ.add(51).writeU8(0);
equ.add(13).writeU32(0);
//通知客户端更新装备
CUser_SendUpdateItemList(user, 1, 3, i);
CUser_SendUpdateItemList(user, 1, 0, 9);
successTag = true;
console.log("success!!!")
api_CUser_SendNotiPacketMessage(user,"继承成功!!!",0);
}
break;
}
}
}
if(!successTag){
// 失败 没有合适的装备,不符合装备
api_CUser_SendNotiPacketMessage(user,"继承失败:没有合适的装备",0);
}
}
}
function startHellParty(){
Interceptor.attach(ptr(0x085a0954), {
onEnter: function (args) {
if(heffPartyTag){
args[3] = ptr(1);
}
}
});
}
function test(){
Interceptor.attach(ptr(0x084be970), {
onEnter: function (args) {
// a1 InterDispatcher对象 a2 dest消息 a3 消息 a4 获取buffer a5 Stream::length
console.log("InterDispatcher::dispatch arg =:"+args[0]+' '+args[1]+' '+args[2]+' '+args[3]+' '+args[4]+' ')
}
});
Interceptor.attach(ptr(0x08594e52), {
onEnter: function (args) {
// a1 PacketDispatcher对象 a2 消息 a3 获取buffer a4 Stream::length
console.log("PacketDispatcher::dispatch:=:"+args[0]+' '+args[1]+' '+args[2]+' '+args[3])
}
});
Interceptor.attach(ptr(0x08594922), {
onEnter: function (args) {
// a1 PacketDispatcher对象 a2 user a3 buffer的int值 a4 buffer+1的双字节值(类型) a5 获取buffer a6 Stream::length a7 a8
console.log("PacketDispatcher::doDispatch:=:"+args[0]+' '+args[1]+' '+args[2]+' '+args[3]+' '+args[4]+' '+args[5]+' '+args[6]+' '+args[7])
}
});
}
var QUEST_GRADE_COMMON_UNIQUE = 5; //任务脚本中[grade]字段对应的常量定义 可以在importQuestScript函数中找到
var QUEST_GRADE_NORMALY_REPEAT = 4; //可重复提交的重复任务
var QUEST_GRADE_DAILY = 3; //每日任务
var QUEST_GRADE_EPIC = 0; //史诗任务
//无条件完成指定任务并领取奖励
function api_force_clear_quest(user, quest_id)
{
//设置GM完成任务模式(无条件完成任务)
CUser_setGmQuestFlag(user, 1);
//接受任务
CUser_quest_action(user, 33, quest_id, 0, 0);
//完成任务
CUser_quest_action(user, 35, quest_id, 0, 0);
//领取任务奖励(倒数第二个参数表示领取奖励的编号, -1=领取不需要选择的奖励; 0=领取可选奖励中的第1个奖励; 1=领取可选奖励中的第二个奖励)
CUser_quest_action(user, 36, quest_id, -1, 1);
//服务端有反作弊机制: 任务完成时间间隔不能小于1秒. 这里将上次任务完成时间清零 可以连续提交任务
user.add(0x79644).writeInt(0);
//关闭GM完成任务模式(不需要材料直接完成)
CUser_setGmQuestFlag(user, 0);
return;
}
//重置所有任务(需要小退重新选择角色刷新)
function api_reset_all_quest(user)
{
var user_quest = CUser_getCurCharacQuestW(user);
//清空已接任务列表
for(var i=0; i<20; i++)
{
user_quest.add(4 * (i + 7500 + 2)).writeInt(0);
}
//所有任务设置未完成状态
for(var i=0; i<29999; i++)
{
WongWork_CQuestClear_resetClearedQuests(user_quest.add(4), i);
}
api_CUser_SendNotiPacketMessage(user, '所有任务已重置, 请重新选择角色刷新任务列表!', 14);
}
//完成当前已接任务并领取奖励
function clear_doing_quest(user)
{
//玩家任务信息
var user_quest = CUser_getCurCharacQuestW(user);
//遍历20个已接任务
//任务列表(保存任务id): user_quest.add(4 * (i + 7500 + 2))
//任务完成状态(0=已满足任务条件): user_quest.add(4 * (i + 7520 + 2))
for(var i=0; i<20; i++)
{
//任务id
var quest_id = user_quest.add(4 * (i + 7500 + 2)).readInt();
if(quest_id > 0)
{
//无条件完成任务并领取奖励
api_force_clear_quest(user, quest_id);
}
}
//通知客户端更新已完成任务列表
CUser_send_clear_quest_list(user);
//通知客户端更新任务列表
var packet_guard = api_PacketGuard_PacketGuard();
UserQuest_get_quest_info(user_quest, packet_guard);
CUser_Send(user, packet_guard);
Destroy_PacketGuard_PacketGuard(packet_guard);
}
//完成角色当前可接的所有任务(仅发送金币/经验/QP等基础奖励 无道具奖励)
function clear_all_quest_by_character_level(user)
{
//log('clear_all_quest_by_character_level start!');
//玩家任务信息
var user_quest = CUser_getCurCharacQuestW(user);
//玩家已完成任务信息
var WongWork_CQuestClear = user_quest.add(4);
//玩家当前等级
var charac_lv = CUserCharacInfo_get_charac_level(user);
//本次完成任务数量
var clear_quest_cnt = 0;
//pvf数据
var data_manager = G_CDataManager();
//首先完成当前已接任务
clear_doing_quest(user);
//完成当前等级所有任务总经验奖励
var total_exp_bonus = 0;
//完成当前等级所有任务总金币奖励
var total_gold_bonus = 0;
//任务点奖励
var total_quest_point_bonus = 0;
var total_quest_piece_bonus = 0;
//任务最大编号: 29999
for(var quest_id=1; quest_id<30000; quest_id++)
{
//跳过已完成的任务
if(WongWork_CQuestClear_isClearedQuest(WongWork_CQuestClear, quest_id))
continue;
//获取任务数据
var quest = CDataManager_find_quest(data_manager, quest_id);
if(!quest.isNull())
{
//任务类型
var quest_grade = quest.add(8).readInt();
//跳过grade为[common unique]类型的任务(转职等任务)
//跳过可重复提交的任务
//跳过每日任务
if((quest_grade != QUEST_GRADE_COMMON_UNIQUE) && (quest_grade != QUEST_GRADE_NORMALY_REPEAT) && (quest_grade != QUEST_GRADE_DAILY))
{
//判断任务当前是否可接
//var stSelectQuestParam = Memory.alloc(100);
//stSelectQuestParam_stSelectQuestParam(stSelectQuestParam, user);
//if(Quest_check_possible(quest, stSelectQuestParam))
//只判断任务最低等级要求 忽略 职业/前置 等任务要求 可一次性完成当前等级所有任务
var quest_min_lv = quest.add(0x20).readInt();
if(quest_min_lv <= charac_lv)
{
//获取该任务的基础奖励
var exp_bonus = Memory.alloc(4);
var gold_bonus = Memory.alloc(4);
var quest_point_bonus = Memory.alloc(4);
var quest_piece_bonus = Memory.alloc(4);
//QP奖励已直接发送到角色 经验/金币只返回结果 需要手动发送
CUser_quest_basic_reward(user,quest, exp_bonus, gold_bonus, quest_point_bonus, quest_piece_bonus, 1);
//统计本次自动完成任务的基础奖励
var exp = exp_bonus.readInt();
var gold = gold_bonus.readInt();
var quest_point = quest_point_bonus.readInt();
var quest_piece = quest_piece_bonus.readInt();
if(exp > 0)
total_exp_bonus += exp;
if(gold > 0)
total_gold_bonus += gold;
if(quest_point > 0)
total_quest_point_bonus += quest_point; //没有[quest point]字段的任务quest_point=10000
if(quest_piece > 0)
total_quest_piece_bonus += quest_piece;
//将该任务设置为已完成状态
WongWork_CQuestClear_setClearedQuest(user_quest.add(4), quest_id);
//本次自动完成任务计数
clear_quest_cnt++;
}
}
}
}
//通知客户端更新
if(clear_quest_cnt > 0)
{
//发送任务经验奖励
if(total_exp_bonus > 0)
api_CUser_gain_exp_sp(user, total_exp_bonus);
//发送任务金币奖励
if(total_gold_bonus > 0)
CInventory_gain_money(CUserCharacInfo_getCurCharacInvenW(user), total_gold_bonus, 0, 0, 0);
//通知客户端更新奖励数据
if ( CUser_get_state(user) == 3 )
{
CUser_SendNotiPacket(user, 0, 2, 0);
CUser_SendNotiPacket(user, 1, 2, 1);
CUser_SendUpdateItemList(user, 1, 0, 0);
CUser_sendCharacQp(user);
CUser_sendCharacQuestPiece(user);
}
//通知客户端更新已完成任务列表
CUser_send_clear_quest_list(user);
//通知客户端更新任务列表
var packet_guard = api_PacketGuard_PacketGuard();
UserQuest_get_quest_info(user_quest, packet_guard);
CUser_Send(user, packet_guard);
Destroy_PacketGuard_PacketGuard(packet_guard);
//公告通知客户端本次自动完成任务数据
api_CUser_SendNotiPacketMessage(user, '已自动完成当前等级任务数量: ' + clear_quest_cnt, 14);
api_CUser_SendNotiPacketMessage(user, '任务经验奖励: ' + total_exp_bonus, 14);
api_CUser_SendNotiPacketMessage(user, '任务金币奖励: ' + total_gold_bonus, 14);
api_CUser_SendNotiPacketMessage(user, '任务QuestPoint奖励: ' + total_quest_point_bonus, 14);
api_CUser_SendNotiPacketMessage(user, '任务QuestPiece奖励: ' + total_quest_piece_bonus, 14);
}
//log('clear_all_quest_by_character_level end!');
return;
}
//发送每日首次登陆奖励
function send_first_login_reward(user)
{
//奖励道具列表(道具id, 每级奖励数量)
var REWARD_LIST = [[8, 0.1], [3037, 10]];
//获取玩家登录
var cur_level = CUserCharacInfo_get_charac_level(user);
for(var i=0; i<REWARD_LIST.length; i++)
{
//道具id
var reward_item_id = REWARD_LIST[i][0];
//道具数量
var reward_item_cnt = 1 + Math.floor((cur_level * REWARD_LIST[i][1]));
//发送道具到玩家背包
api_CUser_AddItem(user, reward_item_id, reward_item_cnt);
}
}
//角色每日首次登录奖励
function hook_user_first_login()
{
//角色每日重置处理函数 Hook CUser::AddDailyItem
Interceptor.attach(ptr(0x8656CAA), {
onEnter: function (args) {
//保存函数参数
var user = args[0];
console.log('[CUser::AddDailyItem] user=' + user);
//发送每日首次登陆奖励
send_first_login_reward(user);
},
onLeave: function (retval) {
}
});
}
//发送离线奖励
function send_offline_reward(user)
{
//当前系统时间
var cur_time = api_CSystemTime_getCurSec();
//用户上次退出游戏时间
var user_last_play_time = CUserCharacInfo_getCurCharacLastPlayTick(user);
//新创建的角色首次登陆user_last_play_time为0
if(user_last_play_time > 0)
{
//离线时长(分钟)
var diff_time = (cur_time - user_last_play_time) / 60;
//离线10min后开始计算
if(diff_time < 10)
return;
//离线奖励最多发送3天
if(diff_time > 3*24*60)
diff_time = 3*24*60;
//经验奖励: 每分钟当前等级经验的0.2%
var REWARD_EXP_PER_MIN = 0.002;
//金币奖励: 每分钟当前等级*100
var REWARD_GOLD_PER_MIN = 100;
//计算奖励
var cur_level = CUserCharacInfo_get_charac_level(user);
var reward_exp = Math.floor(CUserCharacInfo_get_level_up_exp(user, cur_level) * REWARD_EXP_PER_MIN * diff_time);
var reward_gold = Math.floor(cur_level * REWARD_GOLD_PER_MIN * diff_time);
//发经验
api_CUser_gain_exp_sp(user, reward_exp);
//发金币
CInventory_gain_money(CUserCharacInfo_getCurCharacInvenW(user), reward_gold, 0, 0, 0);
//通知客户端有游戏道具更新
CUser_SendUpdateItemList(user, 1, 0, 0);
//发消息通知客户端奖励已发送
api_CUser_SendNotiPacketMessage(user, '离线奖励已发送(经验奖励:' + reward_exp + ', 金币奖励:' + reward_gold + ')', 6);
}
}
//角色登入登出处理
function hook_user_inout_game_world()
{
//选择角色处理函数 Hook GameWorld::reach_game_world
Interceptor.attach(ptr(0x86C4E50), {
//函数入口, 拿到函数参数args
onEnter: function (args) {
//保存函数参数
this.user = args[1];
console.log('[GameWorld::reach_game_world] this.user=' + this.user);
},
//原函数执行完毕, 这里可以得到并修改返回值retval
onLeave: function (retval) {
//给角色发消息问候
api_CUser_SendNotiPacketMessage(this.user, 'Hello ' + api_CUserCharacInfo_getCurCharacName(this.user)+":"+get_timestamp(), 1);
//离线奖励处理
send_offline_reward(this.user);
//怪物攻城活动更新进度
if(villageAttackEventInfo.state != VILLAGEATTACK_STATE_END)
{
//通知客户端打开活动UI
notify_villageattack_score(this.user);
//公告通知客户端活动进度
event_villageattack_broadcast_diffcult();
}
}
});
//角色退出时处理函数 Hook GameWorld::leave_game_world
Interceptor.attach(ptr(0x86C5288), {
onEnter: function (args) {
var user = args[1];
this.user = user;
console.log('[GameWorld::leave_game_world] user=' + user);
}
});
//角色退出时处理函数 Hook CGameManager::user_exit
Interceptor.attach(ptr(0x082985a8), {
onEnter: function (args) {
var user = args[1];
this.user = user;
console.log('[CGameManager::user_exit] user=' + user);
},
onLeave: function (retval) {
var accId = CUser_get_acc_id(this.user);
// 清除账号仓库 释放空间
if(accountCargfo[accId]){
delete accountCargfo[accId];
// console.log('clean accountCargfo accId:'+accId)
}
}
});
}
//修复绝望之塔
//skip_user_apc: 为true时, 跳过每10层的UserAPC
function fix_TOD(skip_user_apc)
{
//每日进入次数限制
//TOD_UserState::getEnterCount
Interceptor.attach(ptr(0x08643872), {
onEnter: function (args) {
//今日已进入次数强制清零
args[0].add(0x10).writeInt(0);
},
onLeave: function (retval) {
}
});
//每10层挑战玩家APC 服务器内角色不足10个无法进入
if(skip_user_apc)
{
//跳过10/20/.../90层
//TOD_UserState::getTodayEnterLayer
Interceptor.attach(ptr(0x0864383E), {
onEnter: function (args) {
//绝望之塔当前层数
var today_enter_layer = args[1].add(0x14).readShort();
if(((today_enter_layer%10) == 9) && (today_enter_layer > 0) && (today_enter_layer < 100))
{
//当前层数为10的倍数时 直接进入下一层
args[1].add(0x14).writeShort(today_enter_layer + 1);
}
},
onLeave: function (retval) {
}
});
}
//修复金币异常
//CParty::UseAncientDungeonItems
var CParty_UseAncientDungeonItems_ptr = ptr(0x859EAC2);
var CParty_UseAncientDungeonItems = new NativeFunction(CParty_UseAncientDungeonItems_ptr, 'int', ['pointer', 'pointer', 'pointer', 'pointer'], {"abi":"sysv"});
Interceptor.replace(CParty_UseAncientDungeonItems_ptr, new NativeCallback(function (party, dungeon, inven_item, a4) {
//当前进入的地下城id
var dungeon_index = CDungeon_get_index(dungeon);
//根据地下城id判断是否为绝望之塔
if((dungeon_index >= 11008) && (dungeon_index <= 11107))
{
//绝望之塔 不再扣除金币
return 1;
}
//其他副本执行原始扣除道具逻辑
return CParty_UseAncientDungeonItems(party, dungeon, inven_item, a4);
}, 'int', ['pointer', 'pointer', 'pointer', 'pointer']));
}
// 史诗免确认
function cancel_epic_ok()
{
Memory.patchCode(ptr(0x085A56CE).add(2), 1, function (code) {
var cw = new X86Writer(code, { pc: ptr(0x085A56CE).add(2) });
cw.putU8(9);
cw.flush();
});
Interceptor.attach(ptr(0x08150f18), {
onLeave: function (retval) {
retval.replace(0);
}
});
}
/**
* 开启创建缔造
*/
function enable_createCreator(){
Memory.patchCode(ptr(0x081C029E).add(1), 1, function (code) {
var cw = new X86Writer(code, { pc: ptr(0x081C029E).add(1) });
cw.putU8(11);
cw.flush();
});
}
function use_item_handler(user, item_id){
// 任务清除券, 任务完成券 成就任务完成券 主线等
if('8070' == item_id)
{
//所有的任务完成券
clear_all_quest_by_character_level(user);
}
if('690000119' === item_id)
{
//以接任务完成券
equInherit(user);
}
if('8071' == item_id){
// 装备继承 完美继承强化,增幅 ,宝珠 ,锻造(还可以实现 +n的锻造券)
equInherit(user);
}
if('8073' == item_id){
// 装备跨界
crossover(user);
}
if('20220912' == item_id){
// 分解
decompose(user)
}
if('8068' == item_id){
// 初阶异界入场重置
resetResetDimensionInout(user,0)
resetResetDimensionInout(user,1)
resetResetDimensionInout(user,2)
}
if('8069' == item_id){
// 高阶异界入场重置
resetResetDimensionInout(user,3)
resetResetDimensionInout(user,4)
resetResetDimensionInout(user,5)
}
}
暂无讨论,说说你的看法吧