Makes sure til effects and items apply after backstab

This commit is contained in:
Linus Probert 2019-02-24 23:33:08 +01:00
parent 1b440c248d
commit fffcac12c0
1 changed files with 39 additions and 23 deletions

View File

@ -198,6 +198,40 @@ static char *health_tooltip[] = {
NULL NULL
}; };
static void
perform_pickups_for_space(RoomSpace *space, Player *player)
{
// 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);
}
}
static void
handle_space_effects(RoomSpace *space,
Player *player)
{
if (space->lethal)
player_set_falling(player);
else if (space->trap)
trap_activate(space->trap, player);
LinkedList *objects = space->objects;
while (objects) {
object_damage(objects->data, player);
objects = objects->next;
}
}
static Skill * static Skill *
create_default(const char *s_label, Sprite *s) create_default(const char *s_label, Sprite *s)
{ {
@ -505,6 +539,9 @@ skill_backstab(Skill *skill, SkillData *data)
} }
} }
perform_pickups_for_space(targetSpace, data->player);
handle_space_effects(targetSpace, data->player);
return true; return true;
} }
@ -617,19 +654,7 @@ skill_charge_check_path(SkillData *data,
player_monster_kill_check(data->player, monster); player_monster_kill_check(data->player, monster);
} }
// Pick up items in the path perform_pickups_for_space(space, player);
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) if (space->trap)
space->trap->sprite->animate = true; space->trap->sprite->animate = true;
@ -707,16 +732,7 @@ skill_charge(Skill *skill, SkillData *data)
Position lastTilePos = position_to_matrix_coords(&playerDestinationPos); Position lastTilePos = position_to_matrix_coords(&playerDestinationPos);
RoomSpace *destSpace = &matrix->spaces[lastTilePos.x][lastTilePos.y]; RoomSpace *destSpace = &matrix->spaces[lastTilePos.x][lastTilePos.y];
if (destSpace->lethal) handle_space_effects(destSpace, player);
player_set_falling(player);
else if (destSpace->trap)
trap_activate(destSpace->trap, player);
LinkedList *objects = destSpace->objects;
while (objects) {
object_damage(objects->data, player);
objects = objects->next;
}
return true; return true;
} }