Index: code/branches/AsteroidMining_HS17/data/levels/AsteroidFarming.oxw
===================================================================
--- code/branches/AsteroidMining_HS17/data/levels/AsteroidFarming.oxw	(revision 11550)
+++ code/branches/AsteroidMining_HS17/data/levels/AsteroidFarming.oxw	(revision 11551)
@@ -90,5 +90,6 @@
     <!-----AsteroidMinable --->
 
-    <AsteroidMinable size=100 position="0,-500,0" />
+    <AsteroidMinable size=15 position="0,-500,0" />
+    <AsteroidMinable size=5 position="100,-500,100" />
 
     
Index: code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc
===================================================================
--- code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc	(revision 11550)
+++ code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc	(revision 11551)
@@ -37,4 +37,23 @@
 *
 
+*/
+
+/*
+Veraenderungstagebuch
+- Dynamische Definition von Argumenten funktioniert nicht (Immer auf default Values gesetzt)
+---> Was tut registerVariable? Wann werden die Argumente im XML-File angewendet?
+    (Fall Konstruktor -> Methoden: Beim ersten Tick initialisieren?)
+---> Mesh-Teil klappt, Hitbox noch nicht. 
+---> Maximale Hitpunkte = 200?
+---> Meshgroesse passt, aber Hitbox wird iwieso nicht mehr generiert. 
+
+- Neue Asteroiden generieren -> Absturz
+- Pickup spawning -> Absturz
+- Manchmal: Absturz bei Zerstoerung eines Asteroiden
+
+
+
+Erlegt:
+o Rand() geht bis zu riesigen Nummern!
 */
 
@@ -70,13 +89,5 @@
 
 
-/*
-Veraenderungstagebuch
-- Dynamische Definition von Argumenten funktioniert nicht
-- Death-Methode -> Absturz
-
-
-
-
-*/
+
 
 
@@ -89,71 +100,64 @@
     {
         RegisterObject(AsteroidMinable);
+
+        // Old stuff from pawn
         this->setRadarObjectColour(ColourValue(1.0f, 1.0f, 0.0f, 1.0f));
         this->setRadarObjectShape(RadarViewable::Shape::Dot);
-
         this->setCollisionType(WorldEntity::CollisionType::Dynamic);
-
+        this->bAlive_ = true;
+        this->bVulnerable_ = true;
+
+
+
+        // Default Values
         this->generateSmaller = true;
         //this->size = this->getSize(); // Value doesn-t get accepted. Weird. 
-        this->size = 5;
+        this->size = 10;
         this->context = context;
-
-
+        this->initialised = false;
+        //this->roll = rand()*5; //etwas Drehung. richtige Variable
+
+
+        // DELETE if other stuff works! (wrong size etc.)
+        SphereCollisionShape* cs = new SphereCollisionShape(this->context);
+        cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien 
+        this->attachCollisionShape(cs); 
+
+
+
+
+        // Old from Pawn
+        this->registerVariables();
+
+    }
+
+    AsteroidMinable::~AsteroidMinable()
+    {
+
+    }
+
+    void AsteroidMinable::putStuff(){
+
+        // Add Model
+        //<Model position="0,-40,40" yaw="90" pitch="-90" roll="0" scale="4" mesh="ast6.mesh" />
         Model* hull = new Model(this->context);
         // random one of the 6 shapes
-        //char meshThingy[] = "";
-        //sprintf(meshThingy, "ast%f.mesh", round(rand()*5)+1);
+        char meshThingy[] = "";
+        sprintf(meshThingy, "ast%.0f.mesh", (round((5*(double)rand()/(double)RAND_MAX))+1));
         //    sprintf(str, "Value of Pi = %f", M_PI);
-        char meshThingy[] = "ast5.mesh";
-
-
+        //char meshThingy[] = "ast5.mesh";
         hull->setMeshSource(meshThingy);
-        hull->setScale(size);
+        hull->setScale(this->size);
         this->attach(hull);
         //hull->setPosition(this->getPosition());
 
+        // Collision shape
         SphereCollisionShape* cs = new SphereCollisionShape(this->context);
-        cs->setRadius(size*2); //OFFEN: Feinabstimmung der Radien 
-        this->attachCollisionShape(cs);
-
-
-
-        //      <Model position="0,-40,40" yaw="90" pitch="-90" roll="0" scale="4" mesh="ast6.mesh" />
-/*
-            Model* slotModel = nullptr;
-
-            for (int i = 0; i < numWeaponSlots; ++i)
-            {
-                slotPosition = weaponSlots.at(i)->getPosition();
-                slotOrientation = weaponSlots.at(i)->getOrientation();
-                slotModel = new Model(this->getContext());
-                slotModel->setMeshSource("Coordinates.mesh");
-                slotModel->setScale(3.0f);
-                slotModel->setOrientation(slotOrientation);
-                slotModel->setPosition(slotPosition);
-
-                this->attach(slotModel);
-                debugWeaponSlotModels_.push_back(slotModel);
-            }
-        }
-        else
-        {
-            // delete all debug models
-            for(Model* model : debugWeaponSlotModels_) 
-            {
-                model->destroy();
-            }
-            debugWeaponSlotModels_.clear();
-        }
-*/
-
-
-
- 
-    }
-
-    AsteroidMinable::~AsteroidMinable()
-    {
-
+        cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien 
+        this->attachCollisionShape(cs); 
+
+
+
+        this->initialised=true;
     }
 
