Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Please read the forum rules before posting.



Check if you are posting in the correct category.



The Off Topic section is not meant for discussing Cookie Clicker.

New Cookie Particle Effect

NeoSpearBladeNeoSpearBlade Posts: 101Member ✭✭
Well, it's not just the golden cookies that was updated.

If Game.prefs.particles is active, one of its visual effects is the image smallCookies.png falling from the top of the screen. On top of that, if you bought any flavored cookie upgrades, their respective icons will fall from there as well.

Here's the code that checks this:
//Found at line 3873 var cookies=[[10,0]]; for (var i in Game.Upgrades) { var cookie=Game.Upgrades[i]; if (cookie.bought>0 && cookie.pool=='cookie') cookies.push(cookie.icon); } me.picPos=choose(cookies); pic='icons.png';

I want to know what's going on here. Can anyone explain how the code works?

Best Answers

Answers

  • NeoSpearBladeNeoSpearBlade Posts: 101Member ✭✭
    OK, that does answer my question somewhat.

    But what else is at work here? I just tried to apply this code to v.1.0466 using eval() and while it works, it spawns icons that are not BFCUs and it's chopped like crazy.

    Here, copy-paste this in the console on v.1.0466 and see the results:
    eval('Game.particleAdd='+Game.particleAdd.toString().replace("me.pic=pic||(Game.season=='fools'?'smallDollars.png':'smallCookies.png');","if (!pic){if (Game.season=='fools') pic='smallDollars.png';else{var cookies=[[10,0]];for (var i in Game.Upgrades){var cookie=Game.Upgrades[i];if (cookie.bought>0 && cookie.pool=='cookie') cookies.push(cookie.icon);}me.picPos=choose(cookies);pic='icons.png';}}me.pic=pic||'smallCookies.png';"))

    Now, what's the problem here and how do I fix it?
  • erdbeereerdbeere Posts: 3,384Member, Helpful ✭✭✭✭✭
    v.1.0466 doesn't have a way to detect BFCUs because the attribute "pool" doesn't exist. Contrary to what I would have predicted this means that the for-loop puts every bought upgrade in the array to select from instead of putting none in.
    To fix this you would have to write a new function to check if an upgrade is a flavoured cookie upgrade or not. But since there is no attribute to easily detect them in v.1.0466, this function would have to check against the names of every flavoured cookie.
  • NeoSpearBladeNeoSpearBlade Posts: 101Member ✭✭
    OK, that explains why every icon is falling instead of just the BFCUs but that doesn't explain why the images are chopped up.
  • NeoSpearBladeNeoSpearBlade Posts: 101Member ✭✭
    edited August 2016
    Whoops. By marking posts as "answered", it moves them below the first post, therefore putting the posts out of order. Maybe I shouldn't have marked this discussion as a question. ^_^'

    Anyway, I did a straight-up replacement of the code using eval() and it works.

    Here's my code as it stands:
    eval('Game.Init='+Game.Init.toString().replace("for (var i=0;i<50;i++){Game.particles[i]={x:0,y:0,xd:0,yd:0,w:64,h:64,z:0,size:1,dur:2,life:-1,r:0,pic:'smallCookies.png',picId:0};}","for (var i=0;i<50;i++){Game.particles[i]={x:0,y:0,xd:0,yd:0,w:64,h:64,z:0,size:1,dur:2,life:-1,r:0,pic:'smallCookies.png',picId:0};}")) eval('Game.Upgrade='+Game.Upgrade.toString().replace("this.hide=0;//0=show, 3=hide (1-2 : I have no idea)","this.pool='';//can be '', cookie, toggle, debug, prestige, prestigeDecor, tech, or unusedif (pool) this.pool=pool;")) eval('Game.particleAdd='+Game.particleAdd.toString().replace("me.pic=pic||(Game.season=='fools'?'smallDollars.png':'smallCookies.png');","if (!pic){if (Game.season=='fools') pic='smallDollars.png';else{var cookies=[[10,0]];for (var i in Game.Upgrades){var cookie=Game.Upgrades[i];if (cookie.bought>0 && cookie.pool=='cookie') cookies.push(cookie.icon);}me.picPos=choose(cookies);pic='icons.png';}}me.pic=pic||'smallCookies.png';")) eval('Game.particlesDraw='+Game.particlesDraw.toString().replace("Game.LeftBackground.drawImage(Pic(me.pic),(me.picId%8)*64,0,64,64,-32*me.size,-32*me.size,64*me.size,64*me.size);","var w=64;var h=64;if (me.pic=='icons.png'){w=48;h=48;Game.LeftBackground.drawImage(Pic(me.pic),me.picPos[0]*w,me.picPos[1]*h,w,h,-w/2*me.size,-h/2*me.size,w*me.size,h*me.size);}"))

    Now, the only issue remaining is that the replaced code (which goes into effect immediately after applying it in the console) is not checking my BFCUs and only 1 icon is falling, which is located at [10,0] because of this line:
    var cookies=[[10,0]]
  • erdbeereerdbeere Posts: 3,384Member, Helpful ✭✭✭✭✭
    You added the attribute "pool" to upgrades, but it stays empty for every upgrade since "pool" doesn't get assigned anything anywhere in the code. Since the attribute is empty for every upgrade, "cookie.pool=='cookie' " will always give back false. Thus no upgrade gets pushed into the array "cookies".

    Also, your first replace command doesn't change anything since you replace code with itself.
Sign In or Register to comment.