TeamID (Civ5 Type)

From Civilization Modding Wiki
Jump to: navigation, search

This page is a part of the Lua and UI Reference (Civ5).


ID.png The TeamID pseudo-type is actually a regular integer. Pseudo-types do not exist in Lua, they only serve a documentation purpose on the wiki!


Usage

  • You can get a team's ID through Team.GetID().
  • There is a global Teams table that stores all teams. Keys are the teams' ID and values are Team instances.
  • A team's ID is usually the founding player's ID but you should not rely on it.


How to retrieve a Team object from an ID:

local pTeam = Teams[teamID]


Enumerating teams

As opposed to PlayerID there is no special precaution to take for using teams.

for id, team in pairs(Teams) do
	print(id, team:GetName())
end


Built-in constants

You can also use the built-in constants: GameDefines.MAX_TEAMS (64), GameDefines.MAX_CIV_TEAMS (63). See also GameDefines
The following example enumerates non-barbarian teams only:

for i = 0, GameDefines.MAX_CIV_TEAMS - 1 do
	print(i, Teams[i]:GetName())
end


Code snippets

Here is a function to check whether a player has a given tech. Indeed, since techs are shared by all team's member, the Player has no method to check the techs a player knows.

function HasPlayerTech(pPlayer, techType)
	local teamID = pPlayer:GetTeam();
	local pTeam = Teams[teamID];
	return pTeam:HasTech(techType);
end


Used by

