public void registerFlight(int goodsID) { string cmd = ""; //注册读取飞行棋坐标信息 ex.RegMsgCallBack(0x3B, new MsgCallBack(false, delegate(int msgType, byte[] data) { //3B 3A 00 0D if (data[3] == 0x0D) { int mid = BitConverter.ToInt16(new byte[] { data[8], data[9] }, 0); if (mapID == mid) { int point = readAxis(data, this.toAxis); //发送飞行指令 cmd = "3B 07 0F {0} {1} 00"; cmd = String.Format(cmd, StringUtil.FormatIntToHexStyle(goodsID, true).Trim(), StringUtil.FormatIntToHexStyle(point, true).Trim()); LoadDll.sendMsg((IntPtr)hwnd, cmd); } } }, true, null)); //注册飞行棋使用信息 ex.RegMsgCallBack(0x37, new MsgCallBack(false, delegate(int msgType, byte[] data) { //37 04 00 C6 D4 27 40 if (data[1] == 0x04 && data[2] == 0x00) { int gid = BitConverter.ToInt32(new byte[] { data[3], data[4], data[5], data[6] }, 0); cmd = "33 05 {0} 00"; cmd = String.Format(cmd, StringUtil.FormatIntToHexStyle(gid, true).Trim()); //回应服务器已经到了 LoadDll.sendMsg((IntPtr)hwnd, cmd); } }, true, null)); }
/// <summary> /// 发货 /// </summary> public void sendDelivery(int t) { if (t == 1) { biaoID = mhxy.CallFunc.GetBagTypeID(hwnd, 3001); //镖货的种类ID if (biaoID == 0) { biaoID = mhxy.CallFunc.GetBagTypeID(hwnd, 3002); } if (biaoID == 0) { biaoID = mhxy.CallFunc.GetBagTypeID(hwnd, 3003); } if (biaoID == 0) { biaoID = mhxy.CallFunc.GetBagTypeID(hwnd, 3004); } //封包发货 if (biaoID > 0) { string cmd = String.Format("33 05 {0} 00", StringUtil.FormatIntToHexStyle(biaoID, true).Trim()); //先发包告诉是手动给予 LoadDll.sendMsg((IntPtr)hwnd, cmd); System.Threading.Thread.Sleep(1500); //物品ID1075273487->0F 5F 17 40 //FA 0C 16 00 00 00 D4 01 00 0F 5F 17 40 00 cmd = String.Format("FA 0C 16 00 00 00 D4 01 00 {0} 00", StringUtil.FormatIntToHexStyle(biaoID, true).Trim()); LoadDll.sendMsg((IntPtr)hwnd, cmd); Log.WriteLine("发送货物给NPC:{0}", cmd); } } if (t == 2 && biaoID > 0) { string cmd = String.Format("89 18 {0} {1} 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", StringUtil.FormatIntToHexStyle(NPC_ID, true).Trim(), StringUtil.FormatIntToHexStyle(biaoID, true).Trim()); LoadDll.sendMsg((IntPtr)hwnd, cmd); Log.WriteLine("收到回应,发出确认:{0}", cmd); //交货结束 is_play = false; System.Threading.Thread.Sleep(3000); toChangAn(); Log.WriteLine("回到长安找郑镖头!"); } }
/// <summary> /// 飞到城市 /// </summary> /// <returns></returns> public bool GoToCity() { List <bean.Goods> goods = mhxy.CallFunc.itBag(hwnd); for (int i = 0; i < goods.Count; i++) { if (goods[i].type == 673 && flag == false) { string cmd = String.Format("32 09 {0} 00 00 00 00 00", StringUtil.FormatIntToHexStyle(goods[i].id, true).Trim()); int goodsID = goods[i].id; registerFlight(goodsID); //发送飞行棋指令 LoadDll.sendMsg((IntPtr)hwnd, cmd); flag = true; } //System.Threading.Thread.Sleep(3000); } return(false); }
//气血检测线程 public override void AddHPMP(IntPtr hwnd) { if (Global.mh_cfg[hwnd].hp_mp_auto == 0) { return; } bean.AttrsPanel attr = mhxy.CallFunc.ReadAttrsPanel(hwnd.ToInt32()); if (attr.peopleMP < Global.mh_cfg[hwnd].mp) { Log.WriteLine("人物加满蓝"); //蓝加满 LoadDll.sendMsg(hwnd, "35 06 00 00 00 00 02 00"); } if (attr.peopleHP < Global.mh_cfg[hwnd].hp) { //血加满 Log.WriteLine("人物加满气血"); LoadDll.sendMsg(hwnd, "35 06 00 00 00 00 01 00"); } }
/// <summary> /// 接货 /// </summary> public void recvDelivery() { //注册,一级对话回复被打开 //FA 47 01 3E 00 00 00 05 ex.RegMsgCallBack(0xFA, new MsgCallBack(false, delegate(int msgType, byte[] data) { CallNPCOpen = true; System.Threading.Thread.Sleep(1000); regBiao(); bean.Axis ax = mhxy.CallFunc.ReadDialogOption(hwnd, goodsLv); mhxy.CallFunc.taskClick(hwnd, ax.x, ax.y); }, true, new Dictionary <int, int>() { { 3, 0x3E }, { 4, 0x00 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x05 } })); //打开郑镖头对话框 while (!CallNPCOpen) { mxCheck.WaitOne(); string cmd = mhxy.CallNPC.GetNpcDialog(536871314, 0, 0); LoadDll.sendMsg((IntPtr)hwnd, cmd); mxCheck.ReleaseMutex(); Log.WriteLine("NPC郑镖头放锁"); System.Threading.Thread.Sleep(4000); } //判断身上有没有货物,如果没有继续回调 System.Threading.Thread.Sleep(20000); if (GetBiaoYinID() == 0) { recvDelivery(); } }
//延迟发送 void delaySend() { if (prevFunc != null) { this.prevFunc(); } if (random) { Random r = new Random(); int m = r.Next(s, e); System.Threading.Thread.Sleep(m * 1000); } else { System.Threading.Thread.Sleep(s * 1000); } LoadDll.sendMsg((IntPtr)hwnd, cmd); if (lastFunc != null) { this.lastFunc(); } Log.WriteLine("延迟发送报文:{0}", cmd); }
public override void AddHPMP(IntPtr hwnd) { if (Global.mh_cfg[hwnd].bb_hp_mp_auto == 0) { return; } bean.AttrsPanel attr = mhxy.CallFunc.ReadAttrsPanel(hwnd.ToInt32()); if (attr.bbHP == 0 || id <= 0) { return; } if (attr.bbHP < Global.mh_cfg[hwnd].bb_hp) { byte[] b = BitConverter.GetBytes(id); LoadDll.sendMsg(hwnd, String.Format("35 06 {0} 01 00", StringUtil.FormatBytesToHex(b).Trim())); Log.WriteLine("宝宝满血"); } if (attr.bbMP < Global.mh_cfg[hwnd].bb_mp) { byte[] b = BitConverter.GetBytes(id); LoadDll.sendMsg(hwnd, String.Format("35 06 {0} 02 00", StringUtil.FormatBytesToHex(b).Trim())); Log.WriteLine("宝宝满蓝"); } }
/// <summary> /// 攻击指令 /// 存在同步和等待的情况 /// </summary> public void attackEnemy() { mxMonster.WaitOne(); if (monster.Count > 0) { System.Threading.Thread.Sleep(1000); Monster mon = GetRandomMonsterPosIndx(); int peopleCode = 0x00;//普通攻击 //检查有没有宝宝 int bb_pos = checkBB(); //判断是否自动释放技能 if (Global.mh_cfg.ContainsKey(hwnd) == true && Global.mh_cfg[hwnd].skill_auto == 1) { peopleCode = Global.mh_cfg[hwnd].skill; string cmd = ""; //没有宝宝发动攻击,或者魔法不够直接攻击 if (bb_pos == -1 || ex.mySelf.mp < 26) { //检测自己使用魔法时气血和所剩魔法是否满足,不够使用普通攻击 if (ex.mySelf.mp < Global.skill_map[peopleCode].mp || ex.mySelf.hp < Global.skill_map[peopleCode].hp || peopleCode <= 0) { cmd = mhxy.GameCmd.CmdBattleAttack(0, mon.postion, 0, 0x61, 0); } else { cmd = mhxy.GameCmd.CmdBattleAttack(0, mon.postion, 0, 0x62, peopleCode); //技能附着随机码 Console.WriteLine("技能附着随机码【{0}】:【{1}】", skill_first, skill_random); if (skill_first && skill_random) { Random rm = new Random(); cmd = cmd.Substring(0, cmd.Length - 3); //获取怪物的个数 if (monster.Count > 1) { //两个怪物 随机码两个,加长 cmd = cmd.Replace("04", "06"); cmd = String.Format(cmd + " {0} {1} 00", StringUtil.FormatIntToHexStyle(rm.Next(60, 235), false), StringUtil.FormatIntToHexStyle(rm.Next(60, 235), false)); } else { //1个怪物 随机码1个,加长 cmd = cmd.Replace("04", "05"); cmd = String.Format(cmd + " {0} 00", StringUtil.FormatIntToHexStyle(rm.Next(60, 235), false)); } skill_first = false; } } } else { //抓宝宝 cmd = mhxy.GameCmd.CmdBattleAttack(0, bb_pos, 0, 0x6F, 0); } Console.WriteLine("【{0}】:【{1}】", masterName, cmd); LoadDll.sendMsg(hwnd, cmd); if (baby) { System.Threading.Thread.Sleep(1000); cmd = mhxy.GameCmd.CmdBattleAttack(babyPos, mon.postion, 1, 0, 0); int bb_code = Global.mh_cfg[hwnd].bb_skill; //判断宝宝魔法是否够发出技能 if (ex.myBaby.mp >= Global.skill_map[bb_code].mp && ex.mySelf.hp >= Global.skill_map[bb_code].hp && bb_code > 0) { cmd = mhxy.GameCmd.CmdBattleAttack(babyPos, mon.postion, 1, 0x6B, bb_code); } Console.WriteLine("【宝宝技能】:【{0}】", cmd); LoadDll.sendMsg(hwnd, cmd); } } } mxMonster.ReleaseMutex(); }
private void ExcuteTask() { //设置初始化信息移动 am = new AutoMove(hwnd, 0, list[idx].mapExit.wait_x, list[idx].mapExit.wait_y, list[idx].mapExit.myMap.map_no, ex); while (runStatus) { if (init) { am.Run(); init = false; } //检查是否到达该地图出口 if (list[idx].exit_id > 0) { int[] xy = Global.addr.getPeopleXY(hwnd); //判断是否达到出口的地图 if (list[idx].mapExit.toMap.map_no == Global.addr.GetMapID(hwnd)) { //判断是否还有任务存在,如果没有就结束当前线程 if (list.Count - 1 == idx) { runStatus = false; am.Stop(); } else { //还有剩下任务没有处理,继续处理 //移动下标位置 if (idx + 1 < list.Count - 1) { idx += 1; } else { idx = list.Count - 1; } //启用下一次寻路任务 int x = list[idx].mapExit.wait_x; int y = list[idx].mapExit.wait_y; am.ReSetMove(Global.addr.GetMapID(hwnd), x, y, 0); } } else { //判断是否到达地址过出口 if (xy[0] == list[idx].mapExit.wait_x && xy[1] == list[idx].mapExit.wait_y) { if (list[idx].mapExit.npc_id == 0) { //调用过出口 mhxy.CallFunc.MhxyToExit(hwnd, list[idx].mapExit.x, list[idx].mapExit.y); } else { string cmd = mhxy.CallNPC.OpenDialog(list[idx].mapExit.npc_id); //打开NPC的对话框 LoadDll.sendMsg((IntPtr)hwnd, cmd); // NPC过出口 呼出NPC 注册收包选项 ex.RegMsgCallBack(0x81, new MsgCallBack(false, delegate(int msgType, byte[] data) { //回调代码 LoadDll.sendMsg((IntPtr)hwnd, String.Format("82 02 {0} 00", list[idx].mapExit.call_npc_option)); System.Threading.Thread.Sleep(1500); mhxy.CallFunc.CloseDia(hwnd); }, true, null)); } } else { //过口失败重新过去 if (am.status == false) { if (xy[0] != list[idx].mapExit.wait_x || xy[1] != list[idx].mapExit.wait_y) { Log.WriteLine("过出口失败,重新定位出口!"); int x = list[idx].mapExit.wait_x; int y = list[idx].mapExit.wait_y; am.ReSetMove(Global.addr.GetMapID(hwnd), x, y, 0); } } } } } System.Threading.Thread.Sleep(2000); } Log.WriteLine("已到达目的地图"); if (list[idx].is_type == 0) { MoveNPC(list[idx].target_id); } else { if (callback != null) { callback(); } } }