From c7c5346afc6088c1bafd7dfe0943be6ac13a1059 Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Tue, 2 Oct 2018 22:42:29 +0200 Subject: [PATCH] Completes testing of phase and fixes some errors - Fixes some information in skill tooltips - Fixes a bug with menu mouse selections --- src/menu.c | 2 +- src/monster.c | 4 ++++ src/player.c | 6 +++--- src/roommatrix.c | 7 +++++++ src/roommatrix.h | 3 +++ src/skill.c | 13 ++++++++----- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/menu.c b/src/menu.c index a24ae0b..1c6c015 100644 --- a/src/menu.c +++ b/src/menu.c @@ -193,7 +193,7 @@ menu_update(Menu *m, Input *input) if (position_in_rect(&p, &item->button->area) && input_mousebutton_is_pressed(input, MBUTTON_LEFT)) { - item->button->event(NULL); + item->button->event(item->button->usrdata); return; } } diff --git a/src/monster.c b/src/monster.c index 8aa74d1..0138330 100644 --- a/src/monster.c +++ b/src/monster.c @@ -528,6 +528,10 @@ monster_perform_aoe_attack(Monster *m, RoomMatrix *rm) bool monster_move(Monster *m, RoomMatrix *rm, Map *map) { + Player *player = roommatrix_get_player(rm); + if (player && player->phase_count) + return true; + if (m->stats.hp <= 0 || m->sprite->state == SPRITE_STATE_FALLING) return true; diff --git a/src/player.c b/src/player.c index 91913b8..2198bdf 100644 --- a/src/player.c +++ b/src/player.c @@ -103,9 +103,9 @@ action_spent(Player *p) for (size_t i = 0; i < PLAYER_SKILL_COUNT; ++i) { if (p->skills[i] != NULL && p->skills[i]->resetCountdown > 0) p->skills[i]->resetCountdown--; - if (p->phase_count > 0) - p->phase_count--; } + if (p->phase_count > 0) + p->phase_count--; } } @@ -231,7 +231,7 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction) else { player_collect_items(player, space); player_pickup_artifacts(player, space); - if (player->phase_count) { + if (!player->phase_count) { player_interact_objects(player, space); player_interact_traps_and_pits(player, space); } diff --git a/src/roommatrix.c b/src/roommatrix.c index 5ba2621..1420fd1 100644 --- a/src/roommatrix.c +++ b/src/roommatrix.c @@ -307,3 +307,10 @@ void roommatrix_destroy(RoomMatrix *m) free(m); } + +Player * +roommatrix_get_player(RoomMatrix *rm) +{ + Position *pos = &rm->playerRoomPos; + return rm->spaces[pos->x][pos->y].player; +} diff --git a/src/roommatrix.h b/src/roommatrix.h index 1b6370e..998b495 100644 --- a/src/roommatrix.h +++ b/src/roommatrix.h @@ -90,4 +90,7 @@ roommatrix_render_debug(RoomMatrix*, Camera*); void roommatrix_destroy(RoomMatrix*); +Player * +roommatrix_get_player(RoomMatrix*); + #endif // ROOMMATRIX_H_ diff --git a/src/skill.c b/src/skill.c index a3b15e8..1f09bc1 100644 --- a/src/skill.c +++ b/src/skill.c @@ -77,9 +77,10 @@ static char *trip_tooltip[] = { "TRIP", "", " Trips an adjecant enemy causing him to fall (move), in", - " the direction you tripped him.", + " the direction you tripped it in.", + " On a successful hit the enemy will also be stunned." "", - " This can be combined with traps and pits to great effect", + " This can be combined with traps and pits to great effect.", "", "COOLDOWN:", " 3 turns", @@ -99,6 +100,7 @@ static char *backstab_tooltip[] = { " You flip over an adjecant enemy taking it's place and", " it taking yours, finnishing off with a stab in the back", " of your foe.", + " A successful attack will also leave the enemy stunned." "", "COOLDOWN:", " 5 turns", @@ -116,8 +118,8 @@ static char *phase_tooltip[] = { "PHASE", "", " You phase out of existence for a time. While you are phased you", - " are unaffected by gravity, traps and monsters won't see you.", - " You can also pass through monsters", + " are unaffected by gravity, traps and enemies won't see you.", + " You can also pass through enemies.", "", " The effect lasts for 3 turns", "", @@ -425,7 +427,7 @@ skill_trip(Skill *skill, SkillData *data) 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); - if (space->monster->stats.hp > 0) { + if (dmg && space->monster->stats.hp > 0) { Uint32 pushCount = 1 + player_has_artifact(data->player, PUSH_BACK); for (Uint32 i = 0; i < pushCount; ++i) { monster_push(space->monster, data->player, data->matrix, data->direction); @@ -433,6 +435,7 @@ skill_trip(Skill *skill, SkillData *data) break; } } + monster_set_state(space->monster, STUNNED, (Uint8)(1 + player_has_artifact(data->player, INCREASED_STUN))); }