From 47ac1b7868b8bfb3e5fe71395a34124bf9f7209a Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 14 Dec 2017 22:16:48 +0100 Subject: Improve combat. --- src/game/game.hpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src/game/game.hpp') diff --git a/src/game/game.hpp b/src/game/game.hpp index d4aed5d..57dbb07 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -49,6 +49,9 @@ namespace game { world::cmodel_t make_cmodel(v2f_t at); void compute_bounds(); + double next_targetting = -INFINITY; + double last_attack = -INFINITY; + public: v2f_t x; rectf_t size, render_size; @@ -88,6 +91,12 @@ namespace game { virtual void wake(unit_t *by_whom) = 0; virtual void sleep(void) = 0; + struct { + size_t armor_class; + roll_params_t hit_roll; + roll_params_t damage_roll; + } cs; + bool dead = false; double death_time = -INFINITY; int health = 1, max_health = 1; @@ -99,15 +108,14 @@ namespace game { double say_time = -INFINITY; void say(std::string str); + void render_to(render::state_t *render); }; class human_t : public unit_t { - double next_targetting = -INFINITY; double last_target_time = -INFINITY; v2f_t last_target_x; - double last_attack = -INFINITY; public: human_t(game::state_t *game); @@ -121,9 +129,7 @@ namespace game { class alien_t : public unit_t { double next_targetting = -INFINITY; - double next_attack = -INFINITY; - void attack(unit_t *target, float range); public: alien_t(game::state_t *game); void render_to(render::state_t *render); @@ -133,14 +139,4 @@ namespace game { void think(void); void die(void); }; - - static inline size_t roll(size_t count, size_t sides) - { - size_t total = 0; - - for (size_t i = 0; i < count; i++) - total += rand() % sides + 1; - - return total; - } }; -- cgit