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

Problem adjusting profession consumption

Discussion in 'Civ4Col - Creation & Customization' started by Sanotra, Jan 14, 2013.

  1. Sanotra

    Sanotra Wannabe Modder

    Joined:
    May 16, 2007
    Messages:
    668
    Location:
    Wa - USA
    Below I will detail a problem I encountered while trying to change the amount of materials it cost to build a cannon.

    File: xml/units/professioninfos

    If you take a look at the cannonsmith profession, you will find that in order to produce cannons:

    <YieldsProduced>
    <YieldType>YIELD_CANNONS</YieldType>
    </YieldsProduced>
    <YieldsConsumed>
    <YieldType>YIELD_TOOLS</YieldType>
    </YieldsConsumed>


    He consumes 1 tool to make 1 cannon.
    I wanted to push this threshold and make him require 2.

    <YieldsProduced>
    <YieldType>YIELD_CANNONS</YieldType>
    </YieldsProduced>
    <YieldsConsumed>
    <YieldType>YIELD_TOOLS</YieldType>
    <YieldType>YIELD_TOOLS</YieldType>
    </YieldsConsumed>


    Now he consumes 2 tools to make 1 cannon when assigned to the armory.
    I wanted to again push the threshold and make him consume 3.

    <YieldsProduced>
    <YieldType>YIELD_CANNONS</YieldType>
    </YieldsProduced>
    <YieldsConsumed>
    <YieldType>YIELD_TOOLS</YieldType>
    <YieldType>YIELD_TOOLS</YieldType>
    <YieldType>YIELD_TOOLS</YieldType>
    </YieldsConsumed>


    That's where I ran into the problem. A picture speaks a thousand words, so here are two.

    Spoiler :

    Unlike normal, the building says it is going to produce 3 cannons and remove 9 tools even though there are no tools in the settlement.
    Spoiler :


    The next turn, you can see that the settlement now is in the negatives, and presumably can make an infinite amount of cannons for free.

    Whoever made the dyer profession for RaR used the 2 yeilds consumed threshold. If you're reading this, did you also program this, or was it already maxed out at 2 yeilds? I would like to remove the limit in the programming and make it demand 10 tools if I want, or 10,000 tools (lol) to make 1 cannon. Please somebody help me, this one is driving me nuts. Also, the strategy box the pops up when you scroll over the armory says 'Converts Tool and Tool and Tool into Cannon. If we can resolve the limit issue can we make it say 'Converts 3 Tools into Cannon', or 'Converts 10,000 Tools into Cannon."?
     
  2. Sanotra

    Sanotra Wannabe Modder

    Joined:
    May 16, 2007
    Messages:
    668
    Location:
    Wa - USA
    On a second, somewhat related note. I also wanted to discontinue the combined use of both cannonsmith and gunsmith in the same building. I fought for hours with this one as well. The xml seemed easy enough to change.

    I made a specialbuilding_cannons and assigned the cannonsmith to it instead of specialbuilding_muskets, and adjusted all the xml files accordingly. I made two new buildings, CANNON_SHOP and CANNON_FACTORY, and adjusted all texts and what not. The one thing I ran into issues with was actually getting my building to appear in the city management screen. I played with the font index numbers, but I don't really fully understand them. I changed a few of the numbers and the buildings still would not move.

    Further more, I had to delete one building to get to that screen at all. Just adding the specialbuilding_cannons code at the end caused the game to act funky and would not operate correctly when I loaded. But when I deleted a building and substituted it with the new building, the city management screen would show buildings all over the place. What's up with that. If one of you have a moment to explain to me how the building placement in the city management view works, I would be grateful. (The reason I did this is so I could have the Gunsmith building producing 5 muskets per assigned colonist and the Cannonsmith building only producing 1 or 2 per assigned colonist).
     
  3. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,935
    Gender:
    Male
    Location:
    Stuttgart, Germany
    I programmed MYC/P for RaR.
    (I used parts of code from Aymerick and Kailric but reprogrammed a lot on my own.)

    I never designed the feature to have more than 2 Yields consumed or more than 2 Yields produced.

    The feature is quite complicated and big.
    (Especially AI had to be taught a few things.)

    However it is of course possible to adjust and it is quite well commented in the sources. :thumbsup:
     
  4. Commander Bello

    Commander Bello Say No 2 Net Validations

    Joined:
    Sep 3, 2003
    Messages:
    3,858
    Location:
    near Koblenz, Germany
    The quantity of yields put out is defined in the buildings.
    There you find a tag <YieldModifiers>, too. I have never tested it, but maybe a negative value there like -50 could result in what you try to achieve?
     
  5. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,935
    Gender:
    Male
    Location:
    Stuttgart, Germany
    Please also consider that amounts of Yields produced and Yields consumed do affect AI decisions considering the "value" of professions.
    It is not a good idea to simply change XML values without consideration what these changes will do to AI or other game logic.
     
  6. Sanotra

    Sanotra Wannabe Modder

    Joined:
    May 16, 2007
    Messages:
    668
    Location:
    Wa - USA
    Thanks for your speedy response Ray. Where and what exactly are the sources? This requires a working knowledge of C++ right? At the moment I can fly around xml files like a madman and change values and tags and source files with relative ease, but I'm not sure if I can understand the underlying programming language. I'm sure if I can look at it I am bound to learn. Where and what are the sources and how can I view them?

    I have messed a little with Building output modifiers. I don't think I tried a negative, but from what I have seen all negatives are programmed to cancel that line of text and make it null and void. For example on immigration (in the other thread), a Europe cost of 0 for a unit would make the unit free, but it's value is -1 or more, and that is programmed to make it not for sale in the Europe screen.

    Modifying a building output to -50% would mean .5 a cannon for every 1 tool. But what if there is only 1 tool in the settlement or the tool amount is odd? :confused: It can't store cannons in decimal values but only in whole units. I have not tried it, and cannot at the moment, but I would imagine that this would cause the game to crash.

    The general idea is to make a cannon worth 10 tools or more. And I think the best approach is to change the programming and allow for it in the yields consumed text. :crazyeye:

    I have considered these aspects, it seems the overall goal is worth the trouble along the way. All of my files are backed up, and I have had to replace my changes with the original files multiple times as I have been editing all these values, but the improvement on my knowledge and the potential delight of making something unique have seemed worth the headache. :lol:
     
  7. Commander Bello

    Commander Bello Say No 2 Net Validations

    Joined:
    Sep 3, 2003
    Messages:
    3,858
    Location:
    near Koblenz, Germany
    As I said, I have never tested it by myself, so your concerns may be very well justified.
    Nevertheless, it would be the quickest and easiest way to test.

    I don't see the problem here.
    It is just the same like in any other case in which a tool is missing for finishing the respective construction. The game will stop and you will be notified that one (or more) tool(s) are missing. And then you will have the chance to buy that missing quantity.
    If you don't, the game doesn't store 0.876 buildings, ships or whatever, either. It just keeps in mind that there is an unfinished construction order, lacking x tools.

    Actually, I have to disagree.
    Changing XML values means just changing parameters but not logic. As the way the logic is working is known, you can rather easily identify if changed parameters will influence the game.
    If yes, then ok... you will have to change the logic,too. But then you will do it because you know that you have to do it.
     
  8. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,935
    Gender:
    Male
    Location:
    Stuttgart, Germany
    Well, do whatever you prefer.

    I can just tell you that it is incredibly hard to find out what AI is really doing ingame.
    You might need many many test games to find a problem or a bug that causes CTD.

    It is much better and faster to check the DLL for possible side effects and problems.
    Of course, some problems may slip even the most experienced programmers and will only be discovered during actual games.

    But yes of course, you can also do try and error instead of systematic approaches.

    Do whatever fits best to your style of modding. :thumbsup:
    (Trying to consider what side effects to AI or other logic might be caused is never wrong though.)
     
  9. raystuttgart

    raystuttgart Civ4Col Modder

    Joined:
    Jan 24, 2011
    Messages:
    5,935
    Gender:
    Male
    Location:
    Stuttgart, Germany
    The sources are the files that are used to compile the DLL.
    They are included in the download of Religion and Revolution.

    Yes, and knowledge about usage of a development environment like Visual Studio.

    Commander Bello might help you with that.
    He just recently set up his development environment.

    Good luck with your modding. :thumbsup:
     
  10. Sanotra

    Sanotra Wannabe Modder

    Joined:
    May 16, 2007
    Messages:
    668
    Location:
    Wa - USA
    I tested the - modifiers and here is what I found. In the below image a modifier of -50% works as intended.
    Spoiler :



    In this one the -200% modifier (4 tools per cannon) is not working, even with the cannonsmith (+100%) working the building. I think the reason is: that a value of -100% or more tells the computer that 1 tool = 0 cannons. So it will consume all of the tools but never produce a single cannon. I tried different values, but only a modifier within -100 to -1 works.
    Spoiler :


    I was actually introduced to Visual Studio in person by a programmer that I am acquainted with. So I created the standard hello world box, and got shown around the features. I tried unsuccessfully several times to install it on my computer. I guess I will have to try again.

    ---------------
    I thought a lot about what this line of thinking will make available to modders and in particular the first thing I can think of is the modcomp Real Prices I talked about in my Radical Concepts thread. What I would like to see in the xml is code like this.

    Spoiler :


    And ultimately achieve a pop up strategy box as clean as this:


    How much time do you think it will take to work the features I just detailed? For an experienced programmer? For me?
     
  11. Commander Bello

    Commander Bello Say No 2 Net Validations

    Joined:
    Sep 3, 2003
    Messages:
    3,858
    Location:
    near Koblenz, Germany
    This sounds like a reasonable explanation. :goodjob:


    There shouldn't be any problem with the installation as long as you don't have special characters in your username nor spaces in the directory path (spaces actually do not create problems with the installation as such, but can cause problems later on when trying to create the dll)
    I am working with MS Visual C++ 2008 Express Edition (google for it, it's free) and had it installed in the default path. Works like a charm.

    No idea. :blush:

    I am even less than a bloody beginner in programming.
     

Share This Page