Aller au contenu

Photo

How to unequip a weapon when equip a monk gloves?


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

#1
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

and the contrary (unequip monk gloves when equip a weapon)



#2
WhiZard

WhiZard
  • Members
  • 1 204 messages

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
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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
Shadooow

Shadooow
  • Members
  • 4 471 messages

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
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

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
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I got your idea to make all gloves BASE_ITEM_GLOVES to unequip too, but we still do not use it for all