Skip to content

Commit

Permalink
StaticFlags: Implement CANNOT_DAZE (#540)
Browse files Browse the repository at this point in the history
* StaticFlags: Implement CANNOT_DAZE

* StaticFlag: Make CanDaze virtual
  • Loading branch information
insunaa authored Oct 7, 2024
1 parent 227ad5c commit a34ccb4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3061,6 +3061,12 @@ void Creature::SetCanDualWield(bool state)
UpdateDamagePhysical(OFF_ATTACK);
}

bool Creature::CanDaze() const
{
// Generally, only npcs are able to daze targets in melee
return (!IsPlayerControlled() && !GetSettings().HasFlag(CreatureStaticFlags4::CANNOT_DAZE));
}

bool Creature::CanRestockPickpocketLoot() const
{
return GetMap()->GetCurrentClockTime() >= m_pickpocketRestockTime;
Expand Down
2 changes: 2 additions & 0 deletions src/game/Entities/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,8 @@ class Creature : public Unit
bool hasWeaponForAttack(WeaponAttackType type) const override { return (Unit::hasWeaponForAttack(type) && hasWeapon(type)); }
virtual void SetCanDualWield(bool value) override;

virtual bool CanDaze() const override;

void SetInvisible(bool invisible) { m_isInvisible = invisible; }
bool IsInvisible() const { return m_isInvisible; }

Expand Down
6 changes: 0 additions & 6 deletions src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3267,12 +3267,6 @@ bool Unit::CanGlance() const
return false;
}

bool Unit::CanDaze() const
{
// Generally, only npcs are able to daze targets in melee
return (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED));
}

void Unit::SetCanDodge(const bool flag)
{
if (m_canDodge == flag)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Entities/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ class Unit : public WorldObject
// Unit Melee events API: Crush/Glance/Daze
bool CanCrush() const;
bool CanGlance() const;
bool CanDaze() const;
virtual bool CanDaze() const { return false; };

void SetCanDodge(const bool flag);
void SetCanParry(const bool flag);
Expand Down

0 comments on commit a34ccb4

Please sign in to comment.