Advertisement
Janne252

How to: Classic population cap system part #1

Feb 2nd, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1.     territoryPointType = {
  2.         strategic = 1,
  3.         fuel = 2,
  4.         munition = 3,
  5.         victory = 4,
  6.     }
  7.    
  8.     _territory_point_blueprints = {
  9.         {blueprint = BP_GetEntityBlueprint("territory_point_mp"), type = territoryPointType.strategic},
  10.         {blueprint = BP_GetEntityBlueprint("territory_fuel_point_mp"), type = territoryPointType.fuel},
  11.         {blueprint = BP_GetEntityBlueprint("territory_munitions_point_mp"), type = territoryPointType.munition},
  12.         {blueprint = BP_GetEntityBlueprint("victory_point"), type = territoryPointType.victory},
  13.     }
  14.    
  15.     TerritoryPoints = {}
  16.  
  17.     _PopCapSystemConfig = {
  18.         default_basepop = {
  19.             [0] = 35,
  20.             [1] = 40,
  21.         },
  22.         grant_per_point = {
  23.             -- strategic
  24.             [1] = {
  25.                 [0] = 6,
  26.                 [1] = 7,
  27.             },
  28.             -- fuel
  29.             [2] = {
  30.                 [0] = 12,
  31.                 [1] = 16,
  32.             },
  33.             -- muni
  34.             [3] = {
  35.                 [0] = 12,
  36.                 [1] = 16,
  37.             },
  38.             -- victory
  39.             [4] = {
  40.                 [0] = 4,
  41.                 [1] = 5,
  42.             },
  43.         },
  44.     }
  45.    
  46.     for i = 1, World_GetPlayerCount() do
  47.         local player = World_GetPlayerAt(i)
  48.         Player_SetPopCapOverride(player, _PopCapSystemConfig.default_basepop[Player_GetRace(player)])
  49.     end
  50.    
  51.     for index = 0, World_GetNumEntities() -1 do
  52.         local entity = World_GetEntity(index)
  53.         if Entity_IsOfType(entity, "strategic_node") then
  54.             local _blueprint = Entity_GetBlueprint(entity)
  55.             local _type
  56.            
  57.             for key, item in ipairs(_territory_point_blueprints) do
  58.                 if _blueprint == item.blueprint then
  59.                     _type = item.type
  60.                 end
  61.             end
  62.             local _territory_point = {
  63.                 worldID = Entity_GetGameID(entity),
  64.                 blueprint = _blueprint,
  65.                 type = _type,
  66.                 owner = "world",
  67.                 granted = false,
  68.             }
  69.             table.insert(TerritoryPoints, _territory_point)
  70.         end        
  71.     end
  72.    
  73.     Rule_Add(Monitor_TerritorySectors)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement