Markvitank
Chieftain
- Joined
- Nov 26, 2018
- Messages
- 3
Yeah it looks like it should be part of the prohibition choice, but the sugar is received on the wild horses choice.
But the Prohibition Choice is granting the Sugar? Was this with the recent version or...?Yeah it looks like it should be part of the prohibition choice, but the sugar is received on the wild horses choice.
sorry ive been working on this indicated by progress here CBP E&D is likely to be done before New Years though if I finish CE before Christmas.Hey I was wondering how the progress doing so far
I know you said use the wiki to look at the progress however I can't really see the progress![]()
Unit:UpgradeTo(iUnitType, bIsFree)
function TheLastModder(iPlayer, iOldUnit, iNewUnit, bGoodyHut)
local pPlayer = Players[iPlayer]
local pUnit = pPlayer:GetUnitByID(iNewUnit)
if pUnit:GetUnitType() == iLancer then
if load(pPlayer, "Decisions_OttomanGunpowder") == true then
local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot()
pUnit:Kill(false, -1)
local iBringerofDeath = pPlayer:InitUnit(iSipahi, pPlot:GetX(), pPlot:GetY())
iBringerofDeath:JumpToNearestValidPlot()
iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience())
elseif load(pPlayer, "Decisions_SwedenIndelningsverket") == true then
local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot()
pUnit:Kill(false, -1)
local iBringerofDeath = pPlayer:InitUnit(iHakkapeliitta, pPlot:GetX(), pPlot:GetY())
iBringerofDeath:JumpToNearestValidPlot()
iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience())
end
elseif pUnit:GetUnitType() == iGalleasses then
if load(pPlayer, "Decisions_VenetianArsenale") == true then
local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot()
pUnit:Kill(false, -1)
local iBringerofDeath = pPlayer:InitUnit(iGalleass, pPlot:GetX(), pPlot:GetY())
iBringerofDeath:JumpToNearestValidPlot()
iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience())
end
elseif pUnit:GetUnitType() == iCrossbow then
if load(pPlayer, "Decisions_EnglishArmada") == true then
local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot()
pUnit:Kill(false, -1)
local iBringerofDeath = pPlayer:InitUnit(iLongbow, pPlot:GetX(), pPlot:GetY())
iBringerofDeath:JumpToNearestValidPlot()
iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience())
end
elseif pUnit:GetUnitType() == iCaravel then
if load(pPlayer, "Decisions_KoreanGunpowder") == true then
local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot()
pUnit:Kill(false, -1)
local iBringerofDeath = pPlayer:InitUnit(iTurtleShip, pPlot:GetX(), pPlot:GetY())
iBringerofDeath:JumpToNearestValidPlot()
iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience())
end
end
end
function TheLastModder(iPlayer, iOldUnit, iNewUnit, bGoodyHut)
local pPlayer = Players[iPlayer]
local pUnit = pPlayer:GetUnitByID(iNewUnit)
if pUnit:GetUnitType() == iLancer then
if load(pPlayer, "Decisions_OttomanGunpowder") == true then
local pBringerofDeath = pUnit:UpgradeTo(iSipahi, true)
pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true)
elseif load(pPlayer, "Decisions_SwedenIndelningsverket") == true then
local pBringerofDeath = pUnit:UpgradeTo(iHakkapeliitta, true)
pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true)
end
elseif pUnit:GetUnitType() == iGalleasses then
if load(pPlayer, "Decisions_VenetianArsenale") == true then
local pBringerofDeath = pUnit:UpgradeTo(iGalleass, true)
pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true)
end
elseif pUnit:GetUnitType() == iCrossbow then
if load(pPlayer, "Decisions_EnglishArmada") == true then
local pBringerofDeath = pUnit:UpgradeTo(iLongbow, true)
pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true)
end
elseif pUnit:GetUnitType() == iCaravel then
if load(pPlayer, "Decisions_KoreanGunpowder") == true then
local pBringerofDeath = pUnit:UpgradeTo(iTurtleShip, true)
pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true)
end
end
end
wow very basedA recent change in the DLL (by me) which comes with 3-14 is causing your unit upgrade Lua (for units unlocked by decisions) to cause a crash, due to the position of the UnitUpgraded Lua hook in the DLL.
In short, the original upgraded unit (eg Crossbowman rather than the Longbowman) is deleted before the DLL finishes processing it, causing an access violation error.
So looking through the available Lua methods in the DLL, I found a new one for CP, which works much better for what you need. It basically forces a unit to upgrade into something, even if it normally shouldn't be able to.
Code:Unit:UpgradeTo(iUnitType, bIsFree)
Unit is your unit instance, iUnitType is the unit to upgrade to (eg Longbowman), bIsFree is whether to charge the player gold.
There's also Convert, by Firaxis. It is how the XP and promotions are transferred inside the DLL; it transfers all attributes of the old unit to the new unit, eg name, all promotions, etc.
Previous code looks like this:
Code:function TheLastModder(iPlayer, iOldUnit, iNewUnit, bGoodyHut) local pPlayer = Players[iPlayer] local pUnit = pPlayer:GetUnitByID(iNewUnit) if pUnit:GetUnitType() == iLancer then if load(pPlayer, "Decisions_OttomanGunpowder") == true then local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot() pUnit:Kill(false, -1) local iBringerofDeath = pPlayer:InitUnit(iSipahi, pPlot:GetX(), pPlot:GetY()) iBringerofDeath:JumpToNearestValidPlot() iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience()) elseif load(pPlayer, "Decisions_SwedenIndelningsverket") == true then local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot() pUnit:Kill(false, -1) local iBringerofDeath = pPlayer:InitUnit(iHakkapeliitta, pPlot:GetX(), pPlot:GetY()) iBringerofDeath:JumpToNearestValidPlot() iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience()) end elseif pUnit:GetUnitType() == iGalleasses then if load(pPlayer, "Decisions_VenetianArsenale") == true then local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot() pUnit:Kill(false, -1) local iBringerofDeath = pPlayer:InitUnit(iGalleass, pPlot:GetX(), pPlot:GetY()) iBringerofDeath:JumpToNearestValidPlot() iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience()) end elseif pUnit:GetUnitType() == iCrossbow then if load(pPlayer, "Decisions_EnglishArmada") == true then local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot() pUnit:Kill(false, -1) local iBringerofDeath = pPlayer:InitUnit(iLongbow, pPlot:GetX(), pPlot:GetY()) iBringerofDeath:JumpToNearestValidPlot() iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience()) end elseif pUnit:GetUnitType() == iCaravel then if load(pPlayer, "Decisions_KoreanGunpowder") == true then local pPlot = pPlayer:GetUnitByID(iNewUnit):GetPlot() pUnit:Kill(false, -1) local iBringerofDeath = pPlayer:InitUnit(iTurtleShip, pPlot:GetX(), pPlot:GetY()) iBringerofDeath:JumpToNearestValidPlot() iBringerofDeath:SetExperience(pPlayer:GetUnitByID(iOldUnit):GetExperience()) end end end
New code looks like this:
Code:function TheLastModder(iPlayer, iOldUnit, iNewUnit, bGoodyHut) local pPlayer = Players[iPlayer] local pUnit = pPlayer:GetUnitByID(iNewUnit) if pUnit:GetUnitType() == iLancer then if load(pPlayer, "Decisions_OttomanGunpowder") == true then local pBringerofDeath = pUnit:UpgradeTo(iSipahi, true) pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true) elseif load(pPlayer, "Decisions_SwedenIndelningsverket") == true then local pBringerofDeath = pUnit:UpgradeTo(iHakkapeliitta, true) pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true) end elseif pUnit:GetUnitType() == iGalleasses then if load(pPlayer, "Decisions_VenetianArsenale") == true then local pBringerofDeath = pUnit:UpgradeTo(iGalleass, true) pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true) end elseif pUnit:GetUnitType() == iCrossbow then if load(pPlayer, "Decisions_EnglishArmada") == true then local pBringerofDeath = pUnit:UpgradeTo(iLongbow, true) pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true) end elseif pUnit:GetUnitType() == iCaravel then if load(pPlayer, "Decisions_KoreanGunpowder") == true then local pBringerofDeath = pUnit:UpgradeTo(iTurtleShip, true) pBringerofDeath:Convert(pPlayer:GetUnitByID(iOldUnit), true) end end end
Bonus is that it fixes the issue where the new unit is spawned at a hex next to the original unit.
I recommend posting a hotfix as this is causing a crash. As it is Lua, it is save game compatible.
To users of this mod: Though I'm not sure if my version is the same as the public version, I'll post a fix. Replace "...\MODS\(8) Events and Decisions (CBO) (v 14)\Core\Decisions\Civ Decisions\CivDecisions.lua" with the attached file.
I am really hoping for an update, i love this mod.
I am really hoping for an update, i love this mod.