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

[Solved] Simple passive ability help:)

Status
Not open for further replies.
Level 8
Joined
Feb 3, 2013
Messages
277
JASS:
scope AS initializer Init

    globals
        private constant string EFFECT = "war3mapImported\\BlinkCaster.mdx" // The effect that will be displayed at the attacker's previous position
        private constant integer ID    = 'A000' // The ability's raw ID
    endglobals
    
    private function Register takes nothing returns nothing
        call TriggerRegisterUnitEvent(GetTriggeringTrigger(), GetEnumUnit(), EVENT_UNIT_DAMAGED)
    endfunction
    
    private function Conditions takes nothing returns boolean
        return GetUnitAbilityLevel(GetEventDamageSource(), ID) > 0
    endfunction
    
    private function AS_Actions takes nothing returns nothing
        local unit target             = GetTriggerUnit()
        local unit attacker           = GetEventDamageSource()
        local location attacker_point = GetUnitLoc(attacker)
        local location temp_point     = PolarProjectionBJ(GetUnitLoc(target), 100, GetRandomReal(0,360))
        call SetUnitX(attacker, GetLocationX(temp_point))
        call SetUnitY(attacker, GetLocationY(temp_point))
        call DestroyEffect(AddSpecialEffectLoc(EFFECT, attacker_point))
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local group g   = CreateGroup ()
        set g           = GetUnitsInRectAll(GetPlayableMapRect())
        call ForGroup(g, function Register)
        call TriggerAddCondition(t, Filter(function Conditions))
        call TriggerAddAction(t, function AS_Actions)
    endfunction
    
endscope

hi all, this is my first time trying to put together a vjass spell.
basically this trigger is supposed to let a unit blink to its attack target on attack. For some reason the code saves fine - but doesn't work in game. a little help would be appreciated. thanks in advance. (SOLVED THANKS, WaterKnight)
 
Last edited:
Level 8
Joined
Feb 3, 2013
Messages
277
GetTriggeringTrigger is not the new trigger you created. Pass it globally if you want to use ForGroup. Also this registers only those units that were picked when the Init method ran.

Pass it globally if you want to use ForGroup"
Let me try something - I'll get back on that

Also this registers only those units that were picked when the Init method ran"
Yes i know that - I was just trying to make somethig in vJASS :) Thanks a lot for your responses. Much appreciated

EDIT:
Thank you, Waterknight - I'm very happy to let you know that, you just help me succeed in creating my first own vJASS spell :)
 
Status
Not open for further replies.
Top