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

#include <AttributesImpl.hpp>

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

Public Member Functions

 BaseAttack (std::weak_ptr< Unit > unit)
 
 ~BaseAttack ()
 
void on_observable_changed (Strength *)
 
void on_observable_changed (Dexterity *)
 
void on_observable_changed (Luck *)
 
void on_observable_changed (BaseLevel *)
 
void on_equipment_changed ()
 
int32_t compute ()
 
void set_strength (Strength *str)
 
void set_dexterity (Dexterity *dex)
 
void set_luck (Luck *luk)
 
void set_base_level (BaseLevel *blvl)
 
- 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}
 
Luck_luk {nullptr}
 
BaseLevel_blvl {nullptr}
 

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

◆ BaseAttack()

Horizon::Zone::Traits::BaseAttack::BaseAttack ( std::weak_ptr< Unit unit)
inline
1596 { }
@ STATUS_BASE_ATK
Definition: UnitDefinitions.hpp:428
std::shared_ptr< Unit > unit()
Definition: Attribute.hpp:259

◆ ~BaseAttack()

Horizon::Zone::Traits::BaseAttack::~BaseAttack ( )
inline
1597{ }

Member Function Documentation

◆ compute()

int32_t BaseAttack::compute ( )
virtual

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

999{
1000 if (unit()->type() == UNIT_PLAYER) {
1001 bool melee = true;
1002 EquipmentListType const &equipments = unit()->downcast<Horizon::Zone::Units::Player>()->inventory()->equipments();
1003 std::shared_ptr<const item_entry_data> rhw = nullptr;
1004
1005 if (!equipments[IT_EQPI_HAND_R].second.expired()) {
1006 rhw = equipments[IT_EQPI_HAND_R].second.lock();
1007
1008 switch (rhw->config->sub_type.weapon_t)
1009 {
1010 case IT_WT_BOW:
1011 case IT_WT_MUSICAL:
1012 case IT_WT_WHIP:
1013 case IT_WT_REVOLVER:
1014 case IT_WT_RIFLE:
1015 case IT_WT_GATLING:
1016 case IT_WT_SHOTGUN:
1017 case IT_WT_GRENADE:
1018 melee = false;
1019 default:
1020 break;
1021 }
1022 }
1023
1024 set_base((melee ? _str->total() : _dex->total()) + (float) ((melee ? _dex->get_base() : _str->total()) / 5) + (float) (_luk->get_base() / 3) + (_blvl->get_base() / 4));
1025 }
1026 else if (unit()->type() == UNIT_MONSTER)
1027 set_base(_str->total() + _blvl->get_base());
1028
1029 return total();
1030}
@ IT_EQPI_HAND_R
Definition: ItemDefinitions.hpp:214
@ 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
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
@ UNIT_MONSTER
Definition: UnitDefinitions.hpp:50
virtual void set_base(int32_t val, bool notify=true)
Definition: Attribute.hpp:262
virtual int32_t get_base() const
Definition: Attribute.hpp:269
virtual int32_t total() const
Definition: Attribute.hpp:289
BaseLevel * _blvl
Definition: AttributesImpl.hpp:1617
Luck * _luk
Definition: AttributesImpl.hpp:1616
Dexterity * _dex
Definition: AttributesImpl.hpp:1615
Strength * _str
Definition: AttributesImpl.hpp:1614
Definition: Player.hpp:62

References IT_EQPI_HAND_R, IT_WT_BOW, IT_WT_GATLING, IT_WT_GRENADE, IT_WT_MUSICAL, IT_WT_REVOLVER, IT_WT_RIFLE, IT_WT_SHOTGUN, IT_WT_WHIP, Horizon::Zone::Traits::s_attribute_change_values::set_base(), UNIT_MONSTER, 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::BaseAttack::on_equipment_changed ( )
inline
1604{ if (is_compute_ready()) compute(); }
bool is_compute_ready() const
Definition: Attribute.hpp:412
int32_t compute()
Definition: Attribute.cpp:998

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

+ Here is the call graph for this function:

◆ on_observable_changed() [1/4]

void Horizon::Zone::Traits::BaseAttack::on_observable_changed ( BaseLevel )
inline
1602{ 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/4]

void Horizon::Zone::Traits::BaseAttack::on_observable_changed ( Dexterity )
inline
1600{ 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/4]

void Horizon::Zone::Traits::BaseAttack::on_observable_changed ( Luck )
inline
1601{ 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() [4/4]

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

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

+ Here is the call graph for this function:

◆ set_base_level()

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

References _blvl.

◆ set_dexterity()

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

References _dex.

◆ set_luck()

void Horizon::Zone::Traits::BaseAttack::set_luck ( Luck luk)
inline
1610{ _luk = luk; }

References _luk.

◆ set_strength()

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

References _str.

Member Data Documentation

◆ _blvl

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

Referenced by set_base_level().

◆ _dex

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

Referenced by set_dexterity().

◆ _luk

Luck* Horizon::Zone::Traits::BaseAttack::_luk {nullptr}
private

Referenced by set_luck().

◆ _str

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

Referenced by set_strength().


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