| 01-04-2009, 01:07 PM | #1 |
Hey, JASS:scope ItemMerge initializer Init private function Conditions takes nothing returns boolean return (GetItemCharges(GetManipulatedItem()) != 0) endfunction private function Actions takes nothing returns nothing local item it=GetManipulatedItem() //item picked up local item iis local unit u=GetManipulatingUnit() local integer i=0 loop exitwhen i > 5 //loop trough inventory set iis=UnitItemInSlot(u, i) //item in slot i //ItemLevel of an Item determines the max ammount of items, which can be in one stack if ( ( GetItemTypeId(iis) == GetItemTypeId(it) )and ( GetItemCharges(iis) < GetItemLevel(iis) )and( iis != it ) ) then if ( GetItemCharges(iis) + GetItemCharges(it) ) > GetItemLevel(it) then call SetItemCharges( it, ( ( GetItemCharges(iis) + GetItemCharges(it) ) - GetItemLevel(it) ) ) call SetItemCharges( iis, GetItemLevel(it) ) else call SetItemCharges( iis, ( GetItemCharges(iis) + GetItemCharges(it) ) ) call RemoveItem( it) endif else endif set i = i + 1 endloop set iis=null set it=null set u=null endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger t = CreateTrigger( ) call MyTriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_PICKUP_ITEM ) call TriggerAddCondition(t, Condition( function Conditions ) ) call TriggerAddAction(t, function Actions ) set t=null endfunction endscope i dont know how i can get the above script to work, when the inventory is already full... otherwise it performs quite well :) If trying to buy an item, altough the inventory is already full would fire an orderevent, i would perhaps be able to fix the problem for myself, but it seems like it doesnt fire any orderevent :/ Thanks in advance, Akolyt0r |
| 01-04-2009, 01:27 PM | #2 |
One solution is to make a powerup version of every item, and an inventory version of every item. |
| 01-04-2009, 02:10 PM | #3 | |
Quote:
That really sounds like a lot of boring object-editor work 0.o Is there any other possibility ? |
| 01-04-2009, 02:45 PM | #4 |
Needs more investigation, but here's a tip. You can put two different inventory abilities into a unit. Try using a one-slot inventory ability and use triggers to make sure nothing gets into that. |
| 01-04-2009, 02:54 PM | #5 | |
Quote:
either you would have to drop the item on the ground instead, or remove it, and add the itemcost to players gold again ....but you cant get an items cost with triggers :/ ...Well yeah there is a system somewhere on this page which accomplishes that, but i dont like how it works :> looks to messy and its performance isnt that good aswell... If there isnt any other possibility i will either use the Tome-way, or just ...call DoNothing() |
| 01-04-2009, 03:02 PM | #6 | |
Quote:
Well, actually that's pretty straightforward and not so messy. You just have to: 1. stack item and quit if possible 2. check inventory item count 3. drop item if count is 7 (or 6 if the item is not in the inventory at the time of event) Event will catch any incident of an item getting into the inventory. AFAIK DotA does this too. |
