diff --git a/data/talent.cpp b/data/talent.cpp index 785bb77..fcad947 100644 --- a/data/talent.cpp +++ b/data/talent.cpp @@ -1,10 +1,31 @@ #include "talent.h" -Ref Talent::get_next_rank() const { - return _next_rank; +Ref Talent::get_required_talent() const { + return _required_talent; } -void Talent::set_next_rank(const Ref rank) { - _next_rank = rank; +void Talent::set_required_talent(const Ref rank) { + _required_talent = rank; +} + +Ref Talent::get_required_spell() const { + return _required_talent; +} +void Talent::set_required_spell(const Ref spell) { + _required_spell = spell; +} + +Ref Talent::get_teaches_spell() const { + return _teaches_spell; +} +void Talent::set_teaches_spell(const Ref spell) { + _teaches_spell = spell; +} + +Ref Talent::get_apply_aura() const { + return _aura; +} +void Talent::set_apply_aura(Ref aura) { + _aura = Ref(aura); } Talent::Talent() { @@ -13,14 +34,24 @@ Talent::Talent() { } Talent::~Talent() { - _next_rank.unref(); + _required_talent.unref(); + _required_spell.unref(); + _teaches_spell.unref(); _aura.unref(); } void Talent::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_next_rank"), &Talent::get_next_rank); - ClassDB::bind_method(D_METHOD("set_next_rank", "next_rank"), &Talent::set_next_rank); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_rank", PROPERTY_HINT_RESOURCE_TYPE, "Talent"), "set_next_rank", "get_next_rank"); + ClassDB::bind_method(D_METHOD("get_required_talent"), &Talent::get_required_talent); + ClassDB::bind_method(D_METHOD("set_required_talent", "next_rank"), &Talent::set_required_talent); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "required_talent", PROPERTY_HINT_RESOURCE_TYPE, "Talent"), "set_required_talent", "get_required_talent"); + + ClassDB::bind_method(D_METHOD("get_required_spell"), &Talent::get_required_spell); + ClassDB::bind_method(D_METHOD("set_required_spell", "next_rank"), &Talent::set_required_spell); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "required_spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_required_spell", "get_required_spell"); + + ClassDB::bind_method(D_METHOD("get_teaches_spell"), &Talent::get_teaches_spell); + ClassDB::bind_method(D_METHOD("set_teaches_spell", "next_rank"), &Talent::set_teaches_spell); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "teaches_spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_teaches_spell", "get_teaches_spell"); ClassDB::bind_method(D_METHOD("get_apply_aura"), &Talent::get_apply_aura); ClassDB::bind_method(D_METHOD("set_apply_aura", "value"), &Talent::set_apply_aura); diff --git a/data/talent.h b/data/talent.h index 75978fa..e8ef9bc 100644 --- a/data/talent.h +++ b/data/talent.h @@ -6,15 +6,23 @@ #include "aura.h" +class Spell; + class Talent : public Aura { GDCLASS(Talent, Aura); public: - Ref get_next_rank() const; - void set_next_rank(const Ref rank); + Ref get_required_talent() const; + void set_required_talent(const Ref rank); - Ref get_apply_aura() const { return _aura; } - void set_apply_aura(Ref aura) { _aura = Ref(aura); } + Ref get_required_spell() const; + void set_required_spell(const Ref spell); + + Ref get_teaches_spell() const; + void set_teaches_spell(const Ref spell); + + Ref get_apply_aura() const; + void set_apply_aura(Ref aura); Talent(); ~Talent(); @@ -23,7 +31,9 @@ protected: static void _bind_methods(); private: - Ref _next_rank; + Ref _required_talent; + Ref _required_spell; + Ref _teaches_spell; Ref _aura; }; diff --git a/entities/entity.cpp b/entities/entity.cpp index 67c987c..5deb8ba 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -3383,7 +3383,17 @@ void Entity::_sreceive_talent_learn_request(int spec_index, int talent_row, int if (hass_talent(talent_id)) continue; - //check requirement + if (talent->get_required_talent().is_valid()) { + if (!hass_talent(talent->get_required_talent()->get_id())) { + return; + } + } + + if (talent->get_required_spell().is_valid()) { + if (!hass_spell(talent->get_required_spell())) { + return; + } + } Ref info; info.instance();