Hey coders! Would this coding work?

Joined
Jun 29, 2006
Messages
607
Location
Louisville, KY
Like many of you, I am working on a mod. I, however, have no coding experience. So I, like many of you, have no idea if my approach to the code is correct or would even do a dang thing.

That's why I wanted to make this post. Yes, it's about my current issue, but I thought it could serve as a debugging post for those of us that want to try modding, but don't have the necessary knowledge (and are just going off of how we understand what we read). Below is my current issue, but feel free to add your post to the mix my fellow modder wannabes!
 
Currently, I am working on a mod that alters culture to make it easier to obtain and, therefore, causes more policies to be enacted while raising the policy tree requirement for Utopia to 6 full trees instead of 5.

One of the first elements I was hoping to implement would be to enable a single policy option upon the founding of your civilization (to signify the principles upon which your civilization is founded). I was thinking of different ways to implement this, but I came up with the following...

Code:
<GameData>
    <technologies>
        <update>
            <Type>TECH_AGRICULTURE</Type>
            <freepolicies>1</freepolicies>
        </update>
    </technologies>  
</GameData>

I'm an utter code noob and don't want to do something too wild to start.

If this is correct syntax then I can proceed with increasing culture yields and eventually upping the Utopia req to six policy trees. I have a feeling that this is bad code though and would really appreciate one of the stronger coders to look at it just to give a thumbs up or thumbs down about the code.
 
I dont think so, from what I understand Update works for fields that already exist. for example, you can increase production from horses because they add production but if you want to add food you have to use the row command because theres no entry for food to update.
 
Feyd's code is right. The technology TECH_AGRICULTURE already exists in it's own row, you can't make a new one without making a new TECH_AGRICULTURE which would conflict with it. You need to use the update command. It's not updating an entry mind you, it's simply updating the 'row'. You are correct with horses however because each increase in yield is handled in a seperate row. If he wanted to add a domain extra moves attached to agriculture then he would need row rather that update because no such entry exists.

Same fruit, different basket.

Or something cool like that ;)
 
Inside of the update element, you need a tag telling it how to update. Typically you will use a <Set> tag which specifies a field and a value, for example <Set FreePolicies="1" />

Another element which you usually need is a <Where> without a Where, it's just going to Set every FreePolicies element in the table to 1, and you don't want that.

For instance, you may do <Where Type="TECH_AGRICULTURE">

However, before you go and try
Code:
<GameData>
    <technologies>
        <update>
            <Where Type="TECH_AGRICULTURE">
            <Set FreePolicies="1" />
        </update>
    </technologies>  
</GameData>

Which looks right, you have to make sure you are updating a field that actually exists.
Turns out, the technologies table doesn't have any fields called "FreePolicies" so that piece of code isn't actually going to do anything.

There's not really any way to add free policies for techs without resorting to more advanced modding. The game engine just isn't built to handle it at the moment.
 
Currently, I am working on a mod that alters culture to make it easier to obtain and, therefore, causes more policies to be enacted while raising the policy tree requirement for Utopia to 6 full trees instead of 5.

It sounds like we are working on exactly the same mod :lol:
 
I haven't done XML-editing with social policies yet, but what if you could change the cost of each social policy so that the first one is 0, then 25, etc.? Instead of making it tech based, just adjust the values that already exist?

I'll look into it.
 
no its not right, first of all you are not using the update tag correctly, It should contain a "Where" and a "Set" for each object type you are trying to modify

Secondly there is no table or row in the CIV5Technologies.xml called "freepolicies"

geez, Emu'd by 3 post. ^^ quick typers
 
I haven't done XML-editing with social policies yet, but what if you could change the cost of each social policy so that the first one is 0, then 25, etc.? Instead of making it tech based, just adjust the values that already exist?

I'll look into it.

Policy costs are generated by a formula:
25+(6n)^1.7

While any of the numbers in the formula can be adjusted in the XML, there's no way to simply add the number 0 to the front of the sequences without adjusting the formula in a way that affects the rest of the numbers in the series.
 
Policy costs are generated by a formula:
25+(6n)^1.7

While any of the numbers in the formula can be adjusted in the XML, there's no way to simply add the number 0 to the front of the sequences without adjusting the formula in a way that affects the rest of the numbers in the series.

