• 🏆 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!

[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