Aller au contenu

Photo

Making an item that cannot be unequipped?


  • Veuillez vous connecter pour répondre
20 réponses à ce sujet

#1
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages
 Just a quick on here - is there a way to create a "cursed" item that cannot be unequpped until certain conditions are met, Baldur's Gate-style? The standard "cursed" funtion only seems to stop the PC from dropping or selling a given item; I need a certain item (a cursed amulet) to stay in its slot until the relevant quest is finished.

#2
Shadooow

Shadooow
  • Members
  • 4 465 messages
of course, you can re-equip the item in the OnUnEquip event

#3
Krevett

Krevett
  • Members
  • 104 messages
Here's my item_equip script:

#include "inc_functions"
void main()
{
object oPC = GetPCItemLastEquippedBy();
object oItem = GetPCItemLastEquipped();
string sTag = GetTag(oItem);
////////////////////////////////////////////////////////////////////////////////
if (!GetIsCursed(oPC) && sTag == "grandeepee16")
 {
 SetLocalInt(oPC, "cursed", 1);
 SetBerserk(oPC);
 }
else if (!GetIsCursed(oPC) && sTag == "ceinture23")
 {
 SetLocalInt(oPC, "cursed", 1);
 SetLocalInt(oPC, "apparence", GetAppearanceType(oPC));
 if (GetGender(oPC) == GENDER_MALE) SetCreatureAppearanceType(oPC, APPEARANCE_TYPE_FEMALE_01);
 else if (GetGender(oPC) == GENDER_FEMALE) SetCreatureAppearanceType(oPC, APPEARANCE_TYPE_MALE_01);
 }
//
if (GetIsCursed(oItem))
 {
 SetLocalInt(oPC, "cursed", 1);
 SetLocalInt(oItem, "cursed", 2);
 }
}

My item_unequip script:

#include "inc_functions"
void main()
{
object oPC = GetPCItemLastUnequippedBy();
object oItem = GetPCItemLastUnequipped();
string sTag = GetTag(oItem);
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oPC) && GetIsCursed(oItem))
 {
 int nSlot = GetItemSlot(oItem);
 AssignCommand(oPC, ClearAllActions(TRUE));
 AssignCommand(oPC, ActionEquipItem(oItem, nSlot));
 SendMessageToPC(oPC, "Cet objet est maudit!");
 DelayCommand(0.1, SetCommandable(FALSE, oPC));
 DelayCommand(2.0, SetCommandable(TRUE, oPC));
 }
else if (!GetIsCursed(oPC) && GetIsCursed(oItem) && GetTag(oItem) == "ceinture23") SetCreatureAppearanceType(oPC, GetLocalInt(oPC, "apparence"));
if (!GetIsCursed(oPC) && GetIsCursed(oItem)) SetLocalInt(oItem, "cursed", 1);
}

My item_unacquire script:

#include "inc_functions"
void main()
{
object oPC = GetModuleItemLostBy();
object oItem = GetModuleItemLost();
string sTag = GetTag(oItem);
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oPC) && GetLocalInt(oItem, "cursed") == 2)
 {
 int nSlot = GetItemSlot(oItem);
 AssignCommand(oPC, ClearAllActions(TRUE));
 AssignCommand(oPC, ActionPickUpItem(oItem));
 AssignCommand(oPC, ActionEquipItem(oItem, nSlot));
 SendMessageToPC(oPC, "Cet objet est maudit!");
 DelayCommand(0.1, SetCommandable(FALSE, oPC));
 DelayCommand(2.0, SetCommandable(TRUE, oPC));
 }
}

And the two custom functions in my include:

