GPuzzle

RJ Brunei UA

Jun 29th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1. ----------------------------------------------------
  2. --Basic Data
  3. ----------------------------------------------------
  4. local iCiv = GameInfoTypes.CIVILIZATION_RBRUNEI;
  5. local eOilTradeBuilding = GameInfoTypes.BUILDING_RBRUNEI_DUMMY_OIL;
  6. local sImprov = GameInfoTypes.IMPROVEMENT_RBRUNEI_MOD;
  7. local uCargo = GameInfoTypes.UNIT_CARGO_SHIP;
  8. ----------------------------------------------------
  9. --OilTradeGold
  10. ----------------------------------------------------
  11. function OilTradeGold(iPlayer)
  12.     local pPlayer = Players[iPlayer]
  13.     if pPlayer:GetCivilizationType() == iCiv then
  14.         for pCity in pPlayer:Cities() do
  15.             local oilTradeAmount = 0
  16.             local iNumPlots = pCity:GetNumCityPlots()
  17.             for i = 0, iNumPlots - 1 do
  18.                 local pPlot = pCity:GetCityIndexPlot(i)
  19.                 if pCity:IsWorkingPlot(pPlot) and pPlot:GetResourceType() == ResourceTypes.RESOURCE_OIL then
  20.                     oilTradeAmount = oilTradeAmount + 1
  21.                 end
  22.             end
  23.             pCity:SetNumRealBuilding(eOilTradeBuilding, oilTradeAmount)
  24.         end
  25.     end
  26. end
  27.  
  28. GameEvents.PlayerDoTurn.Add(OilTradeGold)
  29.  
  30. ----------------------------------------------------
  31. --CargoShipBonus
  32. ----------------------------------------------------
  33. function CargoShipBonus(iPlayer, pPlayer, pcCity)
  34.     for mPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do
  35.         local mPlayer = Players[mPlayer];
  36.         if (mPlayer:IsAlive()) then
  37.             for mUnit in mPlayer:Units() do        
  38.                 if mUnit:GetUnitType() == uCargo then
  39.                     local uPlot = mUnit:GetPlot()
  40.  
  41.                     -- Steal Gold Function
  42.                     CargoShipStealGold(iPlayer, pPlayer, mPlayer, mUnit, uPlot, pcCity)
  43.  
  44.                     local plotX = uPlot:GetX();
  45.                     local plotY = uPlot:GetY();
  46.                     local iRange = 1;
  47.                     for iDX = -iRange, iRange do
  48.                         for iDY = -iRange, iRange do
  49.                             local pTargetPlot = Map.PlotXYWithRangeCheck(plotX, plotY, iDX, iDY, iRange);
  50.                             if pTargetPlot then
  51.                                 if pTargetPlot:GetImprovementType() == sImprov then
  52.                                     local nPlayer = Players[mUnit:GetOwner()];
  53.                                     if (nPlayer:IsAlive()) then
  54.                                         pPlayer:ChangeGold(1); -- 1 Default
  55.                                         end
  56.                                     end
  57.                                 end
  58.                             end
  59.                         end
  60.                     end
  61.                 end
  62.             end
  63.         end
  64.     end
  65.     CargoShipBonus(pPlayer, iPlayer, pcCity)
  66. end
Advertisement
Add Comment
Please, Sign In to add comment