Page 1 of 1

Force Unequip?

Posted: Fri Apr 21, 2023 1:53 pm
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.

Re: Force Unequip?

Posted: Sat Apr 22, 2023 5:27 pm
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.)?

Re: Force Unequip?

Posted: Mon Apr 24, 2023 12:45 am
by zach_holbrook
Thanks! I'll go back and double check -- maybe I'm not using the right resref?

Re: Force Unequip?

Posted: Mon Apr 24, 2023 12:46 am
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!

Re: Force Unequip?

Posted: Thu May 11, 2023 3:47 pm
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: