AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
PlayerUpdates.cpp File Reference
#include "AchievementMgr.h"
#include "BattlefieldMgr.h"
#include "CellImpl.h"
#include "Channel.h"
#include "ChannelMgr.h"
#include "Formulas.h"
#include "GameTime.h"
#include "GridNotifiers.h"
#include "Group.h"
#include "Guild.h"
#include "InstanceScript.h"
#include "Language.h"
#include "OutdoorPvPMgr.h"
#include "Pet.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "SkillDiscovery.h"
#include "SpellAuraEffects.h"
#include "SpellMgr.h"
#include "UpdateFieldFlags.h"
#include "Vehicle.h"
#include "Weather.h"
#include "WeatherMgr.h"
#include "WorldState.h"
#include "WorldStatePackets.h"
#include "GridNotifiersImpl.h"

Go to the source code of this file.

Functions

int SkillGainChance (uint32 SkillValue, uint32 GrayLevel, uint32 GreenLevel, uint32 YellowLevel)
 
int32 CraftSkillGainChance (uint32 skillValue, uint32 grayLevel, uint32 yellowLevel)
 
float getProbabilityOfLevelUp (uint32 SkillValue)
 
template<class T >
void UpdateVisibilityOf_helper (Player *player, T *target, std::vector< Unit * > &)
 
template<>
void UpdateVisibilityOf_helper (Player *player, GameObject *target, std::vector< Unit * > &)
 
template<>
void UpdateVisibilityOf_helper (Player *player, Creature *target, std::vector< Unit * > &v)
 
template<>
void UpdateVisibilityOf_helper (Player *player, Player *target, std::vector< Unit * > &v)
 
template<class T >
void BeforeVisibilityDestroy (T *, Player *)
 
template<>
void BeforeVisibilityDestroy< Creature > (Creature *t, Player *p)
 

Variables

constexpr auto ZONE_UPDATE_INTERVAL = 1000
 
static uint32 bonusSkillLevels [] = {75, 150, 225, 300, 375, 450}
 
static const std::size_t bonusSkillLevelsSize
 

Function Documentation

◆ BeforeVisibilityDestroy()

template<class T >
void BeforeVisibilityDestroy ( T *  ,
Player *   
)
inline
1693{
1694}

◆ BeforeVisibilityDestroy< Creature >()

template<>
void BeforeVisibilityDestroy< Creature > ( Creature *  t,
Player *  p 
)
inline
1698{
1699 if (p->GetPetGUID() == t->GetGUID() && t->IsPet())
1700 ((Pet*) t)->Remove(PET_SAVE_NOT_IN_SLOT, true);
1701}
@ PET_SAVE_NOT_IN_SLOT
Definition PetDefines.h:46
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:120
Definition Pet.h:41
bool IsPet() const
Definition Unit.h:803
ObjectGuid GetPetGUID() const
Definition Unit.h:729

References Object::GetGUID(), Unit::GetPetGUID(), Unit::IsPet(), and PET_SAVE_NOT_IN_SLOT.

Referenced by Player::UpdateVisibilityOf().

◆ CraftSkillGainChance()

int32 CraftSkillGainChance ( uint32  skillValue,
uint32  grayLevel,
uint32  yellowLevel 
)
inline
764{
765 int32 orangeChance = sWorld->getIntConfig(CONFIG_SKILL_CHANCE_ORANGE) * 10;
766 int32 grayChance = sWorld->getIntConfig(CONFIG_SKILL_CHANCE_GREY) * 10;
767
768 // Invalid or equal thresholds cannot be interpolated. Preserve the
769 // previous orange/gray boundary behavior for malformed DBC entries.
770 if (grayLevel <= yellowLevel)
771 return skillValue < grayLevel ? orangeChance : grayChance;
772
773 if (skillValue <= yellowLevel)
774 return orangeChance;
775 if (skillValue >= grayLevel)
776 return grayChance;
777
778 // Crafting skill-up chance falls linearly from orange at the yellow
779 // threshold to gray at the gray threshold. The green threshold is the
780 // midpoint of that range and therefore has a 50% chance by default.
781 return grayChance + int32(int64(grayLevel - skillValue) * (orangeChance - grayChance) /
782 (grayLevel - yellowLevel));
783}
std::int32_t int32
Definition Define.h:103
std::int64_t int64
Definition Define.h:102
@ CONFIG_SKILL_CHANCE_ORANGE
Definition WorldConfig.h:224
@ CONFIG_SKILL_CHANCE_GREY
Definition WorldConfig.h:227
#define sWorld
Definition World.h:337

