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

#include <AttributesImpl.hpp>

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

Public Member Functions

 AttackSpeed (std::weak_ptr< Unit > unit)
 
 ~AttackSpeed ()
 
void on_observable_changed (Agility *)
 
void on_observable_changed (Dexterity *)
 
void on_observable_changed (BaseLevel *)
 
void on_equipment_changed ()
 
int32_t compute ()
 
void set_agility (Agility *agi)
 
void set_dexterity (Dexterity *dex)
 
void set_base_level (BaseLevel *blvl)
 
void set_base (int32_t val, bool notify_client=true) override
 
void add_base (int32_t val, bool notify_client=true) override
 
void sub_base (int32_t val, bool notify_client=true) override
 
void set_equip (int32_t val, bool notify_client=true) override
 
void add_equip (int32_t val, bool notify_client=true) override
 
void sub_equip (int32_t val, bool notify_client=true) override
 
void set_status (int32_t val, bool notify_client=true) override
 
void add_status (int32_t val, bool notify_client=true) override
 
void sub_status (int32_t val, bool notify_client=true) override
 
- 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
 
- Public Member Functions inherited from ObservableStatus< AttackSpeed *, AttackDelay * >
 ObservableStatus (HAS_OBSERVERS ... args)
 
 ~ObservableStatus ()
 
std::enable_if< I==sizeof...(Tp), void >::type notify (std::tuple< Tp... > &)
 
 notify (t)
 
 std::enable_if (_observers) -> on_observable_changed(_observable)
 
void notify_observers ()
 
void register_observable (AttackSpeed * obs)
 
void register_observers (HAS_OBSERVERS... obs)
 

Private Attributes

Agility_agi {nullptr}
 
Dexterity_dex {nullptr}
 
BaseLevel_blvl {nullptr}
 

Additional Inherited Members

- Public Attributes inherited from ObservableStatus< AttackSpeed *, AttackDelay * >
AttackSpeed * _observable
 
std::tuple< HAS_OBSERVERS... > _observers
 
- 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

◆ AttackSpeed()

Horizon::Zone::Traits::AttackSpeed::AttackSpeed ( std::weak_ptr< Unit unit)
inline
1463 ObservableStatus(nullptr)
1464 { }
@ STATUS_ASPD
Definition: UnitDefinitions.hpp:142
std::shared_ptr< Unit > unit()
Definition: Attribute.hpp:259
ObservableStatus(HAS_OBSERVERS ... args)
Definition: ObservableStatus.hpp:39

◆ ~AttackSpeed()

Horizon::Zone::Traits::AttackSpeed::~AttackSpeed ( )
inline
1465{ }

Member Function Documentation

◆ add_base()

void Horizon::Zone::Traits::AttackSpeed::add_base ( int32_t  val,
bool  notify_client = true 
)
inlineoverridevirtual

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

1485 {
1486 Attribute::add_base(val, notify_client);
1487 this->notify_observers();
1488 }
virtual void add_base(int32_t val, bool notify=true)
Definition: Attribute.cpp:244
void notify_observers()
Definition: ObservableStatus.hpp:59

References Horizon::Zone::Traits::Attribute::add_base(), and ObservableStatus< AttackSpeed *, AttackDelay * >::notify_observers().

+ Here is the call graph for this function:

◆ add_equip()

void Horizon::Zone::Traits::AttackSpeed::add_equip ( int32_t  val,
bool  notify_client = true 
)
inlineoverridevirtual

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

1503 {
1504 Attribute::add_equip(val, notify_client);
1505 this->notify_observers();
1506 }
virtual void add_equip(int32_t val, bool notify=true)
Definition: Attribute.cpp:252

References Horizon::Zone::Traits::Attribute::add_equip(), and ObservableStatus< AttackSpeed *, AttackDelay * >::notify_observers().

+ Here is the call graph for this function:

◆ add_status()

