diff options
-rw-r--r-- | actions.c | 14 | ||||
-rw-r--r-- | actions.h | 1 | ||||
-rw-r--r-- | jouer.c | 2 | ||||
-rw-r--r-- | menuchoixpersos.c | 2 | ||||
-rw-r--r-- | players.h | 2 | ||||
-rw-r--r-- | priv_entries.h | 8 |
6 files changed, 29 insertions, 0 deletions
@@ -45,6 +45,10 @@ static int compute_damages(const struct character_t *src, const struct character } } + if (dest->defensive) { + avg /= 2; + } + min = avg - avg / 4; max = avg + avg / 4; @@ -81,6 +85,16 @@ void attack(SURFACES *surfaces, POSITIONS *positions, struct character_t *src, s __attack(surfaces, positions, src, dest->chr); } +void defend(SURFACES *surfaces, POSITIONS *positions, struct character_t *src, struct target_t *dest, void *data) +{ + (void) data; + (void) dest; + (void) surfaces; + (void) positions; + + src->defensive = true; +} + void cast_element(SURFACES *surfaces, POSITIONS *positions, struct character_t *src, struct target_t *dest, void *data) { int damages; @@ -10,5 +10,6 @@ void cast_element(SURFACES *, POSITIONS *, struct character_t *src, struct targe void cast_cure(SURFACES *, POSITIONS *, struct character_t *src, struct target_t *dst, void *data); void use_potion(SURFACES *, POSITIONS *, struct character_t *src, struct target_t *dst, void *data); void use_ether(SURFACES *, POSITIONS *, struct character_t *src, struct target_t *dst, void *data); +void defend(SURFACES *, POSITIONS *, struct character_t *src, struct target_t *dst, void *data); #endif /* ACTIONS_H */ @@ -290,6 +290,8 @@ enum action_state_t dig_entry(const struct entry_t *entries, int cnt_entries, st static enum action_state_t character_play_turn(struct action_params_t *params) { + params->src->defensive = false; + if (!params->src->team->cpu) { return dig_entry(action_entries_g, countof(action_entries_g), params); } diff --git a/menuchoixpersos.c b/menuchoixpersos.c index 3eb77a9..f83fb16 100644 --- a/menuchoixpersos.c +++ b/menuchoixpersos.c @@ -21,6 +21,8 @@ static void init_team_players(struct team_t *team, bool left, chr->class_ = classes[i]; chr->alive = true; + chr->defensive = false; + switch (chr->class_) { case CLASS_PALADIN: chr->def_surf = surfaces->Ppaladin; @@ -36,6 +36,8 @@ struct character_t { bool alive; + bool defensive; + int hp; int max_hp; int mp; diff --git a/priv_entries.h b/priv_entries.h index f553a2b..f7697a6 100644 --- a/priv_entries.h +++ b/priv_entries.h @@ -199,6 +199,14 @@ struct entry_t action_entries_g[] = { .name = "Use", .children = object_entries, .children_cnt = countof(object_entries), + }, { + .name = "Defend", + .children_cnt = 0, + .action = { + .f = defend, + .data = NULL, + .target = TARGET_SELF, + }, }, }; |