Changeset 9656 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Aug 4, 2006, 11:01:28 PM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 32 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/WorldEntities.am
r9235 r9656 5 5 world_entities/npcs/ground_turret.cc \ 6 6 world_entities/npcs/space_turret.cc \ 7 world_entities/npcs/network_turret.cc \ 7 8 world_entities/npcs/generic_npc.cc \ 8 9 world_entities/npcs/door.cc \ … … 79 80 npcs/ground_turret.h \ 80 81 npcs/space_turret.h \ 82 npcs/network_turret.h \ 81 83 npcs/door.cc \ 82 84 npcs/repair_station.h \ -
trunk/src/world_entities/bsp_entity.cc
r9406 r9656 54 54 this->bspManager = NULL; 55 55 56 this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name" ) );56 this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name", PERMISSION_MASTER_SERVER ) ); 57 57 58 58 this->setSynchronized( true ); -
trunk/src/world_entities/environments/model_entity.cc
r9406 r9656 36 36 this->speed = NULL; 37 37 this->momentum = NULL; 38 39 this->setSynchronized(true); 38 40 39 41 if (root != NULL) -
trunk/src/world_entities/environments/water.cc
r9406 r9656 59 59 // To test the Wave equation 60 60 //this->wave(5.0,4.0, 1, 10); 61 62 height_handle = registerVarId( new SynchronizeableFloat( &height, &height, "height" ) );63 resX_handle = registerVarId( new SynchronizeableUInt( &resX, &resX, "resX" ) );64 resY_handle = registerVarId( new SynchronizeableUInt( &resY, &resY, "resY" ) );65 sizeX_handle = registerVarId( new SynchronizeableFloat( &sizeX, &sizeX, "sizeX" ) );66 sizeY_handle = registerVarId( new SynchronizeableFloat( &sizeY, &sizeY, "sizeY" ) );61 62 height_handle = registerVarId( new SynchronizeableFloat( &height, &height, "height", PERMISSION_MASTER_SERVER ) ); 63 resX_handle = registerVarId( new SynchronizeableUInt( &resX, &resX, "resX", PERMISSION_MASTER_SERVER ) ); 64 resY_handle = registerVarId( new SynchronizeableUInt( &resY, &resY, "resY", PERMISSION_MASTER_SERVER ) ); 65 sizeX_handle = registerVarId( new SynchronizeableFloat( &sizeX, &sizeX, "sizeX", PERMISSION_MASTER_SERVER ) ); 66 sizeY_handle = registerVarId( new SynchronizeableFloat( &sizeY, &sizeY, "sizeY", PERMISSION_MASTER_SERVER ) ); 67 67 } 68 68 … … 313 313 this->rebuildGrid(); 314 314 } 315 315 316 316 WorldEntity::varChangeHandler( id ); 317 317 } -
trunk/src/world_entities/npcs/ground_turret.cc
r9406 r9656 39 39 */ 40 40 GroundTurret::GroundTurret(const TiXmlElement* root) 41 : NPC(root)41 : NPC(root) 42 42 { 43 43 this->init(); … … 52 52 GroundTurret::~GroundTurret () 53 53 { 54 55 54 } 56 55 … … 80 79 81 80 /** 82 * loads a GroundTurret from a XML-element81 * @brief loads a GroundTurret from a XML-element 83 82 * @param root the XML-element to load from 84 83 * @todo make the class Loadable … … 88 87 // all the clases this Entity is directly derived from must be called in this way, to load all settings. 89 88 NPC::loadParams(root); 90 91 89 92 90 /** … … 126 124 void GroundTurret::tick(float dt) 127 125 { 128 if(this->getHealth() > 0.0f && State::getPlayer() && 129 State::getPlayer()->getPlayable() && 130 State::getPlayer()->getPlayable()->distance(this) < 120) // HACK 126 if(this->getHealth() > 0.0f 127 ) // HACK <--- YOU ARE THE MOTHERFUCKER 131 128 { 132 if (likely(this->left != NULL))133 {134 // this->left->tickW(dt);135 this->left->requestAction(WA_SHOOT);136 }137 if (likely(this->right != NULL))138 {139 // this->right->tickW(dt);140 this->right->requestAction(WA_SHOOT);141 }129 if (likely(this->left != NULL)) 130 { 131 // this->left->tickW(dt); 132 this->left->requestAction(WA_SHOOT); 133 } 134 if (likely(this->right != NULL)) 135 { 136 // this->right->tickW(dt); 137 this->right->requestAction(WA_SHOOT); 138 } 142 139 } 143 140 } … … 164 161 void GroundTurret::postSpawn () 165 162 { 166 167 163 } 168 164 … … 173 169 void GroundTurret::leftWorld () 174 170 { 175 176 171 } 177 172 -
trunk/src/world_entities/npcs/ground_turret.h
r9235 r9656 15 15 { 16 16 17 17 public: 18 18 GroundTurret(const TiXmlElement* root = NULL); 19 19 virtual ~GroundTurret(); 20 20 21 void init();22 21 virtual void loadParams(const TiXmlElement* root); 23 22 … … 30 29 virtual void tick(float time); 31 30 32 private: 33 PNode weaponHolder[2]; 34 Weapon *left, *right; 31 private: 32 void init(); 33 34 35 private: 36 PNode weaponHolder[2]; 37 Weapon *left, *right; 35 38 }; 36 39 -
trunk/src/world_entities/npcs/space_turret.cc
r9235 r9656 74 74 this->weaponHolder[0].setParent(this); 75 75 this->weaponHolder[1].setParent(this); 76 77 this->wLeftHandle = registerVarId( new SynchronizeableString( &this->wLeft, &this->wLeft, "weapon-left", PERMISSION_MASTER_SERVER ) ); 78 this->wRightHandle = registerVarId( new SynchronizeableString( &this->wRight, &this->wRight, "weapon-right", PERMISSION_MASTER_SERVER ) ); 79 76 80 } 77 81 … … 98 102 if (this->left) 99 103 { 104 this->wLeft = element->Value(); 105 100 106 this->left->setParent(this); 101 107 this->left->toList(this->getOMListNumber()); … … 110 116 if (this->right) 111 117 { 118 this->wRight = element->Value(); 119 112 120 this->right->setParent(this); 113 121 this->right->toList(this->getOMListNumber()); … … 117 125 } 118 126 } 127 128 129 /** 130 * sets the left weapon called from net sync 131 * @param wLeft the left weapon string 132 */ 133 void SpaceTurret::setWeaponLeft(const std::string& wLeft) 134 { 135 136 } 137 138 /** 139 * sets the left weapon called from net sync 140 * @param wRught the right weapon string 141 */ 142 void SpaceTurret::setWeaponRight(const std::string& wRight) 143 {} 119 144 120 145 /** … … 198 223 199 224 } 225 226 227 228 /** 229 * handler for changes on registred vars 230 * @param id id's which changed 231 */ 232 void SpaceTurret::varChangeHandler( std::list< int > & id ) 233 { 234 if ( std::find( id.begin(), id.end(), this->wLeftHandle ) != id.end()) 235 { 236 this->setWeaponLeft(this->wLeft); 237 } 238 239 if ( std::find( id.begin(), id.end(), this->wRightHandle ) != id.end() ) 240 { 241 this->setWeaponRight(this->wRight); 242 } 243 244 245 WorldEntity::varChangeHandler( id ); 246 } 247 -
trunk/src/world_entities/npcs/space_turret.h
r9235 r9656 8 8 9 9 #include "npcs/npc.h" 10 11 #include <string> 12 #include <list> 13 10 14 11 15 class Weapon; … … 20 24 21 25 virtual void loadParams(const TiXmlElement* root); 26 virtual void varChangeHandler( std::list< int > & id ); 27 28 29 void setWeaponLeft(const std::string& wLeft); 30 void setWeaponRight(const std::string& wRight); 22 31 23 32 virtual void postSpawn (); … … 36 45 PNode weaponHolder[2]; 37 46 Weapon *left, *right; 47 48 std::string wLeft; 49 std::string wRight; 50 int wLeftHandle; 51 int wRightHandle; 38 52 }; 39 53 -
trunk/src/world_entities/playable.cc
r9406 r9656 68 68 69 69 70 registerVar( new SynchronizeableInt( &score, &score, "score" ) ); 70 this->teamChangeHandler = registerVarId( new SynchronizeableInt( &this->teamId, &this->teamId, "team-id", PERMISSION_MASTER_SERVER ) ); 71 72 registerVar( new SynchronizeableInt( &score, &score, "score", PERMISSION_MASTER_SERVER ) ); 71 73 registerVar( new SynchronizeableBool( &bFire, &bFire, "bFire", PERMISSION_OWNER)); 72 74 } … … 139 141 bool Playable::addWeapon(Weapon* weapon, int configID, int slotID) 140 142 { 143 weapon->setOwner(this->getOwner()); 144 145 141 146 if(this->weaponMan.addWeapon(weapon, configID, slotID)) 142 147 { … … 272 277 return false; 273 278 } 279 280 281 /** 282 * @brief sets the TeamID and all the properties needed to be visible on the Playable 283 * @param teamID: the new TeamID of the Entity 284 */ 285 void Playable::setTeam(int teamID) 286 { 287 /// Derive this function to make it look different with differen groups. 288 PRINTF(4)("No special team specific function implemented for %s::%s in Team %d\n", this->getClassCName(), this->getCName(), teamID); 289 } 290 274 291 275 292 /** … … 512 529 "FirstPerson" 513 530 }; 531 532 533 /** 534 * handler for changes on registred vars 535 * @param id id's which changed 536 */ 537 void Playable::varChangeHandler( std::list< int > & id ) 538 { 539 if ( std::find( id.begin(), id.end(), this->teamChangeHandler) != id.end() ) 540 { 541 this->setTeam(this->teamId); 542 } 543 544 WorldEntity::varChangeHandler(id); 545 } -
trunk/src/world_entities/playable.h
r9406 r9656 11 11 #include "event.h" 12 12 #include <vector> 13 #include <list> 13 14 14 15 #include "world_entities/weapons/weapon_manager.h" … … 43 44 44 45 virtual void loadParams(const TiXmlElement* root); 46 void varChangeHandler( std::list< int > & id ); 45 47 46 48 // Weapon and Pickups … … 62 64 inline const std::vector<int>& getEventList() { return this->events; }; 63 65 66 64 67 // Camera and Playmode 65 68 void attachCamera(); … … 72 75 void setPlayDirection(float angle, float dirX, float dirY, float dirZ, float speed = 0.0f); 73 76 77 // Networking interface 74 78 inline void setScore( int score ) { this->score = score; } 75 79 inline int getScore() { return this->score; } 80 inline void setTeamId( int teamId) { this->teamId = teamId;} 81 inline int getTeamId() const { return this->teamId; } 82 virtual void setTeam(int teamID); 83 76 84 77 85 void setEnterRadius(float radius) { this->enterRadius = radius; }; … … 85 93 virtual void tick(float dt); 86 94 95 96 inline bool beFire() const { return this->bFire; } 97 inline void fire(bool bF) { this->bFire = bF;} 98 87 99 // Transformations: 88 100 static Playable::Playmode stringToPlaymode(const std::string& playmode); 89 101 static const std::string& playmodeToString(Playable::Playmode playmode); 90 102 static const std::string playmodeNames[]; 91 92 inline bool beFire(){ return this->bFire; }93 inline void fire(bool bF){ this->bFire = bF;}94 103 95 104 protected: … … 117 126 118 127 int score; //!< players score 128 int teamChangeHandler; //!< handler id for team changes network sync 129 int teamId; //!< id of the current team 119 130 120 131 bool bDead; … … 124 135 float enterRadius; //!< How far one can be away from the Playable to enter it. 125 136 126 WorldEntity* collider;137 WorldEntity* collider; 127 138 }; 128 139 -
trunk/src/world_entities/power_ups/param_power_up.cc
r9406 r9656 43 43 if( root != NULL) 44 44 this->loadParams(root); 45 46 registerVar( new SynchronizeableInt( (int*)&type, (int*)&type, "type" ) );47 registerVar( new SynchronizeableFloat( &value, &value, "value" ) );48 registerVar( new SynchronizeableFloat( &max_value, &max_value, "max_value" ) );49 registerVar( new SynchronizeableFloat( &min_value, &min_value, "min_value" ) );45 46 registerVar( new SynchronizeableInt( (int*)&type, (int*)&type, "type", PERMISSION_MASTER_SERVER ) ); 47 registerVar( new SynchronizeableFloat( &value, &value, "value", PERMISSION_MASTER_SERVER ) ); 48 registerVar( new SynchronizeableFloat( &max_value, &max_value, "max_value", PERMISSION_MASTER_SERVER ) ); 49 registerVar( new SynchronizeableFloat( &min_value, &min_value, "min_value", PERMISSION_MASTER_SERVER ) ); 50 50 } 51 51 -
trunk/src/world_entities/projectiles/guided_missile.h
r9235 r9656 13 13 class ParticleEmitter; 14 14 class FastFactory; 15 class Aim;16 15 17 16 class GuidedMissile : public Projectile -
trunk/src/world_entities/projectiles/laser.cc
r9406 r9656 88 88 } 89 89 90 this->setDamage( 0);90 this->setDamage(20); 91 91 this->setHealth(0); 92 92 } -
trunk/src/world_entities/projectiles/projectile.cc
r9406 r9656 45 45 this->explosionBuffer = NULL; 46 46 this->engineBuffer = NULL; 47 48 //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 47 49 } 48 50 -
trunk/src/world_entities/script_trigger.cc
r9406 r9656 49 49 */ 50 50 ScriptTrigger::ScriptTrigger(const TiXmlElement* root) 51 { PRINT(1)("testerror\n");51 { 52 52 this->setClassID(CL_SCRIPT_TRIGGER, "ScriptTrigger"); 53 53 this->toList(OM_COMMON); -
trunk/src/world_entities/skybox.cc
r9406 r9656 96 96 { 97 97 this->rebuild(); 98 99 textureName_handle = registerVarId( new SynchronizeableString( &textureName, &textureName, "textureName" ) );100 size_handle = registerVarId( new SynchronizeableFloat( &size, &size, "size" ) );98 99 textureName_handle = registerVarId( new SynchronizeableString( &textureName, &textureName, "textureName", PERMISSION_MASTER_SERVER) ); 100 size_handle = registerVarId( new SynchronizeableFloat( &size, &size, "size", PERMISSION_MASTER_SERVER ) ); 101 101 } 102 102 … … 297 297 { 298 298 bool somethinChanged = false; 299 299 300 300 if ( std::find( id.begin(), id.end(), textureName_handle ) != id.end() ) 301 301 { … … 303 303 setTexture( textureName ); 304 304 } 305 305 306 306 if ( std::find( id.begin(), id.end(), size_handle ) != id.end() ) 307 307 { 308 308 somethinChanged = true; 309 309 } 310 310 311 311 rebuild(); 312 312 313 313 WorldEntity::varChangeHandler( id ); 314 314 } -
trunk/src/world_entities/space_ships/hover.cc
r9235 r9656 330 330 this->shiftCoor (this->velocity * dt); 331 331 332 332 // limit the maximum rotation speed. 333 333 if (this->rotation != 0.0f) 334 334 { -
trunk/src/world_entities/space_ships/space_ship.cc
r9494 r9656 234 234 this->burstSystem->setColor(1.0, .8,.8,.8,.0); 235 235 236 registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity" ) );236 registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity", PERMISSION_MASTER_SERVER ) ); 237 237 registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mousedir", PERMISSION_OWNER ) ); 238 238 -
trunk/src/world_entities/space_ships/turbine_hover.cc
r9494 r9656 91 91 92 92 this->loadModel("models/ships/hoverglider_mainbody.obj"); 93 93 94 } 94 95 … … 222 223 registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) ); 223 224 registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) ); 225 226 if( State::isOnline()) 227 toList( OM_PLAYERS ); 224 228 } 225 229 … … 231 235 { 232 236 Playable::loadParams(root); 237 } 238 239 240 void TurbineHover::setBoostColor(const Color& color) 241 { 242 this->burstSystem->setColor(0.0, color); 243 this->burstSystem->setColor(0.2, color * 0.6); 244 this->burstSystem->setColor(0.5, color * .3 + Color(0.5, 0.5, 0.8, 0.3)); 245 this->burstSystem->setColor(1.0, 0.8, 0.8, 0.8, 0.0); 246 247 printf(":::::::::::::::::::::::\n"); 248 this->burstSystem->debug(); 233 249 } 234 250 … … 256 272 257 273 } 274 275 void TurbineHover::setTeam(int teamID) 276 { 277 printf("::::::::::::::::: TEAM ::: %d\n", teamID); 278 if (teamID == 0) 279 { 280 this->setBoostColor(Color::blue); 281 } 282 else if (teamID == 1) 283 { 284 this->setBoostColor(Color::red); 285 } 286 287 ///HACK this is very much hard coded.set the owner of the weapons 288 this->getWeaponManager().getWeapon(0)->setOwner(this->getOwner()); 289 this->getWeaponManager().getWeapon(1)->setOwner(this->getOwner()); 290 291 //choose collision list 292 if( State::isOnline()) 293 { 294 if( teamID == 0) 295 toList( OM_GROUP_00 ); 296 else if(teamID == 1) 297 toList( OM_GROUP_01); 298 } 299 300 301 // set the local team id, very important 302 this->setTeamId(teamID); 303 } 304 258 305 259 306 … … 527 574 } 528 575 } 576 577 578 /** 579 * respawning function called by the GameRules 580 */ 581 void TurbineHover::respawn( ) 582 { 583 584 Playable::respawn(); 585 } -
trunk/src/world_entities/space_ships/turbine_hover.h
r8490 r9656 9 9 10 10 #include "playable.h" 11 12 #include "color.h" 11 13 12 14 // Forward Declaration … … 21 23 virtual ~TurbineHover(); 22 24 25 void setBoostColor(const Color& color); 26 23 27 virtual void loadParams(const TiXmlElement* root); 24 28 virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f); … … 26 30 virtual void leave(); 27 31 32 virtual void setTeam(int teamID); 33 28 34 virtual void postSpawn(); 29 35 virtual void leftWorld(); 36 virtual void respawn(); 30 37 31 38 virtual void collidesWith(WorldEntity* entity, const Vector& location); -
trunk/src/world_entities/spawning_point.cc
r9494 r9656 207 207 void SpawningPoint::sendRespawnMessage( int uniqueId ) 208 208 { 209 #warning this byte array is not being deleted according to valginrd 210 byte * buf = new byte[2*INTSIZE]; 209 byte buf[2*INTSIZE]; 211 210 212 211 assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE ); 213 212 assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE ); 214 213 215 MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH ); 216 } 217 218 bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 214 MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_BUT_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH ); 215 } 216 217 /** 218 * message handler for respawn message 219 */ 220 bool SpawningPoint::respawnMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId ) 219 221 { 220 222 if ( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/) -
trunk/src/world_entities/spawning_point.h
r9494 r9656 70 70 71 71 void sendRespawnMessage( int uniqueId ); 72 static bool respawnMessageHandler( Message Id messageId, byte * data, int dataLength, void * someData, int userId);72 static bool respawnMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId ); 73 73 74 74 -
trunk/src/world_entities/weapons/aim.cc
r9406 r9656 50 50 Aim::~Aim () 51 51 { 52 if (this->material)53 delete this->material;54 55 52 /* if (this->text != NULL) 56 53 delete this->text;*/ … … 70 67 71 68 this->setBindNode(this); 72 this->material = new Material;73 69 this->source = NULL; 74 70 75 this->range = 1000 0;71 this->range = 1000; 76 72 this->angle = M_PI_4; 77 this-> group = OM_GROUP_01;73 this->targetGroup = OM_GROUP_01; 78 74 this->anim = new tAnimation<Aim>(this, &Aim::setSize); 79 75 this->anim->setInfinity(ANIM_INF_CONSTANT); … … 103 99 LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed) 104 100 .describe("the Speed with which the Aim should rotate"); 101 102 LoadParam(root, "target-group", this, Aim, setTargetGroupS); 105 103 } 106 104 … … 108 106 { 109 107 ObjectManager::EntityList::iterator entity; 110 111 for (entity = State::getObjectManager()->getObjectList( group).begin();112 entity != State::getObjectManager()->getObjectList( group).end();108 //printf("%d\n", this->targetGroup); 109 for (entity = State::getObjectManager()->getObjectList(this->targetGroup).begin(); 110 entity != State::getObjectManager()->getObjectList(this->targetGroup).end(); 113 111 entity ++) 114 112 { 115 113 diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() ); 116 114 117 if ( diffVec.len() < range && acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle)115 if ( diffVec.len() < range )//&& acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle) 118 116 { 119 117 //if (this->getParent() != (*entity)) 120 118 { 119 printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName()); 121 120 this->anim->replay(); 122 121 this->setParentSoft(*entity, 5); … … 128 127 //if no target found: 129 128 this->setParent(PNode::getNullParent()); 130 131 132 133 } 134 129 } 130 131 void Aim::setTargetGroupS(const std::string& groupName) 132 { 133 OM_LIST id = ObjectManager::StringToOMList(groupName); 134 if (id != OM_NULL) 135 this->setTargetGroup(id); 136 else 137 PRINTF(2)("List %s not found for targetting\n", groupName.c_str()); 138 } 135 139 136 140 /** … … 149 153 void Aim::setTexture(const std::string& textureFile) 150 154 { 151 this->material ->setDiffuseMap(textureFile);155 this->material.setDiffuseMap(textureFile); 152 156 } 153 157 … … 170 174 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 171 175 if(this->getParent() == PNode::getNullParent() || 172 diffVec.len() > range ||173 ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))176 diffVec.len() > range )// || 177 //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 174 178 { 175 179 this->setParentSoft(PNode::getNullParent(),5); … … 213 217 214 218 glRotatef(this->getAbsDir2D(), 0,0,1); 215 this->material ->select();219 this->material.select(); 216 220 glBegin(GL_TRIANGLE_STRIP); 217 221 glTexCoord2f(0, 0); -
trunk/src/world_entities/weapons/aim.h
r7221 r9656 11 11 #include "object_manager.h" 12 12 13 #include "material.h" 14 13 15 // FORWARD DECLARATION 14 16 class Model; 15 17 class Text; 16 class Material;17 18 class TiXmlElement; 18 19 template<class T> class tAnimation; … … 25 26 * Also the Aim is a Element2D, as it draws a cross onto the Target. 26 27 */ 27 class Aim : public PNode, public Element2D { 28 class Aim : public PNode, public Element2D 29 { 28 30 29 31 public: 30 32 Aim(PNode* source, const TiXmlElement* root = NULL); 31 33 virtual ~Aim(); 32 34 33 void init();34 35 virtual void loadParams(const TiXmlElement* root); 35 36 … … 37 38 38 39 inline void selectTarget(PNode* target) { this->setParent(target); }; 39 inline PNode* getTarget(PNode* target) { return this->getParent(); };40 inline PNode* getTarget(PNode* target) const { return this->getParent(); }; 40 41 41 42 void searchTarget(); 42 43 43 void setRange(float range){this->range = range;}; 44 void setAngle(float angle){this->angle = angle;}; 45 void setGroup(OM_LIST group){this->group = group;}; 44 void setRange(float range) {this->range = range;}; 45 void setAngle(float angle) {this->angle = angle;}; 46 void setTargetGroup(OM_LIST group) { this->targetGroup = group; }; 47 void setTargetGroupS(const std::string& grounName); 46 48 47 49 void setSize(float size); … … 53 55 virtual void draw() const; 54 56 55 private: 56 Material* material; //!< a material for the Aim. 57 float rotationSpeed; //!< Speed of the Rotation. 58 tAnimation<Aim>* anim; 57 private: 58 void init(); 59 59 60 float range; //!<61 float angle; //!<62 Vector diffVec;63 OM_LIST group;64 60 65 PNode* source; //!< Where this Shot has come from. 61 private: 62 Material material; //!< a material for the Aim. 63 float rotationSpeed; //!< Speed of the Rotation. 64 tAnimation<Aim>* anim; 66 65 67 Text* text; //!< A Text to display onto this Node. (distance to Target) 66 float range; //!< 67 float angle; //!< 68 Vector diffVec; 69 OM_LIST targetGroup; 70 71 PNode* source; //!< Where this Shot has come from. 72 73 // Text text; //!< A Text to display onto this Node. (distance to Target) 68 74 }; 69 75 -
trunk/src/world_entities/weapons/aiming_turret.cc
r9406 r9656 38 38 */ 39 39 AimingTurret::AimingTurret () 40 : Weapon()40 : Weapon(), target(this) 41 41 { 42 42 this->init(); … … 46 46 47 47 AimingTurret::AimingTurret(const TiXmlElement* root) 48 : target(this) 48 49 { 49 50 this->init(); … … 58 59 { 59 60 // model will be deleted from WorldEntity-destructor 60 // delete this->target;61 // delete this->target; 61 62 } 62 63 … … 91 92 //this->getProjectileFactory()->prepare(100); 92 93 93 this->target = new Aim(this);94 this->target ->setVisibility(false);95 this->target ->setRange(400);96 this->target ->setAngle(M_PI_2);94 this->target.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE); 95 this->target.setVisibility(false); 96 this->target.setRange(400); 97 this->target.setAngle(M_PI_2); 97 98 98 99 this->setActionSound(WA_SHOOT, "sound/explosions/explosion_3.wav"); … … 110 111 void AimingTurret::activate() 111 112 { 112 this->target ->setVisibility(true);113 this->target.setVisibility(true); 113 114 } 114 115 115 116 void AimingTurret::deactivate() 116 117 { 117 this->target ->setVisibility(false);118 this->target.setVisibility(false); 118 119 } 119 120 … … 123 124 return; 124 125 Quaternion quat; 125 Vector direction = this->target ->getAbsCoor() - this->getAbsCoor();126 Vector direction = this->target.getAbsCoor() - this->getAbsCoor(); 126 127 127 128 direction.normalize(); 128 129 129 130 if (likely (this->getParent() != NULL)) 130 quat = Quaternion(direction, this->getParent()->getAbsDir().apply(Vector(0,1,0))) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 131 //quat = Quaternion(direction, this->getParent()->getAbsDirY()) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 132 quat = Quaternion ( M_PI_2, this->getParent()->getAbsDirY()) * Quaternion::lookAt(this->getAbsCoor(), this->target.getAbsCoor(), this->getParent()->getAbsDirY()); 131 133 else 132 quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 134 //quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 135 quat = Quaternion ( M_PI_2, Vector(0,1,0)) * Quaternion::lookAt(this->getAbsCoor(), this->target.getAbsCoor(), Vector(0,1,0)); 133 136 134 137 this->setAbsDirSoft(quat, 5); 135 138 136 this->target ->tick(dt);139 this->target.tick(dt); 137 140 } 138 141 … … 143 146 return; 144 147 145 pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir ().apply(Vector(1,0,0))*250.0 + VECTOR_RAND(13)146 /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity());148 pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDirX()*250.0 + VECTOR_RAND(4) 149 /*target.getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity()); 147 150 148 151 pj->setParent(PNode::getNullParent()); -
trunk/src/world_entities/weapons/aiming_turret.h
r8777 r9656 8 8 9 9 #include "weapon.h" 10 10 #include "aim.h" 11 11 /* FORWARD DECLARATION */ 12 class Aim;13 12 14 13 class AimingTurret : public Weapon 15 16 17 18 19 14 { 15 public: 16 AimingTurret (); 17 AimingTurret(const TiXmlElement* root); 18 virtual ~AimingTurret (); 20 19 21 void init(); 22 virtual void loadParams(const TiXmlElement* root); 20 virtual void loadParams(const TiXmlElement* root); 23 21 24 virtual void activate(); 25 virtual void deactivate(); 22 void setTargetGroup(OM_LIST targetGroup) { this->target.setTargetGroup(targetGroup); }; 26 23 27 virtual void tick(float dt); 28 virtual void fire(); 24 virtual void activate(); 25 virtual void deactivate(); 26 27 virtual void tick(float dt); 28 virtual void fire(); 29 29 30 30 31 31 virtual void draw() const; 32 32 33 private: 34 Aim* target; 35 }; 33 private: 34 void init(); 35 36 private: 37 Aim target; 38 }; 36 39 37 40 #endif /* _AIMING_TURRET_H */ -
trunk/src/world_entities/weapons/laser_cannon.cc
r9235 r9656 121 121 return; 122 122 123 // make this to let the onKill(...) fuction get the stuff 124 pj->setOwner(this->getOwner()); 125 123 126 pj->setParent(PNode::getNullParent()); 124 127 -
trunk/src/world_entities/weapons/targeting_turret.cc
r9406 r9656 17 17 #include "targeting_turret.h" 18 18 19 #include "weapon_manager.h" 20 #include "aim.h" 21 #include "world_entities/projectiles/projectile.h" 19 #include "projectiles/projectile.h" 22 20 23 21 #include "model.h" … … 25 23 #include "animation3d.h" 26 24 25 #include "util/loading/load_param.h" 27 26 #include "util/loading/factory.h" 28 27 … … 30 29 31 30 32 33 34 /**35 * standard constructor36 37 creates a new weapon38 */39 TargetingTurret::TargetingTurret ()40 : Weapon()41 {42 this->init();43 44 }45 46 47 31 TargetingTurret::TargetingTurret(const TiXmlElement* root) 32 : target(this) 48 33 { 49 34 this->init(); … … 91 76 //this->getProjectileFactory()->prepare(100); 92 77 93 this->target = new Aim(this);94 this->target ->setVisibility(false);95 this->target ->setRange(1000);96 this->target ->setAngle(M_PI_4);97 this->lockedTarget = this->target;78 this->target.setVisibility(false); 79 this->target.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE); 80 this->target.setRange(1000); 81 this->target.setAngle(M_PI_4); 82 this->lockedTarget = &this->target; 98 83 99 84 this->lockedTime = 0; … … 112 97 Weapon::loadParams(root); 113 98 99 LoadParam(root, "target-group", &target, Aim, setTargetGroupS); 100 114 101 } 115 102 … … 122 109 void TargetingTurret::deactivate() 123 110 { 124 this->target ->setVisibility(false);111 this->target.setVisibility(false); 125 112 } 126 113 … … 130 117 return; 131 118 119 this->target.tick(dt); 120 132 121 if( lockedTime >= neededLockTime ) 133 122 { 134 lockedTarget = this->target ->getParent();123 lockedTarget = this->target.getParent(); 135 124 lockedTime = 0; 136 125 } 137 126 138 this->target->tick(dt);139 127 140 if(this->target ->getParent() == PNode::getNullParent())128 if(this->target.getParent() == PNode::getNullParent()) 141 129 lockedTime = 0; 142 130 else … … 159 147 pj->setAbsDir(this->getAbsDir()); 160 148 pj->activate(); 161 162 149 } 163 150 -
trunk/src/world_entities/weapons/targeting_turret.h
r8777 r9656 8 8 9 9 #include "weapon.h" 10 11 /* FORWARD DECLARATION */ 12 class Aim; 10 #include "aim.h" 13 11 14 12 class TargetingTurret : public Weapon 15 { 16 public: 17 TargetingTurret (); 18 TargetingTurret(const TiXmlElement* root); 19 virtual ~TargetingTurret (); 13 { 14 public: 15 TargetingTurret(const TiXmlElement* root = NULL); 16 virtual ~TargetingTurret (); 20 17 21 void init(); 22 virtual void loadParams(const TiXmlElement* root); 18 virtual void loadParams(const TiXmlElement* root); 23 19 24 25 20 virtual void activate(); 21 virtual void deactivate(); 26 22 27 28 23 virtual void tick(float dt); 24 virtual void fire(); 29 25 30 26 virtual void draw() const; 31 27 32 private: 33 Aim* target; 34 PNode* lockedTarget; 35 float lockedTime; 36 float neededLockTime; 37 }; 28 void setTargetGroup(OM_LIST targetGroup) { this->target.setTargetGroup(targetGroup); }; 29 const PNode* getLockedTarget() const { return lockedTarget; }; 30 31 private: 32 void init(); 33 34 private: 35 Aim target; 36 PNode* lockedTarget; 37 float lockedTime; 38 float neededLockTime; 39 }; 38 40 39 41 #endif /* _TARGETING_TURRET_H */ -
trunk/src/world_entities/weapons/test_gun.cc
r9002 r9656 177 177 if (pj == NULL) 178 178 return; 179 180 // set the owner 181 pj->setOwner(this->getOwner()); 179 182 180 183 pj->setParent(PNode::getNullParent()); -
trunk/src/world_entities/world_entity.cc
r9494 r9656 28 28 #include "util/loading/resource_manager.h" 29 29 #include "util/loading/load_param.h" 30 #include "vector.h"31 30 #include "obb_tree.h" 32 31 … … 86 85 this->toList(OM_NULL); 87 86 88 registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName" ) );89 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );90 scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );91 list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) );92 93 health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health" ) );94 healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth" ) );87 registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName", PERMISSION_MASTER_SERVER ) ); 88 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName", PERMISSION_MASTER_SERVER ) ); 89 scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling", PERMISSION_MASTER_SERVER ) ); 90 list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list", PERMISSION_MASTER_SERVER ) ); 91 92 health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health", PERMISSION_MASTER_SERVER ) ); 93 healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth", PERMISSION_MASTER_SERVER ) ); 95 94 } 96 95 … … 141 140 .describe("The Health the WorldEntity has at this moment") 142 141 .defaultValues(1.0f); 142 143 LoadParam(root, "list", this, WorldEntity, toListS); 143 144 } 144 145 … … 478 479 } 479 480 481 void WorldEntity::toListS(const std::string& listName) 482 { 483 OM_LIST id = ObjectManager::StringToOMList(listName); 484 if (id != OM_NULL) 485 this->toList(id); 486 else 487 PRINTF(2)("List %s not found\n", listName.c_str()); 488 } 489 490 480 491 void WorldEntity::toReflectionList() 481 492 { … … 822 833 PRINT(0)("WorldEntity %s::%s (DEBUG)\n", this->getClassCName(), this->getCName()); 823 834 this->debugNode(); 824 PRINT(0)("List: %s ; ModelCount %d - ", ObjectManager::OMListToString(this->objectListNumber) 835 PRINT(0)("List: %s ; ModelCount %d - ", ObjectManager::OMListToString(this->objectListNumber).c_str(), this->models.size()); 825 836 for (unsigned int i = 0; i < this->models.size(); i++) 826 837 { -
trunk/src/world_entities/world_entity.h
r9298 r9656 115 115 /* --- Object Manager Block --- */ 116 116 void toList(OM_LIST list); 117 void toListS(const std::string& listName); 117 118 118 119 void toReflectionList();
Note: See TracChangeset
for help on using the changeset viewer.