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

New modder looking for some pointers on a custom Civ

Discussion in 'Civ5 - Creation & Customization' started by DarkScythe, May 14, 2014.

  1. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Yes, the Trading Post improvement. (Also the Customs House improvement.)
     
  2. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Eh.. so much for that idea.
    I'm not too sure what's going on here.

    I have a hidden building with <ConquestProb>100</ConquestProb> which should mean it will always be captured, but for some reason it never survives the city capture. Or maybe it does, but by the time I recapture the city, it's gone.
    (For testing, I set GreatWorkCount to zero and added a <Description> to make it appear in the list of buildings.)

    FWIW, this building is being granted via <FreeBuildingThisCity> via another building.
    This particular dummy building is also part of a dummy buildingclass which has <MaxPlayerInstances>1</MaxPlayerInstances> set.
     
  3. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,529
    Location:
    Near Portsmouth, UK
    You haven't inadvertently set NeverCapture=true?
     
  4. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Haha, I double-checked that as the first thought, too. It's not set, as I made sure to replace NeverCapture with ConquestProb.

    Here's the relevant code I have right now, maybe there is some error that I'm not aware of:
    (EMPTY_DUMMY refers to the dummy building code I posted previously. Both of these classes are overridden in my Civ with the "UBs" defined.)
    Code:
    	<BuildingClasses>
    		<Row>
    			<Type>BUILDINGCLASS_MIDDLEMAN_DUMMY</Type>
    			<DefaultBuilding>BUILDING_EMPTY_DUMMY</DefaultBuilding>
    			<MaxPlayerInstances>1</MaxPlayerInstances>
    		</Row>
    		<Row>
    			<Type>BUILDINGCLASS_GIFT_DUMMY</Type>
    			<DefaultBuilding>BUILDING_EMPTY_DUMMY</DefaultBuilding>
    			<MaxPlayerInstances>1</MaxPlayerInstances>
    		</Row>
    	</BuildingClasses>
    	<Buildings>
    		<Row>
    			<Type>BUILDING_MIDDLEMAN_DUMMY</Type>
    			<BuildingClass>BUILDINGCLASS_MIDDLEMAN_DUMMY</BuildingClass>
    			<Cost>-1</Cost>
    			<FaithCost>-1</FaithCost>
    			<Description>MiddlemanDummy</Description>
    			<PrereqTech>NULL</PrereqTech>
    			<GreatWorkCount>0</GreatWorkCount>
    			<ArtDefineTag>NONE</ArtDefineTag>
    			<MinAreaSize>-1</MinAreaSize>
    			[B]<ConquestProb>100</ConquestProb>[/B]
    			<HurryCostModifier>-1</HurryCostModifier>
    			<PortraitIndex>0</PortraitIndex>
    			<IconAtlas>CIV_COLOR_ATLAS</IconAtlas>
    			<FreeBuildingThisCity>BUILDINGCLASS_GIFT_DUMMY</FreeBuildingThisCity>
    		</Row>
    		<Row>
    			<Type>BUILDING_GIFT_DUMMY</Type>
    			<BuildingClass>BUILDINGCLASS_GIFT_DUMMY</BuildingClass>
    			<Cost>-1</Cost>
    			<FaithCost>-1</FaithCost>
    			<Description>GiftDummy</Description>
    			<PrereqTech>NULL</PrereqTech>
    			<GreatWorkCount>0</GreatWorkCount>
    			<ArtDefineTag>NONE</ArtDefineTag>
    			<MinAreaSize>-1</MinAreaSize>
    			<NeverCapture>true</NeverCapture>
    			<HurryCostModifier>-1</HurryCostModifier>
    			<PortraitIndex>0</PortraitIndex>
    			<IconAtlas>CIV_COLOR_ATLAS</IconAtlas>
    			<ExtraSpies>1</ExtraSpies>
    		</Row>
    	</Buildings>
    	<Building_ClassesNeededInCity>
    		<Row>
    			<BuildingType>BUILDING_GIFT_DUMMY</BuildingType>
    			<BuildingClassType>BUILDINGCLASS_NATIONAL_TREASURY</BuildingClassType>
    		</Row>
    	</Building_ClassesNeededInCity>
    
    So, what this code is intended to do:
    Construction of an EIC building provides MIDDLEMAN_DUMMY via FreeBuildingThisCity.
    MIDDLEMAN_DUMMY is limited to 1 per Player, like a NW, and is set to always be captured. EIC building is set to NeverCapture. Intent is to leave MIDDLEMAN_DUMMY behind upon capture.
    MIDDLEMAN_DUMMY then provides an additional building, GIFT_DUMMY, via FreeBuildingThisCity.
    GIFT_DUMMY has its own prerequisite of having an EIC building available first -- I am not sure if FreeBuildingThisCity respects this or not.
    GIFT_DUMMY is set to NeverCapture, since I don't know if it might continue to provide its effects when it changes hands.
    GIFT_DUMMY provides 1 free Spy.

    What I am intending for this to resolve is that when the city gets captured, the EIC and GIFT_DUMMY buildings are destroyed, but the MIDDLEMAN_DUMMY remains. Upon recapture of the city, MIDDLEMAN_DUMMY cannot provide its free building because GIFT_DUMMY requires the EIC. Once the EIC is built, it cannot provide another MIDDLEMAN_DUMMY because one already exists, and is limited to a maximum of 1, and therefore should not trigger a second GIFT_DUMMY.

    Unfortunately, what appears to be happening is that on capture, and subsequent recapture of my city, all 3 buildings are gone. :(
     
  5. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,140
    Location:
    Illinois, USA
    EIC building is set to NeverCapture. Root of the tree, most likely root of the problem.

    But boy! I'm still trying to parse all that out. A look at the EIC code might help make sense of it all. Though maybe not. All this from the guy who at the start of this thread was saying stuff like "wow! you guys are fast!" I'm starting to feel like a very confused and very slow slow turtle.:crazyeye:
     
  6. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Hahaha!

    I attribute my quick learning to all of your helpful responses and tips pointing me in the right direction; Unless I'm truly stuck, I'll generally try to forge ahead and look up information based on where you guys last pointed me toward.

    The wealth of information around here helps quite a bit as well!

    In the back of my mind, I kind of wondered if having the "root" building be NeverCapture could cascade like that, but I don't really have any idea how the FreeBuildingThisCity dependencies work. I suppose I could try setting the EIC building temporarily to ConquestProb 100 just to see if that was the true culprit. It's not ideal though, since the EIC building is one of my Civ's UB's.

    As far as the EIC code goes, it's a simple EIC replacement with buffs to trade routes and such, except it has this in its properties in order to call the "Free building chain."
    <FreeBuildingThisCity>BUILDINGCLASS_MIDDLEMAN_DUMMY</FreeBuildingThisCity>

    The chain itself sounds complicated, but it was random logic I was toying around with in my head trying to see how I could have it give me a Spy once, and only once, regardless of how many times I (re)built the thing.

    I wouldn't mind letting you see all the code I have written so far, although I'd rather do it via PM or Steam, as I'm not yet ready to announce my Civ. If you are okay with it, may I add you on Steam?

    This last question goes to everyone who has helped me so far; Vicevirtuoso, bouncymischa, LeeS, and whoward69 -- I am incredibly appreciative of your collective assistance in getting me plowing through so quickly on a modding system I've never used before.

    As an aside:
    While I really am stuck at the moment regarding the free building chain, I've been working on Promotions. Is there any way to assign Civ-specific Promotions to Great Generals and Great Admirals without having them propagate to every other Civ's GG/GA's as well?

    I looked at how I gave a promotion to my Great Merchant UU, which was via <Unit_FreePromotions> but I think this is a universal promotion, which only worked in this case because the GM is a new UU I created.

    I also see <UnitPromotions_CivilianUnitType> available, which is used to give movement speed bonus promotions to the GG/GA's but I've no idea how they are actually used.

    If worse comes to worst, I suppose I -could- simply mirror the GG/GA again and make them UU's with their own promotions, but otherwise identical in every way to stock units, but ugh. Such a pain, lol. Linking up my GM UU to all of the stock GM Unique Names was quite tedious.
     
  7. bouncymischa

    bouncymischa Synthetic Genie

    Joined:
    Nov 28, 2012
    Messages:
    1,537
    Location:
    In a bottle
    I have no problems with you adding me on Steam -- I'm indebted to you for pointing me in the direction of getting spies before the Renaissance, which helped my most recent Touhou civ come together. :p

    That said, if your goal is to generate the spy once and only once, your best bet may be to use the SaveUtils lua. My Human Village civ uses it to generate Workers when certain buildings are constructed, but only once per city. (You can't sell the building and rebuild it to get another worker.) It does this by using the SaveUtils lua file to keep track of which buildings have been built in which cities. It would probably end up simpler than trying to use an odd chain of dummy buildings to do it...
     
  8. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    7,140
    Location:
    Illinois, USA
    Feel free to on Steam or even here. Steam I am "lshipp". I'm not super-selective with who I friend on Steam. I just ignore requests from people I've never had interaction with before...a lot of people seem more interested in collecting friends just to be collecting friends, or else because they want to "help" me "get in on a good deal" for "free" steam wallets.
    Only way I can think of off the top of my head would be to 1st create a unique replacement version of those for your civ, and give the promotions only to that unique replacement version of the unit. But I'm not really much of an expert on units or promotions...I can read the tables and understand pretty much what most of the commands do, but I haven't built the personal knowledge-base of what will and won't work. Oh! Actually making use of Reading Comprehension skills, I see you were already heading in that direction, says the slow slow turtle.
     
  9. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Ah! The free worker from Watermills!
    I remember that Civ.. Didn't realize it was yours. xD
    I'm not sure what the SaveUtils.lua is, but I'll look into it.

    Even with the way I've tried to (carefully) set up my FreeBuilding chain, it's still susceptible to exploiting, because when you lose whatever city the NW is in, there's nothing stopping you from rebuilding it in a different city entirely.. at which point you'd still get the Spy and stuff, since the middleman building gets destroyed alongside everything else; even if it survives, it's no longer in your possession so the game would still grant it to you since you technically have zero of them at time of construction.

    On that note, LeeS, I did run a test by replacing the NeverCapture property on the EIC building to ConquestProb 100. Theoretically, now the EIC should be captured by the enemy, its spawned building, the middleman, should also be captured since it has the same ConquestProb 100 set, and only the final building in the chain should be destroyed.
    I say should, because, of course it didn't happen that way and everything was destroyed regardless.

    I wonder if it's hardcoded into the game such that UB's or NW's are always destroyed regardless? I need to run another test by setting my regular, non-NW UB to always be captured. At this point it could be that the building being a NW and/or a UB means it must be destroyed, which then in turn requires its spawned buildings to also be destroyed. Something convoluted like that.

    I can help you get in on a good deal for some free steam wallets, too... ;)

    Haha, I wouldn't stress about missing my last line; I actually did a ninja edit to add that after I posted, because I had forgotten to mention that as a possibility. It would be annoying having to copy over everything for the GG and GA, but it would be guaranteed to work, seeing as how I got my GM UU working.

    Actually, while I don't know if Building_FreePromotions would work on them, I know there are a few social policies that boost the abilities of GG/GA's, and I think they use their own Policy_FreePromotions parameter. I haven't considered it yet since I haven't started research into how to make and give my Civ a hidden social policy.

    While we're on the topic of Promotions, I took your advice and used Trait_FreePromotionUnitCombats to add the unique promotions to my civ's units. I spent a few minutes scouring the XML files for the schema holding all of the unit CombatTypes (only to realize you already had a list in your Buildings thread.)
    I got that finished, saved, built the mod, and went off into the game, only to wonder why it wasn't working.

    I was about to come back here somewhat distraught looking for advice when I realized I hadn't actually told the mod to update the database with the new promotions file..

    Took that as a sign to take a short break. Haha.
     
  10. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Well.

    Mark me as utterly confused.

    I just ran a test after editing my regular UB (it doesn't replace any other building) to have ConquestProb 100. At this point, both UB's, and the middleman dummy should be 100% capturable.

    Unfortunately, the buildings still disappear when the city gets captured.
    I can't peek into the AI's cities, so I am going by what IGE is telling me is located in the target city. Once it changes hands, the normal UB disappears (though, curiously, my empty dummy building appears in the city, which disappears when I recapture it. This could be misleading though, since it doesn't list my "trait helper" hidden building, even though its effects are being applied in the city.)

    When I allow my Capital (which houses both the normal UB along with the NW UB, and the 2 FreeBuildings it chains out) to be captured, both FreeBuildings disappear, along with the NW, but seems like it gets replaced by the normal EIC. When I go to recapture the city, even the normal EIC disappears, leaving the only thing left in the city (as always) being the Market, which is the prerequisite to building either of the UB's.

    (By capturing and recapturing, I am using IGE's "Capture city" option, since the results appear to be the same as when I used IGE to give both me and the AI a bunch of units around my Capital before declaring war on each other.)
     
  11. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    I am now stuck on multiple fronts. :(

    My Google-fu doesn't appear to be strong enough, as I've been trying for about an hour, but have been unsuccessful at locating any sort of Policy modding guide, much less any information about how to make such a policy hidden and/or make a dummy policy.

    I think I can create a policy itself pretty simply if I follow the conventions of the XML used in the Buildings, Traits, etc. files, but I have no idea how to assign it to a Civ or a Leader.

    Any pointers here would be appreciated.

    On the bright side, all the promotions are working properly, once I told the mod to actually update the database with the new content.
     
  12. bouncymischa

    bouncymischa Synthetic Genie

    Joined:
    Nov 28, 2012
    Messages:
    1,537
    Location:
    In a bottle
    SaveUtils is a set of lua functions created to basically allow you to do data saving and loading. You basically copy the SaveUtils.lua file into your mod, and load it by setting it to VFS=True (as opposed to make it an UIAddIn like most Lua files). Then you can just call certain functions like "save" and "load" to save/load data. In your case, you'd check to see whether or not the "player X has gained his extra spy" flag was active before spawning the dummy building that made the spy, and then once you spawned it, trip the flag, so they could never get it again.

    The core of making a dummy policy is the following Lua code:

    Code:
    		if not(pPlayer:HasPolicy(GameInfo.Policies["" .. p .. ""].ID)) then
    			pPlayer:SetNumFreePolicies(1)
    			pPlayer:SetNumFreePolicies(0)
    			pPlayer:SetHasPolicy(GameInfo.Policies["" .. p .. ""].ID, true);
    		end
    
    With the relevant policy information filled in. Apparently the "SetNumFreePolicies" bit is the trick -- by doing that switch, it allows you to add a free policy without affecting the number of policies the player needs to get to the next one. Or something. :p

    It might be useful to look at Leugi's Tropico mod -- he has a Lua file there that handles dummy policies generically. He uses SQL to add a new column to the Traits table for "DummyPolicyT", so all you need to do is use that Lua/SQL code, and add the dummy policy to your trait in the XML.

    To be honest, nearly everything I've learned about Lua has come from looking at existing mods, and studying how they accomplished certain functions I wanted to emulate... :p
     
  13. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Ahhhhh. That would explain why I had so much trouble finding information.

    I thought it was something that could be implemented in XML like the other stuff I've done so far.
    If that's the case, it looks like I'm basically done with my Civ from an XML standpoint..
    Everything going forward is LUA and artwork.

    Is there anything special with regard to making the policy that will be referenced, or am I safe just creating a dummy policy by following the Civ5Policies schema, and then just placing that Policy Type name into that LUA?
     
  14. bouncymischa

    bouncymischa Synthetic Genie

    Joined:
    Nov 28, 2012
    Messages:
    1,537
    Location:
    In a bottle
    I think this would be the code you'd need...:

    Code:
    function MyDummyPolicyFunction(iPlayer)
    	if iPlayer < GameDefines.MAX_MAJOR_CIVS then
    		local pPlayer = Players[iPlayer]
    		if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_MY_CIV_HERE then
    			if not(pPlayer:HasPolicy(GameInfoTypes.POLICY_TEST)) then
    				pPlayer:SetNumFreePolicies(1)
    				pPlayer:SetNumFreePolicies(0)
    				pPlayer:SetHasPolicy(GameInfoTypes.POLICY_TEST, true)
    			end
    		end
    	end
    end
    
    GameEvents.PlayerDoTurn.Add(MyDummyPolicyFunction)
    
     
  15. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Thank you so much for the quick tutorial!

    It's finally working now, and it's a great starting place for me to dive deeper into all this stuff.
     
  16. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,529
    Location:
    Near Portsmouth, UK
    Correct, it's one of the few useful "bugs" in the DLL ;)
     
  17. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Who doesn't love a few useful bugs?
    This and the hidden building stuff makes modding some of this stuff way easier.

    Being able to get this hidden policy in and playing with the available parameters, I've actually been able to find out a few useful bits of information about various policies in the game and how they work. This is amazing.

    I've also gotten the unique promotions onto my Great Generals and Great Admirals via this hidden policy without having to muck around with creating "UU" versions of each of them! This has saved quite a bit of time and effort in having to duplicate all of the related assets for the standard GG/GA, and I've also verified that adding the promotion via a Policy does -not- propagate over to other Civs' GG/GA's, which is perfect.

    Of course, the promotion itself doesn't appear to have any effect (I was dubious to begin with; was trying to use the GreatGeneralCombatBonus used by PROMOTION_GENERAL_STACKING) but this in itself may not necessarily be a bad thing -- I had only wanted an 'empty' promotion on the GG/GA just to display the name of my unique promotion (mostly to cover up the fact that the GG/GA use the combat boost trait used by China.)

    For anyone interested, this is accomplished by using a combination of creating the <UnitPromotions>, then assigning it to UNIT_GREAT_GENERAL and UNIT_GREAT_ADMIRAL via <UnitPromotions_CivilianUnitType>. Afterward, create a policy via <Policies>, and finally have said policy provide the promotion via <Policy_FreePromotions>.

    Now to move onward to the next phase of development!
    Everyone here has been absolutely invaluable in helping me get to this point.

    We'll see where I get stuck again.
     
  18. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Whew, time certainly does fly by quickly.

    After over 2 months of development, from conceptualization to learning how to mod, and then executing the development, I am finally close to completion, and feel I have accomplished enough to start releasing some teasers of my very first mod -- one I've undoubtedly poured very much love and effort into making happen. It's now at a very playable stage and in beta testing for balance and bug fixing; I'll probably start looking for volunteers at some point to help with this. For now, I believe I'll start with just one teaser; the Civ icon.

    Spoiler :


    I definitely would not be here without all those that pitched in to help me whenever they could, especially Vice Virtuoso and bouncymischa, whose Civs inspired me to try my hand at it, as well as LeeS and Whoward who, along with countless others, contributed their knowledge at key moments when I was absolutely stuck in a wall. To you, and everyone else who has posted various guides on this forum, and those that pitched in suggestions and ideas when I needed them, I thank you.

    Here's to hoping I can push onward to a full fledged release!
     
  19. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    Is this mod a browser war? When can I expect the O Civ? :D
     
  20. DarkScythe

    DarkScythe Hunkalicious Holo

    Joined:
    May 6, 2014
    Messages:
    804
    Haha, that icon certainly DOES look very similar to the Firefox icon, but unfortunately, I have not been creative enough to think of a Web browser civilization. (Hint hint to new modders!)
     

Share This Page