Is there an easy way to make items with charges stackable in the inventory? The shop in my map sells medikits which have 3 charges each- is there a way to make it so that picking up or buying additional medikits just adds stacks in the inventory instead of taking up more inventory space?
(this would fix a problem i'm having when a player has medikits in multiple inventory slots, and using one won't set off the cooldown for the others).
I could use a solution to this as well. I found how to add charges and remove them, but how to add the remaining charges of one item to another is still eluding me, at one point I found out how to add the used up charges to the other item, but that isn't really what I'm looking for
In this code, "100" is the maximum of charges available for all items on my map.
If you have many "maximum charges", you must to manage each case separatly.
When you add a number of charges, you will add a name to the "Link" properties on the item. Use this name to manage charges of your item.
This trigger is functionnal (localisation from french) :
Inventory - Hero acquires Events Unit - Any unit gains Any object Local variables Compte = 0.0 <Real> Conditions Actions Unit Group - Choose each unit in (All transported elements by (Triggering Unit) and do (actions) Actions Main - If (Conditions) then do (Actions) else do (Actions) If (Unit-type of (Unit chosen)) == (Unit-type of (Triggering Inventory Object)) (Unit chosen) != (Triggering Inventory Object) Then Variable - Set Compte = (100.0 - (Used charges for charge "Item/HealBlock" for Unit (Triggering Inventory Object))) Unit - Add (0.0 - Compte) used charges for charge "Item/HealBlock" for Unit (Unit chosen) Unit - Remove (Triggering Inventory Object) of the game. Else
In this code, "100" is the maximum of charges available for all items on my map. If you have many "maximum charges", you must to manage each case separatly.
This worked perfectly for me, but im curious if you know how to make it so once that item reaches it's max stacks, lets say 10, that it'll start a new stack an stat counting up, so i could potentially have 3 stacks of 10 of the same item. becauseat the moment once u have max stacks, it destroys the item when u try to pick up an 11th
Here is my upgraded version of Doubotis's code, it's dynamic enough that you don't need to create specific ones for different items or items that has different max charge. It also finish stacking the existing stacks before create a new one (ie. 7, 7 + 10 = 10, 10, 4)
It also doesn't annoyly moving the stacks everytime when you pick up something, like the one from the item utility library I saw here.
The only thing you need to worry when using this code is make sure you create a behaviour for tracking which items are stackable. I have all my stackable items a behaviour buff called stackable item.
Just bare in mind I only started making map 2 weeks ago, so this obviously won't be the best way to do it. Bugs is also a possibility, but so far I haven't detect any.
ItemStackingEventsUnit-AnyUnitPicksUpAnyItemLocalVariablesitem's max charge = 0 <Integer>newitem's current charge = 0 <Integer>existingitem's current charge = 0 <Integer>chargelink=""<String>Conditions((Triggeringinventoryitem)hasStackableItem)==trueActionsVariable-Setchargelink=(ValueofItems(String((Unittypeof(Triggeringinventoryitem))))"EffectCost.Charge.Link"forplayerAnyPlayer)Variable-Setitem's max charge = (Integer((Value of Items (String((Unit type of (Triggering inventory item)))) "EffectCost.Charge.CountMax" for player Any Player)))Variable-Setnewitem's current charge = (item'smaxcharge-(Integer((Chargesusedofchargechargelinkonunit(Triggeringinventoryitem)))))UnitGroup-Pickeachunitin(Allitemscarriedby(Triggeringunit))anddo(Actions)ActionsVariable-Setexistingitem's current charge = (item'smaxcharge-(Integer((Chargesusedofchargechargelinkonunit(Pickedunit)))))General-If(Conditions)thendo(Actions)elsedo(Actions)If(Unittypeof(Pickedunit))==(Unittypeof(Triggeringinventoryitem))(Pickedunit)!=(Triggeringinventoryitem)existingitem's current charge < item'smaxchargeThenGeneral-While(Conditions)aretrue,do(Actions)Conditionsexistingitem's current charge < item'smaxchargenewitem's current charge > 0Actions------- Negative charges adds items, positive charges remove itemsUnit-Add-1.0chargesusedforchargechargelinkonunit(Pickedunit)Unit-Add1.0chargesusedforchargechargelinkonunit(Triggeringinventoryitem)Variable-Modifyexistingitem's current charge: + 1Variable-Modifynewitem's current charge: - 1General-If(Conditions)thendo(Actions)elsedo(Actions)Ifnewitem's current charge <= 0ThenUnit-Remove(Triggeringinventoryitem)fromthegameElseElse
Is there an easy way to make items with charges stackable in the inventory? The shop in my map sells medikits which have 3 charges each- is there a way to make it so that picking up or buying additional medikits just adds stacks in the inventory instead of taking up more inventory space?
(this would fix a problem i'm having when a player has medikits in multiple inventory slots, and using one won't set off the cooldown for the others).
@PirateArcade | I make games | Ask me things on Discord
shesh i was really hoping someone could figure this one out. I dont understand the add charge trigger at all.
@zigzagrocket: Go
bumpity bump bump
.>
@PirateArcade | I make games | Ask me things on Discord
@greythepirate: Go
I could use a solution to this as well. I found how to add charges and remove them, but how to add the remaining charges of one item to another is still eluding me, at one point I found out how to add the used up charges to the other item, but that isn't really what I'm looking for
@greythepirate: Go
For interested people, founded :
When you add a number of charges, you will add a name to the "Link" properties on the item. Use this name to manage charges of your item.
This trigger is functionnal (localisation from french) :
In this code, "100" is the maximum of charges available for all items on my map. If you have many "maximum charges", you must to manage each case separatly.
@greythepirate: Go
http://forums.sc2mapster.com/development/galaxy-scripting-and-trigger-lib/5636-library-galaxy-item-utility-library/#p5
@Doubotis: Go
Worked Perfectly, thanks.
This worked perfectly for me, but im curious if you know how to make it so once that item reaches it's max stacks, lets say 10, that it'll start a new stack an stat counting up, so i could potentially have 3 stacks of 10 of the same item. becauseat the moment once u have max stacks, it destroys the item when u try to pick up an 11th
Here is my upgraded version of Doubotis's code, it's dynamic enough that you don't need to create specific ones for different items or items that has different max charge. It also finish stacking the existing stacks before create a new one (ie. 7, 7 + 10 = 10, 10, 4)
It also doesn't annoyly moving the stacks everytime when you pick up something, like the one from the item utility library I saw here.
The only thing you need to worry when using this code is make sure you create a behaviour for tracking which items are stackable. I have all my stackable items a behaviour buff called stackable item.
Just bare in mind I only started making map 2 weeks ago, so this obviously won't be the best way to do it. Bugs is also a possibility, but so far I haven't detect any.