Continues #2 FEAR_INDUCING impl
This required changes (improvements imo) to the monster state logic.
This commit is contained in:
parent
0aacdd2d84
commit
19e7583f3e
|
@ -80,6 +80,7 @@ monster_state_change(Monster *m, StateType newState)
|
||||||
m->state.last = m->state.current;
|
m->state.last = m->state.current;
|
||||||
m->state.current = newState;
|
m->state.current = newState;
|
||||||
m->state.stepsSinceChange = 0;
|
m->state.stepsSinceChange = 0;
|
||||||
|
m->state.forceCount = 0;
|
||||||
|
|
||||||
monster_set_state_display_time(m);
|
monster_set_state_display_time(m);
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ monster_state_change(Monster *m, StateType newState)
|
||||||
static void
|
static void
|
||||||
monster_behaviour_check_post_hit(Monster *m)
|
monster_behaviour_check_post_hit(Monster *m)
|
||||||
{
|
{
|
||||||
if (m->state.current == STUNNED)
|
if (m->state.stepsSinceChange < m->state.forceCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (m->behaviour) {
|
switch (m->behaviour) {
|
||||||
|
@ -194,6 +195,7 @@ monster_create(void)
|
||||||
m->stateIndicator.sprite->dim = GAME_DIMENSION;
|
m->stateIndicator.sprite->dim = GAME_DIMENSION;
|
||||||
m->stateIndicator.displayCount = 0;
|
m->stateIndicator.displayCount = 0;
|
||||||
m->stateIndicator.shownOnPlayerRoomEnter = false;
|
m->stateIndicator.shownOnPlayerRoomEnter = false;
|
||||||
|
m->state.forceCount = 0;
|
||||||
monster_set_behaviour(m, NORMAL);
|
monster_set_behaviour(m, NORMAL);
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
@ -376,17 +378,18 @@ monster_coward_walk(Monster *m, RoomMatrix *rm)
|
||||||
bool
|
bool
|
||||||
monster_move(Monster *m, RoomMatrix *rm)
|
monster_move(Monster *m, RoomMatrix *rm)
|
||||||
{
|
{
|
||||||
|
if (m->state.forceCount) {
|
||||||
if (m->state.current == STUNNED) {
|
if (m->state.stepsSinceChange >= m->state.forceCount) {
|
||||||
if (m->state.stepsSinceChange < 3) {
|
|
||||||
m->state.stepsSinceChange += 1;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
monster_state_change(m, m->state.last);
|
monster_state_change(m, m->state.last);
|
||||||
monster_behaviour_check_post_hit(m);
|
monster_behaviour_check_post_hit(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m->state.current == STUNNED) {
|
||||||
|
m->state.stepsSinceChange += 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
monster_behaviour_check(m, rm);
|
monster_behaviour_check(m, rm);
|
||||||
|
|
||||||
Position originalPosition =
|
Position originalPosition =
|
||||||
|
@ -595,9 +598,10 @@ monster_set_behaviour(Monster *m, MonsterBehaviour behaviour)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
monster_set_state(Monster *m, StateType state)
|
monster_set_state(Monster *m, StateType state, Uint8 forceCount)
|
||||||
{
|
{
|
||||||
monster_state_change(m, state);
|
monster_state_change(m, state);
|
||||||
|
m->state.forceCount = forceCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -51,6 +51,7 @@ typedef struct State {
|
||||||
StateType current;
|
StateType current;
|
||||||
StateType last;
|
StateType last;
|
||||||
unsigned int stepsSinceChange;
|
unsigned int stepsSinceChange;
|
||||||
|
Uint8 forceCount;
|
||||||
} State;
|
} State;
|
||||||
|
|
||||||
typedef struct MonsterStateIndicator {
|
typedef struct MonsterStateIndicator {
|
||||||
|
@ -59,7 +60,7 @@ typedef struct MonsterStateIndicator {
|
||||||
int displayCount;
|
int displayCount;
|
||||||
} MonsterStateIndicator;
|
} MonsterStateIndicator;
|
||||||
|
|
||||||
typedef struct Monster_t {
|
typedef struct Monster {
|
||||||
char *label;
|
char *label;
|
||||||
char *lclabel;
|
char *lclabel;
|
||||||
Sprite *sprite;
|
Sprite *sprite;
|
||||||
|
@ -97,7 +98,7 @@ void
|
||||||
monster_set_behaviour(Monster *, MonsterBehaviour behaviour);
|
monster_set_behaviour(Monster *, MonsterBehaviour behaviour);
|
||||||
|
|
||||||
void
|
void
|
||||||
monster_set_state(Monster *m, StateType state);
|
monster_set_state(Monster *m, StateType state, Uint8 forceCount);
|
||||||
|
|
||||||
void
|
void
|
||||||
monster_push(Monster *, RoomMatrix*, Vector2d dir);
|
monster_push(Monster *, RoomMatrix*, Vector2d dir);
|
||||||
|
|
|
@ -158,7 +158,7 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
|
||||||
if (get_random(10) < player_has_artifact(player, FEAR_INDUCING)) {
|
if (get_random(10) < player_has_artifact(player, FEAR_INDUCING)) {
|
||||||
gui_log("%s shivers with fear at the sight of you",
|
gui_log("%s shivers with fear at the sight of you",
|
||||||
space->monster->label);
|
space->monster->label);
|
||||||
monster_set_state(space->monster, SCARED);
|
monster_set_state(space->monster, SCARED, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
typedef struct Sprite Sprite;
|
typedef struct Sprite Sprite;
|
||||||
typedef struct Map_t Map;
|
typedef struct Map_t Map;
|
||||||
typedef struct Monster_t Monster;
|
typedef struct Monster Monster;
|
||||||
typedef struct Player Player;
|
typedef struct Player Player;
|
||||||
typedef struct Item_t Item;
|
typedef struct Item_t Item;
|
||||||
typedef struct Node LinkedList;
|
typedef struct Node LinkedList;
|
||||||
|
|
|
@ -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_state(monster, STUNNED);
|
monster_set_state(monster, STUNNED, 3);
|
||||||
}
|
}
|
||||||
mixer_play_effect(SLAM);
|
mixer_play_effect(SLAM);
|
||||||
data->player->stat_data.hits += 1;
|
data->player->stat_data.hits += 1;
|
||||||
|
|
Loading…
Reference in New Issue