Refactor manual typing of HP Ratios with an HP Ratio function for the monster and player classes. Release Build 9524.

pull/57/head
sigonasr2 6 months ago
parent cfbd4dce97
commit 5918846fbd
  1. 2
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 11
      Adventures in Lestoria/Monster.cpp
  3. 2
      Adventures in Lestoria/Monster.h
  4. 12
      Adventures in Lestoria/Player.cpp
  5. 1
      Adventures in Lestoria/Player.h
  6. 6
      Adventures in Lestoria/SlimeKing.cpp
  7. 4
      Adventures in Lestoria/Ursule.cpp
  8. 2
      Adventures in Lestoria/Version.h
  9. 5
      Adventures in Lestoria/Zephy.cpp
  10. 9
      Adventures in Lestoria/assets/config/MonsterStrategies.txt
  11. BIN
      x64/Release/Adventures in Lestoria.exe

@ -1866,7 +1866,7 @@ void AiL::RenderHud(){
}
Pixel healthOutlineCol=BLACK;
if(player->GetHealth()/float(player->GetMaxHealth())<="Player.Health Warning Pct"_F/100.f){
if(player->GetHealthRatio()<="Player.Health Warning Pct"_F/100.f){
float runTimeAmt=fmod(GetRunTime(),"Player.Health Warning Flicker Time"_F*2);
if(runTimeAmt<"Player.Health Warning Flicker Time"_F){
healthOutlineCol="Player.Health Warning Outline Color"_Pixel;

@ -84,14 +84,9 @@ const vf2d&Monster::GetPos()const{
}
const int Monster::GetHealth()const{
return hp;
}
}
const int Monster::GetMaxHealth()const{
return stats.A_Read("Health");
}
const float Monster::GetRemainingHPPct()const{
return float(GetHealth())/GetMaxHealth();
}
int Monster::GetAttack(){
float mod_atk=float(stats.A("Attack"));
@ -1091,4 +1086,8 @@ const bool Monster::HasArrowIndicator()const{
const bool Monster::ReachedTargetPos(const float maxDistanceFromTarget)const{
return util::distance(GetPos(),GetTargetPos())<=maxDistanceFromTarget;
}
const float Monster::GetHealthRatio()const{
return GetHealth()/float(GetMaxHealth());
}

@ -79,7 +79,6 @@ public:
const vf2d&GetPos()const;
const int GetHealth()const;
const int GetMaxHealth()const;
const float GetRemainingHPPct()const;
int GetAttack();
float GetMoveSpdMult();
//Obtains the size multiplier (from 0.f-1.f).
@ -180,6 +179,7 @@ public:
const std::string_view GetDisplayName()const;
const bool HasArrowIndicator()const;
const bool ReachedTargetPos(const float maxDistanceFromTarget=4.f)const;
const float GetHealthRatio()const;
private:
//NOTE: Marking a monster for deletion does not trigger any death events. It just simply removes the monster from the field!!
// The way this works is that monsters marked for deletion will cause the monster update loop to detect there's at least one or more monsters that must be deleted and will call erase_if on the list at the end of the iteration loop.

@ -809,7 +809,7 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z){
hurtRumbleTime="Player.Hurt Rumble Time"_F;
Input::StartVibration();
Input::SetLightbar(PixelLerp(DARK_RED,GREEN,GetHealth()/float(GetMaxHealth())));
Input::SetLightbar(PixelLerp(DARK_RED,GREEN,GetHealthRatio()));
if(lastHitTimer>0){
damageNumberPtr.get()->damage+=int(mod_dmg);
@ -821,7 +821,7 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z){
}
lastHitTimer=0.05f;
if(!lowHealthSoundPlayed&&lowHealthSoundPlayedTimer==0.f&&GetHealth()/float(GetMaxHealth())<="Player.Health Warning Pct"_F/100.f){
if(!lowHealthSoundPlayed&&lowHealthSoundPlayedTimer==0.f&&GetHealthRatio()<="Player.Health Warning Pct"_F/100.f){
SoundEffect::PlaySFX("Health Warning",SoundEffect::CENTERED);
lowHealthSoundPlayed=true;
lowHealthSoundPlayedTimer="Player.Health Warning Cooldown"_F;
@ -1088,7 +1088,7 @@ bool Player::Heal(int damage,bool suppressDamageNumber){
if(!suppressDamageNumber&&damage>0){
DAMAGENUMBER_LIST.push_back(std::make_shared<DamageNumber>(GetPos(),damage,true,HEALTH_GAIN));
}
Input::SetLightbar(PixelLerp(DARK_RED,GREEN,GetHealth()/float(GetMaxHealth())));
Input::SetLightbar(PixelLerp(DARK_RED,GREEN,GetHealthRatio()));
return true;
}
@ -1358,7 +1358,7 @@ void Player::PerformHPRecovery(){
Heal(hpRecoveryAmt);
}
if(GetHealth()/float(GetMaxHealth())>"Player.Health Warning Pct"_F/100.f){
if(GetHealthRatio()>"Player.Health Warning Pct"_F/100.f){
lowHealthSoundPlayed=false;
}
}
@ -1584,4 +1584,8 @@ void Player::ProximityKnockback(const vf2d centerPoint,const float knockbackFact
void Player::AddVelocity(vf2d vel){
this->vel+=vel*game->GetElapsedTime();
}
const float Player::GetHealthRatio()const{
return GetHealth()/float(GetMaxHealth());
}

@ -264,6 +264,7 @@ public:
const float GetIframeTime()const;
const Renderable&GetMinimapImage()const;
void AddVelocity(vf2d vel);
const float GetHealthRatio()const;
private:
int hp="Warrior.BaseHealth"_I;
int mana="Player.BaseMana"_I;

@ -253,7 +253,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat
m.phase=ConfigInt("StartPhase");
}break;
case 1:{
if(m.GetRemainingHPPct()<=ConfigFloat("Phase2.Change")/100.f){
if(m.GetHealthRatio()<=ConfigFloat("Phase2.Change")/100.f){
m.phase=2;
m.SetSize(ConfigFloat("Phase2.Size")/100,false);
TransitionPhase(m.phase);
@ -286,7 +286,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat
}
}break;
case 2:{
if(m.GetRemainingHPPct()<=ConfigFloat("Phase3.Change")/100.f){
if(m.GetHealthRatio()<=ConfigFloat("Phase3.Change")/100.f){
m.phase=3;
m.SetSize(ConfigFloat("Phase3.Size")/100,false);
if(m.I(A::PATTERN_REPEAT_COUNT)==0){
@ -314,7 +314,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat
}
}break;
case 3:{
if(m.GetRemainingHPPct()<=ConfigFloat("Phase4.Change")/100.f){
if(m.GetHealthRatio()<=ConfigFloat("Phase4.Change")/100.f){
m.phase=4;
m.SetSize(ConfigFloat("Phase4.Size")/100,false);
m.AddBuff(BuffType::SLOWDOWN,99999,ConfigFloat("Phase4.MoveSpdModifier")/100);

@ -104,7 +104,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
m.I(A::ENVIRONMENT_PHASE)=0;
};
if(m.GetRemainingHPPct()<=ConfigFloat("Phase 2.Change")/100.f){
if(m.GetHealthRatio()<=ConfigFloat("Phase 2.Change")/100.f){
//before moving to Phase 2, we need to make sure we're in Phase 0 of the bear AI.
if(m.overlaySpriteTransparency<210U){
if(m.I(A::PHASE)!=0)goto bear;
@ -269,7 +269,7 @@ void Monster::STRATEGY::URSULE(Monster&m,float fElapsedTime,std::string strategy
if(m.I(A::PHASE)!=0)goto bear2; //Prevent doing anything else if a part of bear AI is still running.
if(m.GetRemainingHPPct()<=ConfigFloat("Phase 4.Change")/100.f){
if(m.GetHealthRatio()<=ConfigFloat("Phase 4.Change")/100.f){
auto TransitionToPhase5=[&](){
m.phase=5;
m.PerformAnimation("SIT");

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 3
#define VERSION_BUILD 9522
#define VERSION_BUILD 9524
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -95,6 +95,11 @@ void Monster::STRATEGY::ZEPHY(Monster&m,float fElapsedTime,std::string strategy)
game->GetOverlay().Disable();
return true;
});
if(m.GetHealthRatio()<=ConfigFloat("Mid Phase Health Transition %")/100.f&&!m.B(A::PHASE)){
m.B(A::PHASE)=true;
m.phase=HALFHEALTH_PHASE;
}
}break;
case IDLE:{
const int randomAttackChoice=2;

@ -785,6 +785,8 @@ MonsterStrategy
Flight Oscillation Amount = 1.5px
Mid Phase Health Transition % = 50%
Fly Across Attack
{
Poop Damage = 25
@ -859,5 +861,12 @@ MonsterStrategy
Wind Streak Y Speed Range = -16px/s, 16px/s
Wind Streak Lifetime Range = 2s, 8s
}
Mid Phase
{
# The boss will go land at this position first.
Pillar Position = 2040, 1488
}
}
}
Loading…
Cancel
Save