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

[vJASS] spell problem

Status
Not open for further replies.
I don't know why this code doesn't work.
JASS:
library spellNew initializer init
globals
    private  constant real DAMAGE       = 50.00
    private  constant integer ABIL_ID   = 'A001'
    private  constant real AOE          =  500.00
    private  constant string SFX        = "Abilities\\Spells\\Human\\ManaFlare\\ManaFlareBoltImpact.mdl"
    private  constant string ATTACHMENT = "origin"
    private  constant damagetype D_TYPE = DAMAGE_TYPE_NORMAL
    private  constant attacktype A_TYPE = ATTACK_TYPE_NORMAL
endglobals
native UnitAlive takes unit id returns boolean
private function getAoE takes integer level returns real
    return AOE*level
endfunction

private function getDamage takes integer level returns real
    return DAMAGE*level
endfunction

private function getFilter takes unit caster, unit u returns boolean
    return UnitAlive(u)/*
    */and IsUnitEnemy(u, GetOwningPlayer(caster))/*
    */and not IsUnitType(u, UNIT_TYPE_STRUCTURE)/*
    */and not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE)
endfunction

private function spellConditions takes nothing returns boolean
    return  GetSpellAbilityId ( ) == ABIL_ID
endfunction

globals
     group g = bj_lastCreatedGroup
endglobals

private function spellActions takes nothing returns nothing
    local unit caster
    local integer level
    local real x
    local real y   
    local unit u
    local real d
    local real r
    set caster = GetTriggerUnit()
    set level = GetUnitAbilityLevel(caster, ABIL_ID)
    set x = GetUnitX(caster)
    set y = GetUnitY(caster)
    set r = getAoE(level)
    set d = getDamage(level)
    call GroupEnumUnitsInRange(g, x, y, r, null)
    loop 
        set u = FirstOfGroup (g)
        exitwhen u == null
        if getFilter(caster, u) then
            call UnitDamageTarget(caster,u,d,true,false,A_TYPE,D_TYPE,null)
            call DestroyEffect(AddSpecialEffectTarget(SFX, u, ATTACHMENT))
        endif
        call GroupRemoveUnit(g, u)
    endloop        
        set u       = null
        set caster  = null
endfunction

private function init takes nothing returns nothing
    local trigger t 
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function spellConditions))
    call TriggerAddAction(t, function spellActions)
endfunction
endlibrary
 
Status
Not open for further replies.
Top