From 553c7b9bf9b477544f28123eaeb2ea5714495086 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Nov 2013 20:36:48 +0000 Subject: Moved profile definition from NPC to Patrol. --- src/game/base/game.cc | 4 ++-- src/game/base/npc.cc | 5 ++--- src/game/base/npc.h | 28 +++------------------------- src/game/base/patrol.cc | 7 ++++--- src/game/base/patrol.h | 19 +++++++++++++++---- 5 files changed, 26 insertions(+), 37 deletions(-) (limited to 'src/game/base') diff --git a/src/game/base/game.cc b/src/game/base/game.cc index 46151f9..d5e541b 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -2100,9 +2100,9 @@ bool Game::load_zone(core::Zone *zone) continue; } else if (zoneini.got_key_label("profile", strval)) { if (strval.compare("convoy")) { - patrol->set_profile(NPC::ProfileConvoy); + patrol->set_profile(Patrol::ProfileConvoy); } else if (strval.compare("patrol")) { - patrol->set_profile(NPC::ProfilePatrol); + patrol->set_profile(Patrol::ProfilePatrol); } else { zoneini.unknown_error("unknown profile '" + strval + "'"); } diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc index 0997ed2..fa0ef44 100644 --- a/src/game/base/npc.cc +++ b/src/game/base/npc.cc @@ -21,7 +21,7 @@ NPC *NPC::add_wingman(Ship *leader) return 0; } - NPC *npc = new NPC(ProfileWingman, leader->shipmodel()); + NPC *npc = new NPC(leader->shipmodel()); npc->set_leader(leader); //npc->set_owner(leader->owner()); @@ -68,9 +68,8 @@ NPC *NPC::add_wingman(Ship *leader) return npc; } -NPC::NPC(const Profile profile, const ShipModel *shipmodel) : Ship(0, shipmodel) +NPC::NPC(const ShipModel *shipmodel) : Ship(0, shipmodel) { - npc_profile = profile; npc_mood = MoodWander; npc_destroyed_timestamp = 0; diff --git a/src/game/base/npc.h b/src/game/base/npc.h index 48fff35..8139c9a 100644 --- a/src/game/base/npc.h +++ b/src/game/base/npc.h @@ -17,39 +17,19 @@ class Patrol; class NPC : public Ship { public: - /** - * @brief Definse the general profile of the NPC - * The NPC profile is set at creating time and can not be altered. - * - * Freelancer fallback value - * Convoy Trade convoy member, prefers trade routes - * Patrol Police or military, prefers patrol routes - * Guard Guard an area - * Wingman wingman, prefers protecting its leader - * */ - enum Profile { ProfileFreelancer = 0, ProfileConvoy = 1, ProfilePatrol = 2, ProfileGuard = 3, ProfileWingman = 4 }; - /** * @brief Defines the general moode of the NPC * Wander Wamder around * Formation Follow the leader in formation + * Attack Attack at will * */ - enum Mood { MoodWander = 0, MoodFormation = 1 }; + enum Mood { MoodWander = 0, MoodFormation = 1, MoodAttack = 2}; - NPC(const Profile profile, const ShipModel *shipmodel); + NPC(const ShipModel *shipmodel); virtual ~NPC(); /* ---- inspectors ----------------------------------------- */ - /** - * @brief Treturns te general profile of the NPC - * The NPC profile is set at creating time and can not be altered. - * */ - inline const Profile profile() const - { - return npc_profile; - } - /** * @brief returns the general moode of the NPC * */ @@ -103,8 +83,6 @@ public: static NPC *add_wingman(Ship *leader); private: - Profile npc_profile; - Mood npc_mood; Ship *npc_leader; diff --git a/src/game/base/patrol.cc b/src/game/base/patrol.cc index f3cfa07..fbe02df 100644 --- a/src/game/base/patrol.cc +++ b/src/game/base/patrol.cc @@ -62,7 +62,7 @@ Patrol::Patrol() : core::Entity() patrol_faction = 0; - patrol_profile = NPC::ProfilePatrol; + patrol_profile = ProfilePatrol; patrol_waypoint_current == patrol_waypoints.end(); @@ -98,7 +98,7 @@ Patrol::~Patrol() patrol_members.clear(); } -void Patrol::set_profile(const NPC::Profile profile) +void Patrol::set_profile(const Profile profile) { patrol_profile = profile; } @@ -302,7 +302,8 @@ void Patrol::frame(const unsigned long elapsed) for (size_t i = 0; i < nbships; i++) { // add NPC - NPC *npc = new NPC(patrol_profile, npctype->shipmodel()); + NPC *npc = new NPC(npctype->shipmodel()); + npc->set_mood(NPC::MoodFormation); // set NPC name if (npctype->name().size()) { diff --git a/src/game/base/patrol.h b/src/game/base/patrol.h index e4ba19b..cc3bf61 100644 --- a/src/game/base/patrol.h +++ b/src/game/base/patrol.h @@ -27,6 +27,17 @@ namespace game class Patrol: public core::Entity { public: + /** + * @brief Definse the general profile of the patrol + * The NPC profile is set at creating time and can not be altered. + * + * Freelancer fallback value + * Convoy Trade convoy member, prefers trade routes + * Patrol Police or military, prefers patrol routes + * Guard Guard an area + * Wingman wingman, prefers protecting its leader + * */ + enum Profile { ProfileFreelancer = 0, ProfileConvoy = 1, ProfilePatrol = 2, ProfileGuard = 3, ProfileWingman = 4 }; /* --- WayPoint -------------------------------------------- */ @@ -84,7 +95,7 @@ public: Patrol(); virtual ~Patrol(); - inline const NPC::Profile profile() const { + inline const Profile profile() const { return patrol_profile; } @@ -104,7 +115,7 @@ public: return patrol_faction; } - void set_profile(const NPC::Profile profile); + void set_profile(const Profile profile); void set_faction(Faction *faction); @@ -118,7 +129,7 @@ public: void add_member(NPC *npc); - void erase_member(NPC *npc); + void erase_member(NPC *npc); private: void set_leader(); @@ -133,7 +144,7 @@ private: NPCTypes patrol_npctypes; - NPC::Profile patrol_profile; + Profile patrol_profile; NPC *patrol_leader; -- cgit v1.2.3