Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ldvhl_Squamish_Functions.lua
- -- Author: DMS
- --==========================================================================================================================
- -- includes
- --==========================================================================================================================
- include("PlotIterators.lua")
- --==========================================================================================================================
- -- UTILITIES
- --==========================================================================================================================
- -- JFD_IsCivilisationActive
- ----------------------------------------------------------------------------------------------------------------------------
- function JFD_IsCivilisationActive(civilisationID)
- for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
- local slotStatus = PreGame.GetSlotStatus(iSlot)
- if (slotStatus == SlotStatus["SS_TAKEN"] or slotStatus == SlotStatus["SS_COMPUTER"]) then
- if PreGame.GetCivilization(iSlot) == civilisationID then
- return true
- end
- end
- end
- return false
- end
- ----------------------------------------------------------------------------------------------------------------------------
- -- JFD_GetRandom
- --------------------------------------------------------------------------------------------------------------------------
- function JFD_GetRandom(lower, upper)
- return Game.Rand((upper + 1) - lower, "") + lower
- end
- ------------------------------------------------------------------------------------------------------------------------
- -- JFD_SendNotification
- ------------------------------------------------------------------------------------------------------------------------
- function JFD_SendNotification(playerID, notificationType, description, descriptionShort, global, iX, iY)
- local player = Players[playerID]
- if global then
- Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes[notificationType], description, descriptionShort, iX or -1, iY or -1)
- else
- if player:IsHuman() then
- Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes[notificationType], description, descriptionShort, iX or -1, iY or -1)
- end
- end
- end
- ----------------------------------------------------------------------------------------------------------------------------
- -- JFD_GetEraAdjustedValue
- ----------------------------------------------------------------------------------------------------------------------------
- function JFD_GetEraAdjustedValue(playerID, num)
- local player = Players[playerID]
- local currentEraID = player:GetCurrentEra()
- local eraMod = GameInfo.Eras[currentEraID].ResearchAgreementCost
- return math.ceil(num * eraMod/100)
- end
- ----------------------------------------------------------------------------------------------------------------------------
- -- Globals
- ----------------------------------------------------------------------------------------------------------------------------
- local activePlayerID = Game.GetActivePlayer()
- local activePlayer = Players[activePlayerID]
- local activePlayerTeam = Teams[Game.GetActiveTeam()]
- local civilisationSquamishID = GameInfoTypes["CIVILIZATION_LDVHL_SQUAMISH"]
- local isSquamishCivActive = JFD_IsCivilisationActive(civilisationSquamishID)
- local isSquamishActivePlayer = activePlayer:GetCivilizationType() == civilisationSquamishID
- -- unique components
- local buildingSacredPalmsID = GameInfoTypes["BUILDING_LDVHL_POTLATCH_HOUSE"]
- local unitSabuNagibID = GameInfoTypes["BUILDING_LDVHL_LANGUAGE_SCHOOL"]
- if isSquamishCivActive then
- print("Sahpluk of the Squamish joins the game!")
- end
- --==========================================================================================================================
- -- MAIN FUNCTIONS
- --==========================================================================================================================
- local squamishID = GameInfoTypes.CIVILIZATION_LDVHL_SQUAMISH
- local goldBoost = GameInfoTypes.BUILDING_LDVHL_SQUAMISH_GOLD
- function SquamishWLTKD(playerID)
- local player = Players[playerID]
- if (player:IsAlive() and player:GetCivilizationType() == squamishID) then
- for city in player:Cities() do
- if city:GetWeLoveTheKingDayCounter() > 0 then
- if (not city:IsHasBuilding(goldBoost)) then
- city:SetNumRealBuilding(goldBoost, 1)
- end
- else
- if city:IsHasBuilding(goldBoost) then
- city:SetNumRealBuilding(goldBoost, 0)
- end
- end
- end
- end
- end
- GameEvents.PlayerDoTurn.Add(SquamishWLTKD)
- local squamishHappiness = GameInfoTypes.BUILDING_DVH_SQUAMISH_HAPPINESS
- function SquamishHappiness(playerID, cityID, unitID, isGold)
- local player = Players[playerID]
- if (player:IsAlive() and player:GetCivilizationType() == squamishID) then
- if isGold then
- local city = player:GetCityByID(cityID)
- local num = city:GetNumRealBuilding(squamishHappiness)
- city:SetNumRealBuilding(squamishHappiness, num + 1)
- end
- end
- GameEvents.CityConstructed.Add(SquamishHappiness)
- local potlatchHouse = GameInfoTypes.BUILDING_LDVHL_POTLATCH_HOUSE
- local phCulture = GameInfoTypes.BUILDING_LDVHL_POTLATCH_HOUSE_CULTURE
- function SquamishPotlatchHouse(playerID)
- local player = Players[playerID]
- if (player:IsAlive() and player:GetCivilizationType() == squamishID) then
- for city in player:Cities() do
- if city:IsHasBuilding(potlatchHouse) then
- local culture = math.floor(player:CountNumBuildings(potlatchHouse) / 3)
- city:SetNumRealBuilding(phCulture, culture)
- end
- end
- end
- end
- GameEvents.PlayerDoTurn.Add(SquamishPotlatchHouse)
- ----------------------------------------------------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement