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

[JASS] This is bizzare.

Status
Not open for further replies.
Level 7
Joined
Oct 14, 2008
Messages
340
I don't understand this.
The spell: shoots a missile at a target, upon impact the target is sent to where the caster is. Now, this spell works just fine as long as i don't issue the caster any orders after casting, but say i cast the spell, then walk away.. the target doesn't get teleported, anybody know why this is happening?

JASS:
function Trig_Displace_cast_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A02S'
endfunction

function targetHasBuff takes nothing returns boolean
    return ( UnitHasBuffBJ(GetSpellTargetUnit(), 'B00U') == true )
endfunction

function Trig_Displace_cast_Actions takes nothing returns nothing
    local real x
    local real y
    local real x1
    local real y1
    loop
        exitwhen ( targetHasBuff() )
        call TriggerSleepAction(0.1)
    endloop
    set x = GetUnitX(GetTriggerUnit())
    set y = GetUnitY(GetTriggerUnit())
    set x1 = GetUnitX(GetSpellTargetUnit())
    set y1 = GetUnitY(GetSpellTargetUnit())
    call SetUnitPosition( GetSpellTargetUnit(), x+50.0, y+50.0 )
    set x = GetUnitX(GetSpellTargetUnit())
    set y = GetUnitY(GetSpellTargetUnit())
    call AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", x, y)
    call DestroyEffect(GetLastCreatedEffectBJ())
    call AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", x1, y1)
    call DestroyEffect(GetLastCreatedEffectBJ())
endfunction

//===========================================================================
function InitTrig_Displace_cast takes nothing returns nothing
    set gg_trg_Displace_cast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Displace_cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Displace_cast, Condition( function Trig_Displace_cast_Conditions ) )
    call TriggerAddAction( gg_trg_Displace_cast, function Trig_Displace_cast_Actions )
endfunction
 
Just changed a bit out

JASS:
function Trig_Displace_cast_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real array x
    local real array y
    if GetSpellAbilityID() == 'A02S' then
        loop
            exitwhen UnitHasBuffBJ(target, 'B00U') == true
            call TriggerSleepAction(0.1)
        endloop
        set x[0] = GetUnitX(caster) + 50
        set y[0] = GetUnitY(caster) + 50
        set x[1] = GetUnitX(target)
        set y[1] = GetUnitY(target)
        call SetUnitPosition(target, x[0], y[0])
        call AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl",x[0], y[0])
        call DestroyEffect(GetLastCreatedEffectBJ())
        call AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", x[1], y[1])
        call DestroyEffect(GetLastCreatedEffectBJ())
    endif
    set target = null
    set caster = null
endfunction

//===========================================================================
function InitTrig_Displace_cast takes nothing returns nothing
    set gg_trg_Displace_cast = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Displace_cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Displace_cast, function Trig_Displace_cast_Actions )
endfunction

#1, I wouldn't use any BJ functions.

#2, weird.. lemme look at it for awhile and I'll edit this post in a few :eek:

#3: I edited some of the code already just so it's easy for me to myself to read. You don't have to edit this code, but this is how I normally write : D.
 
Level 7
Joined
Oct 14, 2008
Messages
340
okay, i like the changes you made. :)
also i got rid of the lastcreated effect bj, but the problem still stands.
JASS:
function Trig_Displace_cast_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A02S'
endfunction

function Trig_Displace_cast_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real array x
    local real array y
    local effect e
    loop
        exitwhen UnitHasBuffBJ(target, 'B00U') == true
        call TriggerSleepAction(0.1)
    endloop
    set x[0] = GetUnitX(caster) + 50.0
    set y[0] = GetUnitY(caster) + 50.0
    set x[1] = GetUnitX(target)
    set y[1] = GetUnitY(target)
    call SetUnitPosition( target, x[0], y[0] )
    set x[1] = GetUnitX(target)
    set y[1] = GetUnitY(target)
    set e = AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", x[0], y[0])
    call DestroyEffect(e)
    set e = AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", x[1], y[1])
    call DestroyEffect(e)
endfunction

//===========================================================================
function InitTrig_Displace_cast takes nothing returns nothing
    set gg_trg_Displace_cast = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Displace_cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Displace_cast, Condition( function Trig_Displace_cast_Conditions ) )
    call TriggerAddAction( gg_trg_Displace_cast, function Trig_Displace_cast_Actions )
endfunction

scraaatch that, nevermind, something about those tweaks made it work just fine :p
thanks, +rep
 
Status
Not open for further replies.
Top