DLL - Lua API requests

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).
 
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).

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.

Regarding 'InitUnitWithSpecificName,' care to give me an example? Are you wanting to be able to specifically create a single named unit?

G
 
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.
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.

Regarding 'InitUnitWithSpecificName,' care to give me an example? Are you wanting to be able to specifically create a single named unit?

G
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 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.

I'll look into the function for you, and I'll post here when I add it.

Cheers,

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.

That would be useful. I've made countless unique units that are dummy Artists/Writers/Musicians for decisions and events. Of course, that's for my civs, so this feature wouldn't really help me much. But the usefulness is attested.
 
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 table doesn't have an ID column though; so I'm not sure how to get that value.

I honestly am not sure it's the ID though, like I said, it's not constant. Returning true when the ID is equal to, say 66, never gets me the same Great Person.
 
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
 
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?
 
It works fine! Thanks! But our of interest, is there an easy way to retrieve the name's ID via lua?

I don't think so, as the data isn't cached in the DLL - it is read out of the XML files. The ID # is the best way to correctly select the GP, though I can make it based on the UniqueName column if that would be easier. In short, I can replace the ID # in the function with the UniqueName, and that would be used for finding it.

Edit: Okay, I've rewritten it so that you put the TXT_KEY file in the function instead of the ID#. It looks like this:

Code:
#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

I think that this will be easier to use.

G
 
Sorry for the double post, but it's been a few days.

I have another request. Could we have a tag in the UnitPromotions table which prevents a unit from being captured from things such as Suleiman's vanilla trait?
 
How does Game.CreateGreatWork() work?

Using it in Firetuner, it only ever returns an incremental number according to however many times I fire it. Never creates a Great Work, so perhaps I misunderstand its purpose.
 
The number is the GW id, you'll need to assign the GW into a building slot
 
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?
 
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?

Once I get this version finished, I'll look at them – sorry for the delay, busy week!
G
 
Top Bottom