[WIP]Randomized Unique Components, and Traits

Divine Yuri

Never Closes Chrome
Joined
Oct 28, 2014
Messages
89
Location
Brrrr, USA


Download | Source Code
Alternative Download Available at this time below, but Source Code Below is likely out of Date.
To make a randomized game run the .jar file in the located in the folder.
See below for instructions on where to download it.

Current Version : v0.32 (December 8th, 2015)

Ever wanted to throw reality out the window, and have completely random Unique Components and abilities? This is the mod for you!

I made this after seeing a post on one of Marbozir's videos. Someone was talking about the idea of having a randomized game, and while I thought the idea sounded cool I couldn't think of anyway to do it as just a mod in Civilization 5, but I know exactly how to do it with java. I've had this sitting on my computer for 5 months, and never released it for reasons (mostly writing the post), but now it's here with a few changes since then! Any questions or requests add to the post and I'll get back to you.

What the program does is it creates all the necessary files in a folder by your designated name. This file is the randomized set-up created by the program, and will be the same until you run the program again with the same name.

This mod also has randomized support for :
You will still need the original mods to work with the generated games.

Screenshots :
Spoiler :







FAQ:
  • Can you get units of the same class type?
    The program is designed to stop Class Types from overlapping.​
  • What if I use modded civs with 3rd, and 4th unique components?
    It'll be find as long as the 'number of components' option is low enough that you can give each civ that amount of components.​


Requirements:
Civilization 5. It should work with any set of DLC, but I recommend all the DLC for the best experience.
Java

How to create your randomized game :
  1. Download the Mod above
  2. Put the [BNW]Randomized Game folder into your mods folder location.
  3. In this folder there will be a few things. Core, and the .modinfo are the mod part of this for Civilization 5. Random(v01).jar, and the Defines folder are used to create the randomized set-up.
  4. To create the randomized game just run the .jar file, and you'll get something that looks like this:
    Spoiler :

    4a. If the .jar doesn't run as executable :​
    Spoiler :

    Note : My computer is set to Japan for reasons so the command prompt displays \ as the yen symbol.
  5. Click on choose directory, and if you put this in the MODS folder all you'll have to do is go up a directory.
    Spoiler :
  6. Click save to set your mods folder location.
    Spoiler :
  7. Use whatever name you want (changing the name allows you to start a new one without losing your old save.)
  8. Click run, and now you have a mod with your specified name.

