Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2025
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.62 KB | None | 0 0
  1. ; script made by u/ArrasDesmos
  2. ; if you're ever using this please credit me
  3. ; thy script stealers are not welcome here
  4. ; enjoy this year long work of hell
  5.  
  6. #NoEnv
  7. SendMode Input
  8. SetWorkingDir %A_ScriptDir%
  9.  
  10. file := "The Board.txt"
  11. shop := {}
  12.  
  13. shop["Cloth Armor"] := {price:100, DEF:3, DEFpercent:15}
  14. shop["Chainmail Armor"] := {price:250, DEF:7, DEFpercent:25}
  15. shop["Iron Armor"] := {price:400, DEF:10, DEFpercent:40}
  16. shop["Diamond Armor"] := {price:700, DEF:15, DEFpercent:60}
  17. shop["Armor of the Void"] := {price:1100, DEF:20, DEFpercent:80}
  18.  
  19. shop["Wood Sword"] := {price:90, DMG:1.5}
  20. shop["Silver Sword"] := {price:180, DMG:3}
  21. shop["Diamond Sword"] := {price:270, DMG:4.5}
  22. shop["Sword of the Void"] := {price:450, DMG:6}
  23. shop["TNT"] := {price:250, DMG:20}
  24. shop["Snowball"] := {price:2, DMG:0.1}
  25. shop["Bow"] := {price:300, DMG:1.5}
  26. shop["Arrow"] := {price:30, DMG:0}
  27. shop["Buns"] := {price:10, Heal:2}
  28. shop["Glass Cannon"] := {price:1500, DMG:100}
  29. shop["Mutton"] := {price:100, Heal:10}
  30.  
  31. shovelTiers := ["Wooden Shovel", "Plastic Shovel", "Rake", "Military Shovel", "Mechanical Shovel", "Golden Shovel", "Flaming Shovel", "Shovel of the Void", "Light Shovel"]
  32. shovelPrices := [0, 100, 200, 300, 600, 900, 1800, 2500, 3250]
  33. shovelDigValues := [1, 3, 4, 5, 7, 10, 15, 20, 25]
  34.  
  35. gems := ["Iron", "Gold", "Diamond", "Ruby", "Emerald"]
  36. gemPrices := [10, 20, 30, 40, 50] ; example prices for gems by index
  37.  
  38. global players := []
  39. LoadPlayers()
  40.  
  41. F1::Dig()
  42. F2::Sell()
  43. F3::Attack()
  44. F4::Buy()
  45. F5::UpgradeShovel()
  46. F6::AddPlayer()
  47. F7::EatFood()
  48. F8::ShowHelp()
  49. return
  50.  
  51. LoadPlayers() { ; LOAD THE DAMN PLAYERS RAHHHHHHHHH
  52. global players, file
  53. players := []
  54. if !FileExist(file)
  55. FileAppend,, %file%
  56. FileRead, content, %file%
  57. Loop, Parse, content, `n, `r
  58. {
  59. line := A_LoopField
  60. if (line = "")
  61. continue
  62. if !RegExMatch(line, "^(.*?) \((\d+)\) - (\d+)\$ - \((.*?)\) - (.*?) - (\d+) - (.*) - (\d+)/(\d+) HP - (\d+)/(\d+)", m)
  63. continue
  64.  
  65. p := {}
  66. p.name := m1
  67. p.id := m2 + 0
  68. p.cash := m3 + 0
  69. p.gems := ParseGems(m4)
  70. p.shovel := m5
  71. p.score := m6 + 0
  72.  
  73. p.items := []
  74. if (m7 != "") {
  75. itemsRaw := StrSplit(m7, ", ")
  76. for _, itemStr in itemsRaw {
  77. if RegExMatch(itemStr, "^(.*?) x(\d+)$", match) {
  78. p.items.Push({name: match1, qty: match2 + 0})
  79. } else {
  80. p.items.Push({name: itemStr, qty: 1})
  81. }
  82. }
  83. }
  84. ; skibidi signma 😂
  85. p.currentHP := m8 + 0
  86. p.maxHP := m9 + 0
  87. p.currentLives := m10 + 0
  88. p.maxLives := m11 + 0
  89. players.Push(p)
  90. }
  91. }
  92.  
  93. ParseGems(str) {
  94. arr := []
  95. Loop, Parse, str, `,
  96. {
  97. val := Trim(A_LoopField)
  98. arr.Push(val + 0)
  99. }
  100. while arr.Length() < 5
  101. arr.Push(0)
  102. return arr
  103. }
  104.  
  105. SavePlayers() { ; SAVE THE PLAYERS SO THAT IT DOESN'T OVERWRITE RAHHHHHHHH
  106. global players, file
  107. text := ""
  108. for index, p in players
  109. text .= BuildPlayerLine(p) . "`n"
  110. FileDelete, %file%
  111. FileAppend, %text%, %file%
  112. }
  113.  
  114. BuildPlayerLine(p) {
  115. gemsStr := "(" . StrJoin(", ", p.gems) . ")"
  116. itemsStr := ""
  117. for _, item in p.items {
  118. if (item.qty > 1)
  119. itemsStr .= (itemsStr = "" ? "" : ", ") . item.name . " x" . item.qty
  120. else
  121. itemsStr .= (itemsStr = "" ? "" : ", ") . item.name
  122. }
  123. return p.name . " (" . p.id . ") - " . p.cash . "$ - " . gemsStr . " - " . p.shovel . " - " . p.score . " - " . itemsStr . " - " . p.currentHP . "/" . p.maxHP . " HP - " . p.currentLives . "/" . p.maxLives
  124. }
  125.  
  126. StrJoin(sep, arr) {
  127. str := ""
  128. for i, v in arr
  129. str .= (i > 1 ? sep : "") . v
  130. return str
  131. }
  132.  
  133. ArrayContains(arr, val) {
  134. for _, v in arr
  135. if (v = val)
  136. return true
  137. return false
  138. }
  139.  
  140. FindPlayerIndex(name) {
  141. global players
  142. StringLower, lname, name
  143. for i, p in players {
  144. pname := p["name"]
  145. StringLower, pnameLower, pname
  146. if (pnameLower = lname)
  147. return i
  148. }
  149. return 0
  150. }
  151.  
  152. GetPlayer(name, ByRef idx) {
  153. idx := FindPlayerIndex(name)
  154. if (idx)
  155. return players[idx]
  156. return ""
  157. }
  158.  
  159. GetShovelTierIndex(name) {
  160. global shovelTiers
  161. for i, v in shovelTiers
  162. if (v = name)
  163. return i
  164. return 1
  165. }
  166.  
  167. FindItemIndex(items, name) {
  168. for i, item in items
  169. if (item.name = name)
  170. return i
  171. return 0
  172. }
  173.  
  174.  
  175. Dig() {
  176. global players, gems, shovelDigValues
  177. InputBox, pname, Dig, Enter player name:
  178. if ErrorLevel
  179. return
  180. idx := FindPlayerIndex(pname)
  181. if (!idx) {
  182. MsgBox, Player not found.
  183. return
  184. }
  185. p := players[idx]
  186. tier := GetShovelTierIndex(p.shovel)
  187. totalGems := shovelDigValues[tier]
  188.  
  189.  
  190. gemsFound := []
  191. Loop, % gems.Length()
  192. gemsFound.Push(0)
  193.  
  194. treasureChestCount := 0
  195. treasureChestValue := 40
  196.  
  197. Loop, % totalGems {
  198. Random, gemTypeIndex, 1, gems.Length() + 1
  199. if (gemTypeIndex = gems.Length() + 1) {
  200. treasureChestCount++
  201. } else {
  202. gemsFound[gemTypeIndex]++
  203. }
  204. }
  205.  
  206. ; Add gems to player's inventory OBVIOUSLY (when digging)
  207. for i, count in gemsFound {
  208. if (count > 0)
  209. p.gems[i] += count ; p.gems is 1-based
  210. }
  211.  
  212. ; give the kiddo money when find the treasure chest arrr
  213. if (treasureChestCount > 0) {
  214. p.cash += treasureChestCount * treasureChestValue
  215. }
  216.  
  217. Msg := p.name . " dug up:"
  218. for i, count in gemsFound
  219. if (count > 0)
  220. Msg .= "`n" . count . " " . gems[i]
  221.  
  222. if (treasureChestCount > 0)
  223. Msg .= "`n" . treasureChestCount . " Treasure Chest(s) for $" . (treasureChestCount * treasureChestValue)
  224.  
  225. MsgBox, % Msg
  226. players[idx] := p
  227. SavePlayers() ; save the players to prevent overwriting
  228. }
  229.  
  230.  
  231. Sell() {
  232. global players, gemPrices
  233. InputBox, pname, Sell, Enter player name:
  234. if ErrorLevel
  235. return
  236. idx := FindPlayerIndex(pname)
  237. if (!idx) {
  238. MsgBox, Player not found. ; return an error when the player is nonexistant
  239. return
  240. }
  241. p := players[idx]
  242. gain := 0
  243. for i, val in p.gems {
  244. gain += val * gemPrices[i]
  245. p.gems[i] := 0
  246. }
  247. p.cash += gain
  248. p.score += gain
  249. players[idx] := p
  250. MsgBox, % p.name . " sold all gemstones for $" . gain ; tells the player that they sold all the gemstones for a certain amount of cash
  251. SavePlayers()
  252. }
  253.  
  254. Attack() {
  255. global players, shop
  256. InputBox, attacker, Attack, Who is attacking?
  257. if ErrorLevel
  258. return
  259. idx1 := FindPlayerIndex(attacker)
  260. if (!idx1) {
  261. MsgBox, Attacker not found. ; tell the player that the attacker doesn't exist (like your dad)
  262. return
  263. }
  264. p1 := players[idx1]
  265.  
  266. InputBox, target, Attack, Who is attacked?
  267. if ErrorLevel
  268. return
  269. idx2 := FindPlayerIndex(target)
  270. if (!idx2) {
  271. MsgBox, Target not found. ; you already know what this does
  272. return
  273. }
  274. p2 := players[idx2]
  275.  
  276. InputBox, weapon, Attack, Which weapon?
  277. if ErrorLevel
  278. return
  279. if !shop.HasKey(weapon) || !shop[weapon].HasKey("DMG") {
  280. MsgBox, Invalid weapon. ; why do i have to explain
  281. return
  282. }
  283.  
  284. ; check if attacker has the weapon, except for snowballs (if you handle them differently)
  285. if (weapon != "Snowball" && !ArrayContains(p1.items, weapon)) {
  286. MsgBox, You do not have that weapon.
  287. return
  288. }
  289.  
  290. dmg := shop[weapon].DMG
  291. defense := 0
  292. for item, props in shop {
  293. if (ArrayContains(p2.items, item) && props.HasKey("DEF"))
  294. defense += props.DEF
  295. }
  296. net := Max(dmg - defense, 0)
  297. p2.currentHP -= net
  298. result := p1.name . " dealt " . net . " damage to " . p2.name . "!"
  299.  
  300. if (p2.currentHP <= 0) {
  301. p2.currentLives -= 1
  302. if (p2.currentLives > 0) {
  303. p2.currentHP := p2.maxHP
  304. result .= "`n" . p2.name . " lost a life! (" . p2.currentLives . " lives left)"
  305. } else {
  306. result .= "`n" . p2.name . " has no lives left!"
  307. }
  308. }
  309.  
  310. ; glass cannon breaking mechanism
  311. if (weapon = "Glass Cannon") {
  312. RemoveOneItem(p1.items, "Glass Cannon")
  313. }
  314.  
  315. players[idx1] := p1
  316. players[idx2] := p2
  317. MsgBox, % result
  318. SavePlayers()
  319. }
  320.  
  321. RemoveOneItem(ByRef itemsArray, itemToRemove) {
  322. for i, item in itemsArray {
  323. if (item = itemToRemove) {
  324. itemsArray.RemoveAt(i)
  325. return
  326. }
  327. }
  328. }
  329.  
  330. Buy() { ; call the buying function on f4 obviously
  331. global players, shop
  332. InputBox, pname, Buy, Enter player name:
  333. if ErrorLevel
  334. return
  335. idx := FindPlayerIndex(pname)
  336. if (!idx) {
  337. MsgBox, Player not found. ; what
  338. return
  339. }
  340. p := players[idx]
  341. InputBox, item, Buy, Enter item to buy:
  342. if ErrorLevel
  343. return
  344. if !shop.HasKey(item) {
  345. MsgBox, Invalid item. ; when you write something stupid. you can't deal damage with a "aiofnhiondf" ofcourse
  346. return
  347. }
  348.  
  349. ; use hasitem to check if player already owns the item (except snowball(s))
  350. if (item != "Snowball" && HasItem(p.items, item)) {
  351. MsgBox, You already own %item%.
  352. return
  353. }
  354.  
  355. cost := shop[item].price
  356. if (p.cash < cost) {
  357. MsgBox, Not enough cash. ; when you're broke so you cant buy the thing without ummmmmm cash i guess
  358. return
  359. }
  360.  
  361. ; armor replacing mechanism (ignore if buggy i was sleepy af at the time)
  362. if (shop[item].HasKey("DEF")) {
  363. newItems := []
  364. for _, invItem in p.items {
  365. if (!shop.HasKey(invItem.name) || !shop[invItem.name].HasKey("DEF")) {
  366. newItems.Push(invItem)
  367. }
  368. }
  369. p.items := newItems
  370. }
  371.  
  372. p.cash -= cost
  373.  
  374. if (item = "Snowball") {
  375. Loop, 16 ; so you buy 16 snowballs instead of 1 at a time (note that the original amount was supposed to be 30)
  376. p.items.Push({name: item, qty: 1})
  377. } else {
  378. p.items.Push({name: item, qty: 1})
  379. }
  380.  
  381. players[idx] := p
  382. MsgBox, % p.name . " bought " . item
  383. SavePlayers()
  384. }
  385.  
  386. HasItem(items, name) {
  387. for _, item in items
  388. if (item.name = name && item.qty > 0)
  389. return true
  390. return false
  391. }
  392.  
  393. UpgradeShovel() {
  394. global players, shovelTiers, shovelPrices
  395. InputBox, pname, Upgrade, Enter player name:
  396. if ErrorLevel
  397. return
  398. idx := FindPlayerIndex(pname)
  399. if (!idx) {
  400. MsgBox, Player not found. ; do i have to explain this? unless you're 5 you can understand this whether you can code or not
  401. return
  402. }
  403. p := players[idx]
  404.  
  405. tier := GetShovelTierIndex(p.shovel) ; this checks whether your shovel is max tier or not
  406. if (tier >= shovelTiers.Length()) {
  407. MsgBox, Already max shovel.
  408. return
  409. }
  410.  
  411. nextTier := tier + 1
  412. price := shovelPrices[nextTier]
  413.  
  414. if (p.cash < price) {
  415. MsgBox, Lack of cash.
  416. return
  417. }
  418.  
  419. p.cash -= price
  420. p.shovel := shovelTiers[nextTier]
  421. MsgBox, % p.name . " upgraded shovel to " . p.shovel ; upgrades your shovel
  422. players[idx] := p
  423. SavePlayers()
  424. }
  425.  
  426. AddPlayer() { ; calls the f6 add player function
  427. global players
  428. InputBox, pname, New Player, Enter new player name:
  429. if ErrorLevel
  430. return
  431. if FindPlayerIndex(pname) {
  432. MsgBox, Player already exists. ; no duplicate players
  433. return
  434. }
  435. ; adds player data
  436. p := {}
  437. p.name := pname
  438. p.id := players.Length() + 1
  439. p.cash := 0
  440. p.gems := [0,0,0,0,0]
  441. p.shovel := "Wooden Shovel"
  442. p.score := 0
  443. p.items := []
  444. p.currentHP := 20
  445. p.maxHP := 20
  446. p.currentLives := 3
  447. p.maxLives := 3
  448. players.Push(p)
  449. MsgBox, Player %pname% added.
  450. SavePlayers()
  451. }
  452.  
  453. EatFood() { ; calls the f7 eat food function :DDD
  454. global players, shop
  455. InputBox, pname, Eat, Enter player name:
  456. if ErrorLevel
  457. return
  458. idx := FindPlayerIndex(pname)
  459. if (!idx) {
  460. MsgBox, Player not found.
  461. return
  462. }
  463. p := players[idx]
  464. ; making this is hell
  465. ; find food items in inventory (items with heal property in shop of course)
  466. foods := []
  467. for _, item in p.items {
  468. if (shop.HasKey(item.name) && shop[item.name].HasKey("Heal") && item.qty > 0)
  469. foods.Push(item.name)
  470. }
  471. if (foods.Length() = 0) {
  472. MsgBox, No food items found.
  473. return
  474. }
  475. ; i am sorry that food isn't stackable. but that adds balancing cause you can't just heal mid battle instantly (unless you can cause i forgot)
  476.  
  477. InputBox, food, Eat, Choose food to eat:`n %foodslist%
  478. if ErrorLevel
  479. return
  480. if !ArrayContains(foods, food) {
  481. MsgBox, Invalid food.
  482. return
  483. }
  484.  
  485. ; remove the food item
  486. i := FindItemIndex(p.items, food)
  487. if (i) {
  488. p.items[i].qty -= 1
  489. if (p.items[i].qty <= 0)
  490. p.items.RemoveAt(i)
  491. }
  492.  
  493. heal := shop[food].Heal
  494. p.currentHP += heal
  495. if (p.currentHP > p.maxHP)
  496. p.currentHP := p.maxHP
  497.  
  498. MsgBox, % p.name . " healed for " . heal . " HP."
  499. players[idx] := p
  500. SavePlayers() ; prevent overwriting
  501. }
  502.  
  503. ShowHelp() { ; this one is simple to understand
  504. MsgBox,
  505. (
  506. F1 - Dig gems
  507. F2 - Sell gems
  508. F3 - Attack
  509. F4 - Buy items (Snowballs come in 16)
  510. F5 - Upgrade shovel
  511. F6 - Add player
  512. F7 - Eat food
  513. F8 - Show help
  514. ) ; i know i could've used newline (`n) but this works too i guess
  515. }
  516.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement