Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- title Mini RPG v0.2 Beta
- color 0B
- setlocal EnableDelayedExpansion
- REM Connor's RPG v0.2 - Added combat and more features
- REM Still using the same terrain system from v0.1 but expanded
- set VERSION=0.2
- set px=1
- set py=1
- set coins=0
- set health=15
- set max_health=15
- set game_time=0
- REM Same terrain matrix as before
- 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"
- 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"
- 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"
- 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"
- REM More items this time
- set "item_2_2=C" & set "item_0_3=C" & set "item_1_4=C"
- set "item_3_1=H" & set "item_0_0=H"
- set "item_2_4=E" & set "item_3_3=E"
- :game_loop
- cls
- echo ================================
- echo Mini RPG v%VERSION% Beta
- echo HP: %health%/%max_health% ^| Coins: %coins% ^| Time: %game_time%s
- echo ================================
- echo.
- REM Display terrain legend - kept forgetting what numbers meant
- echo [0]Plains [1]Forest [2]Mountain [3]Swamp [4]Desert [5]Hills [6]Cave [7]Rocky [8]Volcano [9]Ice
- echo Items: C=Coin H=Health E=Enemy Player=P
- echo.
- for /L %%r in (0,1,3) do (
- set "line="
- for /L %%c in (0,1,4) do (
- if %%r==%py% if %%c==%px% (
- set "line=!line![P]"
- ) else (
- call set t_num=%%t_%%r%_%%c%%
- call set item_at=%%item_%%r%_%%c%%
- if defined item_at (
- set "line=!line![!item_at!]"
- ) else (
- set "line=!line![!t_num!]"
- )
- )
- )
- echo !line!
- )
- REM Show current terrain effect
- call set current_terrain=%%t_%py%_%px%%%
- echo.
- echo Current terrain: !current_terrain! -
- if !current_terrain!==8 echo WARNING: Volcanic heat! & set /a health-=1
- if !current_terrain!==9 echo COLD: Ice terrain chills you & set /a health-=1
- if !current_terrain!==3 echo Swamp slows movement
- if !current_terrain!==6 echo Dark cave - be careful
- echo.
- set /p cmd="Action [WASD=move, Q=quit]: "
- set /a game_time+=1
- if /I "!cmd!"=="Q" exit /b
- if /I "!cmd!"=="W" set /a py-=1
- if /I "!cmd!"=="A" set /a px-=1
- if /I "!cmd!"=="S" set /a py+=1
- if /I "!cmd!"=="D" set /a px+=1
- REM Bounds checking
- if %px% LSS 0 set px=0
- if %px% GTR 4 set px=4
- if %py% LSS 0 set py=0
- if %py% GTR 3 set py=3
- REM Item interaction
- call set item_here=%%item_%py%_%px%%%
- if defined item_here (
- if "!item_here!"=="C" (
- set /a coins+=1
- echo Collected coin! [Total: %coins%]
- set item_%py%_%px%=
- timeout /t 1 >nul
- )
- if "!item_here!"=="H" (
- set /a health+=5
- if %health% GTR %max_health% set health=%max_health%
- echo Health restored! [HP: %health%/%max_health%]
- set item_%py%_%px%=
- timeout /t 1 >nul
- )
- if "!item_here!"=="E" (
- echo Enemy encounter!
- call :combat_routine
- set item_%py%_%px%=
- )
- )
- REM Random encounters - probability based on terrain
- call set terrain_here=%%t_%py%_%px%%%
- set /a encounter_roll=!RANDOM! %% 20
- if !terrain_here!==1 if !encounter_roll! LEQ 2 echo Forest creature startles you! & set /a health-=1 & timeout /t 1 >nul
- if !terrain_here!==6 if !encounter_roll! LEQ 3 echo Cave monster attacks! & set /a health-=2 & timeout /t 1 >nul
- if %health% LEQ 0 (
- echo.
- echo *** GAME OVER ***
- echo Survived %game_time% turns with %coins% coins
- pause
- exit /b
- )
- goto game_loop
- :combat_routine
- echo ========================
- echo COMBAT ENCOUNTER
- echo ========================
- set enemy_hp=6
- set /a player_damage=2 + !RANDOM! %% 3
- :combat_turn
- echo Enemy HP: %enemy_hp% ^| Your HP: %health%
- set /p combat_action="[A]ttack or [R]un: "
- if /I "!combat_action!"=="R" (
- echo You fled the battle!
- timeout /t 1 >nul
- goto :eof
- )
- if /I "!combat_action!"=="A" (
- echo You attack for %player_damage% damage!
- set /a enemy_hp-=%player_damage%
- if !enemy_hp! LEQ 0 (
- echo Enemy defeated! +3 coins, +1 HP
- set /a coins+=3
- set /a health+=1
- if %health% GTR %max_health% set health=%max_health%
- timeout /t 2 >nul
- goto :eof
- )
- REM Enemy counterattack
- set /a enemy_damage=1 + !RANDOM! %% 3
- echo Enemy strikes back for !enemy_damage! damage!
- set /a health-=!enemy_damage!
- timeout /t 1 >nul
- if %health% LEQ 0 goto :eof
- goto combat_turn
- )
- goto combat_turn
Advertisement
Add Comment
Please, Sign In to add comment