int GetItemSlot(object oItem)
{
int nType = GetBaseItemType(oItem);
if (nType == BASE_ITEM_AMULET) return INVENTORY_SLOT_NECK;
else if (nType == BASE_ITEM_ARMOR) return INVENTORY_SLOT_CHEST;
else if (nType == BASE_ITEM_BASTARDSWORD ||
         nType == BASE_ITEM_BATTLEAXE ||
         nType == BASE_ITEM_CLUB ||
         nType == BASE_ITEM_DAGGER ||
         nType == BASE_ITEM_DIREMACE ||
         nType == BASE_ITEM_DOUBLEAXE ||
         nType == BASE_ITEM_DWARVENWARAXE ||
         nType == BASE_ITEM_GREATAXE ||
         nType == BASE_ITEM_GREATSWORD ||
         nType == BASE_ITEM_HALBERD ||
         nType == BASE_ITEM_HANDAXE ||
         nType == BASE_ITEM_HEAVYCROSSBOW ||
         nType == BASE_ITEM_HEAVYFLAIL ||
         nType == BASE_ITEM_KAMA ||
         nType == BASE_ITEM_KATANA ||
         nType == BASE_ITEM_KUKRI ||
         nType == BASE_ITEM_LIGHTCROSSBOW ||
         nType == BASE_ITEM_LIGHTFLAIL ||
         nType == BASE_ITEM_LIGHTHAMMER ||
         nType == BASE_ITEM_LIGHTMACE ||
         nType == BASE_ITEM_LONGBOW ||
         nType == BASE_ITEM_LONGSWORD ||
         nType == BASE_ITEM_MAGICROD ||
         nType == BASE_ITEM_MAGICSTAFF ||
         nType == BASE_ITEM_MAGICWAND ||
         nType == BASE_ITEM_MORNINGSTAR||
         nType == BASE_ITEM_QUARTERSTAFF ||
         nType == BASE_ITEM_RAPIER ||
         nType == BASE_ITEM_SCIMITAR ||
         nType == BASE_ITEM_SCYTHE ||
         nType == BASE_ITEM_SHORTBOW ||
         nType == BASE_ITEM_SHORTSPEAR ||
         nType == BASE_ITEM_SHORTSWORD ||
         nType == BASE_ITEM_SICKLE ||
         nType == BASE_ITEM_SLING ||
         nType == BASE_ITEM_TRIDENT ||
         nType == BASE_ITEM_TWOBLADEDSWORD ||
         nType == BASE_ITEM_WARHAMMER ||
         nType == BASE_ITEM_WHIP) return INVENTORY_SLOT_RIGHTHAND;
else if (nType == BASE_ITEM_BELT) return INVENTORY_SLOT_BELT;
else if (nType == BASE_ITEM_BOOTS) return INVENTORY_SLOT_BOOTS;
else if (nType == BASE_ITEM_BRACER ||
         nType == BASE_ITEM_GLOVES) return INVENTORY_SLOT_ARMS;
else if (nType == BASE_ITEM_CLOAK) return INVENTORY_SLOT_CLOAK;
else if (nType == BASE_ITEM_HELMET) return INVENTORY_SLOT_HEAD;
else if (nType == BASE_ITEM_LARGESHIELD ||
         nType == BASE_ITEM_SMALLSHIELD ||
         nType == BASE_ITEM_TOWERSHIELD) return INVENTORY_SLOT_RIGHTHAND;
else if (nType == BASE_ITEM_RING) return INVENTORY_SLOT_LEFTRING;
else return -1;
}

int GetIsCursed(object oObject)
{
if (GetLocalInt(oObject, "cursed") != 0) return TRUE;
return FALSE;
}


The only problem is with a ring in the right slot, it will be reequiped in the left slot... Otherwise it works pretty well for what you want to do. And in my spellhook, casting remove curse delete the local int on the pc or the item (depends on what you cast it). Of course for this to work you need to set the variable "cursed" to 1 on the item you want to be cursed!

Modifié par Krevett, 09 juillet 2012 - 04:07 .


#4
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages

Krevett wrote...

Here's my item_equip script:

#include "inc_functions"
void main()
{
object oPC = GetPCItemLastEquippedBy();
object oItem = GetPCItemLastEquipped();
string sTag = GetTag(oItem);
////////////////////////////////////////////////////////////////////////////////
if (!GetIsCursed(oPC) && sTag == "grandeepee16")
 {
 SetLocalInt(oPC, "cursed", 1);
 SetBerserk(oPC);
 }
else if (!GetIsCursed(oPC) && sTag == "ceinture23")
 {
 SetLocalInt(oPC, "cursed", 1);
 SetLocalInt(oPC, "apparence", GetAppearanceType(oPC));
 if (GetGender(oPC) == GENDER_MALE) SetCreatureAppearanceType(oPC, APPEARANCE_TYPE_FEMALE_01);
 else if (GetGender(oPC) == GENDER_FEMALE) SetCreatureAppearanceType(oPC, APPEARANCE_TYPE_MALE_01);
 }
//
if (GetIsCursed(oItem))
 {
 SetLocalInt(oPC, "cursed", 1);
 SetLocalInt(oItem, "cursed", 2);
 }
}

