and the contrary (unequip monk gloves when equip a weapon)
How to unequip a weapon when equip a monk gloves?
#1
Posté 06 juillet 2014 - 01:19
#2
Posté 06 juillet 2014 - 04:46
If this is for PCs then just use the module events for OnPlayerEquipItem and OnPlayerUnequipItem. The base item type should tell you whether the item is gloves or a weapon.
#3
Posté 06 juillet 2014 - 05:04
Thanks for the answer. I tried to use these events, but I'm not sure witch function I need to call.
All my doubts is onplayerequip event.
I would like to unequip the monkgloves001 (resref) if the player equips a weapon. And I would like to unequip whatever weapon equipped if the player equips the monkgloves001.
I started this way
void main()
{
object oItem = GetPCItemLastEquipped();
object oPC = GetPCItemLastEquippedBy();
string sItem = GetResRef (oItem);
if (sItem == "monkgloves001")
{
//oItem = weapon???
//AssignCommand(oPC, ActionUnequipItem(oItem));
}
//if (oItem == weapon???)
//{
//oItem = monkgloves001???
//AssignCommand(oPC, ActionUnequipItem(oItem));
//}
}
#4
Posté 06 juillet 2014 - 11:07
forget resref check GetBaseItemType instead check if its BASE_ITEM_GLOVES
then inside the if statement, you need to retrieve (both) weapon in player hands
for this use GetItemInSlot and start with left hand, check if the item in slot is valid, if its a melee weapon (IPGetIsMeleeWeapon from #include "x2_inc_itemprops") and if so unequip it. And do the same for right hand - there you dont need to check weapon type I guess.
#5
Posté 06 juillet 2014 - 10:43
Thanks shadooow
#include "x2_inc_itemprop"
void main()
{
object oItem = GetPCItemLastEquipped();
object oPC = GetPCItemLastEquippedBy();
string sItem = GetResRef (oItem);
if (sItem == "monkgloves001")
{
object oItemHand1 = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
object oItemHand2 = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
AssignCommand(oPC, ActionUnequipItem(oItemHand1));
AssignCommand(oPC, ActionUnequipItem(oItemHand2));
}
if(((IPGetIsMeleeWeapon(oItem) == TRUE) || (IPGetIsRangedWeapon(oItem) == TRUE)) && (GetIsObjectValid(GetItemInSlot(INVENTORY_SLOT_ARMS, oPC)) == TRUE))
{
object oItemArm = GetItemInSlot(INVENTORY_SLOT_ARMS, oPC);
if(GetResRef(oItemArm) == "monkgloves001")
{
AssignCommand(oPC, ActionUnequipItem(oItemArm));
}
}
}
#6
Posté 07 juillet 2014 - 05:11
I got your idea to make all gloves BASE_ITEM_GLOVES to unequip too, but we still do not use it for all





Retour en haut






