Refactored stat system such that equip stats can be obtained easily, while base stats are hidden away to prevent accidental usage.
This commit is contained in:
parent
808cc32418
commit
5eec1a21c5
@ -180,7 +180,7 @@ void Menu::InitializeCharacterMenuWindow(){
|
|||||||
for(ItemAttribute attribute:displayAttrs){
|
for(ItemAttribute attribute:displayAttrs){
|
||||||
AttributeData data=ItemAttributable::GetDisplayInfo(attribute);
|
AttributeData data=ItemAttributable::GetDisplayInfo(attribute);
|
||||||
std::string attrStr=data.name+":\n ";
|
std::string attrStr=data.name+":\n ";
|
||||||
attrStr+=std::to_string(game->GetPlayer()->A(attribute));
|
attrStr+=std::to_string(game->GetPlayer()->GetStat(attribute));
|
||||||
if(data.displayAsPercent){
|
if(data.displayAsPercent){
|
||||||
attrStr+="%";
|
attrStr+="%";
|
||||||
}
|
}
|
||||||
|
@ -1699,8 +1699,9 @@ void Crawler::ChangePlayerClass(Class cl){
|
|||||||
player.reset(NEW Witch(player.get()));
|
player.reset(NEW Witch(player.get()));
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
player->hp=player->A(ItemAttribute::health)=DATA.GetProperty(player->GetClassName()+".BaseHealth").GetInt();
|
player->SetBaseStat(ItemAttribute::health,DATA.GetProperty(player->GetClassName()+".BaseHealth").GetInt());
|
||||||
player->A(ItemAttribute::attack)=DATA.GetProperty(player->GetClassName()+".BaseAtk").GetInt();
|
player->hp=player->GetBaseStat(ItemAttribute::health);
|
||||||
|
player->SetBaseStat(ItemAttribute::attack,DATA.GetProperty(player->GetClassName()+".BaseAtk").GetInt());
|
||||||
player->hpGrowthRate=float(DATA.GetProperty(player->GetClassName()+".HealthGrowthRate").GetReal());
|
player->hpGrowthRate=float(DATA.GetProperty(player->GetClassName()+".HealthGrowthRate").GetReal());
|
||||||
player->atkGrowthRate=float(DATA.GetProperty(player->GetClassName()+".AtkGrowthRate").GetReal());
|
player->atkGrowthRate=float(DATA.GetProperty(player->GetClassName()+".AtkGrowthRate").GetReal());
|
||||||
sig::Animation::SetupPlayerAnimations();
|
sig::Animation::SetupPlayerAnimations();
|
||||||
|
@ -500,6 +500,7 @@ void Inventory::EquipItem(Item&it,EquipSlot slot){
|
|||||||
if(equippedSlot!=EquipSlot::NONE)UnequipItem(equippedSlot);
|
if(equippedSlot!=EquipSlot::NONE)UnequipItem(equippedSlot);
|
||||||
if(GetEquip(slot)!=nullptr)UnequipItem(slot);
|
if(GetEquip(slot)!=nullptr)UnequipItem(slot);
|
||||||
Inventory::equipment[slot]=⁢
|
Inventory::equipment[slot]=⁢
|
||||||
|
PlayerStats::RecalculateEquipStats();
|
||||||
};
|
};
|
||||||
void Inventory::UnequipItem(EquipSlot slot){
|
void Inventory::UnequipItem(EquipSlot slot){
|
||||||
Inventory::equipment[slot]=nullptr;
|
Inventory::equipment[slot]=nullptr;
|
||||||
|
@ -68,6 +68,9 @@ InputGroup Player::KEY_ITEM1;
|
|||||||
InputGroup Player::KEY_ITEM2;
|
InputGroup Player::KEY_ITEM2;
|
||||||
InputGroup Player::KEY_ITEM3;
|
InputGroup Player::KEY_ITEM3;
|
||||||
|
|
||||||
|
ItemAttributable PlayerStats::equipStats;
|
||||||
|
ItemAttributable PlayerStats::baseStats;
|
||||||
|
|
||||||
Player::Player()
|
Player::Player()
|
||||||
:lastReleasedMovementKey(DOWN),facingDirection(DOWN),state(State::NORMAL){
|
:lastReleasedMovementKey(DOWN),facingDirection(DOWN),state(State::NORMAL){
|
||||||
Initialize();
|
Initialize();
|
||||||
@ -76,21 +79,20 @@ Player::Player()
|
|||||||
Player::Player(Player*player)
|
Player::Player(Player*player)
|
||||||
:pos(player->GetPos()),vel(player->GetVelocity()),iframe_time(player->iframe_time),lastReleasedMovementKey(DOWN),
|
:pos(player->GetPos()),vel(player->GetVelocity()),iframe_time(player->iframe_time),lastReleasedMovementKey(DOWN),
|
||||||
facingDirection(DOWN),state(State::NORMAL){
|
facingDirection(DOWN),state(State::NORMAL){
|
||||||
player->copyTo(*this);
|
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Initialize(){
|
void Player::Initialize(){
|
||||||
Player::GROUND_SLAM_SPIN_TIME="Warrior.Ability 2.SpinTime"_F;
|
Player::GROUND_SLAM_SPIN_TIME="Warrior.Ability 2.SpinTime"_F;
|
||||||
A(ItemAttribute::health)=hp;
|
SetBaseStat(ItemAttribute::health,hp);
|
||||||
A(ItemAttribute::defense)=0;
|
SetBaseStat(ItemAttribute::defense,0);
|
||||||
A(ItemAttribute::attack)="Warrior.BaseAtk"_I;
|
SetBaseStat(ItemAttribute::attack,"Warrior.BaseAtk"_I);
|
||||||
A(ItemAttribute::moveSpdPct)=100;
|
SetBaseStat(ItemAttribute::moveSpdPct,100);
|
||||||
A(ItemAttribute::cdrPct)=0;
|
SetBaseStat(ItemAttribute::cdrPct,0);
|
||||||
A(ItemAttribute::critPct)=0;
|
SetBaseStat(ItemAttribute::critPct,0);
|
||||||
A(ItemAttribute::critDmgPct)=0;
|
SetBaseStat(ItemAttribute::critDmgPct,0);
|
||||||
A(ItemAttribute::healthPct)=0;
|
SetBaseStat(ItemAttribute::healthPct,0);
|
||||||
A(ItemAttribute::healthPctRecoveryPer6sec)=0;
|
SetBaseStat(ItemAttribute::healthPctRecoveryPer6sec,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::SetX(float x){
|
bool Player::SetX(float x){
|
||||||
@ -174,32 +176,32 @@ float Player::GetZ(){
|
|||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::GetHealth(){
|
const int Player::GetHealth()const{
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::GetMaxHealth(){
|
const int Player::GetMaxHealth()const{
|
||||||
return A(ItemAttribute::health);
|
return GetStat(ItemAttribute::health);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::GetMana(){
|
const int Player::GetMana()const{
|
||||||
return mana;
|
return mana;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::GetMaxMana() {
|
const int Player::GetMaxMana()const{
|
||||||
return maxmana;
|
return maxmana;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::GetAttack(){
|
const int Player::GetAttack(){
|
||||||
float mod_atk=float(A(ItemAttribute::attack));
|
float mod_atk=float(GetStat(ItemAttribute::attack));
|
||||||
for(Buff&b:GetBuffs(BuffType::ATTACK_UP)){
|
for(Buff&b:GetBuffs(BuffType::ATTACK_UP)){
|
||||||
mod_atk+=A(ItemAttribute::attack)*b.intensity;
|
mod_atk+=GetStat(ItemAttribute::attack)*b.intensity;
|
||||||
}
|
}
|
||||||
return int(mod_atk);
|
return int(mod_atk);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Player::GetMoveSpdMult(){
|
float Player::GetMoveSpdMult(){
|
||||||
float mod_moveSpd=A(ItemAttribute::moveSpdPct)/100.f;
|
float mod_moveSpd=GetStat(ItemAttribute::moveSpdPct)/100.f;
|
||||||
for(Buff&b:GetBuffs(BuffType::SLOWDOWN)){
|
for(Buff&b:GetBuffs(BuffType::SLOWDOWN)){
|
||||||
mod_moveSpd-=mod_moveSpd*b.intensity;
|
mod_moveSpd-=mod_moveSpd*b.intensity;
|
||||||
}
|
}
|
||||||
@ -789,7 +791,7 @@ void Player::SetIframes(float duration){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Player::Heal(int damage){
|
bool Player::Heal(int damage){
|
||||||
hp=std::clamp(hp+damage,0,A(ItemAttribute::health));
|
hp=std::clamp(hp+damage,0,GetStat(ItemAttribute::health));
|
||||||
if(damage>0){
|
if(damage>0){
|
||||||
DAMAGENUMBER_LIST.push_back(std::make_shared<DamageNumber>(GetPos(),damage,true,HEALTH_GAIN));
|
DAMAGENUMBER_LIST.push_back(std::make_shared<DamageNumber>(GetPos(),damage,true,HEALTH_GAIN));
|
||||||
}
|
}
|
||||||
@ -851,4 +853,31 @@ void Player::SetItem2UseFunc(Ability a){
|
|||||||
};
|
};
|
||||||
void Player::SetItem3UseFunc(Ability a){
|
void Player::SetItem3UseFunc(Ability a){
|
||||||
useItem3=a;
|
useItem3=a;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const int Player::GetStat(ItemAttribute a)const{
|
||||||
|
return PlayerStats::GetStat(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int Player::GetBaseStat(ItemAttribute a)const{
|
||||||
|
return PlayerStats::GetBaseStat(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PlayerStats::RecalculateEquipStats(){
|
||||||
|
baseStats.copyTo(equipStats);
|
||||||
|
}
|
||||||
|
const int PlayerStats::GetStat(ItemAttribute stat){
|
||||||
|
return equipStats.A(stat);
|
||||||
|
}
|
||||||
|
const int PlayerStats::GetBaseStat(ItemAttribute stat){
|
||||||
|
return baseStats.A(stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerStats::SetBaseStat(ItemAttribute stat,int val){
|
||||||
|
baseStats.A(stat)=val;
|
||||||
|
RecalculateEquipStats();
|
||||||
|
}
|
||||||
|
void Player::SetBaseStat(ItemAttribute a,int val){
|
||||||
|
PlayerStats::SetBaseStat(a,val);
|
||||||
|
}
|
@ -49,6 +49,7 @@ All rights reserved.
|
|||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
#include "AttributableStat.h"
|
#include "AttributableStat.h"
|
||||||
|
|
||||||
|
|
||||||
#undef GetClassName
|
#undef GetClassName
|
||||||
struct DamageNumber;
|
struct DamageNumber;
|
||||||
|
|
||||||
@ -59,7 +60,19 @@ struct CastInfo{
|
|||||||
vf2d castPos;
|
vf2d castPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Player:ItemAttributable{
|
class PlayerStats{
|
||||||
|
friend class Inventory;
|
||||||
|
static ItemAttributable equipStats; //The stats after gear calculations are applied.
|
||||||
|
static ItemAttributable baseStats;
|
||||||
|
|
||||||
|
static void RecalculateEquipStats(); //Called when equipment is updated.
|
||||||
|
public:
|
||||||
|
static const int GetStat(ItemAttribute stat); //Get stats with equipment applied.
|
||||||
|
static const int GetBaseStat(ItemAttribute stat);
|
||||||
|
static void SetBaseStat(ItemAttribute stat,int val);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Player{
|
||||||
friend class Crawler;
|
friend class Crawler;
|
||||||
friend class sig::Animation;
|
friend class sig::Animation;
|
||||||
friend struct Warrior;
|
friend struct Warrior;
|
||||||
@ -69,6 +82,7 @@ struct Player:ItemAttributable{
|
|||||||
friend struct Wizard;
|
friend struct Wizard;
|
||||||
friend struct Witch;
|
friend struct Witch;
|
||||||
friend class State_GameRun;
|
friend class State_GameRun;
|
||||||
|
friend class Inventory;
|
||||||
private:
|
private:
|
||||||
int hp="Warrior.BaseHealth"_I;
|
int hp="Warrior.BaseHealth"_I;
|
||||||
int mana="Player.BaseMana"_I,maxmana=mana;
|
int mana="Player.BaseMana"_I,maxmana=mana;
|
||||||
@ -149,11 +163,14 @@ public:
|
|||||||
float GetX();
|
float GetX();
|
||||||
float GetY();
|
float GetY();
|
||||||
float GetZ();
|
float GetZ();
|
||||||
int GetHealth();
|
const int GetStat(ItemAttribute a)const;
|
||||||
int GetMaxHealth();
|
const int GetBaseStat(ItemAttribute a)const;
|
||||||
int GetMana();
|
void SetBaseStat(ItemAttribute a,int val);
|
||||||
int GetMaxMana();
|
const int GetMaxHealth()const;
|
||||||
int GetAttack();
|
const int GetHealth()const;
|
||||||
|
const int GetMana()const;
|
||||||
|
const int GetMaxMana()const;
|
||||||
|
const int GetAttack();
|
||||||
float GetMoveSpdMult();
|
float GetMoveSpdMult();
|
||||||
float GetSizeMult();
|
float GetSizeMult();
|
||||||
void SetSizeMult(float size);
|
void SetSizeMult(float size);
|
||||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 1
|
#define VERSION_PATCH 1
|
||||||
#define VERSION_BUILD 3510
|
#define VERSION_BUILD 3517
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user