Over 100 camangos Cata commits applied (to c12950)

Over 100 camangos Cata commits applied. up to and inclusing c12950.
This commit is contained in:
Charles A Edwards 2016-08-20 17:10:24 +01:00 committed by Antz
parent b4ec0440aa
commit eef77eadb9
117 changed files with 4314 additions and 3547 deletions

View file

@ -177,15 +177,15 @@ Commands and their parameters
TemporaryFactionFlags
---------------------
* `TEMPFACTION_NONE`: 0x00, when no flag is used in temporary faction change, faction will be persistent. It will then require manual change back to default/another faction when changed once
* `TEMPFACTION_RESTORE_RESPAWN`: 0x01, default faction will be restored at respawn
* `TEMPFACTION_RESTORE_COMBAT_STOP`: 0x02, ... at CombatStop() (happens at creature death, at evade or custom script among others)
* `TEMPFACTION_RESTORE_REACH_HOME`: 0x04, ... at reaching home in home movement (evade), if not already done at CombatStop()
* `TEMPFACTION_NONE` = 0x00, // When no flag is used in temporary faction change, faction will be persistent. It will then require manual change back to default/another faction when changed once
* `TEMPFACTION_RESTORE_RESPAWN` = 0x01, // Default faction will be restored at respawn
* `TEMPFACTION_RESTORE_COMBAT_STOP` = 0x02, // ... at CombatStop() (happens at creature death, at evade or custom scripte among others)
* `TEMPFACTION_RESTORE_REACH_HOME` = 0x04, // ... at reaching home in home movement (evade), if not already done at CombatStop()
The next flags allow to remove unit_flags combined with a faction change (also these flags will be reapplied when the faction is changed back)
// The next flags allow to remove unit_flags combined with a faction change (also these flags will be reapplied when the faction is changed back)
* `TEMPFACTION_TOGGLE_NON_ATTACKABLE`: 0x08, remove UNIT_FLAG_NON_ATTACKABLE(0x02) when faction is changed (reapply when temp-faction is removed)
* `TEMPFACTION_TOGGLE_OOC_NOT_ATTACK`: 0x10, remove UNIT_FLAG_OOC_NOT_ATTACKABLE(0x100) when faction is changed (reapply when temp-faction is removed)
* `TEMPFACTION_TOGGLE_PASSIVE` : 0x20, remove UNIT_FLAG_PASSIVE(0x200)
* `TEMPFACTION_TOGGLE_PACIFIED` : 0x40, remove UNIT_FLAG_PACIFIED(0x20000) when faction is changed (reapply when temp-faction is removed)
* `TEMPFACTION_TOGGLE_NOT_SELECTABLE`: 0x80, remove UNIT_FLAG_NOT_SELECTABLE(0x2000000) when faction is changed (reapply when temp-faction is removed)
* `TEMPFACTION_TOGGLE_NON_ATTACKABLE` = 0x08, // Remove UNIT_FLAG_NON_ATTACKABLE(0x02) when faction is changed (reapply when temp-faction is removed)
* `TEMPFACTION_TOGGLE_OOC_NOT_ATTACK` = 0x10, // Remove UNIT_FLAG_OOC_NOT_ATTACKABLE(0x100) when faction is changed (reapply when temp-faction is removed)
* `TEMPFACTION_TOGGLE_PASSIVE` = 0x20, // Remove UNIT_FLAG_PASSIVE(0x200) when faction is changed (reapply when temp-faction is removed)
* `TEMPFACTION_TOGGLE_PACIFIED` = 0x40, // Remove UNIT_FLAG_PACIFIED(0x20000) when faction is changed (reapply when temp-faction is removed)
* `TEMPFACTION_TOGGLE_NOT_SELECTABLE` = 0x80, // Remove UNIT_FLAG_NOT_SELECTABLE(0x2000000) when faction is changed (reapply when temp-faction is removed)

View file

@ -694,7 +694,7 @@ uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config)
{
config.SameItemInfo.clear();
uint32 count = 0;
time_t Now = time(NULL);
time_t Now = time(nullptr);
AuctionHouseObject::AuctionEntryMapBounds bounds = sAuctionMgr.GetAuctionsMap(config.GetHouseType())->GetAuctionsBounds();
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
@ -706,20 +706,21 @@ uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config)
ItemPrototype const* prototype = item->GetProto();
if (prototype)
{
++config.SameItemInfo[item->GetEntry()].ItemCount; // Structure constructor will make sure Element are correctly initialised if entry is created here.
config.SameItemInfo[item->GetEntry()].BuyPrice = config.SameItemInfo[item->GetEntry()].BuyPrice + (itr->second->buyout / item->GetCount());
config.SameItemInfo[item->GetEntry()].BidPrice = config.SameItemInfo[item->GetEntry()].BidPrice + (itr->second->startbid / item->GetCount());
if (itr->second->buyout != 0)
BuyerItemInfo& buyerItem = config.SameItemInfo[item->GetEntry()]; // Structure constructor will make sure Element are correctly initialised if entry is created here.
++buyerItem.ItemCount;
buyerItem.BuyPrice = buyerItem.BuyPrice + (Aentry->buyout / item->GetCount());
buyerItem.BidPrice = buyerItem.BidPrice + (Aentry->startbid / item->GetCount());
if (Aentry->buyout != 0)
{
if (itr->second->buyout / item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBuyPrice)
config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout / item->GetCount();
else if (config.SameItemInfo[item->GetEntry()].MinBuyPrice == 0)
config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout / item->GetCount();
if (Aentry->buyout / item->GetCount() < buyerItem.MinBuyPrice)
buyerItem.MinBuyPrice = Aentry->buyout / item->GetCount();
else if (buyerItem.MinBuyPrice == 0)
buyerItem.MinBuyPrice = Aentry->buyout / item->GetCount();
}
if (itr->second->startbid / item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBidPrice)
config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid / item->GetCount();
else if (config.SameItemInfo[item->GetEntry()].MinBidPrice == 0)
config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid / item->GetCount();
if (Aentry->startbid / item->GetCount() < buyerItem.MinBidPrice)
buyerItem.MinBidPrice = Aentry->startbid / item->GetCount();
else if (buyerItem.MinBidPrice == 0)
buyerItem.MinBidPrice = Aentry->startbid / item->GetCount();
if (!Aentry->owner)
{
@ -898,7 +899,7 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config)
PrepareListOfEntry(config);
time_t Now = time(NULL);
time_t Now = time(nullptr);
uint32 BuyCycles;
if (config.CheckedEntry.size() > sAuctionBotConfig.GetItemPerCycleBoost())
{
@ -906,21 +907,22 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config)
BASIC_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Boost value used for Buyer! (if this happens often adjust both ItemsPerCycle in ahbot.conf)");
}
else
{ BuyCycles = sAuctionBotConfig.GetItemPerCycleNormal(); }
BuyCycles = sAuctionBotConfig.GetItemPerCycleNormal();
for (CheckEntryMap::iterator itr = config.CheckedEntry.begin(); itr != config.CheckedEntry.end();)
{
AuctionEntry* auction = auctionHouse->GetAuction(itr->second.AuctionId);
BuyerAuctionEval& auctionEval = itr->second;
AuctionEntry* auction = auctionHouse->GetAuction(auctionEval.AuctionId);
if (!auction || auction->moneyDeliveryTime) // is auction not active now
{
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Entry %u on ah %u doesn't exists, perhaps bought already?",
itr->second.AuctionId, auction->GetHouseId());
auctionEval.AuctionId, auction->GetHouseId());
config.CheckedEntry.erase(itr++);
continue;
}
if ((itr->second.LastChecked != 0) && ((Now - itr->second.LastChecked) <= m_CheckInterval))
if ((auctionEval.LastChecked != 0) && ((Now - auctionEval.LastChecked) <= m_CheckInterval))
{
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: In time interval wait for entry %u!", auction->Id);
++itr;
@ -928,7 +930,7 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config)
}
if (BuyCycles == 0)
{ break; }
break;
uint32 MaxChance = 5000;
@ -945,11 +947,10 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config)
BasePrice *= item->GetCount();
double MaxBuyablePrice = (BasePrice * config.BuyerPriceRatio) / 100;
BuyerItemInfoMap::iterator sameitem_itr = config.SameItemInfo.find(item->GetEntry());
uint64 buyoutPrice = auction->buyout / item->GetCount();
uint32 buyoutPrice = auction->buyout / item->GetCount();
uint32 bidPrice;
uint32 bidPriceByItem;
uint64 bidPrice;
uint64 bidPriceByItem;
if (auction->bid >= auction->startbid)
{
bidPrice = auction->GetAuctionOutBid();
@ -963,26 +964,38 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config)
double InGame_BuyPrice;
double InGame_BidPrice;
uint32 minBidPrice;
uint32 minBuyPrice;
BuyerItemInfoMap::iterator sameitem_itr = config.SameItemInfo.find(item->GetEntry());
if (sameitem_itr == config.SameItemInfo.end())
{
InGame_BuyPrice = 0;
InGame_BidPrice = 0;
minBidPrice = 0;
minBuyPrice = 0;
}
else
{
if (sameitem_itr->second.ItemCount == 1) MaxBuyablePrice = MaxBuyablePrice * 5; // if only one item exist can be buyed if the price is high too.
InGame_BuyPrice = sameitem_itr->second.BuyPrice / sameitem_itr->second.ItemCount;
InGame_BidPrice = sameitem_itr->second.BidPrice / sameitem_itr->second.ItemCount;
const BuyerItemInfo& sameBuyerItem = sameitem_itr->second;
if (sameBuyerItem.ItemCount == 1)
MaxBuyablePrice = MaxBuyablePrice * 5; // if only one item exist can be bought if the price is high too.
InGame_BuyPrice = sameBuyerItem.BuyPrice / sameBuyerItem.ItemCount;
InGame_BidPrice = sameBuyerItem.BidPrice / sameBuyerItem.ItemCount;
minBidPrice = sameBuyerItem.MinBidPrice;
minBuyPrice = sameBuyerItem.MinBuyPrice;
}
double MaxBidablePrice = MaxBuyablePrice - (MaxBuyablePrice / 30); // Max Bidable price defined to 70% of max buyable price
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Auction added with data:");
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: MaxPrice of Entry %u is %.1fg.", itr->second.AuctionId, MaxBuyablePrice / 10000);
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: MaxPrice of Entry %u is %.1fg.", auctionEval.AuctionId, MaxBuyablePrice / 10000);
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: GamePrice buy=%.1fg, bid=%.1fg.", InGame_BuyPrice / 10000, InGame_BidPrice / 10000);
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Minimal price see in AH Buy=" UI64FMTD "g, Bid=" UI64FMTD "g.",
sameitem_itr->second.MinBuyPrice / 10000, sameitem_itr->second.MinBidPrice / 10000);
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Actual Entry price, Buy=" UI64FMTD "g, Bid=" UI64FMTD "g.", buyoutPrice / 10000, bidPrice / 10000);
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Minimal price see in AH Buy=%ug, Bid=%ug.",
minBuyPrice / 10000, minBidPrice / 10000);
DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Actual Entry price, Buy=%ug, Bid=%ug.", buyoutPrice / 10000, bidPrice / 10000);
if (!auction->owner) // Original auction owner
{
@ -990,24 +1003,24 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config)
}
if (auction->buyout != 0) // Is the item directly buyable?
{
if (IsBuyableEntry(buyoutPrice, InGame_BuyPrice, MaxBuyablePrice, sameitem_itr->second.MinBuyPrice, MaxChance, config.FactionChance))
if (IsBuyableEntry(buyoutPrice, InGame_BuyPrice, MaxBuyablePrice, minBuyPrice, MaxChance, config.FactionChance))
{
if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice, MaxChance / 2, config.FactionChance))
if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, minBidPrice, MaxChance / 2, config.FactionChance))
if (urand(0, 5) == 0) PlaceBidToEntry(auction, bidPrice); else BuyEntry(auction);
else
{ BuyEntry(auction); }
BuyEntry(auction);
}
else
{
if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice, MaxChance / 2, config.FactionChance))
{ PlaceBidToEntry(auction, bidPrice); }
if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, minBidPrice, MaxChance / 2, config.FactionChance))
PlaceBidToEntry(auction, bidPrice);
}
}
else // buyout = 0 mean only bid are possible
if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice, MaxChance, config.FactionChance))
{ PlaceBidToEntry(auction, bidPrice); }
if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, minBidPrice, MaxChance, config.FactionChance))
PlaceBidToEntry(auction, bidPrice);
itr->second.LastChecked = Now;
auctionEval.LastChecked = Now;
--BuyCycles;
++itr;
@ -1920,9 +1933,12 @@ void AuctionHouseBot::Rebuild(bool all)
{
AuctionHouseObject::AuctionEntryMapBounds bounds = sAuctionMgr.GetAuctionsMap(AuctionHouseType(i))->GetAuctionsBounds();
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
if (!itr->second->owner) // ahbot auction
if (all || itr->second->bid == 0) // expire now auction if no bid or forced
itr->second->expireTime = sWorld.GetGameTime();
{
AuctionEntry* entry = itr->second;
if (!entry->owner) // ahbot auction
if (all || entry->bid == 0) // expire now auction if no bid or forced
entry->expireTime = sWorld.GetGameTime();
}
}
}

View file

@ -81,7 +81,7 @@ namespace MaNGOS
class BattleGroundYellBuilder
{
public:
BattleGroundYellBuilder(Language language, int32 textId, Creature const* source, va_list* args = nullptr)
BattleGroundYellBuilder(Language language, int32 textId, Creature const* source, va_list* args = NULL)
: i_language(language), i_textId(textId), i_source(source), i_args(args) {}
void operator()(WorldPacket& data, int32 loc_idx)
{
@ -125,13 +125,13 @@ namespace MaNGOS
snprintf(str, 2048, text, arg1str, arg2str);
ObjectGuid guid;
char const* pName = nullptr;
char const* pName = NULL;
if (i_source)
{
guid = i_source->GetObjectGuid();
pName = i_source->GetName();
}
ChatHandler::BuildChatPacket(data, i_msgtype, str, LANG_UNIVERSAL, CHAT_TAG_NONE, ObjectGuid(), nullptr, guid, pName);
ChatHandler::BuildChatPacket(data, i_msgtype, str, LANG_UNIVERSAL, CHAT_TAG_NONE, ObjectGuid(), NULL, guid, pName);
}
private:
ChatMsg i_msgtype;
@ -997,6 +997,7 @@ void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen
plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);
plr->RemoveAurasDueToSpell(isArena() ? SPELL_ARENA_DAMPENING : SPELL_BATTLEGROUND_DAMPENING);
plr->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
if (!plr->IsAlive()) // resurrect on exit
{
@ -1313,11 +1314,12 @@ void BattleGround::RemoveFromBGFreeSlotQueue()
{
// set to be able to re-add if needed
m_InBGFreeSlotQueue = false;
for (BGFreeSlotQueueType::iterator itr = sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].begin(); itr != sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].end(); ++itr)
BGFreeSlotQueueType& bgFreeSlot = sBattleGroundMgr.BGFreeSlotQueue[m_TypeID];
for (BGFreeSlotQueueType::iterator itr = bgFreeSlot.begin(); itr != bgFreeSlot.end(); ++itr)
{
if ((*itr)->GetInstanceID() == GetInstanceID())
{
sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].erase(itr);
bgFreeSlot.erase(itr);
return;
}
}

View file

@ -491,6 +491,12 @@ class BattleGround
// Process Capture event
virtual bool HandleEvent(uint32 /*eventId*/, GameObject* /*go*/) { return false; }
// Called when a creature is created
virtual void HandleCreatureCreate(Creature* /*creature*/) {}
// handle capture objective complete
virtual void HandleObjectiveComplete(uint32 /*eventId*/, const std::list<Player*>& /*players*/, Team /*team*/) {}
// Called when a gameobject is created
virtual void HandleGameObjectCreate(GameObject* /*go*/) {}

View file

@ -92,7 +92,7 @@ void BattleGroundBE::HandleKillPlayer(Player* player, Player* killer)
bool BattleGroundBE::HandlePlayerUnderMap(Player* player)
{
player->TeleportTo(GetMapId(), 6238.930176f, 262.963470f, 0.889519f, player->GetOrientation(), false);
player->TeleportTo(GetMapId(), 6238.930176f, 262.963470f, 0.889519f, player->GetOrientation());
return true;
}

View file

@ -1437,7 +1437,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg)
if (bg->isArena())
{
// it seems this must be according to BG_WINNER_A/H and _NOT_ BG_TEAM_A/H
for (int8 i = 0; i < BG_TEAMS_COUNT; ++i)
for (int8 i = 0; i < PVP_TEAM_COUNT; ++i)
{
if (ArenaTeam* at = sObjectMgr.GetArenaTeamById(bg->m_ArenaTeamIds[i]))
data->WriteBits(at->GetName().length(), 8);
@ -1451,6 +1451,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg)
{
ObjectGuid memberGuid = itr->first;
Player* player = sObjectMgr.GetPlayer(itr->first);
const BattleGroundScore* score = itr->second;
data->WriteBit(0); // unk1
data->WriteBit(0); // unk2
@ -1466,18 +1467,18 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg)
data->WriteBit(team == ALLIANCE); // unk7
data->WriteGuidMask<7>(memberGuid);
buffer << uint32(itr->second->HealingDone); // healing done
buffer << uint32(itr->second->DamageDone); // damage done
buffer << uint32(score->HealingDone); // healing done
buffer << uint32(score->DamageDone); // damage done
if (!bg->isArena())
{
buffer << uint32(itr->second->BonusHonor);
buffer << uint32(itr->second->Deaths);
buffer << uint32(itr->second->HonorableKills);
buffer << uint32(score->BonusHonor);
buffer << uint32(score->Deaths);
buffer << uint32(score->HonorableKills);
}
buffer.WriteGuidBytes<4>(memberGuid);
buffer << uint32(itr->second->KillingBlows);
buffer << uint32(score->KillingBlows);
// if (unk5) << uint32() unk
buffer.WriteGuidBytes<5>(memberGuid);
// if (unk6) << uint32() unk
@ -1493,25 +1494,25 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg)
{
case BATTLEGROUND_AV:
data->WriteBits(5, 24); // count of next fields
buffer << uint32(((BattleGroundAVScore*)itr->second)->GraveyardsAssaulted); // GraveyardsAssaulted
buffer << uint32(((BattleGroundAVScore*)itr->second)->GraveyardsDefended); // GraveyardsDefended
buffer << uint32(((BattleGroundAVScore*)itr->second)->TowersAssaulted); // TowersAssaulted
buffer << uint32(((BattleGroundAVScore*)itr->second)->TowersDefended); // TowersDefended
buffer << uint32(((BattleGroundAVScore*)itr->second)->SecondaryObjectives); // SecondaryObjectives - free some of the Lieutnants
buffer << uint32(((BattleGroundAVScore*)score)->GraveyardsAssaulted); // GraveyardsAssaulted
buffer << uint32(((BattleGroundAVScore*)score)->GraveyardsDefended); // GraveyardsDefended
buffer << uint32(((BattleGroundAVScore*)score)->TowersAssaulted); // TowersAssaulted
buffer << uint32(((BattleGroundAVScore*)score)->TowersDefended); // TowersDefended
buffer << uint32(((BattleGroundAVScore*)score)->SecondaryObjectives); // SecondaryObjectives - free some of the Lieutnants
break;
case BATTLEGROUND_WS:
data->WriteBits(2, 24); // count of next fields
buffer << uint32(((BattleGroundWGScore*)itr->second)->FlagCaptures); // flag captures
buffer << uint32(((BattleGroundWGScore*)itr->second)->FlagReturns); // flag returns
buffer << uint32(((BattleGroundWGScore*)score)->FlagCaptures); // flag captures
buffer << uint32(((BattleGroundWGScore*)score)->FlagReturns); // flag returns
break;
case BATTLEGROUND_AB:
data->WriteBits(2, 24); // count of next fields
buffer << uint32(((BattleGroundABScore*)itr->second)->BasesAssaulted); // bases asssulted
buffer << uint32(((BattleGroundABScore*)itr->second)->BasesDefended); // bases defended
buffer << uint32(((BattleGroundABScore*)score)->BasesAssaulted); // bases asssulted
buffer << uint32(((BattleGroundABScore*)score)->BasesDefended); // bases defended
break;
case BATTLEGROUND_EY:
data->WriteBits(1, 24); // count of next fields
buffer << uint32(((BattleGroundEYScore*)itr->second)->FlagCaptures); // flag captures
buffer << uint32(((BattleGroundEYScore*)score)->FlagCaptures); // flag captures
break;
case BATTLEGROUND_NA:
case BATTLEGROUND_BE:
@ -1541,7 +1542,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg)
if (bg->isRated()) // arena
{
for (int8 i = 0; i < BG_TEAMS_COUNT; ++i)
for (int8 i = 0; i < PVP_TEAM_COUNT; ++i)
{
uint32 pointsLost = bg->m_ArenaTeamRatingChanges[i] < 0 ? abs(bg->m_ArenaTeamRatingChanges[i]) : 0;
uint32 pointsGained = bg->m_ArenaTeamRatingChanges[i] > 0 ? bg->m_ArenaTeamRatingChanges[i] : 0;
@ -1558,7 +1559,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg)
if (bg->isArena())
{
for (int8 i = 0; i < BG_TEAMS_COUNT; ++i)
for (int8 i = 0; i < PVP_TEAM_COUNT; ++i)
{
if (ArenaTeam* at = sObjectMgr.GetArenaTeamById(bg->m_ArenaTeamIds[i]))
data->append(at->GetName().data(), at->GetName().length());
@ -1902,15 +1903,17 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
uint32 MinPlayersPerTeam = fields[1].GetUInt32();
uint32 MaxPlayersPerTeam = fields[2].GetUInt32();
// check values from DB
if (MaxPlayersPerTeam == 0 || MinPlayersPerTeam == 0)
if (MaxPlayersPerTeam == 0)
{
sLog.outErrorDb("Table `battleground_template` for id %u have wrong min/max players per team settings. BG not created.", bgTypeID);
sLog.outErrorDb("Table `battleground_template` for id %u doesn't allow any player per team settings. BG not created.", bgTypeID);
continue;
}
if (MinPlayersPerTeam > MaxPlayersPerTeam)
{
MinPlayersPerTeam = MaxPlayersPerTeam;
sLog.outErrorDb("Table `battleground_template` for id %u has min players > max players per team settings. Min players will use same value as max players.", bgTypeID);
}
float AStartLoc[4];
float HStartLoc[4];

View file

@ -93,7 +93,7 @@ void BattleGroundNA::HandleKillPlayer(Player* player, Player* killer)
bool BattleGroundNA::HandlePlayerUnderMap(Player* player)
{
player->TeleportTo(GetMapId(), 4055.504395f, 2919.660645f, 13.611241f, player->GetOrientation(), false);
player->TeleportTo(GetMapId(), 4055.504395f, 2919.660645f, 13.611241f, player->GetOrientation());
return true;
}

View file

@ -92,7 +92,7 @@ void BattleGroundRL::HandleKillPlayer(Player* player, Player* killer)
bool BattleGroundRL::HandlePlayerUnderMap(Player* player)
{
player->TeleportTo(GetMapId(), 1285.810547f, 1667.896851f, 39.957642f, player->GetOrientation(), false);
player->TeleportTo(GetMapId(), 1285.810547f, 1667.896851f, 39.957642f, player->GetOrientation());
return true;
}

View file

@ -175,10 +175,11 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/)
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
AccountTypes itr_sec = itr->second->GetSession()->GetSecurity();
if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_GM_LIST))) &&
(!m_session || itr->second->IsVisibleGloballyFor(m_session->GetPlayer())))
{ names.push_back(std::make_pair<std::string, bool>(GetNameLink(itr->second), itr->second->isAcceptWhispers())); }
Player* player = itr->second;
AccountTypes security = player->GetSession()->GetSecurity();
if ((player->isGameMaster() || (security > SEC_PLAYER && security <= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_GM_LIST))) &&
(!m_session || player->IsVisibleGloballyFor(m_session->GetPlayer())))
names.push_back(std::make_pair<std::string, bool>(GetNameLink(player), player->isAcceptWhispers()));
}
}
@ -189,10 +190,10 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/)
char const* accepts = GetMangosString(LANG_GM_ACCEPTS_WHISPER);
char const* not_accept = GetMangosString(LANG_GM_NO_WHISPER);
for (std::list<std::pair< std::string, bool> >::const_iterator iter = names.begin(); iter != names.end(); ++iter)
{ PSendSysMessage("%s - %s", iter->first.c_str(), iter->second ? accepts : not_accept); }
PSendSysMessage("%s - %s", iter->first.c_str(), iter->second ? accepts : not_accept);
}
else
{ SendSysMessage(LANG_GMS_NOT_LOGGED); }
SendSysMessage(LANG_GMS_NOT_LOGGED);
return true;
}

View file

@ -383,8 +383,8 @@ bool ChatHandler::HandleSummonCommand(char* args)
if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name))
return false;
Player* _player = m_session->GetPlayer();
if (target == _player || target_guid == _player->GetObjectGuid())
Player* player = m_session->GetPlayer();
if (target == player || target_guid == player->GetObjectGuid())
{
PSendSysMessage(LANG_CANT_TELEPORT_SELF);
SetSentErrorMessage(true);
@ -405,7 +405,7 @@ bool ChatHandler::HandleSummonCommand(char* args)
return false;
}
Map* pMap = m_session->GetPlayer()->GetMap();
Map* pMap = player->GetMap();
if (pMap->IsBattleGroundOrArena())
{
@ -442,9 +442,9 @@ bool ChatHandler::HandleSummonCommand(char* args)
}
// we are in instance, and can summon only player in our group with us as lead
if (!m_session->GetPlayer()->GetGroup() || !target->GetGroup() ||
(target->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) ||
(m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()))
if (!player->GetGroup() || !target->GetGroup() ||
(target->GetGroup()->GetLeaderGuid() != player->GetObjectGuid()) ||
(player->GetGroup()->GetLeaderGuid() != player->GetObjectGuid()))
// the last check is a bit excessive, but let it be, just in case
{
PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink.c_str());
@ -455,7 +455,7 @@ bool ChatHandler::HandleSummonCommand(char* args)
PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), "");
if (needReportToTarget(target))
ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, playerLink(_player->GetName()).c_str());
ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, playerLink(player->GetName()).c_str());
// stop flight if need
if (target->IsTaxiFlying())
@ -483,12 +483,12 @@ bool ChatHandler::HandleSummonCommand(char* args)
PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), GetMangosString(LANG_OFFLINE));
// in point where GM stay
Player::SavePositionInDB(target_guid, m_session->GetPlayer()->GetMapId(),
m_session->GetPlayer()->GetPositionX(),
m_session->GetPlayer()->GetPositionY(),
m_session->GetPlayer()->GetPositionZ(),
m_session->GetPlayer()->GetOrientation(),
m_session->GetPlayer()->GetZoneId());
Player::SavePositionInDB(target_guid, player->GetMapId(),
player->GetPositionX(),
player->GetPositionY(),
player->GetPositionZ(),
player->GetOrientation(),
player->GetZoneId());
}
return true;
@ -1984,13 +1984,14 @@ bool ChatHandler::HandleGroupgoCommand(char* args)
return false;
}
Map* gmMap = m_session->GetPlayer()->GetMap();
Player* player = m_session->GetPlayer();
Map* gmMap = player->GetMap();
bool to_instance = gmMap->Instanceable();
// we are in instance, and can summon only player in our group with us as lead
if (to_instance && (
!m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid()) ||
(m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid())))
!player->GetGroup() || (grp->GetLeaderGuid() != player->GetObjectGuid()) ||
(player->GetGroup()->GetLeaderGuid() != player->GetObjectGuid())))
// the last check is a bit excessive, but let it be, just in case
{
SendSysMessage(LANG_CANNOT_SUMMON_TO_INST);
@ -1998,7 +1999,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args)
return false;
}
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* pl = itr->getSource();

File diff suppressed because it is too large Load diff

View file

