127 lines
3.2 KiB
Plaintext
127 lines
3.2 KiB
Plaintext
/*
|
|
s_lore_pickup - "Lore" items (from EQ)
|
|
|
|
This script prevents a PC from collecting more than one item
|
|
designated as "Lore"
|
|
|
|
To use:
|
|
|
|
1) Incorporate this script into Module::OnAcquireItem. s_acquireitem,
|
|
included with this package, is an example
|
|
|
|
2) Update the list of Tags in GetIsLore() (in i_tagtests)
|
|
to include the items you designate as Lore
|
|
|
|
3) Recompile this script
|
|
|
|
|
|
Author: Scott Thorne
|
|
E-mail: Thornex2@wans.net
|
|
Updated: Sept 01, 2002
|
|
|
|
*/
|
|
|
|
#include "i_tagtests"
|
|
|
|
int AlreadyHaveOne(object oOriginal);
|
|
|
|
|
|
void main () {
|
|
|
|
object oItem = GetModuleItemAcquired();
|
|
|
|
if (GetIsPC(OBJECT_SELF)) {
|
|
|
|
if (AlreadyHaveOne(oItem)) {
|
|
|
|
if (GetIsNoDrop(oItem)) {
|
|
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_MAGBLUE), OBJECT_SELF);
|
|
SpeakString("Yikes! It just exploded in my hands!");
|
|
DestroyObject(oItem);
|
|
|
|
} else {
|
|
|
|
ActionDoCommand(SetCommandable(FALSE));
|
|
ActionDoCommand(ClearAllActions());
|
|
ActionSpeakString("Hmm, I already have one of these.");
|
|
ActionPutDownItem(oItem);
|
|
ActionDoCommand(SetCommandable(TRUE));
|
|
|
|
}
|
|
}
|
|
|
|
} /* if */
|
|
|
|
} /* main() */
|
|
|
|
|
|
|
|
/* check for an equipped item matching the original's tag */
|
|
int SlotMatch(object oOriginal, int iSlot) {
|
|
|
|
object oItem = GetItemInSlot(iSlot);
|
|
int iSlotMatch = ((GetTag(oItem) == GetTag(oOriginal)) && (oItem != oOriginal));
|
|
|
|
return iSlotMatch;
|
|
}
|
|
|
|
|
|
/* check inventory and equipped items to see if they already have an item */
|
|
int AlreadyHaveOne(object oOriginal) {
|
|
|
|
int iAlreadyHaveOne = FALSE;
|
|
|
|
string sItemTag = GetTag(oOriginal);
|
|
object oItem = GetFirstItemInInventory();
|
|
while (GetIsObjectValid(oItem)) {
|
|
|
|
if ((GetTag(oItem) == sItemTag) && (oItem != oOriginal)) {
|
|
|
|
iAlreadyHaveOne = TRUE;
|
|
break;
|
|
|
|
}
|
|
|
|
oItem = GetNextItemInInventory();
|
|
|
|
} /* while */
|
|
|
|
|
|
/* check equipped slots too as they are seperate from inventory */
|
|
if (!iAlreadyHaveOne) {
|
|
|
|
iAlreadyHaveOne = TRUE;
|
|
|
|
do {
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_ARMS)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_ARROWS)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_BELT)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_BOLTS)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_BOOTS)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_BULLETS)) break;
|
|
//if (SlotMatch(oOriginal, INVENTORY_SLOT_CARMOUR)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_CHEST)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_CLOAK)) break;
|
|
//if (SlotMatch(oOriginal, INVENTORY_SLOT_CWEAPON_B)) break;
|
|
//if (SlotMatch(oOriginal, INVENTORY_SLOT_CWEAPON_L)) break;
|
|
//if (SlotMatch(oOriginal, INVENTORY_SLOT_CWEAPON_R)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_HEAD)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_LEFTHAND)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_LEFTRING)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_NECK)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_RIGHTHAND)) break;
|
|
if (SlotMatch(oOriginal, INVENTORY_SLOT_RIGHTRING)) break;
|
|
|
|
iAlreadyHaveOne = FALSE;
|
|
|
|
} while (FALSE);
|
|
|
|
} /* if */
|
|
|
|
return iAlreadyHaveOne;
|
|
|
|
} /* AlreadyHaveOne() */
|
|
|
|
|