Diplomacy

Here is an interesting comment by the producer with regard to diplomacy in the upcoming patch:

"Basically, there was a problem that we corrected that was keeping the AI approach values below a certain level. Now, a player can achieve a much higher approach value. This is not the value you see when you're in diplomacy, this is the approach that the AI is adopting behind the scenes.

Some of the benefits? Gaining Friend/Ally, the AI won't really want to engage in coop wars vs. you, will be more likely to continue coop wars with you, considerably less likely to denounce, more likely to adopt a Friendly approach, etc."

Would this affect WWGD?
 
You get a bonus for capturing a :c5citystate:, depending on their trait it's one of 3 things. Could you maybe add an 'else' statement for if people add new Traits? Currently if a :c5citystate: isn't of one of the 3 vanilla Traits, it gets no bonus. Something like a bunch of gold would probably be most universal.

Also, how do you distribute the (normal, not on conquer) food bonus over the cities? Just divide it over the cities equally?
For a new "productive" Trait I did something like this: (Sharing it with you because it could be relevant and/or give you ideas)
Code:
[COLOR="Green"]-- Every 6th hammer goes to the capital, 
-- the others are distributed over all cities (incl. capital) 
-- according to a sort of 'first come, first serve' principle.[/COLOR]
local ProductionBonus = 3 + (Players[iPlayer]:GetCurrentEra() * 3 )
if ProductionBonus >= 6 then
	local pCapital = Players[iPlayer]:GetCapitalCity()
	if pCapital ~= nil then
		local Remainder = ProductionBonus % 6
		ProductionBonus = ProductionBonus - Remainder
		local CapitalExtraBonus = ProductionBonus / 6
		pCapital:ChangeProduction( CapitalExtraBonus )
		ProductionBonus = ProductionBonus - CapitalExtraBonus + Remainder
	end
end
repeat
	for pCity in Players[iPlayer]:Cities() do
		if ProductionBonus > 0 then
			pCity:ChangeProduction( 1 )
		end
		ProductionBonus = ProductionBonus - 1
	end
until ProductionBonus < 1
The capital gets significantly more than other cities and others are better off the earlier in line they are.
 
Where do you add new minor civ traits? I did a search on "MinorCivTraitTypes" and "MINOR_CIV_TRAIT_CULTURED" that didn't come up with any hits in the XML files.

I've added an else clause as you requested for 7.0 b10. :)

The three functions involved can be seen in "CiVUP_General.lua." This is identical between conquering and normal distribution; conquering just gives 50 turns at once.

Code:
City food per turn = (
    GetPlayerRewardsFromMinorCivs(player)
    * GetCityWeight(city)
    / GetPlayerTotalWeight(player)
)
  1. GetPlayerRewardsFromMinorCivs(player) sums the food bonus of all friendly/allied citystates (or substitute the 50-turn conquer value in here).
  2. GetCityWeight(city) loops through the "CityWeights" table located in "CiVUP - New Tables.xml" and multiplies them together for the city.
  3. GetPlayerWeight(player) sums the weight of the player's cities.

Here's the CityWeights:

200% Resistance
200% :c5capital: Capital
050% Not :c5trade: connected
050% :c5puppet: Puppet
000% :c5razing: Razing
000% Avoid button checked (with special handling if >80% of cities are on avoid)