Mod support :
OLD GUIDE:
Spoiler :
Adding mods to this is pretty easy.
  1. Go to the destination of the .jar file.
  2. Go into the defines folder, and there you will find a folder called mods.
  3. In that folder, and create a folder for the civilization you're looking to add.
  4. copy the contents of my Burger King civilization.
  5. You will find 4 files in the folder now :
    • Civilizations:
      Spoiler :
      --This will serve as a example for adding mods, or for modders who want their mod to work with this.
      CIVILIZATION_BURGER_KING
      LEADER_THE_KING
    • RandomSupport:
      Spoiler :
      --This means nothing right now, but the Activate. Better support later. I might add support to add more to

      -- Set true to activate the mod.
      -- Mod ID.
      false
      1bf3a102-8cfa-468f-9255-12e3b31572da

      --Name
      Burger King

      --IGNORE ALL BELOW

      --lua?
      true

      --if lua how do I deal with that?
      --Some notes on how this will be handled.
      --( # ) # in CHANGE case is to tell how many more lines to read RIGHT AFTER (It'll read comments) the Change.

      CHANGE ( 1 )
      CIVILIZATION_BURGER_KING = #TARGETCIV#

      --If you had a second it would be here not the next line.
      --The values you can do is:
      --#TARGETLEADER#
      --#TARGETUNIT#
      --#TARGETBUILDING#
      --#TARGETIMPROVEMENT#
      --This is for the future though. I want to make it work with lua mods in particular for a lot of the really good civs are lua base.
      --Any comments from lua mod makers is great to help me make files that will help make the random process work on the civilizations.
    • Trait:
      Spoiler :
      TRAIT_THE_KING
    • Uniques (needs to be 2 in current version.):
      Spoiler :
      UNIT_BK_MECH
      UNITCLASS_MECH
      BUILDING_BURGER_KING
      BUILDINGCLASS_GRANARY
  6. Change the contents to the modded civilization.
  7. If one of the unique components is a unique improvement use the civilization's name after the improvement.
  8. If all the contents are correct it should work with any civilization.

    Other :
    • LUA : Lua based mods are usually connected to the civilization, and so to fix this if the civilization is LUA based add " #Connected# " to the end of the Civilization ID, and add the Trait ID to the end of that. Now the Civilization will always have the same trait.
    • Connecting Traits, and unique components: Same as above add #Connected# to the end of the Trait, and add the unique component.
Video:
New Guide:
  1. Run the .jar
  2. Get the modded Civ's directory.
  3. Click on Generate
  4. You're Done!
Though old guide is still needed for : Mods with >1 Civs. This has been addressed for a while now.
To enable the modded civs you just need to go to Defines > Mods > Mod's Folder > ModSupport.txt, and change false to true. Click the Change Mods button, and it'll do the work of changing the ModSupport.txt for you.

What I want to do in the future :
Spoiler :

  • Total Random version. Mostly it will change the text and picture of all components, and traits to just be ? marks.
  • Random Events and decisions. (Mostly Decisions)
  • Add a starting bias fix. Mostly something that will push a civilization towards a certain starting bias based on there Uniques.
  • More competitive AI. More to say AI that will take advantage of the new uniques they are given.
  • Adding in a Mod Component. Something that will deal with certain problems that exist like only one city for Venice, and The Huns.
  • Fix my own civilizations to work with this.


For Modders (Dec 7):
Spoiler :

Nothing on your end. This now creates the necessary files from just having the folder of the mod.
You still don't really have to do anything, but if you make a lua based mod and it's trait is based off the trait, and not the civilization add a file called: RandomSupport.txt anywhere, and put into it : TraitBasedLua = 'TRUE';

Also if you want a quick way to change the CivID I've created this lua function which will allow you to still use your existing CivID. Just Copy this to the top of your lua, and make your CivID = GetCivilizationByTrait( "TRAIT_ID" )
Code:
function GetCivilizationByTrait( uType )
	local civilization = nil
	for uniqueTrait in GameInfo.Leader_Traits() do
		if ( uniqueTrait.TraitType == uType ) then
			local leader = uniqueTrait.LeaderType
			for uniqueLeader in GameInfo.Civilization_Leaders() do
				if( uniqueLeader.LeaderheadType == leader ) then
					local civilizationTXT = uniqueLeader.CivilizationType
					for uniqueCivilization in GameInfo.Civilizations() do
						if uniqueCivilization.Type == civilizationTXT then
							civilization = uniqueCivilization.ID
							break
						end
					end
				end
			end
		end
	end
	return civilization
end

Also you can make the randomize function to work indefinitely by adding this to the file :
Code:
TraitBasedLua = 'TRUE';

OVERRIDE_AUTO  = { 
	MOD_SUPPORT = {
		Civ4Traits = {
			LEADER_AKANE = {
				Leader 	= 	'LEADER_AKANE';
				LeaderTXT	=	'Akane ';
			};
		};
	};
	CIVILIZATIONS = {
		CIVILIZATION = {
			Civilization = 'CIVILIZATION_ID';
			Leader = 'LEADER_ID';
		};
	};
	
	COMPONENTS = {
		COMPONENT = {
			Type = 'TYPE_ID';
			Class = 'CLASS_ID';
		};
		COMPONENT = {
			Type = 'TYPE_ID';
			Class = 'CLASS_ID';
		};
	};
	TRAITS = {
		TRAIT = {
			--Required adds to the Pool of traits.
			Type = 'TRAIT_KOMI_TOLERANCE';
			
			--Not Required you could just remove this, but will keep these components with the Trait.
			--These components ARE counted towards the number of components per Civilization, 
			--and should be added to normal Components or it won't add the component.
			Components = {
				COMPONENT = {
					Type = '';
					Class= '';
				};
				COMPONENT = {
					Type = '';
					Class= '';
				};
			};
			
			--Not Required you could just remove this, but will keep these components with the Trait.
			--These components ARE NOT counted towards the number of components per Civilization, 
			--and should NOT be added to normal Components. 
			--They are added with the trait to the designated Civilization around the same time.
			TraitComponents = {
				COMPONENT = {
					Type = '';
					Class= '';
				};
				COMPONENT = {
					Type = '';
					Class= '';
				};
			};
		};
	};
};


Known Bugs:
Spoiler :

None atm, but Murphy's Law will find a way.


Updates:
Spoiler :

Update v0.31

  • Added the Rejected(Additional) Unique Components mod support. If selected it will add 19 extra components to the pool of possible components when randomizing.

Version 3 :

  • Support for Third Unique Components Added
  • Support for Fourth Unique Components Added
  • The User can change the number of unique components (up to what's available, so the max is 4 with both Unique Components mods, but you're allowed to have 3 components given with all mods.).
  • The Auto-Modder has been reworked, and while not perfect yet should work with more mods.
  • Auto-Modder now works with mods with multiple civilizations.
  • Auto-Modder could possibly work with mods that have NO civilizations just uniques.
Update v0.21 :

  • Various "Fixes"(watch it break something else! :twitch: ) to the Auto Modded Civilizations.
  • Only For source : a new function for distributing components that allows any number of combinations (still keeping classes separate).
v0.2 update:
  • Added support for various Mods :
    1. Culture Diversity - If you use the Cultural Diversity Mod you can now have all civilizations given a Randomized Culture Group.
    2. Civilization 4 Traits in Civilization 5 - All civilizations will end up with 2 Randomized Traits from this Mod.

  • Removed the problems with new Civilizations for the user. Now to add modded civilizations all you have to do is find is directory, and click a button.


Trying to play with reddit's auto-picture system (didn't work) :


