public void Initialize(ref WS_PlayerData.CharacterObject objCharacter) { if (ObjectivesDeliver > 0) { ItemObject tmpItem = new ItemObject(ObjectivesDeliver, objCharacter.GUID); if (!objCharacter.ItemADD(ref tmpItem)) { tmpItem.Delete(); Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_QUESTGIVER_QUEST_FAILED); response.AddInt32(ID); response.AddInt32(4); objCharacter.client.Send(ref response); response.Dispose(); return; } objCharacter.LogLootItem(tmpItem, 1, Recieved: true, Created: false); } byte i = 0; do { checked { if (ObjectivesItem[i] != 0) { ProgressItem[i] = (byte)objCharacter.ItemCOUNT(ObjectivesItem[i]); } i = (byte)unchecked ((uint)(i + 1)); } }while (i <= 3u); if (((uint)ObjectiveFlags & 2u) != 0) { Explored = false; } IsCompleted(); }
public void Check() { if (Looters.Count != Rolls.Count) { return; } byte maxRollType = 0; foreach (KeyValuePair <WS_PlayerData.CharacterObject, int> looter2 in Looters) { if (looter2.Value == 1) { maxRollType = 1; } if (looter2.Value == 2 && maxRollType != 1) { maxRollType = 2; } } if (maxRollType == 0) { LootObject.GroupLootInfo.Remove(LootSlot); Packets.PacketClass response2 = new(Opcodes.SMSG_LOOT_ALL_PASSED); response2.AddUInt64(LootObject.GUID); response2.AddInt32(LootSlot); response2.AddInt32(Item.ItemID); response2.AddInt32(0); response2.AddInt32(0); Broadcast(ref response2); response2.Dispose(); return; } WS_PlayerData.CharacterObject looterCharacter = null; checked { int maxRoll = -1; foreach (KeyValuePair <WS_PlayerData.CharacterObject, int> looter in Looters) { if (looter.Value == maxRollType) { byte rollValue = (byte)WorldServiceLocator._WorldServer.Rnd.Next(0, 100); if (rollValue > maxRoll) { maxRoll = rollValue; looterCharacter = looter.Key; } Packets.PacketClass response = new(Opcodes.SMSG_LOOT_ROLL); response.AddUInt64(LootObject.GUID); response.AddInt32(LootSlot); response.AddUInt64(looter.Key.GUID); response.AddInt32(Item.ItemID); response.AddInt32(0); response.AddInt32(0); response.AddInt8(rollValue); response.AddInt8((byte)looter.Value); Broadcast(ref response); response.Dispose(); } } ItemObject itemObject = new(Item.ItemID, looterCharacter.GUID) { StackCount = Item.ItemCount }; ItemObject tmpItem = itemObject; Packets.PacketClass wonItem = new(Opcodes.SMSG_LOOT_ROLL_WON); wonItem.AddUInt64(LootObject.GUID); wonItem.AddInt32(LootSlot); wonItem.AddInt32(Item.ItemID); wonItem.AddInt32(0); wonItem.AddInt32(0); wonItem.AddUInt64(looterCharacter.GUID); wonItem.AddInt8((byte)maxRoll); wonItem.AddInt8(maxRollType); Broadcast(ref wonItem); if (looterCharacter.ItemADD(ref tmpItem)) { looterCharacter.LogLootItem(tmpItem, Item.ItemCount, Recieved: false, Created: false); LootObject.GroupLootInfo.Remove(LootSlot); LootObject.Items[LootSlot] = null; } else { tmpItem.Delete(); LootObject.GroupLootInfo.Remove(LootSlot); } } }
public void GetLoot(ref WS_Network.ClientClass client, byte Slot) { try { if (Items[Slot] == null) { Packets.PacketClass response4 = new(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE); response4.AddInt8(49); response4.AddUInt64(0uL); response4.AddUInt64(0uL); response4.AddInt8(0); client.Send(ref response4); response4.Dispose(); return; } if (GroupLootInfo.ContainsKey(Slot)) { Packets.PacketClass response3 = new(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE); response3.AddInt8(58); response3.AddUInt64(0uL); response3.AddUInt64(0uL); response3.AddInt8(0); client.Send(ref response3); response3.Dispose(); return; } ItemObject itemObject = new(Items[Slot].ItemID, client.Character.GUID) { StackCount = Items[Slot].ItemCount }; ItemObject tmpItem = itemObject; if (client.Character.ItemADD(ref tmpItem)) { if (tmpItem.ItemInfo.Bonding == 1) { ItemObject itemObject2 = tmpItem; WS_Network.ClientClass client2 = null; itemObject2.SoulbindItem(client2); } Packets.PacketClass response2 = new(Opcodes.SMSG_LOOT_REMOVED); response2.AddInt8(Slot); client.Send(ref response2); response2.Dispose(); client.Character.LogLootItem(tmpItem, Items[Slot].ItemCount, Recieved: false, Created: false); Items[Slot].Dispose(); Items[Slot] = null; if (LootType == LootType.LOOTTYPE_FISHING && IsEmpty) { SendRelease(ref client); Dispose(); } } else { tmpItem.Delete(); Packets.PacketClass response = new(Opcodes.SMSG_INVENTORY_CHANGE_FAILURE); response.AddInt8(50); response.AddUInt64(0uL); response.AddUInt64(0uL); response.AddInt8(0); client.Send(ref response); response.Dispose(); } } catch (Exception e) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.WARNING, "Error getting loot.{0}", Environment.NewLine + e); } }
public void On_CMSG_PETITION_BUY(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { checked { if (packet.Data.Length - 1 < 26) { return; } packet.GetInt16(); ulong GUID = packet.GetUInt64(); packet.GetInt64(); packet.GetInt32(); string Name = packet.GetString(); if (packet.Data.Length - 1 < 26 + Name.Length + 40 + 2 + 1 + 4 + 4) { return; } packet.GetInt64(); packet.GetInt64(); packet.GetInt64(); packet.GetInt64(); packet.GetInt64(); packet.GetInt16(); packet.GetInt8(); int Index = packet.GetInt32(); packet.GetInt32(); if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID) || (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].CreatureInfo.cNpcFlags & 0x200) == 0) { return; } WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_PETITION_BUY [GuildName={2}]", client.IP, client.Port, Name); if ((ulong)client.Character.GuildID != 0) { return; } int CharterID = WorldServiceLocator._Global_Constants.PETITION_GUILD; int CharterPrice = WorldServiceLocator._Global_Constants.PETITION_GUILD_PRICE; DataTable q = new DataTable(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT guild_id FROM guilds WHERE guild_name = '{Name}'", ref q); if (q.Rows.Count > 0) { SendGuildResult(ref client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_NAME_EXISTS, Name); } q.Clear(); if (!WorldServiceLocator._Functions.ValidateGuildName(Name)) { SendGuildResult(ref client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_NAME_INVALID, Name); } if (!WorldServiceLocator._WorldServer.ITEMDatabase.ContainsKey(CharterID)) { Packets.PacketClass response2 = new Packets.PacketClass(Opcodes.SMSG_BUY_FAILED); response2.AddUInt64(GUID); response2.AddInt32(CharterID); response2.AddInt8(0); client.Send(ref response2); response2.Dispose(); return; } if (client.Character.Copper < CharterPrice) { Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_BUY_FAILED); response.AddUInt64(GUID); response.AddInt32(CharterID); response.AddInt8(2); client.Send(ref response); response.Dispose(); return; } ref uint copper = ref client.Character.Copper; copper = (uint)(copper - CharterPrice); client.Character.SetUpdateFlag(1176, client.Character.Copper); client.Character.SendCharacterUpdate(toNear: false); ItemObject tmpItem = new ItemObject(CharterID, client.Character.GUID) { StackCount = 1 }; tmpItem.AddEnchantment((int)(tmpItem.GUID - WorldServiceLocator._Global_Constants.GUID_ITEM), 0); if (client.Character.ItemADD(ref tmpItem)) { WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("INSERT INTO petitions (petition_id, petition_itemGuid, petition_owner, petition_name, petition_type, petition_signedMembers) VALUES ({0}, {0}, {1}, '{2}', {3}, 0);", tmpItem.GUID - WorldServiceLocator._Global_Constants.GUID_ITEM, client.Character.GUID - WorldServiceLocator._Global_Constants.GUID_PLAYER, Name, 9)); } else { tmpItem.Delete(); } }