Advertisement
Neirai

New Mythic Emblems

Nov 16th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.96 KB | None | 0 0
  1. -- Mythic Emblem powers. These are legion
  2. --------------------------------------------------------------
  3. include( "Sukritact_SaveUtils.lua" ); MY_MOD_NAME = "CLBeothukMythic";
  4. function RemoveCLBeoHidden()
  5.     for iPlayer = 0, GameDefines.MAX_MAJOR_CIVS - 1, 1 do
  6.         local pPlayer = Players[iPlayer]
  7.         if pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  8.             if pPlayer ~= nil then
  9.                 local iTeam = pPlayer:GetTeam()
  10.                 local pTeam = Teams[iTeam]
  11.                 if pTeam:IsHasTech(GameInfoTypes.TECH_CLBEOHIDDEN) then
  12.                     pTeam:SetHasTech(GameInfoTypes.TECH_CLBEOHIDDEN, false, pPlayer, false, false)
  13.                 end
  14.             end
  15.         end
  16.     end
  17. end
  18. RemoveCLBeoHidden()
  19.  
  20. function MythicShipPower(player)
  21.     local pPlayer = Players[player]
  22.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  23.         for pCity in pPlayer:Cities() do
  24.             if pCity:IsHasBuilding(GameInfoTypes.BUILDING_CLBEOSHIP) then
  25.                 local SeaLuxes = 0
  26.                 for pCityPlot = 0, pCity:GetNumCityPlots() - 1, 1 do
  27.                     local pSpecificPlot = pCity:GetCityIndexPlot(pCityPlot)
  28.                     if pSpecificPlot ~= nil then
  29.                         if pSpecificPlot:GetOwner() == pCity:GetOwner() then
  30.                             if pSpecificPlot:GetResourceType(-1) == GameInfoTypes.RESOURCE_PEARLS or pSpecificPlot:GetResourceType(-1) == GameInfoTypes.RESOURCE_CORAL or pSpecificPlot:GetResourceType(-1) == GameInfoTypes.RESOURCE_WHALE or pSpecificPlot:GetResourceType(-1) == GameInfoTypes.RESOURCE_CRAB then
  31.                                 SeaLuxes = SeaLuxes + 1
  32.                             end
  33.                         end
  34.                     end
  35.                 end
  36.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOSHIPPROD, SeaLuxes)
  37.             end
  38.         end
  39.     end
  40. end
  41. --PlayerDoTurn
  42.  
  43. function MythicHuntPower(player, city, unit)
  44.     print("Mythic Hunt Power Triggered")
  45.     local pPlayer = Players[player]
  46.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  47.         local pCity = pPlayer:GetCityByID(city)
  48.         local pUnit = pPlayer:GetUnitByID(unit)
  49.         if pCity:IsHasBuilding(GameInfoTypes.BUILDING_CLBEOHUNT) then
  50.             print("Unit domain is " .. pUnit:GetDomainType())
  51.             if pUnit:GetDomainType() == DomainTypes.DOMAIN_SEA then
  52.                 print("You made a boat! Have some culture")
  53.                 pPlayer:ChangeJONSCulture(2)
  54.                 if pPlayer:IsHuman() then
  55.                     Events.GameplayAlertMessage(Locale.ConvertTextKey("TXT_KEY_CLBEOTHUK_HUNT_NOTIFICATION", pCity:GetName()))
  56.                 end
  57.             end
  58.         end
  59.     end
  60. end
  61. --CityTrained
  62.  
  63. function MythicCouncilRequires(player)
  64.     local pPlayer = Players[player]
  65.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  66.         print("Council Requirements fired")
  67.         for pCity in pPlayer:Cities() do
  68.             if pCity:IsCapital() or pPlayer:IsCapitalConnectedToCity(pCity) then
  69.                 print("Connected city found!")
  70.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOCOUNCILREQ, 1)
  71.             else
  72.                 print("City is disconnected")
  73.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOCOUNCILREQ, 0)
  74.             end
  75.         end
  76.     end
  77. end
  78. --PlayerDoTurn
  79.  
  80. function MythicCouncilPower(player)
  81.     local pPlayer = Players[player]
  82.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  83.         for pCity in pPlayer:Cities() do
  84.             if pCity:IsHasBuilding(GameInfoTypes.BUILDING_CLBEOCOUNCIL) then
  85.                 local WorkUnits = 0
  86.                 for pCityPlot = 0, pCity:GetNumCityPlots() - 1, 1 do
  87.                     local pSpecificPlot = pCity:GetCityIndexPlot(pCityPlot)
  88.                     if pSpecificPlot ~= nil then
  89.                         if pSpecificPlot:GetOwner() == pCity:GetOwner() then
  90.                             if pSpecificPlot:GetImprovementType() == GameInfoTypes.IMPROVEMENT_FISHING_BOATS or pSpecificPlot:GetImprovementType() == GameInfoTypes.IMPROVEMENT_OFFSHORE_PLATFORM then
  91.                                 WorkUnits = WorkUnits + 1
  92.                             else
  93.                                 for  i = 0, pSpecificPlot:GetNumUnits() - 1, 1 do
  94.                                     local pUnit = pSpecificPlot:GetUnit(i)
  95.                                     if pUnit ~= nil then
  96.                                         if pUnit:GetUnitType() == GameInfoTypes.UNIT_WORKER then
  97.                                             WorkUnits = WorkUnits + 1
  98.                                         end
  99.                                     end
  100.                                 end
  101.                             end
  102.                         end
  103.                     end
  104.                 end
  105.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOGPPROD, WorkUnits)
  106.             end
  107.         end
  108.     end
  109. end
  110. --PlayerDoTurn
  111.  
  112. function MythicMoonRequires(player)
  113.     local pPlayer = Players[player]
  114.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  115.         for pCity in pPlayer:Cities() do
  116.             if pPlayer:HasCreatedPantheon() then
  117.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOMOONREQ, 1)
  118.             else
  119.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOMOONREQ, 0)
  120.             end
  121.         end
  122.     end
  123. end
  124. --PlayerDoTurn
  125.  
  126. function MythicMoonPower(player)
  127.     local pPlayer = Players[player]
  128.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  129.         for pCity in pPlayer:Cities() do
  130.             if pCity:IsHasBuilding(GameInfoTypes.BUILDING_CLBEOMOON) then
  131.                 local ForeignBoat = 0
  132.                 for pCityPlot = 0, pCity:GetNumCityPlots() - 1, 1 do
  133.                     local pSpecificPlot = pCity:GetCityIndexPlot(pCityPlot)
  134.                     if pSpecificPlot ~= nil then
  135.                         if pSpecificPlot:IsWater() then
  136.                             local pUnit = pSpecificPlot:GetUnit(0)
  137.                             if pUnit ~= nil then
  138.                                 if pUnit:GetDomainType() == DomainTypes.DOMAIN_SEA then
  139.                                     if Players[pUnit:GetOwner()] ~= pPlayer then
  140.                                         ForeignBoat = ForeignBoat + 1
  141.                                     end
  142.                                 end
  143.                             end
  144.                         end
  145.                     end
  146.                 end
  147.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOSHIPFAITH, ForeignBoat)
  148.             end
  149.         end
  150.     end
  151. end
  152. --PlayerDoTurn
  153.  
  154. function MythicFestivalRequires(player)
  155.     local pPlayer = Players[player]
  156.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  157.         for pCity in pPlayer:Cities() do
  158.             if pCity:GetResourceDemanded(true) == GameInfoTypes.RESOURCE_PEARLS or pCity:GetResourceDemanded(true) == GameInfoTypes.RESOURCE_CORAL or pCity:GetResourceDemanded(true) == GameInfoTypes.RESOURCE_WHALE or pCity:GetResourceDemanded(true) == GameInfoTypes.RESOURCE_CRAB then
  159.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOFESTIVALREQ, 1)
  160.             else
  161.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOFESTIVALREQ, 0)
  162.             end
  163.         end
  164.     end
  165. end
  166. --PlayerDoTurn
  167.  
  168. function PlaceMythicalBeast(pCity, pResource)
  169.     for pCityPlot = 0, pCity:GetNumCityPlots() - 1, 1 do
  170.         local pSpecificPlot = pCity:GetCityIndexPlot(pCityPlot)
  171.         if pSpecificPlot ~= nil then
  172.             if pSpecificPlot:IsWater() then
  173.                 print("We found water")
  174.                 if pSpecificPlot:GetResourceType(-1) == -1 then
  175.                     pSpecificPlot:SetResourceType(pResource, 1)
  176.                     print("resource placed.")
  177.                     return
  178.                 else
  179.                     print("but it's full")
  180.                 end
  181.             end
  182.         end
  183.     end
  184. end
  185.  
  186. function MythicFestivalPower(player, city, buildingType)
  187.     local pPlayer = Players[player]
  188.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  189.         if buildingType == GameInfoTypes.BUILDING_CLBEOFESTIVAL then
  190.             local pCity = pPlayer:GetCityByID(city)
  191.             print(pCity:GetName() .. " has a Festical Emblem")
  192.             local pResource = pCity:GetResourceDemanded(true)
  193.             print(pResource .. " demanded!")
  194.             PlaceMythicalBeast(pCity, pResource)
  195.             save(pPlayer, pCity:GetName(), pResource)
  196.         end
  197.     end
  198. end
  199. --GameEvents.CityConstructed
  200.  
  201. function RemoveMythicalBeast(pCity, pResource)
  202.     for pCityPlot = 0, pCity:GetNumCityPlots() - 1, 1 do
  203.         local pSpecificPlot = pCity:GetCityIndexPlot(pCityPlot)
  204.         if pSpecificPlot ~= nil then
  205.             if pSpecificPlot:IsWater() then
  206.                 if pSpecificPlot:GetResourceType(-1) == pResource then
  207.                     pSpecificPlot:SetResourceType(-1)
  208.                     return
  209.                 end
  210.             end
  211.         end
  212.     end
  213. end
  214.  
  215. function StopMythicalFestivalPower(player, city, building)
  216.     local pPlayer = Players[player]
  217.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  218.         print("BuildingType is "..buildingType)
  219.         if buildingType == BUILDING_CLBEOFESTIVAL then
  220.             local pCity = pPlayer:GetCityByID(city)
  221.             local pResource = load(pPlayer, pCity:GetName())
  222.             if pResource ~= nil then
  223.                 RemoveMythicalBeast(pCity, pResource)
  224.             end
  225.         end
  226.     end
  227. end
  228. --GameEvents.CitySoldBuilding
  229.  
  230. function MythicSongRequires(player)
  231.     local pPlayer = Players[player]
  232.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  233.         for pCity in pPlayer:Cities() do
  234.             print(pCity:GetNumWorldWonders() .. " in " .. pCity:GetName())
  235.             if pCity:GetNumWorldWonders() > 0 then
  236.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOSONGREQ, 1)
  237.             else
  238.                 pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CLBEOSONGREQ, 0)
  239.             end
  240.         end
  241.     end
  242. end
  243. --PlayerDoTurn
  244.  
  245. function MythicSongPower(player)
  246.     local pPlayer = Players[player]
  247.     if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  248.         for pCity in pPlayer:Cities() do
  249.             if pCity:IsHasBuilding(GameInfoTypes.BUILDING_CLBEOSONG) then
  250.                 local range = 3
  251.                 local pPlot = pCity:Plot()
  252.                 local x = pPlot:GetX()
  253.                 local y = pPlot:GetY()
  254.                 for dx = -range, range do
  255.                     for dy = -range, range do
  256.                         local SpecificPlot = Map.PlotXYWithRangeCheck(x, y, dx, dy, range)
  257.                         if SpecificPlot ~= nil and SpecificPlot:GetOwner() == -1 then
  258.                             print("SpecificPlot is working")
  259.                             if SpecificPlot:GetTerrainType() == TerrainTypes.TERRAIN_COAST then
  260.                                 SpecificPlot:SetOwner(pCity:GetOwner())
  261.                             end
  262.                         end
  263.                     end
  264.                 end
  265.             end
  266.         end
  267.     end
  268. end
  269. --PlayerDoTurn
  270.  
  271. for i = 0, GameDefines.MAX_MAJOR_CIVS - 1, 1 do
  272.     local pPlayer = Players[i]
  273.     if pPlayer:IsEverAlive() and pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_CLBEOTHUK then
  274.         print("Beothuk Mythic Emblem lua loaded!")
  275.         GameEvents.PlayerDoTurn.Add(MythicShipPower)
  276.         GameEvents.PlayerDoTurn.Add(MythicCouncilRequires)
  277.         GameEvents.PlayerDoTurn.Add(MythicCouncilPower)
  278.         GameEvents.PlayerDoTurn.Add(MythicMoonRequires)
  279.         GameEvents.PlayerDoTurn.Add(MythicMoonPower)
  280.         GameEvents.PlayerDoTurn.Add(MythicFestivalRequires)
  281.         GameEvents.PlayerDoTurn.Add(MythicSongRequires)
  282.         GameEvents.PlayerDoTurn.Add(MythicSongPower)
  283.         GameEvents.CityTrained.Add(MythicHuntPower)
  284.         GameEvents.CityConstructed.Add(MythicFestivalPower)
  285.         GameEvents.CitySoldBuilding.Add(StopMythicFestivalPower)
  286.         break
  287.     end
  288. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement