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
This commit is contained in:
Linus Probert 2018-08-30 11:13:50 +02:00
parent ee8274038f
commit e1c154fc1c
4 changed files with 23 additions and 7 deletions

View File

@ -5,10 +5,10 @@ SET(CMAKE_COLOR_MAKEFILE ON)
project(breakhack C) project(breakhack C)
set(breakhack_GAME_TITLE "BreakHack") set(breakhack_GAME_TITLE "BreakHack")
set(breakhack_MAJOR_VERSION 0) set(breakhack_MAJOR_VERSION 1)
set(breakhack_MINOR_VERSION 3) set(breakhack_MINOR_VERSION 0)
set(breakhack_PATCH_VERSION 0) set(breakhack_PATCH_VERSION 1)
set(breakhack_RELEASE_TYPE "(beta)") set(breakhack_RELEASE_TYPE "")
include(FindLua) include(FindLua)
include(FindPhysFS) include(FindPhysFS)

View File

@ -208,8 +208,7 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
} }
if (space->lethal && !collided) { if (space->lethal && !collided) {
mixer_play_effect(FALL0 + get_random(2) - 1); player_set_falling(player);
player->state = FALLING;
} }
if (space->trap && !collided) { if (space->trap && !collided) {
@ -697,3 +696,10 @@ player_add_artifact(Player *p, Artifact *a)
gui_log("%s (%u)", ad->desc, ad->level); gui_log("%s (%u)", ad->desc, ad->level);
p->equipment.hasArtifacts = true; p->equipment.hasArtifacts = true;
} }
void
player_set_falling(Player *player)
{
mixer_play_effect(FALL0 + get_random(2) - 1);
player->state = FALLING;
}

View File

@ -123,3 +123,6 @@ player_has_artifact(Player *, MagicalEffect);
void void
player_add_artifact(Player*, Artifact*); player_add_artifact(Player*, Artifact*);
void
player_set_falling(Player*);

View File

@ -393,7 +393,7 @@ skill_charge_check_path(SkillData *data,
Monster *monster = matrix->spaces[itPos.x][itPos.y].monster; Monster *monster = matrix->spaces[itPos.x][itPos.y].monster;
Stats tmpStats = player->stats; Stats tmpStats = player->stats;
tmpStats.dmg *= steps > 0 ? steps : 1; 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); unsigned int dmg = stats_fight(&tmpStats, &monster->stats);
if (dmg > 0) { if (dmg > 0) {
gui_log("You charged %s for %u damage", monster->lclabel, dmg); 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); 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; return true;
} }