public void TestRolling() { Setup.EnsureBasicSetup(); ItemMgr.InitMisc(); // create group var group = GroupTest.CreateGroup(3); group.LootMethod = LootMethod.NeedBeforeGreed; var leaderMember = group.Leader; var leader = (TestCharacter)leaderMember.Character; // create corpse var npc = Setup.NPCPool.CreateDummy(); npc.EnsureInWorld(); npc.FirstAttacker = leader; npc.Health = 0; // create loot var loot = npc.Loot = new NPCLoot(npc, 0, new[] { new ItemStackTemplate(new ItemTemplate { ItemId = ItemId.Shortsword, Id = (uint)ItemId.Shortsword, DefaultName = "Test Item1", MaxAmount = 3, Quality = ItemQuality.Artifact }) }); var lootItem = loot.Items[0]; foreach (var member in group) { // let them all be next to the corpse ((TestCharacter)member.Character).EnsureXDistance(npc, 0.5f, true); } leader.Map.AddMessageAndWait(() => { var looters = LootMgr.FindLooters(npc, leader); Assert.AreEqual(group.CharacterCount, looters.Count); // initialize the Loot loot.Initialize(leader, looters, npc.MapId); }); Assert.IsNotNull(lootItem.RollProgress); // everyone should now get the n/g box var i = 0; foreach (var member in group) { var chr = ((TestCharacter)member.Character); var rollStart = chr.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_LOOT_START_ROLL); Assert.IsNotNull(rollStart); Assert.AreEqual(npc.EntityId, rollStart["Looted"].Value); Assert.AreEqual(lootItem.Index, rollStart["ItemIndex"].Value); Assert.AreEqual(lootItem.Template.ItemId, rollStart["ItemTemplate"].Value); i++; } // let everyone roll var packet = new RealmPacketOut(RealmServerOpCode.CMSG_LOOT_ROLL); packet.Write(npc.EntityId); packet.Write(lootItem.Index); packet.Write((byte)LootRollType.Need); // need always before greed leader.FakeClient.ReceiveCMSG(packet, true); Assert.AreEqual(lootItem.RollProgress.HighestParticipant, leader); packet = new RealmPacketOut(RealmServerOpCode.CMSG_LOOT_ROLL); packet.Write(npc.EntityId); packet.Write(lootItem.Index); packet.Write((byte)LootRollType.Greed); ((TestCharacter)leaderMember.Next.Character).FakeClient.ReceiveCMSG(packet, true); Assert.AreEqual(lootItem.RollProgress.HighestParticipant, leader); Assert.AreEqual(1, lootItem.RollProgress.RemainingParticipants.Count); // one left packet = new RealmPacketOut(RealmServerOpCode.CMSG_LOOT_ROLL); packet.Write(npc.EntityId); packet.Write(lootItem.Index); packet.Write((byte)LootRollType.Greed); ((TestCharacter)leaderMember.Next.Next.Character).FakeClient.ReceiveCMSG(packet, true); // everyone rolled, item should have been given to the winner Assert.IsNull(lootItem.RollProgress); Assert.IsTrue(lootItem.Taken); Assert.IsTrue(leader.Inventory.Contains(lootItem.Template.Id, (int)lootItem.Amount, true)); // since that was the only item: Loot should be unset and the corpse should now decay Assert.IsNull(npc.Loot); Assert.IsTrue(npc.IsDecaying); // TODO: Take money // TODO: Be not able to take items that are being rolled for }