If you appreciate the work done within the wiki, please consider supporting The Cutting Room Floor on Patreon. Thanks for all your support!

Cookie Clicker/Unused Code

From The Cutting Room Floor
Jump to navigation Jump to search

This is a sub-page of Cookie Clicker.

Hmmm...
To do:
Update this for the current version

This game has quite a bit of interesting unused code. The source code for the game can be found here.

Note: all commented code will be marked in green to help distinguish what is used from what is not used.

Unfinished Mod Hooks

The game's source code contains an unfinished section intended to help people with creating plugins. This code is technically used, though the code does nothing if the game does not have plugins added.

 /*=====================================================================================
  MOD HOOKS (will be subject to change, probably shouldn't be used yet)
  =======================================================================================*/
//really primitive custom mods support - might not be of any use at all (could theoretically be used for custom upgrades and achievements I guess?)
Game.customChecks=[];//push functions into this to add them to the "check for upgrade/achievement conditions" that happens every few seconds
Game.customInit=[];//add to the initialization call
Game.customLogic=[];//add to the logic calls
Game.customDraw=[];//add to the draw calls
Game.customSave=[];//add to the save write calls (save to your own localstorage key)
Game.customLoad=[];//add to the save load calls
Game.customReset=[];//add to the reset calls
Game.customTickers=[];//add to the random tickers (functions should return arrays of text)
Game.customCps=[];//add to the CpS computation (functions should return something to add to the multiplier ie. 0.1 for an addition of 10 to the CpS multiplier)
Game.customCpsMult=[];//add to the CpS multiplier)
Game.customMouseCpsMult=[];//add to the cookies earned per click multiplicative computation (functions should return something to multiply by the multiplier ie. 1.05 for a 5% increase of the multiplier)
Game.customCookieClicks=[];//add to the cookie click calls
Game.customCreate=[];//create your new upgrades and achievements in there

Game.LoadMod=function(url)//this loads the mod at the given URL and gives the script an automatic id (URL "http://example.com/my_mod.js" gives the id "modscript_my_mod")
{
var js=document.createElement('script');
	var id=url.split('/');id=id[id.length-1].split('.')[0];
	js.setAttribute('type','text/javascript');
	js.setAttribute('id','modscript_'+id);
	js.setAttribute('src',url);
	document.head.appendChild(js);
	console.log('Loaded the mod '+url+', '+id+'.');
}
		
//replacing an existing canvas picture with a new one at runtime : Game.Loader.Replace('perfectCookie.png','imperfectCookie.png');
//upgrades and achievements can use other pictures than icons.png; declare their icon with [posX,posY,'http://example.com/myIcons.png']
//check out the "UNLOCKING STUFF" section to see how unlocking achievs and upgrades is done (queue yours in Game.customChecks)
//if you're making a mod, don't forget to add a Game.Win('Third-party') somewhere in there!
	
//IMPORTANT : all of the above is susceptible to heavy change, proper modding API in the works

Unused Challenge Mode

This is what the mode would look like in the menu. This was made using browser console hacks and photo editing.

As of the legacy update, whenever the player ascends, they are presented with the option to enable challenge mode. Currently, the only available modes are challenge mode 0: "None", which makes the game function normally, or challenge mode 1: "Born again", which makes the game function like a hard reset, without actually being a hard reset.

Interestingly, the code for challenge modes contains code for challenge mode 3: "Trigger finger", which is currently commented out. If the code for the other modes is removed, it looks like this:

/*,
2:{name:'Trigger finger',desc:'In this run, scrolling your mouse wheel on the cookie counts as clicking it. Some upgrades introduce new clicking behaviors.<br>No clicking achievements may be obtained in this mode.<div class="line"></div>Reaching 1 quadrillion cookies in this mode unlocks a special heavenly upgrade.',icon:[12,0]}*/

This is what the text and icon would look like:

Cookieclicker-triggerfinger.png
Trigger finger
In this run, scrolling your mouse wheel on the cookie counts as clicking it. Some upgrades introduce new clicking behaviors.
No clicking achievements may be obtained in this mode.
---
Reaching 1 quadrillion cookies in this mode unlocks a special heavenly upgrade.

Besides the code that sets the icon image and description, this mode is not programmed to do anything. By using browser console commands, it is possible to re-insert this mode. However, selecting the mode will cause the game to behave like "None", besides the appearance of the mode in the stats tab. This effect will go away if the window is refreshed.

The heavenly upgrade the description refers to does not appear to exist in any fashion, though it may be related to one of these unused icons.