My item_unequip script:

#include "inc_functions"
void main()
{
object oPC = GetPCItemLastUnequippedBy();
object oItem = GetPCItemLastUnequipped();
string sTag = GetTag(oItem);
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oPC) && GetIsCursed(oItem))
 {
 int nSlot = GetItemSlot(oItem);
 AssignCommand(oPC, ClearAllActions(TRUE));
 AssignCommand(oPC, ActionEquipItem(oItem, nSlot));
 SendMessageToPC(oPC, "Cet objet est maudit!");
 DelayCommand(0.1, SetCommandable(FALSE, oPC));
 DelayCommand(2.0, SetCommandable(TRUE, oPC));
 }
else if (!GetIsCursed(oPC) && GetIsCursed(oItem) && GetTag(oItem) == "ceinture23") SetCreatureAppearanceType(oPC, GetLocalInt(oPC, "apparence"));
if (!GetIsCursed(oPC) && GetIsCursed(oItem)) SetLocalInt(oItem, "cursed", 1);
}

My item_unacquire script:

#include "inc_functions"
void main()
{
object oPC = GetModuleItemLostBy();
object oItem = GetModuleItemLost();
string sTag = GetTag(oItem);
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oPC) && GetLocalInt(oItem, "cursed") == 2)
 {
 int nSlot = GetItemSlot(oItem);
 AssignCommand(oPC, ClearAllActions(TRUE));
 AssignCommand(oPC, ActionPickUpItem(oItem));
 AssignCommand(oPC, ActionEquipItem(oItem, nSlot));
 SendMessageToPC(oPC, "Cet objet est maudit!");
 DelayCommand(0.1, SetCommandable(FALSE, oPC));
 DelayCommand(2.0, SetCommandable(TRUE, oPC));
 }
}

And the two custom functions in my include:

int GetItemSlot(object oItem)
{
int nType = GetBaseItemType(oItem);
if (nType == BASE_ITEM_AMULET) return INVENTORY_SLOT_NECK;
else if (nType == BASE_ITEM_ARMOR) return INVENTORY_SLOT_CHEST;
else if (nType == BASE_ITEM_BASTARDSWORD ||
         nType == BASE_ITEM_BATTLEAXE ||
         nType == BASE_ITEM_CLUB ||
         nType == BASE_ITEM_DAGGER ||
         nType == BASE_ITEM_DIREMACE ||
         nType == BASE_ITEM_DOUBLEAXE ||
         nType == BASE_ITEM_DWARVENWARAXE ||
         nType == BASE_ITEM_GREATAXE ||
         nType == BASE_ITEM_GREATSWORD ||
         nType == BASE_ITEM_HALBERD ||
         nType == BASE_ITEM_HANDAXE ||
         nType == BASE_ITEM_HEAVYCROSSBOW ||
         nType == BASE_ITEM_HEAVYFLAIL ||
         nType == BASE_ITEM_KAMA ||
         nType == BASE_ITEM_KATANA ||
         nType == BASE_ITEM_KUKRI ||
         nType == BASE_ITEM_LIGHTCROSSBOW ||
         nType == BASE_ITEM_LIGHTFLAIL ||
         nType == BASE_ITEM_LIGHTHAMMER ||
         nType == BASE_ITEM_LIGHTMACE ||
         nType == BASE_ITEM_LONGBOW ||
         nType == BASE_ITEM_LONGSWORD ||
         nType == BASE_ITEM_MAGICROD ||
         nType == BASE_ITEM_MAGICSTAFF ||
         nType == BASE_ITEM_MAGICWAND ||
         nType == BASE_ITEM_MORNINGSTAR||
         nType == BASE_ITEM_QUARTERSTAFF ||
         nType == BASE_ITEM_RAPIER ||
         nType == BASE_ITEM_SCIMITAR ||
         nType == BASE_ITEM_SCYTHE ||
         nType == BASE_ITEM_SHORTBOW ||
         nType == BASE_ITEM_SHORTSPEAR ||
         nType == BASE_ITEM_SHORTSWORD ||
         nType == BASE_ITEM_SICKLE ||
         nType == BASE_ITEM_SLING ||
         nType == BASE_ITEM_TRIDENT ||
         nType == BASE_ITEM_TWOBLADEDSWORD ||
         nType == BASE_ITEM_WARHAMMER ||
         nType == BASE_ITEM_WHIP) return INVENTORY_SLOT_RIGHTHAND;
else if (nType == BASE_ITEM_BELT) return INVENTORY_SLOT_BELT;
else if (nType == BASE_ITEM_BOOTS) return INVENTORY_SLOT_BOOTS;
else if (nType == BASE_ITEM_BRACER ||
         nType == BASE_ITEM_GLOVES) return INVENTORY_SLOT_ARMS;
else if (nType == BASE_ITEM_CLOAK) return INVENTORY_SLOT_CLOAK;
else if (nType == BASE_ITEM_HELMET) return INVENTORY_SLOT_HEAD;
else if (nType == BASE_ITEM_LARGESHIELD ||
         nType == BASE_ITEM_SMALLSHIELD ||
         nType == BASE_ITEM_TOWERSHIELD) return INVENTORY_SLOT_RIGHTHAND;
else if (nType == BASE_ITEM_RING) return INVENTORY_SLOT_LEFTRING;
else return -1;
}

