Force Unequip?
-
- Posts: 94
- Joined: Thu Jan 16, 2020 5:00 am
Force Unequip?
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?
The code for gaTakeItem.cs goes to this function:
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.)?
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++;
}
}
}
-
- Posts: 94
- Joined: Thu Jan 16, 2020 5:00 am
Re: Force Unequip?
Thanks! I'll go back and double check -- maybe I'm not using the right resref?
-
- Posts: 94
- Joined: Thu Jan 16, 2020 5:00 am
Re: Force Unequip?
Looks like the resref is right -- it's the body slot... But now it seems to be working? Perhaps everything is okay after all!
Re: Force Unequip?
Haha, if it is working now than I must have fixed without having to patch it, I like those kind of bugs 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