Wobbly Tooltip

Game.tooltip.wobble is a function meant to make an object's tooltip "bounce-in" on appearance, rather than just becoming visible.

Game.tooltip.wobble=function()
{
	//disabled because this effect doesn't look good with the slight slowdown it might or might not be causing.
	if (false)
	{
		this.tt.className='framed';
		this.tt.offsetWidth=this.tt.offsetWidth;
		this.tt.className='framed wobbling';
	}
}

This function is always called by the tooltip handler, though it does not actually do anything. The if statement's parameter is always set to false, meaning the condition it checks for is never true. As a result of this, the code inside the statement is never executed, even when the function is called.

Unused Stats

The game has a few unused stats.

Background Type

Game.backgroundType is a stat intended to keep track of what background the player is using, but backgrounds have not been implemented yet. The game does not use this stat for any features in the game.

The stat is set to a default value of -1, though it changes to 0 almost immediately after. This is due to a line of code in the function for loading saves. If the game is being played in a version after the prototype, the game sets this stat (and a few others) to 0. This was likely done to prevent the game from loading invalid data.

Heavenly Cookies

Game.heavenlyCookies is a stat that was used to keep track of how many cookies have been baked from heavenly chips. In older versions of the game, the ascension screen would present the option to "bake heavenly cookies". The cookies would increase the player's prestige CpS by 1% (which was actually 10% due to a bug) for every 10 chips spent. This option was removed in later versions of the game, as it now increases the player's prestige CpS based on their prestige level.

The stat is set to a default value of 0, which gets reset back to 0 again if the player performs a hard reset.

Missed Golden Cookies

Game.missedGoldenClicks is a stat that increments by 1 whenever the player fails to click on a golden/wrath cookie in time. This stat does work as intended, but the code for displaying it was commented out.

//' <span class="hidden">(<b>Missed golden cookies :</b> '+Beautify(Game.missedGoldenClicks)+')</span></div>'+

According to the changelog, this was done because players reported it was "messing with their OCD".

If the game is modded to use this code, it would appear under the "General" section, and would look something akin to this:

Missed golden cookies : (Game.missedGoldenClicks)

"(Game.missedGoldenClicks)" represents the variable number of missed golden cookies.

Autosave Button

Every 60 in-game seconds, the game checks to see if it should write a save or not. One of the things it checks is Game.prefs.autosave, which is always set to 1, so this check always passes. The stat cannot be changed through normal means.

Interestingly, the game contains commented code for an autosave button, located in the code for the options menu. This was likely removed because there would be very little reason to disable autosaving.

//'<div class="listing">'+Game.WriteButton('autosave','autosaveButton','Autosave ON','Autosave OFF')+'</div>'+

If the game is modded to use this code, it would appear below the "Defocus" option, and would not have a description. The button would actually work as intended, by setting the autosave stat to 0.

Golden Cookie Buff

buff is an object is used to determine the properties of a golden cookie buff.

var buff={
	visible:true,
	time:0,
	name:'???',
	desc:'',
 	icon:[0,0]
 };

Interestingly, this object contains its own properties, which are normally unused. When the game's code sets a new golden cookie buff, it overwrites the properties in the object, replacing them with properties that are unique to the specific buff type.

If the game sets a new golden cookie buff that does not contain unique properties, it will use the properties in the unmodified buff object. All the golden cookie buffs in the game have their own properties, so this code is never executed. This suggests that the default buff code is intended to act as a fail-safe, in case something goes wrong with the game.

If the game is modded to create a new buff without custom properties, it would display as this in the tooltip:

Cookieclicker-cursor.png
???

This effect would last for zero seconds (causing the buff to end immediately after it starts).

Unused Upgrade Pool

.pool is an object property string that can contain any string data, though the game will only read it correctly if the string matches one of seven upgrade types. One of the upgrade pools is known as "unused" (the literal name of the pool string). Upgrades with this pool will not show up in the stats menu if purchased, and will not count towards the player's total amount of upgrades. This was likely meant to be used for upgrades that were not fully programmed.

Ironically, none of the upgrades in the current version of the game use this pool. As such, the pool itself goes unused.

Dungeon Access

Hmmm...
To do:
Describe the other "special'-related code for context.

The game used to have a dungeon mode, which was removed in recent versions of the game, though the code for gaining access to these dungeons still exists. Interestingly, rather than commenting (or outright removing) the code, the developer used other methods of disabling access.

setSpecial

.setSpecial is an object method that was meant to be used for setting an object's "special" function, which was only ever used for factory dungeons.