@ -2370,7 +2370,8 @@ bool ChatHandler::HandleLearnAllMyClassCommand(char* /*args*/)
bool ChatHandler::HandleLearnAllMySpellsCommand(char* /*args*/)
{
ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(m_session->GetPlayer()->getClass());
Player* player = m_session->GetPlayer();
ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(player->getClass());
if (!clsEntry)
return true;
uint32 family = clsEntry->spellfamily;
@ -2390,7 +2391,7 @@ bool ChatHandler::HandleLearnAllMySpellsCommand(char* /*args*/)
continue;
// skip wrong class/race skills
if (!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id))
if (!player->IsSpellFitByClassAndRace(spellInfo->Id))
continue;
// skip other spell families
@ -2403,10 +2404,10 @@ bool ChatHandler::HandleLearnAllMySpellsCommand(char* /*args*/)
continue;
// skip broken spells
if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer(), false))
if (!SpellMgr::IsSpellValid(spellInfo, player, false))
continue;
m_session->GetPlayer()->learnSpell(spellInfo->Id, false);
player->learnSpell(spellInfo->Id, false);
}
SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS);
@ -2447,7 +2448,7 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(char* /*args*/)
continue;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid);
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer(), false))
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player, false))
continue;
// learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
@ -2540,9 +2541,11 @@ bool ChatHandler::HandleLearnAllMyPetTalentsCommand(char* /*args*/)
bool ChatHandler::HandleLearnAllLangCommand(char* /*args*/)
{
Player* player = m_session->GetPlayer();
// skipping UNIVERSAL language (0)
for (int i = 1; i < LANGUAGES_COUNT; ++i)
m_session->GetPlayer()->learnSpell(lang_description[i].spell_id, false);
player->learnSpell(lang_description[i].spell_id, false);
SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG);
return true;
@ -2563,6 +2566,7 @@ bool ChatHandler::HandleLearnAllDefaultCommand(char* args)
bool ChatHandler::HandleLearnCommand(char* args)
{
Player* player = m_session->GetPlayer();
Player* targetPlayer = getSelectedPlayer();
if (!targetPlayer)
@ -2577,12 +2581,12 @@ bool ChatHandler::HandleLearnCommand(char* args)
if (!spell || !sSpellStore.LookupEntry(spell))
return false;
bool allRanks = ExtractLiteralArg(&args, "all") != NULL;
bool allRanks = ExtractLiteralArg(&args, "all") != nullptr;
if (!allRanks && *args) // can be fail also at syntax error
return false;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell);
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer()))
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player))
{
PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell);
SetSentErrorMessage(true);
@ -2591,7 +2595,7 @@ bool ChatHandler::HandleLearnCommand(char* args)
if (!allRanks && targetPlayer->HasSpell(spell))
{
if (targetPlayer == m_session->GetPlayer())
if (targetPlayer == player)
SendSysMessage(LANG_YOU_KNOWN_SPELL);
else
PSendSysMessage(LANG_TARGET_KNOWN_SPELL, GetNameLink(targetPlayer).c_str());
@ -3956,9 +3960,10 @@ bool ChatHandler::HandleGetDistanceCommand(char* args)
bool ChatHandler::HandleDieCommand(char* /*args*/)
{
Player* player = m_session->GetPlayer();
Unit* target = getSelectedUnit();
if (!target || !m_session->GetPlayer()->GetSelectionGuid())
if (!target || !player->GetSelectionGuid())
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
@ -3973,7 +3978,7 @@ bool ChatHandler::HandleDieCommand(char* /*args*/)
if (target->IsAlive())
{
m_session->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
player->DealDamage(target, target->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
}
return true;
@ -3985,8 +3990,9 @@ bool ChatHandler::HandleDamageCommand(char* args)
return false;
Unit* target = getSelectedUnit();
Player* player = m_session->GetPlayer();
if (!target || !m_session->GetPlayer()->GetSelectionGuid())
if (!target || !player->GetSelectionGuid())
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
@ -4005,12 +4011,12 @@ bool ChatHandler::HandleDamageCommand(char* args)
uint32 damage = damage_int;
// flat melee damage without resistence/etc reduction
// flat melee damage without resistance/etc reduction
if (!*args)
{
m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
if (target != m_session->GetPlayer())
m_session->GetPlayer()->SendAttackStateUpdate(HITINFO_NORMALSWING2, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0);
player->DealDamage(target, damage, nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false);
if (target != player)
player->SendAttackStateUpdate(HITINFO_NORMALSWING2, target, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0);
return true;
}
@ -4024,7 +4030,7 @@ bool ChatHandler::HandleDamageCommand(char* args)
SpellSchoolMask schoolmask = SpellSchoolMask(1 << school);
if (schoolmask & SPELL_SCHOOL_MASK_NORMAL)
damage = m_session->GetPlayer()->CalcArmorReducedDamage(target, damage);
damage = player->CalcArmorReducedDamage(target, damage);
// melee damage by specific school
if (!*args)
@ -4032,16 +4038,16 @@ bool ChatHandler::HandleDamageCommand(char* args)
uint32 absorb = 0;
uint32 resist = 0;
target->CalculateDamageAbsorbAndResist(m_session->GetPlayer(), schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist);
target->CalculateDamageAbsorbAndResist(player, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist);
if (damage <= absorb + resist)
return true;
damage -= absorb + resist;
m_session->GetPlayer()->DealDamageMods(target, damage, &absorb);
m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false);
m_session->GetPlayer()->SendAttackStateUpdate(HITINFO_NORMALSWING2, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_NORMAL, 0);
player->DealDamageMods(target, damage, &absorb);
player->DealDamage(target, damage, nullptr, DIRECT_DAMAGE, schoolmask, nullptr, false);
player->SendAttackStateUpdate(HITINFO_NORMALSWING2, target, schoolmask, damage, absorb, resist, VICTIMSTATE_NORMAL, 0);
return true;
}
@ -4052,7 +4058,7 @@ bool ChatHandler::HandleDamageCommand(char* args)
if (!spellid || !sSpellStore.LookupEntry(spellid))
return false;
m_session->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage);
player->SpellNonMeleeDamageLog(target, spellid, damage);
return true;
}
@ -6411,7 +6417,7 @@ bool ChatHandler::HandleCastCommand(char* args)
return false;
}
bool triggered = ExtractLiteralArg(&args, "triggered") != NULL;
bool triggered = ExtractLiteralArg(&args, "triggered") != nullptr;
if (!triggered && *args) // can be fail also at syntax error
return false;
@ -7132,8 +7138,10 @@ bool ChatHandler::HandleSendMessageCommand(char* args)
if (!*args)
return false;
WorldSession* rPlayerSession = rPlayer->GetSession();
///- Check that he is not logging out.
if (rPlayer->GetSession()->isLogingOut())
if (rPlayerSession->isLogingOut())
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
@ -7142,8 +7150,8 @@ bool ChatHandler::HandleSendMessageCommand(char* args)
///- Send the message
// Use SendAreaTriggerMessage for fastest delivery.
rPlayer->GetSession()->SendAreaTriggerMessage("%s", args);
rPlayer->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
rPlayerSession->SendAreaTriggerMessage("%s", args);
rPlayerSession->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
// Confirmation message
std::string nameLink = GetNameLink(rPlayer);
@ -7301,3 +7309,11 @@ bool ChatHandler::HandleMmapTestArea(char* args)
return true;
}
bool ChatHandler::HandleServerResetAllRaidCommand(char* args)
{
PSendSysMessage("Global raid instances reset, all players in raid instances will be teleported to homebind!");
sMapPersistentStateMgr.GetScheduler().ResetAllRaid();
return true;
}

View file

@ -37,7 +37,6 @@
#include "ObjectMgr.h"
#include "ObjectGuid.h"
#include "SpellMgr.h"
#include "PhaseMgr.h"
bool ChatHandler::HandleDebugSendSpellFailCommand(char* args)
{
@ -129,58 +128,60 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
unit = m_session->GetPlayer();
std::ifstream ifs("opcode.txt");
if (ifs.bad())
std::ifstream stream("opcode.txt");
if (!stream.is_open())
return false;
uint32 opcode;
ifs >> opcode;
uint32 opcode = 0;
if (!(stream >> opcode))
{
stream.close();
return false;
}
WorldPacket data(Opcodes(opcode), 0);
while (!ifs.eof())
{
std::string type;
ifs >> type;
if (type == "")
while (stream >> type)
{
if (type.empty())
break;
if (type == "uint8")
{
uint16 val1;
ifs >> val1;
data << uint8(val1);
uint16 value;
stream >> value;
data << uint8(value);
}
else if (type == "uint16")
{
uint16 val2;
ifs >> val2;
data << val2;
uint16 value;
stream >> value;
data << value;
}
else if (type == "uint32")
{
uint32 val3;
ifs >> val3;
data << val3;
uint32 value;
stream >> value;
data << value;
}
else if (type == "uint64")
{
uint64 val4;
ifs >> val4;
data << val4;
uint64 value;
stream >> value;
data << value;
}
else if (type == "float")
{
float val5;
ifs >> val5;
data << val5;
float value;
stream >> value;
data << value;
}
else if (type == "string")
{
std::string val6;
ifs >> val6;
data << val6;
std::string value;
stream >> value;
data << value;
}
else if (type == "pguid")
{
@ -192,11 +193,15 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
break;
}
}
ifs.close();
stream.close();
DEBUG_LOG("Sending opcode %u, %s", data.GetOpcode(), data.GetOpcodeName());
data.hexlike();
((Player*)unit)->GetSession()->SendPacket(&data);
PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName());
return true;
}
@ -673,31 +678,22 @@ bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(char* args)
if (!*args)
return false;
char* t = strtok((char*)args, " ");
char* m = strtok((char*)args, " ");
char* p = strtok(NULL, " ");
if (!t)
return false;
std::set<uint32> terrainswap;
std::set<uint32> phaseId;
terrainswap.insert((uint32)atoi(t));
if (p)
phaseId.insert((uint32)atoi(p));
m_session->SendSetPhaseShift(phaseId, terrainswap);
uint16 MapId = atoi(m);
uint32 PhaseShift = atoi(p);
m_session->SendSetPhaseShift(PhaseShift, MapId);
return true;
}
bool ChatHandler::HandleDebugPhaseCommand(char* args)
{
Player* player = getSelectedPlayer();
if (!player)
player = m_session->GetPlayer();
uint32 emote_id;
if (!ExtractUInt32(&args, emote_id))
{ return false; }
player->GetPhaseMgr()->SendDebugReportToPlayer(m_session->GetPlayer());
m_session->GetPlayer()->HandleEmoteCommand(emote_id);
return true;
}
@ -973,29 +969,30 @@ bool ChatHandler::HandlerDebugModValueHelper(Object* target, uint32 field, char*
return false;
uint32 value = target->GetUInt32Value(field);
const char* guidString = guid.GetString().c_str();
switch (type)
{
default:
case 1: // int +
value = uint32(int32(value) + int32(iValue));
DEBUG_LOG(GetMangosString(LANG_CHANGE_INT32), guid.GetString().c_str(), field, iValue, value, value);
PSendSysMessage(LANG_CHANGE_INT32_FIELD, guid.GetString().c_str(), field, iValue, value, value);
DEBUG_LOG(GetMangosString(LANG_CHANGE_INT32), guidString, field, iValue, value, value);
PSendSysMessage(LANG_CHANGE_INT32_FIELD, guidString, field, iValue, value, value);
break;
case 2: // |= bit or
value |= iValue;
DEBUG_LOG(GetMangosString(LANG_CHANGE_HEX), guid.GetString().c_str(), field, typeStr, iValue, value);
PSendSysMessage(LANG_CHANGE_HEX_FIELD, guid.GetString().c_str(), field, typeStr, iValue, value);
DEBUG_LOG(GetMangosString(LANG_CHANGE_HEX), guidString, field, typeStr, iValue, value);
PSendSysMessage(LANG_CHANGE_HEX_FIELD, guidString, field, typeStr, iValue, value);
break;
case 3: // &= bit and
value &= iValue;
DEBUG_LOG(GetMangosString(LANG_CHANGE_HEX), guid.GetString().c_str(), field, typeStr, iValue, value);
PSendSysMessage(LANG_CHANGE_HEX_FIELD, guid.GetString().c_str(), field, typeStr, iValue, value);
DEBUG_LOG(GetMangosString(LANG_CHANGE_HEX), guidString, field, typeStr, iValue, value);
PSendSysMessage(LANG_CHANGE_HEX_FIELD, guidString, field, typeStr, iValue, value);
break;
case 4: // &=~ bit and not
value &= ~iValue;
DEBUG_LOG(GetMangosString(LANG_CHANGE_HEX), guid.GetString().c_str(), field, typeStr, iValue, value);
PSendSysMessage(LANG_CHANGE_HEX_FIELD, guid.GetString().c_str(), field, typeStr, iValue, value);
DEBUG_LOG(GetMangosString(LANG_CHANGE_HEX), guidString, field, typeStr, iValue, value);
PSendSysMessage(LANG_CHANGE_HEX_FIELD, guidString, field, typeStr, iValue, value);
break;
}

View file

@ -47,7 +47,7 @@ void HomeMovementGenerator<Creature>::_setTargetLocation(Creature& owner)
Movement::MoveSplineInit init(owner);
float x, y, z, o;
// at apply we can select more nice return points base at current movegen
if (owner.GetMotionMaster()->empty() || !owner.GetMotionMaster()->top()->GetResetPosition(owner, x, y, z))
if (owner.GetMotionMaster()->empty() || !owner.GetMotionMaster()->top()->GetResetPosition(owner, x, y, z, o))
{
owner.GetRespawnCoord(x, y, z, &o);
init.SetFacing(o);

View file

@ -76,6 +76,8 @@ class MotionMaster : private std::stack<MovementGenerator*>
void Initialize();
MovementGenerator const* GetCurrent() const { return top(); }
MovementGenerator* operator->(void) { return top(); }
using Impl::top;

View file

@ -59,7 +59,7 @@ class MovementGenerator
virtual void unitSpeedChanged() { }
// used by Evade code for select point to evade with expected restart default movement
virtual bool GetResetPosition(Unit&, float& /*x*/, float& /*y*/, float& /*z*/) const { return false; }
virtual bool GetResetPosition(Unit&, float& /*x*/, float& /*y*/, float& /*z*/, float& o) const { return false; }
// given destination unreachable? due to pathfinsing or other
virtual bool IsReachable() const { return true; }
@ -70,7 +70,7 @@ class MovementGenerator
};
template<class T, class D>
class MovementGeneratorMedium : public MovementGenerator
class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator
{
public:
void Initialize(Unit& u) override
@ -98,10 +98,10 @@ class MovementGeneratorMedium : public MovementGenerator
// u->AssertIsType<T>();
return (static_cast<D*>(this))->Update(*((T*)&u), time_diff);
}
bool GetResetPosition(Unit& u, float& x, float& y, float& z) const override
bool GetResetPosition(Unit& u, float& x, float& y, float& z, float& o) const override
{
// u->AssertIsType<T>();
return (static_cast<D const*>(this))->GetResetPosition(*((T*)&u), x, y, z);
return (static_cast<D const*>(this))->GetResetPosition(*((T*)&u), x, y, z, o);
}
public:
// Will not link if not overridden in the generators
@ -112,7 +112,7 @@ class MovementGeneratorMedium : public MovementGenerator
bool Update(T& u, const uint32& time_diff);
// not need always overwrites
bool GetResetPosition(T& /*u*/, float& /*x*/, float& /*y*/, float& /*z*/) const { return false; }
bool GetResetPosition(T& /*u*/, float& /*x*/, float& /*y*/, float& /*z*/, float& /*o*/) const { return false; }
};
struct SelectableMovement : public FactoryHolder<MovementGenerator, MovementGeneratorType>

View file

@ -102,9 +102,10 @@ class PathFinder
dtQueryFilter m_filter; // use single filter for all movements, update it when needed
void setStartPosition(const Vector3 &point) { m_startPosition = point; }
void setEndPosition(const Vector3 &point) { m_actualEndPosition = point; m_endPosition = point; }
void setActualEndPosition(const Vector3 &point) { m_actualEndPosition = point; }
void setStartPosition(const Vector3& point) { m_startPosition = point; }
void setEndPosition(const Vector3& point) { m_actualEndPosition = point; m_endPosition = point; }
void setActualEndPosition(const Vector3& point) { m_actualEndPosition = point; }
void clear()
{

View file

@ -317,11 +317,11 @@ void FollowMovementGenerator<T>::Reset(T& owner)
// This factor defines how much of the bounding-radius (as measurement of size) will be used for recalculating a new following position
// The smaller, the more micro movement, the bigger, possibly no proper movement updates
#define FOLLOW_RECALCULATE_FACTOR 0.1f
#define FOLLOW_RECALCULATE_FACTOR 1.0f
// This factor defines when the distance of a follower will have impact onto following-position updates
#define FOLLOW_DIST_GAP_FOR_DIST_FACTOR 3.0f
// This factor defines how much of the follow-distance will be used as sloppyness value (if the above distance is exceeded)
#define FOLLOW_DIST_RECALCULATE_FACTOR 0.1f
#define FOLLOW_DIST_RECALCULATE_FACTOR 1.0f
template<class T>
float FollowMovementGenerator<T>::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const

View file

@ -38,40 +38,35 @@
#include <cassert>
//-----------------------------------------------//
void WaypointMovementGenerator<Creature>::LoadPath(Creature& creature)
void WaypointMovementGenerator<Creature>::LoadPath(Creature& creature, int32 pathId, WaypointPathOrigin wpOrigin, uint32 overwriteEntry)
{
DETAIL_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "LoadPath: loading waypoint path for %s", creature.GetGuidStr().c_str());
i_path = sWaypointMgr.GetPath(creature.GetGUIDLow());
if (!overwriteEntry)
overwriteEntry = creature.GetEntry();
// We may LoadPath() for several occasions:
if (wpOrigin == PATH_NO_PATH && pathId == 0)
i_path = sWaypointMgr.GetDefaultPath(overwriteEntry, creature.GetGUIDLow(), &m_PathOrigin);
else
{
m_PathOrigin = wpOrigin == PATH_NO_PATH ? PATH_FROM_ENTRY : wpOrigin;
i_path = sWaypointMgr.GetPathFromOrigin(overwriteEntry, creature.GetGUIDLow(), pathId, m_PathOrigin);
}
m_pathId = pathId;
// 1: When creature.MovementType=2
// 1a) Path is selected by creature.guid == creature_movement.id
// 1b) Path for 1a) does not exist and then use path from creature.GetEntry() == creature_movement_template.entry
// 2: When creature_template.MovementType=2
// 2a) Creature is summoned and has creature_template.MovementType=2
// Creators need to be sure that creature_movement_template is always valid for summons.
// Mob that can be summoned anywhere should not have creature_movement_template for example.
// No movement found for guid
// No movement found for entry nor guid
if (!i_path)
{
i_path = sWaypointMgr.GetPathTemplate(creature.GetEntry());
// No movement found for entry
if (!i_path)
{
sLog.outErrorDb("WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path",
creature.GetName(), creature.GetEntry(), creature.GetGUIDLow());
if (m_PathOrigin == PATH_FROM_EXTERNAL)
sLog.outErrorScriptLib("WaypointMovementGenerator::LoadPath: %s doesn't have waypoint path %i", creature.GetGuidStr().c_str(), pathId);
else
sLog.outErrorDb("WaypointMovementGenerator::LoadPath: %s doesn't have waypoint path %i", creature.GetGuidStr().c_str(), pathId);
return;
}
}
// Initialize the i_currentNode to point to the first node
if (i_path->empty())
return;
// Initialize the i_currentNode to point to the first node
i_currentNode = i_path->begin()->first;
m_lastReachedWaypoint = 0;
}
@ -80,10 +75,6 @@ void WaypointMovementGenerator<Creature>::Initialize(Creature& creature)
{
creature.addUnitState(UNIT_STAT_ROAMING);
creature.clearUnitState(UNIT_STAT_WAYPOINT_PAUSED);
LoadPath(creature);
StartMoveNow(creature);
}
void WaypointMovementGenerator<Creature>::Finalize(Creature& creature)
@ -158,23 +149,16 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
}
if (MangosStringLocale const* textData = sObjectMgr.GetMangosStringLocale(textId))
creature.MonsterText(textData, nullptr);
creature.MonsterText(textData, NULL);
else
sLog.outErrorDb("%s reached waypoint %u, attempted to do text %i, but required text-data could not be found", creature.GetGuidStr().c_str(), i_currentNode, textId);
}
}
// Inform script
MovementInform(creature);
Stop(node.delay);
}
void WaypointMovementGenerator<Creature>::StartMoveNow(Creature& creature)
{
i_nextMoveTime.Reset(0);
StartMove(creature);
}
void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
{
if (!i_path || i_path->empty())
@ -254,13 +238,7 @@ bool WaypointMovementGenerator<Creature>::Update(Creature& creature, const uint3
return true;
}
void WaypointMovementGenerator<Creature>::MovementInform(Creature& creature)
{
if (creature.AI())
creature.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode);
}
bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x, float& y, float& z) const
bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x, float& y, float& z, float& o) const
{
// prevent a crash at empty waypoint path.
if (!i_path || i_path->empty())
@ -273,7 +251,32 @@ bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x,
MANGOS_ASSERT(lastPoint != i_path->end());
x = lastPoint->second.x; y = lastPoint->second.y; z = lastPoint->second.z;
WaypointNode const* curWP = &(lastPoint->second);
x = curWP->x;
y = curWP->y;
z = curWP->z;
if (curWP->orientation != 100)
o = curWP->orientation;
else // Calculate the resulting angle based on positions between previous and current waypoint
{
WaypointNode const* prevWP;
if (lastPoint != i_path->begin()) // Not the first waypoint
{
--lastPoint;
prevWP = &(lastPoint->second);
}
else // Take the last waypoint (crbegin()) as previous
prevWP = &(i_path->rbegin()->second);
float dx = x - prevWP->x;
float dy = y - prevWP->y;
o = atan2(dy, dx); // returns value between -Pi..Pi
o = (o >= 0) ? o : 2 * M_PI_F + o;
}
return true;
}
@ -418,9 +421,12 @@ void FlightPathMovementGenerator::DoEventIfAny(Player& player, TaxiPathNodeEntry
}
}
bool FlightPathMovementGenerator::GetResetPosition(Player&, float& x, float& y, float& z) const
bool FlightPathMovementGenerator::GetResetPosition(Player&, float& x, float& y, float& z, float& o) const
{
const TaxiPathNodeEntry& node = (*i_path)[i_currentNode];
x = node.x; y = node.y; z = node.z;
x = node.x;
y = node.y;
z = node.z;
return true;
}

View file

