mirror of
https://github.com/Relintai/entity_spell_system.git
synced 2025-04-21 21:41:21 +02:00
Added a few setting to EntityDataManager for levelling.
This commit is contained in:
parent
3367f3bc96
commit
9cc99bbc27
@ -32,6 +32,7 @@ SOFTWARE.
|
||||
#include "../inventory/bag.h"
|
||||
#include "../pipelines/spell_damage_info.h"
|
||||
#include "../pipelines/spell_heal_info.h"
|
||||
#include "../profiles/class_profile.h"
|
||||
#include "./data/character_spec.h"
|
||||
#include "./data/talent_row_data.h"
|
||||
#include "./skills/entity_skill.h"
|
||||
@ -479,6 +480,22 @@ void Entity::_setup(Ref<EntityCreateInfo> info) {
|
||||
}
|
||||
|
||||
if (gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_PLAYER || gets_entity_player_type() == EntityEnums::ENTITY_PLAYER_TYPE_DISPLAY) {
|
||||
if (EntityDataManager::get_instance()->get_use_global_class_level()) {
|
||||
Ref<ClassProfile> cp = ProfileManager::get_instance()->get_class_profile(gets_entity_data()->get_id());
|
||||
|
||||
if (cp.is_valid()) {
|
||||
int leveldiff = cp->get_level() - _s_class_level;
|
||||
|
||||
sets_class_level(cp->get_level());
|
||||
|
||||
if (leveldiff > 0) {
|
||||
sclass_levelup(leveldiff);
|
||||
}
|
||||
|
||||
sets_class_xp(cp->get_xp());
|
||||
}
|
||||
}
|
||||
|
||||
setup_actionbars();
|
||||
}
|
||||
|
||||
@ -836,6 +853,12 @@ int Entity::getc_pet_count() {
|
||||
return _s_pets.size();
|
||||
}
|
||||
|
||||
//// Profiles ////
|
||||
|
||||
Ref<ClassProfile> Entity::get_class_profile() {
|
||||
return ProfileManager::get_instance()->get_class_profile(_s_class_id);
|
||||
}
|
||||
|
||||
//// Serialization ////
|
||||
|
||||
bool Entity::is_deserialized() {
|
||||
@ -862,9 +885,10 @@ Dictionary Entity::_to_dict() {
|
||||
//dict["entity_data_id"] = _s_class_id;
|
||||
dict["type"] = _s_type;
|
||||
dict["gender"] = _s_gender;
|
||||
dict["class_level"] = _s_class_level;
|
||||
dict["class_level"] = gets_class_level();
|
||||
dict["class_xp"] = gets_class_xp();
|
||||
|
||||
dict["character_level"] = _s_character_level;
|
||||
dict["class_xp"] = _s_class_xp;
|
||||
dict["character_xp"] = _s_character_xp;
|
||||
dict["money"] = _s_money;
|
||||
dict["seed"] = _s_seed;
|
||||
@ -1040,9 +1064,15 @@ void Entity::_from_dict(const Dictionary &dict) {
|
||||
|
||||
sets_gender(static_cast<EntityEnums::EntityGender>(static_cast<int>(dict.get("gender", 0))));
|
||||
|
||||
sets_class_level(dict.get("class_level", 0));
|
||||
if (EntityDataManager::get_instance()->get_use_global_class_level()) {
|
||||
_s_class_level = (dict.get("class_level", 0));
|
||||
_s_class_xp = (dict.get("class_xp", 0));
|
||||
} else {
|
||||
sets_class_level(dict.get("class_level", 0));
|
||||
sets_class_xp(dict.get("class_xp", 0));
|
||||
}
|
||||
|
||||
sets_character_level(dict.get("character_level", 0));
|
||||
sets_class_xp(dict.get("class_xp", 0));
|
||||
sets_character_xp(dict.get("character_xp", 0));
|
||||
|
||||
sets_money(dict.get("money", 0));
|
||||
@ -6045,12 +6075,14 @@ void Entity::_scraft(int id) {
|
||||
}
|
||||
|
||||
void Entity::_son_xp_gained(int value) {
|
||||
if (EntityDataManager::get_instance()->get_xp_data()->can_class_level_up(gets_class_level())) {
|
||||
int xpr = EntityDataManager::get_instance()->get_xp_data()->get_class_xp(gets_class_level());
|
||||
if (EntityDataManager::get_instance()->get_use_class_xp() && EntityDataManager::get_instance()->get_automatic_class_levelups()) {
|
||||
if (EntityDataManager::get_instance()->get_xp_data()->can_class_level_up(gets_class_level())) {
|
||||
int xpr = EntityDataManager::get_instance()->get_xp_data()->get_class_xp(gets_class_level());
|
||||
|
||||
if (xpr <= gets_class_xp()) {
|
||||
sclass_levelup(1);
|
||||
sets_class_xp(0);
|
||||
if (xpr <= gets_class_xp()) {
|
||||
sclass_levelup(1);
|
||||
sets_class_xp(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6083,6 +6115,13 @@ void Entity::_son_character_level_up(int level) {
|
||||
Ref<StatModifier> sm = stat->get_modifier(0);
|
||||
sm->set_base_mod(sm->get_base_mod() + st);
|
||||
}
|
||||
|
||||
if (!EntityDataManager::get_instance()->get_use_class_xp()) {
|
||||
if (EntityDataManager::get_instance()->get_use_spell_points())
|
||||
sets_free_spell_points(gets_free_spell_points() + ecd->get_spell_points_per_level() * level);
|
||||
|
||||
sets_free_talent_points(gets_free_talent_points() + level);
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::_son_class_level_up(int level) {
|
||||
|
@ -66,6 +66,7 @@ class EntityCreateInfo;
|
||||
class TalentRowData;
|
||||
class CharacterSpec;
|
||||
class EntitySkill;
|
||||
class ClassProfile;
|
||||
|
||||
enum SpellCastDataSignals {
|
||||
CastFailed,
|
||||
@ -936,6 +937,10 @@ public:
|
||||
//void pets_follow();
|
||||
//void pets_stop();
|
||||
|
||||
//// Profiles ////
|
||||
|
||||
Ref<ClassProfile> get_class_profile();
|
||||
|
||||
//// Serialization ////
|
||||
|
||||
bool is_deserialized();
|
||||
|
@ -57,6 +57,27 @@ void EntityDataManager::set_automatic_load(const bool load) {
|
||||
_automatic_load = load;
|
||||
}
|
||||
|
||||
bool EntityDataManager::get_use_class_xp() const {
|
||||
return _use_class_xp;
|
||||
}
|
||||
void EntityDataManager::set_use_class_xp(const bool value) {
|
||||
_use_class_xp = value;
|
||||
}
|
||||
|
||||
bool EntityDataManager::get_automatic_class_levelups() const {
|
||||
return _automatic_class_levelups;
|
||||
}
|
||||
void EntityDataManager::set_automatic_class_levelups(const bool value) {
|
||||
_automatic_class_levelups = value;
|
||||
}
|
||||
|
||||
bool EntityDataManager::get_use_global_class_level() const {
|
||||
return _use_global_class_level;
|
||||
}
|
||||
void EntityDataManager::set_use_global_class_level(const bool value) {
|
||||
_use_global_class_level = value;
|
||||
}
|
||||
|
||||
Ref<Aura> EntityDataManager::get_skill_for_armor_type(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, ItemEnums::ARMOR_TYPE_MAX, Ref<Aura>());
|
||||
|
||||
@ -973,6 +994,18 @@ void EntityDataManager::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_automatic_load", "load"), &EntityDataManager::set_automatic_load);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_load"), "set_automatic_load", "get_automatic_load");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_automatic_class_levelups"), &EntityDataManager::get_automatic_class_levelups);
|
||||
ClassDB::bind_method(D_METHOD("set_automatic_class_levelups", "load"), &EntityDataManager::set_automatic_class_levelups);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "automatic_class_levelups"), "set_automatic_class_levelups", "get_automatic_class_levelups");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_use_class_xp"), &EntityDataManager::get_use_class_xp);
|
||||
ClassDB::bind_method(D_METHOD("set_use_class_xp", "load"), &EntityDataManager::set_use_class_xp);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_class_xp"), "set_use_class_xp", "get_use_class_xp");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_use_global_class_level"), &EntityDataManager::get_use_global_class_level);
|
||||
ClassDB::bind_method(D_METHOD("set_use_global_class_level", "load"), &EntityDataManager::set_use_global_class_level);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_global_class_level"), "set_use_global_class_level", "get_use_global_class_level");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_skill_for_armor_type", "index"), &EntityDataManager::get_skill_for_armor_type);
|
||||
ClassDB::bind_method(D_METHOD("set_skill_for_armor_type", "index", "aura"), &EntityDataManager::set_skill_for_armor_type);
|
||||
|
||||
@ -1126,6 +1159,11 @@ EntityDataManager::EntityDataManager() {
|
||||
|
||||
_use_spell_points = GLOBAL_DEF("ess/spells/use_spell_points", false);
|
||||
_scale_spells_by_default = GLOBAL_DEF("ess/spells/scale_spells_by_default", false);
|
||||
|
||||
_use_class_xp = GLOBAL_DEF("ess/level/use_class_xp", false);
|
||||
_automatic_class_levelups = GLOBAL_DEF("ess/level/automatic_class_levelups", false);
|
||||
_use_global_class_level = GLOBAL_DEF("ess/level/use_global_class_level", false);
|
||||
|
||||
_automatic_load = GLOBAL_DEF("ess/data/automatic_load", false);
|
||||
|
||||
_xp_data_path = GLOBAL_DEF("ess/data/xp_data_path", "");
|
||||
|
@ -71,6 +71,15 @@ public:
|
||||
bool get_automatic_load() const;
|
||||
void set_automatic_load(const bool load);
|
||||
|
||||
bool get_use_class_xp() const;
|
||||
void set_use_class_xp(const bool value);
|
||||
|
||||
bool get_automatic_class_levelups() const;
|
||||
void set_automatic_class_levelups(const bool value);
|
||||
|
||||
bool get_use_global_class_level() const;
|
||||
void set_use_global_class_level(const bool value);
|
||||
|
||||
Ref<Aura> get_skill_for_armor_type(const int index);
|
||||
void set_skill_for_armor_type(const int index, const Ref<Aura> &aura);
|
||||
|
||||
@ -246,6 +255,9 @@ private:
|
||||
bool _use_spell_points;
|
||||
bool _scale_spells_by_default;
|
||||
bool _automatic_load;
|
||||
bool _use_class_xp;
|
||||
bool _automatic_class_levelups;
|
||||
bool _use_global_class_level;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user