TheLunarArmy
Chieftain
Hi folks,
Been looking around for a decent LUA api but doesnt seem to be a well documented collection yet (or at least I cant find it). The closest being the LUA spreadsheet. Anyway, wouldn't mind a hand with the Religion and Great Person Points, any code/hints/slap-in-the-right direction would be appreciated.
Basic idea: Leader Trait that will give Great Prophet Points when a Barb is killed if:
1. No Religion founded
2. A Great Prophet is available
3. Does not have Great Prophet already for the civ
Otherwise it will give Great Artist Points instead.
4. Give corresponding GPP
Here is a pseudo code of how I think it will work, but need some advice on which direction I can pass the 4 steps listed above
I have l found some approaches to the problem, but hasnt yielded any reliable results.
1.
• Maybe do a lookup using a query looking into a RequirmentSet containing a RequirementSetRequirements containing REQUIRES_PLAYER_FOUNDED_RELIGION ?
• Using GetReligion():GetMajorityReligion() somehow? Problem is if another civ rushes your civ with missionaries then it will return false.
• Maybe Look if the civ has received the inspiration for Theology civic? (Found a Religion)
2.
• No clue yet (currently investigating)
3
• Grab unit list from player, then iterate and determine if unit type is prophet
4.
• Below seems like the logical solution here
Edit:
• JFD's Rule with Faith (RaF) Has some pretty good Utility lua scripts. function Player_CanRecruitGreatTheologian(player) has some code I will try out
Thanks in Advance!
Been looking around for a decent LUA api but doesnt seem to be a well documented collection yet (or at least I cant find it). The closest being the LUA spreadsheet. Anyway, wouldn't mind a hand with the Religion and Great Person Points, any code/hints/slap-in-the-right direction would be appreciated.
Basic idea: Leader Trait that will give Great Prophet Points when a Barb is killed if:
1. No Religion founded
2. A Great Prophet is available
3. Does not have Great Prophet already for the civ
Otherwise it will give Great Artist Points instead.
4. Give corresponding GPP
Here is a pseudo code of how I think it will work, but need some advice on which direction I can pass the 4 steps listed above
Code:
function Give_GreatPeoplePoints(iOwnerPlayerID, iDiedUnitID, iKillerPlayerID, iKillerUnitID)
local pOwner = Players[iOwnerPlayerID]
local pPlayer = Players[iKillerPlayerID]
local pPlayerConfig = PlayerConfigurations[iKillerPlayerID]
-- Determine if dead unit is Barbarian, and killer is correct Civ has Leader with Trait
if pOwner.IsBarbarian and HasLeaderTrait(pPlayerConfig:GetLeaderTypeName(), sGeoffTrait) then
-- (1) and (2) and (3)
If any false:
(4) Give Artist Points
If all true:
(4) Give Prophet Points
end
end
Events.UnitKilledInCombat.Add(Give_GreatPeoplePoints)
I have l found some approaches to the problem, but hasnt yielded any reliable results.
1.
• Maybe do a lookup using a query looking into a RequirmentSet containing a RequirementSetRequirements containing REQUIRES_PLAYER_FOUNDED_RELIGION ?
• Using GetReligion():GetMajorityReligion() somehow? Problem is if another civ rushes your civ with missionaries then it will return false.
• Maybe Look if the civ has received the inspiration for Theology civic? (Found a Religion)
2.
• No clue yet (currently investigating)
3
• Grab unit list from player, then iterate and determine if unit type is prophet
4.
• Below seems like the logical solution here
Code:
pPlayer:GetGreatPeoplePoints():CalculatePointsPerTurn(GreatPersonClass)
-- Math here
pPlayer:GetGreatPeoplePoints():ChangePointsTotal(...)
Edit:
• JFD's Rule with Faith (RaF) Has some pretty good Utility lua scripts. function Player_CanRecruitGreatTheologian(player) has some code I will try out
Thanks in Advance!
Last edited: