• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Trigger Illusions?

Status
Not open for further replies.
Level 25
Joined
Jul 10, 2006
Messages
3,315
I can't seem to find the GUI version I made of this, but the idea is that you create a dummy unit, give it the Item Illusions ability (unit version), and use this custom script to make it cast on your target:
  • Custom script: call IssueTargetOrderById(udg_DummyUnit, 852274, udg_TargetUnit)
If you're using newgen, here's the vjass:
JASS:
library CreateIllusion initializer Init
    globals
        private unit IllusionCaster
        private constant integer IllusionAbility =   'A000'  //item illusion
        private constant integer IllusionUnit    =   'nalb'  //dummy caster
        private boolean IsIllusion                  //used for checking if the illusion was made by system
        unit LastCreatedIllusion                    //as at any time to reference the last illusion made by system
        real IllusionCreatedEvent                   //use to detect when an illusion is created
    endglobals
    
    function UnitCreateIllusion takes unit u returns nothing
        call SetUnitX(IllusionCaster, GetUnitX(u))
        call SetUnitY(IllusionCaster, GetUnitY(u))
        call SetUnitOwner(IllusionCaster, GetOwningPlayer(u), false)
        call IssueTargetOrderById(IllusionCaster, 852274, u)
        call SetUnitOwner(IllusionCaster, Player(15), false)
        set IsIllusion = true
    endfunction
    
    private function GetIllusion takes nothing returns nothing
        if IsIllusion then
            set LastCreatedIllusion = GetTriggerUnit()
            set IllusionCreatedEvent = 0
            set IllusionCreatedEvent = 1
        endif
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local region r = CreateRegion()
        call RegionAddRect(r, GetPlayableMapRect())
        set IllusionCaster = CreateUnit(Player(15), IllusionUnit, 0, 0, 0)
        call UnitAddAbility(IllusionCaster, IllusionAbility)
        call ShowUnit(IllusionCaster, false)
        call TriggerAddAction(t, function GetIllusion)
        call TriggerRegisterEnterRegion( t, r, null )
    endfunction
endlibrary

And how to use:
  • test select
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • Custom script: call UnitCreateIllusion(GetTriggerUnit())
The system was also meant to save the created illusion to an event, but I never got around to fixing that part. The illusion creating works fine, though.
 
Level 7
Joined
Nov 18, 2012
Messages
272
I can't seem to find the GUI version I made of this, but the idea is that you create a dummy unit, give it the Item Illusions ability (unit version), and use this custom script to make it cast on your target:
  • Custom script: call IssueTargetOrderById(udg_DummyUnit, 852274, udg_TargetUnit)

You mean Item Illusions for units?

And do udg_LastCreatedUnit and udg_PickedUnit work?
 
Status
Not open for further replies.
Top