void Horizon::Zone::Traits::AttackSpeed::add_status ( int32_t  val,
bool  notify_client = true 
)
inlineoverridevirtual

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

1521 {
1522 Attribute::add_status(val, notify_client);
1523 this->notify_observers();
1524 }
virtual void add_status(int32_t val, bool notify=true)
Definition: Attribute.cpp:260

References Horizon::Zone::Traits::Attribute::add_status(), and ObservableStatus< AttackSpeed *, AttackDelay * >::notify_observers().

+ Here is the call graph for this function:

◆ compute()

int32_t AttackSpeed::compute ( )
virtual

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

818{
819 float temp_aspd = 0.00f;
820 int amotion = 0;
821
822 if (unit()->type() == UNIT_PLAYER) {
823 EquipmentListType const &equipments = unit()->downcast<Horizon::Zone::Units::Player>()->inventory()->equipments();
824 std::shared_ptr<const item_entry_data> rhw = equipments[IT_EQPI_HAND_R].second.lock();
825 std::shared_ptr<const item_entry_data> lhw = equipments[IT_EQPI_HAND_L].second.lock();
826 std::shared_ptr<const job_config_data> job = JobDB->get_job_by_id(unit()->job_id());
827
828 item_weapon_type rhw_type, lhw_type;
829
830 if (rhw == nullptr) {
831 rhw_type = IT_WT_FIST;
832 } else {
833 rhw_type = rhw->config->sub_type.weapon_t;
834 }
835
836 amotion = job->weapon_base_aspd[rhw_type];
837
838 if (rhw_type > IT_WT_SINGLE_MAX && lhw != nullptr) {
839 lhw_type = lhw->config->sub_type.weapon_t;
840 amotion += job->weapon_base_aspd[lhw_type] / 4; // Dual-wield
841 }
842
843 if (_dex == nullptr || _blvl == nullptr || _agi == nullptr) {
844 HLog(error) << "AttackSpeed::compute: Couldn't compute... Dex, Blvl or Agi was null.";
845 return amotion;
846 }
847
848 switch(rhw_type) {
849 case IT_WT_BOW:
850 case IT_WT_MUSICAL:
851 case IT_WT_WHIP:
852 case IT_WT_REVOLVER:
853 case IT_WT_RIFLE:
854 case IT_WT_GATLING:
855 case IT_WT_SHOTGUN:
856 case IT_WT_GRENADE:
857 temp_aspd = _dex->get_base() * _dex->get_base() / 7.0f + _agi->get_base() * _agi->get_base() * 0.5f;
858 break;
859 default:
860 temp_aspd = _dex->get_base() * _dex->get_base() / 5.0f + _agi->get_base() * _agi->get_base() * 0.5f;
861 break;
862 }
863
864 temp_aspd = (float)(sqrt(temp_aspd) * 0.25f) + 196;
865
866#define ASPD_FROM_STATUS_EFFECTS 0
867#define ASPD_FROM_SKILLS 0
868 amotion = (int)(temp_aspd + ((float)((ASPD_FROM_STATUS_EFFECTS + ASPD_FROM_SKILLS) * _agi->get_base() / 200)) - std::min(amotion, 200));
869 amotion += (std::max(0xc3 - amotion, 2) * (ASPD_FROM_STATUS_EFFECTS)) / 100;
870 amotion = std::min(amotion, MAX_ATTACK_SPEED);
871 amotion = 10 * (200 - amotion);
872#undef ASPD_FROM_STATUS_EFFECTS
873#undef ASPD_FROM_SKILLS
874 }
875
876 set_base(amotion);
877
878 return total();
879}
#define ASPD_FROM_STATUS_EFFECTS
#define ASPD_FROM_SKILLS
#define MAX_ATTACK_SPEED
Definition: Horizon.hpp:50
@ IT_EQPI_HAND_L
Definition: ItemDefinitions.hpp:213
@ IT_EQPI_HAND_R
Definition: ItemDefinitions.hpp:214
item_weapon_type
Definition: ItemDefinitions.hpp:99
@ IT_WT_FIST
Bare hands.
Definition: ItemDefinitions.hpp:100
@ IT_WT_GATLING
Definition: ItemDefinitions.hpp:119
@ IT_WT_GRENADE
Definition: ItemDefinitions.hpp:121
@ IT_WT_RIFLE
Definition: ItemDefinitions.hpp:118
@ IT_WT_BOW
Definition: ItemDefinitions.hpp:111
@ IT_WT_SHOTGUN
Definition: ItemDefinitions.hpp:120
@ IT_WT_WHIP
Definition: ItemDefinitions.hpp:114
@ IT_WT_MUSICAL
Definition: ItemDefinitions.hpp:113
@ IT_WT_REVOLVER
Definition: ItemDefinitions.hpp:117
@ IT_WT_SINGLE_MAX
Definition: ItemDefinitions.hpp:124
std::array< std::pair< item_equip_location_mask, std::weak_ptr< item_entry_data > >, IT_EQPI_MAX > EquipmentListType
Definition: ItemDefinitions.hpp:577
#define JobDB
Definition: JobDB.hpp:87
#define HLog(type)
Definition: Logger.hpp:122
@ UNIT_PLAYER
Definition: UnitDefinitions.hpp:45
BaseLevel * _blvl
Definition: AttributesImpl.hpp:1535
Dexterity * _dex
Definition: AttributesImpl.hpp:1534
void set_base(int32_t val, bool notify_client=true) override
Definition: AttributesImpl.hpp:1478
Agility * _agi
Definition: AttributesImpl.hpp:1533
virtual int32_t get_base() const
Definition: Attribute.hpp:269
virtual int32_t total() const
Definition: Attribute.hpp:289
Definition: Player.hpp:62

