Example #1
0
// ----------------------------------------------------------------------------
// afterburners_stop() will be called when a ship disengages the afterburners.
//
// parameters:   *objp				=> pointer to the object starting afterburners
//						key_released	=>	OPTIONAL parameter (default value 0)
//												This is only used for the player object, to
//												manage starting/stopping
//
void afterburners_stop(object* objp, int key_released)
{
	Assert(objp != NULL);
	Assert(objp->instance >= 0 && objp->instance < MAX_SHIPS);

	ship_info* sip;
	ship* shipp;

	shipp = &Ships[objp->instance];

	Assert(shipp->ship_info_index >= 0 && shipp->ship_info_index < Num_ship_classes);
	sip = &Ship_info[shipp->ship_info_index];

	if ((objp->flags & OF_PLAYER_SHIP) && key_released)
	{
		objp->phys_info.flags &= ~PF_AFTERBURNER_WAIT;
	}

	if (!(sip->flags & SIF_AFTERBURNER))
	{
		nprintf(("Warning", "Ship type %s does not have afterburner capability\n", sip->name));
		return;
	}

	if (!(objp->phys_info.flags & PF_AFTERBURNER_ON))
	{
		return;
	}

	objp->phys_info.flags &= ~PF_AFTERBURNER_ON;
	float percent_left;
	percent_left = shipp->afterburner_fuel / sip->afterburner_fuel_capacity;

	//Do anim
	model_anim_start_type(shipp, TRIGGER_TYPE_AFTERBURNER, ANIMATION_SUBTYPE_ALL, -1);

	if (objp == Player_obj)
	{

		if (!key_released)
		{
			snd_play(&Snds[SND_ABURN_FAIL]);
		}

		if (Player_afterburner_loop_id > -1)
		{
			Player_disengage_timer = timestamp(DISENGAGE_TIME);
		}

		joy_ff_afterburn_off();
	}
}
/**
 * Called when a ship disengages the afterburners.
 *
 * @param *objp			pointer to the object starting afterburners
 * @param key_released	OPTIONAL parameter (default value 0) This is only used for the player object, to manage starting/stopping
 */
void afterburners_stop(object *objp, int key_released)
{
	Assert( objp != NULL );
	Assert( objp->instance >= 0 && objp->instance < MAX_SHIPS );
	
	ship_info *sip;
	ship *shipp;

	shipp = &Ships[objp->instance];

	Assert( shipp->ship_info_index >= 0 && shipp->ship_info_index < static_cast<int>(Ship_info.size()) );
	sip = &Ship_info[shipp->ship_info_index];

	if ( (objp->flags[Object::Object_Flags::Player_ship]) && key_released ) {
		objp->phys_info.flags &= ~PF_AFTERBURNER_WAIT;
	}

	if ( !(sip->flags[Ship::Info_Flags::Afterburner]) )	{
		nprintf(("Warning","Ship type %s does not have afterburner capability\n", sip->name));
		return;
	}

	if ( !(objp->phys_info.flags & PF_AFTERBURNER_ON) ) {
		return;
	}

	Script_system.SetHookObjects(1, "Ship", objp);
	Script_system.RunCondition(CHA_AFTERBURNEND, 0, NULL, objp);
	Script_system.RemHookVars(1, "Ship");

	objp->phys_info.flags &= ~PF_AFTERBURNER_ON;

	//Do anim
	model_anim_start_type(shipp, TRIGGER_TYPE_AFTERBURNER, ANIMATION_SUBTYPE_ALL, -1);

	if ( objp == Player_obj ) {

		if ( !key_released ) {
			snd_play( gamesnd_get_game_sound(ship_get_sound(objp, GameSounds::ABURN_FAIL)) );
		}

		if ( Player_afterburner_loop_id > -1 )	{
			Player_disengage_timer = timestamp(DISENGAGE_TIME);
		}

		joy_ff_afterburn_off();
	}
}
void joy_ff_stop_effects()
{
	joy_ff_afterburn_off();
}