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

#include <AttributesImpl.hpp>

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

Public Member Functions

 MaxHP (std::weak_ptr< Unit > unit, int32_t base=0, int32_t equip=0, int32_t status=0)
 
 ~MaxHP ()
 
void on_observable_changed (BaseLevel *blvl)
 
void on_observable_changed (Vitality *vit)
 
int32_t compute ()
 
void set_base_level (BaseLevel *blvl)
 
void set_vitality (Vitality *vit)
 
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< MaxHP *, HPRegeneration * >
 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 (MaxHP * obs)
 
void register_observers (HAS_OBSERVERS... obs)
 

Private Attributes

BaseLevel_blvl
 
Vitality_vit
 

Additional Inherited Members

- Public Attributes inherited from ObservableStatus< MaxHP *, HPRegeneration * >
MaxHP * _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

◆ MaxHP()

Horizon::Zone::Traits::MaxHP::MaxHP ( std::weak_ptr< Unit unit,
int32_t  base = 0,
int32_t  equip = 0,
int32_t  status = 0 
)
inline
232 : Attribute(unit, STATUS_MAXHP, base, equip, status),
233 ObservableStatus(nullptr)
234 { }
@ STATUS_MAXHP
Definition: UnitDefinitions.hpp:95
std::shared_ptr< Unit > unit()
Definition: Attribute.hpp:259
ObservableStatus(HAS_OBSERVERS ... args)
Definition: ObservableStatus.hpp:39

◆ ~MaxHP()

Horizon::Zone::Traits::MaxHP::~MaxHP ( )
inline
235{ };

Member Function Documentation

◆ add_base()

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

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

252 {
253 Attribute::add_base(val, notify_client);
254 this->notify_observers();
255 }
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< MaxHP *, HPRegeneration * >::notify_observers().

Referenced by Horizon::Zone::UnitComponent::sync_data_types().

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

◆ add_equip()

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

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

270 {
271 Attribute::add_equip(val, notify_client);
272 this->notify_observers();
273 }
virtual void add_equip(int32_t val, bool notify=true)
Definition: Attribute.cpp:252

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

+ Here is the call graph for this function:

◆ add_status()

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

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

288 {
289 Attribute::add_status(val, notify_client);
290 this->notify_observers();
291 }
virtual void add_status(int32_t val, bool notify=true)
Definition: Attribute.cpp:260

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

+ Here is the call graph for this function:

◆ compute()

int32_t MaxHP::compute ( )
virtual

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

434{
435 std::shared_ptr<const job_config_data> job = JobDB->get_job_by_id(unit()->job_id());
436 int val = 0;
437
438 if (job == nullptr)
439 return 0;
440
441 job_class_mask job_mask = JobDB->job_id_to_mask((job_class_type) job->id);
442
443 int base_level = _blvl->total();
444 val += job->hp_table[base_level - 1];
445
446 if ((job_mask & JMASK_EXPANDED) == JOB_SUPER_NOVICE && base_level >= 99)
447 val += 2000; //Supernovice lvl99 hp bonus.
448
449 if ((job_mask & JMASK_EXPANDED_2_1) == JOB_SUPER_NOVICE_E && base_level >= 150)
450 val += 2000; //Extented Supernovice lvl150 hp bonus.
451
452 if ((job_mask & JMASK_TRANS) != 0)
453 val += val * 25 / 100; //Trans classes get a 25% hp bonus
454 else if ((job_mask & JMASK_BABY) != 0)
455 val = val * 70 / 100; //Baby classes get a 30% hp penalty
456
457 val += val * _vit->total() / 100; // +1% per each point of VIT
458
459 set_base(val);
460
461 return total();
462}
#define JobDB
Definition: JobDB.hpp:87
job_class_mask
Definition: UnitDefinitions.hpp:650
@ JMASK_EXPANDED
Definition: UnitDefinitions.hpp:687
@ JMASK_BABY
Definition: UnitDefinitions.hpp:693
@ JMASK_EXPANDED_2_1
Definition: UnitDefinitions.hpp:689
@ JMASK_TRANS
Definition: UnitDefinitions.hpp:694
job_class_type
Definition: UnitDefinitions.hpp:474
@ JOB_SUPER_NOVICE_E
Definition: UnitDefinitions.hpp:609
@ JOB_SUPER_NOVICE
Definition: UnitDefinitions.hpp:498
virtual int32_t total() const
Definition: Attribute.hpp:289
Vitality * _vit
Definition: AttributesImpl.hpp:300
BaseLevel * _blvl
Definition: AttributesImpl.hpp:299
void set_base(int32_t val, bool notify_client=true) override
Definition: AttributesImpl.hpp:245

References JMASK_BABY, JMASK_EXPANDED, JMASK_EXPANDED_2_1, JMASK_TRANS, JOB_SUPER_NOVICE, JOB_SUPER_NOVICE_E, JobDB, and Horizon::Zone::Traits::s_attribute_change_values::set_base().

Referenced by on_observable_changed().

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

◆ on_observable_changed() [1/2]

void Horizon::Zone::Traits::MaxHP::on_observable_changed ( BaseLevel blvl)
inline
237{ if (is_compute_ready()) compute(); }
bool is_compute_ready() const
Definition: Attribute.hpp:412
int32_t compute()
Definition: Attribute.cpp:433

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::MaxHP::on_observable_changed ( Vitality vit)
inline
238{ 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()

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

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

246 {
247 Attribute::set_base(val, notify_client);
248 this->notify_observers();
249 }
virtual void set_base(int32_t val, bool notify=true)
Definition: Attribute.hpp:262

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

Referenced by Horizon::Zone::UnitComponent::sync_data_types().

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

◆ set_base_level()

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

References _blvl.

◆ set_equip()

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

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

264 {
265 Attribute::set_equip(val, notify_client);
266 this->notify_observers();
267 }
virtual void set_equip(int32_t val, bool notify=true)
Definition: Attribute.hpp:271

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

+ Here is the call graph for this function:

◆ set_status()

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

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

282 {
283 Attribute::set_status(val, notify_client);
284 this->notify_observers();
285 }
virtual void set_status(int32_t val, bool notify=true)
Definition: Attribute.hpp:280

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

+ Here is the call graph for this function:

◆ set_vitality()

void Horizon::Zone::Traits::MaxHP::set_vitality ( Vitality vit)
inline
243{ _vit = vit; }

References _vit.

◆ sub_base()

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

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

258 {
259 Attribute::sub_base(val, notify_client);
260 this->notify_observers();
261 }
virtual void sub_base(int32_t val, bool notify=true)
Definition: Attribute.cpp:248

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

Referenced by Horizon::Zone::UnitComponent::sync_data_types().

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

◆ sub_equip()

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

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

276 {
277 Attribute::sub_equip(val, notify_client);
278 this->notify_observers();
279 }
virtual void sub_equip(int32_t val, bool notify=true)
Definition: Attribute.cpp:256

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

+ Here is the call graph for this function:

◆ sub_status()

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

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

294 {
295 Attribute::sub_status(val, notify_client);
296 this->notify_observers();
297 }
virtual void sub_status(int32_t val, bool notify=true)
Definition: Attribute.cpp:264

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

+ Here is the call graph for this function:

Member Data Documentation

◆ _blvl

BaseLevel* Horizon::Zone::Traits::MaxHP::_blvl
private

Referenced by set_base_level().

◆ _vit

Vitality* Horizon::Zone::Traits::MaxHP::_vit
private

Referenced by set_vitality().


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