int Area:GetNumRevealedTiles(TeamID index)
int Area:GetNumUnrevealedTiles(TeamID index)
TeamID City:GetTeam()
bool City:IsRevealed(TeamID index, bool debug)
bool City:IsVisible(TeamID team, bool debug)
City:SetRevealed(TeamID index, bool newValue)
Deal:AddThirdPartyPeace(PlayerID who, TeamID otherPlayer, int arg2)
Deal:AddThirdPartyWar(PlayerID who, TeamID otherPlayer)
int Deal:IsPossibleToTradeItem(PlayerID us, PlayerID them, TradeableItemType tradeType, TeamID dealDuration, ResourceType dealDuration = nil)
Deal:RemoveThirdPartyPeace(PlayerID firstParty, TeamID otherPlayer)
Deal:RemoveThirdPartyWar(PlayerID firstParty, TeamID otherPlayer)
Events.EndGameShow(EndGameType type, TeamID team)
Events.WarStateChanged(TeamID team1, TeamID team2, bool war)
Game.ChangeNumVotesForTeam(TeamID team, int kiVaticanExtraVotes)
Game.DoMinorGoldGift(TeamID gold, int goldGiftSmall)
TeamID Game.GetActiveTeam()
int Game.GetNumVotesForTeam(TeamID teamLoop)
int Game.GetPreviousVoteCast(TeamID teamLoop)
TeamID Game.GetRankTeam(int rank)
int Game.GetTeamRank(TeamID index)
int Game.GetTeamScore(TeamID index)
TeamID Game.GetVoteCast(TeamID team)
TeamID Game.GetWinner()
bool Game.IsTeamVoteEligible(TeamID team, VoteSourceType voteSource)
Game.SetWinner(TeamID newWinner, VictoryType newVictory)
bool GameEvents.CanDeclareWar(TeamID myTeam, TeamID theirTeam)
GameEvents.TeamSetHasTech(TeamID team, TechType tech, bool adopted)
GameEvents.TeamTechResearched(TeamID team, TechType tech, int change)
Network.SendChangeWar(TeamID minorCivTeam, bool arg1)
Network.SendLiberateMinor(TeamID minor, TeamID city)
Network.SendMinorCivEnterTerritory(TeamID rivalTeam)
bool Player:CanStopTradingWithTeam(TeamID team)
bool Player:IsMinorPermanentWar(TeamID activeTeam)
bool Player:IsPeaceBlocked(TeamID activeTeam)
Player:StopTradingWithTeam(TeamID team)
int Plot:CalculateBestNatureYield(YieldType index, TeamID team)
int Plot:CalculateNatureYield(YieldType index, TeamID team, bool ignoreFeature = false)
int Plot:CalculateTotalBestNatureYield(TeamID team)
bool Plot:CanHaveImprovement(ImprovementType improvement, TeamID team, bool potential)
bool Plot:CanSeePlot(Plot target, TeamID team, int range)
bool Plot:ChangeBuildProgress(BuildActionType build, int change, TeamID team)
Plot:ChangeInvisibleVisibilityCount(TeamID team, InvisibilityScopeType invisible, int change)
Plot:ChangeVisibilityCount(TeamID team, int change, InvisibilityScopeType seeInvisibleType, bool informExplorationTracking, bool alwaysSeeInvisible)
int Plot:DefenseModifier(TeamID defendTeam, bool ignoreBuilding, bool help)
int Plot:GetFeatureProduction(BuildActionType build, TeamID team, City city)
int Plot:GetInvisibleVisibilityCount(TeamID team, InvisibilityScopeType invisible)
ResourceType Plot:GetNonObsoleteResourceType(TeamID team)
ResourceType Plot:GetResourceType(TeamID team)
ImprovementType Plot:GetRevealedImprovementType(TeamID team, bool debug)
PlayerID Plot:GetRevealedOwner(TeamID team, bool debug)
RouteType Plot:GetRevealedRouteType(TeamID team, bool debug)
TeamID Plot:GetRevealedTeam(TeamID team, bool debug)
TeamID Plot:GetTeam()
int Plot:GetVisibilityCount(TeamID team)
bool Plot:IsAdjacentNonrevealed(TeamID team)
bool Plot:IsAdjacentNonvisible(TeamID team)
bool Plot:IsAdjacentRevealed(TeamID team)
bool Plot:IsAdjacentTeam(TeamID team, bool landOnly)
bool Plot:IsAdjacentVisible(TeamID team, bool debug)
bool Plot:IsInvisibleVisible(TeamID team, InvisibilityScopeType invisible)
int Plot:IsRevealed(TeamID team, bool debug)
bool Plot:IsRevealedGoody(TeamID team)
int Plot:IsVisible(TeamID team, bool debug)
bool Plot:IsWithinTeamCityRadius(TeamID team, PlayerID ignorePlayer)
int Plot:SeeFromLevel(TeamID team)
Plot:SetRevealed(TeamID team, bool newValue, bool terrainOnly, TeamID fromTeam)
TeamID PreGame.GetTeam(PlayerID player)
Team:AddTeam(TeamID team)
bool Team:CanChangeWarPeace(TeamID team)
bool Team:CanContact(TeamID team)
int Team:CanDeclareWar(TeamID team)
Team:DeclareWar(TeamID team)
TeamID Team:GetID()
TeamID Team:GetLiberatedByTeam(TeamID index)
int Team:GetNumTurnsLockedIntoWar(TeamID team)
TeamID Team:GetTeamVotingForInDiplo()
bool Team:HasEmbassyAtTeam(TeamID themTeam)
bool Team:IsAllowsOpenBordersToTeam(TeamID index)
int Team:IsAtWar(TeamID index)
bool Team:IsDefensivePact(TeamID index)
bool Team:IsForcePeace(TeamID index)
int Team:IsHasMet(TeamID index)
bool Team:IsHasResearchAgreement(TeamID team)
bool Team:IsHasTradeAgreement(TeamID team)
int Team:IsOpenBordersTradingAllowedWithTeam(TeamID arg0)
bool Team:IsPermanentWarPeace(TeamID index)
Team:MakePeace(TeamID team)
Team:Meet(TeamID team, bool newDiplo)
Team:SetPermanentWarPeace(TeamID index, bool newValue)
bool Unit:CanCoexistWithEnemyUnit(TeamID team)
bool Unit:CanEnterTerritory(TeamID team, bool ignoreRightOfPassage = false, bool isCity = false)
bool Unit:CanSiege(TeamID team)
int Unit:GetCombatOwner(TeamID forTeam)
TeamID Unit:GetDeclareWarRangeStrike(Plot plot)
TeamID Unit:GetTeam()
bool Unit:IsInvisible(TeamID team, bool debug, bool checkCargo = false)
bool Unit:IsNukeVictim(Plot plot, TeamID team)



The initial version of this page was created by the Civ5 API Bot, see the Civ5 API Reference FAQ. Some of the texts come from the 2kgames' wiki and most of code samples are copyrighted to Firaxis.
Functions' signatures were either copied from the 2kgames' wiki, or infered from the Lua source files and the binaries. Errors are possible.
Contributors may find help in the Contributors guide to the Civ5 API.