this.setSpecial=function(what)//change whether we're on the special overlay for this object or not
{
	return;//blocked temporarily
	if (what==1) this.onSpecial=1;
	else this.onSpecial=0;
	if (this.id!=0)
	{
		if (this.onSpecial)
		{
			l('rowSpecial'+this.id).style.display='block';
			if (this.specialDrawFunction) this.specialDrawFunction();
		}
		else
		{
			l('rowSpecial'+this.id).style.display='none';
			this.draw();
		}
	}
}

For some reason, the developer chose to disable this code by placing a return expression at the beginning of the function.

Because of the way JavaScript works, if the game reaches a return expression in a function, it will not read the rest of the function. Because of this, when the function is called, it will immediately return undefined. The rest of the code is never used, because the game stops reading the function after the expression is used.

unlockSpecial

.unlockSpecial is an object method that was meant to be used for unlocking dungeons.

this.unlockSpecial=function()
{
	if (this.specialUnlocked==0 && 1==0)
	{
		this.specialUnlocked=1;
		this.setSpecial(0);
		if (this.special) this.special();
		this.refresh();
	}
}

For some reason, the developer chose to disable this code by modifying the if statement. The statement will not execute the code inside it unless two conditions are met at the same time:

  1. The player must not already own the specified object's "special" functionality.
  2. The number 1 has to have the same value as the number 0.

Due to the rules of basic math, the second condition will never be considered true. Since BOTH conditions have to be met when the check occurs, the game will never use the code inside the statement if the function is ever called.

Ascension

The code that determines all the effects of ascension has a few lines that were commented out.

Achievements

/*for (var i in Game.AchievementsById)
{
	var me=Game.AchievementsById[i];
	me.won=0;
}*/

This code would cause ascending to take away all the player's achievements. Thankfully, this was never used.

Golden Cookies

//goldenClicks=0;

This code would cause ascending to reset the player's stat for clicking on golden cookies. This was in the game, but it was later taken out after the introduction of heavenly chips, because this would make certain golden cookie-related achievements even harder to obtain.

Missed Golden Cookies

//missedGoldenClicks=0;

This code would cause ascending to reset the player's stat for not clicking on golden cookies. This stat is already unused, but even if it wasn't, having this would make it easier for players to hide their shameful mistakes reset this statistic.

Options

//Game.DefaultPrefs();

This code would cause ascending to revert the player's options back to their default settings. This was probably removed to make ascending less of a problem for players with custom settings.

Sound Effects

The game has a number of unused sound effects. Out of all of these, the game only contains code for playing "levelPrestige.mp3", which is commented out.

//PlaySound('snd/levelPrestige.mp3');//a bit too annoying

This was removed because the sound effect would be annoying to the player if they were to gain prestige levels very quickly.

Code Comments

The developer left a few... interesting notes in the source code.

Cookie Clicker's Cookies

In older versions of the game, the player's progress was stored using browser cookies. In light of this, the developer wrote a few comments poking fun at the irony.

//guess what we're using to save the game?
//that's right
//we're using cookies
//yeah I went there
//we storin dis for 5 years, people
//mmh stale cookies

However, as of the Valentine's Day update, the game's progress is now saved in local storage. Because of this, part of the text was removed, and a new set of comments were added.

//so we used to save the game using browser cookies, which was just really neat considering the game's name
//we're using localstorage now, which is more efficient but not as cool
//a moment of silence for our fallen puns

Example Golden Cookie Buff

The code for setting golden cookie buffs contains a large comment, intended to function as instructions for modders to create their own buffs.

/*
usage example :
	Game.setBuff({
		name:'Kitten rain',
		desc:'It\'s raining kittens!',
		icon:[0,0],
		time:30*Game.fps
	});
other parameters :
	visible:false - will hide the buff from the buff list
	add:true - if this buff already exists, add the new duration to the old one
	max:true - if this buff already exists, set the new duration to the max of either
	onDie:function(){} - function will execute when the buff runs out
	power:3 - used by some buffs
	multCpS:3 - buff multiplies CpS by this amount
	multClick:3 - buff multiplies click power by this amount
*/

This comment contains example code for a custom buff, which would display as this in the tooltip:

Cookieclicker-cursor.png
Kɪᴛᴛᴇɴ ʀᴀɪɴ
It's raining kittens!

The effect would last for 30 seconds by default.

Golden Cookie Chains

One of the buffs a golden cookie can grant is the "Cookie chain", where golden cookies appear every few seconds, which give the player an increasingly large amount of cookies. The code for determining the amount of time a golden cookie appears on-screen during this buff contains this comment.

