trigger sounds on low hp only
This commit is contained in:
parent
f05e094c17
commit
e1805c07e6
6 changed files with 15 additions and 3 deletions
BIN
resources/sfx/hit0.ogg
Normal file
BIN
resources/sfx/hit0.ogg
Normal file
Binary file not shown.
BIN
resources/sfx/hit1.ogg
Normal file
BIN
resources/sfx/hit1.ogg
Normal file
Binary file not shown.
|
@ -31,3 +31,5 @@ extra_bomb = 60
|
|||
noise1 = 70
|
||||
warp = 80
|
||||
damage_feedback = 120
|
||||
hit0=120
|
||||
hit1=120
|
||||
|
|
|
@ -446,7 +446,11 @@ bool boss_damage(Boss *boss, int dmg) {
|
|||
}
|
||||
|
||||
boss->current->hp -= dmg;
|
||||
play_loop("damage_feedback");
|
||||
if(boss->current->hp < boss->current->maxhp*0.1) {
|
||||
play_loop("hit0");
|
||||
} else if(boss->current->hp < boss->current->maxhp*0.3) {
|
||||
play_loop("hit1");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ Enemy *create_enemy_p(EnemyList *enemies, complex pos, int hp, EnemyVisualRule v
|
|||
e->pos0 = pos;
|
||||
e->pos0_visual = pos;
|
||||
|
||||
e->spawn_hp = hp;
|
||||
e->hp = hp;
|
||||
e->alpha = 1.0;
|
||||
|
||||
|
@ -314,11 +315,15 @@ bool enemy_damage(Enemy *enemy, int damage) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if((enemy->hp -= damage) <= 0) {
|
||||
enemy->hp -= damage;
|
||||
|
||||
if(enemy->hp <= 0) {
|
||||
enemy->hp = ENEMY_KILLED;
|
||||
}
|
||||
|
||||
play_loop("damage_feedback");
|
||||
if(enemy->hp < enemy->spawn_hp*0.3) {
|
||||
play_loop("hit1");
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
|
|
@ -44,6 +44,7 @@ struct Enemy {
|
|||
EnemyLogicRule logic_rule;
|
||||
EnemyVisualRule visual_rule;
|
||||
|
||||
int spawn_hp;
|
||||
int hp;
|
||||
|
||||
complex args[RULE_ARGC];
|
||||
|
|
Loading…
Reference in a new issue