0 Members and 1 Guest are viewing this topic.
@echo offif /i "%1"=="Attrib" (goto checkhighscore.txt)if /i "%1"=="Countermode" (goto countermode)title Splat-The-Ratsetlocal enabledelayedexpansionfor %%I in (%0) do set filename=%%~sIif exist highscore.txt (start /MIN CMD.exe /c "%FILENAME% Attrib")if exist info.dat del info.dat:menutitle Splat-The-Ratclsecho Main Menuecho ---------echo.echo To play a game, enter 1echo For instructions, enter 2echo For Highscores, enter 3echo To exit, enter 4set menu=set /p menu=""if not defined menu goto menuif %menu%==1 (goto startgame)if %menu%==2 (goto instructions)if %menu%==3 (goto Displayscores)if %menu%==4 (exit /b)goto menu:checkhighscore.txtattrib highscore.txt | find "SHR" >nulif %errorlevel%==0 (exit)attrib highscore.txt +S +H +Rexit:instructionsclsecho Splat The Ratecho -------------echo The aim of the game is to hit the rat with your club as soon as itecho pops out of its hole. You can try hitting the ratecho with the quickest reaction time, or hit as many rats in a row asecho possible. Your score is recorded in the same directory as the gameecho file.echo.echo.echo Press any key for the next pagepause>nulclsecho Splat The Ratecho -------------echo As soon as you start the game one extra window will appear, titledecho 'Rat Window' this window shows the activity of the rat. As soon as echo the window appears it should be dragged away from the original echo Bat Window to allow you to see both. You should then click on theecho Bat Window to allow you to use your bat.echo.echo.echo Press any key for the next pagepause>nulclsecho Splat The Ratecho -------------echo To hit the rat, have the Bat Window selected, and press any key as soonecho as you see the rat appear on the Rat Window.echo.echo.echo Press any key to go to the main menu.pause>nulgoto menu:displayscoresclsif not exist highscore.txt (echo No high scores yet.echo.echo Press any key to return to menupause>nulgoto menu)find /i "Fastest-Single-Reaction=" Highscore.txt >nulset count=%errorlevel%find /i "Most-Rats-Hit=" Highscore.txt >nulset /a count= %count% + %errorlevel%find /i "Best-Average-Reaction=" Highscore.txt >nulset /a count= %count% + %errorlevel%if %count%==3 (echo High Score File Incorrectecho.echo Press any key to return to menupause>nulgoto menu)echo High Scoresecho -----------echo.type highscore.txt | find /i "fastest-Single-Reaction"type highscore.txt | find /i "Most-Rats-Hit"type highscore.txt | find /i "Best-Average-Reaction"echo.echo.echo Press any key to return to menupause>nulgoto menu:startgametitle Bat Windowclsset fastestreaction=999set SN=0set totalmil=0set offset=10echo nul >info.datstart cmd /c "%filename% Countermode"Echo Move the Rat window so you can see both windows, then clickecho this window.echo.echo Press any key to begin the gamepause>nulecho START >info.datclsecho Press Any Key To Swing Your Bat!Pause>nulset swingtime=%time:~2%echo Y%SN%-%swingtime% >>info.dat:resultfind /i "w%SN%" info.dat >nulif %errorlevel%==0 (clsset /a sn= %SN% + 1goto Swingagain)find /i "l" info.dat >nulif %errorlevel%==0 (clsecho Game Overgoto gotresult)goto result:swingagainecho Good Hitif %sn%==1 (echo Got 1 rat so far) else (echo Got %sn% rats so far):processreactiontimeif %sn% geq 11 set offset=11if %sn% geq 101 set offset=12set x=1for /f %%A in (info.dat) do set data=%%A & call :Setswingtimeset x=1for /f %%A in (info.dat) do set data=%%A & call :Setfalltimeset /a CFN= ( %sn% * 3 ) - 1set /a CSN= %sn% * 3set truefalltime=!falltime%CFN%!set truefalltime=!truefalltime:~%offset%,2!set trueswingtime=!swingtime%CSN%!set trueswingtime=!trueswingtime:~%offset%,2!if /i %trueswingtime%==08 (set trueswingtime=8)if /i %trueswingtime%==09 (set trueswingtime=9)if /i %truefalltime%==08 (set truefalltime=8)if /i %truefalltime%==09 (set truefalltime=9)set /a reactionmil= %trueswingtime% - %truefalltime%if /i %reactionmil% lss 0 (set /a reactionmil= %reactionmil% + 100)if /i %reactionmil% leq 9 (echo Your reaction time was 0.0%reactionmil% Seconds) else (echo Your reaction time was 0.%reactionmil% Seconds)goto continueswingagain:setswingtimeset Swingtime%x%=%data%set /a x= %x% + 1exit /b:setfalltimeset falltime%x%=%data%set /a x= %x% + 1exit /b:continueswingagainecho.echo Press Any Key To Swing Your Batpause>nulset swingtime=%time:~2%echo Y%SN%-%swingtime% >>info.datset /a totalmil= %totalmil% + %reactionmil%if not defined fastestreaction (set fastestreaction=%reactionmil%)if /i %fastestreaction% gtr %reactionmil% (set fastestreaction=%reactionmil%)goto result:Gotresultif %sn% equ 0 (echo Sorry, you didn't get any ratsgoto moreresults)if %sn% equ 1 (echo Sorry, you only got one ratgoto Moreresults)if /i %sn% leq 3 (echo Sorry, you only got %sn% rats) else (echo Well done, you got %sn% rats):moreresultsfind /i info.dat "LL" >nulif /i %errorlevel% equ 0 (Echo On that last one, you were too slow, he got away.) else (echo On that last one, you swung too soon.)IF %sn%==0 goto end:processratsset /a averagetime= %totalmil% / %sn%echo You got %sn% ratsecho Your average reaction time was 0.%averagetime% secondsif /i %fastestreaction% leq 9 (echo Your reaction time was 0.0%fastestreaction% Seconds) else (echo Your reaction time was 0.%fastestreaction% Seconds)if not exist highscore.txt goto noscorelistgoto scorelistexists:noscorelistset most=1set best=1set fastest=1goto changescore:scorelistexistsset most=set fastest=set best=find /i "Most-Rats-Hit" Highscore.txt >nulif /i NOT %errorlevel% equ 0 (set Most=1)find /i "Fastest-Single-Reaction" Highscore.txt >nulif /i NOT %errorlevel% equ 0 (set Fastest=1)find /i "Best-Average-reaction" Highscore.txt >nulif /i NOT %errorlevel% equ 0 (set Best=1)goto Mustcompare:Mustcomparefor /f %%A in (highscore.txt) do set data=%%A & call :RHsetset sorted=for /f %%A in (highscore.txt) do set data=%%A & call :BAsetset sorted=for /f %%A in (highscore.txt) do set data=%%A & call :FRsetset sorted=set oldRH=%oldRH:~20%set oldBA=%oldBA:~30,2%set oldFR=%oldFR:~32,2%goto comparetime:rhsetset variable=OldRHset keyword=Mostcall :sortvariablesexit /b:basetset variable=OldBAset keyword=Bestcall :sortvariablesexit /b:frsetset variable=OldFRset keyword=Fastestcall :sortvariablesexit /b:sortvariablesif defined sorted (goto endsortvariables)set %variable%=%data%echo !%variable%! | find /i "%keyword%" >nulif NOT errorlevel 1 (set sorted=1) else (set %variable%=):endsortvariablesexit /b:comparetimeif defined fastest goto alreadyfastestif /i %fastestreaction% lss %oldfr% (set fastest=1):alreadyfastestif defined Most goto alreadymostif /i %oldRH% lss %SN% (set Most=1):alreadymostif defined best goto alreadybestif /i %averagetime% lss %OldBA% (set Best=1):alreadybestif defined best goto Changescoreif defined most goto Changescoreif defined fastest goto Changescoregoto end:changescoreecho.Echo New High Score!echo ---------------echo New Score In:echo.if defined most (echo Most Rats Hit)if defined best (echo Best Average Time)if defined fastest (echo Fastest Single Reaction)echo.set initials=echo Please Enter Your Initials (3 Characters Maximum)set /p initials=""IF NOT defined initials (clsgoto changescore)if "%initials:~1%"=="" (set initials=%initials%--)if "%initials:~2%"=="" (set initials=%initials%-)set initials=%initials:~0,3%if defined most goto editmostgoto checkeditbest:editmostif /i %fastestreaction% leq 9 (set fastestreaction=0%fastestreaction%)if exist highscore.txt (type highscore.txt | find /i /v "most-rats-hit" >Highscoreattrib highscore.txt -s -h -rtype highscore >Highscore.txtattrib highscore.txt +s +h +rdel highscoreattrib highscore.txt -s -h -recho %initials%---Most-Rats-Hit=%sn% >>Highscore.txtattrib highscore.txt +s +h +r) else (echo %initials%---Most-Rats-Hit=%sn% >>Highscore.txtattrib highscore.txt +s +h +r):checkeditbestif defined best goto editbestgoto checkeditfastest:editbestif exist highscore.txt (type highscore.txt | find /i /v "best-average-reaction" >Highscoreattrib highscore.txt -s -h -rtype highscore >Highscore.txtattrib highscore.txt +s +h +rdel highscoreattrib highscore.txt -s -h -recho %initials%---Best-Average-Reaction=0.%averagetime% >>Highscore.txtattrib highscore.txt +s +h +r) else (echo %initials%---Best-Average-Reaction=0.%averagetime% >>Highscore.txtattrib highscore.txt +s +h +r):checkeditfastestif defined fastest goto editfastestgoto scoresedited:editfastestif exist highscore.txt (type highscore.txt | find /i /v "Fastest-Single-Reaction" >Highscoreattrib highscore.txt -s -h -rtype highscore >Highscore.txtattrib highscore.txt +s +h +rdel highscoreattrib highscore.txt -s -h -recho %initials%---Fastest-Single-Reaction=0.%fastestreaction% >>Highscore.txtattrib highscore.txt +s +h +r) else (echo %initials%---Fastest-Single-Reaction=0.%fastestreaction% >>Highscore.txtattrib highscore.txt +s +h +r):Scoreseditedecho Scores Savedecho.goto end:enddel info.datpause>nul:playagainecho Go to menu? (Y/N):playagain1set choice=set /p choice=""if /i "%choice:~0,1%"=="Y" (goto menu)if /i "%choice:~0,1%"=="N" (exit /b)goto playagain::###################################################################:COUNTERMODE@echo offcolor f0title Rat Windowsetlocal enabledelayedexpansionecho Move this window so you can see both windows.echo Have the Bat window selected and press any key to begin the game:waittostarttype info.dat | find /i "start" >nulif %errorlevel%==0 (goto TimeTostart) else (goto waittostart):TimeToStartset timestart=%time:~2%echo X%timestart% >info.datset SN=-1set w=0clsgoto timesetup:1find info.dat "Y%sn%" >nulif %errorlevel%==0 goto stopif /i %time:~6,2% equ %timechange% goto ShowRatgoto noRats:ShowRatset ztime%sn%=Z%sn%-%time:~2%clscall :showratset w=1set timechange=CHANGE_DONEecho !ztime%sn%! >>info.dat:noRatsif /i %time:~6,2% equ %timeback% (clscall :noratecho.echo You missed the rat!echo Swing your bat to end the game.set w=0set timeback=CHANGE_DONEset L=L)goto 1:STOPif /i %w%==1 (echo W%sn% >>info.dat) else (echo L%L% >>info.datexit /b):Timesetupclscall :noratset w=0set /a sn= %sn% + 1set timestart=%time:~2%set timechange=%timestart:~4,2%if /i %timechange% equ 08 (set timechange=8)if /i %timechange% equ 09 (set timechange=9)set /a timechange= %timechange% + 2 + %random:~1,1%if %timechange% geq 60 (set /a timechange= %timechange% - 60)set /a timeback= %timechange% + 1if %timeback% geq 60 (set /a timeback=%timeback% - 60)if /i %timechange% equ 8 (set timechange=08)if /i %timechange% equ 9 (set timechange=09)if /i %timeback% equ 8 (set timeback=08)if /i %timeback% equ 9 (set timeback=09)goto 1:NORATecho __ __ __ __ __ __ __ __ __ echo [__][__][__][__][__][__][__][__][__]echo _][__][__][__][__][__][__][__][__][_echo [__][__][__][__][__][__][__][__][__]echo _][__][__][__][__][__][__][__][__][_echo [__][__][__][__][__][__][__][__][__]echo _][__][__][__][__][__][__][__][__][_echo [__][__][__][__][__][__][__][__][__]echo ____________________________________exit /b:showratecho __ __ __ __ __ __ __ __ __ echo [__][__][__][__][__][__][__][__][__]echo _][__][__][__][__][__][__][__][__][_echo [__][__][__] __ __ _][__][__][__]echo _][__][__] (_.)__(._) __][__][__][_echo [__][__][__] (- -) _][__][__][__]echo _][__][__][ --{()}-- [__][__][__][_echo [__][__][__] (____) _][__][__][__]echo ______________''__''________________exit /b