@ -42,7 +42,7 @@
#define STOP_TIME_FOR_PLAYER (3 * MINUTE * IN_MILLISECONDS) // 3 Minutes
template<class T, class P>
class PathMovementBase
class MANGOS_DLL_SPEC PathMovementBase
{
public:
PathMovementBase() : i_currentNode(0) {}
@ -66,7 +66,7 @@ template<class T>
class WaypointMovementGenerator;
template<>
class WaypointMovementGenerator<Creature>
class MANGOS_DLL_SPEC WaypointMovementGenerator<Creature>
: public MovementGeneratorMedium< Creature, WaypointMovementGenerator<Creature> >,
public PathMovementBase<Creature, WaypointPath const*>
{
@ -78,21 +78,21 @@ class WaypointMovementGenerator<Creature>
void Finalize(Creature&);
void Reset(Creature& u);
bool Update(Creature& u, const uint32& diff);
void MovementInform(Creature&);
void InitializeWaypointPath(Creature& u, int32 id, WaypointPathOrigin wpSource, uint32 initialDelay, uint32 overwriteEntry);
MovementGeneratorType GetMovementGeneratorType() const { return WAYPOINT_MOTION_TYPE; }
// now path movement implmementation
void LoadPath(Creature& c);
bool GetResetPosition(Creature&, float& x, float& y, float& z) const;
bool GetResetPosition(Creature&, float& /*x*/, float& /*y*/, float& /*z*/, float& /*o*/) const;
uint32 getLastReachedWaypoint() const { return m_lastReachedWaypoint; }
void GetPathInformation(int32& pathId, WaypointPathOrigin& wpOrigin) const { pathId = m_pathId; wpOrigin = m_PathOrigin; }
void GetPathInformation(std::ostringstream& oss) const;
void AddToWaypointPauseTime(int32 waitTimeDiff);
uint32 getLastReachedWaypoint() const { return m_lastReachedWaypoint; }
bool SetNextWaypoint(uint32 pointId);
private:
void LoadPath(Creature& c, int32 id, WaypointPathOrigin wpOrigin, uint32 overwriteEntry);
void Stop(int32 time) { i_nextMoveTime.Reset(time); }
bool Stopped(Creature& u);
bool CanMove(int32 diff, Creature& u);
@ -100,11 +100,12 @@ class WaypointMovementGenerator<Creature>
void OnArrived(Creature&);
void StartMove(Creature&);
void StartMoveNow(Creature& creature);
ShortTimeTracker i_nextMoveTime;
bool m_isArrivalDone;
uint32 m_lastReachedWaypoint;
int32 m_pathId;
WaypointPathOrigin m_PathOrigin;
};
/** FlightPathMovementGenerator generates movement of the player for the paths
@ -133,7 +134,7 @@ class FlightPathMovementGenerator
void SetCurrentNodeAfterTeleport();
void SkipCurrentNode() { ++i_currentNode; }
void DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure);
bool GetResetPosition(Player&, float& x, float& y, float& z) const;
bool GetResetPosition(Player&, float& x, float& y, float& z, float& o) const;
};
#endif

View file

@ -147,7 +147,7 @@ AggressorAI::IsVisible(Unit* pl) const
void
AggressorAI::AttackStart(Unit* u)
{
if (!u)
if (!u || !m_creature->CanAttackByItself())
return;
if (m_creature->Attack(u, true))

View file

@ -351,8 +351,6 @@ void ArenaTeam::Disband(WorldSession* session)
void ArenaTeam::Roster(WorldSession* session)
{
Player* pl = NULL;
uint8 unk308 = 0;
WorldPacket data(SMSG_ARENA_TEAM_ROSTER, 100);
@ -363,7 +361,7 @@ void ArenaTeam::Roster(WorldSession* session)
for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
{
pl = sObjectMgr.GetPlayer(itr->guid);
Player* pl = sObjectMgr.GetPlayer(itr->guid);
data << itr->guid; // guid
data << uint8((pl ? 1 : 0)); // online flag

View file

@ -353,7 +353,7 @@ void CalendarMgr::RemoveEvent(uint64 eventId, Player* remover)
// Add invit to an event and inform client
// some check done before so it may fail and raison is sent to client
// return value is the CalendarInvite pointer on success
CalendarInvite* CalendarMgr::AddInvite(CalendarEvent* event, ObjectGuid const& senderGuid, ObjectGuid const& inviteeGuid, CalendarInviteStatus status, CalendarModerationRank rank, std::string text, time_t statusTime)
CalendarInvite* CalendarMgr::AddInvite(CalendarEvent* event, ObjectGuid const& senderGuid, ObjectGuid const& inviteeGuid, CalendarInviteStatus status, CalendarModerationRank rank, const std::string& text, time_t statusTime)
{
Player* sender = sObjectMgr.GetPlayer(senderGuid);
if (!event || !sender)
@ -481,7 +481,7 @@ void CalendarMgr::CopyEvent(uint64 eventId, time_t newTime, ObjectGuid const& gu
return;
if (newEvent->IsGuildAnnouncement())
AddInvite(newEvent, guid, guid, CALENDAR_STATUS_CONFIRMED, CALENDAR_RANK_OWNER, "", time(NULL));
AddInvite(newEvent, guid, guid, CALENDAR_STATUS_CONFIRMED, CALENDAR_RANK_OWNER, "", time(nullptr));
else
{
// copy all invitees, set new owner as the one who make the copy, set invitees status to invited
@ -490,18 +490,19 @@ void CalendarMgr::CopyEvent(uint64 eventId, time_t newTime, ObjectGuid const& gu
while (ci_itr != cInvMap->end())
{
if (ci_itr->second->InviteeGuid == guid)
const CalendarInvite* invite = ci_itr->second;
if (invite->InviteeGuid == guid)
{
AddInvite(newEvent, guid, ci_itr->second->InviteeGuid, CALENDAR_STATUS_CONFIRMED, CALENDAR_RANK_OWNER, "", time(NULL));
AddInvite(newEvent, guid, invite->InviteeGuid, CALENDAR_STATUS_CONFIRMED, CALENDAR_RANK_OWNER, "", time(nullptr));
}
else
{
CalendarModerationRank rank = CALENDAR_RANK_PLAYER;
// copy moderator rank
if (ci_itr->second->Rank == CALENDAR_RANK_MODERATOR)
if (invite->Rank == CALENDAR_RANK_MODERATOR)
rank = CALENDAR_RANK_MODERATOR;
AddInvite(newEvent, guid, ci_itr->second->InviteeGuid, CALENDAR_STATUS_INVITED, rank, "", time(NULL));
AddInvite(newEvent, guid, invite->InviteeGuid, CALENDAR_STATUS_INVITED, rank, "", time(nullptr));
}
++ci_itr;
}

View file

@ -235,7 +235,7 @@ class CalendarMgr
CalendarEvent* AddEvent(ObjectGuid const& guid, std::string title, std::string description, uint32 type, uint32 repeatable, uint32 maxInvites,
int32 dungeonId, time_t eventTime, time_t unkTime, uint32 flags);
CalendarInvite* AddInvite(CalendarEvent* event, ObjectGuid const& senderGuid, ObjectGuid const& inviteeGuid, CalendarInviteStatus status, CalendarModerationRank rank, std::string text, time_t statusTime);
CalendarInvite* AddInvite(CalendarEvent* event, ObjectGuid const& senderGuid, ObjectGuid const& inviteeGuid, CalendarInviteStatus status, CalendarModerationRank rank, const std::string& text, time_t statusTime);
void RemoveEvent(uint64 eventId, Player* remover);
bool RemoveInvite(uint64 eventId, uint64 inviteId, ObjectGuid const& removerGuid);

View file

@ -168,8 +168,7 @@ Creature::Creature(CreatureSubtype subtype) : Unit(),
m_corpseDecayTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_aggroDelay(0), m_respawnradius(5.0f),
m_subtype(subtype), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false),
m_regenHealth(true), m_AI_locked(false), m_IsDeadByDefault(false),
m_temporaryFactionFlags(TEMPFACTION_NONE),
m_AI_locked(false), m_IsDeadByDefault(false), m_temporaryFactionFlags(TEMPFACTION_NONE),
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0),
m_creatureInfo(NULL)
{
@ -252,6 +251,12 @@ void Creature::RemoveCorpse()
if (AI())
{ AI()->CorpseRemoved(respawnDelay); }
if (m_isCreatureLinkingTrigger)
GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DESPAWN, this);
if (InstanceData* mapInstance = GetInstanceData())
mapInstance->OnCreatureDespawn(this);
// script can set time (in seconds) explicit, override the original
if (respawnDelay)
{ m_respawnTime = time(NULL) + respawnDelay; }
@ -335,6 +340,24 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender);
// set PowerType based on unit class
switch (cinfo->UnitClass)
{
case CLASS_WARRIOR:
SetPowerType(POWER_RAGE);
break;
case CLASS_PALADIN:
case CLASS_MAGE:
SetPowerType(POWER_MANA);
break;
case CLASS_ROGUE:
SetPowerType(POWER_ENERGY);
break;
default:
sLog.outErrorDb("Creature (Entry: %u) has unhandled unit class. Power type will not be set!", Entry);
break;
}
// Load creature equipment
if (eventData && eventData->equipment_id)
{
@ -663,33 +686,68 @@ void Creature::RegenerateAll(uint32 update_diff)
if (!IsInCombat() || IsPolymorphed())
RegenerateHealth();
RegenerateMana();
RegeneratePower();
m_regenTimer = REGEN_TIME_FULL;
}
void Creature::RegenerateMana()
void Creature::RegeneratePower()
{
uint32 curValue = GetPower(POWER_MANA);
uint32 maxValue = GetMaxPower(POWER_MANA);
if (!IsRegeneratingPower())
return;
Powers powerType = GetPowerType();
uint32 curValue = GetPower(powerType);
uint32 maxValue = GetMaxPower(powerType);
if (curValue >= maxValue)
return;
uint32 addvalue = 0;
float addValue = 0.0f;
switch (powerType)
{
case POWER_MANA:
// Combat and any controlled creature
if (IsInCombat() || GetCharmerOrOwnerGuid())
{
float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA);
float Spirit = GetStat(STAT_SPIRIT);
addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate);
addValue = uint32(Spirit / 5.0f + 17.0f) * ManaIncreaseRate;
}
else
addvalue = maxValue / 3;
addValue = maxValue / 3.0f;
break;
case POWER_ENERGY:
// ToDo: for vehicle this is different - NEEDS TO BE FIXED!
addValue = 20 * sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_ENERGY);
break;
case POWER_FOCUS:
addValue = 24 * sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_FOCUS);
break;
default:
return;
}
ModifyPower(POWER_MANA, addvalue);
// Apply modifiers (if any)
AuraList const& ModPowerRegenAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN);
for (AuraList::const_iterator i = ModPowerRegenAuras.begin(); i != ModPowerRegenAuras.end(); ++i)
{
Modifier const* modifier = (*i)->GetModifier();
if (modifier->m_miscvalue == int32(powerType))
addValue += modifier->m_amount;
}
AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
{
Modifier const* modifier = (*i)->GetModifier();
if (modifier->m_miscvalue == int32(powerType))
addValue *= (modifier->m_amount + 100) / 100.0f;
}
ModifyPower(powerType, int32(addValue));
}
void Creature::RegenerateHealth()
@ -1313,7 +1371,7 @@ float Creature::_GetDamageMod(int32 Rank)
}
}
float Creature::GetSpellDamageMod(int32 Rank)
float Creature::_GetSpellDamageMod(int32 Rank)
{
switch (Rank) // define rates for each elite rank
{
@ -1581,7 +1639,7 @@ void Creature::SetDeathState(DeathState s)
if ((s == JUST_DIED && !m_IsDeadByDefault) || (s == JUST_ALIVED && m_IsDeadByDefault))
{
m_corpseDecayTimer = m_corpseDelay * IN_MILLISECONDS; // the max/default time for corpse decay (before creature is looted/AllLootRemovedFromCorpse() is called)
m_respawnTime = time(NULL) + m_respawnDelay; // respawn delay (spawntimesecs)
m_respawnTime = time(nullptr) + m_respawnDelay; // respawn delay (spawntimesecs)
// always save boss respawn time at death to prevent crash cheating
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY) || IsWorldBoss())
@ -1614,7 +1672,7 @@ void Creature::SetDeathState(DeathState s)
Unit::SetDeathState(ALIVE);
SetHealth(GetMaxHealth());
SetLootRecipient(NULL);
SetLootRecipient(nullptr);
if (GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_RESPAWN)
ClearTemporaryFaction();
@ -2523,6 +2581,10 @@ void Creature::SetFactionTemporary(uint32 factionId, uint32 tempFactionFlags)
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PASSIVE)
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PACIFIED)
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NOT_SELECTABLE)
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
}
void Creature::ClearTemporaryFaction()
@ -2535,13 +2597,17 @@ void Creature::ClearTemporaryFaction()
// Reset to original faction
setFaction(GetCreatureInfo()->FactionAlliance);
// Reset UNIT_FLAG_NON_ATTACKABLE, UNIT_FLAG_OOC_NOT_ATTACKABLE or UNIT_FLAG_PASSIVE flags
// Reset UNIT_FLAG_NON_ATTACKABLE, UNIT_FLAG_OOC_NOT_ATTACKABLE, UNIT_FLAG_PASSIVE, UNIT_FLAG_PACIFIED or UNIT_FLAG_NOT_SELECTABLE flags
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NON_ATTACKABLE && GetCreatureInfo()->UnitFlags & UNIT_FLAG_NON_ATTACKABLE)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_OOC_NOT_ATTACK && GetCreatureInfo()->UnitFlags & UNIT_FLAG_OOC_NOT_ATTACKABLE && !IsInCombat())
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PASSIVE && GetCreatureInfo()->UnitFlags & UNIT_FLAG_PASSIVE)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PACIFIED && GetCreatureInfo()->UnitFlags & UNIT_FLAG_PACIFIED)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NOT_SELECTABLE && GetCreatureInfo()->UnitFlags & UNIT_FLAG_NOT_SELECTABLE)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
m_temporaryFactionFlags = TEMPFACTION_NONE;
}

View file

@ -612,6 +612,8 @@ enum TemporaryFactionFlags // Used at real fact
TEMPFACTION_TOGGLE_NON_ATTACKABLE = 0x08, // Remove UNIT_FLAG_NON_ATTACKABLE(0x02) when faction is changed (reapply when temp-faction is removed)
TEMPFACTION_TOGGLE_OOC_NOT_ATTACK = 0x10, // Remove UNIT_FLAG_OOC_NOT_ATTACKABLE(0x100) when faction is changed (reapply when temp-faction is removed)
TEMPFACTION_TOGGLE_PASSIVE = 0x20, // Remove UNIT_FLAG_PASSIVE(0x200) when faction is changed (reapply when temp-faction is removed)
TEMPFACTION_TOGGLE_PACIFIED = 0x40, // Remove UNIT_FLAG_PACIFIED(0x20000) when faction is changed (reapply when temp-faction is removed)
TEMPFACTION_TOGGLE_NOT_SELECTABLE = 0x80, // Remove UNIT_FLAG_NOT_SELECTABLE(0x2000000) when faction is changed (reapply when temp-faction is removed)
TEMPFACTION_ALL,
};
@ -732,7 +734,10 @@ class Creature : public Unit
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void UpdateDamagePhysical(WeaponAttackType attType) override;
uint32 GetCurrentEquipmentId() { return m_equipmentId; }
float GetSpellDamageMod(int32 Rank);
static float _GetHealthMod(int32 Rank); ///< Get custom factor to scale health (default 1, CONFIG_FLOAT_RATE_CREATURE_*_HP)
static float _GetDamageMod(int32 Rank); ///< Get custom factor to scale damage (default 1, CONFIG_FLOAT_RATE_*_DAMAGE)
static float _GetSpellDamageMod(int32 Rank); ///< Get custom factor to scale spell damage (default 1, CONFIG_FLOAT_RATE_*_SPELLDAMAGE)
VendorItemData const* GetVendorItems() const;
VendorItemData const* GetVendorTemplateItems() const;
@ -921,9 +926,6 @@ class Creature : public Unit
void _RealtimeSetCreatureInfo();
static float _GetHealthMod(int32 Rank);
static float _GetDamageMod(int32 Rank);
uint32 m_lootMoney;
ObjectGuid m_lootRecipientGuid; // player who will have rights for looting if m_lootGroupRecipient==0 or group disbanded
uint32 m_lootGroupRecipientId; // group who will have rights for looting if set and exist
@ -937,7 +939,7 @@ class Creature : public Unit
float m_respawnradius;
CreatureSubtype m_subtype; // set in Creatures subclasses for fast it detect without dynamic_cast use
void RegenerateMana();
void RegeneratePower();
void RegenerateHealth();
MovementGeneratorType m_defaultMovementType;
Cell m_currentCell; // store current cell where creature listed
@ -946,7 +948,6 @@ class Creature : public Unit
// below fields has potential for optimization
bool m_AlreadyCallAssistance;
bool m_AlreadySearchedAssistance;
bool m_regenHealth;
bool m_AI_locked;
bool m_IsDeadByDefault;
uint32 m_temporaryFactionFlags; // used for real faction changes (not auras etc)

View file

@ -154,12 +154,13 @@ void CreatureAI::SetCombatMovement(bool enable, bool stopOrStartMovement /*=fals
void CreatureAI::HandleMovementOnAttackStart(Unit* victim)
{
MotionMaster* creatureMotion = m_creature->GetMotionMaster();
if (m_isCombatMovement)
m_creature->GetMotionMaster()->MoveChase(victim, m_attackDistance, m_attackAngle);
creatureMotion->MoveChase(victim, m_attackDistance, m_attackAngle);
// TODO - adapt this to only stop OOC-MMGens when MotionMaster rewrite is finished
else if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE || m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == RANDOM_MOTION_TYPE)
else if (creatureMotion->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE || creatureMotion->GetCurrentMovementGeneratorType() == RANDOM_MOTION_TYPE)
{
m_creature->GetMotionMaster()->MoveIdle();
creatureMotion->MoveIdle();
m_creature->StopMoving();
}
}
@ -223,10 +224,20 @@ void CreatureAI::SendAIEventAround(AIEventType eventType, Unit* pInvoker, uint32
{
std::list<Creature*> receiverList;
// Allow sending custom AI events to all units in range
if (eventType >= AI_EVENT_CUSTOM_EVENTAI_A && eventType <= AI_EVENT_CUSTOM_EVENTAI_F && eventType != AI_EVENT_GOT_CCED)
{
MaNGOS::AnyUnitInObjectRangeCheck u_check(m_creature, fRadius);
MaNGOS::CreatureListSearcher<MaNGOS::AnyUnitInObjectRangeCheck> searcher(receiverList, u_check);
Cell::VisitGridObjects(m_creature, searcher, fRadius);
}
else
{
// Use this check here to collect only assitable creatures in case of CALL_ASSISTANCE, else be less strict
MaNGOS::AnyAssistCreatureInRangeCheck u_check(m_creature, eventType == AI_EVENT_CALL_ASSISTANCE ? pInvoker : NULL, fRadius);
MaNGOS::CreatureListSearcher<MaNGOS::AnyAssistCreatureInRangeCheck> searcher(receiverList, u_check);
Cell::VisitGridObjects(m_creature, searcher, fRadius);
}
if (!receiverList.empty())
{

View file

@ -85,19 +85,23 @@ enum AIEventType
AI_EVENT_CUSTOM_EVENTAI_A = 5, // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
AI_EVENT_CUSTOM_EVENTAI_B = 6, // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
AI_EVENT_GOT_CCED = 7, // Sender = CCed Npc, Invoker = Caster that CCed
MAXIMAL_AI_EVENT_EVENTAI = 8,
AI_EVENT_CUSTOM_EVENTAI_C = 8, // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
AI_EVENT_CUSTOM_EVENTAI_D = 9, // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
AI_EVENT_CUSTOM_EVENTAI_E = 10, // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
AI_EVENT_CUSTOM_EVENTAI_F = 11, // Sender = Npc that throws custom event, Invoker = TARGET_T_ACTION_INVOKER (if exists)
MAXIMAL_AI_EVENT_EVENTAI = 12,
// Internal Use
AI_EVENT_CALL_ASSISTANCE = 10, // Sender = Attacked Npc, Invoker = Enemy
AI_EVENT_CALL_ASSISTANCE = 13, // Sender = Attacked Npc, Invoker = Enemy
// Predefined for SD3
// Predefined for SD2
AI_EVENT_START_ESCORT = 100, // Invoker = Escorting Player
AI_EVENT_START_ESCORT_B = 101, // Invoker = Escorting Player
AI_EVENT_START_EVENT = 102, // Invoker = EventStarter
AI_EVENT_START_EVENT_A = 103, // Invoker = EventStarter
AI_EVENT_START_EVENT_B = 104, // Invoker = EventStarter
// Some IDs for special cases in SD3
// Some IDs for special cases in SD2
AI_EVENT_CUSTOM_A = 1000,
AI_EVENT_CUSTOM_B = 1001,
AI_EVENT_CUSTOM_C = 1002,

View file

@ -91,16 +91,21 @@ inline bool IsEventFlagsFitForNormalMap(uint8 eFlags)
CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
m_Phase(0),
m_MeleeEnabled(true),
m_DynamicMovement(false),
m_HasOOCLoSEvent(false),
m_InvinceabilityHpLevel(0),
m_throwAIEventMask(0),
m_throwAIEventStep(0)
m_throwAIEventStep(0),
m_LastSpellMaxRange(0)
{
// Need make copy for filter unneeded steps and safe in case table reload
CreatureEventAI_Event_Map::const_iterator creatureEventsItr = sEventAIMgr.GetCreatureEventAIMap().find(m_creature->GetEntry());
if (creatureEventsItr != sEventAIMgr.GetCreatureEventAIMap().end())
{
uint32 events_count = 0;
for (CreatureEventAI_Event_Vec::const_iterator i = creatureEventsItr->second.begin(); i != creatureEventsItr->second.end(); ++i)
const CreatureEventAI_Event_Vec& creatureEvent = creatureEventsItr->second;
for (CreatureEventAI_Event_Vec::const_iterator i = creatureEvent.begin(); i != creatureEvent.end(); ++i)
{
// Debug check
#ifndef MANGOS_DEBUG
@ -119,27 +124,33 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
}
// EventMap had events but they were not added because they must be for instance
if (events_count == 0)
sLog.outErrorEventAI("Creature %u has events but no events added to list because of instance flags.", m_creature->GetEntry());
sLog.outErrorEventAI("Creature %u has events but no events added to list because of instance flags (spawned in map %u, difficulty %u).", m_creature->GetEntry(), m_creature->GetMapId(), m_creature->GetMap()->GetDifficulty());
else
{
m_CreatureEventAIList.reserve(events_count);
for (CreatureEventAI_Event_Vec::const_iterator i = creatureEventsItr->second.begin(); i != creatureEventsItr->second.end(); ++i)
for (CreatureEventAI_Event_Vec::const_iterator i = creatureEvent.begin(); i != creatureEvent.end(); ++i)
{
// Debug check
#ifndef MANGOS_DEBUG
if (i->event_flags & EFLAG_DEBUG_ONLY)
continue;
#endif
bool storeEvent = false;
if (m_creature->GetMap()->IsDungeon())
{
if ((1 << (m_creature->GetMap()->GetSpawnMode() + 1)) & i->event_flags)
{
// event flagged for instance mode
m_CreatureEventAIList.push_back(CreatureEventAIHolder(*i));
}
storeEvent = true;
}
else if (IsEventFlagsFitForNormalMap(i->event_flags))
storeEvent = true;
if (storeEvent)
{
m_CreatureEventAIList.push_back(CreatureEventAIHolder(*i));
// Cache for fast use
if (i->event_type == EVENT_T_OOC_LOS)
m_HasOOCLoSEvent = true;
}
}
}
}
@ -1191,7 +1202,7 @@ void CreatureEventAI::EnterCombat(Unit* enemy)
void CreatureEventAI::AttackStart(Unit* who)
{
if (!who)
if (!who || !m_creature->CanAttackByItself())
return;
if (m_creature->Attack(who, m_MeleeEnabled))

View file

@ -689,6 +689,7 @@ class CreatureEventAI : public CreatureAI
// Note that Step 100 means that AI_EVENT_GOT_FULL_HEALTH was sent
// Steps 0..2 correspond to AI_EVENT_LOST_SOME_HEALTH(90%), AI_EVENT_LOST_HEALTH(50%), AI_EVENT_CRITICAL_HEALTH(10%)
uint32 m_throwAIEventStep; // Used for damage taken/ received heal
float m_LastSpellMaxRange; // Maximum spell range that was cast during dynamic movement
};
#endif

View file

@ -140,7 +140,7 @@ void GameObject::RemoveFromWorld()
Object::RemoveFromWorld();
}
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, QuaternionData rotation, uint8 animprogress, GOState go_state)
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, const QuaternionData& rotation, uint8 animprogress, GOState go_state)
{
MANGOS_ASSERT(map);
Relocate(x, y, z, ang);
@ -1134,8 +1134,8 @@ void GameObject::Use(Unit* user)
// Some may have have animation and/or are expected to despawn.
// TODO: Improve this when more information is available, currently these traps are known that must send the anim (Onyxia/ Heigan Fissures/ Trap in DireMaul)
if (GetDisplayId() == 4392 || GetDisplayId() == 4472 || GetDisplayId() == 6785 || GetDisplayId() == 3073)
{ SendGameObjectCustomAnim(GetObjectGuid()); }
if (GetDisplayId() == 4392 || GetDisplayId() == 4472 || GetDisplayId() == 4491 || GetDisplayId() == 6785 || GetDisplayId() == 3073 || GetDisplayId() == 7998)
SendGameObjectCustomAnim(GetObjectGuid());
// TODO: Despawning of traps? (Also related to code in ::Update)
return;
@ -1733,7 +1733,7 @@ void GameObject::SetWorldRotation(float qx, float qy, float qz, float qw)
m_worldRotation.w = rotation.w;
}
void GameObject::SetTransportPathRotation(QuaternionData rotation)
void GameObject::SetTransportPathRotation(const QuaternionData& rotation)
{
SetFloatValue(GAMEOBJECT_PARENTROTATION + 0, rotation.x);
SetFloatValue(GAMEOBJECT_PARENTROTATION + 1, rotation.y);

View file

@ -647,9 +647,8 @@ class GameObject : public WorldObject
void AddToWorld() override;
void RemoveFromWorld() override;
bool Create(uint32 guidlow, uint32 name_id, Map* map, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state);
bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang,
QuaternionData rotation = QuaternionData(), uint8 animprogress = GO_ANIMPROGRESS_DEFAULT, GOState go_state = GO_STATE_READY);
const QuaternionData& rotation = QuaternionData(), uint8 animprogress = GO_ANIMPROGRESS_DEFAULT, GOState go_state = GO_STATE_READY);
void Update(uint32 update_diff, uint32 p_time) override;
GameObjectInfo const* GetGOInfo() const;
@ -660,7 +659,7 @@ class GameObject : public WorldObject
// z_rot, y_rot, x_rot - rotation angles around z, y and x axes
void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot);
void SetWorldRotation(float qx, float qy, float qz, float qw);
void SetTransportPathRotation(QuaternionData rotation); // transforms(rotates) transport's path
void SetTransportPathRotation(const QuaternionData& rotation); // transforms(rotates) transport's path
int64 GetPackedWorldRotation() const { return m_packedRotation; }
// overwrite WorldObject function for proper name localization

View file

@ -122,7 +122,7 @@ bool Guild::Create(Player* leader, std::string gname)
m_LeaderGuid = leader->GetObjectGuid();
m_Name = gname;
GINFO = "";
GINFO.clear();
MOTD = "No message set.";
m_GuildBankMoney = 0;
m_Id = sObjectMgr.GenerateGuildId();
@ -319,8 +319,11 @@ bool Guild::CheckGuildStructure()
// Allow only 1 guildmaster, set other to officer
for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
if (itr->second.RankId == GR_GUILDMASTER && m_LeaderGuid != itr->second.guid)
itr->second.ChangeRank(GR_OFFICER);
{
MemberSlot& member = itr->second;
if (member.RankId == GR_GUILDMASTER && m_LeaderGuid != member.guid)
member.ChangeRank(GR_OFFICER);
}
return true;
}
@ -580,19 +583,23 @@ bool Guild::ChangeMemberRank(ObjectGuid guid, uint8 newRank)
void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint32 language)
{
if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(), GR_RIGHT_GCHATSPEAK))
{
if (!session)
return;
Player* player = session->GetPlayer();
if (!player || !HasRankRight(player->GetRank(), GR_RIGHT_GCHATSPEAK))
return;
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_GUILD, msg.c_str(), Language(language), session->GetPlayer()->GetChatTag(), session->GetPlayer()->GetObjectGuid(), session->GetPlayer()->GetName());
ChatHandler::BuildChatPacket(data, CHAT_MSG_GUILD, msg.c_str(), Language(language), player->GetChatTag(), player->GetObjectGuid(), player->GetName());
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
{
Player* pl = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetObjectGuid()))
if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(player->GetObjectGuid()))
pl->GetSession()->SendPacket(&data);
}
}
}
void Guild::BroadcastAddonToGuild(WorldSession* session, const std::string& msg, const std::string& prefix)
@ -690,12 +697,12 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max
return;
}
MemberSlot const* member = &itr->second;
uint32 level = Player::GetLevelFromDB(member->guid);
MemberSlot const& member = itr->second;
uint32 level = Player::GetLevelFromDB(member.guid);
if (member->guid != session->GetPlayer()->GetObjectGuid() && level >= minLevel && level <= maxLevel && member->RankId <= minRank)
if (member.guid != session->GetPlayer()->GetObjectGuid() && level >= minLevel && level <= maxLevel && member.RankId <= minRank)
{
data << member->guid.WriteAsPacked();
data << member.guid.WriteAsPacked();
data << uint8(level);
++count;
}
@ -1521,21 +1528,22 @@ uint32 Guild::GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId)
if (itr == members.end())
return 0;
if (itr->second.RankId == GR_GUILDMASTER)
MemberSlot& member = itr->second;
if (member.RankId == GR_GUILDMASTER)
return WITHDRAW_SLOT_UNLIMITED;
if ((GetBankRights(itr->second.RankId, TabId) & GUILD_BANK_RIGHT_VIEW_TAB) != GUILD_BANK_RIGHT_VIEW_TAB)
if ((GetBankRights(member.RankId, TabId) & GUILD_BANK_RIGHT_VIEW_TAB) != GUILD_BANK_RIGHT_VIEW_TAB)
return 0;
uint32 curTime = uint32(time(NULL) / MINUTE);
if (curTime - itr->second.BankResetTimeTab[TabId] >= 24 * HOUR / MINUTE)
uint32 curTime = uint32(time(nullptr) / MINUTE);
if (curTime - member.BankResetTimeTab[TabId] >= 24 * HOUR / MINUTE)
{
itr->second.BankResetTimeTab[TabId] = curTime;
itr->second.BankRemSlotsTab[TabId] = GetBankSlotPerDay(itr->second.RankId, TabId);
member.BankResetTimeTab[TabId] = curTime;
member.BankRemSlotsTab[TabId] = GetBankSlotPerDay(member.RankId, TabId);
CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeTab%u='%u', BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'",
uint32(TabId), itr->second.BankResetTimeTab[TabId], uint32(TabId), itr->second.BankRemSlotsTab[TabId], m_Id, LowGuid);
uint32(TabId), member.BankResetTimeTab[TabId], uint32(TabId), member.BankRemSlotsTab[TabId], m_Id, LowGuid);
}
return itr->second.BankRemSlotsTab[TabId];
return member.BankRemSlotsTab[TabId];
}
uint64 Guild::GetMemberMoneyWithdrawRem(uint32 LowGuid)
@ -1544,19 +1552,20 @@ uint64 Guild::GetMemberMoneyWithdrawRem(uint32 LowGuid)
if (itr == members.end())
return 0;
if (itr->second.RankId == GR_GUILDMASTER)
MemberSlot& member = itr->second;
if (member.RankId == GR_GUILDMASTER)
return WITHDRAW_MONEY_UNLIMITED;
uint32 curTime = uint32(time(NULL) / MINUTE); // minutes
uint32 curTime = uint32(time(nullptr) / MINUTE); // minutes
// 24 hours
if (curTime > itr->second.BankResetTimeMoney + 24 * HOUR / MINUTE)
if (curTime > member.BankResetTimeMoney + 24 * HOUR / MINUTE)
{
itr->second.BankResetTimeMoney = curTime;
itr->second.BankRemMoney = GetBankMoneyPerDay(itr->second.RankId);
member.BankResetTimeMoney = curTime;
member.BankRemMoney = GetBankMoneyPerDay(member.RankId);
CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='%u', BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'",
itr->second.BankResetTimeMoney, itr->second.BankRemMoney, m_Id, LowGuid);
member.BankResetTimeMoney, member.BankRemMoney, m_Id, LowGuid);
}
return itr->second.BankRemMoney;
return member.BankRemMoney;
}
void Guild::SetBankMoneyPerDay(uint32 rankId, uint32 money)
@ -1570,8 +1579,11 @@ void Guild::SetBankMoneyPerDay(uint32 rankId, uint32 money)
m_Ranks[rankId].BankMoneyPerDay = money;
for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
if (itr->second.RankId == rankId)
itr->second.BankResetTimeMoney = 0;
{
MemberSlot& member = itr->second;
if (member.RankId == rankId)
member.BankResetTimeMoney = 0;
}
CharacterDatabase.PExecute("UPDATE guild_rank SET BankMoneyPerDay='%u' WHERE rid='%u' AND guildid='%u'", money, rankId, m_Id);
CharacterDatabase.PExecute("UPDATE guild_member SET BankResetTimeMoney='0' WHERE guildid='%u' AND rank='%u'", m_Id, rankId);
@ -2401,10 +2413,9 @@ void Guild::MoveFromBankToChar(Player* pl, uint8 BankTab, uint8 BankTabSlot, uin
{
pl->MoveItemFromInventory(PlayerBag, PlayerSlot, true);
pItemChar->DeleteFromInventoryDB();
StoreItem(BankTab, gDest, pItemChar);
}
if (pItemChar)
StoreItem(BankTab, gDest, pItemChar);
pl->MoveItemToInventory(iDest, pItemBank, true);
pl->SaveInventoryAndGoldToDB();

View file

@ -130,7 +130,8 @@ uint32 GetItemEnchantMod(int32 entry)
double dRoll = rand_chance();
float fCount = 0;
for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
const EnchStoreList& enchantList = tab->second;
for (EnchStoreList::const_iterator ench_iter = enchantList.begin(); ench_iter != enchantList.end(); ++ench_iter)
{
fCount += ench_iter->chance;
@ -141,7 +142,7 @@ uint32 GetItemEnchantMod(int32 entry)
dRoll = (irand(0, (int)floor(fCount * 100) + 1)) / 100;
fCount = 0;
for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
for (EnchStoreList::const_iterator ench_iter = enchantList.begin(); ench_iter != enchantList.end(); ++ench_iter)
{
fCount += ench_iter->chance;

View file

@ -1592,7 +1592,7 @@ namespace MaNGOS
: i_object(obj), i_msgtype(msgtype), i_textData(textData), i_language(language), i_target(target) {}
void operator()(WorldPacket& data, int32 loc_idx)
{
char const* text = nullptr;
char const* text = NULL;
if ((int32)i_textData->Content.size() > loc_idx + 1 && !i_textData->Content[loc_idx + 1].empty())
text = i_textData->Content[loc_idx + 1].c_str();
else

View file

@ -39,13 +39,15 @@
#define CONTACT_DISTANCE 0.5f
#define INTERACTION_DISTANCE 5.0f
#define ATTACK_DISTANCE 5.0f
#define INSPECT_DISTANCE 28.0f
#define TRADE_DISTANCE 11.11f
#define MAX_VISIBILITY_DISTANCE 333.0f // max distance for visible object show, limited in 333 yards
#define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents
#define DEFAULT_VISIBILITY_INSTANCE 120.0f // default visible distance in instances, 120 yards
#define DEFAULT_VISIBILITY_BGARENAS 180.0f // default visible distance in BG/Arenas, 180 yards
#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // currently used (correctly?) for any non Unit world objects. This is actually the bounding_radius, like player/creature from creature_model_data
#define DEFAULT_OBJECT_SCALE 1.0f // player/item Scale as default, npc/go from database, pets from dbc
#define DEFAULT_OBJECT_SCALE 1.0f // player/item scale as default, npc/go from database, pets from dbc
#define MAX_STEALTH_DETECT_RANGE 45.0f
@ -601,8 +603,8 @@ class WorldObject : public Object
virtual void SendMessageToSetInRange(WorldPacket* data, float dist, bool self) const;
void SendMessageToSetExcept(WorldPacket* data, Player const* skipped_receiver) const;
void MonsterSay(const char* text, uint32 language, Unit const* target = nullptr) const;
void MonsterYell(const char* text, uint32 language, Unit const* target = nullptr) const;
void MonsterSay(const char* text, uint32 language, Unit const* target = NULL) const;
void MonsterYell(const char* text, uint32 language, Unit const* target = NULL) const;
void MonsterTextEmote(const char* text, Unit const* target, bool IsBossEmote = false) const;
void MonsterWhisper(const char* text, Unit const* target, bool IsBossWhisper = false) const;
void MonsterText(MangosStringLocale const* textData, Unit const* target) const;

View file

@ -53,7 +53,9 @@
#include "InstanceData.h"
#include "DB2Structure.h"
#include "DB2Stores.h"
#include "PhaseMgr.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include <limits>
@ -192,15 +194,6 @@ ObjectMgr::~ObjectMgr()
for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr)
itr->second.Clear();
for (PhaseDefinitionStore::iterator itr = _PhaseDefinitionStore.begin(); itr != _PhaseDefinitionStore.end(); ++itr)
{
for (PhaseDefinitionContainer::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
delete *itr2;
}
for (SpellPhaseStore::iterator itr = _SpellPhaseStore.begin(); itr != _SpellPhaseStore.end(); ++itr)
delete itr->second;
}
Group* ObjectMgr::GetGroupById(uint32 id) const
@ -984,14 +977,14 @@ void ObjectMgr::LoadCreatureClassLvlStats()
CreatureClassLvlStats const* ObjectMgr::GetCreatureClassLvlStats(uint32 level, uint32 unitClass, int32 expansion) const
{
if (expansion < 0)
return nullptr;
return NULL;
CreatureClassLvlStats const* cCLS = &m_creatureClassLvlStats[level][classToIndex[unitClass]][expansion];
if (cCLS->BaseHealth != 0 && cCLS->BaseDamage > 0.1f)
return cCLS;
return nullptr;
return NULL;
}
void ObjectMgr::LoadEquipmentTemplates()
@ -5091,19 +5084,17 @@ void ObjectMgr::LoadGossipText()
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u npc texts", count);
sLog.outString();
return;
}
int cic;
BarGoLink bar(result->GetRowCount());
do
{
++count;
cic = 0;
int cic = 0;
Field* fields = result->Fetch();
@ -5135,8 +5126,8 @@ void ObjectMgr::LoadGossipText()
}
while (result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u npc texts", count);
sLog.outString();
delete result;
}
@ -7354,12 +7345,16 @@ void ObjectMgr::LoadNPCSpellClickSpells()
continue;
}
// spell can be 0 for special or custom cases
if (info.spellId)
{
SpellEntry const* spellinfo = sSpellStore.LookupEntry(info.spellId);
if (!spellinfo)
{
sLog.outErrorDb("Table npc_spellclick_spells references unknown spellid %u. Skipping entry.", info.spellId);
continue;
}
}
if (info.conditionId && !sConditionStorage.LookupEntry<PlayerCondition const*>(info.conditionId))
{
@ -7704,7 +7699,7 @@ static LanguageType GetRealmLanguageType(bool create)
}
}
bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create = false)
bool isValidString(const std::wstring& wstr, uint32 strictMask, bool numericOrSpace, bool create = false)
{
if (strictMask == 0) // any language, ignore realm
{
@ -8159,8 +8154,7 @@ bool ObjectMgr::IsPlayerMeetToCondition(uint16 conditionId, Player const* pPlaye
return false;
}
bool ObjectMgr::CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names)
bool ObjectMgr::CheckDeclinedNames(const std::wstring& mainpart, DeclinedName const& names)
{
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{
@ -8490,6 +8484,16 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co
case 3: // Creature source is dead
return !source || source->GetTypeId() != TYPEID_UNIT || !((Unit*)source)->IsAlive();
}
case CONDITION_CREATURE_IN_RANGE:
{
Creature* creature = NULL;
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck creature_check(*player, m_value1, true, false, m_value2, true);
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(creature, creature_check);
Cell::VisitGridObjects(player, searcher, m_value2);
return creature;
}
default:
return false;
}
@ -8945,6 +8949,19 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu
}
break;
}
case CONDITION_CREATURE_IN_RANGE:
{
if (!sCreatureStorage.LookupEntry<CreatureInfo> (value1))
{
sLog.outErrorDb("Creature in range condition (entry %u, type %u) has an invalid value in value1. (Creature %u does not exist in the database), skipping.", entry, condition, value1);
return false;
}
if (value2 <= 0)
{
sLog.outErrorDb("Creature in range condition (entry %u, type %u) has an invalid value in value2. (Range %u must be greater than 0), skipping.", entry, condition, value2);
return false;
}
}
case CONDITION_NONE:
break;
default:
@ -10422,117 +10439,6 @@ bool DoDisplayText(WorldObject* source, int32 entry, Unit const* target /*=NULL*
return true;
}
void ObjectMgr::LoadPhaseDefinitions()
{
for (PhaseDefinitionStore::iterator itr = _PhaseDefinitionStore.begin(); itr != _PhaseDefinitionStore.end(); ++itr)
{
for (PhaseDefinitionContainer::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
delete *itr2;
}
_PhaseDefinitionStore.clear();
// 0 1 2 3 4 5 6
QueryResult* result = WorldDatabase.Query("SELECT zoneId, entry, phasemask, phaseId, terrainswapmap, flags, condition_id FROM `phase_definitions` ORDER BY `entry` ASC");
if (!result)
{
sLog.outString(">> Loaded 0 phasing definitions. DB table `phase_definitions` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
PhaseDefinition* phaseDefinition = new PhaseDefinition();
phaseDefinition->zoneId = fields[0].GetUInt32();
phaseDefinition->entry = fields[1].GetUInt32();
phaseDefinition->phasemask = fields[2].GetUInt32();
phaseDefinition->phaseId = fields[3].GetUInt32();
phaseDefinition->terrainswapmap = fields[4].GetUInt32();
phaseDefinition->flags = fields[5].GetUInt32();
phaseDefinition->conditionId = fields[6].GetUInt16();
// Checks
if ((phaseDefinition->flags & PHASE_FLAG_OVERWRITE_EXISTING) && (phaseDefinition->flags & PHASE_FLAG_NEGATE_PHASE))
{
sLog.outError("Flags defined in phase_definitions in zoneId %d and entry %u does contain PHASE_FLAG_OVERWRITE_EXISTING and PHASE_FLAG_NEGATE_PHASE. Setting flags to PHASE_FLAG_OVERWRITE_EXISTING", phaseDefinition->zoneId, phaseDefinition->entry);
phaseDefinition->flags &= ~PHASE_FLAG_NEGATE_PHASE;
}
if (!sConditionStorage.LookupEntry<PlayerCondition>(phaseDefinition->conditionId))
{
sLog.outError("Condition id defined in phase_definitions in zoneId %d and entry %u does not exists. Skipping condition.", phaseDefinition->zoneId, phaseDefinition->entry);
phaseDefinition->conditionId = 0;
}
_PhaseDefinitionStore[phaseDefinition->zoneId].push_back(phaseDefinition);
++count;
}
while (result->NextRow());
delete result;
sLog.outString(">> Loaded %u phasing definitions.", count);
}
void ObjectMgr::LoadSpellPhaseInfo()
{
for (SpellPhaseStore::iterator itr = _SpellPhaseStore.begin(); itr != _SpellPhaseStore.end(); ++itr)
delete itr->second;
_SpellPhaseStore.clear();
// 0 1 2
QueryResult* result = WorldDatabase.Query("SELECT id, phasemask, terrainswapmap FROM `spell_phase`");
if (!result)
{
sLog.outString(">> Loaded 0 spell dbc infos. DB table `spell_phase` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
SpellPhaseInfo* spellPhaseInfo = new SpellPhaseInfo();
spellPhaseInfo->spellId = fields[0].GetUInt32();
SpellEntry const* spell = sSpellStore.LookupEntry(spellPhaseInfo->spellId);
if (!spell)
{
sLog.outError("Spell %u defined in `spell_phase` does not exists, skipped.", spellPhaseInfo->spellId);
delete spellPhaseInfo;
continue;
}
if (!IsSpellHaveAura(spell, SPELL_AURA_PHASE) && !IsSpellHaveAura(spell, SPELL_AURA_PHASE_2))
{
sLog.outError("Spell %u defined in `spell_phase` does not have aura effect type SPELL_AURA_PHASE or SPELL_AURA_PHASE_2, useless value.", spellPhaseInfo->spellId);
delete spellPhaseInfo;
continue;
}
spellPhaseInfo->phasemask = fields[1].GetUInt32();
spellPhaseInfo->terrainswapmap = fields[2].GetUInt32();
_SpellPhaseStore[spellPhaseInfo->spellId] = spellPhaseInfo;
++count;
}
while (result->NextRow());
delete result;
sLog.outString(">> Loaded %u spell phase dbc infos.", count);
}
CreatureDataPair const* FindCreatureData::GetResult() const
{
if (i_spawnedData)

View file

@ -448,6 +448,7 @@ enum ConditionType
CONDITION_GENDER = 35, // 0=male, 1=female, 2=none (see enum Gender)
CONDITION_DEAD_OR_AWAY = 36, // value1: 0=player dead, 1=player is dead (with group dead), 2=player in instance are dead, 3=creature is dead
// value2: if != 0 only consider players in range of this value
CONDITION_CREATURE_IN_RANGE = 37, // value1: creature entry; value2: range; returns only alive creatures
};
enum ConditionSource // From where was the condition called?
@ -462,7 +463,6 @@ enum ConditionSource // From where was th
CONDITION_FROM_SPELL_AREA = 7, // Used to check a condition from spell_area table
CONDITION_FROM_SPELLCLICK = 8, // Used to check a condition from npc_spellclick_spells table
CONDITION_FROM_DBSCRIPTS = 9, // Used to check a condition from DB Scripts Engine
CONDITION_FROM_PHASEMGR = 10, // Used to check a condition from phase manager
};
class PlayerCondition
@ -1041,7 +1041,7 @@ class ObjectMgr
static PetNameInvalidReason CheckPetName(const std::string& name);
static bool IsValidCharterName(const std::string& name);
static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names);
static bool CheckDeclinedNames(const std::wstring& mainpart, DeclinedName const& names);
int GetIndexForLocale(LocaleConstant loc);
LocaleConstant GetLocaleForIndex(int i);
@ -1192,11 +1192,11 @@ class ObjectMgr
uint32 GetModelForRace(uint32 sourceModelId, uint32 racemask);
/**
* \brief: Data returned is used to compute health, mana, armor, damage of creatures. May be nullptr.
* \brief: Data returned is used to compute health, mana, armor, damage of creatures. May be NULL.
* \param uint32 level creature level
* \param uint32 unitClass creature class, related to CLASSMASK_ALL_CREATURES
* \param uint32 expansion creature expansion (we could have creature exp = 0 for wotlk as well as exp = 1 or exp = 2)
* \return: CreatureClassLvlStats const* or nullptr
* \return: CreatureClassLvlStats const* or NULL
*
* Description: GetCreatureClassLvlStats give fast access to creature stats data.
* FullName: ObjectMgr::GetCreatureClassLvlStats

View file

@ -227,7 +227,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
m_charmInfo->SetReactState(ReactStates(fields[6].GetUInt8()));
uint32 savedhealth = fields[10].GetUInt32();
uint32 savedmana = fields[11].GetUInt32();
uint32 savedpower = fields[11].GetUInt32();
// set current pet as current
// 0=current
@ -274,17 +274,20 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
{
LearnPetPassives();
CastPetAuras(current);
CastOwnerTalentAuras();
}
Powers powerType = GetPowerType();
if (getPetType() == SUMMON_PET && !current) // all (?) summon pets come with full health when called, but not when they are current
{
SetHealth(GetMaxHealth());
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
SetPower(powerType, GetMaxPower(powerType));
}
else
{
SetHealth(savedhealth > GetMaxHealth() ? GetMaxHealth() : savedhealth);
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
SetPower(powerType, savedpower > GetMaxPower(powerType) ? GetMaxPower(powerType) : savedpower);
}
AIM_Initialize();
@ -369,7 +372,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
}
uint32 curhealth = GetHealth();
uint32 curmana = GetPower(POWER_MANA);
uint32 curpower = GetPower(GetPowerType());
// stable and not in slot saves
if (mode != PET_SAVE_AS_CURRENT)
@ -423,7 +426,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
savePet.addString(m_name);
savePet.addUInt32(uint32(HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) ? 0 : 1));
savePet.addUInt32((curhealth < 1 ? 1 : curhealth));
savePet.addUInt32(curmana);
savePet.addUInt32(curpower);
std::ostringstream ss;
for (uint32 i = ACTION_BAR_INDEX_START; i < ACTION_BAR_INDEX_END; ++i)
@ -565,20 +568,10 @@ void Pet::RegenerateAll(uint32 update_diff)
// regenerate focus for hunter pets or energy for deathknight's ghoul
if (m_regenTimer <= update_diff)
{
switch (GetPowerType())
{
case POWER_FOCUS:
case POWER_ENERGY:
Regenerate(GetPowerType());
break;
default:
break;
}
if (!IsInCombat() || IsPolymorphed())
RegenerateHealth();
RegenerateMana();
RegeneratePower();
m_regenTimer = 4000;
}
@ -586,43 +579,6 @@ void Pet::RegenerateAll(uint32 update_diff)
m_regenTimer -= update_diff;
}
void Pet::Regenerate(Powers power)
{
uint32 curValue = GetPower(power);
uint32 maxValue = GetMaxPower(power);
if (curValue >= maxValue)
return;
float addvalue = 0.0f;
switch (power)
{
case POWER_FOCUS:
{
// For hunter pets.
addvalue = 24 * sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_FOCUS);
break;
}
case POWER_ENERGY:
{
// For deathknight's ghoul.
addvalue = 20;
break;
}
default:
return;
}
// Apply modifiers (if any).
AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
if ((*i)->GetModifier()->m_miscvalue == int32(power))
addvalue *= ((*i)->GetModifier()->m_amount + 100) / 100.0f;
ModifyPower(power, (int32)addvalue);
}
bool Pet::CanTakeMoreActiveSpells(uint32 spellid)
{
uint8 activecount = 1;
@ -1060,7 +1016,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner)
UpdateAllStats();
SetHealth(GetMaxHealth());
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
SetPower(GetPowerType(), GetMaxPower(GetPowerType()));
return true;
}
@ -1912,6 +1868,7 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
return;
PetSpellMap::iterator itr = m_spells.find(spellid);
PetSpell& petSpell = itr->second;
uint32 i;
@ -1924,11 +1881,11 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
{
m_autospells.push_back(spellid);
if (itr->second.active != ACT_ENABLED)
if (petSpell.active != ACT_ENABLED)
{
itr->second.active = ACT_ENABLED;
if (itr->second.state != PETSPELL_NEW)
itr->second.state = PETSPELL_CHANGED;
petSpell.active = ACT_ENABLED;
if (petSpell.state != PETSPELL_NEW)
petSpell.state = PETSPELL_CHANGED;
}
}
}
@ -1941,11 +1898,11 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
if (i < m_autospells.size())
{
m_autospells.erase(itr2);
if (itr->second.active != ACT_DISABLED)
if (petSpell.active != ACT_DISABLED)
{
itr->second.active = ACT_DISABLED;
if (itr->second.state != PETSPELL_NEW)
itr->second.state = PETSPELL_CHANGED;
petSpell.active = ACT_DISABLED;
if (petSpell.state != PETSPELL_NEW)
petSpell.state = PETSPELL_CHANGED;
}
}
}
@ -2042,6 +1999,44 @@ void Pet::CastPetAuras(bool current)
}
}
void Pet::CastOwnerTalentAuras()
{
if (!GetOwner() || GetOwner()->GetTypeId() != TYPEID_PLAYER)
return;
Player* pOwner = static_cast<Player*>(GetOwner());
// Handle Ferocious Inspiration Talent
if (pOwner && pOwner->getClass() == CLASS_HUNTER)
{
// clear any existing Ferocious Inspiration auras
RemoveAurasDueToSpell(75593);
RemoveAurasDueToSpell(75446);
RemoveAurasDueToSpell(75447);
if (IsAlive())
{
const SpellEntry* seTalent = pOwner->GetKnownTalentRankById(1800); // Ferocious Inspiration
if (seTalent)
{
switch (seTalent->Id)
{
case 34455: // Ferocious Inspiration Rank 1
CastSpell(this, 75593, true); // Ferocious Inspiration 1%
break;
case 34459: // Ferocious Inspiration Rank 2
CastSpell(this, 75446, true); // Ferocious Inspiration 2%
break;
case 34460: // Ferocious Inspiration Rank 3
CastSpell(this, 75447, true); // Ferocious Inspiration 3%
break;
}
}
}
} // End Ferocious Inspiration Talent
}
void Pet::CastPetAura(PetAura const* aura)
{
uint32 auraId = aura->GetAura(GetEntry());

View file

@ -178,7 +178,6 @@ class Pet : public Creature
}
void RegenerateAll(uint32 update_diff) override; // overwrite Creature::RegenerateAll
void Regenerate(Powers power);
void GivePetXP(uint32 xp);
void GivePetLevel(uint32 level);
void SynchronizeLevelWithOwner();
@ -198,6 +197,11 @@ class Pet : public Creature
void UpdateMaxPower(Powers power) override;
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void UpdateDamagePhysical(WeaponAttackType attType) override;
uint32 GetCurrentEquipmentId() const { return m_equipmentId; }
static float _GetHealthMod(int32 Rank); ///< Get custom factor to scale health (default 1, CONFIG_FLOAT_RATE_CREATURE_*_HP)
static float _GetDamageMod(int32 Rank); ///< Get custom factor to scale damage (default 1, CONFIG_FLOAT_RATE_*_DAMAGE)
static float _GetSpellDamageMod(int32 Rank); ///< Get custom factor to scale spell damage (default 1, CONFIG_FLOAT_RATE_*_SPELLDAMAGE)
bool CanTakeMoreActiveSpells(uint32 SpellIconID);
void ToggleAutocast(uint32 spellid, bool apply);
@ -209,6 +213,7 @@ class Pet : public Creature
void LearnPetPassives();
void CastPetAuras(bool current);
void CastOwnerTalentAuras();
void CastPetAura(PetAura const* aura);
void _LoadSpellCooldowns();

View file

@ -73,7 +73,6 @@
#include "SQLStorages.h"
#include "Vehicle.h"
#include "Calendar.h"
#include "PhaseMgr.h"
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#endif /*ENABLE_ELUNA*/
@ -568,8 +567,6 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_
m_cachedGS = 0;
m_slot = 255;
phaseMgr = new PhaseMgr(this);
}
Player::~Player()
@ -610,8 +607,6 @@ Player::~Player()
delete m_declinedname;
delete m_runes;
delete phaseMgr;
}
void Player::CleanupsBeforeDelete()
@ -853,6 +848,9 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
}
// all item positions resolved
if (info->phaseMap != 0)
CharacterDatabase.PExecute("REPLACE INTO `character_phase_data` (`guid`, `map`) VALUES (%u, %u)", guidlow, info->phaseMap);
return true;
}
@ -958,7 +956,11 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
data << uint32(resist);
SendMessageToSet(&data, true);
uint32 final_damage = DealDamage(this, damage, NULL, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
DamageEffectType damageType = SELF_DAMAGE;
if (type == DAMAGE_FALL && getClass() == CLASS_ROGUE)
damageType = SELF_DAMAGE_ROGUE_FALL;
uint32 final_damage = DealDamage(this, damage, NULL, damageType, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
if (!IsAlive())
{
@ -1390,8 +1392,8 @@ void Player::Update(uint32 update_diff, uint32 p_time)
HandleSobering();
}
// Not auto-free ghost from body in instances
if (m_deathTimer > 0 && !GetMap()->Instanceable())
// Not auto-free ghost from body in instances; also check for resurrection prevention
if (m_deathTimer > 0 && !GetMap()->Instanceable() && !HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
{
if (p_time >= m_deathTimer)
{
@ -2448,7 +2450,15 @@ void Player::SetGameMaster(bool on)
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
// restore phase
SetPhaseMask(phaseMgr->GetCurrentPhasemask(), false);
AuraList const& phases = GetAurasByType(SPELL_AURA_PHASE);
AuraList const& phases2 = GetAurasByType(SPELL_AURA_PHASE_2);
if (!phases.empty())
SetPhaseMask(phases.front()->GetMiscValue(), false);
else if (!phases2.empty())
SetPhaseMask(phases2.front()->GetMiscValue(), false);
else
SetPhaseMask(PHASEMASK_NORMAL, false);
CallForAllControlledUnits(SetGameMasterOffHelper(getFaction()), CONTROLLED_PET | CONTROLLED_TOTEMS | CONTROLLED_GUARDIANS | CONTROLLED_CHARM);
@ -2460,9 +2470,6 @@ void Player::SetGameMaster(bool on)
UpdateArea(m_areaUpdateId);
getHostileRefManager().setOnlineOfflineState(true);
phaseMgr->AddUpdateFlag(PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED);
phaseMgr->Update();
}
m_camera.UpdateVisibilityForOwner();
@ -2691,11 +2698,6 @@ void Player::GiveLevel(uint32 level)
MailDraft(mailReward->mailTemplateId).SendMailTo(this, MailSender(MAIL_CREATURE, mailReward->senderEntry));
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
PhaseUpdateData phaseUdateData;
phaseUdateData.AddConditionType(CONDITION_LEVEL);
phaseMgr->NotifyConditionChanged(phaseUdateData);
}
void Player::UpdateFreeTalentPoints(bool resetIfNeed)
@ -3080,7 +3082,6 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
PlayerSpellState state = learning ? PLAYERSPELL_NEW : PLAYERSPELL_UNCHANGED;
bool dependent_set = false;
bool disabled_case = false;
bool superceded_old = false;
@ -3088,6 +3089,8 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
if (itr != m_spells.end())
{
uint32 next_active_spell_id = 0;
bool dependent_set = false;
// fix activate state for non-stackable low rank (and find next spell for !active case)
if (sSpellMgr.IsRankedSpellNonStackableInSpellBook(spellInfo))
{
@ -4688,7 +4691,7 @@ void Player::KillPlayer()
// SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_IN_PVP );
SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable());
ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable() && !HasAuraType(SPELL_AURA_PREVENT_RESURRECTION));
// 6 minutes until repop at graveyard
m_deathTimer = 6 * MINUTE * IN_MILLISECONDS;
@ -6884,11 +6887,7 @@ void Player::UpdateArea(uint32 newArea)
SetFFAPvP(false);
}
phaseMgr->AddUpdateFlag(PHASE_UPDATE_FLAG_AREA_UPDATE);
UpdateAreaDependentAuras();
phaseMgr->RemoveUpdateFlag(PHASE_UPDATE_FLAG_AREA_UPDATE);
}
bool Player::CanUseCapturePoint()
@ -8498,7 +8497,7 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
// 0 - Battle for Wintergrasp in progress, 1 - otherwise
FillInitialWorldState(data, count, 0xED9, 1);
// Time when next Battle for Wintergrasp starts
FillInitialWorldState(data, count, 0x1102, uint32(time(nullptr) + 9000));
FillInitialWorldState(data, count, 0x1102, uint32(time(NULL) + 9000));
switch (zoneid)
{
@ -8844,10 +8843,10 @@ InventoryResult Player::CanUnequipItems(uint32 item, uint32 count) const
return EQUIP_ERR_OK;
}
}
Bag* pBag;
for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i);
Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (pBag)
{
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
@ -13211,7 +13210,7 @@ void Player::SendPreparedQuest(ObjectGuid guid)
{
qe._Delay = 0; // TEXTEMOTE_MESSAGE; // zyg: player emote
qe._Emote = 0; // TEXTEMOTE_HELLO; // zyg: NPC emote
title = "";
title.clear();
}
else
{
@ -14423,11 +14422,6 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status)
q_status.uState = QUEST_CHANGED;
}
PhaseUpdateData phaseUdateData;
phaseUdateData.AddQuestUpdate(quest_id);
phaseMgr->NotifyConditionChanged(phaseUdateData);
UpdateForQuestWorldObjects();
}
@ -18965,18 +18959,14 @@ void Player::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs)
WorldPacket data(SMSG_SPELL_COOLDOWN, 8 + 1 + m_spells.size() * 8);
data << GetObjectGuid();
data << uint8(0x0); // flags (0x1, 0x2)
time_t curTime = time(NULL);
time_t curTime = time(nullptr);
for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
{
if (itr->second.state == PLAYERSPELL_REMOVED)
continue;
uint32 unSpellId = itr->first;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(unSpellId);
if (!spellInfo)
{
MANGOS_ASSERT(spellInfo);
continue;
}
// Not send cooldown for this spells
if (spellInfo->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE))
@ -22103,6 +22093,25 @@ void Player::_LoadSkills(QueryResult* result)
}
}
uint32 Player::GetPhaseMaskForSpawn() const
{
uint32 phase = PHASEMASK_NORMAL;
if (!isGameMaster())
phase = GetPhaseMask();
else
{
AuraList const& phases = GetAurasByType(SPELL_AURA_PHASE);
if (!phases.empty())
phase = phases.front()->GetMiscValue();
}
// some aura phases include 1 normal map in addition to phase itself
if (uint32 n_phase = phase & ~PHASEMASK_NORMAL)
return n_phase;
return PHASEMASK_NORMAL;
}
InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) const
{
ItemPrototype const* pProto = pItem->GetProto();

View file

@ -60,7 +60,6 @@ class PlayerSocial;
class DungeonPersistentState;
class Spell;
class Item;
class PhaseMgr;
struct AreaTrigger;
@ -1209,7 +1208,7 @@ class Player : public Unit
void RemovePet(PetSaveMode mode);
PhaseMgr* GetPhaseMgr() { return phaseMgr; }
uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
void Say(const std::string& text, const uint32 language);
void Yell(const std::string& text, const uint32 language);
@ -2854,8 +2853,6 @@ class Player : public Unit
uint32 m_timeSyncServer;
uint32 m_cachedGS;
PhaseMgr* phaseMgr;
};
void AddItemsSetItem(Player* player, Item* item);

