From e1c154fc1ca7ffdcbbfd0ad70d65e93d8818b4d7 Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Thu, 30 Aug 2018 11:13:50 +0200 Subject: [PATCH] Fixed charge - Prevent click sound from triggering - Prevent hovering on pits if you end charge on them - Trigger traps if you end charge on them --- CMakeLists.txt | 8 ++++---- src/player.c | 10 ++++++++-- src/player.h | 3 +++ src/skill.c | 9 ++++++++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ad95ea..63997d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,10 +5,10 @@ SET(CMAKE_COLOR_MAKEFILE ON) project(breakhack C) set(breakhack_GAME_TITLE "BreakHack") -set(breakhack_MAJOR_VERSION 0) -set(breakhack_MINOR_VERSION 3) -set(breakhack_PATCH_VERSION 0) -set(breakhack_RELEASE_TYPE "(beta)") +set(breakhack_MAJOR_VERSION 1) +set(breakhack_MINOR_VERSION 0) +set(breakhack_PATCH_VERSION 1) +set(breakhack_RELEASE_TYPE "") include(FindLua) include(FindPhysFS) diff --git a/src/player.c b/src/player.c index 9dd432c..fecbecd 100644 --- a/src/player.c +++ b/src/player.c @@ -208,8 +208,7 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction) } if (space->lethal && !collided) { - mixer_play_effect(FALL0 + get_random(2) - 1); - player->state = FALLING; + player_set_falling(player); } if (space->trap && !collided) { @@ -697,3 +696,10 @@ player_add_artifact(Player *p, Artifact *a) gui_log("%s (%u)", ad->desc, ad->level); p->equipment.hasArtifacts = true; } + +void +player_set_falling(Player *player) +{ + mixer_play_effect(FALL0 + get_random(2) - 1); + player->state = FALLING; +} diff --git a/src/player.h b/src/player.h index 07d970d..d3a9765 100644 --- a/src/player.h +++ b/src/player.h @@ -123,3 +123,6 @@ player_has_artifact(Player *, MagicalEffect); void player_add_artifact(Player*, Artifact*); + +void +player_set_falling(Player*); diff --git a/src/skill.c b/src/skill.c index b512d0b..cd77d7d 100644 --- a/src/skill.c +++ b/src/skill.c @@ -393,7 +393,7 @@ skill_charge_check_path(SkillData *data, Monster *monster = matrix->spaces[itPos.x][itPos.y].monster; Stats tmpStats = player->stats; tmpStats.dmg *= steps > 0 ? steps : 1; - mixer_play_effect(SWING0 + get_random(3) - 1); + mixer_play_effect(SWING0 + get_random(2)); unsigned int dmg = stats_fight(&tmpStats, &monster->stats); if (dmg > 0) { gui_log("You charged %s for %u damage", monster->lclabel, dmg); @@ -492,6 +492,13 @@ skill_charge(Skill *skill, SkillData *data) skill_charge_check_path(data, playerStartPos, destination); + Position lastTilePos = position_to_matrix_coords(&playerDestinationPos); + RoomSpace *destSpace = &matrix->spaces[lastTilePos.x][lastTilePos.y]; + if (destSpace->lethal) + player_set_falling(player); + else if (destSpace->trap) + trap_activate(destSpace->trap, player); + return true; }