diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-12-14 22:16:48 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-12-14 22:16:48 +0100 |
commit | 47ac1b7868b8bfb3e5fe71395a34124bf9f7209a (patch) | |
tree | 4bb1361ac664a3267344f6cf8230621be9c6feed /src/game/game.cpp | |
parent | b914d67b4e683c2d3e43c1854d6ef48b1878e4b6 (diff) |
Improve combat.
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r-- | src/game/game.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index 5067df7..96f76d3 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -84,9 +84,20 @@ void state_t::command(v2f_t x) void state_t::tick(double now_, double dt_) { + union { + double d; + uint32_t i; + } u; + now = now_; dt = dt_; + // FIXME: Is this non-deterministic enough? + u.d = now; + dice_prng.seed(dice_prng.next() ^ u.i); + u.d = dt; + dice_prng.seed(dice_prng.next() ^ u.i); + for (unit_t *unit : units) { rectf_t wake_range; @@ -136,6 +147,34 @@ void state_t::tick(double now_, double dt_) } } +roll_params_t::roll_params_t(size_t sides_) +{ + sides = sides_; +} + +roll_params_t::roll_params_t(size_t count_, size_t sides_) +{ + count = count_; + sides = sides_; +} + +roll_params_t::roll_params_t(size_t count_, size_t sides_, size_t bonus_) +{ + count = count_; + sides = sides_; + bonus = bonus_; +} + +size_t state_t::roll(roll_params_t *P) +{ + size_t total = 0; + + for (size_t i = 0; i < P->count; i++) + total += dice_prng.next() % P->sides + 1; + + return total + P->bonus; +} + bool load_assets(void) { assets::load(); |