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

[Spell] Mirror image attachments

Status
Not open for further replies.
Level 3
Joined
Oct 7, 2011
Messages
37
Hi I have a map where the heroes get weapon attachments and wing attachments and various other items added to them

When someone casts mirror image the image pops up minus the attachments this is obviously a bit of a giveaway as to which is the real hero

Does anyone know an event that would work to detect mirror images being created so I can copy the attachments over?

I have tried A unit spawns a summoned unit but that didn't detect my mirror image spell
I have the condition Summoned Unit is an illusion == true atm it seems appropriate so I don't think it stopped the trigger firing

I can trigger of the specific ability being cast I am trying that at the moment but I'm not sure how its going to work are the units already created and how to i actually get hold of them to attach things seems a mystery if i cant trigger from the creation event

Anyway thanks if someone has any ideas :)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Unit enters map. The problem is more like how to find the owner. Have just tested it. It seems like Mirror Image creates an illusion at where the caster ends up too but instantly removes it again. I know this because it triggered the enter event, was marked as an illusion and held another object id. Well, I do not think this would be a proper solution either to pick units at this location. Best would be to create the illusions yourself via trigger using the Item: Illusions ability (AIil) for example.

Second idea: Mark the caster with some unique data on cast that is transfered to illusions by the system (maybe abilities), then check who matches with them. May finally remove the mark. The enter events fire simultaneously after cast, caster and illusions are just hidden and shown again when they are hit by the missile.
 
Level 3
Joined
Oct 7, 2011
Messages
37
[solved]

Ok I've got it licked now
Thanks for your suggestions

I have added an array for the attachment ability codes, two new triggers and a couple of helper functions as well as follows

For detecting the spell has been cast(This is needed because the wing attachments alter the fly height of units so we need to set the main hero back to mother earth before touching the illusions
JASS:
function isTheSpellMirrorImage takes nothing returns boolean
    return  (GetSpellAbilityId() == 'A02D' )
endfunction

function SetWingedUnitsToGround takes nothing returns nothing
    local unit hero = GetSpellAbilityUnit()
    if(DoesHeroHaveWings(hero)) then
        call SetUnitFlyHeight(hero, 0.00, 0.00 )
        call SetUnitUserData(hero,10)
    else
        call SetUnitUserData(hero,1)
    endif
    set hero = null
endfunction

//===========================================================================
function InitTrig_Image_Attachments takes nothing returns nothing
    set gg_trg_Image_Attachments = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Image_Attachments, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Image_Attachments, Condition( function isTheSpellMirrorImage ) )
    call TriggerAddAction( gg_trg_Image_Attachments, function SetWingedUnitsToGround )
endfunction
I use the custom value for the unit later on to know that the hero has wings so thier height needs to be reset later just easier than another global variable and i have the else condition in case they had wings at one point then lost them later on.

Another trigger to catch illusions being added to the map from your suggestion
There is one extra image that is removed I think it is the one that is bounced around like a missile as you mentioned this trigger calls the copyAttachment function and sets the fly height of the original caster if necessary
JASS:
function isEnteringUnitAnIllusion takes nothing returns boolean
    return (IsUnitIllusionBJ(GetEnteringUnit()) == true )
endfunction

function AddAttachmentsToIllusions takes nothing returns nothing
    local unit target = GetEnteringUnit()
    local player owner = GetOwningPlayer(target)
    local unit source = udg_heroList[GetConvertedPlayerId(owner)]
    call CopyAttachmentsBetweenUnits(source,target)
    if ( GetUnitUserData(source) == 10 ) then
        call SetUnitFlyHeight(source, 150.00, 150.00 )
        call SelectUnitForPlayerSingle( source, owner )
    else
    endif
    set source = null
    set owner = null
    set target = null
endfunction

//===========================================================================
function InitTrig_ImageEntersMap takes nothing returns nothing
    set gg_trg_ImageEntersMap = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_ImageEntersMap, GetPlayableMapRect() )
    call TriggerAddCondition( gg_trg_ImageEntersMap, Condition( function isEnteringUnitAnIllusion ) )
    call TriggerAddAction( gg_trg_ImageEntersMap, function AddAttachmentsToIllusions )
endfunction
And the two functions to detect wings and to detect all other attachments
JASS:
//The wings are items 22, 23, 24 and 25
//So just check those items and whether the passed in hero has the attachment ability
function DoesHeroHaveWings takes unit hero returns boolean
    local integer index = 22
    loop
        exitwhen index > 25
        if(GetUnitAbilityLevel(hero, udg_Attachments[index]) > 0) then
            return true
        endif
        set index = index + 1
    endloop
    return false
endfunction

function CopyAttachmentsBetweenUnits takes unit source, unit target returns nothing
    local integer index = 0
    local boolean hasWings = DoesHeroHaveWings(source)
    loop
        exitwhen index > udg_AttachmentLastIndex
        if(GetUnitAbilityLevel(source, udg_Attachments[index]) > 0) then
            call UnitAddAbility(target, udg_Attachments[index])
            //If the attachment is wings then we need to add the hover ability and set the fly height
            if(index > 21 and index <= 25 ) then
                if UnitAddAbility(target,'Amrf') then
                    call UnitRemoveAbility(target,'Amrf')
                endif
            endif
        endif
        set index = index + 1
    endloop
    if(hasWings == true) then
        call SetUnitFlyHeight(target, 150.00, 150.00 )
    endif
endfunction

And just to complete the spamathon the variables i used for the attachments
  • Actions
    • Set Attachments[0] = Attachment - Axe
    • Set Attachments[1] = Attachment - Bloodbreak
    • Set Attachments[2] = Attachment - Broadsword
    • Set Attachments[3] = Attachment - Chaos Axe
    • Set Attachments[4] = Attachment - Claws
    • Set Attachments[5] = Attachment - ColdSteelKukri
    • Set Attachments[6] = Attachment - Crown
    • Set Attachments[7] = Attachment - Crystal Sword
    • Set Attachments[8] = Attachment - Dragonblade
    • Set Attachments[9] = Attachment - Firesword
    • Set Attachments[10] = Attachment - Fish Finder
    • Set Attachments[11] = Attachment - Fishing Hat
    • Set Attachments[12] = Attachment - Fishing Rod Advanced
    • Set Attachments[13] = Attachment - Fishing Rod Basic
    • Set Attachments[14] = Attachment - Fishing Rod Fancy
    • Set Attachments[15] = Attachment - Maul
    • Set Attachments[16] = Attachment - MindStaff
    • Set Attachments[17] = Attachment - Mystic Staff
    • Set Attachments[18] = Attachment - Psiblade
    • Set Attachments[19] = Attachment - QuarterStaff
    • Set Attachments[20] = Attachment - Staff of Ages
    • Set Attachments[21] = Attachment - Staff of Silence
    • Set Attachments[22] = Attachment - Wing Black
    • Set Attachments[23] = Attachment - Wing Dragon
    • Set Attachments[24] = Attachment - Wing Nightmare
    • Set Attachments[25] = Attachment - Wing Shiva
    • Set AttachmentLastIndex = 25
 
Status
Not open for further replies.
Top