Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core/Battlefield: wintergrasp #69

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/server/game/Entities/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,13 +1018,17 @@ void WorldObject::setActive(bool on)
map->AddToActive(ToCreature());
else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
map->AddToActive((DynamicObject*)this);
else if (GetTypeId() == TYPEID_GAMEOBJECT)
map->AddToActive((GameObject*)this);
}
else
{
if (GetTypeId() == TYPEID_UNIT)
map->RemoveFromActive(ToCreature());
else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
map->RemoveFromActive((DynamicObject*)this);
else if (GetTypeId() == TYPEID_GAMEOBJECT)
map->RemoveFromActive((GameObject*)this);
}
}

Expand Down
80 changes: 41 additions & 39 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6572,6 +6572,42 @@ void Player::RewardReputation(Quest const* quest)
}
}

/*
* If in a battleground or battlefield player dies, and an enemy removes the insignia, the player's bones is lootable
* Called by remove insignia spell effect
*/
void Player::RemovePVPInsignia(Player* looter)
{
// If player is not in battleground and not in battlefield
if (!GetBattlegroundId() && !sBattlefieldMgr->GetEnabledBattlefield(GetZoneId()))
return;

// If not released spirit, do it !
if (m_deathTimer > 0)
{
m_deathTimer = 0;
BuildPlayerRepop();
RepopAtGraveyard();
}

_corpseLocation.WorldRelocate();

// We have to convert player corpse to bones, not to be able to resurrect there
// SpawnCorpseBones isn't handy, 'cos it saves player
Corpse* bones = GetMap()->ConvertCorpseToBones(GetGUID(), true);
if (!bones)
return;

// Now we must make bones lootable, and send player loot
bones->SetFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE);

// We store the level of our player in the gold field
// We retrieve this information at Player::SendLoot()
bones->loot.gold = getLevel();
bones->lootRecipient = looter;
looter->SendLoot(bones->GetGUID(), LOOT_INSIGNIA);
}

void Player::UpdateHonorFields()
{
/// called when rewarding honor and at each save
Expand Down Expand Up @@ -8203,40 +8239,6 @@ bool Player::CheckAmmoCompatibility(ItemTemplate const* ammo_proto) const
return true;
}

/* If in a battleground a player dies, and an enemy removes the insignia, the player's bones is lootable
Called by remove insignia spell effect */
void Player::RemovedInsignia(Player* looterPlr)
{
// If player is not in battleground and not in worldpvpzone
if (!GetBattlegroundId() && !IsInWorldPvpZone())
return;

// If not released spirit, do it !
if (m_deathTimer > 0)
{
m_deathTimer = 0;
BuildPlayerRepop();
RepopAtGraveyard();
}

_corpseLocation.WorldRelocate();

// We have to convert player corpse to bones, not to be able to resurrect there
// SpawnCorpseBones isn't handy, 'cos it saves player while he in BG
Corpse* bones = GetMap()->ConvertCorpseToBones(GetGUID(), true);
if (!bones)
return;

// Now we must make bones lootable, and send player loot
bones->SetFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE);

// We store the level of our player in the gold field
// We retrieve this information at Player::SendLoot()
bones->loot.gold = GetLevel();
bones->lootRecipient = looterPlr;
looterPlr->SendLoot(bones->GetGUID(), LOOT_INSIGNIA);
}

void Player::SendLootRelease(ObjectGuid guid) const
{
WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8+1));
Expand Down Expand Up @@ -8431,7 +8433,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
}
}
}
else if (guid.IsCorpse()) // remove insignia
else if (guid.IsCorpse()) // remove insignia
{
Corpse* bones = ObjectAccessor::GetCorpse(*this, guid);

Expand All @@ -8445,7 +8447,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)

if (loot->loot_type == LOOT_NONE)
{
uint32 pLevel = bones->loot.gold;
float playerLevel = bones->loot.gold;
bones->loot.clear();

// For AV Achievement
Expand All @@ -8455,12 +8457,12 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
loot->FillLoot(PLAYER_CORPSE_LOOT_ENTRY, LootTemplates_Creature, this, true);
}
// For wintergrasp Quests
else if (GetZoneId() == AREA_WINTERGRASP)
else if (GetZoneId() == BATTLEFIELD_ZONEID_WINTERGRASP)
loot->FillLoot(PLAYER_CORPSE_LOOT_ENTRY, LootTemplates_Creature, this, true);

// It may need a better formula
// Now it works like this: lvl10: ~6copper, lvl70: ~9silver
bones->loot.gold = uint32(urand(50, 150) * 0.016f * std::pow(float(pLevel) / 5.76f, 2.5f) * CONF_GET_FLOAT("Rate.Drop.Money"));
bones->loot.gold = uint32(urand(50, 150) * 0.016f * std::pow(playerLevel / 5.76f, 2.5f) * CONF_GET_FLOAT("Rate.Drop.Money"));
}

if (bones->lootRecipient != this)
Expand Down Expand Up @@ -8673,7 +8675,7 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId)
Battleground* battleground = GetBattleground();
OutdoorPvP* outdoorPvP = sOutdoorPvPMgr->GetOutdoorPvPToZoneId(zoneId);
InstanceScript* instance = GetInstanceScript();
Battlefield* battlefield = sBattlefieldMgr->GetBattlefieldToZoneId(zoneId);
Battlefield* battlefield = sBattlefieldMgr->GetBattlefield(zoneId);

LOG_DEBUG("network", "Player::SendInitWorldStates: Sending SMSG_INIT_WORLD_STATES for Map: %u, Zone: %u", mapId, zoneId);

Expand Down
3 changes: 1 addition & 2 deletions src/server/game/Entities/Player/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1629,8 +1629,6 @@ class WH_GAME_API Player : public Unit, public GridObject<Player>
ObjectGuid GetLootGUID() const { return m_lootGuid; }
void SetLootGUID(ObjectGuid guid) { m_lootGuid = guid; }

void RemovedInsignia(Player* looterPlr);

WorldSession* GetSession() const { return m_session; }

void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override;
Expand Down Expand Up @@ -1775,6 +1773,7 @@ class WH_GAME_API Player : public Unit, public GridObject<Player>
/*** PVP SYSTEM ***/
/*********************************************************/
void SetArenaFaction(uint8 arenaFaction) { SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_ARENA_FACTION, arenaFaction); }
void RemovePVPInsignia(Player* looter);
void UpdateHonorFields();
bool RewardHonor(Unit* victim, uint32 groupsize, int32 honor = -1, bool pvptoken = false);
uint32 GetHonorPoints() const { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); }
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Handlers/MiscHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ void WorldSession::HandleHearthAndResurrect(WorldPacket& /*recvData*/)
}

AreaTableEntry const* atEntry = sAreaTableStore.LookupEntry(_player->GetAreaId());
if (!atEntry || !(atEntry->Flags & AREA_FLAG_WINTERGRASP_2))
if (!atEntry || !(atEntry->Flags & AREA_FLAG_CAN_HEARTH_AND_RESURRECT))
return;

_player->BuildPlayerRepop();
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Spells/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4964,7 +4964,7 @@ void Spell::EffectSkinPlayerCorpse(SpellEffIndex /*effIndex*/)
if (!player || !target || target->IsAlive())
return;

target->RemovedInsignia(player);
target->RemovePVPInsignia(player);
}

void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex)
Expand Down
Loading