As using 2 different tech in EnableAdvance for units doesn't work, I have tried to use SLIC.
Here is the code.
int_f mod_CanCityBuildUnit(city_t theCity, int_t theUnit)
{
if (theUnit == UnitDB(UNIT_LEGION))
{
if(HasAdvance(theCity.owner, AdvanceDB(ADVANCE_MILITARISM)))
{
return 1; // can build this
}
else
{
return 0; // can't build this
}
}
if (theUnit == UnitDB(UNIT_HUNTER))
{
if(HasAdvance(theCity.owner, AdvanceDB(ADVANCE_WHEEL)))
{
return 1; // can build this
}
else
{
return 0; // can't build this
}
}
return 1; // can build all other units
}
This way, legion should be buildable only if the player has the techs militarism and iron working (iron working is used in the unit.txt with EnableAdvance, and militarism via SLIC).
Trouble is :
- Legion can appear in the buildable units list as soon as I discover Iron Working. But they do not appear every time ! ("random" behaviour every time you open the build list of the city). When I try to add the unit, it is not added in the list... Most of the time... If I click fast enough, I can add some legions in the lists (like 2 legions if I click 10 times...).
How can I make it work??
Here is the code.
int_f mod_CanCityBuildUnit(city_t theCity, int_t theUnit)
{
if (theUnit == UnitDB(UNIT_LEGION))
{
if(HasAdvance(theCity.owner, AdvanceDB(ADVANCE_MILITARISM)))
{
return 1; // can build this
}
else
{
return 0; // can't build this
}
}
if (theUnit == UnitDB(UNIT_HUNTER))
{
if(HasAdvance(theCity.owner, AdvanceDB(ADVANCE_WHEEL)))
{
return 1; // can build this
}
else
{
return 0; // can't build this
}
}
return 1; // can build all other units
}
This way, legion should be buildable only if the player has the techs militarism and iron working (iron working is used in the unit.txt with EnableAdvance, and militarism via SLIC).
Trouble is :
- Legion can appear in the buildable units list as soon as I discover Iron Working. But they do not appear every time ! ("random" behaviour every time you open the build list of the city). When I try to add the unit, it is not added in the list... Most of the time... If I click fast enough, I can add some legions in the lists (like 2 legions if I click 10 times...).
How can I make it work??
Comment