Need short answers/tips from experienced Modders

Daqidius

Chieftain
Joined
Apr 15, 2020
Messages
10
Greetings Modders,

i have created my first few building and units , trying to balance few aspects of the game.
I am stuck with following

1. Oasis building - i wanted to create building that will be available only when there is nearby Oasis (within 3 tiles). How to set the condition in XML ?

2. the very same , but this time LAKE

3. Manhattan project - i would like to set Uranium as requirement for this wonder, how ?

4. New cities start with buildings in later Eras
I am not sure if this is possible , but i would like to adjust free buildings in new cities in late game
f.e.
Classical Era - Shrine
Mediaval - Monument
Renaissance - Library, Barracks
etc

5. Is there a way how to handle extra luxuries ?
I would like to as some small bonus for extra copies of luxuries

6. Can i change behavior of Great Scientist to give simple one Free Tech? Right now the effect is way too powerfull (its basically 2 free techs)

thank you
 
There's no way to make a building buildable only if an oasis is nearby using XML only
However, you can do it with help of Lua and the GameEvents.CityCanConstruct hook!

The same goes for a lake requirement (though you can also use the <FreshWater>true</FreshWater> and <MinAreaSize>1</MinAreaSize> XML tags to make it buildable only adjacent to sources of fresh water, such as lakes or rivers, just like the Aztec floating gardens)

3) This can be done using Lua with the GameEvents.CityCanCreate hook, and works in a very similar way as GameEvents.CityCanConstruct does:

Code:
local iUranium = GamInfoTypes.RESOURCE_URANIUM
local iManhattanProject = PROJECT_MANHATTAN_PROJECT

function manhattenProjectOnlyIfUranium(iPlayer, iCity, iProject)
    if iProject == iManhattanProject then
       local pPlayer = Players[iPlayer]
       if pPlayer:GetNumResourceTotal(iUranium, true) <= 0 then -- The player has no Uranium (the 'true' indicates that Uranium obtained from trading also counts)
          return false
       end
    end
    return true
end

GameEvents.CityCanCreate.Add(manhattenProjectOnlyIfUranium)

4) This is already done in the base game. For instance, for the Shrine the following XML-tag ensures it's free if you start a game in the Medieval Era or later:
Code:
<FreeStartEra>ERA_MEDIEVAL</FreeStartEra>

5, 6) With some Lua trickery, certainly! Just using XML, not so much unfortunately...
You can count the number of resources using pPlayer:GetNumResourceTotal(<resource>, <include_trade>) (similar to how we did for question 3)
Try to see if you can write up some code for the other questions first; this can be more difficult as there is less reference material from other posts/mods (or well, it will at least be more difficult to find)

As for 6, specifically, I'm unsure how the AI would handle this. IIRC, some of their actions are hardcoded in the DLL, and if those are unavailable they won't do anything with the unit. For this reason, out of all your questions, 6 will be the hardest to achieve.
 
Thank you for the reply , i guess i will need to learn more (atm i am using only XML)

point 4.
i guess i did not express myself exactly, i always start the game in ancient era and i would like new cities founded in later eras to already have some building.
 
#4) Then you would need an lua script that added them to the city when a city is founded later-era.

----------------------------------------------------

Code:
<GameData>
	<Defines>
		<Update>
			<Where Name="HAPPINESS_PER_EXTRA_LUXURY" />
			<Set Value="1" />
		</Update>
	</Defines>
</GameData>
But as I recall the "1" acts as a Boolean and is based on the number of different luxury-types a player has rather than a direct increase of happiness for having more than one copy of a single resource.

You would have to confirm my memory on how this GameDefine works since I just pulled it from some code of an old mod I have not played for literally three or four years.
 
Back
Top Bottom