Advertisement
Guest User

ldhvl_Squamish_Functions.lua

a guest
Sep 7th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.83 KB | None | 0 0
  1. -- ldvhl_Squamish_Functions.lua
  2. -- Author: DMS
  3. --==========================================================================================================================
  4. -- includes
  5. --==========================================================================================================================
  6. include("PlotIterators.lua")
  7. --==========================================================================================================================
  8. -- UTILITIES
  9. --==========================================================================================================================
  10. -- JFD_IsCivilisationActive
  11. ----------------------------------------------------------------------------------------------------------------------------
  12. function JFD_IsCivilisationActive(civilisationID)
  13.     for iSlot = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
  14.         local slotStatus = PreGame.GetSlotStatus(iSlot)
  15.         if (slotStatus == SlotStatus["SS_TAKEN"] or slotStatus == SlotStatus["SS_COMPUTER"]) then
  16.             if PreGame.GetCivilization(iSlot) == civilisationID then
  17.                 return true
  18.             end
  19.         end
  20.     end
  21.  
  22.     return false
  23. end
  24. ----------------------------------------------------------------------------------------------------------------------------
  25. -- JFD_GetRandom
  26. --------------------------------------------------------------------------------------------------------------------------
  27. function JFD_GetRandom(lower, upper)
  28.     return Game.Rand((upper + 1) - lower, "") + lower
  29. end
  30. ------------------------------------------------------------------------------------------------------------------------
  31. -- JFD_SendNotification
  32. ------------------------------------------------------------------------------------------------------------------------
  33. function JFD_SendNotification(playerID, notificationType, description, descriptionShort, global, iX, iY)
  34.     local player = Players[playerID]
  35.     if global then
  36.             Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes[notificationType], description, descriptionShort, iX or -1, iY or -1)
  37.     else
  38.         if player:IsHuman() then
  39.             Players[Game.GetActivePlayer()]:AddNotification(NotificationTypes[notificationType], description, descriptionShort, iX or -1, iY or -1)
  40.         end
  41.     end
  42. end
  43. ----------------------------------------------------------------------------------------------------------------------------
  44. -- JFD_GetEraAdjustedValue
  45. ----------------------------------------------------------------------------------------------------------------------------
  46. function JFD_GetEraAdjustedValue(playerID, num)
  47.     local player = Players[playerID]
  48.     local currentEraID = player:GetCurrentEra()
  49.     local eraMod = GameInfo.Eras[currentEraID].ResearchAgreementCost
  50.     return math.ceil(num * eraMod/100)
  51. end
  52. ----------------------------------------------------------------------------------------------------------------------------
  53. -- Globals
  54. ----------------------------------------------------------------------------------------------------------------------------
  55. local activePlayerID                        = Game.GetActivePlayer()
  56. local activePlayer                          = Players[activePlayerID]
  57. local activePlayerTeam                      = Teams[Game.GetActiveTeam()]
  58. local civilisationSquamishID                = GameInfoTypes["CIVILIZATION_LDVHL_SQUAMISH"]
  59. local isSquamishCivActive                   = JFD_IsCivilisationActive(civilisationSquamishID)
  60. local isSquamishActivePlayer                = activePlayer:GetCivilizationType() == civilisationSquamishID
  61. -- unique components
  62. local buildingSacredPalmsID                 = GameInfoTypes["BUILDING_LDVHL_POTLATCH_HOUSE"]
  63. local unitSabuNagibID                       = GameInfoTypes["BUILDING_LDVHL_LANGUAGE_SCHOOL"]
  64.  
  65. if isSquamishCivActive then
  66.     print("Sahpluk of the Squamish joins the game!")
  67. end
  68. --==========================================================================================================================
  69. -- MAIN FUNCTIONS  
  70. --==========================================================================================================================
  71. local squamishID = GameInfoTypes.CIVILIZATION_LDVHL_SQUAMISH
  72. local goldBoost = GameInfoTypes.BUILDING_LDVHL_SQUAMISH_GOLD
  73.  
  74. function SquamishWLTKD(playerID)
  75.     local player = Players[playerID]
  76.     if (player:IsAlive() and player:GetCivilizationType() == squamishID) then
  77.         for city in player:Cities() do
  78.             if city:GetWeLoveTheKingDayCounter() > 0 then
  79.                 if (not city:IsHasBuilding(goldBoost)) then
  80.                     city:SetNumRealBuilding(goldBoost, 1)
  81.                 end
  82.             else
  83.                 if city:IsHasBuilding(goldBoost) then
  84.                     city:SetNumRealBuilding(goldBoost, 0)
  85.                 end
  86.             end
  87.         end
  88.     end
  89. end
  90.  
  91. GameEvents.PlayerDoTurn.Add(SquamishWLTKD)
  92.  
  93. local squamishHappiness = GameInfoTypes.BUILDING_DVH_SQUAMISH_HAPPINESS
  94.  
  95. function SquamishHappiness(playerID, cityID, unitID, isGold)
  96.     local player = Players[playerID]
  97.     if (player:IsAlive() and player:GetCivilizationType() == squamishID) then
  98.     if isGold then
  99.         local city = player:GetCityByID(cityID)
  100.         local num = city:GetNumRealBuilding(squamishHappiness)
  101.         city:SetNumRealBuilding(squamishHappiness, num + 1)
  102.     end
  103. end
  104.  
  105. GameEvents.CityConstructed.Add(SquamishHappiness)
  106.  
  107. local potlatchHouse = GameInfoTypes.BUILDING_LDVHL_POTLATCH_HOUSE
  108. local phCulture = GameInfoTypes.BUILDING_LDVHL_POTLATCH_HOUSE_CULTURE
  109.  
  110. function SquamishPotlatchHouse(playerID)
  111.     local player = Players[playerID]
  112.     if (player:IsAlive() and player:GetCivilizationType() == squamishID) then
  113.         for city in player:Cities() do
  114.             if city:IsHasBuilding(potlatchHouse) then
  115.                 local culture = math.floor(player:CountNumBuildings(potlatchHouse) / 3)
  116.                 city:SetNumRealBuilding(phCulture, culture)
  117.             end
  118.         end
  119.     end
  120. end
  121.  
  122. GameEvents.PlayerDoTurn.Add(SquamishPotlatchHouse)
  123. ----------------------------------------------------------------------------------------------------------------------------
  124. ----------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement