diff --git a/data/items/item_instance.cpp b/data/items/item_instance.cpp index 3083707..3f257ee 100644 --- a/data/items/item_instance.cpp +++ b/data/items/item_instance.cpp @@ -26,10 +26,10 @@ SOFTWARE. #include "../../singletons/entity_data_manager.h" -Ref ItemInstance::get_item_template() const { +Ref ItemInstance::get_item_template() { return _item_template; } -void ItemInstance::set_item_template(const Ref value) { +void ItemInstance::set_item_template(const Ref &value) { _item_template = value; _item_template_id = 0; @@ -38,15 +38,15 @@ void ItemInstance::set_item_template(const Ref value) { _item_template_id = value->get_id(); } -Ref ItemInstance::get_item_stat_modifier(int index) { +Ref ItemInstance::get_item_stat_modifier(const int index) { ERR_FAIL_INDEX_V(index, _modifiers.size(), Ref()); return _modifiers.get(index); } -void ItemInstance::add_item_stat_modifier(Ref modifier) { +void ItemInstance::add_item_stat_modifier(const Ref &modifier) { _modifiers.push_back(modifier); } -void ItemInstance::remove_item_stat_modifier(int index) { +void ItemInstance::remove_item_stat_modifier(const int index) { ERR_FAIL_INDEX(index, _modifiers.size()); _modifiers.remove(index); @@ -54,19 +54,28 @@ void ItemInstance::remove_item_stat_modifier(int index) { void ItemInstance::clear_item_stat_modifiers() { _modifiers.clear(); } -int ItemInstance::get_item_stat_modifier_count() { +int ItemInstance::get_item_stat_modifier_count() const { return _modifiers.size(); } -int ItemInstance::get_stack_size() { +int ItemInstance::get_stack_size() const { return _stack_size; } -void ItemInstance::set_stack_size(int value) { +void ItemInstance::set_stack_size(const int value) { _stack_size = value; emit_signal("stack_size_changed", Ref(this)); } +int ItemInstance::get_charges() const { + return _charges; +} +void ItemInstance::set_charges(const int value) { + _charges = value; + + emit_signal("stack_charges_changed", Ref(this)); +} + Dictionary ItemInstance::to_dict() { return call("_to_dict"); } @@ -117,6 +126,7 @@ void ItemInstance::_from_dict(const Dictionary &dict) { ItemInstance::ItemInstance() { _stack_size = 1; _item_template_id = 0; + _charges = -1; } ItemInstance::~ItemInstance() { _modifiers.clear(); @@ -124,6 +134,7 @@ ItemInstance::~ItemInstance() { void ItemInstance::_bind_methods() { ADD_SIGNAL(MethodInfo("stack_size_changed", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance"))); + ADD_SIGNAL(MethodInfo("stack_charges_changed", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "ItemInstance"))); ClassDB::bind_method(D_METHOD("get_item_template"), &ItemInstance::get_item_template); ClassDB::bind_method(D_METHOD("set_item_template", "value"), &ItemInstance::set_item_template); @@ -133,6 +144,10 @@ void ItemInstance::_bind_methods() { ClassDB::bind_method(D_METHOD("set_stack_size", "count"), &ItemInstance::set_stack_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "stack_size"), "set_stack_size", "get_stack_size"); + ClassDB::bind_method(D_METHOD("get_charges"), &ItemInstance::get_charges); + ClassDB::bind_method(D_METHOD("set_charges", "size"), &ItemInstance::set_charges); + ADD_PROPERTY(PropertyInfo(Variant::INT, "charges"), "set_charges", "get_charges"); + ClassDB::bind_method(D_METHOD("get_item_stat_modifier", "index"), &ItemInstance::get_item_stat_modifier); ClassDB::bind_method(D_METHOD("add_item_stat_modifier", "modifier"), &ItemInstance::add_item_stat_modifier); ClassDB::bind_method(D_METHOD("remove_item_stat_modifier", "index"), &ItemInstance::remove_item_stat_modifier); diff --git a/data/items/item_instance.h b/data/items/item_instance.h index 7f9f90c..124f85c 100644 --- a/data/items/item_instance.h +++ b/data/items/item_instance.h @@ -36,18 +36,21 @@ class ItemInstance : public Reference { GDCLASS(ItemInstance, Reference); public: - Ref get_item_template() const; - void set_item_template(const Ref value); + Ref get_item_template(); + void set_item_template(const Ref &value); - Ref get_item_stat_modifier(int index); - void add_item_stat_modifier(Ref modifier); - void remove_item_stat_modifier(int index); + Ref get_item_stat_modifier(const int index); + void add_item_stat_modifier(const Ref &modifier); + void remove_item_stat_modifier(const int index); void clear_item_stat_modifiers(); - int get_item_stat_modifier_count(); + int get_item_stat_modifier_count() const; - int get_stack_size(); - void set_stack_size(int value); + int get_stack_size() const; + void set_stack_size(const int value); + + int get_charges() const; + void set_charges(const int value); Dictionary to_dict(); void from_dict(const Dictionary &dict); @@ -66,6 +69,7 @@ private: int _item_template_id; int _stack_size; + int _charges; Vector > _modifiers; }; diff --git a/data/items/item_template.cpp b/data/items/item_template.cpp index 4c0a584..2809aea 100644 --- a/data/items/item_template.cpp +++ b/data/items/item_template.cpp @@ -79,14 +79,14 @@ void ItemTemplate::set_equip_slot(const ItemEnums::EquipSlots value) { Ref ItemTemplate::get_item_visual() const { return _item_visual; } -void ItemTemplate::set_item_visual(const Ref value) { +void ItemTemplate::set_item_visual(const Ref &value) { _item_visual = value; } Ref ItemTemplate::get_required_character_class() const { return _required_character_class; } -void ItemTemplate::set_required_character_class(const Ref value) { +void ItemTemplate::set_required_character_class(const Ref &value) { _required_character_class = value; } @@ -109,7 +109,7 @@ Ref ItemTemplate::get_icon() const { return _icon; } -void ItemTemplate::set_icon(const Ref value) { +void ItemTemplate::set_icon(const Ref &value) { _icon = value; } @@ -146,19 +146,19 @@ void ItemTemplate::set_bag_size(const int size) { //// TEACHES //// -int ItemTemplate::get_num_teaches_spells() { +int ItemTemplate::get_num_teaches_spells() const { return _teaches_spells.size(); } void ItemTemplate::set_num_teaches_spells(int value) { _teaches_spells.resize(value); } -Ref ItemTemplate::get_teaches_spell(int index) const { +Ref ItemTemplate::get_teaches_spell(const int index) { ERR_FAIL_INDEX_V(index, _teaches_spells.size(), Ref()); return _teaches_spells[index]; } -void ItemTemplate::set_teaches_spell(int index, Ref spell) { +void ItemTemplate::set_teaches_spell(const int index, const Ref &spell) { ERR_FAIL_INDEX(index, _teaches_spells.size()); _teaches_spells.set(index, Ref(spell)); @@ -182,19 +182,19 @@ void ItemTemplate::set_teaches_spells(const Vector &spells) { //// GRANTS SPELLS //// -int ItemTemplate::get_num_grants_spells() { +int ItemTemplate::get_num_grants_spells() const { return _grants_spells.size(); } -void ItemTemplate::set_num_grants_spells(int value) { +void ItemTemplate::set_num_grants_spells(const int value) { _grants_spells.resize(value); } -Ref ItemTemplate::get_grants_spell(int index) const { +Ref ItemTemplate::get_grants_spell(const int index) { ERR_FAIL_INDEX_V(index, _grants_spells.size(), Ref()); return _grants_spells[index]; } -void ItemTemplate::set_grants_spell(int index, Ref spell) { +void ItemTemplate::set_grants_spell(const int index, const Ref &spell) { ERR_FAIL_INDEX(index, _grants_spells.size()); _grants_spells.set(index, Ref(spell)); @@ -218,19 +218,19 @@ void ItemTemplate::set_grants_spells(const Vector &spells) { //// AURAS //// -int ItemTemplate::get_num_auras() { +int ItemTemplate::get_num_auras() const { return _auras.size(); } void ItemTemplate::set_num_auras(int value) { _auras.resize(value); } -Ref ItemTemplate::get_aura(int index) const { +Ref ItemTemplate::get_aura(const int index) { ERR_FAIL_INDEX_V(index, _auras.size(), Ref()); return _auras[index]; } -void ItemTemplate::set_aura(int index, Ref aura) { +void ItemTemplate::set_aura(const int index, const Ref &aura) { ERR_FAIL_INDEX(index, _auras.size()); _auras.set(index, Ref(aura)); @@ -253,16 +253,16 @@ void ItemTemplate::set_auras(const Vector &auras) { } //Required Skills -int ItemTemplate::get_num_required_skills() { +int ItemTemplate::get_num_required_skills() const { return _required_skills.size(); } -Ref ItemTemplate::get_required_skill(int index) const { +Ref ItemTemplate::get_required_skill(const int index) { ERR_FAIL_INDEX_V(index, _required_skills.size(), Ref()); return _required_skills.get(index); } -void ItemTemplate::set_required_skill(int index, Ref aura) { +void ItemTemplate::set_required_skill(const int index, const Ref &aura) { ERR_FAIL_INDEX(index, _required_skills.size()); _required_skills.set(index, aura); @@ -285,13 +285,27 @@ void ItemTemplate::set_required_skills(const Vector &skills) { } //use spell -Ref ItemTemplate::get_use_spell() const { +Ref ItemTemplate::get_use_spell() { return _use_spell; } -void ItemTemplate::set_use_spell(Ref use_spell) { +void ItemTemplate::set_use_spell(const Ref &use_spell) { _use_spell = use_spell; } +int ItemTemplate::get_charges() const { + return _charges; +} +void ItemTemplate::set_charges(const int value) { + _charges = value; +} + +bool ItemTemplate::get_consumed() const { + return _consumed; +} +void ItemTemplate::set_consumed(const bool value) { + _consumed = false; +} + int ItemTemplate::get_item_stat_modifier_count() const { return _modifier_count; } @@ -300,71 +314,71 @@ void ItemTemplate::set_item_stat_modifier_count(int value) { _modifier_count = value; } -Stat::StatId ItemTemplate::get_item_stat_id(int index) { +Stat::StatId ItemTemplate::get_item_stat_id(const int index) const { return _modifiers[index]->get_stat_id(); } -void ItemTemplate::set_item_stat_id(int index, Stat::StatId value) { +void ItemTemplate::set_item_stat_id(const int index, const Stat::StatId value) { _modifiers[index]->set_stat_id(value); } -float ItemTemplate::get_item_min_base_mod(int index) { +float ItemTemplate::get_item_min_base_mod(const int index) const { return _modifiers[index]->get_min_base_mod(); } -void ItemTemplate::set_item_min_base_mod(int index, float value) { +void ItemTemplate::set_item_min_base_mod(const int index, const float value) { _modifiers[index]->set_min_base_mod(value); } -float ItemTemplate::get_item_max_base_mod(int index) { +float ItemTemplate::get_item_max_base_mod(const int index) const { return _modifiers[index]->get_max_base_mod(); } -void ItemTemplate::set_item_max_base_mod(int index, float value) { +void ItemTemplate::set_item_max_base_mod(const int index, const float value) { _modifiers[index]->set_max_base_mod(value); } -float ItemTemplate::get_item_min_bonus_mod(int index) { +float ItemTemplate::get_item_min_bonus_mod(const int index) const { return _modifiers[index]->get_min_bonus_mod(); } -void ItemTemplate::set_item_min_bonus_mod(int index, float value) { +void ItemTemplate::set_item_min_bonus_mod(const int index, const float value) { _modifiers[index]->set_min_bonus_mod(value); } -float ItemTemplate::get_item_max_bonus_mod(int index) { +float ItemTemplate::get_item_max_bonus_mod(const int index) const { return _modifiers[index]->get_max_bonus_mod(); } -void ItemTemplate::set_item_max_bonus_mod(int index, float value) { +void ItemTemplate::set_item_max_bonus_mod(const int index, const float value) { _modifiers[index]->set_max_bonus_mod(value); } -float ItemTemplate::get_item_min_percent_mod(int index) { +float ItemTemplate::get_item_min_percent_mod(const int index) const { return _modifiers[index]->get_min_percent_mod(); } -void ItemTemplate::set_item_min_percent_mod(int index, float value) { +void ItemTemplate::set_item_min_percent_mod(const int index, const float value) { _modifiers[index]->set_min_percent_mod(value); } -float ItemTemplate::get_item_max_percent_mod(int index) { +float ItemTemplate::get_item_max_percent_mod(const int index) const { return _modifiers[index]->get_max_percent_mod(); } -void ItemTemplate::set_item_max_percent_mod(int index, float value) { +void ItemTemplate::set_item_max_percent_mod(const int index, const float value) { _modifiers[index]->set_max_percent_mod(value); } -float ItemTemplate::get_item_scaling_factor(int index) { +float ItemTemplate::get_item_scaling_factor(const int index) const { return _modifiers[index]->get_scaling_factor(); } -void ItemTemplate::set_item_scaling_factor(int index, float value) { +void ItemTemplate::set_item_scaling_factor(const int index, const float value) { _modifiers[index]->set_scaling_factor(value); } -Ref ItemTemplate::get_item_template_stat_modifier(int index) { +Ref ItemTemplate::get_item_template_stat_modifier(const int index) { return Ref(_modifiers[index]); } /* @@ -422,6 +436,9 @@ ItemTemplate::ItemTemplate() { _stack_size = 1; _bag_size = 0; + _charges = -1; + _consumed = false; + for (int i = 0; i < MAX_ITEM_STAT_MOD; ++i) { _modifiers[i] = Ref(memnew(ItemTemplateStatModifier())); } @@ -559,6 +576,14 @@ void ItemTemplate::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_spell", "size"), &ItemTemplate::set_use_spell); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "use_spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell"), "set_use_spell", "get_use_spell"); + ClassDB::bind_method(D_METHOD("get_charges"), &ItemTemplate::get_charges); + ClassDB::bind_method(D_METHOD("set_charges", "size"), &ItemTemplate::set_charges); + ADD_PROPERTY(PropertyInfo(Variant::INT, "charges"), "set_charges", "get_charges"); + + ClassDB::bind_method(D_METHOD("get_consumed"), &ItemTemplate::get_consumed); + ClassDB::bind_method(D_METHOD("set_consumed", "size"), &ItemTemplate::set_consumed); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "consumed"), "set_consumed", "get_consumed"); + //StatMods Property binds ClassDB::bind_method(D_METHOD("get_item_stat_modifier_count"), &ItemTemplate::get_item_stat_modifier_count); ClassDB::bind_method(D_METHOD("set_item_stat_modifier_count", "count"), &ItemTemplate::set_item_stat_modifier_count); diff --git a/data/items/item_template.h b/data/items/item_template.h index f035f82..f65efd2 100644 --- a/data/items/item_template.h +++ b/data/items/item_template.h @@ -63,10 +63,10 @@ public: void set_equip_slot(const ItemEnums::EquipSlots value); Ref get_item_visual() const; - void set_item_visual(const Ref value); + void set_item_visual(const Ref &value); Ref get_required_character_class() const; - void set_required_character_class(const Ref value); + void set_required_character_class(const Ref &value); int get_price() const; void set_price(const int value); @@ -75,7 +75,7 @@ public: void set_stack_size(const int value); Ref get_icon() const; - void set_icon(const Ref value); + void set_icon(const Ref &value); float get_scale_x() const; void set_scale_x(const float value); @@ -90,71 +90,77 @@ public: void set_bag_size(const int size); //Teaches - int get_num_teaches_spells(); - void set_num_teaches_spells(int value); + int get_num_teaches_spells() const; + void set_num_teaches_spells(const int value); - Ref get_teaches_spell(int index) const; - void set_teaches_spell(int index, Ref teaches_spell); + Ref get_teaches_spell(const int index); + void set_teaches_spell(const int index, const Ref &teaches_spell); Vector get_teaches_spells(); void set_teaches_spells(const Vector &teaches_spells); //Grants Spells - int get_num_grants_spells(); - void set_num_grants_spells(int value); + int get_num_grants_spells() const; + void set_num_grants_spells(const int value); - Ref get_grants_spell(int index) const; - void set_grants_spell(int index, Ref grants_spell); + Ref get_grants_spell(const int index); + void set_grants_spell(const int index, const Ref &grants_spell); Vector get_grants_spells(); void set_grants_spells(const Vector &grants_spells); //Auras - int get_num_auras(); - void set_num_auras(int value); + int get_num_auras() const; + void set_num_auras(const int value); - Ref get_aura(int index) const; - void set_aura(int index, Ref aura); + Ref get_aura(const int index); + void set_aura(const int index, const Ref &aura); Vector get_auras(); void set_auras(const Vector &auras); //Required Skills - int get_num_required_skills(); + int get_num_required_skills() const; - Ref get_required_skill(int index) const; - void set_required_skill(int index, Ref skills); + Ref get_required_skill(const int index); + void set_required_skill(const int index, const Ref &skills); Vector get_required_skills(); void set_required_skills(const Vector &grants_spells); //use spell - Ref get_use_spell() const; - void set_use_spell(Ref use_spell); + Ref get_use_spell(); + void set_use_spell(const Ref &use_spell); + + int get_charges() const; + void set_charges(const int value); + + bool get_consumed() const; + void set_consumed(const bool value); //Stat mods int get_item_stat_modifier_count() const; void set_item_stat_modifier_count(const int value); - Stat::StatId get_item_stat_id(int index); + Stat::StatId get_item_stat_id(int index) const; void set_item_stat_id(int index, Stat::StatId value); - float get_item_min_base_mod(int index); - void set_item_min_base_mod(int index, float value); - float get_item_max_base_mod(int index); - void set_item_max_base_mod(int index, float value); - float get_item_min_bonus_mod(int index); - void set_item_min_bonus_mod(int index, float value); - float get_item_max_bonus_mod(int index); - void set_item_max_bonus_mod(int index, float value); - float get_item_min_percent_mod(int index); - void set_item_min_percent_mod(int index, float value); - float get_item_max_percent_mod(int index); - void set_item_max_percent_mod(int index, float value); - float get_item_scaling_factor(int index); - void set_item_scaling_factor(int index, float value); + float get_item_min_base_mod(const int index) const; + void set_item_min_base_mod(const int index, const float value); + float get_item_max_base_mod(const int index) const; + void set_item_max_base_mod(const int index, const float value); + float get_item_min_bonus_mod(const int index) const; + void set_item_min_bonus_mod(const int index, const float value); + float get_item_max_bonus_mod(const int index) const; + void set_item_max_bonus_mod(const int index, const float value); + float get_item_min_percent_mod(const int index) const; + void set_item_min_percent_mod(const int index, const float value); + float get_item_max_percent_mod(const int index) const; + void set_item_max_percent_mod(const int index, const float value); + float get_item_scaling_factor(const int index) const; + void set_item_scaling_factor(const int index, const float value); - Ref get_item_template_stat_modifier(int index); + Ref get_item_template_stat_modifier(const int index); //void set_item_stat_modifier(int index, ItemStatModifier modifier); int get_animator_weapon_type(); @@ -207,6 +213,8 @@ private: Vector > _auras; Vector > _required_skills; Ref _use_spell; + int _charges; + bool _consumed; int _modifier_count; Ref _modifiers[MAX_ITEM_STAT_MOD]; diff --git a/data/items/item_template_stat_modifier.cpp b/data/items/item_template_stat_modifier.cpp index e6742f1..26ef297 100644 --- a/data/items/item_template_stat_modifier.cpp +++ b/data/items/item_template_stat_modifier.cpp @@ -22,67 +22,67 @@ SOFTWARE. #include "item_template_stat_modifier.h" -Stat::StatId ItemTemplateStatModifier::get_stat_id() { +Stat::StatId ItemTemplateStatModifier::get_stat_id() const { return _stat_id; } -void ItemTemplateStatModifier::set_stat_id(Stat::StatId value) { +void ItemTemplateStatModifier::set_stat_id(const Stat::StatId value) { _stat_id = value; } -float ItemTemplateStatModifier::get_min_base_mod() { +float ItemTemplateStatModifier::get_min_base_mod() const { return _min_mod_max; } -void ItemTemplateStatModifier::set_min_base_mod(float value) { +void ItemTemplateStatModifier::set_min_base_mod(const float value) { _min_mod_max = value; } -float ItemTemplateStatModifier::get_max_base_mod() { +float ItemTemplateStatModifier::get_max_base_mod() const { return _max_mod_max; } -void ItemTemplateStatModifier::set_max_base_mod(float value) { +void ItemTemplateStatModifier::set_max_base_mod(const float value) { _max_mod_max = value; } -float ItemTemplateStatModifier::get_min_bonus_mod() { +float ItemTemplateStatModifier::get_min_bonus_mod() const { return _min_mod_max; } -void ItemTemplateStatModifier::set_min_bonus_mod(float value) { +void ItemTemplateStatModifier::set_min_bonus_mod(const float value) { _min_mod_max = value; } -float ItemTemplateStatModifier::get_max_bonus_mod() { +float ItemTemplateStatModifier::get_max_bonus_mod() const { return _max_mod_max; } -void ItemTemplateStatModifier::set_max_bonus_mod(float value) { +void ItemTemplateStatModifier::set_max_bonus_mod(const float value) { _max_mod_max = value; } -float ItemTemplateStatModifier::get_min_percent_mod() { +float ItemTemplateStatModifier::get_min_percent_mod() const { return _min_mod_precent; } -void ItemTemplateStatModifier::set_min_percent_mod(float value) { +void ItemTemplateStatModifier::set_min_percent_mod(const float value) { _min_mod_precent = value; } -float ItemTemplateStatModifier::get_max_percent_mod() { +float ItemTemplateStatModifier::get_max_percent_mod() const { return _max_mod_precent; } -void ItemTemplateStatModifier::set_max_percent_mod(float value) { +void ItemTemplateStatModifier::set_max_percent_mod(const float value) { _max_mod_precent = value; } -float ItemTemplateStatModifier::get_scaling_factor() { +float ItemTemplateStatModifier::get_scaling_factor() const { return _scaling_factor; } -void ItemTemplateStatModifier::set_scaling_factor(float value) { +void ItemTemplateStatModifier::set_scaling_factor(const float value) { _scaling_factor = value; } diff --git a/data/items/item_template_stat_modifier.h b/data/items/item_template_stat_modifier.h index 56a3c1b..5ee606f 100644 --- a/data/items/item_template_stat_modifier.h +++ b/data/items/item_template_stat_modifier.h @@ -30,29 +30,29 @@ class ItemTemplateStatModifier : public Reference { GDCLASS(ItemTemplateStatModifier, Reference); public: - Stat::StatId get_stat_id(); - void set_stat_id(Stat::StatId value); + Stat::StatId get_stat_id() const; + void set_stat_id(const Stat::StatId value); - float get_min_base_mod(); - void set_min_base_mod(float value); + float get_min_base_mod() const; + void set_min_base_mod(const float value); - float get_max_base_mod(); - void set_max_base_mod(float value); + float get_max_base_mod() const; + void set_max_base_mod(const float value); - float get_min_bonus_mod(); + float get_min_bonus_mod() const; void set_min_bonus_mod(float value); - float get_max_bonus_mod(); - void set_max_bonus_mod(float value); + float get_max_bonus_mod() const; + void set_max_bonus_mod(const float value); - float get_min_percent_mod(); - void set_min_percent_mod(float value); + float get_min_percent_mod() const; + void set_min_percent_mod(const float value); - float get_max_percent_mod(); - void set_max_percent_mod(float value); + float get_max_percent_mod() const; + void set_max_percent_mod(const float value); - float get_scaling_factor(); - void set_scaling_factor(float value); + float get_scaling_factor() const; + void set_scaling_factor(const float value); ItemTemplateStatModifier(); diff --git a/entities/entity.cpp b/entities/entity.cpp index 04861f7..9325166 100644 --- a/entities/entity.cpp +++ b/entities/entity.cpp @@ -2291,7 +2291,7 @@ void Entity::son_after_aura_applied(Ref data) { void Entity::scast_spell(int spell_id) { Ref cc = gets_entity_data(); - if (cc == NULL) + if (!cc.is_valid()) return; cc->start_casting(spell_id, this, 1); @@ -2301,6 +2301,15 @@ void Entity::crequest_spell_cast(int spell_id) { RPCS(scast_spell, spell_id); } +void Entity::suse_item(int item_id) { + call("_suse_item", item_id); +} +void Entity::crequest_use_item(int item_id) { + RPCS(suse_item, item_id); +} +void Entity::_suse_item(int item_id) { +} + void Entity::update_auras(float delta) { for (int i = 0; i < _s_auras.size(); ++i) { Ref ad = _s_auras.get(i); @@ -5532,6 +5541,7 @@ Entity::Entity() { //// SpellSystem //// SET_RPC_REMOTE("scast_spell"); + SET_RPC_REMOTE("suse_item"); //Damage Operations @@ -6188,6 +6198,12 @@ void Entity::_bind_methods() { ClassDB::bind_method(D_METHOD("scast_spell", "spell_id"), &Entity::scast_spell); ClassDB::bind_method(D_METHOD("crequest_spell_cast", "spell_id"), &Entity::crequest_spell_cast); + BIND_VMETHOD(MethodInfo("_suse_item", PropertyInfo(Variant::INT, "item_id"))); + + ClassDB::bind_method(D_METHOD("suse_item", "item_id"), &Entity::suse_item); + ClassDB::bind_method(D_METHOD("crequest_use_item", "item_id"), &Entity::crequest_use_item); + ClassDB::bind_method(D_METHOD("_suse_item", "item_id"), &Entity::_suse_item); + //Damage Operations ClassDB::bind_method(D_METHOD("stake_damage", "data"), &Entity::stake_damage); ClassDB::bind_method(D_METHOD("sdeal_damage_to", "data"), &Entity::sdeal_damage_to); diff --git a/entities/entity.h b/entities/entity.h index 7502905..b0489cd 100644 --- a/entities/entity.h +++ b/entities/entity.h @@ -528,6 +528,10 @@ public: void scast_spell(int spell_id); void crequest_spell_cast(int spell_id); + void suse_item(int item_id); + void crequest_use_item(int item_id); + void _suse_item(int item_id); + //Damage Operations void stake_damage(Ref info); void sdeal_damage_to(Ref info);