Untested implementation of the TRIP skill

This commit is contained in:
Linus Probert 2018-09-13 15:28:03 +02:00
parent dbf9fe3931
commit 60359d8e9c
2 changed files with 75 additions and 3 deletions

View File

@ -502,9 +502,9 @@ player_create(class_t class, Camera *cam)
case ROGUE: case ROGUE:
m_strcpy(asset, 100, "Commissions/Rogue.png"); m_strcpy(asset, 100, "Commissions/Rogue.png");
player->stats = (Stats) ROGUE_STATS; player->stats = (Stats) ROGUE_STATS;
player->skills[0] = NULL; player->skills[0] = skill_create(BACKSTAB, cam);
player->skills[1] = NULL; player->skills[1] = skill_create(TRIP, cam);
player->skills[2] = NULL; player->skills[2] = skill_create(BLINK, cam);
player->skills[3] = skill_create(DAGGER_THROW, cam); player->skills[3] = skill_create(DAGGER_THROW, cam);
player->daggers = 10; player->daggers = 10;
break; break;

View File

@ -73,6 +73,26 @@ static char *bash_tooltip[] = {
NULL NULL
}; };
static char *trip_tooltip[] = {
"TRIP",
"",
" Trips an adjecant enemy causing him to fall (move), in",
" the direction you tripped him.",
"",
" This can be combined with traps and pits to great effect",
"",
"COOLDOWN:",
" 3 turns",
"",
"USAGE:",
" activate the skill (press 2)",
" followed by a direction (left, right, up or down)",
"",
"",
"Press ESC to close",
NULL
};
static char *charge_tooltip[] = { static char *charge_tooltip[] = {
"CHARGE", "CHARGE",
"", "",
@ -346,6 +366,50 @@ create_bash(void)
return skill; return skill;
} }
static bool
skill_trip(Skill *skill, SkillData *data)
{
UNUSED (skill);
Position playerPos, targetPos;
if (!check_skill_validity(&playerPos, &targetPos, data)) {
return false;
}
RoomSpace *space = &data->matrix->spaces[targetPos.x][targetPos.y];
mixer_play_effect(SWING0 + get_random(2));
if (space->monster) {
monster_push(space->monster, data->player, data->matrix, data->direction);
int dmg = stats_fight(&data->player->stats, &space->monster->stats);
gui_log("You trip %s causing it to fall away from you", space->monster->lclabel);
monster_hit(space->monster, dmg);
player_monster_kill_check(data->player, space->monster);
} else {
gui_log("You flail at the air");
}
return true;
}
static Skill *
create_trip(void)
{
Texture *t = texturecache_add("Extras/Skills.png");
Sprite *s = sprite_create();
sprite_set_texture(s, t, 0);
s->dim = GAME_DIMENSION;
s->clip = CLIP32(96, 0);
s->fixed = true;
Skill *skill = create_default("Trip", s);
skill->levelcap = 3;
skill->instantUse = false;
skill->resetTime = 3;
skill->available = NULL;
skill->use = skill_trip;
skill->actionRequired = true;
return skill;
}
static bool static bool
skill_sip_health_available(Player *player) skill_sip_health_available(Player *player)
{ {
@ -552,6 +616,14 @@ skill_create(enum SkillType t, Camera *cam)
skill = create_bash(); skill = create_bash();
skill->tooltip = tooltip_create(bash_tooltip, cam); skill->tooltip = tooltip_create(bash_tooltip, cam);
break; break;
case TRIP:
skill = create_trip();
skill->tooltip = tooltip_create(trip_tooltip, cam);
break;
case BACKSTAB:
case BLINK:
error("Skill %d not implemented", t);
return NULL;
default: default:
fatal("Unknown SkillType %u", (unsigned int) t); fatal("Unknown SkillType %u", (unsigned int) t);
return NULL; return NULL;