public WorldObject GetWorldObject(WorldObject p, ObjectGuid guid) { switch (guid.GetHigh()) { case HighGuid.Player: return(GetPlayer(p, guid)); case HighGuid.Transport: case HighGuid.GameObject: return(GetGameObject(p, guid)); case HighGuid.Vehicle: case HighGuid.Creature: return(GetCreature(p, guid)); case HighGuid.Pet: return(GetPet(p, guid)); case HighGuid.DynamicObject: return(GetDynamicObject(p, guid)); case HighGuid.AreaTrigger: return(GetAreaTrigger(p, guid)); case HighGuid.Corpse: return(GetCorpse(p, guid)); case HighGuid.Conversation: return(GetConversation(p, guid)); default: return(null); } }
public WorldObject GetObjectByTypeMask(WorldObject p, ObjectGuid guid, TypeMask typemask) { switch (guid.GetHigh()) { case HighGuid.Item: if (typemask.HasAnyFlag(TypeMask.Item) && p.IsTypeId(TypeId.Player)) { return(((Player)p).GetItemByGuid(guid)); } break; case HighGuid.Player: if (typemask.HasAnyFlag(TypeMask.Player)) { return(GetPlayer(p, guid)); } break; case HighGuid.Transport: case HighGuid.GameObject: if (typemask.HasAnyFlag(TypeMask.GameObject)) { return(GetGameObject(p, guid)); } break; case HighGuid.Creature: case HighGuid.Vehicle: if (typemask.HasAnyFlag(TypeMask.Unit)) { return(GetCreature(p, guid)); } break; case HighGuid.Pet: if (typemask.HasAnyFlag(TypeMask.Unit)) { return(GetPet(p, guid)); } break; case HighGuid.DynamicObject: if (typemask.HasAnyFlag(TypeMask.DynamicObject)) { return(GetDynamicObject(p, guid)); } break; case HighGuid.AreaTrigger: if (typemask.HasAnyFlag(TypeMask.AreaTrigger)) { return(GetAreaTrigger(p, guid)); } break; case HighGuid.Conversation: if (typemask.HasAnyFlag(TypeMask.Conversation)) { return(GetConversation(p, guid)); } break; case HighGuid.Corpse: break; } return(null); }
void HandleLootMoney(LootMoney lootMoney) { Player player = GetPlayer(); foreach (var lootView in player.GetAELootView()) { ObjectGuid guid = lootView.Value; Loot loot = null; bool shareMoney = true; switch (guid.GetHigh()) { case HighGuid.GameObject: { GameObject go = player.GetMap().GetGameObject(guid); // do not check distance for GO if player is the owner of it (ex. fishing bobber) if (go && ((go.GetOwnerGUID() == player.GetGUID() || go.IsWithinDistInMap(player, SharedConst.InteractionDistance)))) { loot = go.loot; } break; } case HighGuid.Corpse: // remove insignia ONLY in BG { Corpse bones = ObjectAccessor.GetCorpse(player, guid); if (bones && bones.IsWithinDistInMap(player, SharedConst.InteractionDistance)) { loot = bones.loot; shareMoney = false; } break; } case HighGuid.Item: { Item item = player.GetItemByGuid(guid); if (item) { loot = item.loot; shareMoney = false; } break; } case HighGuid.Creature: case HighGuid.Vehicle: { Creature creature = player.GetMap().GetCreature(guid); bool lootAllowed = creature && creature.IsAlive() == (player.GetClass() == Class.Rogue && creature.loot.loot_type == LootType.Pickpocketing); if (lootAllowed && creature.IsWithinDistInMap(player, AELootCreatureCheck.LootDistance)) { loot = creature.loot; if (creature.IsAlive()) { shareMoney = false; } } else { player.SendLootError(lootView.Key, guid, lootAllowed ? LootError.TooFar : LootError.DidntKill); } break; } default: continue; // unlootable type } if (loot == null) { continue; } loot.NotifyMoneyRemoved(); if (shareMoney && player.GetGroup() != null) //item, pickpocket and players can be looted only single player { Group group = player.GetGroup(); List <Player> playersNear = new List <Player>(); for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next()) { Player member = refe.GetSource(); if (!member) { continue; } if (player.IsAtGroupRewardDistance(member)) { playersNear.Add(member); } } ulong goldPerPlayer = (ulong)(loot.gold / playersNear.Count); foreach (var pl in playersNear) { ulong goldMod = MathFunctions.CalculatePct(goldPerPlayer, pl.GetTotalAuraModifierByMiscValue(AuraType.ModMoneyGain, 1)); pl.ModifyMoney((long)(goldPerPlayer + goldMod)); pl.UpdateCriteria(CriteriaTypes.LootMoney, goldPerPlayer); LootMoneyNotify packet = new LootMoneyNotify(); packet.Money = goldPerPlayer; packet.MoneyMod = goldMod; packet.SoleLooter = playersNear.Count <= 1 ? true : false; pl.SendPacket(packet); } } else { ulong goldMod = MathFunctions.CalculatePct(loot.gold, player.GetTotalAuraModifierByMiscValue(AuraType.ModMoneyGain, 1)); player.ModifyMoney((long)(loot.gold + goldMod)); player.UpdateCriteria(CriteriaTypes.LootMoney, loot.gold); LootMoneyNotify packet = new LootMoneyNotify(); packet.Money = loot.gold; packet.MoneyMod = goldMod; packet.SoleLooter = true; // "You loot..." SendPacket(packet); } loot.gold = 0; // Delete the money loot record from the DB if (!loot.containerID.IsEmpty()) { loot.DeleteLootMoneyFromContainerItemDB(); } // Delete container if empty if (loot.isLooted() && guid.IsItem()) { player.GetSession().DoLootRelease(guid); } } }