So the capital gets twice as much food as a regular city, puppets get half, etc.
 
  • The Traits are in BasicInfos/Civ5MinorCivTraits.xml
  • I add functionality by listening in on GameEvents.PlayerDoTurn and checking for FriendshipLevel and then doing stuff. (I can post you the LUA file if you're interested.)
  • I also need(/needed) to change some UI to recognise the new Traits in the CityState(Greeting and Diplo)Popup, DiploRelationships and DiploList. (I did something funky to make it recognise all traits instead of checking if it's cultured, elseif maritime, elseif militaristic,...)
  • I'll also need to do some UI changes to get the bonuses show in the TopPanel, but I'm not at that point yet.
  • There is also the stuff I could add to the tutorial/advisor system and the civilopedia, but I cba with that.
I don't think the AI has trouble handling new CS Traits, XML doesn't suggest they weight the different Traits separately.
I will also check if CSes with the new traits will give quests (I guess they should) and if I need to work on a notification on reaching friends/ally status or if that is somehow taken care of already.

And I should have known you had your bases covered for the food distribution. :D
 
Oh I see why my searches didn't come up with anything...

sql:

  • MinorCivTraits table
  • MINOR_TRAIT_MARITIME record
lua:

  • MinorCivTraitTypes table
  • MINOR_CIV_TRAIT_MARITIME record
Yay for inconsistency! :lol:

The reason I asked is the best solution would be to add YieldType and Yield columns to that table. Then I can replace out all references to "food" with "yield" and any type of CS is possible with the same code:

  • Food
  • Production
  • Gold
  • Science
  • Culture
  • Happiness
  • Great person points
I've been working on merging all the yields into the Yields table so they're treated identically. It's how it should have been done in the first place since they're all the same concept: stuff cities make that go into a "pool" of the yield type. The only difference is what they're used for. It's ridiculous to have a chaotic mess of dozens of functions that all do the same thing. :badcomp:

I've already finished merging food and production so it should be simple to create a production-based citystate. I'm playtesting through a game as Washington right now though, so I probably won't get back to modding for a day or so. :)
 
The MINOR_(CIV_)TRAIT thing is just stupid.
I don't really get how you'd manage to base off (nearly) all traits off the maritime one, but I'm sure you know what you're doing.
My attempts are decidedly more amateurish, but hey, I got it working too. (And first! :P)
 
Well, basically we just add a new attribute to citystate traits called "YieldType". The code then adds YieldType to each city. If we put YIELD_FOOD there it'll add food, like how maritime citystates currently work. If we put YIELD_PRODUCTION it adds production, YIELD_CULTURE for culture, and so on. We can do this because I replaced this sort of function:

pCity:ChangeProduction( 1 )

with this:

pCity:ChangeYield( YieldType, 1 )

Does that make sense?
 
Would the YieldType then be a field for each city-state, instead of in the minorcivtraits.xml? (So the maritime trait would effectively become a generic 'distribute yield over cities' trait)
If that's what you mean, I think I get it.
Otherwise I'm concerned the (inaccessible?) mechanic behind city-states will not do anything with the new traits.

Also, your use of active tense confuses me. Are you considering on doing something like this yourself, or just trying to help me out? Or something in between?

EDIT: Just realised you replaced the functionality of the maritime trait already, so I guess you found a way to disable the vanilla CS bonus mechanic.
Also, I just thought of something: in your city weight table, you could add cities with focus on food as a higher priority.
 
Good idea about checking city focus! I've added a 200% weight for cities with a food focus. Your idea will certainly be easier than setting "avoid" on all other cities, which is what we currently have to do if we want to focus it on one city.

Sorry for the confusion about traits, what I meant is I'm changing my code so it's more easily moddable for modders like yourself. It also benefits me because I'm doing work to "generic-ize" the yields anyway. :)

I realized that to give us the most options it'd be best to add a new table instead of modifying MinorCivTraits. This lets us not only have citystates of any yield, but multiple types of yields form the same citystate. We could create a citystate that gives great person points and science, for example.

The parameters are the base value (stored with FriendLevel=-99), and an era multiplier for each friendship level (friend=1 ally=2).

Spoiler :
Code:
<Table name="MinorCiv_TraitYields">
    <Column name="TraitType" type="text" reference="MinorCivTraits(Type)"/>
    <Column name="FriendLevel" type="integer" default="0"/>
    <Column name="YieldType" type="text" reference="Yields(Type)"/>
    <Column name="Yield" type="integer" default="0"/>
</Table>
<MinorCiv_TraitYields>
    <Row>
        <TraitType>MINOR_TRAIT_MARITIME</TraitType>
        <FriendLevel>1</FriendLevel>
        <YieldType>YIELD_FOOD</YieldType>
        <Yield>2</Yield>
    </Row>
    <Row>
        <TraitType>MINOR_TRAIT_MARITIME</TraitType>
        <FriendLevel>2</FriendLevel>
        <YieldType>YIELD_FOOD</YieldType>
        <Yield>3</Yield>
    </Row>
    <Row>
        <TraitType>MINOR_TRAIT_CULTURED</TraitType>
        <FriendLevel>-99</FriendLevel>
        <YieldType>YIELD_CULTURE</YieldType>
        <Yield>5</Yield>
    </Row>
    <Row>
        <TraitType>MINOR_TRAIT_CULTURED</TraitType>
        <FriendLevel>1</FriendLevel>
        <YieldType>YIELD_CULTURE</YieldType>
        <Yield>2</Yield>
    </Row>
    <Row>
        <TraitType>MINOR_TRAIT_CULTURED</TraitType>
        <FriendLevel>2</FriendLevel>
        <YieldType>YIELD_CULTURE</YieldType>
        <Yield>3</Yield>
    </Row>
</MinorCiv_TraitYields>
Old lua:
PHP:
local friendBonus  = GameInfo.UnofficialPatch["MARITIME_FOOD_FRIEND"].Value * (1 + majorCiv:GetCurrentEra()) / 100
local allyBonus    = GameInfo.UnofficialPatch["MARITIME_FOOD_ALLY"].Value * (1 + majorCiv:GetCurrentEra()) / 100
local civRewards  = {[YieldTypes.YIELD_FOOD]=0, [YieldTypes.YIELD_CULTURE]=0, spawnrate=-1}
for minorCivID,minorCiv in pairs(Players) do
  if IsValidPlayer(minorCiv) and minorCiv:IsMinorCiv() then
    local minorFriendship = minorCiv:GetMinorCivFriendshipLevelWithMajor(majorCiv:GetID())
    if (minorCiv:GetMinorCivTrait() == MinorCivTraitTypes.MINOR_CIV_TRAIT_MARITIME) then
      if minorFriendship == 1 then
        civRewards[YieldTypes.YIELD_FOOD] = civRewards[YieldTypes.YIELD_FOOD] + friendBonus
      elseif minorFriendship == 2 then
        civRewards[YieldTypes.YIELD_FOOD] = civRewards[YieldTypes.YIELD_FOOD] + allyBonus
      end
    end
  end
end
New lua:
PHP:
for minorCivID,minorCiv in pairs(Players) do
  if IsValidPlayer(minorCiv) and minorCiv:IsMinorCiv() then
    local minorFriendship = minorCiv:GetMinorCivFriendshipLevelWithMajor(majorCiv:GetID())
    local minorTrait = minorCiv:GetMinorCivTrait()
    for traitInfo in GameInfo.MinorCivTrait_Yields() do
      if traitInfo.TraitType == minorTrait then
        civRewards[traitInfo.YieldType] = civRewards[traitInfo.YieldType] or {}
        civRewards[traitInfo.YieldType][traitInfo.FriendLevel] = civRewards[traitInfo.YieldType][traitInfo.FriendLevel] or {}
        if traitInfo.FriendLevel == -99 then
          civRewards[traitInfo.YieldType][traitInfo.FriendLevel].Base = traitInfo.Yield
        else
          civRewards[traitInfo.YieldType][traitInfo.FriendLevel].Base = civRewards[traitInfo.YieldType][traitInfo.FriendLevel].Base or 0
          civRewards[traitInfo.YieldType][traitInfo.FriendLevel].PerEra = traitInfo.Yield
        end
      end
    end
  end
end

Now I just need to adapt the rest of the code to use this new algorithm, which I'll do once I'm done checking forum posts.
 
I don't know. Can a city accumulate weight. For example putting food focus in the capital or a city not connected? And do the effects stack or multiply?
And double is probably the most elegant. Though I would be leaning towards keeping a distinction between being capital and having focus, something like +67%, 75% or 80%.

You could also increase the bonus (I mean total amount of f.e. food received) if a CS is connected to your trade network. It makes sense for having a connection to affect their impact on you and would add some background to why they sometimes request a road themselves.
Would also benefit befriending close CSes.*
I don't know how the AI would handle it though. They do build roads to CSes, but I don't know if that's only on request or also to facilitate their own troop movement.

*And with added traits (my list is currently on :c5gold:commercial, :c5influence:diplomatic, :c5science:intellectual, :c5production:productive, :c5greatperson:progressive and :c5happy:prosperous) each type would be much rarer and have a greater impact. E.g. on a huge map with 20 CSes are none of the 2 cultured ones close to you? Going with a cultural victory will be harder.
Pre-determined strategies would be less certain. The more situational strategy could make the game more fun, or you could see it as a game of chance where a civ which happens to be close to the 2 maritime ones gets game breaking advantage.
 
It loops through the whole table and multiplies all the weights together that apply to a city.

From what I've seen, the AI only builds roads to CSs if there's a request for it, so I wouldn't want to factor that in.

I agree that more traits will result in more diversity between games, I think it's a great idea and that's why I'm doing work to make it easy for you to do whatever traits you want. It's a mod I'd definitely use. :)
 
It loops through the whole table and multiplies all the weights together that apply to a city.

From what I've seen, the AI only builds cities to CSs if there's a request for it, so I wouldn't want to factor that in.

I agree that more traits will result in more diversity between games, I think it's a great idea and that's why I'm doing work to make it easy for you to do whatever traits you want. It's a mod I'd definitely use. :)
A first 'complete' version of the traits is out as part of my NACSM mod. I don't know if I should maybe release it as a separate mod as well. Would be helpful for those that don't want the rest, but you can already just delete all the other folders of the mod and it should work fine.
I didn't yet implement your better way of weighting cities, I first wanted to lay out the ground works before making it more complicated.
Hopefully people will like it.
 
A first 'complete' version of the traits is out as part of my NACSM mod. I don't know if I should maybe release it as a separate mod as well. Would be helpful for those that don't want the rest, but you can already just delete all the other folders of the mod and it should work fine.
I didn't yet implement your better way of weighting cities, I first wanted to lay out the ground works before making it more complicated.
Hopefully people will like it.

I have been following the progress of your mod, and hope it continues. Its potential is huge. Now, some comments and questions:

1. You've created too many categories for all to work effectively in a standard game as we know it - there would theoretically be less than two CS per type for everyone to fight over. I dread to consider what a Maritime would go for in competitive bidding under those circumstances.

2. Some of the new categories seem like such minor variations on each other, that I'm not sure whether they're worth differentiating. Diplomatic is effectively a subset of Commercial, and it would need to offer a very good value to ever be chosen.

3. Categories like Productive, Progressive, and Prosperous would also need to be very cheap to be worthwhile - and if they were that cheap, would probably be on a different, unrealistic scale. I also have a hard time understanding all but Progressive intuitively.

4. Commercial and Intellectual sound really good, though!

5. Why do you differentiate between Lesser Civs and CS - for future development as quasi-vassal states? If so, why not wait until those features are developed? At the moment it's more likely to lead to confusion.

6. Why did the Basques get bumped down to CS status?
 
Would it be possible to make a city-state you're allied with always request a connection?

No, we have no control over the citystate quest system other than a small handful of probabilities to get particular quests. It's very simplistic and randomized.
 
I have been following the progress of your mod, and hope it continues. Its potential is huge. Now, some comments and questions:

1. You've created too many categories for all to work effectively in a standard game as we know it - there would theoretically be less than two CS per type for everyone to fight over. I dread to consider what a Maritime would go for in competitive bidding under those circumstances.

2. Some of the new categories seem like such minor variations on each other, that I'm not sure whether they're worth differentiating. Diplomatic is effectively a subset of Commercial, and it would need to offer a very good value to ever be chosen.

3. Categories like Productive, Progressive, and Prosperous would also need to be very cheap to be worthwhile - and if they were that cheap, would probably be on a different, unrealistic scale. I also have a hard time understanding all but Progressive intuitively.

4. Commercial and Intellectual sound really good, though!

5. Why do you differentiate between Lesser Civs and CS - for future development as quasi-vassal states? If so, why not wait until those features are developed? At the moment it's more likely to lead to confusion.

6. Why did the Basques get bumped down to CS status?
I don't think we should be discussing this in Thal's thread.
(I'm still answering it here, as I don't know if you're reading mine. Sorry Thal.)
  1. The bonuses are meant to be equal. That's what Thal is trying to do for the vanilla traits and I'll try to do for mine. If the maritimes are still the holy grail for people, that's either a psychological leftover or we still need to tweak the bonuses.
    What might have to happen is that the values of all traits need to be upped, since you're no longer stacking the bonuses of 4 CSes with the same trait, but maybe 2. I'm not sure if that's true or it's just a weird thought that came into my head.
  2. I don't want to hide behind broken game mechanics, but Diplomacy (influence) should not equal gold gifts. Gazebo's CSD solves that to some extend.
  3. I don't understand this one. Are you saying that their bonuses should be a multitude of what they are now to have a noticeable impact? And how come prod and pros aren't intuitive and prog is? I always feared prog would be the least understood.
  4. Thanks.
  5. Yes, it's a future project. I started on it because at the time I didn't know how to do the traits. I'm not an actual programmer, so I do things as I learn how to do them, instead of in well defined projects.
    It's confusing, I know, and it bothers me. I could keep it out for the moment, but then some people will miss it. I could maybe more clearly state it's an 'empty box' for the time being. I could also incorporate Gedemon's Mercenaries mod for them, which was the original plan, back in October (temporarily, until I code the elaborate version). I don't think the AI could do anything with it though, same goes for the elaborate version, which is why it's not for tomorrow.
  6. The Basques always were a normal CS.
 
Back
Top Bottom