From e4be331008ca5e64ef2d42f51c5cf5799dd61abc Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Wed, 25 Apr 2018 18:27:13 +0200 Subject: Ammunition mechanic for soldiers. --- src/game/unit_soldier.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/game/unit_soldier.cpp') diff --git a/src/game/unit_soldier.cpp b/src/game/unit_soldier.cpp index f2caaf3..4747060 100644 --- a/src/game/unit_soldier.cpp +++ b/src/game/unit_soldier.cpp @@ -57,6 +57,7 @@ unit_soldier_t::unit_soldier_t(game::state_t *game) : unit_t(game, UNIT_SOLDIER) controllable = true; health = max_health = 28; + storage.max_shells = storage.shells = 20; storage.max_grenades = storage.grenades = 3; } @@ -112,6 +113,14 @@ void unit_soldier_t::fire_shotgun(v2f_t aim) if (next_attack && game->time < next_attack) return; + if (!storage.shells) { + next_attack = game->time + SEC(1); + say("Keine Munition mehr!"); + return; + } + + storage.shells--; + trace = world->ray_v_all_p3d(x, aim, CF_SOLID|CF_BODY|CF_BODY_SMALL, -1, this); if (!manual_firing && trace.hit && trace.ent && trace.ent->type == ET_UNIT) { -- cgit