I'm creating a "Text appears when..." check in a conversation line (logically it says [Slit his throat]) that should only be visible when the PC has a weapon in hands or inventory.
I'm using Get2DAString() function in a loop. I read somewhere that it doesn't have good performance when used in a loop but I can't think of a better way.
int StartingConditional()
{
int iResult;
int i;
object oPC = GetPCSpeaker();
int iBaseType;
object oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem)) {
iBaseType = GetBaseItemType(oItem);
if ( StringToInt(Get2DAString("baseitems", "WeaponType", iBaseType)) ){
iResult = TRUE;
}
oItem = GetNextItemInInventory(oPC);
}
for (i = 0; i < NUM_INVENTORY_SLOTS; ++i) {
oItem = GetItemInSlot(i, oPC);
iBaseType = GetBaseItemType(oItem);
if ( StringToInt(Get2DAString("baseitems", "WeaponType", iBaseType)) ){
iResult = TRUE;
}
}
return iResult;
}
So far so good, but how can I check if the PC can equip the item? It's nice if he has a Battle Axe in his backpack but I don't want the conversation line to show if he is not able to wield it.