Hello everyone. This tutorial is a bit more lengthy than my last one. Here I want to share how to play certain songs depending on what AI deck you play against. I admit I'm not too familiar with the coding languages, but I'll do my best to explain how everything works.
How it works:Basically you will be checking the system.conf file for whenever it gets modified. Everytime you pick an AI deck to duel against, system.conf will update automatically and change the lastdeckai value. You will read lastdeckai and find the song for that deck, then replace song.mp3 with that deck's song.
Instructions:1. First, open up Notepad and copy and paste this code in it. Then save it as
ygopro_invis.vbs. This isn't exactly necessary, it just hides the cmd window whenever you launch YGOPRO.
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
2. Go to your sound folder and make a copy of song.mp3, song2.mp3, and song3.mp3 and name them as
song_default.mp3,
song2_default.mp3, and
song3_default.mp3. This is important because you will constantly be renaming your song files so you need to make sure to keep the original files so you don't lose them.
3. Now let's add our custom deck music. Go back to your ygopro-percy folder and create a new folder called
sound_deck. Place all of your custom deck music in this folder. Make sure that the name of your music matches the deck it will be used with (ie. If your deck is called AIdeck.ydk then your deck song will be called AIdeck.mp3).
4. Create a new Notepad and save it as
ygopro_batch.bat. Then copy and paste this code:
@ECHO OFF
:: === Set YGOPRO directory ===
SET "dir=yourpath\ygopro-percy"
:: === Set TIMEOUT ===
SET "TIMEOUT=%SystemRoot%\System32\timeout.exe"
:: === Set FIND ===
SET "FIND=%SystemRoot%\System32\find.exe"
:: === Set ATTRIB ===
SET "ATTRIB=%SystemRoot%\System32\attrib.exe"
:: === Set TASKLIST ===
SET "TASKLIST=%SystemRoot%\System32\tasklist.exe"
:: === Set FINDSTR ===
SET "FINDSTR=%SystemRoot%\System32\findstr.exe"
:: === Start YGOPRO ===
CD "%dir%"
START ygopro_vs.exe
:: === Deck Music ===
:: Check if system.conf changed
:loop
CD "%dir%"
:: Small wait interval to reduce CPU-Load
%TIMEOUT% -T 1 >NUL
:: Process file, print attributes, try to find "a"rchive-attribute
:: in the output of the previous ECHO and redirect any output to nirvana
FOR %%i IN (system.conf) DO ECHO %%~ai|%FIND% "a">NUL || GOTO :loop
:: If file was changed
:: Find lastdeckai in system.conf and set DeckAI equal to lastdeckai
SETLOCAL
SET FindString="lastdeckai"
SET FileName="system.conf"
FOR /F "tokens=2 delims==" %%v IN ('%FIND% /I %FINDSTRING% "%FILENAME%" ^|%FIND% "="') DO (
CALL :SetDeckAI %%v)
GOTO :EndDeckAI
:SetDeckAI
SET DeckAI=%*
:EndDeckAI
CD "%dir%\sound_deck"
:: If DeckAI exists in sound_deck, copy to sound and replace song.mp3, song2.mp3, song3.mp3
IF EXIST "%DeckAI%".mp3 (
COPY "%DeckAI%".mp3 "%dir%\sound\song.mp3"
COPY "%DeckAI%".mp3 "%dir%\sound\song2.mp3"
COPY "%DeckAI%".mp3 "%dir%\sound\song3.mp3"
) ELSE (
:: If DeckAI doesn't exist in sound_deck, sets song.mp3, song2.mp3, song3.mp3 to default
CD "%dir%\sound"
COPY song_default.mp3 song.mp3
COPY song2_default.mp3 song2.mp3
COPY song3_default.mp3 song3.mp3
)
CD "%dir%"
:: Unset archive attribute of file
%ATTRIB% -A system.conf
:: Break out of loop when YGOPRO closes
%TASKLIST% | %FINDSTR% /I "ygopro_vs.exe"
IF ERRORLEVEL 1 (GOTO :EOF)
GOTO :loop
Old code (use this if the above code does not work):
@ECHO OFF
:: === Set YGOPRO directory ===
SET dir=yourpath\ygopro-percy
:: === Start YGOPRO ===
CD "%dir%"
START ygopro_vs.exe
:: === Deck Music ===
:: Check if system.conf changed
:loop
CD "%dir%"
:: Small wait interval to reduce CPU-Load
TIMEOUT -T 1 >NUL
:: Process file, print attributes, try to find "a"rchive-attribute
:: in the output of the previous ECHO and redirect any output to nirvana
FOR %%i IN (system.conf) DO ECHO %%~ai|FIND "a">NUL || GOTO :loop
:: If file was changed
:: Find lastdeckai in system.conf and set DeckAI equal to lastdeckai
SETLOCAL
SET FindStr="lastdeckai"
SET FileName="system.conf"
FOR /F "tokens=2 delims==" %%v IN ('FIND /I %FindStr% "%FileName%" ^|FIND "="') DO (
CALL :SetDeckAI %%v)
GOTO :EndDeckAI
:SetDeckAI
SET DeckAI=%*
:EndDeckAI
CD "%dir%\sound_deck"
:: If DeckAI exists in sound_deck, copy to sound and replace song.mp3, song2.mp3, song3.mp3
IF EXIST "%DeckAI%".mp3 (
COPY "%DeckAI%".mp3 "%dir%\sound\song.mp3"
COPY "%DeckAI%".mp3 "%dir%\sound\song2.mp3"
COPY "%DeckAI%".mp3 "%dir%\sound\song3.mp3"
) ELSE (
:: If DeckAI doesn't exist in sound_deck, sets song.mp3, song2.mp3, song3.mp3 to default
CD "%dir%\sound"
COPY song_default.mp3 song.mp3
COPY song2_default.mp3 song2.mp3
COPY song3_default.mp3 song3.mp3
)
CD "%dir%"
:: Unset archive attribute of file
ATTRIB -A system.conf
:: Break out of loop when YGOPRO closes
TASKLIST | FINDSTR /I "ygopro_vs.exe"
IF ERRORLEVEL 1 (GOTO :EOF)
GOTO :loop
This is a bit long so bare with me. Replace
yourpath/ygopro-percy with your YGOPRO directory. The next piece of code opens up YGOPRO.
After that is the Deck Music portion. This will constantly be checking if system.conf has changed (using a loop). If it did change, it will find the name of your AI Deck (lastdeckai). Then it will check if that same name is in your sound_deck folder. If so, it'll replace song.mp3, song2.mp3, and song3.mp3 with that deck music. Otherwise, it'll change your songs back to default. The last bit of code just breaks out of the loop once you exit out of YGOPRO.
5. Finally, right-click on your ygopro_vs.exe file and create a Shortcut. Then right-click on the Shortcut and click on Properties. Navigate to Shortcut and where it says Target, replace it with:
wscript.exe "
yourpath\ygopro-percy\ygopro_invis.vbs" "
yourpath\ygopro-percy\ygopro_batch.bat"
Now everytime you click on the Shortcut, it will run the batch file and change your music depending on what AI deck you face. Hope you guys like it.
Edited by user
2020-09-26T21:29:50Z
|
Reason: Not specified