mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-19 21:33:15 +02:00
Added LevelStatData classes.
This commit is contained in:
parent
e0183a53c6
commit
f3a9a9e14a
4
SCsub
4
SCsub
@ -51,6 +51,10 @@ module_env.add_source_files(env.modules_sources,"data/spell/spell_data_constants
|
||||
module_env.add_source_files(env.modules_sources,"entities/stats/stat.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/stats/stat_modifier.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/stats/stat_data.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/stats/stat_data_entry.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/stats/level_stat_data.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/stats/simple_level_stat_data.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"entities/stats/complex_level_stat_data.cpp")
|
||||
|
||||
module_env.add_source_files(env.modules_sources,"spells/spell_projectile.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"spells/world_spell_effect.cpp")
|
||||
|
91
entities/stats/complex_level_stat_data.cpp
Normal file
91
entities/stats/complex_level_stat_data.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include "complex_level_stat_data.h"
|
||||
|
||||
int ComplexLevelStatData::get_agility_for_level(int level) {
|
||||
return _entries[level].agility;
|
||||
}
|
||||
void ComplexLevelStatData::set_agility_for_level(int level, int value) {
|
||||
_entries[level].agility = value;
|
||||
}
|
||||
|
||||
int ComplexLevelStatData::get_strength_for_level(int level) {
|
||||
return _entries[level].strength;
|
||||
}
|
||||
void ComplexLevelStatData::set_strength_for_level(int level, int value) {
|
||||
_entries[level].strength = value;
|
||||
}
|
||||
|
||||
int ComplexLevelStatData::get_stamina_for_level(int level) {
|
||||
return _entries[level].stamina;
|
||||
}
|
||||
void ComplexLevelStatData::set_stamina_for_level(int level, int value) {
|
||||
_entries[level].stamina = value;
|
||||
}
|
||||
|
||||
int ComplexLevelStatData::get_intellect_for_level(int level) {
|
||||
return _entries[level].intellect;
|
||||
}
|
||||
void ComplexLevelStatData::set_intellect_for_level(int level, int value) {
|
||||
_entries[level].intellect = value;
|
||||
}
|
||||
|
||||
int ComplexLevelStatData::get_luck_for_level(int level) {
|
||||
return _entries[level].luck;
|
||||
}
|
||||
void ComplexLevelStatData::set_luck_for_level(int level, int value) {
|
||||
_entries[level].luck = value;
|
||||
}
|
||||
|
||||
int ComplexLevelStatData::_get_stat_diff(int main_stat, int old_level, int new_level) {
|
||||
int s = 0;
|
||||
|
||||
for (int i = old_level; i < new_level; ++i) {
|
||||
switch (main_stat) {
|
||||
case Stat::MAIN_STAT_AGILITY:
|
||||
s += get_agility_for_level(i);
|
||||
break;
|
||||
case Stat::MAIN_STAT_STRENGTH:
|
||||
s += get_strength_for_level(i);
|
||||
break;
|
||||
case Stat::MAIN_STAT_STAMINA:
|
||||
s += get_stamina_for_level(i);
|
||||
break;
|
||||
case Stat::MAIN_STAT_INTELLECT:
|
||||
s += get_intellect_for_level(i);
|
||||
break;
|
||||
case Stat::MAIN_STAT_LUCK:
|
||||
s += get_luck_for_level(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void ComplexLevelStatData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_get_stat_diff", "stat", "old_level", "new_level"), &ComplexLevelStatData::_get_stat_diff);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_agility_for_level", "level"), &ComplexLevelStatData::get_agility_for_level);
|
||||
ClassDB::bind_method(D_METHOD("set_agility_for_level", "level", "value"), &ComplexLevelStatData::set_agility_for_level);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_strength_for_level", "level"), &ComplexLevelStatData::get_strength_for_level);
|
||||
ClassDB::bind_method(D_METHOD("set_strength_for_level", "level", "value"), &ComplexLevelStatData::set_strength_for_level);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_stamina_for_level", "level"), &ComplexLevelStatData::get_stamina_for_level);
|
||||
ClassDB::bind_method(D_METHOD("set_stamina_for_level", "level", "value"), &ComplexLevelStatData::set_stamina_for_level);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_intellect_for_level", "level"), &ComplexLevelStatData::get_intellect_for_level);
|
||||
ClassDB::bind_method(D_METHOD("set_intellect_for_level", "level", "value"), &ComplexLevelStatData::set_intellect_for_level);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_luck_for_level", "level"), &ComplexLevelStatData::get_luck_for_level);
|
||||
ClassDB::bind_method(D_METHOD("set_luck_for_level", "level", "value"), &ComplexLevelStatData::set_luck_for_level);
|
||||
|
||||
|
||||
for (int i = 0; i < EntityEnums::MAX_LEVEL; ++i) {
|
||||
ADD_GROUP("Level " + String::num(i + 1), "level_" + String::num(i + 1));
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "level_" + String::num(i + 1) + "_agility"), "set_agility_for_level", "get_agility_for_level", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "level_" + String::num(i + 1) + "_strength"), "set_strength_for_level", "get_strength_for_level", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "level_" + String::num(i + 1) + "_stamina"), "set_stamina_for_level", "get_stamina_for_level", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "level_" + String::num(i + 1) + "_intellect"), "set_intellect_for_level", "get_intellect_for_level", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "level_" + String::num(i + 1) + "_luck"), "set_luck_for_level", "get_luck_for_level", i);
|
||||
}
|
||||
}
|
54
entities/stats/complex_level_stat_data.h
Normal file
54
entities/stats/complex_level_stat_data.h
Normal file
@ -0,0 +1,54 @@
|
||||
#ifndef COMPLEX_LEVEL_STAT_DATA_H
|
||||
#define SIMPLE_LEVEL_STAT_DATA_H
|
||||
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "../../entity_enums.h"
|
||||
#include "level_stat_data.h"
|
||||
|
||||
class ComplexLevelStatData : public LevelStatData {
|
||||
GDCLASS(ComplexLevelStatData, LevelStatData);
|
||||
|
||||
public:
|
||||
int get_agility_for_level(int level);
|
||||
void set_agility_for_level(int level, int value);
|
||||
|
||||
int get_strength_for_level(int level);
|
||||
void set_strength_for_level(int level, int value);
|
||||
|
||||
int get_stamina_for_level(int level);
|
||||
void set_stamina_for_level(int level, int value);
|
||||
|
||||
int get_intellect_for_level(int level);
|
||||
void set_intellect_for_level(int level, int value);
|
||||
|
||||
int get_luck_for_level(int level);
|
||||
void set_luck_for_level(int level, int value);
|
||||
|
||||
int _get_stat_diff(int stat, int old_level, int new_level);
|
||||
|
||||
public:
|
||||
struct ComplexLevelStatsEntry {
|
||||
int agility;
|
||||
int strength;
|
||||
int stamina;
|
||||
int intellect;
|
||||
int luck;
|
||||
|
||||
ComplexLevelStatsEntry() {
|
||||
agility = 0;
|
||||
strength = 0;
|
||||
stamina = 0;
|
||||
intellect = 0;
|
||||
luck = 0;
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
ComplexLevelStatsEntry _entries[EntityEnums::MAX_LEVEL];
|
||||
};
|
||||
|
||||
#endif
|
16
entities/stats/level_stat_data.cpp
Normal file
16
entities/stats/level_stat_data.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "level_stat_data.h"
|
||||
|
||||
int LevelStatData::get_stat_diff(int main_stat, int old_level, int new_level) {
|
||||
if (has_method("_get_stat_diff"))
|
||||
return call("_get_stat_diff");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LevelStatData::_bind_methods() {
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::INT, "diff"), "_get_stat_diff", PropertyInfo(Variant::INT, "main_stat"), PropertyInfo(Variant::INT, "old_level"), PropertyInfo(Variant::INT, "new_level")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_stat_diff", "stat", "old_level", "new_level"), &LevelStatData::get_stat_diff);
|
||||
}
|
||||
|
18
entities/stats/level_stat_data.h
Normal file
18
entities/stats/level_stat_data.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef LEVEL_STAT_DATA_H
|
||||
#define LEVEL_STAT_DATA_H
|
||||
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "stat.h"
|
||||
|
||||
class LevelStatData : public Resource {
|
||||
GDCLASS(LevelStatData, Resource);
|
||||
|
||||
public:
|
||||
int get_stat_diff(int stat, int old_level, int new_level);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
};
|
||||
|
||||
#endif
|
94
entities/stats/simple_level_stat_data.cpp
Normal file
94
entities/stats/simple_level_stat_data.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
#include "simple_level_stat_data.h"
|
||||
|
||||
int SimpleLevelStatData::get_agility_per_level() {
|
||||
return _agility_per_level;
|
||||
}
|
||||
void SimpleLevelStatData::set_agility_per_level(int value) {
|
||||
_agility_per_level = value;
|
||||
}
|
||||
|
||||
int SimpleLevelStatData::get_strength_per_level() {
|
||||
return _strength_per_level;
|
||||
}
|
||||
void SimpleLevelStatData::set_strength_per_level(int value) {
|
||||
_strength_per_level = value;
|
||||
}
|
||||
|
||||
int SimpleLevelStatData::get_stamina_per_level() {
|
||||
return _stamina_per_level;
|
||||
}
|
||||
void SimpleLevelStatData::set_stamina_per_level(int value) {
|
||||
_stamina_per_level = value;
|
||||
}
|
||||
|
||||
int SimpleLevelStatData::get_intellect_per_level() {
|
||||
return _intellect_per_level;
|
||||
}
|
||||
void SimpleLevelStatData::set_intellect_per_level(int value) {
|
||||
_intellect_per_level = value;
|
||||
}
|
||||
|
||||
int SimpleLevelStatData::get_luck_per_level() {
|
||||
return _luck_per_level;
|
||||
}
|
||||
void SimpleLevelStatData::set_luck_per_level(int value) {
|
||||
_luck_per_level = value;
|
||||
}
|
||||
|
||||
int SimpleLevelStatData::_get_stat_diff(int main_stat, int old_level, int new_level) {
|
||||
int s = 0;
|
||||
|
||||
switch (main_stat) {
|
||||
case Stat::MAIN_STAT_AGILITY:
|
||||
s = _agility_per_level;
|
||||
break;
|
||||
case Stat::MAIN_STAT_STRENGTH:
|
||||
s = _strength_per_level;
|
||||
break;
|
||||
case Stat::MAIN_STAT_STAMINA:
|
||||
s = _stamina_per_level;
|
||||
break;
|
||||
case Stat::MAIN_STAT_INTELLECT:
|
||||
s = _intellect_per_level;
|
||||
break;
|
||||
case Stat::MAIN_STAT_LUCK:
|
||||
s = _luck_per_level;
|
||||
break;
|
||||
}
|
||||
|
||||
s *= new_level - old_level;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
SimpleLevelStatData::SimpleLevelStatData() {
|
||||
_agility_per_level = 0;
|
||||
_strength_per_level = 0;
|
||||
_stamina_per_level = 0;
|
||||
_intellect_per_level = 0;
|
||||
_luck_per_level = 0;
|
||||
}
|
||||
|
||||
void SimpleLevelStatData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_agility_per_level"), &SimpleLevelStatData::get_agility_per_level);
|
||||
ClassDB::bind_method(D_METHOD("set_agility_per_level", "value"), &SimpleLevelStatData::set_agility_per_level);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "agility_per_level"), "set_agility_per_level", "get_agility_per_level");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_strength_per_level"), &SimpleLevelStatData::get_strength_per_level);
|
||||
ClassDB::bind_method(D_METHOD("set_strength_per_level", "value"), &SimpleLevelStatData::set_strength_per_level);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "strength_per_level"), "set_strength_per_level", "get_strength_per_level");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_stamina_per_level"), &SimpleLevelStatData::get_stamina_per_level);
|
||||
ClassDB::bind_method(D_METHOD("set_stamina_per_level", "value"), &SimpleLevelStatData::set_stamina_per_level);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "stamina_per_level"), "set_stamina_per_level", "get_stamina_per_level");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_intellect_per_level"), &SimpleLevelStatData::get_intellect_per_level);
|
||||
ClassDB::bind_method(D_METHOD("set_intellect_per_level", "value"), &SimpleLevelStatData::set_intellect_per_level);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "intellect_per_level"), "set_intellect_per_level", "get_intellect_per_level");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_luck_per_level"), &SimpleLevelStatData::get_luck_per_level);
|
||||
ClassDB::bind_method(D_METHOD("set_luck_per_level", "value"), &SimpleLevelStatData::set_luck_per_level);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "luck_per_level"), "set_luck_per_level", "get_luck_per_level");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_get_stat_diff", "stat", "old_level", "new_level"), &SimpleLevelStatData::_get_stat_diff);
|
||||
}
|
42
entities/stats/simple_level_stat_data.h
Normal file
42
entities/stats/simple_level_stat_data.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef SIMPLE_LEVEL_STAT_DATA_H
|
||||
#define SIMPLE_LEVEL_STAT_DATA_H
|
||||
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "level_stat_data.h"
|
||||
|
||||
class SimpleLevelStatData : public LevelStatData {
|
||||
GDCLASS(SimpleLevelStatData, LevelStatData);
|
||||
|
||||
public:
|
||||
int get_agility_per_level();
|
||||
void set_agility_per_level(int value);
|
||||
|
||||
int get_strength_per_level();
|
||||
void set_strength_per_level(int value);
|
||||
|
||||
int get_stamina_per_level();
|
||||
void set_stamina_per_level(int value);
|
||||
|
||||
int get_intellect_per_level();
|
||||
void set_intellect_per_level(int value);
|
||||
|
||||
int get_luck_per_level();
|
||||
void set_luck_per_level(int value);
|
||||
|
||||
int _get_stat_diff(int stat, int old_level, int new_level);
|
||||
|
||||
SimpleLevelStatData();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _agility_per_level;
|
||||
int _strength_per_level;
|
||||
int _stamina_per_level;
|
||||
int _intellect_per_level;
|
||||
int _luck_per_level;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,9 +1,108 @@
|
||||
#include "stat.h"
|
||||
|
||||
const String Stat::STAT_BINDING_STRING = "Health,Speed,Mana,GCD,Haste,Agility,Strength,Stamina,Intellect,Luck,Haste Rating,Resilience,Armor,Attack Power,Spell Power,Melee Crit,Melee Crit bonus,Spell Crit,Spell Crit Bonus,Block,Parry,Damage Reduction,Melee Damage Reduction,Spell Damage Reduction,Damage Taken,Heal Taken,Melee Damage,Spell Damage,Holy Resist,Shadow Resist,Nature Resist,Fire Resist,Frost Resist,Lightning Resist,Chaos Resist,Silence Resist,Fear Resist,None";
|
||||
const String Stat::STAT_BINDING_STRING = "Health,Speed,Mana,GCD,Haste,Agility,Strength,Stamina,Intellect,Luck,Haste Rating,Resilience,Armor,Attack Power,Spell Power,Melee Crit,Melee Crit bonus,Spell Crit,Spell Crit Bonus,Block,Parry,Damage Reduction,Melee Damage Reduction,Spell Damage Reduction,Damage Taken,Heal Taken,Melee Damage,Spell Damage,Holy Resist,Shadow Resist,Nature Resist,Fire Resist,Frost Resist,Lightning Resist,Chaos Resist,Silence Resist,Fear Resist,Stun Resist,Energy,Rage,XP Rate,None";
|
||||
const String Stat::MAIN_STAT_BINDING_STRING = "Agility,Strength,Stamina,Intellect,Luck";
|
||||
|
||||
const String Stat::MODIFIER_APPLY_TYPE_BINDING_STRING = "Standard,Only min modifier,Only Max modifier";
|
||||
|
||||
String Stat::stat_id_name(int stat_id) {
|
||||
switch (stat_id) {
|
||||
case STAT_ID_HEALTH:
|
||||
return "health";
|
||||
case STAT_ID_SPEED:
|
||||
return "speed";
|
||||
case STAT_ID_MANA:
|
||||
return "mana";
|
||||
case STAT_ID_GLOBAL_COOLDOWN:
|
||||
return "gcd";
|
||||
case STAT_ID_HASTE:
|
||||
return "haste";
|
||||
|
||||
case STAT_ID_AGILITY:
|
||||
return "agility";
|
||||
case STAT_ID_STRENGTH:
|
||||
return "strength";
|
||||
case STAT_ID_STAMINA:
|
||||
return "stamina";
|
||||
case STAT_ID_INTELLECT:
|
||||
return "intellect";
|
||||
case STAT_ID_LUCK:
|
||||
return "luck";
|
||||
|
||||
case STAT_ID_HASTE_RATING:
|
||||
return "haste_rating";
|
||||
case STAT_ID_RESLILIENCE:
|
||||
return "resilience";
|
||||
case STAT_ID_ARMOR:
|
||||
return "armor";
|
||||
|
||||
case STAT_ID_ATTACK_POWER:
|
||||
return "attack_power";
|
||||
case STAT_ID_SPELL_POWER:
|
||||
return "spell_power";
|
||||
|
||||
case STAT_ID_MELEE_CRIT:
|
||||
return "melee_crit";
|
||||
case STAT_ID_MELEE_CRIT_BONUS:
|
||||
return "melee_crit_bonus";
|
||||
case STAT_ID_SPELL_CRIT:
|
||||
return "spell_crit";
|
||||
case STAT_ID_SPELL_CRIT_BONUS:
|
||||
return "spell_crit_bonus";
|
||||
|
||||
case STAT_ID_BLOCK:
|
||||
return "block";
|
||||
case STAT_ID_PARRY:
|
||||
return "parry";
|
||||
case STAT_ID_DAMAGE_REDUCTION:
|
||||
return "damage_reduction";
|
||||
case STAT_ID_MELEE_DAMAGE_REDUCTION:
|
||||
return "melee_damage_reduction";
|
||||
case STAT_ID_SPELL_DAMAGE_REDUCTION:
|
||||
return "spell_damage_reduction";
|
||||
case STAT_ID_DAMAGE_TAKEN:
|
||||
return "damage_taken";
|
||||
case STAT_ID_HEAL_TAKEN:
|
||||
return "heal_taken";
|
||||
|
||||
case STAT_ID_MELEE_DAMAGE:
|
||||
return "melee_damage";
|
||||
case STAT_ID_SPELL_DAMAGE:
|
||||
return "spell_damage";
|
||||
|
||||
case STAT_ID_HOLY_RESIST:
|
||||
return "holy_resist";
|
||||
case STAT_ID_SHADOW_RESIST:
|
||||
return "shadow_resist";
|
||||
case STAT_ID_NATURE_RESIST:
|
||||
return "nature_resist";
|
||||
case STAT_ID_FIRE_RESIST:
|
||||
return "fire_resist";
|
||||
case STAT_ID_FROST_RESIST:
|
||||
return "frost_resist";
|
||||
case STAT_ID_LIGHTNING_RESIST:
|
||||
return "lightning_resist";
|
||||
case STAT_ID_CHAOS_RESIST:
|
||||
return "chaos_resist";
|
||||
case STAT_ID_SILENCE_RESIST:
|
||||
return "silence_resist";
|
||||
case STAT_ID_FEAR_RESIST:
|
||||
return "fear_resist";
|
||||
case STAT_ID_STUN_RESIST:
|
||||
return "stun_resist";
|
||||
|
||||
case STAT_ID_ENERGY:
|
||||
return "energy";
|
||||
case STAT_ID_RAGE:
|
||||
return "rage";
|
||||
|
||||
case STAT_ID_XP_RATE:
|
||||
return "xp_rate";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector<Ref<StatModifier> > *Stat::get_modifiers() {
|
||||
return &_modifiers;
|
||||
}
|
||||
@ -620,6 +719,8 @@ void Stat::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_dependency", "stat", "curve"), &Stat::set_dependency);
|
||||
ClassDB::bind_method(D_METHOD("remove_dependencies"), &Stat::remove_dependencies);
|
||||
|
||||
//ClassDB::bind_method(D_METHOD("stat_id_name", "stat_id"), &Stat::stat_id_name);
|
||||
|
||||
//Serialization
|
||||
BIND_VMETHOD(MethodInfo("_from_dict", PropertyInfo(Variant::DICTIONARY, "dict")));
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::DICTIONARY, "dict"), "_to_dict"));
|
||||
@ -678,4 +779,13 @@ void Stat::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(Stat::MODIFIER_APPLY_TYPE_STANDARD);
|
||||
BIND_ENUM_CONSTANT(Stat::MODIFIER_APPLY_TYPE_ONLY_MIN_MODIFIER);
|
||||
BIND_ENUM_CONSTANT(Stat::MODIFIER_APPLY_TYPE_ONLY_MAX_MODIFIER);
|
||||
|
||||
BIND_ENUM_CONSTANT(Stat::MAIN_STAT_ID_AGILITY);
|
||||
BIND_ENUM_CONSTANT(Stat::MAIN_STAT_ID_STRENGTH);
|
||||
BIND_ENUM_CONSTANT(Stat::MAIN_STAT_ID_STAMINA);
|
||||
BIND_ENUM_CONSTANT(Stat::MAIN_STAT_ID_INTELLECT);
|
||||
BIND_ENUM_CONSTANT(Stat::MAIN_STAT_ID_LUCK);
|
||||
BIND_ENUM_CONSTANT(Stat::MAIN_STAT_ID_COUNT);
|
||||
BIND_ENUM_CONSTANT(Stat::MAIN_STAT_ID_MIN);
|
||||
BIND_ENUM_CONSTANT(Stat::MAIN_STAT_ID_MAX);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ class Stat : public Reference {
|
||||
|
||||
public:
|
||||
static const String STAT_BINDING_STRING;
|
||||
static const String MAIN_STAT_BINDING_STRING;
|
||||
static const String MODIFIER_APPLY_TYPE_BINDING_STRING;
|
||||
|
||||
enum StatId {
|
||||
@ -75,6 +76,28 @@ public:
|
||||
MODIFIER_APPLY_TYPE_ONLY_MAX_MODIFIER,
|
||||
};
|
||||
|
||||
enum MainStats {
|
||||
MAIN_STAT_AGILITY = 0,
|
||||
MAIN_STAT_STRENGTH = 1,
|
||||
MAIN_STAT_STAMINA = 2,
|
||||
MAIN_STAT_INTELLECT = 3,
|
||||
MAIN_STAT_LUCK = 4,
|
||||
};
|
||||
|
||||
enum MainStatIds {
|
||||
MAIN_STAT_ID_AGILITY = STAT_ID_AGILITY,
|
||||
MAIN_STAT_ID_STRENGTH = STAT_ID_STRENGTH,
|
||||
MAIN_STAT_ID_STAMINA = STAT_ID_STAMINA,
|
||||
MAIN_STAT_ID_INTELLECT = STAT_ID_INTELLECT,
|
||||
MAIN_STAT_ID_LUCK = STAT_ID_LUCK,
|
||||
|
||||
MAIN_STAT_ID_COUNT = 5,
|
||||
MAIN_STAT_ID_MIN = MAIN_STAT_ID_AGILITY,
|
||||
MAIN_STAT_ID_MAX = MAIN_STAT_ID_LUCK,
|
||||
};
|
||||
|
||||
static String stat_id_name(int stat_id);
|
||||
|
||||
public:
|
||||
Stat();
|
||||
Stat(Stat::StatId id);
|
||||
@ -172,6 +195,7 @@ private:
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(Stat::StatId);
|
||||
VARIANT_ENUM_CAST(Stat::MainStatIds);
|
||||
VARIANT_ENUM_CAST(Stat::StatModifierApplyType);
|
||||
|
||||
#endif
|
||||
|
@ -23,21 +23,12 @@ void StatData::set_stat_data_enum(Stat::StatId stat_id, Ref<StatDataEntry> entry
|
||||
|
||||
_entries[stat_id] = entry;
|
||||
}
|
||||
|
||||
Ref<Curve> StatData::get_hp_scaling_data() {
|
||||
return _hp_scaling_data;
|
||||
Ref<LevelStatData> StatData::get_level_stat_data() {
|
||||
return _level_stat_data;
|
||||
}
|
||||
|
||||
void StatData::set_hp_scaling_data(Ref<Curve> value) {
|
||||
_hp_scaling_data = value;
|
||||
}
|
||||
|
||||
Ref<Curve> StatData::get_spell_scaling_data() {
|
||||
return _spell_scaling_data;
|
||||
}
|
||||
|
||||
void StatData::set_spell_scaling_data(Ref<Curve> value) {
|
||||
_spell_scaling_data = value;
|
||||
void StatData::set_level_stat_data(Ref<LevelStatData> value) {
|
||||
_level_stat_data = value;
|
||||
}
|
||||
|
||||
void StatData::get_stat_for_stat(Ref<Stat> stat) {
|
||||
@ -81,18 +72,14 @@ void StatData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_stat_data_enum", "index"), &StatData::get_stat_data_enum);
|
||||
ClassDB::bind_method(D_METHOD("set_stat_data_enum", "stat_id", "entry"), &StatData::set_stat_data_enum);
|
||||
|
||||
|
||||
ADD_GROUP("Base Stats", "base_stat");
|
||||
for (int i = 0; i < Stat::STAT_ID_TOTAL_STATS; ++i) {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "stat_" + itos(i + 1), PROPERTY_HINT_RESOURCE_TYPE, "StatDataEntry"), "set_stat_data_enum", "get_stat_data_enum", i);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "base_stat_" + Stat::stat_id_name(i), PROPERTY_HINT_RESOURCE_TYPE, "StatDataEntry"), "set_stat_data_enum", "get_stat_data_enum", i);
|
||||
}
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_hp_scaling_data"), &StatData::get_hp_scaling_data);
|
||||
ClassDB::bind_method(D_METHOD("set_hp_scaling_data", "value"), &StatData::set_hp_scaling_data);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "hp_scaling_data", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_hp_scaling_data", "get_hp_scaling_data");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_spell_scaling_data"), &StatData::get_spell_scaling_data);
|
||||
ClassDB::bind_method(D_METHOD("set_spell_scaling_data", "value"), &StatData::set_spell_scaling_data);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spell_scaling_data", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_spell_scaling_data", "get_spell_scaling_data");
|
||||
|
||||
//ClassDB::bind_method(D_METHOD("GetStatForStat", "stat"), &StatData::GetStatForStat);
|
||||
ClassDB::bind_method(D_METHOD("get_level_stat_data"), &StatData::get_level_stat_data);
|
||||
ClassDB::bind_method(D_METHOD("set_level_stat_data", "value"), &StatData::set_level_stat_data);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "level_stat_data", PROPERTY_HINT_RESOURCE_TYPE, "LevelStatData"), "set_level_stat_data", "get_level_stat_data");
|
||||
}
|
||||
|
||||
|
@ -3,106 +3,10 @@
|
||||
|
||||
#include "scene/resources/curve.h"
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "stat_data_entry.h"
|
||||
#include "stat.h"
|
||||
|
||||
class StatDataEntry : public Resource {
|
||||
GDCLASS(StatDataEntry, Resource);
|
||||
|
||||
public:
|
||||
Stat::StatId get_stat_id() { return _stat_id; }
|
||||
void set_stat_id(Stat::StatId value) { _stat_id = value; }
|
||||
|
||||
float get_base() { return _base; }
|
||||
void set_base(float value) { _base = value; }
|
||||
|
||||
float get_bonus() { return _bonus; }
|
||||
void set_bonus(float value) { _bonus = value; }
|
||||
|
||||
float get_percent() { return _percent; }
|
||||
void set_percent(float value) { _percent = value; }
|
||||
|
||||
Stat::StatModifierApplyType get_modifier_apply_type() { return _modifier_apply_type; }
|
||||
void set_modifier_apply_type(Stat::StatModifierApplyType value) { _modifier_apply_type = value; }
|
||||
|
||||
bool has_dependency() { return _depends_on != Stat::STAT_ID_NONE; }
|
||||
|
||||
Stat::StatId get_depends_on() { return _depends_on; }
|
||||
void set_depends_on(Stat::StatId value) { _depends_on = value; }
|
||||
|
||||
Ref<Curve> get_dependdency_curve() { return _dependdency_curve; }
|
||||
void set_dependdency_curve(Ref<Curve> curve) { _dependdency_curve = curve; }
|
||||
|
||||
|
||||
void get_stats_for_stat(Ref<Stat> stat) {
|
||||
stat->set_stat_modifier_type(get_modifier_apply_type());
|
||||
stat->set_values(get_base(), get_bonus(), get_percent());
|
||||
stat->set_stat_modifier_type(get_modifier_apply_type());
|
||||
|
||||
stat->set_to_max();
|
||||
}
|
||||
|
||||
StatDataEntry() {
|
||||
_stat_id = Stat::STAT_ID_NONE;
|
||||
|
||||
_base = 0;
|
||||
_bonus = 0;
|
||||
_percent = 100;
|
||||
|
||||
_modifier_apply_type = Stat::MODIFIER_APPLY_TYPE_STANDARD;
|
||||
|
||||
_depends_on = Stat::STAT_ID_NONE;
|
||||
}
|
||||
|
||||
protected:
|
||||
static void _bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_stat_id"), &StatDataEntry::get_stat_id);
|
||||
ClassDB::bind_method(D_METHOD("set_stat_id", "value"), &StatDataEntry::set_stat_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "stat_id", PROPERTY_HINT_ENUM, Stat::STAT_BINDING_STRING), "set_stat_id", "get_stat_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_base"), &StatDataEntry::get_base);
|
||||
ClassDB::bind_method(D_METHOD("set_base", "value"), &StatDataEntry::set_base);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base"), "set_base", "get_base");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_bonus"), &StatDataEntry::get_bonus);
|
||||
ClassDB::bind_method(D_METHOD("set_bonus", "value"), &StatDataEntry::set_bonus);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bonus"), "set_bonus", "get_bonus");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_percent"), &StatDataEntry::get_percent);
|
||||
ClassDB::bind_method(D_METHOD("set_percent", "value"), &StatDataEntry::set_percent);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent"), "set_percent", "get_percent");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_modifier_apply_type"), &StatDataEntry::get_modifier_apply_type);
|
||||
ClassDB::bind_method(D_METHOD("set_modifier_apply_type", "value"), &StatDataEntry::set_modifier_apply_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "modifier_apply_type", PROPERTY_HINT_ENUM, Stat::MODIFIER_APPLY_TYPE_BINDING_STRING), "set_modifier_apply_type", "get_modifier_apply_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_dependency"), &StatDataEntry::has_dependency);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_depends_on"), &StatDataEntry::get_depends_on);
|
||||
ClassDB::bind_method(D_METHOD("set_depends_on", "value"), &StatDataEntry::set_depends_on);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "depends_on", PROPERTY_HINT_ENUM, Stat::STAT_BINDING_STRING), "set_depends_on", "get_depends_on");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_dependdency_curve"), &StatDataEntry::get_dependdency_curve);
|
||||
ClassDB::bind_method(D_METHOD("set_dependdency_curve", "value"), &StatDataEntry::set_dependdency_curve);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "dependdency_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_dependdency_curve", "get_dependdency_curve");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_stats_for_stat", "stat"), &StatDataEntry::get_stats_for_stat);
|
||||
}
|
||||
|
||||
private:
|
||||
Stat::StatId _stat_id;
|
||||
float _base;
|
||||
float _bonus;
|
||||
float _percent;
|
||||
|
||||
Stat::StatModifierApplyType _modifier_apply_type;
|
||||
|
||||
Stat::StatId _depends_on;
|
||||
Ref<Curve> _dependdency_curve;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#include "level_stat_data.h"
|
||||
|
||||
class StatData : public Resource {
|
||||
GDCLASS(StatData, Resource);
|
||||
@ -114,11 +18,8 @@ public:
|
||||
Ref<StatDataEntry> get_stat_data_enum(Stat::StatId stat_id);
|
||||
void set_stat_data_enum(Stat::StatId stat_id, Ref<StatDataEntry> entry);
|
||||
|
||||
Ref<Curve> get_hp_scaling_data();
|
||||
void set_hp_scaling_data(Ref<Curve> value);
|
||||
|
||||
Ref<Curve> get_spell_scaling_data();
|
||||
void set_spell_scaling_data(Ref<Curve> value);
|
||||
Ref<LevelStatData> get_level_stat_data();
|
||||
void set_level_stat_data(Ref<LevelStatData> value);
|
||||
|
||||
void get_stat_for_stat(Ref<Stat> stat);
|
||||
|
||||
@ -130,8 +31,7 @@ protected:
|
||||
private:
|
||||
Ref<StatDataEntry> _entries[Stat::STAT_ID_TOTAL_STATS];
|
||||
|
||||
Ref<Curve> _hp_scaling_data;
|
||||
Ref<Curve> _spell_scaling_data;
|
||||
Ref<LevelStatData> _level_stat_data;
|
||||
|
||||
};
|
||||
|
||||
|
2
entities/stats/stat_data_entry.cpp
Normal file
2
entities/stats/stat_data_entry.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include "stat_data_entry.h"
|
||||
|
105
entities/stats/stat_data_entry.h
Normal file
105
entities/stats/stat_data_entry.h
Normal file
@ -0,0 +1,105 @@
|
||||
#ifndef STAT_DATA_ENTRY_H
|
||||
#define STAT_DATA_ENTRY_H
|
||||
|
||||
#include "scene/resources/curve.h"
|
||||
#include "core/resource.h"
|
||||
|
||||
#include "stat.h"
|
||||
#include "level_stat_data.h"
|
||||
|
||||
class StatDataEntry : public Resource {
|
||||
GDCLASS(StatDataEntry, Resource);
|
||||
|
||||
public:
|
||||
Stat::StatId get_stat_id() { return _stat_id; }
|
||||
void set_stat_id(Stat::StatId value) { _stat_id = value; }
|
||||
|
||||
float get_base() { return _base; }
|
||||
void set_base(float value) { _base = value; }
|
||||
|
||||
float get_bonus() { return _bonus; }
|
||||
void set_bonus(float value) { _bonus = value; }
|
||||
|
||||
float get_percent() { return _percent; }
|
||||
void set_percent(float value) { _percent = value; }
|
||||
|
||||
Stat::StatModifierApplyType get_modifier_apply_type() { return _modifier_apply_type; }
|
||||
void set_modifier_apply_type(Stat::StatModifierApplyType value) { _modifier_apply_type = value; }
|
||||
|
||||
bool has_dependency() { return _depends_on != Stat::STAT_ID_NONE; }
|
||||
|
||||
Stat::StatId get_depends_on() { return _depends_on; }
|
||||
void set_depends_on(Stat::StatId value) { _depends_on = value; }
|
||||
|
||||
Ref<LevelStatData> get_dependdency_curve() { return _dependdency_curve; }
|
||||
void set_dependdency_curve(Ref<LevelStatData> curve) { _dependdency_curve = curve; }
|
||||
|
||||
|
||||
void get_stats_for_stat(Ref<Stat> stat) {
|
||||
stat->set_stat_modifier_type(get_modifier_apply_type());
|
||||
stat->set_values(get_base(), get_bonus(), get_percent());
|
||||
stat->set_stat_modifier_type(get_modifier_apply_type());
|
||||
|
||||
stat->set_to_max();
|
||||
}
|
||||
|
||||
StatDataEntry() {
|
||||
_stat_id = Stat::STAT_ID_NONE;
|
||||
|
||||
_base = 0;
|
||||
_bonus = 0;
|
||||
_percent = 100;
|
||||
|
||||
_modifier_apply_type = Stat::MODIFIER_APPLY_TYPE_STANDARD;
|
||||
|
||||
_depends_on = Stat::STAT_ID_NONE;
|
||||
}
|
||||
|
||||
protected:
|
||||
static void _bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_stat_id"), &StatDataEntry::get_stat_id);
|
||||
ClassDB::bind_method(D_METHOD("set_stat_id", "value"), &StatDataEntry::set_stat_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "stat_id", PROPERTY_HINT_ENUM, Stat::STAT_BINDING_STRING), "set_stat_id", "get_stat_id");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_base"), &StatDataEntry::get_base);
|
||||
ClassDB::bind_method(D_METHOD("set_base", "value"), &StatDataEntry::set_base);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base"), "set_base", "get_base");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_bonus"), &StatDataEntry::get_bonus);
|
||||
ClassDB::bind_method(D_METHOD("set_bonus", "value"), &StatDataEntry::set_bonus);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bonus"), "set_bonus", "get_bonus");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_percent"), &StatDataEntry::get_percent);
|
||||
ClassDB::bind_method(D_METHOD("set_percent", "value"), &StatDataEntry::set_percent);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent"), "set_percent", "get_percent");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_modifier_apply_type"), &StatDataEntry::get_modifier_apply_type);
|
||||
ClassDB::bind_method(D_METHOD("set_modifier_apply_type", "value"), &StatDataEntry::set_modifier_apply_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "modifier_apply_type", PROPERTY_HINT_ENUM, Stat::MODIFIER_APPLY_TYPE_BINDING_STRING), "set_modifier_apply_type", "get_modifier_apply_type");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_dependency"), &StatDataEntry::has_dependency);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_depends_on"), &StatDataEntry::get_depends_on);
|
||||
ClassDB::bind_method(D_METHOD("set_depends_on", "value"), &StatDataEntry::set_depends_on);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "depends_on", PROPERTY_HINT_ENUM, Stat::STAT_BINDING_STRING), "set_depends_on", "get_depends_on");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_dependdency_curve"), &StatDataEntry::get_dependdency_curve);
|
||||
ClassDB::bind_method(D_METHOD("set_dependdency_curve", "value"), &StatDataEntry::set_dependdency_curve);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "dependdency_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_dependdency_curve", "get_dependdency_curve");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_stats_for_stat", "stat"), &StatDataEntry::get_stats_for_stat);
|
||||
}
|
||||
|
||||
private:
|
||||
Stat::StatId _stat_id;
|
||||
float _base;
|
||||
float _bonus;
|
||||
float _percent;
|
||||
|
||||
Stat::StatModifierApplyType _modifier_apply_type;
|
||||
|
||||
Stat::StatId _depends_on;
|
||||
Ref<Curve> _dependdency_curve;
|
||||
};
|
||||
|
||||
#endif
|
@ -156,4 +156,6 @@ void EntityEnums::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(ENTITY_IMMUNITY_FLAG_PROJECTILE);
|
||||
BIND_ENUM_CONSTANT(ENTITY_IMMUNITY_FLAG_DEBUFF);
|
||||
BIND_ENUM_CONSTANT(ENTITY_IMMUNITY_FLAG_ATTACKS);
|
||||
|
||||
BIND_CONSTANT(MAX_LEVEL);
|
||||
}
|
||||
|
@ -198,6 +198,10 @@ public:
|
||||
AI_STATE_ATTACK,
|
||||
};
|
||||
|
||||
enum {
|
||||
MAX_LEVEL = 50,
|
||||
};
|
||||
|
||||
EntityEnums() {}
|
||||
|
||||
protected:
|
||||
|
@ -39,6 +39,12 @@
|
||||
#include "entities/stats/stat.h"
|
||||
#include "entities/stats/stat_modifier.h"
|
||||
#include "entities/stats/stat_data.h"
|
||||
#include "entities/stats/stat_data_entry.h"
|
||||
#include "entities/stats/level_stat_data.h"
|
||||
#include "entities/stats/simple_level_stat_data.h"
|
||||
#include "entities/stats/complex_level_stat_data.h"
|
||||
|
||||
|
||||
#include "inventory/bag.h"
|
||||
#include "inventory/inventory.h"
|
||||
|
||||
@ -151,6 +157,10 @@ void register_entity_spell_system_types() {
|
||||
ClassDB::register_class<StatDataEntry>();
|
||||
ClassDB::register_class<StatData>();
|
||||
|
||||
ClassDB::register_class<LevelStatData>();
|
||||
ClassDB::register_class<SimpleLevelStatData>();
|
||||
ClassDB::register_class<ComplexLevelStatData>();
|
||||
|
||||
ClassDB::register_class<CharacterSpec>();
|
||||
|
||||
ClassDB::register_class<Bag>();
|
||||
|
Loading…
Reference in New Issue
Block a user