summaryrefslogtreecommitdiff
path: root/actions.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-10 00:14:19 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-10 00:14:19 +0100
commit30842cc79c0a3e3566e9da61f2499fa1342c6d52 (patch)
treedfe75cbb35d217389ae2c8ec8dfea52f7c50c20d /actions.c
parentc870c8f03ffc7b78bca72dc9d7de7fd5305cf4f2 (diff)
added "Defend" action
physical and magical damages are divided by 2 when a character is on defensive state. Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'actions.c')
-rw-r--r--actions.c14
1 files changed, 14 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;