Implemented Mana and Atk Spd stats

pull/28/head
sigonasr2 11 months ago
parent 3e3e96110c
commit c7e3115b89
  1. 17
      Crawler/AttributableStat.cpp
  2. 4
      Crawler/AttributableStat.h
  3. 6
      Crawler/Crawler.cpp
  4. 10
      Crawler/Item.cpp
  5. 2
      Crawler/Item.h
  6. 11
      Crawler/Player.cpp
  7. 3
      Crawler/Player.h
  8. 2
      Crawler/Ranger.cpp
  9. 2
      Crawler/Version.h
  10. 2
      Crawler/Warrior.cpp
  11. 2
      Crawler/Wizard.cpp
  12. 1
      Crawler/assets/config/items/ItemStats.txt

@ -58,8 +58,8 @@ ItemAttributable&ItemAttributable::operator+=(ItemAttributable&rhs){
return *this;
};
ItemAttribute::ItemAttribute(std::string_view name,bool isPct,std::string_view modifies)
:name(std::string(name)),isPct(isPct),modifies(std::string(modifies)){}
ItemAttribute::ItemAttribute(std::string_view name,bool isPct,bool showDecimal,std::string_view modifies)
:name(std::string(name)),isPct(isPct),showDecimal(showDecimal),modifies(std::string(modifies)){}
void ItemAttribute::Initialize(){
for(auto&[key,size]:DATA["Stats"]){
@ -67,7 +67,11 @@ void ItemAttribute::Initialize(){
if(DATA["Stats"][key].HasProperty("Modifies")){
modifies=DATA["Stats"][key]["Modifies"].GetString();
}
attributes.insert(key,ItemAttribute(DATA["Stats"][key]["Display Name"].GetString(),DATA["Stats"][key]["Percentage"].GetBool(),modifies));
bool showDecimal=false;
if(DATA["Stats"][key].HasProperty("Show Decimal")){
showDecimal=DATA["Stats"][key]["Show Decimal"].GetBool();
}
attributes.insert(key,ItemAttribute(DATA["Stats"][key]["Display Name"].GetString(),DATA["Stats"][key]["Percentage"].GetBool(),showDecimal,modifies));
}
attributes.SetInitialized();
}
@ -164,4 +168,9 @@ float&operator-=(float&lhs,const ItemAttribute&rhs){
const bool ItemAttribute::operator==(const ItemAttribute&rhs)const{
return name==rhs.name;
};
};
const bool ItemAttribute::ShowAsDecimal()const{
return showDecimal;
}

@ -52,16 +52,18 @@ class ItemAttribute{
friend class Crawler;
std::string name;
bool isPct;
bool showDecimal=false;
std::string modifies="";
std::optional<std::variant<Player*,Monster*>>target;
static void Initialize();
public:
inline static safemap<std::string,ItemAttribute>attributes;
ItemAttribute(std::string_view name,bool isPct,std::string_view modifies=""sv);
ItemAttribute(std::string_view name,bool isPct,bool showDecimal,std::string_view modifies=""sv);
static ItemAttribute&Get(const std::string_view name,const std::optional<std::variant<Player*,Monster*>>target={});
const std::string_view Name()const;
const std::string_view Modifies()const;
const bool DisplayAsPercent()const;
const bool ShowAsDecimal()const;
const bool operator<(const ItemAttribute&rhs)const; //WARNING! Implemented for map sorting!!!
friend float&operator+=(float&lhs,const ItemAttribute&rhs);
friend float&operator-=(float&lhs,const ItemAttribute&rhs);

@ -210,6 +210,8 @@ bool Crawler::OnUserCreate(){
Inventory::AddItem("Leather Gloves");
Inventory::AddItem("Leather Shoes");
Inventory::AddItem("Wooden Sword");
Inventory::AddItem("Laser Sword");
Inventory::AddItem("Shell Sword");
LoadLevel(LEVEL_NAMES["starting_map"_S]);
ChangePlayerClass(WARRIOR);
@ -1540,7 +1542,7 @@ void Crawler::LoadLevel(MapName map){
totalBossEncounterMobs=0;
Inventory::Clear("Monster Loot");
Inventory::Clear("Stage Loot");
GetPlayer()->hp=GetPlayer()->GetStat("Health");
GetPlayer()->hp=GetPlayer()->GetMaxHealth();
GetPlayer()->mana=GetPlayer()->GetMaxMana();
GetPlayer()->SetState(State::NORMAL);
GetPlayer()->GetCastInfo()={};
@ -1892,6 +1894,8 @@ void Crawler::ChangePlayerClass(Class cl){
player->stats=previousStats;
player->SetBaseStat("Health",DATA.GetProperty(player->GetClassName()+".BaseHealth").GetInt());
player->hp=player->GetBaseStat("Health");
player->SetBaseStat("Mana",DATA.GetProperty("Player.BaseMana").GetInt());
player->mana=player->GetBaseStat("Mana");
player->SetBaseStat("Attack",DATA.GetProperty(player->GetClassName()+".BaseAtk").GetInt());
player->hpGrowthRate=float(DATA.GetProperty(player->GetClassName()+".HealthGrowthRate").GetReal());
player->atkGrowthRate=float(DATA.GetProperty(player->GetClassName()+".AtkGrowthRate").GetReal());

@ -150,7 +150,7 @@ void ItemInfo::InitializeItems(){
datafile&dat=data[key]["StatValues["+std::to_string(enhancementLevel)+"]"];
int attrIndex=0;
for(ItemAttribute&attr:statValueList){
enhancementStats.SetAttribute(enhancementLevel,attr,dat.GetInt(attrIndex));
enhancementStats.SetAttribute(enhancementLevel,attr,dat.GetReal(attrIndex));
attrIndex++;
}
}
@ -645,7 +645,7 @@ const EquipSlot ItemInfo::Slot()const{
return slot;
}
void EnhancementInfo::SetAttribute(int enhanceLevel,ItemAttribute attribute,int value){
void EnhancementInfo::SetAttribute(int enhanceLevel,ItemAttribute attribute,float value){
while(enhancementStats.size()<=enhanceLevel){
enhancementStats.push_back({});
}
@ -726,7 +726,11 @@ const std::string Stats::GetStatsString(CompactText compact)const{
description+="\n";
}
}
description+=std::string(attr.Name())+": "+std::to_string(int(val))+(attr.DisplayAsPercent()?"%":"");
std::string statNumber=std::to_string(int(val));
if(attr.ShowAsDecimal()){
statNumber=std::format("{:.2f}",val);
}
description+=std::string(attr.Name())+": "+statNumber+(attr.DisplayAsPercent()?"%":"");
first=false;
}
return description;

@ -106,7 +106,7 @@ struct EnhancementInfo{
private:
std::vector<Stats>enhancementStats;
public:
void SetAttribute(int enhanceLevel,ItemAttribute attribute,int value);
void SetAttribute(int enhanceLevel,ItemAttribute attribute,float value);
const Stats&operator[](int level)const;
const size_t size()const;
};

@ -87,6 +87,7 @@ Player::Player(Player*player)
void Player::Initialize(){
Player::GROUND_SLAM_SPIN_TIME="Warrior.Ability 2.SpinTime"_F;
SetBaseStat("Health",hp);
SetBaseStat("Mana",mana);
SetBaseStat("Defense",0);
SetBaseStat("Attack","Warrior.BaseAtk"_I);
SetBaseStat("Move Spd %",100);
@ -191,7 +192,7 @@ const int Player::GetMana()const{
}
const int Player::GetMaxMana()const{
return maxmana;
return GetStat("Mana");
}
const int Player::GetAttack(){
@ -850,14 +851,14 @@ bool Player::Heal(int damage){
}
void Player::RestoreMana(int amt,bool suppressDamageNumber){
mana=std::clamp(mana+amt,0,maxmana);
mana=std::clamp(mana+amt,0,GetMaxMana());
if(amt>0&&!suppressDamageNumber){
DAMAGENUMBER_LIST.push_back(std::make_shared<DamageNumber>(GetPos(),amt,true,MANA_GAIN));
}
}
void Player::ConsumeMana(int amt){
mana=std::clamp(mana-amt,0,maxmana);
mana=std::clamp(mana-amt,0,GetMaxMana());
}
void Player::SetSizeMult(float size){
@ -1147,4 +1148,8 @@ void Player::AddAccumulatedXP(const uint32_t xpGain){
const uint32_t Player::GetAccumulatedXP()const{
return accumulatedXP;
}
const float Player::GetAttackRecoveryRateReduction()const{
return GetStat("Attack Spd");
}

@ -121,6 +121,7 @@ public:
const float GetHP6RecoveryPct()const;
const float GetHP4RecoveryPct()const;
const float GetDamageReductionPct()const;
const float GetAttackRecoveryRateReduction()const;
void SetSizeMult(float size);
float GetAttackRangeMult();
float GetSpinAngle();
@ -225,7 +226,7 @@ public:
void AddAccumulatedXP(const uint32_t xpGain);
private:
int hp="Warrior.BaseHealth"_I;
int mana="Player.BaseMana"_I,maxmana=mana;
int mana="Player.BaseMana"_I;
float hpGrowthRate="Warrior.HealthGrowthRate"_F;
float atkGrowthRate="Warrior.AtkGrowthRate"_F;
vf2d pos;

@ -70,7 +70,7 @@ bool Ranger::AutoAttack(){
geom2d::line pointTowardsCursor(GetPos(),game->GetWorldMousePos());
vf2d extendedLine=pointTowardsCursor.upoint(1.1f);
float angleToCursor=atan2(extendedLine.y-GetPos().y,extendedLine.x-GetPos().x);
attack_cooldown_timer=ARROW_ATTACK_COOLDOWN;
attack_cooldown_timer=ARROW_ATTACK_COOLDOWN-GetAttackRecoveryRateReduction();
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(GetPos(),extendedLine,vf2d{cos(angleToCursor)*"Ranger.Auto Attack.ArrowSpd"_F,float(sin(angleToCursor)*"Ranger.Auto Attack.ArrowSpd"_F-PI/8*"Ranger.Auto Attack.ArrowSpd"_F)}+movementVelocity,"Ranger.Auto Attack.Radius"_F/100*12,int(GetAttack()*"Ranger.Auto Attack.DamageMult"_F),OnUpperLevel(),true)));
SetState(State::SHOOT_ARROW);
SetAnimationBasedOnTargetingDirection(angleToCursor);

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 4867
#define VERSION_BUILD 4874
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -79,7 +79,7 @@ bool Warrior::AutoAttack(){
}
}
if(closest!=nullptr&&closest->Hurt(int(GetAttack()*"Warrior.Auto Attack.DamageMult"_F),OnUpperLevel(),GetZ())){
attack_cooldown_timer=ATTACK_COOLDOWN;
attack_cooldown_timer=ATTACK_COOLDOWN-GetAttackRecoveryRateReduction();
swordSwingTimer="Warrior.Auto Attack.SwordSwingTime"_F;
SetState(State::SWING_SWORD);
switch(facingDirection){

@ -102,7 +102,7 @@ void Wizard::OnUpdate(float fElapsedTime){
}
bool Wizard::AutoAttack(){
attack_cooldown_timer=MAGIC_ATTACK_COOLDOWN;
attack_cooldown_timer=MAGIC_ATTACK_COOLDOWN-GetAttackRecoveryRateReduction();
float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x);
BULLET_LIST.push_back(std::make_unique<EnergyBolt>(EnergyBolt(GetPos(),{cos(angleToCursor)*"Wizard.Auto Attack.Speed"_F,sin(angleToCursor)*"Wizard.Auto Attack.Speed"_F},"Wizard.Auto Attack.Radius"_F/100*12,int(GetAttack()*"Wizard.Auto Attack.DamageMult"_F),upperLevel,true,WHITE)));
return true;

@ -76,6 +76,7 @@ Stats
Attack Spd
{
Display Name = Attack Spd
Show Decimal = True
Percentage = False
}
Mana

Loading…
Cancel
Save