Special Thanks :
Calcul8tor, for allowing me to use his mods as examples.
 

Attachments

  • SourceCode.zip
    126.9 KB · Views: 233
  • [BNW]Randomized Game.zip
    104.4 KB · Views: 324
  • [RisingTide]Randomized Game.zip
    114.9 KB · Views: 233
I shall point out that civ 5 modding scene lacks the mods of this magnitude. Simply great. :)

Heh, I knew this day will come, but in my laziness I was coding traits and buildings linked to civID. I might recode some of them around the January just to test it out.
Thanks for sharing it.
 
This is awesome! I can't wait to test this out, I wonder if something like this can be done with cultural diversity or some other mods out there.
 
I shall point out that civ 5 modding scene lacks the mods of this magnitude. Simply great. :)

Heh, I knew this day will come, but in my laziness I was coding traits and buildings linked to civID. I might recode some of them around the January just to test it out.
Thanks for sharing it.
Thank you! I wanted to try, and find a way to make it work even if someone did this, but couldn't come up with a way. A suggestion on how I'm going to make my civs work with this in the future is to add a "tell" building to the trait, and use that as the tell rather than civID.


This is awesome! I can't wait to test this out, I wonder if something like this can be done with cultural diversity or some other mods out there.
Actually planning on expanding this to other mods. Just going to get the permission from the mod makers first.
Cultural diversity is one of the first on my list, and should be one of the easier ones (Events and decisions, and 3rd/4th component are going to be nightmares, but doable.)
 
cough Civ IV Traits in Civ V support cough

Extraordinary job, really looking forward to trying it out!
 
cough Civ IV Traits in Civ V support cough

Extraordinary job, really looking forward to trying it out!

Don't worry got your back with that one. :D

Spoiler :
 
Oh, this looks very interesting. I'll have to try it out someday!

Are leaders randomized or not? It doesn't look like it on the top screenshot, hence why I ask. Meeting Napoleon of China or Bismarck of the Aztecs would add another level of randomness to it all. :D
 
Oh, this looks very interesting. I'll have to try it out someday!

Are leaders randomized or not? It doesn't look like it on the top screenshot, hence why I ask. Meeting Napoleon of China or Bismarck of the Aztecs would add another level of randomness to it all. :D

