Author Topic: How to unequip a weapon when equip a monk gloves?  (Read 309 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to unequip a weapon when equip a monk gloves?
« on: July 06, 2014, 02:19:55 am »


               

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



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
How to unequip a weapon when equip a monk gloves?
« Reply #1 on: July 06, 2014, 05:46:36 am »


               

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.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to unequip a weapon when equip a monk gloves?
« Reply #2 on: July 06, 2014, 06:04:53 am »


               

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));
    //}

}


               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
How to unequip a weapon when equip a monk gloves?
« Reply #3 on: July 06, 2014, 12:07:05 pm »


               

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.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to unequip a weapon when equip a monk gloves?
« Reply #4 on: July 06, 2014, 11:43:29 pm »


               

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));
        }
    }
}

               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
How to unequip a weapon when equip a monk gloves?
« Reply #5 on: July 07, 2014, 06:11:59 am »


               

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