Horizon Official Technical Documentation
Horizon::Zone::Traits::EquipATK Class Reference

#include <AttributesImpl.hpp>

+ Inheritance diagram for Horizon::Zone::Traits::EquipATK:
+ Collaboration diagram for Horizon::Zone::Traits::EquipATK:

Public Member Functions

 EquipATK (std::weak_ptr< Unit > unit)
 
 ~EquipATK ()
 
void on_observable_changed (Strength *)
 
void on_observable_changed (Dexterity *)
 
void on_weapon_changed ()
 
void set_strength (Strength *str)
 
void set_dexterity (Dexterity *dex)
 
int32_t compute ()
 Computes the EquipATK property of physical attacks. EquipATK = floor[((BaseWeaponDamage + Variance + StatBonus + RefinementBonus + OverUpgradeBonus) × SizePenaltyMultiplier]. More...
 
int32_t compute_variance (int8_t weapon_lvl, int32_t base_weapon_dmg)
 
int32_t get_lhw_overupgrade ()
 
int32_t get_rhw_overupgrade ()
 
- Public Member Functions inherited from Horizon::Zone::Traits::Attribute
 Attribute ()=default
 
 Attribute (std::weak_ptr< Unit > unit, status_point_type st_type, int32_t base=0, int32_t equip=0, int32_t status=0)
 
 Attribute (const Attribute &other)
 
 Attribute (Attribute &&other) noexcept
 
std::shared_ptr< Unitunit ()
 
void unit (std::shared_ptr< Unit > e)
 
virtual void set_base (int32_t val, bool notify=true)
 
virtual void add_base (int32_t val, bool notify=true)
 
virtual void sub_base (int32_t val, bool notify=true)
 
virtual int32_t get_base () const
 
virtual void set_equip (int32_t val, bool notify=true)
 
virtual void add_equip (int32_t val, bool notify=true)
 
virtual void sub_equip (int32_t val, bool notify=true)
 
virtual int32_t get_equip () const
 
virtual void set_status (int32_t val, bool notify=true)
 
virtual void add_status (int32_t val, bool notify=true)
 
virtual void sub_status (int32_t val, bool notify=true)
 
virtual int32_t get_status () const
 
virtual int32_t total () const
 
virtual int32_t compute ()
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
TT operator+ (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
TT operator/ (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
TT operator* (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
TT operator- (TT right)
 
int operator+ (Attribute const &right) const
 
double operator/ (Attribute const &right)
 
double operator* (Attribute const &right)
 
int operator- (Attribute const &right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator== (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator!= (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator> (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator>= (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator< (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator<= (TT right)
 
bool operator== (Attribute const &right)
 
bool operator!= (Attribute const &right)
 
bool operator> (Attribute const &right)
 
bool operator>= (Attribute const &right)
 
bool operator< (Attribute const &right)
 
bool operator<= (Attribute const &right)
 
Attribute operator= (Attribute &right)
 
Attribute operator= (Attribute &&right)
 
void add_permanent_change (s_attribute_change_values change, std::string source)
 
void remove_permanent_change (std::string source)
 
void add_temporary_change (s_attribute_change_values change, uint64_t duration, std::string source)
 
void remove_temporary_change (std::string source)
 
void add_periodic_change (s_attribute_change_values change, uint64_t duration, uint64_t interval, std::string source)
 
void remove_periodic_change (std::string source)
 
void update (uint64_t delta)
 
void apply (bool notify=true)
 
void reset ()
 
void notify ()
 
status_point_type get_type () const
 
bool needs_recalculation () const
 
void recalculate (bool flag)
 
bool is_compute_ready () const
 

Private Attributes

Strength_str {nullptr}
 
Dexterity_dex {nullptr}
 
int32_t _left_hand_val {0}
 
int32_t _right_hand_val {0}
 
int32_t _lhw_overupgrade {0}
 
int32_t _rhw_overupgrade {0}
 

Additional Inherited Members

- Protected Attributes inherited from Horizon::Zone::Traits::Attribute
status_point_type _status_point_type {status_point_type::STATUS_POINT_INVALID}
 
int32_t _base_val {0}
 
int32_t _equip_val {0}
 
int32_t _status_val {0}
 
bool _apply_periodic_changes {false}
 
bool _recalculate_flag {false}
 
bool _calculate_ready {false}
 

Constructor & Destructor Documentation

◆ EquipATK()

Horizon::Zone::Traits::EquipATK::EquipATK ( std::weak_ptr< Unit unit)
inline
1193 { }
@ STATUS_EQUIP_ATK
Definition: UnitDefinitions.hpp:131
std::shared_ptr< Unit > unit()
Definition: Attribute.hpp:259

◆ ~EquipATK()

Horizon::Zone::Traits::EquipATK::~EquipATK ( )
inline
1194{ }

Member Function Documentation

◆ compute()

int32_t EquipATK::compute ( )
virtual

Computes the EquipATK property of physical attacks. EquipATK = floor[((BaseWeaponDamage + Variance + StatBonus + RefinementBonus + OverUpgradeBonus) × SizePenaltyMultiplier].

Reimplemented from Horizon::Zone::Traits::Attribute.

769{
770 int32_t str = 1, dex = 1;
771
772 if (unit() == nullptr || unit()->type() != UNIT_PLAYER)
773 return 0;
774
775 if (_str != nullptr)
776 str = _str->total();
777
778 if (_dex != nullptr)
779 dex = _dex->total();
780
781 std::shared_ptr<Horizon::Zone::Units::Player> player = unit()->downcast<Horizon::Zone::Units::Player>();
782 EquipmentListType const &equipments = player->inventory()->equipments();
783
784 std::shared_ptr<const item_entry_data> lhw = equipments[IT_EQPI_HAND_L].second.lock();
785 std::shared_ptr<const item_entry_data> rhw = equipments[IT_EQPI_HAND_R].second.lock();
786
787 if (lhw && lhw->type == IT_TYPE_WEAPON) {
788 // Base Weapon Damage
789 _left_hand_val = lhw->config->attack;
790 // StatBonus = BaseWeaponDamage × (Melee: Str / Ranged: Dex) ÷ 200
791 _left_hand_val += (lhw->config->attack * (((1ULL << lhw->config->sub_type.weapon_t) & IT_WTM_MELEE) ? str : dex) / 200.00f);
792 } else {
793 _left_hand_val = 0;
794 }
795
796 if (rhw && rhw->type == IT_TYPE_WEAPON) {
797 // Base Weapon Damage
798 _right_hand_val = rhw->config->attack;
799 // StatBonus = BaseWeaponDamage × (Melee: Str / Ranged: Dex) ÷ 200
800 _right_hand_val += (rhw->config->attack * ((( 1ULL << rhw->config->sub_type.weapon_t) & IT_WTM_MELEE) ? str : dex) / 200.00f);
801 } else {
802 _right_hand_val = 0;
803 }
804
806
807 return total();
808}
@ IT_TYPE_WEAPON
Definition: ItemDefinitions.hpp:258
@ IT_EQPI_HAND_L
Definition: ItemDefinitions.hpp:213
@ IT_EQPI_HAND_R
Definition: ItemDefinitions.hpp:214
@ IT_WTM_MELEE
Definition: ItemDefinitions.hpp:142
std::array< std::pair< item_equip_location_mask, std::weak_ptr< item_entry_data > >, IT_EQPI_MAX > EquipmentListType
Definition: ItemDefinitions.hpp:577
@ UNIT_PLAYER
Definition: UnitDefinitions.hpp:45
virtual void set_base(int32_t val, bool notify=true)
Definition: Attribute.hpp:262
virtual int32_t total() const
Definition: Attribute.hpp:289
int32_t _right_hand_val
Definition: AttributesImpl.hpp:1215
int32_t _left_hand_val
Definition: AttributesImpl.hpp:1214
Strength * _str
Definition: AttributesImpl.hpp:1212
Dexterity * _dex
Definition: AttributesImpl.hpp:1213
Definition: Player.hpp:62
std::shared_ptr< Assets::Inventory > inventory()
Definition: Player.hpp:164

References Horizon::Zone::Units::Player::inventory(), IT_EQPI_HAND_L, IT_EQPI_HAND_R, IT_TYPE_WEAPON, IT_WTM_MELEE, Horizon::Zone::Traits::s_attribute_change_values::set_base(), and UNIT_PLAYER.

Referenced by on_observable_changed(), and on_weapon_changed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compute_variance()

int32_t EquipATK::compute_variance ( int8_t  weapon_lvl,
int32_t  base_weapon_dmg 
)
811{
812 srand(time(0));
813
814 return floor(((rand() % 1000 + (-500)) / 10000.f) * weapon_lvl * base_weapon_dmg);
815}

◆ get_lhw_overupgrade()

int32_t Horizon::Zone::Traits::EquipATK::get_lhw_overupgrade ( )
inline
1208{ return _lhw_overupgrade; }
int32_t _lhw_overupgrade
Definition: AttributesImpl.hpp:1216

References _lhw_overupgrade.

◆ get_rhw_overupgrade()

int32_t Horizon::Zone::Traits::EquipATK::get_rhw_overupgrade ( )
inline
1209{ return _rhw_overupgrade; }
int32_t _rhw_overupgrade
Definition: AttributesImpl.hpp:1217

References _rhw_overupgrade.

◆ on_observable_changed() [1/2]

void Horizon::Zone::Traits::EquipATK::on_observable_changed ( Dexterity )
inline
1197{ if (is_compute_ready()) compute(); }
bool is_compute_ready() const
Definition: Attribute.hpp:412
int32_t compute()
Computes the EquipATK property of physical attacks. EquipATK = floor[((BaseWeaponDamage + Variance + ...
Definition: Attribute.cpp:768

References compute(), and Horizon::Zone::Traits::Attribute::is_compute_ready().

+ Here is the call graph for this function:

◆ on_observable_changed() [2/2]

void Horizon::Zone::Traits::EquipATK::on_observable_changed ( Strength )
inline
1196{ if (is_compute_ready()) compute(); }

References compute(), and Horizon::Zone::Traits::Attribute::is_compute_ready().

+ Here is the call graph for this function:

◆ on_weapon_changed()

void Horizon::Zone::Traits::EquipATK::on_weapon_changed ( )
inline
1198{ if (is_compute_ready()) compute(); }

References compute(), and Horizon::Zone::Traits::Attribute::is_compute_ready().

+ Here is the call graph for this function:

◆ set_dexterity()

void Horizon::Zone::Traits::EquipATK::set_dexterity ( Dexterity dex)
inline
1201{ _dex = dex; }

References _dex.

◆ set_strength()

void Horizon::Zone::Traits::EquipATK::set_strength ( Strength str)
inline
1200{ _str = str; }

References _str.

Member Data Documentation

◆ _dex

Dexterity* Horizon::Zone::Traits::EquipATK::_dex {nullptr}
private

Referenced by set_dexterity().

◆ _left_hand_val

int32_t Horizon::Zone::Traits::EquipATK::_left_hand_val {0}
private

◆ _lhw_overupgrade

int32_t Horizon::Zone::Traits::EquipATK::_lhw_overupgrade {0}
private

Referenced by get_lhw_overupgrade().

◆ _rhw_overupgrade

int32_t Horizon::Zone::Traits::EquipATK::_rhw_overupgrade {0}
private

Referenced by get_rhw_overupgrade().

◆ _right_hand_val

int32_t Horizon::Zone::Traits::EquipATK::_right_hand_val {0}
private

◆ _str

Strength* Horizon::Zone::Traits::EquipATK::_str {nullptr}
private

Referenced by set_strength().


The documentation for this class was generated from the following files: