2022-02-07 20:41:39 +01:00
|
|
|
#include <gint/defs/util.h>
|
2022-02-05 14:38:26 +01:00
|
|
|
#include "skills.h"
|
|
|
|
#include "comp/fighter.h"
|
|
|
|
#include "comp/physical.h"
|
|
|
|
#include "comp/visible.h"
|
|
|
|
#include "enemies.h"
|
|
|
|
#include "aoe.h"
|
|
|
|
|
|
|
|
fixed_t skill_cooldown(int skill)
|
|
|
|
{
|
|
|
|
if(skill == SKILL_DASH)
|
|
|
|
return fix(1.0);
|
|
|
|
else if(skill == AOE_PROJECTILE)
|
|
|
|
return fix(2.0);
|
|
|
|
else if(skill == AOE_SHOCK)
|
|
|
|
return fix(4.0);
|
|
|
|
else if(skill == AOE_JUDGEMENT)
|
|
|
|
return fix(3.0);
|
|
|
|
else if(skill == AOE_BULLET)
|
|
|
|
return fix(4.0);
|
|
|
|
|
|
|
|
return fix(0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void skill_use(game_t *game, entity_t *e, int slot, vec2 dir)
|
|
|
|
{
|
|
|
|
fighter_t *f = getcomp(e, fighter);
|
|
|
|
int skill = f->skills[slot];
|
|
|
|
|
|
|
|
if(skill < 0 || f->actions_cooldown[slot] > 0)
|
|
|
|
return;
|
|
|
|
f->actions_cooldown[slot] = skill_cooldown(skill);
|
|
|
|
|
2022-03-19 18:14:00 +01:00
|
|
|
if(skill == SKILL_DASH) {
|
|
|
|
mechanical_dash(e, frdir(dir));
|
|
|
|
}
|
|
|
|
else if(skill == AOE_PROJECTILE) {
|
|
|
|
if(f->current_attack)
|
|
|
|
return;
|
2022-02-05 14:38:26 +01:00
|
|
|
entity_t *aoe = aoe_make_attack(AOE_PROJECTILE, e, dir);
|
|
|
|
game_add_entity(game, aoe);
|
|
|
|
|
2022-02-08 22:48:08 +01:00
|
|
|
if(!f->enemy)
|
2022-02-05 14:38:26 +01:00
|
|
|
visible_set_anim(e, &anims_player_Attack, 2);
|
|
|
|
else
|
2022-02-08 22:48:08 +01:00
|
|
|
visible_set_anim(e, f->enemy->id->anim_attack, 2);
|
2022-02-05 14:38:26 +01:00
|
|
|
}
|
|
|
|
else if(skill == AOE_SHOCK) {
|
2022-03-19 18:14:00 +01:00
|
|
|
if(f->current_attack)
|
|
|
|
return;
|
2022-02-05 14:38:26 +01:00
|
|
|
entity_t *aoe = aoe_make_attack(AOE_SHOCK, e, dir);
|
|
|
|
game_add_entity(game, aoe);
|
|
|
|
|
2022-02-08 22:48:08 +01:00
|
|
|
if(!f->enemy)
|
2022-02-05 14:38:26 +01:00
|
|
|
visible_set_anim(e, &anims_player_Attack, 2);
|
|
|
|
else
|
2022-02-08 22:48:08 +01:00
|
|
|
visible_set_anim(e, f->enemy->id->anim_attack, 2);
|
2022-02-05 14:38:26 +01:00
|
|
|
|
|
|
|
f->current_attack = aoe;
|
|
|
|
f->attack_follows_movement = true;
|
2022-02-07 20:41:39 +01:00
|
|
|
fighter_stun(e, fix(0.5));
|
2022-02-05 14:38:26 +01:00
|
|
|
game_shake(game, 5, fix(0.7));
|
|
|
|
}
|
|
|
|
else if(skill == AOE_JUDGEMENT) {
|
2022-03-19 18:14:00 +01:00
|
|
|
if(f->current_attack)
|
|
|
|
return;
|
2022-02-05 14:38:26 +01:00
|
|
|
entity_t *aoe = aoe_make_attack(AOE_JUDGEMENT, e, dir);
|
|
|
|
game_add_entity(game, aoe);
|
|
|
|
|
2022-02-08 22:48:08 +01:00
|
|
|
if(!f->enemy)
|
2022-02-05 14:38:26 +01:00
|
|
|
visible_set_anim(e, &anims_player_Attack, 2);
|
|
|
|
else
|
2022-02-08 22:48:08 +01:00
|
|
|
visible_set_anim(e, f->enemy->id->anim_attack, 2);
|
2022-02-05 14:38:26 +01:00
|
|
|
|
|
|
|
game_shake(game, 3, fix(1.3));
|
|
|
|
}
|
|
|
|
else if(skill == AOE_BULLET) {
|
2022-03-19 18:14:00 +01:00
|
|
|
if(f->current_attack)
|
|
|
|
return;
|
2022-02-05 14:38:26 +01:00
|
|
|
entity_t *aoe = aoe_make_attack(AOE_BULLET, e, dir);
|
|
|
|
game_add_entity(game, aoe);
|
|
|
|
|
2022-02-08 22:48:08 +01:00
|
|
|
if(!f->enemy)
|
2022-02-05 14:38:26 +01:00
|
|
|
visible_set_anim(e, &anims_player_Attack, 2);
|
|
|
|
else
|
2022-02-08 22:48:08 +01:00
|
|
|
visible_set_anim(e, f->enemy->id->anim_attack, 2);
|
2022-02-05 14:38:26 +01:00
|
|
|
}
|
|
|
|
}
|
2022-03-19 18:14:00 +01:00
|
|
|
|
|
|
|
void skill_render(int x, int y, int skill, int bg, int color)
|
|
|
|
{
|
|
|
|
extern bopti_image_t img_skillicons;
|
|
|
|
|
|
|
|
int n = -1;
|
|
|
|
if(skill == SKILL_DASH)
|
|
|
|
n = 0;
|
|
|
|
if(skill == AOE_SHOCK)
|
|
|
|
n = 1;
|
|
|
|
if(skill == AOE_JUDGEMENT)
|
|
|
|
n = 2;
|
|
|
|
if(skill == AOE_BULLET)
|
|
|
|
n = 3;
|
|
|
|
|
|
|
|
if(bg > 0)
|
|
|
|
dsubimage(x, y, &img_skillicons, 23*(bg-1), 0, 23, 23, DIMAGE_NONE);
|
|
|
|
if(n >= 0)
|
|
|
|
dsubimage(x, y, &img_skillicons, 23*(n+2), 0, 23, 23, DIMAGE_NONE);
|
|
|
|
|
|
|
|
/* Hacky color change */
|
|
|
|
for(int dy = 0; dy < 23; dy++)
|
|
|
|
for(int dx = 0; dx < 23; dx++) {
|
|
|
|
int i = (y+dy) * DWIDTH + (x+dx);
|
|
|
|
if(gint_vram[i] == 0xffff)
|
|
|
|
gint_vram[i] = color;
|
|
|
|
}
|
|
|
|
}
|