Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Monitor_TerritorySectors()
- for key, point in ipairs(TerritoryPoints) do
- local entity = Entity_FromWorldID(point.worldID)
- local current_owner = Entity_GetPlayerOwnerSafe(entity)
- local previous_owner = point.owner
- -- Is owned by world
- if current_owner == "world" then
- if point.granted then
- --remove bonus
- if point.owner ~= "world" then
- GrantPopulationBonus(point.owner, point.type, "-")
- point.owner = "world"
- end
- point.granted = false
- end
- else
- -- IS owned by player
- if not World_IsInSupply(current_owner, Entity_GetPosition(entity)) then
- if point.granted then
- --remove bonus
- GrantPopulationBonus(point.owner, point.type, "-")
- point.owner = current_owner
- point.granted = false
- end
- else
- if not point.granted then
- point.owner = current_owner
- GrantPopulationBonus(point.owner, point.type, "+")
- --give bonus
- point.granted = true
- end
- end
- end
- end
- end
- function GrantPopulationBonus(player, _type, direction)
- local current_population = Player_GetMaxPopulation(player, CT_Personnel)
- local grant = _PopCapSystemConfig.grant_per_point[_type][Player_GetRace(player)]
- if direction == "-" then
- -- turn it negative
- grant = 0 - grant
- end
- for i = 1, World_GetPlayerCount() do
- local _player = World_GetPlayerAt(i)
- if Player_GetTeam(_player) == Player_GetTeam(player) then
- Player_SetPopCapOverride(_player, current_population + grant)
- end
- end
- end
- function Entity_GetPlayerOwnerSafe(entity)
- if World_OwnsEntity(entity) then
- return "world"
- else
- return Entity_GetPlayerOwner(entity)
- end
- end
- function Player_GetIDSafe(player)
- if not player or player == "world" then
- return "world"
- else
- return Player_GetID(player)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement