summaryrefslogtreecommitdiff
path: root/src/game/units.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-03-28 12:30:38 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-03-28 12:30:38 +0200
commitaa4731d2e1305ea4fb6d59032026bf1ce6f2b65d (patch)
tree789422526638c9f9b539e471ec9badd280c4350f /src/game/units.cpp
parenteafbe41b2ceb77f6fcb5f39b80d683d1e8e1e60e (diff)
Another rebalance: no more randomness in combat.
Diffstat (limited to 'src/game/units.cpp')
-rw-r--r--src/game/units.cpp47
1 files changed, 3 insertions, 44 deletions
diff --git a/src/game/units.cpp b/src/game/units.cpp
index bc3a80d..a0dcee3 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -215,41 +215,6 @@ void unit_t::die(unit_t *killer)
on_death();
}
-void unit_t::try_attack(unit_t *target)
-{
- std::stringstream ss;
- size_t hit_roll;
- size_t dmg_roll;
-
- if (sounds.attack)
- sounds.attack->play();
-
- ss << name << " " << text::get(text::UNIT_ATTACK) << " " << target->name << ": ";
-
- hit_roll = game->roll(die_t(20));
- ss << hit_roll << " vs " << target->cs.armor_class;
-
- if (hit_roll == 1 || hit_roll < target->cs.armor_class) {
- ss << " (" << text::get((hit_roll == 1 ? text::UNIT_CRITICAL_MISS : text::UNIT_MISS)) << ")";
- game->interface->print(ss.str());
- return;
- }
-
- dmg_roll = game->roll(cs.hit_die);
-
- if (hit_roll < 20) {
- ss << ", " << text::get(text::UNIT_DAMAGE) << ": ";
- ss << dmg_roll - cs.hit_die.bonus << " + " << cs.hit_die.bonus << " = " << dmg_roll;
- } else {
- ss << " (" << text::get(text::UNIT_CRITICAL_HIT) << ")" << ", " << text::get(text::UNIT_DAMAGE) << ": ";
- ss << "(" << dmg_roll - cs.hit_die.bonus << " + " << cs.hit_die.bonus << ") x 2 = " << dmg_roll * 2;
- dmg_roll *= 2;
- }
-
- game->interface->print(ss.str());
- target->damage(dmg_roll, this);
-}
-
static unit_t *find_target(world::world_t *world, v2f_t x, float r,
bool friendly)
{
@@ -301,10 +266,6 @@ unit_soldier_t::unit_soldier_t(game::state_t *game) : unit_t(game, UNIT_SOLDIER)
controllable = true;
health = max_health = 20;
- cs.armor_class = 10;
- cs.hit_die = die_t(8);
-
- sounds.attack = &assets::soldier.fire;
}
void unit_soldier_t::check_area(void)
@@ -391,7 +352,8 @@ void unit_soldier_t::target_and_attack(void)
flash->place(&game->world);
last_attack = game->now;
- try_attack(target);
+ assets::soldier.fire.play();
+ target->damage(3, this);
}
void unit_soldier_t::on_think(void)
@@ -550,8 +512,6 @@ unit_spider_t::unit_spider_t(game::state_t *game) : unit_t(game, UNIT_SPIDER)
ignore_waking = false;
health = max_health = 4;
- cs.armor_class = 15;
- cs.hit_die = die_t(3, 6);
}
void unit_spider_t::target_and_attack(void)
@@ -579,8 +539,8 @@ void unit_spider_t::target_and_attack(void)
if (trace.hit)
return;
- try_attack(target);
last_attack = game->now;
+ target->damage(15, this);
}
void unit_spider_t::on_think(void)
@@ -631,7 +591,6 @@ unit_nest_t::unit_nest_t(game::state_t *game_) : unit_t(game_, UNIT_NEST)
ignore_waking = false;
health = max_health = 45;
- cs.armor_class = 5;
next_spawning = game->now + 5.0;
}