diff options
author | Stijn Buys <ingar@osirion.org> | 2013-11-04 16:01:21 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2013-11-04 16:01:21 +0000 |
commit | 5f74a6b0f3e84ec00e68cda63da6e66df33a8149 (patch) | |
tree | 4dff3ee1d4e40ac9b42ec304aefc1a8191cffe2e /src/game/base/npc.cc | |
parent | 8126e1941666f5dccd61e9ecc60db162049bb8ff (diff) |
Added support for NPC patrol routes.
Diffstat (limited to 'src/game/base/npc.cc')
-rw-r--r-- | src/game/base/npc.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc index f8c27d9..0997ed2 100644 --- a/src/game/base/npc.cc +++ b/src/game/base/npc.cc @@ -67,7 +67,7 @@ NPC *NPC::add_wingman(Ship *leader) return npc; } - + NPC::NPC(const Profile profile, const ShipModel *shipmodel) : Ship(0, shipmodel) { npc_profile = profile; @@ -78,6 +78,13 @@ NPC::NPC(const Profile profile, const ShipModel *shipmodel) : Ship(0, shipmodel) npc_leader = 0; } +NPC::~NPC() +{ + if (npc_patrol) { + npc_patrol->erase_member(this); + } +} + void NPC::set_mood(const Mood mood) { npc_mood = mood; @@ -195,6 +202,28 @@ void NPC::frame(const unsigned long elapsed) unset_autopilot_flag(Ship::AutoPilotFormation); } } + + } else if (patrol()) { + // patrol leader behaviour + + // autopilot_target() is set by patrol + if (!autopilot_target()) { + + target_direction = 0; + target_pitch = 0; + target_roll = 0; + target_strafe = 0.0f; + target_vstrafe = 0.0f; + + target_afterburner = 0.0f; + target_thrust = 0; + + if (state() == core::Entity::Impulse) { + + func_impulse(); + } + + } } } |