func Place(int amount, proplist rectangle, proplist settings) { var max_tries = 2 * amount; var loc_area = nil; if (rectangle) loc_area = Loc_InArea(rectangle); var f; while ((amount > 0) && (--max_tries > 0)) { var spot = FindLocation(Loc_Material("Water"), Loc_Space(20), loc_area); if (!spot) continue; f = CreateObjectAbove(this, spot.x, spot.y, NO_OWNER); if (!f) continue; // Randomly add some large/slim fish if (Random(3)) { // There are naturally smaller and larger fishes. Fishes above around 150 can be clipped, so stay below that. f->SetCon(RandomX(75, 140)); // make sure the smaller ones don't grow larger any more f->StopGrowth(); // Slim fish. if (f->GetCon() > 100 || !Random(3)) f->SetYZScale(1000 - Random(300)); } if (f->Stuck()) { f->RemoveObject(); continue; } --amount; } return f; // return last created fish }
func Place(int amount, proplist area, proplist settings) { var max_tries = 2 * amount; var loc_area = nil; if (area) loc_area = Loc_InArea(area); while ((amount > 0) && (--max_tries > 0)) { var spot = FindLocation(Loc_Material("Water"), Loc_Wall(CNAT_Bottom), loc_area); if (!spot) continue; var f = CreateObjectAbove(this, spot.x, spot.y, NO_OWNER); --amount; } return true; }
func Place(int amount, proplist area, proplist settings) { var max_tries = 2 * amount; var loc_area = nil; if (area) loc_area = Loc_InArea(area); while ((amount > 0) && (--max_tries > 0)) { var spot = FindLocation(Loc_Material("Water"), Loc_Wall(CNAT_Bottom | CNAT_Top | CNAT_Left | CNAT_Right), loc_area); if (!spot) continue; var plant = CreateObject(this, spot.x, spot.y, NO_OWNER); plant->SetClrModulation(HSL(Random(255), 255, 200)); plant->AddFork(nil, true); --amount; } return true; }