Example #1
0
void TeronBuilder::calculate_fire_weapon()
{
	STACKTRACE;
	if ( fire_weapon && !fire_special && (thrust || turn_left || turn_right) ) {
		if ( weapon_recharge > 0 )
			return;

		if ( thrust ) {
			if ( select_all ) {
				select_all = false;
				current_drone = NULL;
				message.out( "All drones deselected" );
			} else {
				select_all = true;
				message.out( "All drones selected" );
			}

		}
		else if ( turn_right ) {
			select_all = false;
			TeronDrone* first_drone = NULL;
			TeronDrone* next_drone = NULL;
			Query q;
			for( q.begin( this, bit(LAYER_SHIPS), selectRange ); q.currento; q.next() ) {
				if ( !next_drone && sameShip( q.currento ) && q.currento->get_sprite() == data->TERON_DRONE_SPRITE ) {
					next_drone = (TeronDrone*)q.currento;
					if ( !first_drone ) first_drone = (TeronDrone*)q.currento;
				}
				if ( q.currento == current_drone ) {
					next_drone = NULL;
				}
			}
			q.end();
			if ( next_drone ) current_drone = next_drone;
			else current_drone = first_drone;
			message.out( "Next drone selected" );
		}
		else if ( turn_left ) {
			select_all = false;
			TeronDrone* prev_drone = NULL;
			Query q;
			for( q.begin( this, bit(LAYER_SHIPS), selectRange ); q.currento; q.next() ) {
				if ( q.currento == current_drone ) {
					if ( prev_drone ) break;
				}
				if ( sameShip( q.currento ) && q.currento->get_sprite() == data->TERON_DRONE_SPRITE ) {
					prev_drone = (TeronDrone*)q.currento;
				}
			}
			q.end();
			current_drone = prev_drone;
			message.out( "Prev drone selected" );
		}
		weapon_recharge += weapon_rate;

		play_sound2(data->sampleWeapon[weapon_sample]);
	}
}
Example #2
0
void TeronDrone::collect_resources()
{
	STACKTRACE;
	if ( !ship ) {
		assist_building();
		if ( target ) return;
	}
	SpaceObject* ast = NULL;
	double d = TERON_DRONE_SIGHT_RANGE;
	Query q;
	for( q.begin( this, bit(LAYER_CBODIES), TERON_DRONE_SIGHT_RANGE ); q.currento; q.next() ) {
		if ( q.currento->isAsteroid() ) {
			double i = distance( q.currento );
			if ( i < d ) {
				ast = q.currento;
				d = i;
			}
		}
	}
	q.end();
	if ( ast ) {
		control->target = ast;
		target = ast;

		if ( goal != collect ) roger();
		goal = collect;
		if ( docked ) leave_dock();
	}
}
Example #3
0
int EarthlingCruiserMk3::activate_special()
{
	STACKTRACE;
	bool fire = false;;
	SpaceObject *o;
	double rng = 1e40;
	SpaceObject *tgt = NULL;

								 //!!!
	pos -= unit_vector(angle) * 6;
	Query q;
	for (q.begin(this, bit(LAYER_SHIPS) + bit(LAYER_SHOTS) + bit(LAYER_SPECIAL) +
	bit(LAYER_CBODIES), specialRange); q.current; q.next()) {
		o = q.currento;
		if (!o->isInvisible() && !o->sameTeam(this) && (o->collide_flag_anyone&bit(LAYER_LINES))
		&& (distance(o) < rng)) {
			tgt = o;
			rng = distance(o);
		}
	}
	q.end();
								 //!!!
	pos += unit_vector(angle) * 6;

	if (tgt) {
		game->add(new EarthlingCruiserMk3Beam(this, Vector2(0,-6), specialRange,
			specialDamage, specialDamageShots, specialFrames, tgt));
		play_sound(data->sampleSpecial[0]);
		fire = true;
	}

	return(fire);
}
Example #4
0
int EarthlingCruiser2::activate_special()
{
	STACKTRACE;
	int fire = FALSE;
	SpaceObject *o;

	Query q;
	for (q.begin(this, bit(LAYER_SHIPS) + bit(LAYER_SHOTS) + bit(LAYER_SPECIAL) +
	bit(LAYER_CBODIES), specialRange); q.current; q.next()) {
		o = q.currento;
		if (!o->isInvisible() && !o->sameTeam(this) && (o->collide_flag_anyone&bit(LAYER_LINES))) {
			SpaceLocation *l = new PointLaser(this, pallete_color[specialColor], 1,
				specialFrames, this, o, Vector2(0.0,0.0));
			add(l);
			if (l->exists()) {
				fire = TRUE;
				l->set_depth(LAYER_EXPLOSIONS);
			}
		}
	}
	q.end();
	if (fire) sound.play((SAMPLE *)(melee[MELEE_BOOM + 0].dat));

	return(fire);
}
Error Context::endQuery(GLenum target)
{
    Query *queryObject = mState.getActiveQuery(target);
    ASSERT(queryObject);

    gl::Error error = queryObject->end();

    // Always unbind the query, even if there was an error. This may delete the query object.
    mState.setActiveQuery(target, NULL);

    return error;
}
Example #6
0
void TeronDrone::assist_building()
{
	STACKTRACE;
	Query q;
	for( q.begin( this, bit(LAYER_SPECIAL), TERON_DRONE_SIGHT_RANGE ); q.currento; q.next() ) {
		if ( sameShip( q.currento )) {
			TeronBuildPlatform* platform = ((TeronBuildPlatform*)q.currento);
			control->target = platform;
			target = platform;

			goal = build;
			if ( docked ) leave_dock();
			roger();
			break;
		}
	}
	q.end();
}
Example #7
0
void TeronBuilder::animate( Frame* space )
{
	STACKTRACE;
	Ship::animate( space );
	if ( select_all ) {
		Query q;
		for( q.begin( this, bit(LAYER_SHIPS), selectRange ); q.currento; q.next() ) {
			if ( sameShip( q.currento ) && q.currento->get_sprite() == data->TERON_DRONE_SPRITE ) {
				data->TERON_SELECTION_SPRITE->animate(
					q.currento->normal_pos(),
					selection_sprite_index, space );
			}
		}
		q.end();
	}else if ( current_drone ) data->TERON_SELECTION_SPRITE->animate(
				current_drone->normal_pos(),
				selection_sprite_index, space );
}
Example #8
0
int VirtaoLimb::activate_special()
{
	STACKTRACE;
	int fire = FALSE;

	Query q;
	for (q.begin(this, ALL_LAYERS, specialRange);q.current;q.next()) {
		if (q.current->canCollide(this)) {
			double a = trajectory_angle(q.current);
			q.current->translate(specialPower * unit_vector(a));
			fire = TRUE;
		}
	}
	q.end();
	if (fire) play_sound((SAMPLE *)(melee[MELEE_BOOM + 0].dat));

	return(fire);
}
Example #9
0
void GobDefender::calculate()
{
	STACKTRACE;
	SpaceObject::calculate();
	if (!ship) {
		die();
		return;
	}
	if (!(random(3))) {
		if (next_shoot_time < gobgame->game_time) {
			SpaceObject *target = NULL;
			Query q;
			if (advanced)
				q.begin(this, OBJECT_LAYERS, 330 );
			else
				q.begin(this, OBJECT_LAYERS &~ bit(LAYER_SHIPS), 290 );
			while (q.currento && !target) {
				if (!q.currento->sameTeam(ship) && (q.currento->get_team() != gobgame->station_team) && !q.currento->isPlanet()) {
					SpaceLine *l = new PointLaser (
						this, palette_color[7], 2 + advanced, 40,
						this, q.currento
						);
					add(l);
					if (l->exists()) target = q.currento;
				}
				q.next();
			}
			q.end();
			if (target) {
				if (advanced)
					next_shoot_time = gobgame->game_time + 360;
				else
					next_shoot_time = gobgame->game_time + 560;
			}
		}
	}
	double a = base_phase + (gobgame->game_time % 120000) * ( PI2 / 1000.0) / 6;
	angle = normalize(a,PI2);
	pos = normalize(ship->normal_pos() + 270 * unit_vector ( angle ));
	return;
}
Example #10
0
NaroolPoison::NaroolPoison(NaroolGas *gas, int nduration, float poison, Ship *nship, SpaceSprite *osprite) :
SpaceObject (gas, nship->normal_pos(), 0.0, osprite),
oship(nship),
poison(poison),
duration(nduration)
{
	STACKTRACE;
	target = oship;
	id |= NAROOL_POISON_ID;
	layer = LAYER_HOTSPOTS;
	start = TRUE;
	collide_flag_anyone = 0;
	Query q;
	for (q.begin(oship, bit(LAYER_HOTSPOTS), 10); q.current; q.next()) {
		if ((q.current->getID() == getID()) && (((NaroolPoison*)q.current)->oship == oship)) {
			((NaroolPoison*)q.current)->duration = duration;
			state = 0;
		}
	}
	q.end();
}
Example #11
0
void TeronBuilder::calculate()
{
	STACKTRACE;
	if ( selection_sprite_step < 0 ) {
		selection_sprite_step += TERON_SELECTION_ANIM_RATE;
		selection_sprite_index++;
		if ( selection_sprite_index == data->TERON_SELECTION_SPRITE->frames() )
			selection_sprite_index = 0;
	}else selection_sprite_step -= frame_time;
	if ( collecting ) {
		if ( !collecting->exists() ) {
			//fuel_sap -= asteroid_value;
			//handle_damage( this );
			handle_fuel_sap(this, -asteroid_value);
		}
		collecting = NULL;
	} else {
		if ( collect_step <= 0 && collectRange ) {
			Query q;
			for( q.begin( this, bit(LAYER_CBODIES), collectRange ); q.currento; q.next() ) {
				if ( q.currento->isAsteroid() ) {
					collecting = q.currento;
					game->add( new Laser( this, trajectory_angle( collecting ),
						pallete_color[TERON_COLLECT_BEAM_COLOR], distance( collecting ),
						TERON_COLLECT_BEAM_DAMAGE, time_ratio, this, 0, false ));
					collect_step = TERON_BUILDER_COLLECT_RATE;
					break;
				}
			}
			q.end();
		} else {
			collect_step -= frame_time;
		}
	}
	if ( !(current_drone && current_drone->exists()) )
		current_drone = NULL;
	Ship::calculate();
}
Example #12
0
int TeronBuilder::activate_special()
{
	STACKTRACE;

	if ( current_option == option_build_drone ) {
		if ( batt < drone_cost ) {
			special_low = true;
			return false;
		} else
		batt -= drone_cost;

		TeronDrone* drone = new TeronDrone( this,
		//x+100*cos(angle*ANGLE_RATIO), y+100*sin(angle*ANGLE_RATIO),
			pos + 100 * unit_vector(angle),
			angle, data->TERON_DRONE_SPRITE );
		TeronBuildPlatform* platform = drone->get_build_platform();
		game->add( platform );
		#ifdef TERON_SHIPS_TARGETABLE
		target->add( platform );
		#endif

	}
	else if ( current_option == option_build_turret ) {
		if ( batt < turret_cost ) {
			special_low = true;
			return false;
		}else batt -= turret_cost;
		TeronTurret* turret = new TeronTurret( this,
		//x+100*cos(angle*ANGLE_RATIO), y+100*sin(angle*ANGLE_RATIO),
			pos + 100 * unit_vector(angle),
			angle, data->TERON_TURRET_SPRITE );
		TeronBuildPlatform* platform = turret->get_build_platform();
		game->add( platform );
		#ifdef TERON_SHIPS_TARGETABLE
		target->add( platform );
		#endif

	}
	else if ( current_option == option_build_fighter ) {
		if ( batt < fighter_cost ) {
			special_low = true;
			return false;
		}else batt -= fighter_cost;
		TeronFighter* fighter = new TeronFighter( this,
		//x+100*cos(angle*ANGLE_RATIO), y+100*sin(angle*ANGLE_RATIO),
			pos + 100 * unit_vector(angle),
			angle, data->TERON_FIGHTER_SPRITE );
		TeronBuildPlatform* platform = fighter->get_build_platform();
		game->add( platform );
		#ifdef TERON_SHIPS_TARGETABLE
		target->add( platform );
		#endif

	}
	else if ( !select_all && current_option == option_order_assist_building ) {
		if ( current_drone ) current_drone->assist_building();

	}
	else if ( !select_all && current_option == option_order_collect_resources ) {
		if ( current_drone ) current_drone->collect_resources();

	}
	else if ( !select_all && current_option == option_order_return_to_dock ) {
		if ( current_drone ) current_drone->return_to_dock();

	} else {
		Query q;
		for( q.begin( this, bit(LAYER_SHIPS), selectRange ); q.currento; q.next() ) {
			if ( sameShip( q.currento ) && q.currento->get_sprite() == data->TERON_DRONE_SPRITE ) {
				if ( current_option == option_order_assist_building ) {
					((TeronDrone*)q.currento)->assist_building();
				}
				else if ( current_option == option_order_collect_resources ) {
					((TeronDrone*)q.currento)->collect_resources();
				}
				else if ( current_option == option_order_return_to_dock ) {
					((TeronDrone*)q.currento)->return_to_dock();
				}
			}
		}
		q.end();
	}
	return true;
}