• 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.

[Trigger] Just a little help with a little trigger

Status
Not open for further replies.
Level 4
Joined
Aug 15, 2009
Messages
79
i'm making a wilderness survival you know hehe so then im traying to make the Stick + Stick = big Stick. ok now the question if I got 2 equal items and if i mix those it give me 1 item. But then the problem with 1 item it also gives me the the mix that suposed to be the "BIG" item.
 

Attachments

  • This.png
    This.png
    7.4 KB · Views: 98
The problem is, you're just asking "Does the unit have this item" then again "Does this unit have this item"

What you'll need to do is a
  • Custom Script: if GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'ifoo') == 2 then
  • Unit - Remove item type of stick from triggering unit
  • Unit - Remove item type of stick from triggering unit
  • Custom Script: endif
Use "Cntrl + D" to show raw values to replace ifoo, make sure you use " ' " 's
 
  • Actions
    • Custom script: if GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'ifoo') == 2 then
    • Unit - Remove item type of stick from triggering unit
    • Unit - Remove item type of stick from triggering unit
    • Custom script: endif
This forum recognizes GUI formatting for a reason. Don't type "Custom Script: " type "Custom script: " seriously you're infuriating my OCD with this stuff.
 
Oh, sorry, add this to the script code (beginning of the map, like even before catagories

JASS:
function GetAmountOfItemsOfType takes unit u, integer i returns integer
    local integer LOOP = 1
    local integer index = 0
    loop
        exitwhen i == 7
        if GetItemTypeId(UnitItemInSlot(u, LOOP)) == i then
            set index = index + 1
        endif
        set LOOP = LOOP + 1
    endloop
    return index
endfunction

Then just replace "if GetInventoryIndexOfItemTypeBJ(GetTriggerUnit(), 'ifoo')"
with "if GetAmountOfItemsOfType(GetTriggerUnit(), 'ifoo')"
 
Level 4
Joined
Aug 15, 2009
Messages
79
Event
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Make (E is hotkey)
Actions
Custom script if GetAmountOfItemsOfType(GetSpellAbilityUnit(), 'I001') == 2 then
Item - Remove (Item carried by (Casting unit) of type Stick
Item - Remove (Item carried by (Casting unit) of type Stick
Hero - Create Big Stick and give it to (casting unit)
this doesn't work D:
 
Event
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Make (E is hotkey)
Actions
Custom script if GetAmountOfItemsOfType(GetSpellAbilityUnit(), 'I001') == 2 then
Item - Remove (Item carried by (Casting unit) of type Stick
Item - Remove (Item carried by (Casting unit) of type Stick
Hero - Create Big Stick and give it to (casting unit)

  • Events
    • Unit - A unit Begins casting an ability
  • Conditions
    • (Ability being cast) Equal to Make (E is hotkey)
  • Actions
    • Custom script if GetAmountOfItemsOfType(GetTriggerUnit(), 'I001') > 1 then
    • Item - Remove (Item carried by (Triggering unit) of type Stick
    • Item - Remove (Item carried by (Triggering unit) of type Stick
    • Hero - Create Big Stick and give it to (Triggering unit)
    • Custom script: endif
Change "casting unit" to "Triggering unit" for great justice.
 
Level 4
Joined
Aug 15, 2009
Messages
79
BigStick
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Make (E is hotkey)
Actions
Custom script: if GetAmountOfItemsOfType(GetTriggerUnit(), 'I001') > 1 then
Item - Remove (Item carried by (Triggering unit) of type Stick)
Item - Remove (Item carried by (Triggering unit) of type Stick)
Hero - Create Big Stick and give it to (Triggering unit)
Custom script: endif

here it is
 
Ok and did you make a trigger at the very top of your map that has ikillforyou's code in it?

That's where the problem is. There was an error in his code. Copy this code I'm giving you:

Just take your normal trigger like this:

  • Events
  • Conditions
  • Actions
and then right-click it and say "convert to custom script". Copy this above the long //============================== thing:

Code:
function GetAmountOfItemsOfType takes unit u, integer i returns integer
    local integer LOOP = 1
    local integer index = 0
    loop
        exitwhen LOOP == 7
        if GetItemTypeId(UnitItemInSlot(u, LOOP)) == i then
            set index = index + 1
        endif
        set LOOP = LOOP + 1
    endloop
    return index
endfunction
 
Status
Not open for further replies.
Top