Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------------------------------------------------------------------------------
- --NCR's Decisions
- --concept by Kramer, code by Vicevirtuoso, original Events & Decisions code by sukritact
- --------------------------------------------------------------------------------------------------------------------------------------------
- local MINT = GameInfoTypes.BUILDING_MINT
- local CURRENCY_POLICY = GameInfoTypes.POLICY_DECISIONS_NCR_CURRENCY
- --------------------------------------------------------------------------------------------------------------------------------------------
- --Decision 1: Implement Paper Currency
- --------------------------------------------------------------------------------------------------------------------------------------------
- local Decisions_NCRCurrency = {}
- Decisions_NCRCurrency.Name = "TXT_KEY_DECISIONS_FALLOUT_NCR_CURRENCY"
- Decisions_NCRCurrency.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_NCR_CURRENCY_DESC")
- HookDecisionCivilizationIcon(Decisions_NCRCurrency, "CIVILIZATION_FALLOUT_NCR")
- Decisions_NCRCurrency.CanFunc = (
- function(pPlayer)
- if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_FALLOUT_NCR) then
- return false, false
- end
- if load(pPlayer, "Decisions_NCRCurrency") then
- Decisions_NCRCurrency.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_NCR_CURRENCY_ENACTED_DESC")
- return false, false, true
- end
- local iGold = math.ceil(500 * iMod)
- Decisions_NCRCurrency.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_NCR_CURRENCY_DESC", iGold)
- if pPlayer:GetGold() < iGold then return true, false end
- if (pPlayer:GetNumResourceAvailable(iMagistrate, false) < 2) then return true, false end
- local pTeam = Teams[pPlayer:GetTeam()]
- if pTeam:IsHasTech(GameInfoTypes.TECH_PRINTING_PRESS) then
- return true, true
- else
- return true, false
- end
- end
- )
- Decisions_NCRCurrency.DoFunc = (
- function(pPlayer)
- local pCapital = pPlayer:GetCapitalCity()
- if pCapital then
- local iGold = math.ceil(500 * iMod)
- pPlayer:ChangeGold(-iGold)
- pPlayer:ChangeNumResourceTotal(iMagistrate, -2)
- pPlayer:SetNumFreePolicies(1)
- pPlayer:SetNumFreePolicies(0)
- pPlayer:SetHasPolicy(CURRENCY_POLICY, true)
- for pCity in pPlayer:Cities() do
- if pCity:IsHasBuilding(MINT) then
- local sKey = "Decisions_NCRCurrency" .. CompileCityID(pCity)
- save(pPlayer, sKey, true)
- pPlayer:ChangeNumResourceTotal(iMagistrate, 1)
- end
- end
- save(pPlayer, "Decisions_NCRCurrency", true)
- end
- end
- )
- Decisions_NCRCurrency.Monitors = {}
- Decisions_NCRCurrency.Monitors[GameEvents.CityConstructed] = (
- function(iPlayer, iCity, iBuildingType)
- if iBuildingType == MINT and iPlayer < GameDefines.MAX_MAJOR_CIVS then
- local pPlayer = Players[iPlayer]
- if load(pPlayer, "Decisions_NCRCurrency") == true then
- local pCity = pPlayer:GetCityByID(iCity)
- local sKey = "Decisions_NCRCurrency" .. CompileCityID(pCity)
- if not load(pPlayer, sKey) then
- save(pPlayer, sKey, true)
- pPlayer:ChangeNumResourceTotal(iMagistrate, 1)
- end
- end
- end
- end
- )
- Decisions_AddCivilisationSpecific(GameInfoTypes.CIVILIZATION_FALLOUT_NCR, "Decisions_NCRCurrency", Decisions_NCRCurrency)
- --------------------------------------------------------------------------------------------------------------------------------------------
- --Decision 2: Unify With the Desert Rangers
- --------------------------------------------------------------------------------------------------------------------------------------------
- local Decisions_NCRDesertRangers = {}
- Decisions_NCRDesertRangers.Name = "TXT_KEY_DECISIONS_FALLOUT_NCR_RANGERS"
- Decisions_NCRDesertRangers.Desc = "TXT_KEY_DECISIONS_FALLOUT_NCR_RANGERS_DESC"
- HookDecisionCivilizationIcon(Decisions_NCRDesertRangers, "CIVILIZATION_FALLOUT_NCR")
- Decisions_NCRDesertRangers.CanFunc = (
- function(pPlayer)
- if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_FALLOUT_NCR) then
- return false, false
- end
- if load(pPlayer, "Decisions_NCRDesertRangers") == true then
- Decisions_NCRDesertRangers.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_NCR_RANGERS_ENACTED_DESC")
- return false, false, true
- end
- local iGoldCost = math.ceil(1500 * iMod)
- Decisions_NCRDesertRangers.Desc = Locale.ConvertTextKey("TXT_KEY_DECISIONS_FALLOUT_NCR_RANGERS_DESC", iGoldCost)
- if pPlayer:GetGold() < iGoldCost then return true, false end
- if (pPlayer:GetNumResourceAvailable(iMagistrate, false) < 2) then return true, false end
- local pTeam = Teams[pPlayer:GetTeam()]
- if not pTeam:IsHasTech(GameInfoTypes.TECH_REPLACEABLE_PARTS) then
- return true, false
- end
- local pCapital = pPlayer:GetCapitalCity()
- if pCapital then
- local pPlot = pCapital:Plot()
- if pPlot then
- for c = 0, pPlot:GetNumUnits() - 1 do
- local pUnit = pPlot:GetUnit(c)
- if pUnit and pUnit:GetUnitClassType() == GameInfoTypes.UNITCLASS_GREAT_GENERAL then
- return true, true
- end
- end
- end
- end
- return true, false
- end
- )
- Decisions_NCRDesertRangers.DoFunc = (
- function(pPlayer)
- local pCapital = pPlayer:GetCapitalCity()
- if pCapital then
- local pPlot = pCapital:Plot()
- if not pPlot then return end
- local iGoldCost = math.ceil(1500 * iMod)
- local iMagistrateCost = 2
- pPlayer:ChangeGold(-iGoldCost)
- pPlayer:ChangeNumResourceTotal(iMagistrate, -iMagistrateCost)
- local iUnit;
- local iUnitType;
- if pPlot then
- for c = 0, pPlot:GetNumUnits() - 1 do
- local pUnit = pPlot:GetUnit(c)
- if pUnit and pUnit:GetUnitClassType() == GameInfoTypes.UNITCLASS_GREAT_GENERAL then
- iUnit = pUnit:GetID()
- iUnitType = pUnit:GetUnitType()
- end
- end
- end
- local bIsDVMC = false
- if GameInfo.CustomModOptions then
- for row in GameInfo.CustomModOptions() do
- if row.Name == "EVENTS_GREAT_PEOPLE" and row.Value == 1 then
- bIsDVMC = true
- break
- end
- end
- end
- if bIsDVMC then
- GameEvents.GreatPersonExpended.Call(pPlayer:GetID(), iUnit, iUnitType, pPlot:GetX(), pPlot:GetY())
- else
- GameEvents.GreatPersonExpended.Call(pPlayer:GetID(), iUnitType)
- end
- local Unit1 = pPlayer:InitUnit(GameInfoTypes.UNIT_FALLOUT_RANGER, pPlot:GetX(), pPlot:GetY(), UNITAI_ATTACK)
- Unit1:JumpToNearestValidPlot()
- local Unit2 = pPlayer:InitUnit(GameInfoTypes.UNIT_FALLOUT_RANGER, pPlot:GetX(), pPlot:GetY(), UNITAI_ATTACK)
- Unit2:JumpToNearestValidPlot()
- local Unit3 = pPlayer:InitUnit(GameInfoTypes.UNIT_FALLOUT_VET_RANGER, pPlot:GetX(), pPlot:GetY(), UNITAI_ATTACK)
- Unit3:JumpToNearestValidPlot()
- --To figure out how much XP to give it, we'll set it to 4, get the XP it needs to get to 5 from the DLL (it's not in game defines, apparently), set it to have that much XP, then set it back to level 1
- Unit3:SetLevel(4)
- Unit3:SetExperience(Unit3:ExperienceNeeded())
- Unit3:SetLevel(1)
- Unit3:SetPromotionReady(true)
- save(pPlayer, "Decisions_NCRDesertRangers", true)
- end
- end
- )
- Decisions_AddCivilisationSpecific(GameInfoTypes.CIVILIZATION_FALLOUT_NCR, "Decisions_NCRDesertRangers", Decisions_NCRDesertRangers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement