Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------------------------------------------------------------------------------
- --Legion's Decisions
- --concept by Kramer, code by Vicevirtuoso, original Events & Decisions code by sukritact
- --------------------------------------------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------------------------------------------------
- --Decision 1: Establish the Frumentarii
- --------------------------------------------------------------------------------------------------------------------------------------------
- local FRUMENTARII_POLICY = GameInfoTypes.POLICY_DECISIONS_LEGION_FRUMENTARII --for Spy efficacy modifier
- local FRUMENTARII_BUILDING = GameInfoTypes.BUILDING_DECISIONS_LEGION_FRUMENTARII --for free Spy itself
- local Decisions_LegionFrumentarii = {}
- Decisions_LegionFrumentarii.Name = "TXT_KEY_DECISIONS_FALLOUT_LEGION_FRUMENTARII"
- Decisions_LegionFrumentarii.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_LEGION_FRUMENTARII_DESC")
- HookDecisionCivilizationIcon(Decisions_LegionFrumentarii, "CIVILIZATION_FALLOUT_LEGION")
- Decisions_LegionFrumentarii.CanFunc = (
- function(pPlayer)
- if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_FALLOUT_LEGION) then
- return false, false
- end
- if load(pPlayer, "Decisions_LegionFrumentarii") then
- Decisions_LegionFrumentarii.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_LEGION_FRUMENTARII_ENACTED_DESC")
- return false, false, true
- end
- Decisions_LegionFrumentarii.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_LEGION_FRUMENTARII_DESC")
- if (pPlayer:GetNumResourceAvailable(iMagistrate, false) < 2) then return true, false end
- if pPlayer:GetCurrentEra() >= GameInfoTypes.ERA_RENAISSANCE then
- return true, true
- else
- return true, false
- end
- end
- )
- Decisions_LegionFrumentarii.DoFunc = (
- function(pPlayer)
- local pCapital = pPlayer:GetCapitalCity()
- if pCapital then
- pPlayer:ChangeNumResourceTotal(iMagistrate, -2)
- pPlayer:SetNumFreePolicies(1)
- pPlayer:SetNumFreePolicies(0)
- pPlayer:SetHasPolicy(FRUMENTARII_POLICY, true)
- pCapital:SetNumRealBuilding(FRUMENTARII_BUILDING, true)
- save(pPlayer, "Decisions_LegionFrumentarii", true)
- end
- end
- )
- Decisions_AddCivilisationSpecific(GameInfoTypes.CIVILIZATION_FALLOUT_LEGION, "Decisions_LegionFrumentarii", Decisions_LegionFrumentarii)
- --------------------------------------------------------------------------------------------------------------------------------------------
- --Decision 2: Repair Howitzer Garrison
- --------------------------------------------------------------------------------------------------------------------------------------------
- local SIEGE = GameInfoTypes.UNITCOMBAT_SIEGE
- local SIEGE_PROMO = GameInfoTypes.PROMOTION_FALLOUT_LEGION_HOWITZER
- local iMaxCivs = GameDefines.MAX_MAJOR_CIVS
- local tLegionD2Improvements = {
- [GameInfoTypes.IMPROVEMENT_CITADEL] = true,
- [GameInfoTypes.IMPROVEMENT_FORT] = true,
- [GameInfoTypes.IMPROVEMENT_KASBAH] = true, --I figure UIs that provide defense should count as forts here
- [GameInfoTypes.IMPROVEMENT_CHATEAU] = true, --see above
- [GameInfoTypes.IMPROVEMENT_LEGIONARY_FORT] = true --or whatever its GameInfoType is
- }
- function LegionHowitzerCheck(pUnit)
- if pUnit:GetUnitCombatType() == SIEGE then
- local pPlot = pUnit:GetPlot()
- if pPlot:IsCity() or tLegionD2Improvements[pPlot:GetImprovementType()] then
- pUnit:SetHasPromotion(SIEGE_PROMO, true)
- else
- pUnit:SetHasPromotion(SIEGE_PROMO, false)
- end
- else
- pUnit:SetHasPromotion(SIEGE_PROMO, false)
- end
- end
- local Decisions_LegionHowitzer = {}
- Decisions_LegionHowitzer.Name = "TXT_KEY_DECISIONS_FALLOUT_LEGION_HOWITZER"
- Decisions_LegionHowitzer.Desc = "TXT_KEY_DECISIONS_FALLOUT_LEGION_HOWITZER_DESC"
- HookDecisionCivilizationIcon(Decisions_LegionHowitzer, "CIVILIZATION_FALLOUT_LEGION")
- Decisions_LegionHowitzer.CanFunc = (
- function(pPlayer)
- if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_FALLOUT_LEGION) then
- return false, false
- end
- if load(pPlayer, "Decisions_LegionHowitzer") == true then
- Decisions_LegionHowitzer.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_LEGION_HOWITZER_ENACTED_DESC")
- return false, false, true
- end
- local iGoldCost = math.ceil(650 * iMod)
- Decisions_LegionHowitzer.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_LEGION_HOWITZER_DESC", iGoldCost)
- if pPlayer:GetGold() < iGoldCost then return true, false end
- if (pPlayer:GetNumResourceAvailable(iMagistrate, false) < 1) then return true, false end
- local pTeam = Teams[pPlayer:GetTeam()]
- if pTeam:IsHasTech(GameInfoTypes.TECH_MILITARY_SCIENCE) then
- return true, true
- else
- return true, false
- end
- end
- )
- Decisions_LegionHowitzer.DoFunc = (
- function(pPlayer)
- local pCapital = pPlayer:GetCapitalCity()
- if pCapital then
- local pPlot = pCapital:Plot()
- if not pPlot then return end
- local iGoldCost = math.ceil(650 * iMod)
- local iMagistrateCost = 1
- pPlayer:ChangeGold(-iGoldCost)
- pPlayer:ChangeNumResourceTotal(iMagistrate, -iMagistrateCost)
- local pUnit = pPlayer:InitUnit(GameInfoTypes.UNIT_ARTILLERY, pPlot:GetX(), pPlot:GetY(), UNITAI_ATTACK)
- pUnit:JumpToNearestValidPlot()
- for pUnit in pPlayer:Units() do
- LegionHowitzerCheck(pUnit)
- end
- save(pPlayer, "Decisions_LegionHowitzer", true)
- end
- end
- )
- Decisions_LegionFrumentarii.Monitors = {}
- Decisions_LegionFrumentarii.Monitors[GameEvents.UnitSetXY] = (
- function(iPlayer, iUnit, iX, iY)
- if iX > 0 and iY > 0 and iPlayer < iMaxCivs then
- local pPlayer = Players[iPlayer]
- if load(pPlayer, "Decisions_LegionHowitzer") == true then
- local pUnit = pPlayer:GetUnitByID(iUnit)
- if pUnit then
- LegionHowitzerCheck(pUnit)
- end
- end
- end
- end
- )
- Decisions_AddCivilisationSpecific(GameInfoTypes.CIVILIZATION_FALLOUT_LEGION, "Decisions_LegionHowitzer", Decisions_LegionHowitzer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement