Detecting the human player at game creation time

vonJahgmann

Chieftain
Joined
Nov 7, 2010
Messages
43
Location
USA
In a single player game, wondering if anyone has a trick on detecting which Civilization is the human player? Pretty sure I can do this with SQL but have not figured it out just yet.

A simple use-case would be creating a Million Gold mod that simply grants the starting human player a big old pile of Gold at the beginning of a game.

A more useful use-case (and what I intend to work towards) is upon game startup to award certain benefits to the human civilization and then loop through the other AI major civilizations and award them certain other benefits.
 
Follow Lee's detailed and excellent examples here: LINK. You would have to do this through LUA. The XML tables are set in stone before the game begins, and only LUA will allow you to interact with in-game processes. You wouldn't be able to use SQL/XML. See this example:

Code:
function TestPlayerUnits(iPlayer, bIsFirstTime)
    local pPlayer = Players[iPlayer]
    if pPlayer:IsHuman() then
        local pPlayerUnits = pPlayer:GetUnits()
        for i, pUnit in pPlayerUnits:Members() do
            if pUnit:GetType() ~= nil then
                if pUnit:GetType() == GameInfo.Units["UNIT_WARRIOR"].Index then
                    pUnit:GetExperience():ChangeExperience(5)
                end
            end
        end
    end
end
Events.PlayerTurnActivated.Add(TestPlayerUnits)

The function tests whether a player that's starting the turn is human or not, then continues if the answer is positive. Check out Lee's mods.
 
erm, https://forums.civfanatics.com/threads/really-advanced-setup-lite.610454/

There are upper game limits to how much gold (or Faith) you can give a player. It is somewhere between 1,000,000 and 10,000,000 as reported by a little testing and reports by users trying to literally give themselves 10,000,000,000 gold and equally crazy amounts of Faith. The game hits a bit-allocation limit and rolls back to 0 (zero) gold in the treasury. It then tells you that you are are bankrupt via notifications but nothing bad seems to happen when you hit next turn except you did not get the 10 BIllion Gold you tried to give yourself. I have not had time as yet to chase down the actual integer allocation limit and cap what the mod will give as yet based on that. Been trying to get something else done.
 
Follow Lee's detailed and excellent examples here: LINK. You would have to do this through LUA. The XML tables are set in stone before the game begins, and only LUA will allow you to interact with in-game processes. You wouldn't be able to use SQL/XML. See this example:

Code:
function TestPlayerUnits(iPlayer, bIsFirstTime)
    local pPlayer = Players[iPlayer]
    if pPlayer:IsHuman() then
        local pPlayerUnits = pPlayer:GetUnits()
        for i, pUnit in pPlayerUnits:Members() do
            if pUnit:GetType() ~= nil then
                if pUnit:GetType() == GameInfo.Units["UNIT_WARRIOR"].Index then
                    pUnit:GetExperience():ChangeExperience(5)
                end
            end
        end
    end
end
Events.PlayerTurnActivated.Add(TestPlayerUnits)

The function tests whether a player that's starting the turn is human or not, then continues if the answer is positive. Check out Lee's mods.

Thank you very much. Appreciate the tip checking out Lee's mods. I also just stumbled upon this thread which lists a number of LUA events that can be tapped into.

https://forums.civfanatics.com/threads/list-of-game-events.604914/
 
There are upper game limits to how much gold (or Faith) you can give a player. It is somewhere between 1,000,000 and 10,000,000.

Thanks for the pointer Lee. I will aim to put a cheaters gold mod together in the next day or two as a proof of concept to prove (to myself) that I can hack the LUA. Baby steps...
 
Top Bottom