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

Item trigger help

Status
Not open for further replies.
Level 7
Joined
Aug 30, 2008
Messages
347
how do i make a unit morph into another unit using an item, the used item does not expire,and if the currently morphed unit drops the item he had used to morph, it will go back into his inventory or become undroppable until he uses it again to become his original unit, or uses another morphing item.

Can this be done in gui, as i am not too knowledgeable about it and am creating one of those survivor maps..
 
You make a modified version of the "Methamorphosis"-spell and a no-target dummy ability with your duration and such. Then you make 2 version of the item you want. One of them has to be undroppable, usable and have the modified morph-ability, and the other has to be one you can activate, with the dummy-ability on it. Have something like this trigger:
  • ItemMorph
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Morph-item 1
    • Actions
      • Set UserVariable = (Triggering unit)
      • Set MorphItem1Variable = (Item being manipulated)
      • Item - Remove MorphItem1Variable
      • Hero - Create Morph-item 2 and give it to UserVariable
      • Set MorphItem2Variable = (Last created item)
      • Unit - Order UserVariable to Right-Click MorphItem2Variable
      • Wait "YourDuration" seconds
      • Item - Remove MorphItem2Variable
      • Hero - Create Morph-item 1 and give it to UserVariable
or in jass:
JASS:
function Trig_ItemMorphJass_Conditions takes nothing returns boolean
    if (not (GetItemTypeId(GetManipulatedItem()) == 'afac')) then
        return false
    endif
    return true
endfunction

function Trig_ItemMorphJass_Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local item item1 = GetManipulatedItem()
    local item item2
    call RemoveItem(item1)
    call UnitAddItemById(c, 'spsh')
    set item2 = GetLastCreatedItem()
    call IssueTargetItemOrder(c, "smart", item2)
    call TriggerSleepAction("YourDuration")
    call RemoveItem(item2)
    call UnitAddItemById(c, 'afac')
endfunction

//===========================================================================
function InitTrig_ItemMorphJass takes nothing returns nothing
    set gg_trg_ItemMorphJass = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ItemMorphJass, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( gg_trg_ItemMorphJass, Condition( function Trig_ItemMorphJass_Conditions ) )
    call TriggerAddAction( gg_trg_ItemMorphJass, function Trig_ItemMorphJass_Actions )
endfunction

Or something like it and it should work (I think :p).
 
Status
Not open for further replies.
Top