- Timestamp:
- Jan 17, 2007, 4:27:43 PM (18 years ago)
- Location:
- branches/ai/src/world_entities/npcs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ai/src/world_entities/npcs/npc.cc
r9869 r10263 18 18 19 19 20 #include "movement_module.h" 21 #include "ai_module.h" 22 #include "ai_team.h" 23 #include "ai_swarm.h" 24 #include "ai_engine.h" 25 26 #include "loading/load_param.h" 27 28 20 29 #include "npc.h" 21 30 … … 23 32 24 33 NPC::NPC(const TiXmlElement* root) 34 : weaponMan(this) 25 35 { 26 36 this->registerObject(this, NPC::_objectList); … … 28 38 this->toList(OM_GROUP_00); 29 39 40 std::cout << "Team Number: " << teamNumber << "\n"; 41 std::cout << "Swarm Number:" << swarmNumber << "\n"; 42 //aiModule=new MovementModule(this); 43 //AIEngine::getInstance()->addAI(teamNumber,swarmNumber,aiModule); 44 AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this); 45 46 this->bFire = false; 47 30 48 } 31 49 32 50 33 NPC::~NPC () {} 34 35 36 37 /** 38 * adds an AI to this NPC 39 */ 40 void NPC::addAI(AI* ai) 41 {} 51 NPC::~NPC () 52 { 53 AIEngine::getInstance()->removeAI(teamNumber,swarmNumber,(WorldEntity*)this); 54 } 42 55 43 56 … … 50 63 { 51 64 WorldEntity::loadParams(root); 65 66 LoadParam(root, "team", this, NPC, setTeamNumber) 67 .describe("this sets the team number") 68 .defaultValues(0); 69 70 LoadParam(root, "swarm", this, NPC, setSwarmNumber) 71 .describe("this sets the swarm number") 72 .defaultValues(0); 52 73 } 53 74 75 76 void NPC::tick(float dt) 77 { 78 this->weaponMan.tick(dt); 79 if (this->bFire) 80 weaponMan.fire(); 81 } -
branches/ai/src/world_entities/npcs/npc.h
r10138 r10263 4 4 5 5 #include "world_entity.h" 6 #include "ai_module.h" 7 #include "world_entities/weapons/weapon_manager.h" 6 8 7 9 class AI; 8 10 9 class NPC : public WorldEntity { 11 class NPC : public WorldEntity 12 { 10 13 ObjectListDeclaration(NPC); 11 public: 12 NPC (const TiXmlElement* root); 14 15 public: 16 NPC(const TiXmlElement* root = NULL); 13 17 virtual ~NPC (); 14 18 15 19 virtual void loadParams(const TiXmlElement* root = NULL); 16 20 17 void addAI(AI* ai); 21 virtual void tick(float dt); 22 inline int getTeam() { return teamNumber; } 23 24 25 private: 26 inline void setTeamNumber(int number) { teamNumber=number; } 27 inline void setSwarmNumber(int number) { swarmNumber=number; } 18 28 19 29 20 30 private: 21 31 32 int teamNumber; //!< number of the team 33 int swarmNumber; //!< number of the swarm 34 int difficulty; //!< difficulty 35 36 WeaponManager weaponMan; //!< weapon manager 37 bool bFire; //!< fire 38 39 AIModule* aiModule; 22 40 }; 23 41 -
branches/ai/src/world_entities/npcs/npc_test.cc
r10226 r10263 32 32 33 33 #include "class_id_DEPRECATED.h" 34 #include "movement_module.h" 35 #include "ai_module.h" 36 #include "ai_team.h" 37 #include "ai_swarm.h" 38 #include "ai_engine.h" 34 39 35 40 36 ObjectListDefinitionID(NPC2, CL_NPC_TEST2); … … 42 38 43 39 44 NPC2::NPC2(const TiXmlElement* root) : NPC(NULL)40 NPC2::NPC2(const TiXmlElement* root) 45 41 { 46 42 this->registerObject(this, NPC2::_objectList); 47 43 48 49 44 if (root != NULL) 45 this->loadParams(root); 50 46 51 std::cout << "Team Number: " << teamNumber << "\n"; 52 std::cout << "Swarm Number:" << swarmNumber << "\n"; 53 //aiModule=new MovementModule(this); 54 //AIEngine::getInstance()->addAI(teamNumber,swarmNumber,aiModule); 55 AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this); 47 48 // create the weapons and their manager 49 56 50 } 57 51 58 52 NPC2::~NPC2() 59 53 { 60 AIEngine::getInstance()->removeAI(teamNumber,swarmNumber,(WorldEntity*)this);61 54 } 62 55 … … 65 58 NPC::loadParams(root); 66 59 67 LoadParam(root, "team", this, NPC2, setTeamNumber)68 .describe("this sets the team number")69 .defaultValues(0);70 71 LoadParam(root, "swarm", this, NPC2, setSwarmNumber)72 .describe("this sets the swarm number")73 .defaultValues(0);74 60 } 75 61 … … 78 64 void NPC2::tick(float dt) 79 65 { 80 // animating the md2 model 81 if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(MD2Model::staticClassID())) 82 ((MD2Model*)this->getModel(0))->tick(dt); 66 67 68 69 70 // animating the md2 model 71 if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(MD2Model::staticClassID())) 72 ((MD2Model*)this->getModel(0))->tick(dt); 83 73 } 84 74 -
branches/ai/src/world_entities/npcs/npc_test.h
r10138 r10263 4 4 5 5 #include "npc.h" 6 #include "ai_module.h" 6 7 7 8 8 9 class AI; … … 10 11 class AIModule; 11 12 12 class NPC2 : public NPC { 13 ObjectListDeclaration(NPC2); 13 class NPC2 : public NPC 14 { 15 ObjectListDeclaration(NPC2); 14 16 15 public: 16 NPC2 (const TiXmlElement* root); 17 virtual ~NPC2 (); 18 virtual void loadParams(const TiXmlElement* root); 19 virtual void tick(float dt); 20 inline int getTeam(){return teamNumber;} 17 public: 18 NPC2 (const TiXmlElement* root); 19 virtual ~NPC2 (); 20 virtual void loadParams(const TiXmlElement* root); 21 virtual void tick(float dt); 21 22 22 23 23 private:24 inline void setTeamNumber(int number){teamNumber=number;}25 inline void setSwarmNumber(int number){swarmNumber=number;}26 24 27 int teamNumber;28 int swarmNumber;29 int difficulty;30 25 31 AIModule* aiModule; 26 private: 27 32 28 }; 33 29
Note: See TracChangeset
for help on using the changeset viewer.