[-] Fix for sound distance calculation for spells
This commit is contained in:
parent
7a2afec8db
commit
476ee0d05e
3 changed files with 9 additions and 3 deletions
|
@ -163,6 +163,8 @@ extern int DistanceSilent;
|
|||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/// Calculates volume level
|
||||
extern unsigned char CalculateVolume(bool isVolume, int power, unsigned char range);
|
||||
/// Play a unit sound
|
||||
extern void PlayUnitSound(const CUnit &unit, UnitVoiceGroup unit_voice_group);
|
||||
/// Play a unit sound
|
||||
|
|
|
@ -217,7 +217,7 @@ static CSound *ChooseUnitVoiceSound(const CUnit &unit, UnitVoiceGroup voice)
|
|||
**
|
||||
** @return volume for given distance (0..??)
|
||||
*/
|
||||
static unsigned char VolumeForDistance(unsigned short d, unsigned char range)
|
||||
unsigned char VolumeForDistance(unsigned short d, unsigned char range)
|
||||
{
|
||||
// FIXME: THIS IS SLOW!!!!!!!
|
||||
if (d <= ViewPointOffset || range == INFINITE_SOUND_RANGE) {
|
||||
|
@ -242,7 +242,7 @@ static unsigned char VolumeForDistance(unsigned short d, unsigned char range)
|
|||
** Calculate the volume associated with a request, either by clipping the
|
||||
** range parameter of this request, or by mapping this range to a volume.
|
||||
*/
|
||||
static unsigned char CalculateVolume(bool isVolume, int power, unsigned char range)
|
||||
unsigned char CalculateVolume(bool isVolume, int power, unsigned char range)
|
||||
{
|
||||
if (isVolume) {
|
||||
return std::min(MaxVolume, power);
|
||||
|
|
|
@ -529,7 +529,11 @@ int SpellCast(CUnit &caster, const SpellType &spell, CUnit *target, const Vec2i
|
|||
//
|
||||
// Ugly hack, CastAdjustVitals makes it's own mana calculation.
|
||||
//
|
||||
PlayGameSound(spell.SoundWhenCast.Sound, MaxSampleVolume);
|
||||
if (spell.Target == TargetSelf) {
|
||||
PlayUnitSound(caster, spell.SoundWhenCast.Sound);
|
||||
} else {
|
||||
PlayGameSound(spell.SoundWhenCast.Sound, CalculateVolume(false, ViewPointDistance(goalPos), spell.SoundWhenCast.Sound->Range));
|
||||
}
|
||||
for (std::vector<SpellActionType *>::const_iterator act = spell.Action.begin();
|
||||
act != spell.Action.end(); ++act) {
|
||||
if ((*act)->ModifyManaCaster) {
|
||||
|
|
Loading…
Reference in a new issue