Frog tongue should only hit each entity one time.

This commit is contained in:
sigonasr2 2024-01-12 12:32:47 -06:00
parent 20e452b337
commit b97afb24bd
5 changed files with 9 additions and 7 deletions

View File

@ -614,7 +614,7 @@ void AiL::UpdateBullets(float fElapsedTime){
return false; return false;
} }
} }
b->hitList[&m]=true; b->hitList.insert(&m);
} }
} }
} }

View File

@ -67,7 +67,7 @@ private:
public: public:
Animate2D::Animation<std::string>animation; Animate2D::Animation<std::string>animation;
Animate2D::AnimationState internal_animState; Animate2D::AnimationState internal_animState;
std::map<Monster*,bool>hitList; std::set<Monster*>hitList;
virtual ~Bullet()=default; virtual ~Bullet()=default;
Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1}); Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1});
//Initializes a bullet with an animation. //Initializes a bullet with an animation.

View File

@ -63,20 +63,22 @@ void FrogTongue::Update(float fElapsedTime){
} }
if(friendly){ if(friendly){
for(Monster&m:MONSTER_LIST){ for(Monster&m:MONSTER_LIST){
if(geom2d::overlaps(m.Hitbox(),tongueLine)){ if(hitList.find(&m)==hitList.end()&&geom2d::overlaps(m.Hitbox(),tongueLine)){
MonsterHit(m); MonsterHit(m);
hitList.insert(&m);
} }
} }
} }
} }
bool FrogTongue::PlayerHit(Player*player){ bool FrogTongue::PlayerHit(Player*player){
if(!deactivated){
player->Hurt(damage,OnUpperLevel(),0); player->Hurt(damage,OnUpperLevel(),0);
deactivated=true; deactivated=true;
}
return false; return false;
} }
bool FrogTongue::MonsterHit(Monster&monster){ bool FrogTongue::MonsterHit(Monster&monster){
monster.Hurt(damage,OnUpperLevel(),0); monster.Hurt(damage,OnUpperLevel(),0);
deactivated=true;
return false; return false;
} }
void FrogTongue::Draw(){ void FrogTongue::Draw(){

View File

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