Changeset 10268 in orxonox.OLD for branches/ai/src
- Timestamp:
- Jan 17, 2007, 5:15:00 PM (18 years ago)
- Location:
- branches/ai/src/world_entities/npcs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ai/src/world_entities/npcs/npc.cc
r10263 r10268 23 23 #include "ai_swarm.h" 24 24 #include "ai_engine.h" 25 26 #include "debug.h" 25 27 26 28 #include "loading/load_param.h" … … 74 76 75 77 78 /** 79 * @brief adds a Weapon to the NPC. 80 * @param weapon the Weapon to add. 81 * @param configID the Configuration ID to add this weapon to. 82 * @param slotID the slotID to add the Weapon to. 83 */ 84 bool NPC::addWeapon(Weapon* weapon, int configID, int slotID) 85 { 86 weapon->setOwner(this->getOwner()); 87 88 89 if(this->weaponMan.addWeapon(weapon, configID, slotID)) 90 { 91 return true; 92 } 93 else 94 { 95 if (weapon != NULL) 96 PRINTF(2)("Unable to add Weapon (%s::%s) to %s::%s\n", 97 weapon->getClassCName(), weapon->getCName(), this->getClassCName(), this->getCName()); 98 else 99 PRINTF(2)("No weapon defined\n"); 100 return false; 101 102 } 103 } 104 105 /** 106 * @brief removes a Weapon. 107 * @param weapon the Weapon to remove. 108 */ 109 void NPC::removeWeapon(Weapon* weapon) 110 { 111 this->weaponMan.removeWeapon(weapon); 112 113 } 114 115 /** 116 * @brief jumps to the next WeaponConfiguration 117 */ 118 void NPC::nextWeaponConfig() 119 { 120 this->weaponMan.nextWeaponConfig(); 121 } 122 123 /** 124 * @brief moves to the last WeaponConfiguration 125 */ 126 void NPC::previousWeaponConfig() 127 { 128 this->weaponMan.previousWeaponConfig(); 129 } 130 131 132 133 134 /** 135 * ticking 136 * @param dt time since last tick 137 */ 76 138 void NPC::tick(float dt) 77 139 { … … 79 141 if (this->bFire) 80 142 weaponMan.fire(); 143 this->bFire = false; 81 144 } -
branches/ai/src/world_entities/npcs/npc.h
r10263 r10268 19 19 virtual void loadParams(const TiXmlElement* root = NULL); 20 20 21 22 bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1); 23 void removeWeapon(Weapon* weapon); 24 void nextWeaponConfig(); 25 void previousWeaponConfig(); 26 inline WeaponManager& getWeaponManager() { return this->weaponMan; }; 27 28 21 29 virtual void tick(float dt); 22 30 inline int getTeam() { return teamNumber; } 31 32 inline void fire() { this->bFire = true; } 23 33 24 34 -
branches/ai/src/world_entities/npcs/npc_test.cc
r10263 r10268 31 31 #include "playable.h" 32 32 33 #include "weapons/test_gun.h" 34 #include "weapons/turret.h" 35 #include "weapons/cannon.h" 36 37 33 38 #include "class_id_DEPRECATED.h" 34 39 … … 45 50 this->loadParams(root); 46 51 52 Weapon* wpRight = new TestGun(0); 53 wpRight->setName("testGun Right"); 54 Weapon* wpLeft = new TestGun(1); 55 wpLeft->setName("testGun Left"); 56 //Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_CANNON)); 47 57 58 //cannon->setName("BFG"); 59 60 this->addWeapon(wpLeft, 1, 0); 61 this->addWeapon(wpRight,1 ,1); 62 //this->addWeapon(cannon, 0, 6); 63 64 this->getWeaponManager().changeWeaponConfig(1); 48 65 // create the weapons and their manager 66 67 this->setHealthMax(100); 68 this->setHealth(80); 69 70 this->getWeaponManager().setSlotCount(7); 71 72 this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0)); 73 this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 74 75 this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0)); 76 this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 77 78 this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5)); 79 this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0))); 80 81 this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5)); 82 this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0))); 83 84 this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5)); 85 this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0))); 86 87 this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5)); 88 this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 89 // 90 this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0)); 91 this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 92 // 93 // this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0)); 94 // this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0))); 95 // 96 // this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0)); 97 // this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 98 99 this->getWeaponManager().getFixedTarget()->setParent(this); 100 this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0); 49 101 50 102 }
Note: See TracChangeset
for help on using the changeset viewer.