Add in intro level scenes and identify combat-related sounds so they do not play on the main menu. Release Build 7587.

This commit is contained in:
2024-02-25 16:02:26 -06:00
parent 141e1622d6
commit 99049d6fa0
18 changed files with 1774 additions and 22 deletions
+13 -3
View File
@@ -49,23 +49,31 @@ INCLUDE_game
std::multimap<EventName,SoundEffect>SoundEffect::SOUND_EFFECTS;
const vf2d SoundEffect::CENTERED={-8419.f,-3289.f};
SoundEffect::SoundEffect(const std::string_view filename,const float&vol,const float&minPitch,const float&maxPitch)
:filename(filename),vol(vol),minPitch(minPitch),maxPitch(maxPitch){
SoundEffect::SoundEffect(const std::string_view filename,const float&vol,const float&minPitch,const float&maxPitch,const bool combatSound)
:filename(filename),vol(vol),minPitch(minPitch),maxPitch(maxPitch),combatSound(combatSound){
if(vol<0.f||vol>1.f)ERR(std::format("WARNING! Volume must be between 0.0f ~ 1.0f! Provided value {}",vol));
}
void SoundEffect::Initialize(){
for(auto&[key,size]:DATA["Events"]["SFX"]){
int counter=0;
bool combatSound=false;
if(DATA["Events"]["SFX"][key].HasProperty("CombatSound")){
combatSound=DATA["Events"]["SFX"][key]["CombatSound"].GetBool();
}
while(DATA["Events"]["SFX"][key].HasProperty(std::format("File[{}]",counter))){
utils::datafile&data=DATA["Events"]["SFX"][key][std::format("File[{}]",counter)];
float minPitch=0.9f;
float maxPitch=1.1f;
if(data.GetValueCount()>=3){minPitch=data.GetInt(2)/100.f;}
if(data.GetValueCount()>=4){maxPitch=data.GetInt(3)/100.f;}
SOUND_EFFECTS.insert({key,SoundEffect{data.GetString(0),data.GetInt(1)/100.f,minPitch,maxPitch}});
SOUND_EFFECTS.insert({key,SoundEffect{data.GetString(0),data.GetInt(1)/100.f,minPitch,maxPitch,combatSound}});
counter++;
}
auto itr=SOUND_EFFECTS.equal_range(key);
for(auto it=itr.first;it!=itr.second;++it){
it->second.combatSound=combatSound;
}
}
}
@@ -84,6 +92,8 @@ void SoundEffect::PlaySFX(const std::string_view eventName,const vf2d&pos){
}
const SoundEffect&sfx=(*it).second;
if(GameState::STATE==GameState::states[States::MAIN_MENU])return; //Do not play combat sounds on the main menu.
float pitchDiff=sfx.maxPitch-sfx.minPitch;
float pitch=util::random(pitchDiff)+sfx.minPitch;