View file

@ -48,7 +48,7 @@ ReactorAI::MoveInLineOfSight(Unit*)
void
ReactorAI::AttackStart(Unit* p)
{
if (!p)
if (!p || !m_creature->CanAttackByItself())
return;
if (m_creature->Attack(p, true))

View file

@ -142,13 +142,14 @@ void ReputationMgr::SendState(FactionState const* faction, bool anyRankIncreased
for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
if (itr->second.needSend)
FactionState& subFaction = itr->second;
if (subFaction.needSend)
{
itr->second.needSend = false;
if (itr->second.ReputationListID != faction->ReputationListID)
subFaction.needSend = false;
if (subFaction.ReputationListID != faction->ReputationListID)
{
data << uint32(itr->second.ReputationListID);
data << uint32(itr->second.Standing);
data << uint32(subFaction.ReputationListID);
data << uint32(subFaction.Standing);
++count;
}
@ -317,36 +318,39 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr != m_factions.end())
{
FactionState& faction = itr->second;
int32 BaseRep = GetBaseReputation(factionEntry);
if (incremental)
standing += itr->second.Standing + BaseRep;
standing += faction.Standing + BaseRep;
if (standing > Reputation_Cap)
standing = Reputation_Cap;
else if (standing < Reputation_Bottom)
standing = Reputation_Bottom;
ReputationRank old_rank = ReputationToRank(itr->second.Standing + BaseRep);
ReputationRank old_rank = ReputationToRank(faction.Standing + BaseRep);
ReputationRank new_rank = ReputationToRank(standing);
itr->second.Standing = standing - BaseRep;
itr->second.needSend = true;
itr->second.needSave = true;
faction.Standing = standing - BaseRep;
faction.needSend = true;
faction.needSave = true;
SetVisible(&itr->second);
SetVisible(&faction);
if (new_rank <= REP_HOSTILE)
SetAtWar(&itr->second, true);
SetAtWar(&faction, true);
UpdateRankCounters(old_rank, new_rank);
m_player->ReputationChanged(factionEntry);
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, factionEntry->ID);
AchievementMgr& achievementManager = m_player->GetAchievementMgr();
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, factionEntry->ID);
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, factionEntry->ID);
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, factionEntry->ID);
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, factionEntry->ID);
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, factionEntry->ID);
if (new_rank > old_rank)
return true;
@ -532,11 +536,12 @@ void ReputationMgr::SaveToDB()
for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
if (itr->second.needSave)
FactionState& faction = itr->second;
if (faction.needSave)
{
stmtDel.PExecute(m_player->GetGUIDLow(), itr->second.ID);
stmtIns.PExecute(m_player->GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags);
itr->second.needSave = false;
stmtDel.PExecute(m_player->GetGUIDLow(), faction.ID);
stmtIns.PExecute(m_player->GetGUIDLow(), faction.ID, faction.Standing, faction.Flags);
faction.needSave = false;
}
}
}

View file

