Odin_RPG

v 0.2

Aug 21st, 2025
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1. @echo off
  2. title Mini RPG v0.2 Beta
  3. color 0B
  4. setlocal EnableDelayedExpansion
  5.  
  6. REM Connor's RPG v0.2 - Added combat and more features
  7. REM Still using the same terrain system from v0.1 but expanded
  8. set VERSION=0.2
  9.  
  10. set px=1
  11. set py=1
  12. set coins=0
  13. set health=15
  14. set max_health=15
  15. set game_time=0
  16.  
  17. REM Same terrain matrix as before
  18. set "t_0_0=0" & set "t_0_1=7" & set "t_0_2=4" & set "t_0_3=4" & set "t_0_4=5"
  19. set "t_1_0=8" & set "t_1_1=5" & set "t_1_2=9" & set "t_1_3=7" & set "t_1_4=0"
  20. set "t_2_0=1" & set "t_2_1=3" & set "t_2_2=0" & set "t_2_3=6" & set "t_2_4=1"
  21. set "t_3_0=7" & set "t_3_1=5" & set "t_3_2=3" & set "t_3_3=2" & set "t_3_4=7"
  22.  
  23. REM More items this time
  24. set "item_2_2=C" & set "item_0_3=C" & set "item_1_4=C"
  25. set "item_3_1=H" & set "item_0_0=H"
  26. set "item_2_4=E" & set "item_3_3=E"
  27.  
  28. :game_loop
  29. cls
  30. echo ================================
  31. echo Mini RPG v%VERSION% Beta
  32. echo HP: %health%/%max_health% ^| Coins: %coins% ^| Time: %game_time%s
  33. echo ================================
  34. echo.
  35.  
  36. REM Display terrain legend - kept forgetting what numbers meant
  37. echo [0]Plains [1]Forest [2]Mountain [3]Swamp [4]Desert [5]Hills [6]Cave [7]Rocky [8]Volcano [9]Ice
  38. echo Items: C=Coin H=Health E=Enemy Player=P
  39. echo.
  40.  
  41. for /L %%r in (0,1,3) do (
  42. set "line="
  43. for /L %%c in (0,1,4) do (
  44. if %%r==%py% if %%c==%px% (
  45. set "line=!line![P]"
  46. ) else (
  47. call set t_num=%%t_%%r%_%%c%%
  48. call set item_at=%%item_%%r%_%%c%%
  49. if defined item_at (
  50. set "line=!line![!item_at!]"
  51. ) else (
  52. set "line=!line![!t_num!]"
  53. )
  54. )
  55. )
  56. echo !line!
  57. )
  58.  
  59. REM Show current terrain effect
  60. call set current_terrain=%%t_%py%_%px%%%
  61. echo.
  62. echo Current terrain: !current_terrain! -
  63. if !current_terrain!==8 echo WARNING: Volcanic heat! & set /a health-=1
  64. if !current_terrain!==9 echo COLD: Ice terrain chills you & set /a health-=1
  65. if !current_terrain!==3 echo Swamp slows movement
  66. if !current_terrain!==6 echo Dark cave - be careful
  67.  
  68. echo.
  69. set /p cmd="Action [WASD=move, Q=quit]: "
  70. set /a game_time+=1
  71.  
  72. if /I "!cmd!"=="Q" exit /b
  73. if /I "!cmd!"=="W" set /a py-=1
  74. if /I "!cmd!"=="A" set /a px-=1
  75. if /I "!cmd!"=="S" set /a py+=1
  76. if /I "!cmd!"=="D" set /a px+=1
  77.  
  78. REM Bounds checking
  79. if %px% LSS 0 set px=0
  80. if %px% GTR 4 set px=4
  81. if %py% LSS 0 set py=0
  82. if %py% GTR 3 set py=3
  83.  
  84. REM Item interaction
  85. call set item_here=%%item_%py%_%px%%%
  86. if defined item_here (
  87. if "!item_here!"=="C" (
  88. set /a coins+=1
  89. echo Collected coin! [Total: %coins%]
  90. set item_%py%_%px%=
  91. timeout /t 1 >nul
  92. )
  93. if "!item_here!"=="H" (
  94. set /a health+=5
  95. if %health% GTR %max_health% set health=%max_health%
  96. echo Health restored! [HP: %health%/%max_health%]
  97. set item_%py%_%px%=
  98. timeout /t 1 >nul
  99. )
  100. if "!item_here!"=="E" (
  101. echo Enemy encounter!
  102. call :combat_routine
  103. set item_%py%_%px%=
  104. )
  105. )
  106.  
  107. REM Random encounters - probability based on terrain
  108. call set terrain_here=%%t_%py%_%px%%%
  109. set /a encounter_roll=!RANDOM! %% 20
  110. if !terrain_here!==1 if !encounter_roll! LEQ 2 echo Forest creature startles you! & set /a health-=1 & timeout /t 1 >nul
  111. if !terrain_here!==6 if !encounter_roll! LEQ 3 echo Cave monster attacks! & set /a health-=2 & timeout /t 1 >nul
  112.  
  113. if %health% LEQ 0 (
  114. echo.
  115. echo *** GAME OVER ***
  116. echo Survived %game_time% turns with %coins% coins
  117. pause
  118. exit /b
  119. )
  120.  
  121. goto game_loop
  122.  
  123. :combat_routine
  124. echo ========================
  125. echo COMBAT ENCOUNTER
  126. echo ========================
  127. set enemy_hp=6
  128. set /a player_damage=2 + !RANDOM! %% 3
  129.  
  130. :combat_turn
  131. echo Enemy HP: %enemy_hp% ^| Your HP: %health%
  132. set /p combat_action="[A]ttack or [R]un: "
  133.  
  134. if /I "!combat_action!"=="R" (
  135. echo You fled the battle!
  136. timeout /t 1 >nul
  137. goto :eof
  138. )
  139.  
  140. if /I "!combat_action!"=="A" (
  141. echo You attack for %player_damage% damage!
  142. set /a enemy_hp-=%player_damage%
  143. if !enemy_hp! LEQ 0 (
  144. echo Enemy defeated! +3 coins, +1 HP
  145. set /a coins+=3
  146. set /a health+=1
  147. if %health% GTR %max_health% set health=%max_health%
  148. timeout /t 2 >nul
  149. goto :eof
  150. )
  151. REM Enemy counterattack
  152. set /a enemy_damage=1 + !RANDOM! %% 3
  153. echo Enemy strikes back for !enemy_damage! damage!
  154. set /a health-=!enemy_damage!
  155. timeout /t 1 >nul
  156.  
  157. if %health% LEQ 0 goto :eof
  158. goto combat_turn
  159. )
  160.  
  161. goto combat_turn
Advertisement
Add Comment
Please, Sign In to add comment