* Unsummon pet if direct control spell expire out of visibility range from owner (base on VladimirMangos changes)
* Move repeating code to separate method --HG-- branch : trunk
This commit is contained in:
@@ -19568,6 +19568,68 @@ void Player::InitDisplayIds()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemPrototype const *pProto, Creature *pVendor, VendorItem const* crItem, bool bStore)
|
||||||
|
{
|
||||||
|
ItemPosCountVec vDest;
|
||||||
|
uint16 uiDest;
|
||||||
|
uint8 msg = bStore ?
|
||||||
|
CanStoreNewItem(bag, slot, vDest, item, pProto->BuyCount * count) :
|
||||||
|
CanEquipNewItem(slot, uiDest, item, false);
|
||||||
|
if (msg != EQUIP_ERR_OK)
|
||||||
|
{
|
||||||
|
SendEquipError(msg, NULL, NULL, item);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModifyMoney(-price);
|
||||||
|
|
||||||
|
if (crItem->ExtendedCost) // case for new honor system
|
||||||
|
{
|
||||||
|
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
||||||
|
if (iece->reqhonorpoints)
|
||||||
|
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
|
||||||
|
|
||||||
|
if (iece->reqarenapoints)
|
||||||
|
ModifyArenaPoints(- int32(iece->reqarenapoints * count));
|
||||||
|
|
||||||
|
for (uint8 i = 0; i < 5; ++i)
|
||||||
|
{
|
||||||
|
if (iece->reqitem[i])
|
||||||
|
DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item* it = bStore ?
|
||||||
|
StoreNewItem(vDest, item, true) :
|
||||||
|
EquipNewItem(uiDest, item, true);
|
||||||
|
if (it)
|
||||||
|
{
|
||||||
|
uint32 new_count = pVendor->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count);
|
||||||
|
|
||||||
|
WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4));
|
||||||
|
data << uint64(pVendor->GetGUID());
|
||||||
|
data << uint32(vendorslot + 1); // numbered from 1 at client
|
||||||
|
data << int32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF);
|
||||||
|
data << uint32(count);
|
||||||
|
GetSession()->SendPacket(&data);
|
||||||
|
SendNewItem(it, pProto->BuyCount * count, true, false, false);
|
||||||
|
|
||||||
|
if (!bStore)
|
||||||
|
AutoUnequipOffhandIfNeed();
|
||||||
|
|
||||||
|
if (pProto->Flags & ITEM_PROTO_FLAG_REFUNDABLE && crItem->ExtendedCost && pProto->GetMaxStackSize() == 1)
|
||||||
|
{
|
||||||
|
it->SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE);
|
||||||
|
it->SetRefundRecipient(GetGUIDLow());
|
||||||
|
it->SetPaidMoney(price);
|
||||||
|
it->SetPaidExtendedCost(crItem->ExtendedCost);
|
||||||
|
it->SaveRefundDataToDB();
|
||||||
|
AddRefundReference(it->GetGUIDLow());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Return true is the bought item has a max count to force refresh of window by caller
|
// Return true is the bought item has a max count to force refresh of window by caller
|
||||||
bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot)
|
bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot)
|
||||||
{
|
{
|
||||||
@@ -19605,13 +19667,13 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
|||||||
|
|
||||||
if (vendorslot >= vItems->GetItemCount())
|
if (vendorslot >= vItems->GetItemCount())
|
||||||
{
|
{
|
||||||
SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0);
|
SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VendorItem const* crItem = vItems->GetItem(vendorslot);
|
VendorItem const* crItem = vItems->GetItem(vendorslot);
|
||||||
// store diff item (cheating)
|
// store diff item (cheating)
|
||||||
if(!crItem || crItem->item != item)
|
if (!crItem || crItem->item != item)
|
||||||
{
|
{
|
||||||
SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0);
|
SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0);
|
||||||
return false;
|
return false;
|
||||||
@@ -19689,54 +19751,8 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
|||||||
|
|
||||||
if ((bag == NULL_BAG && slot == NULL_SLOT) || IsInventoryPos(bag, slot))
|
if ((bag == NULL_BAG && slot == NULL_SLOT) || IsInventoryPos(bag, slot))
|
||||||
{
|
{
|
||||||
ItemPosCountVec dest;
|
if (!_StoreOrEquipNewItem(vendorslot, item, count, bag, slot, price, pProto, pCreature, crItem, true))
|
||||||
uint8 msg = CanStoreNewItem(bag, slot, dest, item, pProto->BuyCount * count);
|
|
||||||
if (msg != EQUIP_ERR_OK)
|
|
||||||
{
|
|
||||||
SendEquipError(msg, NULL, NULL, item);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
ModifyMoney(-(int32)price);
|
|
||||||
|
|
||||||
if (crItem->ExtendedCost) // case for new honor system
|
|
||||||
{
|
|
||||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
|
||||||
if (iece->reqhonorpoints)
|
|
||||||
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
|
|
||||||
|
|
||||||
if (iece->reqarenapoints)
|
|
||||||
ModifyArenaPoints(- int32(iece->reqarenapoints * count));
|
|
||||||
|
|
||||||
for (uint8 i = 0; i < 5; ++i)
|
|
||||||
{
|
|
||||||
if (iece->reqitem[i])
|
|
||||||
DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Item *it = StoreNewItem(dest, item, true))
|
|
||||||
{
|
|
||||||
uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count);
|
|
||||||
|
|
||||||
WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4));
|
|
||||||
data << uint64(pCreature->GetGUID());
|
|
||||||
data << uint32(vendorslot+1); // numbered from 1 at client
|
|
||||||
data << int32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF);
|
|
||||||
data << uint32(count);
|
|
||||||
GetSession()->SendPacket(&data);
|
|
||||||
SendNewItem(it, pProto->BuyCount*count, true, false, false);
|
|
||||||
|
|
||||||
if (pProto->Flags & ITEM_PROTO_FLAG_REFUNDABLE && crItem->ExtendedCost && pProto->GetMaxStackSize() == 1)
|
|
||||||
{
|
|
||||||
it->SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE);
|
|
||||||
it->SetRefundRecipient(GetGUIDLow());
|
|
||||||
it->SetPaidMoney(price);
|
|
||||||
it->SetPaidExtendedCost(crItem->ExtendedCost);
|
|
||||||
it->SaveRefundDataToDB();
|
|
||||||
AddRefundReference(it->GetGUIDLow());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (IsEquipmentPos(bag, slot))
|
else if (IsEquipmentPos(bag, slot))
|
||||||
{
|
{
|
||||||
@@ -19745,57 +19761,8 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
|||||||
SendEquipError(EQUIP_ERR_ITEM_CANT_BE_EQUIPPED, NULL, NULL);
|
SendEquipError(EQUIP_ERR_ITEM_CANT_BE_EQUIPPED, NULL, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!_StoreOrEquipNewItem(vendorslot, item, count, bag, slot, price, pProto, pCreature, crItem, false))
|
||||||
uint16 dest;
|
|
||||||
uint8 msg = CanEquipNewItem(slot, dest, item, false);
|
|
||||||
if (msg != EQUIP_ERR_OK)
|
|
||||||
{
|
|
||||||
SendEquipError(msg, NULL, NULL, item);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
ModifyMoney(-(int32)price);
|
|
||||||
if (crItem->ExtendedCost) // case for new honor system
|
|
||||||
{
|
|
||||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
|
|
||||||
if (iece->reqhonorpoints)
|
|
||||||
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
|
|
||||||
|
|
||||||
if (iece->reqarenapoints)
|
|
||||||
ModifyArenaPoints(- int32(iece->reqarenapoints * count));
|
|
||||||
|
|
||||||
for (uint8 i = 0; i < 5; ++i)
|
|
||||||
{
|
|
||||||
if (iece->reqitem[i])
|
|
||||||
DestroyItemCount(iece->reqitem[i], iece->reqitemcount[i] * count, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Item *it = EquipNewItem(dest, item, true))
|
|
||||||
{
|
|
||||||
uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count);
|
|
||||||
|
|
||||||
WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4));
|
|
||||||
data << uint64(pCreature->GetGUID());
|
|
||||||
data << uint32(vendorslot + 1); // numbered from 1 at client
|
|
||||||
data << int32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF);
|
|
||||||
data << uint32(count);
|
|
||||||
GetSession()->SendPacket(&data);
|
|
||||||
|
|
||||||
SendNewItem(it, pProto->BuyCount*count, true, false, false);
|
|
||||||
|
|
||||||
AutoUnequipOffhandIfNeed();
|
|
||||||
|
|
||||||
if (pProto->Flags & ITEM_PROTO_FLAG_REFUNDABLE && crItem->ExtendedCost && pProto->GetMaxStackSize() == 1)
|
|
||||||
{
|
|
||||||
it->SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE);
|
|
||||||
it->SetRefundRecipient(GetGUIDLow());
|
|
||||||
it->SetPaidMoney(price);
|
|
||||||
it->SetPaidExtendedCost(crItem->ExtendedCost);
|
|
||||||
it->SaveRefundDataToDB();
|
|
||||||
AddRefundReference(it->GetGUIDLow());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1247,6 +1247,7 @@ class Player : public Unit, public GridObject<Player>
|
|||||||
}
|
}
|
||||||
void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast = false);
|
void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast = false);
|
||||||
bool BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
|
bool BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
|
||||||
|
bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemPrototype const *pProto, Creature *pVendor, VendorItem const* crItem, bool bStore);
|
||||||
|
|
||||||
float GetReputationPriceDiscount(Creature const* pCreature) const;
|
float GetReputationPriceDiscount(Creature const* pCreature) const;
|
||||||
|
|
||||||
|
|||||||
@@ -15409,8 +15409,8 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set charmed
|
// Set charmed
|
||||||
Map* pMap = GetMap();
|
Map* pMap = GetMap();
|
||||||
if (!IsVehicle() || (IsVehicle() && pMap && !pMap->IsBattleground()))
|
if (!IsVehicle() || (IsVehicle() && pMap && !pMap->IsBattleground()))
|
||||||
setFaction(charmer->getFaction());
|
setFaction(charmer->getFaction());
|
||||||
|
|
||||||
charmer->SetCharm(this, true);
|
charmer->SetCharm(this, true);
|
||||||
|
|||||||
@@ -3923,9 +3923,7 @@ void AuraEffect::HandleModPossessPet(AuraApplication const * aurApp, uint8 mode,
|
|||||||
if (!(mode & AURA_EFFECT_HANDLE_REAL))
|
if (!(mode & AURA_EFFECT_HANDLE_REAL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Unit * target = aurApp->GetTarget();
|
Unit* caster = GetCaster();
|
||||||
|
|
||||||
Unit * caster = GetCaster();
|
|
||||||
if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
|
if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -3933,24 +3931,35 @@ void AuraEffect::HandleModPossessPet(AuraApplication const * aurApp, uint8 mode,
|
|||||||
//if (caster->ToPlayer()->GetPet() != target)
|
//if (caster->ToPlayer()->GetPet() != target)
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
|
Unit* target = aurApp->GetTarget();
|
||||||
|
if (target->GetTypeId() != TYPEID_UNIT || !target->ToCreature()->isPet())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Pet* pet = target->ToPet();
|
||||||
|
|
||||||
if (apply)
|
if (apply)
|
||||||
{
|
{
|
||||||
if (caster->ToPlayer()->GetPet() != target)
|
if (caster->ToPlayer()->GetPet() != pet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
target->SetCharmedBy(caster, CHARM_TYPE_POSSESS);
|
pet->SetCharmedBy(caster, CHARM_TYPE_POSSESS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
target->RemoveCharmedBy(caster);
|
pet->RemoveCharmedBy(caster);
|
||||||
|
|
||||||
// Reinitialize the pet bar and make the pet come back to the owner
|
if (!pet->IsWithinDistInMap(caster, pet->GetMap()->GetVisibilityDistance()))
|
||||||
caster->ToPlayer()->PetSpellInitialize();
|
pet->Remove(PET_SAVE_NOT_IN_SLOT, true);
|
||||||
if (!target->getVictim())
|
else
|
||||||
{
|
{
|
||||||
target->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, target->GetFollowAngle());
|
// Reinitialize the pet bar and make the pet come back to the owner
|
||||||
//if (target->GetCharmInfo())
|
caster->ToPlayer()->PetSpellInitialize();
|
||||||
// target->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
if (!pet->getVictim())
|
||||||
|
{
|
||||||
|
pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, pet->GetFollowAngle());
|
||||||
|
//if (target->GetCharmInfo())
|
||||||
|
// target->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user