From d192894dc60562c04a98ea0ba361045178e096d7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 13 Oct 2013 19:58:53 +0000 Subject: Added NPC impulse drive. --- src/game/base/npc.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/game/base') diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc index 2cd193b..bb4c180 100644 --- a/src/game/base/npc.cc +++ b/src/game/base/npc.cc @@ -118,6 +118,29 @@ void NPC::frame(const unsigned long elapsed) const float r = 2.0f * (radius() + leader()->radius()); + if (distance > 2.0f * r + 50.0f) { + if (state() == core::Entity::Normal) { + // enable impulse drive + func_impulse(); + } + } else { + if (state() == core::Entity::Impulse) { + + if (leader()->state() != core::Entity::Impulse) { + // disbable impulse drive + func_impulse(); + } + + } else if (state() == core::Entity::Normal) { + + if ((leader()->state() == core::Entity::Impulse) || (leader()->state() == core::Entity::ImpulseInitiate)) { + // enable impulse drive + func_impulse(); + } + } + + } + if (distance > 2.0f * r) { target_thrust = 1.0f; } else if (distance > r) { @@ -136,6 +159,10 @@ void NPC::frame(const unsigned long elapsed) target_afterburner = 0.0f; target_thrust = 0; + + if (state() == core::Entity::Impulse) { + func_impulse(); + } } } } -- cgit v1.2.3