• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Swap Ability -> Item :(

Status
Not open for further replies.
Level 4
Joined
Jul 3, 2006
Messages
61
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:
JASS:
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

Bahbah, shame on me :(
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
First, there is no Spell Target Loc in this case :p

Second, GetSpellTargetLoc takes no parameters

third, locations suck

fourth, If/Then boolean conditions suck

fifth, GetSpellAbilityUnit is a slower version of GetTriggerUnit

here is a recode of all that

JASS:
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
 
Status
Not open for further replies.
Top