JFD
Kathigitarkh
Yup, I've ensured that everything is quite modular.
Might not be the best place, but since Whoward isn't responding, I might try asking here.
Any idea what "iName" in "UnitCanHaveName" represents? Is there any way to link it to an actual name? (To stay on topic, an "InitUnitWithSpecificName" function would be nice if it were possible).
The problem is, iName is an integer, and I've no idea how to link that to actual names; especially since the name the number corresponds to seems to be inconsistent.I'm pretty sure it refers to the specific name of the unit (i.e. a Great Person's name). So that you have iPlayer, iUnit, iName, where iPlayer is the player, iUnit the unit's type/ID, and iName the unit's specific name.
More or less, yeah. It'd be useful for more flavourful decisions involving Great Artists and such. Maybe something like "pPlayer:InitUnitWithSpecificName(iUnit, sNameKey, iX, iY, bAbort)" with "bAbort" signifying that the unit should simply be deleted if the name isn't available, rather than falling back with a randomly picked name.Regarding 'InitUnitWithSpecificName,' care to give me an example? Are you wanting to be able to specifically create a single named unit?
G
The problem is, iName is an integer, and I've no idea how to link that to actual names; especially since the name the number corresponds to seems to be inconsistent.
More or less, yeah. It'd be useful for more flavourful decisions involving Great Artists and such. Maybe something like "pPlayer:InitUnitWithSpecificName(iUnit, sNameKey, iX, iY, bAbort)" with "bAbort" signifying that the unit should simply be deleted if the name isn't available, rather than falling back with a randomly picked name.
The problem is, iName is an integer, and I've no idea how to link that to actual names; especially since the name the number corresponds to seems to be inconsistent.
More or less, yeah. It'd be useful for more flavourful decisions involving Great Artists and such. Maybe something like "pPlayer:InitUnitWithSpecificName(iUnit, sNameKey, iX, iY, bAbort)" with "bAbort" signifying that the unit should simply be deleted if the name isn't available, rather than falling back with a randomly picked name.
The table doesn't have an ID column though; so I'm not sure how to get that value.The integer is determined by the Unit_UniqueNames Table, I believe. Pull that up in an SQL viewer and you'll see that, for example, Imhotep is ID# 68.
The problem is, iName is an integer, and I've no idea how to link that to actual names; especially since the name the number corresponds to seems to be inconsistent.
More or less, yeah. It'd be useful for more flavourful decisions involving Great Artists and such. Maybe something like "pPlayer:InitUnitWithSpecificName(iUnit, sNameKey, iX, iY, bAbort)" with "bAbort" signifying that the unit should simply be deleted if the name isn't available, rather than falling back with a randomly picked name.
I added a lua function that works like this - see the patchnotes for the 2-15 version for instructions. Let me know if it works!
G
It works fine! Thanks! But our of interest, is there an easy way to retrieve the name's ID via lua?
#if defined(MOD_BALANCE_CORE)
//CvUnit* CvPlayer::initNamedUnit(UnitTypes eUnit, const char* strKey, int iX, int iY, UnitAITypes eUnitAI = NO_UNITAI, DirectionTypes eFacingDirection = NO_DIRECTION);
int CvLuaPlayer::lInitNamedUnit(lua_State* L)
{
CvPlayerAI* pkPlayer = GetInstance(L);
const UnitTypes eUnit = (UnitTypes)lua_tointeger(L, 2);
const char* strKey = lua_tostring(L, 3);
const int x = lua_tointeger(L, 4);
const int y = lua_tointeger(L, 5);
const UnitAITypes eUnitAI = (UnitAITypes)luaL_optint(L, 6, NO_UNITAI);
const DirectionTypes eFacingDirection = (DirectionTypes)luaL_optint(L, 7, NO_DIRECTION);
CvUnit* pkUnit = pkPlayer->initNamedUnit(eUnit, strKey, x, y, eUnitAI, eFacingDirection);
CvLuaUnit::Push(L, pkUnit);
return 1;
}
#endif
Ah, got it. Thanks. I don't suppose there's a shortcut to finding an avaliable Great Work slot?
Method(GetNumGreatWorks);
Method(GetNumGreatWorkSlots);
Better yet:
pPlayer:GetCityOfClosestGreatWorkSlot(iX, iY, iGreatWorkSlotType)
iGreatWorkSlotType being something like GameInfoTypes.GREAT_WORK_SLOT_ART_ARTIFACT. Note that if there are no open slots of the specified iGreatWorkSlotType available, the function returns nil.
Edit: Any feedback for my requests above?