Added bindings for item use support, and marked quite a few methods/arguments as const.

This commit is contained in:
Relintai 2020-02-19 09:11:36 +01:00
parent 9d3bd194ee
commit e16c021ac8
8 changed files with 191 additions and 119 deletions

View File

@ -26,10 +26,10 @@ SOFTWARE.
#include "../../singletons/entity_data_manager.h"
Ref<ItemTemplate> ItemInstance::get_item_template() const {
Ref<ItemTemplate> ItemInstance::get_item_template() {
return _item_template;
}
void ItemInstance::set_item_template(const Ref<ItemTemplate> value) {
void ItemInstance::set_item_template(const Ref<ItemTemplate> &value) {
_item_template = value;
_item_template_id = 0;
@ -38,15 +38,15 @@ void ItemInstance::set_item_template(const Ref<ItemTemplate> value) {
_item_template_id = value->get_id();
}
Ref<ItemStatModifier> ItemInstance::get_item_stat_modifier(int index) {
Ref<ItemStatModifier> ItemInstance::get_item_stat_modifier(const int index) {
ERR_FAIL_INDEX_V(index, _modifiers.size(), Ref<ItemStatModifier>());
return _modifiers.get(index);
}
void ItemInstance::add_item_stat_modifier(Ref<ItemStatModifier> modifier) {
void ItemInstance::add_item_stat_modifier(const Ref<ItemStatModifier> &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<ItemInstance>(this));
}
int ItemInstance::get_charges() const {
return _charges;
}
void ItemInstance::set_charges(const int value) {
_charges = value;
emit_signal("stack_charges_changed", Ref<ItemInstance>(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);

View File

@ -36,18 +36,21 @@ class ItemInstance : public Reference {
GDCLASS(ItemInstance, Reference);
public:
Ref<ItemTemplate> get_item_template() const;
void set_item_template(const Ref<ItemTemplate> value);
Ref<ItemTemplate> get_item_template();
void set_item_template(const Ref<ItemTemplate> &value);
Ref<ItemStatModifier> get_item_stat_modifier(int index);
void add_item_stat_modifier(Ref<ItemStatModifier> modifier);
void remove_item_stat_modifier(int index);
Ref<ItemStatModifier> get_item_stat_modifier(const int index);
void add_item_stat_modifier(const Ref<ItemStatModifier> &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<Ref<ItemStatModifier> > _modifiers;
};

View File

@ -79,14 +79,14 @@ void ItemTemplate::set_equip_slot(const ItemEnums::EquipSlots value) {
Ref<ItemVisual> ItemTemplate::get_item_visual() const {
return _item_visual;
}
void ItemTemplate::set_item_visual(const Ref<ItemVisual> value) {
void ItemTemplate::set_item_visual(const Ref<ItemVisual> &value) {
_item_visual = value;
}
Ref<EntityClassData> ItemTemplate::get_required_character_class() const {
return _required_character_class;
}
void ItemTemplate::set_required_character_class(const Ref<EntityClassData> value) {
void ItemTemplate::set_required_character_class(const Ref<EntityClassData> &value) {
_required_character_class = value;
}
@ -109,7 +109,7 @@ Ref<Texture> ItemTemplate::get_icon() const {
return _icon;
}
void ItemTemplate::set_icon(const Ref<Texture> value) {
void ItemTemplate::set_icon(const Ref<Texture> &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<Spell> ItemTemplate::get_teaches_spell(int index) const {
Ref<Spell> ItemTemplate::get_teaches_spell(const int index) {
ERR_FAIL_INDEX_V(index, _teaches_spells.size(), Ref<Spell>());
return _teaches_spells[index];
}
void ItemTemplate::set_teaches_spell(int index, Ref<Spell> spell) {
void ItemTemplate::set_teaches_spell(const int index, const Ref<Spell> &spell) {
ERR_FAIL_INDEX(index, _teaches_spells.size());
_teaches_spells.set(index, Ref<Spell>(spell));
@ -182,19 +182,19 @@ void ItemTemplate::set_teaches_spells(const Vector<Variant> &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<Spell> ItemTemplate::get_grants_spell(int index) const {
Ref<Spell> ItemTemplate::get_grants_spell(const int index) {
ERR_FAIL_INDEX_V(index, _grants_spells.size(), Ref<Spell>());
return _grants_spells[index];
}
void ItemTemplate::set_grants_spell(int index, Ref<Spell> spell) {
void ItemTemplate::set_grants_spell(const int index, const Ref<Spell> &spell) {
ERR_FAIL_INDEX(index, _grants_spells.size());
_grants_spells.set(index, Ref<Spell>(spell));
@ -218,19 +218,19 @@ void ItemTemplate::set_grants_spells(const Vector<Variant> &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<Aura> ItemTemplate::get_aura(int index) const {
Ref<Aura> ItemTemplate::get_aura(const int index) {
ERR_FAIL_INDEX_V(index, _auras.size(), Ref<Aura>());
return _auras[index];
}
void ItemTemplate::set_aura(int index, Ref<Aura> aura) {
void ItemTemplate::set_aura(const int index, const Ref<Aura> &aura) {
ERR_FAIL_INDEX(index, _auras.size());
_auras.set(index, Ref<Aura>(aura));
@ -253,16 +253,16 @@ void ItemTemplate::set_auras(const Vector<Variant> &auras) {
}
//Required Skills
int ItemTemplate::get_num_required_skills() {
int ItemTemplate::get_num_required_skills() const {
return _required_skills.size();
}
Ref<Aura> ItemTemplate::get_required_skill(int index) const {
Ref<Aura> ItemTemplate::get_required_skill(const int index) {
ERR_FAIL_INDEX_V(index, _required_skills.size(), Ref<Aura>());
return _required_skills.get(index);
}
void ItemTemplate::set_required_skill(int index, Ref<Aura> aura) {
void ItemTemplate::set_required_skill(const int index, const Ref<Aura> &aura) {
ERR_FAIL_INDEX(index, _required_skills.size());
_required_skills.set(index, aura);
@ -285,13 +285,27 @@ void ItemTemplate::set_required_skills(const Vector<Variant> &skills) {
}
//use spell
Ref<Spell> ItemTemplate::get_use_spell() const {
Ref<Spell> ItemTemplate::get_use_spell() {
return _use_spell;
}
void ItemTemplate::set_use_spell(Ref<Spell> use_spell) {
void ItemTemplate::set_use_spell(const Ref<Spell> &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<ItemTemplateStatModifier> ItemTemplate::get_item_template_stat_modifier(int index) {
Ref<ItemTemplateStatModifier> ItemTemplate::get_item_template_stat_modifier(const int index) {
return Ref<ItemTemplateStatModifier>(_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<ItemTemplateStatModifier>(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);

View File

@ -63,10 +63,10 @@ public:
void set_equip_slot(const ItemEnums::EquipSlots value);
Ref<ItemVisual> get_item_visual() const;
void set_item_visual(const Ref<ItemVisual> value);
void set_item_visual(const Ref<ItemVisual> &value);
Ref<EntityClassData> get_required_character_class() const;
void set_required_character_class(const Ref<EntityClassData> value);
void set_required_character_class(const Ref<EntityClassData> &value);
int get_price() const;
void set_price(const int value);
@ -75,7 +75,7 @@ public:
void set_stack_size(const int value);
Ref<Texture> get_icon() const;
void set_icon(const Ref<Texture> value);
void set_icon(const Ref<Texture> &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<Spell> get_teaches_spell(int index) const;
void set_teaches_spell(int index, Ref<Spell> teaches_spell);
Ref<Spell> get_teaches_spell(const int index);
void set_teaches_spell(const int index, const Ref<Spell> &teaches_spell);
Vector<Variant> get_teaches_spells();
void set_teaches_spells(const Vector<Variant> &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<Spell> get_grants_spell(int index) const;
void set_grants_spell(int index, Ref<Spell> grants_spell);
Ref<Spell> get_grants_spell(const int index);
void set_grants_spell(const int index, const Ref<Spell> &grants_spell);
Vector<Variant> get_grants_spells();
void set_grants_spells(const Vector<Variant> &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<Aura> get_aura(int index) const;
void set_aura(int index, Ref<Aura> aura);
Ref<Aura> get_aura(const int index);
void set_aura(const int index, const Ref<Aura> &aura);
Vector<Variant> get_auras();
void set_auras(const Vector<Variant> &auras);
//Required Skills
int get_num_required_skills();
int get_num_required_skills() const;
Ref<Aura> get_required_skill(int index) const;
void set_required_skill(int index, Ref<Aura> skills);
Ref<Aura> get_required_skill(const int index);
void set_required_skill(const int index, const Ref<Aura> &skills);
Vector<Variant> get_required_skills();
void set_required_skills(const Vector<Variant> &grants_spells);
//use spell
Ref<Spell> get_use_spell() const;
void set_use_spell(Ref<Spell> use_spell);
Ref<Spell> get_use_spell();
void set_use_spell(const Ref<Spell> &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<ItemTemplateStatModifier> get_item_template_stat_modifier(int index);
Ref<ItemTemplateStatModifier> 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<Ref<Aura> > _auras;
Vector<Ref<Aura> > _required_skills;
Ref<Spell> _use_spell;
int _charges;
bool _consumed;
int _modifier_count;
Ref<ItemTemplateStatModifier> _modifiers[MAX_ITEM_STAT_MOD];

View File

@ -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;
}

View File

@ -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();

View File

@ -2291,7 +2291,7 @@ void Entity::son_after_aura_applied(Ref<AuraData> data) {
void Entity::scast_spell(int spell_id) {
Ref<EntityData> 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<AuraData> 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);

View File

@ -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<SpellDamageInfo> info);
void sdeal_damage_to(Ref<SpellDamageInfo> info);