int GetIsCursed(object oObject)
{
if (GetLocalInt(oObject, "cursed") != 0) return TRUE;
return FALSE;
}


The only problem is with a ring in the right slot, it will be reequiped in the left slot... Otherwise it works pretty well for what you want to do. And in my spellhook, casting remove curse delete the local int on the pc or the item (depends on what you cast it).

Thanks, I read through that and it looks just about perfect. I'm kind of ashamed to have been scripting for a good four years and still being unable to do such basic stuff! 

Modifié par Mr. Versipellis, 09 juillet 2012 - 04:46 .


#5
Krevett

Krevett
  • Members
  • 104 messages
I was just a perfect beginner two years ago (in the toolset) and it took me a while putting this to work :) so bad that cursed items can't be done more easily!! I didn't put the SetBerserk function but you might guess what it's about!!!

#6
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages

Krevett wrote...

I was just a perfect beginner two years ago (in the toolset) and it took me a while putting this to work :) so bad that cursed items can't be done more easily!! I didn't put the SetBerserk function but you might guess what it's about!!!

How times change! I think the beserk thing is a bit much - this is for story reasons (the amulet I'm working with is part of a magical crystal which is embedded in the PC's chest until the end of the quest, when it gets removed.) I'm still a little confused -  where would I need to put each script and where which variables need changing to get it working properly? 

#7
Krevett

Krevett
  • Members
  • 104 messages
these three scripts each go in the corresponding module event (OnPlayerEquipItem, OnPlayerUnEquipItem, OnUnAcquireItem).
Also if you just want an item that cannot be removed you can just use these:

OnEquip:
#include "inc_functions"
void main()
{
object oPC = GetPCItemLastEquippedBy();
object oItem = GetPCItemLastEquipped();
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oItem))
{
SetLocalInt(oPC, "cursed", 1);
SetLocalInt(oItem, "cursed", 2);
}
}


OnUnEquip:
#include "inc_functions"
void main()
{
object oPC = GetPCItemLastUnequippedBy();
object oItem = GetPCItemLastUnequipped();
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oPC) && GetIsCursed(oItem))
{
int nSlot = GetItemSlot(oItem);
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionEquipItem(oItem, nSlot));
SendMessageToPC(oPC, "Cet objet est maudit!");
DelayCommand(0.1, SetCommandable(FALSE, oPC));
DelayCommand(2.0, SetCommandable(TRUE, oPC));
}
if (!GetIsCursed(oPC) && GetIsCursed(oItem)) SetLocalInt(oItem, "cursed", 1);
}

OnUnAcquire:
#include "inc_functions"
void main()
{
object oPC = GetModuleItemLostBy();
object oItem = GetModuleItemLost();
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oPC) && GetLocalInt(oItem, "cursed") == 2)
{
int nSlot = GetItemSlot(oItem);
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionPickUpItem(oItem));
AssignCommand(oPC, ActionEquipItem(oItem, nSlot));
SendMessageToPC(oPC, "Cet objet est maudit!");
DelayCommand(0.1, SetCommandable(FALSE, oPC));
DelayCommand(2.0, SetCommandable(TRUE, oPC));
}
}

