summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions.c14
-rw-r--r--actions.h1
-rw-r--r--jouer.c2
-rw-r--r--menuchoixpersos.c2
-rw-r--r--players.h2
-rw-r--r--priv_entries.h8
6 files changed, 29 insertions, 0 deletions
diff --git a/actions.c b/actions.c
index e356a83..ac5cc03 100644
--- a/actions.c
+++ b/actions.c
@@ -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;
diff --git a/actions.h b/actions.h
index b7a4f09..7510f38 100644
--- a/actions.h
+++ b/actions.h
@@ -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 */
diff --git a/jouer.c b/jouer.c
index 6d230f9..a5f20ad 100644
--- a/jouer.c
+++ b/jouer.c
@@ -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;
diff --git a/players.h b/players.h
index 062bde5..5d535bf 100644
--- a/players.h
+++ b/players.h
@@ -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,
+ },
},
};