References ASPD_FROM_SKILLS, ASPD_FROM_STATUS_EFFECTS, HLog, IT_EQPI_HAND_L, IT_EQPI_HAND_R, IT_WT_BOW, IT_WT_FIST, IT_WT_GATLING, IT_WT_GRENADE, IT_WT_MUSICAL, IT_WT_REVOLVER, IT_WT_RIFLE, IT_WT_SHOTGUN, IT_WT_SINGLE_MAX, IT_WT_WHIP, JobDB, MAX_ATTACK_SPEED, Horizon::Zone::Traits::s_attribute_change_values::set_base(), and UNIT_PLAYER.

Referenced by on_equipment_changed(), and on_observable_changed().

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

◆ on_equipment_changed()

void Horizon::Zone::Traits::AttackSpeed::on_equipment_changed ( )
inline
1470{ if (is_compute_ready()) compute(); }
int32_t compute()
Definition: Attribute.cpp:817
bool is_compute_ready() const
Definition: Attribute.hpp:412

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

+ Here is the call graph for this function:

◆ on_observable_changed() [1/3]

void Horizon::Zone::Traits::AttackSpeed::on_observable_changed ( Agility )
inline
1467{ if (is_compute_ready()) compute(); }

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

+ Here is the call graph for this function:

◆ on_observable_changed() [2/3]

void Horizon::Zone::Traits::AttackSpeed::on_observable_changed ( BaseLevel )
inline
1469{ if (is_compute_ready()) compute(); }

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

+ Here is the call graph for this function:

◆ on_observable_changed() [3/3]

void Horizon::Zone::Traits::AttackSpeed::on_observable_changed ( Dexterity )
inline
1468{ if (is_compute_ready()) compute(); }

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

+ Here is the call graph for this function:

◆ set_agility()

void Horizon::Zone::Traits::AttackSpeed::set_agility ( Agility agi)
inline
1474{ _agi = agi; }

References _agi.

◆ set_base()

void Horizon::Zone::Traits::AttackSpeed::set_base ( int32_t  val,
bool  notify_client = true 
)
inlineoverridevirtual

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

