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:
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
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
