Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Item functions:
//
library ItemFunctions
//Checks if the given unit has items of the given types.
//Fill the parameters with 0 to have fewer required item types.
//Works with multiple items of the same type.
function UnitCheckItems takes unit whichUnit, integer i1, integer i2, integer i3, integer i4, integer i5, integer i6 returns boolean
local integer array heldItems
local integer array requestedItems
local integer index1
local integer index2
local integer requestedItemsLength = 6
set requestedItems[0] = i1
set requestedItems[1] = i2
set requestedItems[2] = i3
set requestedItems[3] = i4
set requestedItems[4] = i5
set requestedItems[5] = i6
set heldItems[0] = GetItemTypeId(UnitItemInSlot(whichUnit, 0))
set heldItems[1] = GetItemTypeId(UnitItemInSlot(whichUnit, 1))
set heldItems[2] = GetItemTypeId(UnitItemInSlot(whichUnit, 2))
set heldItems[3] = GetItemTypeId(UnitItemInSlot(whichUnit, 3))
set heldItems[4] = GetItemTypeId(UnitItemInSlot(whichUnit, 4))
set heldItems[5] = GetItemTypeId(UnitItemInSlot(whichUnit, 5))
set index1 = 0
loop
if requestedItems[index1] == 0 then
set requestedItemsLength = requestedItemsLength-1
set requestedItems[index1] = requestedItems[requestedItemsLength]
if requestedItemsLength == 0 then
return true
endif
endif
exitwhen index1 == 5
set index1 = index1 +1
endloop
set index1 = 0
loop
set index2 = 0
loop
exitwhen index2 >= requestedItemsLength
if heldItems[index1] == requestedItems[index2] then
set requestedItemsLength = requestedItemsLength-1
set requestedItems[index2] = requestedItems[requestedItemsLength]
if requestedItemsLength == 0 then
return true
endif
exitwhen true
endif
set index2 = index2 +1
endloop
exitwhen index1 == 5
set index1 = index1 +1
endloop
return false
endfunction
function UnitCountItemsOfType takes unit whichUnit, integer itemType returns integer
local integer result = 0
local integer i = 0
loop
exitwhen i >= 6
if GetItemTypeId(UnitItemInSlot(whichUnit, i)) == itemType then
set result = result +1
endif
set i = i +1
endloop
return result
endfunction
endlibrary
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Item functions:
//
library ItemFunctions initializer init
//Checks if the given unit has items of the given types.
//Fill the parameters with 0 to have fewer required item types.
//Works with multiple items of the same type.
function UnitCheckItems takes unit whichUnit, integer i1, integer i2, integer i3, integer i4, integer i5, integer i6 returns boolean
local integer array heldItems
local integer array requestedItems
local integer index1
local integer index2
local integer requestedItemsLength = 6
set requestedItems[0] = i1
set requestedItems[1] = i2
set requestedItems[2] = i3
set requestedItems[3] = i4
set requestedItems[4] = i5
set requestedItems[5] = i6
set heldItems[0] = GetItemTypeId(UnitItemInSlot(whichUnit, 0))
set heldItems[1] = GetItemTypeId(UnitItemInSlot(whichUnit, 1))
set heldItems[2] = GetItemTypeId(UnitItemInSlot(whichUnit, 2))
set heldItems[3] = GetItemTypeId(UnitItemInSlot(whichUnit, 3))
set heldItems[4] = GetItemTypeId(UnitItemInSlot(whichUnit, 4))
set heldItems[5] = GetItemTypeId(UnitItemInSlot(whichUnit, 5))
set index1 = 0
loop
if requestedItems[index1] == 0 then
set requestedItemsLength = requestedItemsLength-1
set requestedItems[index1] = requestedItems[requestedItemsLength]
if requestedItemsLength == 0 then
return true
endif
endif
exitwhen index1 == 5
set index1 = index1 +1
endloop
set index1 = 0
loop
set index2 = 0
loop
exitwhen index2 >= requestedItemsLength
if heldItems[index1] == requestedItems[index2] then
set requestedItemsLength = requestedItemsLength-1
set requestedItems[index2] = requestedItems[requestedItemsLength]
if requestedItemsLength == 0 then
return true
endif
exitwhen true
endif
set index2 = index2 +1
endloop
exitwhen index1 == 5
set index1 = index1 +1
endloop
return false
endfunction
function UnitCountItemsOfType takes unit whichUnit, integer itemType returns integer
local integer result = 0
local integer i = 0
loop
exitwhen i >= 6
if GetItemTypeId(UnitItemInSlot(whichUnit, i)) == itemType then
set result = result +1
endif
set i = i +1
endloop
return result
endfunction
/*globals
trigger udg_TriggerUnitCheckItems
unit udg_UnitCheckItems_Unit
itemtype array udg_UnitCheckItems_Items
endglobals*/
private function UnitCheckItemsHandler takes nothing returns boolean
local boolean b = UnitCheckItems(udg_UnitCheckItems_Unit, udg_UnitCheckItems_Items[0], udg_UnitCheckItems_Items[1], udg_UnitCheckItems_Items[2], udg_UnitCheckItems_Items[3], udg_UnitCheckItems_Items[4], udg_UnitCheckItems_Items[5])
set udg_UnitCheckItems_Items[0] = 0
set udg_UnitCheckItems_Items[1] = 0
set udg_UnitCheckItems_Items[2] = 0
set udg_UnitCheckItems_Items[3] = 0
set udg_UnitCheckItems_Items[4] = 0
set udg_UnitCheckItems_Items[5] = 0
return b
endfunction
private function init takes nothing returns nothing
set udg_TriggerUnitCheckItems = CreateTrigger()
call TriggerAddCondition(udg_TriggerUnitCheckItems, Filter(function UnitCheckItemsHandler))
endfunction
endlibrary
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Actions

