Added knockup status for players/monsters.

pull/30/head
sigonasr2 11 months ago
parent 3e2bd6feb6
commit b7ef0c8712
  1. 2
      Adventures in Lestoria/Chapter_1_Creatures_Part_2.txt
  2. 20
      Adventures in Lestoria/Monster.cpp
  3. 5
      Adventures in Lestoria/Monster.h
  4. 23
      Adventures in Lestoria/Player.cpp
  5. 5
      Adventures in Lestoria/Player.h
  6. 2
      Adventures in Lestoria/Version.h

@ -12,7 +12,7 @@ HP: 210
Atk: 45 Atk: 45
Move-Spd: 60% Move-Spd: 60%
Size: 200% Size: 200%
Strategie: Moves towards player. Once next to the Player character builds itself up and smashes the ground infront of him. 2 seconds time to dodge attack once it locks the area its attacking. Strategie: Moves towards player. Once next to the Player character builds itself up and smashes the ground infront of him. 2 seconds time to dodge attack once it locks the area its attacking. Knockup?
Frog Frog
HP: 60 HP: 60

@ -202,6 +202,20 @@ bool Monster::Update(float fElapsedTime){
size=std::min(targetSize,size+AiL::SIZE_CHANGE_SPEED*fElapsedTime); size=std::min(targetSize,size+AiL::SIZE_CHANGE_SPEED*fElapsedTime);
} }
} }
#pragma region Handle knockup timers
if(knockUpTimer>0.f){
knockUpTimer=std::max(0.f,knockUpTimer-fElapsedTime);
if(knockUpTimer==0.f){
totalKnockupTime=0.f;
knockUpZAmt=0.f;
SetZ(0.f);
}else{
SetZ(util::lerp(0.f,1.f,-(pow((knockUpTimer-totalKnockupTime/2)/(totalKnockupTime/2),2))+1)*knockUpZAmt);
}
}
#pragma endregion
if(IsAlive()){ if(IsAlive()){
for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){ for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){
Buff&b=*it; Buff&b=*it;
@ -598,4 +612,10 @@ geom2d::circle<float>Monster::Hitbox(){
void Monster::Knockback(const vf2d&vel){ void Monster::Knockback(const vf2d&vel){
this->vel+=vel; this->vel+=vel;
}
void Monster::Knockup(float duration){
knockUpTimer+=duration;
totalKnockupTime+=duration;
knockUpZAmt+=32*pow(duration,2);
} }

@ -175,6 +175,8 @@ public:
const EventName&GetDeathSound(); const EventName&GetDeathSound();
const EventName&GetWalkSound(); const EventName&GetWalkSound();
void Knockback(const vf2d&vel); void Knockback(const vf2d&vel);
//Knockup the player for duration amount of seconds, and Zamt pixels.
void Knockup(float duration);
private: private:
std::string name; std::string name;
vf2d pos; vf2d pos;
@ -225,6 +227,9 @@ private:
//Set monsterInvoked to false when you don't want a movement loop due to collisions. //Set monsterInvoked to false when you don't want a movement loop due to collisions.
//Typical usage is monsterInvoked is true on first call, and monsterInvoked is false on all subsequent chained calls. //Typical usage is monsterInvoked is true on first call, and monsterInvoked is false on all subsequent chained calls.
bool _SetY(float y,const bool monsterInvoked=true); bool _SetY(float y,const bool monsterInvoked=true);
float knockUpTimer=0.f;
float totalKnockupTime=0.f;
float knockUpZAmt=0.f;
private: private:
struct STRATEGY{ struct STRATEGY{

@ -621,6 +621,19 @@ void Player::Update(float fElapsedTime){
} }
} }
#pragma endregion #pragma endregion
#pragma region Handle knockup timers
if(knockUpTimer>0.f){
knockUpTimer=std::max(0.f,knockUpTimer-fElapsedTime);
if(knockUpTimer==0.f){
totalKnockupTime=0.f;
knockUpZAmt=0.f;
SetZ(0.f);
}else{
SetZ(util::lerp(0.f,1.f,-(pow((knockUpTimer-totalKnockupTime/2)/(totalKnockupTime/2),2))+1)*knockUpZAmt);
}
}
#pragma endregion
} }
float Player::GetSwordSwingTimer(){ float Player::GetSwordSwingTimer(){
@ -643,7 +656,7 @@ vf2d Player::GetVelocity(){
} }
bool Player::CanMove(){ bool Player::CanMove(){
return state!=State::ANIMATION_LOCK&&(state!=State::CASTING||(castInfo.castTotalTime-castInfo.castTimer>0.2f)); return knockUpTimer==0.f&&state!=State::ANIMATION_LOCK&&(state!=State::CASTING||(castInfo.castTotalTime-castInfo.castTimer>0.2f));
} }
bool Player::CanAct(){ bool Player::CanAct(){
@ -652,7 +665,7 @@ bool Player::CanAct(){
} }
bool Player::CanAct(Ability&ability){ bool Player::CanAct(Ability&ability){
return !ability.waitForRelease&&(ability.canCancelCast||state!=State::CASTING)&&state!=State::ANIMATION_LOCK&&GameState::STATE==GameState::states[States::GAME_RUN]; return knockUpTimer==0&&!ability.waitForRelease&&(ability.canCancelCast||state!=State::CASTING)&&state!=State::ANIMATION_LOCK&&GameState::STATE==GameState::states[States::GAME_RUN];
} }
bool Player::HasIframes(){ bool Player::HasIframes(){
@ -1226,4 +1239,10 @@ void EntityStats::Reset(){
geom2d::circle<float>Player::Hitbox(){ geom2d::circle<float>Player::Hitbox(){
return {GetPos(),12*GetSizeMult()/2}; return {GetPos(),12*GetSizeMult()/2};
}
void Player::Knockup(float duration){
knockUpTimer+=duration;
totalKnockupTime+=duration;
knockUpZAmt+=32*pow(duration,2);
} }

@ -236,6 +236,8 @@ public:
void ResetAccumulatedXP(); void ResetAccumulatedXP();
const uint32_t GetAccumulatedXP()const; const uint32_t GetAccumulatedXP()const;
void AddAccumulatedXP(const uint32_t xpGain); void AddAccumulatedXP(const uint32_t xpGain);
//Knockup the player for duration amount of seconds, and Zamt pixels.
void Knockup(float duration);
private: private:
int hp="Warrior.BaseHealth"_I; int hp="Warrior.BaseHealth"_I;
int mana="Player.BaseMana"_I; int mana="Player.BaseMana"_I;
@ -257,6 +259,9 @@ private:
float hpRecoveryTimer=0; float hpRecoveryTimer=0;
float hp6RecoveryTimer=0; float hp6RecoveryTimer=0;
float hp4RecoveryTimer=0; float hp4RecoveryTimer=0;
float knockUpTimer=0.f;
float totalKnockupTime=0.f;
float knockUpZAmt=0.f;
std::pair<std::string,float> notEnoughManaDisplay={"",0.f}; std::pair<std::string,float> notEnoughManaDisplay={"",0.f};
float teleportAttemptWaitTime=0; //If a teleport fails, we wait awhile before trying again, it's expensive. float teleportAttemptWaitTime=0; //If a teleport fails, we wait awhile before trying again, it's expensive.
State::State state=State::NORMAL; State::State state=State::NORMAL;

@ -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 5794 #define VERSION_BUILD 5799
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save