Skip to content

Commit

Permalink
Rename Unit::getVictim() -> Unit::GetVictim()
Browse files Browse the repository at this point in the history
* Rename Unit::getVictim() -> Unit::GetVictim() in CMaNGOS functions name start with an uppercase
  • Loading branch information
cala committed Apr 14, 2020
1 parent ac5bf0d commit 4007f50
Show file tree
Hide file tree
Showing 375 changed files with 1,480 additions and 1,480 deletions.
2 changes: 1 addition & 1 deletion doc/EventAI.txt
Expand Up @@ -1144,7 +1144,7 @@ Another example: the number "5" (101 in Binary, selecting first and third option
8 128 CAST_SWITCH_CASTER_TARGET Switches target and caster for spell cast - enables casting by spawner on AI owner for example
9 256 CAST_MAIN_SPELL Marks main spell for ranged mode. When this spell is interrupted or goes OOM, the AI owner goes into melee mode. Connected to ACTION_T_SET_RANGED_MODE
10 512 CAST_PLAYER_ONLY To be used in connection with targets. Restricts targeting to player only
11 1024 CAST_DISTANCE_YOURSELF Marks spell which stuns or immobilizes, so that creature distances itself from target, when main aggro target is hit (getVictim()). Connected to ACTION_T_SET_RANGED_MODE.
11 1024 CAST_DISTANCE_YOURSELF Marks spell which stuns or immobilizes, so that creature distances itself from target, when main aggro target is hit (GetVictim()). Connected to ACTION_T_SET_RANGED_MODE.

NOTE: You can add the numbers in the decimal column to combine flags.
For example if you wanted to use CAST_NO_MELEE_IF_OOM(8) and CAST_TRIGGERED(2) you would simply use 10 in the cast flags field (8 + 2 = 10).
Expand Down
4 changes: 2 additions & 2 deletions src/game/AI/BaseAI/CreatureAI.cpp
Expand Up @@ -151,12 +151,12 @@ void CreatureAI::RetreatingEnded()
SetCombatScriptStatus(false);
if (!m_creature->IsAlive())
return;
DoStartMovement(m_creature->getVictim());
DoStartMovement(m_creature->GetVictim());
}

