1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[WIP]Randomized Unique Components, and Traits

Discussion in 'Civ5 - Creation & Customization' started by Divine Yuri, Nov 8, 2015.

  1. Divine Yuri

    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 :
    Mod support :
    OLD GUIDE:
    Spoiler :

    New Guide:
    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.
     

    Attached Files:

  2. LastSword

    LastSword Prince

    Joined:
    Feb 24, 2013
    Messages:
    985
    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.
     
  3. Howard Tafty

    Howard Tafty Minister-Chairman

    Joined:
    May 23, 2015
    Messages:
    731
    Location:
    Indefinite Solitude
    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.
     
  4. Divine Yuri

    Divine Yuri Never Closes Chrome

    Joined:
    Oct 28, 2014
    Messages:
    89
    Location:
    Brrrr, USA
    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.


    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.)
     
  5. SamuraiOutcast

    SamuraiOutcast Grand Duke

    Joined:
    Oct 8, 2014
    Messages:
    147
    cough Civ IV Traits in Civ V support cough

    Extraordinary job, really looking forward to trying it out!
     
  6. Divine Yuri

    Divine Yuri Never Closes Chrome

    Joined:
    Oct 28, 2014
    Messages:
    89
    Location:
    Brrrr, USA
    Don't worry got your back with that one. :D

    Spoiler :
     
  7. Gurra09

    Gurra09 Guru of Hekkia

    Joined:
    Jan 1, 2008
    Messages:
    1,271
    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
     
  8. Divine Yuri

    Divine Yuri Never Closes Chrome

    Joined:
    Oct 28, 2014
    Messages:
    89
    Location:
    Brrrr, USA
    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:
     
  9. LastSword

    LastSword Prince

    Joined:
    Feb 24, 2013
    Messages:
    985
    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.
     
  10. Divine Yuri

    Divine Yuri Never Closes Chrome

    Joined:
    Oct 28, 2014
    Messages:
    89
    Location:
    Brrrr, USA
    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.
     
  11. Klisz

    Klisz Chieftain

    Joined:
    Aug 18, 2014
    Messages:
    804
    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?
     
  12. Hoop Thrower

    Hoop Thrower Cyberbolivarian Inkarri

    Joined:
    Aug 5, 2013
    Messages:
    2,487
    Location:
    Chile
    Oh... the civ that gets both Horse Archers and Camel Archers... :eek:
     
  13. Divine Yuri

    Divine Yuri Never Closes Chrome

    Joined:
    Oct 28, 2014
    Messages:
    89
    Location:
    Brrrr, USA
    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.
     
  14. Klisz

    Klisz Chieftain

    Joined:
    Aug 18, 2014
    Messages:
    804
    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.)

    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.
     
  15. Divine Yuri

    Divine Yuri Never Closes Chrome

    Joined:
    Oct 28, 2014
    Messages:
    89
    Location:
    Brrrr, USA
    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.
     
  16. Typhlomence

    Typhlomence Magical Tomomo

    Joined:
    Mar 19, 2014
    Messages:
    394
    Location:
    Brisbane, Australia
    Wow, I was just thinking about an idea similar to this, and then I come on here and see it. Great job! :)
    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.
     
  17. babyrift

    babyrift Chieftain

    Joined:
    Nov 10, 2015
    Messages:
    1
    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?
     
  18. Divine Yuri

    Divine Yuri Never Closes Chrome

    Joined:
    Oct 28, 2014
    Messages:
    89
    Location:
    Brrrr, USA
    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:.
     
  19. SamuraiOutcast

    SamuraiOutcast Grand Duke

    Joined:
    Oct 8, 2014
    Messages:
    147
    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)
     
  20. Divine Yuri

    Divine Yuri Never Closes Chrome

    Joined:
    Oct 28, 2014
    Messages:
    89
    Location:
    Brrrr, USA
    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.
     

Share This Page