Changeset 11609
- Timestamp:
- Nov 27, 2017, 6:53:05 PM (7 years ago)
- Location:
- code/branches/AsteroidMining_HS17/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc
r11587 r11609 44 44 45 45 KNACKPUNKTE: 46 o Der neu erscheinende Asteroid versucht, das Pickup aufzusammeln.47 --> Mathematisch genuegend Abstand?48 --> Kollisions-Ausnahme richtig, mit Hit-Methode oder so, auch bei Pickup anpassen?49 --> Den Fall im eigenen Pickup behandeln?50 --> Nur ein Pickup generieren, wenn die Groesse sowieso eins ist? -> Loest Kollisionsproblem nicht.51 52 46 53 47 OFFEN: 54 48 o Add custom pickup 'resources'. Weird template stuff -> Problems setting 'size' and other properties? setNumber of Resources. 49 --> PickupTemplateName_ in PickupSpawner ist ein string. Wird via getBaseClassIdentifier ausgelesen, daraus wird ein Pickupable fabriziert. 50 --> MunitionPickup erbt von Pickup erbt von collectiblePickup erbt von Pickupable 51 ----> im MineralsPickup die isPickedUp()-Methode überschreiben? 52 --> data_extern/images/effects: PNG's für die Pickups und GUI-Dinger. 53 55 54 o Explosion parts 56 55 o custom HUD 57 56 o asteroidField.lua anpassen, mit 'Mineraliendichten-Parameter'. 57 58 o Dokumentieren mit @brief? 59 60 o replace ugly random stuff with math.rnd() 61 o set collisionDamage? Just for static entities? 58 62 59 63 HANDBUCH: … … 62 66 damit die Groesse der Collision Shape korrekt initialisiert wird. 63 67 64 Anpassungen Pickup-Zeug: 68 FREMDANPASSUNGEN: 69 Pickup-Zeug: 65 70 o Pickup.h: Zugriffsänderung createSpawner 66 71 o PickupSpawner.h: Zugriffsrechte setPickupTemplateName() und setMaxSpawnedItems() 72 o PickupSpawner.h: In Tick() zwei Testbedingungen eingefuegt. 73 o Pawn.h: Attribut acceptsPickups_ inklusive get/set. 67 74 68 75 ERLEGT: 69 76 o Rand() geht bis zu riesigen Nummern! 70 o Pickupgenerierung: vgl. Anpassungen.71 o Dummes fisch-- statt fisch++ , Endlosschleife!77 o Pickupgenerierung: vgl. Fremdanpassungen. 78 o Minimalbegrenzung fuer Masse vergessen. 72 79 o Dynamische Definition -> putStuff-Methode, Werte noch nicht durchgesickert. 73 80 o Error-Nachricht: Einfach Argumente leer lassen. … … 79 86 o Groessenabhaengige Collison shape: Umweg ueber zweiten Konstruktor. 80 87 o Absturz beim Asteroidengenerieren: Health war auf 0 gesetzt! Wurde nur bei der xml-Variante definiert. 88 o Asteroiden fressen Pickups: Argument in Pawn, Test darauf in Tick() von PickupSpawner. 81 89 82 90 NOTIZEN: 83 91 o SUPER entspricht ueberladen, andere Argumente der Methode. 92 o Warnungsverhinderung anderswo: (void)pickedUp; // To avoid compiler warning. 93 94 Was ist das? friend class Pickupable; 95 96 84 97 85 98 */ … … 164 177 this->health_ = 15*size;// capped at 200 in pawn or smth? 165 178 this->maxHealth_ = this->health_; 179 this->acceptsPickups_ = false; 180 166 181 this->setPosition(position); 167 182 //this->roll = rand()*5; //etwas Drehung. richtige Variable … … 273 288 { 274 289 275 orxout() << "AsteroidMinable::Death() aufgerufen." << endl;290 // orxout() << "AsteroidMinable::Death() aufgerufen." << endl; 276 291 277 292 // OFFEN: Sauber kapputten … … 285 300 286 301 287 // // Stuff that can be harvested. 288 // PickupSpawner* thingy = new PickupSpawner(this->context); 289 290 // // OFFEN: more precise size relation in custom resource pickup. 291 // char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.) 292 // if(this->size <= 5){ 293 // strcat(tname, "smallmunitionpickup"); 294 // }else if(this->size <= 20){ 295 // strcat(tname, "mediummunitionpickup"); 296 // }else{ 297 // strcat(tname, "hugemunitionpickup"); 298 // } 299 // thingy->setPickupTemplateName(tname); 300 // thingy->setPosition(this->getPosition()); 301 // thingy->setMaxSpawnedItems(2); // The first somehow gets destroyed immediately. 302 // thingy->setRespawnTime(0.5f); 302 // Stuff that can be harvested. 303 PickupSpawner* thingy = new PickupSpawner(this->context); 304 // OFFEN: more precise size relation in custom resource pickup. 305 char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.) 306 if(this->size <= 5){ 307 strcat(tname, "smallmunitionpickup"); 308 }else if(this->size <= 20){ 309 strcat(tname, "mediummunitionpickup"); 310 }else{ 311 strcat(tname, "hugemunitionpickup"); 312 } 313 thingy->setPickupTemplateName(tname); 314 thingy->setPosition(this->getPosition()); 315 thingy->setMaxSpawnedItems(1); // Would be default anyways 316 thingy->setRespawnTime(0.2f); 303 317 304 318 // orxout() << "AsteroidMining::Death(): Passed Pickup stuff!" << endl; 305 306 319 307 320 // Smaller Parts = 'Children' … … 310 323 } 311 324 312 313 314 315 316 317 318 319 orxout() << "Wieder retour in death() geschafft. " << endl; 320 321 // if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_)) 322 // { 323 // // Set bAlive_ to false and wait for destroyLater() to do the destruction 324 // this->bAlive_ = false; 325 // this->destroyLater(); 326 327 // this->setDestroyWhenPlayerLeft(false); 328 329 // } 325 // orxout() << "Wieder retour in death() geschafft. " << endl; 326 330 327 } 331 328 … … 335 332 if (this->size <=1){return;} // Absicherung trivialer Fall 336 333 337 338 339 334 // Spawn smaller Children 340 335 int massRem = this->size-1; //some mass is lost 341 336 int num = round((massRem-1)*(double)rand() / (double)RAND_MAX)+1; // random number of children, at least one // Tweak towards bigger junks? 337 if(num > 10){num = 10;} // no max function in C! 338 342 339 // num = 1; // zum Testen mal nur einen generieren. 343 340 341 // // TODO: Check this draft for edge cases etc. 342 // // 'Triangular', discrete probability density with max at massRem/num 343 // // Max at a, value 1, subintervals a+b = c 344 // int c = massRem-num; 345 // float probDensity = [c] 346 // int a = round(massRem/num); 347 // int b = c-a; 348 // for(int z = 0; z<=a; z++){probDensity[z] = m*z/a; } // rising part 349 // for(z = a+1; z<c; z++){probDensity[z] = m - m*(z-a)/b;} // falling part 350 351 // double rand = (double)rand() / (double)RAND_MAX; // between 0 and 1 352 // double probSum = 0; 353 // int result = 0; 354 // while(rand>probSum){ 355 // probSum = probSum+probDensity[result]; 356 // result++: 357 // } 358 359 344 360 massRem = massRem-num; 361 345 362 int extra = 0; 346 347 363 348 364 //orxout() << "Number of Children: " << num << endl; … … 404 420 405 421 } 406 orxout() << "Leaving spawnChildren() method. " << endl;422 // orxout() << "Leaving spawnChildren() method. " << endl; 407 423 } 408 424 … … 429 445 void AsteroidMinable::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage){ 430 446 431 orxout() << "AsteroidMining::Hit(Variante 2) Dings aufgerufen. " << endl;447 //orxout() << "AsteroidMining::Hit(Variante 2) Dings aufgerufen. " << endl; 432 448 // Kollision mit anderem Asteroid oder Pickup (OFFEN: evtl. Spawner oder irgendwas?) verhindern. In diesem Fall einfach nichts tun. 433 449 // Wird staending aufgerufen -> Rechenleistung? 434 450 if(orxonox_cast<AsteroidMinable*>(originator) || orxonox_cast<Pickup*>(originator)){return;} 435 451 436 orxout() << "Schaden. HP: " << this->health_ << " Dmg: " << damage << " hDmg: " << healthdamage << " sDmg: " << shielddamage << endl;452 //orxout() << "Schaden. HP: " << this->health_ << " Dmg: " << damage << " hDmg: " << healthdamage << " sDmg: " << shielddamage << endl; 437 453 438 454 this->damage(damage, healthdamage, shielddamage, originator, cs); … … 451 467 452 468 453 454 455 // Cast-Test aus movableEntity():456 // Pawn* victim = orxonox_cast<Pawn*>(otherObject);457 // if (victim)458 469 459 470 -
code/branches/AsteroidMining_HS17/src/modules/pickup/PickupSpawner.cc
r11103 r11609 158 158 for(Pawn* pawn : ObjectList<Pawn>()) 159 159 { 160 if(spawner == nullptr) // Stop if the PickupSpawner has been deleted (e.g. because it has run out of pickups to distribute). 160 // Stop if the PickupSpawner has been deleted (e.g. because it has run out of pickups to distribute). 2nd condition prevents a possible error in isTarget(...) below. 161 if(spawner == nullptr || this->pickup_ == nullptr) 161 162 break; 163 164 if(!(pawn->doesAcceptPickups())){continue;} // skip those pawns, e.g. AsteroidMinables. 162 165 163 166 Vector3 distance = pawn->getWorldPosition() - this->getWorldPosition(); -
code/branches/AsteroidMining_HS17/src/orxonox/worldentities/pawns/Pawn.cc
r11176 r11609 84 84 // set damage multiplier to default value 1, meaning nominal damage 85 85 this->damageMultiplier_ = 1; 86 this->acceptsPickups_ = true; 86 87 87 88 this->spawnparticleduration_ = 3.0f; -
code/branches/AsteroidMining_HS17/src/orxonox/worldentities/pawns/Pawn.h
r11176 r11609 199 199 { return this->damageMultiplier_; } 200 200 201 // Some pawns can-t harvest pickups (e.g. AsteroidMinables). Checked in PickupSpawner. 202 inline void setPickupAcceptance(bool b) 203 { this->acceptsPickups_ = b; } 204 inline bool doesAcceptPickups() 205 { return this->acceptsPickups_;} 201 206 202 207 virtual void startLocalHumanControl() override; … … 218 223 { return this->weaponSystem_; } 219 224 220 static void consoleCommand_debugDrawWeapons(bool bDraw); 225 static void consoleCommand_debugDrawWeapons(bool bDraw); 226 227 221 228 222 229 protected: … … 256 263 257 264 float damageMultiplier_; ///< Used by the Damage Boost Pickup. 265 bool acceptsPickups_; // Added for the asteroidMinable class, avoid that they attempt to grab the resources 258 266 259 267 WeakPtr<Pawn> lastHitOriginator_;
Note: See TracChangeset
for help on using the changeset viewer.