• Civilization 7 has been announced. For more info please check the forum here .

Military CS gifting broken 10.1

gdwitt

Prince
Joined
Sep 27, 2010
Messages
359
Location
Austin, TX
I played 2 games in 10.0 then 2 in 10.1
Only 2 basic mods for latter 2 plus Thal. (single unit and stacking)

In last game, I allied with military city-state turn 25 and received a unit every turn, not every 5-8 as expected.
By turn 75, I was swimming in 50 donated units and was far beyond the unit cap.
Keep in mind I only had 1 militaristic ally.

This did not occur in my 10.0 trials.

Here's what i saw every turn:
TU - Event Registration: ERROR GiveMilitaristicRewards Catherine current=9 threshold=10
TU - Event Registration: ERROR GiveMilitaristicRewards Montezuma current=11 threshold=10

Catherine's values would go up and then drop back to 0. My (montezuma) rewards would stay at 11 throughout game.
 
I replayed this as Darius without Infoaddict.
The military gifting went appropriately for my side I believe, about every 10 turns while I had one militaristic ally.

TU - Event Registration: ERROR GiveMilitaristicRewards Montezuma current=2 threshold=10
TU - Event Registration: ERROR GiveMilitaristicRewards Darius I current=2 threshold=10
Unlike before Monte was going up and down with points.

Can you explain this?

TU - Event Registration: ERROR GiveMilitaristicRewards Montezuma current=5 threshold=5
TU - Event Registration: DEBUG Reward=UNIT_AZTEC_JAGUAR XP=30

TU - Event Registration: ERROR GiveMilitaristicRewards Catherine current=3 threshold=13
TU - Event Registration: ERROR GiveMilitaristicRewards Darius I current=6 threshold=5
TU - Event Registration: DEBUG Reward=UNIT_WARRIOR_SOUTH XP=30

Why would Catherine receive the units with a threshold of 13 and myself and monte only need a threshold of 5. By this point in the game I had 2 militaristic allies, but I only saw that monte had 1.
 
I played another playthrough with Montezumea using infoaddict and 10.1

At first, the gifts were appropriate, about every 10 turns.

TU - Event Registration: ERROR GiveMilitaristicRewards Montezuma current=3 threshold=10
TU - Event Registration: ERROR GiveMilitaristicRewards Montezuma current=4 threshold=10

After Angkor Wat, when I had about 4 militaristic friends only, I started getting units every turn. Is this to be expected?
Each of these tuner entries resulted in a unit reward:

TU - Event Registration: ERROR GiveMilitaristicRewards Montezuma current=5 threshold=3
TU - Event Registration: ERROR GiveMilitaristicRewards Montezuma current=5 threshold=3
TU - Event Registration: ERROR GiveMilitaristicRewards Montezuma current=5 threshold=4
 
This is very puzzling. The algorithm is simple:

PHP:
local milRewardCurrent = (LoadPlayer(player, "milRewardCurrent") or 0) + 1

if milRewardCurrent >= milRewardThreshold then
  milRewardCurrent = milRewardCurrent - milRewardThreshold
  -- give the free unit
end

SavePlayer(player, "milRewardCurrent", milRewardCurrent)
I'm not sure how it could fail to reset milRewardCurrent... I've been thinking about it two days but I'm stumped. I'll ask about it in the main modding forum.
 
How does the formula work with multiple militaristic city-state allies?
Could the 3 -4 allies themselves have caused me to go 2 past the threshold each turn?
Why does the threshold go down to 3 or 4?

Getting a unit every 2-3 turns doesn't seem to be a major problem like in the first game with Monte.
 
Could the 3 -4 allies themselves have caused me to go 2 past the threshold each turn?

Look at it again... milRewardCurrent only increments by +1 each turn. You can see the full agorithm in CiVUP - Events.lua.

How does the formula work with multiple militaristic city-state allies?
Spoiler :
PHP:
local rateMod = 0
for minorCivID,minorCiv in pairs(Players) do
  if IsValidPlayer(minorCiv) and minorCiv:IsMinorCiv() then
    local traitType = minorCiv:GetMinorCivTrait()
    if traitType == MinorCivTraitTypes.MINOR_CIV_TRAIT_MILITARISTIC then
      local friendLevel = minorCiv:GetMinorCivFriendshipLevelWithMajor(playerID)
      if friendLevel >= 1 then
        rateMod = rateMod + 0.75
      end
      if friendLevel >= 2 then
        rateMod = rateMod + 0.25
      end
    end
  end
end
if rateMod > 0 then
  local milRewardThreshold = UnofficialPatch.MINOR_CIV_MILITARISTIC_BASE_TURNS / rateMod
      milRewardThreshold = milRewardThreshold * GameInfo.GameSpeeds[Game.GetGameSpeedType()].TrainPercent / 100
  local milRewardCurrent = (LoadPlayer(player, "milRewardCurrent") or 0) + 1
  log:Error("%25s %15s current=%i threshold=%i new=%i", "GiveMilitaristicRewards", player:GetName(), milRewardCurrent, milRewardThreshold, milRewardCurrent - milRewardThreshold)
  if milRewardCurrent >= milRewardThreshold then
    milRewardCurrent = milRewardCurrent - milRewardThreshold
	
    -- gives free unit
  end
  SavePlayer(player, "milRewardCurrent", milRewardCurrent)
end
 
Top Bottom