LeeS
Imperator
I've been working on an lua script that essentially disables tech-tree beelining.
As set up a player has to have completed all the techs from Grid X Column "2" before researching any from Grid X Column "4" (etc). The code is as follows
As set up a player has to have completed all the techs from Grid X Column "2" before researching any from Grid X Column "4" (etc). The code is as follows
Spoiler :
Code:
local iColumnsBackToLook = 2
local tImmuneTechnologies = {}
local tTechResearchedRequirements = {}
for row in GameInfo.Technologies() do
local iID = row.ID
if (row.GridX < (iColumnsBackToLook + 1)) or row.Disable then
tImmuneTechnologies[iID] = Locale.ConvertTextKey(row.Description)
else
local iGridXSpec = row.GridX - iColumnsBackToLook
for tech in GameInfo.Technologies("GridX = '" .. iGridXSpec .. "'") do
if not tech.Disable then
if tTechResearchedRequirements[iID] then
tTechResearchedRequirements[iID][tech.ID] = Locale.ConvertTextKey(tech.Description)
else
tTechResearchedRequirements[iID] = { [tech.ID] = Locale.ConvertTextKey(tech.Description) }
end
end
end
end
end
function NoTechBeeLines(iPlayerID, iTechType)
if not tImmuneTechnologies[iTechType] then
local iPlayerTeam = Players[iPlayerID]:GetTeam()
for iTechID,sTechName in pairs(tTechResearchedRequirements[iTechType]) do
if not Teams[iPlayerTeam]:IsHasTech(iTechID) then
return false
end
end
end
return true
end
GameEvents.PlayerCanResearch.Add(NoTechBeeLines)
- I am using this method
Code:
if (row.GridX < (iColumnsBackToLook + 1)) or row.Disable then
- Are there any methods you have seen people use to define a dummy tech other than the "Disable = true" method I am accounting for ?
- As the code is written I am not excluding Barbarian and City-State Players, but am wondering if I ought to ?