Fix bug with multi-target bullets fading out upon hitting a single target. Reduce default fade time of bullets from 0.25 seconds to 0.1 seconds. Release Build 10024.

This commit is contained in:
sigonasr2 2024-07-15 04:20:55 -05:00
parent 421ba4bc4a
commit ed5ab319de
7 changed files with 16 additions and 10 deletions

View File

@ -59,8 +59,7 @@ Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,std::string animation,b
Animate2D::Frame Bullet::GetFrame()const{
return animation.GetFrame(internal_animState);
}
void Bullet::UpdateFadeTime(float fElapsedTime)
{
void Bullet::UpdateFadeTime(float fElapsedTime){
aliveTime+=fElapsedTime;
if(fadeInTime>0){
if(fadeInTimer<fadeInTime){
@ -129,19 +128,22 @@ void Bullet::_Update(const float fElapsedTime){
while(iterations>0){
iterations--;
if(IsPlayerAutoAttackProjectile()){pos+=(game->GetWindSpeed()*game->GetElapsedTime())/float(totalIterations);}
pos+=(vel*fElapsedTime)/float(totalIterations);
if(!CollisionCheck()){
return;
goto DeadBulletCheck;
}
}
pos=finalBulletPos;
if(!CollisionCheck()){
return;
goto DeadBulletCheck;
}
}else{
if(IsPlayerAutoAttackProjectile()){pos+=game->GetWindSpeed()*game->GetElapsedTime();}
pos+=vel*fElapsedTime;
}
if(IsPlayerAutoAttackProjectile()){pos+=game->GetWindSpeed()*game->GetElapsedTime();}
DeadBulletCheck:
if(/*World size in PIXELS!*/vi2d worldSize=game->GetCurrentMapData().MapSize*game->GetCurrentMapData().TileSize;pos.x+radius<-WINDOW_SIZE.x||pos.x-radius>worldSize.x+WINDOW_SIZE.x||pos.y+radius<-WINDOW_SIZE.y||pos.y-radius>worldSize.y+WINDOW_SIZE.y){
dead=true;
return;
@ -194,11 +196,11 @@ BulletDestroyState Bullet::_MonsterHit(Monster&monster){
return destroyBullet;
}
BulletDestroyState Bullet::PlayerHit(Player*player){
fadeOutTime=0.25f;
if(!hitsMultiple)fadeOutTime=0.1f;
return BulletDestroyState::KEEP_ALIVE;
}
BulletDestroyState Bullet::MonsterHit(Monster&monster){
fadeOutTime=0.25f;
if(!hitsMultiple)fadeOutTime=0.1f;
return BulletDestroyState::KEEP_ALIVE;
}
bool Bullet::OnUpperLevel(){return upperLevel;}

View File

@ -63,7 +63,7 @@ struct Bullet{
bool hitsMultiple=false;
bool rotates=false;
bool animated=false;
float fadeOutTime=0; //Setting the fade out time causes the bullet's lifetime to be set to the fadeout time as well, as that's when the bullet's alpha will reach 0, so it dies.
float fadeOutTime=0.f; //Setting the fade out time causes the bullet's lifetime to be set to the fadeout time as well, as that's when the bullet's alpha will reach 0, so it dies.
bool friendly=false; //Whether or not it's a player bullet or enemy bullet.
bool upperLevel=false;
bool alwaysOnTop=false;

View File

@ -89,10 +89,12 @@ void DaggerSlash::Update(float fElapsedTime){
BulletDestroyState DaggerSlash::PlayerHit(Player*player){
game->AddEffect(std::make_unique<Effect>(pos,0,"lightning_splash_effect.png",upperLevel,player->GetSizeMult()*0.25f,0.25,vf2d{}));
player->Knockback(util::pointTo(sourceMonster.GetPos(),player->GetPos())*knockbackAmt);
Deactivate();
return BulletDestroyState::KEEP_ALIVE;
}
BulletDestroyState DaggerSlash::MonsterHit(Monster&monster){
game->AddEffect(std::make_unique<Effect>(pos,0,"lightning_splash_effect.png",upperLevel,monster.GetSizeMult()*0.25f,0.25,vf2d{}));
monster.Knockback(util::pointTo(sourceMonster.GetPos(),monster.GetPos())*knockbackAmt);
Deactivate();
return BulletDestroyState::KEEP_ALIVE;
}

View File

@ -95,10 +95,12 @@ void DaggerStab::Update(float fElapsedTime){
BulletDestroyState DaggerStab::PlayerHit(Player*player){
game->AddEffect(std::make_unique<Effect>(pos,0,"lightning_splash_effect.png",upperLevel,player->GetSizeMult()*0.25f,0.25,vf2d{}));
player->Knockback(util::pointTo(sourceMonster.GetPos(),player->GetPos())*knockbackAmt);
Deactivate();
return BulletDestroyState::KEEP_ALIVE;
}
BulletDestroyState DaggerStab::MonsterHit(Monster&monster){
game->AddEffect(std::make_unique<Effect>(pos,0,"lightning_splash_effect.png",upperLevel,monster.GetSizeMult()*0.25f,0.25,vf2d{}));
monster.Knockback(util::pointTo(sourceMonster.GetPos(),monster.GetPos())*knockbackAmt);
Deactivate();
return BulletDestroyState::KEEP_ALIVE;
}

View File

@ -50,7 +50,7 @@ enum class EffectType{
struct Effect{
friend class AiL;
friend class FallingStone;
friend struct FallingStone;
vf2d pos={0,0};
float lifetime=0;
float fadeout=0;

View File

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