summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/game.hpp9
-rw-r--r--src/game/units.cpp47
2 files changed, 3 insertions, 53 deletions
diff --git a/src/game/game.hpp b/src/game/game.hpp
index c2bc58d..025aa12 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -196,15 +196,6 @@ namespace game {
bool keep_moving(double speed);
bool start_moving(v2f_t dst);
- struct {
- size_t armor_class;
- die_t hit_die;
- } cs;
-
- struct {
- audio::sound_t *attack = NULL;
- } sounds;
-
bool dead = false;
double death_time = -INFINITY;
int health = 1, max_health = 1;
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;
}