Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "misc.au3"
- #include "file.au3"
- #include "array.au3"
- #include "_enableconsole.au3"
- _enableconsole()
- ;design
- dim $boardlength = 30
- dim $fretsline = 5
- dim $beepenable = 0
- dim $beepfrequencybase = 300
- dim $starpowerdrain = 2
- dim $starpowerbars = 16
- ;characters
- dim $beatline = "-"
- dim $emptychar = "-"
- dim $fretoff = "|"
- dim $freton = "#"
- dim $hammeron = "o"
- dim $hold = "="
- dim $normalnote = "O"
- dim $starnote = "X"
- dim $starnotehammer = "x"
- ;vars
- dim $hammeredon[1][6]
- dim $char[$boardlength + 1][6]
- dim $bpm = 100
- dim $delay = 15000 / $bpm
- dim $fret[6]
- dim $holding[6]
- dim $position = 0
- dim $song[1][1]
- dim $songlength
- dim $songname
- dim $streak = 0
- dim $tick
- dim $totalticks
- dim $songlist[1]
- dim $cursorpos
- dim $higheststreak
- dim $pressedfrets[6]
- dim $currentnotes[6]
- dim $requirednotes[6]
- dim $playednote
- dim $totalnotes
- dim $totalnoteshit
- dim $score
- dim $multiplier
- dim $holdscorebase = 5
- dim $scorebase = 50
- dim $maxmulti
- dim $starlines[5]
- dim $starpower
- dim $starpowerenabled
- dim $lightningchars[6]
- dim $tick
- dim $starstring
- func _ini()
- $lightningchars[1] = "_"
- $lightningchars[2] = "-"
- $lightningchars[3] = "."
- $lightningchars[4] = "`"
- $lightningchars[5] = "'"
- $cursorpos = 1
- _songselect()
- endfunc
- func _songselect();first real function to be called. reads in filelist, filters out the .txt and masters the songselect
- $fail = hotkeyset( "{ESC}", "_exit")
- if $fail == 0 Then
- consolewrite( "Failed to set hotkeys, you probably have this game open somewhere else. Exiting.")
- sleep(2000)
- exit
- endif
- $songlist = _filelisttoarray( @scriptdir, "*", 1)
- $counter = 1
- do
- if StringRight( $songlist[$counter], 4) <> ".txt" Then
- _arraydelete( $songlist, $counter)
- $songlist[0] -= 1
- $counter -= 1
- endif
- $counter += 1
- until $counter > $songlist[0]
- hotkeyset( "{UP}" , "_songlistup" )
- hotkeyset( "{DOWN}" , "_songlistdown" )
- hotkeyset( "{ENTER}", "_songload" )
- _drawsonglist()
- EndFunc
- func _drawsonglist();draws the logo and songlist + cursor
- if @compiled then
- $consolestring = @LF & " ___ _____ ______________ __ __ " & @LF & " / | / ___// ____/ _/ _/ / / / /__ _________ " & @LF & " / /| | \__ \/ / / / / / / /_/ / _ \/ ___/ __ \" & @LF & " / ___ |___/ / /____/ /_/ / / __ / __/ / / /_/ /" & @LF & " /_/ |_/____/\____/___/___/ /_/ /_/\___/_/ \____/ v.whocares" & @LF & " by Maurice" & @LF & " Select a song with the arrow keys and press Enter!" & @LF & @LF
- if $songlist[0] > 0 then
- for $i = 1 to $songlist[0]
- if $i < 17 then
- if $cursorpos == $i then
- $consolestring = $consolestring & " -> "
- Else
- $consolestring = $consolestring & " "
- endif
- $consolestring = $consolestring & $songlist[$i] & @LF
- endif
- next
- for $i = 1 to 16 - $songlist[0]
- $consolestring = $consolestring & @LF
- next
- if $songlist[0] > 16 Then
- $consolestring = $consolestring & " [Not showing songs beyond #16, sorry]"
- endif
- Else
- $consolestring = $consolestring & " No songs found :("
- endif
- Else ;only here so I can test it in the IDE
- $consolestring = @LF & "Select a song with the arrow keys and press Enter!" & @LF
- if $songlist[0] > 0 then
- for $i = 1 to $songlist[0]
- if $cursorpos == $i then
- $consolestring = $consolestring & " -> "
- Else
- $consolestring = $consolestring & " "
- endif
- $consolestring = $consolestring & $songlist[$i] & @LF
- next
- for $i = 1 to 4 - $songlist[0]
- $consolestring = $consolestring & @LF
- next
- Else
- $consolestring = $consolestring & " No songs found :("
- endif
- endif
- consolewrite ( $consolestring )
- endfunc
- func _songlistdown();calls _drawsonglist after adjusting $cursorpos
- if $cursorpos < $songlist[0] AND $cursorpos < 16 then
- $cursorpos += 1
- _drawsonglist()
- endif
- EndFunc
- func _songlistup();calls _drawsonglist after adjusting $cursorpos
- if $cursorpos > 1 then
- $cursorpos -= 1
- _drawsonglist()
- endif
- endfunc
- func _songload();is called by ENTER hotkey and calls _start with the songname
- _start($songlist[$cursorpos])
- endfunc
- func _start($name);ini for songload. resets all needed vars and calls _loadsong, then _main
- $songname = $name
- hotkeyset( "{ESC}", "_quitsong")
- $starpower = 0
- $starpowerenabled = 0
- $streak = 0
- $higheststreak = 0
- $totalnoteshit = 0
- $totalnotes = 0
- $multiplier = 1
- $score = 0
- $maxmulti = 1
- $starpower = 0
- _loadsong($name)
- for $y = 1 to 5
- for $x = 1 to $boardlength
- $char[$x][$y] = $emptychar
- Next
- $holding[$y] = 0
- next
- $totalticks = 0
- $position = 0
- _enablecontrols()
- _main()
- endfunc
- func _loadsong($name);reads a song from $songname (.txt); NEED CHECKS FOR ERRORS
- $songfile = fileopen( @scriptdir & "\" & $name, 0)
- for $y = 1 to 5
- if stringlen(filereadline($songfile, $y)) + 2 > $songlength Then
- $songlength = stringlen(filereadline($songfile, $y)) + 2
- endif
- Next
- redim $song[$songlength + 1][6]
- redim $hammeredon[$songlength][6]
- for $y = 1 to 5
- for $x = 1 to $songlength
- $currentchar = stringmid( filereadline( $songfile, $y), $x, 1)
- if $currentchar <> " " Then
- $song[$x][$y] = $currentchar
- Else
- $song[$x][$y] = " "
- endif
- Next
- next
- for $x = 1 to $songlength
- $hasnote = 0
- for $y = 1 to 5
- if $song[$x][$y] == $normalnote OR $song[$x][$y] == $hammeron OR $song[$x][$y] == $starnote Then
- $hasnote = 1
- EndIf
- Next
- if $hasnote == 1 Then
- $totalnotes += 1
- EndIf
- next
- fileclose( $songfile )
- endfunc
- func _main();game updater function. moves everything to the left, checks for note misses, calls _draw() also checks for holds
- while $totalticks <= $songlength + $boardlength - 3
- if $beepenable == 1 then
- $beep = false
- for $y = 1 to 5
- if ($pressedfrets[$y] == 1) OR ($holding[$y] = 1 AND $song[$position - $boardlength + $fretsline + 1][$y] = $hold) Then
- $beep = $y * $beepfrequencybase
- EndIf
- $pressedfrets[$y] = 0
- next
- if $beep <> false AND $streak > 0 Then
- beep( $beep, $delay)
- Else
- sleep($delay)
- endif
- Else
- sleep($delay)
- endif
- if $position < $songlength then
- for $y = 1 to 5
- if $song[$position][$y] == $normalnote OR $song[$position][$y] == $hold OR $song[$position][$y] == $hammeron OR $song[$position][$y] == $starnote Then
- $char[$boardlength][$y] = $song[$position][$y]
- else
- if $tick = 4 then
- $char[$boardlength][$y] = $beatline
- Else
- $char[$boardlength][$y] = $emptychar
- endif
- endif
- next
- $position += 1
- endif
- for $y = 1 to 5
- for $x = 1 to $boardlength - 1
- $char[$x][$y] = $char[$x+1][$y]
- next
- if $char[$fretsline-2][$y] = $normalnote OR $char[$fretsline-2][$y] = $hammeron OR $song[$position][$y] == $starnote Then
- $streak = 0
- $multiplier = 1
- endif
- if $holding[$y] = 1 AND $char[$fretsline][$y] = $hold Then
- $char[$fretsline][$y] = $emptychar
- $score += $holdscorebase * $multiplier
- endif
- if $char[$fretsline+1][$y] == $emptychar Then
- $holding[$y] = 0
- endif
- next
- if $starpowerenabled = 1 Then
- $starpower -= $starpowerdrain
- if $starpower <= 0 Then
- $starpower = 0
- $starpowerenabled = 0
- EndIf
- endif
- $totalticks += 1
- $tick += 1
- if $tick > 4 then $tick = 1
- _updatefrets()
- _draw()
- wend
- _showscores()
- endfunc
- func _updatefrets();Turns of frets and $holding when released
- if _ispressed(31) then
- Else
- $fret[1] = $fretoff
- $holding[1] = 0
- EndIf
- if _ispressed(32) then
- Else
- $fret[2] = $fretoff
- $holding[2] = 0
- EndIf
- if _ispressed(33) then
- Else
- $fret[3] = $fretoff
- $holding[3] = 0
- EndIf
- if _ispressed(34) then
- Else
- $fret[4] = $fretoff
- $holding[4] = 0
- EndIf
- if _ispressed(35) then
- Else
- $fret[5] = $fretoff
- $holding[5] = 0
- EndIf
- endfunc
- func _draw();draws the fretboard and streak counter
- $consolestring = @LF & @LF & @LF & @LF & @LF & @LF & @LF & @LF & @LF & @LF
- if $starpowerenabled == 1 then
- if $tick == 4 then
- $starstring = ""
- $lastchar = ""
- for $x = 1 to $boardlength + $fretsline - 1
- do
- $currentchar = $lightningchars[random( 1, 5 )]
- until $currentchar <> $lastchar
- $lastchar = $currentchar
- $starstring = $starstring & $currentchar
- Next
- endif
- $consolestring = $consolestring & $starstring
- endif
- for $y = 1 to 5
- $consolestring = $consolestring & @LF
- for $x = 1 to $boardlength - 1
- if $char[$x][$y] == $normalnote OR $char[$x][$y] == $hammeron OR $char[$x][$y] == $starnote Then ;HAMMERONS, NORMALS AND STARNOTES ARE DRAWN WHERE THEY ARE NO MATTER WHAT
- $consolestring = $consolestring & $char[$x][$y]
- elseif $x > $fretsline then ;RIGHT OF FRETLINE
- $consolestring = $consolestring & $char[$x][$y]
- elseif $x == $fretsline then ;ON FRETLINE
- $consolestring = $consolestring & $fret[$y]
- elseif $x < $fretsline then ;LEFT OF FRETLINE
- if $char[$x][$y] == $emptychar OR $char[$x][$y] == $beatline then
- $consolestring = $consolestring & " "
- Else
- $consolestring = $consolestring & $char[$x][$y]
- endif
- endif
- Next
- Next
- if $starpowerenabled == 1 then
- $consolestring = $consolestring & @LF & $starstring
- else
- $consolestring = $consolestring & @LF
- endif
- if @compiled then
- $consolestring = $consolestring & @LF & " Starpower: ["
- $starpowerbarstring = ""
- for $i = 1 to round(($starpower / 100 * $starpowerbars))
- $starpowerbarstring = $starpowerbarstring & "#"
- Next
- for $i = 1 to ($starpowerbars - round(($starpower / 100 * $starpowerbars)))
- $starpowerbarstring = $starpowerbarstring & " "
- Next
- $consolestring = $consolestring & $starpowerbarstring & "]" & @LF & @LF & " Streak: " & $streak & @LF & " Multiplier: " & $multiplier & @LF & " Score: " & $score & @LF & @LF & @LF & @LF & @LF
- Else ;IDE testing
- $consolestring = $consolestring & @LF & "Streak: " & $streak & " Mult: " & $multiplier & " Score: " & $score & " Starpower: " & $starpower & " starenabled: " & $starpowerenabled
- endif
- consolewrite( $consolestring)
- endfunc
- func _showscores();will show scores
- _disablecontrols()
- hotkeyset( "{ESC}", "_songselect" )
- if $totalticks < $songlength + $boardlength then
- $consolestring = @LF & " __ __ _____ _ _ " & @LF & " \ \ / / | __ \ | | | |" & @LF & " \ \_/ /__ _ _ | |__) |___ ___| | _| |" & @LF & " \ / _ \| | | | | _ // _ \ / __| |/ / |" & @LF & " | | (_) | |_| | | | \ \ (_) | (__| <|_|" & @LF & " |_|\___/ \__,_| |_| \_\___/ \___|_|\_(_)" & @LF & @LF & @LF
- if $totalnoteshit > 0 then
- $consolestring = $consolestring & " Score: " & $score & @LF & @LF & " Finished song '" & Stringleft( $songname, stringlen( $songname ) - 4) & "'!" & @LF & " " & $totalnoteshit & "/" & $totalnotes & " notes hit. That's " & round( 100 / ($totalnotes / $totalnoteshit), 1) & "%!" & @LF & " Highest multiplier: " & $maxmulti & @LF & @LF & @LF & @LF
- Else
- $consolestring = $consolestring & " Score: " & $score & @LF & @LF & " Finished song '" & Stringleft( $songname, stringlen( $songname ) - 4) & "'!" & @LF & " 0/" & $totalnotes & " notes hit. That's 0%!" & @LF & " Highest multiplier: " & $maxmulti & @LF & @LF & @LF & @LF
- endif
- if $totalnoteshit > 0 then
- switch round( 100 / ($totalnotes / $totalnoteshit))
- case 0 to 30
- $starcount = 0
- case 31 to 45
- $starcount = 1
- case 46 to 60
- $starcount = 2
- case 60 to 75
- $starcount = 3
- case 76 to 89
- $starcount = 4
- case 90 to 99
- $starcount = 5
- case 100
- $starcount = 6
- endswitch
- Else
- $starcount = 0
- endif
- for $i = 1 to 4
- if $starcount < 6 then
- $starlines[$i] = " "
- Else
- $starlines[$i] = " "
- endif
- for $j = 1 to 5 - $starcount
- $starlines[$i] = $starlines[$i] & " "
- next
- for $j = 1 to $starcount
- switch $i
- case 1
- $starlines[$i] = $starlines[$i] & " /\ "
- case 2
- $starlines[$i] = $starlines[$i] & "--/--\-- "
- case 3
- $starlines[$i] = $starlines[$i] & "`/_ _\' "
- case 4
- $starlines[$i] = $starlines[$i] & "/_.''._\ "
- endswitch
- next
- $consolestring = $consolestring & $starlines[$i] & @LF
- Next
- $consolestring = $consolestring & @LF & @LF & @LF & " Press Enter to continue" & @LF
- consolewrite( $consolestring )
- hotkeyset( "{ENTER}", "_songselect")
- Else
- _songselect()
- endif
- endfunc
- func _enablecontrols();enables hotkeys for enter and 1-5
- hotkeyset( "{#}", "_starpower" )
- hotkeyset( "{ENTER}", "_strum" )
- hotkeyset( "{1}", "_1")
- hotkeyset( "{2}", "_2")
- hotkeyset( "{3}", "_3")
- hotkeyset( "{4}", "_4")
- hotkeyset( "{5}", "_5")
- endfunc
- func _disablecontrols();disables hotkeys for enter and 1-5
- hotkeyset( "{#}" )
- hotkeyset( "{ENTER}" )
- hotkeyset( "{1}" )
- hotkeyset( "{2}" )
- hotkeyset( "{3}" )
- hotkeyset( "{4}" )
- hotkeyset( "{5}" )
- endfunc
- ;;;;;;;;;;;;;;;;;;;;;;
- ;; HOTKEY FUNCTIONS ;;
- ;;;;;;;;;;;;;;;;;;;;;;
- func _starpower()
- if $starpower >= 50 AND $starpowerenabled == 0 Then
- $starpowerenabled = 1
- EndIf
- endfunc
- func _1();calls hammeron($y) and sets the fret char
- _hammeron(1)
- $fret[1] = $freton
- endfunc
- func _2();calls hammeron($y) and sets the fret char
- _hammeron(2)
- $fret[2] = $freton
- endfunc
- func _3();calls hammeron($y) and sets the fret char
- _hammeron(3)
- $fret[3] = $freton
- endfunc
- func _4();calls hammeron($y) and sets the fret char
- _hammeron(4)
- $fret[4] = $freton
- endfunc
- func _5();calls hammeron($y) and sets the fret char
- _hammeron(5)
- $fret[5] = $freton
- endfunc
- func _hammeron($y);checks if pressed note is a hammeron; sets streak, holding and sets a hold char if necessary
- _draw()
- $fault = 1
- if $streak > 0 Then
- if $char[$fretsline][$y] == $hammeron Then
- $strumposition = 0
- $fault = 0
- $char[$fretsline][$y] = $emptychar
- if $char[$fretsline + 1][$y] == $hold then
- $holding[$y] = 1
- endif
- $score += $scorebase * $multiplier
- Elseif $char[$fretsline - 1][$y] == $hammeron Then
- $strumposition = -1
- $fault = 0
- $char[$fretsline - 1][$y] = $emptychar
- if $char[$fretsline][$y] == $hold then
- $holding[$y] = 1
- $char[$fretsline][$y] = $emptychar
- endif
- $score += $scorebase * $multiplier
- elseif $char[$fretsline + 1][$y] == $hammeron Then
- $strumposition = 1
- $fault = 0
- $char[$fretsline + 1][$y] = $emptychar
- if $char[$fretsline + 2][$y] == $hold then
- $holding[$y] = 1
- $char[$fretsline + 1][$y] = $hold
- endif
- $score += $scorebase * $multiplier
- endif
- endif
- if $fault = 0 Then
- $streak += 1
- _updatemultiplier()
- $totalnoteshit += 1
- $pressedfrets[$y] = 1
- endif
- if $streak > $higheststreak Then
- $higheststreak = $streak
- endif
- endfunc
- func _strum() ;checks for valid strums, sets some $char and adjusts the streakmeter. Also sets holding.
- if _ispressed(31) OR _ispressed(32) OR _ispressed(33) OR _ispressed(34) OR _ispressed(35) then
- $fault = 0
- else
- $fault = 1
- endif
- $strumposition = 0
- for $y = 1 to 5
- $pressedfrets[$y] = _ispressed(30 + $y)
- if $char[$fretsline+1][$y] == $normalnote OR $char[$fretsline+1][$y] == $hammeron OR $char[$fretsline+1][$y] == $starnote then
- $strumposition = 1
- endif
- next
- for $y = 1 to 5
- if $char[$fretsline-1][$y] == $normalnote OR $char[$fretsline-1][$y] == $hammeron OR $char[$fretsline-1][$y] == $starnote then
- $strumposition = -1
- endif
- next
- for $y = 1 to 5
- if $char[$fretsline][$y] == $normalnote OR $char[$fretsline][$y] == $hammeron OR $char[$fretsline][$y] == $starnote then
- $strumposition = 0
- endif
- next
- for $y = 1 to 5
- $requirednotes[$y] = 0
- if $char[$fretsline+$strumposition][$y] == $normalnote OR $char[$fretsline+$strumposition][$y] == $hammeron OR $char[$fretsline+$strumposition][$y] == $starnote Then
- $requirednotes[$y] = 1
- EndIf
- next
- for $y = 1 to 5
- if $pressedfrets[$y] <> $requirednotes[$y] Then
- $fault = 1
- EndIf
- next
- if $fault = 0 then
- $playednote = $totalticks
- $streak += 1
- _updatemultiplier()
- $totalnoteshit += 1
- if $streak > $higheststreak Then
- $higheststreak = $streak
- endif
- $star = 0
- for $y = 1 to 5
- if $char[$fretsline+$strumposition][$y] == $starnote Then
- $star = 1
- EndIf
- if $requirednotes[$y] == 1 then
- $score += $scorebase * $multiplier
- switch $strumposition
- Case -1
- $char[$fretsline - 1][$y] = $emptychar
- if $char[$fretsline][$y] == $hold then
- $holding[$y] = 1
- $char[$fretsline][$y] = $emptychar
- endif
- case 0
- $char[$fretsline][$y] = $emptychar
- if $char[$fretsline + 1][$y] == $hold then
- $holding[$y] = 1
- endif
- case 1
- $char[$fretsline + 1][$y] = $emptychar
- if $char[$fretsline + 2][$y] == $hold then
- $holding[$y] = 1
- $char[$fretsline + 1][$y] = $hold
- endif
- endswitch
- endif
- next
- if $star == 1 then
- if $starpower <= 75 then
- $starpower += 25
- Else
- $starpower = 100
- endif
- endif
- Else
- if $playednote > $totalticks - $fretsline Then
- $openstrum = 1
- for $y = 1 to 5
- if $requirednotes[$y] == 1 then
- $openstrum = 0
- EndIf
- Next
- if $openstrum = 1 Then
- $streak = 0
- endif
- else
- $streak = 0
- $multiplier = 1
- endif
- endif
- endfunc
- func _updatemultiplier() ;checks $streak and sets $multiplier accordingly, also sets $maxmulti
- switch $streak
- case 0 to 9
- $multiplier = 1
- case 10 to 19
- $multiplier = 2
- case 20 to 29
- $multiplier = 3
- case 30 to 39
- $multiplier = 4
- endswitch
- if $starpowerenabled = 1 Then
- $multiplier = $multiplier * 2
- endif
- if $multiplier > $maxmulti Then
- $maxmulti = $multiplier
- endif
- endfunc
- func _quitsong();quits the song by setting $totalticks over the limit, is called by ESC hotkey
- $totalticks = $songlength + $boardlength
- endfunc
- func _exit() ;exit
- exit
- endfunc
- _ini()
- while True
- sleep(1000)
- wend
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement