API GetFactionInfo

From Wowpedia
(Redirected from API GetFactionInfoByID)
Jump to: navigation, search

Returns information about the specified faction or faction header in the player's reputation pane.

name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader,
    isCollapsed, hasRep, isWatched, isChild, factionID, hasBonusRepGain, canBeLFGBonus = GetFactionInfo(factionIndex)
name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader,
    isCollapsed, hasRep, isWatched, isChild, factionID, hasBonusRepGain, canBeLFGBonus = GetFactionInfoByID(factionID)

Arguments for GetFactionInfo

factionIndex 
Number - Index of the faction to query. Indices correspond to the rows currently displayed in the player's reptuation pane, and include headers, but do not include factions that are not currently displayed because their parent header is collapsed.

Arguments for GetFactionInfoByID

factionID 
Number (FactionID)- Unique numeric identifier for the faction

Returns for both functions

name 
String - Name of the faction
description 
String - Description of the faction, as shown in the detail pane that appears when you click on the faction row
standingID 
Number (StandingId) - Index of the player's current standing (eg. 4 for Neutral, 5 for Friendly, etc.) with the faction
barMin 
Number - Minimum reputation required to reach the current standing (0 for Neutral, 3000 for Friendly, etc.)
barMax 
Number - Maximum reputation that can be earned with the faction before graduating to the next standing (3000 for Neutral, 6000 for Friendly, etc.)
barValue 
Number - Total reputation the player has earned with the faction (starting from 0 at the beginning of Neutral, so a player who is 1500/6000 Friendly would have 3000 for Neutral + 1500 into Friendly for a total reputation of 4500)
atWarWith 
Flag - 1 if the player is at war with the faction, nil otherwise
canToggleAtWar 
Flag - 1 if the player can toggle the "At War" checkbox for the faction, nil otherwise
isHeader 
Flag - 1 if the faction is a header (collapsible group title, eg. Cataclysm, Horde Forces, or Valiance Expedition), nil otherwise
isCollapsed 
Flag - 1 if the faction is a header and is currently collapsed, nil otherwise
hasRep 
Flag - 1 if the faction is a header and has its own reputation (eg. The Tillers), nil otherwise
isWatched 
Flag - 1 if the "Show as Experience Bar" checkbox for the faction is currently checked, nil otherwise
isChild 
Flag - 1 if the faction is a second-level header (eg. Sholazar Basin) or is the child of a second-level header (eg. The Oracles), nil otherwise
factionID (New in 5.0)
Number (FactionID) - Unique numeric identifier for the faction
hasBonusRepGain (New in 5.2)
Flag - 1 if the player has purchased a Grand Commendation to unlock bonus reputation gains with this faction, nil otherwise
canBeLFGBonus (New in 5.2)
Flag - 1 if the player can select the faction for earning bonus reputation through the LFG system, nil otherwise

Notes

Headers

Top-level headers (eg. Cataclysm or Classic) return values for standingID, barMin, and barMax as if the player were at 0/3000 Neutral with a faction (4, 0, and 3000 respectively) except for the Inactive header, which returns values of 0.

Other headers that do not have their own reputation (eg. Sholazar Basin or Steamwheedle Cartel) return values for their child faction with which the player has the highest reputation. For example, if the player is 999/1000 Exalted with Booty Bay, 2900/21000 Revered with Everlook, 5300/12000 Honored with Gadgetzan, and 10/6000 Friendly with Ratchet, querying the Steamwheedle Cartel header will return the standingId, barMin, and barMax values for Booty Bay.

Total Reputation

Within the game reputation is shown as a formatted value of XXXX/YYYYY (eg. 1234/12000) but outside of the reputation tab these values are not avaliable directly. The game uses a flat value for reputation.

The earnedValue returned by GetFactionInfo( ) is NOT the value on your reputation bars, but instead the distance your reputation has moved from 0 (1/3000 Neutral). All reputations given by the game are simply the number of reputation points from the 0 point, Neutral and above are positive reputations, anything below Neutral is a negative value and must be treated as such for any reputation calculations.

Game Value Standing Earned Value Breakdown
1/3000 Neutral 1 1
1600/6000 Friendly 4600 3000 + 1600
11000/12000 Honored 20000 3000 + 6000 + 11000
1400/3000 Unfriendly -1600 -1600
2500/3000 Hostile -3500 -3000 + -500

Notice that for negative reputation that the Earned value is how far below 0 your reputation is, not how far till Hated or Exalted.

Usage Examples

Usage Example #1

for factionIndex = 1, GetNumFactions() do
    local name, description, standingId, bottomValue, topValue, earnedValue, atWarWith, canToggleAtWar,
        isHeader, isCollapsed, hasRep, isWatched, isChild, factionID = GetFactionInfo(factionIndex)
    if hasRep or not isHeader then
        DEFAULT_CHAT_FRAME:AddMessage("Faction: " .. name .. " - " .. earnedValue)
    end
end

Result

Prints the name and total reputation earned for every faction currently displayed in the player's reputation pane:

Faction: Cenarion Circle - 2785
Faction: Argent Dawn - 405
Faction: Thunder Bluff - 15042

Usage Example #2

The above code will only loop over those factions that are currently displayed in the faction panel, thus excluding all factions inside collapsed headers. To loop over all factions, including the hidden ones, you can use the following code to expand each collapsed header:

local numFactions = GetNumFactions()
local factionIndex = 1
while (factionIndex <= numFactions) do
    local name, description, standingId, bottomValue, topValue, earnedValue, atWarWith, canToggleAtWar,
        isHeader, isCollapsed, hasRep, isWatched, isChild, factionID, hasBonusRepGain, canBeLFGBonus = GetFactionInfo(factionIndex)
    if isHeader and isCollapsed then
        ExpandFactionHeader(factionIndex)
        numFactions = GetNumFactions()
    end
    if hasRep or not isHeader then
        DEFAULT_CHAT_FRAME:AddMessage("Faction: " .. name .. " - " .. earnedValue)
    end
    factionIndex = factionIndex + 1
end

See also

Patch changes

  • Mists of Pandaria Patch 5.2.0 (2013-03-05): Added new return values: hasBonusRepGain, canBeLFGBonus
  • Mists of Pandaria Patch 5.0.4 (2012-08-28): Added new return value: factionID