|
|
|
@@ -26,6 +26,42 @@ |
|
|
|
return choices[Math.floor(Math.random() * choices.length)]; |
|
|
|
} |
|
|
|
|
|
|
|
function limbsLost(state) { |
|
|
|
return Object.entries(state.player.limbs).filter(([name, status]) => { |
|
|
|
return !status; |
|
|
|
}).length; |
|
|
|
} |
|
|
|
|
|
|
|
function statLerp(id, stat, change, duration) { |
|
|
|
const iterations = duration / 1000 * 60; |
|
|
|
startTimer({ |
|
|
|
id: id, |
|
|
|
func: state => { |
|
|
|
changeStat(stat, change / iterations, state); |
|
|
|
return true; |
|
|
|
}, |
|
|
|
delay: 1000 / 60, |
|
|
|
loop: true, |
|
|
|
classes: [ |
|
|
|
|
|
|
|
] |
|
|
|
}, state); |
|
|
|
|
|
|
|
startTimer({ |
|
|
|
id: id + "-stopper", |
|
|
|
func: state => { |
|
|
|
stopTimer(id, state); |
|
|
|
return false; |
|
|
|
}, |
|
|
|
delay: duration, |
|
|
|
loop: false, |
|
|
|
classes: [ |
|
|
|
|
|
|
|
] |
|
|
|
}, state); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
const limbs = { |
|
|
|
head: "head", |
|
|
|
leftArm: "left arm", |
|
|
|
@@ -490,14 +526,31 @@ |
|
|
|
state.geta.slurps = 0; |
|
|
|
state.geta.chews = 0; |
|
|
|
state.geta.swallowsLeft = 3 + Math.floor(Math.random() * 3); |
|
|
|
state.geta.mawMovement = 1; |
|
|
|
|
|
|
|
startTimer({ |
|
|
|
id: "maw-random-movement", |
|
|
|
func: state => { |
|
|
|
changeStat("mawPos", Math.random() / 50 - 0.01, state); |
|
|
|
const time = new Date().getTime(); |
|
|
|
const movementFactor = (state.geta.mawMovement + limbsLost(state)); |
|
|
|
const fastPart = Math.sin(time / 200) / 1600 / 3; |
|
|
|
const slowPart = Math.sin(time / 1000) / 1600; |
|
|
|
changeStat("mawPos", movementFactor * (fastPart + slowPart), state); |
|
|
|
|
|
|
|
if (getStat("mawPos", state) <= 0.02) { |
|
|
|
print(["You slip too far back. Geta doesn't even have to try to swallow you like the food you are."]); |
|
|
|
goToRoom("throat", state); |
|
|
|
return false; |
|
|
|
} else if (getStat("mawPos", state) >= 0.98) { |
|
|
|
print(["Geta's jaws close like a falling guillotine's blade. You're crushed like an insect. A sharp gulp drags you down to the fox's guts."]); |
|
|
|
changeStat("health", -90, state); |
|
|
|
goToRoom("stomach", state); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
}, |
|
|
|
delay: 100, |
|
|
|
delay: 1000 / 60, |
|
|
|
loop: true, |
|
|
|
classes: [ |
|
|
|
"maw-struggle" |
|
|
|
@@ -508,17 +561,6 @@ |
|
|
|
id: "maw-struggle", |
|
|
|
func: state => { |
|
|
|
|
|
|
|
if (getStat("mawPos", state) <= 0.05) { |
|
|
|
print(["You slip too far back. Geta doesn't even have to try to swallow you like the food you are."]); |
|
|
|
goToRoom("throat", state); |
|
|
|
return false; |
|
|
|
} else if (getStat("mawPos", state) >= 0.95) { |
|
|
|
print(["Geta's jaws close like a falling guillotine's blade. You're crushed like an insect. A sharp gulp drags you down to the fox's guts."]); |
|
|
|
changeStat("health", -90, state); |
|
|
|
goToRoom("stomach", state); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (state.geta.swallowsLeft <= 0) { |
|
|
|
print(["Geta picks up his bowl of cereal and drinks it down, swallowing you in the process."]); |
|
|
|
goToRoom("throat", state); |
|
|
|
@@ -527,7 +569,9 @@ |
|
|
|
|
|
|
|
let choice; |
|
|
|
|
|
|
|
if (Math.random() > state.geta.slurps / 3) { |
|
|
|
if (Math.random() < 0.1) { |
|
|
|
choice = "slosh"; |
|
|
|
} else if (Math.random() > state.geta.slurps / 3) { |
|
|
|
choice = "slurp"; |
|
|
|
} else if (state.geta.chews - Math.floor(Math.random() * 3) < state.geta.slurps) { |
|
|
|
choice = "chew"; |
|
|
|
@@ -542,7 +586,7 @@ |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
print(["Swallows"]); |
|
|
|
changeStat("mawPos", -0.25, state); |
|
|
|
statLerp("maw-swallow", "mawPos", -0.25, 500); |
|
|
|
state.geta.slurps = 0; |
|
|
|
state.geta.chews = 0; |
|
|
|
state.geta.swallowsLeft -= 1; |
|
|
|
@@ -550,22 +594,49 @@ |
|
|
|
} |
|
|
|
|
|
|
|
} else if (choice == "slurp") { |
|
|
|
changeStat("mawPos", -0.1, state); |
|
|
|
statLerp("maw-swallow", "mawPos", -0.1, 250); |
|
|
|
print(["Slurps"]); |
|
|
|
state.geta.slurps += 1; |
|
|
|
return Math.random() * 1000 + 1500; |
|
|
|
} else if (choice == "chew") { |
|
|
|
if (getStat("mawPos", state) > 0.85) { |
|
|
|
print(["Chewed!"]); |
|
|
|
changeStat("health", -90, state); |
|
|
|
goToRoom("stomach", state); |
|
|
|
return false; |
|
|
|
const limb = randomBodyPart(state); |
|
|
|
state.player.limbs[limb] = false; |
|
|
|
const limbName = limbs[limb]; |
|
|
|
|
|
|
|
if (limb == "head") { |
|
|
|
print(["He chewed your head :((("]); |
|
|
|
changeStat("health", -100, state); |
|
|
|
goToRoom("stomach", state); |
|
|
|
} else { |
|
|
|
print(["He chewed your " + limbName + " :("]); |
|
|
|
changeStat("health", -40, state); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
print(["Chews"]); |
|
|
|
state.geta.chews += 1; |
|
|
|
return Math.random() * 500 + 1000; |
|
|
|
} |
|
|
|
} else if (choice == "slosh") { |
|
|
|
print(["Geta's tongue sloshes from side to side, throwing you around his maw like a ship in a storm."]); |
|
|
|
state.geta.mawMovement = 3; |
|
|
|
startTimer({ |
|
|
|
id: "maw-slosh-end", |
|
|
|
func: state => { |
|
|
|
state.geta.mawMovement = 1; |
|
|
|
print(["The sloshing ends."]); |
|
|
|
return true; |
|
|
|
}, |
|
|
|
delay: 4000, |
|
|
|
loop: false, |
|
|
|
classes: [ |
|
|
|
"maw-struggle" |
|
|
|
] |
|
|
|
}, state); |
|
|
|
|
|
|
|
return Math.random() * 1500 + 4500; |
|
|
|
} |
|
|
|
}, |
|
|
|
delay: 0, |
|
|
|
@@ -604,7 +675,7 @@ |
|
|
|
desc: "Pull yourself away from the fox's throat! Just don't go too far forward...", |
|
|
|
execute: (room, state) => { |
|
|
|
print(["You drag yourself forward"]); |
|
|
|
changeStat("mawPos", Math.random() * 0.1 + 0.15, state); |
|
|
|
statLerp("maw-swallow", "mawPos", 0.15 + Math.random() * 0.05, 250); |
|
|
|
}, |
|
|
|
show: [ |
|
|
|
|
|
|
|
@@ -617,9 +688,14 @@ |
|
|
|
name: "Slip Back", |
|
|
|
desc: "Slide back towards Geta's gullet", |
|
|
|
execute: (room, state) => { |
|
|
|
print(["You let yourself slip back"]); |
|
|
|
changeStat("mawPos", -Math.random() / 5 - 0.2, state); |
|
|
|
|
|
|
|
if (Math.random() < 0.9){ |
|
|
|
print(["You let yourself slip back."]); |
|
|
|
statLerp("maw-swallow", "mawPos", -0.2 - Math.random() * 0.1, 250); |
|
|
|
} else { |
|
|
|
print(["You lose your grip, sliding back quite far!"]); |
|
|
|
statLerp("maw-swallow", "mawPos", -0.3 - Math.random() * 0.15, 250); |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
show: [ |
|
|
|
|
|
|
|
|