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
1697{
1698}

◆ BeforeVisibilityDestroy< Creature >()

template<>
void BeforeVisibilityDestroy< Creature > ( Creature *  t,
Player *  p 
)
inline
1702{
1703 if (p->GetPetGUID() == t->GetGUID() && t->IsPet())
1704 ((Pet*) t)->Remove(PET_SAVE_NOT_IN_SLOT, true);
1705}
@ 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:798
ObjectGuid GetPetGUID() const
Definition Unit.h:724

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

References CONFIG_SKILL_CHANCE_GREY, CONFIG_SKILL_CHANCE_ORANGE, and sWorld.

Referenced by Player::UpdateCraftSkill().

◆ getProbabilityOfLevelUp()

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

Referenced by Player::UpdateFishingSkill().

◆ SkillGainChance()

int SkillGainChance ( uint32  SkillValue,
uint32  GrayLevel,
uint32  GreenLevel,
uint32  YellowLevel 
)
inline
757{
758 if (SkillValue >= GrayLevel)
759 return sWorld->getIntConfig(CONFIG_SKILL_CHANCE_GREY) * 10;
760 if (SkillValue >= GreenLevel)
761 return sWorld->getIntConfig(CONFIG_SKILL_CHANCE_GREEN) * 10;
762 if (SkillValue >= YellowLevel)
763 return sWorld->getIntConfig(CONFIG_SKILL_CHANCE_YELLOW) * 10;
764 return sWorld->getIntConfig(CONFIG_SKILL_CHANCE_ORANGE) * 10;
765}
@ CONFIG_SKILL_CHANCE_YELLOW
Definition WorldConfig.h:224
@ CONFIG_SKILL_CHANCE_GREEN
Definition WorldConfig.h:225

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
1682{
1684 v.push_back(target);
1685}
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
933{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:933

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().