Machiavelli24
Mod creator
- Joined
- May 9, 2012
- Messages
- 818
Chiphead, you could implement that with a "PlayerCanConstruct" restriction.
I already wrote the lua you needed and posted it in your thread like last week:
All you had to do was make a dummy building that provides +2 food. With that code (no changes needed) it would have added 1 dummy building for every unemployed specialist in the city. (So if you had 8 unemployed specialists, it would have added 8 of the dummy building, so 16 food, remove one, 7, the city produces 14. If you want it to also give happiness, make that dummy building also give happiness). The only exception is tourism since that one counts once per building class and not type.Spoiler :Code:local sCitizen = GameInfo.Specialists.SPECIALIST_CITIZEN.ID; local bDummy = GameInfoTypes.BUILDING_WHATEVER; GameEvents.PlayerDoTurn.Add( function(iPlayer) local pPlayer = Players[iPlayer]; if (pPlayer:IsAlive()) then if (pPlayer:GetCivilizationType() == GameInfoTypes.WHATEVER) then -- or Whatever your trigger is for pCity in pPlayer:Cities() do local cCitizen = pCity:GetSpecialistCount(sCitizen); pCity:SetNumRealBuilding(bDummy, cCitizen ); end end end end)
So, there's something I want to do, but don't really know how to... I need to detect when a new luxury resoure has been connected to a civilization. When I say new I mean a resource that has never before being connected to said civ.
I suppose it'd require SaveUtils or something, but I still don't know how to use those well, so if anyone can figure it out I will be truly grateful.
The only thing left to figure out now is whether or not it is possible for the Lua to instantly react. As it stands now there is a 1 turn delay on dummies, whereas specialists can be reassigned multiple times a turn. Is this actually possible to do at all, or have modders been forced to deal with it since forever?
pCity:SetNumRealBuilding(bDummy, [COLOR="DarkOrchid"]cCitizen[/COLOR] );
Couldn't you use FreeGreatWork (used by the Parthenon) to give your dummy building a dummy great work?I am unable to use dummy buildings for tourism. How do I do this?
<EnhancedYieldTech>TECH_AGRICULTURE</EnhancedYieldTech>
<TechEnhancedTourism>1</TechEnhancedTourism>
You can't set tourism dynamically through lua as far as I know...
Couldn't you use FreeGreatWork (used by the Parthenon) to give your dummy building a dummy great work?
You can't set tourism dynamically through lua as far as I know...
You can use the following:
Code:<EnhancedYieldTech>TECH_AGRICULTURE</EnhancedYieldTech> <TechEnhancedTourism>1</TechEnhancedTourism>
To give a building 1 Tourism. (It doesn't stack with the same building type though; so you may need more than one dummy building)
With respect to dynamically adding tourism via lua, has anyone investigated or implemented the following (convoluted) approach?
1) Create a new policy branch that can not be adopted (blocked via PlayerCanAdoptPolicyBranch)
2) Add a policy under this branch that provides Policy_TourismOnUnitCreation for an unbuildable unit.
3) Use Lua to give the player this policy, spawn X copies of the unit, killing the unit right after spawning it, then removing the policy from the player.
If there are effects which trigger on policy adoption than this approach is going to mess up a few things.
If one dummy gives +1, six dummies will also give +1.
local HeroOfMan = GameInfoTypes["UNIT_HERO_OF_MAN"].ID
local BGLevel1Prereq = GameInfo.Technologies["TECH_STEEL"].ID
local BGLevel2Prereq = GameInfo.Technologies["TECH_GUNPOWDER"].ID
local BGLevel3Prereq = GameInfo.Technologies["TECH_RIFLING"].ID
local BGLevel4Prereq = GameInfo.Technologies["TECH_REPLACEABLE_PARTS"].ID
local BGLevel5Prereq = GameInfo.Technologies["TECH_PLASTICS"].ID
local BGLevel6Prereq = GameInfo.Technologies["TECH_MOBILE_TACTICS"].ID
local BGLevel1Combat = 23
local BGLevel2Combat = 26
local BGLevel3Combat = 37
local BGLevel4Combat = 55
local BGLevel5Combat = 77
local BGLevel6Combat = 132
function NorthHero(iPlayer)
for _, pPlayer in pairs(Players) do
local teamID = pPlayer:GetTeam();
local pTeam = Teams[teamID];
if (pPlayer:IsAlive()) then
if (pTeam:IsHasTech(BGLevel1Prereq)) then
for bgunit in pPlayer:Units() do
if (bgunit:GetUnitType().ID == HeroOfMan) then
if (bgunit:GetBaseCombatStrength() < BGLevel1Combat then
bgunit:SetBaseCombatStrength(BGLevel1Combat)
print ("A Hero of the North Level 1 is here!");
end
end
end
end
if (pTeam:IsHasTech(BGLevel2Prereq)) then
for bgunit in pPlayer:Units() do
if (bgunit:GetUnitType().ID == HeroOfMan) then
if (bgunit:GetBaseCombatStrength() < BGLevel2Combat then
bgunit:SetBaseCombatStrength(BGLevel2Combat)
print ("A Hero of the North Level 2 is here!");
end
end
end
end
if (pTeam:IsHasTech(BGLevel3Prereq)) then
for bgunit in pPlayer:Units() do
if (bgunit:GetUnitType().ID == HeroOfMan) then
if (bgunit:GetBaseCombatStrength() < BGLevel3Combat then
bgunit:SetBaseCombatStrength(BGLevel3Combat)
print ("A Hero of the North Level 3 is here!");
end
end
end
end
if (pTeam:IsHasTech(BGLevel4Prereq)) then
for bgunit in pPlayer:Units() do
if (bgunit:GetUnitType().ID == HeroOfMan) then
if (bgunit:GetBaseCombatStrength() < BGLevel4Combat then
bgunit:SetBaseCombatStrength(BGLevel4Combat)
print ("A Hero of the North Level 4 is here!");
end
end
end
end
if (pTeam:IsHasTech(BGLevel5Prereq)) then
for bgunit in pPlayer:Units() do
if (bgunit:GetUnitType().ID == HeroOfMan) then
if (bgunit:GetBaseCombatStrength() < BGLevel5Combat then
bgunit:SetBaseCombatStrength(BGLevel5Combat)
print ("A Hero of the North Level 5 is here!");
end
end
end
end
if (pTeam:IsHasTech(BGLevel6Prereq)) then
for bgunit in pPlayer:Units() do
if (bgunit:GetUnitType().ID == HeroOfMan) then
if (bgunit:GetBaseCombatStrength() < BGLevel6Combat then
bgunit:SetBaseCombatStrength(BGLevel6Combat)
print ("A Hero of the North Level 6 is here!");
end
end
end
end
end
end
end
GameEvents.PlayerAdoptPolicy.Add(NorthHero);
GameEvents.PlayerDoTurn.Add(NorthHero);
Hi everyone! I just started trying out modding Civ-5 a few days ago and already have a functioning XML based mod for a new civilization. Fresh off of my success I thought I might try something a little more complicated for my second Civ and try using some Lua... which may have been a mistake as i cant wrap my head around it at all.
I am trying to create a lua script which changes the combat strength of a faction specific unit, either by era or specific technology. If it is at all possible i would like to do it without creating a set of dummy promotions (as seen in the excellent Chola Civ mod from the Indian Subcontinent pack).
Here is the (mess of) code i am currently trying to use. I'm not going to lie, its an ugly mess, hacked together from other scripts which do (almost) what i want them to. Could i implore someone with a bit more experience to have a quick look at my little abomination and perhaps fix it up for me? (Or throw it out and build a new one).
Spoiler :Code:local HeroOfMan = GameInfoTypes["UNIT_HERO_OF_MAN"].ID local BGLevel1Prereq = GameInfo.Technologies["TECH_STEEL"].ID local BGLevel2Prereq = GameInfo.Technologies["TECH_GUNPOWDER"].ID local BGLevel3Prereq = GameInfo.Technologies["TECH_RIFLING"].ID local BGLevel4Prereq = GameInfo.Technologies["TECH_REPLACEABLE_PARTS"].ID local BGLevel5Prereq = GameInfo.Technologies["TECH_PLASTICS"].ID local BGLevel6Prereq = GameInfo.Technologies["TECH_MOBILE_TACTICS"].ID local BGLevel1Combat = 23 local BGLevel2Combat = 26 local BGLevel3Combat = 37 local BGLevel4Combat = 55 local BGLevel5Combat = 77 local BGLevel6Combat = 132 function NorthHero(iPlayer) for _, pPlayer in pairs(Players) do local teamID = pPlayer:GetTeam(); local pTeam = Teams[teamID]; if (pPlayer:IsAlive()) then if (pTeam:IsHasTech(BGLevel1Prereq)) then for bgunit in pPlayer:Units() do if (bgunit:GetUnitType().ID == HeroOfMan) then if (bgunit:GetBaseCombatStrength() < BGLevel1Combat then bgunit:SetBaseCombatStrength(BGLevel1Combat) print ("A Hero of the North Level 1 is here!"); end end end end if (pTeam:IsHasTech(BGLevel2Prereq)) then for bgunit in pPlayer:Units() do if (bgunit:GetUnitType().ID == HeroOfMan) then if (bgunit:GetBaseCombatStrength() < BGLevel2Combat then bgunit:SetBaseCombatStrength(BGLevel2Combat) print ("A Hero of the North Level 2 is here!"); end end end end if (pTeam:IsHasTech(BGLevel3Prereq)) then for bgunit in pPlayer:Units() do if (bgunit:GetUnitType().ID == HeroOfMan) then if (bgunit:GetBaseCombatStrength() < BGLevel3Combat then bgunit:SetBaseCombatStrength(BGLevel3Combat) print ("A Hero of the North Level 3 is here!"); end end end end if (pTeam:IsHasTech(BGLevel4Prereq)) then for bgunit in pPlayer:Units() do if (bgunit:GetUnitType().ID == HeroOfMan) then if (bgunit:GetBaseCombatStrength() < BGLevel4Combat then bgunit:SetBaseCombatStrength(BGLevel4Combat) print ("A Hero of the North Level 4 is here!"); end end end end if (pTeam:IsHasTech(BGLevel5Prereq)) then for bgunit in pPlayer:Units() do if (bgunit:GetUnitType().ID == HeroOfMan) then if (bgunit:GetBaseCombatStrength() < BGLevel5Combat then bgunit:SetBaseCombatStrength(BGLevel5Combat) print ("A Hero of the North Level 5 is here!"); end end end end if (pTeam:IsHasTech(BGLevel6Prereq)) then for bgunit in pPlayer:Units() do if (bgunit:GetUnitType().ID == HeroOfMan) then if (bgunit:GetBaseCombatStrength() < BGLevel6Combat then bgunit:SetBaseCombatStrength(BGLevel6Combat) print ("A Hero of the North Level 6 is here!"); end end end end end end end GameEvents.PlayerAdoptPolicy.Add(NorthHero); GameEvents.PlayerDoTurn.Add(NorthHero);
I would be grateful for any help, and of course credit will be given in the mod.
<Row Tag="TXT_KEY_PROCESSING_TURN_FOR">
<Text>Processing Turn For {1_CivilizationName[2]}</Text>
</Row>
Needed word "Ameriky" but it gives only 1st form. In most cases it supports forms like in notifications, logs and so on, but in few cases not. How to make it work?<Row Tag="TXT_KEY_CIV_AMERICA_SHORT_DESC">
<Text>Amerika|Ameriky</Text>
<Gender>neuter:an</Gender>
</Row>
Edit: Also it appears that i have accidentally deleted the credit for the original hacked lua. Credit for the orginal script goes to sukritact and Leugi.