public lifeforms(float elevation, bool Gasplanet, int lifeprecentage) { // Constructor for planetside random life gerneation. // Skip out early, easy way to reduce life density. if (rnd.NextDouble() > lifeprecentage / 200) { type = 0; health = 0; return; } chance_of_life[] life_picker = new chance_of_life[6]; if (!Gasplanet) { //If we are not talking a gas planet, then we need to construct // the table for the other types of planets. See the lifeform docs for the tables. if (elevation < 0.39) { // Water life_picker[0].chance = 0.983F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.993F; life_picker[1].mintype = 10; life_picker[1].maxtype = 14; life_picker[2].chance = 0.997F; life_picker[2].mintype = 3; life_picker[2].maxtype = 5; life_picker[3].chance = 0.999F; life_picker[3].mintype = 6; life_picker[3].maxtype = 7; life_picker[4].chance = 1.0F; life_picker[4].mintype = 0; life_picker[4].maxtype = 2; } else if (elevation >= 0.39 && elevation < 0.58) { // Shore life_picker[0].chance = 0.988F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.993F; life_picker[1].mintype = 21; life_picker[1].maxtype = 25; life_picker[2].chance = 0.996F; life_picker[2].mintype = 15; life_picker[2].maxtype = 20; life_picker[3].chance = 0.998F; life_picker[3].mintype = 0; life_picker[3].maxtype = 2; life_picker[4].chance = 1.0F; life_picker[4].mintype = 3; life_picker[4].maxtype = 9; } else if (elevation >= 0.58 && elevation < 0.78) { // Mid Elevation (Temperate) life_picker[0].chance = 0.977F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.988F; life_picker[1].mintype = 3; life_picker[1].maxtype = 9; life_picker[2].chance = 0.994F; life_picker[2].mintype = 15; life_picker[2].maxtype = 25; life_picker[3].chance = 1.0F; life_picker[3].mintype = 0; life_picker[3].maxtype = 3; life_picker[4].chance = 2.0F; // i.e.. This will never happen. life_picker[4].mintype = 0; life_picker[4].maxtype = 0; } else if (elevation >= 0.78 && elevation < 0.92) { // Highlands life_picker[0].chance = 0.977F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.988F; life_picker[1].mintype = 3; life_picker[1].maxtype = 9; life_picker[2].chance = 0.994F; life_picker[2].mintype = 15; life_picker[2].maxtype = 25; life_picker[3].chance = 1.0F; life_picker[3].mintype = 0; life_picker[3].maxtype = 3; life_picker[4].chance = 2.0F; // i.e.. This will never happen. life_picker[4].mintype = 0; life_picker[4].maxtype = 0; } else // Greater Than or Equal to 0.92 { //Mountains life_picker[0].chance = 0.997F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.998F; life_picker[1].mintype = 15; life_picker[1].maxtype = 20; life_picker[2].chance = 0.999F; life_picker[2].mintype = 3; life_picker[2].maxtype = 9; life_picker[3].chance = 1.0F; life_picker[3].mintype = 0; life_picker[3].maxtype = 2; life_picker[4].chance = 2.0F; // i.e.. This will never happen. life_picker[4].mintype = 0; life_picker[4].maxtype = 0; } } else { //Set up for gas planet. life_picker[0].chance = 0.983F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.988F; life_picker[1].mintype = 20; life_picker[1].maxtype = 20; life_picker[2].chance = 0.992F; life_picker[2].mintype = 25; life_picker[2].maxtype = 25; life_picker[3].chance = 0.995F; life_picker[3].mintype = 3; life_picker[3].maxtype = 5; life_picker[4].chance = 1.0F; life_picker[4].mintype = 2; life_picker[4].maxtype = 2; } float random = (float)rnd.NextDouble(); if (random < life_picker[0].chance) { type = 0; health = 0; life_picker = null; return; } else if (random >= life_picker[0].chance && random < life_picker[1].chance) { type = (short)(10 * (life_picker[1].maxtype - life_picker[1].mintype) * rnd.NextDouble() + life_picker[1].mintype); } else if (random >= life_picker[1].chance && random < life_picker[2].chance) { type = (short)(10 * (life_picker[2].maxtype - life_picker[2].mintype) * rnd.NextDouble() + life_picker[2].mintype); } else if (random >= life_picker[2].chance && random < life_picker[3].chance) { type = (short)(10 * (life_picker[3].maxtype - life_picker[3].mintype) * rnd.NextDouble() + life_picker[3].mintype); } else if (random >= life_picker[3].chance) { type = (short)(10 * (life_picker[4].maxtype - life_picker[4].mintype) * rnd.NextDouble() + life_picker[4].mintype); } type = (short)(type + (rnd.NextDouble() * 8 + 1)); //Add our lifeforms random "behavior" seed life_picker = null; onBehavior = 1; health = 100; speed = 0.02f; //Temporary for debuggin. angle = (short)(rnd.NextDouble() * 359); //Temporary for debuggin. }
public lifeforms(float elevation, bool Gasplanet, int lifeprecentage) { // Constructor for planetside random life gerneation. // Skip out early, easy way to reduce life density. if (rnd.NextDouble() > lifeprecentage / 200) { type = 0; health = 0; return; } chance_of_life[] life_picker = new chance_of_life[6]; if (!Gasplanet) { //If we are not talking a gas planet, then we need to construct // the table for the other types of planets. See the lifeform docs for the tables. if (elevation < 0.39) { // Water life_picker[0].chance = 0.983F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.993F; life_picker[1].mintype = 10; life_picker[1].maxtype = 14; life_picker[2].chance = 0.997F; life_picker[2].mintype = 3; life_picker[2].maxtype = 5; life_picker[3].chance = 0.999F; life_picker[3].mintype = 6; life_picker[3].maxtype = 7; life_picker[4].chance = 1.0F; life_picker[4].mintype = 0; life_picker[4].maxtype = 2; } else if (elevation >= 0.39 && elevation < 0.58) { // Shore life_picker[0].chance = 0.988F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.993F; life_picker[1].mintype = 21; life_picker[1].maxtype = 25; life_picker[2].chance = 0.996F; life_picker[2].mintype = 15; life_picker[2].maxtype = 20; life_picker[3].chance = 0.998F; life_picker[3].mintype = 0; life_picker[3].maxtype = 2; life_picker[4].chance = 1.0F; life_picker[4].mintype = 3; life_picker[4].maxtype = 9; } else if (elevation >= 0.58 && elevation < 0.78) { // Mid Elevation (Temperate) life_picker[0].chance = 0.977F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.988F; life_picker[1].mintype = 3; life_picker[1].maxtype = 9; life_picker[2].chance = 0.994F; life_picker[2].mintype = 15; life_picker[2].maxtype = 25; life_picker[3].chance = 1.0F; life_picker[3].mintype = 0; life_picker[3].maxtype = 3; life_picker[4].chance = 2.0F; // i.e.. This will never happen. life_picker[4].mintype = 0; life_picker[4].maxtype = 0; } else if (elevation >= 0.78 && elevation < 0.92) { // Highlands life_picker[0].chance = 0.977F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.988F; life_picker[1].mintype = 3; life_picker[1].maxtype = 9; life_picker[2].chance = 0.994F; life_picker[2].mintype = 15; life_picker[2].maxtype = 25; life_picker[3].chance = 1.0F; life_picker[3].mintype = 0; life_picker[3].maxtype = 3; life_picker[4].chance = 2.0F; // i.e.. This will never happen. life_picker[4].mintype = 0; life_picker[4].maxtype = 0; } else // Greater Than or Equal to 0.92 { //Mountains life_picker[0].chance = 0.997F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.998F; life_picker[1].mintype = 15; life_picker[1].maxtype = 20; life_picker[2].chance = 0.999F; life_picker[2].mintype = 3; life_picker[2].maxtype = 9; life_picker[3].chance = 1.0F; life_picker[3].mintype = 0; life_picker[3].maxtype = 2; life_picker[4].chance = 2.0F; // i.e.. This will never happen. life_picker[4].mintype = 0; life_picker[4].maxtype = 0; } } else { //Set up for gas planet. life_picker[0].chance = 0.983F; life_picker[0].mintype = 0; life_picker[0].maxtype = 0; life_picker[1].chance = 0.988F; life_picker[1].mintype = 20; life_picker[1].maxtype = 20; life_picker[2].chance = 0.992F; life_picker[2].mintype = 25; life_picker[2].maxtype = 25; life_picker[3].chance = 0.995F; life_picker[3].mintype = 3; life_picker[3].maxtype = 5; life_picker[4].chance = 1.0F; life_picker[4].mintype = 2; life_picker[4].maxtype = 2; } float random = (float)rnd.NextDouble(); if (random < life_picker[0].chance) { type = 0; health = 0; life_picker = null; return; } else if (random >= life_picker[0].chance && random < life_picker[1].chance) type = (short)(10 * (life_picker[1].maxtype - life_picker[1].mintype) * rnd.NextDouble() + life_picker[1].mintype); else if (random >= life_picker[1].chance && random < life_picker[2].chance) type = (short)(10 * (life_picker[2].maxtype - life_picker[2].mintype) * rnd.NextDouble() + life_picker[2].mintype); else if (random >= life_picker[2].chance && random < life_picker[3].chance) type = (short)(10 * (life_picker[3].maxtype - life_picker[3].mintype) * rnd.NextDouble() + life_picker[3].mintype); else if (random >= life_picker[3].chance) type = (short)(10 * (life_picker[4].maxtype - life_picker[4].mintype) * rnd.NextDouble() + life_picker[4].mintype); type = (short)(type + (rnd.NextDouble() * 8 + 1)); //Add our lifeforms random "behavior" seed life_picker = null; onBehavior = 1; health = 100; speed = 0.02f; //Temporary for debuggin. angle = (short)(rnd.NextDouble() * 359); //Temporary for debuggin. }