void Awake() { // Save references dfAudioSource = GetComponent <DaggerfallAudioSource>(); player = GameObject.FindGameObjectWithTag("Player"); mobile = GetComponentInChildren <DaggerfallMobileUnit>(); // Setup audio source dfAudioSource.AudioSource.maxDistance = AttractRadius; if (LinearRolloff) { dfAudioSource.AudioSource.rolloffMode = AudioRolloffMode.Linear; } dfAudioSource.AudioSource.spatialBlend = 1; // Assign sounds from mobile if (SoundsFromMobile && mobile) { MoveSound = (SoundClips)mobile.Summary.Enemy.MoveSound; BarkSound = (SoundClips)mobile.Summary.Enemy.BarkSound; AttackSound = (SoundClips)mobile.Summary.Enemy.AttackSound; } RaceForSounds = (Entity.Races)Random.Range(1, 5 + 1); // Start attract timer StartWaiting(); }
public void PlayCombatVoice(Entity.Genders gender, bool isAttack, bool heavyDamage = false) { // Male high elf sounds sound odd when coming from NPCs. Switch out for wood elf. if (gender == Entity.Genders.Male && RaceForSounds == Entity.Races.HighElf) { RaceForSounds = Entity.Races.WoodElf; } if (IsReady()) { SoundClips sound; if (isAttack) { sound = Entity.DaggerfallEntity.GetRaceGenderAttackSound(RaceForSounds, gender); } else { sound = Entity.DaggerfallEntity.GetRaceGenderPainSound(RaceForSounds, gender, heavyDamage); } float pitch = dfAudioSource.AudioSource.pitch; dfAudioSource.AudioSource.pitch = pitch + Random.Range(0, 0.3f); dfAudioSource.PlayOneShot(sound); dfAudioSource.AudioSource.pitch = pitch; } }