Merge branch 'azerothcore:master' into Playerbot

This commit is contained in:
ZhengPeiRu21
2022-09-21 09:42:10 -06:00
committed by GitHub
27 changed files with 327 additions and 72 deletions

View File

@@ -2089,8 +2089,14 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
if (owner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
trigger->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
if (owner->IsFFAPvP())
trigger->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
{
if (!HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
{
sScriptMgr->OnFfaPvpStateUpdate(trigger, true);
trigger->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
}
}
// xinef: Remove Immunity flags
trigger->SetImmuneToNPC(false);
// xinef: set proper orientation, fixes cast against stealthed targets

View File

@@ -569,7 +569,9 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
InitRunes();
SetUInt32Value(PLAYER_FIELD_COINAGE, sWorld->getIntConfig(CONFIG_START_PLAYER_MONEY));
SetUInt32Value(PLAYER_FIELD_COINAGE, getClass() != CLASS_DEATH_KNIGHT
? sWorld->getIntConfig(CONFIG_START_PLAYER_MONEY)
: sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_MONEY));
SetHonorPoints(sWorld->getIntConfig(CONFIG_START_HONOR_POINTS));
SetArenaPoints(sWorld->getIntConfig(CONFIG_START_ARENA_POINTS));
@@ -2177,8 +2179,11 @@ void Player::SetGameMaster(bool on)
pet->SetFaction(FACTION_FRIENDLY);
pet->getHostileRefMgr().setOnlineOfflineState(false);
}
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
{
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
sScriptMgr->OnFfaPvpStateUpdate(this, false);
}
ResetContestedPvP();
getHostileRefMgr().setOnlineOfflineState(false);
@@ -2210,8 +2215,13 @@ void Player::SetGameMaster(bool on)
// restore FFA PvP Server state
if (sWorld->IsFFAPvPRealm())
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
{
if (!HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
{
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
sScriptMgr->OnFfaPvpStateUpdate(this, true);
}
}
// restore FFA PvP area state, remove not allowed for GM mounts
UpdateArea(m_areaUpdateId);
@@ -2654,8 +2664,12 @@ void Player::InitStatsForLevel(bool reapplyMods)
RemovePlayerFlag(PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_ALLOW_ONLY_ABILITY);
RemoveStandFlags(UNIT_STAND_FLAGS_ALL); // one form stealth modified bytes
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY);
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
{
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY);
sScriptMgr->OnFfaPvpStateUpdate(this, false);
}
// restore if need some important flags
SetUInt32Value(PLAYER_FIELD_BYTES2, 0); // flags empty by default
@@ -15001,7 +15015,11 @@ void Player::SetIsSpectator(bool on)
AddUnitState(UNIT_STATE_ISOLATED);
//SetFaction(1100);
SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
{
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
sScriptMgr->OnFfaPvpStateUpdate(this, false);
}
ResetContestedPvP();
SetDisplayId(23691);
}
@@ -15021,7 +15039,14 @@ void Player::SetIsSpectator(bool on)
// restore FFA PvP Server state
// Xinef: it will be removed if necessery in UpdateArea called in WorldPortOpcode
if (sWorld->IsFFAPvPRealm())
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
{
if (!HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
{
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
sScriptMgr->OnFfaPvpStateUpdate(this, true);
}
}
}
}
}

View File

