This change didn't work for me, still getting the CTD
He has replied, he said he is has been busy and will get round to fixing the issues.
I commented out all the lines in that function and that problem didn't happen.
This change didn't work for me, still getting the CTD
He has replied, he said he is has been busy and will get round to fixing the issues.
I commented out all the lines in that function and that problem didn't happen.
function UnitGainScience(iPlayer, iCity, iUnit, bGold, bFaith)
local player = Players[iPlayer]
local pUnit = player:GetUnitByID(iUnit)
local policyID = GameInfoTypes["POLICY_MILITARY_CASTE"]
if (player:HasPolicy(policyID) and pUnit:IsCombatUnit()) then
-- print("New unit built!")
local team = Teams[player:GetTeam()]
local teamTechs = team:GetTeamTechs()
local currentTech = player:GetCurrentResearch()
local researchProgress = teamTechs:GetResearchProgress(currentTech)
local pUnitStrength = pUnit:GetBaseCombatStrength()
local adjustedBonus = pUnitStrength*1
-- Give the Science
if teamTechs ~= nil then
teamTechs:SetResearchProgress(currentTech, researchProgress + adjustedBonus)
end
-- Send a notification to the player
-- if player:IsHuman()then
-- local text = Locale.ConvertTextKey("TXT_KEY_SP_POLICY_SCIENCE_FROM_UNIT", tostring(adjustedBonus), pUnit:GetName())
-- player:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, text, text)
-- end
end
end
GameEvents.CityTrained.Add(UnitGainScience)
Unfortunately I don't think that's the issue. I changed the script, but I still got a CTD.
I'm also pretty sure that the crashes are caused by unit casualties trying to be applied to cities with only 1 population, I tested this by doing a fast 1v1 duel map, built 4 cities, set them all to avoid growth, built a ton of units and sent them to suicide against the enemy civ. My capital was the only city at the start to have more than one pop, and when casualties did occur, they were taken from my capital. Eventually even it had only 1 population, and the next time (I assume) casualties happened, boom, CTD.
Hope this helps.
It was eryu's solution, not mine, I was asking if that was the right function to comment out lol. Glad it works though, I'm looking forward to a long game with this mod.
This looks like a null pointer exception. It's trying to reference a "defending unit" to get it's X coordinate and complains because it couldn't find that object. Assuming your error log reads from top to bottom, I'm just wondering if that may have something to do with adding another war casualty to a city with 0 (or 1) population?
It looks like you attacked a French army and caused a citizen death in Lyon. If Lyon has 1 citizen and you kill a military unit, does the city disappear or is this edge case taken care of in the code?
Looking into the release note, the casualties are supposed to happen at random. If one of the cities is randomly chosen upon a unit death to subtract a citizen from, that's an easy place to forget excluding those cities with only 1 population.
But it's likely that Firaxis added some protection to the subtractCitizen operation, for starving cities with 1 population. If lincoln is using his own scripts for casualties, it might be a good idea to double-check if it's protected (e.g. numCitizens = max(numCitizen--, 1)).
I think I found a solution to the CTDs that are happening around turn 200. It seems to happen when an AI civ with the "military caste" policy builds a unit and is awarded bonus science. With this work-around, I'm unsure if it will fix everyone's CTDs or if the policy will still work as intended. But, it did fix my game and the world now cowers under the mighty heel of the Songhai empire. Hope it works for you guys, too.
To fix your game:
- Use a text editor like notepad to open Documents\my games\Sid Meier's Civilization 5\MODS\Super Power Balance (v 4)\Lua\New Trait and Policies.lua
- Replace line 222 with the three lines of code below
Replace
withCode:[s]teamTechs:SetResearchProgress(currentTech, researchProgress + adjustedBonus)[/s]
Code:if teamTechs ~= nil then teamTechs:SetResearchProgress(currentTech, researchProgress + adjustedBonus) end
@op - great job on this mod, man. lots of fun.
I think I found a solution to the CTDs that are happening around turn 200. It seems to happen when an AI civ with the "military caste" policy builds a unit and is awarded bonus science. With this work-around, I'm unsure if it will fix everyone's CTDs or if the policy will still work as intended. But, it did fix my game and the world now cowers under the mighty heel of the Songhai empire. Hope it works for you guys, too.
To fix your game:
- Use a text editor like notepad to open Documents\my games\Sid Meier's Civilization 5\MODS\Super Power Balance (v 4)\Lua\New Trait and Policies.lua
- Replace line 222 with the three lines of code below
Replace
withCode:[s]teamTechs:SetResearchProgress(currentTech, researchProgress + adjustedBonus)[/s]
Code:if teamTechs ~= nil then teamTechs:SetResearchProgress(currentTech, researchProgress + adjustedBonus) end
@op - great job on this mod, man. lots of fun.
I also downloaded the patch you made. Replaced the LUA as you said, I made it 3 more turns then a hard crash. I rebooted and cleared the cache just in case still a
NO-GO. I love the new mod but I am about to uninstall it too frustrating.
Good News guys. I'm finishing up the Mod 4.1 version which focusing on reducing crash problems and killing lots of Bugs. If lucky I could release it on this Saturday.
Thanks all for report and sorry for the Bugs. I'll reply you all when I have time.