@ -138,19 +138,20 @@ void PlayerSocial::SendSocialList()
for (PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
{
sSocialMgr.GetFriendInfo(plr, itr->first, itr->second);
FriendInfo& friendInfo = itr->second;
sSocialMgr.GetFriendInfo(plr, itr->first, friendInfo);
data << ObjectGuid(HIGHGUID_PLAYER, itr->first); // player guid
data << uint32(itr->second.Flags); // player flag (0x1-friend?, 0x2-ignored?, 0x4-muted?)
data << itr->second.Note; // string note
if (itr->second.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend()
data << uint32(friendInfo.Flags); // player flag (0x1-friend?, 0x2-ignored?, 0x4-muted?)
data << friendInfo.Note; // string note
if (friendInfo.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend()
{
data << uint8(itr->second.Status); // online/offline/etc?
if (itr->second.Status) // if online
data << uint8(friendInfo.Status); // online/offline/etc?
if (friendInfo.Status) // if online
{
data << uint32(itr->second.Area); // player area
data << uint32(itr->second.Level); // player level
data << uint32(itr->second.Class); // player class
data << uint32(friendInfo.Area); // player area
data << uint32(friendInfo.Level); // player level
data << uint32(friendInfo.Class); // player class
}
}
}

View file

@ -776,6 +776,8 @@ bool IsPositiveEffect(SpellEntry const* spellproto, SpellEffectIndex effIndex)
// some explicitly required script effect sets
switch (spellproto->Id)
{
case 42436: // Drink!
case 42492: // Cast Energized
case 46650: // Open Brutallus Back Door
case 62488: // Activate Construct
case 64503: // Water
@ -903,6 +905,7 @@ bool IsPositiveEffect(SpellEntry const* spellproto, SpellEffectIndex effIndex)
case SPELL_AURA_PERIODIC_LEECH:
case SPELL_AURA_MOD_STALKED:
case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
case SPELL_AURA_PREVENT_RESURRECTION:
return false;
case SPELL_AURA_PERIODIC_DAMAGE: // used in positive spells also.
// part of negative spell if casted at self (prevent cancel)
@ -2231,6 +2234,25 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons
if ((spellInfo_1->Id == 62559 && spellInfo_2->Id == 62538) ||
(spellInfo_2->Id == 62559 && spellInfo_1->Id == 62538))
return false;
// Phase 2 Transform and Shadowy Barrier
if ((spellInfo_1->Id == 65157 && spellInfo_2->Id == 64775) ||
(spellInfo_2->Id == 65157 && spellInfo_1->Id == 64775))
return false;
// Empowered (dummy) and Empowered
if ((spellInfo_1->Id == 64161 && spellInfo_2->Id == 65294) ||
(spellInfo_2->Id == 64161 && spellInfo_1->Id == 65294))
return false;
// Spectral Realm (reaction) and Spectral Realm (invisibility)
if ((spellInfo_1->Id == 44852 && spellInfo_2->Id == 46021) ||
(spellInfo_2->Id == 44852 && spellInfo_1->Id == 46021))
return false;
// Halls of Reflection Clone
if (spellInfo_1->SpellIconID == 692 && spellInfo_2->SpellIconID == 692)
return false;
break;
}
case SPELLFAMILY_MAGE:
@ -3489,7 +3511,11 @@ void SpellMgr::LoadSpellScriptTarget()
spellEffect->EffectImplicitTargetA == TARGET_AREAEFFECT_GO_AROUND_SOURCE ||
spellEffect->EffectImplicitTargetB == TARGET_AREAEFFECT_GO_AROUND_SOURCE ||
spellEffect->EffectImplicitTargetA == TARGET_AREAEFFECT_GO_AROUND_DEST ||
spellEffect->EffectImplicitTargetB == TARGET_AREAEFFECT_GO_AROUND_DEST)
spellEffect->EffectImplicitTargetB == TARGET_AREAEFFECT_GO_AROUND_DEST ||
spellEffect->EffectImplicitTargetA == TARGET_NARROW_FRONTAL_CONE ||
spellEffect->EffectImplicitTargetB == TARGET_NARROW_FRONTAL_CONE ||
spellEffect->EffectImplicitTargetA == TARGET_NARROW_FRONTAL_CONE_2 ||
spellEffect->EffectImplicitTargetB == TARGET_NARROW_FRONTAL_CONE_2)
{
targetfound = true;
break;

View file

@ -1129,7 +1129,7 @@ class SpellMgr
return 0;
}
uint8 IsHighRankOfSpell(uint32 spell1, uint32 spell2) const
bool IsHighRankOfSpell(uint32 spell1, uint32 spell2) const
{
SpellChainMap::const_iterator itr = mSpellChains.find(spell1);

View file

@ -217,3 +217,11 @@ void TemporarySummon::UnSummon()
void TemporarySummon::SaveToDB()
{
}
TemporarySummonWaypoint::TemporarySummonWaypoint(ObjectGuid summoner, uint32 waypoint_id, int32 path_id, uint32 pathOrigin) :
TemporarySummon(summoner),
m_waypoint_id(waypoint_id),
m_path_id(path_id),
m_pathOrigin(pathOrigin)
{
}

View file

@ -55,4 +55,20 @@ class TemporarySummon : public Creature
uint32 m_lifetime;
ObjectGuid m_summoner;
};
class TemporarySummonWaypoint : public TemporarySummon
{
public:
explicit TemporarySummonWaypoint(ObjectGuid summoner, uint32 waypoint_id, int32 path_id, uint32 pathOrigin);
uint32 GetWaypointId() const { return m_waypoint_id; }
int32 GetPathId() const { return m_path_id; }
uint32 GetPathOrigin() const { return m_pathOrigin; }
private:
uint32 m_waypoint_id;
int32 m_path_id;
uint32 m_pathOrigin;
};
#endif

View file

@ -189,8 +189,13 @@ void Totem::SetTypeBySummonSpell(SpellEntry const* spellProto)
bool Totem::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index, bool castOnSelf) const
{
// Totem may affected by some specific spells
// Mana Spring, Healing stream, Mana tide
// Flags : 0x00000002000 | 0x00000004000 | 0x00004000000 -> 0x00004006000
if (spellInfo->GetSpellFamilyName() == SPELLFAMILY_SHAMAN && spellInfo->IsFitToFamilyMask(UI64LIT(0x00004006000)))
return false;
SpellEffectEntry const* spellEffect = spellInfo->GetSpellEffect(index);
if(spellEffect)
if (spellEffect)
{
// TODO: possibly all negative auras immune?
switch(spellEffect->Effect)

View file

@ -883,14 +883,12 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
// remove affects from attacker at any non-DoT damage (including 0 damage)
if (damagetype != DOT)
{
if (damagetype != SELF_DAMAGE_ROGUE_FALL)
RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if (pVictim != this)
RemoveSpellsCausingAura(SPELL_AURA_MOD_INVISIBILITY);
if (pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED))
{ pVictim->SetStandState(UNIT_STAND_STATE_STAND); }
pVictim->SetStandState(UNIT_STAND_STATE_STAND);
}
if (!damage)
@ -952,7 +950,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
((Creature*)pVictim)->SetLootRecipient(this);
JustKilledCreature((Creature*)pVictim, nullptr);
JustKilledCreature((Creature*)pVictim, NULL);
pVictim->SetHealth(0);
return damage;
@ -978,7 +976,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
{
SpellEntry const* shareSpell = (*itr)->GetSpellProto();
uint32 shareDamage = uint32(damage*(*itr)->GetModifier()->m_amount / 100.0f);
DealDamageMods(shareTarget, shareDamage, nullptr);
DealDamageMods(shareTarget, shareDamage, NULL);
DealDamage(shareTarget, shareDamage, 0, damagetype, GetSpellSchoolMask(shareSpell), shareSpell, false);
}
}
@ -4346,7 +4344,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder* holder)
case SPELL_AURA_OBS_MOD_MANA:
case SPELL_AURA_POWER_BURN_MANA:
case SPELL_AURA_CONTROL_VEHICLE:
case SPELL_AURA_284: // SPELL_AURA_LINKED_AURA, unknown how it is handled, but let it stack like vehicle control aura
case SPELL_AURA_TRIGGER_LINKED_AURA:
case SPELL_AURA_PERIODIC_DUMMY:
break;
case SPELL_AURA_PERIODIC_ENERGIZE: // all or self or clear non-stackable
@ -4367,7 +4365,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder* holder)
if (!IsPassiveSpell(aurSpellInfo) || !IsPassiveSpellStackableWithRanks(aurSpellInfo))
{
// Hack exceptions for Vehicle/Linked auras
if (!IsSpellHaveAura(aurSpellInfo, SPELL_AURA_CONTROL_VEHICLE) && !IsSpellHaveAura(aurSpellInfo, SPELL_AURA_284) &&
if (!IsSpellHaveAura(aurSpellInfo, SPELL_AURA_CONTROL_VEHICLE) && !IsSpellHaveAura(aurSpellInfo, SPELL_AURA_TRIGGER_LINKED_AURA) &&
!RemoveNoStackAurasDueToAuraHolder(holder))
{
delete holder;
@ -5750,8 +5748,10 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, SpellSchoolMask d
void Unit::SetPowerType(Powers new_powertype)
{
// set power type
SetByteValue(UNIT_FIELD_BYTES_0, 3, new_powertype);
// group updates
if (GetTypeId() == TYPEID_PLAYER)
{
if (((Player*)this)->GetGroup())
@ -5768,23 +5768,39 @@ void Unit::SetPowerType(Powers new_powertype)
}
}
// special cases for power type switching (druid and pets only)
if (GetTypeId() == TYPEID_PLAYER || (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsPet()))
{
uint32 maxValue = GetCreatePowers(new_powertype);
uint32 curValue = maxValue;
// special cases with current power = 0
switch (new_powertype)
{
default:
case POWER_MANA:
break;
case POWER_RAGE:
SetMaxPower(POWER_RAGE, GetCreatePowers(POWER_RAGE));
SetPower(POWER_RAGE, 0);
case POWER_RUNE:
case POWER_RUNIC_POWER:
curValue = 0;
break;
case POWER_FOCUS:
SetMaxPower(POWER_FOCUS, GetCreatePowers(POWER_FOCUS));
SetPower(POWER_FOCUS, GetCreatePowers(POWER_FOCUS));
break;
case POWER_ENERGY:
SetMaxPower(POWER_ENERGY, GetCreatePowers(POWER_ENERGY));
default:
break;
}
// set power (except for mana)
if (new_powertype != POWER_MANA)
{
SetMaxPower(new_powertype, maxValue);
SetPower(new_powertype, curValue);
}
// send power type update to client
WorldPacket data(SMSG_POWER_UPDATE);
data << GetPackGUID();
data << uint32(1); // power count
data << uint8(new_powertype);
data << uint32(curValue);
SendMessageToSet(&data, true);
}
}
FactionTemplateEntry const* Unit::getFactionTemplateEntry() const
@ -6717,7 +6733,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u
// Creature damage
if (GetTypeId() == TYPEID_UNIT && !((Creature*)this)->IsPet())
DoneTotalMod *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->Rank);
DoneTotalMod *= ((Creature*)this)->_GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->Rank);
AuraList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
for (AuraList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i)
@ -9269,6 +9285,10 @@ void Unit::SetDeathState(DeathState s)
if (IsVehicle())
m_vehicleInfo->RemoveAccessoriesFromMap();
// Unboard from transport
if (GetTransportInfo() && ((Unit*)GetTransportInfo()->GetTransport())->IsVehicle())
((Unit*)GetTransportInfo()->GetTransport())->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE, GetObjectGuid());
ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false);
ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false);
// remove aurastates allowing special moves
@ -10417,14 +10437,14 @@ uint32 Unit::GetCreatePowers(Powers power) const
{
case POWER_HEALTH: return 0; // is it really should be here?
case POWER_MANA: return GetCreateMana();
case POWER_RAGE: return 1000;
case POWER_RAGE: return POWER_RAGE_DEFAULT;
case POWER_FOCUS:
if(GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_HUNTER)
return 100;
return (GetTypeId() == TYPEID_PLAYER || !((Creature const*)this)->IsPet() || ((Pet const*)this)->getPetType() != HUNTER_PET ? 0 : 100);
case POWER_ENERGY: return 100;
case POWER_RUNE: return GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_DEATH_KNIGHT ? 8 : 0;
case POWER_RUNIC_POWER: return GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_DEATH_KNIGHT ? 1000 : 0;
return POWER_FOCUS_DEFAULT;
return (GetTypeId() == TYPEID_PLAYER || !((Creature const*)this)->IsPet() || ((Pet const*)this)->getPetType() != HUNTER_PET ? 0 : POWER_FOCUS_DEFAULT);
case POWER_ENERGY: return POWER_ENERGY_DEFAULT;
case POWER_RUNE: return GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_DEATH_KNIGHT ? POWER_RUNE_DEFAULT : 0;
case POWER_RUNIC_POWER: return GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_DEATH_KNIGHT ? POWER_RUNIC_POWER_DEFAULT : 0;
case POWER_SOUL_SHARDS: return 0;
case POWER_ECLIPSE: return 0; // TODO: fix me
case POWER_HOLY_POWER: return 0;
@ -10438,9 +10458,9 @@ uint32 Unit::GetCreateMaxPowers(Powers power) const
switch (power)
{
case POWER_HOLY_POWER:
return GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_PALADIN ? 3 : 0;
return GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_PALADIN ? POWER_HOLY_POWER_DEFAULT : 0;
case POWER_SOUL_SHARDS:
return GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_WARLOCK ? 3 : 0;
return GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_WARLOCK ? POWER_SOUL_SHARDS_DEFAULT : 0;
default:
return GetCreatePowers(power);
}
@ -10593,7 +10613,6 @@ void CharmInfo::InitCharmCreateSpells()
bool onlyselfcast = true;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo) onlyselfcast = false;
for (uint32 i = 0; i < 3 && onlyselfcast; ++i) // nonexistent spell will not make any problems as onlyselfcast would be false -> break right away
{
SpellEffectEntry const* spellEffect = spellInfo->GetSpellEffect(SpellEffectIndex(i));
@ -10843,7 +10862,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag,
if (itr->second->IsDeleted())
continue;
SpellProcEventEntry const* spellProcEvent = nullptr;
SpellProcEventEntry const* spellProcEvent = NULL;
// check if that aura is triggered by proc event (then it will be managed by proc handler)
if (!IsTriggeredAtSpellProcEvent(pTarget, itr->second, procSpell, procFlag, procExtra, attType, isVictim, spellProcEvent))
{
@ -11031,8 +11050,7 @@ void Unit::StopMoving(bool forceSendStop /*=false*/)
return;
Movement::MoveSplineInit init(*this);
init.SetFacing(GetOrientation());
init.Launch();
init.Stop();
}
void Unit::InterruptMoving(bool forceSendStop /*=false*/)
@ -11644,6 +11662,24 @@ void Unit::SetFFAPvP(bool state)
CallForAllControlledUnits(SetFFAPvPHelper(state), CONTROLLED_PET | CONTROLLED_TOTEMS | CONTROLLED_GUARDIANS | CONTROLLED_CHARM);
}
void Unit::RestoreOriginalFaction()
{
if (GetTypeId() == TYPEID_PLAYER)
((Player*)this)->setFactionForRace(getRace());
else
{
Creature* creature = (Creature*)this;
if (creature->IsPet() || creature->IsTotem())
{
if (Unit* owner = GetOwner())
setFaction(owner->getFaction());
}
else
setFaction(creature->GetCreatureInfo()->FactionAlliance);
}
}
void Unit::KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpeed)
{
float angle = this == target ? GetOrientation() + M_PI_F : target->GetAngle(this);

View file

@ -753,6 +753,7 @@ class MovementInfo
MovementFlags GetMovementFlags() const { return MovementFlags(moveFlags); }
void SetMovementFlags(MovementFlags f) { moveFlags = f; }
MovementFlags2 GetMovementFlags2() const { return MovementFlags2(moveFlags2); }
void AddMovementFlags2(MovementFlags2 f) { moveFlags2 |= f; }
// Position manipulations
Position const* GetPos() const { return &pos; }
@ -1861,6 +1862,10 @@ class Unit : public WorldObject
*/
void setFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); }
FactionTemplateEntry const* getFactionTemplateEntry() const;
/**
*
*/
void RestoreOriginalFaction();
/**
* Are we hostile towards the given Unit?
* @param unit the unit we want to check against
@ -3384,6 +3389,7 @@ class Unit : public WorldObject
SpellAuraProcResult HandleManaShieldAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
SpellAuraProcResult HandleModResistanceAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
SpellAuraProcResult HandleRemoveByDamageChanceProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
SpellAuraProcResult HandleInvisibilityAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown);
SpellAuraProcResult HandleNULLProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* /*triggeredByAura*/, SpellEntry const* /*procSpell*/, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/)
{
// no proc handler for this aura type

View file

@ -115,7 +115,7 @@ VehicleInfo::VehicleInfo(Unit* owner, VehicleEntry const* vehicleEntry, uint32 o
if (IsUsableSeatForCreature(seatEntry->m_flags))
m_creatureSeats |= 1 << i;
if (IsUsableSeatForPlayer(seatEntry->m_flags))
if (IsUsableSeatForPlayer(seatEntry->m_flags, seatEntry->m_flagsB))
m_playerSeats |= 1 << i;
}
}
@ -146,6 +146,32 @@ void VehicleInfo::Initialize()
summoned->CastCustomSpell((Unit*)m_owner, SPELL_RIDE_VEHICLE_HARDCODED, &basepoint0, NULL, NULL, true);
}
}
// Initialize movement limitations
uint32 vehicleFlags = GetVehicleEntry()->m_flags;
Unit* pVehicle = (Unit*)m_owner;
if (vehicleFlags & VEHICLE_FLAG_NO_STRAFE)
pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_STRAFE);
if (vehicleFlags & VEHICLE_FLAG_NO_JUMPING)
pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_JUMPING);
if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDTURNING)
pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDTURNING);
if (vehicleFlags & VEHICLE_FLAG_ALLOW_PITCHING)
pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_ALLOW_PITCHING);
if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDPITCHING)
pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDPITCHING);
if (vehicleFlags & VEHICLE_FLAG_FIXED_POSITION)
pVehicle->SetRoot(true);
// Initialize power type based on DBC values (creatures only)
if (pVehicle->GetTypeId() == TYPEID_UNIT)
{
if (PowerDisplayEntry const* powerEntry = sPowerDisplayStore.LookupEntry(GetVehicleEntry()->m_powerDisplayID))
pVehicle->SetPowerType(Powers(powerEntry->power));
}
m_isInitialized = true;
}
@ -304,6 +330,7 @@ void VehicleInfo::UnBoard(Unit* passenger, bool changeVehicle)
{
Player* pPlayer = (Player*)passenger;
pPlayer->ResummonPetTemporaryUnSummonedIfAny();
pPlayer->SetFallInformation(0, pPlayer->GetPositionZ());
// SMSG_PET_DISMISS_SOUND (?)
}
@ -473,9 +500,13 @@ uint8 VehicleInfo::GetTakenSeatsMask() const
return takenSeatsMask;
}
bool VehicleInfo:: IsUsableSeatForPlayer(uint32 seatFlags) const
bool VehicleInfo::IsUsableSeatForPlayer(uint32 seatFlags, uint32 seatFlagsB) const
{
return seatFlags & SEAT_FLAG_USABLE;
return seatFlags & SEAT_FLAG_CAN_EXIT ||
seatFlags & SEAT_FLAG_UNCONTROLLED ||
seatFlagsB &
(SEAT_FLAG_B_USABLE_FORCED | SEAT_FLAG_B_USABLE_FORCED_2 |
SEAT_FLAG_B_USABLE_FORCED_3 | SEAT_FLAG_B_USABLE_FORCED_4);
}
/// Add control and such modifiers to a passenger if required
@ -483,10 +514,17 @@ void VehicleInfo::ApplySeatMods(Unit* passenger, uint32 seatFlags)
{
Unit* pVehicle = (Unit*)m_owner; // Vehicles are alawys Unit
if (seatFlags & SEAT_FLAG_NOT_SELECTABLE)
passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if (passenger->GetTypeId() == TYPEID_PLAYER)
{
Player* pPlayer = (Player*)passenger;
// group update
if (pPlayer->GetGroup())
pPlayer->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_VEHICLE_SEAT);
if (seatFlags & SEAT_FLAG_CAN_CONTROL)
{
pPlayer->GetCamera().SetView(pVehicle);
@ -511,10 +549,13 @@ void VehicleInfo::ApplySeatMods(Unit* passenger, uint32 seatFlags)
{
((Creature*)pVehicle)->SetWalk(true, true);
}
// set vehicle faction as per the controller faction
((Creature*)pVehicle)->SetFactionTemporary(pPlayer->getFaction(), TEMPFACTION_NONE);
}
}
if (seatFlags & (SEAT_FLAG_USABLE | SEAT_FLAG_CAN_CAST))
if (seatFlags & SEAT_FLAG_CAN_CAST)
{
CharmInfo* charmInfo = pVehicle->InitCharmInfo(pVehicle);
charmInfo->InitVehicleCreateSpells();
@ -543,35 +584,47 @@ void VehicleInfo::RemoveSeatMods(Unit* passenger, uint32 seatFlags)
{
Unit* pVehicle = (Unit*)m_owner;
if (seatFlags & SEAT_FLAG_NOT_SELECTABLE)
passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if (passenger->GetTypeId() == TYPEID_PLAYER)
{
Player* pPlayer = (Player*)passenger;
// group update
if (pPlayer->GetGroup())
pPlayer->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_VEHICLE_SEAT);
if (seatFlags & SEAT_FLAG_CAN_CONTROL)
{
pPlayer->SetCharm(NULL);
pPlayer->SetCharm(nullptr);
pVehicle->SetCharmerGuid(ObjectGuid());
pPlayer->SetClientControl(pVehicle, 0);
pPlayer->SetMover(NULL);
pPlayer->SetMover(nullptr);
pVehicle->clearUnitState(UNIT_STAT_CONTROLLED);
pVehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
// must be called after movement control unapplying
pPlayer->GetCamera().ResetView();
// reset vehicle faction
if (pVehicle->GetTypeId() == TYPEID_UNIT)
((Creature*)pVehicle)->ClearTemporaryFaction();
}
if (seatFlags & (SEAT_FLAG_USABLE | SEAT_FLAG_CAN_CAST))
if (seatFlags & SEAT_FLAG_CAN_CAST)
pPlayer->RemovePetActionBar();
}
else if (passenger->GetTypeId() == TYPEID_UNIT)
{
if (seatFlags & SEAT_FLAG_CAN_CONTROL)
{
passenger->SetCharm(NULL);
passenger->SetCharm(nullptr);
pVehicle->SetCharmerGuid(ObjectGuid());
}
// Reinitialize movement
((Creature*)passenger)->AI()->SetCombatMovement(true, true);
if (!passenger->getVictim())

View file

@ -74,6 +74,7 @@ class VehicleInfo : public TransportBase
~VehicleInfo();
VehicleEntry const* GetVehicleEntry() const { return m_vehicleEntry; }
VehicleSeatEntry const* GetSeatEntry(uint8 seat) const;
void Board(Unit* passenger, uint8 seat); // Board a passenger to a vehicle
void SwitchSeat(Unit* passenger, uint8 seat); // Used to switch seats of a passenger
@ -89,7 +90,6 @@ class VehicleInfo : public TransportBase
void CalculateBoardingPositionOf(float gx, float gy, float gz, float go, float& lx, float& ly, float& lz, float& lo) const;
// Seat information
VehicleSeatEntry const* GetSeatEntry(uint8 seat) const;
bool GetUsableSeatFor(Unit* passenger, uint8& seat) const;
bool IsSeatAvailableFor(Unit* passenger, uint8 seat) const;
@ -97,8 +97,8 @@ class VehicleInfo : public TransportBase
uint8 GetEmptySeatsMask() const { return ~GetTakenSeatsMask(); }
uint8 GetEmptySeats() const { return m_vehicleSeats.size() - m_passengers.size(); }
bool IsUsableSeatForPlayer(uint32 seatFlags) const;
bool IsUsableSeatForCreature(uint32 seatFlags) const { return true; } // special flag?, !IsUsableSeatForPlayer(seatFlags)?
bool IsUsableSeatForPlayer(uint32 seatFlags, uint32 seatFlagsB) const;
bool IsUsableSeatForCreature(uint32 /*seatFlags*/) const { return true; } // special flag?, !IsUsableSeatForPlayer(seatFlags)?
// Apply/ Remove Controlling of the vehicle
void ApplySeatMods(Unit* passenger, uint32 seatFlags);

View file

@ -141,7 +141,7 @@ void OutdoorPvPHP::HandleObjectiveComplete(uint32 eventId, const std::list<Playe
if ((*itr) && (*itr)->GetTeam() == team)
{
(*itr)->KilledMonsterCredit(credit);
(*itr)->RewardHonor(nullptr, 1, HONOR_REWARD_HELLFIRE);
(*itr)->RewardHonor(NULL, 1, HONOR_REWARD_HELLFIRE);
}
}
}

View file

@ -537,7 +537,8 @@ void OutdoorPvPNA::RespawnSoldier()
if (Player* player = sObjectMgr.GetPlayer(itr->first))
{
// summon a soldier replacement in the order they were set in the deque. delete the element after summon
player->SummonCreature(m_zoneOwner == ALLIANCE ? NPC_ALLIANCE_HANAANI_GUARD : NPC_HORDE_HALAANI_GUARD, m_deadSoldiers.front().x, m_deadSoldiers.front().y, m_deadSoldiers.front().z, m_deadSoldiers.front().o, TEMPSUMMON_DEAD_DESPAWN, 0, true);
const HalaaSoldiersSpawns& location = m_deadSoldiers.front();
player->SummonCreature(m_zoneOwner == ALLIANCE ? NPC_ALLIANCE_HANAANI_GUARD : NPC_HORDE_HALAANI_GUARD, location.x, location.y, location.z, location.o, TEMPSUMMON_DEAD_DESPAWN, 0, true);
m_deadSoldiers.pop();
break;
}

View file

@ -593,6 +593,7 @@ enum VehicleFlags
VEHICLE_FLAG_UNK12 = 0x00080000,
VEHICLE_FLAG_UNK13 = 0x00100000,
VEHICLE_FLAG_UNK14 = 0x00200000,
VEHICLE_FLAG_FIXED_POSITION = 0x00200000, // Used for vehicles that have a fixed position, such as cannons
VEHICLE_FLAG_DISABLE_SWITCH = 0x00400000, // Can't change seats, VEHICLE_ID = 335 chopper
VEHICLE_FLAG_UNK15 = 0x00800000,
VEHICLE_FLAG_UNK16 = 0x01000000,
@ -620,19 +621,19 @@ enum VehicleSeatFlags
SEAT_FLAG_UNK10 = 0x00000400, // "AllowsTurning"
SEAT_FLAG_CAN_CONTROL = 0x00000800, // Lua_UnitInVehicleControlSeat
SEAT_FLAG_UNK11 = 0x00001000, // "Can Cast Mount Spell"
SEAT_FLAG_UNK12 = 0x00002000, // "Uncontrolled"
SEAT_FLAG_UNCONTROLLED = 0x00002000, // "Uncontrolled"
SEAT_FLAG_CAN_ATTACK = 0x00004000, // Can attack, cast spells and use items from vehicle?
SEAT_FLAG_UNK13 = 0x00008000, // "ShouldUseVehicleSeatExitAnimationOnForcedExit"
SEAT_FLAG_UNK14 = 0x00010000,
SEAT_FLAG_UNK15 = 0x00020000,
SEAT_FLAG_UNK16 = 0x00040000, // "HasVehicleExitAnimForVoluntaryExit"
SEAT_FLAG_UNK17 = 0x00080000, // "HasVehicleExitAnimForForcedExit"
SEAT_FLAG_UNK18 = 0x00100000,
SEAT_FLAG_NOT_SELECTABLE = 0x00100000,
SEAT_FLAG_UNK19 = 0x00200000,
SEAT_FLAG_UNK20 = 0x00400000, // "RecHasVehicleEnterAnim"
SEAT_FLAG_UNK21 = 0x00800000, // Lua_IsUsingVehicleControls
SEAT_FLAG_UNK22 = 0x01000000, // "EnableVehicleZoom"
SEAT_FLAG_USABLE = 0x02000000, // Lua_CanExitVehicle
SEAT_FLAG_CAN_EXIT = 0x02000000, // Lua_CanExitVehicle
SEAT_FLAG_CAN_SWITCH = 0x04000000, // Lua_CanSwitchVehicleSeats
SEAT_FLAG_UNK23 = 0x08000000, // "HasStartWaitingForVehicleTransitionAnimEnter"
SEAT_FLAG_UNK24 = 0x10000000, // "HasStartWaitingForVehicleTransitionAnimExit"
@ -641,4 +642,16 @@ enum VehicleSeatFlags
SEAT_FLAG_UNK26 = 0x80000000, // "AllowsInteraction"
};
enum VehicleSeatFlagsB
{
SEAT_FLAG_B_USABLE_FORCED = 0x00000002,
SEAT_FLAG_B_TARGETS_IN_RAIDUI = 0x00000008, // Lua_UnitTargetsVehicleInRaidUI
SEAT_FLAG_B_EJECTABLE = 0x00000020, // Ejectable
SEAT_FLAG_B_USABLE_FORCED_2 = 0x00000040,
SEAT_FLAG_B_USABLE_FORCED_3 = 0x00000100,
SEAT_FLAG_B_USABLE_FORCED_4 = 0x02000000,
SEAT_FLAG_B_CAN_SWITCH = 0x04000000,
SEAT_FLAG_B_PLAYERFRAME_UI = 0x80000000 // Lua_UnitHasVehiclePlayerFrameUI
};
#endif

View file

@ -165,6 +165,7 @@ DBCStorage <QuestSortEntry> sQuestSortStore(QuestSortEntryfmt);
DBCStorage <QuestXPLevel> sQuestXPLevelStore(QuestXPLevelfmt);
DBCStorage <PhaseEntry> sPhaseStore(Phasefmt);
DBCStorage <PowerDisplayEntry> sPowerDisplayStore(PowerDisplayfmt);
DBCStorage <PvPDifficultyEntry> sPvPDifficultyStore(PvPDifficultyfmt);
DBCStorage <RandomPropertiesPointsEntry> sRandomPropertiesPointsStore(RandomPropertiesPointsfmt);
@ -599,6 +600,7 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sQuestSortStore, dbcPath, "QuestSort.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sQuestXPLevelStore, dbcPath, "QuestXP.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sPhaseStore, dbcPath,"Phase.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sPowerDisplayStore, dbcPath,"PowerDisplay.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sPvPDifficultyStore, dbcPath, "PvpDifficulty.dbc");
for (uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i)
if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i))

View file

@ -206,6 +206,7 @@ extern DBCStorage <QuestFactionRewardEntry> sQuestFactionRewardStore;
extern DBCStorage <QuestSortEntry> sQuestSortStore;
extern DBCStorage <QuestXPLevel> sQuestXPLevelStore;
extern DBCStorage <PhaseEntry> sPhaseStore;
extern DBCStorage <PowerDisplayEntry> sPowerDisplayStore;
// extern DBCStorage <PvPDifficultyEntry> sPvPDifficultyStore; -- use GetBattlegroundSlotByLevel for access
extern DBCStorage <RandomPropertiesPointsEntry> sRandomPropertiesPointsStore;
extern DBCStorage <ScalingStatDistributionEntry> sScalingStatDistributionStore;

View file

@ -1456,6 +1456,16 @@ struct PhaseEntry
uint32 Flags; // 2 - 0x0, 0x4, 0x8
};
struct PowerDisplayEntry
{
uint32 id; // 0 m_ID
uint32 power; // 1 m_power
// uint32 unk1 // 2
// float unk2 // 3
// float unk3 // 4
// float unk4 // 5
};
struct PvPDifficultyEntry
{
//uint32 id; // 0 m_ID
@ -1808,31 +1818,30 @@ struct SpellCooldownsEntry
struct SpellEffectEntry
{
//uint32 Id; // 0 m_ID
uint32 Effect; // 73-75 m_effect
float EffectMultipleValue; // 106-108 m_effectAmplitude
uint32 EffectApplyAuraName; // 100-102 m_effectAura
uint32 EffectAmplitude; // 103-105 m_effectAuraPeriod
int32 EffectBasePoints; // 82-84 m_effectBasePoints (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints)
//float unk_320_4; // 169-171 3.2.0
float DmgMultiplier; // 156-158 m_effectChainAmplitude
uint32 EffectChainTarget; // 109-111 m_effectChainTargets
int32 EffectDieSides; // 76-78 m_effectDieSides
uint32 EffectItemType; // 112-114 m_effectItemType
uint32 EffectMechanic; // 85-87 m_effectMechanic
int32 EffectMiscValue; // 115-117 m_effectMiscValue
int32 EffectMiscValueB; // 118-120 m_effectMiscValueB
float EffectPointsPerComboPoint; // 124-126 m_effectPointsPerCombo
uint32 EffectRadiusIndex; // 94-96 m_effectRadiusIndex - spellradius.dbc
uint32 EffectRadiusMaxIndex; // 97-99 4.0.0
float EffectRealPointsPerLevel; // 79-81 m_effectRealPointsPerLevel
ClassFamilyMask EffectSpellClassMask; // 127-129 m_effectSpellClassMask
uint32 EffectTriggerSpell; // 121-123 m_effectTriggerSpell
uint32 EffectImplicitTargetA; // 88-90 m_implicitTargetA
uint32 EffectImplicitTargetB; // 91-93 m_implicitTargetB
uint32 EffectSpellId; // new 4.0.0
uint32 EffectIndex; // new 4.0.0
//uint32 unk; // 24 - 4.2.0
uint32 Effect; // 1 m_effect
float EffectMultipleValue; // 2 m_effectAmplitude
uint32 EffectApplyAuraName; // 3 m_effectAura
uint32 EffectAmplitude; // 4 m_effectAuraPeriod
int32 EffectBasePoints; // 5 m_effectBasePoints (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints)
float EffectBonusMultiplier; // 6 m_effectBonus
float EffectDamageMultiplier; // 7 m_effectChainAmplitude
uint32 EffectChainTarget; // 8 m_effectChainTargets
int32 EffectDieSides; // 9 m_effectDieSides
uint32 EffectItemType; // 10 m_effectItemType
uint32 EffectMechanic; // 11 m_effectMechanic
int32 EffectMiscValue; // 12 m_effectMiscValue
int32 EffectMiscValueB; // 13 m_effectMiscValueB
float EffectPointsPerComboPoint; // 14 m_effectPointsPerCombo
uint32 EffectRadiusIndex; // 15 m_effectRadiusIndex - spellradius.dbc
uint32 EffectRadiusMaxIndex; // 16 4.0.0
float EffectRealPointsPerLevel; // 17 m_effectRealPointsPerLevel
ClassFamilyMask EffectSpellClassMask; // 18 19 20 m_effectSpellClassMask
uint32 EffectTriggerSpell; // 21 m_effectTriggerSpell
uint32 EffectImplicitTargetA; // 22 m_implicitTargetA
uint32 EffectImplicitTargetB; // 23 m_implicitTargetB
uint32 EffectSpellId; // 24 m_spellId - spell.dbc
uint32 EffectIndex; // 25 m_spellEffectIdx
//uint32 unk; // 26 4.2.0 only 0 or 1
// helpers
int32 CalculateSimpleValue() const { return EffectBasePoints; }
@ -2353,7 +2362,7 @@ struct VehicleEntry
uint32 m_uiLocomotionType; // 34
float m_msslTrgtImpactTexRadius; // 35
uint32 m_uiSeatIndicatorType; // 36 m_vehicleUIIndicatorID
uint32 m_powerType; // 37 m_powerDisplayID
uint32 m_powerDisplayID; // 37
// 38 new in 3.1
// 39 new in 3.1
};
@ -2421,9 +2430,6 @@ struct VehicleSeatEntry
//uint32 unk[6]; // 58-63
//uint32 unk2; // 64 4.0.0
//uint32 unk3; // 65 4.0.1
bool IsUsable() const { return m_flags & SEAT_FLAG_USABLE; }
};
struct WMOAreaTableEntry

View file

@ -104,7 +104,8 @@ const char OverrideSpellDatafmt[]="niiiiiiiiiixx";
const char QuestFactionRewardfmt[] = "niiiiiiiiii";
const char QuestSortEntryfmt[]="nx";
const char QuestXPLevelfmt[] = "niiiiiiiiii";
const char Phasefmt[]="nii";
const char Phasefmt[] = "nii";
const char PowerDisplayfmt[] = "nixxxx";
const char PvPDifficultyfmt[] = "diiiii";
const char RandomPropertiesPointsfmt[] = "niiiiiiiiiiiiiii";
const char ScalingStatDistributionfmt[]="niiiiiiiiiiiiiiiiiiiixi";

View file

