- Joined
- Sep 16, 2008
- Messages
- 47
Hi, i was trying something new, simple item system.
So what i want to do it:
When unit get item this is moved to specific slot but if unit already has item of this type item is dropped.
In this code items are dropped if unit already has item of same type but error is not displayed and item is not moving to specific slot because i don't rly know how to do this - i was trying UnitDropItemSlot
JASS:
scope Items
globals
private constant string MESSAGE = "You already have item of this type equipped"
private constant integer WEAPON_SLOT = 2
private constant itemtype WEAPON_TYPE = ITEM_TYPE_CAMPAIGN
endglobals
private struct IS
private static method onGet takes nothing returns nothing
local item i = GetManipulatedItem()
local unit u = GetTriggerUnit()
local player o = GetTriggerPlayer()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
if GetItemType(i) == WEAPON_TYPE then
//Move item to slot WEAPON_SLOT
if i != UnitItemInSlot(u, WEAPON_SLOT) and GetItemType(i) == GetItemType(UnitItemInSlot(u, WEAPON_SLOT)) then
call UnitDropItemPoint(u, i, x, y)
call SimError(o, MESSAGE)
else
call BJDebugMsg("weapon")
endif
endif
endmethod
private static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_PICKUP_ITEM, function thistype.onGet)
endmethod
endstruct
endscope
So what i want to do it:
When unit get item this is moved to specific slot but if unit already has item of this type item is dropped.
In this code items are dropped if unit already has item of same type but error is not displayed and item is not moving to specific slot because i don't rly know how to do this - i was trying UnitDropItemSlot