Continues #2 Adds PUSH_BACK impl

This commit is contained in:
Linus Probert 2018-08-09 15:31:27 +02:00
parent ac7dada0d5
commit 0aacdd2d84
5 changed files with 31 additions and 8 deletions

View File

@ -120,11 +120,11 @@ get_event_mousebutton(SDL_Event *event)
Uint32 key = 0; Uint32 key = 0;
switch (event->button.button) { switch (event->button.button) {
case SDL_BUTTON_LEFT: case SDL_BUTTON_LEFT:
key = MBUTTON_LEFT; key = MBUTTON_LEFT; break;
case SDL_BUTTON_MIDDLE: case SDL_BUTTON_MIDDLE:
key = MBUTTON_MIDDLE; key = MBUTTON_MIDDLE; break;
case SDL_BUTTON_RIGHT: case SDL_BUTTON_RIGHT:
key = MBUTTON_RIGHT; key = MBUTTON_RIGHT; break;
default: default:
key = 0; key = 0;
} }

View File

@ -556,7 +556,7 @@ monster_drop_loot(Monster *monster, Map *map, Player *player)
// TODO: This should not occur every time // TODO: This should not occur every time
// Debug code. // Debug code.
Artifact *a = artifact_create(CHARGE_THROUGH); Artifact *a = artifact_create(FEAR_INDUCING);
a->sprite->pos = monster->sprite->pos; a->sprite->pos = monster->sprite->pos;
linkedlist_append(&map->artifacts, a); linkedlist_append(&map->artifacts, a);
} }
@ -595,9 +595,15 @@ monster_set_behaviour(Monster *m, MonsterBehaviour behaviour)
} }
void void
monster_set_stunned(Monster *m) monster_set_state(Monster *m, StateType state)
{ {
monster_state_change(m, STUNNED); monster_state_change(m, state);
}
void
monster_push(Monster *m, RoomMatrix *rm, Vector2d dir)
{
move(m, rm, dir);
} }
void void

View File

@ -97,7 +97,10 @@ void
monster_set_behaviour(Monster *, MonsterBehaviour behaviour); monster_set_behaviour(Monster *, MonsterBehaviour behaviour);
void void
monster_set_stunned(Monster *m); monster_set_state(Monster *m, StateType state);
void
monster_push(Monster *, RoomMatrix*, Vector2d dir);
void void
monster_destroy(Monster*); monster_destroy(Monster*);

View File

@ -148,6 +148,20 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
} }
player_monster_kill_check(player, space->monster); player_monster_kill_check(player, space->monster);
if (space->monster->stats.hp > 0) {
if (get_random(10) < player_has_artifact(player, PUSH_BACK)) {
gui_log("The force of your blow sends %s reeling",
space->monster->lclabel);
monster_push(space->monster, matrix, direction);
}
if (get_random(10) < player_has_artifact(player, FEAR_INDUCING)) {
gui_log("%s shivers with fear at the sight of you",
space->monster->label);
monster_set_state(space->monster, SCARED);
}
}
action_spent(player); action_spent(player);
} else if (collided) { } else if (collided) {

View File

@ -205,7 +205,7 @@ skill_bash(Skill *skill, SkillData *data)
gui_log("You hit for %u damage", dmg); gui_log("You hit for %u damage", dmg);
if (monster->stats.hp > 0) { if (monster->stats.hp > 0) {
gui_log("%s seems dazed and confused", monster->label); gui_log("%s seems dazed and confused", monster->label);
monster_set_stunned(monster); monster_set_state(monster, STUNNED);
} }
mixer_play_effect(SLAM); mixer_play_effect(SLAM);
data->player->stat_data.hits += 1; data->player->stat_data.hits += 1;