They do just stay with their civilization. I choose to do this to allow instead for Unique abilities that are only viable from a unique component (Venice).
I went with Mechanics > flavor. It's not impossible just difficult to do both. :crazyeye:
 
Thank you! I wanted to try, and find a way to make it work even if someone did this, but couldn't come up with a way. A suggestion on how I'm going to make my civs work with this in the future is to add a "tell" building to the trait, and use that as the tell rather than civID.
Humm, I am gonna probably just iterate through players->leaders->traits and players->civs->building_replacements in database and store the proper data in tables. Then change condition "GetCivilizationType" into "is playerID in the table".
I think it will be the quickiest way for me (copy-pasta), except for rare scenarios when trait's and building's codes are somehow tied together.
I have only one civ with three uniques, so I am gonna remade it slightly to make it work.


I have some probably naive questions about mechanics of mod.
If I make Shoshones unplayable, can I customize this mod so the Shoshone civ and its' uniques are not considered in the pool. The way the mod support works, I assume you have somewhere stored "CIVILIZATION_SHOSHONES", "TRAIT_", "UNIQUE_1", "UNIQUE_2". So do I have to delete it only?
Same procedure for mods replacing vanilla traits, I assume? For example, my mod makes vanilla Winged Hussars not used by any civilization, so I would like it to not be distributed to any civ.
In overall, I believe everything will be ok if (number of civs =< number of traits) and (number of civs * 2 =< number of uniques).

Finally, is it coded that way that one civ cannot receive double replacement of one unitclass or buildingclass (quite important to me)? I doubt though that it is coded that way that Unique General (or Civilian) can be only acquired as second unique component.
 
Humm, I am gonna probably just iterate through players->leaders->traits and players->civs->building_replacements in database and store the proper data in tables. Then change condition "GetCivilizationType" into "is playerID in the table".
I think it will be the quickiest way for me (copy-pasta), except for rare scenarios when trait's and building's codes are somehow tied together.
I have only one civ with three uniques, so I am gonna remade it slightly to make it work.


I have some probably naive questions about mechanics of mod.
If I make Shoshones unplayable, can I customize this mod so the Shoshone civ and its' uniques are not considered in the pool. The way the mod support works, I assume you have somewhere stored "CIVILIZATION_SHOSHONES", "TRAIT_", "UNIQUE_1", "UNIQUE_2". So do I have to delete it only?
Same procedure for mods replacing vanilla traits, I assume? For example, my mod makes vanilla Winged Hussars not used by any civilization, so I would like it to not be distributed to any civ.
In overall, I believe everything will be ok if (number of civs =< number of traits) and (number of civs * 2 =< number of uniques).

Finally, is it coded that way that one civ cannot receive double replacement of one unitclass or buildingclass (quite important to me)? I doubt though that it is coded that way that Unique General (or Civilian) can be only acquired as second unique component.

Shoshone / Winged :
Yeah if you just remove them from the Defines folder it should just act as if they don't exist. Thinking that people might want that I'll look into having a way to remove any unique without touching those files.

Number of Civs vs Number of Uniques :
Yeah I mostly have the code print out based on number of civs.

2 Components with the same unit class :
The program specifically tries to make sure the unitclasses and buildingclasses are separate. Though how it's coded as well if 2 improvements belonged to the same civilization it would act as if they were the same improvement.

Great People (civilian) :
There could always turn out to be two in a single civilization. As long as they aren't both a replacement for the same Unitclass.
 
This is really fun! In a few turns, I'll be able to upgrade my Kris Swordsmen into Samurai. :D

Have you considered also randomizing start biases?

Oh... the civ that gets both Horse Archers and Camel Archers... :eek:
 
This is really fun! In a few turns, I'll be able to upgrade my Kris Swordsmen into Samurai. :D

Have you considered also randomizing start biases?

Glad you like it! :D

I believe just turning off start biases does the same thing, but maybe I'm wrong. It's probably going to be a side product anyways of my idea to make the start bias be somewhat based on the Components/Traits.

Say if you have "Sun Never Sets" than starting in the middle of the map would make it effectively useless. So instead having it would make you more likely to get that start bias.
 
I believe just turning off start biases does the same thing, but maybe I'm wrong.

