Random Civilization Drafter for Modded Civs

TheOneHitPupper

Chieftain
Joined
Jun 15, 2017
Messages
98

I wrote a batch script that randomly selects a designated number of folders from a parent directory and makes symbolic links for them in your Civ5 mod folder. The idea being you can run the script and it can make certain custom Civ mods available while keeping the others disabled. If you like the idea of a randomized leader loadout for custom games, you can use this to swap available leaders. I made this to reduce overhead from enabling all the mods like you would do normally to get random leaders in-game.​

Please read the installation before proceeding. I am not responsible if you accidentally delete some of your mods.

Code:
set loop=0

:DELETE
RD /S /Q "C:\Users\Admin\Documents\My Games\Sid Meier's Civilization 5\MODS\Civilizations"
MKDIR "C:\Users\Admin\Documents\My Games\Sid Meier's Civilization 5\MODS\Civilizations"


SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=*" %%@ in ('DIR "C:\Users\Admin\Documents\My Games\Civilizations" /A:D /B') DO (
    SET /A "count+=1"
    SET "folder[!count!]=%%@"
)
:LOOP
set /a loop=%loop%+1 
SET /A "rand=(%RANDOM% %%100 * %count%)/(100 + 1)"
Set "!folder[%rand%]!=%%@"
cls
ECHO !folder[%rand%]!
MKLINK /D "C:\Users\Admin\Documents\My Games\Sid Meier's Civilization 5\MODS\Civilizations\!folder[%rand%]!" "C:\Users\Admin\Documents\My Games\Civilizations\!folder[%rand%]!"
    if errorlevel 1 set /a loop=%loop%-1 & goto loop


if "%loop%"=="42" goto next
goto loop
:NEXT

Installation:
  1. Copy code above into a text editor like Notepad ++.
  2. In this line: RD /S /Q "C:\Users\Admin\Documents\My Games\Sid Meier's Civilization 5\MODS\Civilizations" change the directory to your Civ5 Mods folder where you want the symbolic links to go.
  3. In this line: MKDIR "C:\Users\Admin\Documents\My Games\Sid Meier's Civilization 5\MODS\Civilizations" change the directory to the same one you used above. This clears the directory on each instance of the script.
  4. In this line: FOR /F "tokens=*" %%@ in ('DIR "C:\Users\Admin\Documents\My Games\Civilizations" /A: D /B') DO ( change the directory to the folder where you want to keep all of the real custom civ mods.
  5. In this line: MKLINK /D "C:\Users\Admin\Documents\My Games\Sid Meier's Civilization 5\MODS\Civilizations\!folder[%rand%]!" "C:\Users\Admin\Documents\My Games\Civilizations\!folder[%rand%]!" change the first directory to your Civ5 mod directory (the one we used in step 2 and 3) and change the second directory to the real custom civ folder we used in step 4.
  6. In this line: if "%loop%"=="42" goto next change the 42 value to whatever <=42 value you want. It will import exactly that many. Do note that if you are using a custom DLL like the one in the Community Patch, the max playable civilizations are 43 (-1 after you).
  7. Save file as Civilizations.bat
  8. Run file as Admin.


Note: this mod does not disable vanilla civs.​


Feel free to delete the symbolic links once you are done with them or if you prefer, the script does it for you on launch.

I hope this makes sense for anyone reading, bit tricky to explain :lol: If you have any questions, feel free to ask!
 
Last edited:
Top Bottom