Force Unequip?

Discuss IB/IBx toolset ideas, bugs, etc.
Post Reply
zach_holbrook
Posts: 94
Joined: Thu Jan 16, 2020 5:00 am

Force Unequip?

Post by zach_holbrook »

Hello all...Still plugging away. Is there a way to force unequip via script? GaTakeItem doesn't seem to take an item if a PC has it equipped.
User avatar
slowdive
Site Admin
Posts: 510
Joined: Wed Jan 15, 2020 4:37 am

Re: Force Unequip?

Post by slowdive »

The code for gaTakeItem.cs goes to this function:

Code: Select all

public void TakeItem(string resref, int quantity)
        {
            for (int i = 0; i < quantity; i++)
            {
                bool FoundOne = false;
                int cnt = 0;
                foreach (ItemRefs itr in mod.partyInventoryRefsList)
                {
                    if (!FoundOne)
                    {
                        if (itr.resref.Equals(resref))
                        {
                            gv.sf.RemoveItemFromInventory(itr, 1);
                            FoundOne = true;
                            break;
                        }
                    }
                    cnt++;
                }
                cnt = 0;
                foreach (Player pc in mod.playerList)
                {
                    if (!FoundOne)
                    {
                        if (pc.BodyRefs.resref.Equals(resref))
                        {
                            mod.playerList[cnt].BodyRefs = new ItemRefs();
                            FoundOne = true;
                        }
                        if (pc.OffHandRefs.resref.Equals(resref))
                        {
                            mod.playerList[cnt].OffHandRefs = new ItemRefs();
                            FoundOne = true;
                        }
                        if (pc.MainHandRefs.resref.Equals(resref))
                        {
                            mod.playerList[cnt].MainHandRefs = new ItemRefs();
                            FoundOne = true;
                        }
                        if (pc.RingRefs.resref.Equals(resref))
                        {
                            mod.playerList[cnt].RingRefs = new ItemRefs();
                            FoundOne = true;
                        }
                        if (pc.Ring2Refs.resref.Equals(resref))
                        {
                            mod.playerList[cnt].Ring2Refs = new ItemRefs();
                            FoundOne = true;
                        }
                        if (pc.HeadRefs.resref.Equals(resref))
                        {
                            mod.playerList[cnt].HeadRefs = new ItemRefs();
                            FoundOne = true;
                        }
                        if (pc.GlovesRefs.resref.Equals(resref))
                        {
                            mod.playerList[cnt].GlovesRefs = new ItemRefs();
                            FoundOne = true;
                        }
                        if (pc.NeckRefs.resref.Equals(resref))
                        {
                            mod.playerList[cnt].NeckRefs = new ItemRefs();
                            FoundOne = true;
                        }
                        if (pc.FeetRefs.resref.Equals(resref))
                        {
                            mod.playerList[cnt].FeetRefs = new ItemRefs();
                            FoundOne = true;
                        }
                    }
                    cnt++;
                }
            }
        }
Looking at it, it looks like it should search through all equipped items and change them to a new blank item (new ItemRefs();) if found. What item slot is the item in (aka head, neck, ring, etc.)?
zach_holbrook
Posts: 94
Joined: Thu Jan 16, 2020 5:00 am

Re: Force Unequip?

Post by zach_holbrook »

Thanks! I'll go back and double check -- maybe I'm not using the right resref?
zach_holbrook
Posts: 94
Joined: Thu Jan 16, 2020 5:00 am

Re: Force Unequip?

Post by zach_holbrook »

Looks like the resref is right -- it's the body slot... But now it seems to be working? :oops: Perhaps everything is okay after all!
User avatar
slowdive
Site Admin
Posts: 510
Joined: Wed Jan 15, 2020 4:37 am

Re: Force Unequip?

Post by slowdive »

Haha, if it is working now than I must have fixed without having to patch it, I like those kind of bugs :lol: okay, serious now, if it does happen again, I'll need to track it down and maybe revisit the way takeitem works to be more robust. I need to get back on the Unity version, but the UI process is brutal for me. I need to research a better way to do it than what I am doing now :lol:
Post Reply