1479 {
1480 Attribute::set_base(val, notify_client);
1481 this->notify_observers();
1482 }
virtual void set_base(int32_t val, bool notify=true)
Definition: Attribute.hpp:262

References ObservableStatus< AttackSpeed *, AttackDelay * >::notify_observers(), and Horizon::Zone::Traits::Attribute::set_base().

+ Here is the call graph for this function:

◆ set_base_level()

void Horizon::Zone::Traits::AttackSpeed::set_base_level ( BaseLevel blvl)
inline
1476{ _blvl = blvl; }

References _blvl.

◆ set_dexterity()

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

References _dex.

◆ set_equip()

void Horizon::Zone::Traits::AttackSpeed::set_equip ( int32_t  val,
bool  notify_client = true 
)
inlineoverridevirtual

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

1497 {
1498 Attribute::set_equip(val, notify_client);
1499 this->notify_observers();
1500 }
virtual void set_equip(int32_t val, bool notify=true)
Definition: Attribute.hpp:271

References ObservableStatus< AttackSpeed *, AttackDelay * >::notify_observers(), and Horizon::Zone::Traits::Attribute::set_equip().

+ Here is the call graph for this function:

◆ set_status()

void Horizon::Zone::Traits::AttackSpeed::set_status ( int32_t  val,
bool  notify_client = true 
)
inlineoverridevirtual

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

1515 {
1516 Attribute::set_status(val, notify_client);
1517 this->notify_observers();
1518 }
virtual void set_status(int32_t val, bool notify=true)
Definition: Attribute.hpp:280

References ObservableStatus< AttackSpeed *, AttackDelay * >::notify_observers(), and Horizon::Zone::Traits::Attribute::set_status().

+ Here is the call graph for this function:

◆ sub_base()

void Horizon::Zone::Traits::AttackSpeed::sub_base ( int32_t  val,
bool  notify_client = true 
)
inlineoverridevirtual

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

1491 {
1492 Attribute::sub_base(val, notify_client);
1493 this->notify_observers();
1494 }
virtual void sub_base(int32_t val, bool notify=true)
Definition: Attribute.cpp:248

References ObservableStatus< AttackSpeed *, AttackDelay * >::notify_observers(), and Horizon::Zone::Traits::Attribute::sub_base().

+ Here is the call graph for this function:

◆ sub_equip()

void Horizon::Zone::Traits::AttackSpeed::sub_equip ( int32_t  val,
bool  notify_client = true 
)
inlineoverridevirtual

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

1509 {
1510 Attribute::sub_equip(val, notify_client);
1511 this->notify_observers();
1512 }
virtual void sub_equip(int32_t val, bool notify=true)
Definition: Attribute.cpp:256

References ObservableStatus< AttackSpeed *, AttackDelay * >::notify_observers(), and Horizon::Zone::Traits::Attribute::sub_equip().

+ Here is the call graph for this function:

◆ sub_status()

void Horizon::Zone::Traits::AttackSpeed::sub_status ( int32_t  val,
bool  notify_client = true 
)
inlineoverridevirtual

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

1527 {
1528 Attribute::sub_status(val, notify_client);
1529 this->notify_observers();
1530 }
virtual void sub_status(int32_t val, bool notify=true)
Definition: Attribute.cpp:264

References ObservableStatus< AttackSpeed *, AttackDelay * >::notify_observers(), and Horizon::Zone::Traits::Attribute::sub_status().

+ Here is the call graph for this function:

Member Data Documentation

◆ _agi

Agility* Horizon::Zone::Traits::AttackSpeed::_agi {nullptr}
private

Referenced by set_agility().

◆ _blvl

BaseLevel* Horizon::Zone::Traits::AttackSpeed::_blvl {nullptr}
private

Referenced by set_base_level().

◆ _dex

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

Referenced by set_dexterity().


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