summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-04-01 14:04:53 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-04-01 14:04:53 +0200
commit020e91ca69f35329eae518f3fe92afba2e117d06 (patch)
treee7205023072b5d3a6bba4806c9663a7be469184f /src/game
parent2c8e84a3d2fe93f84d0ffca63967e81a03534c00 (diff)
Remove the fear mechanic.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/assets.cpp1
-rw-r--r--src/game/game.cpp30
-rw-r--r--src/game/game.hpp20
-rw-r--r--src/game/text.cpp27
-rw-r--r--src/game/unit_nest.cpp6
-rw-r--r--src/game/unit_soldier.cpp102
-rw-r--r--src/game/unit_spider.cpp2
7 files changed, 14 insertions, 174 deletions
diff --git a/src/game/assets.cpp b/src/game/assets.cpp
index 8ca0592..46c1b81 100644
--- a/src/game/assets.cpp
+++ b/src/game/assets.cpp
@@ -36,7 +36,6 @@ void load(void)
soldier.body_idle.load("assets/units/soldier/body_idle", 2, 2, 2);
soldier.body_aiming.load("assets/units/soldier/body_aiming", 2, 2, 2);
soldier.body_firing.load("assets/units/soldier/body_firing", 2, 2, 2);
- soldier.body_panic.load("assets/units/soldier/body_panic_", 2);
soldier.legs_idle.load("assets/units/soldier/legs_idle", 2, 2);
soldier.legs_walking.load("assets/units/soldier/legs_walking", 2, 2);
soldier.dead.load("assets/units/soldier/dead_", 1);
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 27db5e5..d82cff0 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -300,7 +300,7 @@ void state_t::tick(ntime_t time_)
while (frames_since_t0 < target) {
// FIXME: Is this non-deterministic enough?
- dice_prng.seed(dice_prng.next() ^ time);
+ prng.seed(prng.next() ^ time);
// setting up old variables (refactor them out eventually)
now = time * 1.0e-9;
@@ -388,34 +388,6 @@ void state_t::compute_ambience(render::state_t *render)
}
}
-die_t::die_t(size_t sides_)
-{
- sides = sides_;
-}
-
-die_t::die_t(size_t count_, size_t sides_)
-{
- count = count_;
- sides = sides_;
-}
-
-die_t::die_t(size_t count_, size_t sides_, size_t bonus_)
-{
- count = count_;
- sides = sides_;
- bonus = bonus_;
-}
-
-size_t state_t::roll(die_t die)
-{
- size_t total = 0;
-
- for (size_t i = 0; i < die.count; i++)
- total += dice_prng.next() % die.sides + 1;
-
- return total + die.bonus;
-}
-
bool load_assets(void)
{
assets::load();
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 517f74a..29b3d3b 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -59,7 +59,6 @@ namespace game {
typedef struct {
render::oriented_sprite_4M_t head_idle, body_idle;
render::oriented_sprite_4M_t body_aiming, body_firing;
- render::animated_texture_t body_panic;
render::oriented_sprite_4M2_t legs_idle, legs_walking;
render::animated_texture_t dead;
@@ -120,19 +119,10 @@ namespace game {
SAY_STOPPING_GROUP,
SAY_FIRING,
SAY_FIRING_GROUP,
- SAY_PANIC,
UNIT_NAME_SPIDER,
UNIT_NAME_SOLDIER,
UNIT_NAME_NEST,
- UNIT_DEATH,
- UNIT_ATTACK,
- UNIT_MISS,
- UNIT_CRITICAL_MISS,
- UNIT_CRITICAL_HIT,
- UNIT_DAMAGE,
- UNIT_SAVING_THROW_WILLPOWER,
- UNIT_SAVING_THROW_SUCCESS,
- UNIT_SAVING_THROW_FAILURE
+ UNIT_DEATH
} index_t;
std::string get(index_t index);
@@ -234,14 +224,6 @@ namespace game {
sf::Color selection_color;
- double next_fear_test = -INFINITY;
- size_t willpower_bonus;
- size_t fear_dc;
-
- bool panic = false;
- double panic_end;
- double panic_turn;
-
bool manual_firing = false;
v2f_t manual_firing_target;
diff --git a/src/game/text.cpp b/src/game/text.cpp
index 75fb032..dfb2aef 100644
--- a/src/game/text.cpp
+++ b/src/game/text.cpp
@@ -64,9 +64,6 @@ static std::string get_english(index_t index)
case SAY_FIRING_GROUP:
return "Firing!";
- case SAY_PANIC:
- return "I'm not getting paid enough for this!";
-
case UNIT_NAME_SPIDER:
return "Spider";
@@ -79,30 +76,6 @@ static std::string get_english(index_t index)
case UNIT_DEATH:
return "died";
- case UNIT_ATTACK:
- return "attacks";
-
- case UNIT_MISS:
- return "miss";
-
- case UNIT_CRITICAL_MISS:
- return "critical miss";
-
- case UNIT_CRITICAL_HIT:
- return "critical hit";
-
- case UNIT_DAMAGE:
- return "deals damage";
-
- case UNIT_SAVING_THROW_WILLPOWER:
- return "makes a saving throw for willpower";
-
- case UNIT_SAVING_THROW_SUCCESS:
- return "success";
-
- case UNIT_SAVING_THROW_FAILURE:
- return "failure";
-
default:
abort();
}
diff --git a/src/game/unit_nest.cpp b/src/game/unit_nest.cpp
index 326741e..9b3e1e1 100644
--- a/src/game/unit_nest.cpp
+++ b/src/game/unit_nest.cpp
@@ -44,8 +44,8 @@ void spawn_spider(game::state_t *game, v2f_t nest)
world::cmodel_t cmodel;
unit_spider_t *spider;
- offset = game->dice_prng.unit_vec2();
- x = nest + offset * (game->dice_prng.next_float() * 0.2 + 0.4);
+ offset = game->prng.unit_vec2();
+ x = nest + offset * (game->prng.next_float() * 0.2 + 0.4);
cmodel.bounds = rectf_t(v2f_t(-0.5f, -0.5f), v2f_t(0.5f, 0.5f)) + x;
cmodel.cflags = CF_SOLID | CF_WATER | CF_BODY_SMALL;
@@ -67,7 +67,7 @@ void unit_nest_t::on_think(void)
return;
spawn_spider(game, x);
- next_spawning = game->now + game->dice_prng.next_float() * 10 + 5;
+ next_spawning = game->now + game->prng.next_float() * 10 + 5;
}
void unit_nest_t::on_spawn(void)
diff --git a/src/game/unit_soldier.cpp b/src/game/unit_soldier.cpp
index 152f475..e7d3849 100644
--- a/src/game/unit_soldier.cpp
+++ b/src/game/unit_soldier.cpp
@@ -44,12 +44,8 @@ void unit_soldier_t::check_area(void)
bounds[0] = x - v2f_t(10, 10);
bounds[1] = x + v2f_t(10, 10);
- willpower_bonus = 0;
- fear_dc = 0;
-
for (world::entity_t *went : game->world.get_entities(bounds, -1)) {
auto ent = dynamic_cast<game::entity_t*>(went);
- unit_t *unit;
// WTF?
if (!ent)
@@ -65,23 +61,6 @@ void unit_soldier_t::check_area(void)
if (!ent->awake)
ent->wake();
}
-
- if (ent->type != ET_UNIT)
- continue;
-
- unit = (unit_t*)ent;
-
- if (unit->dead)
- continue;
-
- if (unit->friendly)
- willpower_bonus += 6;
- else {
- if (unit->type == UNIT_NEST)
- fear_dc += 6;
- else
- fear_dc += 4;
- }
}
}
@@ -145,78 +124,20 @@ void unit_soldier_t::target_and_attack(void)
last_target_x = target->x;
skip_targetting:
- if (last_attack + game->dice_prng.next_float(1.4f, 1.6f) > game->now)
+ if (last_attack + game->prng.next_float(1.4f, 1.6f) > game->now)
return;
- shoot(spread_aim(aim, 0.2, &game->dice_prng));
+ shoot(spread_aim(aim, 0.2, &game->prng));
}
void unit_soldier_t::on_think(void)
{
check_area();
+ target_and_attack();
- if (panic && game->now > panic_end) {
- move.moving = false;
- move.path.clear();
- panic = false;
- controllable = true;
- }
-
- if (health == max_health)
- willpower_bonus += 3;
- else if (fear_dc > 1 && health < max_health / 2)
- fear_dc += 3;
-
- if (!panic && fear_dc > 1 && game->now > next_fear_test) {
- size_t roll;
- bool success;
- std::stringstream ss;
-
- roll = game->roll(die_t(20));
- success = roll + willpower_bonus >= fear_dc;
-
- ss << name << " " << text::get(text::UNIT_SAVING_THROW_WILLPOWER);
- ss << ": " << roll << " + " << willpower_bonus << " = " << roll + willpower_bonus;
- ss << " vs " << fear_dc << ": ";
-
- if (success)
- ss << text::get(text::UNIT_SAVING_THROW_SUCCESS);
- else
- ss << text::get(text::UNIT_SAVING_THROW_FAILURE);
-
- game->interface->print(ss.str());
-
- if (!success) {
- say(text::get(text::SAY_PANIC));
- panic = true;
- panic_end = game->now + 10;
- panic_turn = -INFINITY;
- controllable = false;
- }
-
- next_fear_test = game->now + 3;
- }
-
- if (!panic) {
- target_and_attack();
-
- keep_moving(2.0);
- if (!move.moving)
- move_marker.reset();
- } else {
- move.moving = true;
- keep_moving(3.0);
-
- if (game->now >= panic_turn) {
- v2f_t t;
-
- t = game->dice_prng.unit_vec2();
-
- move.path.clear();
- move.path.push_back(x + t * 10);
- panic_turn = game->now + 0.3;
- }
- }
+ keep_moving(2.0);
+ if (!move.moving)
+ move_marker.reset();
if (move.moving && (x - move.last_step).len() > 0.5f) {
move.last_step = x;
@@ -250,9 +171,6 @@ void unit_soldier_t::render_to(render::state_t *render)
else
selection_color = sf::Color::Red;
- if (panic && (game->now - floor(game->now) > 0.5))
- selection_color = sf::Color::Blue;
-
render->render(0.0, &assets::unit_selected, cmodel.bounds, selection_color);
}
@@ -265,7 +183,7 @@ void unit_soldier_t::render_to(render::state_t *render)
else
legs = &assets::soldier.legs_idle;
- if (!panic && (manual_firing || last_target_time + 3 > game->now)) {
+ if (manual_firing || last_target_time + 3 > game->now) {
if (last_attack + 0.1 > game->now)
body = &assets::soldier.body_firing;
else
@@ -279,11 +197,7 @@ void unit_soldier_t::render_to(render::state_t *render)
}
render->render(game->now * 10, legs, render_bounds, move.angle);
-
- if (panic)
- render->render(game->now * 10, &assets::soldier.body_panic, render_bounds);
- else
- render->render(game->now * 10, body, render_bounds, body_angle);
+ render->render(game->now * 10, body, render_bounds, body_angle);
render->render(game->now * 10, &assets::soldier.head_idle, render_bounds, body_angle);
} else
diff --git a/src/game/unit_spider.cpp b/src/game/unit_spider.cpp
index ed6b0f0..9d1ec30 100644
--- a/src/game/unit_spider.cpp
+++ b/src/game/unit_spider.cpp
@@ -48,7 +48,7 @@ void unit_spider_t::target_and_attack(void)
return;
start_moving(target->x);
- next_targetting = game->now + game->dice_prng.next_float(0.2f, 0.4f);
+ next_targetting = game->now + game->prng.next_float(0.2f, 0.4f);
if (last_attack + 0.5 > game->now)
return;