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

Giving a Civ unique yields from vanilla buildings.

Discussion in 'Civ5 - Creation & Customization' started by Countbuffalo, May 30, 2017.

  1. Countbuffalo

    Countbuffalo Chieftain

    Joined:
    Aug 16, 2013
    Messages:
    94
    Hi, I'm working on my latest mod at the minute and I want to have the Civ gain bonus yields from vanilla buildings. The actual description is +1 culture from culture buildings, at the minute I've got unique copies of the buildings that are the exact same except for the changed yield. But I'd imagine there's a much cleaner way to do it with lua, anyone who could give me a hand with this?
    Cheers.
     
  2. sman1975

    sman1975 Emperor

    Joined:
    Aug 27, 2016
    Messages:
    1,102
    Location:
    Dallas, TX
    I haven't tested this, but it looks like you could use something like this:
    Code:
    <Traits>
            <Row>
                <Type>TRAIT_CULT_OSIRIS</Type>
                <Description>TXT_KEY_TRAIT_CULT_OSIRIS</Description>
                <ShortDescription>TXT_KEY_TRAIT_CULT_OSIRIS_SHORT</ShortDescription>
                <CultureBuildingYieldChange>1</CultureBuildingYieldChange>
            </Row>          
    </Traits>
    This trait is from DLC06 Scenario "Wonders of the Ancient World" - it adds an INTEGER amount of culture to buildings already producing culture, so it could be more than the 1 in the example.
     
  3. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    6,979
    Location:
    Illinois, USA
    Dummy Policy will also work and can be given the player via lua. Policies already have these two tables available:
    Code:
    	<Table name="Policy_BuildingClassYieldChanges">
    		<Column name="PolicyType" type="text" reference="Policies(Type)"/>
    		<Column name="BuildingClassType" type="text" reference="BuildingClasses(Type)"/>
    		<Column name="YieldType" type="text" reference="Yields(Type)"/>
    		<Column name="YieldChange" type="integer"/>
    	</Table>
    	<Table name="Policy_BuildingClassCultureChanges">
    		<Column name="PolicyType" type="text" reference="Policies(Type)"/>
    		<Column name="BuildingClassType" type="text" reference="BuildingClasses(Type)"/>
    		<Column name="CultureChange" type="integer"/>
    	</Table>
    This method allows you to specify by Building-Class individually which will and will not be affected.
     
  4. Countbuffalo

    Countbuffalo Chieftain

    Joined:
    Aug 16, 2013
    Messages:
    94
    Thankyou for your replies, for the culture I can use Sman's method and that works quite happily. However I still have a use for lua, though with % science yield rather than flat culture, so I'll look into that.
     
  5. sman1975

    sman1975 Emperor

    Joined:
    Aug 27, 2016
    Messages:
    1,102
    Location:
    Dallas, TX
    Are you saying you want to have the same ability to increase science yields on science buildings for a specific civ?
     
  6. Countbuffalo

    Countbuffalo Chieftain

    Joined:
    Aug 16, 2013
    Messages:
    94
    No, this time I want to do % science on walls for a specific Civ.
     
  7. sman1975

    sman1975 Emperor

    Joined:
    Aug 27, 2016
    Messages:
    1,102
    Location:
    Dallas, TX
    OK. Look more closely at LeeS' post above - I believe it is the best way to add Science, or any other non-Culture yield.
     
  8. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    6,979
    Location:
    Illinois, USA
  9. Chrisy15

    Chrisy15 Flower, Beautiful

    Joined:
    Jul 9, 2015
    Messages:
    2,077
    So instead yea, you'd be using Lua:

    Code:
    
    local iScienceBuilding = GameInfoTypes["BUILDING_I_HAVE_A_25_SCIENCE_MOD"]
    local civilizationID = GameInfoTypes["CIVILIZATION_ANIME_IDK"]
    local iWalls = GameInfoTypes["BUILDING_WALLS"]
    
    function C15_ScienceWallsDoTurn(playerID)
    	local pPlayer = Players[playerID]
    	if pPlayer:IsAlive() and pPlayer:GetCivilizationType() == civilizationID then
    		for pCity in pPlayer:Cities() do
    			local iNum = 0
    			if pCity:IsHasBuilding(iWalls) then
    				iNum = 1
    			end
    			pCity:SetNumRealBuilding(iScienceBuilding, iNum)
    		end
    	end
    end
    
    function C15_ScienceWallsCityConstructed(playerID, cityID, buildingID)
    	if buildingID ~= iWalls then return end
    	local pPlayer = Players[playerID]
    	if pPlayer:GetCivilizationType() == civilizationID then
    		pPlayer:GetCityByID(cityID):SetNumRealBuilding(iScienceBuilding, 1)
    	end
    end
    
    GameEvents.PlayerDoTurn.Add(C15_ScienceWallsDoTurn)
    GameEvents.CityConstructed.Add(C15_ScienceWallsCityConstructed)
    
    Just be sure to give the Science Dummy NeverCapture = 1, so that other civs don't get it.
     
  10. Countbuffalo

    Countbuffalo Chieftain

    Joined:
    Aug 16, 2013
    Messages:
    94
    Thanks, I've implemented your suggestion and it should help to clean things up a lot.
     
  11. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    6,979
    Location:
    Illinois, USA
  12. Chrisy15

    Chrisy15 Flower, Beautiful

    Joined:
    Jul 9, 2015
    Messages:
    2,077
    Huh. Learn something new every day...
     

Share This Page