public byte[] npcSpawn(Character character) { OutPacket initNPCData = new OutPacket(615); initNPCData.WriteInt(615); initNPCData.WriteShort(0x04); initNPCData.WriteShort(0x04); initNPCData.WriteByte(0x01); initNPCData.WriteInt(character.getuID()); initNPCData.WriteInt(character.getArea().getaID()); initNPCData.WriteFloat(character.getPosition()[0]); initNPCData.WriteFloat(character.getPosition()[1]); initNPCData.WriteByte(3); initNPCData.WriteInt(this.uID); initNPCData.WriteInt(); initNPCData.WritePaddedString(this.getName(), 16); initNPCData.Skip(18); initNPCData.WriteInt(this.getModule()); initNPCData.Skip(10); initNPCData.WriteInt(this.getmID()); initNPCData.Skip(16); initNPCData.WriteFloat(this.npcPosition[0]); initNPCData.WriteFloat(this.npcPosition[1]); initNPCData.Skip(502); initNPCData.WriteByte(0x22); initNPCData.WriteByte(0x08); return(initNPCData.ToArray()); }
public static void spawnMonster(Client c, Monster Monster, int CharacterID, int Damage, short HitX, short HitY) { using (OutPacket plew = new OutPacket(ServerOpcode.MON_SPAWN)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(Monster.State); plew.WriteInt(Monster.OriginalID); plew.WriteShort(0); plew.WriteShort(0); plew.WriteInt(Monster.Direction); plew.WriteFloat(Monster.Speed); plew.WriteShort(Monster.PositionX); plew.WriteShort(Monster.PositionY); plew.WriteShort(0); plew.WriteShort(0); plew.WriteByte(0); plew.WriteHexString("00 00 00"); plew.WriteInt(0); plew.WriteInt(CharacterID); plew.WriteShort(Damage); plew.WriteShort(Monster.Effect); // 怪物受到的效果(0: 無、1: 無法移動、2: 中毒、3: 黑暗、4: 未知、5: 冰凍) plew.WriteInt(0); plew.WriteInt(Monster.HP); plew.WriteShort(HitX); plew.WriteShort(HitY); c.Send(plew); } }
public byte[] npcSpawnChained(Character chr) { OutPacket initNPCData = new OutPacket(589); initNPCData.WriteByte(3); initNPCData.WriteInt(this.uID); initNPCData.WriteInt(); initNPCData.WritePaddedString(this.getName(), 16); initNPCData.Skip(18); initNPCData.WriteInt(this.getModule()); initNPCData.Skip(10); initNPCData.WriteInt(this.getmID()); initNPCData.Skip(16); initNPCData.WriteFloat(this.npcPosition[0]); initNPCData.WriteFloat(this.npcPosition[1]); return(initNPCData.ToArray()); }
public byte[] getInitialPacket() { OutPacket p = new OutPacket(608); p.WriteInt(608); p.WriteShort(0x05); p.WriteShort(0x03); p.WriteInt(0x02); p.WriteInt(uID); p.WriteZero(48); p.WriteInt(this.mController.getData().getmID()); p.WriteInt(); p.WriteInt(curHP); p.WriteZero(8); p.WriteFloat(positionX); p.WriteFloat(positionY); //Console.WriteLine("mobid {0} mobuid {1} xcord {2} ycord {3} hp {4}", this.mController.getData().getmID(), uID, positionX, positionY, curHP); return(p.ToArray()); }
public static void MoveToVV(MartialClient c, InPacket p) { if (c.getAccount().activeCharacter != null) { Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character while being ingame."); c.Close(); return; } byte selected_character = p.ReadByte(); if (!c.getAccount().characters.ContainsKey(selected_character)) { Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Wrong target '{0}' has been selected by packet", selected_character); c.Close(); return; } Character target = c.getAccount().characters[selected_character]; target.setPosition(new float[] { -1660, 2344 }); target.setMap(1); OutPacket op = new OutPacket(24); op.WriteInt(24); op.WriteShort(3); op.WriteShort(14); op.WriteByte(1); op.WriteByte(selected_character); op.WriteByte(6); op.WriteByte(8); op.WriteInt(1); // map op.WriteFloat(-1660); // X op.WriteFloat(2344); // Y c.WriteRawPacket(op.ToArray()); }
public static void createAllMonster(Client c, Map Map, List <Monster> Monster) { using (OutPacket plew = new OutPacket(ServerOpcode.MON_ALLCREATE)) { int j = 0; for (int i = 0; i < 50; i++) { if (Map.Monster[i] != null) { j++; } } plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(j); // 怪物數量 for (int i = 0; i < 50; i++) { plew.WriteByte(Monster[i] != null ? Monster[i].State : 0); } for (int i = 0; i < 50; i++) { plew.WriteByte(Monster[i] != null ? Monster[i].Level : 0); } for (int i = 0; i < 50; i++) { plew.WriteByte(Monster[i] != null ? Monster[i].AddEffect : 0); } for (int i = 0; i < 50; i++) { plew.WriteByte(Monster[i] != null ? Monster[i].Direction : 0); } for (int i = 0; i < 50; i++) { plew.WriteByte(Monster[i] != null ? Monster[i].MoveType : 0); } for (int i = 0; i < 50; i++) { plew.WriteByte(Monster[i] != null ? Monster[i].AttackType : 0); } for (int i = 0; i < 50; i++) { plew.WriteShort(Monster[i] != null ? Monster[i].OriginalID : -1); } for (int i = 0; i < 50; i++) { plew.WriteShort(Monster[i] != null ? Monster[i].PositionX : 0); } for (int i = 0; i < 50; i++) { plew.WriteShort(Monster[i] != null ? Monster[i].PositionY : 0); } for (int i = 0; i < 50; i++) { plew.WriteInt(0); } for (int i = 0; i < 50; i++) { plew.WriteInt(0); } for (int i = 0; i < 50; i++) { plew.WriteShort(Monster[i] != null ? Monster[i].Attack1 : 0); } for (int i = 0; i < 50; i++) { plew.WriteShort(Monster[i] != null ? Monster[i].Attack2 : 0); } for (int i = 0; i < 50; i++) { plew.WriteShort(Monster[i] != null ? Monster[i].CrashAttack : 0); } for (int i = 0; i < 50; i++) { plew.WriteShort(Monster[i] != null ? Monster[i].Defense : 0); } for (int i = 0; i < 50; i++) { plew.WriteInt(Monster[i] != null ? Monster[i].MonsterID : 0); } for (int i = 0; i < 50; i++) { plew.WriteFloat(Monster[i] != null ? Monster[i].Speed : 0); } for (int i = 0; i < 50; i++) { plew.WriteHexString("CB 46"); } for (int i = 0; i < 50; i++) { plew.WriteInt(Monster[i] != null ? Monster[i].MaxHP : 0); } for (int i = 0; i < 50; i++) { plew.WriteInt(Monster[i] != null ? Monster[i].HP : 0); } c.Send(plew); } }
public static void setPlayerPosition(Character chr, float goX, float goY, short map) { MartialClient c = chr.getAccount().mClient; Logger.WriteLog(Logger.LogTypes.Debug, goX + " | " + goY + " | " + map); Area lastArea = chr.getArea(); Area newArea = WMap.Instance.getGrid(map).getAreaByRound(goX, goY); if (newArea == null) { StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "The position " + goX + "|" + goY + "|" + map + " can't be reached."); Waypoint closestTown = TownCoordsCache.Instance.getClosestWaypointForMap(map, new Waypoint(goX, goY)); if (closestTown == null) { Area vvArea = WMap.Instance.getGrid(1).getAreaByRound(-1660, 2344); if (vvArea == null) { Logger.WriteLog(Logger.LogTypes.Error, "Pure setPlayerPosition error {0}|{1}|{2}", goX, goY, map); StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "We're sorry, but an hard error has occured. Please report it to an admin."); c.Close(); return; } else { goX = -1660; goY = 2344; map = 1; newArea = vvArea; } } else { goX = closestTown.getX(); goY = closestTown.getY(); newArea = WMap.Instance.getGrid(map).getAreaByRound(goX, goY); } } if (lastArea != null) { WMap.Instance.getGrid(chr.getMap()).sendTo3x3AreaLeave(chr, lastArea); lastArea.removeCharacter(chr); } if (newArea != null) { chr.setArea(newArea); } else { chr.getAccount().mClient.Close(); return; } newArea.addCharacter(chr); chr.setMap(map); chr.setPosition(new float[] { goX, goY }); OutPacket op = new OutPacket(5840); op.WriteInt(5824); op.WriteShort(4); // 4 - 5 op.WriteShort(1); // 6 - 7 op.WriteInt(1); // 8 - 11 op.WriteInt(chr.getuID()); // 12 - 15 op.WriteShort(1); // 16 - 19 op.WriteShort(1); // 16 - 19 op.WriteInt(chr.getMap()); // 20 - 23 op.WriteInt(DateTime.Now.Year - 2000); // 24 - 27 op.WriteByte((byte)DateTime.Now.Month); // 28 op.WriteByte(DateTime.Now.Day > 30 ? (byte)0x1e : (byte)DateTime.Now.Day); // 29 op.WriteInt(DateTime.Now.Hour); // 30 - 37 for (int i = 0; i < 120; i++) { if (chr.getCargo().getSeqSaved()[i] != -1 && chr.getCargo().getCargoSaved()[chr.getCargo().getSeqSaved()[i]] != null) { op.WriteInt(); op.WriteByte((byte)(chr.getCargo().getSeqSaved()[i] / 100)); op.WriteByte((byte)(chr.getCargo().getSeqSaved()[i] % 100)); Item item = chr.getCargo().getCargoSaved()[chr.getCargo().getSeqSaved()[i]]; op.WriteInt(item.getItemID()); ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID()); if (itemData.getTimeToExpire() > 0) { } op.WriteShort(item.getQuantity()); } else { op.WriteZero(12); } } // 38 - 1477 op.Position = 1476; for (int i = 0; i < chr.getCommunity().getFriendsList().Capacity; i++) { if (chr.getCommunity().getFriendsList().ElementAtOrDefault(i) != null) { op.WritePaddedString(chr.getCommunity().getFriendsList()[i], 17); } else { op.WriteZero(17); } } // 1476 - 1934 op.WriteRepeatedByte(0x58, 40); op.Position = 1986; for (int i = 0; i < chr.getCommunity().getIgnoresList().Capacity; i++) { if (chr.getCommunity().getIgnoresList().ElementAtOrDefault(i) != null) { op.WritePaddedString(chr.getCommunity().getIgnoresList()[i], 17); } else { op.WriteZero(17); } } // 1987 - 2157 op.WriteInt(363); // questsy op.WriteLong(); op.WriteLong(138769276674441706); op.WriteLong(21692910); op.WriteShort(); op.WriteShort(1); op.Position = 2248; for (byte i = 0; i < 240; i++) { if (chr.getInventory().getSeqSaved()[i] != -1 && chr.getInventory().getInvSaved()[chr.getInventory().getSeqSaved()[i]] != null) { op.WriteShort(); op.WriteByte((byte)(chr.getInventory().getSeqSaved()[i] / 100)); op.WriteByte((byte)(chr.getInventory().getSeqSaved()[i] % 100)); Item item = chr.getInventory().getInvSaved()[chr.getInventory().getSeqSaved()[i]]; op.WriteInt(item.getItemID()); op.WriteInt(item.getQuantity()); } else { op.WriteZero(12); } } // 2252 - 5133 op.WriteLong(chr.getCoin()); op.Position = 5140; for (byte i = 0; i < 21; i++) { if (chr.getSkillBar().getSkillBar().ContainsKey(i)) { int barID = chr.getSkillBar().getSkillBar()[i]; if (barID > 200000000) { op.WriteInt(1); } else if (barID > 511) { op.WriteInt(5); barID -= 512; } else if (barID > 255) { op.WriteInt(6); barID -= 256; } else { SkillData skill = SkillDataCache.Instance.getSkill(chr.getSkills().getLearnedSkills().ElementAtOrDefault(barID)); if (skill == null) { op.WriteInt(0); } else if (skill.getTypeSpecific() == 6) { op.WriteInt(3); } else if (skill.getTypeSpecific() == 7) { op.WriteInt(4); } else { op.WriteInt(2); } } op.WriteInt(barID); } else { op.WriteZero(8); } } // 5140 - 5299 op.Position = 5320; for (int i = 0; i < 60; i++) { if (chr.getSkills().getLearnedSkills().Count > i && chr.getSkills().getLearnedSkills()[i] != 0) { op.WriteInt(chr.getSkills().getLearnedSkills()[i]); op.WriteInt(SkillDataCache.Instance.getSkill(chr.getSkills().getLearnedSkills()[i]).getSkillPoints()); } else { op.WriteLong(); } } // 5320 - 5799 op.WriteFloat(chr.getPosition()[0]); op.WriteFloat(chr.getPosition()[1]); op.WriteInt(0x0c); op.WriteInt(140338688); op.WriteInt(); op.WriteShort(); op.WriteShort(10962); //s3c0nd p4ck3t op.WriteInt(16); op.WriteInt(7929861); op.WriteInt(chr.getuID()); c.WriteRawPacket(op.ToArray()); WMap.Instance.getGrid(chr.getMap()).sendTo3x3AreaSpawn(chr, chr.getArea()); }