From 020e91ca69f35329eae518f3fe92afba2e117d06 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sun, 1 Apr 2018 14:04:53 +0200 Subject: Remove the fear mechanic. --- src/game/unit_soldier.cpp | 102 ++++------------------------------------------ 1 file changed, 8 insertions(+), 94 deletions(-) (limited to 'src/game/unit_soldier.cpp') 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(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 -- cgit