And when creating your amulet put a local variable "cursed" on it set to 1.
You will also need the two functions GetItemSlot and GetIsCursed of course!

Modifié par Krevett, 09 juillet 2012 - 05:38 .


#8
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages

Krevett wrote...

these three scripts each go in the corresponding module event (OnPlayerEquipItem, OnPlayerUnEquipItem, OnUnAcquireItem).
Also if you just want an item that cannot be removed you can just use these:

OnEquip:
#include "inc_functions"
void main()
{
object oPC = GetPCItemLastEquippedBy();
object oItem = GetPCItemLastEquipped();
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oItem))
{
SetLocalInt(oPC, "cursed", 1);
SetLocalInt(oItem, "cursed", 2);
}
}


OnUnEquip:
#include "inc_functions"
void main()
{
object oPC = GetPCItemLastUnequippedBy();
object oItem = GetPCItemLastUnequipped();
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oPC) && GetIsCursed(oItem))
{
int nSlot = GetItemSlot(oItem);
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionEquipItem(oItem, nSlot));
SendMessageToPC(oPC, "Cet objet est maudit!");
DelayCommand(0.1, SetCommandable(FALSE, oPC));
DelayCommand(2.0, SetCommandable(TRUE, oPC));
}
if (!GetIsCursed(oPC) && GetIsCursed(oItem)) SetLocalInt(oItem, "cursed", 1);
}

OnUnAcquire:
#include "inc_functions"
void main()
{
object oPC = GetModuleItemLostBy();
object oItem = GetModuleItemLost();
////////////////////////////////////////////////////////////////////////////////
if (GetIsCursed(oPC) && GetLocalInt(oItem, "cursed") == 2)
{
int nSlot = GetItemSlot(oItem);
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionPickUpItem(oItem));
AssignCommand(oPC, ActionEquipItem(oItem, nSlot));
SendMessageToPC(oPC, "Cet objet est maudit!");
DelayCommand(0.1, SetCommandable(FALSE, oPC));
DelayCommand(2.0, SetCommandable(TRUE, oPC));
}
}

And when creating your amulet put a local variable "cursed" on it set to 1.
You will also need the two functions GetItemSlot and GetIsCursed of course!

I think I get it. Wouldn't it be more simple just to do a tag-based script that re-equipped the item, though?

#9
Krevett

Krevett
  • Members
  • 104 messages
The problem lies in the unacquire then... It probably needs some testing but I think that if you just make the item beeing re-equipped on unequipping it and the player tries to drop it directly the item get dropped on the ground. That's why I dit the script that way, but anyway it could be tagbased with some small change ;-)

#10
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages

Krevett wrote...

The problem lies in the unacquire then... It probably needs some testing but I think that if you just make the item beeing re-equipped on unequipping it and the player tries to drop it directly the item get dropped on the ground. That's why I dit the script that way, but anyway it could be tagbased with some small change ;-)

Ah, in that case, I'll just go with your version - it's not that there was anything wrong with it, I just like to find the very best way of doing such things! Thanks terribly for the fast replies, if you ever need help with anything NWN-related, don't hesitate to ask c:

#11
Krevett

Krevett
  • Members
  • 104 messages
I also like to find an optimal way to do things but unfortunatly haven't found something better for now (and it works well for what I want to do so...) anyway a pleasure to help!! Good night for those other frenchies here!!

#12
ShadowM

ShadowM
  • Members
  • 768 messages
Why are you not using GetItemCursedFlag(object oItem) and SetItemCursedFlag(object oItem, int nCursed) functions to make the item not dropable?

#13
Krevett

Krevett
  • Members
  • 104 messages
Because I want the item to be droppable if not equipped

#14
Mr. Versipellis

Mr. Versipellis
  • Members
  • 206 messages
Hmm... I can't seem to get these working. I did what you said, and when I unequip the item, I get the message. However, at the same time, it appears normally in my inventory, and as a kind of "ghost image" in the neck slot. Any clue what's causing this?

#15
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
The GUI is not updating on the screen. Close your character sheet and reopen it, to see where your items really are.

#16
ShadowM

ShadowM
  • Members
  • 768 messages

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.

#17
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
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 .


#18
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
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 .


#19
Krevett

Krevett
  • Members
  • 104 messages
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 :)

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


#20
ShadowM

ShadowM
  • Members
  • 768 messages
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

#21
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
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 Image

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 Image

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