Merge branch 'master' into rebalance

This commit is contained in:
Andrei "Akari" Alexeyev 2017-04-06 01:46:28 +03:00
commit f2f13af804
8 changed files with 51 additions and 34 deletions

View file

@ -184,14 +184,6 @@ void boss_rule_extra(Boss *boss, float alpha) {
}
}
void boss_kill_projectiles(void) {
Projectile *p;
for(p = global.projs; p; p = p->next)
if(p->type == FairyProj)
p->type = DeadProj;
delete_lasers();
}
bool boss_is_dying(Boss *boss) {
return boss->current && boss->current->endtime && boss->current->type != AT_Move && boss->current - boss->attacks >= boss->acount-1;
}
@ -259,7 +251,7 @@ void boss_finish_current_attack(Boss *boss) {
boss->current->finished = true;
boss->current->rule(boss, EVENT_DEATH);
boss_kill_projectiles();
stage_clear_hazards(true);
AttackType t = boss->current->type;
if(t == AT_Spellcard || t == AT_ExtraSpell || t == AT_SurvivalSpell) {
@ -371,7 +363,7 @@ void boss_death(Boss **boss) {
free_boss(*boss);
*boss = NULL;
boss_kill_projectiles();
stage_clear_hazards(true);
}
void free_boss(Boss *boss) {
@ -417,12 +409,7 @@ void start_attack(Boss *b, Attack *a) {
}
}
Projectile *p;
for(p = global.projs; p; p = p->next)
if(p->type == FairyProj)
p->type = DeadProj;
delete_lasers();
stage_clear_hazards(true);
}
Attack* boss_add_attack(Boss *boss, AttackType type, char *name, float timeout, int hp, BossRule rule, BossRule draw_rule) {

View file

@ -32,6 +32,7 @@ Laser *create_laser(complex pos, float time, float deathtime, Color color, Laser
l->speed = 1;
l->timeshift = 0;
l->in_background = false;
l->dead = false;
if(l->lrule)
l->lrule(l, EVENT_BIRTH);
@ -176,17 +177,39 @@ void process_lasers(void) {
Laser *laser = global.lasers, *del = NULL;
while(laser != NULL) {
if(collision_laser_curve(laser))
player_death(&global.plr);
if(laser->dead) {
laser->timespan *= 0.93;
bool kill_now = laser->timespan < 5;
if(laser->lrule)
laser->lrule(laser, global.frames - laser->birthtime);
if(!((global.frames - laser->birthtime) % 24) || kill_now) {
complex p = laser->prule(laser, global.frames - laser->birthtime)*laser->speed + laser->timeshift;
double x = creal(p);
double y = cimag(p);
if(x > 0 && x < VIEWPORT_W && y > 0 && y < VIEWPORT_H) {
create_particle1c("flare", p, 0, Fade, timeout, 30);
create_item(p, 0, BPoint)->auto_collect = 10;
}
if(kill_now) {
create_particle1c("flare", p, 0, GrowFade, timeout, 20);
laser->deathtime = 0;
}
}
} else {
if(collision_laser_curve(laser)) {
player_death(&global.plr);
}
if(laser->lrule) {
laser->lrule(laser, global.frames - laser->birthtime);
}
}
if(global.frames - laser->birthtime > laser->deathtime + laser->timespan*laser->speed) {
del = laser;
laser = laser->next;
_delete_laser((void **)&global.lasers, del);
if(laser == NULL) break;
} else {
laser = laser->next;
}

View file

@ -44,6 +44,9 @@ struct Laser {
int in_background;
complex args[4];
bool unclearable;
bool dead;
};
#define create_lasercurve1c(p, time, deathtime, clr, rule, a0) create_laser(p, time, deathtime, clr, rule, 0, a0, 0, 0, 0)

View file

@ -48,11 +48,7 @@ Animation *player_get_ani(Character cha) {
static void player_full_power(Player *plr) {
play_sound("full_power");
Projectile *p;
for(p = global.projs; p; p = p->next)
if(p->type < PlrProj)
p->type = DeadProj;
stage_clear_hazards(false);
}
void player_set_power(Player *plr, short npow) {
@ -194,17 +190,13 @@ void player_logic(Player* plr) {
if(!en->unbombable && en->hp > ENEMY_IMMUNE)
en->hp -= 300;
Projectile *p;
for(p = global.projs; p; p = p->next)
if(p->type < PlrProj)
p->type = DeadProj;
if(global.boss && global.boss->current) {
AttackType at = global.boss->current->type;
if(at != AT_Move && at != AT_SurvivalSpell)
global.boss->dmg += 30;
}
stage_clear_hazards(false);
player_fail_spell(plr);
}
}

View file

@ -835,6 +835,18 @@ static void stage_logic(void) {
}
}
void stage_clear_hazards(bool force) {
for(Projectile *p = global.projs; p; p = p->next) {
if(p->type == FairyProj)
p->type = DeadProj;
}
for(Laser *l = global.lasers; l; l = l->next) {
if(!l->unclearable || force)
l->dead = true;
}
}
static void stage_free(void) {
delete_enemies(&global.enemies);
delete_items();

View file

@ -106,6 +106,8 @@ void draw_hud(void);
void stage_pause(void);
void stage_gameover(void);
void stage_clear_hazards(bool force);
#include "stages/stage1.h"
#include "stages/stage2.h"
#include "stages/stage3.h"

View file

@ -276,9 +276,6 @@ void stage3_mid_intro(Boss *boss, int time) {
void stage3_mid_outro(Boss *boss, int time) {
if(time == 0) {
spawn_items(boss->pos, Point, 10, Power, 10, Life, 1, NULL);
Projectile *p;
for(p = global.projs; p; p = p->next)
p->type = DeadProj;
}
boss->pos += pow(max(0, time)/30.0, 2) * cexp(I*(3*M_PI/2 + 0.5 * sin(time / 20.0)));

View file

@ -379,6 +379,7 @@ void elly_frequency2(Boss *b, int t) {
complex maxwell_laser(Laser *l, float t) {
if(t == EVENT_BIRTH) {
l->unclearable = true;
l->shader = get_shader("laser_maxwell");
return 0;
}