mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-02-20 17:14:44 +01:00
Also reworked how AuraStatAttributes are stored.
This commit is contained in:
parent
598d02022a
commit
8ed462ece2
@ -16,7 +16,6 @@ def get_doc_classes():
|
||||
"ESS",
|
||||
|
||||
"AuraGroup",
|
||||
"AuraStatAttribute",
|
||||
"Aura",
|
||||
"CraftRecipeHelper",
|
||||
"CraftRecipe",
|
||||
|
@ -357,10 +357,6 @@ Aura::Aura() {
|
||||
_supress_states = 0;
|
||||
|
||||
_aura_stat_attribute_count = 0;
|
||||
for (int i = 0; i < MAX_AURA_STATS; ++i) {
|
||||
_aura_stat_attributes[i] = Ref<AuraStatAttribute>(memnew(AuraStatAttribute()));
|
||||
}
|
||||
|
||||
_trigger_count = 0;
|
||||
}
|
||||
|
||||
@ -379,10 +375,6 @@ Aura::~Aura() {
|
||||
_trigger_datas[i].spell.unref();
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_AURA_STATS; ++i) {
|
||||
_aura_stat_attributes[i].unref();
|
||||
}
|
||||
|
||||
_talent_required_talent.unref();
|
||||
_talent_required_spell.unref();
|
||||
}
|
||||
@ -488,45 +480,45 @@ void Aura::stat_attribute_set_count(int count) {
|
||||
int Aura::stat_attribute_get_stat(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_AURA_STATS, 0);
|
||||
|
||||
return _aura_stat_attributes[index]->get_stat();
|
||||
return _aura_stat_attributes[index].stat;
|
||||
}
|
||||
void Aura::stat_attribute_set_stat(int index, const int value) {
|
||||
ERR_FAIL_INDEX(index, MAX_AURA_STATS);
|
||||
|
||||
_aura_stat_attributes[index]->set_stat(value);
|
||||
_aura_stat_attributes[index].stat = value;
|
||||
}
|
||||
|
||||
float Aura::stat_attribute_get_base_mod(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_AURA_STATS, 0);
|
||||
|
||||
return _aura_stat_attributes[index]->get_base_mod();
|
||||
return _aura_stat_attributes[index].base_mod;
|
||||
}
|
||||
void Aura::stat_attribute_set_base_mod(int index, float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_AURA_STATS);
|
||||
|
||||
_aura_stat_attributes[index]->set_base_mod(value);
|
||||
_aura_stat_attributes[index].base_mod = value;
|
||||
}
|
||||
|
||||
float Aura::stat_attribute_get_bonus_mod(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_AURA_STATS, 0);
|
||||
|
||||
return _aura_stat_attributes[index]->get_bonus_mod();
|
||||
return _aura_stat_attributes[index].bonus_mod;
|
||||
}
|
||||
void Aura::stat_attribute_set_bonus_mod(int index, float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_AURA_STATS);
|
||||
|
||||
_aura_stat_attributes[index]->set_bonus_mod(value);
|
||||
_aura_stat_attributes[index].bonus_mod = value;
|
||||
}
|
||||
|
||||
float Aura::stat_attribute_get_percent_mod(int index) const {
|
||||
ERR_FAIL_INDEX_V(index, MAX_AURA_STATS, 0);
|
||||
|
||||
return _aura_stat_attributes[index]->get_percent_mod();
|
||||
return _aura_stat_attributes[index].percent_mod;
|
||||
}
|
||||
void Aura::stat_attribute_set_percent_mod(int index, float value) {
|
||||
ERR_FAIL_INDEX(index, MAX_AURA_STATS);
|
||||
|
||||
_aura_stat_attributes[index]->set_percent_mod(value);
|
||||
_aura_stat_attributes[index].percent_mod = value;
|
||||
}
|
||||
|
||||
void Aura::sapply_simple(Entity *caster, Entity *target, float spell_scale) {
|
||||
@ -991,12 +983,10 @@ void Aura::_sapply(Ref<AuraApplyInfo> info) {
|
||||
Entity *owner = ad->get_owner();
|
||||
|
||||
for (int i = 0; i < _aura_stat_attribute_count; ++i) {
|
||||
Ref<AuraStatAttribute> stat_attribute = _aura_stat_attributes[i];
|
||||
|
||||
int stat_index = stat_attribute->get_stat();
|
||||
owner->stat_mod_base(stat_index, stat_attribute->get_base_mod());
|
||||
owner->stat_mod_bonus(stat_index, stat_attribute->get_bonus_mod());
|
||||
owner->stat_mod_percent(stat_index, stat_attribute->get_percent_mod());
|
||||
int stat_index = _aura_stat_attributes[i].stat;
|
||||
owner->stat_mod_base(stat_index, _aura_stat_attributes[i].base_mod);
|
||||
owner->stat_mod_bonus(stat_index, _aura_stat_attributes[i].bonus_mod);
|
||||
owner->stat_mod_percent(stat_index, _aura_stat_attributes[i].percent_mod);
|
||||
}
|
||||
|
||||
if (_add_states != 0) {
|
||||
@ -1021,12 +1011,10 @@ void Aura::_sdeapply(Ref<AuraData> data) {
|
||||
Entity *owner = data->get_owner();
|
||||
|
||||
for (int i = 0; i < _aura_stat_attribute_count; ++i) {
|
||||
Ref<AuraStatAttribute> stat_attribute = _aura_stat_attributes[i];
|
||||
|
||||
int stat_index = stat_attribute->get_stat();
|
||||
owner->stat_mod_base(stat_index, -stat_attribute->get_base_mod());
|
||||
owner->stat_mod_bonus(stat_index, -stat_attribute->get_bonus_mod());
|
||||
owner->stat_mod_percent(stat_index, -stat_attribute->get_percent_mod());
|
||||
int stat_index = _aura_stat_attributes[i].stat;
|
||||
owner->stat_mod_base(stat_index, -_aura_stat_attributes[i].base_mod);
|
||||
owner->stat_mod_bonus(stat_index, -_aura_stat_attributes[i].bonus_mod);
|
||||
owner->stat_mod_percent(stat_index, -_aura_stat_attributes[i].percent_mod);
|
||||
}
|
||||
|
||||
if (_add_states != 0) {
|
||||
@ -1184,8 +1172,11 @@ void Aura::_handle_aura_heal(Ref<AuraData> aura_data, Ref<SpellHealInfo> info) {
|
||||
|
||||
void Aura::_validate_property(PropertyInfo &property) const {
|
||||
String prop = property.name;
|
||||
if (prop.begins_with("StatModAttribute_")) {
|
||||
int frame = prop.get_slicec('/', 0).get_slicec('_', 1).to_int();
|
||||
if (prop.begins_with("stat_attribute_")) {
|
||||
if (prop.ends_with("count"))
|
||||
return;
|
||||
|
||||
int frame = prop.get_slicec('/', 0).get_slicec('_', 2).to_int();
|
||||
if (frame >= _aura_stat_attribute_count) {
|
||||
property.usage = 0;
|
||||
}
|
||||
@ -1718,7 +1709,7 @@ void Aura::_bind_methods() {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "trigger_" + itos(i) + "/spell", PROPERTY_HINT_RESOURCE_TYPE, "Spell", PROPERTY_USAGE_DEFAULT), "trigger_set_spell", "trigger_get_spell", i);
|
||||
}
|
||||
|
||||
ADD_GROUP("Attributes", "attribute");
|
||||
ADD_GROUP("Stat Attributes", "stat_attribute");
|
||||
//AuraStatAttributes
|
||||
ClassDB::bind_method(D_METHOD("stat_attribute_get_count"), &Aura::stat_attribute_get_count);
|
||||
ClassDB::bind_method(D_METHOD("stat_attribute_set_count", "count"), &Aura::stat_attribute_set_count);
|
||||
@ -1735,15 +1726,13 @@ void Aura::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("stat_attribute_get_percent_mod", "index"), &Aura::stat_attribute_get_percent_mod);
|
||||
ClassDB::bind_method(D_METHOD("stat_attribute_set_percent_mod", "index", "value"), &Aura::stat_attribute_set_percent_mod);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("stat_attribute_get", "index"), &Aura::stat_attribute_get);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "attribute_count", PROPERTY_HINT_RANGE, "0," + itos(MAX_AURA_STATS), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "stat_attribute_set_count", "stat_attribute_get_count");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "stat_attribute_count", PROPERTY_HINT_RANGE, "0," + itos(MAX_AURA_STATS), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "stat_attribute_set_count", "stat_attribute_get_count");
|
||||
|
||||
for (int i = 0; i < MAX_AURA_STATS; i++) {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "StatModAttribute_" + itos(i) + "/stat", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "stat_attribute_set_stat", "stat_attribute_get_stat", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "StatModAttribute_" + itos(i) + "/base_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "stat_attribute_set_base_mod", "stat_attribute_get_base_mod", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "StatModAttribute_" + itos(i) + "/bonus_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "stat_attribute_set_bonus_mod", "stat_attribute_get_bonus_mod", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "StatModAttribute_" + itos(i) + "/percent_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "stat_attribute_set_percent_mod", "stat_attribute_get_percent_mod", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "stat_attribute_" + itos(i) + "/stat", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "stat_attribute_set_stat", "stat_attribute_get_stat", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "stat_attribute_" + itos(i) + "/base_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "stat_attribute_set_base_mod", "stat_attribute_get_base_mod", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "stat_attribute_" + itos(i) + "/bonus_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "stat_attribute_set_bonus_mod", "stat_attribute_get_bonus_mod", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "stat_attribute_" + itos(i) + "/percent_mod", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "stat_attribute_set_percent_mod", "stat_attribute_get_percent_mod", i);
|
||||
}
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_talent"), &Aura::is_talent);
|
||||
|
@ -35,8 +35,6 @@ SOFTWARE.
|
||||
#include "../../entities/entity.h"
|
||||
#include "../../infos/aura_infos.h"
|
||||
|
||||
#include "aura_stat_attribute.h"
|
||||
|
||||
#include "../../entities/auras/aura_data.h"
|
||||
#include "../../infos/spell_cast_info.h"
|
||||
#include "../../pipelines/spell_damage_info.h"
|
||||
@ -240,8 +238,6 @@ public:
|
||||
float stat_attribute_get_percent_mod(int index) const;
|
||||
void stat_attribute_set_percent_mod(int index, float value);
|
||||
|
||||
Ref<AuraStatAttribute> stat_attribute_get(int index) { return _aura_stat_attributes[index]; }
|
||||
|
||||
//// SpellSystem ////
|
||||
|
||||
//Commands, c++ only
|
||||
@ -380,6 +376,20 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
struct AuraStatAttribute {
|
||||
int stat;
|
||||
float base_mod;
|
||||
float bonus_mod;
|
||||
float percent_mod;
|
||||
|
||||
AuraStatAttribute() {
|
||||
stat = 0;
|
||||
base_mod = 0;
|
||||
bonus_mod = 0;
|
||||
percent_mod = 0;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
enum {
|
||||
MAX_AURA_STATS = 5, //Increase if necessary, should be enough for now
|
||||
@ -439,7 +449,7 @@ private:
|
||||
AuraTriggerData _trigger_datas[MAX_TRIGGER_DATA];
|
||||
|
||||
int _aura_stat_attribute_count;
|
||||
Ref<AuraStatAttribute> _aura_stat_attributes[MAX_AURA_STATS];
|
||||
AuraStatAttribute _aura_stat_attributes[MAX_AURA_STATS];
|
||||
|
||||
SpellEnums::DiminishingReturnCategory _diminishing_category;
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2020 Péter Magyar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "aura_stat_attribute.h"
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2020 Péter Magyar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef AURA_STAT_ATTRIBUTE_H
|
||||
#define AURA_STAT_ATTRIBUTE_H
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
#include "../../singletons/ess.h"
|
||||
|
||||
class AuraStatAttribute : public Reference {
|
||||
GDCLASS(AuraStatAttribute, Reference);
|
||||
|
||||
public:
|
||||
int get_stat() const { return _stat; }
|
||||
void set_stat(int value) { _stat = value; }
|
||||
|
||||
float get_base_mod() const { return _base_mod; }
|
||||
void set_base_mod(float value) { _base_mod = value; }
|
||||
|
||||
float get_bonus_mod() const { return _bonus_mod; }
|
||||
void set_bonus_mod(float value) { _bonus_mod = value; }
|
||||
|
||||
float get_percent_mod() const { return _percent_mod; }
|
||||
void set_percent_mod(float value) { _percent_mod = value; }
|
||||
|
||||
AuraStatAttribute() {
|
||||
_stat = 0;
|
||||
_base_mod = 0;
|
||||
_bonus_mod = 0;
|
||||
_percent_mod = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
void validate_property(PropertyInfo &property) const {
|
||||
if (property.name == "stat") {
|
||||
property.hint_string = ESS::get_singleton()->stat_get_string();
|
||||
}
|
||||
}
|
||||
|
||||
static void _bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_stat"), &AuraStatAttribute::get_stat);
|
||||
ClassDB::bind_method(D_METHOD("set_stat", "value"), &AuraStatAttribute::set_stat);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "stat", PROPERTY_HINT_ENUM, ""), "set_stat", "get_stat");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_base_mod"), &AuraStatAttribute::get_base_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_base_mod", "value"), &AuraStatAttribute::set_base_mod);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_mod"), "set_base_mod", "get_base_mod");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_bonus_mod"), &AuraStatAttribute::get_bonus_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_bonus_mod", "value"), &AuraStatAttribute::set_bonus_mod);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bonus_mod"), "set_bonus_mod", "get_bonus_mod");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_percent_mod"), &AuraStatAttribute::get_percent_mod);
|
||||
ClassDB::bind_method(D_METHOD("set_percent_mod", "value"), &AuraStatAttribute::set_percent_mod);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent_mod"), "set_percent_mod", "get_percent_mod");
|
||||
}
|
||||
|
||||
private:
|
||||
int _stat;
|
||||
float _base_mod;
|
||||
float _bonus_mod;
|
||||
float _percent_mod;
|
||||
};
|
||||
|
||||
#endif
|
@ -25,6 +25,8 @@ SOFTWARE.
|
||||
#include "../auras/aura.h"
|
||||
#include "../spells/spell.h"
|
||||
|
||||
#include "../../singletons/ess.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
int EntitySpeciesData::get_id() const {
|
||||
|
@ -30,6 +30,8 @@ SOFTWARE.
|
||||
#include "character_spec.h"
|
||||
#include "vendor_item_data.h"
|
||||
|
||||
#include "../../singletons/ess.h"
|
||||
|
||||
#include "../../defines.h"
|
||||
|
||||
int EntityData::get_id() const {
|
||||
|
@ -29,7 +29,6 @@ SOFTWARE.
|
||||
|
||||
#include "data/auras/aura.h"
|
||||
#include "data/auras/aura_group.h"
|
||||
#include "data/auras/aura_stat_attribute.h"
|
||||
|
||||
#include "data/entities/xp_data.h"
|
||||
#include "data/items/equipment_data.h"
|
||||
@ -90,8 +89,6 @@ SOFTWARE.
|
||||
#include "entities/auras/aura_data.h"
|
||||
#include "entities/entity.h"
|
||||
|
||||
#include "data/auras/aura_stat_attribute.h"
|
||||
|
||||
#include "drag_and_drop/es_drag_and_drop.h"
|
||||
|
||||
#include "skeleton/character_skeleton_2d.h"
|
||||
@ -153,7 +150,6 @@ void register_entity_spell_system_types() {
|
||||
ClassDB::register_class<Spell>();
|
||||
ClassDB::register_class<Aura>();
|
||||
ClassDB::register_class<AuraGroup>();
|
||||
ClassDB::register_class<AuraStatAttribute>();
|
||||
|
||||
ClassDB::register_class<EntityData>();
|
||||
ClassDB::register_class<EntityClassData>();
|
||||
|
Loading…
Reference in New Issue
Block a user