Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 31.06 KB | None | 0 0
  1. ::Programmed by Loreadarkshade
  2. ::------------------------------------------------
  3. ::DEVELOPER'S NOTES:
  4. ::
  5. ::TO IMPLEMENT:
  6. ::-add pets (follows player?, attacks on turn with player)
  7. ::-save backups in case of crash, and reload said backups if load corrupt
  8. ::-implements a check if user has permissions for all files and folders when launching the game for the first time
  9. ::add pretty UI with bars n such
  10. ::add random world generation with a world map seed
  11. ::add dungeon bosses and dungeons
  12. ::multiplayer mode?
  13. ::find sound software that can be manipulated using batch
  14. ::optimize
  15. ::Add 'L' look feature for items onground or objects, etc
  16. ::add haggling system to lower shop keepers prices like Moria
  17. ::KNOWN BUGS:
  18. ::
  19.  
  20.  
  21. @echo off
  22. set currentversion=1.8
  23. title Game v.%currentversion%
  24. ::This is absolutely necessary for variable inception.
  25. setlocal enabledelayedexpansion
  26. call :check_integrity
  27. ::Loads game config.
  28. call config.bat
  29. ::Sets window size based on what is defined "config.bat".
  30. mode con cols=%window_width% lines=%window_height%
  31. ::Start title screen music.
  32. ::start "" "sounds\main_title.mp3"
  33. :mainmenu
  34. cls
  35. color 06
  36. ::Direct to correct menu depending on whether old saves exist or not.
  37. dir /b /ad "saves\*" | >nul findstr "^" && (goto saves_exist) || (goto no_saves_exist)
  38. :saves_exist
  39. echo __________________________________________________________________________________
  40. echo                                     Game v.%currentversion% | bin\cmdcolor.exe
  41. echo __________________________________________________________________________________
  42. echo.
  43. echo                        Use the NUMBER keys to navigate menus.
  44. echo.
  45. echo.
  46. echo                                ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  47. echo                                ³  1) Load Game    ³
  48. echo                                ³  2) New Game     ³
  49. echo                                ³  3) Exit         ³
  50. echo                                ³                  ³
  51. echo                                ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  52. echo.
  53. echo.
  54. echo.
  55. echo.
  56. echo.
  57. echo.
  58. echo.
  59. call bin\choice.exe /c:123 /N
  60. if %errorlevel% equ 1 goto loadgame
  61. if %errorlevel% equ 2 goto newgame
  62. if %errorlevel% equ 3 exit
  63. :no_saves_exist
  64. echo __________________________________________________________________________________
  65. echo                                     Game v.%currentversion% | bin\cmdcolor.exe
  66. echo __________________________________________________________________________________
  67. echo.
  68. echo                        Use the NUMBER keys to navigate menus.
  69. echo.
  70. echo.
  71. echo                                ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  72. echo                                ³  1) New Game     ³
  73. echo                                ³  2) Exit         ³
  74. echo                                ³                  ³
  75. echo                                ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  76. echo.
  77. echo.
  78. echo.
  79. echo.
  80. echo.
  81. echo.
  82. echo.
  83. echo.
  84. echo.
  85. echo.
  86. call bin\choice.exe /c:12 /N
  87. if %errorlevel% equ 1 goto newgame
  88. if %errorlevel% equ 2 exit
  89.  
  90. :loadgame
  91. color 06
  92. cls
  93. echo Load Game
  94. echo.
  95. dir "saves" /b
  96. echo.
  97. set player_name=
  98. set /p player_name=Select Save:
  99. if not defined player_name goto mainmenu
  100. if not exist "saves\%player_name%\stats.bat" call :errormessage mainmenu "Save game does not exist."
  101. call "saves\%player_name%\stats.bat"
  102. call "saves\%player_name%\inventory\inventory.bat"
  103. ::Load empty map tiles.
  104. call bin\maploader.bat
  105. ::Load static objects only one time.
  106. call maps\default\static.bat
  107. ::Sets user's preferred UI color.
  108. color %usercolor%
  109. ::Start game.
  110. goto disp
  111.  
  112. :newgame
  113. color 06
  114. cls
  115. set player_name=
  116. echo       ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  117. set /p player_name=Name:
  118. if not defined player_name goto mainmenu
  119. cls
  120. set acclongcheck=%player_name:~28,1%
  121. if defined acclongcheck call :errormessage mainmenu "Name is too long."
  122. if exist "saves\%player_name%\stats.bat" (
  123. cls
  124. color 0c
  125. echo Name already taken.
  126. echo.
  127. pause
  128. goto mainmenu
  129. )
  130. echo Creating character . . .
  131. ::Create main file that contains stats.
  132. md "saves\%player_name%"
  133. (
  134. echo set player_name=%player_name%
  135. echo set usercolor=%default_user_color%
  136. echo set level=1
  137. echo set Exp=0
  138. echo set maxExp=100
  139. echo set hp=100
  140. echo set maxhp=100
  141. echo set mana=100
  142. echo set maxmana=100
  143. echo set gold=0
  144. echo set bank=0
  145. echo set potions=0
  146. echo set ypos=20
  147. echo set xpos=30
  148. )>"saves\%player_name%\stats.bat"
  149. ::Create inventory file.
  150. md "saves\%player_name%\inventory"
  151. (
  152. echo set inventory_selection=1
  153. echo set item1=-
  154. echo set item2=-
  155. echo set item3=-
  156. echo set item4=-
  157. echo set item5=-
  158. echo set item6=-
  159. echo set item7=-
  160. echo set item8=-
  161. echo set item9=-
  162. echo set item10=-
  163. )>"saves\%player_name%\inventory\inventory.bat"
  164. ::Load new character and start the game.
  165. call "saves\%player_name%\stats.bat"
  166. call "saves\%player_name%\inventory\inventory.bat"
  167. ::Load empty map tiles.
  168. call bin\maploader.bat
  169. ::Load static objects only one time.
  170. call maps\default\static.bat
  171. ::Sets user's preferred UI color.
  172. color %usercolor%
  173. ::Start game.
  174. goto disp
  175.  
  176.  
  177.  
  178.  
  179. ::\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  180. ::\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  181. ::\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  182. ::\\\\\\\\\\\\\\\\\\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is what the player will look at 99% of the time.
  204. :disp
  205.  
  206. ::Reload anything that isn't static.
  207. call maps\default\game_objects.bat
  208.  
  209. ::Reload any moving objects such as NPCs or MOBS.
  210. call maps\default\moving_objects.bat
  211.  
  212. ::Load character on top of everything else.
  213. set g%ypos%%xpos%=%char%
  214.  
  215. ::Clear screen for fresh map rendering.
  216. cls
  217.  
  218. ::Draw map with its GUI on the right.
  219. if not "%fully_loaded%" equ "true" call bin\display.bat full_load
  220. if "%fully_loaded%" equ "true" call bin\display.bat
  221.  
  222. echo %line10%
  223. echo %line11%
  224. echo %line12%
  225. echo %line13%
  226. echo %line14%
  227. echo %line15%
  228. echo %line16%
  229. echo %line17%
  230. echo %line18%
  231. echo %line19%
  232. echo %line20%
  233. echo %line21%
  234. echo %line22%
  235. echo %line23%
  236. echo %line24%
  237. echo %line25%
  238. echo %line26%
  239. echo %line27%
  240. echo %line28%
  241. echo %line29%
  242. echo %line30%
  243.  
  244. call bin\choice.exe /c:8246%interact_key%%options_key%%inventory_key%%heal_key%%map_key%79135 /N
  245. if %errorlevel% equ 1 goto 8
  246. if %errorlevel% equ 2 goto 2
  247. if %errorlevel% equ 3 goto 4
  248. if %errorlevel% equ 4 goto 6
  249. if %errorlevel% equ 5 goto action.interact
  250. if %errorlevel% equ 6 goto options
  251. if %errorlevel% equ 7 goto inventory
  252. if %errorlevel% equ 8 goto drinkpotion
  253. if %errorlevel% equ 9 goto changemap
  254. if %errorlevel% equ 10 goto 7
  255. if %errorlevel% equ 11 goto 9
  256. if %errorlevel% equ 12 goto 1
  257. if %errorlevel% equ 13 goto 3
  258. if %errorlevel% equ 14 goto stand_still
  259.  
  260. :action.interact
  261. if "%current_pos%" equ "X" (
  262. set /a gainexp=%maxExp%/10
  263. set /a Exp=%Exp%+%gainexp%
  264. ::Checks for level up.
  265. call :levelcheck
  266. goto disp
  267. )
  268.  
  269. if "%current_pos%" equ "B" goto bank
  270.  
  271. if "%current_pos%" equ "M" goto market
  272.  
  273. if "%current_pos%" equ "*" goto pickup_item
  274.  
  275. if "%current_pos%" equ "O" goto wander
  276.  
  277. if "%current_pos%" equ "F" goto fishing_spot
  278.  
  279. if "%current_pos%" equ "8" goto traveler
  280.  
  281. ::Code reaches here if player is in empty tile.
  282. goto disp
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292. ::==============================================================
  293. ::==============================================================
  294. ::==============================================================
  295. ::===========================MOVEMENT===========================
  296. ::==============================================================
  297. ::==============================================================
  298. ::==============================================================
  299. :8
  300. ::Check for north boundary. If so, cancel move request.
  301. set /a nexttile_y=%ypos%-1
  302. if "!g%nexttile_y%%xpos%!" equ "Û" goto disp
  303. ::Clears old character spot with an empty tile.
  304. set g%ypos%%xpos%=%backgroundtile%
  305. ::Move character.
  306. set /a ypos=%ypos%-1
  307. ::Set variable 'current_pos' for future detection of interactable tile.
  308. set current_pos=!g%ypos%%xpos%!
  309. goto disp
  310.  
  311. :2
  312. ::Check for south boundary. If so, cancel move request.
  313. set /a nexttile_y=%ypos%+1
  314. if "!g%nexttile_y%%xpos%!" equ "Û" goto disp
  315. ::Clears old character spot with an empty tile.
  316. set g%ypos%%xpos%=%backgroundtile%
  317. ::Move character.
  318. set /a ypos=%ypos%+1
  319. ::Set variable 'current_pos' for future detection of interactable tile.
  320. set current_pos=!g%ypos%%xpos%!
  321. goto disp
  322.  
  323. :4
  324. ::Check for west boundary. If so, cancel move request.
  325. set /a nexttile_x=%xpos%-1
  326. if "!g%ypos%%nexttile_x%!" equ "Û" goto disp
  327. ::Clears old character spot with an empty tile.
  328. set g%ypos%%xpos%=%backgroundtile%
  329. ::Move character.
  330. set /a xpos=%xpos%-1
  331. ::Set variable 'current_pos' for future detection of interactable tile.
  332. set current_pos=!g%ypos%%xpos%!
  333. goto disp
  334.  
  335. :6
  336. ::Check for east boundary. If so, cancel move request.
  337. set /a nexttile_x=%xpos%+1
  338. if "!g%ypos%%nexttile_x%!" equ "Û" goto disp
  339. ::Clears old character spot with an empty tile.
  340. set g%ypos%%xpos%=%backgroundtile%
  341. ::Move character.
  342. set /a xpos=%xpos%+1
  343. ::Set variable 'current_pos' for future detection of interactable tile.
  344. set current_pos=!g%ypos%%xpos%!
  345. goto disp
  346.  
  347. :7
  348. ::Check for northwest boundary. If so, cancel move request.
  349. set /a nexttile_y=%ypos%-1
  350. set /a nexttile_x=%xpos%-1
  351. if "!g%nexttile_y%%nexttile_x%!" equ "Û" goto disp
  352. ::Clears old character spot with an empty tile.
  353. set g%ypos%%xpos%=%backgroundtile%
  354. ::Move character.
  355. set /a ypos=%ypos%-1
  356. set /a xpos=%xpos%-1
  357. ::Set variable 'current_pos' for future detection of interactable tile.
  358. set current_pos=!g%ypos%%xpos%!
  359. goto disp
  360.  
  361. :9
  362. ::Check for northwest boundary. If so, cancel move request.
  363. set /a nexttile_y=%ypos%-1
  364. set /a nexttile_x=%xpos%+1
  365. if "!g%nexttile_y%%nexttile_x%!" equ "Û" goto disp
  366. ::Clears old character spot with an empty tile.
  367. set g%ypos%%xpos%=%backgroundtile%
  368. ::Move character.
  369. set /a ypos=%ypos%-1
  370. set /a xpos=%xpos%+1
  371. ::Set variable 'current_pos' for future detection of interactable tile.
  372. set current_pos=!g%ypos%%xpos%!
  373. goto disp
  374.  
  375. :1
  376. ::Check for northwest boundary. If so, cancel move request.
  377. set /a nexttile_y=%ypos%+1
  378. set /a nexttile_x=%xpos%-1
  379. if "!g%nexttile_y%%nexttile_x%!" equ "Û" goto disp
  380. ::Clears old character spot with an empty tile.
  381. set g%ypos%%xpos%=%backgroundtile%
  382. ::Move character.
  383. set /a ypos=%ypos%+1
  384. set /a xpos=%xpos%-1
  385. ::Set variable 'current_pos' for future detection of interactable tile.
  386. set current_pos=!g%ypos%%xpos%!
  387. goto disp
  388.  
  389. :3
  390. ::Check for northwest boundary. If so, cancel move request.
  391. set /a nexttile_y=%ypos%+1
  392. set /a nexttile_x=%xpos%+1
  393. if "!g%nexttile_y%%nexttile_x%!" equ "Û" goto disp
  394. ::Clears old character spot with an empty tile.
  395. set g%ypos%%xpos%=%backgroundtile%
  396. ::Move character.
  397. set /a ypos=%ypos%+1
  398. set /a xpos=%xpos%+1
  399. ::Set variable 'current_pos' for future detection of interactable tile.
  400. set current_pos=!g%ypos%%xpos%!
  401. goto disp
  402.  
  403. :stand_still
  404. ::Do absolutely nothing.
  405. goto disp
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412. ::==============================================================
  413. :inventory
  414. ::==============================================================
  415. ::Load player's inventory.
  416. call "saves\%player_name%\inventory\inventory.bat"
  417. :inventory_noload
  418. set sel%inventory_selection%=*
  419. ::Display inventory to player.
  420. cls
  421. echo                                      Inventory sel: %inventory_selection%
  422. echo           'Numpad 8,2' to scroll. '%interact_key%' to select. 'D' to drop. 'I' to exit.
  423. echo.
  424. echo 1.  %sel1%%item1%%sel1%
  425. echo 2.  %sel2%%item2%%sel2%
  426. echo 3.  %sel3%%item3%%sel3%
  427. echo 4.  %sel4%%item4%%sel4%
  428. echo 5.  %sel5%%item5%%sel5%
  429. echo 6.  %sel6%%item6%%sel6%
  430. echo 7.  %sel7%%item7%%sel7%
  431. echo 8.  %sel8%%item8%%sel8%
  432. echo 9.  %sel9%%item9%%sel9%
  433. echo 10. %sel10%%item10%%sel10%
  434. echo 11. Not yet added.
  435. echo 12. Not yet added.
  436. echo 13. Not yet added.
  437. echo 14. Not yet added.
  438. echo 15. Not yet added.
  439. echo 16. Not yet added.
  440. echo 17. Not yet added.
  441. echo 18. Not yet added.
  442. echo 19. Not yet added.
  443. echo 20. Not yet added.
  444. call bin\choice.exe /c:"82%interact_key%di" /n
  445. if %errorlevel% equ 1 goto inv_up
  446. if %errorlevel% equ 2 goto inv_down
  447. if %errorlevel% equ 3 goto inv_select
  448. if %errorlevel% equ 4 goto drop
  449. if %errorlevel% equ 5 goto close_inventory
  450. :close_inventory
  451. ::Save current marker spot.
  452. (
  453. echo set inventory_selection=%inventory_selection%
  454. echo set item1=%item1%
  455. echo set item2=%item2%
  456. echo set item3=%item3%
  457. echo set item4=%item4%
  458. echo set item5=%item5%
  459. echo set item6=%item6%
  460. echo set item7=%item7%
  461. echo set item8=%item8%
  462. echo set item9=%item9%
  463. echo set item10=%item10%
  464. )>"saves\%player_name%\inventory\inventory.bat"
  465. goto disp
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473. :inv_up
  474. ::Set in memory last spot, to clear markers later.
  475. set old_inventory_selection=%inventory_selection%
  476. ::Check bounds.
  477. set /a inventory_selection=%inventory_selection%-1
  478. if "%inventory_selection%" equ "0" set inventory_selection=1
  479. if "%inventory_selection%" equ "0" goto inventory_noload
  480. ::Not out of bounds, clear last spot of markers.
  481. set sel%old_inventory_selection%=
  482. goto inventory_noload
  483.  
  484. :inv_down
  485. ::Set in memory last spot, to clear markers later.
  486. set old_inventory_selection=%inventory_selection%
  487. ::Check bounds.
  488. set /a inventory_selection=%inventory_selection%+1
  489. if "%inventory_selection%" equ "11" set inventory_selection=10
  490. if "%inventory_selection%" equ "11" goto inventory_noload
  491. ::Not out of bounds, clear last spot of markers.
  492. set sel%old_inventory_selection%=
  493. goto inventory_noload
  494.  
  495. :inv_select
  496. if "!item%inventory_selection%!" equ "-" goto inventory_noload
  497. cls
  498. echo You have selected: !item%inventory_selection%!
  499. echo.
  500. echo Drop? Destroy? Eat? Use? Equip?
  501. pause
  502. goto inventory_noload
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512. :pickup_item
  513. ::Choose a loot group at random.
  514. set /a item_group=%random% %%3+1
  515. if %item_group% equ 1 goto item_group_1
  516. if %item_group% equ 2 goto item_group_2
  517. if %item_group% equ 3 goto item_group_3
  518.  
  519. :item_group_1
  520. ::Will produce number between 1-3.
  521. set /a num=%random% %%3+1
  522. if %num% equ 1 set item_to_pickup=Iron Ore
  523. if %num% equ 2 set item_to_pickup=Copper Ore
  524. if %num% equ 3 set item_to_pickup=Tin Ore
  525. goto done_item_group
  526.  
  527. :item_group_2
  528. ::Will produce number between 1-3.
  529. set /a num=%random% %%3+1
  530. if %num% equ 1 set item_to_pickup=Bass Fish
  531. if %num% equ 2 set item_to_pickup=Snapper Fish
  532. if %num% equ 3 set item_to_pickup=Sun Fish
  533. goto done_item_group
  534.  
  535. :item_group_3
  536. ::Will produce number between 1-3.
  537. set /a num=%random% %%3+1
  538. if %num% equ 1 set item_to_pickup=Ruby Gem
  539. if %num% equ 2 set item_to_pickup=Emerald Gem
  540. if %num% equ 3 set item_to_pickup=Topaz Gem
  541. goto done_item_group
  542.  
  543. ::Go here when item selection is complete.
  544. :done_item_group
  545.  
  546. ::(BUG PREVENTION) Cancel request if item is not designated.
  547. if "%item_to_pickup%" equ "" call :errormessage disp "ERROR #213 VARIABLE 'ITEM_TO_PICKUP' NOT DEFINED"
  548.  
  549. ::Call inventory file to check which spot is available to fill.
  550. call "saves\%player_name%\inventory\inventory.bat"
  551. ::Set counters.
  552. set inv_check=1
  553. set inv_counter=1
  554. :inv_check
  555. ::Check for full inventory. If 'x' amount of slots are taken, means inventory is full.
  556. if "%inv_counter%" equ "10" call :ColorText 0c "Inventory is full."
  557. if "%inv_counter%" equ "10" pause >nul
  558. if "%inv_counter%" equ "10" goto disp
  559. ::Each time a loop rolls, add to counter. When loops 'x' times, it means inventory is full.
  560. if not "!item%inv_check%!" equ "-" set /a inv_counter=%inv_counter%+1
  561. ::Scan inventory for empty spot.
  562. if not "!item%inv_check%!" equ "-" set /a inv_check=%inv_check%+1
  563. if not "!item%inv_check%!" equ "-" goto inv_check
  564. ::Empty spot found, place item there.
  565. set item%inv_check%=%item_to_pickup%
  566. ::Save new item in corresponding slot.
  567. echo set item=%item_to_pickup% > "saves\%player_name%\inventory\%inv_check%.bat"
  568. ::Save in inventory registry.
  569. (
  570. echo set inventory_selection=%inventory_selection%
  571. echo set item1=%item1%
  572. echo set item2=%item2%
  573. echo set item3=%item3%
  574. echo set item4=%item4%
  575. echo set item5=%item5%
  576. echo set item6=%item6%
  577. echo set item7=%item7%
  578. echo set item8=%item8%
  579. echo set item9=%item9%
  580. echo set item10=%item10%
  581. )>"saves\%player_name%\inventory\inventory.bat"
  582. call :ColorText 0a "Picked up %item_to_pickup%."
  583. ::Reset item to pickup.
  584. set item_to_pickup=
  585. pause >nul
  586. goto disp
  587.  
  588. :drop
  589. if "!item%inventory_selection%!" equ "-" goto inventory
  590. cls
  591. echo Dropping: !item%inventory_selection%!
  592. echo.
  593. echo D. Drop
  594. echo C. Cancel
  595. call bin\choice.exe /c:dc /N >nul
  596. if %errorlevel% equ 1 goto proceeddrop
  597. if %errorlevel% equ 2 goto inventory
  598. :proceeddrop
  599. set item%inventory_selection%=-
  600. ::Save now empty slot.
  601. (
  602. echo set item=-
  603. )>"saves\%player_name%\inventory\%inventory_selection%.bat"
  604. ::Save in file.
  605. (
  606. echo set inventory_selection=%inventory_selection%
  607. echo set item1=%item1%
  608. echo set item2=%item2%
  609. echo set item3=%item3%
  610. echo set item4=%item4%
  611. echo set item5=%item5%
  612. echo set item6=%item6%
  613. echo set item7=%item7%
  614. echo set item8=%item8%
  615. echo set item9=%item9%
  616. echo set item10=%item10%
  617. )>"saves\%player_name%\inventory\inventory.bat"
  618. goto inventory
  619.  
  620. ::==============================================================
  621. :drinkpotion
  622. ::==============================================================
  623. ::Check to see if player has enough potions to heal.
  624. if %potions% equ 0 (
  625. call :ColorText 0c "You don't have any potions left."
  626. echo.
  627. pause >nul
  628. goto disp
  629. )
  630. ::Check to see if player is already at full health.
  631. if %maxhp% equ %hp% (
  632. call :ColorText 0c "You are already at full health."
  633. echo.
  634. pause >nul
  635. goto disp
  636. )
  637. ::Heal the player
  638. set gainhealth=%hp%/10
  639. set /a hp=%hp%+10
  640. ::Overheal check.
  641. if %maxhp% lss %hp% (
  642. set hp=%maxhp%
  643. )
  644. ::Reduce potions by 1.
  645. set /a potions=%potions%-1
  646. goto disp
  647. :changemap
  648. cls
  649. echo Available maps:
  650. echo.
  651. dir maps /b
  652. echo.
  653. set input=
  654. set /p input=Map:
  655. if not defined input goto disp
  656. if not exist "maps\%input%\%input%.bat" (
  657. call :ColorText 0c "Map does not exist."
  658. echo.
  659. pause >nul
  660. goto disp
  661. )
  662. set loaded=false
  663. set map=%input%
  664. goto disp
  665.  
  666. :levelcheck
  667. ::Checks for level up.
  668. if %Exp% gtr %maxExp% (
  669. if %level% lss 50 (
  670. set /a Exp=%Exp%-%maxExp%
  671. set /a maxExp=%maxExp%*12/10
  672. set /a level=%level%+1
  673. set /a hp=%maxhp%
  674. set /a maxhp=%maxhp%*11/10
  675. )
  676. if %level% geq 50 (
  677. set /a Exp=%Exp%-%maxExp%
  678. set /a maxExp=%maxExp%*11/10
  679. set /a level=%level%+1
  680. set /a hp=%maxhp%
  681. set /a maxhp=%maxhp%+167
  682. )
  683. if %level% geq 51 (
  684. set /a Exp=%Exp%-%maxExp%
  685. set /a maxExp=%maxExp%*11/10
  686. set /a level=%level%+1
  687. set /a hp=%maxhp%
  688. set /a maxhp=%maxhp%+200
  689. )
  690. if %level% equ 99 (
  691. set /a Exp=%Exp%-%maxExp%
  692. set /a maxExp=100000000
  693. set /a level=%level%+1
  694. set /a hp=%maxhp%
  695. set /a maxhp=%maxhp%+100
  696. )
  697. if %level% geq 100 (
  698. set /a Exp=0
  699. set /a maxExp=0
  700. set /a level=100
  701. set /a hp=%maxhp%
  702. set /a maxhp=22000
  703. )
  704. cls
  705. color 0a
  706. echo You have leveled up.
  707. echo.
  708. pause
  709. color %usercolor%
  710. )
  711. goto :eof
  712.  
  713. :traveler
  714. cls
  715. echo Traveler: Greetings,  %player_name%.
  716. echo.
  717. pause
  718. goto disp
  719.  
  720. :fishing_spot
  721. call :pickup_item 0 Fish
  722. goto disp
  723.  
  724. :wander
  725. ::Set values.
  726. set hplossratio=35
  727. set /a losehp=%random% %%%hplossratio%
  728. set /a hp=%hp%-%losehp%
  729. set /a Expwin=%random% %%25
  730. set /a potionwin=%random% %%03
  731. set /a potions=%potions%+%potionwin%
  732. set /a goldwin=%random% %%25
  733. set /a gold=%gold%+%goldwin%
  734. ::Checks if player has died.
  735. if %hp% lss 1 (
  736. cls
  737. color 0c
  738. echo You have died.
  739. echo.
  740. pause
  741. set hp=5
  742. set gold=0
  743. set potions=0
  744. color %usercolor%
  745. goto disp
  746. )
  747. cls
  748. echo You successfully killed the monsters.
  749. echo.
  750. echo You lost %losehp% Health.
  751. echo.
  752. if not %Expwin% equ 0 (
  753. echo +%Expwin% Exp
  754. )
  755. if not %goldwin% equ 0 (
  756. echo +%goldwin% Gold
  757. )
  758. if not %potionwin% equ 0 (
  759. echo +%potionwin% Potion/s
  760. )
  761. echo.
  762. set /a Exp=%Exp%+%Expwin%
  763. pause
  764. ::Checks for level up.
  765. call :levelcheck
  766. goto disp
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782. :bank
  783. cls
  784. echo Gold in inventory: $%gold%
  785. echo Gold in bank: $%bank%
  786. echo.
  787. echo 1) Deposit            2) Withdraw
  788. echo.
  789. echo %interact_key%) Leave
  790. echo.
  791. call bin\choice.exe /c:12%interact_key% /n /m ">"
  792. if %errorlevel% equ 1 goto deposit
  793. if %errorlevel% equ 2 goto withdraw
  794. if %errorlevel% equ 3 goto disp
  795.  
  796. :deposit
  797. cls
  798. echo Gold in inventory: $%gold%
  799. echo.
  800. echo Deposit:
  801. echo.
  802. ::Backup gold value in case player doesn't have enough cash.
  803. set goldbackup=%gold%
  804. set bankbackup=%bank%
  805. ::Prompt player.
  806. set input=
  807. set /p input="$"
  808. ::If player enters negative amount, cancel transaction.
  809. if %input% equ "" goto bank
  810. if %input% lss 0 goto bank
  811. set /a gold=%gold%-%input%
  812. set /a bank=%bank%+%input%
  813. ::Check if player has that much gold in inventory.
  814. if %gold% lss 0 (
  815. call :ColorText 0c "Insufficient funds"
  816. echo.
  817. pause
  818. set gold=%goldbackup%
  819. set bank=%bankbackup%
  820. goto bank
  821. )
  822. ::Insufficient funds
  823. if %bank% lss 0 (
  824. call :ColorText 0c "Insufficient funds"
  825. echo.
  826. pause
  827. set gold=%goldbackup%
  828. set bank=%bankbackup%
  829. goto bank
  830. )
  831. goto bank
  832.  
  833. :withdraw
  834. cls
  835. echo Gold in bank: $%bank%
  836. echo.
  837. echo Withdraw:
  838. echo.
  839. ::Backup gold value in case player doesn't have enough cash.
  840. set goldbackup=%gold%
  841. set bankbackup=%bank%
  842. ::Prompt player.
  843. set input=
  844. set /p input="$"
  845. ::If player enters negative amount, cancel transaction.
  846. if %input% equ "" goto bank
  847. if %input% lss 0 goto bank
  848. set /a gold=%gold%+%input%
  849. set /a bank=%bank%-%input%
  850. ::Check if player has that much gold in inventory.
  851. if %bank% lss 0 (
  852. call :ColorText 0c "Insufficient funds"
  853. echo.
  854. pause
  855. set gold=%goldbackup%
  856. set bank=%bankbackup%
  857. goto bank
  858. )
  859. ::Redundancy
  860. goto bank
  861. :market
  862. ::start "" "sounds\fire_loop.wav"
  863. cls
  864. echo Welcome to the market.
  865. echo What would you like to buy?
  866. echo.
  867. echo 1) [5 Gold] Potion
  868. echo 2) [10 Gold] Heal
  869. echo 3) [250 Gold] 1 Level
  870. echo.
  871. echo %interact_key%) Leave
  872. echo.
  873. call bin\choice.exe /c:123%interact_key% /n /m ">"
  874. if %errorlevel% equ 1 goto buypotion
  875. if %errorlevel% equ 2 goto buyhealth
  876. if %errorlevel% equ 3 goto buylevel
  877. if %errorlevel% equ 4 set pos=45
  878. if %errorlevel% equ 4 goto disp
  879. :buypotion
  880. set goldbackup=%gold%
  881. set /a gold=%gold%-5
  882. if %gold% lss 0 (
  883. cls
  884. color 0c
  885. echo Not enough gold to do that.
  886. echo.
  887. pause
  888. color %usercolor%
  889. set gold=%goldbackup%
  890. goto market
  891. )
  892. set /a potions=%potions%+1
  893. cls
  894. color 0a
  895. echo Successfully bought a potion.
  896. echo.
  897. pause
  898. color %usercolor%
  899. goto market
  900. :buyhealth
  901. set goldbackup=%gold%
  902. set /a gold=%gold%-10
  903. if %gold% lss 0 (
  904. cls
  905. color 0c
  906. echo Could not process your order, Insufficient funds.
  907. echo.
  908. pause
  909. color %usercolor%
  910. set gold=%goldbackup%
  911. goto market
  912. )
  913. if %hp% equ %maxhp% (
  914. call :ColorText 0c "You are already at full health."
  915. set gold=%goldbackup%
  916. goto market
  917. )
  918. set hp=%maxhp%
  919. cls
  920. color 0a
  921. echo Successfully payed to be healed.
  922. echo.
  923. pause
  924. color %usercolor%
  925. goto disp
  926. :buylevel
  927. set goldbackup=%gold%
  928. set /a gold=%gold%-250
  929. if %gold% lss 0 (
  930. cls
  931. color 0c
  932. echo Could not process your order, Insufficient funds.
  933. echo.
  934. pause
  935. color %usercolor%
  936. set gold=%goldbackup%
  937. goto market
  938. )
  939. set /a level=%level%+1
  940. cls
  941. color 0a
  942. echo Successfully bought a level.
  943. echo.
  944. pause
  945. color %usercolor%
  946. goto disp
  947. :givexp
  948. set /p Expwin=xp
  949. set /a Exp=%Exp%+%Expwin%
  950. cls
  951. echo You gained %Expwin% Exp.
  952. echo.
  953. pause
  954. set hp=%maxhp%
  955. goto disp
  956. :options
  957. cls
  958. echo Options:
  959. echo [1] Color
  960. echo [2] Hotkeys
  961. echo [3] Save
  962. echo [4] Exit without saving
  963. echo [5] Save and exit
  964. echo.
  965. echo [O] Back
  966. call bin\choice.exe /c:12345o /N
  967. if %errorlevel% equ 1 goto changecolors
  968. if %errorlevel% equ 2 goto disp
  969. if %errorlevel% equ 3 goto save
  970. if %errorlevel% equ 4 goto exitwithoutsaving
  971. if %errorlevel% equ 5 goto saveandexit
  972. if %errorlevel% equ 6 goto disp
  973. :changecolors
  974. if "%backgroundcolor%" equ "" set backgroundcolor=0
  975. color %backgroundcolor%f
  976. cls
  977. echo Note: Colors are unique to saves.
  978. echo.
  979. echo 0 = Black
  980. echo 1 = Blue
  981. echo 2 = Green
  982. echo 3 = Aqua
  983. echo 4 = Red
  984. echo 5 = Purple
  985. echo 6 = Yellow
  986. echo 7 = White
  987. echo 8 = Gray
  988. echo 9 = Light Blue
  989. echo A = Light Green
  990. echo B = Light Aqua
  991. echo C = Light Red
  992. echo D = Light Purple
  993. echo E = Light Yellow
  994. echo F = Bright White
  995. echo.
  996. echo Press 'M' to move on.
  997. echo.
  998. ver >nul
  999. call bin\choice.exe /c:0123456789abcdefm /n "Choose background color:"
  1000. if %errorlevel% equ 1 set backgroundcolor=0
  1001. if %errorlevel% equ 2 set backgroundcolor=1
  1002. if %errorlevel% equ 3 set backgroundcolor=2
  1003. if %errorlevel% equ 4 set backgroundcolor=3
  1004. if %errorlevel% equ 5 set backgroundcolor=4
  1005. if %errorlevel% equ 6 set backgroundcolor=5
  1006. if %errorlevel% equ 7 set backgroundcolor=6
  1007. if %errorlevel% equ 8 set backgroundcolor=7
  1008. if %errorlevel% equ 9 set backgroundcolor=8
  1009. if %errorlevel% equ 10 set backgroundcolor=9
  1010. if %errorlevel% equ 11 set backgroundcolor=a
  1011. if %errorlevel% equ 12 set backgroundcolor=b
  1012. if %errorlevel% equ 13 set backgroundcolor=c
  1013. if %errorlevel% equ 14 set backgroundcolor=d
  1014. if %errorlevel% equ 15 set backgroundcolor=e
  1015. if %errorlevel% equ 16 set backgroundcolor=f
  1016. if %errorlevel% equ 17 goto changetxt
  1017. goto changecolors
  1018. :changetxt
  1019. if "%textcolor%" equ "" set textcolor=f
  1020. color %backgroundcolor%%textcolor%
  1021. cls
  1022. echo Note: Colors are unique to saves.
  1023. echo.
  1024. echo 0 = Black
  1025. echo 1 = Blue
  1026. echo 2 = Green
  1027. echo 3 = Aqua
  1028. echo 4 = Red
  1029. echo 5 = Purple
  1030. echo 6 = Yellow
  1031. echo 7 = White
  1032. echo 8 = Gray
  1033. echo 9 = Light Blue
  1034. echo A = Light Green
  1035. echo B = Light Aqua
  1036. echo C = Light Red
  1037. echo D = Light Purple
  1038. echo E = Light Yellow
  1039. echo F = Bright White
  1040. echo.
  1041. echo Press 'M' to move on.
  1042. echo.
  1043. ver >nul
  1044. call bin\choice.exe /c:0123456789abcdefm /n "Choose text color:"
  1045. if %errorlevel% equ 1 set textcolor=0
  1046. if %errorlevel% equ 2 set textcolor=1
  1047. if %errorlevel% equ 3 set textcolor=2
  1048. if %errorlevel% equ 4 set textcolor=3
  1049. if %errorlevel% equ 5 set textcolor=4
  1050. if %errorlevel% equ 6 set textcolor=5
  1051. if %errorlevel% equ 7 set textcolor=6
  1052. if %errorlevel% equ 8 set textcolor=7
  1053. if %errorlevel% equ 9 set textcolor=8
  1054. if %errorlevel% equ 10 set textcolor=9
  1055. if %errorlevel% equ 11 set textcolor=a
  1056. if %errorlevel% equ 12 set textcolor=b
  1057. if %errorlevel% equ 13 set textcolor=c
  1058. if %errorlevel% equ 14 set textcolor=d
  1059. if %errorlevel% equ 15 set textcolor=e
  1060. if %errorlevel% equ 16 set textcolor=f
  1061. if %errorlevel% equ 17 goto save_colors_verification
  1062. goto changetxt
  1063. :save_colors_verification
  1064. cls
  1065. color %backgroundcolor%%textcolor%
  1066. echo Are you sure?
  1067. echo.
  1068. call bin\choice.exe /c:yn /n "Y/N >"
  1069. if %errorlevel% equ 1 goto save_colors
  1070. if %errorlevel% equ 2 goto disp
  1071. :save_colors
  1072. set usercolor=%backgroundcolor%%textcolor%
  1073. goto save
  1074.  
  1075. :hotkeys
  1076. ::UNDER DEVELOPMENT
  1077. ::show all hotkeys here
  1078. goto disp
  1079.  
  1080. :save
  1081. ::Save all data.
  1082. cls
  1083. echo Saving...
  1084. (
  1085. echo set player_name=%player_name%
  1086. echo set usercolor=%usercolor%
  1087. echo set level=%level%
  1088. echo set Exp=%Exp%
  1089. echo set maxExp=%maxExp%
  1090. echo set hp=%hp%
  1091. echo set maxhp=%maxhp%
  1092. echo set mana=%mana%
  1093. echo set maxmana=%maxmana%
  1094. echo set gold=%gold%
  1095. echo set bank=%bank%
  1096. echo set potions=%potions%
  1097. echo set xpos=%xpos%
  1098. echo set ypos=%ypos%
  1099. )>"saves\%player_name%\stats.bat"
  1100. (
  1101. echo set inventory_selection=%inventory_selection%
  1102. echo set item1=%item1%
  1103. echo set item2=%item2%
  1104. echo set item3=%item3%
  1105. echo set item4=%item4%
  1106. echo set item5=%item5%
  1107. echo set item6=%item6%
  1108. echo set item7=%item7%
  1109. echo set item8=%item8%
  1110. echo set item9=%item9%
  1111. echo set item10=%item10%
  1112. )>"saves\%player_name%\inventory\inventory.bat"
  1113. goto disp
  1114. :exitwithoutsaving
  1115. cls
  1116. color 0c
  1117. echo Are you sure you want to quit WITHOUT saving? Y/N
  1118. call bin\choice.exe /c:yn /N
  1119. if %errorlevel% equ 1 exit
  1120. if %errorlevel% equ 2 goto disp
  1121. :saveandexit
  1122. ::Save all data.
  1123. cls
  1124. echo Saving...
  1125. (
  1126. echo set player_name=%player_name%
  1127. echo set usercolor=%usercolor%
  1128. echo set level=%level%
  1129. echo set Exp=%Exp%
  1130. echo set maxExp=%maxExp%
  1131. echo set hp=%hp%
  1132. echo set maxhp=%maxhp%
  1133. echo set mana=%mana%
  1134. echo set maxmana=%maxmana%
  1135. echo set gold=%gold%
  1136. echo set bank=%bank%
  1137. echo set potions=%potions%
  1138. echo set xpos=%xpos%
  1139. echo set ypos=%ypos%
  1140. )>"saves\%player_name%\stats.bat"
  1141. (
  1142. echo set inventory_selection=%inventory_selection%
  1143. echo set item1=%item1%
  1144. echo set item2=%item2%
  1145. echo set item3=%item3%
  1146. echo set item4=%item4%
  1147. echo set item5=%item5%
  1148. echo set item6=%item6%
  1149. echo set item7=%item7%
  1150. echo set item8=%item8%
  1151. echo set item9=%item9%
  1152. echo set item10=%item10%
  1153. )>"saves\%player_name%\inventory\inventory.bat"
  1154. exit
  1155.  
  1156.  
  1157. :check_integrity
  1158. cls
  1159. echo Checking integrity . . .
  1160. ::Display corrupt installation message if some core files are missing.
  1161. set check_status=0
  1162. if exist "bin" set /a check_status=%check_status%+1
  1163. if exist "bin\choice.exe" set /a check_status=%check_status%+1
  1164. if exist "maps" set /a check_status=%check_status%+1
  1165. if exist "npc" set /a check_status=%check_status%+1
  1166. if exist "saves" set /a check_status=%check_status%+1
  1167. if exist "sounds" set /a check_status=%check_status%+1
  1168. if exist "config.bat" set /a check_status=%check_status%+1
  1169. if "%check_status%" equ "7" goto :eof
  1170. cls
  1171. echo Some core files were not detected. Game may not work correctly.
  1172. echo.
  1173. pause
  1174. goto :eof
  1175.  
  1176.  
  1177. :ColorText
  1178. for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do set "DEL=%%a"
  1179. <nul set /p ".=%DEL%" > "%~2"
  1180. findstr /v /a:%1 /R "^$" "%~2" nul
  1181. del "%~2" > nul 2>&1
  1182. goto :eof
  1183.  
  1184. :errormessage
  1185. set oldtext=%2
  1186. set text=%oldtext:"=%
  1187. cls
  1188. color %backgroundcolor%c
  1189. echo %text%
  1190. echo.
  1191. pause
  1192. color %backgroundcolor%2
  1193. goto %1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement