diff --git a/TODO.txt b/TODO.txt index 8eb890f..9d658d6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,15 +1,4 @@ -o Make things less difficult and more interesting - o Interesting items - x Daggers - - Bombs? - - Magical permanent items would be nice - - Piercing daggers - - Charge passthrough - - +1 atk / +1 def items - o Creat some nice room modifiers - x Windy room - x Liquid in rooms - Falling floor tiles - Credit screen showing music and graphics guys: diff --git a/assets/Sounds/FX/magic_pickup.wav b/assets/Sounds/FX/magic_pickup.wav new file mode 100644 index 0000000..e4f6891 Binary files /dev/null and b/assets/Sounds/FX/magic_pickup.wav differ diff --git a/src/mixer.c b/src/mixer.c index 2dc3e28..e002637 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -82,6 +82,7 @@ load_effects(void) effects[FALL0] = load_effect("Sounds/FX/fall0.wav"); effects[FALL1] = load_effect("Sounds/FX/fall1.wav"); effects[SLAM] = load_effect("Sounds/FX/slam.wav"); + effects[MAGIC_PICKUP] = load_effect("Sounds/FX/magic_pickup.wav"); } void diff --git a/src/mixer.h b/src/mixer.h index c242b85..637ce5c 100644 --- a/src/mixer.h +++ b/src/mixer.h @@ -58,6 +58,7 @@ typedef enum Fx_t { PLAYER_HIT2, DAGGER_PICKUP, SLAM, + MAGIC_PICKUP, LAST_EFFECT } Fx; diff --git a/src/monster.c b/src/monster.c index 77e1955..2c1742f 100644 --- a/src/monster.c +++ b/src/monster.c @@ -556,7 +556,7 @@ monster_drop_loot(Monster *monster, Map *map, Player *player) // TODO: This should not occur every time // Debug code. - Artifact *a = artifact_create(TRAP_AVOIDANCE); + Artifact *a = artifact_create(CHARGE_THROUGH); a->sprite->pos = monster->sprite->pos; linkedlist_append(&map->artifacts, a); } diff --git a/src/player.c b/src/player.c index 9680573..928587a 100644 --- a/src/player.c +++ b/src/player.c @@ -629,6 +629,7 @@ player_add_artifact(Player *p, Artifact *a) if (a->collected) return; + mixer_play_effect(MAGIC_PICKUP); a->collected = true; ArtifactData *ad = &p->equipment.artifacts[a->effect]; diff --git a/src/position.c b/src/position.c index ddb8837..3bde442 100644 --- a/src/position.c +++ b/src/position.c @@ -95,5 +95,8 @@ position_in_room(Position *pos, Position *roomPos) bool position_in_roommatrix(const Position *pos) { - return pos->x >= 0 && pos->x < MAP_ROOM_WIDTH && pos->y >= 0 && pos->y < MAP_ROOM_HEIGHT; + return pos->x >= 0 + && pos->x < MAP_ROOM_WIDTH + && pos->y >= 0 + && pos->y < MAP_ROOM_HEIGHT; } diff --git a/src/skill.c b/src/skill.c index 48bf3ea..69a551b 100644 --- a/src/skill.c +++ b/src/skill.c @@ -34,6 +34,7 @@ #include "item.h" #include "animation.h" #include "artifact.h" +#include "trap.h" static Skill * create_default(const char *s_label, Sprite *s) @@ -271,6 +272,60 @@ create_sip_health(void) return skill; } +static void +skill_charge_check_path(SkillData *data, + Position origin, + Position dest) +{ + RoomMatrix *matrix = data->matrix; + Player *player = data->player; + + Position itPos = origin; + Position lastPos = dest; + lastPos.x += (int) data->direction.x * 2; + lastPos.y += (int) data->direction.y * 2; + Uint8 steps = 1; + while (position_in_roommatrix(&itPos) && !position_equals(&itPos, &lastPos)) { + RoomSpace *space = &matrix->spaces[itPos.x][itPos.y]; + if (space->monster) { + 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); + unsigned int dmg = stats_fight(&tmpStats, &monster->stats); + if (dmg > 0) { + gui_log("You charged %s for %u damage", monster->lclabel, dmg); + mixer_play_effect(SWORD_HIT); + data->player->stat_data.hits += 1; + } + monster_hit(monster, dmg); + player_monster_kill_check(data->player, monster); + } + + // Pick up items in the path + LinkedList *items = space->items; + while (items != NULL) { + Item *item = items->data; + items = items->next; + item_collected(item, player); + } + LinkedList *artifacts = space->artifacts; + while (artifacts != NULL) { + Artifact *artifact = artifacts->data; + artifacts = artifacts->next; + player_add_artifact(player, artifact); + } + + if (space->trap) + space->trap->sprite->animate = true; + + itPos.x += (int) data->direction.x; + itPos.y += (int) data->direction.y; + + steps++; + } +} + static bool skill_charge(Skill *skill, SkillData *data) { @@ -279,46 +334,40 @@ skill_charge(Skill *skill, SkillData *data) Player *player = data->player; RoomMatrix *matrix = data->matrix; - Position playerPos = position_to_matrix_coords(&player->sprite->pos); - Position destination = playerPos; - - unsigned int steps = 0; + Position playerStartPos = position_to_matrix_coords(&player->sprite->pos); + Position destination = playerStartPos; // Find collider destination.x += (int) data->direction.x; destination.y += (int) data->direction.y; RoomSpace *space = &matrix->spaces[destination.x][destination.y]; - while (position_in_roommatrix(&destination) && !space->occupied) + Uint32 passThroughCount = 0; + Uint32 chargeThroughLvl = player_has_artifact(data->player, CHARGE_THROUGH); + Position lastAvailableDest = playerStartPos; + while (position_in_roommatrix(&destination)) { + if (space->occupied) { + if (!space->monster || passThroughCount >= chargeThroughLvl) + break; + else + passThroughCount++; + } else { + lastAvailableDest = destination; + } + destination.x += (int) data->direction.x; destination.y += (int) data->direction.y; - if (space->items != NULL) { - LinkedList *items = space->items; - while (items != NULL) { - Item *item = items->data; - items = items->next; - item_collected(item, player); - } - LinkedList *artifacts = space->artifacts; - while (artifacts != NULL) { - Artifact *artifact = artifacts->data; - artifacts = artifacts->next; - player_add_artifact(player, artifact); - } - } space = &matrix->spaces[destination.x][destination.y]; - steps++; } - if (!position_in_roommatrix(&destination)) { - destination.x -= (int) data->direction.x; - destination.y -= (int) data->direction.y; - } + destination = lastAvailableDest; // Move player Position playerOriginPos = player->sprite->pos; - player->sprite->pos.x += (steps * TILE_DIMENSION) * (int) data->direction.x; - player->sprite->pos.y += (steps * TILE_DIMENSION) * (int) data->direction.y; + Sint32 xdiff = destination.x - playerStartPos.x; + Sint32 ydiff = destination.y - playerStartPos.y; + player->sprite->pos.x += xdiff * TILE_DIMENSION; + player->sprite->pos.y += ydiff * TILE_DIMENSION; Position playerDestinationPos = player->sprite->pos; player_turn(data->player, &data->direction); @@ -326,9 +375,9 @@ skill_charge(Skill *skill, SkillData *data) bool horizontal = data->direction.x != 0; Dimension particleArea; if (horizontal) - particleArea = (Dimension) { steps * TILE_DIMENSION, TILE_DIMENSION }; + particleArea = (Dimension) { abs(xdiff) * TILE_DIMENSION, TILE_DIMENSION }; else - particleArea = (Dimension) { TILE_DIMENSION, steps * TILE_DIMENSION }; + particleArea = (Dimension) { TILE_DIMENSION, abs(ydiff) * TILE_DIMENSION }; Position speedLinePos; if (playerOriginPos.x < playerDestinationPos.x || playerOriginPos.y < playerDestinationPos.y) @@ -339,20 +388,7 @@ skill_charge(Skill *skill, SkillData *data) particle_engine_speed_lines(speedLinePos, particleArea, horizontal); mixer_play_effect(SWOOSH); - if (matrix->spaces[destination.x][destination.y].monster) { - Monster *monster = matrix->spaces[destination.x][destination.y].monster; - Stats tmpStats = player->stats; - tmpStats.dmg *= steps > 0 ? steps : 1; - mixer_play_effect(SWING0 + get_random(3) - 1); - unsigned int dmg = stats_fight(&tmpStats, &monster->stats); - if (dmg > 0) { - gui_log("You charged %s for %u damage", monster->lclabel, dmg); - mixer_play_effect(SWORD_HIT); - data->player->stat_data.hits += 1; - } - monster_hit(monster, dmg); - player_monster_kill_check(data->player, monster); - } + skill_charge_check_path(data, playerStartPos, destination); return true; }