C++/Lua Request Thread

If this wouldn't be too much of a bother, could someone write some LUA code that would place a building in a civ's capitol after it researched a certain technology?
 
Just some code that is needed for the Upcoming Vietnam release:

Defensive structures within a city increases the spawn rate of :c5greatperson: Great Writers, Artists and Musicians.

So essentially Walls, Castles, Arsenals and Military Bases increases the spawn rate of GWAMs by 10% Each.

Also -

Receive +5% :c5culture: Culture and +5% :c5food: Food in each city for each Social Policy adopted in the Honor Tree.

Each policy (not the opener).

We'd be forever indebted to whoever can do this. Cheers.
 
Just some code that is needed for the Upcoming Vietnam release:

Defensive structures within a city increases the spawn rate of :c5greatperson: Great Writers, Artists and Musicians.

So essentially Walls, Castles, Arsenals and Military Bases increases the spawn rate of GWAMs by 10% Each.

Also -

Receive +5% :c5culture: Culture and +5% :c5food: Food in each city for each Social Policy adopted in the Honor Tree.

Each policy (not the opener).

We'd be forever indebted to whoever can do this. Cheers.

Permission to use the military building/Great People bonus (by itself) in a mod for another civ, please? It sounds perfect for a warrior culture with a strong oral-history tradition. :culture: Two more questions, though--


  1. How would you add a prerequisite (like having created a Heroic Epic) before the bonus applies?
  2. How would you limit the bonus to military buildings raised before a certain era (say, pre-Industrial only)?

I'd be very grateful for any help you can offer.
 
Go ahead!

Here is an ability that is needed for the Anangu Aboriginals:

If the Warmala is the first to discover a Natural Wonder, a Settler appears on the tile on which the Warmala is present.
 
Hello, i'd like to know how to make a promotion out of a trait (for instance, i want the shoshone extra territory upon city placement to be a promotion given to settlers when taking a social policy).

i'd also like to know how to make a religious belief a social policy (i want to make messanger of the gods into a policy)

lastly, i'd like to make a policy reducing the science penalty when founding new cities - kinda like what representation does to culture. any pointers on how to start?

thanks!
 
A UI for Afghanistan:

Can be built on any land tile and provides +1 :c5gold: Gold and +1 :c5food: Food, with their tile yields doubled if built adjacent to a mountain. Trade Routes that pass over a tile with a Dida generate points towards Great Writers in the Capital. Units stationed on a Dida receive also receive a 15% bonus defensive combat bonus.
 
A UI for Afghanistan:

Can be built on any land tile and provides +1 :c5gold: Gold and +1 :c5food: Food, with their tile yields doubled if built adjacent to a mountain. Trade Routes that pass over a tile with a Dida generate points towards Great Writers in the Capital. Units stationed on a Dida receive also receive a 15% bonus defensive combat bonus.

The only bit that actually requires Lua is the Trade Routes passing over Didas generating Great Writer points! The rest can be done in XML, and I have done so already. At least, assuming the combat bonus can be altered in XML (which I am overwhelmingly confident it can).
 
Quick request: Is it possible to make a UI provide a source of fresh water to all the tiles around (i.e. touching) it through lua? If so, I'm requesting that ;)
 
Quick request: Is it possible to make a UI provide a source of fresh water to all the tiles around (i.e. touching) it through lua? If so, I'm requesting that ;)

No and yes.

Directly in XML/Lua - no

Indirectly by putting an oasis like feature under the UI when it is built - yes. But that will depend on if it's acceptable for the UI to remove any existing feature on the tile.
 
No and yes.

Directly in XML/Lua - no

Indirectly by putting an oasis like feature under the UI when it is built - yes. But that will depend on if it's acceptable for the UI to remove any existing feature on the tile.

Well, it's designed to only be able to be built on flat grassland, so that shouldn't be a problem.
 
Is it possible to have a script add all buildings to a city in a custom scenario on startup?

Reason I ask is that I'm working on a scenario right now with multiple cities and would rather not have to keep manually adding buildings over and over again in world builder; there's got to be a better way to do this, right?
 
Is it possible to have a script add all buildings to a city in a custom scenario on startup?

Yes.

Search for "SetNumRealBuilding" in NewWorld_Scenario_MapScript.lua that's part of the (free) DLC07
 
The only bit that actually requires Lua is the Trade Routes passing over Didas generating Great Writer points!

Alright then, I hereby request just this!
 
Well, TPangolin and I need quite a lot of Lua for the upcoming Colonialist Legacies - Boers mod. Any sort of code a kind soul could contribute is of course, a great step forward. Here's what we need, in no particular order of importance:

For the Unique Ability:
A script/promotion that gives +1 Movement and the ability to withdraw before being captured/destroyed to Workers, Settlers, and Great People. If we can't get the withdraw, I suppose some other method that prevents them from being captured or destroyed would work. We have the +1 movement for the Workers and Settlers already, but I dunno how we could get the +1 movement for ALL BNW great people (excluding maybe the Admiral), and keep it civ-specific. We tried to give the "withdraw before melee" promotion to some civilian units, but I suppose it only triggers on a melee battle, and not a straightforward capture.
For the Unique Building:
This building (BUILDING_BOERSTAATSMUSEUM) needs 2 attributes: 25% of the city's Tourism output is converted into Growth. So for example, if your city is providing 20 Tourism per turn, the city's food growth rate is increased by 5%. The other attribute: Every Farm worked by this city provides points towards a Golden Age. This would probably apply to the civ-specific Farm replacement (IMPROVEMENT_BOERFARM), as opposed to the normal Farm. Though, if it's possible, both could work. As for the specific number of golden age points per farm, 1 or 2 sounds fair considering how many farms you're bound to have by then.
And, for the Unique Unit, shouldn't require a degree in Rocket Science like the other 2:
A promotion that gives a 25% defensive bonus when stationed on a Farm. (Normal farm or Boer farm, though probably the Boer farm first and foremost.)

