- Joined
- May 4, 2007
- Messages
- 2,260
JASS:
//condition
function Cond takes nothing returns boolean
return GetSpellAbilityId()== 'A000'
endfunction
//actoin
function Mass_Sleep takes nothing returns nothing
local group sleep_units
local unit first_spell_target
local unit caster
local unit dummy_caster
local location target_ability_point
set caster = GetTriggerUnit()
set target_ability_point = GetSpellTargetLoc()
set sleep_units = GetUnitsInRangeOfLocAll(200.00, target_ability_point)
set first_spell_target = FirstOfGroup(sleep_units)
loop
exitwhen first_spell_target==null
set first_spell_target = FirstOfGroup(sleep_units)
if IsUnitEnemy(first_spell_target, GetOwningPlayer(caster))==true then
call GroupRemoveUnit(sleep_units, first_spell_target)
set dummy_caster = CreateUnitAtLoc(GetOwningPlayer(caster), 'h000', GetUnitLoc(first_spell_target), 0.00)
call UnitAddAbility(dummy_caster, 'A001')
call IssueTargetOrderBJ (dummy_caster, "sleep", first_spell_target)
call UnitApplyTimedLifeBJ (2.5, 'BTLF', dummy_caster)
set dummy_caster = null
endif
endloop
set sleep_units = null
set caster = null
set target_ability_point = null
endfunction
//well, events, conditions and other (i think)
function InitTrig_masssleep takes nothing returns nothing
local trigger Mytrigger
set Mytrigger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(Mytrigger, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(Mytrigger, Condition(function Cond))
call TriggerAddAction(Mytrigger, function Mass_Sleep)
endfunction
Guys, this is my AoE mass sleep spell. I know it is not new (i don't need new spells, just want to learn how they are created so i can create my owns).
It was in a tutorial and i made a few changes... Problem is that it doesn't work properly. It is not due my modifications.
It works fine at first, but if you keep casting it, it will eventually stop working ... I don't know if it is some kind of bug ...
Problems:
1- If casted too many times, just breaks up
2 - If there are in the AoE 2 units, an an enemy and an allied unit, the spell doesn't work
3 - If the unit under the sleep spell is attacked, when the spell is cast again, it doesn't work
Notes:
1- Spell created using silence ability
2- Uses a dummy unit and a dummy sleep ability
Raw Codes:
Dummy unit = h000
Silence = A000
Dummy Sleep = A001
The JassCraft program detects no errors and i don't know why it doesn't work properly.
Together with this post i have the test map, where you can found the jass script.
Please help me out.