@ -326,13 +326,13 @@ enum SpellAttributesEx
SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE = 0x00010000,// 16 unaffected by school immunity
SPELL_ATTR_EX_UNK17 = 0x00020000,// 17 for auras SPELL_AURA_TRACK_CREATURES, SPELL_AURA_TRACK_RESOURCES and SPELL_AURA_TRACK_STEALTHED select non-stacking tracking spells
SPELL_ATTR_EX_UNK18 = 0x00040000,// 18
SPELL_ATTR_EX_UNK19 = 0x00080000,// 19
SPELL_ATTR_EX_CANT_TARGET_SELF = 0x00080000,// 19 spells with area effect or friendly targets that exclude the caster
SPELL_ATTR_EX_REQ_TARGET_COMBO_POINTS = 0x00100000,// 20 Req combo points on target
SPELL_ATTR_EX_UNK21 = 0x00200000,// 21
SPELL_ATTR_EX_REQ_COMBO_POINTS = 0x00400000,// 22 Use combo points (in 4.x not required combo point target selected)
SPELL_ATTR_EX_REQ_COMBO_POINTS = 0x00400000,// 22 Use combo points
SPELL_ATTR_EX_UNK23 = 0x00800000,// 23
SPELL_ATTR_EX_UNK24 = 0x01000000,// 24 Req fishing pole??
SPELL_ATTR_EX_UNK25 = 0x02000000,// 25 not set in 2.4.2
SPELL_ATTR_EX_UNK25 = 0x02000000,// 25
SPELL_ATTR_EX_UNK26 = 0x04000000,// 26
SPELL_ATTR_EX_UNK27 = 0x08000000,// 27
SPELL_ATTR_EX_UNK28 = 0x10000000,// 28
@ -896,11 +896,11 @@ enum SpellEffects
SPELL_EFFECT_LEAP_BACK = 138,
SPELL_EFFECT_CLEAR_QUEST = 139,
SPELL_EFFECT_FORCE_CAST = 140,
SPELL_EFFECT_141 = 141,
SPELL_EFFECT_FORCE_CAST_WITH_VALUE = 141,
SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE = 142,
SPELL_EFFECT_APPLY_AREA_AURA_OWNER = 143,
SPELL_EFFECT_KNOCKBACK_FROM_POSITION = 144,
SPELL_EFFECT_145 = 145,
SPELL_EFFECT_GRAVITY_PULL = 145,
SPELL_EFFECT_ACTIVATE_RUNE = 146,
SPELL_EFFECT_QUEST_FAIL = 147,
SPELL_EFFECT_148 = 148,
@ -1411,7 +1411,7 @@ enum Targets
TARGET_SELF = 1,
TARGET_RANDOM_ENEMY_CHAIN_IN_AREA = 2, // only one spell has that, but regardless, it's a target type after all
TARGET_RANDOM_FRIEND_CHAIN_IN_AREA = 3,
TARGET_4 = 4, // some plague spells that are infectious - maybe targets not-infected friends inrange
TARGET_RANDOM_UNIT_CHAIN_IN_AREA = 4, // some plague spells that are infectious - maybe targets not-infected friends inrange
TARGET_PET = 5,
TARGET_CHAIN_DAMAGE = 6,
TARGET_AREAEFFECT_INSTANT = 7, // targets around provided destination point
@ -1460,7 +1460,7 @@ enum Targets
TARGET_ALL_RAID_AROUND_CASTER = 56,
TARGET_SINGLE_FRIEND_2 = 57,
TARGET_58 = 58,
TARGET_59 = 59,
TARGET_FRIENDLY_FRONTAL_CONE = 59,
TARGET_NARROW_FRONTAL_CONE = 60,
TARGET_AREAEFFECT_PARTY_AND_CLASS = 61,
TARGET_DUELVSPLAYER_COORDINATES = 63,
@ -1503,12 +1503,12 @@ enum Targets
TARGET_VEHICLE_PASSENGER_6 = 102,
TARGET_VEHICLE_PASSENGER_7 = 103,
TARGET_IN_FRONT_OF_CASTER_30 = 104,
TARGET_105 = 105, // 1 spell
TARGET_105 = 105,
TARGET_106 = 106,
TARGET_107 = 107, // possible TARGET_WMO(GO?)_IN_FRONT_OF_CASTER(_30 ?) TODO: Verify the angle!
TARGET_GO_IN_FRONT_OF_CASTER_90 = 108,
TARGET_109 = 109, // spell 89008
TARGET_110 = 110, // front enemy aoe
TARGET_NARROW_FRONTAL_CONE_2 = 110,
TARGET_111 = 111, // not used
TARGET_112 = 112, // spell 89549
TARGET_113 = 113, // not used
@ -1598,7 +1598,9 @@ enum DamageEffectType
HEAL = 3,
/// used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
NODAMAGE = 4,
SELF_DAMAGE = 5
/// used to avoid rogue loosing stealth on falling damage
SELF_DAMAGE_ROGUE_FALL = 5,
SELF_DAMAGE = 6
};
enum GameobjectTypes

View file

@ -671,6 +671,51 @@ void WorldSession::SendNotification(int32 string_id, ...)
}
}
void WorldSession::SendSetPhaseShift(uint32 phaseMask, uint16 mapId)
{
ObjectGuid guid = _player->GetObjectGuid();
uint32 phaseFlags = 0;
for (uint32 i = 0; i < sPhaseStore.GetNumRows(); i++)
{
if (PhaseEntry const* phase = sPhaseStore.LookupEntry(i))
{
if (phase->PhaseShift == phaseMask)
{
phaseFlags = phase->Flags;
break;
}
}
}
WorldPacket data(SMSG_SET_PHASE_SHIFT, 30);
data.WriteGuidMask<2, 3, 1, 6, 4, 5, 0, 7>(guid);
data.WriteGuidBytes<7, 4>(guid);
data << uint32(0); // number of WorldMapArea.dbc entries to control world map shift * 2
data.WriteGuidBytes<1>(guid);
data << uint32(phaseMask ? phaseFlags : 8);
data.WriteGuidBytes<2, 6>(guid);
data << uint32(0); // number of inactive terrain swaps * 2
data << uint32(phaseMask ? 2 : 0); // WRONG: number of Phase.dbc ids * 2
if (phaseMask)
data << uint16(phaseMask);
data.WriteGuidBytes<3, 0>(guid);
data << uint32(mapId ? 2 : 0); // number of terrains swaps * 2
if (mapId)
data << uint16(mapId);
data.WriteGuidBytes<5>(guid);
SendPacket(&data);
}
/*
void WorldSession::SendSetPhaseShift(std::set<uint32> const& phaseIds, std::set<uint32> const& terrainswaps)
{
if (PlayerLoading())
@ -707,6 +752,7 @@ void WorldSession::SendSetPhaseShift(std::set<uint32> const& phaseIds, std::set<
data.WriteGuidBytes<5>(guid);
SendPacket(&data);
}
*/
const char* WorldSession::GetMangosString(int32 entry) const
{
@ -807,7 +853,7 @@ void WorldSession::LoadAccountData(QueryResult* result, uint32 mask)
delete result;
}
void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::string data)
void WorldSession::SetAccountData(AccountDataType type, time_t time_, const std::string& data)
{
if ((1 << type) & GLOBAL_CACHE_MASK)
{
@ -828,7 +874,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
}
else
{
// _player can be NULL and packet received after logout but m_GUID still store correct guid
// _player can be nullptr and packet received after logout but m_GUID still store correct guid
if (!m_GUIDLow)
return;

View file

@ -277,7 +277,7 @@ class WorldSession
void SendGroupInvite(Player* player, bool alreadyInGroup = false);
void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2, 3);
void SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg = 0);
void SendSetPhaseShift(std::set<uint32> const& phaseIds, std::set<uint32> const& terrainswaps);
void SendSetPhaseShift(uint32 phaseMask, uint16 mapId = 0);
void SendQueryTimeResponse();
void SendRedirectClient(std::string& ip, uint16 port);
@ -380,7 +380,7 @@ class WorldSession
// Account Data
AccountData* GetAccountData(AccountDataType type) { return &m_accountData[type]; }
void SetAccountData(AccountDataType type, time_t time_, std::string data);
void SetAccountData(AccountDataType type, time_t time_, const std::string& data);
void SendAccountDataTimes(uint32 mask);
void LoadGlobalAccountData();
void LoadAccountData(QueryResult* result, uint32 mask);
@ -778,8 +778,8 @@ class WorldSession
void HandleQuestPushResult(WorldPacket& recvPacket);
bool processChatmessageFurtherAfterSecurityChecks(std::string&, uint32);
void SendPlayerNotFoundNotice(std::string name);
void SendPlayerAmbiguousNotice(std::string name);
void SendPlayerNotFoundNotice(const std::string& name);
void SendPlayerAmbiguousNotice(const std::string& name);
void SendWrongFactionNotice();
void SendChatRestrictedNotice(ChatRestrictionType restriction);
void HandleMessagechatOpcode(WorldPacket& recvPacket);

View file

@ -210,39 +210,39 @@ enum MangosStrings
LANG_RESETALL_SPELLS = 218,
LANG_RESETALL_TALENTS = 219,
LANG_WAYPOINT_NOTFOUND = 220,
LANG_WAYPOINT_NOTFOUNDLAST = 221,
LANG_WAYPOINT_NOTFOUNDSEARCH = 222,
LANG_WAYPOINT_NOTFOUNDDBPROBLEM = 223,
LANG_WAYPOINT_CREATSELECTED = 224,
LANG_WAYPOINT_CREATNOTFOUND = 225,
LANG_WAYPOINT_VP_SELECT = 226,
LANG_WAYPOINT_VP_NOTFOUND = 227,
LANG_WAYPOINT_VP_NOTCREATED = 228,
LANG_WAYPOINT_VP_ALLREMOVED = 229,
LANG_WAYPOINT_NOTCREATED = 230,
LANG_WAYPOINT_NOGUID = 231,
LANG_WAYPOINT_NOWAYPOINTGIVEN = 232,
LANG_WAYPOINT_ARGUMENTREQ = 233,
LANG_WAYPOINT_ADDED = 234,
LANG_WAYPOINT_ADDED_NO = 235,
LANG_WAYPOINT_CHANGED = 236,
LANG_WAYPOINT_CHANGED_NO = 237,
LANG_WAYPOINT_EXPORTED = 238,
LANG_WAYPOINT_NOTHINGTOEXPORT = 239,
LANG_WAYPOINT_IMPORTED = 240,
LANG_WAYPOINT_REMOVED = 241,
LANG_WAYPOINT_NOTREMOVED = 242,
LANG_WAYPOINT_TOOFAR1 = 243,
LANG_WAYPOINT_TOOFAR2 = 244,
LANG_WAYPOINT_TOOFAR3 = 245,
LANG_WAYPOINT_INFO_TITLE = 246,
LANG_WAYPOINT_INFO_WAITTIME = 247,
LANG_WAYPOINT_INFO_MODEL = 248,
LANG_WAYPOINT_INFO_EMOTE = 249,
LANG_WAYPOINT_INFO_SPELL = 250,
LANG_WAYPOINT_INFO_TEXT = 251,
LANG_WAYPOINT_INFO_AISCRIPT = 252,
LANG_WAYPOINT_NOTFOUND = 220, // Cannot find waypoint id %u for %s (in path %i, loaded from %s)
LANG_WAYPOINT_NOTFOUNDLAST = 221, // Last Waypoint not found for %s
LANG_WAYPOINT_NOTFOUNDPATH = 222, // %s has no path or path empty, path-id %i (loaded from %s)
LANG_WAYPOINT_NOTFOUNDDBPROBLEM = 223, // Creature (GUID: %u) No waypoints found - This is a MaNGOS db problem (single float).
LANG_WAYPOINT_NOTFOUND_NPC = 224, // Cannot access %s on map, maybe you are too far away from its spawn location
LANG_WAYPOINT_CREATNOTFOUND = 225, // Creature (GUID: %u) not found
LANG_WAYPOINT_VP_SELECT = 226, // You must select a visual waypoint.
LANG_WAYPOINT_VP_NOTFOUND = 227, // No visual waypoints found
LANG_WAYPOINT_VP_NOTCREATED = 228, // Could not create visual waypoint with creatureID: %d
LANG_WAYPOINT_VP_ALLREMOVED = 229, // All visual waypoints removed
LANG_WAYPOINT_NOTCREATED = 230, // Could not add waypoint %u to %s (pathId %i stored by %s)
LANG_WAYPOINT_NOGUID = 231, // No GUID provided.
LANG_WAYPOINT_NOWAYPOINTGIVEN = 232, // No waypoint number provided.
LANG_WAYPOINT_ARGUMENTREQ = 233, // Argument required for \'%s\'.
LANG_WAYPOINT_ADDED = 234, // Added Waypoint %u to %s (PathId %i, path stored by %s)
LANG_WAYPOINT_ADDED_NO = 235, // UNUSED
LANG_WAYPOINT_CHANGED = 236, // Waypoint changed.
LANG_WAYPOINT_CHANGED_NO = 237, // Waypoint %s modified.
LANG_WAYPOINT_EXPORTED = 238, // WP export successfull.
LANG_WAYPOINT_NOTHINGTOEXPORT = 239, // No waypoints found inside the database.
LANG_WAYPOINT_IMPORTED = 240, // File imported.
LANG_WAYPOINT_REMOVED = 241, // Waypoint removed.
LANG_WAYPOINT_NOTREMOVED = 242, // UNUSED
LANG_WAYPOINT_TOOFAR1 = 243, // UNUSED
LANG_WAYPOINT_TOOFAR2 = 244, // UNUSED
LANG_WAYPOINT_TOOFAR3 = 245, // UNUSED
LANG_WAYPOINT_INFO_TITLE = 246, // Waypoint %u for %s (from pathId %i, stored by %s)
LANG_WAYPOINT_INFO_WAITTIME = 247, // Waittime: %d
LANG_WAYPOINT_INFO_ORI = 248, // Orientation: %f
LANG_WAYPOINT_INFO_SCRIPTID = 249, // ScriptId: %u
LANG_WAYPOINT_INFO_UNK_SCRIPTID = 250, // ScriptID set to non-existing id %u, add it to DBScriptsEngine and reload the table.
LANG_WAYPOINT_INFO_TEXT = 251, // UNUSED
LANG_WAYPOINT_INFO_AISCRIPT = 252, // AIScriptName: %s
LANG_RENAME_PLAYER = 253,
LANG_RENAME_PLAYER_GUID = 254,
@ -742,13 +742,12 @@ enum MangosStrings
LANG_DEBUG_ARENA_OFF = 738,
LANG_DEBUG_BG_ON = 739,
LANG_DEBUG_BG_OFF = 740,
LANG_DIST_ARENA_POINTS_START = 741,
LANG_DIST_ARENA_POINTS_ONLINE_START = 742,
LANG_DIST_ARENA_POINTS_ONLINE_END = 743,
LANG_DIST_ARENA_POINTS_TEAM_START = 744,
LANG_DIST_ARENA_POINTS_TEAM_END = 745,
LANG_DIST_ARENA_POINTS_END = 746,
// = 741, not used
// = 742, not used
// = 743, not used
// = 744, not used
// = 745, not used
// = 746, not used
// = 747, not used
// = 748, not used
// = 749, not used
@ -1026,14 +1025,6 @@ enum MangosStrings
LANG_VENDOR_WRONG_ITEM_TYPE = 1700,
LANG_VENDOR_WRONG_CURRENCY_MAXCOUNT = 1701,
LANG_PHASING_REPORT_STATUS = 1702,
LANG_PHASING_NO_DEFINITIONS = 1703,
LANG_PHASING_SUCCESS = 1704,
LANG_PHASING_FAILED = 1705,
LANG_PHASING_LAST_PHASE = 1706,
LANG_PHASING_LIST = 1707,
LANG_PHASING_PHASEMASK = 1708,
// FREE IDS 1800-9999
// Use for not-in-official-sources patches
@ -1045,4 +1036,5 @@ enum MangosStrings
// `db_script_string` table index 2000000000-2000999999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID)
// For other tables maybe 2001000000-2147483647 (max index)
};
#endif

View file

@ -558,7 +558,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
if (!changenth(line, 2, chraccount)) // characters.account update
ROLLBACK(DUMP_FILE_BROKEN);
if (name == "")
if (name.empty())
{
// check if the original name already exists
name = getnth(line, 3); // characters.name

View file

@ -64,7 +64,7 @@ namespace MaNGOS
{
char const* text = sObjectMgr.GetMangosString(i_textId, loc_idx);
ChatHandler::BuildChatPacket(data, i_msgtype, text, LANG_UNIVERSAL, i_player.GetChatTag(), i_player.GetObjectGuid(), nullptr, i_player.GetObjectGuid(), nullptr, nullptr,
ChatHandler::BuildChatPacket(data, i_msgtype, text, LANG_UNIVERSAL, i_player.GetChatTag(), i_player.GetObjectGuid(), NULL, i_player.GetObjectGuid(), NULL, NULL,
i_achievementId);
}

View file

@ -50,7 +50,7 @@ ChannelMgr::~ChannelMgr()
channels.clear();
}
Channel* ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id)
Channel* ChannelMgr::GetJoinChannel(const std::string& name, uint32 channel_id)
{
std::wstring wname;
Utf8toWStr(name, wname);
@ -66,7 +66,7 @@ Channel* ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id)
return channels[wname];
}
Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt)
Channel* ChannelMgr::GetChannel(const std::string& name, Player* p, bool pkt)
{
std::wstring wname;
Utf8toWStr(name, wname);
@ -83,13 +83,13 @@ Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt)
p->GetSession()->SendPacket(&data);
}
return NULL;
return nullptr;
}
else
return i->second;
}
void ChannelMgr::LeftChannel(std::string name)
void ChannelMgr::LeftChannel(const std::string& name)
{
std::wstring wname;
Utf8toWStr(name, wname);
@ -109,7 +109,7 @@ void ChannelMgr::LeftChannel(std::string name)
}
}
void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string name)
void ChannelMgr::MakeNotOnPacket(WorldPacket* data, const std::string& name)
{
data->Initialize(SMSG_CHANNEL_NOTIFY, (1 + 10)); // we guess size
(*data) << (uint8)CHAT_NOT_MEMBER_NOTICE << name;

View file

@ -38,12 +38,12 @@ class ChannelMgr
ChannelMgr() {}
~ChannelMgr();
Channel* GetJoinChannel(std::string name, uint32 channel_id);
Channel* GetChannel(std::string name, Player* p, bool pkt = true);
void LeftChannel(std::string name);
Channel* GetJoinChannel(const std::string& name, uint32 channel_id);
Channel* GetChannel(const std::string& name, Player* p, bool pkt = true);
void LeftChannel(const std::string& name);
private:
ChannelMap channels;
void MakeNotOnPacket(WorldPacket* data, std::string name);
void MakeNotOnPacket(WorldPacket* data, const std::string& name);
};
class AllianceChannelMgr : public ChannelMgr {};

View file

@ -1047,7 +1047,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult* result, uin
WorldSession* session = sWorld.FindSession(accountId);
if (!session)
{
if (result) delete result;
delete result;
return;
}
@ -1077,6 +1077,8 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult* result, uin
data << guid;
data << newname;
session->SendPacket(&data);
sWorld.InvalidatePlayerDataToAllClient(guid);
}
void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
@ -1325,6 +1327,8 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
data << uint8(hairColor);
data << uint8(facialHair);
SendPacket(&data);
sWorld.InvalidatePlayerDataToAllClient(guid);
}
void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket& recv_data)

View file

@ -450,7 +450,6 @@ ChatCommand* ChatHandler::getCommandTable()
{ "add", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddCommand, "", NULL },
{ "addcurrency", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddVendorCurrencyCommand,"", NULL },
{ "additem", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddVendorItemCommand, "", NULL },
{ "addmove", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddMoveCommand, "", NULL },
{ "aiinfo", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAIInfoCommand, "", NULL },
{ "allowmove", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcAllowMovementCommand, "", NULL },
{ "changeentry", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcChangeEntryCommand, "", NULL },
@ -537,12 +536,12 @@ ChatCommand* ChatHandler::getCommandTable()
{ "creature_ai_summons", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadEventAISummonsCommand, "", NULL },
{ "creature_ai_texts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadEventAITextsCommand, "", NULL },
{ "creature_battleground", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadBattleEventCommand, "", NULL },
{ "creature_template_classlevelstats", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreaturesStatsCommand, "", nullptr },
{ "creature_template_classlevelstats", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreaturesStatsCommand, "", NULL },
{ "creature_involvedrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand, "", NULL },
{ "creature_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesCreatureCommand, "", NULL },
{ "creature_questrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestRelationsCommand, "", NULL },
{ "db_script_string", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDbScriptStringCommand, "", NULL },
{ "dbscripts_on_creature_death", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDBScriptsOnCreatureDeathCommand,"", NULL },
{ "dbscripts_on_creature_death", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDBScriptsOnCreatureDeathCommand, "", NULL },
{ "dbscripts_on_event", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDBScriptsOnEventCommand, "", NULL },
{ "dbscripts_on_gossip", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDBScriptsOnGossipCommand, "", NULL },
{ "dbscripts_on_go_use", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDBScriptsOnGoUseCommand, "", NULL },
@ -583,7 +582,6 @@ ChatCommand* ChatHandler::getCommandTable()
{ "npc_trainer", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadNpcTrainerCommand, "", NULL },
{ "npc_vendor", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadNpcVendorCommand, "", NULL },
{ "page_text", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPageTextsCommand, "", NULL },
{ "phase_definitions", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPhaseDefinitionsCommand, "", NULL },
{ "pickpocketing_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesPickpocketingCommand, "", NULL},
{ "points_of_interest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPointsOfInterestCommand, "", NULL },
{ "prospecting_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesProspectingCommand, "", NULL },
@ -691,7 +689,7 @@ ChatCommand* ChatHandler::getCommandTable()
{ "corpses", SEC_GAMEMASTER, true, &ChatHandler::HandleServerCorpsesCommand, "", NULL },
{ "exit", SEC_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", NULL },
{ "idlerestart", SEC_ADMINISTRATOR, true, NULL, "", serverIdleRestartCommandTable },
{ "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverShutdownCommandTable },
{ "idleshutdown", SEC_ADMINISTRATOR, true, NULL, "", serverIdleShutdownCommandTable },
{ "info", SEC_PLAYER, true, &ChatHandler::HandleServerInfoCommand, "", NULL },
{ "log", SEC_CONSOLE, true, NULL, "", serverLogCommandTable },
{ "motd", SEC_PLAYER, true, &ChatHandler::HandleServerMotdCommand, "", NULL },
@ -2637,8 +2635,6 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*=
if (*tail == ':' && somethingPair) // optional data extraction
{
// :something...|h[name]|h|r
if (*tail == ':')
++tail;
// something|h[name]|h|r or something:something2...|h[name]|h|r
@ -3626,9 +3622,9 @@ void ChatHandler::LogCommand(char const* fullcmd)
}
void ChatHandler::BuildChatPacket(WorldPacket& data, ChatMsg msgtype, char const* message, Language language /*= LANG_UNIVERSAL*/, ChatTagFlags chatTag /*= CHAT_TAG_NONE*/,
ObjectGuid const& senderGuid /*= ObjectGuid()*/, char const* senderName /*= nullptr*/,
ObjectGuid const& targetGuid /*= ObjectGuid()*/, char const* targetName /*= nullptr*/,
char const* channelName /*= nullptr*/, uint32 achievementId /*= 0*/, const char* addonPrefix /*= nullptr*/)
ObjectGuid const& senderGuid /*= ObjectGuid()*/, char const* senderName /*= NULL*/,
ObjectGuid const& targetGuid /*= ObjectGuid()*/, char const* targetName /*= NULL*/,
char const* channelName /*= NULL*/, uint32 achievementId /*= 0*/, const char* addonPrefix /*= NULL*/)
{
bool isGM = chatTag & CHAT_TAG_GM;
bool isAchievement = false;

View file

@ -368,7 +368,6 @@ class ChatHandler
//-----------------------Npc Commands-----------------------
bool HandleNpcAddCommand(char* args);
bool HandleNpcAddMoveCommand(char* args);
bool HandleNpcAddVendorCurrencyCommand(char* args);
bool HandleNpcAddVendorItemCommand(char* args);
bool HandleNpcAIInfoCommand(char* args);
@ -538,6 +537,7 @@ class ChatHandler
bool HandleServerLogLevelCommand(char* args);
bool HandleServerMotdCommand(char* args);
bool HandleServerPLimitCommand(char* args);
bool HandleServerResetAllRaidCommand(char* args);
bool HandleServerRestartCommand(char* args);
bool HandleServerSetMotdCommand(char* args);
bool HandleServerShutDownCommand(char* args);
@ -640,8 +640,6 @@ class ChatHandler
bool HandleMmap(char* args);
bool HandleMmapTestArea(char* args);
bool HandleReloadPhaseDefinitionsCommand(char* /*args*/);
//! Development Commands
bool HandleSaveAllCommand(char* args);

View file

@ -774,14 +774,14 @@ void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data)
player->GetSession()->SendPacket(&data);
}
void WorldSession::SendPlayerNotFoundNotice(std::string name)
void WorldSession::SendPlayerNotFoundNotice(const std::string& name)
{
WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, name.size() + 1);
data << name;
SendPacket(&data);
}
void WorldSession::SendPlayerAmbiguousNotice(std::string name)
void WorldSession::SendPlayerAmbiguousNotice(const std::string& name)
{
WorldPacket data(SMSG_CHAT_PLAYER_AMBIGUOUS, name.size() + 1);
data << name;

View file

@ -261,6 +261,7 @@ enum EventMask
EVENT_MASK_ON_DIE = FLAG_DESPAWN_ON_DEATH | FLAG_SELFKILL_ON_DEATH | FLAG_RESPAWN_ON_DEATH | FLAG_FOLLOW,
EVENT_MASK_ON_RESPAWN = FLAG_RESPAWN_ON_RESPAWN | FLAG_DESPAWN_ON_RESPAWN | FLAG_FOLLOW,
EVENT_MASK_TRIGGER_TO = FLAG_TO_AGGRO_ON_AGGRO | FLAG_TO_RESPAWN_ON_EVADE | FLAG_FOLLOW,
EVENT_MASK_ON_DESPAWN = FLAG_DESPAWN_ON_DESPAWN,
};
// This functions checks if the NPC has linked NPCs for dynamic action
@ -413,6 +414,7 @@ void CreatureLinkingHolder::DoCreatureLinkingEvent(CreatureLinkingEvent eventTyp
case LINKING_EVENT_EVADE: eventFlagFilter = EVENT_MASK_ON_EVADE; reverseEventFlagFilter = FLAG_TO_RESPAWN_ON_EVADE; break;
case LINKING_EVENT_DIE: eventFlagFilter = EVENT_MASK_ON_DIE; reverseEventFlagFilter = 0; break;
case LINKING_EVENT_RESPAWN: eventFlagFilter = EVENT_MASK_ON_RESPAWN; reverseEventFlagFilter = FLAG_FOLLOW; break;
case LINKING_EVENT_DESPAWN: eventFlagFilter = EVENT_MASK_ON_DESPAWN; reverseEventFlagFilter = 0; break;
}
// Process Slaves (by entry)
@ -470,6 +472,7 @@ void CreatureLinkingHolder::DoCreatureLinkingEvent(CreatureLinkingEvent eventTyp
SetFollowing(pSource, pMaster);
break;
case LINKING_EVENT_DIE: // Nothing linked for this case
case LINKING_EVENT_DESPAWN: // Nothing linked for this case
break;
}
}
@ -549,6 +552,11 @@ void CreatureLinkingHolder::ProcessSlave(CreatureLinkingEvent eventType, Creatur
if (flag & FLAG_FOLLOW && pSlave->IsAlive() && !pSlave->IsInCombat())
SetFollowing(pSlave, pSource);
break;
case LINKING_EVENT_DESPAWN:
if (flag & FLAG_DESPAWN_ON_DESPAWN && !pSlave->IsDespawned())
pSlave->ForcedDespawn();
break;
}
}

View file

@ -56,6 +56,7 @@ enum CreatureLinkingEvent
LINKING_EVENT_EVADE = 1,
LINKING_EVENT_DIE = 2,
LINKING_EVENT_RESPAWN = 3,
LINKING_EVENT_DESPAWN = 4,
};
// enum describing possible flags action flags for NPCs linked to other NPCs
@ -77,12 +78,13 @@ enum CreatureLinkingFlags
// Dynamic behaviour, out of combat
FLAG_FOLLOW = 0x0200,
FLAG_DESPAWN_ON_DESPAWN = 0x2000,
// Passive behaviour
FLAG_CANT_SPAWN_IF_BOSS_DEAD = 0x0400,
FLAG_CANT_SPAWN_IF_BOSS_ALIVE = 0x0800,
LINKING_FLAG_INVALID = 0x2000, // TODO adjust when other flags are implemented
LINKING_FLAG_INVALID = 0x4000, // TODO adjust when other flags are implemented
};
// Structure holding the information for an entry

View file

@ -555,8 +555,11 @@ namespace MaNGOS
void Visit(CameraMapType& m)
{
for (CameraMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->GetBody()->InSamePhase(i_searcher) && itr->getSource()->GetBody()->IsWithinDist(i_searcher, i_dist))
i_do(itr->getSource()->GetOwner());
{
Camera* camera = itr->getSource();
if (camera->GetBody()->InSamePhase(i_searcher) && camera->GetBody()->IsWithinDist(i_searcher, i_dist))
i_do(camera->GetOwner());
}
}
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
@ -678,13 +681,14 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_unit; }
bool operator()(GameObject* go) const
{
if (go->GetGOInfo()->type != GAMEOBJECT_TYPE_SPELL_FOCUS)
GameObjectInfo const* goInfo = go->GetGOInfo();
if (goInfo->type != GAMEOBJECT_TYPE_SPELL_FOCUS)
return false;
if (go->GetGOInfo()->spellFocus.focusId != i_focusId)
if (goInfo->spellFocus.focusId != i_focusId)
return false;
float dist = (float)go->GetGOInfo()->spellFocus.dist;
float dist = (float)goInfo->spellFocus.dist;
return go->IsWithinDistInMap(i_unit, dist);
}

View file

@ -485,7 +485,7 @@ void Group::Disband(bool hideDestroy)
}
m_leaderGuid.Clear();
m_leaderName = "";
m_leaderName.clear();
}
/*********************************************************/

View file

