• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

stacking items?

Status
Not open for further replies.
Level 2
Joined
Jun 26, 2005
Messages
11
I'm currently working on a Inu Yasha map and I'm making it so that they have to find the shikon jewel fragments and make it whole. Now here's the problem. Whenever the character picks up one of the jewel fragments, it doesnt stack and appear as another item in the inventory. There are 24 fragments, after getting half i want it to forge a new item and after getting it all i want it to turn into "Whole Shikon Jewel". Problem is unless i can stack im goign to have to cut the amount of shikon jewels in half, which i dont want to do.

Feedback will be much appreciated, asap.
 
Level 8
Joined
Nov 27, 2004
Messages
251
JASS:
function HasItemtype takes unit whichUnit, item this returns item
   local integer i = 0
   local item whichItem = null
   local integer itemType = GetItemTypeId(this)
   if whichUnit != null then
     loop
       exitwhen i > 6
       set whichItem = UnitItemInSlot(whichUnit, i)
       if GetItemTypeId(whichItem) == itemType and whichItem != this then
          return whichItem
       endif
       set i = i + 1
     endloop
   endif
   return null
endfunction

function StackItem takes unit whichHero, item whichItem returns nothing
   local item stack = HasItemtype(whichHero,whichItem)
   local integer itemCharges = GetItemCharges(stack)
   if stack != null and stack != whichItem and itemCharges > 0 then
       call SetItemCharges( stack, itemCharges+ GetItemCharges(whichItem))
       call RemoveItem( whichItem)
   endif
endfunction

this is how you stack items!

you jsut need to copy this into map's custom script seciton,create a trigger

Events-Unit Aquires an item
Actions-custom script -
call StackItem(GetManipulatingUnit(),GetManipulatedItem())

however keep in mind that i did not make that function,the author is Aiursrage2k so give him credits,i just found this from a great jass site


after reading the post (since i did only the title) this might not be what you are looking for(not sure again)
the script i gave does the following. if the hero has item X with 1 charge and aquires another then he will have 1 item X with 2 charges.

however you might want to do this!

set the items into an item array.
set also an integer variable FragmentNum to 1

and each time a hero picks the fragment the triggers remove the fragment and give him fragment item [FragmentNum]
and set FragmentNum = FragmentNum +1

this should work,i hope you understood what i told . . . it isnt difficult :)
 
Level 1
Joined
Sep 27, 2005
Messages
4
This doesnt seem to work for me

I dont understand but this isnt working for me i was wondering why... all i need is a simple trigger that allows charge class items to be stacked
 
Status
Not open for further replies.
Top