Mipha

Untitled

Oct 14th, 2018
1,372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 172.79 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn ; Enable warnings to assist with detecting common errors.
  3. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir, %A_ScriptDir% ; Ensures a consistent starting directory.
  5. savename := A_workingdir . "\backgroundpowersave.ini"
  6. DetectHiddenWindows, on
  7. #singleinstance force
  8. #MaxHotkeysPerInterval 500
  9. OnExit("savegame_onclick")
  10. ;Version. I change this value with new versions. Some features on savefiles of older versions may not be compatible so I try to make something that fixes that
  11. Currentversion := 134
  12. if(!FileExist(savename)){
  13. ;if there is no savefile. One will be made and filled with some values as to not freak out the check below that checks if values got corrupted (just in case)
  14. FileAppend,[values]`n[treasures]`n[garden]`n[options], %savename%
  15. iniwrite, 0, %savename%, values, power
  16. iniwrite, 0, %savename%, values, treasurekeys
  17. iniwrite, 0, %savename%, values, treasurechests
  18. iniwrite, 0, %savename%, values, treasureradarbought
  19. iniwrite, 0, %savename%, values, gardentiles
  20. iniwrite, 0, %savename%, values, freezertiles
  21. iniwrite, 0, %savename%, garden, almanacunlocked
  22. iniwrite, currentversion, %savename%, values, version
  23. }
  24. ;read all the values from the savefile
  25. IniRead, Power, %savename%, Values, Power
  26. IniRead, upgrades, %savename%, Upgrades, upgrades
  27. IniRead, gardentiles, %savename%, Values, gardentiles
  28. IniRead, freezertiles, %savename%, Values, freezertiles
  29. iniread, stats, %savename%, values, stats
  30. IniRead, treasurekeys, %savename%, Values, treasurekeys
  31. IniRead, treasurechests, %savename%, Values, treasurechests
  32. iniread, version, %savename%, Values, version
  33. IniRead, treasures, %savename%, Treasures, treasures
  34. IniRead, treasureradarbought, %savename%, Values, treasureradarbought
  35. IniRead, plantknowledge, %savename%, garden, plantknowledge
  36. IniRead, almanacunlocked, %savename%, garden, almanacunlocked
  37. iniread, optionchecks, %savename%, options, optionchecks
  38. if(VersionCompare("1.1.30.00", A_ahkversion) == 1 && currentversion <> version){
  39. msgbox % "Your autohotkey version is outdated. This may end up causing problems."
  40. }
  41. ;just to be sure I added a couple failsaves in case something goes wrong with the values
  42. checkvalues := ["power", "treasurekeys", "treasurechests", "treasureradarbought", "gardentiles", "freezertiles"]
  43. loop, % checkvalues.MaxIndex(){
  44. somevalue := checkvalues[A_index]
  45. if %somevalue% is not number
  46. {
  47. msgbox % "something went wrong. " . checkvalues[A_index] . " is not a number. The value contained the following: " . arraytostring(%somevalue%) . "`nif there's nothing here that means the values are empty. Sadly this means " . checkvalues[A_index] . " has been reset to 0. Please report this problem to the game maker. found on reddit by the name /u/pimhazeveld"
  48. %somevalue% := 0
  49. }
  50. }
  51. ;these V are all the upgrades available in the shop. They have an abillity, description, cost, and increase in price.
  52. ;clickpower, movepower and treasurepower should sound obvious. Ones with 'percent' after them boost the power gain by a procentual amount instead.
  53. ;price is the base price of the upgrade, priceincrease increases the price by a set amount after every purchase and priceincreasepercent increases the price by a set % after every upgrade, formula should be price := price + (priceincrease * purchased) * ((priceincreasepercent / 100)^purchased) + 1
  54. ;repeated means the amount of times the upgrade can be purchased
  55. clickingpower := {clickpower: 1, descr: "You can only gain power by clicking once every 2 seconds", name: "Clicking power", price: 5, priceincrease: 4, priceincreasepercent: 10, repeated: 100}
  56. clickingpower2 := {clickpower: 2, clickpowerpercent: 1, descr: "A more powerful way to click. Also gives a procentual buff", name: "Clicking power 2", price: 250, priceincrease: 30, priceincreasepercent: 15, repeated: 100, unlockcondition:[{name:"clickingpower", array:"purchased", amount:15, requirement:">="}]}
  57. mouseengine := {movepower: 4, movespeed: 1, descr: "Every 10 seconds you gain power based on how much the mouse was moved.", name: "Mouse engine", price: 20, priceincrease: 20, priceincreasepercent: 8, repeated: 100, unlockcondition:[{name:"clickingpower", array:"purchased", amount:3, requirement:">="}]}
  58. keyboardmotor := {keyboardkeypower:1, descr:"Every second, gain power when pressing a letter on the keyboard", name:"Keyboard motor", price:50, priceincrease:25, priceincreasepercent:10, repeated: 100, unlockcondition:[{name:"mouseengine", array:"purchased", amount:5, requirement:">="}, {name:"clickingpower", array:"purchased", amount:5, requirement:">="}]}
  59. keyboardmotor2 := {keyboardkeypower:3, keyboardkeypowerpercent:1, descr:"Everything needs a second level nowadays.", name:"Keyboard motor 2", price:500, priceincrease:100, priceincreasepercent:12, repeated: 100, unlockcondition:[{name:"keyboardmotor", array:"purchased", amount:15, requirement:">="}]}
  60. gamersfuel := {descr:"Doubles keyboard power gain when pressing one of the WASD keys", name:"Gamers fuel", repeated:1, price:7500, unlockcondition:[{name:"keyboardmotor", array:"purchased", amount:10, requirement:">="}]}
  61. mouseengine2 := {movepower: 8, movespeed: 1, movepowerpercent: 1, descr: "A more powerful mouse engine. Also gives a procentual buff.", name: "Mouse engine 2", price: 600, priceincrease: 200, priceincreasepercent: 15, repeated: 100, unlockcondition:[{name:"mouseengine", array:"purchased", amount:15, requirement:">="}]}
  62. mousemastery := {descr:"Moving the mouse now also grants power for clicking", name:"Mouse mastery", price:35000, repeated:1, unlockcondition:[{name:"clickingpower2", array:"purchased", amount:5, requirement:">="}, {name:"mouseengine2", array:"purchased", amount:5, requirement:">="}]}
  63. mouseengine3 := {descr: "Grants a lot of extra power for mouse movements based on how much the mouse was moved", name: "Mouse engine 3", price: 1000000000, unlockcondition:[{name:"mouseengine2", array:"purchased", amount:50, requirement:">="}]}
  64. ;this one ^ is neat but slightly too powerful so it isn't included in all upgrades right now. However if you want to add it to the game. All you have to do is add its name (mouseengine3) to the allupgrades array below
  65. knowledgepower := {movepowerpercent: 5, clickpowerpercent: 5, keyboardkeypowerpercent: 5, harvestpowerpercent:5, descr: "This knowledge is getting to your head. Great!", name: "Knowledge is power", price: 500000, repeated:10, priceincreasepercent:95, unlockcondition:[{name:"plantknowledge", array:"knowledge", amount:100, requirement:">="}]}
  66. knowledgepower2 := {descr:"Making power with your mind", name:"Knowledge is power too", knowledgepower:0.02, price:1234567, repeated:1, unlockcondition:[{name:"plantknowledge", array:"knowledge", amount:500, requirement:">="}, {name:"knowledgepower", array:"purchased", amount:1}]}
  67. garden := {plantchance: 1, descr: "The first level of this upgrade also unlocks the garden in the options menu.`n", name: "Garden", price: 1000, repeated: 100, priceincreasepercent: 10, unlockcondition:[{name:"clickingpower", array:"purchased", amount:12, requirement:">="}]}
  68. garden2 := {harvestpowerpercent:1, descr: "Spices up your garden by increasing power gained", name: "Garden 2", price:3000, repeated: 100, priceincrease:100, priceincreasepercent:12, unlockcondition:[{name:"power", amount:10000, requirement:">="}, {name:"garden", array:"purchased", requirement:">=", amount:15}]}
  69. hiddentreasure := {descr: "Occasionally assigns a random point on the screen as a treasure point.`n Mouse over them to gain 25 times the power of a normal mouse movement and sometimes a chest", name: "Hidden treasures", repeated: 1, price: 6250, unlockcondition:[{name:"mouseengine", array:"purchased", amount:15, requirement:">="}, {name:"keyboardmotor", array:"purchased", amount:10, requirement:">="}]}
  70. goldenkeys := {descr: "Occasionally turns a random keyboard letter key into an golden key.`nPressing it gives 25 times the power of a normal keyboard key and sometimes a treasure key.", name: "Golden keys", repeated:1, price: 6250, unlockcondition:[{name:"keyboardmotor", array:"purchased", amount:15, requirement:">="}, {name:"mouseengine", array:"purchased", amount:10, requirement:">="}]}
  71.  
  72. allupgrades := ["clickingpower", "mouseengine", "keyboardmotor", "garden", "clickingpower2", "mouseengine2", "keyboardmotor2", "garden2", "mousemastery", "gamersfuel", "hiddentreasure", "goldenkeys", "knowledgepower", "knowledgepower2"]
  73.  
  74. ;all plants available in the game are listed here except one which is created by "evolution"
  75. dusttree := {rarity: 100, knowledge: 4, descr: "Contains power. Mostly dust but some power", name:"dust tree", symbol:"Dt", background:"#888888", textcolor:"#000000", harvest:{harvestpower:90}, global:{clickpower:2}}
  76. barkwood := {rarity: 100, knowledge: 15, descr: "A small but dense tree. Its bark makes for a great power source but sadly this plant has barely any of it", name:"barkwood", symbol:"Bw", background:"#55AA88", textcolor:"#000000", harvest:{harvestpower:200}, passive:{harvestpowerpercent:400}, global:{harvestpowerpercent:1}}
  77. titantree := {rarity: 100, knowledge: 30, descr:"A tall tree with tons of bark. Its almost impossible to harvest most of the possible power from it but its influence stands tall", name:"titantree", symbol:"TT", background:"#55AA88", textcolor:"#555555", harvest:{harvestpower:1900}, global:{harvestpowerpercent:10}}
  78. tickflower := {rarity: 100, knowledge: 5, descr: "A relatively normal flower. It smells like progress", name:"tick flower", symbol:"Tf", background:"#AADD88", textcolor:"#DD4444", global:{clickpowerpercent:2}}
  79. pumpkin := {rarity:100, knowledge: 50, descr:"Spooky", name:"pumpkin", symbol:"P", background:"#FF7700", textcolor:"#00AA00", harvest:{harvestpower:5000, chest:1}}
  80. goldleaf := {rarity:100, knowledge: 50, descr:"A plant known for its great wealth and secrets.", name:"gold leaf", symbol:"Gl", background:"#55AA88", textcolor:"#FFCC55", harvest:{harvestpower:7777, goldenkey:1, knowledge:1}}
  81. lockbloom := {rarity:100, knowledge:50, descr:"A neat plant that occasionally takes on the shape of the current golden key", name:"lockbloom", symbol:"Lb", background:"#DDDD00", harvest:{harvestpower:3000}}
  82. yellowberry := {rarity: 100, knowledge: 7, descr: "Yellow berries don't do anything special but are great at creating new and exciting plants",name: "yellowberry", symbol:"Yb", background:"#55AA88", textcolor:"#FFFF00"}
  83. bluestalk := {rarity: 100, knowledge: 15, descr: "An uncommon plant containing a high density of power", name:"blue stalk", symbol:"Bs", background:"#AA9900", textcolor:"#3333FF", harvest:{harvestpower:1200}, global:{clickpower:6}}
  84. fruittree := {rarity: 100, knowledge: 8, descr: "Useful for when you're hungry. Or just want to fruit up your clicks.", name:"fruit tree", symbol:"Ft", background:"#55AA88", textcolor:"#FF4422", harvest:{harvestpower:270}, passive:{clickpower:2}, global:{clickpowerpercent:4}}
  85. yellowbulb := {rarity: 100, knowledge: 8, descr: "A rather large bulb shrowded in green leaves, ready to explode with power.", name: "yellow bulb", symbol:"YB", background:"#55AA55", textcolor:"#FFFF00", harvest:{harvestpower:350}}
  86. bluebulb := {rarity: 100, knowledge:24, descr: "This plant contains a dense pocket of power. Useful for sure", name: "blue bulb", symbol:"Bb", background:"#9999FF", textcolor:"#3333FF", harvest:{harvestpower:5000}}
  87. crystalbulb := {rarity: 100, knowledge:24, descr: "A giant berry made of pure crystallized power.", name: "crystal bulb", symbol:"Cb", background:"#225522", textcolor:"#9999FF", harvest:{harvestpower:25000}}
  88. partythyme :={rarity: 100, knowledge: 28, descr: "Happy birthda.... Wait what do you mean its not your birthday? Or is it?", name:"party thyme", symbol:"Pt", background:"#55AA88", textcolor:"#FF8888", harvest:{harvestpower:8000}, global:{clickpower:10, movepower:25, keyboardkeypower:15}}
  89. yellowstalk := {rarity: 100, knowledge: 12, descr: "Does a bit of everything", name: "yellow stalk", symbol:"Ys", textcolor:"#FFFF00", background:"#55AA88", harvest:{harvestpower:800}, global:{clickpower:2, movepower:6, movespeed:1, movepowerpercent:1, clickpowerpercent:1}}
  90. dimbloom := {rarity: 100, knowledge: 20, descr: "The mist seems to have disappeared leaving behind a purely black flower. Eldritch powers lie within. What happens if you continue breeding?", name:"dimbloom", symbol:"D", background:"#555555", textcolor:"#000000", harvest:{harvestpower:900}, global:{clickpowerpercent:7}}
  91. greenstalk := fusearrays([{descr: "This outcome should not be a surprise", name:"green stalk", symbol:"Gs", background:"#55AA88", textcolor:"#00FF00"}, yellowstalk, bluestalk])
  92. greenstalk["rarity"] := 100
  93. weaversivy := {rarity:100, knowledge:35, descr:"A moderately toxic plant affecting the life around it.", name:"weavers ivy", symbol:"Wi", background:"#22AAAA", auras:{passive:{toxic:1}}}
  94. ;popoppy := {rarity:100, knowledge:17, descr:"Pop!", name:"Popoppy", symbol:"Pp", background:"#55AA88", textcolor:"#FF6666", harvest:{harvestseeds:1}}
  95. ;agrose := {rarity: 100, knowledge:40, descr: "Violent red flower that blasts rather harmless seeds that are mostly helpful.", name:"agrose", symbol:"Ar", background:"#FF6666", harvest:{harvestseeds:6}}
  96. ;these two are currently unused due to them possibly causing bugs because they delay the harvest animation meaning you could move or inspect them during the harvest which screws stuff up.
  97. sapleaf := {rarity: 100, knowledge:35, descr: "A rich energetic sap oozes from this plant to the neighboring tiles", name:"sapleaf", symbol:"Sl", background:"#DD8844", textcolor:"#111111", auras:{global:{clickpower:1}, passive:{harvestpower:3, harvestpowerpercent:5, movepowerpercent:1}}, tileauras:{passive:{harvestpowerpercent:5}}}
  98. shockweaver := {rarity: 100, knowledge:35, descr: "An plant with electric current running through it. It ""helps"" perform better mouse movement", name:"shockweaver", symbol:"Sw", background:"#DD9900", textcolor:"#7766FF", global:{movespeed:2, movepower:5}, auras:{passive:{movepowerpercent:5}}, tileauras:{global:{movepower:3}, passive:{movepowerpercent:5}}}
  99. rootwraith := {rarity: 100, knowledge:40, descr: "This tree looks rather hollow and cursed. But a good kind of cursed", name:"rootwraith", symbol:"Rw", background:"#997700", textcolor:"#880088", harvest:{harvestpower:1900}, passive:{harvestpowerpercent:50}, auras:{passive:{harvestpower:15, harvestpowerpercent:7}}, tileauras:{passive:{harvestpower:10}, global:{harvestpowerpercent:1}}}
  100. knowleaf := {rarity: 100, knowledge:6, descr: "A plant that knows a lot about plants", name:"knowleaf", symbol:"kl", background:"#55AA88", textcolor:"#FFAAFF", harvest:{harvestpower:2, knowledge:2}}
  101. knowleafier := {rarity:100, knowledge:16, descr:"Now we're talking knowledge", name:"knowleafier", symbol:"Kl", background:"#55AA88", textcolor:"#FF55AA", harvest:{harvestpower:5, knowledge:5}}
  102. knowleafiest := {rarity:100, knowledge:36, descr:"Its bursting with knowledge. You're probably not gonna fit anything else in it", name:"knowleafiest", symbol:"KL", background:"#55AA88", textcolor:"#FF0000", harvest:{harvestpower:10, knowledge:10}}
  103. smartstalk := {rarity:100, knowledge:66, descr:"Luckily knowleaf plants arent the only ones capable of storing knowledge", name:"smartstalk", symbol:"Ss", background:"#55AA88", textcolor:"#5555FF", harvest:{knowledge:25}}
  104. brainmoss := {rarity:100, knowledge:166, descr:"The ultimate solution to your lack of knowledge (not a personal insult). You should probably stop here before your plants gain sentience", name:"brainmoss", symbol:"Bm", background:"#FFAAFF", textcolor:"#AA00AA", harvest:{knowledge:40}, auras:{passive:{knowledgepercent:100}}, tileauras:{global:{knowledgepercent:4}}}
  105. grimpetal := {rarity: 100, knowledge:16, descr: "A dark mist shrouds this flower making it kinda hard to see", name:"grimpetal", symbol:"Gp", background:"#000000", textcolor:"#FFFFFF", global:{clickpower:10}, auras:{passive:{clickpowerpercent:10}}}
  106. gripvine := {rarity: 100, knowledge:24, descr: "A vine that gets a good grip on things", name: "gripvine", symbol:"Gv", background:"#665500", textcolor:"#22FF44", global:{movepower:25, movespeed:1}}
  107. clickvine := {rarity: 100, knowledge:40, descr: "A very potent vine infused with clicking power", name:"clickvine", symbol:"Cv", background:"#665500", textcolor:"#22FF44", harvest:{harvestpower:800}, auras:{passive:{clickpowerpercent:5}}, tileauras:{passive:{clickpowerpercent:5}}}
  108. evolution := {rarity: 100, knowledge:100, descr: "A weird plant composed of a combination of darkness, potency and combination.", name: "evolution", symbol:"Ev", background:"#000000", textcolor:"#AA00AA", harvest:{harvestpower:6666}, fusion:{strength:1, amount:2, result:{rarity:100, knowledge:1, descr:"Turns out fusing plants doesn't combine the appeal of them.", name:"amalgam plant", symbol:"X"}}}
  109. ;The plants value contains an array of all plants that can appear naturally in the garden
  110.  
  111. plants := [dusttree, tickflower]
  112.  
  113. allplants := {dusttree:dusttree, barkwood:barkwood, titantree:titantree, tickflower:tickflower, pumpkin:pumpkin, goldleaf:goldleaf, lockbloom:lockbloom, yellowberry:yellowberry, bluestalk:bluestalk, bluebulb:bluebulb, crystalbulb:crystalbulb, fruittree:fruittree, yellowbulb:yellowbulb, partythyme:partythyme, yellowstalk:yellowstalk, dimbloom:dimbloom, greenstalk:greenstalk
  114. , weaversivy:weaversivy, sapleaf:sapleaf, shockweaver:shockweaver, rootwraith:rootwraith, knowleaf:knowleaf, knowleafier:knowleafier, knowleafiest:knowleafiest, smartstalk:smartstalk, brainmoss:brainmoss, grimpetal:grimpetal, gripvine:gripvine, clickvine:clickvine, evolution:evolution}
  115.  
  116. plantcombos := [{pardners:["dusttree", "tickflower"], result:"fruittree", rarity:25}, {pardners:["tickflower"], result:"yellowberry", rarity:80}, {pardners:["yellowbulb", "grimpetal"], result:"yellowstalk", rarity:25}
  117. , {pardners:["dusttree", "yellowberry"], result:"yellowbulb", rarity:45}, {pardners:["yellowstalk", "bluestalk"], result:"greenstalk", rarity:35}, {pardners:["greenstalk", "dimbloom"], result:"gripvine", rarity:40}
  118. , {pardners:["fruittree", "gripvine", "grimpetal"], result:"clickvine", rarity:35}, {pardners:["tickflower", "tickflower", "yellowberry"], result:"grimpetal", rarity:50}, {pardners:["grimpetal", "tickflower", "tickflower"], result:"dimbloom", rarity:35}
  119. , {pardners:["yellowbulb", "dimbloom"], result:"bluestalk", rarity:50}, {pardners:["greenstalk", "dimbloom", "clickvine"], result:"evolution", rarity:15}, {pardners:["dusttree", "yellowberry"], result:"knowleaf", rarity:100}
  120. , {pardners:["dusttree", "fruittree"], result:"barkwood", rarity:40}, {pardners:["dusttree", "dusttree", "dusttree", "dusttree", "dusttree", "dusttree", "dusttree"], result:"titantree", rarity:4}, {pardners:["barkwood", "barkwood", "dusttree"], result:"titantree", rarity:30}
  121. , {pardners:["tickflower", "yellowbulb", "dimbloom", "fruittree"], result:"sapleaf", rarity:45}, {pardners:["knowleaf", "dimbloom", "yellowbulb", "bluestalk"], result:"shockweaver", rarity:35}
  122. , {pardners:["dusttree", "dusttree", "barkwood", "fruittree", "titantree", "titantree"], result:"rootwraith", rarity:75}, {pardners:["fruittree", "fruittree", "yellowbulb", "rootwraith", "evolution"], result:"pumpkin", rarity:25}
  123. , {pardners:["knowleaf", "dimbloom", "rootwraith", "sapleaf", "evolution"], result:"goldleaf", rarity:25}, {pardners:["knowleaf", "evolution", "fruittree", "yellowbulb"], result:"partythyme", rarity:75}
  124. , {pardners:["knowleaf", "knowleaf", "knowleaf"], result:"knowleafier", rarity:25}, {pardners:["knowleaf", "yellowbulb", "tickflower"], result:"knowleafier", rarity:50}, {pardners:["knowleafier"], result:"knowleaf", rarity:25}]
  125. ;here are all the combos in the game. When the listed plants are next to an empty tile. The plant in the result object can appear there.
  126. ;The statement ended up being too long so I had to end it and step over to pushing additional entries individually
  127. plantcombos.push({pardners:["titantree", "yellowbulb", "bluestalk"], result:"bluebulb", rarity:30})
  128. plantcombos.push({pardners:["bluebulb", "shockweaver", "evolution"], result:"crystalbulb", rarity:10})
  129. plantcombos.push({pardners:["yellowberry", "tickflower"], result:"knowleaf", rarity:100})
  130. plantcombos.push({pardners:["knowleafier", "knowleafier", "knowleafier"], result:"knowleafiest", rarity:25})
  131. plantcombos.push({pardners:["knowleafier", "dimbloom", "grimpetal", "tickflower"], result:"knowleafiest", rarity:100})
  132. plantcombos.push({pardners:["knowleafiest"], result:"knowleafier", rarity:25})
  133. plantcombos.push({pardners:["knowleaf", "knowleafier", "knowleafiest", "evolution"], result:"smartstalk", rarity:100})
  134. plantcombos.push({pardners:["evolution", "knowleafiest", "smartstalk", "shockweaver"], result:"brainmoss", rarity:16})
  135. plantcombos.push({pardners:["shockweaver", "yellowberry", "tickflower"], result:"weaversivy", rarity:50})
  136. plantcombos.push({pardners:["goldleaf", "dimbloom"], result:"lockbloom", rarity:100})
  137.  
  138. ;garden height and size are listed here (different sizes could occur in the future)
  139. gardenmaxX := 10
  140. gardenmaxY := 10
  141.  
  142. upgrades := stringtoarray(upgrades)
  143. if (!IsObject(upgrades) || upgrades.Count() == 0 ||upgrades.Count() == ""){
  144. upgrades := {}
  145. }
  146. for a, b in allupgrades
  147. {
  148. if(!isnum(upgrades[b]["purchased"])){
  149. upgrades[b] := {purchased:0, unlocked:"locked"}
  150. if(b == "clickingpower"){
  151. upgrades[b]["purchased"] := 1
  152. }
  153. fusearrays([%b%, upgrades[b]])
  154. }
  155. for c, d in upgrades[b]{
  156. %b%[c] := d
  157. }
  158. }
  159.  
  160. plantknowledge := stringtoarray(plantknowledge)
  161. if (!IsObject(plantknowledge) || plantknowledge.Count() == 0 ||plantknowledge.Count() == ""){
  162. plantknowledge := {}
  163. }
  164. if(!plantknowledge["knowledge"]){
  165. plantknowledge["knowledge"] := 0
  166. }
  167. for a, b in allplants{
  168. if(!plantknowledge[a]){
  169. plantknowledge[a] := {}
  170. }
  171. if(!plantknowledge[a]["current"]){
  172. plantknowledge[a]["current"] := 0
  173. }
  174. if(!plantknowledge[a]["cap"]){
  175. plantknowledge[a]["cap"] := b["Knowledge"]
  176. }
  177. if(!plantknowledge[a]["seen"]){
  178. plantknowledge[a]["seen"] := 0
  179. }
  180. }
  181. ;here are all the treasures in the game. Their rarity and their name.
  182. treasurestats := {amulets:{rarity:100, name:"amulet"}, rings:{rarity:100, name:"ring"}, grails:{rarity:100, name:"grail"}, goldbars:{rarity:100, name:"gold bar"}, goldcoins:{rarity:100, name: "gold coin"}, pearls:{rarity:100, name:"pearl"}, emeralds:{rarity:100, name:"emerald"}}
  183. treasures := stringtoarray(treasures)
  184. if (!IsObject(treasures) || treasures.Count() == 0 ||treasures.Count() == ""){
  185. treasures := {}
  186. }
  187. for a, b in treasurestats
  188. {
  189. if(!treasures[a]){
  190. treasures[a] := 0
  191. }
  192. }
  193.  
  194. stats := stringtoarray(stats)
  195. if (!IsObject(stats) || stats.Count() == 0 ||stats.Count() == ""){
  196. stats := {}
  197. }
  198. ;these are all the buttons in the options menu. Optionchecks stores whether they are selected or not.
  199. alloptions := {disablemenusnapping:"Disable putting the main menu to another location when it is moved off screen. (does not work on the top of the screen)"
  200. , autoclickprevention:"Prevent clicking rewards gained when clicking really fast (in case autoclickers are used and you dont want them to affect the game)"}
  201. optionchecks := stringtoarray(optionchecks)
  202. if (!IsObject(optionchecks) || optionchecks.Count() == 0 ||optionchecks.Count() == ""){
  203. optionchecks := {}
  204. }
  205. optioncheckvalue := {}
  206. for a, b in alloptions
  207. {
  208. if(optionchecks[a] == 1){
  209. optioncheckvalue[a] := 1
  210. }
  211. else{
  212. optioncheckvalue[a] := 0
  213. }
  214. }
  215. optionchecks := optioncheckvalue
  216.  
  217. ;assign all garden tiles with their values
  218. loop, % gardenMaxX * gardenMaxY{
  219. CX := mod(A_index, gardenMaxX)
  220. CY := ceil(A_index / gardenMaxY)
  221. if(CX == 0){
  222. CX := gardenMaxX
  223. }
  224. ;check if the buttons contain plants and if you have enough garden tiles to make them visible. Tiles you dont have are invisible. Tiles you dont have but with a plant are disabled.
  225. nextto := [ CX - 1 . "A" . CY - 1, CX . "A" . CY - 1, CX + 1 . "A" . CY - 1, CX - 1 . "A" . CY, CX + 1 . "A" . CY, CX - 1 . "A" . CY + 1, CX . "A" . CY + 1, CX + 1 . "A" . CY + 1]
  226. ;this part reads the savedata for the garden and imports and plants in their correct locations.
  227. freezertile%CX%A%CY% := {nextto:nextto, temp:{}, permanent:{}, location:[CX, CY, "freezer", A_index]}
  228. iniread, savedtile, %savename%, garden, freezertile%CX%A%CY%
  229. if(savedtile <> "ERROR"){
  230. gardenvalue := objfullyclone(stringtoarray(savedtile))
  231. freezertile%CX%A%CY%["plant"] := gardenvalue["plant"]
  232. }
  233. tile%CX%A%CY% := {nextto:nextto, temp:{}, permanent:{}, location:[CX, CY, "garden", A_index]}
  234. iniread, savedtile, %savename%, garden, tile%CX%A%CY%
  235. if(savedtile <> "ERROR"){
  236. gardenvalue := objfullyclone(stringtoarray(savedtile))
  237. tile%CX%A%CY%["permanent"] := gardenvalue["permanent"]
  238. tile%CX%A%CY%["plant"] := gardenvalue["plant"]
  239. }
  240. ;this is an average tile string looks like remove the ; symbol from all text below this to see what happens and get some info out of it. (I hope)
  241. ;tile4A5 := {plant: ;if there's a plant here V. This object contains its stats
  242. ;{rarity: 100, descr: "An ordinary tree", name: "tree", harvest:{harvestpower:25}, global:{clickpower:1}}
  243. ;, nextto: ;here V are all the tiles that the current tile is next to. Does not go below 1 but can go above the current amount of tiles in case new ones get added
  244. ;[3A4, 4A4, 5A4, 3A5, 5A5, 3A6, 4A6, 5A6]
  245. ;, location: ; This contains the location of the tile itself
  246. ;[4, 5, garden, 54]
  247. ;, temp: ;here V come temporary effects from plants that buff nearby tiles
  248. ;{passive:{clickpowerpercent: 10}}
  249. ;, permanent: ;here V come the permanent buffs to a tile which are slowly affected by certain other plants
  250. ;{passive:{movepowerpercent: 20, clickpowerpercent: 10}}}
  251. ;msgbox % arraytostring(tile4A5["nextto"]) ;returns the tiles the current tile is next to
  252. ;msgbox % tile4A5["nextto"][1] ;returns the first tile that the current tile is next to. Tiles that do not exist like tiles below 0 should be ignored.
  253. ;msgbox % arraytostring(tile4A5) returns everything from garden tile 3-2
  254. }
  255.  
  256. clickwaitvalue := 2000
  257. autoclickwaitvalue := 125
  258. movewaitvalue := 10000
  259. timercheckvalue := 100
  260. treasurewaitvalue := 60000
  261. keyboardkeywaitvalue := 1000
  262. goldenkeywaitvalue := 60000
  263. autosavewaitvalue := 300000
  264. clickwait := A_tickcount + clickwaitvalue
  265. autoclickwait := A_tickcount + autoclickwaitvalue
  266. movewait := A_tickcount + movewaitvalue
  267. timercheck := A_tickcount + timercheckvalue
  268. treasurewait := A_tickcount + treasurewaitvalue
  269. keyboardkeywait := A_tickcount + keyboardkeywaitvalue
  270. goldenkeywait := A_tickcount + goldenkeywaitvalue
  271. autosavewait := A_tickcount + autosavewaitvalue
  272. logs := {}
  273. tooltips := []
  274.  
  275. starttime := A_tickcount
  276. coordmode, mouse, screen
  277. coordmode, tooltip, screen
  278.  
  279. ;dev functions
  280. instantmouseclicks := "false" ;disables the waiting time before claiming power by clicking
  281. instantmousemovement := "false" ;disables the waiting time before claiming power by moving the mouse. Even when not moving at all
  282. silentmovementlogs := "100" ;removes the "moving the mouse gave (AMOUNT) power" logs. Set this to a number to reduce the amount of logs put in (250 sets it to 1/4th of the original rate)
  283. maxgardenplantchance := "false" ;grants a 100% chance of a plant appearing on a tile when moving the mouse
  284. maxgardenpermbuffs := "false" ;Makes garden plants with permanent effects apply their max possible effect immediately
  285. silentplants := "false" ;same deal as silent movement logs but for when a garden plant appears in the garden instead. Some special plants still bypass this
  286. ignoreplantrarity := "false" ;plant rarity no longer makes it appear less
  287. noplants := "false" ;moving the mouse doesn't cause plants to appear anymore
  288. limitlessfusions := "false" ;causes plants with the fusion abillity to ignore plant weakness allowing them to fuse as many already fused plants together as you want.
  289. devbuttonenabled := "false" ;enables the dev button which has varying effects based on what I want to test right now
  290. F11reset := "false" ;reloads the game when pressing F11
  291.  
  292. loop, 26{
  293. ;binds all letter keys to a hotkey
  294. Hotkey, % "~" . Chr(A_index+96) . " up", keyboardletters
  295. }
  296.  
  297. guiwidth := A_screenwidth / 1.5
  298. guiheight := A_screenheight / 1.5
  299. gui Backgroundpower:default
  300. gui, add, edit, h0 w0
  301. gui, font, s10
  302. gui +Border -Caption +lastfound
  303. gui, color, EBAE02
  304. WinSet, TransColor, EBAE02
  305. winsettitle, Background Power
  306. selectedfeature := "nothing"
  307. updatemain()
  308. updategardeneffects()
  309. if(version <> "ERROR" && 130 > version){
  310. ;in v 1.30, hidden keys have been renamed to golden keys so this part turns all the hidden keys levels into golden key levels. Furthermore the power gained from hidden treasures has been changed to 25x the power of moving the mouse with 1 max level
  311. almanacunlocked := 0
  312. if(upgrades["hiddenkeys"]["purchased"] >= 1){
  313. if(!upgrades["goldenkeys"]){
  314. upgrades["goldenkeys"] := {}
  315. }
  316. upgrades["goldenkeys"]["purchased"] := 1
  317. upgrades.delete("hiddenkeys")
  318. }
  319. if(hiddentreasure["purchased"] > 1){
  320. hiddentreasure["purchased"] := 1
  321. }
  322. IniRead, plantcomboknowledge, %savename%, garden, plantcomboknowledge
  323. ;the plant combo part system has been overhauled and turned into the almanac rendering the old system useless. Anyone gets 2 free knowledge points per unlocked recipe. They still need to unlock the almanac though
  324. plantcomboknowledge := stringtoarray(plantcomboknowledge)
  325. loop, % plantcomboknowledge.maxIndex(){
  326. if(plantcomboknowledge[A_index] == 1){
  327. plantknowledge["knowledge"] += 2
  328. }
  329. }
  330. IniDelete, %savename%, garden, plantcomboknowledge
  331. }
  332.  
  333. if(version <> "ERROR" && 134 > version){
  334. loop, % gardenMaxX * gardenMaxY{
  335. CX := mod(A_index, gardenMaxX)
  336. CY := ceil(A_index / gardenMaxY)
  337. if(CX == 0){
  338. CX := gardenMaxX
  339. }
  340. if(tile%CX%A%CY%["plant"]["fusion"]){
  341. tile%CX%A%CY%["plant"]["fusion"] := {strength:1, amount:2, result:{rarity:100, knowledge:1, descr:"Turns out fusing plants doesn't combine the appeal of them.", name:"amalgam plant", symbol:"X"}}
  342. }
  343. }
  344. }
  345. ;not sure what this V part does but it makes moving the gui with the mouse possible so it stays
  346. OnMessage(0x0201, "WM_LBUTTONDOWN")
  347. WM_LBUTTONDOWN()
  348. {
  349. If (A_Gui){
  350. PostMessage, 0xA1, 2
  351. }
  352. }
  353. timervalue := 25
  354. SetTimer, globaltimer, %timervalue%
  355. gui, show, autosize
  356. return
  357.  
  358. ~LButton::
  359. ;this triggers whenever the left mouse button is clicked.
  360. removetooltip("shopdescription")
  361. removetooltip("gardendescription")
  362. if(A_tickcount > clickwait && !(autoclickwait > A_tickcount && optionchecks["autoclickprevention"] == 1) || instantmouseclicks == "true"){
  363. ;autoclickprevention is an option that you can turn on (default off) which prevents power gain from clicking too fast
  364. ;in case people really want to play the game but also really feel like autoclickers are cheating
  365. clickwait := A_tickcount + clickwaitvalue
  366. somemousevalue := calculateclickvalue()
  367. changepower(somemousevalue)
  368. if(!stats["clicks"]){
  369. stats["clicks"] := 0
  370. }
  371. stats["clicks"] += 1
  372. }
  373. autoclickwait := A_tickcount + autoclickwaitvalue
  374. return
  375.  
  376. keyboardletters:
  377. ;when a keyboard key is released. This part triggers.
  378. ;I made it trigger on release instead of pressing because you could trigger this multiple times by holding.
  379. if(A_tickcount > keyboardkeywait && keyboardmotor["purchased"] >= 1){
  380. somekeyboardvalue := calculatekeyboardkeyvalue(A_thishotkey)
  381. keyboardkeywait := A_tickcount + keyboardkeywaitvalue
  382. changepower(somekeyboardvalue)
  383. if(!stats["keyboardletterspressed"]){
  384. stats["keyboardletterspressed"] := 0
  385. }
  386. stats["keyboardletterspressed"] += 1
  387. ;pressing keys can sometimes create hidden treasures and rarely spawns a golden key
  388. random, keyboardrngesus, 1, 100
  389. if(keyboardrngesus > 95 && hiddentreasure["purchased"] >= 1){
  390. treasureavailable := randompointonscreen()
  391. }
  392. random, keyboardrngesus, 1, 100
  393. if(keyboardrngesus > 98 && goldenkeys["purchased"] >= 1){
  394. keyavailable := randomletter()
  395. }
  396. }
  397. if(A_thishotkey == "~" . keyavailable . " up"){
  398. ;if the hidden key is pressed. Do this
  399. somekeyboardvalue := calculatekeyboardkeyvalue(A_thishotkey) * 25
  400. goldenkeywait := A_tickcount + goldenkeywaitvalue
  401. addlog("collecting the golden key (" . keyavailable . ") gave " . somekeyboardvalue . " power", "power")
  402. addlog("collecting the golden key (" . keyavailable . ") gave " . somekeyboardvalue . " power", "treasure")
  403. keyavailable := ""
  404. changepower(somekeyboardvalue)
  405. somekeyboardvalue := getkeys()
  406. if(!stats["goldenkeyspressed"]){
  407. stats["goldenkeyspressed"] := 0
  408. }
  409. stats["goldenkeyspressed"] += 1
  410. if(somekeyboardvalue >= 1){
  411. ;when a treasure key is obtained. Do this
  412. treasurekeys += somekeyboardvalue
  413. chesttext := "collecting a golden key gave " . somekeyboardvalue . " treasure Key"
  414. if(somekeyboardvalue >= 2){
  415. chesttext .= "s"
  416. }
  417. addlog(chesttext, "treasure")
  418. if(!stats["goldenkeysfound"]){
  419. stats["goldenkeysfound"] := 0
  420. }
  421. stats["goldenkeysfound"] += somekeyboardvalue
  422. }
  423. updatemain()
  424. }
  425. return
  426.  
  427. globaltimer:
  428. if(A_tickcount > timercheck){
  429. ;update the power on the menu
  430. timercheck := A_tickcount + timercheckvalue
  431. power := round(power)
  432. shownpower := % toscientific(power, 3)
  433. mainshowpower.InnerHtml := "Power: " . shownpower
  434. ;fixwindowpos moves the window if its offscreen
  435. if(optionchecks["disablemenusnapping"] == 0){
  436. fixwindowpos("Background Power")
  437. }
  438. }
  439. if(A_tickcount > autosavewait){
  440. ;save the game
  441. savegame_onclick()
  442. }
  443. ;get where the mouse is currently at on screen
  444. Coordmode, Mouse, Screen
  445. MouseGetPos, MouseX, MouseY
  446.  
  447. ;this part handles moving the mouse dot in the radar on the hidden treasure gui
  448. if(selectedfeature == "treasure" && treasureradarbought == 1){
  449. treasureradardot.style.left := (MouseX / (A_screenwidth / 100)) . "%"
  450. treasureradardot.style.top := (MouseY / (A_screenheight / 100)) . "%"
  451. if(treasureavailable && 100 >= abs(treasureavailable[1] - MouseX) && 100 >= abs(treasureavailable[2] - MouseY)){
  452. treasureradardot.innerhtml := "O"
  453. }
  454. else if(treasureavailable && 200 >= abs(treasureavailable[1] - MouseX) && 200 >= abs(treasureavailable[2] - MouseY)){
  455. treasureradardot.innerhtml := "0"
  456. }
  457. else if(treasureavailable && 400 >= abs(treasureavailable[1] - MouseX) && 400 >= abs(treasureavailable[2] - MouseY)){
  458. treasureradardot.innerhtml := "o"
  459. }
  460. else{
  461. treasureradardot.innerhtml := "."
  462. }
  463. }
  464. if(treasureavailable && 30 >= abs(treasureavailable[1] - MouseX) && 30 >= abs(treasureavailable[2] - MouseY)){
  465. ;check if the mouse is near a hidden treasure and if so. Collect it
  466. treasurewait := A_tickcount + treasurewaitvalue
  467. somevalue := calculatemovevalue() * 25
  468. changepower(somevalue)
  469. addlog("collecting a hidden treasure gave " . somevalue . " power", "power")
  470. addlog("collecting a hidden treasure gave " . somevalue . " power", "treasure")
  471. if(!stats["hiddentreasuresfound"]){
  472. stats["hiddentreasuresfound"] := 0
  473. }
  474. somevalue := getchests()
  475. treasurechests += somevalue
  476. stats["hiddentreasuresfound"] += 1
  477. if(somevalue >= 1){
  478. ;check if a treasure chest has been obtained
  479. if(!stats["treasurechestsfound"]){
  480. stats["treasurechestsfound"] := 0
  481. }
  482. stats["treasurechestsfound"] += somevalue
  483. chesttext := "collecting a hidden treasure gave " . somevalue . " chest"
  484. if(somevalue >= 2){
  485. chesttext .= "s"
  486. }
  487. addlog(chesttext, "treasure")
  488. }
  489. treasureavailable := ""
  490. updatemain()
  491. }
  492. moveX := (MouseX - MouseStartX)
  493. moveY := (MouseY - MouseStartY)
  494. ;subract the place where the mouse was last with where the mouse is now.
  495. MouseStartX := MouseX
  496. MouseStartY := MouseY
  497. ;the current place is stored for the next time.
  498. ;moving the mouse increases this V value. When it reaches a certain treshhold and after enough time passes. Power is gained for moving the mouse.
  499. movetrack += round((abs(moveX) + abs(moveY)) * calculatemovespeed())
  500. if((movetrack >= 15000 && A_tickcount >= movewait) || instantmousemovement == "true"){
  501. ;movement is more effective the more the mouse was moved
  502. min("IF YOU'RE reading this as an error message. That means your autohotkey version is outdated. Please update it to play the game.")
  503. moveeffectiveness := min(1 + (movetrack / 300000), 2)
  504. somevalue := floor(calculatemovevalue() * moveeffectiveness)
  505. if(mouseengine3["purchased"] >= 1){
  506. somevalue += movetrack
  507. }
  508. movetrack = 0
  509. changepower(somevalue)
  510. random, globalrngesus, 1, 1000
  511. if(silentmovementlogs == "false" || silentmovementlogs >= globalrngesus){
  512. addlog("moving the mouse gave " . somevalue . " power", "power")
  513. }
  514. if(globalrngesus > 900){
  515. keyavailable := randomletter()
  516. }
  517. random, globalrngesus, 1, 1000
  518. if(globalrngesus > 975 && hiddentreasure["purchased"] >= 1){
  519. treasureavailable := randompointonscreen()
  520. }
  521. if(!stats["mousemoves"]){
  522. stats["mousemoves"] := 0
  523. }
  524. stats["mousemoves"] += 1
  525. movewait := A_tickcount + movewaitvalue
  526. ;calculate the chance of garden plants appearing. Its 3% by default + up to 3 from upgrades + up to 3 if the mouse was moved a lot.
  527. plantchance := 3
  528. gardenplantchance := 0
  529. for globalentry, globalcontent in upgrades{
  530. if(%globalentry%["plantchance"]){
  531. gardenplantchance += %globalentry%["plantchance"] * globalcontent["purchased"]
  532. }
  533. }
  534. plantchance += (gardenplantchance * plantchance / 100) + ((moveeffectiveness - 1) * plantchance)
  535. if(noplants == "false"){
  536. creategardenplant(plantchance)
  537. }
  538. ;gardentick handles permanent effects for now. I plan on eventually adding a plant growth feature that uses this
  539. gardentick()
  540. }
  541. ;this part here handles the tooltips added by addtooltip() and puts them below eachother and next to your mouse on every call.
  542. totaltooltips := ""
  543. loop, % tooltips.MaxIndex(){
  544. if(0 >= tooltips[A_index]["timer"]){
  545. tooltips.remove(A_index)
  546. }
  547. totaltooltips .= tooltips[A_index]["content"] . "`n"
  548. tooltips[A_index]["timer"] -= timervalue / 100
  549. }
  550. ;This function makes tooltips smoother and prevents flickering
  551. ToolTipFM(totaltooltips, 5)
  552. return
  553.  
  554. updatemain(){
  555. global
  556. critical, on
  557. gui, backgroundpower:default
  558. guicontrolget, mainguiexist, hwnd, maindoc
  559. if(!mainguiexist){
  560. ;create the main menu used for displaying all features
  561. mainmenuhighW := guiwidth * 0.1
  562. mainmenuhighH := guiheight
  563. Gui, Add, ActiveX, x0 y0 w%mainmenuhighW% h%mainmenuhighH% vmaindoc, HtmlFile
  564. guicontrolget, maindoc, pos
  565. mainmenuhighX := maindocW
  566. Gui, Add, ActiveX, x%mainmenuhighX% y0 w%mainmenuhighW% h%mainmenuhighH% vmaindoc2, HtmlFile
  567. mainhtmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; width:100%; height: 100%; font-family: 'Verdana'; font-size:" . guiwidth / 100 . "px;} body {background:#666666; width:100%; height: 100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  568. mainhtmlpart1 .= "button{font-size:" . guiwidth / 100 . "px;}"
  569. mainhtmlpart1 .= ".power{width:100%; height: 30px; color: #000000;}"
  570. mainhtmlpart1 .= ".shop{width:100%; height: 30px; background: #AAAAAA; color: #000000;}"
  571. mainhtmlpart1 .= ".garden{width:100%; height: 30px; background: #AAAAAA; color: #000000;}"
  572. mainhtmlpart1 .= ".hiddentreasure{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  573. mainhtmlpart1 .= ".logs{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  574. mainhtmlpart1 .= ".stats{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  575. mainhtmlpart1 .= ".options{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  576. mainhtmlpart1 .= ".help{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  577. mainhtmlpart1 .= ".devbutton{width:100%; height: 30px; left:0px; background: #000000; color: #DDDDDD;}"
  578. mainhtmlpart1 .= ".save{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  579. mainhtmlpart1 .= ".exit{width:100%; height: 30px; left:0px; background: #222222; color: #FFFFFF;}"
  580. mainhtmlpart2 := "</style></head><body><table id='mainmenutable'>"
  581. mainhtmlpart2 .= "<tr><td><p class='power' id='showpower'>Power: " . power . "</button></td></tr>"
  582. mainhtmlpart2 .= "<tr><td><button class='shop' id='shop' mode='shop'>Shop</button></td></tr>"
  583. mainhtmlpart2 .= "<tr id='gardentable' style=""display:none;""><td><button class='garden' id='garden' mode='garden' style=""display:none;"">Garden</button></td></tr>"
  584. mainhtmlpart2 .= "<tr id='treasuretable' style=""display:none;""><td><button class='hiddentreasure' id='treasure' mode='treasure' style=""display:none;"">Hidden treasures</button></td></tr>"
  585. mainhtmlpart2 .= "<tr><td><button class='logs' id='logs' mode='logs'>Logs</button></td></tr>"
  586. mainhtmlpart2 .= "<tr><td><button class='stats' id='stats' mode='stats'>Stats</button></td></tr>"
  587. mainhtmlpart2 .= "<tr><td><button class='options' id='options' mode='options'>Options</button></td></tr>"
  588. mainhtmlpart2 .= "<tr><td><button class='help' id='help' mode='help'>Help</button></td></tr>"
  589. mainhtmlpart2 .= "<tr><td><button class='save' id='save'>Save</button></td></tr>"
  590. mainhtmlpart2 .= "<tr id='devtable' style=""display:none;""><td><button class='devbutton' id='devbutton' style=""display:none;"">Devbutton</button></td></tr>"
  591. mainhtmlpart2 .= "<tr><td><button class='exit' id='exit'>Exit</button></td></tr>"
  592. mainhtmlpart2 .= "</table></body></html>"
  593. mainhtml := mainhtmlpart1 . mainhtmlpart2
  594. maindoc.open()
  595. maindoc.write(mainhtml)
  596. maindoc.close()
  597.  
  598. mainshowpower := maindoc.getElementById("showpower")
  599. mainshopbutton := maindoc.getElementById("shop")
  600. maingardenbutton := maindoc.getElementById("garden")
  601. maingardentable := maindoc.getElementById("gardentable")
  602. maintreasurebutton := maindoc.getElementById("treasure")
  603. maintreasuretable := maindoc.getElementById("treasuretable")
  604. mainlogsbutton := maindoc.getElementById("logs")
  605. mainstatsbutton := maindoc.getElementById("stats")
  606. mainoptionsbutton := maindoc.getElementById("options")
  607. mainhelpbutton := maindoc.getElementById("help")
  608. mainsavebutton := maindoc.getElementById("save")
  609. maindevbutton := maindoc.getElementById("devbutton")
  610. maindevtable := maindoc.getElementById("devtable")
  611. mainexitbutton := maindoc.getElementById("exit")
  612. ComObjConnect(mainshopbutton, "selectfeature_")
  613. ComObjConnect(maingardenbutton, "selectfeature_")
  614. ComObjConnect(maintreasurebutton, "selectfeature_")
  615. ComObjConnect(mainlogsbutton, "selectfeature_")
  616. ComObjConnect(mainstatsbutton, "selectfeature_")
  617. ComObjConnect(mainoptionsbutton, "selectfeature_")
  618. ComObjConnect(mainhelpbutton, "selectfeature_")
  619. ComObjConnect(mainsavebutton, "savegame_")
  620. ComObjConnect(maindevbutton, "devbutton_")
  621. ComObjConnect(mainexitbutton, "exit_")
  622. }
  623. if(devbuttonenabled == "true"){
  624. maindevbutton.style.display := "block"
  625. maindevtable.style.display := "block"
  626. }
  627. if(maintreasurebutton.style.display == "none" && hiddentreasure["purchased"] >= 1){
  628. maintreasurebutton.style.display := "block"
  629. maintreasuretable.style.display := "block"
  630. }
  631. else if(0 >= hiddentreasure["purchased"]){
  632. maintreasurebutton.style.display := "none"
  633. maintreasuretable.style.display := "none"
  634. }
  635. if(maingardenbutton.style.display == "none" && garden["purchased"] >= 1){
  636. maingardenbutton.style.display := "block"
  637. maingardentable.style.display := "block"
  638. }
  639. else if(0 >= garden["purchased"]){
  640. maingardenbutton.style.display := "none"
  641. maingardentable.style.display := "none"
  642. }
  643. if(selectedfeature){
  644. mainbuttoncheck := maindoc.getElementById(selectedfeature)
  645. mainbuttoncheck.disable := "disabled"
  646. mainbuttoncheck.value := mainbuttoncheck.value
  647. }
  648. guicontrolget, mainguiexist, hwnd, featuredoc
  649. if(!mainguiexist){
  650. guicontrolget, maindoc, pos
  651. guicontrolget, maindoc2, pos
  652. mainmenuhighW := guiwidth - maindocW - maindoc2W
  653. mainmenuhighH := guiheight
  654. mainmenuhighX := maindocW + maindoc2W
  655. Gui, Add, ActiveX, w%mainmenuhighW% h%mainmenuhighH% x%mainmenuhighX% y0 vfeaturedoc, HTMLFile
  656. }
  657. ;pressing a button on the sidebar changes the selectedfeature value. The displayed info changes depending on the currently pressed button
  658. if(selectedfeature == "nothing"){
  659. if(!storedselectedfeature <> selectedfeature){
  660. storedselectedfeature := selectedfeature
  661. htmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; border-style: none; height: 100%;} body {background:#888888; height: 100%;}"
  662. htmlpart2 := "</style></head><body><table>"
  663. htmlpart2 .= "</table></body></html>"
  664. html := htmlpart1 . htmlpart2
  665.  
  666. html2 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; width:100%; height: 100%;} body {background:#777777; width:100%; height: 100%;}</style></head></html>"
  667. }
  668. featuredoc.open()
  669. featuredoc.write(html)
  670. featuredoc.close()
  671. maindoc2.open()
  672. maindoc2.write(html2)
  673. maindoc2.close()
  674. }
  675. if(selectedfeature == "shop"){
  676. if(storedselectedfeature <> selectedfeature){
  677. storedselectedfeature := selectedfeature
  678. htmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:auto; height: 100%;} body {background:#888888; height: 100%; font-family:verdana; font-size:" . guiwidth / 100 . "px;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  679. htmlpart1 .= "button{font-size:" . guiwidth / 100 . "px;}"
  680. htmlpart1 .= ".scrollable {overflow-y: auto;}"
  681. htmlpart2 := "</style></head><body><table class='scrollable'>"
  682. loop, % allupgrades.MaxIndex(){
  683. shopentry := allupgrades[A_index]
  684. htmlpart1 .= "." . shopentry . "{width: 100%; height: 30px; background: #AAAAAA; color: #000000;}"
  685. htmlpart2 .= "<tr id='" . shopentry . "table'><td style=""width:10%;""><button class='" . shopentry . "' id='" . shopentry . "' disable=''> " . %shopentry%["name"] . "</button></td><td><p id='" . shopentry . "price'>Price: " . round(calculateshopprice(%shopentry%)) . "</p></td></tr>"
  686. }
  687. htmlpart2 .= "</table></div></body></html>"
  688. html := htmlpart1 . htmlpart2
  689.  
  690. html2part1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; height: 100%;} body {background:#777777; height: 100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  691. html2part1 .= "button{font-size:" . guiwidth / 100 . "px;}"
  692. html2part1 .= ".inspect{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  693. html2part1 .= ".purchase{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  694. html2part2 := "</style></head><body><table style='float:left;'>"
  695. html2part2 .= "<tr><td><button class='inspect' id='inspect' mode='inspect'>Inspect mode</button></td></tr>"
  696. html2part2 .= "<tr><td><button class='purchase' id='purchase' mode='purchase'>Purchase Mode</button></td></tr>"
  697. html2part2 .= "</table></div></body></html>"
  698. html2 := html2part1 . html2part2
  699. featuredoc.open()
  700. featuredoc.write(html)
  701. featuredoc.close()
  702.  
  703. maindoc2.open()
  704. maindoc2.write(html2)
  705. maindoc2.close()
  706. shoppurchasebutton := maindoc2.getElementById("purchase")
  707. shopinspectbutton := maindoc2.getElementById("inspect")
  708. ComObjConnect(shoppurchasebutton, "shopmode_")
  709. ComObjConnect(shopinspectbutton, "shopmode_")
  710. for, mainentry, maincontent in allupgrades{
  711. if(%maincontent%){
  712. shopupgrade%maincontent%button := featuredoc.getElementById(maincontent)
  713. ComObjConnect(shopupgrade%maincontent%button, "shoppurchase_")
  714. }
  715. }
  716. }
  717. for shopentry, shopcontent in allupgrades{
  718. ;example of an upgrade with an unlock requirement: clickingpower2 := {unlockcondition:[{name:"clickingpower", array:"purchased", amount:10, requirement:">="}, {name:"power", amount:5000, requirement:">="}]}
  719. ;this part hides any upgrade that does not have their unlock requirement met and permanently shows them if they are met.
  720. unlockcheck := "unlocked"
  721. if(%shopcontent%["unlocked"] <> "unlocked"){
  722. ;this part checks for buttons with an unlock requirement and checks if that requirement has been met.
  723. loop % %shopcontent%["unlockcondition"].Count(){
  724. unlockcondition := %shopcontent%["unlockcondition"]
  725. shopvalue := unlockcondition[A_index]["name"]
  726. if(unlockcondition[A_index]["array"]){
  727. shopvalue := %shopvalue%[unlockcondition[A_index]["array"]]
  728. }
  729. else{
  730. shopvalue := %shopvalue%
  731. }
  732. if(unlockcondition[A_index]["requirement"] == "<"){
  733. if(shopvalue >= unlockcondition[A_index]["amount"]){
  734. unlockcheck := "locked"
  735. }
  736. }
  737. if(unlockcondition[A_index]["requirement"] == "<="){
  738. if(shopvalue > unlockcondition[A_index]["amount"]){
  739. unlockcheck := "locked"
  740. }
  741. }
  742. if(unlockcondition[A_index]["requirement"] == "=="){
  743. if(shopvalue <> unlockcondition[A_index]["amount"]){
  744. unlockcheck := "locked"
  745. }
  746. }
  747. if(unlockcondition[A_index]["requirement"] == ">="){
  748. if(unlockcondition[A_index]["amount"] > shopvalue){
  749. unlockcheck := "locked"
  750. }
  751. }
  752. if(unlockcondition[A_index]["requirement"] == ">"){
  753. if(unlockcondition[A_index]["amount"] >= shopvalue){
  754. unlockcheck := "locked"
  755. }
  756. }
  757. }
  758. if(unlockcheck == "unlocked"){
  759. %shopcontent%["unlocked"] := "unlocked"
  760. }
  761. }
  762. shopupgradetable := featuredoc.getElementById(shopcontent . "table")
  763. shopupgradebutton := featuredoc.getElementById(shopcontent)
  764. shopupgradeprice := featuredoc.getElementById(shopcontent . "price")
  765. ;disable does not mean the button is disabled. disabled with an d at the end means that its disabled. Disable is something I added myself which only changes the button color.
  766. if(shopupgradebutton.disable <> "disabled" && (%shopcontent%["repeated"] && %shopcontent%["purchased"] >= %shopcontent%["repeated"]) || !%shopcontent%["repeated"] && %shopcontent%["purchased"] > 0){
  767. shopupgradebutton.disable := "disabled"
  768. }
  769. else if(shopupgradebutton.disable == "disabled" && %shopcontent%["repeated"] > %shopcontent%["purchased"]){
  770. shopupgradebutton.disable := ""
  771. }
  772. if(%shopcontent%["unlocked"] <> "unlocked"){
  773. shopupgradetable.style.display := "none"
  774. }
  775. else{
  776. shopupgradetable.style.display := "block"
  777. }
  778. ;change the button value to itself to update the visibillity/color etc
  779. shopupgradebutton.value := %shopcontent%["name"]
  780. if(shopupgradebutton.disable <> "disabled"){
  781. shopupgradeprice.innerhtml := "Price: " . round(calculateshopprice(%shopcontent%))
  782. }
  783. else{
  784. shopupgradeprice.innerhtml := "Max level"
  785. }
  786. }
  787. if(shopmode){
  788. mainbuttoncheck := maindoc2.getElementById(shopmode)
  789. mainbuttoncheck.disable := "disabled"
  790. mainbuttoncheck.value := mainbuttoncheck.value
  791. }
  792. }
  793. if(selectedfeature == "garden" || selectedfeature == "freezer"){
  794. if(storedselectedfeature <> selectedfeature || storedgardentiles <> gardentiles || storedfreezertiles <> freezertiles){
  795. storedselectedfeature := selectedfeature
  796. storedgardentiles := gardentiles
  797. storedfreezertiles := freezertiles
  798. htmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow: hidden; height:100%; width:100%;} body {background:#888888; height:100%; width:100%;} [disable=disabled]{background: #666666 !important;}"
  799. htmlpart1 .= "button{font-size:" . guiwidth / 100 . "px;}"
  800. htmlpart1 .= ".gardentable {width:100%; height:100%; left:0px; top:0px; border-style:none; position:absolute;}"
  801. htmlpart2 := "</style></head><body><table class='gardentable'>"
  802. guicontrolget, featuredoc, pos
  803. loop, % gardenmaxX * gardenmaxY{
  804. ;this loop creates the buttons for every garden and freezer tile
  805. CX := mod(A_index, gardenmaxX)
  806. CY := ceil(A_index / gardenmaxY)
  807. if(CX == 1){
  808. htmlpart2 .= "<tr>"
  809. }
  810. if(CX == 0){
  811. CX := gardenmaxX
  812. }
  813. ;IMPORTANT buttons here are set at a specific pixel length instead of % length. For some reason pressing any button with % width shrinks it before it turns normal again (only the first one is unaffected)
  814. ;to see this for yourself. Replace the following
  815. ;width: " . round(featuredocW / 100 * 9, 1) . "px; >>>> width: " . round((100 / gardenmaxX) * 0.9) . "px;
  816. ;height: " . round(featuredocH / 100 * 9, 1) . "px; >>>> height: " . round((100 / gardenmaxY) * 0.9) . "px;
  817. if(selectedfeature == "garden"){
  818. htmlpart1 .= ".Tile" . CX . "A" . CY . " {left:" . round((CX - 0.95) * (100 / gardenmaxX), 1) . "%; width: " . round(featuredocW / 100 * 9, 1) . "px; top:" . round((CY - 0.95) * (100 / gardenmaxY), 1) . "%; height: " . round(featuredocH / 100 * 9, 1) . "px; font-size:" . guiwidth / 40 . "px; background: #55DD88; color: #000000; position: absolute;}"
  819. htmlpart2 .= "<td><button class='Tile" . CX . "A" . CY . "' id='tile" . CX . "A" . CY . "'></button></td>"
  820. }
  821. else if(selectedfeature == "freezer"){
  822. htmlpart1 .= ".Freezertile" . CX . "A" . CY . " {left:" . round((CX - 0.95) * (100 / gardenmaxX), 1) . "%; width: " . round(featuredocW / 100 * 9, 1) . "px; top:" . round((CY - 0.95) * (100 / gardenmaxY), 1) . "%; height: " . round(featuredocH / 100 * 9, 1) . "px; font-size:" . guiwidth / 40 . "px; background: #AADDDD; color: #000000; position: absolute;}"
  823. htmlpart2 .= "<td><button class='Freezertile" . CX . "A" . CY . "' id='freezertile" . CX . "A" . CY . "' style=''></button></td>"
  824. }
  825. if(CX == gardenmaxX){
  826. htmlpart2 .= "</tr>"
  827. }
  828. }
  829. htmlpart2 .= "</table>"
  830. html := htmlpart1 . htmlpart2
  831.  
  832. html2part1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; border-style:none; border-color:#FFFFFF; height: 100%; width: 100%;} body {background:#777777; height: 100%; width: 100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  833. html2part1 .= "button{word-break: break-word; font-size:" . guiwidth / 100 . "px;}"
  834. html2part1 .= ".inspect{width:100%; left:0px; height: 30px; background: #AAAAAA; color: #000000;}"
  835. html2part1 .= ".harvest{width:100%; left:0px; height: 30px; background: #AAAAAA; color: #000000;}"
  836. html2part1 .= ".protect{width:100%; left:0px; height: 30px; background: #AAAAAA; color: #000000;}"
  837. html2part1 .= ".swap{width:100%; left:0px; height: 30px; background: #AAAAAA; color: #000000;}"
  838. html2part1 .= ".swapgarden{width:100%; left:0px; height: 30px; color: #000000;}"
  839. html2part1 .= ".almanac{width:100%; left:0px; height: 30px;, background: #55DD88; color: #000000;}"
  840. html2part1 .= ".purchasetile{width:100%; left:0px; height: 64px; background: #AAAAAA; color: #000000;}"
  841. html2part2 := "</style></head><body><table style='float:left;'>"
  842. html2part2 .= "<tr><td><button class='inspect' id='inspect' mode='inspect'>Inspect mode</button></td></tr>"
  843. html2part2 .= "<tr><td><button class='harvest' id='harvest' mode='harvest'>Harvest mode</button></td></tr>"
  844. html2part2 .= "<tr><td><button class='swap' id='swap' mode='swap'>Swap mode</button></td></tr>"
  845. html2part2 .= "<tr><td><button class='protect' id='protect' mode='protect'>Protect mode</button></td></tr>"
  846. if(selectedfeature == "garden"){
  847. html2part2 .= "<tr><td><button class='swapgarden' id='swapgarden' mode='freezer' style=""background: #AADDDD;"">Freezer</button></td></tr>"
  848. html2part2 .= "<tr id='almanactable' style=""display:none;""><td><button class='almanac' id='almanac' mode='almanac'>Almanac</button></td></tr>"
  849. html2part2 .= "<tr><td><button class='purchasetile' id='purchasetile' topurchase='gardentile'>Purchase garden tile</br>costs " . tileprice("garden") . "</button></td></tr>"
  850. }
  851. if(selectedfeature == "freezer"){
  852. html2part2 .= "<tr><td><button class='swapgarden' id='swapgarden' mode='garden' style=""background: #55DD88;"">Garden</button></td></tr>"
  853. html2part2 .= "<tr id='almanactable' style=""display:none;""><td><button class='almanac' id='almanac' mode='almanac'>Almanac</button></td></tr>"
  854. html2part2 .= "<tr><td><button class='purchasetile' id='purchasetile' topurchase='freezertile'>Purchase freezer tile</br>costs " . tileprice("freezer") . "</button></td></tr>"
  855. }
  856. html2part2 .= "</table></body></html>"
  857. html2 := html2part1 . html2part2
  858. featuredoc.open()
  859. featuredoc.write(html)
  860. featuredoc.close()
  861.  
  862. maindoc2.open()
  863. maindoc2.write(html2)
  864. maindoc2.close()
  865. if(gardenmode){
  866. mainbuttoncheck := maindoc2.getElementById(gardenmode)
  867. mainbuttoncheck.disable := "disabled"
  868. mainbuttoncheck.value := mainbuttoncheck.value
  869. }
  870. gardeninspectbutton := maindoc2.getElementById("inspect")
  871. gardenharvestbutton := maindoc2.getElementById("harvest")
  872. gardenprotectbutton := maindoc2.getElementById("protect")
  873. gardenswapbutton := maindoc2.getElementById("swap")
  874. gardenswapgardenbutton := maindoc2.getElementById("swapgarden")
  875. gardenalmanacbutton := maindoc2.getElementById("almanac")
  876. gardenalmanactable := maindoc2.getElementById("almanactable")
  877. gardenpurchasetilebutton := maindoc2.getElementById("purchasetile")
  878. ComObjConnect(gardeninspectbutton, "gardenmode_")
  879. ComObjConnect(gardenharvestbutton, "gardenmode_")
  880. ComObjConnect(gardenswapbutton, "gardenmode_")
  881. ComObjConnect(gardenprotectbutton, "gardenmode_")
  882. ComObjConnect(gardenswapgardenbutton, "selectfeature_")
  883. ComObjConnect(gardenpurchasetilebutton, "purchasetile_")
  884. ComObjConnect(gardenalmanacbutton, "selectfeature_")
  885. ComObjConnect(gardenswapgardenbutton, "selectfeature_")
  886.  
  887. loop, % gardenmaxX * gardenmaxY{
  888. CX := mod(A_index, gardenMaxX)
  889. CY := ceil(A_index / gardenMaxY)
  890. if(CX == 0){
  891. CX := gardenMaxX
  892. }
  893. if(selectedfeature == "garden"){
  894. gardentile%CX%A%CY%button := featuredoc.getElementById("tile" . CX . "A" . CY)
  895. ComObjConnect(gardentile%CX%A%CY%button, "garden_")
  896. }
  897. else if(selectedfeature == "freezer"){
  898. freezertile%CX%A%CY%button := featuredoc.getElementById("freezertile" . CX . "A" . CY)
  899. ComObjConnect(freezertile%CX%A%CY%button, "garden_")
  900. }
  901. }
  902. if(selectedfeature == "garden" && gardentiles >= GardenmaxX * GardenmaxY){
  903. gardenpurchasetilebutton.disable := "disabled"
  904. gardenpurchasetilebutton.value := gardentiles . " Tiles!"
  905. }
  906. else if(selectedfeature == "garden"){
  907. gardenpurchasetilebutton.disable := ""
  908. gardenpurchasetilebutton.value := "Purchase garden tile</br>costs " . tileprice("garden")
  909. }
  910. else if(selectedfeature == "freezer" && freezertiles >= GardenmaxX * GardenmaxY){
  911. gardenpurchasetilebutton.disable := "disabled"
  912. gardenpurchasetilebutton.value := freezertiles . " Tiles!"
  913. }
  914. else if(selectedfeature == "garden"){
  915. gardenpurchasetilebutton.disable := ""
  916. gardenpurchasetilebutton.value := "Purchase freezer tile</br>costs " . tileprice("freezer")
  917. }
  918. loop, % gardenMaxX * gardenMaxY{
  919. CX := mod(A_index, gardenMaxX)
  920. CY := ceil(A_index / gardenMaxY)
  921. if(CX == 0){
  922. CX := gardenMaxX
  923. }
  924. if(selectedfeature == "garden"){
  925. gardenbuttoncheck := featuredoc.getElementById("tile" . CX . "A" . CY)
  926. ;this part hides garden tiles that you havent unlocked yet or if there's somehow a plant on it. It disables them instead
  927. if(tile%CX%A%CY%["plant"]["name"] && A_index > gardentiles){
  928. gardenbuttoncheck.disable := "disabled"
  929. }
  930. else if(A_index > gardentiles){
  931. gardenbuttoncheck.style.display := "none"
  932. }
  933. else{
  934. gardenbuttoncheck.style.display := "block"
  935. gardenbuttoncheck.disable := ""
  936. }
  937. }
  938. if(selectedfeature == "freezer"){
  939. gardenbuttoncheck := featuredoc.getElementById("freezertile" . CX . "A" . CY)
  940. if(freezertile%CX%A%CY%["plant"]["name"] && A_index > freezertiles){
  941. gardenbuttoncheck.disable := "disabled"
  942. gardenbuttoncheck.style.display := "block"
  943. }
  944. else if(A_index > freezertiles){
  945. gardenbuttoncheck.style.display := "none"
  946. }
  947. else{
  948. gardenbuttoncheck.style.display := "block"
  949. gardenbuttoncheck.disable := ""
  950. }
  951. }
  952. }
  953. }
  954. if(gardenalmanactable.style.display == "none" && almanacunlocked){
  955. gardenalmanactable.style.display := "block"
  956. }
  957. loop, % gardenmaxX * GardenmaxY{
  958. CX := mod(A_index, 10)
  959. CY := ceil(A_index / 10)
  960. if(CX == 0){
  961. CX = 10
  962. }
  963. ;update any garden tiles that don't have their current name as the same one displayed on the button
  964. if(selectedfeature == "garden"){
  965. storedplantname := tile%CX%A%CY%["plant"]["name"]
  966. if(storedplantname == "lockbloom" && !keyavailable){
  967. tile%CX%A%CY%["plant"]["symbol"] := "Lb"
  968. }
  969. storedplantsymbol := tile%CX%A%CY%["plant"]["symbol"]
  970. storedplantbackgroundcolor := tile%CX%A%CY%["plant"]["background"]
  971. storedplanttextcolor := tile%CX%A%CY%["plant"]["textcolor"]
  972. gardendocedit := featuredoc.getelementbyid("tile" . CX . "A" . CY)
  973. if(CX == plantselect["location"][1] && CY == plantselect["location"][2] && plantselect["location"][3] == "garden"){
  974. gardendocedit.style.background := "#FF6666"
  975. }
  976. else if(tile%CX%A%CY%["plant"]["protected"] == 1){
  977. gardendocedit.style.background := "#557744"
  978. }
  979. else{
  980. gardendocedit.style.background := "#55DD88"
  981. }
  982. }
  983. if(selectedfeature == "freezer"){
  984. storedplantname := freezertile%CX%A%CY%["plant"]["name"]
  985. storedplantsymbol := freezertile%CX%A%CY%["plant"]["symbol"]
  986. storedplantbackgroundcolor := freezertile%CX%A%CY%["plant"]["background"]
  987. storedplanttextcolor := freezertile%CX%A%CY%["plant"]["textcolor"]
  988. gardendocedit := featuredoc.getelementbyid("freezertile" . CX . "A" . CY)
  989. if(CX == plantselect["location"][1] && CY == plantselect["location"][2] && plantselect["location"][3] == "freezer"){
  990. gardendocedit.style.background := "#FF6666"
  991. }
  992. else if(freezertile%CX%A%CY%["plant"]["protected"] == 1){
  993. gardendocedit.style.background := "#AAAADD"
  994. }
  995. else{
  996. gardendocedit.style.background := "#AADDDD"
  997. }
  998. }
  999. ;update garden tile names if they have been changed.
  1000. if((storedplantname <> gardendocedit.value && storedplantsymbol <> gardendocedit.value)){
  1001. if(storedplantbackgroundcolor){
  1002. if(storedplantsymbol){
  1003. gardendocedit.value := "<table style=""background:" . storedplantbackgroundcolor . "; width:60%; height:60%;""><td>" . storedplantsymbol . "</td></table>"
  1004. }
  1005. else{
  1006. gardendocedit.value := "<table style=""background:" . storedplantbackgroundcolor . "; width:60%; height:60%;""><td>" . storedplantname . "</td></table>"
  1007. }
  1008. }
  1009. else{
  1010. if(storedplantsymbol){
  1011. gardendocedit.value := storedplantsymbol
  1012. }
  1013. else{
  1014. gardendocedit.value := storedplantname
  1015. }
  1016. }
  1017. if(storedplanttextcolor){
  1018. gardendocedit.style.color := storedplanttextcolor
  1019. }
  1020. else{
  1021. gardendocedit.style.color := "#000000"
  1022. }
  1023. }
  1024. }
  1025. if(gardenmode){
  1026. mainbuttoncheck := maindoc2.getElementById(gardenmode)
  1027. mainbuttoncheck.disable := "disabled"
  1028. mainbuttoncheck.value := mainbuttoncheck.value
  1029. }
  1030. }
  1031. if(selectedfeature == "almanac"){
  1032. if(storedselectedfeature <> selectedfeature || storedalmanacplant <> selectedalmanacplant || plantknowledge["knowledge"] <> storedknowledge){
  1033. storedalmanacplant := selectedalmanacplant
  1034. storedknowledge := plantknowledge["knowledge"]
  1035. ;the almanac is rather complex. Most of the code is either displaying the html or comparing knowledge points invested in the selected plant to see which recipes to display.
  1036. htmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow: hidden; height:100%; width:100%; font-family: 'Verdana'; font-size:" . guiwidth / 75 . "px;} body {background:#888888; height:100%; width:100%;} table {top:0px; border-style: none;} [disable=disabled]{background: #666666 !important;}"
  1037. htmlpart1 .= "button{font-size:" . guiwidth / 100 . "px;}"
  1038. htmlpart1 .= ".know{background: #55DD88; color: #000000; width:100%;}"
  1039. htmlpart1 .= ".maindiv{position:absolute; left:0px; top:0px; width:100%;}"
  1040. htmlpart2 := "</style></head><body>"
  1041. if(selectedalmanacplant){
  1042. mainvalue := %selectedalmanacplant%
  1043. htmlpart2 .= "<div class='maindiv' style=""overflow-y:scroll; overflow-X:hidden; height:66%;""><table>"
  1044. htmlpart2 .= "<tr><td><button style=""width: " . round(featuredocW / 100 * 9, 1) . "px; height: " . round(featuredocH / 100 * 9, 1) . "px; font-size:" . guiwidth / 40 . "px; background: #55DD88; "
  1045. if(mainvalue["textcolor"]){
  1046. htmlpart2 .= "color: " . mainvalue["textcolor"] . "; "
  1047. }
  1048. else{
  1049. htmlpart2 .= "color: #000000; "
  1050. }
  1051. htmlpart2 .= """>"
  1052. if(mainvalue["background"]){
  1053. if(mainvalue["symbol"]){
  1054. htmlpart2 .= "<table style=""background:" . mainvalue["background"] . "; width:60%; height:60%;""><td>" . mainvalue["symbol"] . "</td></table>"
  1055. }
  1056. else{
  1057. htmlpart2 .= "<table style=""background:" . mainvalue["background"] . "; width:60%; height:60%;""><td>" . mainvalue["name"] . "</td></table>"
  1058. }
  1059. }
  1060. else if(mainvalue["symbol"]){
  1061. htmlpart2 .= mainvalue["symbol"]
  1062. }
  1063. else{
  1064. htmlpart2 .= mainvalue["name"]
  1065. }
  1066. htmlpart2 .= "</button></td></tr></table><table>"
  1067. htmlpart2 .= "<tr><td colspan='2'><p>" . getplantdescription(mainvalue, "</br>") . "</p></td></tr></table><table>"
  1068. mainvalue := plantknowledge[selectedalmanacplant]
  1069. if(mainvalue["current"] > 0){
  1070. createdby := 0
  1071. cancreate := 0
  1072. loop, % plantcombos.maxIndex(){
  1073. mainindex := A_index
  1074. for mainentry, maincontent in plantcombos[mainindex]{
  1075. if(mainentry == "result" && maincontent == selectedalmanacplant){
  1076. createdby += 1
  1077. }
  1078. }
  1079. for mainentry, maincontent in plantcombos[mainindex]["pardners"]{
  1080. if(maincontent == selectedalmanacplant){
  1081. cancreate += 1
  1082. break
  1083. }
  1084. }
  1085. }
  1086. writtendescriptions := 0
  1087. loop, % plants.MaxIndex(){
  1088. if(plants[A_index]["name"] == selectedalmanacplant){
  1089. createdby += 1
  1090. }
  1091. }
  1092. if((mainvalue["current"] / mainvalue["cap"] * 100) >= ((100 / createdby) - (50 / createdby)) / 2 && createdby > 0){
  1093. htmlpart2 .= "<tr><td><p></br>This plant can be created the following way"
  1094. if((mainvalue["current"] / mainvalue["cap"] * 100) >= (((100 / createdby) * 2) - (50 / createdby)) / 2 && createdby > 1){
  1095. htmlpart2 .= "s"
  1096. }
  1097. htmlpart2 .= ":</p></td></tr>"
  1098. }
  1099. loop, % plants.MaxIndex(){
  1100. if(plants[A_index]["name"] == selectedalmanacplant){
  1101. if((mainvalue["current"] / mainvalue["cap"] * 100) >= (100 / createdby) / 2){
  1102. htmlpart2 .= "<tr><td><p>By randomly appearing in the garden</p></td></tr>"
  1103. writtendescriptions += 1
  1104. }
  1105. else if((mainvalue["current"] / mainvalue["cap"] * 100) >= ((100 / createdby) - (50 / createdby)) / 2){
  1106. htmlpart2 .= "<tr><td><p>????????????????????</p></td></tr>"
  1107. writtendescriptions += 1
  1108. }
  1109. }
  1110. }
  1111. loop, % plantcombos.maxIndex(){
  1112. mainindex := A_index
  1113. for mainentry, maincontent in plantcombos[mainindex]{
  1114. if(mainentry == "result" && maincontent == selectedalmanacplant){
  1115. writtendescriptions += 1
  1116. if((mainvalue["current"] / mainvalue["cap"] * 100) >= (100 / createdby) * writtendescriptions / 2){
  1117. htmlpart2 .= "<tr><td><p>breeding using a "
  1118. for mainentry2, maincontent2 in plantcombos[mainindex]["pardners"]{
  1119. plantname := %maincontent2%["name"]
  1120. if(plantknowledge[maincontent2]["current"] / plantknowledge[maincontent2]["cap"] >= 0.25){
  1121. htmlpart2 .= plantname . " and a "
  1122. }
  1123. else{
  1124. htmlpart2 .= "????? and a "
  1125. }
  1126. }
  1127. stringtrimright, htmlpart2, htmlpart2, 7
  1128. htmlpart2 .= "</p></td></tr>"
  1129. }
  1130. else if((mainvalue["current"] / mainvalue["cap"] * 100) >= (((100 / createdby) * writtendescriptions) - (50 / createdby)) / 2){
  1131. htmlpart2 .= "<tr><td><p>????????????????????</p></td></tr>"
  1132. }
  1133. }
  1134. }
  1135. }
  1136. writtendescriptions := 0
  1137. if((mainvalue["current"] / mainvalue["cap"] * 100) >= 50 + (((100 / cancreate) - (50 / cancreate)) / 2) && cancreate > 0){
  1138. htmlpart2 .= "<tr><td><p></br>This plant can be used in creating the following plant"
  1139. if((mainvalue["current"] / mainvalue["cap"] * 100) >= 50 + ((((100 / cancreate) * 2) - (50 / cancreate)) / 2) && cancreate > 1){
  1140. htmlpart2 .= "s"
  1141. }
  1142. htmlpart2 .= ":</p></td></tr>"
  1143. }
  1144. loop, % plantcombos.maxIndex(){
  1145. mainindex := A_index
  1146. for mainentry, maincontent in plantcombos[mainindex]["pardners"]{
  1147. if(maincontent == selectedalmanacplant){
  1148. writtendescriptions += 1
  1149. if((mainvalue["current"] / mainvalue["cap"] * 100) >= 50 + ((100 / cancreate) * writtendescriptions / 2)){
  1150. htmlpart2 .= "<tr><td><p>breeding using a "
  1151. for mainentry2, maincontent2 in plantcombos[mainindex]["pardners"]{
  1152. plantname := %maincontent2%["name"]
  1153. if(plantknowledge[maincontent2]["current"] / plantknowledge[maincontent2]["cap"] >= 0.5 || maincontent2 == selectedalmanacplant){
  1154. htmlpart2 .= plantname . " and a "
  1155. }
  1156. else{
  1157. htmlpart2 .= "????? and a "
  1158. }
  1159. }
  1160. stringtrimright, htmlpart2, htmlpart2, 7
  1161. htmlpart2 .= " may result in a "
  1162. plantname := plantcombos[mainindex]["result"]
  1163. plantname := %plantname%["name"]
  1164. if(plantknowledge[plantcombos[mainindex]["result"]]["current"] / plantknowledge[plantcombos[mainindex]["result"]]["cap"] >= 0.1){
  1165. htmlpart2 .= plantname
  1166. }
  1167. else{
  1168. htmlpart2 .= "?????"
  1169. }
  1170. mhtlpart2 .= "</p></td></tr>"
  1171. }
  1172. else if((mainvalue["current"] / mainvalue["cap"] * 100) >= 50 + (((100 / cancreate * writtendescriptions) - (50 / cancreate)) / 2)){
  1173. htmlpart2 .= "<tr><td><p>????????????????????</p></td></tr>"
  1174. }
  1175. break
  1176. }
  1177. }
  1178. }
  1179. }
  1180. htmlpart2 .= "</table></div><div style=""bottom:0px; position:absolute;""><table><tr><td></br></br><p>knowledge: " . plantknowledge["knowledge"] . "</p></td></tr>"
  1181. htmlpart2 .= "<tr><td><button class='know' id='addknowledge1' mode='1' percent='false'>add 1 knowledge</button></td>"
  1182. htmlpart2 .= "<td><button class='know' id='addknowledge2' mode='10' percent='true'>add 10% of your knowledge</button></td></tr>"
  1183. htmlpart2 .= "<tr><td><button class='know' id='addknowledge3' mode='10' percent='false'>add 10 knowledge</button></td>"
  1184. htmlpart2 .= "<td><button class='know' id='addknowledge4' mode='25' percent='true'>add 25% of your knowledge</button></td></tr>"
  1185. htmlpart2 .= "<tr><td><button class='know' id='addknowledge5' mode='100' percent='false'>add 100 knowledge</button></td>"
  1186. htmlpart2 .= "<td><button class='know' id='addknowledge6' mode='50' percent='true'>add 50% of your knowledge</button></td></tr>"
  1187. htmlpart2 .= "<tr><td><button class='know' id='addknowledge7' mode='1000' percent='false'>add 1000 knowledge</button></td>"
  1188. htmlpart2 .= "<td><button class='know' id='addknowledge8' mode='100' percent='true'>add 100% of your knowledge</button></td></tr>"
  1189. htmlpart2 .= "<tr><td><p>knowledge: " . mainvalue["current"] . "/" . mainvalue["cap"] . "</p></td></tr></table></div>"
  1190. }
  1191. htmlpart2 .= "</body></html>"
  1192. html := htmlpart1 . htmlpart2
  1193.  
  1194. html2part1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow-x:hidden; height:100%; width:100%; font-family: 'Verdana'; font-size:" . guiwidth / 100 . "px;} body {background:#777777; height:100%; width:100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  1195. html2part1 .= "button{font-size:" . guiwidth / 100 . "px;}"
  1196. html2part1 .= "button{width:100%; left:0px; height: 30px; background: #AAAAAA; color: #000000;}"
  1197. html2part2 := "</style></head><body><table>"
  1198. html2part2 .= "<tr><td><p>seen plants</p></td></tr>"
  1199.  
  1200. for mainentry, maincontent in plantknowledge{
  1201. if(maincontent["seen"] > 0){
  1202. html2part2 .= "<tr><td><button id='" . mainentry . "' mode='" . mainentry . "'>" . %mainentry%["name"] . "</td></tr>"
  1203. }
  1204. }
  1205. html2part2 .= "</table></body></html>"
  1206. html2 := html2part1 . html2part2
  1207.  
  1208. featuredoc.open()
  1209. featuredoc.write(html)
  1210. featuredoc.close()
  1211.  
  1212. if(storedselectedfeature <> selectedfeature){
  1213. maindoc2.open()
  1214. maindoc2.write(html2)
  1215. maindoc2.close()
  1216. }
  1217. storedselectedfeature := selectedfeature
  1218. if(selectedalmanacplant){
  1219. addknowledgebutton1 := featuredoc.getElementById("addknowledge1")
  1220. addknowledgebutton2 := featuredoc.getElementById("addknowledge2")
  1221. addknowledgebutton3 := featuredoc.getElementById("addknowledge3")
  1222. addknowledgebutton4 := featuredoc.getElementById("addknowledge4")
  1223. addknowledgebutton5 := featuredoc.getElementById("addknowledge5")
  1224. addknowledgebutton6 := featuredoc.getElementById("addknowledge6")
  1225. addknowledgebutton7 := featuredoc.getElementById("addknowledge7")
  1226. addknowledgebutton8 := featuredoc.getElementById("addknowledge8")
  1227. comObjConnect(addknowledgebutton1, "addknowledge_")
  1228. comObjConnect(addknowledgebutton2, "addknowledge_")
  1229. comObjConnect(addknowledgebutton3, "addknowledge_")
  1230. comObjConnect(addknowledgebutton4, "addknowledge_")
  1231. comObjConnect(addknowledgebutton5, "addknowledge_")
  1232. comObjConnect(addknowledgebutton6, "addknowledge_")
  1233. comObjConnect(addknowledgebutton7, "addknowledge_")
  1234. comObjConnect(addknowledgebutton8, "addknowledge_")
  1235. }
  1236. for mainentry, maincontent in plantknowledge{
  1237. if(maincontent["seen"] > 0){
  1238. almanac%mainentry%button := maindoc2.getElementById(mainentry)
  1239. comObjConnect(almanac%mainentry%button, "almanacmode_")
  1240. }
  1241. }
  1242. }
  1243. if(selectedalmanacplant){
  1244. mainbuttoncheck := maindoc2.getElementById(selectedalmanacplant)
  1245. mainbuttoncheck.disable := "disabled"
  1246. mainbuttoncheck.value := mainbuttoncheck.value
  1247. }
  1248. }
  1249. if(selectedfeature == "treasure"){
  1250. if(storedselectedfeature <> selectedfeature){
  1251. storedselectedfeature := selectedfeature
  1252. htmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow: hidden; height:100%; width:100%;} body {background:#888888; height:100%; width:100%;} table {left:0px; top:0px; width:20%; border-style: none; position:absolute;} [disable=disabled]{background: #888888 !important;}"
  1253. htmlpart1 .= "button{font-size:" . guiwidth / 100 . "px;}"
  1254. htmlpart1 .= ".radarbutton{width: 100%; height: 64px; left:0px; background: #AAAAAA; color: #000000;}"
  1255. htmlpart1 .= ".radardot{position:absolute; color: #000000; font-size:" . guiwidth / 50 . "px;}"
  1256. htmlpart2 := "</style></head><body><table align='left'>"
  1257. htmlpart2 .= "<tr><td><button class='radarbutton' id='radarbutton'>Purchase radar</br>costs 50000 power</button></td></tr>"
  1258. htmlpart2 .= "</table><p class='radardot' id='radardot'></p>"
  1259. htmlpart2 .= "</body></html>"
  1260. html := htmlpart1 . htmlpart2
  1261.  
  1262. html2part1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; height: 100%; width: 100%; font-family: 'Verdana'; font-size:" . guiwidth / 100 . "px;} body {background:#777777; height: 100%; width: 100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  1263. html2part1 .= "p{height:0%;}"
  1264. html2part1 .= ".openchest{width:100%; height: 64px; left:0px; background: #AAAAAA; color: #000000;}"
  1265. html2part1 .= ".openallchests{width: 100%; height: 96px; left:0px; background: #AAAAAA; color: #000000;}"
  1266. html2part1 .= ".treasureinfo{word-wrap:break-word;}"
  1267. html2part2 := "</style></head><body><table>"
  1268. html2part2 .= "<tr><td><button class='openchest' id='openchest' mode='1' style=""font-size:" . guiwidth / 120 . "px;"">Open A treasure chest</br>using 1 key</button></td></tr>"
  1269. html2part2 .= "<tr><td><button class='openallchests' id='openallchests' mode='all' style=""font-size:" . guiwidth / 120 . "px;""></button></td></tr>"
  1270. html2part2 .= "<tr><td><p id='chests'><p></td></tr>"
  1271. html2part2 .= "<tr><td><p id='keys'><p></td></tr>"
  1272. for mainentry, maincontent in treasures{
  1273. html2part2 .= "<tr><td><p id='" . mainentry . "'><p></td></tr>"
  1274. }
  1275. html2part2 .= "<tr><td><p id='treasureinfo' style='height:100%;'><p></td></tr>"
  1276. html2part2 .= "</table></body></html>"
  1277. html2 := html2part1 . html2part2
  1278. featuredoc.open()
  1279. featuredoc.write(html)
  1280. featuredoc.close()
  1281.  
  1282. maindoc2.open()
  1283. maindoc2.write(html2)
  1284. maindoc2.close()
  1285. treasureopenchestbutton := maindoc2.getElementById("openchest")
  1286. treasureopenallchestsbutton := maindoc2.getElementById("openallchests")
  1287. treasureradarbutton := featuredoc.getElementById("radarbutton")
  1288. treasureradardot := featuredoc.getElementById("radardot")
  1289. treasureinfotable := maindoc2.getElementById("treasureinfotable")
  1290. treasureinfo := maindoc2.getElementById("treasureinfo")
  1291. treasurecheststext := maindoc2.getElementById("chests")
  1292. treasurekeystext := maindoc2.getElementById("keys")
  1293. for mainentry, maincontent in treasures{
  1294. treasure%mainentry%text := maindoc2.getElementById(mainentry)
  1295. }
  1296. ComObjConnect(treasureopenchestbutton, "treasureopen_")
  1297. ComObjConnect(treasureopenallchestsbutton, "treasureopen_")
  1298. ComObjConnect(treasureradarbutton, "purchaseradar_")
  1299. }
  1300. if(treasureradarbought <> 1){
  1301. treasureradardot.style.display := "none"
  1302. treasureradarbutton.style.display := "block"
  1303. }
  1304. else{
  1305. treasureradardot.style.display := "block"
  1306. treasureradarbutton.style.display := "none"
  1307. }
  1308. treasurecheststext.Innerhtml := "chests: " . treasurechests
  1309. treasurekeystext.Innerhtml := "golden keys: " . treasurekeys
  1310. mainvalue := Min(treasurechests, treasurekeys)
  1311. if(mainvalue == 1){
  1312. treasureopenallchestsbutton.Innerhtml := "Open 1 chest</br>usng 1 Key"
  1313. }
  1314. else{
  1315. treasureopenallchestsbutton.Innerhtml := "Open " . mainvalue . " chests</br>using " . mainvalue . " Keys"
  1316. }
  1317. for mainentry, maincontent in treasures{
  1318. treasure%mainentry%text.InnerHtml := mainentry . ": " . maincontent
  1319. }
  1320. treasureinfo.InnerHtml := treasureinfotext
  1321. }
  1322. if(selectedfeature == "logs"){
  1323. if(storedselectedfeature <> selectedfeature){
  1324. storedselectedfeature := selectedfeature
  1325. htmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:shown; border-style:none; height: 100%; font-family: 'Verdana'; font-size:" . guiwidth / 100 . "px;} body {background:#888888; height: 100%;}"
  1326. htmlpart1 .= ".logstext{width:100%; height:30px; left:0px; color: #000000;}"
  1327. htmlpart2 := "</style></head><body><table width='100%'>"
  1328. htmlpart2 .= "<tr><td><p class='logstext' id='logstext' style='height:100%; width:100%;'></p></td></tr>"
  1329. htmlpart2 .= "</table></body></html>"
  1330. html := htmlpart1 . htmlpart2
  1331.  
  1332. html2part1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; border-style:none; height: 100%;} body {background:#777777; height: 100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  1333. html2part1 .= "button{font-size:" . guiwidth / 100 . "px;}"
  1334. html2part1 .= ".general{width:100%; height:30px; left:0px; background: #AAAAAA; color: #000000;}"
  1335. html2part1 .= ".power{width:100%; height:30px; left:0px; background: #AAAAAA; color: #000000;}"
  1336. html2part1 .= ".garden{width:100%; height:30px; left:0px; background: #AAAAAA; color: #000000;}"
  1337. html2part1 .= ".treasure{width:100%; height:30px; left:0px; background: #AAAAAA; color: #000000;}"
  1338. html2part1 .= ".shop{width:100%; height:30px; left:0px; background: #AAAAAA; color: #000000;}"
  1339. html2part2 := "</style></head><body><table width='100%' id='logstable'>"
  1340. html2part2 .= "<tr><td><button class='general' id='general' mode='general'>General logs</button></td></tr>"
  1341. html2part2 .= "<tr><td><button class='shop' id='shop' mode='shop'>Shop logs</button></td></tr>"
  1342. html2part2 .= "<tr><td><button class='power' id='power' mode='power'>Power logs</button></td></tr>"
  1343. html2part2 .= "<tr><td id='gardentable'><button class='garden' id='garden' mode='garden'>Garden Logs</button></td></tr>"
  1344. html2part2 .= "<tr><td id='treasuretable'><button class='treasure' id='treasure' mode='treasure'>Treasure Logs</button></td></tr>"
  1345. html2part2 .= "</table></body></html>"
  1346. html2 := html2part1 . html2part2
  1347.  
  1348. featuredoc.open()
  1349. featuredoc.write(html)
  1350. featuredoc.close()
  1351.  
  1352. maindoc2.open()
  1353. maindoc2.write(html2)
  1354. maindoc2.close()
  1355.  
  1356. logstext := featuredoc.getElementById("logstext")
  1357. logsgeneralbutton := maindoc2.getElementById("general")
  1358. logsshopbutton := maindoc2.getElementById("shop")
  1359. logspowerbutton := maindoc2.getElementById("power")
  1360. logsgardenbutton := maindoc2.getElementById("garden")
  1361. logsgardentable := maindoc2.getElementById("gardentable")
  1362. logstreasurebutton := maindoc2.getElementById("treasure")
  1363. logstreasuretable := maindoc2.getElementById("treasuretable")
  1364. ComObjConnect(logsgeneralbutton, "logsmode_")
  1365. ComObjConnect(logsshopbutton, "logsmode_")
  1366. ComObjConnect(logspowerbutton, "logsmode_")
  1367. ComObjConnect(logsgardenbutton, "logsmode_")
  1368. ComObjConnect(logstreasurebutton, "logsmode_")
  1369. }
  1370. if(logsmode){
  1371. mainbuttoncheck := maindoc2.getElementById(logsmode)
  1372. mainbuttoncheck.disable := "disabled"
  1373. mainbuttoncheck.value := mainbuttoncheck.value
  1374. }
  1375. totallogs := ""
  1376. for logsentry, logscontent in logs{
  1377. while(logscontent.MaxIndex() > 50){
  1378. logs[logsentry].remove(1) ;logscontent
  1379. }
  1380. loop, % logs[logsentry].MaxIndex(){
  1381. if(logsentry == logsmode || logsmode == "all"){
  1382. totallogs .= logs[logsentry][A_index] . "</br>"
  1383. }
  1384. if(totallogs.MaxIndex() > 50){
  1385. totallogs.Remove(1)
  1386. }
  1387. }
  1388. }
  1389. logstext.innerhtml := totallogs
  1390. }
  1391. if(selectedfeature == "stats"){
  1392. storedselectedfeature := selectedfeature
  1393. htmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow: hidden; height:100%; width:100%; font-family: 'Verdana'; font-size:" . guiwidth / 100 . "px;} body {background:#888888; height:100%; width:100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  1394. htmlpart2 := "</style></head><body><table>"
  1395. if(stats["clicks"] >= 0){
  1396. htmlpart2 .= "<tr><td>times power gained by clicking: " . stats["clicks"] . "</td></tr>"
  1397. }
  1398. if(stats["powergained"] >= 0){
  1399. htmlpart2 .= "<tr><td>total power gained: " . stats["powergained"] . "</td></tr>"
  1400. }
  1401. if(stats["powerspent"] >= 0){
  1402. htmlpart2 .= "<tr><td>total power spent: " . stats["powerspent"] . "</td></tr>"
  1403. }
  1404. if(stats["upgradespurchased"] >= 0){
  1405. htmlpart2 .= "<tr><td>Upgrades purchased: " . stats["upgradespurchased"] . "</td></tr>"
  1406. }
  1407. if(stats["mousemoves"] >= 0){
  1408. htmlpart2 .= "<tr><td>times power gained by moving the mouse: " . stats["mousemoves"] . "</td></tr>"
  1409. }
  1410. if(stats["keyboardletterspressed"] >= 0){
  1411. htmlpart2 .= "<tr><td>times power gained by using the keyboard: " . stats["keyboardletterspressed"] . "</td></tr>"
  1412. }
  1413. if(stats["hiddentreasuresfound"] >= 0){
  1414. htmlpart2 .= "<tr><td>hidden treasures found: " . stats["hiddentreasuresfound"] . "</td></tr>"
  1415. }
  1416. if(stats["goldenkeyspressed"] >= 0){
  1417. htmlpart2 .= "<tr><td>golden keyboard keys pressed: " . stats["goldenkeyspressed"] . "</td></tr>"
  1418. }
  1419. if(stats["treasurechestsfound"] >= 0){
  1420. htmlpart2 .= "<tr><td>treasure chests found: " . stats["treasurechestsfound"] . "</td></tr>"
  1421. }
  1422. if(stats["goldenkeysfound"] >= 0){
  1423. htmlpart2 .= "<tr><td>golden keys found: " . stats["goldenkeysfound"] . "</td></tr>"
  1424. }
  1425. if(stats["chestsopened"] >= 0){
  1426. htmlpart2 .= "<tr><td>Chests opened: " . stats["chestsopened"] . "</td></tr>"
  1427. }
  1428. if(stats["gardenplantscreated"] >= 0){
  1429. htmlpart2 .= "<tr><td>garden plants created: " . stats["gardenplantscreated"] . "</td></tr>"
  1430. }
  1431. if(stats["powerharvested"] >= 0){
  1432. htmlpart2 .= "<tr><td>Total power harvested from plants: " . stats["powerharvested"] . "</td></tr>"
  1433. }
  1434. if(stats["plantsharvested"] >= 0){
  1435. htmlpart2 .= "<tr><td>Total plants harvested: " . stats["plantsharvested"] . "</td></tr>"
  1436. }
  1437. htmlpart2 .= "</table></body></html>"
  1438. html := htmlpart1 . htmlpart2
  1439.  
  1440. html2part1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; height:100%; width:100%; font-family: 'Verdana'; font-size:" . guiwidth / 100 . "px;} body {background:#777777; height:100%; width:100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  1441. html2part2 := "</style></head><body><table>"
  1442. html2part2 := "<tr><td></td></tr>"
  1443. html2part2 .= "</table></body></html>"
  1444. html2 := html2part1 . html2part2
  1445. featuredoc.open()
  1446. featuredoc.write(html)
  1447. featuredoc.close()
  1448. maindoc2.open()
  1449. maindoc2.write(html2)
  1450. maindoc2.close()
  1451. }
  1452. if(selectedfeature == "options"){
  1453. if(storedselectedfeature <> selectedfeature){
  1454. storedselectedfeature := selectedfeature
  1455. ;these handle the option checkboxes. I'm not entirely sure what other options should be added though there should probably eventually be one to set autosave timer or notation.
  1456. htmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {border-style:none; overflow:shown; width:100%; height: 100%; font-family:verdana; font-size:" . guiwidth / 100 . "px;} body {background:#888888; width:100%; height: 100%;} table {left:0px; top:0px; border-style: none; position:absolute;} input[type='checkbox'] {width:20px; height:15px;}"
  1457. htmlpart2 := "</style></head><body><table width='100%'>"
  1458. for mainentry, maincontent in alloptions{
  1459. htmlpart1 .= "." . mainentry . "{height: 30px; left:0px; color: #000000;}"
  1460. htmlpart2 .= "<tr><td><input type='checkbox' class='" . mainentry . "' id='" . mainentry . "'>" . maincontent . "</td></tr>"
  1461. }
  1462. htmlpart2 .= "</table></body></html>"
  1463. html := htmlpart1 . htmlpart2
  1464.  
  1465. html2 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; width:100%; height: 100%;} body {background:#777777; width:100%; height: 100%;}</style></head></html>"
  1466. featuredoc.open()
  1467. featuredoc.write(html)
  1468. featuredoc.close()
  1469.  
  1470. maindoc2.open()
  1471. maindoc2.write(html2)
  1472. maindoc2.close()
  1473. for mainentry, maincontent in alloptions{
  1474. options%mainentry%checkbox := featuredoc.getElementById(mainentry)
  1475. if(optionchecks[mainentry] == 1){
  1476. options%mainentry%checkbox.checked := "true"
  1477. optionchecks[mainentry] := 1
  1478. }
  1479. ComObjConnect(options%mainentry%checkbox, "optionscheckbox_")
  1480. }
  1481. }
  1482. }
  1483. if(selectedfeature == "help"){
  1484. if(storedselectedfeature <> selectedfeature){
  1485. storedselectedfeature := selectedfeature
  1486. htmlpart1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:shown; border-style: none; height: 100%; font-family: 'Verdana'; font-size:" . guiwidth / 75 . "px;} body {background:#888888; height: 100%;}"
  1487. htmlpart1 .= ".helpinfo{width:100%; left:0px; color: #000000; word-wrap: break-word;}"
  1488. htmlpart2 := "</style></head><body><table id='helpbuttonstable'>"
  1489. htmlpart2 .= "<tr><td><p class='helpinfo 'id='helpinfo'></p></td></tr>"
  1490. htmlpart2 .= "<table></body></html>"
  1491. html := htmlpart1 . htmlpart2
  1492.  
  1493. html2part1 := "<!DOCTYPE html><html><head><style type=text/css> html {overflow:hidden; border-style: none; height: 100%;} body {background:#777777; height: 100%;} table {left:0px; top:0px; width:100%; border-style: none; position:absolute;} [disable=disabled]{background: #666666 !important;}"
  1494. html2part1 .= "button{font-size:" . guiwidth / 100 . "px;}"
  1495. html2part1 .= ".basics{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  1496. html2part1 .= ".powergeneration{width:100%; height: 60px; left:0px; background: #AAAAAA; color: #000000;}"
  1497. html2part1 .= ".saving{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  1498. html2part1 .= ".shop{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  1499. html2part1 .= ".logs{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  1500. html2part1 .= ".treasure{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  1501. html2part1 .= ".garden{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  1502. html2part1 .= ".almanac{width:100%; height: 30px; left:0px; background: #AAAAAA; color: #000000;}"
  1503. html2part2 := "</style></head><body><table id='helpbuttonstable'>"
  1504. html2part2 .= "<tr><td><button class='basics' id='basics' mode='basics'>The Basics</button></td></tr>"
  1505. html2part2 .= "<tr><td><button class='powergeneration' id='powergeneration' mode='powergeneration'>Methods of</br>power generation</button></td></tr>"
  1506. html2part2 .= "<tr><td><button class='saving' id='saving' mode='saving'>Saving the game</button></td></tr>"
  1507. html2part2 .= "<tr><td><button class='shop' id='shop' mode='shop'>Shop</button></td></tr>"
  1508. html2part2 .= "<tr><td><button class='logs' id='logs' mode='logs'>Logs</button></td></tr>"
  1509. html2part2 .= "<tr id='treasuretable'><td><button class='treasure' id='treasure' mode='treasure'>Treasures</button></td></tr>"
  1510. html2part2 .= "<tr id='gardentable'><td><button class='garden' id='garden' mode='garden'>Garden</button></td></tr>"
  1511. html2part2 .= "<tr id='almanactable'><td><button class='almanac' id='almanac' mode='almanac'>Almanac</button></td></tr>"
  1512. html2part2 .= "</table></body></html>"
  1513. html2 := html2part1 . html2part2
  1514.  
  1515. featuredoc.open()
  1516. featuredoc.write(html)
  1517. featuredoc.close()
  1518. maindoc2.open()
  1519. maindoc2.write(html2)
  1520. maindoc2.close()
  1521.  
  1522. helpbasicsbutton := maindoc2.getElementById("basics")
  1523. helpsavingbutton := maindoc2.getElementById("saving")
  1524. helplogsbutton := maindoc2.getElementById("logs")
  1525. helpshopbutton := maindoc2.getElementById("shop")
  1526. helpmousepowerbutton := maindoc2.getElementById("powergeneration")
  1527. helpgardenbutton := maindoc2.getElementById("garden")
  1528. helpgardentable := maindoc2.getElementById("gardentable")
  1529. helpalmanacbutton := maindoc2.getElementById("almanac")
  1530. helpalmanactable := maindoc2.getElementById("almanactable")
  1531. helptreasurebutton := maindoc2.getElementById("treasure")
  1532. helptreasuretable := maindoc2.getElementById("treasuretable")
  1533. helpkeytable := maindoc2.getElementById("helpkeytable")
  1534.  
  1535. if(0 >= garden["purchased"]){
  1536. ;hide these buttons if you haven't unlocked them yet.
  1537. helpgardentable.style.display := "none"
  1538. }
  1539. else{
  1540. helpgardentable.style.display := "block"
  1541. }
  1542. if(0 >= hiddentreasure["purchased"] && 0 >= goldenkeys["purchased"]){
  1543. helptreasuretable.style.display := "none"
  1544. }
  1545. else{
  1546. helptreasuretable.style.display := "block"
  1547. }
  1548. if(!plantknowledge["knowledge"]){
  1549. helpalmanactable.style.display := "none"
  1550. }
  1551. else{
  1552. helpalmanactable.style.display := "block"
  1553. }
  1554. ComObjConnect(helpbasicsbutton, "helpmode_")
  1555. ComObjConnect(helpsavingbutton, "helpmode_")
  1556. ComObjConnect(helpshopbutton, "helpmode_")
  1557. ComObjConnect(helplogsbutton, "helpmode_")
  1558. ComObjConnect(helpmousepowerbutton, "helpmode_")
  1559. ComObjConnect(helpgardenbutton, "helpmode_")
  1560. ComObjConnect(helpalmanacbutton, "helpmode_")
  1561. ComObjConnect(helptreasurebutton, "helpmode_")
  1562. helpinfotext := featuredoc.getElementById("helpinfo")
  1563. }
  1564. if(helpmode){
  1565. mainbuttoncheck := maindoc2.getElementById(helpmode)
  1566. mainbuttoncheck.disable := "disabled"
  1567. mainbuttoncheck.value := mainbuttoncheck.value
  1568. }
  1569. helpvalue := ""
  1570. if(helpmode == "basics"){
  1571. helpvalue :=
  1572. (
  1573. "Welcome to Background power. Made by mipha (also known as /u/pimhazeveld) In this game you can earn power which is the game's main resource by clicking. Click anywhere you want, while having anything selected.
  1574. It could be this screen, some page on the internet or even another game. This game will register the clicks and earn you power.</br>Clicking power gain is affected by various sources and new ways of earning power will quickly become available."
  1575. )
  1576. }
  1577. if(helpmode == "saving"){
  1578. helpvalue :=
  1579. (
  1580. "The game autosaves every 5 minutes and can be saved by manually pressing the save button. It saves by making a file near where the game is located and reads the savedata there.
  1581. Saves can be backed up by copying them somewhere else and can be imported by replacing the current one. Make sure to quit the game before doing this, otherwise the game will overwrite parts of the save and possibly do some weird stuff.
  1582. Futhermore the save should always be called 'backgroundpowersave.ini' otherwise it doesn't work."
  1583. )
  1584. }
  1585. if(helpmode == "powergeneration"){
  1586. if(calculateclickvalue() >= 1){
  1587. helpvalue := calculateclickvalue() . " power is currently obtained every click.</br>"
  1588. helpvalue .= clickpowerbonus . " from upgrades</br>"
  1589. ;check if some upgrades have been bought at least once
  1590. if(garden["purchased"] >= 1){
  1591. helpvalue .= "+" . round(farmclickpower) . " from garden plants</br>"
  1592. helpvalue .= "*" . round((farmclickpowerpercent / 100) + 1, 3) . " from garden plants</br>"
  1593. }
  1594. helpvalue .= "*" . round(clickpowermult, 3) . " from upgrades</br>"
  1595. if(hiddentreasure["purchased"] >= 1){
  1596. helpvalue .= "*" . round(treasureclickpowermult, 3) . " from amulets</br>"
  1597. }
  1598. if(knowledgepower2["purchased"] >= 1){
  1599. helpvalue .= "*" . round(knowledgeclickpowermult, 3) . " from knowledge points</br>"
  1600. }
  1601. }
  1602. if(calculatemovevalue() >= 1){
  1603. helpvalue .= "</br>" . calculatemovevalue() * 2 . " power is currently obtained at most when moving the mouse</br>"
  1604. helpvalue .= movepowerbonus . " from upgrades</br>"
  1605. if(garden["purchased"] >= 1){
  1606. helpvalue .= "+" . round(farmmovepower) . " from garden plants</br>"
  1607. helpvalue .= "*" . round((farmmovepowerpercent / 100) + 1, 3) . " from garden plants</br>"
  1608. }
  1609. if(hiddentreasure["purchased"] >= 1){
  1610. helpvalue .= "*" . round(treasuremovepowermult, 3) . " from rings</br>"
  1611. }
  1612. helpvalue .= "*" . round(movepowermult, 3) . " from upgrades</br>"
  1613. helpvalue .= "* up to 2 depending on how much the mouse was moved</br>"
  1614. if(knowledgepower2["purchased"] >= 1){
  1615. helpvalue .= "*" . round(knowledgemovepowermult, 3) . " from knowledge points</br>"
  1616. }
  1617. if(mousemastery["purchased"] >= 1){
  1618. helpvalue .= "+" . calculateclickvalue() . " from clicking power added by mouse mastery</br>"
  1619. }
  1620. }
  1621. if(calculatemovespeed() >= 1){
  1622. helpvalue .= "</br>Mouse movement efficiency is " . calculatemovespeed() . "</br>"
  1623. helpvalue .= movespeedbonus . " from upgrades</br>"
  1624. if(garden["purchased"] >= 1){
  1625. helpvalue .= "+" . round(farmmovespeed) . " from garden plants</br>"
  1626. helpvalue .= "*" . round((farmmovespeedpercent / 100) + 1, 3) . " from garden plants</br>"
  1627. }
  1628. helpvalue .= "*" . round(movespeedmult, 3) . " from upgrades</br>"
  1629. if(hiddentreasure["purchased"] >= 1){
  1630. helpvalue .= "*" . round(treasuremovespeedmult, 3) . " from pearls</br>"
  1631. }
  1632. helpvalue .= "Mouse movement affects how quick power is built up when moving the mouse</br>"
  1633. }
  1634. if(calculatekeyboardkeyvalue() >= 1){
  1635. helpvalue .= "</br>power gained from keyboard keys is " . calculatekeyboardkeyvalue() . "</br>"
  1636. helpvalue .= keyboardkeypowerbonus . " from upgrades</br>"
  1637. if(garden["purchased"] >= 1){
  1638. helpvalue .= "+" . round(farmkeyboardkeypower) . " from garden plants</br>"
  1639. helpvalue .= "*" . round((farmkeyboardkeypowerpercent / 100) + 1, 3) . " from garden plants</br>"
  1640. }
  1641. helpvalue .= "*" . round(keyboardkeypowermult, 3) . " from upgrades</br>"
  1642. if(gamerfuel["purchased"] >= 1){
  1643. helpvalue .= "*2 when pressing a WASD key</br>"
  1644. }
  1645. if(hiddentreasure["purchased"] >= 1){
  1646. helpvalue .= "*" . round(treasurekeyboardkeymult, 3) . " from gold bars</br>"
  1647. }
  1648. if(knowledgepower2["purchased"] >= 1){
  1649. helpvalue .= "*" . round(knowledgekeyboardkeymult, 3) . " from knowledge points</br>"
  1650. }
  1651. }
  1652. }
  1653. if(helpmode == "shop"){
  1654. helpvalue :=
  1655. (
  1656. "In the shop you can spend power to gain upgrades. The shop has 2 modes, purchase and inspect. Inspect provides information about what the upgrade does and purchase mode does the same but will also attempt to buy the upgrades using power.
  1657. Most upgrades in the shop are hidden until you meet the right requirement."
  1658. )
  1659. }
  1660. if(helpmode == "logs"){
  1661. helpvalue := "The logs show general info of what recently happened. Things like purchases, power gain from mouse moving"
  1662. if(garden["purchased"] >= 1){
  1663. helpvalue .= ", garden plants appearing"
  1664. }
  1665. if(hiddentreasure["purchased"] >= 1){
  1666. helpvalue .= ", hidden treasures being found"
  1667. }
  1668. helpvalue .= ", the game being saved and many other things are all displayed there."
  1669. }
  1670. if(helpmode == "garden"){
  1671. helpvalue :=
  1672. (
  1673. "In the garden. Plants appear over time when moving the mouse. Plants provide various buffs when left alone or harvested. Plants can occasionally create new plants next to them so keep your eyes open.</br>The garden has 4 modes to manage plants
  1674. </br>Inspect mode, which displays information about the tile</br>Harvest mode which removes a plant and gives rewards based on the plant</br> Swap mode which swaps the contents of 2 tiles</br> and protect mode which prevents plants from
  1675. accidentally being harvested.</br> Furthermore there's also a freezer which is an entirely different garden but plants wont grow there. Plants can be moved from the garden to the freezer"
  1676. )
  1677. calculateharvestvalue()
  1678. helpvalue .= "</br></br>Power gained from harvesting a plant varies per plant. Here is an example when harvesting a plant that yields 50 power.</br>"
  1679. helpvalue .= "It would yield 50 from the plant itself</br>"
  1680. helpvalue .= "+" . harvestpowerbonus . " from upgrades</br>"
  1681. helpvalue .= "+" . round(farmharvestpower) . " from garden plants</br>"
  1682. helpvalue .= "*" . round((farmharvestpowerpercent / 100) + 1, 3) . " from garden plants</br>"
  1683. helpvalue .= "*" . round(harvestpowermult, 3) . " from upgrades</br>"
  1684. if(hiddentreasure["purchased"] >= 1){
  1685. helpvalue .= "*" . round(treasureharvestmult, 3) . " from emeralds</br>"
  1686. }
  1687. if(knowledgepower2["purchased"] >= 1){
  1688. helpvalue .= "*" . round(knowledgeharvestpowermult, 3) . " from knowledge points</br>"
  1689. }
  1690. helpvalue .= "For a total of " . calculateharvestvalue(50) . " power"
  1691. plantchance := 3
  1692. gardenplantchance := 0
  1693. for globalentry, globalcontent in upgrades{
  1694. if(%globalentry%["plantchance"]){
  1695. gardenplantchance += %globalentry%["plantchance"] * globalcontent["purchased"]
  1696. }
  1697. }
  1698. plantchance += (((gardenplantchance * plantchance / 100)))
  1699. helpvalue .= "</br></br>Empty tiles have a " . round(plantchance, 3) . " - " . round(plantchance * 2, 3) . "% chance of spawning a plant when the mouse is moved depending on how much the mouse was moved."
  1700.  
  1701. }
  1702. if(helpmode == "almanac"){
  1703. helpvalue :=
  1704. (
  1705. "The almanac is an extension to the garden. Here you can learn more about plants without many other plants affecting their stats so you can take a good look at them. Note however that rewards gained by harvesting are still affected by things
  1706. like upgrades or global buffs.</br>Furthermore, here you can dump knowledge points
  1707. in your discovered plants which are obtained by harvesting knowleaf plants. As more knowledge is dumped into plants, you'll discover how to create the plant and eventually start discovering how you can create other plants with it
  1708. as well. Note that recipes often show question marks (?????). That means that either the plant does not have enough knowledge yet, or that it is trying to show a different plant that you do not have enough knowledge for yet.
  1709. So dumping knowledge in every plant should be a priority if you want to know every plant there is to create.</br></br>"
  1710. )
  1711. if(10 <> calculateknowledge(10)){
  1712. helpvalue .= "knowledge gained from a plant varies per plant. Here is an example when harvesting a plant that yields 10 knowledge.</br>"
  1713. helpvalue .= "It would yield 10 from the plant itself</br>"
  1714. helpvalue .= "+" . knowledgebonus . " from upgrades</br>"
  1715. helpvalue .= "+" . round(farmknowledge) . " from garden plants</br>"
  1716. helpvalue .= "*" . round((farmknowledgepercent / 100) + 1, 3) . " from garden plants</br>"
  1717. helpvalue .= "*" . round(knowledgemult, 3) . " from upgrades</br>"
  1718. helpvalue .= "For a total of " . calculateknowledge(10) . " knowledge"
  1719. }
  1720. }
  1721. if(helpmode == "treasure"){
  1722. if(hiddentreasure["purchased"] >= 1){
  1723. helpvalue :=
  1724. (
  1725. "</br></br>Points on the screen can occasionally be assigned as hidden treasures when pressing keyboard keys. Mousing close to them digs them up and grants rewards. The process is entirely silent.
  1726. You wont know whenever a treasure appears or when one is collected as to not bug the player with information while doing something else.</br></br>Furthermore treasure chests can occasionally be found and opened with a key to gain additional power and treasures."
  1727. )
  1728. if(0 >= hiddenkeys["purchased"]){
  1729. helpvalue .= " How do you get a key you ask? Well you'll have to wait a little longer to find out.</br>"
  1730. }
  1731. helpvalue .= "power gained from hidden treasures is currently " . calculateclickvalue() * 25 . "</br>"
  1732. helpvalue .=
  1733. (
  1734. "</br>Each treasure obtained from chests provides a 1% boost to a feature.</br>Amulets boost power gain from clicking.</br>Emeralds boost power gain from harvesting garden plants.</br>
  1735. Gold bars boost power gain from opening treasure chests.</br>Grails boost power gain from finding keys.</br>Pearls boost mouse movement effeciency</br>Rings boost power gain from moving the mouse"
  1736. )
  1737. if(treasureradarbought == 1){
  1738. helpvalue .=
  1739. (
  1740. "</br></br>The treasure radar is an useful feature that shows where treasures are currently located on the screen. Your mouse is displayed as a dot most of the time. When you are near a treasure.
  1741. The mouse becomes an o, getting even closer makes it a 0 and finally an O until you move away or collect it."
  1742. )
  1743. }
  1744. }
  1745. if(goldenkeys["purchased"] >= 1){
  1746. helpvalue .=
  1747. (
  1748. "</br></br>Golden keys are a slightly different type of key where occasionally a random letter key on the keyboard becomes a secret golden key when the mouse has been moved.
  1749. Pressing that letter gives way more power than a normal keyboard key and occasionally an usable key</br>"
  1750. )
  1751. if(0 >= hiddentreasure["purchased"]){
  1752. helpvalue .= " Where do you use these keys? Well you'll have to wait a little longer to find out.</br>"
  1753. }
  1754. helpvalue .= "power gained from golden keys currently is " . calculatekeyboardkeyvalue() * 25 . "</br>"
  1755. }
  1756. if(hiddentreasure["purchased"] >= 1 && goldenkeys["purchased"] >= 1){
  1757. helpvalue .= "</br>Hidden treasures and golden keys can appear when both moving the mouse or pressing keyboard keys but pressing keys is more effective for treasures to appear and moving the mouse is more effective for golden keys"
  1758. }
  1759. }
  1760. helpinfotext.innerHTML := helpvalue
  1761. }
  1762. critical, off
  1763. }
  1764.  
  1765. selectfeature_onclick(selectfeaturedoc){
  1766. global
  1767. ;change the selected feature and disable the pressed button
  1768. if(selectedfeature){
  1769. buttoncheck := maindoc.getElementById(selectedfeature)
  1770. buttoncheck.disable := ""
  1771. buttoncheck.value := buttoncheck.value
  1772. }
  1773. selectedfeature := selectfeaturedoc.mode
  1774. if(selectedfeature == "freezer" && gardenmode == "harvest"){
  1775. gardenmode := "inspect"
  1776. }
  1777. updatemain()
  1778. }
  1779.  
  1780. shopmode_onclick(shopmodedoc){
  1781. global
  1782. if(shopmode){
  1783. buttoncheck := maindoc2.getElementById(shopmode)
  1784. buttoncheck.disable := ""
  1785. buttoncheck.value := buttoncheck.value
  1786. }
  1787. shopmode := shopmodedoc.mode
  1788. updatemain()
  1789. }
  1790.  
  1791. gardenmode_onclick(gardenmodedoc){
  1792. global
  1793. gardenmodedoc := gardenmodedoc.mode
  1794. if(gardenmode){
  1795. gardenbuttoncheck := maindoc2.getElementById(gardenmode)
  1796. gardenbuttoncheck.disable := ""
  1797. gardenbuttoncheck.value := gardenbuttoncheck.value
  1798. }
  1799. ;changes garden mode. Also handles changing from garden to freezer and vice versa.
  1800. if(gardenmodedoc == "harvest" && selectedfeature == "freezer"){
  1801. addtooltip("Harvest mode doesnt work in the freezer")
  1802. }
  1803. else{
  1804. gardenmode := gardenmodedoc
  1805. plantselect := ""
  1806. }
  1807. updatemain()
  1808. }
  1809.  
  1810. almanacmode_onclick(almanacdoc){
  1811. global
  1812. if(selectedalmanacplant){
  1813. buttoncheck := maindoc2.getElementById(selectedalmanacplant)
  1814. buttoncheck.disable := ""
  1815. buttoncheck.value := buttoncheck.value
  1816. }
  1817. selectedalmanacplant := almanacdoc.mode
  1818. updatemain()
  1819. }
  1820.  
  1821. addknowledge_onclick(addknowledgedoc){
  1822. global
  1823. ;add knowledge points to a plant based on which button is pressed and the amount of knowledge you and the plant already have.
  1824. almanacvalue := min(plantknowledge[selectedalmanacplant]["cap"] - plantknowledge[selectedalmanacplant]["current"])
  1825. if(addknowledgedoc.percent == "true"){
  1826. addknowledgevalue := round(min(almanacvalue, plantknowledge["knowledge"] / 100 * addknowledgedoc.mode))
  1827. plantknowledge[selectedalmanacplant]["current"] := round(plantknowledge[selectedalmanacplant]["current"] + addknowledgevalue)
  1828. }
  1829. else{
  1830. addknowledgevalue := round(min(almanacvalue, plantknowledge["knowledge"], addknowledgedoc.mode))
  1831. plantknowledge[selectedalmanacplant]["current"] := round(plantknowledge[selectedalmanacplant]["current"] + addknowledgevalue)
  1832. }
  1833. plantknowledge["knowledge"] := round(plantknowledge["knowledge"] - addknowledgevalue)
  1834. updatemain()
  1835. }
  1836.  
  1837. logsmode_onclick(logsmodedoc){
  1838. global
  1839. if(logsmode){
  1840. buttoncheck := maindoc2.getElementById(logsmode)
  1841. buttoncheck.disable := ""
  1842. buttoncheck.value := buttoncheck.value
  1843. }
  1844. logsmode := logsmodedoc.mode
  1845. updatemain()
  1846. }
  1847.  
  1848. helpmode_onclick(helpmodedoc){
  1849. global
  1850. if(helpmode){
  1851. buttoncheck := maindoc2.getElementById(helpmode)
  1852. buttoncheck.disable := ""
  1853. buttoncheck.value := buttoncheck.value
  1854. }
  1855. helpmode := helpmodedoc.mode
  1856. updatemain()
  1857. }
  1858.  
  1859. optionscheckbox_onclick(optionscheckboxdoc){
  1860. global
  1861. ;for the checkboxes in the options
  1862. gui, Options:default
  1863. optionscheckboxvalue := optionscheckboxdoc.id
  1864. if(optionscheckboxdoc.checked){
  1865. optionchecks[optionscheckboxvalue] := 1
  1866. }
  1867. else{
  1868. optionchecks[optionscheckboxvalue] := 0
  1869. }
  1870. updatemain()
  1871. }
  1872.  
  1873. purchaseradar_onclick(){
  1874. global
  1875. if(power > 50000 && treasureradarbought <> 1){
  1876. changepower(50000, "subtract")
  1877. treasureradarbought := 1
  1878. addtooltip("radar bought. Look in the help tab about treasure power generation to learn more about it", 50)
  1879. addlog("radar bought. Look in the help tab about treasure power generation to learn more about it", "treasure")
  1880. updatemain()
  1881. }
  1882. }
  1883.  
  1884. shoppurchase_onclick(shoppurchasedoc){
  1885. global
  1886. shoppurchasedoc := shoppurchasedoc.id
  1887. shoppurchasedoc := % %shoppurchasedoc%
  1888. ;this gets the id of the button pressed which contains the name of an upgrad. The name of the upgrade then gets turned into its value because every upgrade contains an array of its stats and cost and such.
  1889. ;shopmode is set in shopmode_onclick()
  1890. upgradeprice := calculateshopprice(shoppurchasedoc)
  1891. upgradeprice := round(upgradeprice)
  1892. totaldescription := ""
  1893. if(shopmode == "purchase"){
  1894. ;if you can afford the upgrade and you haven't bought equal or more upgrades than the repeated tag or you haven't bought this and there is no repeated tag. Buy the upgrade
  1895. if(power >= upgradeprice && ((shoppurchasedoc["repeated"] > shoppurchasedoc["purchased"]) || (shoppurchasedoc["purchased"] == 0 && !shoppurchasedoc["repeated"]))){
  1896. addlog("bought " . shoppurchasedoc["name"] . " " . shoppurchasedoc["purchased"] . " > " . shoppurchasedoc["purchased"] + 1 . ". Power -" . upgradeprice, "shop")
  1897. changepower(upgradeprice, "subtract")
  1898. shoppurchasedoc["purchased"] += 1
  1899. if(!stats["upgradespurchased"]){
  1900. stats["upgradespurchased"] := 0
  1901. }
  1902. stats["upgradespurchased"] += 1
  1903. }
  1904. else if(shoppurchasedoc["purchased"] >= shoppurchasedoc["repeated"] || !shoppurchasedoc["repeated"]){
  1905. totaldescription .= "No more levels of that upgrade available`n"
  1906. }
  1907. else if(upgradeprice > power){
  1908. totaldescription .= "Not enough power (need " . round(upgradeprice - power) . " more)`n"
  1909. }
  1910. }
  1911. ;this creates the description of the upgrade based on what they boost and their associated description. Use tostring(name of upgrade) to see how the array and its description look.
  1912. totaldescription .= shoppurchasedoc["name"] . "`n"
  1913. if(shoppurchasedoc["repeated"] > hoppurchasedoc["purchased"]){
  1914. totaldescription .= "Cost: " . upgradeprice . "`n"
  1915. }
  1916. if(shoppurchasedoc["repeated"]){
  1917. totaldescription .= "Level: " . shoppurchasedoc["purchased"] . "/" . shoppurchasedoc["repeated"] . "`n"
  1918. }
  1919. else{
  1920. totaldescription .= "Level: " . shoppurchasedoc["purchased"] . "`n"
  1921. }
  1922. for UpgradeDescrA, UpgradeDescrB in shoppurchasedoc{
  1923. if(UpgradeDescrA == "clickpower"){
  1924. totaldescription .= "+" . UpgradeDescrB . " power gained for every click. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1925. }
  1926. if(UpgradeDescrA == "clickpowerpercent"){
  1927. totaldescription .= "+" . UpgradeDescrB . "% power gained for every click (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1928. }
  1929. if(UpgradeDescrA == "movepower"){
  1930. totaldescription .= "+" . UpgradeDescrB . " power gained for moving the mouse. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1931. }
  1932. if(UpgradeDescrA == "movepowerpercent"){
  1933. totaldescription .= "+" . UpgradeDescrB . "% power gained for moving the mouse. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1934. }
  1935. if(UpgradeDescrA == "movespeedtopower"){
  1936. totaldescription .= "+" . UpgradeDescrB . " power gained every time the mouse moves. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1937. }
  1938. if(UpgradeDescrA == "movespeed"){
  1939. totaldescription .= "+" . UpgradeDescrB . " to mouse movement efficiency. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1940. }
  1941. if(UpgradeDescrA == "harvestpower"){
  1942. totaldescription .= "+" . UpgradeDescrB . " power gained from harvested plants. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1943. }
  1944. if(UpgradeDescrA == "harvestpowerpercent"){
  1945. totaldescription .= "+" . UpgradeDescrB . "% power gained from harvested plants. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1946. }
  1947. if(UpgradeDescrA == "plantchance"){
  1948. totaldescription .= "+" . UpgradeDescrB . "% plant appearance rate. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1949. }
  1950. if(UpgradeDescrA == "treasurepower"){
  1951. totaldescription .= "+" . UpgradeDescrB . " power gained from hidden treasures. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1952. }
  1953. if(UpgradeDescrA == "keyboardkeypower"){
  1954. totaldescription .= "+" . UpgradeDescrB . " power gained from keyboard keys. (" . UpgradeDescrB * shoppurchasedoc["purchased"] . ") total`n"
  1955. }
  1956. if(UpgradeDescrA == "knowledgepower"){
  1957. totaldescription .= "each point of knowledge grants + " . UpgradeDescrB . "% power generation from all sources`n"
  1958. }
  1959. }
  1960. totaldescription .= shoppurchasedoc["descr"]
  1961. addtooltip(totaldescription, 150, "shopdescription")
  1962. updatemain()
  1963. }
  1964.  
  1965. updategardeneffects(){
  1966. global
  1967.  
  1968. farmclickpower := 0
  1969. farmclickpowerpercent := 0
  1970. farmmovepower := 0
  1971. farmmovepowerpercent := 0
  1972. farmharvestpower := 0
  1973. farmharvestpowerpercent := 0
  1974. farmmovespeed := 0
  1975. farmmovespeedpercent := 0
  1976. farmmovespeedtopower := 0
  1977. farmmovespeedtopowerpercent := 0
  1978. farmtreasurepower := 0
  1979. farmtreasurepowerpercent := 0
  1980. farmkeyboardkeypower := 0
  1981. farmkeyboardkeypowerpercent := 0
  1982. farmknowledge := 0
  1983. farmknowledgepercent := 0
  1984. ;all plant effects are here. They need to be set to 0 here otherwise things that use them return empty string instead of an actual number.
  1985.  
  1986. loop, % gardentiles{
  1987. GX := mod(A_index, 10)
  1988. GY := ceil(A_index / 10)
  1989. if(GX == 0){
  1990. GX = 10
  1991. }
  1992. ;remove the temporary effects on tiles. FIRST. Otherwise effects from plants to the top or left get wiped.
  1993. tile%GX%A%GY%["temp"] := {}
  1994. }
  1995. loop, % gardentiles{
  1996. GX := mod(A_index, 10)
  1997. GY := ceil(A_index / 10)
  1998. if(GX == 0){
  1999. GX = 10
  2000. }
  2001. if(tile%GX%A%GY%["plant"]["auras"]){
  2002. loop, % tile%GX%A%GY%["nextto"].MaxIndex(){
  2003. nexttoentry := tile%GX%A%GY%["nextto"][A_index]
  2004. tile%nexttoentry%["temp"] := fusearrays([tile%nexttoentry%["temp"], tile%GX%A%GY%["plant"]["auras"]])
  2005. ;the temp stat of a plant gets combined with the auras of all nearby plants
  2006. }
  2007. }
  2008. }
  2009. ;This part was rather complicated so I put all plant effects here so I can easily take a look at them
  2010. ;tree := {harvest:{harvestpower:25}, global:{clickpower:1}}
  2011. ;barkwood := {harvest:{harvestpower:50}, passive:{harvestpowerpercent:400}}
  2012. ;titantree := {harvest:{harvestpower:300}, global:{harvestpowerpercent:10}}
  2013. ;flower := {global:{clickpowerpercent:1}}
  2014. ;yellowberry := {name: "Y berry"}
  2015. ;bluestalk := {harvest:{harvestpower:350}, global:{clickpower:3}}
  2016. ;appletree := {harvest:{harvestpower:170}, global:{clickpowerpercent:4}}
  2017. ;yellowbulb := {name: "Y bulb", harvest:{tpower:250}}
  2018. ;yellowstalk := {harvest:{harvestpower:100}, global:{clickpower:2, movepower: 1, clickpowerpercent:1}}
  2019. ;dimbloom := {harvest:{harvestpower:200}, global:{clickpowerpercent:9}}
  2020. ;greenstalk := {harvest:{harvestpower:450}, global:{clickpower:5, movepower:1, clickpowerpercent:1}}
  2021. ;sapleaf := {auras:{global:{clickpower:1}, harvest:{harvestpower:1, harvestpowerpercent:5}}, tileauras:{harvest:{harvestpowerpercent:5}}}
  2022. ;grimpetal := {global:{clickpower:1}, auras:{passive:{clickpowerpercent:5}}}
  2023. ;gripvine := {global:{movepower:5, movespeed:1}}
  2024. ;GX := 2
  2025. ;GY := 2
  2026. ;farmvalue := fusearrays([tile%GX%A%GY%["plant"], tile%GX%A%GY%["temp"]])
  2027. ;msgbox % arraytostring(farmvalue)
  2028. loop, % gardentiles{
  2029. GX := mod(A_index, 10)
  2030. GY := ceil(A_index / 10)
  2031. if(GX == 0){
  2032. GX = 10
  2033. }
  2034. if(tile%GX%A%GY%["plant"]["name"]){
  2035. ;this part gathers all the stats of all plants and puts them into one appropriate value for each different stat for other features to use.
  2036. farmvalue := fusearrays([tile%GX%A%GY%["plant"], tile%GX%A%GY%["permanent"], tile%GX%A%GY%["temp"]])
  2037. ;msgbox % arraytostring(farmvalue) ;shows the entire array of what the tile with its plant, temp and permanent effects look like
  2038. for gardeneffectentry, gardeneffectcontent in farmvalue["global"]{
  2039. ;gardenglobalbonus contains the global bonus
  2040. gardenglobalbonus := gardeneffectcontent
  2041. Stringright, farmvalue3, gardeneffectentry, 7
  2042. if(farmvalue3 <> "percent"){
  2043. gardenpassivebonus := farmvalue["passive"][gardeneffectentry]
  2044. ;gardenpassive bonus contains an added passive bonus for the global bonus
  2045. }
  2046. gardenpassivepercentbonus := farmvalue["passive"][gardeneffectentry . "percent"]
  2047. ;gardenpassivepercent bonus contains an added passive % bonus for the global bonus
  2048. if gardenpassivebonus is not number
  2049. {
  2050. gardenpassivebonus := 0
  2051. }
  2052. if gardenpassivepercentbonus is not number
  2053. {
  2054. gardenpassivepercentbonus := 0
  2055. }
  2056. if(!farmvalue[gardeneffectentry]){
  2057. farmvalue[gardeneffectentry] := 0
  2058. }
  2059. farm%gardeneffectentry% += (gardenglobalbonus + gardenpassivebonus) * ((gardenpassivepercentbonus / 100) + 1)
  2060. }
  2061. }
  2062. }
  2063. }
  2064.  
  2065. purchasetile_onclick(purchasedoc){
  2066. global
  2067. ;handles purchasing garden/freezer tiles. Its very similar to buying upgrades. The price is 300 power for every garden tile + 8% for every garden tile. The price for freezer tiles is 400 per freezer tile + 8% per freezer tile
  2068. purchasedoc := purchasedoc.topurchase
  2069. if(purchasedoc == "gardentile"){
  2070. if(power >= tileprice("garden") && 100 > gardentiles){
  2071. changepower(tileprice("garden"), "subtract")
  2072. addlog("bought garden tile " . gardentiles . ". Power -" . tileprice("garden"), "garden")
  2073. gardentiles += 1
  2074. updatemain()
  2075. }
  2076. }
  2077. else if(purchasedoc == "freezertile"){
  2078. if(power >= tileprice("freezer") && 100 > freezertiles){
  2079. changepower(tileprice("freezer"), "subtract")
  2080. addlog("bought freezer tile " . freezertiles . ". Power -" . tileprice("freezer"), "garden")
  2081. freezertiles += 1
  2082. updatemain()
  2083. }
  2084. }
  2085. }
  2086.  
  2087. garden_onclick(gardendoc){
  2088. global
  2089. updategardeneffects()
  2090. contents := gardendoc.id
  2091. contents := % %contents%
  2092. loginfo := ""
  2093. ;when any tile on the garden/freezer is clicked. This activates. The biggest part here is assembling the description for the tiles based on what's on there at the moment
  2094. farmvalue := fusearrays([contents["plant"], contents["permanent"], contents["temp"]])
  2095. ;when trying to harvest a plant. This part activates
  2096. if (gardenmode == "harvest" && featuredoc.getElementById(gardendoc.id).getAttribute("disable") <> "disabled" && !contents["plant"]["protected"]){
  2097. if(farmvalue["name"] == ""){
  2098. ;addtooltip("there is no plant here to harvest")
  2099. }
  2100. else{
  2101. contents["plant"] := ""
  2102. addlog("Harvested a " . farmvalue["name"], "garden")
  2103. descr := "harvested " . farmvalue["name"]
  2104. loginfo .= "harvested " . farmvalue["name"]
  2105. gardentreasurelog := ""
  2106. for farmentry, farmcontent in allplants{
  2107. if(farmcontent["name"] == farmvalue["name"]){
  2108. ;show new harvested plants in the almanac
  2109. plantknowledge[farmentry]["seen"] := 1
  2110. }
  2111. }
  2112. farmvalue2 := {}
  2113. farmvalue2["harvest"] := fusearrays([farmvalue["harvest"], farmvalue["passive"], farmvalue["global"]])
  2114. for gardenentry, gardencontent in farmvalue2["harvest"]{
  2115. if(gardenentry == "harvestpower"){
  2116. gardenvalue := calculateharvestvalue(farmvalue2)
  2117. ;plant example
  2118. ;barkwood := {rarity: 25, descr: "A small but dense tree. Its bark makes for a great power source but sadly this plant has barely any of it", name:"barkwood", harvest:{power:5}, passive:{harvestpowerpercent:400}}
  2119. descr .= "`ngained " . gardenvalue . " power"
  2120. addlog("Harvested a " . farmvalue["name"] . ". Gained " . gardenvalue . " Power.", "power")
  2121. changepower(gardenvalue)
  2122. if(!stats["powerharvested"]){
  2123. stats["powerharvested"] := 0
  2124. }
  2125. stats["powerharvested"] += gardenvalue
  2126. }
  2127. if(gardenentry == "chest"){
  2128. gardentreasurelog .= "Harvested a " . farmvalue["name"] . ". Gained " . gardencontent . " chest"
  2129. descr .= "`ngained " . gardencontent . " chest"
  2130. if(gardenvalue <> 1){
  2131. gardentreasurelog .= "s"
  2132. descr .= "s"
  2133. }
  2134. gardentreasurelog .= "`n"
  2135. treasurechests += gardencontent
  2136. if(!stats["treasurechestsfound"]){
  2137. stats["treasurechestsfound"] := 0
  2138. }
  2139. stats["treasurechestsfound"] += gardencontent
  2140. }
  2141. if(gardenentry == "key"){
  2142. gardentreasurelog .= "Harvested a " . farmvalue["name"] . ". Gained " . gardencontent . " key"
  2143. descr .= "`ngained " . gardencontent . " key"
  2144. if(gardenvalue <> 1){
  2145. gardentreasurelog .= "s"
  2146. descr .= "s"
  2147. }
  2148. gardentreasurelog .= "`n"
  2149. goldenkeys += gardencontent
  2150. if(!stats["goldenkeysfound"]){
  2151. stats["goldenkeysfound"] := 0
  2152. }
  2153. stats["goldenkeysfound"] += gardencontent
  2154. }
  2155. if(gardenentry == "knowledge"){
  2156. gardenvalue := calculateknowledge(farmvalue2)
  2157. if(!almanacunlocked){
  2158. almanacunlocked := 1
  2159. addtooltip("You could harness this knowledge into something useful. You unlocked the almanac", 100)
  2160. }
  2161. plantknowledge["knowledge"] += gardenvalue
  2162. descr .= "`ngained " . gardenvalue . " knowledge"
  2163. }
  2164. }
  2165. if(farmvalue["fusion"]){
  2166. ;this entire part handles plant fusion. Its rather complex
  2167. fusiontargets := []
  2168. loop, % contents["nextto"].Maxindex(){
  2169. farmvalue2 := contents["nextto"][A_index]
  2170. if (tile%farmvalue2%["plant"] && (!tile%farmvalue2%["plant"]["weakness"] || farmvalue["fusion"]["strength"] > tile%farmvalue2%["plant"]["weakness"] || limitlessfusions == "true") && (!tile%farmvalue2%["plant"]["fusion"])){
  2171. fusiontargets.push(tile%farmvalue2%["plant"])
  2172. ;gather all plants around the harvested tile that have less weakness than the harvested plant has strength
  2173. }
  2174. }
  2175. while(fusiontargets.MaxIndex() > farmvalue["fusion"]["amount"]){
  2176. random, farmrngesus, 1, fusiontargets.MaxIndex()
  2177. fusiontargets.remove(farmrngesus)
  2178. }
  2179. ;then it removes random ones until it has equal or less than the max amount of plants it can fuse. The rest is handled in the createamalgamplant() function which combines the stats of the selected plants
  2180. amalgamplant := createamalgamplant(fusiontargets, farmvalue["fusion"])
  2181. if(amalgamplant){
  2182. loginfo := "Harvesting the " . farmvalue["name"] . " made it target " . fusiontargets.Maxindex() . " plant"
  2183. descr .= "`n fused " . fusiontargets.Maxindex() . " plant"
  2184. if(fusiontargets.MaxIndex() <> 1){
  2185. loginfo .= "s"
  2186. descr .= "s"
  2187. }
  2188. descr .= " together into one plant"
  2189. loginfo .= " and added their stats together forming an " . amalgamplant["name"] . " on tile " . contents["location"][1] . " - " . contents["location"][2]
  2190. addlog(loginfo, "garden")
  2191. }
  2192. }
  2193. if(amalgamplant){
  2194. contents["plant"] := amalgamplant
  2195. amalgamplant := ""
  2196. if(!stats["gardenplantscreated"]){
  2197. stats["gardenplantscreated"] := 0
  2198. }
  2199. stats["gardenplantscreated"] += 1
  2200. }
  2201. if(gardentreasurelog){
  2202. addlog(gardentreasurelog)
  2203. }
  2204. if(!stats["plantsharvested"]){
  2205. stats["plantsharvested"] := 0
  2206. }
  2207. stats["plantsharvested"] += 1
  2208. addtooltip(descr, 100, "gardendescription")
  2209. updategardeneffects()
  2210. }
  2211. }
  2212. if(gardenmode == "swap"){
  2213. if(!plantselect){
  2214. plantselect := objfullyclone(contents)
  2215. ;I don't really understand how these clones work but it prevents changing arrays in weird ways. The normal clone() function is imperfect so objfullyclone() handles that
  2216. }
  2217. else if(plantselect == contents){
  2218. plantselect := ""
  2219. }
  2220. else{
  2221. ;change the location of both selected plants.
  2222. swapprepvalue2 := plantselect["location"][1]
  2223. swapprepvalue3 := plantselect["location"][2]
  2224. swapprepvalue4 := contents["location"][1]
  2225. swapprepvalue5 := contents["location"][2]
  2226. ;plantselect == first clicked tile. contents == second clicked tile
  2227. if(plantselect["location"][3] == "freezer"){
  2228. freezertile%swapprepvalue2%A%swapprepvalue3%["plant"] := contents["plant"]
  2229. }
  2230. else{
  2231. tile%swapprepvalue2%A%swapprepvalue3%["plant"] := contents["plant"]
  2232. }
  2233. if(contents["location"][3] == "freezer"){
  2234. freezertile%swapprepvalue4%A%swapprepvalue5%["plant"] := plantselect["plant"]
  2235. }
  2236. else{
  2237. tile%swapprepvalue4%A%swapprepvalue5%["plant"] := plantselect["plant"]
  2238. }
  2239. plantselect := ""
  2240. }
  2241. if(plantselect){
  2242. addtooltip("selected " . plantselect["plant"]["name"] . " in the " . selectedfeature . " on tile " . plantselect["location"][1] . "-" . plantselect["location"][2], 150, "gardendescription")
  2243. }
  2244. updategardeneffects()
  2245. updatemain()
  2246. }
  2247. if(gardenmode == "protect"){
  2248. ;protect is really simple. It just switches a value on the plant.
  2249. if(!contents["plant"]["protected"]){
  2250. contents["plant"]["protected"] := 1
  2251. }
  2252. else{
  2253. contents["plant"]["protected"] := 0
  2254. }
  2255. }
  2256. if(gardenmode == "inspect"){
  2257. ;re-assign farmvalue because the clicked plant may have been swapped or harvested
  2258. farmvalue := fusearrays([contents["plant"], contents["permanent"], contents["temp"]])
  2259. addtooltip(getplantdescription(farmvalue, "`n", contents, gardendoc), 150, "gardendescription")
  2260. }
  2261. updatemain()
  2262. }
  2263.  
  2264. getplantdescription(plant, break, tile:="", doc:=""){
  2265. global
  2266. ;ahk tooltip's use `n to create a new line why html uses </br>
  2267. descr := ""
  2268. if(tile){
  2269. descr .= tile["location"][3] . " tile " . tile["location"][1] . "-" . tile["location"][2]
  2270. }
  2271. if(plant["name"]){
  2272. descr .= " (" . plant["name"] . ")"
  2273. if(featuredoc.getElementById(doc.id).getAttribute("disable") && doc.disable == "disabled"){
  2274. descr .= break . "The plant here is currently inactive because its garden tile disappeared." . break . "It can't be moved or harvested and has no effects."
  2275. }
  2276. }
  2277. descr .= break
  2278. farmvalue := fusearrays([tile["temp"], tile["permanent"]])
  2279. for farmentry, farmcontent in farmvalue{
  2280. if(farmentry == "global" && farmcontent["clickpower"]){
  2281. descr .= "plants here gain +" . round(farmcontent["clickpower"]) . " power per click" . break
  2282. }
  2283. if(farmentry == "passive" && farmcontent["clickpowerpercent"]){
  2284. descr .= "increases the click power by " . round(farmcontent["clickpowerpercent"], 3) . "% on plants here" . break
  2285. }
  2286. if(farmentry == "global" && farmcontent["movepower"]){
  2287. descr .= "plants here gain +" . round(farmcontent["movepower"]) . " move power" . break
  2288. }
  2289. if(farmentry == "passive" && farmcontent["movepowerpercent"]){
  2290. descr .= "increases the move power by " . round(farmcontent["movepowerpercent"], 3) . "% to plants here" . break
  2291. }
  2292. if(farmentry == "passive" && farmcontent["harvestpower"]){
  2293. descr .= "plants here gain +" . round(farmcontent["harvestpower"]) . " power when harvested" . break
  2294. }
  2295. if(farmentry == "passive" && farmcontent["harvestpowerpercent"]){
  2296. descr .= "increases resources harvested by " . round(farmcontent["harvestpowerpercent"], 3) . "% to plants here" . break
  2297. }
  2298. if(farmentry == "global" && farmcontent["harvestpowerpercent"]){
  2299. descr .= "plants here grant +" . round(farmcontent["harvestpowerpercent"], 3) . "% resources harvested from all plants" . break
  2300. }
  2301. if(farmentry == "global" && farmcontent["treasurepower"]){
  2302. descr .= "plants here gain +" . round(farmcontent["treasurepower"], 3) . " power when finding treasures" . break
  2303. }
  2304. if(farmentry == "passive" && farmcontent["treasurepowerpercent"]){
  2305. descr .= "Increases the treasure power gained by " . round(farmcontent["treasurepowerpercent"], 3) . "% to plants here" . break
  2306. }
  2307. if(farmentry == "global" && farmcontent["keyboardkeypower"]){
  2308. descr .= "plants here gain +" . round(farmcontent["keyboardkeypower"], 3) . " power when pressing keyboard keys" . break
  2309. }
  2310. if(farmentry == "passive" && farmcontent["keyboardkeypowerpercent"]){
  2311. descr .= "Increases the keyboard key power gained by " . round(farmcontent["keyboardkeypowerpercent"], 3) . "% to plants here" . break
  2312. }
  2313. if(farmentry == "passive" && farmcontent["knowledge"]){
  2314. descr .= "plants here grant +" . farmcontent["knowledge"] . " knowledge points when harvested" . break
  2315. }
  2316. if(farmentry == "passive" && farmcontent["knowledgepercent"]){
  2317. descr .= "Increases knowledge points gained by " . round(farmcontent["knowledgepercent"], 3) . "% to plants here" . break
  2318. }
  2319. if(farmentry == "global" && farmcontent["knowledgepercent"]){
  2320. descr .= "plants here grant +" . round(farmcontent["knowledgepercent"], 3) . "% knowledge points harvested to all plants" . break
  2321. }
  2322. if(farmentry == "passive" && farmcontent["toxic"]){
  2323. descr .= "Something is preventing basic plants from spawning here" . break
  2324. }
  2325. }
  2326. if(plant["rarity"]){
  2327. descr .= break . "Plant rarity: " . plant["rarity"] . " (lower numbers mean a rarer plant)" . break
  2328. }
  2329. if((plant["global"] || plant["auras"] || plant["tileauras"]) && plant["name"]){
  2330. descr .= break . "Passive bonusses:" . break
  2331. if(gardenselection == "freezer"){
  2332. descr .= "These do currently not apply because the plant is frozen" . break
  2333. }
  2334. ;msgbox % arraytostring(farmvalue["global"])
  2335. for farmentry, farmcontent in plant["global"]{
  2336. farmglobalbonus := farmcontent
  2337. Stringright, farmvalue, farmentry, 7
  2338. if(farmvalue <> "percent"){
  2339. farmpassivebonus := plant["passive"][farmentry]
  2340. ;gardenpassive bonus contains an added passive bonus for the global bonus
  2341. }
  2342. farmpassivepercentbonus := plant["passive"][farmentry . "percent"]
  2343. if farmpassivebonus is not number
  2344. {
  2345. farmpassivebonus := 0
  2346. }
  2347. if farmpassivepercentbonus is not number
  2348. {
  2349. farmpassivepercentbonus := 0
  2350. }
  2351. ;msgbox % farmpassivepercentbonus . ", " . farmpassivebonus . ", " farmglobalbonus . ", " . round((farmglobalbonus + farmpassivebonus) * ((farmpassivepercentbonus / 100) + 1))
  2352. if(farmentry == "clickpower"){
  2353. descr .= "Increases power gain from clicking by " . round((farmglobalbonus + farmpassivebonus) * ((farmpassivepercentbonus / 100) + 1)) break
  2354. }
  2355. if(farmentry == "clickpowerpercent"){
  2356. descr .= "Increases power gain from clicking by " . round(farmcontent, 3) . "%" . break
  2357. }
  2358. if(farmentry == "movepower"){
  2359. descr .= "Increases power gain from moving the mouse by " . round((farmglobalbonus + farmpassivebonus) * ((farmpassivepercentbonus / 100) + 1)) break
  2360. }
  2361. if(farmentry == "movepowerpercent"){
  2362. descr .= "Increases power gain from moving the mouse by " . round(farmcontent, 3) . "%" . break
  2363. }
  2364. if(farmentry == "movespeed"){
  2365. descr .= "Increases mouse movement efficiency by " . round((farmglobalbonus + farmpassivebonus) * ((farmpassivepercentbonus / 100) + 1)) break
  2366. }
  2367. if(farmentry == "harvestpower"){
  2368. descr .= "Increases power gain from all harvested plants by " . round((farmglobalbonus + farmpassivebonus) * ((farmpassivepercentbonus / 100) + 1)) break
  2369. }
  2370. if(farmentry == "harvestpowerpercent"){
  2371. descr .= "Increases power gain from all harvested plants by " . round(farmcontent, 3) . "%" . break
  2372. }
  2373. if(farmentry == "treasurepower"){
  2374. descr .= "Increases power gain from treasures by " . round((farmglobalbonus + farmpassivebonus) * ((farmpassivepercentbonus / 100) + 1)) break
  2375. }
  2376. if(farmentry == "treasurepowerpercent"){
  2377. descr .= "Increases power gain from treasures by " . round(farmcontent, 3) . "%" . break
  2378. }
  2379. if(farmentry == "keyboardkeypower"){
  2380. descr .= "Increases power gain from keyboard keys by " . round((farmglobalbonus + farmpassivebonus) * ((farmpassivepercentbonus / 100) + 1)) . "%" . break
  2381. }
  2382. if(farmentry == "keyboardkeypowerpercent"){
  2383. descr .= "Increases power gain from keyboard keys by " . round(farmcontent, 3) . "%" . break
  2384. }
  2385. }
  2386. ;msgbox % arraytostring(farmvalue["auras"])
  2387. for farmentry, farmcontent in plant["auras"]{
  2388. if(farmentry == "global" && farmcontent["clickpower"]){
  2389. descr .= "boosts the power per click of plants around this by " . farmcontent["clickpower"] break
  2390. }
  2391. if(farmentry == "passive" && farmcontent["clickpowerpercent"]){
  2392. descr .= "boosts the power per click % bonus of plants around this by " . farmcontent["clickpowerpercent"] . "%" . break
  2393. }
  2394. if(farmentry == "global" && farmcontent["movepower"]){
  2395. descr .= "boosts the power gained from moving the mouse of plants around this by " . farmcontent["movepower"] break
  2396. }
  2397. if(farmentry == "passive" && farmcontent["movepowerpercent"]){
  2398. descr .= "boosts the power % gained from moving the mouse of plants around this by " . farmcontent["movepowerpercent"] . "%" . break
  2399. }
  2400. if(farmentry == "passive" && farmcontent["harvestpower"]){
  2401. descr .= "boosts the power gained from harvesting plants around this by " . farmcontent["harvestpower"] break
  2402. }
  2403. if(farmentry == "passive" && farmcontent["harvestpowerpercent"]){
  2404. descr .= "boosts the power gained from harvesting plants around this by " . farmcontent["harvestpowerpercent"] . "%" . break
  2405. }
  2406. if(farmentry == "global" && farmcontent["treasurepower"]){
  2407. descr .= "boosts the power gained from hidden treasures of plants around this by " . farmcontent["treasurepower"] break
  2408. }
  2409. if(farmentry == "passive" && farmcontent["treasurepowerpercent"]){
  2410. descr .= "boosts the power gained from hidden treasures of plants around this by " . farmcontent["treasurepowerpercent"] . "%" . break
  2411. }
  2412. if(farmentry == "global" && farmcontent["keyboardkeypower"]){
  2413. descr .= "boosts the power gained from keyboard keys of plants around this by " . farmcontent["keyboardkeypower"] . "%" . break
  2414. }
  2415. if(farmentry == "passive" && farmcontent["keyboardkeypowerpercent"]){
  2416. descr .= "boosts the power gained from keyboard keys of plants around this by " . farmcontent["keyboardkeypowerpercent"] . "%" . break
  2417. }
  2418. if(farmentry == "passive" && farmcontent["knowledge"]){
  2419. descr .= "boosts the knowledge gained from plants around this by " . farmcontent["knowledge"] break
  2420. }
  2421. if(farmentry == "passive" && farmcontent["knowledgepercent"]){
  2422. descr .= "boosts the knowledge gained from plants around this by " . farmcontent["knowledgepercent"] . "%" . break
  2423. }
  2424. if(farmentry == "passive" && farmcontent["toxic"]){
  2425. descr .= "prevents basic plants from appearing around this" . break
  2426. }
  2427. }
  2428. ;msgbox % arraytostring(farmvalue["tileauras"])
  2429. for farmentry, farmcontent in plant["tileauras"]{
  2430. ;rootwraith := {auras:{passive:{harvestpower:15, harvestpowerpercent:7}}, tileauras:{passive:{harvestpower:10}, global:{harvestpowerpercent:1}}}
  2431. if(farmentry == "global" && farmcontent["clickpower"]){
  2432. descr .= "slowly affects nearby tiles with a permanent bonus to click power. up to a max of " . farmcontent["clickpower"] break
  2433. }
  2434. if(farmentry == "passive" && farmcontent["clickpowerpercent"]){
  2435. descr .= "slowly affects nearby tiles with a permanent bonus to click power. up to a max of " . farmcontent["clickpowerpercent"] . "%" . break
  2436. }
  2437. if(farmentry == "global" && farmcontent["movepower"]){
  2438. descr .= "slowly affects nearby tiles with a permanent bonus to move power. up to a max of " . farmcontent["movepower"] break
  2439. }
  2440. if(farmentry == "passive" && farmcontent["movepowerpercent"]){
  2441. descr .= "slowly affects nearby tiles with a permanent bonus to move power. up to a max of " . farmcontent["movepowerpercent"] . "%" . break
  2442. }
  2443. if(farmentry == "passive" && farmcontent["harvestpower"]){
  2444. descr .= "slowly affects nearby tiles with a permanent bonus to harvest power. up to a max of " . farmcontent["harvestpower"] break
  2445. }
  2446. if(farmentry == "passive" && farmcontent["harvestpowerpercent"]){
  2447. descr .= "slowly affects nearby tiles with a permanent bonus to harvest power. up to a max of " . farmcontent["harvestpowerpercent"] . "%" . break
  2448. }
  2449. if(farmentry == "global" && farmcontent["harvestpowerpercent"]){
  2450. descr .= "slowly affects nearby tiles with a permanent bonus to harvest power to all plants. up to a max of " . farmcontent["harvestpowerpercent"] . "%" . break
  2451. }
  2452. if(farmentry == "global" && farmcontent["treasurepower"]){
  2453. descr .= "slowly affects nearby tiles with a permanent bonus to treasure power. up to a max of " . farmcontent["treasurepower"] break
  2454. }
  2455. if(farmentry == "passive" && farmcontent["treasurepowerpercent"]){
  2456. descr .= "slowly affects nearby tiles with a permanent bonus to treasure power. up to a max of " . farmcontent["treasurepowerpercent"] . "%" . break
  2457. }
  2458. if(farmentry == "global" && farmcontent["keyboardkeypower"]){
  2459. descr .= "slowly affects nearby tiles with a permanent bonus to keyboard key power. up to a max of " . farmcontent["keyboardkeypower"] break
  2460. }
  2461. if(farmentry == "passive" && farmcontent["keyboardkeypowerpercent"]){
  2462. descr .= "slowly affects nearby tiles with a permanent bonus to keyboard key power. up to a max of " . farmcontent["keyboardkeypowerpercent"] break
  2463. }
  2464. if(farmentry == "global" && farmcontent["knowledgepercent"]){
  2465. descr .= "slowly affects nearby tiles with a permanent bonus to knowledge points gained from all plants up to a max of " . farmcontent["knowledgepercent"] . "%" . break
  2466. }
  2467. }
  2468. if(plant["weakness"]){
  2469. descr .= break . "Fusion weakness: " . plant["weakness"] . " (weakened plants can only be fused using plants with more strength than this has weakness)" . break
  2470. }
  2471. }
  2472. plant2 := {}
  2473. plant2["harvest"] := fusearrays([plant["harvest"], plant["passive"], plant["global"]])
  2474. for farmentry, farmcontent in plant2["harvest"]{
  2475. stringleft, farmvalue, farmentry, 7
  2476. if(farmvalue == "harvest"){
  2477. descr .= break . "Harvest rewards:" . break
  2478. if(gardenselection == "freezer"){
  2479. descr .= "move this plant to the garden to be able to harvest it" . break
  2480. }
  2481. break
  2482. }
  2483. }
  2484. for farmentry, farmcontent in plant2["harvest"]{
  2485. farmglobalbonus := farmcontent
  2486. farmpassivepercentbonus := plant[farmentry . "percent"]
  2487. if farmpassivepercentbonus is not number
  2488. {
  2489. farmpassivepercentbonus := 0
  2490. }
  2491. if(farmentry == "harvestpower"){
  2492. descr .= "Power: " . calculateharvestvalue(plant2)
  2493. if(plant["harvest"]["harvestpower"]){
  2494. descr .= " (" . plant["harvest"]["harvestpower"] . ") default"
  2495. }
  2496. else{
  2497. descr .= " (0) default"
  2498. }
  2499. descr .= break
  2500. }
  2501. if(farmentry == "harvestseeds"){
  2502. descr .= "plants up" . floor(farmglobalbonus) . " plants around this."
  2503. }
  2504. if(farmentry == "chest"){
  2505. descr .= farmglobalbonus . " chest"
  2506. if(farmglobalbonus <> 1){
  2507. descr .= "s"
  2508. }
  2509. descr .= break
  2510. }
  2511. if(farmentry == "key"){
  2512. descr .= farmglobalbonus . " key"
  2513. if(farmglobalbonus <> 1){
  2514. descr .= "s"
  2515. }
  2516. descr .= break
  2517. }
  2518. if(farmentry == "knowledge"){
  2519. descr .= "plant knowledge: " . calculateknowledge(plant2)
  2520. if(plant["harvest"]["knowledge"]){
  2521. descr .= " (" . plant["harvest"]["knowledge"] . ") default"
  2522. }
  2523. else{
  2524. descr .= " (0) default"
  2525. }
  2526. descr .= break
  2527. }
  2528. }
  2529. if(plant["fusion"]){
  2530. descr .= break . "Fusion strength: " . plant["fusion"]["strength"] . " (Higher strength levels are required to fuse already fused plants together)" . break
  2531. descr .= "This plant copies the stats of up to " . plant["fusion"]["amount"] . " nearby plants when harvested and forms it together." . break . "Creating a single plant with the stats of all selected plants combined." . break
  2532. }
  2533. if(plant["descr"]){
  2534. descr .= break "Description: " . plant["descr"]
  2535. }
  2536. return descr
  2537. }
  2538.  
  2539. creategardenplant(fixedchance:=5, fixedposX:="", fixedposY:="", fixedplant:="", aggressive:=""){
  2540. global
  2541. ;fixedchance. If this value is given, the chance of a plant appearing for tiles checked will be a percentage equal to the given value. Say putting it on 50 gives a 50% for putting a plant on every tile
  2542. ;fixedposX, if this value is given, plants can only appear on the X location of the given value
  2543. ;fixedposY is pretty self explanatory now
  2544. ;aggressive, if this value is given. Plants will override other plants.
  2545. ;fixedplant should be filled with the array of a plant, examples are shown here below. This changes all plants changed to be this specific plant instead.
  2546. if(s0 >= garden["purchased"]){
  2547. ;no plants when there is no garden
  2548. return
  2549. }
  2550. loop, %gardentiles%{
  2551. SX := mod(A_index, gardenmaxX)
  2552. SY := ceil(A_index / gardenmaxY)
  2553. if(SX == 0){
  2554. SX = 10
  2555. }
  2556. if(fixedposX && SX <> fixedposX){
  2557. continue
  2558. ;continue just ends the current loop and starts a new one
  2559. }
  2560. if(fixedposY && SY <> fixedposY){
  2561. continue
  2562. }
  2563. if(tile%SX%A%SY%["plant"]["name"] == "" || aggressive){
  2564. random, rngesus, 1, 100
  2565. if(fixedchance >= rngesus || maxgardenplantchance == "true"){
  2566. ;plant combo example
  2567. ;plantcombos := [{pardners:["tree", "flower"], result:"appletree", rarity:100}]
  2568. random, trycombo, 1, 2
  2569. ;if trycombo is 2 it tries to create a combo plant which checks nearby tiles to see if it can create something
  2570. loop{
  2571. result := ""
  2572. if(trycombo == 2){
  2573. plantcombototal := {}
  2574. ;first it loops through every available combo
  2575. loop, % plantcombos.MaxIndex(){
  2576. plantloop := A_index
  2577. plantsneeded := {}
  2578. ;an array is created containing a number according to the plant needed.
  2579. loop, % plantcombos[plantloop]["Pardners"].MaxIndex(){
  2580. whatneeded := plantcombos[plantloop]["Pardners"][A_index]
  2581. whatneeded := %whatneeded%["name"]
  2582. if(!plantsneeded[whatneeded]){
  2583. plantsneeded[whatneeded] := 0
  2584. }
  2585. plantsneeded[whatneeded] += 1
  2586. }
  2587. ;it checks all the tiles next to the selected tile and if it finds a plant that the combo needs. It subtracts 1 from the array.
  2588. for, creategardenplantentry, creategardenplantcontent in tile%SX%A%SY%["nextto"]{
  2589. if(plantsneeded[tile%creategardenplantcontent%["plant"]["name"]] > 0){
  2590. plantsneeded[tile%creategardenplantcontent%["plant"]["name"]] -= 1
  2591. }
  2592. }
  2593. ;so simple! it checks the entire array and gets the largest number. If its 0 then the combo is successful. Else it removes the combo from the current list and tries again.
  2594. if(0 >= objectminmax(plantsneeded, "max")){
  2595. random, rngesus3, 1, 1000
  2596. if(plantcombos[plantloop]["rarity"] * 10 >= rngesus3 || ignoreplantrarity == "true"){
  2597. plantcombototal.push(plantcombos[plantloop]["result"])
  2598. }
  2599. }
  2600. }
  2601. loop{
  2602. ;loop through all successful combos and choose one.
  2603. if(plantcombototal.MaxIndex() > 0){
  2604. random, rngesus3, 1, 1000
  2605. random, whichcombo, 1, plantcombototal.MaxIndex()
  2606. creategardenplantvalue := plantcombototal[whichcombo]
  2607. ;check the rarity. If the check fails. Remove this combo too and try the next one.
  2608. if(%creategardenplantvalue%["rarity"] * 10 >= rngesus3 || ignoreplantrarity == "true"){
  2609. ;if it succeeds. Put the plant in result which will be added to the garden
  2610. result := %creategardenplantvalue%
  2611. break
  2612. }
  2613. else{
  2614. plantcombototal.remove(whichcombo)
  2615. }
  2616. }
  2617. else{
  2618. break
  2619. }
  2620. }
  2621. if(plantcombototal.MaxIndex() >= 1){
  2622. break
  2623. }
  2624. else{
  2625. ;no combinations are possible. Create a normal non-combo plant instead
  2626. trycombo = 1
  2627. }
  2628. }
  2629. else{
  2630. random, rngesus2, 1, plants.MaxIndex()
  2631. random, rngesus3, 1, 1000
  2632. selectedplant := plants[rngesus2]
  2633. ;take a random plant from the list, check its rarity and if the check succeeds.
  2634. if((selectedplant["rarity"] * 10) >= rngesus3 || ignoreplantrarity == "true"){
  2635. ;if it succeeds. Put the plant in result which will be added to the garden
  2636. if(!tile%SX%A%SY%["temp"]["passive"]["toxic"]){
  2637. ;non-combo plants can not be created next to a toxic plant. No more useless clearing of dust trees and tick flowers while searching for those rare plants
  2638. result := selectedplant
  2639. }
  2640. break
  2641. }
  2642. }
  2643. }
  2644. random, gardentimerrngesus, 1, 1000
  2645. if(fixedplant){
  2646. result := fixedplant
  2647. }
  2648. if(result){
  2649. if(result["name"] == "lockbloom" && keyavailable){
  2650. result["symbol"] := keyavailable
  2651. }
  2652. tile%SX%A%SY%["plant"] := ObjFullyClone(result)
  2653. if(silentplants == "false" || silentplants >= gardentimerrngesus){
  2654. ;silentplants is a dev function which causes plants to not fill the logs as much as they normally do.
  2655. addlog(result["name"] . " appeared on tile " . SX . " - " . SY, "garden")
  2656. }
  2657. ;I had a lot of trouble with this until I figured out objfullyclone(). If I remove this function. Every plant will think its next to the same spaces
  2658. gardendocedit := gardendoc.getelementbyid("tile" . SX . "A" . SY)
  2659. storedplantname := tile%SX%A%SY%["plant"]["name"]
  2660. if(!stats["gardenplantscreated"]){
  2661. stats["gardenplantscreated"] := 0
  2662. }
  2663. stats["gardenplantscreated"] += 1
  2664. updategardeneffects()
  2665. }
  2666. updatemain()
  2667. }
  2668. }
  2669. }
  2670. }
  2671.  
  2672. gardentick(){
  2673. global
  2674. ;plant example
  2675. ;clickvine := {tileauras:{passive:{percent:{clickpower:5}, direct:{clickpower:5}}}}
  2676. ;this function activates whenever mouse movement tries to spawn garden plants.
  2677. ;this part handles garden ticks which happen after moving the mouse. The activate effects like permanent tile buffing.
  2678. loop, % gardentiles{
  2679. GTX := mod(A_index, 10)
  2680. GTY := ceil(A_index / 10)
  2681. if(GTX == 0){
  2682. GTX = 10
  2683. }
  2684. ;rootwraith := {tileauras:{global:{harvestpower:10, harvestpowerpercent:1}}}
  2685. gardentickvalue := fusearrays([tile%GTX%A%GTY%["plant"], tile%GTX%A%GTY%["passive"], tile%GTX%A%GTY%["permanent"]])
  2686. for gardentickentry, gardentickcontent in gardentickvalue["tileauras"]{
  2687. for gardentickentry2, gardentickcontent2 in gardentickvalue["tileauras"][gardentickentry]{
  2688. for, gardentickentry3, gardentickcontent3 in tile%GTX%A%GTY%["nextto"]{
  2689. ;this part is painfully complex but kinda required to handle this correctly.
  2690. if(!tile%gardentickcontent3%["permanent"]){
  2691. tile%gardentickcontent3%["permanent"] := {}
  2692. }
  2693. if(!tile%gardentickcontent3%["permanent"][gardentickentry]){
  2694. tile%gardentickcontent3%["permanent"][gardentickentry] := {}
  2695. }
  2696. if(!tile%gardentickcontent3%["permanent"][gardentickentry][gardentickentry2]){
  2697. tile%gardentickcontent3%["permanent"][gardentickentry][gardentickentry2] := 0
  2698. }
  2699. tile%gardentickcontent3%["permanent"][gardentickentry][gardentickentry2] += calculateauraincrease(gardentickcontent2, tile%gardentickcontent3%["permanent"][gardentickentry][gardentickentry2])
  2700. }
  2701. }
  2702. }
  2703. if(gardentickvalue["name"] == "lockbloom" && keyavailable){
  2704. ;lockbloom's symbol can randomly change to that of the current hidden key
  2705. random, gardentickrngesus, 1, 100
  2706. if(gardentickrngesus >= 98){
  2707. tile%GTX%A%GTY%["plant"]["symbol"] := keyavailable
  2708. }
  2709. }
  2710. }
  2711. updategardeneffects()
  2712. }
  2713.  
  2714. calculateauraincrease(plantmax, tilecurrent){
  2715. global maxgardenpermbuffs
  2716. ;the rate at which permanent buffs grow is higher based on the value on the plant and slows down after the value on the tile is higher.
  2717. ;there is a mimimum growth so the value doesn't stay right under the maximum all the time but it stops increasing at all once it reaches the max.
  2718. if tilecurrent is not number
  2719. {
  2720. tilecurrent := 0
  2721. }
  2722. a := (plantmax / 500) * (1 - min((tilecurrent + 1) / plantmax, 1)) + (plantmax / 1000)
  2723. if(tilecurrent + a >= plantmax || maxgardenpermbuffs == "true"){
  2724. a := max(plantmax - tilecurrent, 0)
  2725. }
  2726. return a
  2727. }
  2728.  
  2729. tileprice(value:=""){
  2730. global gardentiles, freezertiles
  2731. if(value == "garden"){
  2732. return round((200 * gardentiles) * (1.08 ** gardentiles))
  2733. }
  2734. else if(value == "freezer"){
  2735. return round((225 * freezertiles) * (1.08 ** freezertiles))
  2736. }
  2737. }
  2738.  
  2739. treasureopen_onclick(treasureopendoc){
  2740. global
  2741. ;activates when the open treasure button is clicked.
  2742. treasureopendoc := treasureopendoc.Mode
  2743. treasuretoopen := treasureopendoc
  2744. if (treasureopendoc == "all"){
  2745. treasuretoopen := Min(treasurekeys, treasurechests)
  2746. }
  2747. treasuresopened := "false"
  2748. ;loop once for every treasure chest to open
  2749. loop, % treasuretoopen{
  2750. if(treasurekeys >= 1 && treasurechests >= 1){
  2751. if(treasuresopened == "false"){
  2752. treasuresinfo := []
  2753. ;true when at least one chest has been opened. It resets the description of what happened
  2754. treasuresopened := "true"
  2755. }
  2756. treasurekeys -= 1
  2757. treasurechests -= 1
  2758. random, powergained, 5000, 10000
  2759. random, treasureartifacts, 0, 4
  2760. treasureresult := []
  2761. loop{
  2762. random, whichtreasure, 1, treasurestats.Count()
  2763. for, treasureentry, treasurecontent in treasures{
  2764. random, whichtreasurechance, 1, 100
  2765. if(A_index == whichtreasure){
  2766. if(treasurestats[treasureentry]["rarity"] >= whichtreasurechance){
  2767. treasureresult.Push(treasureentry)
  2768. treasureartifacts -= 1
  2769. }
  2770. if(0 >= treasureartifacts){
  2771. break
  2772. }
  2773. }
  2774. }
  2775. if(0 >= treasureartifacts){
  2776. break
  2777. }
  2778.  
  2779. }
  2780. if(!treasuresinfo["power"]){
  2781. treasuresinfo["power"] := [0, "power"]
  2782. }
  2783. treasuresinfo["power"][1] += powergained
  2784. changepower(powergained)
  2785. for each, treasureopencontent in treasureresult{
  2786. treasures[treasureopencontent] += 1
  2787. if(!treasuresinfo[treasureopencontent]){
  2788. treasuresinfo[treasureopencontent] := [0, treasurestats[treasureopencontent]["name"]]
  2789. }
  2790. treasuresinfo[treasureopencontent][1] += 1
  2791. }
  2792. }
  2793. }
  2794. if(treasuresopened == "true"){
  2795. ;turns the treasuresinfo string into an actual readable description and changes the description to that text.
  2796. if(!stats["chestsopened"]){
  2797. stats["chestsopened"] := 0
  2798. }
  2799. stats["chestsopened"] += treasuretoopen
  2800. treasureinfotext := "Last "
  2801. if(treasuretoopen > 1){
  2802. treasureinfotext .= treasuretoopen . " chests gave"
  2803. }
  2804. else{
  2805. treasureinfotext .= "chest gave"
  2806. }
  2807. for treasureopenentry, treasureopencontent in treasuresinfo{
  2808. treasureinfotext .= "</br>" . treasureopencontent[1] . " " . treasureopencontent[2]
  2809. if(treasureopencontent[1] <> 1 && treasureopenentry <> "power"){
  2810. treasureinfotext .= "s"
  2811. }
  2812. }
  2813. }
  2814. updatemain()
  2815. }
  2816.  
  2817. ObjFullyClone(obj){
  2818. ;no idea how this works but it solves my problems so.. Yay
  2819. nobj := obj.Clone()
  2820. for k,v in nobj
  2821. if IsObject(v)
  2822. nobj[k] := A_ThisFunc.(v)
  2823. return nobj
  2824. }
  2825.  
  2826. addlog(log, ID:="Default"){
  2827. global logs
  2828. ;this function adds an extra log to the pile...... Anyways. This stuff is handled in the updatelogs() function
  2829. if(!logs[ID]){
  2830. logs[ID] := []
  2831. }
  2832. logs[ID].push(log)
  2833. }
  2834.  
  2835. addtooltip(content:="nothingness", timer:=15, identifier:=""){
  2836. global tooltips
  2837. ;timer goes down by 1 around 5 times every second
  2838. loop{
  2839. if(!tooltips[A_index]){
  2840. tooltips[A_index] := {content:content, timer:timer, identifier:identifier}
  2841. break
  2842. }
  2843. }
  2844. }
  2845.  
  2846. ;I found this V function on the internet. Its a better way to put the tooltip next to the mouse which doesnt flicker.
  2847. ToolTipFM(Text="", WhichToolTip=16, xOffset=16, yOffset=16) { ; ToolTip which Follows the Mouse
  2848. static LastText, hwnd, VirtualScreenWidth, VirtualScreenHeight ; http://www.autohotkey.com/forum/post-430240.html#430240
  2849.  
  2850. if (VirtualScreenWidth = "" or VirtualScreenHeight = "")
  2851. {
  2852. SysGet, VirtualScreenWidth, 78
  2853. SysGet, VirtualScreenHeight, 79
  2854. }
  2855.  
  2856. if (Text = "") ; destroy tooltip
  2857. {
  2858. ToolTip,,,, % WhichToolTip
  2859. LastText := "", hwnd := ""
  2860. return
  2861. }
  2862. else ; move or recreate tooltip
  2863. {
  2864. CoordMode, Mouse, Screen
  2865. MouseGetPos, x,y
  2866. x += xOffset, y += yOffset
  2867. WinGetPos,,,w,h, ahk_id %hwnd%
  2868.  
  2869. ; if necessary, adjust Tooltip position
  2870. if ((x+w) > VirtualScreenWidth)
  2871. AdjustX := 1
  2872. if ((y+h) > VirtualScreenHeight)
  2873. AdjustY := 1
  2874.  
  2875. if (AdjustX and AdjustY)
  2876. x := x - xOffset*2 - w, y := y - yOffset*2 - h
  2877. else if AdjustX
  2878. x := VirtualScreenWidth - w
  2879. else if AdjustY
  2880. y := VirtualScreenHeight - h
  2881.  
  2882. if (Text = LastText) ; move tooltip
  2883. DllCall("MoveWindow", A_PtrSize ? "UPTR" : "UInt",hwnd,"Int",x,"Int",y,"Int",w,"Int",h,"Int",0)
  2884. else ; recreate tooltip
  2885. {
  2886. ; Perfect solution would be to update tooltip text (TTM_UPDATETIPTEXT), but must be compatible with all versions of AHK_L and AHK Basic.
  2887. ; My Ask For Help link: http://www.autohotkey.com/forum/post-421841.html#421841
  2888. CoordMode, ToolTip, Screen
  2889. ToolTip,,,, % WhichToolTip ; destroy old
  2890. ToolTip, % Text, x, y, % WhichToolTip ; show new
  2891. hwnd := WinExist("ahk_class tooltips_class32 ahk_pid " DllCall("GetCurrentProcessId")), LastText := Text
  2892. %A_ThisFunc%(Text, WhichToolTip, xOffset, yOffset) ; move new
  2893. }
  2894. Winset, AlwaysOnTop, on, ahk_id %hwnd%
  2895. }
  2896. }
  2897.  
  2898. removetooltip(identifier:="", all:="false"){
  2899. ;remove tooltips based on their identifier. Very versatile
  2900. global tooltips
  2901. loop{
  2902. if(!tooltips[A_index]){
  2903. break
  2904. }
  2905. else if(tooltips[A_index]["identifier"] == identifier || all <> "false"){
  2906. tooltips[A_index] := ""
  2907. }
  2908. }
  2909. }
  2910.  
  2911. isnum(number){
  2912. ;if (thing) is number is stupid and works really bad with and/or statements so dumped into a function it is.
  2913. if number is number
  2914. {
  2915. return 1
  2916. }
  2917. return 0
  2918. }
  2919.  
  2920. randompointonscreen(){
  2921. ;simple
  2922. random, X, 0, A_screenwidth
  2923. random, Y, 0, A_screenheight
  2924. return, [X, Y]
  2925. }
  2926.  
  2927. randomletter(){
  2928. ;gets a random letter from the alphabet. Used for golden keys
  2929. random, rngesus, 1, 26
  2930. return % Chr(rngesus+96)
  2931. }
  2932.  
  2933. arraytostring(object){
  2934. ;turns arrays and objects into strings.
  2935. ;very rough example. I haven't tested many things on it like inputting incorrect arrays.
  2936. firstrun := 1
  2937. firstrun2 := 1
  2938. result := object
  2939. for entry, content in object{
  2940. if(firstrun == 1){
  2941. result := "{"
  2942. firstrun == 0
  2943. }
  2944. result .= entry . ":" . arraytostring(content) . ", "
  2945. }
  2946. for entry, content in object{
  2947. if(firstrun2 == 1){
  2948. StringTrimright, result, result, 2
  2949. result .= "}"
  2950. firstrun2 := 0
  2951. }
  2952. }
  2953. if result is not number
  2954. if(firstrun2 == 1)
  2955. {
  2956. result := """" . result . """"
  2957. }
  2958. return result
  2959. }
  2960.  
  2961. stringToArray(String){
  2962. ;my experiment of turning strings into objects. Also very rough and will also break on array strings being sent instead of objects.
  2963. stringleft, a, string, 1
  2964. stringright, b, string, 1
  2965. if(a == "{"){
  2966. stringtrimleft, string, string, 1
  2967. }
  2968. if(b == "}"){
  2969. stringtrimright, string, string, 1
  2970. string .= ","
  2971. }
  2972. if(a <> "{" && b <> "}"){
  2973. return string
  2974. }
  2975. result := []
  2976. storedvalue := ""
  2977. bracketcount := 0
  2978. plaintext := "false"
  2979. part := 1
  2980. loop, parse, string
  2981. {
  2982. if(A_loopfield == """"){
  2983. if(plaintext == "false"){
  2984. plaintext := "true"
  2985. }
  2986. else{
  2987. plaintext := "false"
  2988. }
  2989. }
  2990. if(plaintext == "false" && bracketcount == 0){
  2991. if(A_loopfield == " "){
  2992. continue
  2993. }
  2994. if(A_loopfield == ":" && part == 1){
  2995. part := 2
  2996. storedpart := storedvalue
  2997. storedvalue := ""
  2998. continue
  2999. }
  3000. if(A_loopfield == "," && part == 2){
  3001. part := 1
  3002. result[storedpart] := stringtoarray(storedvalue)
  3003. storedvalue := ""
  3004. continue
  3005. }
  3006. if(A_loopfield == "{"){
  3007. bracketcount += 1
  3008. storedvalue := ""
  3009. }
  3010. }
  3011. else if(plaintext == "false" && bracketcount > 0){
  3012. if(A_loopfield == "{"){
  3013. bracketcount += 1
  3014. }
  3015. if(A_loopfield == "}"){
  3016. bracketcount -= 1
  3017. }
  3018. }
  3019. if(A_loopfield <> """" || bracketcount > 0){
  3020. dontstore := ""
  3021. storedvalue .= A_loopfield
  3022. if(A_loopfield == "e"){
  3023. }
  3024. }
  3025. }
  3026. if(!IsObject(result) || result.Count() == 0 || result.Count() == ""){
  3027. return, storedvalue
  3028. }
  3029. return, result
  3030. }
  3031.  
  3032. fusearrays(object){
  3033. result2 := {}
  3034. ;another very rought example similar to the arraytostring() and stringtoarray() but this one should work with any kind of array, object or string with no problems.
  3035. ;if one object has another object in place another one has an string or number. The object gets priority. Same with numbers over strings. If there's just strings. Only the one of the first plant gets used.
  3036. for entry, content in object{
  3037. if (IsObject(object[A_index]) || object[A_index].Count() > 0 || selected == "object"){
  3038. selected := "object"
  3039. }
  3040. else if (isnum(object[A_index]) || selected == "number"){
  3041. selected := "number"
  3042. }
  3043. else{
  3044. selected := "text"
  3045. }
  3046. }
  3047. for entry, content in object{
  3048. storedvalue := A_index
  3049. if (selected == "text"){
  3050. if(!result){
  3051. result := object[storedvalue]
  3052. }
  3053. }
  3054. else if(selected == "number"){
  3055. if result is not number
  3056. {
  3057. result := 0
  3058. }
  3059. result += object[storedvalue]
  3060. }
  3061. else if(selected == "object"){
  3062. for entry2, content2 in object[storedvalue]{
  3063. if(!result){
  3064. result := {}
  3065. }
  3066. if(!result[entry2]){
  3067. for entry3, content3 in object{
  3068. result2.Push(object[entry3][entry2])
  3069. }
  3070. result[entry2] := fusearrays(result2)
  3071. result2 := {}
  3072. }
  3073. }
  3074. }
  3075. }
  3076. return result
  3077. }
  3078.  
  3079. createamalgamplant(object, fusiontype:=""){
  3080. ;the continuation of an already tricky piece of code. The purpose of this function is to fuse multiple plants objects together which thankfully is way easier with the combine arrays function
  3081. result := []
  3082. object2 := {}
  3083. object2.push(fusiontype["result"])
  3084. loop, % object.maxIndex(){
  3085. object2.push(object[A_index])
  3086. }
  3087. result := fusearrays(object2)
  3088. resultdescription := " The combined power of a "
  3089. for entry, content in object{
  3090. ;the rarity of the resulting plant is the lowest of all combined plants
  3091. morethanzeroplants := "true"
  3092. resultdescription .= content["name"] . " and a "
  3093. for, entry2, content2 in object[A_index]["fusion"]{
  3094. ;overwrite any fusion stats this plant has with the highest of a single plant. This is to prevent 2 fusion strength 1 plants to combine into one that has 2 strength which would result in potential infinite fusions
  3095. if content2 is number
  3096. {
  3097. if(!result["fusion"][entry2]){
  3098. result["fusion"][entry2] := 0
  3099. }
  3100. result["fusion"][entry2] := Max(result["fusion"][entry2], content2)
  3101. }
  3102. else if(!result["fusion"][entry2]){
  3103. result["fusion"][entry2] := content2
  3104. }
  3105. }
  3106. }
  3107. ;some extra values to add to the plant. Name, descr and weakness don't depend on the fused plants but on the plant used to fuse instead.
  3108. ;V create the plant and further build the description if the plant used to fuse targetted anything.
  3109. stringtrimright, resultdescription, resultdescription, 7
  3110. result["descr"] .= resultdescription
  3111. result["weakness"] := fusionstats["strength"]
  3112. if(fusiontype){
  3113. result["rarity"] := fusiontype["rarity"]
  3114. }
  3115. else{
  3116. result["rarity"] := min(object["rarity"])
  3117. }
  3118. result["protected"] := 0
  3119. ;if(fusionstats["background"]){
  3120. ;result["background"] := fusionstats["background"]
  3121. ;}
  3122. ;else{
  3123. ;result.delete("background")
  3124. ;}
  3125. ;if(fusionstats["textcolor"]){
  3126. ;result["textcolor"] := fusionstats["textcolor"]
  3127. ;}
  3128. ;else{
  3129. ;result.delete("textcolor")
  3130. ;}
  3131. ;if(fusionstats["symbol"]){
  3132. ;result["symbol"] := fusionstats["symbol"]
  3133. ;}
  3134. ;else{
  3135. ;result.delete("symbol")
  3136. ;}
  3137. stringtrimright, resultdescription, resultdescription, 6
  3138. if(!morethanzeroplants){
  3139. ;if no plant was used to fuse. Just return nothing.
  3140. return
  3141. }
  3142. return result
  3143. }
  3144.  
  3145. HasVal(haystack, needle){
  3146. ;check if an array contains a specific word
  3147. if !(IsObject(haystack)) || (haystack.Length() == 0){
  3148. return 0
  3149. }
  3150. for index, value in haystack{
  3151. if (value = needle){
  3152. return index
  3153. }
  3154. }
  3155. return 0
  3156. }
  3157.  
  3158. objectminmax(object, minmax){
  3159. ;get the highest or lowest number in an entire object (doesnt work on objects inside objects)
  3160. switch := 1
  3161. if (!IsObject(object) || object.Count() == 0 ||object.Count() == ""){
  3162. return object
  3163. }
  3164. for, a, b in object{
  3165. if(isnum(b)){
  3166. if(switch){
  3167. switch := ""
  3168. result := b
  3169. }
  3170. if(minmax == "min"){
  3171. result := min(result, b)
  3172. }
  3173. else if(minmax == "max"){
  3174. result := max(result, b)
  3175. }
  3176. }
  3177. }
  3178. return result
  3179. }
  3180.  
  3181. VersionCompare(version1, version2){
  3182. ;I found and copy/pasted this from somewhere. Checks if your ahk version is higher or lower depending on the one that I made this game in.
  3183. ;I have had a couple people telling me that they got errors with lower versions meaning they likely didn't see the message I put up. So any help with that is appreciated
  3184. StringSplit, verA, version1, .
  3185. StringSplit, verB, version2, .
  3186. Loop, % (verA0> verB0 ? verA0 : verB0)
  3187. {
  3188. if (verA0 < A_Index)
  3189. verA%A_Index% := "0"
  3190. if (verB0 < A_Index)
  3191. verB%A_Index% := "0"
  3192. if (verA%A_Index% > verB%A_Index%)
  3193. return 1
  3194. if (verB%A_Index% > verA%A_Index%)
  3195. return 2
  3196. }
  3197. return 0
  3198. }
  3199.  
  3200. fixwindowpos(name){
  3201. ;name is case sensitive. Moves windows that are slightly or entirely offscreen. Can be disabled with an checkbox option
  3202. GetKeyState, LButtonState, LButton, P
  3203. if(LButtonState == "U"){
  3204. wingetpos, X, Y, W, H, %name%
  3205. if(X + W > A_screenwidth){
  3206. WinMove,%name%,, A_screenwidth - W, Y
  3207. }
  3208. wingetpos, X, Y, W, H, %name%
  3209. if(Y + H >= A_screenheight){
  3210. WinMove,%name%,, X, A_screenheight - H
  3211. }
  3212. wingetpos, X, Y, W, H, %name%
  3213. if(0 > X){
  3214. WinMove,%name%,, 0, Y
  3215. }
  3216. wingetpos, X, Y, W, H, %name%
  3217. if(0 > Y){
  3218. WinMove,%name%,, X, 0
  3219. }
  3220. }
  3221. }
  3222.  
  3223. toscientific(input:=0, rounding:=1, donttouchnumberlength:=6){
  3224. ;rounding means the amount of numbers the result should have. For example an input of 1000000 and a rounding of 4 should result in 1.000E+6, a rounding of 5 becomes 1.0000E+6
  3225. ;I might add different roundings eventually if the demand is high.
  3226. numbers := strlen(input)
  3227. if(donttouchnumberlength >= numbers){
  3228. return input
  3229. }
  3230. StringLeft, result, input, 1
  3231. StringTrimLeft, result2, input, 1
  3232. Stringleft, result2, result2, rounding - 1
  3233. result .= "." . result2 . "E+" . numbers - 1
  3234. return result
  3235. }
  3236.  
  3237. devbutton_onclick(){
  3238. ;this button does whatever I want it to do.
  3239. global
  3240. ;addtooltip(plantchance)
  3241. ;addtooltip(seeddrops)
  3242. ;addtooltip(keyavailable)
  3243. ;treasurekeys += 1
  3244. ;treasurechests += 1
  3245. ;plantknowledge["knowledge"] += 10
  3246. ;addtooltip(plantknowledge["knowledge"])
  3247. ;power *= 1.5
  3248. ;tile2A2["plant"] := {rarity: 100, knowledge:6, descr: "This is a plant that knows a lot about plants. Who knows what info you can extract when you harvest this", name:"knowleaf", symbol:"kl", background:"#55AA88", textcolor:"#FFAAFF", harvest:{harvestpower:100, knowledge:100}}
  3249. creategardenplant(100, 2, 2, lockbloom, "aggressive")
  3250. if(!keyavailable){
  3251. keyavailable := randomletter()
  3252. }
  3253. updatemain()
  3254. }
  3255.  
  3256. changepower(change:=0, subtract:="", changepercent:=100){
  3257. global
  3258. ;the main reason this function exists is to track the stats when power is increased or decreased
  3259. if(!stats["powergained"]){
  3260. stats["powergained"] := 0
  3261. }
  3262. if(!stats["powerspent"]){
  3263. stats["powerspent"] := 0
  3264. }
  3265. if(!subtract){
  3266. stats["powergained"] += change
  3267. }
  3268. else{
  3269. stats["powerspent"] += change
  3270. }
  3271. if(power * (changepercent / 100) > power){
  3272. stats["powergained"] += ((power * (changepercent / 100)) - power)
  3273. }
  3274. if(power > power * (changepercent / 100)){
  3275. stats["powerspent"] += ((power * (changepercent / 100)) + power)
  3276. }
  3277. if(!subtract){
  3278. power += change
  3279. }
  3280. else{
  3281. power -= change
  3282. }
  3283. power *= (changepercent / 100)
  3284. }
  3285.  
  3286. ;These are all the functions that calculate power gain. Most are the same but some got tiny differences.
  3287. calculateclickvalue(){
  3288. global
  3289. ;base
  3290. clickpower := 0
  3291. ;from upgrades
  3292. clickpowerbonus := 0
  3293. ;% increase from upgrades
  3294. clickpowermult := 1
  3295. ;% increase from treasures
  3296. treasureclickpowermult := 1 + (treasures["amulets"] / 100)
  3297. ;from knowledge points
  3298. knowledgeclickpowermult := 1
  3299.  
  3300. for a, b in upgrades{
  3301. ;loop through all upgrades
  3302. clickpowerbonus += %a%["clickpower"] * %a%["purchased"]
  3303. if(%a%["clickpowerpercent"] && %a%["purchased"]){
  3304. clickpowermult *= (%a%["clickpowerpercent"] * %a%["purchased"] / 100) + 1
  3305. }
  3306. if(%a%["knowledgepower"] && %a%["purchased"]){
  3307. knowledgeclickpowermult *= (%a%["knowledgepower"] * plantknowledge["knowledge"] * %a%["purchased"] / 100) + 1
  3308. }
  3309. }
  3310. clickpower += clickpowerbonus
  3311. clickpower += farmclickpower
  3312. clickpower *= (farmclickpowerpercent / 100) + 1
  3313. clickpower *= clickpowermult
  3314. clickpower *= treasureclickpowermult
  3315. clickpower *= knowledgeclickpowermult
  3316. return round(clickpower)
  3317. }
  3318.  
  3319. calculateharvestvalue(plantharvest:=""){
  3320. global
  3321. ;a plant array or number can be used here to affect power gain. Note that when a plant is input here. It should be combined with the temp and permanent stats to apply those in the harvest
  3322. harvestpower := 0
  3323. plantharvestpowermult := 0
  3324. if plantharvest is number
  3325. {
  3326. harvestpower := plantharvest
  3327. }
  3328. for, a, b in plantharvest["harvest"]{
  3329. if(a == "harvestpower"){
  3330. harvestpower += b
  3331. }
  3332. if(a == "harvestpowerpercent"){
  3333. plantharvestpowermult += b
  3334. }
  3335. }
  3336. harvestpowerbonus := 0
  3337. harvestpowermult := 1
  3338. treasureharvestmult := 1 + (treasures["emeralds"] / 100)
  3339. knowledgeharvestpowermult := 1
  3340. for a, b in upgrades{
  3341. harvestpowerbonus += %a%["harvestpower"] * %a%["purchased"]
  3342. if(%a%["harvestpowerpercent"] && %a%["purchased"]){
  3343. harvestpowermult *= (%a%["harvestpowerpercent"] * %a%["purchased"] / 100) + 1
  3344. }
  3345. if(%a%["knowledgepower"] && %a%["purchased"]){
  3346. knowledgeharvestpowermult *= (%a%["knowledgepower"] * plantknowledge["knowledge"] * %a%["purchased"] / 100) + 1
  3347. }
  3348. }
  3349. harvestpower += harvestpowerbonus
  3350. harvestpower += farmharvestpower
  3351. harvestpower *= (farmharvestpowerpercent / 100) + 1
  3352. harvestpower *= (plantharvestpowermult / 100) + 1
  3353. harvestpower *= harvestpowermult
  3354. harvestpower *= treasureharvestmult
  3355. harvestpower *= knowledgeharvestpowermult
  3356. return round(harvestpower)
  3357. }
  3358.  
  3359. calculateknowledge(plantharvest:=""){
  3360. global
  3361. knowledge := 0
  3362. plantharvestknowledgemult := 0
  3363. if plantharvest is number
  3364. {
  3365. knowledge := plantharvest
  3366. }
  3367. for, a, b in plantharvest["harvest"]{
  3368. if(a == "knowledge"){
  3369. knowledge += b
  3370. }
  3371. if(a == "knowledgepercent"){
  3372. plantharvestknowledgemult += b
  3373. }
  3374. }
  3375. knowledgebonus := 0
  3376. knowledgemult := 1
  3377. treasureknowledgemult := 1
  3378. for a, b in upgrades{
  3379. knowledgebonus += %a%["knowledge"] * %a%["purchased"]
  3380. if(%a%["knowledgepercent"] && %a%["purchased"]){
  3381. knowledgemult *= (%a%["knowledgepercent"] * %a%["purchased"] / 100) + 1
  3382. }
  3383. }
  3384. knowledge += knowledgebonus
  3385. knowledge += farmknowledge
  3386. knowledge *= (farmknowledgepercent / 100) + 1
  3387. knowledge *= (plantharvestknowledgemult / 100) + 1
  3388. knowledge *= knowledgemult
  3389. knowledge *= treasureknowledgemult
  3390. return round(knowledge)
  3391. }
  3392.  
  3393. calculatemovevalue(){
  3394. global
  3395. movepower := 0
  3396. movepowerbonus := 0
  3397. movepowermult := 1
  3398. treasuremovepowermult := 1 + (treasures["rings"] / 100)
  3399. knowledgemovepowermult := 1
  3400. for a, b in upgrades{
  3401. movepowerbonus += %a%["movepower"] * %a%["purchased"]
  3402. if(%a%["movepowerpercent"] && %a%["purchased"]){
  3403. movepowermult *= (%a%["movepowerpercent"] * %a%["purchased"] / 100) + 1
  3404. }
  3405. if(%a%["knowledgepower"] && %a%["purchased"]){
  3406. knowledgemovepowermult *= (%a%["knowledgepower"] * plantknowledge["knowledge"] * %a%["purchased"] / 100) + 1
  3407. }
  3408. }
  3409. movepower += movepowerbonus
  3410. movepower += farmmovepower
  3411. movepower *= (farmmovepowerpercent / 100) + 1
  3412. movepower *= treasuremovepowermult
  3413. movepower *= movepowermult
  3414. movepower *= knowledgemovepowermult
  3415. if(mousemastery["purchased"] >= 1){
  3416. movepower += calculateclickvalue()
  3417. }
  3418. return round(movepower)
  3419. }
  3420.  
  3421. calculatemovespeed(){
  3422. global
  3423. movespeed := 0
  3424. movespeedbonus := 0
  3425. movespeedmult := 1
  3426. treasuremovespeedmult := 1 + (treasures["pearls"] / 100)
  3427. for a, b in upgrades{
  3428. movespeedbonus += %a%["movespeed"] * %a%["purchased"]
  3429. if(%a%["movespeedpercent"] && %a%["purchased"]){
  3430. movespeedmult *= (%a%["movespeedpercent"] * %a%["purchased"] / 100) + 1
  3431. }
  3432. }
  3433. movespeed += movespeedbonus
  3434. movespeed += farmmovespeed
  3435. movespeed *= (farmmovespeedpercent / 100) + 1
  3436. movespeed *= treasuremovespeedmult
  3437. movespeed *= movespeedmult
  3438. return round(movespeed)
  3439. }
  3440.  
  3441. calculatemovespeedtopowervalue(movespeedtopower:=0){
  3442. global
  3443. ;super OP and rightfully unused right now
  3444. movespeedtopowerbonus := 0
  3445. movespeedtopowermult := 1
  3446. treasuremovespeedtopowermult := 1
  3447. knowledgemovespeedtopowermult := 1
  3448. for a, b in upgrades{
  3449. movespeedtopowerbonus += %a%["movespeedtopower"] * %a%["purchased"]
  3450. if(%a%["movespeedtopowerpercent"] && %a%["purchased"]){
  3451. movespeedtopowermult *= (%a%["movespeedtopowerpercent"] * %a%["purchased"] / 100) + 1
  3452. }
  3453. if(%a%["knowledgepower"] && %a%["purchased"]){
  3454. knowledgemovespeedtopowermult *= (%a%["knowledgepower"] * plantknowledge["knowledge"] * %a%["purchased"] / 100) + 1
  3455. }
  3456. }
  3457. movespeedtopower += movespeedtopowerbonus
  3458. movespeedtopower += farmmovespeedtopower
  3459. movespeedtopower *= (farmmovespeedtopowerpercent / 100) + 1
  3460. movespeedtopower *= treasuremovespeedtopowermult
  3461. movespeedtopower *= movespeedtopowermult
  3462. movespeedtopower *= knowledgemovespeedtopowermult
  3463. return round(movespeedtopower)
  3464. }
  3465.  
  3466. calculatekeyboardkeyvalue(key:=""){
  3467. global
  3468. keyboardkeypower := 0
  3469. keyboardkeypowerbonus := 0
  3470. keyboardkeypowermult := 1
  3471. treasurekeyboardkeymult := 1 + (treasures["grails"] / 100)
  3472. knowledgekeyboardkeymult := 1
  3473. for a, b in upgrades{
  3474. keyboardkeypowerbonus += %a%["keyboardkeypower"] * %a%["purchased"]
  3475. if(%a%["keyboardkeypowerpercent"] && %a%["purchased"]){
  3476. keyboardkeypowermult *= (%a%["keyboardkeypowerpercent"] * %a%["purchased"] / 100) + 1
  3477. }
  3478. if(%a%["knowledgepower"] && %a%["purchased"]){
  3479. knowledgekeyboardkeymult *= (%a%["knowledgepower"] * plantknowledge["knowledge"] * %a%["purchased"] / 100) + 1
  3480. }
  3481. }
  3482. keyboardkeypower += keyboardkeypowerbonus
  3483. keyboardkeypower += farmkeyboardkeypower
  3484. if(gamersfuel["purchased"] >= 1){
  3485. if(key = "~W up" || key = "~A up" || key = "~S up" || key = "~D up" ||){
  3486. ;turns out gaming is a good way to earn money (power) afterall
  3487. keyboardkeypower *= 2
  3488. }
  3489. }
  3490. keyboardkeypower *= (farmkeyboardkeypowerpercent / 100) + 1
  3491. keyboardkeypower *= treasurekeyboardkeymult
  3492. keyboardkeypower *= keyboardkeypowermult
  3493. keyboardkeypower *= knowledgekeyboardkeymult
  3494. return round(keyboardkeypower)
  3495. }
  3496.  
  3497. calculateshopprice(object){
  3498. price := object["price"]
  3499. if(object["priceincrease"]){
  3500. price += (object["priceincrease"] * object["purchased"])
  3501. }
  3502. if(object["priceincreasepercent"]){
  3503. price *= ((1 + (object["priceincreasepercent"] / 100)) ** object["purchased"])
  3504. }
  3505. return price
  3506. }
  3507.  
  3508. getchests(){
  3509. chestchance := 30
  3510. random, chestodds, 1, 100
  3511. if(chestchance >= chestodds){
  3512. return 1
  3513. }
  3514. else{
  3515. return 0
  3516. }
  3517. }
  3518.  
  3519. getkeys(){
  3520. keychance := 30
  3521. random, keyodds, 1, 100
  3522. if(keychance >= keyodds){
  3523. return 1
  3524. }
  3525. else{
  3526. return 0
  3527. }
  3528. }
  3529.  
  3530. savegame_onclick(){
  3531. global
  3532. critical, on
  3533. if(lastsave){
  3534. gui, backgroundpower:default
  3535. gui, hide
  3536. }
  3537. autosavewait := A_tickcount + autosavewaitvalue
  3538. iniwrite, % power, %savename%, values, power
  3539. iniwrite, % gardentiles, %savename%, values, gardentiles
  3540. iniwrite, % freezertiles, %savename%, values, freezertiles
  3541. iniwrite, % treasurekeys, %savename%, values, treasurekeys
  3542. iniwrite, % treasurechests, %savename%, values, treasurechests
  3543. iniwrite, % treasureradarbought, %savename%, values, treasureradarbought
  3544. iniwrite, % currentversion, %savename%, values, version
  3545. iniwrite, % almanacunlocked, %savename%, garden, almanacunlocked
  3546. iniwrite, % arraytostring(treasures), %savename%, treasures, treasures
  3547. for savegameindex, savegamecontent in upgrades{
  3548. for savegameindex2, savegamecontent2 in upgrades[savegameindex]{
  3549. upgrades[savegameindex][savegameindex2] := %savegameindex%[savegameindex2]
  3550. }
  3551. }
  3552. iniwrite, % arraytostring(upgrades), %savename%, upgrades, upgrades
  3553. iniwrite, % arraytostring(plantknowledge), %savename%, garden, plantknowledge
  3554. iniwrite, % arraytostring(optionchecks), %savename%, options, optionchecks
  3555. iniwrite, % arraytostring(stats), %savename%, values, stats
  3556. ;saving garden tiles can get pretty long at times if there's many unlocked tiles
  3557. loop, % gardentiles{
  3558. SaveX := mod(A_index, 10)
  3559. SaveY := ceil(A_index / 10)
  3560. if(SaveX == 0){
  3561. SaveX = 10
  3562. }
  3563. savevalue := {plant:tile%SaveX%A%SaveY%["plant"], permanent:tile%SaveX%A%SaveY%["permanent"]}
  3564. savevalue := arraytostring(savevalue)
  3565. IniWrite, % savevalue, %savename%, garden, tile%SaveX%A%SaveY%
  3566. }
  3567. loop, % freezertiles{
  3568. SaveX := mod(A_index, 10)
  3569. SaveY := ceil(A_index / 10)
  3570. if(SaveX == 0){
  3571. SaveX = 10
  3572. }
  3573. savevalue := {plant:freezertile%SaveX%A%SaveY%["plant"]}
  3574. savevalue := arraytostring(savevalue)
  3575. IniWrite, % savevalue, %savename%, garden, freezertile%SaveX%A%SaveY%
  3576. }
  3577. addlog("saved the game", "general")
  3578. critical, off
  3579. }
  3580.  
  3581. exit_onclick(){
  3582. global
  3583. lastsave := 1
  3584. exitapp
  3585. }
  3586.  
  3587. BackgroundpowerGuiClose:
  3588. lastsave := 1
  3589. exitapp
  3590. return
  3591.  
  3592. ~F11::
  3593. if(F11reset == "true"){
  3594. savegame_onclick()
  3595. Reload
  3596. }
  3597. return
  3598.  
  3599. ;here are all future ideas listed for the game that I hope to implement some day.
  3600.  
  3601. ;Ascension system with a new resource: Mana. Mana is gained from varying sources like upgrades or garden plants. (garden plants need to be alive and not harvest to get their mana)
  3602. ;Ascension destroys most things and ascends your character into a deity. Allowing you to spend your mana on a skill tree to buff further progression.
  3603. ;Future playthrough players would be able to build a statue to your previous character as a deity for example which would yield various buffs
  3604.  
  3605. ;Bloobs, Floobs are pets that you can breed and train (sorta). Bloobs have various benefits that can be utilized when they are equipped. 1 can be equipped by default but some ways unlock more slots.
  3606. ;Bloobs can breed when put in a queen and king slot (they dont buff your stats in there). Over time they create new bloops with stats based on the current bloob with around an equal chance of increasing or decreasing the stats
  3607. ;Bloobs have a stat cap which they will quickly reach. Once all stats are maxed, a bloob can be ascended and be reset back but their max stat caps will be increased
  3608.  
  3609. ;I have started working on this feature V
  3610. ;A dungeon crawler feature controlled by the arrow/wasd keys. A character moves through a dungeon based on your input and encounters treasures, blockades and enemies.
  3611. ;The player enters stairs automatically upon entering and the stairs are always near a wall. Enemies trap you when walking on them and pressing a arroy/wasd key starts attacking it.
  3612. ;I'm not sure if I want to introduce a health system or just want the character to be invurnerable with progress limited by time.
  3613. ;Deeper floors give better rewards of course
  3614. ;The character gets various buffs from other features, like bloobs or plants.
  3615. ;The theme of the dungeon is reptiles. Almost every enemy is some sort of lizard or snake. This doesn't mean there wont be a wide variety of enemies.
  3616. ;Locked doors which are enemies that have large amounts of health but are insta-killed when a golden key is collected during combat.
  3617. ;hidden doors which are the same thing but finding a hidden treasure kills them instead
  3618.  
  3619. ;Maybe a safe cracking minigame played with the number keys. Eventually pressing enough buttons will open the safe and grant rewards.
  3620.  
  3621. ;Garden rework (again). I'm not entirely sure what I want the garden to be. But right now my mind goes something like this.
  3622. ;Fully remove random plant spawns. Seeds for plants can be bought and mystery seeds can be planted to attempt breeding pairs.
  3623. ;Special enchants on tile allow random plant spawns
  3624. ;Plant managing. Plants that move other plants around or auto-harvest them (this does not break the no-idle rule as plants only appear/grow/move/harvest when the mouse moves)
  3625. ;A growth system. Plants are less efficient when they are not fully grown and many powerful effects only work when the plant is grown 100% (note: making an amalgam plant combines the growth times for both plants so it may take long to grow at times)
  3626. ;extra reasons to use the knowledge system. More knowledge can be invested in completed plants for increased 'mana' gain
  3627. ;Rework the breeding system. Instead of requiring plants nearby. Plants require certain stats to be met. For example one plant could need the 8 plants around it to have a combined total of 10 clickpower before it grows there.
Add Comment
Please, Sign In to add comment