Bah I shame myself that this 'easy' JASS spell doesn't work, and that I can't create it Well the currently plan is to whenever a hero uses its item on a unit, it is changing its position with it. (So the hero on the place of the target, and the target on place of the hero). Currently I had this:
function Trig_Swap_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A06G' ) ) then
return false
endif
return true
endfunction
function Trig_Swap_Actions takes nothing returns nothing
local unit Caster = GetSpellAbilityUnit()
local unit Target = GetSpellTargetUnit()
local location C = GetUnitLoc(Caster)
local location T = GetSpellTargetLoc(Target)
call TriggerSleepAction( 0.10 )
call SetUnitPositionLoc( Caster, T )
call SetUnitPositionLoc( Target, C )
set Caster=null
set Target=null
call RemoveLocation(C)
call RemoveLocation(T)
endfunction
//===========================================================================
function InitTrig_Swap takes nothing returns nothing
set gg_trg_Swap = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Swap, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Swap, Condition( function Trig_Swap_Conditions ) )
call TriggerAddAction( gg_trg_Swap, function Trig_Swap_Actions )
endfunction
fifth, GetSpellAbilityUnit is a slower version of GetTriggerUnit
here is a recode of all that
function Trig_Swap_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A06G'
endfunction
function Trig_Swap_Actions takes nothing returns nothing
local unit c = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local real x = GetUnitX( c )
local real y = GetUnitY( c )
call SetUnitX( c, GetUnitX( t ) )
call SetUnitY( c, GetUnitY( t ) )
call SetUnitX( t, x )
call SetUnitY( t, y )
set c=null
set t=null
endfunction
//===========================================================================
function InitTrig_Swap takes nothing returns nothing
set gg_trg_Swap = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Swap, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Swap, Condition( function Trig_Swap_Conditions ) )
call TriggerAddAction( gg_trg_Swap, function Trig_Swap_Actions )
endfunction