Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into repacker
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Apr 28, 2024
2 parents e26cb67 + c293519 commit bd871d4
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 16 deletions.
21 changes: 21 additions & 0 deletions sql/migrations/20240428090619_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
DROP PROCEDURE IF EXISTS add_migration;
DELIMITER ??
CREATE PROCEDURE `add_migration`()
BEGIN
DECLARE v INT DEFAULT 1;
SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20240428090619');
IF v = 0 THEN
INSERT INTO `migrations` VALUES ('20240428090619');
-- Add your query below.


-- Add No Target flag to Grobbulus Cloud and Scourge Summoning Crystal.
UPDATE `creature_template` SET `flags_extra`=(`flags_extra` | 0x00020000) WHERE `entry`IN (11623, 16363);


-- End of migration.
END IF;
END??
DELIMITER ;
CALL add_migration();
DROP PROCEDURE IF EXISTS add_migration;
1 change: 1 addition & 0 deletions src/game/Chat/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "npcflags", SEC_MODERATOR, false, &ChatHandler::HandleUnitShowNPCFlagsCommand, "", nullptr },
{ "moveflags", SEC_MODERATOR, false, &ChatHandler::HandleUnitShowMoveFlagsCommand, "", nullptr },
{ "createspell", SEC_MODERATOR, false, &ChatHandler::HandleUnitShowCreateSpellCommand, "", nullptr },
{ "combattimer", SEC_MODERATOR, false, &ChatHandler::HandleUnitShowCombatTimerCommand, "", nullptr },
{ nullptr, 0, false, nullptr, "", nullptr }
};

Expand Down
1 change: 1 addition & 0 deletions src/game/Chat/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ class ChatHandler
bool HandleUnitShowSheathStateCommand(char* args);
bool HandleUnitShowMoveFlagsCommand(char* args);
bool HandleUnitShowCreateSpellCommand(char* args);
bool HandleUnitShowCombatTimerCommand(char* args);

bool HandlePDumpLoadCommand(char* args);
bool HandlePDumpWriteCommand(char* args);
Expand Down
17 changes: 17 additions & 0 deletions src/game/Commands/UnitCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,23 @@ bool ChatHandler::HandleUnitShowCreateSpellCommand(char* args)
return true;
}

bool ChatHandler::HandleUnitShowCombatTimerCommand(char* args)
{
Unit* pTarget = GetSelectedUnit();

if (!pTarget)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}

PSendSysMessage("Combat timer for %s:", pTarget->GetObjectGuid().GetString().c_str());
PSendSysMessage("%u", pTarget->GetCombatTimer());

return true;
}

bool ChatHandler::HandlePvPCommand(char* args)
{
Unit* pTarget = GetSelectedUnit();
Expand Down
4 changes: 2 additions & 2 deletions src/game/Objects/CreatureDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ enum CreatureFlagsExtra
CREATURE_FLAG_EXTRA_GIGANTIC_AOI = 0x00000100, // 256 CREATURE_DIFFICULTYFLAGS_3_GIGANTIC_AOI (400 yards)
CREATURE_FLAG_EXTRA_INFINITE_AOI = 0x00000200, // 512 CREATURE_DIFFICULTYFLAGS_3_INFINITE_AOI
CREATURE_FLAG_EXTRA_GUARD = 0x00000400, // 1024 Creature is a guard
CREATURE_FLAG_EXTRA_NO_THREAT_LIST = 0x00000800, // 2048 Creature does not select targets based on threat
CREATURE_FLAG_EXTRA_NO_THREAT_LIST = 0x00000800, // 2048 Creature does not select targets based on threat (all enemies have 0 threat)
CREATURE_FLAG_EXTRA_KEEP_POSITIVE_AURAS_ON_EVADE = 0x00001000, // 4096 Creature keeps positive auras at reset
CREATURE_FLAG_EXTRA_ALWAYS_CRUSH = 0x00002000, // 8192 Creature always roll a crushing melee outcome when not miss/crit/dodge/parry/block
CREATURE_FLAG_EXTRA_APPEAR_DEAD = 0x00004000, // 16384 Creature will have UNIT_DYNFLAG_DEAD applied
CREATURE_FLAG_EXTRA_CHASE_GEN_NO_BACKING = 0x00008000, // 32768 Creature does not move back when target is within bounding radius
CREATURE_FLAG_EXTRA_NO_ASSIST = 0x00010000, // 65536 Creature does not aggro when nearby creatures aggro
CREATURE_FLAG_EXTRA_NO_TARGET = 0x00020000, // 131072 Creature is passive and does not acquire targets
CREATURE_FLAG_EXTRA_NO_TARGET = 0x00020000, // 131072 Creature is passive and does not acquire targets, uses 5 second combat timer like players
CREATURE_FLAG_EXTRA_ONLY_VISIBLE_TO_FRIENDLY = 0x00040000, // 262144 Creature can only be seen by friendly units
CREATURE_FLAG_EXTRA_CAN_ASSIST = 0x00080000, // 524288 CREATURE_TYPEFLAGS_CAN_ASSIST from TBC
};
Expand Down
39 changes: 31 additions & 8 deletions src/game/Objects/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,19 @@ void Unit::Update(uint32 update_diff, uint32 p_time)
m_combatTimer = UNIT_COMBAT_CHECK_TIMER_MAX - std::min(update_diff - m_combatTimer, UNIT_COMBAT_CHECK_TIMER_MAX);

