Added MP restore and consume functions. Converted old direct variable accesses to use these as well. Item restore script completed.

pull/28/head
sigonasr2 1 year ago
parent ba6505b266
commit 48a8165086
  1. 6
      Crawler/Item.cpp
  2. 14
      Crawler/Player.cpp
  3. 2
      Crawler/Player.h
  4. 2
      Crawler/Version.h

@ -97,9 +97,9 @@ std::string ItemProps::GetStringProp(std::string prop){
void ItemInfo::InitializeScripts(){
ITEM_SCRIPTS["Restore"]=[](Crawler*game,ItemProps props){
game->GetPlayer()->Heal(props.GetIntProp("HP Restore"));
game->GetPlayer()->Heal(props.GetIntProp("HP % Restore"));
game->GetPlayer()->Heal(props.GetIntProp("HP Restore"));
game->GetPlayer()->Heal(props.GetIntProp("HP % Restore"));
game->GetPlayer()->Heal(game->GetPlayer()->GetMaxHealth()*props.GetIntProp("HP % Restore")/100.f);
game->GetPlayer()->RestoreMana(props.GetIntProp("MP Restore"));
game->GetPlayer()->RestoreMana(game->GetPlayer()->GetMaxMana()*props.GetIntProp("MP % Restore")/100.f);
return true;
};

@ -195,7 +195,7 @@ void Player::Update(float fElapsedTime){
if(castInfo.castTimer<=0){
if(castPrepAbility->action(this,castInfo.castPos)){
castPrepAbility->cooldown=castPrepAbility->COOLDOWN_TIME;
mana-=castPrepAbility->manaCost;
ConsumeMana(castPrepAbility->manaCost);
}
castInfo.castTimer=0;
SetState(State::NORMAL);
@ -203,7 +203,7 @@ void Player::Update(float fElapsedTime){
}
while(manaTickTimer<=0){
manaTickTimer+=0.2;
mana=std::min(maxmana,mana+1);
RestoreMana(1);
}
for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){
Buff&b=*it;
@ -365,7 +365,7 @@ void Player::Update(float fElapsedTime){
}
if(AllowedToCast(ability)&&ability.action(this,{})){
ability.cooldown=ability.COOLDOWN_TIME;
mana-=ability.manaCost;
ConsumeMana(ability.manaCost);
}else
if(ability.precastInfo.precastTargetingRequired&&GetState()==State::NORMAL){
PrepareCast(ability);
@ -704,4 +704,12 @@ void Player::SetIframes(float duration){
bool Player::Heal(int damage){
hp=std::clamp(hp+damage,0,maxhp);
return true;
}
void Player::RestoreMana(int amt){
mana=std::clamp(mana+amt,0,maxmana);
}
void Player::ConsumeMana(int amt){
mana=std::clamp(mana-amt,0,maxmana);
}

@ -134,6 +134,8 @@ public:
bool CanAct(Ability&ability);
void Knockback(vf2d vel);
void SetIframes(float duration);
void RestoreMana(int amt);
void ConsumeMana(int amt);
void AddBuff(BuffType type,float duration,float intensity);
std::vector<Buff>GetBuffs(BuffType buff);

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 1811
#define VERSION_BUILD 1814
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save