@ -37,6 +37,8 @@
#include "Util.h"
#include "DB2Structure.h"
#include "DB2Stores.h"
#include "Vehicle.h"
#include "TransportSystem.h"
/* differeces from off:
-you can uninvite yourself - is is useful
@ -905,6 +907,14 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke
*data << uint32(0);
*data << uint8(0);
}
if (mask & GROUP_UPDATE_FLAG_VEHICLE_SEAT)
{
if (player->GetTransportInfo())
*data << uint32(((Unit*)player->GetTransportInfo()->GetTransport())->GetVehicleInfo()->GetVehicleEntry()->m_seatID[player->GetTransportInfo()->GetTransportSeat()]);
else
*data << uint32(0);
}
}
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
@ -1048,6 +1058,9 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data)
data << uint32(0); // GROUP_UPDATE_FLAG_PET_AURAS
}
if (player->GetTransportInfo()) // GROUP_UPDATE_FLAG_VEHICLE_SEAT
data << uint32(((Unit*)player->GetTransportInfo()->GetTransport())->GetVehicleInfo()->GetVehicleEntry()->m_seatID[player->GetTransportInfo()->GetTransportSeat()]);
data << uint32(8); // GROUP_UPDATE_FLAG_PHASE
data << uint32(0); // GROUP_UPDATE_FLAG_PHASE
data << uint8(0); // GROUP_UPDATE_FLAG_PHASE

View file

@ -59,3 +59,39 @@ bool InstanceData::CheckConditionCriteriaMeet(Player const* /*source*/, uint32 i
instance->GetId(), instance_condition_id, uint32(conditionSourceType));
return false;
}
void InstanceData::SendEncounterFrame(uint32 type, ObjectGuid sourceGuid /*= NULL*/, uint8 param1 /*= 0*/, uint8 param2 /*= 0*/)
{
// size of this packet is at most 15 (usually less)
WorldPacket data(SMSG_INSTANCE_ENCOUNTER, 15);
data << uint32(type);
switch (type)
{
case ENCOUNTER_FRAME_ENGAGE:
case ENCOUNTER_FRAME_DISENGAGE:
case ENCOUNTER_FRAME_UPDATE_PRIORITY:
MANGOS_ASSERT(sourceGuid);
data << sourceGuid.WriteAsPacked();
data << uint8(param1);
break;
case ENCOUNTER_FRAME_ADD_TIMER:
case ENCOUNTER_FRAME_ENABLE_OBJECTIVE:
case ENCOUNTER_FRAME_DISABLE_OBJECTIVE:
case ENCOUNTER_FRAME_SET_COMBAT_RES_LIMIT:
data << uint8(param1);
break;
case ENCOUNTER_FRAME_UPDATE_OBJECTIVE:
data << uint8(param1);
data << uint8(param2);
break;
case ENCOUNTER_FRAME_UNK7:
case ENCOUNTER_FRAME_ADD_COMBAT_RES_LIMIT:
case ENCOUNTER_FRAME_RESET_COMBAT_RES_LIMIT:
default:
break;
}
instance->SendToPlayers(&data);
}

View file

@ -27,6 +27,7 @@
#include "Common.h"
#include "ObjectGuid.h"
#include "WorldPacket.h"
class Map;
class Unit;
@ -55,7 +56,22 @@ enum InstanceConditionIDs // Suggested values
INSTANCE_CONDITION_ID_ULDUAR = 33113,
};
class InstanceData
enum EncounterFrameTypes // only raid UI specific
{
ENCOUNTER_FRAME_SET_COMBAT_RES_LIMIT = 0,
ENCOUNTER_FRAME_RESET_COMBAT_RES_LIMIT = 1,
ENCOUNTER_FRAME_ENGAGE = 2,
ENCOUNTER_FRAME_DISENGAGE = 3,
ENCOUNTER_FRAME_UPDATE_PRIORITY = 4,
ENCOUNTER_FRAME_ADD_TIMER = 5,
ENCOUNTER_FRAME_ENABLE_OBJECTIVE = 6,
ENCOUNTER_FRAME_UPDATE_OBJECTIVE = 7,
ENCOUNTER_FRAME_DISABLE_OBJECTIVE = 8,
ENCOUNTER_FRAME_UNK7 = 9, // Seems to have something to do with sorting the encounter units
ENCOUNTER_FRAME_ADD_COMBAT_RES_LIMIT = 10
};
class MANGOS_DLL_SPEC InstanceData
{
public:
@ -128,6 +144,9 @@ class InstanceData
// This is used for such things are heroic loot
// See ObjectMgr.h enum ConditionSource for possible values of conditionSourceType
virtual bool CheckConditionCriteriaMeet(Player const* source, uint32 instance_condition_id, WorldObject const* conditionSource, uint32 conditionSourceType) const;
// Special UI unit frame - sent mostly for raid bosses
void SendEncounterFrame(uint32 type, ObjectGuid sourceGuid = ObjectGuid(), uint8 param1 = 0, uint8 param2 = 0);
};
#endif

View file

@ -223,35 +223,6 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry)
SendPacket(&data);
}
/*
* pre dev21 version
* delete this if the one below it proves to be good (chucky)
void WorldSession::SendLfgJoinResult(LfgJoinResult result)
{
WorldPacket data(SMSG_LFG_JOIN_RESULT, 0);
data << uint32(result);
data << uint32(0); // ERR_LFG_ROLE_CHECK_FAILED_TIMEOUT = 3, ERR_LFG_ROLE_CHECK_FAILED_NOT_VIABLE = (value - 3 == result)
if (result == ERR_LFG_NO_SLOTS_PARTY)
{
uint8 count1 = 0;
data << uint8(count1); // players count?
for (uint32 i = 0; i < count1; ++i)
{
data << uint64(0); // player guid?
uint32 count2 = 0;
for (uint32 j = 0; j < count2; ++j)
{
data << uint32(0); // dungeon id/type
data << uint32(0); // lock status?
}
}
}
SendPacket(&data);
}
*/
void WorldSession::SendLfgJoinResult(LfgJoinResult result, LFGState state, partyForbidden const& lockedDungeons)
{
uint32 packetSize = 0;

View file

@ -747,7 +747,7 @@ void Map::CreatureRelocation(Creature* creature, float x, float y, float z, floa
MANGOS_ASSERT(CheckGridIntegrity(creature, true));
}
bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
bool Map::CreatureCellRelocation(Creature* c, const Cell& new_cell)
{
Cell const& old_cell = c->GetCurrentCell();
if (old_cell.DiffGrid(new_cell))
@ -1311,6 +1311,32 @@ void Map::CreateInstanceData(bool load)
}
} */
void Map::TeleportAllPlayersTo(TeleportLocation loc)
{
while (HavePlayers())
{
if (Player* plr = m_mapRefManager.getFirst()->getSource())
{
// Teleport to specified location and removes the player from this map (if the map exists).
// Todo : we can add some specific location if needed (ex: map exit location for dungeon)
switch (loc)
{
case TELEPORT_LOCATION_HOMEBIND:
plr->TeleportToHomebind();
break;
case TELEPORT_LOCATION_BG_ENTRY_POINT:
plr->TeleportToBGEntryPoint();
break;
default:
break;
}
// just in case, remove the player from the list explicitly here as well to prevent a possible infinite loop
// note that this remove is not needed if the code works well in other places
plr->GetMapRef().unlink();
}
}
}
void Map::SetWeather(uint32 zoneId, WeatherType type, float grade, bool permanently)
{
Weather* wth = m_weatherSystem->FindOrCreateWeather(zoneId);
@ -1565,15 +1591,7 @@ void DungeonMap::PermBindAllPlayers(Player* player)
void DungeonMap::UnloadAll(bool pForce)
{
if (HavePlayers())
{
sLog.outError("DungeonMap::UnloadAll: there are still players in the instance at unload, should not happen!");
for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
{
Player* plr = itr->getSource();
plr->TeleportToHomebind();
}
}
TeleportAllPlayersTo(TELEPORT_LOCATION_HOMEBIND);
if (m_resetAfterUnload == true)
GetPersistanceState()->DeleteRespawnTimes();
@ -1669,17 +1687,10 @@ void BattleGroundMap::SetUnload()
void BattleGroundMap::UnloadAll(bool pForce)
{
while (HavePlayers())
{
if (Player* plr = m_mapRefManager.getFirst()->getSource())
{
plr->TeleportTo(plr->GetBattleGroundEntryPoint());
// TeleportTo removes the player from this map (if the map exists) -> calls BattleGroundMap::Remove -> invalidates the iterator.
// just in case, remove the player from the list explicitly here as well to prevent a possible infinite loop
// note that this remove is not needed if the code works well in other places
plr->GetMapRef().unlink();
}
}
TeleportAllPlayersTo(TELEPORT_LOCATION_BG_ENTRY_POINT);
Map::UnloadAll(pForce);
TeleportAllPlayersTo(TELEPORT_LOCATION_BG_ENTRY_POINT);
Map::UnloadAll(pForce);
}

View file

@ -323,7 +323,7 @@ class Map : public GridRefManager<NGridType>
void SendInitTransports(Player* player);
void SendRemoveTransports(Player* player);
bool CreatureCellRelocation(Creature* creature, Cell new_cell);
bool CreatureCellRelocation(Creature* c, const Cell& new_cell);
bool loaded(const GridPair&) const;
void EnsureGridCreated(const GridPair&);

View file

@ -44,7 +44,10 @@
INSTANTIATE_SINGLETON_1(MapPersistentStateManager);
static uint32 resetEventTypeDelay[MAX_RESET_EVENT_TYPE] = { 0, 3600, 900, 300, 60 };
static uint32 resetEventTypeDelay[MAX_RESET_EVENT_TYPE] = { 0, // not used
3600, 900, 300, 60, // (seconds) normal and official timer delay to inform player about instance reset
60, 30, 10, 5 // (seconds) fast reset by gm command inform timer
};
//== MapPersistentState functions ==========================
MapPersistentState::MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty)
@ -220,6 +223,11 @@ DungeonPersistentState::DungeonPersistentState(uint16 MapId, uint32 InstanceId,
DungeonPersistentState::~DungeonPersistentState()
{
DEBUG_LOG("Unloading DungeonPersistantState of map %u instance %u", GetMapId(), GetInstanceId());
UnbindThisState();
}
void DungeonPersistentState::UnbindThisState()
{
while (!m_playerList.empty())
{
Player* player = *(m_playerList.begin());
@ -537,7 +545,7 @@ void DungeonResetScheduler::ScheduleReset(bool add, time_t time, DungeonResetEve
void DungeonResetScheduler::Update()
{
time_t now = time(NULL), t;
time_t now = time(nullptr), t;
while (!m_resetTimeQueue.empty() && (t = m_resetTimeQueue.begin()->first) < now)
{
DungeonResetEvent& event = m_resetTimeQueue.begin()->second;
@ -550,8 +558,10 @@ void DungeonResetScheduler::Update()
{
// global reset/warning for a certain map
time_t resetTime = GetResetTimeFor(event.mapid, event.difficulty);
m_InstanceSaves._ResetOrWarnAll(event.mapid, event.difficulty, event.type != RESET_EVENT_INFORM_LAST, uint32(resetTime - now));
if (event.type != RESET_EVENT_INFORM_LAST)
uint32 timeLeft = uint32(std::max(int32(resetTime - now), 0));
bool warn = event.type != RESET_EVENT_INFORM_LAST && event.type != RESET_EVENT_FORCED_INFORM_LAST;
m_InstanceSaves._ResetOrWarnAll(event.mapid, event.difficulty, warn, timeLeft);
if (event.type != RESET_EVENT_INFORM_LAST && event.type != RESET_EVENT_FORCED_INFORM_LAST)
{
// schedule the next warning/reset
event.type = ResetEventType(event.type + 1);
@ -584,6 +594,32 @@ void DungeonResetScheduler::Update()
}
}
void DungeonResetScheduler::ResetAllRaid()
{
time_t now = time(nullptr);
ResetTimeQueue rTQ;
rTQ.clear();
time_t timeleft = resetEventTypeDelay[RESET_EVENT_FORCED_INFORM_1];
for (ResetTimeQueue::iterator itr = m_resetTimeQueue.begin(); itr != m_resetTimeQueue.end(); ++itr)
{
DungeonResetEvent& event = itr->second;
// we only reset raid dungeon
if (event.type == RESET_EVENT_NORMAL_DUNGEON)
{
rTQ.insert(std::pair<time_t, DungeonResetEvent>(itr->first, event));
continue;
}
event.type = RESET_EVENT_FORCED_INFORM_1;
time_t next_reset = now + timeleft;
SetResetTimeFor(event.mapid, event.difficulty, next_reset);
rTQ.insert(std::pair<time_t, DungeonResetEvent>(now, event));
}
m_resetTimeQueue = rTQ;
}
//== MapPersistentStateManager functions =========================
MapPersistentStateManager::MapPersistentStateManager() : lock_instLists(false), m_Scheduler(*this)
@ -855,14 +891,37 @@ void MapPersistentStateManager::_ResetInstance(uint32 mapid, uint32 instanceId)
DeleteInstanceFromDB(instanceId); // even if state not loaded
}
struct MapPersistantStateResetWorker
{
MapPersistantStateResetWorker() {};
void operator()(Map* map)
{
((DungeonMap*)map)->TeleportAllPlayersTo(TELEPORT_LOCATION_HOMEBIND);
((DungeonMap*)map)->Reset(INSTANCE_RESET_GLOBAL);
}
};
struct MapPersistantStateWarnWorker
{
MapPersistantStateWarnWorker(time_t _timeLeft) : timeLeft(_timeLeft)
{};
void operator()(Map* map)
{
((DungeonMap*)map)->SendResetWarnings(timeLeft);
}
time_t timeLeft;
};
void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeLeft)
{
// global reset for all instances of the given map
MapEntry const* mapEntry = sMapStore.LookupEntry(mapid);
if (!mapEntry->Instanceable())
if (!mapEntry->IsDungeon())
return;
time_t now = time(NULL);
time_t now = time(nullptr);
if (!warn)
{
@ -873,14 +932,21 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficu
return;
}
// remove all binds to instances of the given map
for (PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end();)
{
// remove all binds for online player
std::list<DungeonPersistentState *> unbindList;
// note that we must build a list of states to unbind and then unbind them in two steps. this is because the unbinding may
// trigger the modification of the collection, which would invalidate the iterator and cause a crash.
for (PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end(); ++itr)
if (itr->second->GetMapId() == mapid && itr->second->GetDifficulty() == difficulty)
_ResetSave(m_instanceSaveByInstanceId, itr);
else
++itr;
}
unbindList.push_back((DungeonPersistentState *)itr->second);
for (auto i : unbindList)
i->UnbindThisState();
// reset maps, teleport player automaticaly to their homebinds and unload maps
MapPersistantStateResetWorker worker;
sMapMgr.DoForAllMapsWithMapId(mapid, worker);
// delete them from the DB, even if not loaded
CharacterDatabase.BeginTransaction();
@ -893,23 +959,12 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficu
time_t next_reset = DungeonResetScheduler::CalculateNextResetTime(mapDiff, now + timeLeft);
// update it in the DB
CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '" UI64FMTD "' WHERE mapid = '%u' AND difficulty = '%u'", (uint64)next_reset, mapid, difficulty);
return;
}
// note: this isn't fast but it's meant to be executed very rarely
const MapManager::MapMapType& maps = sMapMgr.Maps();
MapManager::MapMapType::const_iterator iter_last = maps.lower_bound(MapID(mapid + 1));
for (MapManager::MapMapType::const_iterator mitr = maps.lower_bound(MapID(mapid)); mitr != iter_last; ++mitr)
{
Map* map2 = mitr->second;
if (map2->GetId() != mapid)
break;
if (warn)
((DungeonMap*)map2)->SendResetWarnings(timeLeft);
else
((DungeonMap*)map2)->Reset(INSTANCE_RESET_GLOBAL);
}
MapPersistantStateWarnWorker worker(timeLeft);
sMapMgr.DoForAllMapsWithMapId(mapid, worker);
}
void MapPersistentStateManager::GetStatistics(uint32& numStates, uint32& numBoundPlayers, uint32& numBoundGroups)

View file

@ -229,6 +229,8 @@ class DungeonPersistentState : public MapPersistentState
void DeleteFromDB();
/* Delete respawn data at dungeon reset */
void DeleteRespawnTimes();
/* Remove players bind to this state */
void UnbindThisState();
protected:
bool CanBeUnload() const override; // overwrite MapPersistentState::CanBeUnload
@ -278,9 +280,13 @@ enum ResetEventType
RESET_EVENT_INFORM_2 = 2,
RESET_EVENT_INFORM_3 = 3,
RESET_EVENT_INFORM_LAST = 4,
RESET_EVENT_FORCED_INFORM_1 = 5,
RESET_EVENT_FORCED_INFORM_2 = 6,
RESET_EVENT_FORCED_INFORM_3 = 7,
RESET_EVENT_FORCED_INFORM_LAST = 8,
};
#define MAX_RESET_EVENT_TYPE 5
#define MAX_RESET_EVENT_TYPE 9
/* resetTime is a global propery of each (raid/heroic) map
all instances of that map reset at the same time */
@ -323,6 +329,7 @@ class DungeonResetScheduler
void Update();
void ResetAllRaid();
private: // fields
MapPersistentStateManager& m_InstanceSaves;

View file

@ -41,7 +41,8 @@
INSTANTIATE_SINGLETON_1(MassMailMgr);
void MassMailMgr::AddMassMailTask(MailDraft* mailProto, MailSender sender, uint32 raceMask)
void MassMailMgr::AddMassMailTask(MailDraft* mailProto, const MailSender& sender, uint32 raceMask)
{
if (RACEMASK_ALL_PLAYABLE & ~raceMask) // have races not included in mask
{
@ -72,9 +73,9 @@ struct MassMailerQueryHandler
}
} massMailerQueryHandler;
void MassMailMgr::AddMassMailTask(MailDraft* mailProto, MailSender sender, char const* query)
void MassMailMgr::AddMassMailTask(MailDraft* mailProto, const MailSender& sender, char const* query)
{
CharacterDatabase.AsyncPQuery(&massMailerQueryHandler, &MassMailerQueryHandler::HandleQueryCallback, mailProto, sender, query);
CharacterDatabase.AsyncPQuery(&massMailerQueryHandler, &MassMailerQueryHandler::HandleQueryCallback, mailProto, sender, "%s", query);
}
void MassMailMgr::Update(bool sendall /*= false*/)

View file

@ -70,7 +70,7 @@ class MassMailMgr
*
* Note: this function safe to be called from Map::Update content/etc, real data add will executed in next tick after query results ready
*/
void AddMassMailTask(MailDraft* mailProto, MailSender sender, uint32 raceMask);
void AddMassMailTask(MailDraft* mailProto, const MailSender& sender, uint32 raceMask);
/**
* And new mass mail task with SQL query text for fill receivers list.
@ -80,7 +80,7 @@ class MassMailMgr
*
* Note: this function safe to be called from Map::Update content/etc, real data add will executed in next tick after query results ready
*/
void AddMassMailTask(MailDraft* mailProto, MailSender sender, char const* queryStr);
void AddMassMailTask(MailDraft* mailProto, const MailSender& sender, char const* queryStr);
/**
* And new mass mail task and let fill receivers list returned as result.
@ -90,7 +90,7 @@ class MassMailMgr
*
* Note: this function NOT SAFE for call from Map::Update content/etc
*/
ReceiversList& AddMassMailTask(MailDraft* mailProto, MailSender sender)
ReceiversList& AddMassMailTask(MailDraft* mailProto, const MailSender& sender)
{
m_massMails.push_back(MassMail(mailProto, sender));
return m_massMails.rbegin()->m_receivers;

View file

@ -59,6 +59,9 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data)
if (GetPlayer()->IsAlive() || GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
return;
if (GetPlayer()->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
return;
// the world update order is sessions, players, creatures
// the netcode runs in parallel with all of these
// creatures can kill players

View file

@ -1,383 +0,0 @@
/*
* This file is part of the MaNGOS Project. See AUTHORS file for Copyright information
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#include "PhaseMgr.h"
#include "Chat.h"
#include "Language.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "SpellAuras.h"
//////////////////////////////////////////////////////////////////
// Updating
PhaseMgr::PhaseMgr(Player* _player) : player(_player), _UpdateFlags(0)
{
phaseData = new PhaseData(_player);
_PhaseDefinitionStore = sObjectMgr.GetPhaseDefinitionStore();
_SpellPhaseStore = sObjectMgr.GetSpellPhaseStore();
}
void PhaseMgr::Update()
{
if (IsUpdateInProgress())
return;
if (_UpdateFlags & PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED)
phaseData->SendPhaseshiftToPlayer();
if (_UpdateFlags & PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED)
phaseData->SendPhaseMaskToPlayer();
_UpdateFlags = 0;
}
void PhaseMgr::RemoveUpdateFlag(PhaseUpdateFlag updateFlag)
{
_UpdateFlags &= ~updateFlag;
if (updateFlag == PHASE_UPDATE_FLAG_ZONE_UPDATE)
{
// Update zone changes
if (phaseData->HasActiveDefinitions())
{
phaseData->ResetDefinitions();
_UpdateFlags |= (PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED | PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED);
}
if (_PhaseDefinitionStore->find(player->GetZoneId()) != _PhaseDefinitionStore->end())
Recalculate();
}
Update();
}
/////////////////////////////////////////////////////////////////
// Notifier
void PhaseMgr::NotifyConditionChanged(PhaseUpdateData const& updateData)
{
if (NeedsPhaseUpdateWithData(updateData))
{
Recalculate();
Update();
}
}
//////////////////////////////////////////////////////////////////
// Phasing Definitions
void PhaseMgr::Recalculate()
{
if (phaseData->HasActiveDefinitions())
{
phaseData->ResetDefinitions();
_UpdateFlags |= (PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED | PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED);
}
PhaseDefinitionStore::const_iterator itr = _PhaseDefinitionStore->find(player->GetZoneId());
if (itr != _PhaseDefinitionStore->end())
for (PhaseDefinitionContainer::const_iterator phase = itr->second.begin(); phase != itr->second.end(); ++phase)
if (CheckDefinition(*phase))
{
phaseData->AddPhaseDefinition(*phase);
if ((*phase)->phasemask)
_UpdateFlags |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
if ((*phase)->phaseId || (*phase)->terrainswapmap)
_UpdateFlags |= PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED;
if ((*phase)->IsLastDefinition())
break;
}
}
inline bool PhaseMgr::CheckDefinition(PhaseDefinition const* phaseDefinition)
{
return !phaseDefinition->conditionId || sObjectMgr.IsPlayerMeetToCondition(phaseDefinition->conditionId, player, player->GetMap(), player, CONDITION_FROM_PHASEMGR);
}
bool PhaseMgr::NeedsPhaseUpdateWithData(PhaseUpdateData const updateData)
{
PhaseDefinitionStore::const_iterator itr = _PhaseDefinitionStore->find(player->GetZoneId());
if (itr != _PhaseDefinitionStore->end())
{
for (PhaseDefinitionContainer::const_iterator phase = itr->second.begin(); phase != itr->second.end(); ++phase)
{
std::vector<PlayerCondition const*> conditions;
sObjectMgr.GetConditions((*phase)->conditionId, conditions);
for (std::vector<PlayerCondition const*>::const_iterator itr = conditions.begin(); itr != conditions.end(); ++itr)
if (updateData.IsConditionRelated(*itr))
return true;
}
}
return false;
}
//////////////////////////////////////////////////////////////////
// Auras
void PhaseMgr::RegisterPhasingAuraEffect(Aura const* auraEffect)
{
PhaseInfo* phaseInfo = new PhaseInfo();
if (auraEffect->GetMiscValue())
{
_UpdateFlags |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
phaseInfo->phasemask = auraEffect->GetMiscValue();
}
else
{
SpellPhaseStore::const_iterator itr = _SpellPhaseStore->find(auraEffect->GetHolder()->GetId());
if (itr != _SpellPhaseStore->end())
{
if (itr->second->phasemask)
{
_UpdateFlags |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
phaseInfo->phasemask = itr->second->phasemask;
}
if (itr->second->terrainswapmap)
phaseInfo->terrainswapmap = itr->second->terrainswapmap;
}
}
// this is not Phase.dbc id...
// phaseInfo->phaseId = auraEffect->GetMiscBValue();
if (phaseInfo->NeedsClientSideUpdate())
_UpdateFlags |= PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED;
phaseData->AddAuraInfo(auraEffect->GetHolder()->GetId(), phaseInfo);
Update();
}
void PhaseMgr::UnRegisterPhasingAuraEffect(Aura const* auraEffect)
{
_UpdateFlags |= phaseData->RemoveAuraInfo(auraEffect->GetHolder()->GetId());
Update();
}
//////////////////////////////////////////////////////////////////
// Commands
void PhaseMgr::SendDebugReportToPlayer(Player* const debugger)
{
ChatHandler(debugger).PSendSysMessage(LANG_PHASING_REPORT_STATUS, player->GetName(), player->GetZoneId(), player->getLevel(), player->GetTeam(), _UpdateFlags);
PhaseDefinitionStore::const_iterator itr = _PhaseDefinitionStore->find(player->GetZoneId());
if (itr == _PhaseDefinitionStore->end())
ChatHandler(debugger).PSendSysMessage(LANG_PHASING_NO_DEFINITIONS, player->GetZoneId());
else
{
for (PhaseDefinitionContainer::const_iterator phase = itr->second.begin(); phase != itr->second.end(); ++phase)
{
if (CheckDefinition(*phase))
ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_SUCCESS, (*phase)->entry, (*phase)->IsNegatingPhasemask() ? "negated Phase" : "Phase", (*phase)->phasemask);
else
ChatHandler(debugger).PSendSysMessage(LANG_PHASING_FAILED, (*phase)->phasemask, (*phase)->entry, (*phase)->zoneId);
if ((*phase)->IsLastDefinition())
{
ChatHandler(debugger).PSendSysMessage(LANG_PHASING_LAST_PHASE, (*phase)->phasemask, (*phase)->entry, (*phase)->zoneId);
break;
}
}
}
ChatHandler(debugger).PSendSysMessage(LANG_PHASING_LIST, phaseData->_PhasemaskThroughDefinitions, phaseData->_PhasemaskThroughAuras, phaseData->_CustomPhasemask);
ChatHandler(debugger).PSendSysMessage(LANG_PHASING_PHASEMASK, phaseData->GetPhaseMaskForSpawn(), player->GetPhaseMask());
}
void PhaseMgr::SetCustomPhase(uint32 const phaseMask)
{
phaseData->_CustomPhasemask = phaseMask;
// phase auras normally not expected at BG but anyway better check
if (BattleGround* bg = player->GetBattleGround())
bg->EventPlayerDroppedFlag(player);
_UpdateFlags |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
Update();
}
//////////////////////////////////////////////////////////////////
// Phase Data
uint32 PhaseData::GetCurrentPhasemask() const
{
if (player->isGameMaster())
return uint32(PHASEMASK_ANYWHERE);
if (_CustomPhasemask)
return _CustomPhasemask;
return GetPhaseMaskForSpawn();
}
inline uint32 PhaseData::GetPhaseMaskForSpawn() const
{
uint32 const phase = (_PhasemaskThroughDefinitions | _PhasemaskThroughAuras);
return (phase ? phase : PHASEMASK_NORMAL);
}
void PhaseData::SendPhaseMaskToPlayer()
{
// Server side update
uint32 const phasemask = GetCurrentPhasemask();
if (player->GetPhaseMask() == phasemask)
return;
player->SetPhaseMask(phasemask, false);
if (player->IsInWorld())
player->UpdateVisibilityAndView();
}
void PhaseData::SendPhaseshiftToPlayer()
{
// Client side update
std::set<uint32> phaseIds;
std::set<uint32> terrainswaps;
for (PhaseInfoContainer::const_iterator itr = spellPhaseInfo.begin(); itr != spellPhaseInfo.end(); ++itr)
{
if (itr->second->terrainswapmap)
terrainswaps.insert(itr->second->terrainswapmap);
if (itr->second->phaseId)
phaseIds.insert(itr->second->phaseId);
}
// Phase Definitions
for (std::list<PhaseDefinition const*>::const_iterator itr = activePhaseDefinitions.begin(); itr != activePhaseDefinitions.end(); ++itr)
{
if ((*itr)->phaseId)
phaseIds.insert((*itr)->phaseId);
if ((*itr)->terrainswapmap)
terrainswaps.insert((*itr)->terrainswapmap);
}
player->GetSession()->SendSetPhaseShift(phaseIds, terrainswaps);
}
void PhaseData::AddPhaseDefinition(PhaseDefinition const* phaseDefinition)
{
if (phaseDefinition->IsOverwritingExistingPhases())
{
activePhaseDefinitions.clear();
_PhasemaskThroughDefinitions = phaseDefinition->phasemask;
}
else
{
if (phaseDefinition->IsNegatingPhasemask())
_PhasemaskThroughDefinitions &= ~phaseDefinition->phasemask;
else
_PhasemaskThroughDefinitions |= phaseDefinition->phasemask;
}
activePhaseDefinitions.push_back(phaseDefinition);
}
void PhaseData::AddAuraInfo(uint32 const spellId, PhaseInfo* phaseInfo)
{
if (phaseInfo->phasemask)
_PhasemaskThroughAuras |= phaseInfo->phasemask;
spellPhaseInfo[spellId] = phaseInfo;
}
uint32 PhaseData::RemoveAuraInfo(uint32 const spellId)
{
PhaseInfoContainer::iterator rAura = spellPhaseInfo.find(spellId);
if (rAura != spellPhaseInfo.end())
{
uint32 updateflag = 0;
if (rAura->second->NeedsClientSideUpdate())
updateflag |= PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED;
if (rAura->second->NeedsServerSideUpdate())
{
_PhasemaskThroughAuras = 0;
updateflag |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
spellPhaseInfo.erase(rAura);
for (PhaseInfoContainer::const_iterator itr = spellPhaseInfo.begin(); itr != spellPhaseInfo.end(); ++itr)
_PhasemaskThroughAuras |= itr->second->phasemask;
}
return updateflag;
}
else
return 0;
}
//////////////////////////////////////////////////////////////////
// Phase Update Data
void PhaseUpdateData::AddQuestUpdate(uint32 const questId)
{
AddConditionType(CONDITION_QUESTREWARDED);
AddConditionType(CONDITION_QUESTTAKEN);
AddConditionType(CONDITION_QUEST_NONE);
_questId = questId;
}
bool PhaseUpdateData::IsConditionRelated(PlayerCondition const* condition) const
{
switch (condition->m_condition)
{
case CONDITION_QUESTREWARDED:
case CONDITION_QUESTTAKEN:
case CONDITION_QUEST_NONE:
return condition->m_value1 == _questId && ((1 << condition->m_condition) & _conditionTypeFlags);
default:
return (1 << condition->m_condition) & _conditionTypeFlags;
}
}
bool PhaseMgr::IsConditionTypeSupported(ConditionType const conditionType)
{
switch (conditionType)
{
case CONDITION_QUESTREWARDED:
case CONDITION_QUESTTAKEN:
case CONDITION_QUEST_NONE:
case CONDITION_TEAM:
case CONDITION_RACE_CLASS:
case CONDITION_LEVEL:
return true;
default:
return false;
}
}

View file

@ -1,175 +0,0 @@
/*
* This file is part of the MaNGOS Project. See AUTHORS file for Copyright information
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef MANGOS_PHASEMGR_H
#define MANGOS_PHASEMGR_H
#include "SharedDefines.h"
#include "ObjectMgr.h"
class ObjectMgr;
class Player;
class Aura;
class PlayerCondition;
// Phasing (visibility)
enum PhasingFlags
{
PHASE_FLAG_OVERWRITE_EXISTING = 0x01, // don't stack with existing phases, overwrites existing phases
PHASE_FLAG_NO_MORE_PHASES = 0x02, // stop calculating phases after this phase was applied (no more phases will be applied)
PHASE_FLAG_NEGATE_PHASE = 0x04 // negate instead to add the phasemask
};
enum PhaseUpdateFlag
{
PHASE_UPDATE_FLAG_ZONE_UPDATE = 0x01,
PHASE_UPDATE_FLAG_AREA_UPDATE = 0x02,
// Internal flags
PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED = 0x08,
PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED = 0x10,
};
struct PhaseDefinition
{
uint32 zoneId;
uint32 entry;
uint32 phasemask;
uint32 phaseId;
uint32 terrainswapmap;
uint8 flags;
uint16 conditionId;
bool IsOverwritingExistingPhases() const { return flags & PHASE_FLAG_OVERWRITE_EXISTING; }
bool IsLastDefinition() const { return flags & PHASE_FLAG_NO_MORE_PHASES; }
bool IsNegatingPhasemask() const { return flags & PHASE_FLAG_NEGATE_PHASE; }
};
struct SpellPhaseInfo
{
uint32 spellId;
uint32 phasemask;
uint32 terrainswapmap;
};
struct PhaseInfo
{
PhaseInfo() : phasemask(0), terrainswapmap(0), phaseId(0) {}
uint32 phasemask;
uint32 terrainswapmap;
uint32 phaseId;
bool NeedsServerSideUpdate() const { return phasemask; }
bool NeedsClientSideUpdate() const { return terrainswapmap || phaseId; }
};
typedef UNORDERED_MAP<uint32 /*spellId*/, PhaseInfo*> PhaseInfoContainer;
struct PhaseData
{
PhaseData(Player* _player) : _PhasemaskThroughDefinitions(0), _PhasemaskThroughAuras(0), _CustomPhasemask(0), player(_player) {}
uint32 _PhasemaskThroughDefinitions;
uint32 _PhasemaskThroughAuras;
uint32 _CustomPhasemask;
uint32 GetCurrentPhasemask() const;
inline uint32 GetPhaseMaskForSpawn() const;
void ResetDefinitions() { _PhasemaskThroughDefinitions = 0; activePhaseDefinitions.clear(); }
void AddPhaseDefinition(PhaseDefinition const* phaseDefinition);
bool HasActiveDefinitions() const { return !activePhaseDefinitions.empty(); }
void AddAuraInfo(uint32 const spellId, PhaseInfo* phaseInfo);
uint32 RemoveAuraInfo(uint32 const spellId);
void SendPhaseMaskToPlayer();
void SendPhaseshiftToPlayer();
private:
Player* player;
std::list<PhaseDefinition const*> activePhaseDefinitions;
PhaseInfoContainer spellPhaseInfo;
};
struct PhaseUpdateData
{
void AddConditionType(ConditionType const conditionType) { _conditionTypeFlags |= (1 << conditionType); }
void AddQuestUpdate(uint32 const questId);
bool IsConditionRelated(PlayerCondition const* condition) const;
private:
uint32 _conditionTypeFlags;
uint32 _questId;
};
class PhaseMgr
{
public:
PhaseMgr(Player* _player);
~PhaseMgr() { delete phaseData; }
uint32 GetCurrentPhasemask() { return phaseData->GetCurrentPhasemask(); };
inline uint32 GetPhaseMaskForSpawn() { return phaseData->GetCurrentPhasemask(); }
// Phase definitions update handling
void NotifyConditionChanged(PhaseUpdateData const& updateData);
void NotifyStoresReloaded() { Recalculate(); Update(); }
void Update();
// Aura phase effects
void RegisterPhasingAuraEffect(Aura const* auraEffect);
void UnRegisterPhasingAuraEffect(Aura const* auraEffect);
// Update flags (delayed phasing)
void AddUpdateFlag(PhaseUpdateFlag const updateFlag) { _UpdateFlags |= updateFlag; }
void RemoveUpdateFlag(PhaseUpdateFlag const updateFlag);
// Needed for modify phase command
void SetCustomPhase(uint32 const phaseMask);
// Debug
void SendDebugReportToPlayer(Player* const debugger);
static bool IsConditionTypeSupported(ConditionType const conditionType);
private:
void Recalculate();
inline bool CheckDefinition(PhaseDefinition const* phaseDefinition);
bool NeedsPhaseUpdateWithData(PhaseUpdateData const updateData);
inline bool IsUpdateInProgress() const { return (_UpdateFlags & PHASE_UPDATE_FLAG_ZONE_UPDATE) || (_UpdateFlags & PHASE_UPDATE_FLAG_AREA_UPDATE); }
PhaseDefinitionStore const* _PhaseDefinitionStore;
SpellPhaseStore const* _SpellPhaseStore;
Player* player;
PhaseData* phaseData;
uint8 _UpdateFlags;
};
#endif

View file

@ -100,7 +100,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult* result, uint32
uint32 lowguid = fields[0].GetUInt32();
std::string name = fields[1].GetCppString();
uint8 pRace = 0, pGender = 0, pClass = 0;
if (name == "")
if (name.empty())
name = session->GetMangosString(LANG_NON_EXIST_CHARACTER);
else
{
@ -120,7 +120,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult* result, uint32
data << uint8(pClass); // class
// if the first declined name field (5) is empty, the rest must be too
if (sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED) && fields[5].GetCppString() != "")
if (sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED) && !fields[5].GetCppString().empty())
{
data << uint8(1); // is declined
for (int i = 5; i < MAX_DECLINED_NAME_CASES + 5; ++i)

View file

@ -35,7 +35,6 @@
#include "ObjectAccessor.h"
#include "ScriptMgr.h"
#include "Group.h"
#include "PhaseMgr.h"
void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recv_data)
{
@ -352,11 +351,6 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data)
}
_player->SetQuestStatus(quest, QUEST_STATUS_NONE);
PhaseUpdateData phaseUdateData;
phaseUdateData.AddQuestUpdate(quest);
_player->GetPhaseMgr()->NotifyConditionChanged(phaseUdateData);
}
_player->SetQuestSlot(slot, 0);

View file

@ -1547,12 +1547,12 @@ bool ScriptAction::HandleScriptStep()
}
// bitmask: 0/1=target-player, 0/2=with distance dependent, 0/4=map wide, 0/8=zone wide
Player* pSoundTarget = NULL;
Player* pSoundTarget = nullptr;
if (m_script->playSound.flags & 1)
{
pSoundTarget = GetPlayerTargetOrSourceAndLog(pSource, pTarget);
if (!pSoundTarget)
{ break; }
break;
}
if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL)
@ -1560,11 +1560,11 @@ bool ScriptAction::HandleScriptStep()
else
{
if (m_script->playSound.flags & 2)
{ pSource->PlayDistanceSound(m_script->playSound.soundId, pSoundTarget); }
pSource->PlayDistanceSound(m_script->playSound.soundId, pSoundTarget);
else if (m_script->playSound.flags & (4 | 8))
{ m_map->PlayDirectSoundToMap(m_script->playSound.soundId, m_script->playSound.flags & 8 ? pSource->GetZoneId() : 0); }
m_map->PlayDirectSoundToMap(m_script->playSound.soundId, m_script->playSound.flags & 8 ? pSource->GetZoneId() : 0);
else
{ pSource->PlayDirectSound(m_script->playSound.soundId, pSoundTarget); }
pSource->PlayDirectSound(m_script->playSound.soundId, pSoundTarget);
}
break;
}
@ -2697,3 +2697,8 @@ uint32 GetScriptIdsCount()
{
return sScriptMgr.GetScriptIdsCount();
}
bool AddWaypointFromExternal(uint32 entry, int32 pathId, uint32 pointId, float x, float y, float z, float o, uint32 waittime)
{
return sWaypointMgr.AddExternalNode(entry, pathId, pointId, x, y, z, o, waittime);
}