@@ -396,8 +396,11 @@ void Player::UpdateFFAPvPFlag(time_t currTime)
}
pvpInfo.FFAPvPEndTimer = time_t(0);
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
{
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
sScriptMgr->OnFfaPvpStateUpdate(this, false);
}
for (ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
(*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);

View File

@@ -982,42 +982,56 @@ void Player::UpdateWeaponSkill(Unit* victim, WeaponAttackType attType, Item* ite
void Player::UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defence, Item* item /*= nullptr*/)
{
uint8 plevel = getLevel(); // if defense than victim == attacker
uint8 greylevel = Acore::XP::GetGrayLevel(plevel);
uint8 moblevel = victim->getLevelForTarget(this);
uint8 playerLevel = getLevel();
uint16 currentSkillValue = defence ? GetBaseDefenseSkillValue() : GetBaseWeaponSkillValue(attType);
uint16 currentSkillMax = 5 * playerLevel;
int32 skillDiff = currentSkillMax - currentSkillValue;
// Max skill reached for level.
// Can in some cases be less than 0: having max skill and then .level -1 as example.
if (skillDiff <= 0)
{
return;
}
uint8 greylevel = Acore::XP::GetGrayLevel(playerLevel);
uint8 moblevel = defence ? victim->getLevelForTarget(this) : victim->getLevel(); // if defense than victim == attacker
/*if (moblevel < greylevel)
return;*/
// Patch 3.0.8 (2009-01-20): You can no longer skill up weapons on mobs that are immune to damage.
if (moblevel > plevel + 5)
moblevel = plevel + 5;
if (moblevel > playerLevel + 5)
{
moblevel = playerLevel + 5;
}
uint8 lvldif = moblevel - greylevel;
int16 lvldif = moblevel - greylevel;
if (lvldif < 3)
{
lvldif = 3;
}
uint32 skilldif = 5 * plevel - (defence ? GetBaseDefenseSkillValue()
: GetBaseWeaponSkillValue(attType));
if (skilldif <= 0)
return;
float chance = float(3 * lvldif * skilldif) / plevel;
float chance = float(3 * lvldif * skillDiff) / playerLevel;
if (!defence)
if (getClass() == CLASS_WARRIOR || getClass() == CLASS_ROGUE)
chance += chance * 0.02f * GetStat(STAT_INTELLECT);
{
chance += chance * 0.02f * GetStat(STAT_INTELLECT);
}
chance =
chance < 1.0f ? 1.0f : chance; // minimum chance to increase skill is 1%
chance = chance < 1.0f ? 1.0f : chance; // minimum chance to increase skill is 1%
LOG_DEBUG("entities.player", "Player::UpdateCombatSkills(defence:{}, playerLevel:{}, moblevel:{}) -> ({}/{}) chance to increase skill is {}\%", defence, playerLevel, moblevel, currentSkillValue, currentSkillMax, chance);
if (roll_chance_f(chance))
{
if (defence)
{
UpdateDefense();
}
else
{
UpdateWeaponSkill(victim, attType, item);
}
}
else
return;
}
void Player::UpdateSkillsForLevel()
@@ -1403,6 +1417,7 @@ void Player::UpdateFFAPvPState(bool reset /*= true*/)
{
if (!IsFFAPvP())
{
sScriptMgr->OnFfaPvpStateUpdate(this, true);
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
for (ControlSet::iterator itr = m_Controlled.begin();
itr != m_Controlled.end(); ++itr)
@@ -1421,8 +1436,11 @@ void Player::UpdateFFAPvPState(bool reset /*= true*/)
!pvpInfo.EndTimer)
{
pvpInfo.FFAPvPEndTimer = time_t(0);
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
if (HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
{
RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
sScriptMgr->OnFfaPvpStateUpdate(this, false);
}
for (ControlSet::iterator itr = m_Controlled.begin();
itr != m_Controlled.end(); ++itr)
(*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1,

View File

@@ -15759,21 +15759,18 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u
// Update skills here for players
// only when you are not fighting other players or their pets/totems (pvp)
if (GetTypeId() == TYPEID_PLAYER &&
target->GetTypeId() != TYPEID_PLAYER &&
!(target->IsTotem() && target->ToTotem()->GetOwner()->IsPlayer()) &&
!target->IsPet()
)
if (IsPlayer() && !target->IsCharmedOwnedByPlayerOrPlayer())
{
// On melee based hit/miss/resist/parry/dodge need to update skill (for victim and attacker)
if (procExtra & (PROC_EX_NORMAL_HIT | PROC_EX_MISS | PROC_EX_RESIST | PROC_EX_PARRY | PROC_EX_DODGE))
{
if (target->GetTypeId() != TYPEID_PLAYER)
ToPlayer()->UpdateCombatSkills(target, attType, isVictim, procSpell ? procSpell->m_weaponItem : nullptr);
ToPlayer()->UpdateCombatSkills(target, attType, isVictim, procSpell ? procSpell->m_weaponItem : nullptr);
}
// Update defence if player is victim and we block
// Update defence if player is victim and we block - TODO: confirm that blocked attacks only have a chance to increase defence skill
else if (isVictim && procExtra & (PROC_EX_BLOCK))
{
ToPlayer()->UpdateCombatSkills(target, attType, true);
}
}
// If exist crit/parry/dodge/block need update aura state (for victim and attacker)
if (procExtra & (PROC_EX_CRITICAL_HIT | PROC_EX_PARRY | PROC_EX_DODGE | PROC_EX_BLOCK))

View File

@@ -109,8 +109,10 @@ void Vehicle::Uninstall()
LOG_DEBUG("vehicles", "Vehicle::Uninstall {}", _me->GetGUID().ToString());
RemoveAllPassengers();
if (GetBase()->GetTypeId() == TYPEID_UNIT)
if (_me && _me->GetTypeId() == TYPEID_UNIT)
{
sScriptMgr->OnUninstall(this);
}
}
void Vehicle::Reset(bool evading /*= false*/)