User prompt
Make “custom night”, night 6. And after player finishes it, it ends with “custom night cutscene” and them takes player to the main menu. No night 1, night 2, night 3, night 4, night 5.
User prompt
Make custom night, night 6. And after player finishes it, it ends with custom night cutscene and them takes player to the main menu. No night 1, night 2, night 3, night 4, night 5.
User prompt
Still it’s not one night, make it 1 part only different from main game. When player finishes it show custom night end cutscene
User prompt
It is still not one night
User prompt
Make custom night only one night, when player finishes it, show the customNightCutscene and play customNightEndSound
User prompt
add "Unlock Extras" button in admin mode, it shows extras button
User prompt
take player back to the main menu after night 5 ends
User prompt
when the night 5 ends, everything in game dissappears in menu
User prompt
remove "Unlock Extras" button from admin mode
User prompt
make the jumpscares text a little bit bigger
User prompt
write Jumpscares on top animatronic's images also change the name of; freddy to Sigma Bart bonnie to George Floyd chica to Noyan foxy to Sigma Mango Mustard
User prompt
also don't take player back to the main menu after "Extras" Jumpscare
User prompt
don't make the player die in "Extras" Jumpscare
User prompt
in "Extras" add each animatronic's jumpscare button; freddy, bonnie, Chica and foxy in order with their image
User prompt
when player finishes all 5 nights they unlock, "Extras" button, if they didn't finish all 5 nights, they can't see and access the "Extras" Button ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
add menu image into "Extras"
User prompt
add "Unlock Extras" button in admin mode, it shows extras button ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
when player finishes all 5 nights they unlock, "Extras" button, if they didn't finish all 5 nights, they can't see and access the "Extras" Button ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
When player buys the anime poster it appears on office wall ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add anime poster image
User prompt
Add “Anime poster” to the shop for 350 $ ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
When player finishes a night it gets 50$ ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add unlimited money button in admin mode ↪💡 Consider importing and using the following plugins: @upit/storage.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Animatronic = Container.expand(function (type, startX, startY) {
var self = Container.call(this);
var graphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.type = type;
self.currentRoom = 0; // 0 = stage, 1-10 = various rooms
self.moveTimer = 0;
self.aggressionLevel = 1;
self.isMoving = false;
// Movement state tracking for specific patterns
self.movementState = 0; // Track current state in movement cycle
self.lastMoveTime = 0; // Track when last move happened
self.waitingInBasement = false;
self.waitingInParty = false;
// Different movement patterns for each animatronic
self.movementPattern = {
freddy: [0],
// Freddy stays on stage
bonnie: [0, 5, 2, 3],
// Stage -> Basement -> Party -> Left Corridor (repeats)
chica: [0, 2, 4, 6],
// Stage -> Party Area -> Right Corridor -> Office
foxy: [5, 2, 3] // Basement -> Party Area -> Left Corridor
};
self.update = function () {
self.moveTimer++;
// Get current aggression level (use custom night values if in custom night mode)
var currentAggression = self.aggressionLevel;
if (nightNumber === 7 && typeof window.characterLevels !== 'undefined') {
// In custom night mode, use the character level set by player (single night only)
if (self.type === 'freddy' && window.characterLevels.freddy) {
currentAggression = window.characterLevels.freddy;
} else if (self.type === 'bonnie' && window.characterLevels.bonnie) {
currentAggression = window.characterLevels.bonnie;
} else if (self.type === 'chica' && window.characterLevels.chica) {
currentAggression = window.characterLevels.chica;
} else if (self.type === 'foxy' && window.characterLevels.foxy) {
currentAggression = window.characterLevels.foxy;
}
}
// Handle specific movement patterns
if (self.type === 'freddy') {
// In custom night, Freddy moves based on aggression level
if (nightNumber === 7) {
var moveChance = currentAggression * 0.001;
if (Math.random() < moveChance && !self.isMoving) {
self.attemptMove();
}
} else if (nightNumber === 5) {
// Night 5 behavior: moves to right corridor at 12:20, repeats after 15 seconds
var currentTime = LK.ticks / 60; // Convert to seconds
if (self.movementState === 0 && gameHour >= 0 && gameMinutes >= 20) {
self.moveToRoom(4); // Move to right corridor
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In right corridor, wait 15 seconds then restart cycle
else if (self.movementState === 1 && currentTime - self.lastMoveTime >= 15) {
self.moveToRoom(4); // Move back to right corridor (stay there, repeat cycle)
self.movementState = 1;
self.lastMoveTime = currentTime;
}
} else {
// Freddy doesn't move, stays on stage
return;
}
} else if (self.type === 'bonnie') {
// Increase Bonnie's movement frequency based on aggression
if (nightNumber === 7) {
// In custom night, override time-based movement with aggression-based
var moveChance = currentAggression * 0.002;
if (Math.random() < moveChance && !self.isMoving) {
self.attemptMove();
}
} else {
self.updateBonnieMovement();
}
} else if (self.type === 'chica') {
// Increase Chica's movement frequency based on aggression
if (nightNumber === 7) {
// In custom night, override time-based movement with aggression-based
var moveChance = currentAggression * 0.002;
if (Math.random() < moveChance && !self.isMoving) {
self.attemptMove();
}
} else {
self.updateChicaMovement();
}
} else if (self.type === 'foxy') {
// Increase Foxy's movement frequency based on aggression
if (nightNumber === 7) {
// In custom night, override time-based movement with aggression-based
var moveChance = currentAggression * 0.003; // Foxy is more aggressive
if (Math.random() < moveChance && !self.isMoving) {
self.attemptMove();
}
} else {
self.updateFoxyMovement();
}
} else {
// Original movement logic for other animatronics
var moveChance = currentAggression * 0.002;
if (Math.random() < moveChance && !self.isMoving) {
self.attemptMove();
}
}
};
self.updateBonnieMovement = function () {
if (self.isMoving) return; // Don't move if already moving
var currentTime = LK.ticks / 60; // Convert to seconds
// Get current aggression level for timing adjustments
var currentAggression = self.aggressionLevel;
if (nightNumber === 7 && typeof window.characterLevels !== 'undefined' && window.characterLevels.bonnie) {
currentAggression = window.characterLevels.bonnie;
}
// Calculate time reductions based on aggression level (5 seconds per level)
var timeReduction = (currentAggression - 1) * 5;
var basementWaitTime = Math.max(5, 30 - timeReduction); // Minimum 5 seconds
var corridorWaitTime = Math.max(5, 20 - timeReduction); // Minimum 5 seconds
// Night 2 behavior with difficulty-based timing
if (nightNumber === 2) {
// Calculate adjusted timing based on difficulty
var moveToBasementTime = Math.max(5, 45 - timeReduction); // 12:45 AM adjusted by difficulty
var moveToPartyTime = Math.max(0, 60 - timeReduction); // 1:00 AM adjusted by difficulty
var moveToCorridorTime = Math.max(15, 90 - timeReduction); // 1:30 AM adjusted by difficulty
// State 0: On stage, move to basement at adjusted time
if (self.movementState === 0 && gameHour >= 0 && gameMinutes >= moveToBasementTime) {
self.moveToRoom(5); // Move to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
// State 1: In basement, move to party room at adjusted time
else if (self.movementState === 1 && gameHour >= 1 && gameMinutes >= moveToPartyTime && self.waitingInBasement) {
self.moveToRoom(2); // Move to party room
self.movementState = 2;
self.lastMoveTime = currentTime;
self.waitingInBasement = false;
self.waitingInParty = true;
}
// State 2: In party room, move to left corridor at adjusted time
else if (self.movementState === 2 && gameHour >= 1 && gameMinutes >= moveToCorridorTime && self.waitingInParty) {
self.moveToRoom(3); // Move to left corridor
self.movementState = 3;
self.lastMoveTime = currentTime;
self.waitingInParty = false;
}
// State 3: In left corridor, wait reduced time then restart cycle
else if (self.movementState === 3 && currentTime - self.lastMoveTime >= corridorWaitTime) {
self.moveToRoom(5); // Move back to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
} else if (nightNumber === 3) {
// Night 3 behavior: Moves to basement at 12:20 AM, then to party room after 20 seconds, then to left corridor at 1:10 AM, repeats after 15 seconds
// State 0: On stage, move to basement at 12:20 AM
if (self.movementState === 0 && gameHour >= 0 && gameMinutes >= 20) {
self.moveToRoom(5); // Move to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
// State 1: In basement, wait 20 seconds then move to party room
else if (self.movementState === 1 && self.waitingInBasement && currentTime - self.lastMoveTime >= 20) {
self.moveToRoom(2); // Move to party room
self.movementState = 2;
self.lastMoveTime = currentTime;
self.waitingInBasement = false;
self.waitingInParty = true;
}
// State 2: In party room, move to left corridor at 1:10 AM
else if (self.movementState === 2 && gameHour >= 1 && gameMinutes >= 10 && self.waitingInParty) {
self.moveToRoom(3); // Move to left corridor
self.movementState = 3;
self.lastMoveTime = currentTime;
self.waitingInParty = false;
}
// State 3: In left corridor, wait 15 seconds then restart cycle
else if (self.movementState === 3 && currentTime - self.lastMoveTime >= 15) {
self.moveToRoom(5); // Move back to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
} else if (nightNumber === 4) {
// Night 4 behavior: Moves to basement at 12:10 AM, then to party room after 10 seconds, then to left corridor at 1:00 AM, repeats after 10 seconds
// State 0: On stage, move to basement at 12:10 AM
if (self.movementState === 0 && gameHour >= 0 && gameMinutes >= 10) {
self.moveToRoom(5); // Move to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
// State 1: In basement, wait 10 seconds then move to party room
else if (self.movementState === 1 && self.waitingInBasement && currentTime - self.lastMoveTime >= 10) {
self.moveToRoom(2); // Move to party room
self.movementState = 2;
self.lastMoveTime = currentTime;
self.waitingInBasement = false;
self.waitingInParty = true;
}
// State 2: In party room, move to left corridor at 1:00 AM
else if (self.movementState === 2 && gameHour >= 1 && gameMinutes >= 0 && self.waitingInParty) {
self.moveToRoom(3); // Move to left corridor
self.movementState = 3;
self.lastMoveTime = currentTime;
self.waitingInParty = false;
}
// State 3: In left corridor, wait 10 seconds then restart cycle
else if (self.movementState === 3 && currentTime - self.lastMoveTime >= 10) {
self.moveToRoom(5); // Move back to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
} else if (nightNumber === 5) {
// Night 5 behavior: Moves to basement at 12:05 AM, then to party room after 5 seconds, then to left corridor at 12:30 AM, repeats after 5 seconds
// State 0: On stage, move to basement at 12:05 AM
if (self.movementState === 0 && gameHour >= 0 && gameMinutes >= 5) {
self.moveToRoom(5); // Move to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
// State 1: In basement, wait 5 seconds then move to party room
else if (self.movementState === 1 && self.waitingInBasement && currentTime - self.lastMoveTime >= 5) {
self.moveToRoom(2); // Move to party room
self.movementState = 2;
self.lastMoveTime = currentTime;
self.waitingInBasement = false;
self.waitingInParty = true;
}
// State 2: In party room, move to left corridor at 12:30 AM
else if (self.movementState === 2 && gameHour >= 0 && gameMinutes >= 30 && self.waitingInParty) {
self.moveToRoom(3); // Move to left corridor
self.movementState = 3;
self.lastMoveTime = currentTime;
self.waitingInParty = false;
}
// State 3: In left corridor, wait 5 seconds then restart cycle
else if (self.movementState === 3 && currentTime - self.lastMoveTime >= 5) {
self.moveToRoom(5); // Move back to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
} else {
// Original behavior for other nights with difficulty-based timing
var moveToBasementHour = Math.max(0, 1 - Math.floor(timeReduction / 60)); // 1 AM adjusted by difficulty
var moveToPartyHour = Math.max(1, 2 - Math.floor(timeReduction / 60)); // 2 AM adjusted by difficulty
if (gameHour < moveToBasementHour) return; // Bonnie doesn't move until adjusted time
// State 0: On stage, move to basement at adjusted time
if (self.movementState === 0 && gameHour >= moveToBasementHour) {
self.moveToRoom(5); // Move to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
// State 1: In basement, wait reduced time then move to party room
else if (self.movementState === 1 && self.waitingInBasement && currentTime - self.lastMoveTime >= basementWaitTime) {
self.moveToRoom(2); // Move to party room
self.movementState = 2;
self.lastMoveTime = currentTime;
self.waitingInBasement = false;
self.waitingInParty = true;
}
// State 2: In party room, move to left corridor at adjusted time
else if (self.movementState === 2 && gameHour >= moveToPartyHour && self.waitingInParty) {
self.moveToRoom(3); // Move to left corridor
self.movementState = 3;
self.lastMoveTime = currentTime;
self.waitingInParty = false;
}
// State 3: In left corridor, wait reduced time then restart cycle
else if (self.movementState === 3 && currentTime - self.lastMoveTime >= corridorWaitTime) {
self.moveToRoom(5); // Move back to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
self.waitingInBasement = true;
}
}
};
self.updateChicaMovement = function () {
if (self.isMoving) return; // Don't move if already moving
var currentTime = LK.ticks / 60; // Convert to seconds
// Get current aggression level for timing adjustments
var currentAggression = self.aggressionLevel;
if (nightNumber === 7 && typeof window.characterLevels !== 'undefined' && window.characterLevels.chica) {
currentAggression = window.characterLevels.chica;
}
// Calculate time reductions based on aggression level (5 seconds per level)
var timeReduction = (currentAggression - 1) * 5;
var corridorWaitTime = Math.max(5, 20 - timeReduction); // Minimum 5 seconds for corridor wait
// Night 2 behavior
if (nightNumber === 2) {
// State 0: On stage, move to basement at 12:30 AM
if (self.movementState === 0 && gameHour >= 0 && gameMinutes >= 30) {
self.moveToRoom(5); // Move to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In basement, move to bathroom at 12:50 AM
else if (self.movementState === 1 && gameHour >= 0 && gameMinutes >= 50) {
self.moveToRoom(1); // Move to bathroom
self.movementState = 2;
self.lastMoveTime = currentTime;
}
// State 2: In bathroom, move to party room at 1:00 AM
else if (self.movementState === 2 && gameHour >= 1 && gameMinutes >= 0) {
self.moveToRoom(2); // Move to party room
self.movementState = 3;
self.lastMoveTime = currentTime;
}
// State 3: In party room, move to right corridor at 1:25 AM
else if (self.movementState === 3 && gameHour >= 1 && gameMinutes >= 25) {
self.moveToRoom(4); // Move to right corridor
self.movementState = 4;
self.lastMoveTime = currentTime;
}
// State 4: In right corridor, wait reduced time then restart cycle
else if (self.movementState === 4 && currentTime - self.lastMoveTime >= corridorWaitTime) {
self.moveToRoom(5); // Move back to basement
self.movementState = 1;
self.lastMoveTime = currentTime;
}
} else if (nightNumber === 3) {
// Night 3 behavior: moves to bathroom at 12:30 AM, then to party room at 12:30 AM, then to right corridor at 2:20 AM, repeats after 10 seconds
// State 0: On stage, move to bathroom at 12:30 AM
if (self.movementState === 0 && gameHour >= 0 && gameMinutes >= 30) {
self.moveToRoom(1); // Move to bathroom
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In bathroom, immediately move to party room (same time 12:30 AM)
else if (self.movementState === 1) {
self.moveToRoom(2); // Move to party room
self.movementState = 2;
self.lastMoveTime = currentTime;
}
// State 2: In party room, move to right corridor at 2:20 AM
else if (self.movementState === 2 && gameHour >= 2 && gameMinutes >= 20) {
self.moveToRoom(4); // Move to right corridor
self.movementState = 3;
self.lastMoveTime = currentTime;
}
// State 3: In right corridor, wait 10 seconds then restart cycle
else if (self.movementState === 3 && currentTime - self.lastMoveTime >= 10) {
self.moveToRoom(1); // Move back to bathroom
self.movementState = 1;
self.lastMoveTime = currentTime;
}
} else if (nightNumber === 4) {
// Night 4 behavior: moves to bathroom at 12:20 AM, then to party room at 12:40 AM, then to right corridor at 2:00 AM, repeats after 5 seconds
// State 0: On stage, move to bathroom at 12:20 AM
if (self.movementState === 0 && gameHour >= 0 && gameMinutes >= 20) {
self.moveToRoom(1); // Move to bathroom
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In bathroom, move to party room at 12:40 AM
else if (self.movementState === 1 && gameHour >= 0 && gameMinutes >= 40) {
self.moveToRoom(2); // Move to party room
self.movementState = 2;
self.lastMoveTime = currentTime;
}
// State 2: In party room, move to right corridor at 2:00 AM
else if (self.movementState === 2 && gameHour >= 2 && gameMinutes >= 0) {
self.moveToRoom(4); // Move to right corridor
self.movementState = 3;
self.lastMoveTime = currentTime;
}
// State 3: In right corridor, wait 5 seconds then restart cycle
else if (self.movementState === 3 && currentTime - self.lastMoveTime >= 5) {
self.moveToRoom(1); // Move back to bathroom
self.movementState = 1;
self.lastMoveTime = currentTime;
}
} else if (nightNumber === 5) {
// Night 5 behavior: moves to bathroom at 12:10 AM, then to party room at 12:20 AM, then to right corridor at 1:30 AM, repeats after 5 seconds
// State 0: On stage, move to bathroom at 12:10 AM
if (self.movementState === 0 && gameHour >= 0 && gameMinutes >= 10) {
self.moveToRoom(1); // Move to bathroom
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In bathroom, move to party room at 12:20 AM
else if (self.movementState === 1 && gameHour >= 0 && gameMinutes >= 20) {
self.moveToRoom(2); // Move to party room
self.movementState = 2;
self.lastMoveTime = currentTime;
}
// State 2: In party room, move to right corridor at 1:30 AM
else if (self.movementState === 2 && gameHour >= 1 && gameMinutes >= 30) {
self.moveToRoom(4); // Move to right corridor
self.movementState = 3;
self.lastMoveTime = currentTime;
}
// State 3: In right corridor, wait 5 seconds then restart cycle
else if (self.movementState === 3 && currentTime - self.lastMoveTime >= 5) {
self.moveToRoom(1); // Move back to bathroom
self.movementState = 1;
self.lastMoveTime = currentTime;
}
} else {
// Original behavior for other nights
if (gameHour < 1 || gameHour === 1 && gameMinutes < 30) return; // Chica doesn't move until 1:30 AM
// State 0: On stage, move to bathroom at 1:30 AM
if (self.movementState === 0 && gameHour >= 1 && gameMinutes >= 30) {
self.moveToRoom(1); // Move to bathroom
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In bathroom, move to party room at 2:00 AM
else if (self.movementState === 1 && gameHour >= 2 && gameMinutes >= 0) {
self.moveToRoom(2); // Move to party room
self.movementState = 2;
self.lastMoveTime = currentTime;
}
// State 2: In party room, move to right corridor at 2:45 AM
else if (self.movementState === 2 && gameHour >= 2 && gameMinutes >= 45) {
self.moveToRoom(4); // Move to right corridor
self.movementState = 3;
self.lastMoveTime = currentTime;
}
}
};
self.updateFoxyMovement = function () {
if (self.isMoving) return; // Don't move if already moving
var currentTime = LK.ticks / 60; // Convert to seconds
// Get current aggression level for timing adjustments
var currentAggression = self.aggressionLevel;
if (nightNumber === 7 && typeof window.characterLevels !== 'undefined' && window.characterLevels.foxy) {
currentAggression = window.characterLevels.foxy;
}
// Calculate time reductions based on aggression level (5 seconds per level)
var timeReduction = (currentAggression - 1) * 5;
var waitTime = Math.max(5, 15 - timeReduction); // Minimum 5 seconds
if (nightNumber === 3) {
// Night 3 behavior: moves to party room at 2 AM, then to left corridor at 2:30 AM, repeats after 15 seconds
// State 0: In basement, move to party room at 2:00 AM
if (self.movementState === 0 && gameHour >= 2 && gameMinutes >= 0) {
self.moveToRoom(2); // Move to party room
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In party room, move to left corridor at 2:30 AM
else if (self.movementState === 1 && gameHour >= 2 && gameMinutes >= 30) {
self.moveToRoom(3); // Move to left corridor
self.movementState = 2;
self.lastMoveTime = currentTime;
}
// State 2: In left corridor, wait 15 seconds then return to party room
else if (self.movementState === 2 && currentTime - self.lastMoveTime >= 15) {
self.moveToRoom(2); // Return to party room
self.movementState = 1;
self.lastMoveTime = currentTime;
}
} else if (nightNumber === 4) {
// Night 4 behavior: moves to party room at 2 AM, then to left corridor at 2:30 AM, repeats after 15 seconds
// State 0: In basement, move to party room at 2:00 AM
if (self.movementState === 0 && gameHour >= 2 && gameMinutes >= 0) {
self.moveToRoom(2); // Move to party room
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In party room, move to left corridor at 2:30 AM
else if (self.movementState === 1 && gameHour >= 2 && gameMinutes >= 30) {
self.moveToRoom(3); // Move to left corridor
self.movementState = 2;
self.lastMoveTime = currentTime;
}
// State 2: In left corridor, wait 15 seconds then return to party room
else if (self.movementState === 2 && currentTime - self.lastMoveTime >= 15) {
self.moveToRoom(2); // Return to party room
self.movementState = 1;
self.lastMoveTime = currentTime;
}
} else if (nightNumber === 5) {
// Night 5 behavior: moves to party room at 1:30 AM, then to left corridor at 2:00 AM, repeats after 10 seconds
// State 0: In basement, move to party room at 1:30 AM
if (self.movementState === 0 && gameHour >= 1 && gameMinutes >= 30) {
self.moveToRoom(2); // Move to party room
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In party room, move to left corridor at 2:00 AM
else if (self.movementState === 1 && gameHour >= 2 && gameMinutes >= 0) {
self.moveToRoom(3); // Move to left corridor
self.movementState = 2;
self.lastMoveTime = currentTime;
}
// State 2: In left corridor, wait 10 seconds then return to party room
else if (self.movementState === 2 && currentTime - self.lastMoveTime >= 10) {
self.moveToRoom(2); // Return to party room
self.movementState = 1;
self.lastMoveTime = currentTime;
}
} else {
// Original behavior for other nights
if (gameHour < 2) return; // Foxy doesn't move until 2 AM
// State 0: In basement, move to party room at 2:30 AM
if (self.movementState === 0 && gameHour >= 2 && gameMinutes >= 30) {
self.moveToRoom(2); // Move to party room
self.movementState = 1;
self.lastMoveTime = currentTime;
}
// State 1: In party room, wait reduced time then move to left corridor
else if (self.movementState === 1 && currentTime - self.lastMoveTime >= waitTime) {
self.moveToRoom(3); // Move to left corridor
self.movementState = 2;
self.lastMoveTime = currentTime;
}
// State 2: In left corridor, wait reduced time then return to party room
else if (self.movementState === 2 && currentTime - self.lastMoveTime >= waitTime) {
self.moveToRoom(2); // Return to party room
self.movementState = 1;
self.lastMoveTime = currentTime;
}
}
};
self.moveToRoom = function (roomId) {
self.isMoving = true;
// Clear corridor timer if moving away from corridor
if (corridorWaitTimers[self.type] && (self.currentRoom === 3 || self.currentRoom === 4) && roomId !== 3 && roomId !== 4) {
delete corridorWaitTimers[self.type];
}
self.currentRoom = roomId;
// Start corridor wait timer if moving to left or right corridor
if ((roomId === 3 || roomId === 4) && !corridorWaitTimers[self.type]) {
corridorWaitTimers[self.type] = {
room: roomId,
startTime: LK.ticks,
triggered: false
};
}
// Play movement sound
LK.getSound('footsteps').play();
// Play special sound when Freddy enters right corridor
if (self.type === 'freddy' && roomId === 4) {
LK.getSound('freddyCorridorSound').play();
}
// Reset after movement
LK.setTimeout(function () {
self.isMoving = false;
}, 1000);
};
self.attemptMove = function () {
// Check if animatronic is allowed to move based on time
var canMove = false;
if (self.type === 'bonnie' && gameHour >= 1) canMove = true;
if (self.type === 'chica' && gameHour >= 2) canMove = true;
if (self.type === 'foxy' && gameHour >= 3) canMove = true;
if (self.type === 'freddy' && gameHour >= 4) canMove = true;
if (!canMove) return;
var pattern = self.movementPattern[self.type];
var currentIndex = pattern.indexOf(self.currentRoom);
if (currentIndex < pattern.length - 1) {
self.isMoving = true;
var nextRoom = pattern[currentIndex + 1];
// Clear corridor timer if moving away from corridor
if (corridorWaitTimers[self.type] && (self.currentRoom === 3 || self.currentRoom === 4) && nextRoom !== 3 && nextRoom !== 4) {
delete corridorWaitTimers[self.type];
}
self.currentRoom = nextRoom;
// Start corridor wait timer if moving to left or right corridor
if ((nextRoom === 3 || nextRoom === 4) && !corridorWaitTimers[self.type]) {
corridorWaitTimers[self.type] = {
room: nextRoom,
startTime: LK.ticks,
triggered: false
};
}
// Play movement sound
LK.getSound('footsteps').play();
// Reset after movement
LK.setTimeout(function () {
self.isMoving = false;
}, 1000);
}
};
self.setAggression = function (level) {
self.aggressionLevel = level;
};
return self;
});
var SecurityCamera = Container.expand(function (roomId, roomName, assetName) {
var self = Container.call(this);
var cameraView = self.attachAsset('cameraView', {
anchorX: 0.5,
anchorY: 0.5
});
var roomDisplay = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
var roomLabel = new Text2(roomName, {
size: 24,
fill: 0xFFFFFF
});
roomLabel.anchor.set(0.5, 0);
roomLabel.y = 120;
self.addChild(roomLabel);
self.roomId = roomId;
self.roomName = roomName;
self.isActive = false;
self.activate = function () {
self.isActive = true;
self.alpha = 1;
powerDrain += 1;
};
self.deactivate = function () {
self.isActive = false;
self.alpha = 0.3;
powerDrain -= 1;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game state variables
// Office view
// Door controls
// Doors
// Animatronics
// UI elements
// Sounds
var gameHour = 0; // 0-5 (12AM to 6AM)
var gameMinutes = 0;
var nightNumber = 1;
var powerLevel = 100;
var powerDrain = 0.2; // Base power drain per second (further reduced for better gameplay)
var gameRunning = false; // Start with false, will be set to true when game starts
var cameraMode = false;
var currentCameraRoom = 0;
var cameras = [];
var cameraButtons = [];
var gameStarted = false; // Track if game has started
var mangoPlushieDisplay = null; // Display object for mango plushie on office table
var animePosterDisplay = null; // Display object for anime poster on office wall
// Door states
var leftDoorClosed = false;
var rightDoorClosed = false;
var leftLightOn = false;
var rightLightOn = false;
// Animatronics
var animatronics = [];
// Corridor wait timers for jumpscares
var corridorWaitTimers = {};
var freddy = new Animatronic('freddy', 1024, 1366);
var bonnie = new Animatronic('bonnie', 1024, 1366);
var chica = new Animatronic('chica', 1024, 1366);
var foxy = new Animatronic('foxy', 1024, 1366);
animatronics.push(freddy, bonnie, chica, foxy);
// Set initial positions
freddy.currentRoom = 0; // Stage
bonnie.currentRoom = 0; // Stage
chica.currentRoom = 0; // Stage
foxy.currentRoom = 5; // Basement
// Set initial aggression based on night
freddy.setAggression(nightNumber);
bonnie.setAggression(nightNumber);
chica.setAggression(nightNumber);
foxy.setAggression(nightNumber);
// Office setup
var office = game.addChild(LK.getAsset('office', {
x: 1024,
y: 1366,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.28,
scaleY: 2.28
}));
var desk = game.addChild(LK.getAsset('desk', {
x: 1024,
y: 2582,
anchorX: 0.5,
anchorY: 1
}));
var monitor = game.addChild(LK.getAsset('monitor', {
x: 1024,
y: 2432,
anchorX: 0.5,
anchorY: 1
}));
var monitorScreen = game.addChild(LK.getAsset('monitorScreen', {
x: 1024,
y: 2432,
anchorX: 0.5,
anchorY: 1
}));
// Create mango plushie on office table (initially hidden)
mangoPlushieDisplay = game.addChild(LK.getAsset('mangoPlushie', {
x: 900,
y: 2400,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
}));
mangoPlushieDisplay.visible = false; // Initially hidden
// Create anime poster on office wall (initially hidden)
animePosterDisplay = game.addChild(LK.getAsset('animePoster', {
x: 1400,
y: 1200,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
}));
animePosterDisplay.visible = false; // Initially hidden
// Door controls
var leftDoorButton = game.addChild(LK.getAsset('leftDoorButton', {
x: 200,
y: 2300,
anchorX: 0.5,
anchorY: 0.5
}));
var rightDoorButton = game.addChild(LK.getAsset('rightDoorButton', {
x: 1848,
y: 2300,
anchorX: 0.5,
anchorY: 0.5
}));
var leftLightButton = game.addChild(LK.getAsset('leftLightButton', {
x: 200,
y: 2150,
anchorX: 0.5,
anchorY: 0.5
}));
var rightLightButton = game.addChild(LK.getAsset('rightLightButton', {
x: 1848,
y: 2150,
anchorX: 0.5,
anchorY: 0.5
}));
// Doors
var leftDoor = game.addChild(LK.getAsset('leftDoor', {
x: 0,
y: 1366,
anchorX: 0,
anchorY: 0.5
}));
var rightDoor = game.addChild(LK.getAsset('rightDoor', {
x: 2048,
y: 1366,
anchorX: 1,
anchorY: 0.5
}));
// Initially hide doors
leftDoor.x = -300;
rightDoor.x = 2348;
// Initially hide all game elements until game starts
office.visible = false;
desk.visible = false;
monitor.visible = false;
monitorScreen.visible = false;
leftDoorButton.visible = false;
rightDoorButton.visible = false;
leftLightButton.visible = false;
rightLightButton.visible = false;
leftDoor.visible = false;
rightDoor.visible = false;
// Hide animatronics
for (var i = 0; i < animatronics.length; i++) {
game.removeChild(animatronics[i]);
}
// UI Elements
var timeText = new Text2('12:00 AM', {
size: 60,
fill: 0xFFFFFF
});
timeText.anchor.set(1, 0);
timeText.visible = false;
LK.gui.topRight.addChild(timeText);
var nightText = new Text2('Night ' + nightNumber, {
size: 50,
fill: 0xFFFFFF
});
nightText.anchor.set(0, 0);
nightText.visible = false;
LK.gui.topLeft.addChild(nightText);
nightText.x = 120; // Avoid platform menu
var powerBarBg = LK.gui.bottomLeft.addChild(LK.getAsset('powerBarBg', {
x: 20,
y: -60,
anchorX: 0,
anchorY: 0
}));
powerBarBg.visible = false;
var powerBar = LK.gui.bottomLeft.addChild(LK.getAsset('powerBar', {
x: 20,
y: -60,
anchorX: 0,
anchorY: 0
}));
powerBar.visible = false;
var powerText = new Text2('Power: 100%', {
size: 30,
fill: 0xFFFFFF
});
powerText.anchor.set(0, 0);
powerText.x = 20;
powerText.y = -100;
powerText.visible = false;
LK.gui.bottomLeft.addChild(powerText);
var cameraText = new Text2('Camera: OFF', {
size: 40,
fill: 0xFFFFFF
});
cameraText.anchor.set(0.5, 0);
cameraText.x = 0;
cameraText.y = 50;
cameraText.visible = false;
LK.gui.center.addChild(cameraText);
// Create camera system
var cameraRooms = [{
id: 0,
name: 'Stage',
asset: 'cameraStage'
}, {
id: 1,
name: 'Bathroom',
asset: 'cameraBathroom'
}, {
id: 2,
name: 'Party Area',
asset: 'cameraPartyArea'
}, {
id: 3,
name: 'Left Corridor',
asset: 'cameraLeftCorridor'
}, {
id: 4,
name: 'Right Corridor',
asset: 'cameraRightCorridor'
}, {
id: 5,
name: 'Basement',
asset: 'cameraBasement'
}, {
id: 6,
name: 'Office',
asset: 'cameraView'
}];
// Create camera displays
for (var i = 0; i < cameraRooms.length; i++) {
var room = cameraRooms[i];
var camera = new SecurityCamera(room.id, room.name, room.asset);
camera.x = 1024;
camera.y = 2302;
camera.visible = false;
cameras.push(camera);
game.addChild(camera);
// Add animatronics to specific cameras
if (room.id === 0) {
// Stage - Add Freddy, Bonnie, Chica to stage
var freddySprite = camera.addChild(LK.getAsset('freddy', {
x: -100,
y: -50,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
}));
var bonnieSprite = camera.addChild(LK.getAsset('bonnie', {
x: -30,
y: -50,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
}));
var chicaSprite = camera.addChild(LK.getAsset('chica', {
x: 40,
y: -50,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6
}));
camera.freddySprite = freddySprite;
camera.bonnieSprite = bonnieSprite;
camera.chicaSprite = chicaSprite;
} else if (room.id === 5) {
// Basement - Add Foxy and Bonnie to basement
var foxySprite = camera.addChild(LK.getAsset('foxy', {
x: -40,
y: -50,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
}));
var bonnieSprite = camera.addChild(LK.getAsset('bonnie', {
x: 40,
y: -50,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6,
visible: false
}));
camera.foxySprite = foxySprite;
camera.bonnieSprite = bonnieSprite;
} else {
// Other rooms - Add placeholder sprites for animatronics that might visit
var freddySprite = camera.addChild(LK.getAsset('freddy', {
x: 0,
y: -50,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6,
visible: false
}));
var bonnieSprite = camera.addChild(LK.getAsset('bonnie', {
x: -40,
y: -50,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6,
visible: false
}));
var chicaSprite = camera.addChild(LK.getAsset('chica', {
x: 40,
y: -50,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.6,
scaleY: 0.6,
visible: false
}));
var foxySprite = camera.addChild(LK.getAsset('foxy', {
x: 0,
y: -30,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.7,
scaleY: 0.7,
visible: false
}));
camera.freddySprite = freddySprite;
camera.bonnieSprite = bonnieSprite;
camera.chicaSprite = chicaSprite;
camera.foxySprite = foxySprite;
}
}
// Create close camera button
var closeCameraButton = LK.gui.topRight.addChild(LK.getAsset('closeCameraButton', {
x: -150,
y: 100,
anchorX: 0.5,
anchorY: 0.5
}));
var closeCameraText = new Text2('CLOSE', {
size: 20,
fill: 0xFFFFFF
});
closeCameraText.anchor.set(0.5, 0.5);
closeCameraText.x = -150;
closeCameraText.y = 100;
LK.gui.topRight.addChild(closeCameraText);
closeCameraButton.visible = false;
closeCameraText.visible = false;
closeCameraButton.down = function (x, y, obj) {
if (cameraMode) {
toggleCamera();
}
};
// Create camera selection buttons with room names
var cameraButtonTexts = [];
// Stage camera button
var stageButton = LK.gui.topLeft.addChild(LK.getAsset('cameraButton', {
x: 150,
y: 50,
anchorX: 0.5,
anchorY: 0.5
}));
var stageButtonText = new Text2('Stage', {
size: 18,
fill: 0xFFFFFF
});
stageButtonText.anchor.set(0.5, 0.5);
stageButtonText.x = 150;
stageButtonText.y = 50;
LK.gui.topLeft.addChild(stageButtonText);
stageButton.roomId = 0;
stageButton.down = function (x, y, obj) {
if (cameraMode && powerLevel > 0) {
switchCamera(0);
}
};
stageButton.visible = false;
stageButtonText.visible = false;
cameraButtons.push(stageButton);
cameraButtonTexts.push(stageButtonText);
// Bathroom camera button
var bathroomButton = LK.gui.topLeft.addChild(LK.getAsset('cameraButton', {
x: 300,
y: 50,
anchorX: 0.5,
anchorY: 0.5
}));
var bathroomButtonText = new Text2('Bath', {
size: 18,
fill: 0xFFFFFF
});
bathroomButtonText.anchor.set(0.5, 0.5);
bathroomButtonText.x = 300;
bathroomButtonText.y = 50;
LK.gui.topLeft.addChild(bathroomButtonText);
bathroomButton.roomId = 1;
bathroomButton.down = function (x, y, obj) {
if (cameraMode && powerLevel > 0) {
switchCamera(1);
}
};
bathroomButton.visible = false;
bathroomButtonText.visible = false;
cameraButtons.push(bathroomButton);
cameraButtonTexts.push(bathroomButtonText);
// Party Area camera button
var partyButton = LK.gui.topLeft.addChild(LK.getAsset('cameraButton', {
x: 450,
y: 50,
anchorX: 0.5,
anchorY: 0.5
}));
var partyButtonText = new Text2('Party', {
size: 18,
fill: 0xFFFFFF
});
partyButtonText.anchor.set(0.5, 0.5);
partyButtonText.x = 450;
partyButtonText.y = 50;
LK.gui.topLeft.addChild(partyButtonText);
partyButton.roomId = 2;
partyButton.down = function (x, y, obj) {
if (cameraMode && powerLevel > 0) {
switchCamera(2);
}
};
partyButton.visible = false;
partyButtonText.visible = false;
cameraButtons.push(partyButton);
cameraButtonTexts.push(partyButtonText);
// Left Corridor camera button
var leftCorridorButton = LK.gui.topLeft.addChild(LK.getAsset('cameraButton', {
x: 150,
y: 130,
anchorX: 0.5,
anchorY: 0.5
}));
var leftCorridorButtonText = new Text2('L-Corr', {
size: 18,
fill: 0xFFFFFF
});
leftCorridorButtonText.anchor.set(0.5, 0.5);
leftCorridorButtonText.x = 150;
leftCorridorButtonText.y = 130;
LK.gui.topLeft.addChild(leftCorridorButtonText);
leftCorridorButton.roomId = 3;
leftCorridorButton.down = function (x, y, obj) {
if (cameraMode && powerLevel > 0) {
switchCamera(3);
}
};
leftCorridorButton.visible = false;
leftCorridorButtonText.visible = false;
cameraButtons.push(leftCorridorButton);
cameraButtonTexts.push(leftCorridorButtonText);
// Right Corridor camera button
var rightCorridorButton = LK.gui.topLeft.addChild(LK.getAsset('cameraButton', {
x: 300,
y: 130,
anchorX: 0.5,
anchorY: 0.5
}));
var rightCorridorButtonText = new Text2('R-Corr', {
size: 18,
fill: 0xFFFFFF
});
rightCorridorButtonText.anchor.set(0.5, 0.5);
rightCorridorButtonText.x = 300;
rightCorridorButtonText.y = 130;
LK.gui.topLeft.addChild(rightCorridorButtonText);
rightCorridorButton.roomId = 4;
rightCorridorButton.down = function (x, y, obj) {
if (cameraMode && powerLevel > 0) {
switchCamera(4);
}
};
rightCorridorButton.visible = false;
rightCorridorButtonText.visible = false;
cameraButtons.push(rightCorridorButton);
cameraButtonTexts.push(rightCorridorButtonText);
// Basement camera button
var basementButton = LK.gui.topLeft.addChild(LK.getAsset('cameraButton', {
x: 450,
y: 130,
anchorX: 0.5,
anchorY: 0.5
}));
var basementButtonText = new Text2('Base', {
size: 18,
fill: 0xFFFFFF
});
basementButtonText.anchor.set(0.5, 0.5);
basementButtonText.x = 450;
basementButtonText.y = 130;
LK.gui.topLeft.addChild(basementButtonText);
basementButton.roomId = 5;
basementButton.down = function (x, y, obj) {
if (cameraMode && powerLevel > 0) {
switchCamera(5);
}
};
basementButton.visible = false;
basementButtonText.visible = false;
cameraButtons.push(basementButton);
cameraButtonTexts.push(basementButtonText);
// Office camera button
var officeButton = LK.gui.topLeft.addChild(LK.getAsset('cameraButton', {
x: 600,
y: 130,
anchorX: 0.5,
anchorY: 0.5
}));
var officeButtonText = new Text2('Office', {
size: 18,
fill: 0xFFFFFF
});
officeButtonText.anchor.set(0.5, 0.5);
officeButtonText.x = 600;
officeButtonText.y = 130;
LK.gui.topLeft.addChild(officeButtonText);
officeButton.roomId = 6;
officeButton.down = function (x, y, obj) {
if (cameraMode && powerLevel > 0) {
switchCamera(6);
}
};
officeButton.visible = false;
officeButtonText.visible = false;
cameraButtons.push(officeButton);
cameraButtonTexts.push(officeButtonText);
// Create game menu
var menuOverlay = game.addChild(LK.getAsset('jumpscareOverlay', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0,
alpha: 0.9
}));
var menuBackground = menuOverlay.addChild(LK.getAsset('menuBackground', {
x: 1024,
y: 1366,
anchorX: 0.5,
anchorY: 0.5
}));
var menuTitle = new Text2('Five Nights at Mango\'s', {
size: 80,
fill: 0xFFFFFF
});
menuTitle.anchor.set(0.5, 0.5);
menuTitle.x = 1024;
menuTitle.y = 800;
menuOverlay.addChild(menuTitle);
var newGameButton = menuOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1300,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var newGameText = new Text2('NEW GAME', {
size: 40,
fill: 0xFFFFFF
});
newGameText.anchor.set(0.5, 0.5);
newGameText.x = 1024;
newGameText.y = 1300;
menuOverlay.addChild(newGameText);
newGameButton.down = function (x, y, obj) {
startGame();
};
// Add admin mode button
// Add continue button above admin mode
var continueButton = menuOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1500,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var continueText = new Text2('CONTINUE', {
size: 40,
fill: 0xFFFFFF
});
continueText.anchor.set(0.5, 0.5);
continueText.x = 1024;
continueText.y = 1500;
menuOverlay.addChild(continueText);
continueButton.down = function (x, y, obj) {
// Continue the current game if already started
if (gameStarted) {
menuOverlay.visible = false;
gameRunning = true;
// Resume office ambiance if not playing
try {
LK.getSound('officeAmbiance').play();
} catch (e) {}
}
};
var adminButton = menuOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1700,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var adminText = new Text2('ADMIN MODE', {
size: 40,
fill: 0xFFFFFF
});
adminText.anchor.set(0.5, 0.5);
adminText.x = 1024;
adminText.y = 1700;
menuOverlay.addChild(adminText);
adminButton.down = function (x, y, obj) {
showPasswordPrompt();
};
var shopButton = menuOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1900,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var shopText = new Text2('SHOP', {
size: 40,
fill: 0xFFFFFF
});
shopText.anchor.set(0.5, 0.5);
shopText.x = 1024;
shopText.y = 1900;
menuOverlay.addChild(shopText);
shopButton.down = function (x, y, obj) {
showShopMenu();
};
// Night 6 removed - now only Custom Night available after Night 5
// Add Custom Night button (initially hidden)
var customNightButton = menuOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var customNightText = new Text2('CUSTOM NIGHT', {
size: 40,
fill: 0xFFFFFF
});
customNightText.anchor.set(0.5, 0.5);
customNightText.x = 1024;
customNightText.y = 1000;
menuOverlay.addChild(customNightText);
customNightButton.visible = false;
customNightText.visible = false;
customNightButton.down = function (x, y, obj) {
// Show Custom Night character selection menu
showCustomNightMenu();
};
// Add Extras button (initially hidden until all 5 nights completed)
var extrasButton = menuOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1100,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var extrasText = new Text2('EXTRAS', {
size: 40,
fill: 0xFFFFFF
});
extrasText.anchor.set(0.5, 0.5);
extrasText.x = 1024;
extrasText.y = 1100;
menuOverlay.addChild(extrasText);
extrasButton.visible = false;
extrasText.visible = false;
extrasButton.down = function (x, y, obj) {
// Show extras menu (placeholder for now)
showExtrasMenu();
};
// Create Custom Night Menu
function showCustomNightMenu() {
// Create custom night overlay
var customNightOverlay = game.addChild(LK.getAsset('jumpscareOverlay', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0,
alpha: 0.9
}));
var customNightTitle = new Text2('CUSTOM NIGHT', {
size: 80,
fill: 0xFFFFFF
});
customNightTitle.anchor.set(0.5, 0.5);
customNightTitle.x = 1024;
customNightTitle.y = 400;
customNightOverlay.addChild(customNightTitle);
// Add character images in order: Freddy, Bonnie, Chica, Foxy
var characterSpacing = 300;
var startX = 1024 - 3 * characterSpacing / 2;
// Freddy
var freddyImage = customNightOverlay.addChild(LK.getAsset('freddy', {
x: startX,
y: 1200,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
}));
var freddyLabel = new Text2('SIGMA BART', {
size: 40,
fill: 0xFFFFFF
});
freddyLabel.anchor.set(0.5, 0.5);
freddyLabel.x = startX;
freddyLabel.y = 1400;
customNightOverlay.addChild(freddyLabel);
// Bonnie
var bonnieImage = customNightOverlay.addChild(LK.getAsset('bonnie', {
x: startX + characterSpacing,
y: 1200,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
}));
var bonnieLabel = new Text2('george floyd', {
size: 40,
fill: 0xFFFFFF
});
bonnieLabel.anchor.set(0.5, 0.5);
bonnieLabel.x = startX + characterSpacing;
bonnieLabel.y = 1400;
customNightOverlay.addChild(bonnieLabel);
// Chica
var chicaImage = customNightOverlay.addChild(LK.getAsset('chica', {
x: startX + characterSpacing * 2,
y: 1200,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
}));
var chicaLabel = new Text2('Noyan', {
size: 40,
fill: 0xFFFFFF
});
chicaLabel.anchor.set(0.5, 0.5);
chicaLabel.x = startX + characterSpacing * 2;
chicaLabel.y = 1400;
customNightOverlay.addChild(chicaLabel);
// Foxy
var foxyImage = customNightOverlay.addChild(LK.getAsset('foxy', {
x: startX + characterSpacing * 3,
y: 1200,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
}));
var foxyLabel = new Text2('Sigma Mango Mustard', {
size: 40,
fill: 0xFFFFFF
});
foxyLabel.anchor.set(0.5, 0.5);
foxyLabel.x = startX + characterSpacing * 3;
foxyLabel.y = 1400;
customNightOverlay.addChild(foxyLabel);
// Character difficulty levels (start at 1)
var characterLevels = {
freddy: 1,
bonnie: 1,
chica: 1,
foxy: 1
};
// Add level controls for each character
var characterPositions = [{
name: 'freddy',
x: startX
}, {
name: 'bonnie',
x: startX + characterSpacing
}, {
name: 'chica',
x: startX + characterSpacing * 2
}, {
name: 'foxy',
x: startX + characterSpacing * 3
}];
for (var c = 0; c < characterPositions.length; c++) {
var charData = characterPositions[c];
// Level display
var levelText = new Text2('1', {
size: 60,
fill: 0xFFFFFF
});
levelText.anchor.set(0.5, 0.5);
levelText.x = charData.x;
levelText.y = 1500;
customNightOverlay.addChild(levelText);
// Up arrow
var upArrow = customNightOverlay.addChild(LK.getAsset('cameraButton', {
x: charData.x,
y: 1580,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.6
}));
var upArrowText = new Text2('▲', {
size: 30,
fill: 0x00FF00
});
upArrowText.anchor.set(0.5, 0.5);
upArrowText.x = charData.x;
upArrowText.y = 1580;
customNightOverlay.addChild(upArrowText);
// Down arrow
var downArrow = customNightOverlay.addChild(LK.getAsset('cameraButton', {
x: charData.x,
y: 1650,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.6
}));
var downArrowText = new Text2('▼', {
size: 30,
fill: 0xFF0000
});
downArrowText.anchor.set(0.5, 0.5);
downArrowText.x = charData.x;
downArrowText.y = 1650;
customNightOverlay.addChild(downArrowText);
// Store references for the button handlers
upArrow.characterName = charData.name;
upArrow.levelText = levelText;
downArrow.characterName = charData.name;
downArrow.levelText = levelText;
// Up arrow click handler
upArrow.down = function (x, y, obj) {
var charName = this.characterName;
if (characterLevels[charName] < 20) {
characterLevels[charName]++;
this.levelText.setText(characterLevels[charName].toString());
}
};
// Down arrow click handler
downArrow.down = function (x, y, obj) {
var charName = this.characterName;
if (characterLevels[charName] > 1) {
characterLevels[charName]--;
this.levelText.setText(characterLevels[charName].toString());
}
};
}
// Add back button
var backToMenuButton = customNightOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 2000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var backToMenuText = new Text2('BACK TO MENU', {
size: 40,
fill: 0xFFFFFF
});
backToMenuText.anchor.set(0.5, 0.5);
backToMenuText.x = 1024;
backToMenuText.y = 2000;
customNightOverlay.addChild(backToMenuText);
backToMenuButton.down = function (x, y, obj) {
game.removeChild(customNightOverlay);
};
// Add start custom night button
var startCustomButton = customNightOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1800,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var startCustomText = new Text2('START CUSTOM NIGHT', {
size: 40,
fill: 0x00FF00
});
startCustomText.anchor.set(0.5, 0.5);
startCustomText.x = 1024;
startCustomText.y = 1800;
customNightOverlay.addChild(startCustomText);
startCustomButton.down = function (x, y, obj) {
// Store character levels globally for use in game
window.characterLevels = characterLevels;
// Start Custom Night
nightNumber = 7;
game.removeChild(customNightOverlay);
customNightButton.visible = false;
customNightText.visible = false;
startGame();
};
}
// Create skip night button for main game (initially hidden)
var skipNightGameButton = LK.gui.topRight.addChild(LK.getAsset('closeCameraButton', {
x: -20,
y: 200,
anchorX: 1,
anchorY: 0,
scaleX: 1.5,
scaleY: 1
}));
var skipNightGameText = new Text2('SKIP NIGHT', {
size: 25,
fill: 0xFFFF00
});
skipNightGameText.anchor.set(1, 0.5);
skipNightGameText.x = -20;
skipNightGameText.y = 200;
LK.gui.topRight.addChild(skipNightGameText);
skipNightGameButton.visible = false;
skipNightGameText.visible = false;
skipNightGameButton.down = function (x, y, obj) {
if (window.skipNightEnabled && gameStarted && gameRunning) {
// Skip current night
nightCompleted();
}
};
// Check if all 5 nights completed and show Extras button if so
if (storage.allNightsCompleted) {
extrasButton.visible = true;
extrasText.visible = true;
}
// Play scary menu music when game loads
LK.playMusic('menuMusic');
// Event handlers
leftDoorButton.down = function (x, y, obj) {
toggleLeftDoor();
};
rightDoorButton.down = function (x, y, obj) {
toggleRightDoor();
};
leftLightButton.down = function (x, y, obj) {
toggleLeftLight();
};
rightLightButton.down = function (x, y, obj) {
toggleRightLight();
};
monitor.down = function (x, y, obj) {
toggleCamera();
};
// Game functions
function toggleLeftDoor() {
if (powerLevel <= 0) return;
leftDoorClosed = !leftDoorClosed;
LK.getSound('doorSlam').play();
if (leftDoorClosed) {
tween(leftDoor, {
x: 0
}, {
duration: 500
});
leftDoorButton.tint = 0x00ff00;
} else {
tween(leftDoor, {
x: -300
}, {
duration: 500
});
leftDoorButton.tint = 0xffffff;
}
}
function toggleRightDoor() {
if (powerLevel <= 0) return;
rightDoorClosed = !rightDoorClosed;
LK.getSound('doorSlam').play();
if (rightDoorClosed) {
tween(rightDoor, {
x: 1748
}, {
duration: 500
});
rightDoorButton.tint = 0x00ff00;
} else {
tween(rightDoor, {
x: 2348
}, {
duration: 500
});
rightDoorButton.tint = 0xffffff;
}
}
function toggleLeftLight() {
if (powerLevel <= 0) return;
leftLightOn = !leftLightOn;
if (leftLightOn) {
leftLightButton.tint = 0xffff00;
checkHallway('left');
} else {
leftLightButton.tint = 0xffffff;
}
}
function toggleRightLight() {
if (powerLevel <= 0) return;
rightLightOn = !rightLightOn;
if (rightLightOn) {
rightLightButton.tint = 0xffff00;
checkHallway('right');
} else {
rightLightButton.tint = 0xffffff;
}
}
function toggleCamera() {
if (powerLevel <= 0) return;
cameraMode = !cameraMode;
if (cameraMode) {
LK.getSound('cameraToggle').play();
// Play camera switch sound
LK.getSound('cameraSwitch').play();
cameraText.setText('Camera: ON - ' + cameraRooms[currentCameraRoom].name);
monitorScreen.tint = 0x0000ff;
cameras[currentCameraRoom].visible = true;
cameras[currentCameraRoom].activate();
// Scale up camera to full screen
cameras[currentCameraRoom].scaleX = 5.7;
cameras[currentCameraRoom].scaleY = 10.5;
cameras[currentCameraRoom].x = 1024;
cameras[currentCameraRoom].y = 1366;
// Update animatronic visibility in cameras
updateAnimatronicVisibility();
// Hide office elements
office.visible = false;
desk.visible = false;
monitor.visible = false;
leftDoorButton.visible = false;
rightDoorButton.visible = false;
leftLightButton.visible = false;
rightLightButton.visible = false;
leftDoor.visible = false;
rightDoor.visible = false;
// Play camera ambiance sound
try {
LK.getSound('cameraAmbiance').play();
} catch (e) {}
// Show camera buttons and close button
for (var i = 0; i < cameraButtons.length; i++) {
cameraButtons[i].visible = true;
cameraButtonTexts[i].visible = true;
}
closeCameraButton.visible = true;
closeCameraText.visible = true;
} else {
cameraText.setText('Camera: OFF');
monitorScreen.tint = 0xffffff;
for (var i = 0; i < cameras.length; i++) {
cameras[i].visible = false;
cameras[i].scaleX = 1;
cameras[i].scaleY = 1;
cameras[i].x = 1024;
cameras[i].y = 2302;
if (cameras[i].isActive) {
cameras[i].deactivate();
}
}
// Show office elements
office.visible = true;
desk.visible = true;
monitor.visible = true;
leftDoorButton.visible = true;
rightDoorButton.visible = true;
leftLightButton.visible = true;
rightLightButton.visible = true;
leftDoor.visible = true;
rightDoor.visible = true;
// Hide camera buttons and close button
for (var i = 0; i < cameraButtons.length; i++) {
cameraButtons[i].visible = false;
cameraButtonTexts[i].visible = false;
}
closeCameraButton.visible = false;
closeCameraText.visible = false;
}
LK.getSound('cameraToggle').play();
// Play camera switch sound
LK.getSound('cameraSwitch').play();
// Stop camera ambiance sound
try {
LK.getSound('cameraAmbiance').stop();
} catch (e) {}
}
function switchCamera(roomId) {
if (!cameraMode || powerLevel <= 0) return;
// Play camera switch sound
LK.getSound('cameraSwitch').play();
// Deactivate current camera
if (cameras[currentCameraRoom].isActive) {
cameras[currentCameraRoom].deactivate();
cameras[currentCameraRoom].visible = false;
cameras[currentCameraRoom].scaleX = 1;
cameras[currentCameraRoom].scaleY = 1;
}
// Activate new camera
currentCameraRoom = roomId;
cameras[currentCameraRoom].visible = true;
cameras[currentCameraRoom].activate();
// Scale up new camera to full screen
cameras[currentCameraRoom].scaleX = 5.7;
cameras[currentCameraRoom].scaleY = 10.5;
cameras[currentCameraRoom].x = 1024;
cameras[currentCameraRoom].y = 1366;
cameraText.setText('Camera: ON - ' + cameraRooms[currentCameraRoom].name);
// Update animatronic visibility
updateAnimatronicVisibility();
// Update button appearances
for (var i = 0; i < cameraButtons.length; i++) {
if (i === roomId) {
cameraButtons[i].tint = 0x00ff00;
} else {
cameraButtons[i].tint = 0xffffff;
}
}
}
function updateAnimatronicVisibility() {
// Hide all animatronics first
for (var i = 0; i < cameras.length; i++) {
var camera = cameras[i];
if (camera.freddySprite) camera.freddySprite.visible = false;
if (camera.bonnieSprite) camera.bonnieSprite.visible = false;
if (camera.chicaSprite) camera.chicaSprite.visible = false;
if (camera.foxySprite) camera.foxySprite.visible = false;
}
// Show animatronics in their current rooms
for (var i = 0; i < animatronics.length; i++) {
var animatronic = animatronics[i];
var room = animatronic.currentRoom;
if (room < cameras.length) {
var camera = cameras[room];
if (animatronic.type === 'freddy' && camera.freddySprite) {
camera.freddySprite.visible = true;
} else if (animatronic.type === 'bonnie' && camera.bonnieSprite) {
camera.bonnieSprite.visible = true;
} else if (animatronic.type === 'chica' && camera.chicaSprite) {
camera.chicaSprite.visible = true;
} else if (animatronic.type === 'foxy' && camera.foxySprite) {
camera.foxySprite.visible = true;
}
}
}
}
function checkHallway(side) {
// Check if animatronics are in the hallway
var animatronicPresent = false;
for (var i = 0; i < animatronics.length; i++) {
var animatronic = animatronics[i];
if (side === 'left' && (animatronic.type === 'bonnie' || animatronic.type === 'foxy') && animatronic.currentRoom === 6 || side === 'right' && animatronic.type === 'chica' && animatronic.currentRoom === 6) {
animatronicPresent = true;
break;
}
}
if (animatronicPresent) {
LK.effects.flashScreen(0xff0000, 200);
}
}
function checkForJumpscares() {
for (var i = 0; i < animatronics.length; i++) {
var animatronic = animatronics[i];
// Check if animatronic reached office
if (animatronic.currentRoom === 6) {
// Bonnie/Foxy check left door
if ((animatronic.type === 'bonnie' || animatronic.type === 'foxy') && !leftDoorClosed) {
jumpscare(animatronic.type);
return;
}
// Chica checks right door
if (animatronic.type === 'chica' && !rightDoorClosed) {
jumpscare(animatronic.type);
return;
}
// Freddy can attack from either side
if (animatronic.type === 'freddy' && (!leftDoorClosed || !rightDoorClosed)) {
jumpscare(animatronic.type);
return;
}
}
}
}
function jumpscare(animatronicType, isExtrasMode) {
if (!isExtrasMode) {
gameRunning = false;
}
LK.getSound('scream').play();
if (!isExtrasMode) {
try {
LK.getSound('officeAmbiance').stop();
} catch (e) {}
// Stop camera ambiance sound
try {
LK.getSound('cameraAmbiance').stop();
} catch (e) {}
}
// Create full-screen overlay (transparent to show animatronic face)
var jumpscareOverlay = game.addChild(LK.getAsset('jumpscareOverlay', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0,
alpha: 0.3
}));
// Add animatronic sprite to overlay (make face prominent)
var jumpscareSprite = jumpscareOverlay.addChild(LK.getAsset(animatronicType, {
x: 1024,
y: 1200,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 10,
scaleY: 10
}));
// Add glow effect to make face stand out
jumpscareSprite.tint = 0xffffff;
// Animate the jumpscare
tween(jumpscareSprite, {
scaleX: 15,
scaleY: 15
}, {
duration: 500,
easing: tween.easeOut
});
// Pulse the animatronic to make it more visible
tween(jumpscareSprite, {
alpha: 0.8
}, {
duration: 100,
repeat: 5,
yoyo: true
});
// Flash effect
LK.effects.flashScreen(0xff0000, 1000);
LK.setTimeout(function () {
if (isExtrasMode) {
// In extras mode, remove the jumpscare overlay and return to extras menu
game.removeChild(jumpscareOverlay);
showExtrasMenu();
} else {
// In normal game mode, show game over
LK.showGameOver();
}
}, 1000);
}
function updateTime() {
gameMinutes += 1;
if (gameMinutes >= 60) {
gameMinutes = 0;
gameHour += 1;
if (gameHour >= 6) {
// Night completed
nightCompleted();
return;
}
}
var displayHour = gameHour === 0 ? 12 : gameHour;
var displayMinutes = gameMinutes.toString().padStart(2, '0');
var ampm = gameHour < 6 ? 'AM' : 'AM';
timeText.setText(displayHour + ':' + displayMinutes + ' ' + ampm);
}
function nightCompleted() {
gameRunning = false;
// Award player 50$ for completing the night
var currentMoney = storage.money || 0;
storage.money = currentMoney + 50;
try {
LK.getSound('officeAmbiance').stop();
} catch (e) {}
// Stop camera ambiance sound
try {
LK.getSound('cameraAmbiance').stop();
} catch (e) {}
// Show 6 AM completion sequence
var displayHour = 6;
var displayMinutes = '00';
var ampm = 'AM';
timeText.setText(displayHour + ':' + displayMinutes + ' ' + ampm);
// Create black screen overlay
var completionOverlay = game.addChild(LK.getAsset('jumpscareOverlay', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0,
alpha: 1.0
}));
// Add 6 AM text display centered on black screen
var sixAmText = new Text2('6:00 AM', {
size: 120,
fill: 0x00ff00
});
sixAmText.anchor.set(0.5, 0.5);
sixAmText.x = 1024;
sixAmText.y = 1366;
completionOverlay.addChild(sixAmText);
// Play completion sound
try {
LK.getSound('completion').play();
} catch (e) {}
// Show 6:00 AM for 10 seconds then transition to next night
LK.setTimeout(function () {
// Remove completion overlay
game.removeChild(completionOverlay);
if (nightNumber === 7) {
// Custom night completed after just one night - show special cutscene and play sound
showCustomNightCutscene();
return; // Exit early to prevent progression to next night
} else if (nightNumber >= 5) {
// Night 5 completed - mark all nights as completed and show special cutscene
storage.allNightsCompleted = true;
showNight5Cutscene();
} else {
// Move to next night
nightNumber++;
// Reset night text - display Night 6 for custom night
if (nightNumber === 7) {
nightText.setText('Night 6');
} else {
nightText.setText('Night ' + nightNumber);
}
// Start the next night directly without going to menu
resetNight();
}
}, 10000);
}
function resetNight() {
gameHour = 0;
gameMinutes = 0;
powerLevel = 100;
if (isAdminMode) {
powerLevel = 100; // Ensure power stays at 100% in admin mode
}
gameRunning = true;
powerDrainTimer = 0;
nextPowerDrainTick = 20 * 60; // Reset to 20 seconds (nothing activated)
currentCameraRoom = 0;
// Reset corridor wait timers
corridorWaitTimers = {};
// Reset animatronics
for (var i = 0; i < animatronics.length; i++) {
if (animatronics[i].type === 'foxy') {
animatronics[i].currentRoom = 5; // Foxy starts in basement
} else {
animatronics[i].currentRoom = 0; // Others start on stage
}
// Reset Bonnie's movement state
if (animatronics[i].type === 'bonnie') {
animatronics[i].movementState = 0;
animatronics[i].lastMoveTime = 0;
animatronics[i].waitingInBasement = false;
animatronics[i].waitingInParty = false;
}
// Reset Chica's movement state
if (animatronics[i].type === 'chica') {
animatronics[i].movementState = 0;
animatronics[i].lastMoveTime = 0;
}
// Set aggression based on night type
if (nightNumber === 7 && typeof window.characterLevels !== 'undefined') {
// Custom night - use character levels set by player (single night only)
if (animatronics[i].type === 'freddy' && window.characterLevels.freddy) {
animatronics[i].setAggression(window.characterLevels.freddy);
} else if (animatronics[i].type === 'bonnie' && window.characterLevels.bonnie) {
animatronics[i].setAggression(window.characterLevels.bonnie);
} else if (animatronics[i].type === 'chica' && window.characterLevels.chica) {
animatronics[i].setAggression(window.characterLevels.chica);
} else if (animatronics[i].type === 'foxy' && window.characterLevels.foxy) {
animatronics[i].setAggression(window.characterLevels.foxy);
} else {
animatronics[i].setAggression(1);
}
} else {
// Regular night - use night number
animatronics[i].setAggression(nightNumber);
}
}
// Reset doors and lights
leftDoorClosed = false;
rightDoorClosed = false;
leftLightOn = false;
rightLightOn = false;
cameraMode = false;
// Reset camera views
for (var i = 0; i < cameras.length; i++) {
cameras[i].visible = false;
cameras[i].scaleX = 1;
cameras[i].scaleY = 1;
cameras[i].x = 1024;
cameras[i].y = 2302;
if (cameras[i].isActive) {
cameras[i].deactivate();
}
}
// Show office elements
if (gameStarted) {
office.visible = true;
desk.visible = true;
monitor.visible = true;
monitorScreen.visible = true;
leftDoorButton.visible = true;
rightDoorButton.visible = true;
leftLightButton.visible = true;
rightLightButton.visible = true;
leftDoor.visible = true;
rightDoor.visible = true;
// Show UI elements
timeText.visible = true;
nightText.visible = true;
powerBarBg.visible = true;
powerBar.visible = true;
powerText.visible = true;
cameraText.visible = true;
// Show mango plushie if purchased
if (storage.mangoPlushie) {
mangoPlushieDisplay.visible = true;
} else {
mangoPlushieDisplay.visible = false;
}
// Show anime poster if purchased
if (storage.animePoster) {
animePosterDisplay.visible = true;
} else {
animePosterDisplay.visible = false;
}
}
// Hide camera buttons
for (var i = 0; i < cameraButtons.length; i++) {
cameraButtons[i].visible = false;
cameraButtons[i].tint = 0xffffff;
cameraButtonTexts[i].visible = false;
}
// Reset UI - display Night 6 for custom night
if (nightNumber === 7) {
nightText.setText('Night 6');
} else {
nightText.setText('Night ' + nightNumber);
}
leftDoorButton.tint = 0xffffff;
rightDoorButton.tint = 0xffffff;
leftLightButton.tint = 0xffffff;
rightLightButton.tint = 0xffffff;
monitorScreen.tint = 0xffffff;
cameraText.setText('Camera: OFF');
// Reset door positions
leftDoor.x = -300;
rightDoor.x = 2348;
}
// Game timers
var timeTimer = LK.setInterval(function () {
if (gameRunning) {
updateTime();
}
}, 1000); // 1 second = 1 minute in game
// Power drain timing system
var powerDrainTimer = 0;
var nextPowerDrainTick = 20 * 60; // Start with 20 seconds (nothing activated - slower)
var powerTimer = LK.setInterval(function () {
if (gameRunning && powerLevel > 0) {
powerDrainTimer++;
// Check if it's time to drain power
if (powerDrainTimer >= nextPowerDrainTick) {
if (!isAdminMode) {
powerLevel -= 1; // Drain 1% power
} else {
powerLevel = 100; // Keep power at 100% in admin mode
}
powerDrainTimer = 0; // Reset timer
if (powerLevel < 0) powerLevel = 0;
}
// Calculate next drain interval based on current state
var camerasOpen = cameraMode;
var doorsClosedCount = (leftDoorClosed ? 1 : 0) + (rightDoorClosed ? 1 : 0);
var lightsOnCount = (leftLightOn ? 1 : 0) + (rightLightOn ? 1 : 0);
var totalActivatedSystems = (camerasOpen ? 1 : 0) + doorsClosedCount + lightsOnCount;
if (totalActivatedSystems === 0) {
// Nothing activated: slowest drain (10 seconds)
nextPowerDrainTick = 10 * 60;
} else if (totalActivatedSystems === 1) {
// One system activated: slower drain (1 second)
nextPowerDrainTick = 1 * 60;
} else if (totalActivatedSystems === 2) {
// Two systems activated: medium drain (0.75 seconds)
nextPowerDrainTick = 0.75 * 60;
} else if (totalActivatedSystems === 3) {
// Three systems activated: faster drain (0.5 seconds)
nextPowerDrainTick = 0.5 * 60;
} else if (totalActivatedSystems === 4) {
// Four systems activated: fast drain (0.25 seconds)
nextPowerDrainTick = 0.25 * 60;
} else {
// All systems activated: fastest drain (0.1 seconds)
nextPowerDrainTick = 0.1 * 60;
}
// Update power bar
var powerPercent = powerLevel / 100;
powerBar.width = 300 * powerPercent;
powerText.setText('Power: ' + Math.ceil(powerLevel) + '%');
if (powerLevel <= 0) {
powerOut();
}
}
}, 100);
function showPasswordPrompt() {
// Create password input overlay
var passwordOverlay = game.addChild(LK.getAsset('jumpscareOverlay', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0,
alpha: 0.8
}));
var passwordPrompt = new Text2('Enter Admin Password:', {
size: 60,
fill: 0xFFFFFF
});
passwordPrompt.anchor.set(0.5, 0.5);
passwordPrompt.x = 1024;
passwordPrompt.y = 1200;
passwordOverlay.addChild(passwordPrompt);
var passwordInput = '';
var passwordDisplay = new Text2('', {
size: 50,
fill: 0x00FF00
});
passwordDisplay.anchor.set(0.5, 0.5);
passwordDisplay.x = 1024;
passwordDisplay.y = 1300;
passwordOverlay.addChild(passwordDisplay);
var messageText = new Text2('', {
size: 40,
fill: 0xFF0000
});
messageText.anchor.set(0.5, 0.5);
messageText.x = 1024;
messageText.y = 1400;
passwordOverlay.addChild(messageText);
// Create virtual keyboard buttons
var keyboard = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
var keyButtons = [];
var keyTexts = [];
for (var i = 0; i < keyboard.length; i++) {
var _char = keyboard[i];
var row = Math.floor(i / 8);
var col = i % 8;
var keyButton = passwordOverlay.addChild(LK.getAsset('cameraButton', {
x: 500 + col * 130,
y: 1500 + row * 90,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
}));
var keyText = new Text2(_char, {
size: 24,
fill: 0xFFFFFF
});
keyText.anchor.set(0.5, 0.5);
keyText.x = 500 + col * 130;
keyText.y = 1500 + row * 90;
passwordOverlay.addChild(keyText);
keyButton["char"] = _char;
keyButton.down = function (x, y, obj) {
if (passwordInput.length < 20) {
passwordInput += this["char"];
passwordDisplay.setText(passwordInput);
}
};
keyButtons.push(keyButton);
keyTexts.push(keyText);
}
// Add Enter button
var enterButton = passwordOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 800,
y: 2000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1
}));
var enterText = new Text2('ENTER', {
size: 30,
fill: 0xFFFFFF
});
enterText.anchor.set(0.5, 0.5);
enterText.x = 800;
enterText.y = 2000;
passwordOverlay.addChild(enterText);
enterButton.down = function (x, y, obj) {
if (passwordInput === 'AR300710ON') {
// Correct password - activate admin mode
messageText.setText('Admin Mode Activated!');
messageText.tint = 0x00FF00;
LK.setTimeout(function () {
game.removeChild(passwordOverlay);
activateAdminMode();
}, 1000);
} else {
// Wrong password
messageText.setText('Wrong password!');
messageText.tint = 0xFF0000;
passwordInput = '';
passwordDisplay.setText('');
}
};
// Add Clear button
var clearButton = passwordOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1200,
y: 2000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1
}));
var clearText = new Text2('CLEAR', {
size: 30,
fill: 0xFFFFFF
});
clearText.anchor.set(0.5, 0.5);
clearText.x = 1200;
clearText.y = 2000;
passwordOverlay.addChild(clearText);
clearButton.down = function (x, y, obj) {
passwordInput = '';
passwordDisplay.setText('');
messageText.setText('');
};
// Add Back button
var backButton = passwordOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1000,
y: 2100,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1
}));
var backText = new Text2('BACK', {
size: 30,
fill: 0xFFFFFF
});
backText.anchor.set(0.5, 0.5);
backText.x = 1000;
backText.y = 2100;
passwordOverlay.addChild(backText);
backButton.down = function (x, y, obj) {
game.removeChild(passwordOverlay);
};
}
var isAdminMode = false;
function activateAdminMode() {
isAdminMode = true;
// Set unlimited power
powerLevel = 100;
// Create admin mode interface
var adminOverlay = game.addChild(LK.getAsset('jumpscareOverlay', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0,
alpha: 0.9
}));
var adminTitle = new Text2('ADMIN MODE', {
size: 80,
fill: 0x00FF00
});
adminTitle.anchor.set(0.5, 0.5);
adminTitle.x = 1024;
adminTitle.y = 500;
adminOverlay.addChild(adminTitle);
var adminInfo = new Text2('UNLIMITED POWER ACTIVATED\nAdmin controls activated\nAll debug features unlocked', {
size: 40,
fill: 0xFFFFFF
});
adminInfo.anchor.set(0.5, 0.5);
adminInfo.x = 1024;
adminInfo.y = 800;
adminOverlay.addChild(adminInfo);
// Add unlimited power button
var unlimitedPowerButton = adminOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1200,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var unlimitedPowerText = new Text2('UNLIMITED POWER: ' + (isAdminMode ? 'ON' : 'OFF'), {
size: 35,
fill: isAdminMode ? 0x00FF00 : 0xFF0000
});
unlimitedPowerText.anchor.set(0.5, 0.5);
unlimitedPowerText.x = 1024;
unlimitedPowerText.y = 1200;
adminOverlay.addChild(unlimitedPowerText);
unlimitedPowerButton.down = function (x, y, obj) {
isAdminMode = !isAdminMode;
if (isAdminMode) {
powerLevel = 100;
unlimitedPowerText.setText('UNLIMITED POWER: ON');
unlimitedPowerText.tint = 0x00FF00;
} else {
unlimitedPowerText.setText('UNLIMITED POWER: OFF');
unlimitedPowerText.tint = 0xFF0000;
}
};
// Add unlock all nights button
var unlockAllButton = adminOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1300,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var unlockAllText = new Text2('UNLOCK ALL NIGHTS', {
size: 35,
fill: 0x00FFFF
});
unlockAllText.anchor.set(0.5, 0.5);
unlockAllText.x = 1024;
unlockAllText.y = 1300;
adminOverlay.addChild(unlockAllText);
unlockAllButton.down = function (x, y, obj) {
// Show Custom Night button in menu
customNightButton.visible = true;
customNightText.visible = true;
// Store unlock progress
storage.customNightUnlocked = true;
// Visual feedback
unlockAllText.setText('CUSTOM NIGHT UNLOCKED!');
unlockAllText.tint = 0x00FF00;
LK.setTimeout(function () {
unlockAllText.setText('UNLOCK ALL NIGHTS');
unlockAllText.tint = 0x00FFFF;
}, 2000);
};
// Add unlimited money button
var unlimitedMoneyButton = adminOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1400,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var unlimitedMoneyText = new Text2('UNLIMITED MONEY', {
size: 35,
fill: 0x00FF00
});
unlimitedMoneyText.anchor.set(0.5, 0.5);
unlimitedMoneyText.x = 1024;
unlimitedMoneyText.y = 1400;
adminOverlay.addChild(unlimitedMoneyText);
unlimitedMoneyButton.down = function (x, y, obj) {
// Set unlimited money
storage.money = 999999;
unlimitedMoneyText.setText('MONEY SET TO $999,999!');
unlimitedMoneyText.tint = 0x00FF00;
LK.setTimeout(function () {
unlimitedMoneyText.setText('UNLIMITED MONEY');
unlimitedMoneyText.tint = 0x00FF00;
}, 2000);
};
// Add unlock extras button
var unlockExtrasButton = adminOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1500,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var unlockExtrasText = new Text2('UNLOCK EXTRAS', {
size: 35,
fill: 0xFF00FF
});
unlockExtrasText.anchor.set(0.5, 0.5);
unlockExtrasText.x = 1024;
unlockExtrasText.y = 1500;
adminOverlay.addChild(unlockExtrasText);
unlockExtrasButton.down = function (x, y, obj) {
// Show Extras button in menu
extrasButton.visible = true;
extrasText.visible = true;
// Store unlock progress
storage.allNightsCompleted = true;
// Visual feedback
unlockExtrasText.setText('EXTRAS UNLOCKED!');
unlockExtrasText.tint = 0x00FF00;
LK.setTimeout(function () {
unlockExtrasText.setText('UNLOCK EXTRAS');
unlockExtrasText.tint = 0xFF00FF;
}, 2000);
};
// Add skip night button
var skipNightButton = adminOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1600,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var skipNightText = new Text2('ENABLE SKIP NIGHT', {
size: 35,
fill: 0xFFFF00
});
skipNightText.anchor.set(0.5, 0.5);
skipNightText.x = 1024;
skipNightText.y = 1600;
adminOverlay.addChild(skipNightText);
skipNightButton.down = function (x, y, obj) {
// Enable skip night feature in main game
window.skipNightEnabled = true;
skipNightText.setText('SKIP NIGHT ENABLED!');
skipNightText.tint = 0x00FF00;
LK.setTimeout(function () {
skipNightText.setText('ENABLE SKIP NIGHT');
skipNightText.tint = 0xFFFF00;
}, 2000);
};
// Add close admin button
var closeAdminButton = adminOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1700,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var closeAdminText = new Text2('CLOSE ADMIN', {
size: 40,
fill: 0xFFFFFF
});
closeAdminText.anchor.set(0.5, 0.5);
closeAdminText.x = 1024;
closeAdminText.y = 1700;
adminOverlay.addChild(closeAdminText);
closeAdminButton.down = function (x, y, obj) {
game.removeChild(adminOverlay);
};
}
function startGame() {
gameStarted = true;
gameRunning = true;
menuOverlay.visible = false;
// Stop menu music when starting game
LK.stopMusic();
// Play office ambiance sound
try {
LK.getSound('officeAmbiance').play();
} catch (e) {}
// Show all UI elements
timeText.visible = true;
nightText.visible = true;
powerBarBg.visible = true;
powerBar.visible = true;
powerText.visible = true;
cameraText.visible = true;
monitorScreen.visible = true;
// Show mango plushie if purchased
if (storage.mangoPlushie) {
mangoPlushieDisplay.visible = true;
}
// Show anime poster if purchased
if (storage.animePoster) {
animePosterDisplay.visible = true;
}
// Add animatronics back to game
for (var i = 0; i < animatronics.length; i++) {
game.addChild(animatronics[i]);
}
// Initialize night 1
nightNumber = 1;
resetNight();
// Show night text - display Night 6 for custom night
if (nightNumber === 7) {
nightText.setText('Night 6');
} else {
nightText.setText('Night ' + nightNumber);
}
}
function powerOut() {
try {
LK.getSound('powerDown').play();
} catch (e) {}
// Stop camera ambiance sound
try {
LK.getSound('cameraAmbiance').stop();
} catch (e) {}
// Turn off all systems
leftDoorClosed = false;
rightDoorClosed = false;
leftLightOn = false;
rightLightOn = false;
cameraMode = false;
// Reset visual states
leftDoorButton.tint = 0x333333;
rightDoorButton.tint = 0x333333;
leftLightButton.tint = 0x333333;
rightLightButton.tint = 0x333333;
monitorScreen.tint = 0x333333;
// Hide doors
tween(leftDoor, {
x: -300
}, {
duration: 1000
});
tween(rightDoor, {
x: 2348
}, {
duration: 1000
});
// Freddy will attack after power runs out
LK.setTimeout(function () {
if (gameRunning) {
jumpscare('freddy');
}
}, 3000);
}
game.update = function () {
// Show/hide skip night button based on admin mode and game state
if (window.skipNightEnabled && gameStarted && gameRunning) {
skipNightGameButton.visible = true;
skipNightGameText.visible = true;
} else {
skipNightGameButton.visible = false;
skipNightGameText.visible = false;
}
if (!gameRunning || !gameStarted) return;
// Update animatronics
for (var i = 0; i < animatronics.length; i++) {
animatronics[i].update();
}
// Check corridor wait timers
for (var animatronicType in corridorWaitTimers) {
var timer = corridorWaitTimers[animatronicType];
if (!timer.triggered) {
var timeWaited = (LK.ticks - timer.startTime) / 60; // Convert to seconds
// Check if door was closed while animatronic is waiting
var doorClosed = false;
if (timer.room === 3 && leftDoorClosed) {
doorClosed = true;
} else if (timer.room === 4 && rightDoorClosed) {
doorClosed = true;
}
// If door is closed, start disappear timer
if (doorClosed && !timer.disappearStartTime) {
timer.disappearStartTime = LK.ticks;
}
// If disappear timer started, check if 3 seconds passed
if (timer.disappearStartTime) {
var disappearTime = (LK.ticks - timer.disappearStartTime) / 60;
if (disappearTime >= 3) {
// Find the animatronic and move it away from corridor
for (var i = 0; i < animatronics.length; i++) {
if (animatronics[i].type === animatronicType) {
// Move back to previous room or stage
if (animatronics[i].type === 'bonnie') {
animatronics[i].currentRoom = 2; // Back to party room
} else if (animatronics[i].type === 'chica') {
animatronics[i].currentRoom = 2; // Back to party room
}
break;
}
}
delete corridorWaitTimers[animatronicType];
continue;
}
}
// Check if 10 seconds have passed (only if door not closed)
if (timeWaited >= 10 && !doorClosed) {
var shouldJumpscare = false;
// Check if appropriate door is closed
if (timer.room === 3 && !leftDoorClosed) {
// Left corridor
shouldJumpscare = true;
} else if (timer.room === 4 && !rightDoorClosed) {
// Right corridor
shouldJumpscare = true;
}
if (shouldJumpscare) {
timer.triggered = true;
jumpscare(animatronicType);
return;
} else {
// Door was closed in time, remove timer
delete corridorWaitTimers[animatronicType];
}
}
}
}
// Check for jumpscares
checkForJumpscares();
// Update power drain visualization
if (powerDrain > 1) {
powerBar.tint = 0xff0000;
} else {
powerBar.tint = 0x00ff00;
}
};
function showNight5Cutscene() {
// Create cutscene overlay
var cutsceneOverlay = game.addChild(LK.getAsset('jumpscareOverlay', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0,
alpha: 1.0
}));
// Add cutscene background image
var cutsceneBackground = cutsceneOverlay.addChild(LK.getAsset('night5Cutscene', {
x: 1024,
y: 1366,
anchorX: 0.5,
anchorY: 0.5
}));
// Play cutscene music
try {
LK.playMusic('cutsceneMusic');
} catch (e) {}
// Add cutscene title
var cutsceneTitle = new Text2('Five Nights Completed!', {
size: 100,
fill: 0x00FF00
});
cutsceneTitle.anchor.set(0.5, 0.5);
cutsceneTitle.x = 1024;
cutsceneTitle.y = 1000;
cutsceneOverlay.addChild(cutsceneTitle);
// Add subtitle
var cutsceneSubtitle = new Text2('You survived the terror...', {
size: 60,
fill: 0xFFFFFF
});
cutsceneSubtitle.anchor.set(0.5, 0.5);
cutsceneSubtitle.x = 1024;
cutsceneSubtitle.y = 1200;
cutsceneOverlay.addChild(cutsceneSubtitle);
// Add bonus text
var bonusText = new Text2('Custom Night Unlocked!', {
size: 50,
fill: 0xFFD700
});
bonusText.anchor.set(0.5, 0.5);
bonusText.x = 1024;
bonusText.y = 1400;
cutsceneOverlay.addChild(bonusText);
// Animate the text
tween(cutsceneTitle, {
alpha: 0
}, {
duration: 1000,
easing: tween.easeIn
});
tween(cutsceneTitle, {
alpha: 1
}, {
duration: 1000,
easing: tween.easeOut
});
tween(cutsceneSubtitle, {
y: 1150,
alpha: 0.8
}, {
duration: 2000,
easing: tween.easeInOut
});
tween(bonusText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 1500,
easing: tween.bounceOut
});
// Show cutscene for 10 seconds then transition to menu
LK.setTimeout(function () {
// Stop cutscene music
try {
LK.stopMusic();
} catch (e) {}
// Remove cutscene overlay
game.removeChild(cutsceneOverlay);
// After completing Night 5, return player to main menu with unlocked content
menuOverlay.visible = true;
customNightButton.visible = true;
customNightText.visible = true;
extrasButton.visible = true;
extrasText.visible = true;
newGameButton.visible = true;
newGameText.visible = true;
continueButton.visible = true;
continueText.visible = true;
adminButton.visible = true;
adminText.visible = true;
shopButton.visible = true;
shopText.visible = true;
menuTitle.visible = true;
menuBackground.visible = true;
gameRunning = false;
gameStarted = false;
// Play menu music
LK.playMusic('menuMusic');
}, 10000);
}
function showShopMenu() {
// Create shop overlay
var shopOverlay = game.addChild(LK.getAsset('shopMenu', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0
}));
var shopTitle = new Text2('SHOP', {
size: 100,
fill: 0x000000
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 1024;
shopTitle.y = 400;
shopOverlay.addChild(shopTitle);
var shopDescription = new Text2('Purchase upgrades and items', {
size: 50,
fill: 0x333333
});
shopDescription.anchor.set(0.5, 0.5);
shopDescription.x = 1024;
shopDescription.y = 600;
shopOverlay.addChild(shopDescription);
// Display player money
var playerMoney = storage.money || 0;
var moneyDisplay = new Text2('Money: $' + playerMoney, {
size: 40,
fill: 0x00FF00
});
moneyDisplay.anchor.set(0.5, 0.5);
moneyDisplay.x = 1024;
moneyDisplay.y = 800;
shopOverlay.addChild(moneyDisplay);
// Add Mango plushie button
var mangoPlushieButton = shopOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 812,
y: 1000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.5
}));
var mangoPlushieText = new Text2('MANGO PLUSHIE\n$200', {
size: 30,
fill: 0xFFFFFF
});
mangoPlushieText.anchor.set(0.5, 0.5);
mangoPlushieText.x = 812;
mangoPlushieText.y = 1000;
shopOverlay.addChild(mangoPlushieText);
// Add Anime poster button
var animePosterButton = shopOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1236,
y: 1000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.5
}));
var animePosterText = new Text2('ANIME POSTER\n$350', {
size: 30,
fill: 0xFFFFFF
});
animePosterText.anchor.set(0.5, 0.5);
animePosterText.x = 1236;
animePosterText.y = 1000;
shopOverlay.addChild(animePosterText);
// Add close button
var closeButton = shopOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1600,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var closeText = new Text2('CLOSE SHOP', {
size: 40,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 1024;
closeText.y = 1600;
shopOverlay.addChild(closeText);
// Add back to menu button
var backToMenuButton = shopOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1800,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var backToMenuText = new Text2('BACK TO MENU', {
size: 40,
fill: 0xFFFFFF
});
backToMenuText.anchor.set(0.5, 0.5);
backToMenuText.x = 1024;
backToMenuText.y = 1800;
shopOverlay.addChild(backToMenuText);
// Button handlers
mangoPlushieButton.down = function (x, y, obj) {
var currentMoney = storage.money || 0;
if (currentMoney >= 200) {
storage.money = currentMoney - 200;
storage.mangoPlushie = true;
moneyDisplay.setText('Money: $' + storage.money);
mangoPlushieText.setText('PURCHASED!\nTHANK YOU!');
mangoPlushieText.tint = 0x00FF00;
mangoPlushieButton.tint = 0x555555;
// Show mango plushie on office table immediately if game is active
if (mangoPlushieDisplay && gameStarted) {
mangoPlushieDisplay.visible = true;
}
} else {
mangoPlushieText.setText('NOT ENOUGH\nMONEY!');
mangoPlushieText.tint = 0xFF0000;
LK.setTimeout(function () {
mangoPlushieText.setText('MANGO PLUSHIE\n$200');
mangoPlushieText.tint = 0xFFFFFF;
}, 2000);
}
};
animePosterButton.down = function (x, y, obj) {
var currentMoney = storage.money || 0;
if (currentMoney >= 350) {
storage.money = currentMoney - 350;
storage.animePoster = true;
moneyDisplay.setText('Money: $' + storage.money);
animePosterText.setText('PURCHASED!\nTHANK YOU!');
animePosterText.tint = 0x00FF00;
animePosterButton.tint = 0x555555;
// Show anime poster on office wall immediately if game is active
if (animePosterDisplay && gameStarted) {
animePosterDisplay.visible = true;
}
} else {
animePosterText.setText('NOT ENOUGH\nMONEY!');
animePosterText.tint = 0xFF0000;
LK.setTimeout(function () {
animePosterText.setText('ANIME POSTER\n$350');
animePosterText.tint = 0xFFFFFF;
}, 2000);
}
};
closeButton.down = function (x, y, obj) {
game.removeChild(shopOverlay);
};
backToMenuButton.down = function (x, y, obj) {
game.removeChild(shopOverlay);
};
}
function showExtrasMenu() {
// Create extras overlay
var extrasOverlay = game.addChild(LK.getAsset('jumpscareOverlay', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0,
alpha: 0.9
}));
// Add menu background image
var menuImageDisplay = extrasOverlay.addChild(LK.getAsset('menuImage', {
x: 1024,
y: 1366,
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.3
}));
var extrasTitle = new Text2('EXTRAS', {
size: 80,
fill: 0xFFFFFF
});
extrasTitle.anchor.set(0.5, 0.5);
extrasTitle.x = 1024;
extrasTitle.y = 400;
extrasOverlay.addChild(extrasTitle);
var extrasDescription = new Text2('Bonus content unlocked!', {
size: 50,
fill: 0xFFFFFF
});
extrasDescription.anchor.set(0.5, 0.5);
extrasDescription.x = 1024;
extrasDescription.y = 600;
extrasOverlay.addChild(extrasDescription);
// Add animatronic jumpscare buttons in order: Freddy, Bonnie, Chica, Foxy
var buttonSpacing = 300;
var startX = 1024 - 3 * buttonSpacing / 2;
// Freddy jumpscare button
var freddyJumpscareButton = extrasOverlay.addChild(LK.getAsset('closeCameraButton', {
x: startX,
y: 1000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
}));
var freddyImage = extrasOverlay.addChild(LK.getAsset('freddy', {
x: startX,
y: 950,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
}));
var freddyJumpscareText = new Text2('Jumpscares', {
size: 30,
fill: 0xFFFFFF
});
freddyJumpscareText.anchor.set(0.5, 0.5);
freddyJumpscareText.x = startX;
freddyJumpscareText.y = 850;
extrasOverlay.addChild(freddyJumpscareText);
var freddyLabel = new Text2('SIGMA BART', {
size: 30,
fill: 0xFFFFFF
});
freddyLabel.anchor.set(0.5, 0.5);
freddyLabel.x = startX;
freddyLabel.y = 1050;
extrasOverlay.addChild(freddyLabel);
// Bonnie jumpscare button
var bonnieJumpscareButton = extrasOverlay.addChild(LK.getAsset('closeCameraButton', {
x: startX + buttonSpacing,
y: 1000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
}));
var bonnieImage = extrasOverlay.addChild(LK.getAsset('bonnie', {
x: startX + buttonSpacing,
y: 950,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
}));
var bonnieJumpscareText = new Text2('Jumpscares', {
size: 30,
fill: 0xFFFFFF
});
bonnieJumpscareText.anchor.set(0.5, 0.5);
bonnieJumpscareText.x = startX + buttonSpacing;
bonnieJumpscareText.y = 850;
extrasOverlay.addChild(bonnieJumpscareText);
var bonnieLabel = new Text2('GEORGE FLOYD', {
size: 30,
fill: 0xFFFFFF
});
bonnieLabel.anchor.set(0.5, 0.5);
bonnieLabel.x = startX + buttonSpacing;
bonnieLabel.y = 1050;
extrasOverlay.addChild(bonnieLabel);
// Chica jumpscare button
var chicaJumpscareButton = extrasOverlay.addChild(LK.getAsset('closeCameraButton', {
x: startX + buttonSpacing * 2,
y: 1000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
}));
var chicaImage = extrasOverlay.addChild(LK.getAsset('chica', {
x: startX + buttonSpacing * 2,
y: 950,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
}));
var chicaJumpscareText = new Text2('Jumpscares', {
size: 30,
fill: 0xFFFFFF
});
chicaJumpscareText.anchor.set(0.5, 0.5);
chicaJumpscareText.x = startX + buttonSpacing * 2;
chicaJumpscareText.y = 850;
extrasOverlay.addChild(chicaJumpscareText);
var chicaLabel = new Text2('NOYAN', {
size: 30,
fill: 0xFFFFFF
});
chicaLabel.anchor.set(0.5, 0.5);
chicaLabel.x = startX + buttonSpacing * 2;
chicaLabel.y = 1050;
extrasOverlay.addChild(chicaLabel);
// Foxy jumpscare button
var foxyJumpscareButton = extrasOverlay.addChild(LK.getAsset('closeCameraButton', {
x: startX + buttonSpacing * 3,
y: 1000,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
}));
var foxyImage = extrasOverlay.addChild(LK.getAsset('foxy', {
x: startX + buttonSpacing * 3,
y: 950,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
}));
var foxyJumpscareText = new Text2('Jumpscares', {
size: 30,
fill: 0xFFFFFF
});
foxyJumpscareText.anchor.set(0.5, 0.5);
foxyJumpscareText.x = startX + buttonSpacing * 3;
foxyJumpscareText.y = 850;
extrasOverlay.addChild(foxyJumpscareText);
var foxyLabel = new Text2('SIGMA MANGO MUSTARD', {
size: 30,
fill: 0xFFFFFF
});
foxyLabel.anchor.set(0.5, 0.5);
foxyLabel.x = startX + buttonSpacing * 3;
foxyLabel.y = 1050;
extrasOverlay.addChild(foxyLabel);
// Button handlers for jumpscares
freddyJumpscareButton.down = function (x, y, obj) {
game.removeChild(extrasOverlay);
jumpscare('freddy', true);
};
bonnieJumpscareButton.down = function (x, y, obj) {
game.removeChild(extrasOverlay);
jumpscare('bonnie', true);
};
chicaJumpscareButton.down = function (x, y, obj) {
game.removeChild(extrasOverlay);
jumpscare('chica', true);
};
foxyJumpscareButton.down = function (x, y, obj) {
game.removeChild(extrasOverlay);
jumpscare('foxy', true);
};
// Add back button
var backButton = extrasOverlay.addChild(LK.getAsset('closeCameraButton', {
x: 1024,
y: 1200,
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5
}));
var backText = new Text2('BACK TO MENU', {
size: 40,
fill: 0xFFFFFF
});
backText.anchor.set(0.5, 0.5);
backText.x = 1024;
backText.y = 1200;
extrasOverlay.addChild(backText);
backButton.down = function (x, y, obj) {
game.removeChild(extrasOverlay);
};
}
function showCustomNightCutscene() {
// Create cutscene overlay
var cutsceneOverlay = game.addChild(LK.getAsset('jumpscareOverlay', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0,
alpha: 1.0
}));
// Add cutscene background image
var cutsceneBackground = cutsceneOverlay.addChild(LK.getAsset('customNightCutscene', {
x: 1024,
y: 1366,
anchorX: 0.5,
anchorY: 0.5
}));
// Play cutscene sound using tween for enhanced timing
tween({}, {}, {
duration: 100,
onFinish: function onFinish() {
try {
LK.getSound('customNightEndSound').play();
} catch (e) {}
}
});
// Add cutscene title
var cutsceneTitle = new Text2('CUSTOM NIGHT COMPLETED!', {
size: 100,
fill: 0x00FF00
});
cutsceneTitle.anchor.set(0.5, 0.5);
cutsceneTitle.x = 1024;
cutsceneTitle.y = 1000;
cutsceneOverlay.addChild(cutsceneTitle);
// Add subtitle
var cutsceneSubtitle = new Text2('You have mastered the nightmare...', {
size: 60,
fill: 0xFFFFFF
});
cutsceneSubtitle.anchor.set(0.5, 0.5);
cutsceneSubtitle.x = 1024;
cutsceneSubtitle.y = 1200;
cutsceneOverlay.addChild(cutsceneSubtitle);
// Add completion text
var completionText = new Text2('Congratulations!', {
size: 50,
fill: 0xFFD700
});
completionText.anchor.set(0.5, 0.5);
completionText.x = 1024;
completionText.y = 1400;
cutsceneOverlay.addChild(completionText);
// Animate the text
tween(cutsceneTitle, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 1000,
easing: tween.bounceOut
});
tween(cutsceneSubtitle, {
alpha: 0.9,
y: 1150
}, {
duration: 2000,
easing: tween.easeInOut
});
tween(completionText, {
scaleX: 1.3,
scaleY: 1.3,
alpha: 0.8
}, {
duration: 1500,
easing: tween.elasticOut
});
// Show cutscene for 10 seconds then go to main menu
LK.setTimeout(function () {
// Remove cutscene overlay
game.removeChild(cutsceneOverlay);
// Return to main menu
menuOverlay.visible = true;
gameRunning = false;
gameStarted = false;
// Play menu music
LK.playMusic('menuMusic');
}, 10000);
} ===================================================================
--- original.js
+++ change.js
@@ -36,18 +36,18 @@
self.update = function () {
self.moveTimer++;
// Get current aggression level (use custom night values if in custom night mode)
var currentAggression = self.aggressionLevel;
- if (nightNumber === 7 && typeof characterLevels !== 'undefined') {
- // In custom night mode, use the character level set by player
- if (self.type === 'freddy' && characterLevels.freddy) {
- currentAggression = characterLevels.freddy;
- } else if (self.type === 'bonnie' && characterLevels.bonnie) {
- currentAggression = characterLevels.bonnie;
- } else if (self.type === 'chica' && characterLevels.chica) {
- currentAggression = characterLevels.chica;
- } else if (self.type === 'foxy' && characterLevels.foxy) {
- currentAggression = characterLevels.foxy;
+ if (nightNumber === 7 && typeof window.characterLevels !== 'undefined') {
+ // In custom night mode, use the character level set by player (single night only)
+ if (self.type === 'freddy' && window.characterLevels.freddy) {
+ currentAggression = window.characterLevels.freddy;
+ } else if (self.type === 'bonnie' && window.characterLevels.bonnie) {
+ currentAggression = window.characterLevels.bonnie;
+ } else if (self.type === 'chica' && window.characterLevels.chica) {
+ currentAggression = window.characterLevels.chica;
+ } else if (self.type === 'foxy' && window.characterLevels.foxy) {
+ currentAggression = window.characterLevels.foxy;
}
}
// Handle specific movement patterns
if (self.type === 'freddy') {
@@ -120,10 +120,10 @@
if (self.isMoving) return; // Don't move if already moving
var currentTime = LK.ticks / 60; // Convert to seconds
// Get current aggression level for timing adjustments
var currentAggression = self.aggressionLevel;
- if (nightNumber === 7 && typeof characterLevels !== 'undefined' && characterLevels.bonnie) {
- currentAggression = characterLevels.bonnie;
+ if (nightNumber === 7 && typeof window.characterLevels !== 'undefined' && window.characterLevels.bonnie) {
+ currentAggression = window.characterLevels.bonnie;
}
// Calculate time reductions based on aggression level (5 seconds per level)
var timeReduction = (currentAggression - 1) * 5;
var basementWaitTime = Math.max(5, 30 - timeReduction); // Minimum 5 seconds
@@ -296,10 +296,10 @@
if (self.isMoving) return; // Don't move if already moving
var currentTime = LK.ticks / 60; // Convert to seconds
// Get current aggression level for timing adjustments
var currentAggression = self.aggressionLevel;
- if (nightNumber === 7 && typeof characterLevels !== 'undefined' && characterLevels.chica) {
- currentAggression = characterLevels.chica;
+ if (nightNumber === 7 && typeof window.characterLevels !== 'undefined' && window.characterLevels.chica) {
+ currentAggression = window.characterLevels.chica;
}
// Calculate time reductions based on aggression level (5 seconds per level)
var timeReduction = (currentAggression - 1) * 5;
var corridorWaitTime = Math.max(5, 20 - timeReduction); // Minimum 5 seconds for corridor wait
@@ -440,10 +440,10 @@
if (self.isMoving) return; // Don't move if already moving
var currentTime = LK.ticks / 60; // Convert to seconds
// Get current aggression level for timing adjustments
var currentAggression = self.aggressionLevel;
- if (nightNumber === 7 && typeof characterLevels !== 'undefined' && characterLevels.foxy) {
- currentAggression = characterLevels.foxy;
+ if (nightNumber === 7 && typeof window.characterLevels !== 'undefined' && window.characterLevels.foxy) {
+ currentAggression = window.characterLevels.foxy;
}
// Calculate time reductions based on aggression level (5 seconds per level)
var timeReduction = (currentAggression - 1) * 5;
var waitTime = Math.max(5, 15 - timeReduction); // Minimum 5 seconds
@@ -1953,8 +1953,9 @@
game.removeChild(completionOverlay);
if (nightNumber === 7) {
// Custom night completed after just one night - show special cutscene and play sound
showCustomNightCutscene();
+ return; // Exit early to prevent progression to next night
} else if (nightNumber >= 5) {
// Night 5 completed - mark all nights as completed and show special cutscene
storage.allNightsCompleted = true;
showNight5Cutscene();
@@ -2004,18 +2005,18 @@
animatronics[i].movementState = 0;
animatronics[i].lastMoveTime = 0;
}
// Set aggression based on night type
- if (nightNumber === 7 && typeof characterLevels !== 'undefined') {
- // Custom night - use character levels (single night only)
- if (animatronics[i].type === 'freddy' && characterLevels.freddy) {
- animatronics[i].setAggression(characterLevels.freddy);
- } else if (animatronics[i].type === 'bonnie' && characterLevels.bonnie) {
- animatronics[i].setAggression(characterLevels.bonnie);
- } else if (animatronics[i].type === 'chica' && characterLevels.chica) {
- animatronics[i].setAggression(characterLevels.chica);
- } else if (animatronics[i].type === 'foxy' && characterLevels.foxy) {
- animatronics[i].setAggression(characterLevels.foxy);
+ if (nightNumber === 7 && typeof window.characterLevels !== 'undefined') {
+ // Custom night - use character levels set by player (single night only)
+ if (animatronics[i].type === 'freddy' && window.characterLevels.freddy) {
+ animatronics[i].setAggression(window.characterLevels.freddy);
+ } else if (animatronics[i].type === 'bonnie' && window.characterLevels.bonnie) {
+ animatronics[i].setAggression(window.characterLevels.bonnie);
+ } else if (animatronics[i].type === 'chica' && window.characterLevels.chica) {
+ animatronics[i].setAggression(window.characterLevels.chica);
+ } else if (animatronics[i].type === 'foxy' && window.characterLevels.foxy) {
+ animatronics[i].setAggression(window.characterLevels.foxy);
} else {
animatronics[i].setAggression(1);
}
} else {
footsteps
Sound effect
menuMusic
Music
doorSlam
Sound effect
cameraSwitch
Sound effect
scream
Sound effect
officeAmbiance
Sound effect
cameraAmbiance
Sound effect
cameraToggle
Sound effect
completion
Sound effect
powerDown
Sound effect
cutsceneMusic
Sound effect
freddyCorridorSound
Sound effect
customNightEndSound
Sound effect