Esempio n. 1
0
// --------------------------------------------------------
// get an sound from a stack
// --------------------------------------------------------
t_sound_ptr get_combat_sound( t_creature_stack const& stack, t_combat_actor_action_id action )
{
	t_hero const* hero = stack.get_hero();

	if (hero != 0)
		return get_sound( hero->get_alignment(), hero->uses_spellcaster_model(),
			              hero->has_ability( k_ability_ranged ), 
						  hero->is_male(), action );
	return get_sound( stack.get_creature_type(), action );
}
Esempio n. 2
0
// ----------------------------------------------------------------------------
// get a sound for a creature
// ----------------------------------------------------------------------------
static t_sound_ptr get_sound( t_creature_type creature, t_combat_actor_action_id action )
{
	static bool          initialized = false;
	static t_sound_cache caches[k_creature_type_count][k_combat_actor_action_count];

	if (!initialized)
	{
		t_creature_type          index;
		t_combat_actor_action_id id;
		std::string              name;
		
		for (index = t_creature_type(0); index < k_creature_type_count; enum_incr(index))
		{
			for (id = t_combat_actor_action_id(0); id < k_combat_actor_action_count; 
			     enum_incr(id))
			{
				name = get_keyword( index );
				name += ".";
				name += get_combat_actor_action_name( id );
				caches[index][id] = t_sound_cache( name );
			}
		}
		initialized = true;
	}
	
	t_sound_ptr result = caches[creature][action].get();

	if (result == 0)
		if ( action == k_combat_actor_action_melee_down 
			 || action == k_combat_actor_action_melee_up)
			return get_sound( creature, k_combat_actor_action_melee );
		
	return result;
}
Esempio n. 3
0
void sound_resume_all()
{
  for (size_t i = 0; i < sound_resources.size(); i++) {
    get_sound(snd, i, 0);
	snd->soundBuffer->Play(0, 0, 0);
  }
}
Esempio n. 4
0
void sound_stop_all()
{
  for (size_t i = 0; i < sound_resources.size(); i++) {
    get_sound(snd, i, 0);
	snd->soundBuffer->Stop();
  }
}
Esempio n. 5
0
bool sound_loop(int sound) // Returns whether sound is playing
{
	get_sound(snd, sound, false);
	snd->soundBuffer->SetCurrentPosition(0);
	snd->soundBuffer->Play(0, 0, DSBPLAY_LOOPING);
	return true;
}
Esempio n. 6
0
bool sound_isplaying(int sound) {
	get_sound(snd, sound, false);
	LPDWORD ret = NULL;
	snd->soundBuffer->GetStatus(ret);
	if (*ret == DSBSTATUS_LOOPING || *ret == DSBSTATUS_LOOPING) {
		return true;
	} else {
		return false;
	}
}
Esempio n. 7
0
// --------------------------------------------------------
// get an sound based on a hero's alignment and traits
// --------------------------------------------------------
static t_sound_ptr get_sound( t_town_type alignment,
							  bool		  is_spellcaster,
							  bool        has_archery,
							  bool		  is_male,
							  t_combat_actor_action_id action)
{
	static bool initialized = false;
	t_hero_combat_model_type	type;

	static t_sound_cache caches[k_town_type_count][k_hero_combat_model_count][2][k_combat_actor_action_count];
	
	if (!initialized)
	{
		t_town_type					town;
		std::string					base_name;
		std::string					name;
		int							sex;
		t_combat_actor_action_id	id;


		for (town = t_town_type(0); town < k_town_type_count; enum_incr(town))
		{
			for (type = t_hero_combat_model_type(0); type < k_hero_combat_model_count; 
			     enum_incr(type))
			{
				for (sex = 0; sex < 2; sex++)
				{
					base_name = get_combat_type_keyword( town, type, sex == 1);
					for (id = t_combat_actor_action_id(0); id < k_combat_actor_action_count; 
						 enum_incr(id))
					{
						name = base_name;
						name += ".";
						name += get_combat_actor_action_name( id );
						caches[town][type][sex][id] = t_sound_cache( name );
					}
				}
			}
		}
		initialized = true;
	}

	if (is_spellcaster && alignment != k_town_might)
		type = k_model_spellcaster;
	else if (has_archery)
		type = k_model_archer;
	else
		type = k_model_fighter;

	t_sound_ptr result = caches[alignment][type][is_male][action].get();

	if (result == 0)
		result = get_sound( k_mage, action );
	return result;
}
Esempio n. 8
0
void Resources::prepare_resources() throw (ResourcesException) {
    /* load animation sounds */
    for (ResourceObjects::iterator it = animations.begin(); it != animations.end(); it++) {
        ResourceObject& ro = *it;
        Animation *ani = static_cast<Animation *>(ro.object);
        const std::string& sound_name = ani->get_value("sound_name");
        if (sound_name.length()) {
            ani->set_sound(get_sound(sound_name));
        }
    }
}
Esempio n. 9
0
float sound_get_volume(int sound) {
	get_sound(snd, sound, -1);
	LPLONG ret = NULL;
	snd->soundBuffer->GetVolume(ret);
	return *ret;
}
Esempio n. 10
0
float sound_get_pan(int sound) {
	get_sound(snd, sound, -1);
	LPLONG ret = NULL;
	snd->soundBuffer->GetPan(ret);
	return *ret;
}
Esempio n. 11
0
bool sound_ispaused(int sound) {
  get_sound(snd, sound, false);
  return !snd->idle and !snd->playing;
}
Esempio n. 12
0
bool sound_resume(int sound) // Returns whether the sound is playing
{
	get_sound(snd, sound, false);
	snd->soundBuffer->Play(0, 0, 0);
	return true;
}
Esempio n. 13
0
bool sound_play(int sound) // Returns whether sound is playing
{
	get_sound(snd, sound, 0);
	snd->soundBuffer->SetCurrentPosition(0);
	snd->soundBuffer->Play(0, 0, 0);
}
Esempio n. 14
0
void sound_seek(int sound, float position) {
	get_sound(snd, sound, 0);
	snd->soundBuffer->SetCurrentPosition(position);
}
Esempio n. 15
0
void sound_volume(int sound, float volume) {
	get_sound(snd,sound,0);
	snd->soundBuffer->SetVolume((1-volume) * DSBVOLUME_MIN);
}
Esempio n. 16
0
void sound_delete(int sound) {
  get_sound(snd,sound,0);
  sound_stop(sound);
  sound_resources.erase(sound_resources.begin() + sound);
}
Esempio n. 17
0
void sound_stop(int sound) {
	get_sound(snd, sound, 0);
	snd->soundBuffer->Stop();
}
Esempio n. 18
0
float sound_get_length(int sound) { // Not for Streams
	get_sound(snd, sound, -1);
	//snd->soundBuffer->GetLength();
	return 0;
}
Esempio n. 19
0
float sound_get_position(int sound) { // Not for Streams
	get_sound(snd, sound, -1);
	LPDWORD ret = NULL;
	snd->soundBuffer->GetCurrentPosition(ret, NULL);
	return *ret;
}
Esempio n. 20
0
void sound_pan(int sound, float value)
{
	get_sound(snd, sound, 0);
	snd->soundBuffer->SetPan(value * 10000);
}
Esempio n. 21
0
bool sound_pause(int sound) // Returns whether the sound was successfully paused
{
	get_sound(snd, sound, false);
	snd->soundBuffer->Stop();
	return true;
}
Esempio n. 22
0
void sound_seek_all(float position) {
  for (size_t i = 0; i < sound_resources.size(); i++) {
    get_sound(snd, i, 0);
	snd->soundBuffer->SetCurrentPosition(position);
  }
}