diff --git a/game.js b/game.js index b1ec340..ed2dcce 100644 --- a/game.js +++ b/game.js @@ -1944,24 +1944,10 @@ function chew() let linesummary = summarize(prey.sum(), false); let people = get_living_prey(prey.sum()); - let sound = ""; - if (people == 0) { - sound = ""; - } else if (people < 3) { - sound = "Snap."; - } else if (people < 10) { - sound = "Crunch."; - } else if (people < 50) { - sound = "Crack!"; - } else if (people < 500) { - sound = "CRUNCH!"; - } else if (people < 5000) { - sound = "CRRRUNCH!"; - } else { - sound = "Oh the humanity!"; - } let preyMass = prey.sum_property("mass"); + + let sound = getSound("chew", preyMass); add_victim_people("chew",prey); diff --git a/sounds.js b/sounds.js index 705cf26..b24391a 100644 --- a/sounds.js +++ b/sounds.js @@ -1,34 +1,47 @@ +let last_used = {}; + let sounds = { - "crush": ["Thump.", "Crunch.", "Crrruunch.", "CRUNCH!", "CRRRUNNCH!", "SKRRRRUNCH!", "SKRRRRRRRSMASH!"], - "swallow": ["Ulp.", "Gulp.", "Glrph.", "Glrrrpkh.", "Gluuuurrkph!","GLRP!","GLRRRRPKH!","GLUUUUURRPKH!"], - "liquid": ["Dribble.","Splat.","Splash.","Sploosh.","SPLASH!","SPLOOSH!","SPLOOOOOOSH!"], - "insert": ["Slp.","Shlp.","Shlllp.","Shlllrp.","SHLP!","SHLLLLRP!"], - "drop": ["Thump.","Thump!","Splat.","Splat!","SPLAT!"], - "belch": ["Burp.","Urph.","Urrrrrph.","UuuuuuuRRRRRPPHHHhhhh.","UUUURRRRPHH!","BUUUURRRRRRRRPPPHHH!"], + "crush": [["Thump.", "Thoomp."], ["Crunch."], ["Crrruunch."], ["CRUNCH!"], ["CRRRUNNCH!"], ["SKRRRRUNCH!"], ["SKRRRRRRRSMASH!"]], + "swallow": [["Ulp.", "Glp.", "Slurp."], ["Glrph.", "Glurk."], ["Gluuuurrkph!", "Glurp - GLK."],["GLRP!", "GULP!", "GLUK!"],["GLRRRRPKH!", "GLUUUURK!"],["GLUUUUURRPKH!", "GLOOOORPH-GLK!"]], + "liquid": [["Dribble."],["Splat."],["Splash."],["Sploosh."],["SPLASH!"],["SPLOOSH!"],["SPLOOOOOOSH!"]], + "insert": [["Slp.", "Shlk."],["Shlp.", "Shlrp."],["Shlllp."],["SHLP!", "SQUELCH!"],["SHLLLLRP!"]], + "drop": [["Thump."],["Thump!"],["Splat."],["Splat!"],["SPLAT!"]], + "belch": [["Burp.", "Urp."],["Urph.", "Burph."],["Urrrrrph."],["UuuuuuuRRRRRPPHHHhhhh."],["UUUURRRRPHH!"],["BUUUURRRRRRRRPPPHHH!"]], "fart": - ["Pft.","Pffft.","Pfffffbt.","Frrrrrrrt.","FRRRRRRRRPBBT!"], + [["Pft."],["Pffft."],["Pfffffbt."],["Frrrrrrrt."],["FRRRRRRRRPBBT!"]], "scat": - ["Clench.","Squeeeeeze.","Squeeeeeeeeeeeze.","Sqlllllch.","SQLLLLLLCH!"], + [["Clench."],["Squeeeeeze."],["Squeeeeeeeeeeeze."],["Sqlllllch."],["SQLLLLLLCH!"]], "digest": - ["Grrgle.","Grrrrgle","Grrrrlglorp.","GrrrrGLRRRLPH!","GRRRRRLGPRLHK!"], + [["Grrgle."],["Grrrrgle"],["Grrrrlglorp."],["GrrrrGLRRRLPH!"],["GRRRRRLGPRLHK!"]], "goo": - ["Splat.", "Squish.", "Squish!", "SQLCH!", "SQLLLLRCH!", "SQQQQUEEEEELLCH!"], + [["Splat."], ["Squish."], ["Squish!"], ["SQLCH!"], ["SQLLLLRCH!"], ["SQQQQUEEEEELLCH!"]], "vomit": - ["Hurk.", "Hurrk.", "Bleugh.", "Bleugh!", "Bleeeugh!", "BLEEEUGHK!"], + [["Hurk."], ["Hurrk."], ["Bleugh."], ["Bleugh!"], ["Bleeeugh!"], ["BLEEEUGHK!"]], "breath": - ["Woosh.","Fwoosh.","FWOOSH.","FWOOSH!","FWOOOOOOSH!"] + [["Woosh."],["Fwoosh."],["FWOOSH."],["FWOOSH!"],["FWOOOOOOSH!"]], + "chew": + [["Snap.", "Crack."],["Crunch."],["Crack!"],["CRUNCH!"],["CRRRUNCH!"]] }; -function pickByMass(list, mass) { +function pickByMass(name, mass) { + let list = sounds[name]; let index = Math.floor(Math.log10(mass/100)/2); index = Math.max(index, 0); - if (index < list.length) - return list[index]; - else - return list[list.length-1]; + choice = index < list.length ? list[index] : list[list.length-1]; + + let subindex = Math.floor(Math.random() * Math.floor(choice.length)); + + // less likely to repeat + if (last_used[name] != undefined && last_used[name] == subindex) { + subindex = Math.floor(Math.random() * Math.floor(choice.length)); + } + + last_used[name] = subindex; + + return choice[subindex]; } function getSound(name, mass) { - return pickByMass(sounds[name],mass); + return "" + pickByMass(name,mass) + ""; }