コード例 #1
0
/**
 * Returns the AMLA-advanced version of a unit (with traits and items retained).
 */
unit_ptr get_amla_unit(const unit &u, const config &mod_option)
{
	unit_ptr amla_unit(new unit(u));
	amla_unit->set_experience(amla_unit->experience_overflow());
	amla_unit->add_modification("advancement", mod_option);
	return amla_unit;
}
コード例 #2
0
ファイル: attack.cpp プロジェクト: Coffee--/wesnoth-old
/**
 * Returns the AMLA-advanced version of a unit (with traits and items retained).
 */
unit get_amla_unit(const unit &u, const config &mod_option)
{
	unit amla_unit(u);
	amla_unit.set_experience(amla_unit.experience() - amla_unit.max_experience());
	amla_unit.add_modification("advance", mod_option);
	return amla_unit;
}
コード例 #3
0
ファイル: dialogs.cpp プロジェクト: bjrnt/littlebobbytables
bool animate_unit_advancement(const map_location &loc, size_t choice, const bool &fire_event)
{
	const events::command_disabler cmd_disabler;

	unit_map::iterator u = resources::units->find(loc);
	if (u == resources::units->end()) {
		LOG_DP << "animate_unit_advancement suppressed: invalid unit\n";
		return false;
	} else if (!u->advances()) {
		LOG_DP << "animate_unit_advancement suppressed: unit does not advance\n";
		return false;
	}

	const std::vector<std::string>& options = u->advances_to();
	std::vector<config> mod_options = u->get_modification_advances();

	if(choice >= options.size() + mod_options.size()) {
		LOG_DP << "animate_unit_advancement suppressed: invalid option\n";
		return false;
	}

	// When the unit advances, it fades to white, and then switches
	// to the new unit, then fades back to the normal color

	if (!resources::screen->video().update_locked()) {
		unit_animator animator;
		bool with_bars = true;
		animator.add_animation(&*u,"levelout", u->get_location(), map_location(), 0, with_bars);
		animator.start_animations();
		animator.wait_for_end();
	}

	if(choice < options.size()) {
		// chosen_unit is not a reference, since the unit may disappear at any moment.
		std::string chosen_unit = options[choice];
		::advance_unit(loc, chosen_unit, fire_event);
	} else {
		unit amla_unit(*u);
		const config &mod_option = mod_options[choice - options.size()];

		if(fire_event)
		{
			LOG_NG << "firing advance event (AMLA)\n";
			game_events::fire("advance",loc);
		}

		amla_unit.set_experience(amla_unit.experience() - amla_unit.max_experience());
		amla_unit.add_modification("advance",mod_option);
		resources::units->replace(loc, amla_unit);

		if(fire_event)
		{
			LOG_NG << "firing post_advance event (AMLA)\n";
			game_events::fire("post_advance",loc);
		}

	}

	u = resources::units->find(loc);
	resources::screen->invalidate_unit();

	if (u != resources::units->end() && !resources::screen->video().update_locked()) {
		unit_animator animator;
		animator.add_animation(&*u, "levelin", u->get_location(), map_location(), 0, true);
		animator.start_animations();
		animator.wait_for_end();
		animator.set_all_standing();
		resources::screen->invalidate(loc);
		resources::screen->draw();
		events::pump();
	}

	resources::screen->invalidate_all();
	resources::screen->draw();

	return true;
}