//The following is meant to be used as an include file. It contains a
function "IsArmed" which reports if a player is armed. This is useful for
starting //conditionals in conversations, where you could have an NPC say
something like: "I do not speak to armed thugs." if the player was armed when
//speaking to them.
//::///////////////////////////////////////////////
//:: Name Armed?
//:: FileName armed_include.txt
//:://////////////////////////////////////////////
/*
This file is designed to be used as an include. It contains
three functions:
int IsInInventory(object oContainer, string sItemTag)
This function returns TRUE if the specified Item Tag is found
in the inventory of oContainer.
int IsWeapon(int nBaseType)
This function returns TRUE if the specified base type is a
weapon. You would use this in conjunction with the function
GetBaseItemType(object oItem).
int IsArmed(object oPC)
This function returns TRUE if the specified player is armed
(checking both left and right hands). It does NOT check the
special creature slots, but if you need that it is trivial
to add.
*/
//:://////////////////////////////////////////////
//:: Created By: Ped Xing (pedx1ng@lycos.com)
//:: Created On: 02 July, 2002
//:://////////////////////////////////////////////
// This function determines if a specific item exists in the
// specfified container, which can be a creature or placeable
// object that is a container.
int IsInInventory(object oContainer, string sItemTag)
{
object oItem;
if (GetHasInventory(oContainer))
{
oItem = GetFirstItemInInventory(oContainer);
while ( OBJECT_INVALID != oItem )
{
if (GetTag(oItem) == sItemTag)
{ return TRUE; }
oItem = GetNextItemInInventory(oContainer);
} // end while
} // endif
return FALSE;
} // end IsInInventory
// This function determines if the specified base-type is a weapon base-type
// Returns TRUE if a weapon, FALSE if not
int IsWeapon(int nBaseType)
{
int nResult;
switch (nBaseType)
{
case BASE_ITEM_BASTARDSWORD :
case BASE_ITEM_BATTLEAXE :
case BASE_ITEM_CBLUDGWEAPON :
case BASE_ITEM_CLUB :
case BASE_ITEM_DAGGER :
case BASE_ITEM_DART :
case BASE_ITEM_DIREMACE :
case BASE_ITEM_DOUBLEAXE :
case BASE_ITEM_GREATAXE :
case BASE_ITEM_GREATSWORD :
case BASE_ITEM_HALBERD :
case BASE_ITEM_HANDAXE :
case BASE_ITEM_HEAVYCROSSBOW :
case BASE_ITEM_HEAVYFLAIL :
case BASE_ITEM_KAMA :
case BASE_ITEM_KATANA :
case BASE_ITEM_KUKRI :
case BASE_ITEM_LIGHTCROSSBOW :
case BASE_ITEM_LIGHTFLAIL :
case BASE_ITEM_LIGHTHAMMER :
case BASE_ITEM_LIGHTMACE :
case BASE_ITEM_LONGBOW :
case BASE_ITEM_LONGSWORD :
case BASE_ITEM_MAGICROD :
case BASE_ITEM_MAGICSTAFF :
case BASE_ITEM_MAGICWAND : // maybe shouldn't treat this as weapon??
case BASE_ITEM_MORNINGSTAR :
case BASE_ITEM_QUARTERSTAFF :
case BASE_ITEM_RAPIER :
case BASE_ITEM_SCIMITAR :
case BASE_ITEM_SCYTHE :
case BASE_ITEM_SHORTBOW :
case BASE_ITEM_SHORTSPEAR :
case BASE_ITEM_SHORTSWORD :
case BASE_ITEM_SHURIKEN :
case BASE_ITEM_SICKLE :
case BASE_ITEM_SLING :
case BASE_ITEM_THROWINGAXE :
case BASE_ITEM_TWOBLADEDSWORD :
case BASE_ITEM_WARHAMMER : return TRUE;
break;
}
return FALSE;
} // end IsWeapon
// This function checks if the specified character has weapons drawn
// Returns TRUE or FALSE
int IsArmed(object oPC)
{
object oItem = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
int nBaseType1 = GetBaseItemType(oItem);
oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
int nBaseType2 = GetBaseItemType(oItem);
if (IsWeapon(nBaseType1) == TRUE || IsWeapon(nBaseType2) == TRUE) { return TRUE;
}
return FALSE;
} // end IsArmed
/*
void main()
{
}
*/