GetFirstItemInInventory(object)
オブジェクトの所持品にある最初のアイテムを調べます。
object GetFirstItemInInventory( object oTarget = OBJECT_SELF );
Parameters
oTarget
所持品を持っているオブジェクト。(デフォルトではOBJECT_SELF)
Description
oTargetの所持品にある最初のアイテムを返します(oTargetの所持品のアイテム全て調べ始めます)。
そしてスクリプトを呼び出したのがクリーチャーでなかったり、アイテムや配置物や商店だった場合、もしくはアイテムが見つからなかった場合はOBJECT_INVALIDを返します。
Remarks
次の2番目の例のスクリプトを見てください。これはファクションが必要なだけのアイテムや装備品を持っているかをチェックします。
これは所持品の18個ある装備スロットを全て取得するために、0から17までループさせる必要があります。
Version
1.31
Example
// この関数は最初のPCの所持品のアイテムを全て数え上げます。
//(積み重ねられているアイテムはその合計数を数えます)
main()
{
int nItems = 0;
object oItem = GetFirstItemInInventory(GetFirstPC());
while (GetIsObjectValid(oItem) == TRUE)
{
nItems = nItems + GetNumStackedItems(oItem);
oItem = GetNextItemInInventory(GetFirstPC());
}
}
/*
CheckFactionForItemseのサンプル
この関数では、あなたはファクションのメンバーの所持品か装備品に入っているアイテムの 数を調べられます。
Created By: Arlas Gilhith (arlas@cyberlife-studios.de)
Created On: 29.07.2003
*/
int CheckFactionForItems(object oMemberOfFaction, string sItem,
int nAmount = 2)
{
int iCnt = 0;
int i;
object oMember = GetFirstFactionMember(oMemberOfFaction, FALSE);
object oItem;
// ファクションのメンバーをループさせます
while (!(oMember == OBJECT_INVALID) && (iCnt < nAmount))
{
oItem = GetFirstItemInInventory(oMember);
// 所持品欄にあるアイテムをチェックします
while (!(oItem == OBJECT_INVALID) && (iCnt < nAmount))
{
if (GetTag(oItem) == sItem)
iCnt++;
oItem = GetNextItemInInventory(oMember);
}
// 装備欄のアイテムをチェックします
for (i = 0; i < NUM_INVENTORY_SLOTS; ++i)
{
if (!(GetItemInSlot(i, oMember) == OBJECT_INVALID)
&& (GetTag(GetItemInSlot(i, oMember)) == sItem))
iCnt++;
}
oMember = GetNextFactionMember(oMemberOfFaction, FALSE);
}
return (iCnt >= nAmount);
}
// この例(カンバセーションでstarting conditionaを使用)では、話者のファクションから
//4つのハチェットを得ました。
int StartingConditional()
{
return CheckFactionForItems(OBJECT_SELF, "NW_WAXHN001", 4);
}
See Also
| functions: | GetNextItemInInventory |
| categories: | Inventory Functions |
author: Tom Cassiotis, editor: Charles Feduke, additional contributor(s): Marc Ermshaus, JP team: NamaYake
Send comments on this topic.