@ -43,6 +43,7 @@ All rights reserved.
INCLUDE_DATA
INCLUDE_DATA
INCLUDE_ANIMATION_DATA
INCLUDE_ANIMATION_DATA
INCLUDE_MONSTER_LIST
INCLUDE_game
INCLUDE_game
Bomb : : Bomb ( const vf2d pos , const float z , const float gravity , const float detonationTime , const float bombFadeoutTime , const float bombKnockbackFactor , const vf2d targetPos , const float radius , const int damage , const bool upperLevel , const bool friendly , const Pixel col , const vf2d scale )
Bomb : : Bomb ( const vf2d pos , const float z , const float gravity , const float detonationTime , const float bombFadeoutTime , const float bombKnockbackFactor , const vf2d targetPos , const float radius , const int damage , const bool upperLevel , const bool friendly , const Pixel col , const vf2d scale )
@ -65,19 +66,28 @@ void Bomb::Update(float fElapsedTime){
if ( fadeOutTime = = 0.f ) {
if ( fadeOutTime = = 0.f ) {
z = 0 ; //Force the bomb to be grounded.
z = 0 ; //Force the bomb to be grounded.
fadeOutTime = bombFadeoutTime ;
fadeOutTime = bombFadeoutTime ;
game - > AddEffect ( std : : make_unique < BombBoom > ( pos , 0.f , OnUpperLevel ( ) , scale * 1.5f /*Upscale 24x24 to 36x36*/ , 1.f , vf2d { } , WHITE , 0.f , 0.f , true ) ) ;
game - > AddEffect ( std : : make_unique < BombBoom > ( pos , 0.f , OnUpperLevel ( ) , vf2d { radius , radius } / 12.f / 1.5f /*Upscale 24x24 to 36x36*/ , 1.f , vf2d { } , WHITE , 0.f , 0.f , true ) ) ;
float distToPlayer = geom2d : : line < float > ( pos , game - > GetPlayer ( ) - > GetPos ( ) ) . length ( ) ;
if ( friendly ) {
if ( friendly ) {
const MonsterHurtList hurtEnemies = game - > HurtEnemies ( pos , radius , damage , OnUpperLevel ( ) , z ) ;
const MonsterHurtList hurtEnemies = game - > HurtEnemies ( pos , radius , damage , OnUpperLevel ( ) , z ) ;
for ( auto & [ monsterPtr , wasHit ] : hurtEnemies ) {
for ( auto & [ monsterPtr , wasHit ] : hurtEnemies ) {
if ( wasHit ) monsterPtr - > ProximityKnockback ( pos , bombKnockbackFactor ) ;
if ( wasHit ) monsterPtr - > ProximityKnockback ( pos , bombKnockbackFactor ) ;
}
}
if ( distToPlayer < = radius ) {
game - > GetPlayer ( ) - > ProximityKnockback ( pos , bombKnockbackFactor ) ;
}
} else {
} else {
float distToPlayer = geom2d : : line < float > ( pos , game - > GetPlayer ( ) - > GetPos ( ) ) . length ( ) ;
if ( distToPlayer < = radius ) {
if ( distToPlayer < = radius ) {
if ( game - > GetPlayer ( ) - > Hurt ( damage , OnUpperLevel ( ) , z ) ) {
if ( game - > GetPlayer ( ) - > Hurt ( damage , OnUpperLevel ( ) , z ) ) {
game - > GetPlayer ( ) - > ProximityKnockback ( pos , bombKnockbackFactor ) ;
game - > GetPlayer ( ) - > ProximityKnockback ( pos , bombKnockbackFactor ) ;
}
}
}
}
for ( auto & monsterPtr : MONSTER_LIST ) {
float distToMonster = geom2d : : line < float > ( pos , monsterPtr - > GetPos ( ) ) . length ( ) ;
if ( distToMonster < = radius ) {
monsterPtr - > ProximityKnockback ( pos , bombKnockbackFactor ) ;
}
}
}
}
}
}
}
}