//this is hilarious

Apparently, the developer finds the concept of an increasingly shorter window of time to click on a golden cookie funny.

Wrinklers

Wrinklers are leech-like creatures that feed off the player's cookie production until the player pops them. Oddly, the code contains comments describing other strange aspects of these creatures.

  • Wrinklers: //cookie dough does weird things inside wrinkler digestive tracts
  • Shiny Wrinklers: //shiny wrinklers are an elusive, profitable breed

Ruin the Fun

"Ruin the Fun" is a function that cannot be accessed without cheating. The code for this function contains a comment.

//booooo

Grandma Upgrades

In version 1.0375, the code contained some... strange comments between the lines of code for each grandma upgrade. The comments were removed in the following update for unknown reasons.

When the comments are isolated from the rest of the code, it looks like this:

  • Farmer grandmas: //I remember the first time I saw her, amidst the cookie crops.
  • Worker grandmas: //Her eyes like a burning furnace; my heart like a racing engine.
  • Miner grandmas: //It was as if she could pierce through me, burrow at my deepest.
  • Cosmic grandmas: //In that moment, the universe felt empty, save for just her and me.
  • Transmuted grandmas: //I could feel it growing in me. Changing me... making me something else, something better.
  • Altered grandmas: //There was no way she was of this world. Her very mind was... alien, pervasive; a distortion of the real thing.
  • Grandma's grandmas: //She was not what I had first assumed; she was from another time, another eon altogether.
  • Antigrandmas: //And with her hair... sparkling like starlight... she whispered something.
(Source: Cookie Clicker Wiki)

News Ticker

The game has a news ticker on the top of the screen, which shows fake news reports on events happening in the game's world.

Base 10

//somehow I got flak for this one

This comment is located after the code for a news report for obtaining the achievement Base 10, which reads "News : cookie manufacturer completely forgoes common sense, lets OCD drive building decisions!" Apparently, the developer got flak for that one.

This has since been removed, and "OCD" was changed to "strange obsession with round numbers".

Rare News

//apologies to Will Wright

This comment is located in front of the code that is used to pick a "special" news report 0.1% of the time. Will Wright is a game designer notable for his work on the Sims series and Spore, though what this code has to do with him is unclear.

Stop Playing

//only show this for 100 millions (it's funny for a moment)

This comment is located after the code for a news report, which simply reads "it's time to stop playing".

Removed Covid Lines

//'News : scientists advise getting used to cookies suffusing every aspect of life; "this is the new normal", expert says.' //'News : doctors advise against wearing face masks when going outside. "You never know when you might need a cookie... a mask would just get in the way."' //these were written back when covid hadn't really done much damage yet but they just feel in poor taste now

These news headlines were added during the beginning of the real-life COVID-19 pandemic, then commented out later in the year when the true impact of the disease became clear. These were included in the >10,000-cookie-requirement section, where the majority of headlines are located.

CSS

Hmmm...
To do:
Finish this section. There's a lot more to cover.

The game uses a cascading style sheet to handle how everything in the game is rendered in the browser.

#tooltipAnchor

tooltipAnchor is a selector that handles the location of a tooltip when an applicable object is highlighted.

#tooltipAnchor
{
	position:absolute;
	z-index:1000000000;
	display:none;
	//transition:left 0.1s ease-out,right 0.1s ease-out,top 0.1s ease-out,bottom 0.1s ease-out;
}

The code for this selector contains a commented-out property for tooltip transition. If the game is modded to use this code, the tooltip will slide from a previous highlighted object when a different object is highlighted, rather than appearing immediately at the cursor. This was probably removed because of the weird graphical glitches it causes, such as the tooltip appearing in the wrong location before sliding to the correct slot.

#ascendContent

ascendContent is a selector that handles the contents of the ascension screen.

#ascendContent
{
	position:absolute;
	left:0px;
	top:0px;
	/*transition:transform 0.1s ease-out;*/
}

The rule code for this selector contains a commented-out property for ascension screen transition. If the game is modded to use this code, dragging the ascension screen around will have a smoother transition. This was probably removed because of the weird graphical glitches it causes, such as the background layers keeping their rough transitioning.

.inset

Hmmm...
To do:
Figure out what this unused selector does if modded-in.

inset is a selector that is used for the game's panel sections.

.inset
{
	/*box-shadow:0px 0px 12px #000 inset;*/
}

The rule code for this selector is entirely commented-out, and contains one property. This selector is called by the HTML document multiple times, but it has no effect.