very silly and simple boss immunity system

This commit is contained in:
laochailan 2018-08-11 15:16:22 +02:00
parent a9048d22b1
commit 157a59dbbd
No known key found for this signature in database
GPG key ID: 49BE98017AFBC943
2 changed files with 25 additions and 2 deletions

View file

@ -39,6 +39,12 @@ Boss* create_boss(char *name, char *ani, char *dialog, complex pos) {
buf->ent.damage_func = ent_damage_boss;
ent_register(&buf->ent, ENT_BOSS);
// This is not necessary because the default will be set at the start of every attack.
// But who knows. Maybe this will be triggered somewhen. If bosses without attacks start
// taking over the world, I will be the one who put in this weak point to make them vulnerable.
buf->bomb_damage_multiplier = 1.0;
buf->shot_damage_multiplier = 1.0;
return buf;
}
@ -461,7 +467,13 @@ bool boss_is_vulnerable(Boss *boss) {
static DamageResult ent_damage_boss(EntityInterface *ent, const DamageInfo *dmg) {
Boss *boss = ENT_CAST(ent, Boss);
if(!boss_is_vulnerable(boss) || dmg->type == DMG_ENEMY_SHOT || dmg->type == DMG_ENEMY_COLLISION) {
float factor = 1.0;
if(dmg->type == DMG_PLAYER_SHOT)
factor = boss->shot_damage_multiplier;
if(dmg->type == DMG_PLAYER_BOMB)
factor = boss->bomb_damage_multiplier;
if(!boss_is_vulnerable(boss) || dmg->type == DMG_ENEMY_SHOT || dmg->type == DMG_ENEMY_COLLISION || factor == 0) {
return DMG_RESULT_IMMUNE;
}
@ -469,7 +481,7 @@ static DamageResult ent_damage_boss(EntityInterface *ent, const DamageInfo *dmg)
boss->lastdamageframe = global.frames;
}
boss->current->hp -= dmg->amount;
boss->current->hp -= dmg->amount*factor;
if(boss->current->hp < boss->current->maxhp * 0.1) {
play_loop("hit1");
@ -855,6 +867,10 @@ void boss_start_attack(Boss *b, Attack *a) {
}
}
// This should go before a->rule(b,EVENT_BIRTH), so it doesnt reset values set by the attack rule.
b->bomb_damage_multiplier = 1.0;
b->shot_damage_multiplier = 1.0;
a->starttime = global.frames + (a->type == AT_ExtraSpell? ATTACK_START_DELAY_EXTRA : ATTACK_START_DELAY);
a->rule(b, EVENT_BIRTH);
if(ATTACK_IS_SPELL(a->type)) {

View file

@ -120,6 +120,13 @@ typedef struct Boss {
int birthtime;
BossRule global_rule;
// These are publicly accessible damage multipliers *you* can use to buff your spells.
// Just change the numbers. global.shake_view style. 1.0 is the default.
// If a new attack starts, they are reset. Nothing can go wrong!
float bomb_damage_multiplier;
float shot_damage_multiplier;
} Boss;
Boss* create_boss(char *name, char *ani, char *dialog, complex pos) attr_nonnull(1, 2) attr_returns_nonnull;