bool CreatureAI::DoRetreat()
{
Unit* victim = m_creature->getVictim();
Unit* victim = m_creature->GetVictim();
if (!victim)
return false;

Expand Down
6 changes: 3 additions & 3 deletions src/game/AI/BaseAI/GuardAI.cpp
Expand Up @@ -39,7 +39,7 @@ void GuardAI::MoveInLineOfSight(Unit* who)
if (!m_creature->CanFly() && who->IsFlying() && m_creature->GetDistanceZ(who) > (IsRangedUnit() ? CREATURE_Z_ATTACK_RANGE_RANGED : CREATURE_Z_ATTACK_RANGE_MELEE))
return;

if (m_creature->getVictim())
if (m_creature->GetVictim())
return;

if (who->IsInCombat() && m_creature->CanAssist(who))
Expand Down Expand Up @@ -92,8 +92,8 @@ void GuardAI::MoveInLineOfSight(Unit* who)

void GuardAI::UpdateAI(const uint32 /*diff*/)
{
// update i_victimGuid if i_creature.getVictim() !=0 and changed
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
// update i_victimGuid if i_creature.GetVictim() !=0 and changed
if (!m_creature->SelectHostileTarget() || !m_creature->GetVictim())
return;

DoMeleeAttackIfReady();
Expand Down
12 changes: 6 additions & 6 deletions src/game/AI/BaseAI/PetAI.cpp
Expand Up @@ -72,7 +72,7 @@ PetAI::PetAI(Unit* unit) : UnitAI(unit), inCombat(false), m_followAngle(PET_FOLL

void PetAI::MoveInLineOfSight(Unit* who)
{
if (Unit* victim = m_unit->getVictim())
if (Unit* victim = m_unit->GetVictim())
if (victim->IsAlive())
return;

Expand Down Expand Up @@ -138,7 +138,7 @@ void PetAI::UpdateAI(const uint32 diff)
else
m_updateAlliesTimer -= diff;

Unit* victim = (pet && pet->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) ? nullptr : m_unit->getVictim();
Unit* victim = (pet && pet->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) ? nullptr : m_unit->GetVictim();

// Do not continue attacking if victim is moving home
if (victim && victim->GetCombatManager().IsEvadingHome())
Expand Down Expand Up @@ -182,7 +182,7 @@ void PetAI::UpdateAI(const uint32 diff)
if (charminfo->GetSpellOpener() != 0) // have opener stored
{
uint32 minRange = charminfo->GetSpellOpenerMinRange();
victim = m_unit->getVictim();
victim = m_unit->GetVictim();

if (!victim || (minRange != 0 && m_unit->IsWithinDistInMap(victim, minRange)))
charminfo->SetSpellOpener();
Expand Down Expand Up @@ -301,11 +301,11 @@ void PetAI::UpdateAI(const uint32 diff)
}

// we may get our actions disabled during spell casting, so do entire recheck for victim
victim = (pet && pet->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) ? nullptr : m_unit->getVictim();
victim = (pet && pet->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) ? nullptr : m_unit->GetVictim();

if (victim)
{
// i_pet.getVictim() can't be used for check in case stop fighting, i_pet.getVictim() clear at Unit death etc.
// i_pet.GetVictim() can't be used for check in case stop fighting, i_pet.GetVictim() clear at Unit death etc.
// This is needed for charmed creatures, as once their target was reset other effects can trigger threat
if (!m_unit->CanAttack(victim))
{
Expand Down Expand Up @@ -409,6 +409,6 @@ void PetAI::AttackedBy(Unit* attacker)
MANGOS_ASSERT(charminfo);

// when attacked, fight back if no victim unless we have a charm state set to passive
if (!(m_unit->getVictim() || charminfo->GetIsRetreating() || HasReactState(REACT_PASSIVE)))
if (!(m_unit->GetVictim() || charminfo->GetIsRetreating() || HasReactState(REACT_PASSIVE)))
AttackStart(attacker);
}
28 changes: 14 additions & 14 deletions src/game/AI/BaseAI/UnitAI.cpp
Expand Up @@ -59,7 +59,7 @@ void UnitAI::MoveInLineOfSight(Unit* who)
if (m_unit->GetDistanceZ(who) > (IsRangedUnit() ? CREATURE_Z_ATTACK_RANGE_RANGED : CREATURE_Z_ATTACK_RANGE_MELEE))
return;

if (m_unit->getVictim() && !m_unit->GetMap()->IsDungeon())
if (m_unit->GetVictim() && !m_unit->GetMap()->IsDungeon())
return;

if (m_unit->IsNeutralToAll())
Expand Down Expand Up @@ -105,7 +105,7 @@ void UnitAI::EnterEvadeMode()

void UnitAI::AttackedBy(Unit* attacker)
{
if (!m_unit->IsInCombat() && !m_unit->getVictim())
if (!m_unit->IsInCombat() && !m_unit->GetVictim())
AttackStart(attacker);
}

Expand Down Expand Up @@ -250,12 +250,12 @@ void UnitAI::SetCombatMovement(bool enable, bool stopOrStartMovement /*=false*/)
else
m_unit->addUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT);

if (stopOrStartMovement && m_unit->getVictim()) // Only change current movement while in combat
if (stopOrStartMovement && m_unit->GetVictim()) // Only change current movement while in combat
{
if (!m_unit->IsCrowdControlled())
{
if (enable)
DoStartMovement(m_unit->getVictim());
DoStartMovement(m_unit->GetVictim());
else if (m_unit->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
m_unit->StopMoving();
}
Expand Down Expand Up @@ -334,8 +334,8 @@ void UnitAI::OnSpellCastStateChange(Spell const* spell, bool state, WorldObject*
}
else
{
if (m_unit->getVictim() && !GetCombatScriptStatus())
m_unit->SetTarget(m_unit->getVictim());
if (m_unit->GetVictim() && !GetCombatScriptStatus())
m_unit->SetTarget(m_unit->GetVictim());
else
m_unit->SetTarget(nullptr);
}
Expand Down Expand Up @@ -391,8 +391,8 @@ void UnitAI::OnChannelStateChange(Spell const* spell, bool state, WorldObject* t
}
else
{
if (m_unit->getVictim() && !GetCombatScriptStatus())
m_unit->SetTarget(m_unit->getVictim());
if (m_unit->GetVictim() && !GetCombatScriptStatus())
m_unit->SetTarget(m_unit->GetVictim());
else
m_unit->SetTarget(nullptr);
}
Expand Down Expand Up @@ -438,7 +438,7 @@ void UnitAI::DetectOrAttack(Unit* who)
if (!m_unit->IsWithinLOSInMap(who))
return;

if (!m_unit->getVictim() && !m_unit->IsInCombat())
if (!m_unit->GetVictim() && !m_unit->IsInCombat())
{
if (CanTriggerStealthAlert(who, attackRadius))
{
Expand Down Expand Up @@ -615,11 +615,11 @@ void UnitAI::SetMeleeEnabled(bool state)
{
if (m_meleeEnabled)
{
if (m_unit->getVictim())
m_unit->MeleeAttackStart(m_unit->getVictim());
if (m_unit->GetVictim())
m_unit->MeleeAttackStart(m_unit->GetVictim());
}
else
m_unit->MeleeAttackStop(m_unit->getVictim());
m_unit->MeleeAttackStop(m_unit->GetVictim());
}
}

Expand All @@ -642,12 +642,12 @@ void UnitAI::TimedFleeingEnded()
SetCombatScriptStatus(false);
if (!m_unit->IsAlive())
return;
DoStartMovement(m_unit->getVictim());
DoStartMovement(m_unit->GetVictim());
}

bool UnitAI::DoFlee()
{
Unit* victim = m_unit->getVictim();
Unit* victim = m_unit->GetVictim();
if (!victim)
return false;

Expand Down
60 changes: 30 additions & 30 deletions src/game/AI/EventAI/CreatureEventAI.cpp
Expand Up @@ -385,10 +385,10 @@ bool CreatureEventAI::CheckEvent(CreatureEventAIHolder& holder, Unit* actionInvo
case EVENT_T_SPELLHIT_TARGET:
break;
case EVENT_T_RANGE:
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->IsInMap(m_creature->getVictim()))
if (!m_creature->IsInCombat() || !m_creature->GetVictim() || !m_creature->IsInMap(m_creature->GetVictim()))
return false;

if (!m_creature->IsInRange(m_creature->getVictim(), (float)event.range.minDist, (float)event.range.maxDist, true, true))
if (!m_creature->IsInRange(m_creature->GetVictim(), (float)event.range.minDist, (float)event.range.maxDist, true, true))
return false;
break;
case EVENT_T_OOC_LOS:
Expand All @@ -401,17 +401,17 @@ bool CreatureEventAI::CheckEvent(CreatureEventAIHolder& holder, Unit* actionInvo
break;
case EVENT_T_TARGET_HP:
{
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth())
if (!m_creature->IsInCombat() || !m_creature->GetVictim() || !m_creature->GetVictim()->GetMaxHealth())
return false;

uint32 perc = (m_creature->getVictim()->GetHealth() * 100) / m_creature->getVictim()->GetMaxHealth();
uint32 perc = (m_creature->GetVictim()->GetHealth() * 100) / m_creature->GetVictim()->GetMaxHealth();

if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false;
break;
}
case EVENT_T_TARGET_CASTING:
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true))
if (!m_creature->IsInCombat() || !m_creature->GetVictim() || !m_creature->GetVictim()->IsNonMeleeSpellCasted(false, false, true))
return false;
break;
case EVENT_T_FRIENDLY_HP:
Expand Down Expand Up @@ -474,10 +474,10 @@ bool CreatureEventAI::CheckEvent(CreatureEventAIHolder& holder, Unit* actionInvo
}
case EVENT_T_TARGET_MANA:
{
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->HasMana() || !m_creature->getVictim()->GetMaxPower(POWER_MANA))
if (!m_creature->IsInCombat() || !m_creature->GetVictim() || !m_creature->GetVictim()->HasMana() || !m_creature->GetVictim()->GetMaxPower(POWER_MANA))
return false;

uint32 perc = (m_creature->getVictim()->GetPower(POWER_MANA) * 100) / m_creature->getVictim()->GetMaxPower(POWER_MANA);
uint32 perc = (m_creature->GetVictim()->GetPower(POWER_MANA) * 100) / m_creature->GetVictim()->GetMaxPower(POWER_MANA);

if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false;
Expand All @@ -501,10 +501,10 @@ bool CreatureEventAI::CheckEvent(CreatureEventAIHolder& holder, Unit* actionInvo
}
case EVENT_T_TARGET_AURA:
{
if (!m_creature->IsInCombat() || !m_creature->getVictim())
if (!m_creature->IsInCombat() || !m_creature->GetVictim())
return false;

SpellAuraHolder* auraHolder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId);
SpellAuraHolder* auraHolder = m_creature->GetVictim()->GetSpellAuraHolder(event.buffed.spellId);
if (!auraHolder || auraHolder->GetStackAmount() < event.buffed.amount)
return false;
break;
Expand All @@ -518,10 +518,10 @@ bool CreatureEventAI::CheckEvent(CreatureEventAIHolder& holder, Unit* actionInvo
}
case EVENT_T_TARGET_MISSING_AURA:
{
if (!m_creature->IsInCombat() || !m_creature->getVictim())
if (!m_creature->IsInCombat() || !m_creature->GetVictim())
return false;

SpellAuraHolder* auraHolder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId);
SpellAuraHolder* auraHolder = m_creature->GetVictim()->GetSpellAuraHolder(event.buffed.spellId);
if (auraHolder && auraHolder->GetStackAmount() >= event.buffed.amount)
return false;
break;
Expand Down Expand Up @@ -552,14 +552,14 @@ bool CreatureEventAI::CheckEvent(CreatureEventAIHolder& holder, Unit* actionInvo
}
case EVENT_T_FACING_TARGET:
{
if (!m_creature->IsInCombat() || !m_creature->getVictim())
if (!m_creature->IsInCombat() || !m_creature->GetVictim())
return false;

// Creature expected in back of target (melee range)
if (event.facingTarget.backOrFront == 0 && !m_creature->getVictim()->isInBackInMap(m_creature, 5.0f))
if (event.facingTarget.backOrFront == 0 && !m_creature->GetVictim()->isInBackInMap(m_creature, 5.0f))
return false;
// Creature expected in front of target (melee range)
if (event.facingTarget.backOrFront == 1 && !m_creature->getVictim()->isInFrontInMap(m_creature, 5.0f))
if (event.facingTarget.backOrFront == 1 && !m_creature->GetVictim()->isInFrontInMap(m_creature, 5.0f))
return false;
break;
}
Expand Down Expand Up @@ -732,7 +732,7 @@ bool CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
else
{
target = m_creature->getVictim();
target = m_creature->GetVictim();
if (target && target->GetTypeId() != TYPEID_PLAYER)
{
Unit* owner = target->GetOwner();
Expand Down Expand Up @@ -927,10 +927,10 @@ bool CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32

SetCombatMovement(action.combat_movement.state != 0, true);

if (hasCombatMovement && action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim())
m_creature->SendMeleeAttackStart(m_creature->getVictim());
else if (action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim())
m_creature->SendMeleeAttackStop(m_creature->getVictim());
if (hasCombatMovement && action.combat_movement.melee && m_creature->IsInCombat() && m_creature->GetVictim())
m_creature->SendMeleeAttackStart(m_creature->GetVictim());
else if (action.combat_movement.melee && m_creature->IsInCombat() && m_creature->GetVictim())
m_creature->SendMeleeAttackStop(m_creature->GetVictim());
break;
}
case ACTION_T_SET_PHASE:
Expand Down Expand Up @@ -998,7 +998,7 @@ bool CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{
// Drop current movement gen
m_creature->GetMotionMaster()->Clear(false);
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle);
m_creature->GetMotionMaster()->MoveChase(m_creature->GetVictim(), m_attackDistance, m_attackAngle);
}
}
break;
Expand Down Expand Up @@ -1544,7 +1544,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit* who)
{
// Check for OOC LOS Event
IncreaseDepthIfNecessary();
if (m_HasOOCLoSEvent && !m_creature->getVictim())
if (m_HasOOCLoSEvent && !m_creature->GetVictim())
{
for (auto& itr : m_CreatureEventAIList)
{
Expand Down Expand Up @@ -1602,11 +1602,11 @@ void CreatureEventAI::SpellHitTarget(Unit* target, const SpellEntry* spellInfo)
void CreatureEventAI::UpdateAI(const uint32 diff)
{
// Check if we are in combat (also updates calls threat update code)
bool Combat = m_creature->SelectHostileTarget() && m_creature->getVictim();
bool Combat = m_creature->SelectHostileTarget() && m_creature->GetVictim();

UpdateEventTimers(diff);

Unit* victim = m_creature->getVictim();
Unit* victim = m_creature->GetVictim();
// Melee Auto-Attack
if (Combat && victim)
{
Expand Down Expand Up @@ -1651,7 +1651,7 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 target, Unit* actionInvoker
case TARGET_T_SELF:
return m_creature;
case TARGET_T_HOSTILE:
resTarget = m_creature->getVictim();
resTarget = m_creature->GetVictim();
if (!resTarget)
isError = true;
return resTarget;
Expand Down Expand Up @@ -1940,8 +1940,8 @@ void CreatureEventAI::SetCurrentRangedMode(bool state)
m_currentRangedMode = true;
m_meleeEnabled = false;
m_attackDistance = m_chaseDistance;
m_creature->MeleeAttackStop(m_creature->getVictim());
DoStartMovement(m_creature->getVictim());
m_creature->MeleeAttackStop(m_creature->GetVictim());
DoStartMovement(m_creature->GetVictim());
}
else
{
Expand All @@ -1951,8 +1951,8 @@ void CreatureEventAI::SetCurrentRangedMode(bool state)
m_currentRangedMode = false;
m_meleeEnabled = true;
m_attackDistance = 0.f;
m_creature->MeleeAttackStart(m_creature->getVictim());
DoStartMovement(m_creature->getVictim());
m_creature->MeleeAttackStart(m_creature->GetVictim());
DoStartMovement(m_creature->GetVictim());
}
}

Expand All @@ -1963,7 +1963,7 @@ enum EAIPoints

void CreatureEventAI::DistanceYourself()
{
Unit* victim = m_creature->getVictim();
Unit* victim = m_creature->GetVictim();
if (!victim->CanReachWithMeleeAttack(m_creature))
return;

Expand All @@ -1989,7 +1989,7 @@ void CreatureEventAI::DistancingEnded()

void CreatureEventAI::JustStoppedMovementOfTarget(SpellEntry const* spellInfo, Unit* victim)
{
if (m_creature->getVictim() != victim)
if (m_creature->GetVictim() != victim)
return;
if (m_distanceSpells.find(spellInfo->Id) != m_distanceSpells.end())
DistanceYourself();
Expand Down

0 comments on commit 4007f50

Please sign in to comment.