Set UnitCheckItems_Unit = (Triggering unit)

Set UnitCheckItems_Items[0] = Claws of Attack +15

Set UnitCheckItems_Items[1] = Claws of Attack +15

Set UnitCheckItems_Items[2] = Crown of Kings +5

Set UnitCheckItems_Items[3] = Kelen's Dagger of Escape

If (All Conditions are True) then do (Then Actions) else do (Else Actions)


If - Conditions



(Evaluate TriggerUnitCheckItems conditions) Equal to True


Then - Actions



-------- unit has the items --------


Else - Actions



-------- unit doesnt have the items --------
local integer a = 0
local integer b = 0
local integer c = 0
local integer d = 5
loop
exitwhen b == 6
if ( *Hero has an item of (What Item) on slot #(b) ) then
if ( a < (How many number of that item does it requires) ) then
a = a + 1
c = a
endif
endif
b = b + 1
endloop
//Item checking
**A unit acquired an item**
if (*Hero has an item of (The item from the recipe, not the item that requires 2 or more) then
if ( *Hero has an item of (The item that requires 2 or more.) ) ) then
if (a == (Number of that item that requires)) then
loop
if ( *Hero has an item of (Same Item) on slot #(d) ) then
**Remove the item from that slot**
c = c - 1
endif
d = d - 1
exitwhen c == 0
if ( c == 0 ) then
**Actions here**
endif
endloop
endif
endif
endif
Well remove the ; they are not needed unless you code in Zinc.
Otherwise it seems correct.
doesn't work.
ChargesAddGUI

Events


Unit - A unit Acquires an item

Conditions


(Item-class of (Item being manipulated)) Equal to Charged

Actions


For each (Integer A) from 1 to 6, do (Actions)



Loop - Actions




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to (Item-type of (Item being manipulated))






(Item carried by (Triggering unit) in slot (Integer A)) Not equal to (Item being manipulated)





Then - Actions






Item - Set charges remaining in (Item carried by (Triggering unit) in slot (Integer A)) to ((Charges remaining in (Item carried by (Triggering unit) in slot (Integer A))) + (Charges remaining in (Item being manipulated)))






Item - Remove (Item being manipulated)





Else - Actions
Craft

Events


Unit - A unit Starts the effect of an ability

Conditions

Actions


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




(Ability being cast) Equal to Craft Claw



Then - Actions




Set UnitCheckItems_Unit = (Triggering unit)




Set UnitCheckItems_Items[0] = Claws of Attack +3




Set UnitCheckItems_Items[1] = Claws of Attack +3




Set UnitCheckItems_Items[2] = Claws of Attack +3




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Evaluate TriggerUnitCheckItems conditions) Equal to True





Then - Actions






Item - Remove (Item carried by UnitCheckItems_Unit of type Claws of Attack +3)






Item - Remove (Item carried by UnitCheckItems_Unit of type Claws of Attack +3)






Item - Remove (Item carried by UnitCheckItems_Unit of type Claws of Attack +3)






Hero - Create Claws of Attack +15 and give it to UnitCheckItems_Unit





Else - Actions






Game - Display to (All players) the text: You dont have the r...




Skip remaining actions



Else - Actions


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




(Ability being cast) Equal to Craft Moonstone



Then - Actions




Set UnitCheckItems_Unit = (Triggering unit)




Set UnitCheckItems_Items[0] = Mooncrystal




Set UnitCheckItems_Items[1] = Partial Key of the Three Moons




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






(Evaluate TriggerUnitCheckItems conditions) Equal to True





Then - Actions






Item - Remove (Item carried by UnitCheckItems_Unit of type Mooncrystal)






Item - Remove (Item carried by UnitCheckItems_Unit of type Partial Key of the Three Moons)






Hero - Create Key of Three Moons and give it to UnitCheckItems_Unit





Else - Actions






Set UnitCheckItems_Unit = (Triggering unit)






Set UnitCheckItems_Items[0] = Mooncrystal






Set UnitCheckItems_Items[1] = Mooncrystal






Set UnitCheckItems_Items[2] = Mooncrystal






If (All Conditions are True) then do (Then Actions) else do (Else Actions)







If - Conditions








(Evaluate TriggerUnitCheckItems conditions) Equal to True







Then - Actions








Item - Remove (Item carried by UnitCheckItems_Unit of type Mooncrystal)








Item - Remove (Item carried by UnitCheckItems_Unit of type Mooncrystal)








Item - Remove (Item carried by UnitCheckItems_Unit of type Mooncrystal)








Hero - Create Key of Three Moons and give it to UnitCheckItems_Unit







Else - Actions








Set UnitCheckItems_Unit = (Triggering unit)








Set UnitCheckItems_Items[0] = Mooncrystal








Set UnitCheckItems_Items[1] = Mooncrystal








If (All Conditions are True) then do (Then Actions) else do (Else Actions)









If - Conditions










(Evaluate TriggerUnitCheckItems conditions) Equal to True









Then - Actions










Item - Remove (Item carried by UnitCheckItems_Unit of type Mooncrystal)










Item - Remove (Item carried by UnitCheckItems_Unit of type Mooncrystal)










Hero - Create Partial Key of the Three Moons and give it to UnitCheckItems_Unit









Else - Actions










Game - Display to (All players) the text: You dont have the r...




Skip remaining actions



Else - Actions
(Evaluate TriggerUnitCheckItems conditions) Equal to True
if TriggerEvaluate(trig) thenCan you quote that solution please?Ah, I see.
Well that certainly seems like a lot of code compared to the other pure GUI solutions presented.
Seems != is.Your way may provide a better API but it seems like you use more function calls, maybe that's just an illusion the 'huge' code makes when compared to the GUI presented in this thread.
yes.
you can do it even in GUI.
i am new at triggers so i don't understand variable
plus you use jass for that and jass is uncopyable
So what the hex is this??
![]()
so jass is like in minecraft command block