References CONFIG_SKILL_CHANCE_GREY, CONFIG_SKILL_CHANCE_ORANGE, and sWorld.

Referenced by Player::UpdateCraftSkill().

◆ getProbabilityOfLevelUp()

float getProbabilityOfLevelUp ( uint32  SkillValue)
886{
887 /* According to El's Extreme Angling page, from 1 to 115 the probability of
888 * a skill level up is 100% since 100/1 = 100. From 115 - 135 should average
889 * 2 catches per skill up so that means 100/2 = 50%. This returns the
890 * probability depending on the player's SkillValue.
891 */
892 if (!SkillValue)
893 {
894 return 0.0f;
895 }
896
897 std::array<uint32, 10> bounds {115, 135, 160, 190, 215,
898 295, 315, 355, 425, 450};
899 std::array<float, 11> dens {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f,
900 9.0f, 10.0f, 11.0f, 12.0f, 1.0f};
901 auto it =
902 std::lower_bound(std::begin(bounds), std::end(bounds), SkillValue);
903 return 100 / dens[std::distance(std::begin(bounds), it)];
904}

Referenced by Player::UpdateFishingSkill().

◆ SkillGainChance()

int SkillGainChance ( uint32  SkillValue,
uint32  GrayLevel,
uint32  GreenLevel,
uint32  YellowLevel 
)
inline
753{
754 if (SkillValue >= GrayLevel)
755 return sWorld->getIntConfig(CONFIG_SKILL_CHANCE_GREY) * 10;
756 if (SkillValue >= GreenLevel)
757 return sWorld->getIntConfig(CONFIG_SKILL_CHANCE_GREEN) * 10;
758 if (SkillValue >= YellowLevel)
759 return sWorld->getIntConfig(CONFIG_SKILL_CHANCE_YELLOW) * 10;
760 return sWorld->getIntConfig(CONFIG_SKILL_CHANCE_ORANGE) * 10;
761}
@ CONFIG_SKILL_CHANCE_YELLOW
Definition WorldConfig.h:225
@ CONFIG_SKILL_CHANCE_GREEN
Definition WorldConfig.h:226

References CONFIG_SKILL_CHANCE_GREEN, CONFIG_SKILL_CHANCE_GREY, CONFIG_SKILL_CHANCE_ORANGE, CONFIG_SKILL_CHANCE_YELLOW, and sWorld.

Referenced by Player::UpdateGatherSkill().

◆ UpdateVisibilityOf_helper() [1/4]

template<>
void UpdateVisibilityOf_helper ( Player *  player,
Creature *  target,
std::vector< Unit * > &  v 
)
inline
1678{
1680 v.push_back(target);
1681}
void LinkWorldObjectVisibility(WorldObject *worldObject)
Definition ObjectVisibilityContainer.cpp:63
ObjectVisibilityContainer & GetObjectVisibilityContainer()
Definition Object.h:744

References WorldObject::GetObjectVisibilityContainer(), and ObjectVisibilityContainer::LinkWorldObjectVisibility().

◆ UpdateVisibilityOf_helper() [2/4]

template<>
void UpdateVisibilityOf_helper ( Player *  player,
GameObject *  target,
std::vector< Unit * > &   
)
inline

◆ UpdateVisibilityOf_helper() [3/4]

template<>
void UpdateVisibilityOf_helper ( Player *  player,
Player *  target,
std::vector< Unit * > &  v 
)
inline

◆ UpdateVisibilityOf_helper() [4/4]

template<class T >
void UpdateVisibilityOf_helper ( Player *  player,
T *  target,
std::vector< Unit * > &   
)
inline

Variable Documentation

◆ bonusSkillLevels

uint32 bonusSkillLevels[] = {75, 150, 225, 300, 375, 450}
static
929{75, 150, 225, 300, 375, 450};

Referenced by Player::UpdateSkillPro().

◆ bonusSkillLevelsSize

const std::size_t bonusSkillLevelsSize
static
Initial value:
=
sizeof(bonusSkillLevels) / sizeof(uint32)
std::uint32_t uint32
Definition Define.h:107
static uint32 bonusSkillLevels[]
Definition PlayerUpdates.cpp:929

Referenced by Player::UpdateSkillPro().

◆ ZONE_UPDATE_INTERVAL

constexpr auto ZONE_UPDATE_INTERVAL = 1000
constexpr
Todo:
: this import is not necessary for compilation and marked as unused by the IDE

Referenced by Player::Update(), and Player::UpdateZone().