If you're up to it, create a whole different formula (I mean, if you can, I have no idea if this is possible).

Just trying to throw ideas out there. :P
 
If you're up to it, create a whole different formula (I mean, if you can, I have no idea if this is possible).

Just trying to throw ideas out there. :P

Not through XML. The only fields we have to modify are the specific parameters used in the formula.
The formula itself is part of the source code.
 
Inside of the update element, you need a tag telling it how to update. Typically you will use a <Set> tag which specifies a field and a value, for example <Set FreePolicies="1" />

Another element which you usually need is a <Where> without a Where, it's just going to Set every FreePolicies element in the table to 1, and you don't want that.

For instance, you may do <Where Type="TECH_AGRICULTURE">

However, before you go and try
Code:
<GameData>
    <technologies>
        <update>
            <Where Type="TECH_AGRICULTURE">
            <Set FreePolicies="1" />
        </update>
    </technologies>  
</GameData>

Which looks right, you have to make sure you are updating a field that actually exists.
Turns out, the technologies table doesn't have any fields called "FreePolicies" so that piece of code isn't actually going to do anything.

There's not really any way to add free policies for techs without resorting to more advanced modding. The game engine just isn't built to handle it at the moment.
Ahh... But I have yet another workaround!! Mwuhaahaa :evil:

Code:
<GameData>
    <buildings>
        <update>
            <Where Type="PALACE">
            <Set FreePolicies="1" />
        </update>
    </buildings>  
</GameData>

It would be able to use the code already tied to Sydney Opera House and The Oracle to give a free policy when you founded your first city. It could have a side effect of causing a civ whose capital is lost to get a free policy, but for a workaround it is fine by me.

Thank you all for the help, and please let me know if you need any testers for your mod masterD

I've got some other ideas as well perhaps down the line. Any other guys looking for code debugging?
 
Ahh... But I have yet another workaround!! Mwuhaahaa :evil:

Code:
<GameData>
    <buildings>
        <update>
            <Where Type="PALACE">
            <Set FreePolicies="1" />
        </update>
    </buildings>  
</GameData>

It would be able to use the code already tied to Sydney Opera House and The Oracle to give a free policy when you founded your first city. It could have a side effect of causing a civ whose capital is lost to get a free policy, but for a workaround it is fine by me.

Thank you all for the help, and please let me know if you need any testers for your mod masterD

I've got some other ideas as well perhaps down the line. Any other guys looking for code debugging?

I had considered precisely that for my own mod, but I rejected it for the reasons you mentioned. Oh well.
 
I think the palace relocates when you lose your capitol, and if it is your only/last city then it is destroyed. Haven't actually confirmed this (i forgot actually, haven't played enough lately), but it was this way in civ4.
 
Try creating a building. Make it free, cost no maintenance and have it grant a free policy. Try putting superbly high flavors on it so the AI will always nab it, and making a national wonder so that you can only have one, but every civ can have one (is that possible? I think it is).
 
It would be more advanced, but you could get into the "relocation" code and make a duplicate palace entry that it would reference for any palaces past the first one.

You could also make a second free building that you get when you found your capital. It's beyond the skills I can muster, but you could have it be a national wonder as well with perhaps a dose of culture added on for good measure.
 
thats the thing... a Palace is a national wonder..... ;)

But would you get a free social policy...say, if you lost your capital? I'm just saying, create a duplicate Palace but make it not make your city a capital, unless the Palace wouldn't work like that?

Requires testing, I don't know.
 
I'm not sure what you mean, the solution is simple. Have the palace give 1 free social policy. You cannot capture another Civ's national wonders.

Edit:
But would you get a free social policy...say, if you lost your capital? I'm just saying, create a duplicate Palace but make it not make your city a capital, unless the Palace wouldn't work like that?

Requires testing, I don't know.

yea, I guess you would just have to try and find out.
 
I'm not sure what you mean, the solution is simple. Have the palace give 1 free social policy. You cannot capture another Civ's national wonders.

Edit:


yea, I guess you would just have to try and find out.

Tuner it I guess, make two cities, give the AI mechs near your capital, have it (hopefully?) destroy your capital, and see if you got another social policy.
 
Back
Top Bottom