Exemplo n.º 1
0
void RainbowRift::calculate()
{
	STACKTRACE;
	while (game->game_time > next_time) {
		next_time += 25;
		squiggle();
	}
	if (spawn_counter > 0) {
		spawn_counter -= frame_time;
		return;
	}
	while (game->game_time > next_time2) {
		STACKTRACE;
		next_time2 += random() % 3000;
		Query q;
		for (q.begin(this, bit(LAYER_SHIPS), 48); q.current; q.next()) {
			GobPlayer *p = gobgame->get_player(q.currento);
			if (!p) continue;
			if (q.currento == p->ship) {
				STACKTRACE;
				int i = 0;
				gobgame->pause();
				i = p->control->choose_ship(game->window, "You found the Rainbow Rift!\n(select your current ship type to hunt for resources instead of a new ship)", reference_fleet);
				game->log_int(p->channel, i);
				if (i == -1) i = random(reference_fleet->getSize());
				if (reference_fleet->getShipType(i) == p->ship->type) {
					times_found += 1;
					p->starbucks += random((times_found+2) * 9);
					p->buckazoids += random((times_found+2) * 6);
					pos = random(map_size);
					//game->add(new RainbowRift());
				}
				else {
					p->starbucks += random() % (1+p->value_starbucks);
					p->buckazoids += random() % (1+p->value_buckazoids);
					p->new_ship(reference_fleet->getShipType(i));
					pos = random(map_size);
					gobgame->station[0]->station_screen(p);
				}
				gobgame->unpause();
				game->redraw();
				spawn_counter = random(90000 + times_found * 15000);
			}
		}
		Planet *planet = nearest_planet();
		while (planet && distance(planet) < planet->gravity_range) {
			pos = random(map_size);
			planet = nearest_planet();
		}
	}
	return;
}
Exemplo n.º 2
0
planet_pointer dist_planetary_masses(long double stell_mass_ratio,
									 long double stell_luminosity_ratio, 
									 long double inner_dust, 
									 long double outer_dust,
									 long double outer_planet_limit,
									 long double dust_density_coeff,
									 planet_pointer seed_system,
									 int		 do_moons)
{
	long double 	a; 
	long double 	e; 
	long double 	mass;
	long double		dust_mass;
	long double		gas_mass;
	long double 	crit_mass; 
	long double 	planet_inner_bound; 
	long double 	planet_outer_bound;
	planet_pointer 	seeds = seed_system;
	
	set_initial_conditions(inner_dust,outer_dust);
	planet_inner_bound = nearest_planet(stell_mass_ratio);
	
	if (outer_planet_limit == 0)
		planet_outer_bound = farthest_planet(stell_mass_ratio);
	else
		planet_outer_bound = outer_planet_limit;
		
	while (dust_left)
	{
		if (seeds != NULL)
		{
			a = seeds->a;
			e = seeds->e;
			seeds = seeds->next_planet;
		}
		else
		{
			a = random_number(planet_inner_bound,planet_outer_bound);
			e = random_eccentricity( );
		}
		
		mass      = PROTOPLANET_MASS;
		dust_mass = 0;
		gas_mass  = 0;
		
		if (flag_verbose & 0x0200)
			fprintf (stderr, "Checking %Lg AU.\n",a);
			
		if (dust_available(inner_effect_limit(a, e, mass),
						   outer_effect_limit(a, e, mass))) 
		{
			if (flag_verbose & 0x0100)
				fprintf (stderr, "Injecting protoplanet at %Lg AU.\n", a);
			
			dust_density = dust_density_coeff * sqrt(stell_mass_ratio)
						   * exp(-ALPHA * pow(a,(1.0 / N)));
			crit_mass = critical_limit(a,e,stell_luminosity_ratio);
			accrete_dust(&mass, &dust_mass, &gas_mass,
						 a,e,crit_mass,
						 planet_inner_bound,
						 planet_outer_bound);
			
			dust_mass += PROTOPLANET_MASS;
			
			if (mass > PROTOPLANET_MASS)
				coalesce_planetesimals(a,e,mass,crit_mass,
									   dust_mass, gas_mass,
									   stell_luminosity_ratio,
									   planet_inner_bound,planet_outer_bound,
									   do_moons);
			else if (flag_verbose & 0x0100)
				fprintf (stderr, ".. failed due to large neighbor.\n");
		}
		else if (flag_verbose & 0x0200)
			fprintf (stderr, ".. failed.\n");
	}
	return(planet_head);
}