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.

Location:
code/branches/AsteroidMining_HS17/src
Files:
4 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
  • code/branches/AsteroidMining_HS17/src/modules/pickup/PickupSpawner.cc

    r11103 r11609  
    158158            for(Pawn* pawn : ObjectList<Pawn>())
    159159            {
    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)
    161162                    break;
     163
     164                if(!(pawn->doesAcceptPickups())){continue;} // skip those pawns, e.g. AsteroidMinables.
    162165
    163166                Vector3 distance = pawn->getWorldPosition() - this->getWorldPosition();
  • code/branches/AsteroidMining_HS17/src/orxonox/worldentities/pawns/Pawn.cc

    r11176 r11609  
    8484        // set damage multiplier to default value 1, meaning nominal damage
    8585        this->damageMultiplier_ = 1;
     86        this->acceptsPickups_ = true;
    8687
    8788        this->spawnparticleduration_ = 3.0f;
  • code/branches/AsteroidMining_HS17/src/orxonox/worldentities/pawns/Pawn.h

    r11176 r11609  
    199199                { return this->damageMultiplier_; }
    200200
     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_;}
    201206
    202207            virtual void startLocalHumanControl() override;
     
    218223                { return this->weaponSystem_; }
    219224
    220             static void consoleCommand_debugDrawWeapons(bool bDraw);
     225            static void consoleCommand_debugDrawWeapons(bool bDraw);
     226
     227
    221228
    222229        protected:
     
    256263
    257264            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
     265            bool acceptsPickups_; // Added for the asteroidMinable class, avoid that they attempt to grab the resources
    258266
    259267            WeakPtr<Pawn> lastHitOriginator_;
Note: See TracChangeset for help on using the changeset viewer.