Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 27, 2017, 6:53:05 PM (7 years ago)
Author:
remartin
Message:

Solved pickup problem with tiny adaptation in Pawn.h and PickupSpawner.cc. Started work on SpicedAsteroidField.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc

    r11587 r11609  
    4444
    4545KNACKPUNKTE:
    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 
    5246
    5347OFFEN:
    5448o 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
    5554o Explosion parts
    5655o custom HUD
    5756o asteroidField.lua anpassen, mit 'Mineraliendichten-Parameter'.
     57
     58o Dokumentieren mit @brief?
     59
     60o replace ugly random stuff with math.rnd()
     61o set collisionDamage? Just for static entities?
    5862
    5963HANDBUCH:
     
    6266  damit die Groesse der Collision Shape korrekt initialisiert wird.
    6367
    64 Anpassungen Pickup-Zeug:
     68FREMDANPASSUNGEN:
     69Pickup-Zeug:
    6570o Pickup.h: Zugriffsänderung createSpawner
    6671o PickupSpawner.h: Zugriffsrechte setPickupTemplateName() und setMaxSpawnedItems()
     72o PickupSpawner.h: In Tick() zwei Testbedingungen eingefuegt.
     73o Pawn.h: Attribut acceptsPickups_ inklusive get/set.
    6774
    6875ERLEGT:
    6976o Rand() geht bis zu riesigen Nummern!
    70 o Pickupgenerierung: vgl. Anpassungen.
    71 o Dummes fisch-- statt fisch++ , Endlosschleife!
     77o Pickupgenerierung: vgl. Fremdanpassungen.
     78o Minimalbegrenzung fuer Masse vergessen.
    7279o Dynamische Definition -> putStuff-Methode, Werte noch nicht durchgesickert.
    7380o Error-Nachricht: Einfach Argumente leer lassen.
     
    7986o Groessenabhaengige Collison shape: Umweg ueber zweiten Konstruktor.
    8087o Absturz beim Asteroidengenerieren: Health war auf 0 gesetzt! Wurde nur bei der xml-Variante definiert.
     88o Asteroiden fressen Pickups: Argument in Pawn, Test darauf in Tick() von PickupSpawner.
    8189
    8290NOTIZEN:
    8391o SUPER entspricht ueberladen, andere Argumente der Methode.
     92o Warnungsverhinderung anderswo: (void)pickedUp; // To avoid compiler warning.
     93
     94Was ist das?         friend class Pickupable;
     95
     96
    8497
    8598*/
     
    164177        this->health_ = 15*size;// capped at 200 in pawn or smth?
    165178        this->maxHealth_ = this->health_;
     179        this->acceptsPickups_ = false;
     180
    166181        this->setPosition(position);
    167182        //this->roll = rand()*5; //etwas Drehung. richtige Variable
     
    273288    {
    274289
    275         orxout() << "AsteroidMinable::Death() aufgerufen." << endl;
     290        // orxout() << "AsteroidMinable::Death() aufgerufen." << endl;
    276291
    277292        // OFFEN: Sauber kapputten
     
    285300
    286301
    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);
    303317
    304318        // orxout() << "AsteroidMining::Death(): Passed Pickup stuff!" << endl;
    305 
    306319
    307320        // Smaller Parts = 'Children'
     
    310323        }
    311324
    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
    330327    }
    331328
     
    335332    if (this->size <=1){return;} // Absicherung trivialer Fall
    336333
    337 
    338 
    339334    // Spawn smaller Children
    340335    int massRem = this->size-1; //some mass is lost
    341336    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
    342339    // 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
    344360    massRem = massRem-num;   
     361
    345362    int extra = 0;
    346 
    347363
    348364    //orxout() << "Number of Children: " << num << endl;
     
    404420
    405421    }
    406     orxout() << "Leaving spawnChildren() method. " << endl;
     422    // orxout() << "Leaving spawnChildren() method. " << endl;
    407423}
    408424
     
    429445    void AsteroidMinable::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage){
    430446
    431         orxout() << "AsteroidMining::Hit(Variante 2) Dings aufgerufen. " << endl;
     447        //orxout() << "AsteroidMining::Hit(Variante 2) Dings aufgerufen. " << endl;
    432448        // Kollision mit anderem Asteroid oder Pickup (OFFEN: evtl. Spawner oder irgendwas?) verhindern. In diesem Fall einfach nichts tun.
    433449        // Wird staending aufgerufen -> Rechenleistung?
    434450        if(orxonox_cast<AsteroidMinable*>(originator) || orxonox_cast<Pickup*>(originator)){return;}
    435451
    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;
    437453
    438454        this->damage(damage, healthdamage, shielddamage, originator, cs);
     
    451467
    452468
    453 
    454 
    455             // Cast-Test aus movableEntity():
    456             // Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    457             // if (victim)
    458469
    459470
Note: See TracChangeset for help on using the changeset viewer.