aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorNay <dnpd.dd@gmail.com>2012-12-27 17:53:34 +0000
committerNay <dnpd.dd@gmail.com>2012-12-27 17:53:34 +0000
commit7e196e8e58800c3e0cde80a07f20c4ecccd1a842 (patch)
treed77aa80f8e6bd417eb2d8b368006fd3d7fc8fa19 /src/server/game/Entities
parent79b1895223bbf16bfd6484e34e067beea457e4cc (diff)
parent7fe2d7309ae3b850f3a7c75fc9bb6ec18bea00a1 (diff)
Merge remote-tracking branch 'origin/master' into mmaps
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Object/Object.cpp14
-rw-r--r--src/server/game/Entities/Player/Player.cpp62
-rw-r--r--src/server/game/Entities/Player/Player.h9
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp22
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
5 files changed, 52 insertions, 57 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 6f16618491e..5c6f287b726 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -302,6 +302,19 @@ void Object::DestroyForPlayer(Player* target, bool onDeath) const
{
ASSERT(target);
+ if (isType(TYPEMASK_UNIT) || isType(TYPEMASK_PLAYER))
+ {
+ if (Battleground* bg = target->GetBattleground())
+ {
+ if (bg->isArena())
+ {
+ WorldPacket data(SMSG_ARENA_UNIT_DESTROYED, 8);
+ data << uint64(GetGUID());
+ target->GetSession()->SendPacket(&data);
+ }
+ }
+ }
+
WorldPacket data(SMSG_DESTROY_OBJECT, 8 + 1);
data << uint64(GetGUID());
//! If the following bool is true, the client will call "void CGUnit_C::OnDeath()" for this object.
@@ -2254,6 +2267,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
mask = UNIT_MASK_GUARDIAN;
break;
case SUMMON_TYPE_TOTEM:
+ case SUMMON_TYPE_LIGHTWELL:
mask = UNIT_MASK_TOTEM;
break;
case SUMMON_TYPE_VEHICLE:
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index bca94517ef4..3607e8a9ec3 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -2031,24 +2031,18 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data)
return true;
}
-bool Player::ToggleAFK()
+void Player::ToggleAFK()
{
ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK);
- bool state = HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK);
-
// afk player not allowed in battleground
- if (state && InBattleground() && !InArena())
+ if (isAFK() && InBattleground() && !InArena())
LeaveBattleground();
-
- return state;
}
-bool Player::ToggleDND()
+void Player::ToggleDND()
{
ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND);
-
- return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND);
}
uint8 Player::GetChatTag() const
@@ -15232,7 +15226,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
_SaveQuestStatus(trans);
if (announce)
- SendQuestReward(quest, XP, questGiver);
+ SendQuestReward(quest, XP);
// cast spells after mark quest complete (some spells have quest completed state requirements in spell_area data)
if (quest->GetRewSpellCast() > 0)
@@ -16042,7 +16036,7 @@ void Player::KilledMonsterCredit(uint32 entry, uint64 guid)
continue;
// just if !ingroup || !noraidgroup || raidgroup
QuestStatusData& q_status = m_QuestStatus[questid];
- if (q_status.Status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid()))
+ if (q_status.Status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid(GetMap()->GetDifficulty())))
{
if (qInfo->HasFlag(QUEST_TRINITY_FLAGS_KILL_OR_CAST))
{
@@ -16097,7 +16091,7 @@ void Player::KilledPlayerCredit()
continue;
// just if !ingroup || !noraidgroup || raidgroup
QuestStatusData& q_status = m_QuestStatus[questid];
- if (q_status.Status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid()))
+ if (q_status.Status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid(GetMap()->GetDifficulty())))
{
if (qInfo->HasFlag(QUEST_TRINITY_FLAGS_PLAYER_KILL))
{
@@ -16365,7 +16359,7 @@ bool Player::HasQuestForItem(uint32 itemid) const
continue;
// hide quest if player is in raid-group and quest is no raid quest
- if (GetGroup() && GetGroup()->isRaidGroup() && !qinfo->IsAllowedInRaid())
+ if (GetGroup() && GetGroup()->isRaidGroup() && !qinfo->IsAllowedInRaid(GetMap()->GetDifficulty()))
if (!InBattleground()) //there are two ways.. we can make every bg-quest a raidquest, or add this code here.. i don't know if this can be exploited by other quests, but i think all other quests depend on a specific area.. but keep this in mind, if something strange happens later
continue;
@@ -16413,7 +16407,7 @@ void Player::SendQuestComplete(uint32 quest_id)
}
}
-void Player::SendQuestReward(Quest const* quest, uint32 XP, Object* questGiver)
+void Player::SendQuestReward(Quest const* quest, uint32 XP)
{
uint32 questid = quest->GetQuestId();
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTGIVER_QUEST_COMPLETE quest = %u", questid);
@@ -16436,9 +16430,6 @@ void Player::SendQuestReward(Quest const* quest, uint32 XP, Object* questGiver)
data << uint32(quest->GetBonusTalents()); // bonus talents
data << uint32(quest->GetRewArenaPoints());
GetSession()->SendPacket(&data);
-
- if (quest->GetQuestCompleteScript() != 0)
- GetMap()->ScriptsStart(sQuestEndScripts, quest->GetQuestCompleteScript(), questGiver, this);
}
void Player::SendQuestFailed(uint32 questId, InventoryResult reason)
@@ -20089,42 +20080,29 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver)
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer);
- // when player you are whispering to is dnd, he cannot receive your message, unless you are in gm mode
- if (!rPlayer->isDND() || isGameMaster())
- {
- WorldPacket data(SMSG_MESSAGECHAT, 200);
- BuildPlayerChat(&data, CHAT_MSG_WHISPER, _text, language);
- rPlayer->GetSession()->SendPacket(&data);
-
- // not send confirmation for addon messages
- if (!isAddonMessage)
- {
- data.Initialize(SMSG_MESSAGECHAT, 200);
- rPlayer->BuildPlayerChat(&data, CHAT_MSG_WHISPER_INFORM, _text, language);
- GetSession()->SendPacket(&data);
- }
- }
- else if (!isAddonMessage)
- // announce to player that player he is whispering to is dnd and cannot receive his message
- ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->dndMsg.c_str());
+ WorldPacket data(SMSG_MESSAGECHAT, 200);
+ BuildPlayerChat(&data, CHAT_MSG_WHISPER, _text, language);
+ rPlayer->GetSession()->SendPacket(&data);
// rest stuff shouldn't happen in case of addon message
if (isAddonMessage)
return;
+ data.Initialize(SMSG_MESSAGECHAT, 200);
+ rPlayer->BuildPlayerChat(&data, CHAT_MSG_WHISPER_INFORM, _text, language);
+ GetSession()->SendPacket(&data);
+
if (!isAcceptWhispers() && !isGameMaster() && !rPlayer->isGameMaster())
{
SetAcceptWhispers(true);
ChatHandler(GetSession()).SendSysMessage(LANG_COMMAND_WHISPERON);
}
- // announce to player that player he is whispering to is afk
+ // announce afk or dnd message
if (rPlayer->isAFK())
- ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName().c_str(), rPlayer->afkMsg.c_str());
-
- // if player whisper someone, auto turn of dnd to be able to receive an answer
- if (isDND() && !rPlayer->isGameMaster())
- ToggleDND();
+ ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_AFK, rPlayer->GetName().c_str(), rPlayer->autoReplyMsg.c_str());
+ else if (rPlayer->isDND())
+ ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->autoReplyMsg.c_str());
}
void Player::PetSpellInitialize()
@@ -22786,7 +22764,7 @@ bool Player::HasQuestForGO(int32 GOId) const
if (!qinfo)
continue;
- if (GetGroup() && GetGroup()->isRaidGroup() && !qinfo->IsAllowedInRaid())
+ if (GetGroup() && GetGroup()->isRaidGroup() && !qinfo->IsAllowedInRaid(GetMap()->GetDifficulty()))
continue;
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 1e8b6aedb3e..522fe529b41 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1108,13 +1108,12 @@ class Player : public Unit, public GridObject<Player>
Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask);
GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const;
- bool ToggleAFK();
- bool ToggleDND();
+ void ToggleAFK();
+ void ToggleDND();
bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); }
bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); }
uint8 GetChatTag() const;
- std::string afkMsg;
- std::string dndMsg;
+ std::string autoReplyMsg;
uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin=NULL);
@@ -1480,7 +1479,7 @@ class Player : public Unit, public GridObject<Player>
bool CanShareQuest(uint32 quest_id) const;
void SendQuestComplete(uint32 quest_id);
- void SendQuestReward(Quest const* quest, uint32 XP, Object* questGiver);
+ void SendQuestReward(Quest const* quest, uint32 XP);
void SendQuestFailed(uint32 questId, InventoryResult reason = EQUIP_ERR_OK);
void SendQuestTimerFailed(uint32 quest_id);
void SendCanTakeQuestResponse(uint32 msg) const;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index dee977de054..4148e3177fe 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -17064,7 +17064,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
}
if (IsInMap(caster))
- caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId+1, target, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, NULL, NULL, origCasterGUID);
+ caster->CastCustomSpell(itr->second.spellId, SpellValueMod(SPELLVALUE_BASE_POINT0+i), seatId, target, GetVehicleKit() ? TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE : TRIGGERED_NONE, NULL, NULL, origCasterGUID);
else // This can happen during Player::_LoadAuras
{
int32 bp0 = seatId;
@@ -17094,7 +17094,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
void Unit::EnterVehicle(Unit* base, int8 seatId)
{
- CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, seatId+1, base, TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE);
+ CastCustomSpell(VEHICLE_SPELL_RIDE_HARDCODED, SPELLVALUE_BASE_POINT0, seatId, base, TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE);
}
void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* aurApp)
@@ -17324,23 +17324,27 @@ void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool cas
ToPlayer()->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0));
else
{
- UpdatePosition(x, y, z, orientation, true);
- Position pos; // dummy, not used for creatures.
+ Position pos = {x, y, z, orientation};
SendTeleportPacket(pos);
+ UpdatePosition(x, y, z, orientation, true);
UpdateObjectVisibility();
}
}
-void Unit::SendTeleportPacket(Position& oldPos)
+void Unit::SendTeleportPacket(Position& pos)
{
+ Position oldPos = { GetPositionX(), GetPositionY(), GetPositionZMinusOffset(), GetOrientation() };
+ if (GetTypeId() == TYPEID_UNIT)
+ Relocate(&pos);
+
WorldPacket data2(MSG_MOVE_TELEPORT, 38);
data2.append(GetPackGUID());
BuildMovementPacket(&data2);
-
- if (GetTypeId() == TYPEID_PLAYER)
+ if (GetTypeId() == TYPEID_UNIT)
Relocate(&oldPos);
-
- SendMessageToSet(&data2, false);
+ if (GetTypeId() == TYPEID_PLAYER)
+ Relocate(&pos);
+ SendMessageToSet(&data2, true);
}
bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool teleport)
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 5dbf800dc31..c79cbca469f 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1593,7 +1593,7 @@ class Unit : public WorldObject
void SendSpellDamageImmune(Unit* target, uint32 spellId);
void NearTeleportTo(float x, float y, float z, float orientation, bool casting = false);
- void SendTeleportPacket(Position& oldPos);
+ void SendTeleportPacket(Position& pos);
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false);
// returns true if unit's position really changed
bool UpdatePosition(const Position &pos, bool teleport = false) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); }