// update combat timer only for players and pets
if (IsInCombat() && (IsPlayer() || (IsPet() && GetOwnerGuid().IsPlayer()) || GetCharmerGuid().IsPlayer()))
if (IsInCombat() && UsesPvPCombatTimer() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN))
{
// Pet in combat ?
Pet* myPet = GetPet();
if (HasUnitState(UNIT_STAT_FEIGN_DEATH) || !myPet || myPet->GetHostileRefManager().isEmpty())
{
if (m_HostileRefManager.isEmpty() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN))
ClearInCombat();
if (m_HostileRefManager.isEmpty())
{
if (!IsCharmerOrOwnerPlayerOrPlayerItself() && static_cast<Creature const*>(this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_TARGET))
OnLeaveCombat();
else
ClearInCombat();
}
}
}
}
Expand Down Expand Up @@ -330,6 +335,23 @@ void Unit::Update(uint32 update_diff, uint32 p_time)
m_damageTakenHistory.clear();
}

bool Unit::UsesPvPCombatTimer() const
{
if (IsPlayer())
return true;

if (IsPet() && GetOwnerGuid().IsPlayer())
return true;

if (GetCharmerGuid().IsPlayer())
return true;

if (static_cast<Creature const*>(this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_TARGET))
return true;

return false;
}

AutoAttackCheckResult Unit::CanAutoAttackTarget(Unit const* pVictim) const
{
if (HasUnitState(UNIT_STAT_CAN_NOT_REACT) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
Expand Down Expand Up @@ -5980,7 +6002,7 @@ void Unit::SetInCombatWith(Unit* pEnemy)
{
ASSERT(pEnemy);

SetInCombatState(pEnemy->IsCharmerOrOwnerPlayerOrPlayerItself() ? UNIT_PVP_COMBAT_TIMER : 0, pEnemy);
SetInCombatState(pEnemy->UsesPvPCombatTimer() ? UNIT_PVP_COMBAT_TIMER : 0, pEnemy);
}

void Unit::SetInCombatState(uint32 combatTimer, Unit* pEnemy)
Expand Down Expand Up @@ -6148,7 +6170,7 @@ void Unit::SetInCombatWithVictim(Unit* pVictim, bool touchOnly/* = false*/, uint

if (!touchOnly)
{
SetInCombatState(pVictim->IsCharmerOrOwnerPlayerOrPlayerItself() && (combatTimer < UNIT_PVP_COMBAT_TIMER) ? UNIT_PVP_COMBAT_TIMER : combatTimer, pVictim);
SetInCombatState(pVictim->UsesPvPCombatTimer() && (combatTimer < UNIT_PVP_COMBAT_TIMER) ? UNIT_PVP_COMBAT_TIMER : combatTimer, pVictim);

// pet owner should not enter combat on spell missile launching
if (!combatTimer)
Expand Down Expand Up @@ -7432,9 +7454,6 @@ bool Unit::CanHaveThreatList() const
if (pCreature->GetCharmerGuid().IsPlayer())
return false;

if (pCreature->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_THREAT_LIST))
return false;

return true;
}

Expand Down Expand Up @@ -7611,6 +7630,10 @@ bool Unit::SelectHostileTarget()
return true;
}

// mobs that dont acquire targets use 5 second combat timer like players
if (((Creature*)this)->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_TARGET))
return false;

// no target but something prevent go to evade mode // Nostalrius - fix evade quand CM.
if (!IsInCombat() || HasAuraType(SPELL_AURA_MOD_TAUNT) || GetCharmerGuid())
return false;
Expand Down
1 change: 1 addition & 0 deletions src/game/Objects/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ class Unit : public SpellCaster
uint32 GetCombatTimer() const { return m_combatTimer; }
void SetCombatTimer(uint32 t) { m_combatTimer = t; }
virtual void OnEnterCombat(Unit* /*pAttacker*/, bool /*notInCombat*/) {} // (pAttacker must be valid)
bool UsesPvPCombatTimer() const; // 5 second combat timer

// Stop this unit from combat, if includingCast==true, also interrupt casting
void CombatStop(bool includingCast = false);
Expand Down
19 changes: 13 additions & 6 deletions src/game/Threat/ThreatManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,21 @@ void ThreatManager::addThreat(Unit* pVictim, float threat, bool crit, SpellSchoo

MANGOS_ASSERT(getOwner()->GetTypeId() == TYPEID_UNIT);

// don't add assist threat to targets under hard CC
// check for fear, blind, freezing trap, reckless charge, banish, etc.
if (isAssistThreat)
if (threat)
{
if (getOwner()->HasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_ISOLATED) ||
(getOwner()->HasUnitState(UNIT_STAT_STUNNED) && getOwner()->HasBreakableByDamageAuraType(SPELL_AURA_MOD_STUN, 0)))
// mob does not count threat, just keeps list of enemies
if (static_cast<Creature*>(getOwner())->HasExtraFlag(CREATURE_FLAG_EXTRA_NO_THREAT_LIST))
threat = 0;

// don't add assist threat to targets under hard CC
// check for fear, blind, freezing trap, reckless charge, banish, etc.
else if (isAssistThreat)
{
threat = 0.0f;
if (getOwner()->HasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_ISOLATED) ||
(getOwner()->HasUnitState(UNIT_STAT_STUNNED) && getOwner()->HasBreakableByDamageAuraType(SPELL_AURA_MOD_STUN, 0)))
{
threat = 0.0f;
}
}
}

Expand Down

0 comments on commit bd871d4

Please sign in to comment.