what do you mean so you have a potion that you use or passive item? if passive you make it so that if they have 6 of the same item you stack it wit the behavior stack count
Lol NP, but anyway his issue is not that behaviors wouldnt stack, but moreso that if you had a potion and picked up another one, it wouldn't be 2 separate potions in your inventory, but instead one potion with a little "2" on it on a stack like in WoW.
And as far as I'm concerned it's not doable easily... but prove me wrong somebody.
ok now i understand ive sorta seen it not a stacked item but it said how many times i could use it i had 2 items and they both had a 2 at the bottom and it was with data not a created image maybe a work around requiring requirements and validators
I made my own stacking system using triggers, I don't know of a data-driven way to do this.
I don't think my trigger is the most elegant one, but it works properly.
Its written in plain galaxy, to use it, copy&paste it in a new custom script object, and use ConsumableStacking_Init as initializer.
If you want to use this exact code, there are some requirements:
The item and the item unit need to have the exact same id
The item charge cost needs to have the link "Item/"+id
Every consumable, which should stack, needs to be registered in the ConsumableDatabase - Function, using the ConsumableAdd(id) Function.
If the item meets all the requirements, it will stack in your inventory until it reached the maximum amount of charges specified by the constant, then it will fill a second slot. Should account any amount of initial charges per item properly.
I could probably use catalog functions to circumvent the requirements; the system was written before I discovered them. Also maybe some people would need the max charges on a per-item basis, which is currently not supported.
<div style="margin: 5px 20px 20px;">
<div class="alt2" style="text-align: right; margin: 0px; padding: 6px; border: 1px;">
<span style="float: left; padding-top: 2px;">Code: </span>
<input value="Show" style="margin: 0px; padding: 0px; width: 80px; font-size: 10px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.value = 'Show';}" type="button">
</div>
<div style="padding-top: 4px;">
<div class="alt2" style="display:none; margin: 0px; padding: 6px; border: 1px inset;">
//Consumable stacking
const fixed MAX_CHARGES=50; //can only stack up to MAX_CHARGES items in one slot
string[50] ConsumableId; //no constants for array indexes in galaxy,
//take the number of the consumables in your map
//for the array size
void ConsumableAdd(string id);
void ConsumableDatabase(){
//add all consumables, which should stack here
ConsumableAdd("Medkit");
ConsumableAdd("Battery");
ConsumableAdd("Metamorphines");
ConsumableAdd("BigSurvivalPack");
ConsumableAdd("HealingBeacon");
}
//config end
int ConsumableCount=0;
void ConsumableAdd(string id){
ConsumableCount+=1;
ConsumableId[ConsumableCount]=id;
DataTableSetBool(true,id,true);
}
bool IsConsumable(unit u){
return DataTableGetBool(true,UnitGetType(u));
}
string ConsumableGetLink(unit u){
return "Item/"+UnitGetType(u);
}
bool ConsumableStacking (bool a, bool b) {
unit caster=EventUnit();
unit item=EventUnitInventoryItem();
unit u;
string id=UnitGetType(item);
string s;
unitgroup g=UnitInventoryGroup(caster);
int j=UnitGroupCount(g,c_unitCountAlive);
int i=0;
fixed val1;
fixed val2;
fixed val3;
if (IsConsumable(item)){
s=ConsumableGetLink(item);
while (i<j){ i+="1;" u="UnitGroupUnit(g,i);" if="" (id="=UnitGetType(u)&&u!=item){" val1="MAX_CHARGES-UnitGetChargeUsed(item,s);" Print("Charges="" on="" new="" acquired="" item:="" "+FixedToString(val1,2));="" val2="MAX_CHARGES-UnitGetChargeUsed(u,s);" Print("Charges="" on="" present="" item:="" "+FixedToString(val2,2));="" if(val1+val2<="MAX_CHARGES){" UnitAddChargeUsed(u,s,-val1);="" UnitRemove(item);="" val2="MAX_CHARGES-UnitGetChargeUsed(u,s);" Print("Charges="" after="" stacking:="" "+FixedToString(val2,2));="" break;="" }="" else{="" val3="val2-MAX_CHARGES;" UnitAddChargeUsed(u,s,-MAX_CHARGES);="" UnitAddChargeUsed(item,s,-val3);="" }="" }="" }="" }="" return="" true;="" }="" void="" ConsumableStacking_Init()="" {="" trigger="" t="TriggerCreate("ConsumableStacking");" TriggerAddEventUnitInventoryChange(t,="" null,="" c_unitInventoryChangeGains,="" null);="" ConsumableDatabase();="" }="" <="" div="">
I'm surprised I couldn't find this in search.
How do you make specific items stack?
for example if i made a healing potion item, how could I make it able to be stacked 6 times.
@cinicraft: Go
It's because I don't think it's a trivial matter... I haven't bothered to try but probably requires triggers.
what do you mean so you have a potion that you use or passive item? if passive you make it so that if they have 6 of the same item you stack it wit the behavior stack count
thx onetwo for getting me into map editing
@aczchef: Go
Lol NP, but anyway his issue is not that behaviors wouldnt stack, but moreso that if you had a potion and picked up another one, it wouldn't be 2 separate potions in your inventory, but instead one potion with a little "2" on it on a stack like in WoW.
And as far as I'm concerned it's not doable easily... but prove me wrong somebody.
ok now i understand ive sorta seen it not a stacked item but it said how many times i could use it i had 2 items and they both had a 2 at the bottom and it was with data not a created image maybe a work around requiring requirements and validators
I made my own stacking system using triggers, I don't know of a data-driven way to do this.
I don't think my trigger is the most elegant one, but it works properly.
Its written in plain galaxy, to use it, copy&paste it in a new custom script object, and use ConsumableStacking_Init as initializer.
If you want to use this exact code, there are some requirements:
If the item meets all the requirements, it will stack in your inventory until it reached the maximum amount of charges specified by the constant, then it will fill a second slot. Should account any amount of initial charges per item properly.
I could probably use catalog functions to circumvent the requirements; the system was written before I discovered them. Also maybe some people would need the max charges on a per-item basis, which is currently not supported.
<div style="margin: 5px 20px 20px;"> <div class="alt2" style="text-align: right; margin: 0px; padding: 6px; border: 1px;"> <span style="float: left; padding-top: 2px;">Code: </span> <input value="Show" style="margin: 0px; padding: 0px; width: 80px; font-size: 10px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.value = 'Show';}" type="button"> </div> <div style="padding-top: 4px;"> <div class="alt2" style="display:none; margin: 0px; padding: 6px; border: 1px inset;"> //Consumable stacking const fixed MAX_CHARGES=50; //can only stack up to MAX_CHARGES items in one slot string[50] ConsumableId; //no constants for array indexes in galaxy, //take the number of the consumables in your map //for the array size void ConsumableAdd(string id); void ConsumableDatabase(){ //add all consumables, which should stack here ConsumableAdd("Medkit"); ConsumableAdd("Battery"); ConsumableAdd("Metamorphines"); ConsumableAdd("BigSurvivalPack"); ConsumableAdd("HealingBeacon"); } //config end int ConsumableCount=0; void ConsumableAdd(string id){ ConsumableCount+=1; ConsumableId[ConsumableCount]=id; DataTableSetBool(true,id,true); } bool IsConsumable(unit u){ return DataTableGetBool(true,UnitGetType(u)); } string ConsumableGetLink(unit u){ return "Item/"+UnitGetType(u); } bool ConsumableStacking (bool a, bool b) { unit caster=EventUnit(); unit item=EventUnitInventoryItem(); unit u; string id=UnitGetType(item); string s; unitgroup g=UnitInventoryGroup(caster); int j=UnitGroupCount(g,c_unitCountAlive); int i=0; fixed val1; fixed val2; fixed val3; if (IsConsumable(item)){ s=ConsumableGetLink(item); while (i<j){ i+="1;" u="UnitGroupUnit(g,i);" if="" (id="=UnitGetType(u)&&u!=item){" val1="MAX_CHARGES-UnitGetChargeUsed(item,s);" Print("Charges="" on="" new="" acquired="" item:="" "+FixedToString(val1,2));="" val2="MAX_CHARGES-UnitGetChargeUsed(u,s);" Print("Charges="" on="" present="" item:="" "+FixedToString(val2,2));="" if(val1+val2<="MAX_CHARGES){" UnitAddChargeUsed(u,s,-val1);="" UnitRemove(item);="" val2="MAX_CHARGES-UnitGetChargeUsed(u,s);" Print("Charges="" after="" stacking:="" "+FixedToString(val2,2));="" break;="" }="" else{="" val3="val2-MAX_CHARGES;" UnitAddChargeUsed(u,s,-MAX_CHARGES);="" UnitAddChargeUsed(item,s,-val3);="" }="" }="" }="" }="" return="" true;="" }="" void="" ConsumableStacking_Init()="" {="" trigger="" t="TriggerCreate("ConsumableStacking");" TriggerAddEventUnitInventoryChange(t,="" null,="" c_unitInventoryChangeGains,="" null);="" ConsumableDatabase();="" }="" <="" div="">
</div>
</div>