@@ -170,5 +174,5 @@
         SUPER(AsteroidMinable, XMLEventPort, xmlelement, mode);
 
-        //XMLPortEventState(AsteroidMinable, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
+        XMLPortEventState(AsteroidMinable, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
     }
 
@@ -179,12 +183,15 @@
         registerVariable(this->health_,            VariableDirection::ToClient);
         registerVariable(this->maxHealth_,         VariableDirection::ToClient);
+
+        registerVariable(this->size, VariableDirection::ToClient);
+        registerVariable(this->generateSmaller, VariableDirection::ToClient);
     }
 
     void AsteroidMinable::tick(float dt)
     {
-        SUPER(Pawn, tick, dt);
-        if(this->health_ <=0){
-            this->death();
-        }
+        // SUPER(Pawn, tick, dt);
+        if(!(this->initialised)){this->putStuff();}
+
+        if(this->health_ <=0){this->death();}
 
     }
@@ -192,5 +199,6 @@
     void AsteroidMinable::setSize(float s){
         this->size = s;
-        this->health_ = 200*s;
+        this->health_ = 5*s;// capped at 200 in pawn or smth?
+        this->setHealth(health_);
     }
 
@@ -202,21 +210,22 @@
     {
 
-        // pawn -> addExplosionPart
-        // this.goWithStyle()
-
-        // Spawn Pickup
-        HealthPickup* hP = new HealthPickup(context);
+
+
+
+        //Spawn Pickup
+        HealthPickup* hP = new HealthPickup(this->context);
         //OFFEN: Add custom pickup 'resources' 
-        PickupSpawner* thingy = new PickupSpawner(context);
+        PickupSpawner* thingy = new PickupSpawner(this->context);
         thingy->setPosition(this->getPosition());
-        thingy->createDroppedPickup(context, hP, nullptr, 10);
+        thingy->createDroppedPickup(this->context, hP, nullptr, 10);
 
 //    /*static*/ PickupSpawner* PickupSpawner::createDroppedPickup(Context* context, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance)
    
 
-
+        // Smaller Parts
         if(this->generateSmaller){
             this->spawnChildren();
         }
+
 
         // OFFEN: Sauber kapputten
@@ -226,4 +235,7 @@
         this->destroyLater();
         this->setDestroyWhenPlayerLeft(false);
+        // pawn -> addExplosionPart
+        // this->goWithStyle();
+
 
         // if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
@@ -240,7 +252,8 @@
 
 void AsteroidMinable::spawnChildren(){
-    // Spawn smaller Children
+    
+    // Spawn smaller Children 
     int massRem = this->size-1; //some mass is lost
-    int num = round((massRem-1)*rand())+1; // random number of children, at least one
+    int num = round((massRem-1)*(double)rand() / (double)RAND_MAX)+1; // random number of children, at least one
     massRem = massRem-num;
     int extra = 0;
@@ -250,9 +263,12 @@
             extra = massRem;
         }else{
-            extra = round(massRem*rand());
+            extra = round(massRem*(double)rand() / (double)RAND_MAX);
             massRem = massRem-extra;
         }
-        //Spawn this child
-        AsteroidMinable* child = new AsteroidMinable(context);
+
+
+
+        //Spawn this child  Game crashes!
+        AsteroidMinable* child = new AsteroidMinable(this->context);
         child->setSize(extra + 1);
             
@@ -260,6 +276,17 @@
         //Relativ zu Elternteil automatisch?
         //Typ position:rand()*Vektoriwas?
-        // pawn->getWorldPosition() + Vector3(30,0,-30);
+        //pawn->getWorldPosition() + Vector3(30,0,-30);
         child->setPosition(this->getPosition() + Vector3(num*5, 0, 0));
+
+
+                //         Pawn* pawn = this->carrierToPawnHelper();
+                // if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+                //     this->Pickupable::destroy();
+
+                // //Attach to pawn
+                // Drone* drone = new Drone(pawn->getContext()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)
+                // drone->addTemplate(this->getDroneTemplate());
+
+
     }
 }
Index: code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.h
===================================================================
--- code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.h	(revision 11550)
+++ code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.h	(revision 11551)
@@ -62,9 +62,14 @@
         protected:
             // Da neue Argumente reinstellen
-            float asteroidVersion; // Bodenstrich-Konvention?, 
+            //float asteroidVersion; // Bodenstrich-Konvention?, 
             // Wert zwischen 1 und 6 (Spezialdinger?), die Mesh-Form
             float size;
             bool generateSmaller;
-            virtual void death();
+            bool initialised;
+
+            Context* context;
+
+            virtual void death(); 
+            virtual void putStuff();
 
 
@@ -74,5 +79,4 @@
             virtual void spawnChildren();
 
-            Context* context;
 
 
