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

Creating New Specialists

Discussion in 'Civ5 - Modding Tutorials & Reference' started by Sneaks, Jan 6, 2011.

  1. Sneaks

    Sneaks Brooklyn Bum

    Joined:
    Oct 15, 2010
    Messages:
    1,877
    Location:
    NYC
    HowTo: Creating New Specialists.

    This tutorial assumes you read through Kael's guide and understand the basics of ModBuddy.

    Step 1: Creating the Graphics for your Specialist

    Specialists require 6 unique .dds files to display in game. The first 5 are similar to custom graphics for buildings or units. The 6th exists specifically to display the specialists in the City View screen.

    I have included a .rar file with all of my current custom .dds files as well as .png versions of the original CityView files so that you can use them as a template.

    The easiest (though not prettiest) way to add a new specialist is to select a currently existing one in Photoshop (you will need the .dds plugin available here. NOTE: You cannot use 64 bit PS for this, only 32.). Simply lasso or box the colored versions of the Citizen, apply a black and white filter, then Tint it to the new color of your choice.
    When saving, make sure to:
    1. Flatten the image first.
    2. Choose DXT3, 2D Texture, and No MIP Maps on the NVIDIA screen.

    For the multiple Citizen files 128, 180, 256, 512, and 1024 make sure to include the same colors in the same spots. This is important. Also, write down which spot each of your citizens is in on the grid. For example, the Brown citizen on my grids is my Bureaucrat. The Pink one is my Monk, Dark Blue is my Philosopher. So, I would write down:
    0. Bureaucrat
    1. Monk
    2. Philosopher
    Note that numbering starts at 0 and not 1.

    For the individual .dds file (ex. citizenbureaucrat), do not add a tint to the lowest of the 4 icons, as it represents an empty slot.

    Step 2: Add your Graphics to the Icon Atlas
    Add all of your new .dds files to your ModBuddy project. Make sure that for every single .dds, you change its Properties to include Import Into VFS as True.
    You will need to come up with a name for your Custom Specialists Icon Atlas. Try to keep it unique. I named mine SNCIT_ATLAS (Sneaks Citizen Atlas).

    Add an XML file to your project in ModBuddy:
    Spoiler :
    Code:
    <GameData>
    	<IconTextureAtlases>
    		<Row>
    			<Atlas>SNCIT_ATLAS</Atlas>
    			<IconSize>256</IconSize>
    			<Filename>SnCit1024.dds</Filename>
    			<IconsPerRow>4</IconsPerRow>
    			<IconsPerColumn>4</IconsPerColumn>
    		</Row>
    		<Row>
    			<Atlas>SNCIT_ATLAS</Atlas>
    			<IconSize>128</IconSize>
    			<Filename>SnCit512.dds</Filename>
    			<IconsPerRow>4</IconsPerRow>
    			<IconsPerColumn>4</IconsPerColumn>
    		</Row>
    		<Row>
    			<Atlas>SNCIT_ATLAS</Atlas>
    			<IconSize>64</IconSize>
    			<Filename>SnCit256.dds</Filename>
    			<IconsPerRow>4</IconsPerRow>
    			<IconsPerColumn>4</IconsPerColumn>
    		</Row>
    		<Row>
    			<Atlas>SNCIT_ATLAS</Atlas>
    			<IconSize>45</IconSize>
    			<Filename>SnCit180.dds</Filename>
    			<IconsPerRow>4</IconsPerRow>
    			<IconsPerColumn>4</IconsPerColumn>
    		</Row>
    		<Row>
    			<Atlas>SNCIT_ATLAS</Atlas>
    			<IconSize>32</IconSize>
    			<Filename>SnCit128.dds</Filename>
    			<IconsPerRow>4</IconsPerRow>
    			<IconsPerColumn>4</IconsPerColumn>
    		</Row>
    	</IconTextureAtlases>
    </GameData>

    Replace the Atlas name with your Atlas name and each File name with what you named your files.

    Step 3: Add Your Citizens to the XMLs
    In a new XML, or the same, add the following:
    Spoiler :
    Code:
    <GameData>
    	<Specialists>
    		<Row>
    			<Type>SPECIALIST_BUREAUCRAT</Type>
    			<Description>TXT_KEY_SPECIALIST_BUREAUCRAT</Description>
    			<Strategy>TXT_KEY_SPECIALIST_BUREAUCRAT_STRATEGY</Strategy>
    			<Visible>true</Visible>
    			<Cost>0</Cost>
    			<CulturePerTurn>-4</CulturePerTurn>
    			<IconAtlas>SNCIT_ATLAS</IconAtlas>
    			<PortraitIndex>0</PortraitIndex>
    		</Row>
    	</Specialists>
    	<SpecialistYields>
    		<Row>
    			<SpecialistType>SPECIALIST_BUREAUCRAT</SpecialistType>
    			<YieldType>YIELD_PRODUCTION</YieldType>
    			<Yield>4</Yield>
    		</Row>
    		<Row>
    			<SpecialistType>SPECIALIST_BUREAUCRAT</SpecialistType>
    			<YieldType>YIELD_SCIENCE</YieldType>
    			<Yield>4</Yield>
    		</Row>
    		<Row>
    			<SpecialistType>SPECIALIST_BUREAUCRAT</SpecialistType>
    			<YieldType>YIELD_GOLD</YieldType>
    			<Yield>-4</Yield>
    		</Row>
    	</SpecialistYields>
    	<Language_en_US>
    		<Row Tag="TXT_KEY_SPECIALIST_BUREAUCRAT">
    			<Text>Bureaucrat</Text>
    		</Row>
    	</Language_en_US>

    Obviously, replace Bureaucrat with the name of your specialist and alter/delete/add the yields you want. Add Great Person points and a Great Person association if you choose as well.

    Most importantly, make sure to put in the name of your Icon Atlas, and for <PortraitIndex>, put the number your Specialist appears in your Atlas, as we listed above.

    Onward to part 2.
     
  2. Sneaks

    Sneaks Brooklyn Bum

    Joined:
    Oct 15, 2010
    Messages:
    1,877
    Location:
    NYC
    Part 2!

    Step 4: Getting the Suckers into the Lua

    .Lua is pretty rough for most people so I included my CityView.lua file to work with.

    First step, add the CityView.lua to your Mod, and go into properties, and set that suckers Import into VFS to True.

    Now open up that badboy and do a search for "Sneaks"

    The second section you should see should look like this:
    Code:
    local artistTexture = "citizenArtist.dds";
    local engineerTexture = "citizenEngineer.dds";
    local merchantTexture = "citizenMerchant.dds";
    local scientistTexture = "citizenScientist.dds";
    local unemployedTexture = "citizenUnemployed.dds";
    local workerTexture = "citizenWorker.dds";
    -- Sneaks Specialist
    local bureaucratTexture = "citizenbureaucrat.dds";
    local magistrateTexture = "citizenmagistrate.dds";
    local monkTexture = "citizenmonk.dds";
    local inventorTexture = "citizeninventor.dds";
    local aristocratTexture = "citizenaristocrat.dds";
    local professorTexture = "citizenprofessor.dds";
    -- Sneaks  End
    local emptySlotString = Locale.ConvertTextKey("TXT_KEY_CITYVIEW_EMPTY_SLOT");
    In the Section inside the Sneaks comments, add a line for your specialist, and delete mine. Use the same naming style for the first part and your individual .dds file for the second:
    Code:
    local yourspecialistTexture = "citizenyourspecialist.dds";
    Next, do a search for bureaucratTexture. That should bring you to this monster:
    Spoiler :
    Code:
    -- Sneaks Specialist
    			elseif building.SpecialistType == "SPECIALIST_BUREAUCRAT" then
    				controlTable.BuildingFilledSpecialistSlot1:SetTexture(bureaucratTexture);
    				controlTable.BuildingFilledSpecialistSlot2:SetTexture(bureaucratTexture);
    				controlTable.BuildingFilledSpecialistSlot3:SetTexture(bureaucratTexture);
    			elseif building.SpecialistType == "SPECIALIST_ARISTOCRAT" then
    				controlTable.BuildingFilledSpecialistSlot1:SetTexture(aristocratTexture);
    				controlTable.BuildingFilledSpecialistSlot2:SetTexture(aristocratTexture);
    				controlTable.BuildingFilledSpecialistSlot3:SetTexture(aristocratTexture);
    			elseif building.SpecialistType == "SPECIALIST_MAGISTRATE" then
    				controlTable.BuildingFilledSpecialistSlot1:SetTexture(magistrateTexture);
    				controlTable.BuildingFilledSpecialistSlot2:SetTexture(magistrateTexture);
    				controlTable.BuildingFilledSpecialistSlot3:SetTexture(magistrateTexture);
    			elseif building.SpecialistType == "SPECIALIST_PROFESSOR" then
    				controlTable.BuildingFilledSpecialistSlot1:SetTexture(professorTexture);
    				controlTable.BuildingFilledSpecialistSlot2:SetTexture(professorTexture);
    				controlTable.BuildingFilledSpecialistSlot3:SetTexture(professorTexture);
    			elseif building.SpecialistType == "SPECIALIST_MONK" then
    				controlTable.BuildingFilledSpecialistSlot1:SetTexture(monkTexture);
    				controlTable.BuildingFilledSpecialistSlot2:SetTexture(monkTexture);
    				controlTable.BuildingFilledSpecialistSlot3:SetTexture(monkTexture);
    			elseif building.SpecialistType == "SPECIALIST_INVENTOR" then
    				controlTable.BuildingFilledSpecialistSlot1:SetTexture(inventorTexture);
    				controlTable.BuildingFilledSpecialistSlot2:SetTexture(inventorTexture);
    				controlTable.BuildingFilledSpecialistSlot3:SetTexture(inventorTexture);
    -- Sneaks End


    Add an identical set for your specialist, and delete all of mine that you don't plan on using. Save the file, and you are pretty much good to go.


    Remember, you do NOT want to add CityView.lua to the Actions or Content menu, but DO want to add your Icon Atlas update to the Actions menu as an OnModActivated.

    As always, feel free to steal my icons, code, concepts, whatever. All I ask is you give me credit or if you find a better way to do certain things, give me advice!

    Cheers!

    Sneaks
     

    Attached Files:

  3. SamBC

    SamBC Emperor

    Joined:
    Feb 2, 2010
    Messages:
    1,052
    Location:
    Lancaster
    It's disappointing that Lua modification is necessary for this; there's no good reason, architecturally, that it shouldn't be able to get all of the relevant info from the XML, including that texture.
     
  4. Apeiron

    Apeiron Warlord

    Joined:
    Feb 7, 2010
    Messages:
    161
    Is it possible to create a new "buldingfree" specialist like the citizen, and how ?

    I think there is a link with the Lua :

    I think this "else" makes a new type of buildingfree specialist impossible but i want to be sure.

    (PS : Don't worry, you're already in my "thanks" ^^)

    [edit]
    My idea was to create a "slave" specialist, and i wanted them to be linked with a special type of great people : when the "slave GP" borns, the city will be in a period of anarchy (and the GP disappears of course, or the GP IS the anarchy, without unit). Is it possible ?
     
  5. Sneaks

    Sneaks Brooklyn Bum

    Joined:
    Oct 15, 2010
    Messages:
    1,877
    Location:
    NYC
    All else does is create a fallback option if a building is not given a specific type of specialist assignment in the buildings.xml file. What you want to do most likely, would be to duplicate the unemployed citizen section with a box that allows you to add and remove slave specialists. Once you build the boxes for it in the xml, the lua code to hold them would be a pretty simple, but a bit lengthy, check process duplicating that of the specialist buildings.
     
  6. Apeiron

    Apeiron Warlord

    Joined:
    Feb 7, 2010
    Messages:
    161
    Thanks for your quick answer. :)

    Ok.

    True.

    Well... how can i do that ?

    You are talking about that ID ? Where is the original box for citizen, and is there other things to do except that box ?
     
  7. Catalonia

    Catalonia Warlord

    Joined:
    Jan 4, 2012
    Messages:
    118
    How can I create a Great Specialist?
     
  8. Kannloar

    Kannloar Chieftain

    Joined:
    Jul 19, 2012
    Messages:
    6
    Hello,

    first, thank you for sharing your job :)

    I'm trying to add some new specialist. "Military specialist". So i follow your hints.
    But it's not working.

    WHen i load my game with your cityview lua, i get this :

    .

    and the city view interface is quite a mess. The specialists building, overwrite the other buildings, when i close this window, the other buildings also disapear..

    So i was asking myself : did you know if your cityview lua works with G&K expansion or not ? Did you think i've made a mistake ? Perhaps have you already meet this problems.

    Thank you

    Kannlaor
     
  9. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,426
    Location:
    Near Portsmouth, UK
    If you used a CityView.lua that was attached to the original posts (from Jan 2011) it most certainly will NOT work with G&K (or patch 675/704)

    You will need to take a copy of the original G&K CityView.lua and make the appropriate changes into that.
     
  10. Kannloar

    Kannloar Chieftain

    Joined:
    Jul 19, 2012
    Messages:
    6
    Ok, i found the file, i'll follow your advise.

    thank you
     
  11. Kannloar

    Kannloar Chieftain

    Joined:
    Jul 19, 2012
    Messages:
    6
    Hello,

    It's still not working.

    I create all the dds file and import them in modbuddy and set the VFS true.
    I wrote the xml files specialist / buildings / atlas and set them "on mod activated" "update database"

    I took the cityview lua file from the expansion folder, i add the line as describe by sneaks, and set the vfs true but not set anything else.

    It's still not working.
    Anyone as any idea ? I miss something ?
    In is guide Kael says that when lua is modified, you have to update xml file as weel. I sneak in the xml but i dont' find anything about specialist but this :

    Spoiler :
    <!-- BUILDINGS -->
    <Instance Name="BuildingInstance">
    <Button NoStateChange="1" Anchor="L,C" Color="White.0" Offset="0,0" Size="254,64" ID="BuildingButton" ToolTip="Placeholder Tooltip">
    <Label Anchor="R,T" Offset="64,8" TruncateWidth="185" Font="TwCenMT18" ColorSet="Beige_Black_Alpha" FontStyle="Shadow" String="Building Name" ID="BuildingName"/>
    <Image Anchor="R,C" Size="64,64" Offset="0,-2" Texture="64x64FrameButtons.dds">
    <Image Anchor="C,C" Texture="WonderAtlas512.dds" Size="64,64" ID="BuildingImage"/>
    <Button Anchor="L,B" AnchorSide="O.I" Size="32,32" Offset="0,6" Texture="assets\UI\Art\Icons\CitizenWorker.dds" ID="BuildingFilledSpecialistSlot1" Hidden="True"/>
    <Button Anchor="L,B" AnchorSide="O.I" Size="32,32" Offset="32,6" Texture="assets\UI\Art\Icons\CitizenWorker.dds" ID="BuildingFilledSpecialistSlot2" Hidden="True"/>
    <Button Anchor="L,B" AnchorSide="O.I" Size="32,32" Offset="64,6" Texture="assets\UI\Art\Icons\CitizenWorker.dds" ID="BuildingFilledSpecialistSlot3" Hidden="True"/>
    <Button Anchor="L,B" AnchorSide="O.I" Size="32,32" Offset="0,6" Texture="assets\UI\Art\Icons\CitizenEmpty.dds" ID="BuildingEmptySpecialistSlot1" Hidden="True"/>
    <Button Anchor="L,B" AnchorSide="O.I" Size="32,32" Offset="32,6" Texture="assets\UI\Art\Icons\CitizenEmpty.dds" ID="BuildingEmptySpecialistSlot2" Hidden="True"/>
    <Button Anchor="L,B" AnchorSide="O.I" Size="32,32" Offset="64,6" Texture="assets\UI\Art\Icons\CitizenEmpty.dds" ID="BuildingEmptySpecialistSlot3" Hidden="True"/>
    </Image>


    With this "ToolTip="Placeholder Tooltip" that i found in my bug. But i can't figure out how to modify it. And i'm surprised to fond only a cityworker.dds reference but no specialits texture..

    Thanks for any help.

    PS : i'm sorry for my english, i hope you can understand what i'm writing.
     
  12. FramedArchitect

    FramedArchitect Reluctant Modder

    Joined:
    Mar 25, 2012
    Messages:
    798
    Location:
    Missouri
    This method works for me (I used the G&K CityView.lua) I added GP points for this specialist (though it works with no GP points allocated to specialist).
     

    Attached Files:

  13. isnorden

    isnorden Amnesiac Modder

    Joined:
    Jul 6, 2012
    Messages:
    608
    Location:
    Madison, Wisconsin, USA
    Does the game allow specialists to generate religious pressure? I was planning to give certain buildings Clergy specialist slots, each of which generates +1 Faith and +3 religious pressure. (Of course, the latter applies only after a civ "gets religion" -- either by founding or by converting.} If any usable, non-DLL code exists to allow that kind of behavior, please show me what I should do that isn't already covered here. Thank you!
     
  14. Chinese American

    Chinese American Hamtastic Knight

    Joined:
    Aug 23, 2001
    Messages:
    432
    Location:
    Chinatown, USA
    The only way I got this to work is to copy these five files related to the city screen and set them all to VFS=true. Otherwise the city view looks messed up and/or doesn't work properly.
    CityView.lua
    CityView.xml
    CityView_small.xml
    ProductionPopup.lua
    ProductionPopup.xml

    Unfortunately some things will not work as before, such as clicking a Great Work icon to bring up the Culture Overview screen. Also the Great People progress bars don't appear any more and I can't fix this.

    Basically I would have to copy every single UI file over just to change a tiny thing. So stupid. Should have been like WOW where you can hook into or even overwrite any function with a single line of code. Don't know why they don't split up these huge functions into smaller functions that can be hooked or replaced easily.
     

Share This Page