View file

@ -128,7 +128,7 @@ SpellCastTargets::SpellCastTargets()
m_itemTargetEntry = 0;
m_srcX = m_srcY = m_srcZ = m_destX = m_destY = m_destZ = 0.0f;
m_strTarget = "";
m_strTarget.clear();
m_targetMask = 0;
m_elevation = 0.0f;
@ -1406,7 +1406,7 @@ void Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask)
if (m_applyMultiplierMask & (1 << effectNumber))
{
// Get multiplier
float multiplier = spellEffect ? spellEffect->DmgMultiplier : 1.0f;
float multiplier = spellEffect ? spellEffect->EffectDamageMultiplier : 1.0f;
// Apply multiplier mods
if (realCaster)
if (Player* modOwner = realCaster->GetSpellModOwner())
@ -1529,7 +1529,7 @@ void Spell::HandleDelayedSpellLaunch(TargetInfo* target)
if (m_applyMultiplierMask & (1 << effectNumber))
{
// Get multiplier
float multiplier = spellEffect ? spellEffect->DmgMultiplier : 1.0f;
float multiplier = spellEffect ? spellEffect->EffectDamageMultiplier : 1.0f;
// Apply multiplier mods
if (real_caster)
if (Player* modOwner = real_caster->GetSpellModOwner())
@ -1771,6 +1771,8 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
targetUnitMap.push_back(m_caster);
break;
case TARGET_RANDOM_ENEMY_CHAIN_IN_AREA:
case TARGET_RANDOM_FRIEND_CHAIN_IN_AREA:
case TARGET_RANDOM_UNIT_CHAIN_IN_AREA:
{
m_targets.m_targetMask = 0;
unMaxTargets = EffectChainTarget;
@ -1778,70 +1780,29 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
UnitList tempTargetUnitMap;
switch (targetMode)
{
case TARGET_RANDOM_ENEMY_CHAIN_IN_AREA:
{
MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(m_caster, max_range);
MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(tempTargetUnitMap, u_check);
Cell::VisitAllObjects(m_caster, searcher, max_range);
}
if (tempTargetUnitMap.empty())
break;
tempTargetUnitMap.sort(TargetDistanceOrderNear(m_caster));
// Now to get us a random target that's in the initial range of the spell
uint32 t = 0;
UnitList::iterator itr = tempTargetUnitMap.begin();
while (itr != tempTargetUnitMap.end() && (*itr)->IsWithinDist(m_caster, radius))
++t, ++itr;
if (!t)
break;
itr = tempTargetUnitMap.begin();
std::advance(itr, rand() % t);
Unit* pUnitTarget = *itr;
targetUnitMap.push_back(pUnitTarget);
tempTargetUnitMap.erase(itr);
tempTargetUnitMap.sort(TargetDistanceOrderNear(pUnitTarget));
t = unMaxTargets - 1;
Unit* prev = pUnitTarget;
UnitList::iterator next = tempTargetUnitMap.begin();
while (t && next != tempTargetUnitMap.end())
{
if (!prev->IsWithinDist(*next, CHAIN_SPELL_JUMP_RADIUS))
break;
if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX2_IGNORE_LOS) && !prev->IsWithinLOSInMap(*next))
{
++next;
continue;
}
prev = *next;
targetUnitMap.push_back(prev);
tempTargetUnitMap.erase(next);
tempTargetUnitMap.sort(TargetDistanceOrderNear(prev));
next = tempTargetUnitMap.begin();
--t;
}
break;
}
case TARGET_RANDOM_FRIEND_CHAIN_IN_AREA:
{
m_targets.m_targetMask = 0;
unMaxTargets = EffectChainTarget;
float max_range = radius + unMaxTargets * CHAIN_SPELL_JUMP_RADIUS;
UnitList tempTargetUnitMap;
{
MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(m_caster, max_range);
MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(tempTargetUnitMap, u_check);
Cell::VisitAllObjects(m_caster, searcher, max_range);
break;
}
case TARGET_RANDOM_UNIT_CHAIN_IN_AREA:
{
MaNGOS::AnyUnitInObjectRangeCheck u_check(m_caster, max_range);
MaNGOS::UnitListSearcher<MaNGOS::AnyUnitInObjectRangeCheck> searcher(tempTargetUnitMap, u_check);
Cell::VisitAllObjects(m_caster, searcher, max_range);
break;
}
}
if (tempTargetUnitMap.empty())
@ -1974,6 +1935,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
switch (m_spellInfo->Id)
{
// Do not target current victim
case 30769: // Pick Red Riding Hood
case 30843: // Enfeeble
case 31347: // Doom
case 37676: // Insidious Whisper
@ -2010,10 +1972,12 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case SPELL_EFFECT_KILL_CREDIT_PERSONAL:
case SPELL_EFFECT_KILL_CREDIT_GROUP:
targetB = SPELL_TARGETS_ALL;
break;
default:
// Select friendly targets for positive effect
if (IsPositiveEffect(m_spellInfo, effIndex))
targetB = SPELL_TARGETS_FRIENDLY;
break;
}
UnitList tempTargetUnitMap;
@ -2055,9 +2019,6 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
}
}
}
// exclude caster
targetUnitMap.remove(m_caster);
break;
}
case TARGET_AREAEFFECT_CUSTOM:
@ -2302,10 +2263,6 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER:
switch (m_spellInfo->Id)
{
case 56153: // Guardian Aura - Ahn'Kahet
FillAreaTargets(targetUnitMap, radius, PUSH_SELF_CENTER, SPELL_TARGETS_FRIENDLY);
targetUnitMap.remove(m_caster);
break;
case 64844: // Divine Hymn
// target amount stored in parent spell dummy effect but hard to access
FillRaidOrPartyHealthPriorityTargets(targetUnitMap, m_caster, m_caster, radius, 3, true, false, true);
@ -2364,7 +2321,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
if (target && target != m_caster)
{
// Can only be casted on group's members or its pets
Group* pGroup = NULL;
Group* pGroup = nullptr;
Unit* owner = m_caster->GetCharmerOrOwner();
Unit* targetOwner = target->GetCharmerOrOwner();
@ -2431,9 +2388,57 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case TARGET_LARGE_FRONTAL_CONE:
FillAreaTargets(targetUnitMap, radius, PUSH_IN_FRONT_90, SPELL_TARGETS_AOE_DAMAGE);
break;
case TARGET_NARROW_FRONTAL_CONE:
FillAreaTargets(targetUnitMap, radius, PUSH_IN_FRONT_15, SPELL_TARGETS_AOE_DAMAGE);
case TARGET_FRIENDLY_FRONTAL_CONE:
FillAreaTargets(targetUnitMap, radius, PUSH_IN_FRONT_30, SPELL_TARGETS_FRIENDLY);
break;
case TARGET_NARROW_FRONTAL_CONE:
case TARGET_NARROW_FRONTAL_CONE_2:
{
SpellTargets targetB = SPELL_TARGETS_AOE_DAMAGE;
if (spellEffect->Effect == SPELL_EFFECT_SCRIPT_EFFECT)
targetB = SPELL_TARGETS_ALL;
UnitList tempTargetUnitMap;
SQLMultiStorage::SQLMSIteratorBounds<SpellTargetEntry> bounds = sSpellScriptTargetStorage.getBounds<SpellTargetEntry>(m_spellInfo->Id);
// fill real target list if no spell script target defined
FillAreaTargets(bounds.first != bounds.second ? tempTargetUnitMap : targetUnitMap,
radius, PUSH_IN_FRONT_15, bounds.first != bounds.second ? SPELL_TARGETS_ALL : targetB);
if (!tempTargetUnitMap.empty())
{
for (UnitList::const_iterator iter = tempTargetUnitMap.begin(); iter != tempTargetUnitMap.end(); ++iter)
{
if ((*iter)->GetTypeId() != TYPEID_UNIT)
continue;
for (SQLMultiStorage::SQLMultiSIterator<SpellTargetEntry> i_spellST = bounds.first; i_spellST != bounds.second; ++i_spellST)
{
if (i_spellST->CanNotHitWithSpellEffect(effIndex))
continue;
// only creature entries supported for this target type
if (i_spellST->type == SPELL_TARGET_TYPE_GAMEOBJECT)
continue;
if ((*iter)->GetEntry() == i_spellST->targetEntry)
{
if (i_spellST->type == SPELL_TARGET_TYPE_DEAD && ((Creature*)(*iter))->IsCorpse())
{
targetUnitMap.push_back((*iter));
}
else if (i_spellST->type == SPELL_TARGET_TYPE_CREATURE && (*iter)->IsAlive())
{
targetUnitMap.push_back((*iter));
}
break;
}
}
}
}
break;
}
case TARGET_IN_FRONT_OF_CASTER_30:
FillAreaTargets(targetUnitMap, radius, PUSH_IN_FRONT_30, SPELL_TARGETS_AOE_DAMAGE);
break;
@ -2486,6 +2491,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
if (m_targets.getUnitTarget() && m_targets.getUnitTarget() != pUnitTarget)
m_spellFlags |= SPELL_FLAG_REDIRECTED;
m_targets.setUnitTarget(pUnitTarget);
targetUnitMap.push_back(pUnitTarget);
}
break;
@ -2493,7 +2499,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case TARGET_AREAEFFECT_PARTY:
{
Unit* owner = m_caster->GetCharmerOrOwner();
Player* pTarget = NULL;
Player* pTarget = nullptr;
if (owner)
{
@ -2519,13 +2525,13 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
}
}
Group* pGroup = pTarget ? pTarget->GetGroup() : NULL;
Group* pGroup = pTarget ? pTarget->GetGroup() : nullptr;
if (pGroup)
{
uint8 subgroup = pTarget->GetSubGroup();
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
for (GroupReference* itr = pGroup->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* Target = itr->getSource();
@ -2641,12 +2647,12 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case TARGET_AREAEFFECT_PARTY_AND_CLASS:
{
Player* targetPlayer = m_targets.getUnitTarget() && m_targets.getUnitTarget()->GetTypeId() == TYPEID_PLAYER
? (Player*)m_targets.getUnitTarget() : NULL;
? (Player*)m_targets.getUnitTarget() : nullptr;
Group* pGroup = targetPlayer ? targetPlayer->GetGroup() : NULL;
Group* pGroup = targetPlayer ? targetPlayer->GetGroup() : nullptr;
if (pGroup)
{
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
for (GroupReference* itr = pGroup->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* Target = itr->getSource();
@ -2683,7 +2689,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case TARGET_RIGHT_FROM_VICTIM:
case TARGET_LEFT_FROM_VICTIM:
{
Unit* pTarget = NULL;
Unit* pTarget = nullptr;
// explicit cast data from client or server-side cast
// some spell at client send caster
@ -2770,7 +2776,6 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case TARGET_POINT_AT_SE:
case TARGET_POINT_AT_SW:
{
if (!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
{
Unit* currentTarget = m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster;
@ -2968,6 +2973,10 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
break;
}
// remove caster from the list if required by attribute
if (targetMode != TARGET_SELF && targetMode != TARGET_SELF2 && m_spellInfo->HasAttribute(SPELL_ATTR_EX_CANT_TARGET_SELF))
targetUnitMap.remove(m_caster);
if (unMaxTargets && targetUnitMap.size() > unMaxTargets)
{
// make sure one unit is always removed per iteration
@ -6038,6 +6047,42 @@ SpellCastResult Spell::CheckCast(bool strict)
}
break;
}
case SPELL_EFFECT_RESURRECT:
case SPELL_EFFECT_RESURRECT_NEW:
{
if (m_targets.m_targetMask & (TARGET_FLAG_CORPSE | TARGET_FLAG_PVP_CORPSE))
{
if (Corpse* corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid()))
{
if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid()))
{
if (owner->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED;
}
else
return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED;
}
else
return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED;
}
else if (m_targets.m_targetMask & TARGET_FLAG_UNIT)
{
Unit* target = m_targets.getUnitTarget();
if (!target || target->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED;
}
else
return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED;
break;
}
case SPELL_EFFECT_SELF_RESURRECT:
{
if (m_caster->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED;
break;
}
case SPELL_EFFECT_LEAP:
case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER:
{
@ -6608,9 +6653,11 @@ SpellCastResult Spell::CheckRange(bool strict)
return SPELL_CAST_OK;
float range_mod = strict ? 0.0f : 5.0f;
float base = ATTACK_DISTANCE;
if (Player* modOwner = m_caster->GetSpellModOwner())
range_mod += modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, base, this);
{
float base = ATTACK_DISTANCE;
range_mod += modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, base);
}
// with additional 5 dist for non stricted case (some melee spells have delay in apply
return m_caster->CanReachWithMeleeAttack(target, range_mod) ? SPELL_CAST_OK : SPELL_FAILED_OUT_OF_RANGE;
@ -6628,7 +6675,7 @@ SpellCastResult Spell::CheckRange(bool strict)
float min_range = GetSpellMinRange(srange, friendly);
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, max_range, this);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, max_range);
if (target && target != m_caster)
{
@ -7382,16 +7429,22 @@ bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff)
if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
return false;
// unselectable targets skipped in all cases except TARGET_SCRIPT targeting
// unselectable targets skipped in all cases except TARGET_SCRIPT targeting or vehicle passengers
// in case TARGET_SCRIPT target selected by server always and can't be cheated
if ((!m_IsTriggeredSpell || target != m_targets.getUnitTarget()) &&
target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) &&
(!target->GetTransportInfo() || (target->GetTransportInfo() &&
!((Unit*)target->GetTransportInfo()->GetTransport())->IsVehicle())) &&
spellEffect->EffectImplicitTargetA != TARGET_SCRIPT &&
spellEffect->EffectImplicitTargetB != TARGET_SCRIPT &&
spellEffect->EffectImplicitTargetA != TARGET_AREAEFFECT_INSTANT &&
spellEffect->EffectImplicitTargetB != TARGET_AREAEFFECT_INSTANT &&
spellEffect->EffectImplicitTargetA != TARGET_AREAEFFECT_CUSTOM &&
spellEffect->EffectImplicitTargetB != TARGET_AREAEFFECT_CUSTOM )
spellEffect->EffectImplicitTargetB != TARGET_AREAEFFECT_CUSTOM &&
spellEffect->EffectImplicitTargetA != TARGET_NARROW_FRONTAL_CONE &&
spellEffect->EffectImplicitTargetB != TARGET_NARROW_FRONTAL_CONE &&
spellEffect->EffectImplicitTargetA != TARGET_NARROW_FRONTAL_CONE_2 &&
spellEffect->EffectImplicitTargetB != TARGET_NARROW_FRONTAL_CONE_2)
return false;
}
@ -7999,15 +8052,21 @@ void Spell::GetSpellRangeAndRadius(SpellEffectEntry const* spellEffect, float& r
case 62577: // Blizzard (Ulduar, Thorim)
case 62603: // Blizzard (h) (Ulduar, Thorim)
case 62797: // Storm Cloud (Ulduar, Hodir)
case 62978: // Summon Guardian (Ulduar, Yogg Saron)
case 63018: // Searing Light (Ulduar, XT-002)
case 63024: // Gravity Bomb (Ulduar, XT-002)
case 63545: // Icicle (Ulduar, Hodir)
case 63744: // Sara's Anger (Ulduar, Yogg-Saron)
case 63745: // Sara's Blessing (Ulduar, Yogg-Saron)
case 63747: // Sara's Fervor (Ulduar, Yogg-Saron)
case 63795: // Psychosis (Ulduar, Yogg-Saron)
case 63820: // Summon Scrap Bot Trigger (Ulduar, Mimiron) use for Scrap Bots, hits npc 33856
case 63830: // Malady of the Mind (Ulduar, Yogg-Saron)
case 64218: // Overcharge (VoA, Emalon)
case 64234: // Gravity Bomb (h) (Ulduar, XT-002)
case 64402: // Rocket Strike (Ulduar, Mimiron)
case 64425: // Summon Scrap Bot Trigger (Ulduar, Mimiron) use for Assault Bots, hits npc 33856
case 64465: // Shadow Beacon (Ulduar, Yogg-Saron)
case 64543: // Melt Ice (Ulduar, Hodir)
case 64623: // Frost Bomb (Ulduar, Mimiron)
case 65121: // Searing Light (h) (Ulduar, XT-002)
@ -8055,6 +8114,7 @@ void Spell::GetSpellRangeAndRadius(SpellEffectEntry const* spellEffect, float& r
case 10258: // Awaken Vault Warder (Uldaman)
case 28542: // Life Drain (Naxx, Sapphiron)
case 62476: // Icicle (Ulduar, Hodir)
case 63802: // Brain Link (Ulduar, Yogg-Saron)
case 66013: // Penetrating Cold (10 man) (ToCrusader, Anub'arak)
case 67755: // Nerubian Burrower (Mode 1) (ToCrusader, Anub'arak)
case 67756: // Nerubian Burrower (Mode 2) (ToCrusader, Anub'arak)
@ -8243,6 +8303,10 @@ void Spell::GetSpellRangeAndRadius(SpellEffectEntry const* spellEffect, float& r
case 73143: // Bone Spike Graveyard (during Bone Storm) (Icecrown Citadel, Lord Marrowgar encounter, 25N)
case 73144: // Bone Spike Graveyard (during Bone Storm) (Icecrown Citadel, Lord Marrowgar encounter, 10H)
case 73145: // Bone Spike Graveyard (during Bone Storm) (Icecrown Citadel, Lord Marrowgar encounter, 25H)
case 72350: // Fury of Frostmourne
case 72351: // Fury of Frostmourne
case 72706: // Achievement Check
case 72830: // Achievement Check
radius = DEFAULT_VISIBILITY_INSTANCE;
break;
default:

View file

@ -382,6 +382,8 @@ class Spell
void EffectActivateSpec(SpellEffectEntry const* effect);
void EffectCancelAura(SpellEffectEntry const* effect);
void EffectKnockBackFromPosition(SpellEffectEntry const* effect);
void EffectGravityPull(SpellEffectEntry const* effect);
void EffectCreateTamedPet(SpellEffectEntry const* effect);
Spell(Unit* caster, SpellEntry const* info, bool triggered, ObjectGuid originalCasterGUID = ObjectGuid(), SpellEntry const* triggeredBy = NULL);
~Spell();

View file

@ -85,9 +85,6 @@ enum AuraType
* 50 the attackspeed will increase by 50%
*/
SPELL_AURA_MOD_ATTACKSPEED = 9,
//This doesn't make sense if you look at SpellAuras.cpp:2696
//Where a bitwise check is made, but the SpellSchools enum is just
//a normal enumeration, not in the style: 1 2 4 8 ...
/**
* Modifies the threat that the Aura does in percent,
* the Modifier::m_miscvalue decides which of the SpellSchools
@ -391,7 +388,7 @@ enum AuraType
SPELL_AURA_MOD_EXPERTISE = 240,
SPELL_AURA_FORCE_MOVE_FORWARD = 241,
SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING = 242,
SPELL_AURA_243 = 243,
SPELL_AURA_FACTION_OVERRIDE = 243,
SPELL_AURA_COMPREHEND_LANGUAGE = 244,
SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS = 245,
SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL = 246,
@ -427,12 +424,12 @@ enum AuraType
SPELL_AURA_MOD_DAMAGE_DONE_BY_MECHANIC = 276,
SPELL_AURA_277 = 277, // SPELL_AURA_MOD_MAX_AFFECTED_TARGETS
SPELL_AURA_MOD_DISARM_RANGED = 278,
SPELL_AURA_INITIALIZE_IMAGES = 279,
SPELL_AURA_MIRROR_NAME = 279,
SPELL_AURA_280 = 280, // old SPELL_AURA_MOD_TARGET_ARMOR_PCT
SPELL_AURA_MOD_HONOR_GAIN = 281,
SPELL_AURA_MOD_BASE_HEALTH_PCT = 282,
SPELL_AURA_MOD_HEALING_RECEIVED = 283, // Possibly only for some spell family class spells
SPELL_AURA_284 = 284,
SPELL_AURA_TRIGGER_LINKED_AURA = 284,
SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR = 285,
SPELL_AURA_ABILITY_PERIODIC_CRIT = 286,
SPELL_AURA_DEFLECT_SPELLS = 287,

File diff suppressed because it is too large Load diff

View file

@ -414,6 +414,10 @@ class Aura
void HandleAuraModBlockCritChance(bool apply, bool Real);
void HandleModIncreaseSpellPowerPct(bool apply, bool Real);
void HandleOverrideSpellPowerByAp(bool apply, bool Real);
void HandleMirrorName(bool apply, bool Real);
void HandlePreventResurrection(bool apply, bool Real);
void HandleFactionOverride(bool apply, bool Real);
void HandleTriggerLinkedAura(bool apply, bool Real);
virtual ~Aura();

File diff suppressed because it is too large Load diff

View file

@ -602,6 +602,9 @@ void WorldSession::HandleSelfResOpcode(WorldPacket& /*recv_data*/)
{
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: CMSG_SELF_RES"); // empty opcode
if (_player->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
return;
if (_player->GetUInt32Value(PLAYER_SELF_RES_SPELL))
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(_player->GetUInt32Value(PLAYER_SELF_RES_SPELL));
@ -617,7 +620,8 @@ void WorldSession::HandleSpellClick(WorldPacket& recv_data)
ObjectGuid guid;
recv_data >> guid;
if (_player->IsInCombat()) // client prevent click and set different icon at combat state
// client prevent click and set different icon at combat state; however combat state is allowed for dungeons
if (_player->IsInCombat() && !_player->GetMap()->IsDungeon())
return;
Creature* unit = _player->GetMap()->GetAnyTypeCreature(guid);
@ -629,10 +633,16 @@ void WorldSession::HandleSpellClick(WorldPacket& recv_data)
{
if (itr->second.IsFitToRequirements(_player, unit))
{
if (sScriptMgr.OnNpcSpellClick(_player, unit, itr->second.spellId))
return;
Unit* caster = (itr->second.castFlags & 0x1) ? (Unit*)_player : (Unit*)unit;
Unit* target = (itr->second.castFlags & 0x2) ? (Unit*)_player : (Unit*)unit;
if (itr->second.spellId)
caster->CastSpell(target, itr->second.spellId, true);
else
sLog.outError("WorldSession::HandleSpellClick: npc_spell_click with entry %u has 0 in spell_id. Not handled custom case?", unit->GetEntry());
}
}
}

Some files were not shown because too many files have changed in this diff Show more