• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[JASS] Help with a spell

Status
Not open for further replies.
Level 1
Joined
Jul 13, 2009
Messages
2
Hey people...I've been struggling to make my first spell in JASS work, but something is wrong and I can't find out what it really is... the code is as following:

Code:
function HolyCondition takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction

function HolyActions2 takes nothing returns nothing
     local unit caster = GetSpellAbilityUnit()
     local location caster_position = GetUnitLoc(caster)
     local group allies = CreateGroup()
     local unit temp
     local integer count
     local location temp_loc
     local unit dummy
     local unit temp2
     local group all = CreateGroup()
     local group enemies = CreateGroup()
     if (IsUnitOwnedByPlayer(FirstOfGroup(GetUnitsInRangeOfLocMatching(1000, caster_position, null)), GetOwningPlayer(caster)) == true) then
     call GroupEnumUnitsInRangeOfLoc(allies, caster_position, 600.0, null)
     endif
     if (IsUnitOwnedByPlayer(FirstOfGroup(GetUnitsInRangeOfLocMatching(1000, caster_position, null)), GetOwningPlayer(caster)) == false) then
     call GroupEnumUnitsInRangeOfLoc(enemies, caster_position, 1000.0, null)
     endif
     loop
        set count = CountUnitsInGroup(allies)
        set temp = FirstOfGroup(allies)
        set temp2 = FirstOfGroup(enemies)
    call GroupAddGroup(allies, all)
    call GroupAddGroup(enemies, all)
        exitwhen count == 0
        if IsUnitOwnedByPlayer(temp, GetOwningPlayer(caster)) then
            set temp_loc = GetUnitLoc(temp)
            call CreateNUnitsAtLoc(1, 'h000', GetOwningPlayer(caster), temp_loc, bj_UNIT_FACING)
            set dummy = GetLastCreatedUnit()
            call UnitAddAbilityBJ('A002', dummy)
            call IssueTargetOrderBJ(dummy, "holybolt", FirstOfGroup(all))
        endif
        if IsUnitType(temp2, UNIT_TYPE_UNDEAD) then
            call UnitDamageTarget(caster, temp2, (45 * I2R(GetUnitAbilityLevelSwapped('A000', caster))), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
        endif
        call GroupRemoveUnit(allies, temp)
        call GroupRemoveUnit(enemies, temp2)
        call GroupRemoveUnit(all, temp2)
        call GroupRemoveUnit(all, temp)
        set count = count - 1
    endloop
        set temp = null
        set caster = null
        set temp_loc = null
        set enemies = null
        set allies = null
        set caster_position = null
        set dummy = null
        set temp2 = null
        set all  = null
endfunction
  
function InitTrig_Holy_Light_JASS takes nothing returns nothing
 set gg_trg_Holy_Light_JASS = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Holy_Light_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Holy_Light_JASS, Condition(function HolyCondition))
    call TriggerAddAction(gg_trg_Holy_Light_JASS, function HolyActions2)
endfunction

The spell is supposed to work as a commanding order, but providing units with an ability they didn't use to have. In this specific spell, units are given the Holy Light spell and are supposed to cast it on a random unit (any ally or undead foes), but instead of dealing half damage to undead, dealing twice as much damage to them. Help please :sad:
 
Status
Not open for further replies.
Top