Author Topic: Making an item that cannot be unequipped?  (Read 1028 times)

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Making an item that cannot be unequipped?
« Reply #15 on: July 10, 2012, 05:38:14 pm »


               

Krevett wrote...

Because I want the item to be droppable if not equipped


Yeah and you can do all that within on equip and un equip. You do not even need the on aquire part.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Making an item that cannot be unequipped?
« Reply #16 on: July 10, 2012, 06:05:44 pm »


               This is what ShadowM is talking about - add it to you Module Unequip Event. You will only need this one script to handle the effects of the item being cursed.
.

if (GetItemCursedFlag(oItem) == TRUE)
{
int nItemType = GetBaseItemType(oItem);
int nSlot;

switch (nItemType)
{
case BASE_ITEM_AMULET : nSlot = INVENTORY_SLOT_NECK; break;
case BASE_ITEM_ARMOR : nSlot = INVENTORY_SLOT_CHEST; break;
case BASE_ITEM_BASTARDSWORD : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_BATTLEAXE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_BELT : nSlot = INVENTORY_SLOT_BELT; break;
case BASE_ITEM_CLUB : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_DAGGER : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_DIREMACE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_DOUBLEAXE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_DWARVENWARAXE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_GLOVES : nSlot = INVENTORY_SLOT_ARMS; break;
case BASE_ITEM_GREATAXE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_GREATSWORD : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_HALBERD : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_HANDAXE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_HEAVYCROSSBOW : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_HEAVYFLAIL : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_HELMET : nSlot = INVENTORY_SLOT_HEAD; break;
case BASE_ITEM_KAMA : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_KATANA : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_KUKRI : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_LARGESHIELD : nSlot = INVENTORY_SLOT_LEFTHAND; break;
case BASE_ITEM_LIGHTCROSSBOW : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_LIGHTFLAIL : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_LIGHTHAMMER : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_LIGHTMACE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_LONGBOW : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_LONGSWORD : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_MORNINGSTAR : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_QUARTERSTAFF : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_RAPIER : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_RING : nSlot = INVENTORY_SLOT_RIGHTRING; break;
case BASE_ITEM_SCIMITAR : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_SCYTHE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_SHORTBOW : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_SHORTSPEAR : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_SHORTSWORD : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_SICKLE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_SMALLSHIELD : nSlot = INVENTORY_SLOT_LEFTHAND; break;
case BASE_ITEM_THROWINGAXE : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_TOWERSHIELD : nSlot = INVENTORY_SLOT_LEFTHAND; break;
case BASE_ITEM_TRIDENT : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_TWOBLADEDSWORD : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_WARHAMMER : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
case BASE_ITEM_WHIP : nSlot = INVENTORY_SLOT_RIGHTHAND; break;
}

AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionEquipItem(oItem, nSlot));
SendMessageToPC(oPC, "You cannot unequip this item - it's cursed!");
}

               
               

               


                     Modifié par Pstemarie, 10 juillet 2012 - 05:13 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Making an item that cannot be unequipped?
« Reply #17 on: July 10, 2012, 06:09:41 pm »


               Oops didn't see the post about "droppable if not equipped". In that case don't use cursed flag, use a local variable on the item and change the line

if (GetItemCursedFlag(oItem) == TRUE)

to

if (GetLocalInt(oItem, "FLAG_CURSED") == 1)

The variable will be named "FLAG_CURSED" and set to "1" if you want the item to be cursed.
               
               

               


                     Modifié par Pstemarie, 10 juillet 2012 - 05:11 .
                     
                  


            

Legacy_Krevett

  • Full Member
  • ***
  • Posts: 203
  • Karma: +0/-0
Making an item that cannot be unequipped?
« Reply #18 on: July 10, 2012, 06:11:36 pm »


               Without the unacquire event, with the cursed item equipped I simply right click the item and select drop...the item is unequipped and dropped on the ground!! That's why I added the unacquire event.

Edit: Yes pstemarie that's why I use variable instead of cursed flag '<img'>
               
               

               


                     Modifié par Krevett, 10 juillet 2012 - 05:12 .
                     
                  


            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Making an item that cannot be unequipped?
« Reply #19 on: July 10, 2012, 10:20:24 pm »


               It would let you do that if you did not flag the item SetItemCursedFlag(object oItem, int nCursed) to true which you do on the equip part. Check out my hr_base equip script and functions, been tested for years and does not use on aquire or on onunaquire scripts. Allow everything you said inventory items can be dropped, cursed items equip cannot be drop or unequiped
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Making an item that cannot be unequipped?
« Reply #20 on: July 11, 2012, 12:39:21 am »


               ShadowM, I just thought of why you did it with OnEquip and OnUnEquip - nice way to hide the curse until the player equips the item 'Posted

When the item is equipped you set the cursed flag to TRUE, then when they try to unequip it (using the script I posted above, for example) they can't because its cursed. 'Posted
               
               

               


                     Modifié par Pstemarie, 10 juillet 2012 - 11:40 .