Add a proximity knockback overload function that handles hurt list target types instead. Make large stone toss knockback only apply to targets actually hit. Release Build 9837.

This commit is contained in:
sigonasr2 2024-06-25 03:11:56 -05:00
parent d8c2c615dc
commit afff03e201
7 changed files with 28 additions and 5 deletions

View File

@ -794,6 +794,22 @@ void AiL::ProximityKnockback(const vf2d pos,const float radius,const float knock
} }
} }
void AiL::ProximityKnockback(const vf2d pos,const float radius,const float knockbackAmt,const HurtList&knockbackTargets,const KnockbackCondition condition)const{
using enum KnockbackCondition;
for(auto&[target,wasHurt]:knockbackTargets){
if(condition==KNOCKBACK_HURT_TARGETS&&!wasHurt||
condition==KNOCKBACK_UNHURT_TARGETS&&wasHurt)continue;
if(std::holds_alternative<Player*>(target)){
Player*player{std::get<Player*>(target)};
player->ProximityKnockback(pos,knockbackAmt);
}else
if(std::holds_alternative<Monster*>(target)){
Monster*monster{std::get<Monster*>(target)};
monster->ProximityKnockback(pos,knockbackAmt);
}else ERR("WARNING! Target list was holding an unknown type??? THIS SHOULD NOT BE HAPPENING!")
}
}
const HurtList AiL::HurtNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z,const HurtType hurtTargets)const{ const HurtList AiL::HurtNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z,const HurtType hurtTargets)const{
HurtList affectedList; HurtList affectedList;
const bool CheckForMonsterCollisions=hurtTargets&HurtType::MONSTER; const bool CheckForMonsterCollisions=hurtTargets&HurtType::MONSTER;

View File

@ -75,6 +75,12 @@ enum class HurtType{
MONSTER=0b10, MONSTER=0b10,
}; };
enum class KnockbackCondition{
KNOCKBACK_HURT_TARGETS, //Knockback only targets that took damage.
KNOCKBACK_ALL_TARGETS, //Knockback all targets, even if they were invulnerable or immovable.
KNOCKBACK_UNHURT_TARGETS, //Knockback only targets that did not get hit.
};
namespace PlayerTests{ namespace PlayerTests{
class PlayerTest; class PlayerTest;
} }
@ -246,6 +252,7 @@ public:
void AddEffect(std::unique_ptr<Effect>foreground,bool back=false); void AddEffect(std::unique_ptr<Effect>foreground,bool back=false);
const HurtList Hurt(vf2d pos,float radius,int damage,bool upperLevel,float z,const HurtType hurtTargets)const; const HurtList Hurt(vf2d pos,float radius,int damage,bool upperLevel,float z,const HurtType hurtTargets)const;
void ProximityKnockback(const vf2d pos,const float radius,const float knockbackAmt,const HurtType knockbackTargets)const; void ProximityKnockback(const vf2d pos,const float radius,const float knockbackAmt,const HurtType knockbackTargets)const;
void ProximityKnockback(const vf2d pos,const float radius,const float knockbackAmt,const HurtList&knockbackTargets,const KnockbackCondition condition=KnockbackCondition::KNOCKBACK_HURT_TARGETS)const;
//NOTE: This function will also add any enemies that were hit into the hit list! //NOTE: This function will also add any enemies that were hit into the hit list!
const HurtList HurtNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z,const HurtType hurtTargets)const; const HurtList HurtNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z,const HurtType hurtTargets)const;
// angle: The central angle where the arc will extend from. // angle: The central angle where the arc will extend from.

View File

@ -74,7 +74,7 @@ void LargeStone::Update(float fElapsedTime){
monsterPtr->_DealTrueDamage(3); monsterPtr->_DealTrueDamage(3);
} }
game->ProximityKnockback(pos,radius,knockbackAmt,HurtType::MONSTER|HurtType::PLAYER); game->ProximityKnockback(pos,radius,knockbackAmt,list);
fadeOutTime=0.5f; fadeOutTime=0.5f;

View File

@ -932,7 +932,7 @@ geom2d::circle<float>Monster::BulletCollisionHitbox(){
} }
void Monster::Knockback(const vf2d&vel){ void Monster::Knockback(const vf2d&vel){
if(IsSolid()||GetZ()>=1.f)return; if(IsSolid())return;
//A new angle will be applied, but will be constrained by whichever applied velocity is strongest (either the current velocity, or the new one). This prevents continuous uncapped velocities to knockbacks applied. //A new angle will be applied, but will be constrained by whichever applied velocity is strongest (either the current velocity, or the new one). This prevents continuous uncapped velocities to knockbacks applied.
if(vel==vf2d{})return; if(vel==vf2d{})return;
float maxVelThreshold; float maxVelThreshold;

View File

@ -307,7 +307,7 @@ State::State Player::GetState(){
void Player::Knockback(vf2d vel){ void Player::Knockback(vf2d vel){
//A new angle will be applied, but will be constrained by whichever applied velocity is strongest (either the current velocity, or the new one). This prevents continuous uncapped velocities to knockbacks applied. //A new angle will be applied, but will be constrained by whichever applied velocity is strongest (either the current velocity, or the new one). This prevents continuous uncapped velocities to knockbacks applied.
if(vel==vf2d{}||GetZ()>=1.f)return; if(vel==vf2d{})return;
float maxVelThreshold; float maxVelThreshold;
if(GetState()==State::BLOCK)vel*=1-("Warrior.Right Click Ability.Knockback Reduction"_I/100.f); if(GetState()==State::BLOCK)vel*=1-("Warrior.Right Click Ability.Knockback Reduction"_I/100.f);
if(this->vel==vf2d{})maxVelThreshold=vel.mag(); if(this->vel==vf2d{})maxVelThreshold=vel.mag();

View File

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