Staking items
#1
Posté 10 décembre 2010 - 08:30
The baseitems.2da file has miscsmall items (line #24 - it_smlmisc) as stackable=1. YET when I have the same item in my inventory that is considered a miscsmall item, they are individual icons in the inventory. How do I get them to become stackable?
When I view the item in the toolset, the Base Type Name is "Miscellaneous Small", so shouldn't the items stack based on the information in baseitems.2da? Yet they do not stack in-game.
Thanks,
FP!
#2
Posté 10 décembre 2010 - 08:33
Stacking=1 in the baseitems.2da means that it takes up 1 square in the inventory per ONE ITEM.
Stacking=50 or Stacking=99 means that it takes up 1 square in the inventory UP TO 50 or 99 STACKS.
Yes?
FP!
Modifié par Fester Pot, 10 décembre 2010 - 08:34 .
#3
Posté 10 décembre 2010 - 08:47
The "Stacking" column (between "BaseCost" and "ItemMultiplier") in the baseitems 2da file... Yes, if you increase that number you will be able to have stacks of Misc Small in game. So if you change that column for misc small to be 10, then you could have a 1x1 inventory grid size of 10 misc small items that have the same resref and icon. The highest I ever tried to set something was a stack size of 99. No idea if it can go higher. Usually I had it set to 10.
Hope that answers your question.
Lesson learned: Do not stack equipable gear.
Second Lesson Learned: Custom stacks can be exploited using barter. Meaning players can turn a single item into multiples. I had to undo custom stacking on my server because of this. *sighs* And WOW do I miss having it. This data is old, 1.69 could have fixed this issue for all I know.
-- Mistress
#4
Posté 10 décembre 2010 - 08:53
#5
Posté 10 décembre 2010 - 08:55
#6
Posté 10 décembre 2010 - 10:23
Thanks!
FP!
#7
Posté 10 décembre 2010 - 10:47
There are several thing to keep in mind when stacking items that have charges. The problems become easier to understand once your realize that items in a stack are really only one item. This has negtive effects on two things:
ONE CHARGES
If you use a charge from an item in a stack, The charges are reduced. This in effect reduces the charges of all the items in the stack. Since the stack is one item and all items are using the same number.
TWO LOCAL VARS
Here again since it is only one item seperate VAR list are not kept for each indivisable item. The Item Var list does not copy over to a stack an item is merged into. when an item is split from a stack it will have the VAR list that the stack had. This can cause some pretty big bugs/exploits if all items, from a given blueprint, do not have the same constant VARS.
There is no real fix for the Local vars. This is just something that you will have to keep in mind anytime you start placing vars on any stackable item. You are asking for bugs if you ever change them via scripting.
As far as that stackable and charges go, The Idea is to split the item off the stack if it is ever used. So if you have a stack of 10 item and use a charg fome one, You will end up with a stack of 9 tiems with fifty charges and 1 item with 9 charges. The way I do this is with a tag based script.
#include "x2_inc_switches"
// Private Function.
void SplitItemsOffStack(object oSplit,int nSize,itemproperty iProp,object oPC )
{
object oCopy=CopyItem(oSplit,oPC);
SetItemStackSize(oCopy,nSize);
AddItemProperty(DURATION_TYPE_PERMANENT ,iProp, oCopy);
AddItemProperty(DURATION_TYPE_PERMANENT ,iProp, oSplit);
SetItemStackSize(oSplit,1);
}
itemproperty GetItemProp (object oItem)
{
itemproperty iProp = GetFirstItemProperty(oItem);
while (GetIsItemPropertyValid(iProp))
{
if (GetItemPropertyType(iProp)==ITEM_PROPERTY_CAST_SPELL) break;
GetNextItemProperty(oItem);
}
return iProp;
}
void main()
{
object oPC;
object oItem;
object oCopy;
int nCharges;
int nStack;
int nMaxStack;
int nChargesPerUse;
itemproperty iProp;
int nEvent = GetUserDefinedItemEventNumber();
switch (nEvent)
{
case X2_ITEM_EVENT_ACTIVATE:
oPC = GetItemActivator();
oItem = GetItemActivated();
nStack = GetNumStackedItems(oItem);
nCharges = GetItemCharges(oItem);
if (nStack>1)
{
iProp = GetItemProp( oItem);
nChargesPerUse = 7-GetItemPropertyCostTableValue(iProp);
nMaxStack= StringToInt(Get2DAString("baseitems","Stacking",GetBaseItemType(oItem)));
SetItemStackSize(oItem,nMaxStack);
if(nCharges)
{
RemoveItemProperty(oItem,iProp);
SetItemCharges(oItem,nCharges+nChargesPerUse);
DelayCommand(0.1,SplitItemsOffStack(oItem,nStack-1, iProp,oPC ) );
DelayCommand(0.2,SetItemCharges(oItem,nCharges));
}
else
{
// This is for the case of more then one item in a stack that has only one charge.
// We will remove the iProp and add it back to keep the item useable.
nChargesPerUse = 7-GetItemPropertyCostTableValue(iProp);
nCharges = (nStack-1) *nChargesPerUse;
if (nCharges/50)
{
oCopy = CopyItem(oItem,oPC);
iProp = GetItemProp(oCopy);
DelayCommand(0.1, AddItemProperty(DURATION_TYPE_PERMANENT ,iProp, oCopy));
RemoveItemProperty(oCopy,iProp);
DelayCommand(0.1, SetItemStackSize(oCopy,nCharges/50));
SetItemCharges(oCopy,50);
}
if (nCharges%50)
{
oCopy = CopyItem(oItem,oPC);
iProp = GetItemProp(oCopy);
DelayCommand(0.1, AddItemProperty(DURATION_TYPE_PERMANENT ,iProp, oCopy));
RemoveItemProperty(oCopy,iProp);
SetItemCharges(oCopy,nCharges%50);
SetItemStackSize(oCopy,1);
}
}
}
// Place Item inpact code here.
break;
}
}
Most of the code in the script is to handle the situation where where there is a stack of item with only one charge. The iProp has to be removed and readded to the item to make the item able to take charges again.
Modifié par Lightfoot8, 11 décembre 2010 - 05:04 .
#8
Posté 11 décembre 2010 - 10:21
Tyndrel wrote...
The highest I've built a stack was 999, there must be a limit but I have no idea at what point it will fall on your head!
Really! My game install won't recognize a stack bigger than 99 - anything set higher seems to always default to that value.
#9
Posté 11 décembre 2010 - 11:23
#10
Posté 11 décembre 2010 - 01:27
#11
Posté 11 décembre 2010 - 02:03
FP!
Modifié par Fester Pot, 11 décembre 2010 - 02:03 .
#12
Posté 11 décembre 2010 - 02:22
Lightfoot8 wrote...
There are several thing to keep in mind when stacking items that have charges. The problems become easier to understand once your realize that items in a stack are really only one item. This has negtive effects on two things:
...
TWO LOCAL VARS
Here again since it is only one item seperate VAR list are not kept for each indivisable item... There is no real fix for the Local vars. This is just something that you will have to keep in mind anytime you start placing vars on any stackable item. You are asking for bugs if you ever change them via scripting.
Yes, I ran into precisely this problem when I added the food-based resting system in my modules. What I really wanted was for food to be stackable, and that was how I originally implemented it. But the design also involved tracking a "spoil time" variable on each item, counting down to zero with a decrement on each rest (with spoilage on reaching zero, unless it was being carried in a special food-preserving container). Those variables wouldn't hold on stackable items, though, so in the end I had to make each food item individual.
Modifié par AndarianTD, 11 décembre 2010 - 02:22 .
#13
Posté 11 décembre 2010 - 02:33
#14
Posté 11 décembre 2010 - 06:39





Retour en haut







