SOLUTION (Relies on the object having a template in the toolset with the variables required on it.)
============================================================
EDIT: It may be possible to write a script using both CopyItem and CopyObject to get around having to refer to a template object. However, as I do not need this level of "fix", I am not looking any further yet. As an aside, I did find that Store stacks are not an issue during my testing.
NEW SPLITSTACK.XML CODE (Place in campaign or override):
========================================
<?xml version="1.0" encoding="utf-8">
<UIScene name="SCREEN_MESSAGEBOX_SPLITSTACKSTORE" width=388 height=160 x=ALIGN_CENTER y=ALIGN_CENTER draggable="true" fadeout="0.3" fadein="0.3" backoutkey=true
scriptloadable=true OnCreate="UIScene_OnCreate_SetupMessageBox(320,195,10,10,10,10)" priority="SCENE_SCRIPT" modal="true"
OnAdd=UIScene_OnAdd_SetFocus("inputbox") />
<!-- Message Listbox -->
<UIListBox name="messageboxlb" x=ALIGN_CENTER y=8 width=300 height=40 showpartialchild="true" xPadding=10 yPadding=10
hidescrollbarwhennotneeded="true" scrollsegmentsize=17 unequalcontrols="true">
<UIText name="messagetext" fontfamily="Title_Font" style=1 width=PARENT_WIDTH height=DYNAMIC sizetofit="true" align="center" />
<UIScrollBar name="SB" style="STYLE_SB_THIN"></UIScrollBar>
</UIListBox>
<UIText name="inputbox" x=ALIGN_CENTER y=44 align=right valign="middle" width=80 height=28
editable="true" selectable="true" filter="numeric" maxlength=6 multiline=false fontfamily="Body_Font" style=1
update="true" OnUpdate=UIText_OnUpdate_ParseSplitStackInput("inputbox")
OnReturn=UIText_OnReturn_ParseSplitStackInput("inputbox") />
<UIFrame x=ALIGN_CENTER y=42 width=86 height=32 topleft="tp_frame_tl.tga" topright="tp_frame_tr.tga" bottomleft="tp_frame_bl.tga"
bottomright="tp_frame_BR.tga" top="tp_frame_t.tga" bottom="tp_frame_b.tga"
left="tp_frame_l.tga" right="tp_frame_r.tga" fillstyle="stretch" fill="tp_frame_bg.tga"
border=5 />
<UIScrollBar name="scrollbar" style="STYLE_OPTION_SLIDER" x=ALIGN_CENTER y=75 width=292 height=24
OnSliderPositionChange=UIScrollBar_Input_HandleSplitStackChange() horizontal="true">
</UIScrollBar>
<!-- BUTTON CONTAINER -->
<UIPane name="BUTTON_CONTAINER" x=ALIGN_CENTER y=104 width=254 height=32 >
<!-- OK button -->
<UIButton name="okbutton" strref="66" x=0 y=0 style="STYLE_SMALL_BUTTON" OnLeftClick0=UIButton_Input_HandleSplitStackOK("inputbox") OnLeftClick1=UIObject_Misc_ExecuteServerScript("gui_splitfix","FixStack")>
</UIButton>
<!-- Cancel Button -->
<UIButton name="cancelbutton" strref="67" x=130 y=0 style="STYLE_SMALL_BUTTON" OnLeftClick=UIButton_Input_HandleSplitStackCancel()>
</UIButton>
</UIPane>
<!-- Main Window -->
<UIFrame width=PARENT_WIDTH height=PARENT_HEIGHT topleft="frame1_tl.tga" topright="frame1_tr.tga" bottomleft="frame1_bl.tga"
bottomright="frame1_BR.tga" top="frame1_t.tga" bottom="frame1_b.tga"
left="frame1_l.tga" right="frame1_r.tga" border=32 />
<UIFrame x=7 y=8 width=374 height=144 fillstyle="tile" fill="cloth_bg.tga"/>
The GUI_SPLITFIX SCRIPT (Add to campaign/module):
==================================
// FIXES STACKING SPLIT FUNCTION
void CreateFixedStacks(object oPlayer, string sNAME, string sTagObject, string sResRefObject, int iStackSize)
{
SetNoticeText(oPlayer, "SPLITTING >>> " + sNAME);
// CREATE A RANDOM TAG FOR TIME BEING
int iRandomNumber = Random(10000);
string sRandomName = IntToString(iRandomNumber);
// RECREATE THE STACKS WITH THE CORRECT VARIABLES & RESTORE THE ORIGINAL TAG
object oNEW = CreateItemOnObject(sResRefObject, oPlayer, iStackSize, sRandomName, FALSE);
DelayCommand(0.1, SetTag(oNEW, sTagObject));
}
void main(string sAction)
{
object oPlayer = OBJECT_SELF;
if(sAction == "FixStack")
{
object oTarget = GetPlayerCurrentTarget(oPlayer);
string sNAME = GetName(oTarget);
// PREPARE DESTRUCTION & RECREATION
string sResRefObject = GetResRef(oTarget);
string sTagObject = GetTag(oTarget);
object oFindSplit = GetFirstItemInInventory(oPlayer);
while(oFindSplit != OBJECT_INVALID)
{
string sRRFind = GetResRef(oFindSplit);
string sTagFind = GetTag(oFindSplit);
if(sRRFind == sResRefObject && sTagFind == sTagObject)
{
SetTag(oFindSplit, "DESTROYSPLIT");
int iStackSize = GetItemStackSize(oFindSplit);
DelayCommand(0.1, CreateFixedStacks(oPlayer, sNAME, sTagObject, sResRefObject, iStackSize));
DestroyObject(oFindSplit, 0.0, FALSE);
}
oFindSplit = GetNextItemInInventory(oPlayer);
}
}
}
==================================================================================
NOTE: This split fix is for when the player splits a stack in their PC's inventory. It is not for any other SPLIT usage, which may use a different XML file. E.g. Splitting STORE stock. However, I imagine a similar fix may be possible if required. (I did not require a fix of Store stacks and testing did not show them to be an issue at this time.)
==================================================================================
UPDATE: Good news! I had no idea that this would work, but it does, and has great implications. I used:
object oTarget = GetPlayerCurrentTarget(OBJECT_SELF);
within a standard script called back from UIObject_Misc_ExecuteServerScript and it returned the object!
Hopefully that means I can start to manipulate the object with that info to fix the split action. I think this may have greater implications for other purposes of the game.
UPDATE 2: OK, so the problem also occurs when a PC picks up a stackable object with different variables on it. I need to look at the "acquisition" side I think. Although, to be fair, this is less of a problem because such items, should, in theory, also have a different name, which would differentiate the stack. Therefore, I will ignore this side of the issue, as the real problem is when the item should remain the same after a split .... including keeping the same variables. The reason it could have been a problem is because I needed to work out a way to differentiate between a stack when applying the new split stack to the PC. Hopefully, I will get around that issue, even if it means a very quick renaming after creation of the items.
Lance.
0 ----- 0
A search showed me that this same question was raised 2 years ago, but I am trying to address the problem again now since discovering it for myself.
The Problem: When you have a stack of an item (all with the same variable attached), one of the split piles loses the variable after the split.
I am currently looking at the splitstack.xml, but do not know how to return an "item" or the current "object" being worked upon. Is there a standard method of doing this from an XML script?
Any help woul be appreciated.
Many thanks,
Lance.
Modifié par Lance Botelle, 10 février 2013 - 07:22 .





Retour en haut






