diff options
Diffstat (limited to 'src/game/unit_scientist.cpp')
-rw-r--r-- | src/game/unit_scientist.cpp | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/src/game/unit_scientist.cpp b/src/game/unit_scientist.cpp index a432241..bac2a23 100644 --- a/src/game/unit_scientist.cpp +++ b/src/game/unit_scientist.cpp @@ -51,11 +51,55 @@ unit_scientist_t::unit_scientist_t(game::state_t *game) : unit_t(game, UNIT_SCIE health = max_health = 15; } +void unit_scientist_t::gather_crystals(void) +{ + rectf_t rect; + world::trace_t trace; + bool found = true; + deco_t *deco; + + if (!move.moving) + start_moving(gathering_at); + + if ((x - gathering_at).len() > 0.5f) + return; + + trace = game->world.ray_v_all(x, gathering_at, CF_SOLID|CF_DECOS, this); + if (!trace.hit || !trace.ent || trace.ent->type != ET_DECO) { + found = false; + goto out; + } + + deco = dynamic_cast<deco_t*>(trace.ent); + if (deco->type != DECO_CRYSTAL) { + found = false; + goto out; + } + + deco->type = DECO_CRYSTAL_BROKEN; + assets::scientist.gather.play_3d(x); + + if (!last_laugh || game->time - last_laugh > MSEC(750)) { + assets::scientist.laugh.play_3d(x); + last_laugh = game->time; + } + +out: + if (!found) + say("Здесь ничего нет!"); + + gathering = false; + gather_marker.reset(); +} + void unit_scientist_t::on_think(void) { keep_moving(4.0); game->wake_area(x); + if (gathering) + gather_crystals(); + if (!move.moving) move_marker.reset(); @@ -65,9 +109,10 @@ void unit_scientist_t::on_think(void) } } -void unit_scientist_t::on_damage(unit_t *attacker) +void unit_scientist_t::on_spawn(void) { - + assets::scientist.laugh.play_3d(x); + last_laugh = game->time; } void unit_scientist_t::on_death(void) |