public static void SendPartyMemberCordChange(ZoneClient client) { if (Program.Entity.Parties.Where(c => c.CharNo == client.Character.ID).Count() == 1) { Party PartyNo = Program.Entity.Parties.First(c => c.CharNo == client.Character.ID); foreach (Party party in Program.Entity.Parties.Where(c => c.PartyNo == PartyNo.PartyNo)) { using (var ppacket = new Packet(SH14Type.PartyLoginCord)) { Character Pcharacter = Program.Entity.Characters.First(c => c.ID == party.CharNo); ZoneClient otherLiveInfo = ClientManager.Instance.GetClientByName(Pcharacter.Name); if (otherLiveInfo != null) { if (otherLiveInfo.Character.MapID == client.Character.MapID) { ppacket.WriteByte(1); //unk ppacket.WriteString(client.Character.Name, 16); ppacket.WriteInt(client.Character.Position.X); ppacket.WriteInt(client.Character.Position.Y); otherLiveInfo.SendPacket(ppacket); } } } } } }
public static Packet Animation(ZoneCharacter character, byte id) { Packet packet = new Packet(SH8Type.Emote); packet.WriteUShort(character.MapObjectID); packet.WriteByte(id); return packet; }
public static void SendClientTime(WorldClient client, DateTime time) { using (var packet = new Packet(SH2Type.UpdateClientTime)) { //pPacket.WriteUInt((59 << 25) | (23 << 19) | (31 << 13) | (12 << 8) | (254)); // * Minutes | Hours | Days | Months | Years packet.WriteInt(3); packet.WriteInt(time.Minute);//minutes packet.WriteInt(time.Hour);//hourses packet.WriteInt(time.Day); packet.WriteInt(time.Month-1); packet.WriteInt((time.Year - 1900)); packet.WriteInt((int)time.DayOfWeek);//wekday? packet.WriteInt(105); packet.WriteInt(2); packet.WriteByte(1); //GMT 0-130 positive 130 -254 negative // packet.WriteLong(2012); // packet.WriteInt(4);//unk //packet.WriteInt(1);//unk //packet.WriteInt(3);//unk //packet.WriteInt(46); // packet.Fill(3, 0);//unk // packet.WriteByte(2); client.SendPacket(packet); } }
public static void SendPing(WorldClient client) { using (var packet = new Packet(SH2Type.Ping)) { client.SendPacket(packet); } }
public static void CharacterSelectHandler(WorldClient client, Packet packet) { byte slot; if (!packet.TryReadByte(out slot) || slot > 10 || !client.Characters.ContainsKey(slot)) { Log.WriteLine(LogLevel.Warn, "{0} selected an invalid character.", client.Username); return; } WorldCharacter character; if (client.Characters.TryGetValue(slot, out character)) { //generate transfer ZoneConnection zone = Program.GetZoneByMap(character.Character.PositionInfo.Map); if (zone != null) { client.Characters.Clear(); //we clear the other ones from memory client.Character = character; //only keep the one selecte //Database.Storage.Characters.AddChars(character.Character); zone.SendTransferClientFromZone(client.AccountID, client.Username, client.Character.Character.Name,client.Character.ID, client.RandomID, client.Admin, client.Host); ClientManager.Instance.AddClientByName(client); //so we can look them up fast using charname later. SendZoneServerIP(client, zone); } else { Log.WriteLine(LogLevel.Warn, "Character tried to join unloaded map: {0}", character.Character.PositionInfo.Map); SendConnectError(client, ConnectErrors.MapUnderMaintenance); } } }
public static Packet ShowDrops(List<Drop> drops) { Packet packet = new Packet(SH7Type.ShowDrops); packet.WriteByte((byte)drops.Count); drops.ForEach(d => d.Write(packet)); return packet; }
public static void GetAcademyGoldRewardList(WorldClient client, Packet packet) { using (var pack = new Packet(SH38Type.SendAcademyGoldRewardList)) { pack.WriteHexAsBytes("80 18");//responsecode pack.WriteByte(1);//stat count pack.WriteHexAsBytes("0A 0A CA 9A 3B 00 00 00 00");//unk pack.WriteByte(10);//levelbreich pack.WriteLong(1000); pack.WriteByte(15);//level bereich pack.WriteLong(1000); pack.WriteByte(26);//level bereich pack.WriteLong(1000); pack.WriteByte(31);//level bereich pack.WriteLong(1000); pack.WriteByte(36);//levelbereich pack.WriteLong(1000); pack.WriteByte(41);//level bereich pack.WriteLong(9000); pack.WriteByte(46);//level bereich pack.WriteLong(1000); pack.WriteByte(51);//level bereich pack.WriteLong(1000); pack.WriteByte(56);//level bereich pack.WriteLong(1000); client.SendPacket(pack); } }
public static void WriteLook(WorldCharacter wchar, Packet packet) { packet.WriteByte(Convert.ToByte(0x01 | (wchar.Character.Job << 2) | (Convert.ToByte(wchar.Character.Male)) << 7)); packet.WriteByte(wchar.Character.Hair); packet.WriteByte(wchar.Character.HairColor); packet.WriteByte(wchar.Character.Face); }
public static void TradeLock(ZoneClient pClient, Packet pPacket) { if (pClient.Character.Trade != null) { pClient.Character.Trade.TradeLock(pClient.Character); } }
public static void TradeReqest(ZoneClient pClient, Packet pPacket) { ushort MapObjectID; if (!pPacket.TryReadUShort(out MapObjectID)) return; TradeManager.Instance.AddTradeRequest(pClient, MapObjectID); }
public static void TradeAgree(ZoneClient pClient, Packet pPacket) { if (pClient.Character.Trade == null) return; pClient.Character.Trade.AcceptTrade(pClient.Character); }
public static void ChangeDropMode(WorldClient client, Packet packet) { byte dropState; if (packet.TryReadByte(out dropState)) { client.Character.Group.ChangeDropType(client.Character, dropState); } }
public void WritePremiumInfo(Packet packet) { packet.WriteInt(this.UniqueID); packet.WriteInt(this.ShopID); packet.WriteInt(0);//unk packet.WriteInt(0);//unk }
public static void sendPartyMessage(WorldClient client, Packet packet) { string mess; byte len; if (!packet.TryReadByte(out len) || !packet.TryReadString(out mess, len)) { Log.WriteLine(LogLevel.Error, "PartyChat :: Can not parse party chat from {0}", client.Character.Character.Name); return; } if(Program.Entity.Parties.Where(c => c.CharNo == client.Character.Character.ID).Count() == 1) { Party getPartyInfo = Program.Entity.Parties.First(c => c.CharNo == client.Character.Character.ID); foreach (Party party in Program.Entity.Parties.Where(c => c.PartyNo == getPartyInfo.PartyNo)) { Character character = Program.Entity.Characters.First(c => c.ID == party.CharNo); WorldClient wclient = ClientManager.Instance.GetClientByCharname(character.Name); using (var ppacket = new Packet(SH8Type.PartyChat)) { ppacket.WriteString(client.Character.Character.Name, 16); ppacket.WriteByte(len); ppacket.WriteString(mess, len); wclient.SendPacket(ppacket); } } } else { using (var ppacket = new Packet(SH8Type.PartyChatErr)) { ppacket.WriteUShort(1985); client.SendPacket(ppacket); } } }
public static void ClientReadyHandler(ZoneClient client, Packet packet) { Handler4.SendUsablePoints(client); if (!client.Character.IsDead) { // Just logged on. client.Character.Map.FinalizeAdd(client.Character); //Handler27.SendGameMessage(client.Character, "GAMEPLAY NOT FINAL :: WELCOME TO OSMO, " + client.Character.Name.ToUpper(), "Universal_2"); Handler9.SendUpdateHP(client.Character); Handler9.SendUpdateSP(client.Character); if (client.Character.Job == Job.Crusader) { Handler9.SendUpdateLP(client.Character); } Handler14.SendPartyInformation(client); } else { // Reviving, not readding for this one! MapInfo mi; if (DataProvider.Instance.MapsByID.TryGetValue(client.Character.MapID, out mi)) { client.Character.State = PlayerState.Normal; client.Character.Map.SendCharacterLeftMap(client.Character, false); client.Character.Position.X = mi.RegenX; client.Character.Position.Y = mi.RegenY; client.Character.Map.SendCharacterEnteredMap(client.Character); } client.Character.SetHP(client.Character.MaxHP / 4); } }
public static void WriteBasicCharInfo(WorldCharacter wchar, Packet packet) { packet.WriteInt(wchar.Character.ID); packet.WriteString(wchar.Character.Name, 16); packet.WriteUShort(wchar.Character.CharLevel); packet.WriteByte(wchar.Character.Slot); MapInfo mapinfo; if (!DataProvider.Instance.Maps.TryGetValue(wchar.Character.Map, out mapinfo)) { Log.WriteLine(LogLevel.Warn, "{0} has an invalid MapID ({1})", wchar.Character.Name, wchar.Character.Map); wchar.Character.Map = 0;//we reset packet.WriteString("Rou", 12); } else { packet.WriteString(mapinfo.ShortName, 12); } packet.WriteByte(0); // UNK packet.WriteInt(0x00000000); // Random seed WriteLook(wchar, packet); WriteEquipment(wchar, packet); WriteRefinement(wchar, packet); packet.Fill(4, 0xff); // UNK packet.WriteString("Rou", 12); //TODO: load from mapinfo.shn packet.WriteInt(0); // X, doesn't matter packet.WriteInt(0); // Y, neither packet.WriteInt(0x63dd45ca); packet.WriteByte(0); packet.WriteInt(100); // Test later! packet.WriteByte(0); wchar.Detach(); }
public static void LeaveParty(WorldClient client, Packet packet) { Party party; party = Program.Entity.Parties.First(c => c.CharNo == client.Character.Character.ID); foreach (Party PartyListFromDB in Program.Entity.Parties.Where(c => c.PartyNo == party.PartyNo).OrderBy(c => c.MasterNo)) { Character character; character = Program.Entity.Characters.First(c => c.ID == PartyListFromDB.CharNo); WorldClient Partyclient = ClientManager.Instance.GetClientByCharname(character.Name); using (var ppacket = new Packet(SH14Type.LeaveParty)) { ppacket.WriteString(client.Character.Character.Name, 16); ppacket.WriteUShort(1281); Partyclient.SendPacket(ppacket); } } if(Program.Entity.Parties.Where(c => c.PartyNo == party.PartyNo).Count() == 2){ Party OtherClientParty; OtherClientParty = Program.Entity.Parties.First(c => c.CharNo != client.Character.Character.ID); Program.Entity.DeleteObject(OtherClientParty); } Program.Entity.DeleteObject(party); Program.Entity.SaveChanges(); }
public static void WriteRefinement(WorldCharacter wchar, Packet pPacket) { //TODO: pPacket.WriteByte(Convert.ToByte(this.Inventory.GetEquippedUpgradesByType(ItemType.Weapon) << 4 | this.Inventory.GetEquippedUpgradesByType(ItemType.Shield))); pPacket.WriteByte(0xff); //this must be the above, but currently not cached pPacket.WriteByte(0xff); // UNK pPacket.WriteByte(0xff); // UNK }
public static void HandleSetStatPoint(ZoneClient client, Packet packet) { byte stat; if (!packet.TryReadByte(out stat)) { Log.WriteLine(LogLevel.Warn, "Couldn't read HandleSetStatPoint packet. {0}", client); return; } if (client.Character.Character.UsablePoints == 0) { Log.WriteLine(LogLevel.Warn, "User tried to set stat point while not having any left. {0}", client); } else { // LETS DO ET switch (stat) { case 0: client.Character.Str++; break; case 1: client.Character.Dex++; break; case 2: client.Character.End++; break; case 3: client.Character.Int++; break; case 4: client.Character.Spr++; break; default: { Log.WriteLine(LogLevel.Warn, "User tried to set stat point on unknown stat {0} {1}", stat, client); return; } } client.Character.Character.UsablePoints--; //Program.Entity.SaveChanges(); SendSetUsablePoint(client, stat); } }
public static void MasterRemove(WorldClient client, Packet packet) { string removename; if(!packet.TryReadString(out removename,16)) return; MasterManager.Instance.RemoveMasterMember(client.Character, removename); }
public static void ClientReadyHandler(ZoneClient client, Packet packet) { if (client.Admin > 0) { client.Character.DropMessage("AdminLevel = {0}; ClientLoad = {1};", client.Admin, ClientManager.Instance.ZoneLoad); } Handler4.SendUsablePoints(client); if (!client.Character.IsDead) { // Just logged on. client.Character.Map.FinalizeAdd(client.Character); } else { // Reviving, not readding for this one! MapInfo mi; if (DataProvider.Instance.MapsByID.TryGetValue(client.Character.MapID, out mi)) { client.Character.State = PlayerState.Normal; client.Character.Map.SendCharacterLeftMap(client.Character, false); client.Character.Position.X = mi.RegenX; client.Character.Position.Y = mi.RegenY; client.Character.Map.SendCharacterEnteredMap(client.Character); } client.Character.SetHP(client.Character.MaxHP / 4); } }
public override void WriteInfo(Packet pPacket, bool WriteStats = true) { byte length; byte statCount; if (ItemInfo.Slot == ItemSlot.None) { length = GetInfoLength(ItemInfo.Class); statCount = 0; } else { length = GetEquipLength(this); statCount = GetInfoStatCount(this); } byte lenght = 9;//later pPacket.WriteByte(lenght); pPacket.WriteByte((byte)this.Slot);//itemslot pPacket.WriteByte(0x08);//unk if (WriteStats) { if (ItemInfo.Slot == ItemSlot.None) this.WriteStats(pPacket); else WriteEquipStats(pPacket); } }
public static Packet CreateWorldMessage(WorldMessageTypes pType, string pMessage) { var packet = new Packet(SH25Type.WorldMessage); packet.WriteByte((byte)pType); packet.WriteStringLen(pMessage, true); return packet; }
public static void EquipHandler(ZoneClient client, Packet packet) { sbyte slot; if (!packet.TryReadSByte(out slot)) { Log.WriteLine(LogLevel.Warn, "Error reading equipping slot."); return; } Item item; if (client.Character.InventoryItems.TryGetValue(slot, out item)) { if (item is Equip) { if (((Equip)item).Info.Level > client.Character.Level) { FailedEquip(client.Character, 645); // 85 02 } else { client.Character.EquipItem((Equip)item); } } else { FailedEquip(client.Character); Log.WriteLine(LogLevel.Warn, "{0} equippped an item. What a moron.", client.Character.Name); } } }
public static void SelectObjectHandler(ZoneClient client, Packet packet) { ushort id; if (!packet.TryReadUShort(out id)) { Log.WriteLine(LogLevel.Warn, "Could not read entity select request."); return; } MapObject mo; // Try to see if there is a map object with this ID if (!client.Character.Map.Objects.TryGetValue(id, out mo)) { client.Character.CharacterInTarget = mo; return; // Nothing found. Just return lawl } mo.SelectedBy.Add(client.Character); if (mo is ZoneCharacter || mo is Mob) { client.Character.SelectedObject = mo; SendStatsUpdate(mo, client, false); } }
public static void SendPing(ZoneClient character) { using (var packet = new Packet(SH2Type.Ping)) { character.SendPacket(packet); } }
public static void sendUnk14(WorldClient client) { using (var packet = new Packet(SH2Type.Unk14)) { packet.WriteHexAsBytes("07 2C 2A"); client.SendPacket(packet); } }
public static void FailedUnequip(ZoneCharacter character) { using (var packet = new Packet(SH12Type.FailedUnequip)) { packet.WriteUShort(706); character.Client.SendPacket(packet); } }
public static void FailedEquip(ZoneCharacter character, ushort val = 0) { using (var packet = new Packet(SH12Type.FailedEquip)) { packet.WriteUShort(val); character.Client.SendPacket(packet); } }
public static void SendChatBlock(ZoneCharacter character, int seconds) { using (var packet = new Packet(SH2Type.Chatblock)) { packet.WriteInt(seconds); character.Client.SendPacket(packet); } }