Once again, we thank anyone who can do any of these for us very, very much.
 
For the Unique Ability:

A script/promotion that gives +1 Movement and the ability to withdraw before being captured/destroyed to Workers, Settlers, and Great People. If we can't get the withdraw, I suppose some other method that prevents them from being captured or destroyed would work. We have the +1 movement for the Workers and Settlers already, but I dunno how we could get the +1 movement for ALL BNW great people (excluding maybe the Admiral), and keep it civ-specific. We tried to give the "withdraw before melee" promotion to some civilian units, but I suppose it only triggers on a melee battle, and not a straightforward capture.



I can think of two ways to implement something like this:



A. Create a "combat" version of Settlers/Workers/GPs, and have them automatically replace the default versions when the Civ creates them. And by "combat," I mean they have 1 Strength and a promotion to give them 100% withdrawal chance. Problem with this is that if you do this with GWAMs, you aren't going to be able to make Great Works with them, since they won't have the name key properly associated with them to find which Great Work they should generate.



B. Make a Lua script which automatically kills captured civilians if their original owner of the civilian unit was the Boer Civ.



Which sounds better to you?



For the Unique Building:

This building (BUILDING_BOERSTAATSMUSEUM) needs 2 attributes: 25% of the city's Tourism output is converted into Growth. So for example, if your city is providing 20 Tourism per turn, the city's food growth rate is increased by 5%. The other attribute: Every Farm worked by this city provides points towards a Golden Age. This would probably apply to the civ-specific Farm replacement (IMPROVEMENT_BOERFARM), as opposed to the normal Farm. Though, if it's possible, both could work. As for the specific number of golden age points per farm, 1 or 2 sounds fair considering how many farms you're bound to have by then.



Code:
local iBoers = GameInfoTypes.CIVILIZATION_BOERS

local iUB = GameInfoTypes.BUILDING_BOERSTAATSMUSEUM

local iGrowthDummy = GameInfoTypes.BUILDING_BOER_GROWTHDUMMY

local iImprovement = GameInfoTypes.IMPROVEMENT_BOERFARM



function BoerUniqueBuilding(iPlayer)

if iPlayer < GameDefines.MAX_MAJOR_CIVS then

local pPlayer = Players[iPlayer]

if pPlayer:GetCivilizationType() == iBoers then

for pCity in pPlayer:Cities() do

--Growth Bonus

local iGrowthMod = math.floor(pCity:GetBaseTourism() / 4)

pCity:SetNumRealBuilding(iGrowthDummy, iGrowthMod)

--Golden Age from Farm

local iNumPlots = pCity:GetNumCityPlots()

local iTotalFarms = 0;

for iPlot = 0, iNumPlots - 1 do

local pPlot = pCity:GetCityIndexPlot(iPlot)

if pPlot and pPlot:GetOwner() == iPlayer and pPlot:GetImprovementType() == iImprovement then

iTotalFarms = iTotalFarms + 1

end

end

pPlayer:ChangeGoldenAgeProgressMeter(iTotalFarms)

end

end

end

end



GameEvents.PlayerDoTurn.Add(BoerUniqueBuilding)



BUILDING_BOER_GROWTHDUMMY should be a building with its own BuildingClass defined in either XML or SQL which provides +1% city growth and has NoLimit set to true in its BuildingClass. And, ideally, set its FaithCost to -1 and PrereqTech to NULL to hide it from the city view.



And, for the Unique Unit, shouldn't require a degree in Rocket Science like the other 2:

A promotion that gives a 25% defensive bonus when stationed on a Farm. (Normal farm or Boer farm, though probably the Boer farm first and foremost.)



Code:
local iUU = GameInfoTypes.BUILDING_BOER_UU

local iPromotion = GameInfoTypes.PROMOTION_BOER_UU_PROMOTION

local iImprovement = GameInfoTypes.IMPROVEMENT_BOERFARM



function BoerUniqueUnit(iPlayer, iUnitID)

if iPlayer < GameDefines.MAX_MAJOR_CIVS then

local pPlayer = Players[iPlayer]

local pUnit = pPlayer:GetUnitByID(iUnitID)

if pUnit:GetUnitType() == iUU then

local pPlot = pUnit:GetPlot()

if pPlot:GetImprovementType() == iImprovement then

pUnit:SetHasPromotion(iPromotion, true)

return

end

end

pUnit:SetHasPromotion(iPromotion, false)

end

end



GameEvents.UnitSetXY.Add(BoerUniqueUnit)



Both the UB and the UU are set only to use the unique version of the improvement, but that can easily be changed if needed. I haven't plugged this code into the game, so if it doesn't work, let me know.
 
A. Create a "combat" version of Settlers/Workers/GPs, and have them automatically replace the default versions when the Civ creates them. And by "combat," I mean they have 1 Strength and a promotion to give them 100% withdrawal chance.

The civ will then only be playable by a human, as the AI is incapable of using secondary found/work abilities for combat units.
 
The civ will then only be playable by a human, as the AI is incapable of using secondary found/work abilities for combat units.


I've seen your posts about this, but would that happen even if you set them to have UNITAI_SETTLE/UNITAI_WORKER/etc as their only valid AI types?


Sent from my iPhone using Tapatalk
 
From earlier, is it possible to make a UI add a feature to a tile through lua?
 
Top Bottom