Fair enough. (My samurai civ was Portugal anyway, and Sacrificial Captives' and Kris Swordsmen's utility aren't really affected by start bias, so it doesn't matter too much in my current game.)

It's probably going to be a side product anyways of my idea to make the start bias be somewhat based on the Components/Traits.

Say if you have "Sun Never Sets" than starting in the middle of the map would make it effectively useless. So instead having it would make you more likely to get that start bias.

Yeah, I got the idea because the Iroquois ended up with Druidic Lore, and it made me picture Siam, Egypt, or the Huns having it.
 
Version 02 update:
  • Added support for various Mods :
    1. Culture Diversity - If you use the Cultural Diversity Mod you can now have all civilizations given a Randomized Culture Group.
    2. Civilization 4 Traits in Civilization 5 - All civilizations will end up with 2 Randomized Traits from this Mod.

  • Removed the problems with new Civilizations for the user. Now to add modded civilizations all you have to do is find is directory, and click a button.
 
Wow, I was just thinking about an idea similar to this, and then I come on here and see it. Great job! :)
Thank you! I wanted to try, and find a way to make it work even if someone did this, but couldn't come up with a way. A suggestion on how I'm going to make my civs work with this in the future is to add a "tell" building to the trait, and use that as the tell rather than civID.
Yeah... there's going to be a lot of mod civs that won't play nicely with this since they assume that traits and buildings will always belong to the civilization they are assigned to, and that's not getting into really complicated stuff (like Vicevirtuoso's Neptunia civs). This assumption isn't necessarily a bad thing, in my opinion, since this is a very unusual case. :p

It might be fun to try coding my civs up so that it supports this, but it's not going to be a priority right now, just something to consider in the future.
 
I've followed every single step, yet it doesn't react at all when i press the Randomize! button.
Any ideas what could cause this?
 
I've followed every single step, yet it doesn't react at all when i press the Randomize! button.
Any ideas what could cause this?

Are all the files in the same folder? (will do that without the defines).

I've re-downloaded the files, and put them in a different directory, and it still produced the right files. I'll add that you should use the find directory as only forwardslash( / ) links will work.
If it still does work the best I can do in this version is give you a link to a Previous Version. I'll work on more ways for the user to debug, but I'm busy today and tomorrow(exam) :undecide:.
 
Version 02 update:

OHYMYGOD You did it! :lol:

EDIT~~~

I Tested it out, but I'm pretty sure the error is on my own behalf. I attempted to add a large sum of modded civilizations to the mix along with Cultural Diversity and Civ IV Traits.
In doing so however, after adding a few many dozen civs, I forgot to actually enable each Civ themselves in loading the game so all civs showed up with error screens and no Uniques at all. So I suppose I'll confirm that I have to enable the modded civilizations I add to the randomization list.

Also wanted to ask while adding modded civs, with most activations I'd receive a popup notifying me that LUA mods would keep their traits, but with some I didn't get this alert, so were they added to the random list at all?

(I'm going to try activating and getting back to you, but that may take a little while due to amount :p)
 
OHYMYGOD You did it! :lol:

EDIT~~~

I Tested it out, but I'm pretty sure the error is on my own behalf. I attempted to add a large sum of modded civilizations to the mix along with Cultural Diversity and Civ IV Traits.
In doing so however, after adding a few many dozen civs, I forgot to actually enable each Civ themselves in loading the game so all civs showed up with error screens and no Uniques at all. So I suppose I'll confirm that I have to enable the modded civilizations I add to the randomization list.

Also wanted to ask while adding modded civs, with most activations I'd receive a popup notifying me that LUA mods would keep their traits, but with some I didn't get this alert, so were they added to the random list at all?

(I'm going to try activating and getting back to you, but that may take a little while due to amount :p)

Hmm this sounds like another problem shouldn't allow you to run the mod unless you have all the modded civilizations activated.

If you don't get the message it probably had an error, (if it was through my compiler I would get an error in the command prompt.) It's not perfect. A list(even just a few) of those that don't work would help a lot. Allows me to bug test more effectively as I can test the civilization, and see where the error occurs exactly.
 
Top Bottom