- Joined
- Jan 26, 2007
- Messages
- 4,789
Hi, I've been learning JASS for... 2 and a half days now and thought "hey, let's create a spell".
I didn't want to create anything fancy, so here is the idea:
Spell Idea:
When a certain AoE-ability is cast, every enemy unit inside that AoE will be hit by storm bolt.
As the level of the spell increases, the amount of targets hit by the spell will increase.
I've used dummies for the storm bolt and the AoE-spell is based of Blizzard.
Problem:
The problem is that the spell doesn't always work, I've tried it multiple times and got a 10% activation chance (I've tested the map twice, casted the spell 10 times in each run, in the first run the spell activated 2 times, in the second run it didn't activate at all - that makes 2/20, or 10% -.-).
Of course, I want it to activate whenever I want it, 10% isn't enough...
Narrow the problem down:
I've created simple messages that occured at logically placed times in the trigger.
This is what I have found out:
Object Info:
Any help is appreciated.
Please do not begin shouting for obvious fails -.-
I didn't want to create anything fancy, so here is the idea:
Spell Idea:
When a certain AoE-ability is cast, every enemy unit inside that AoE will be hit by storm bolt.
As the level of the spell increases, the amount of targets hit by the spell will increase.
I've used dummies for the storm bolt and the AoE-spell is based of Blizzard.
Problem:
The problem is that the spell doesn't always work, I've tried it multiple times and got a 10% activation chance (I've tested the map twice, casted the spell 10 times in each run, in the first run the spell activated 2 times, in the second run it didn't activate at all - that makes 2/20, or 10% -.-).
Of course, I want it to activate whenever I want it, 10% isn't enough...
JASS:
function MS_C takes nothing returns boolean
return GetSpellAbilityId()=='A001'
endfunction
function MS_A takes nothing returns nothing
local group g
local integer i
local unit dummy
local location array TempLoc
local unit array Unit
local integer targets
set i = 0
set Unit[1] = GetSpellAbilityUnit()
set TempLoc[1] = GetUnitLoc(Unit[1])
set TempLoc[2] = GetSpellTargetLoc()
set targets = (2 + (GetUnitAbilityLevelSwapped('A001', Unit[1])))
set g = GetUnitsInRangeOfLocAll(800.00, TempLoc[2])
loop
exitwhen i == targets
set Unit[2] = FirstOfGroup(g)
if IsUnitEnemy(Unit[2], GetOwningPlayer(Unit[1]))==true then
call GroupRemoveUnit(g,Unit[2])
set i = i + 1
set dummy = CreateUnitAtLoc(GetOwningPlayer(Unit[1]), 'h000', GetUnitLoc(Unit[1]), 0.00)
call IssueTargetOrderBJ(dummy, "thunderbolt", Unit[2])
call UnitApplyTimedLifeBJ (1.50, 'BTLF', dummy)
call UnitDamageTargetBJ( Unit[1], Unit[2], ( I2R(GetHeroStatBJ(bj_HEROSTAT_STR, Unit[1], true)) * 2.50 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
set dummy = null
endif
endloop
set Unit[1] = null
set Unit[2] = null
set TempLoc[1] = null
set TempLoc[2] = null
set g = null
endfunction
function InitTrig_My_Spell takes nothing returns nothing
local trigger spell
set spell=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(spell, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(spell, Condition(function MS_C))
call TriggerAddAction(spell, function MS_A)
endfunction
Narrow the problem down:
I've created simple messages that occured at logically placed times in the trigger.
This is what I have found out:
- Everything before the loop always works as expected
- The loop itself only activates in 10% of the cases (when the actual spell works)
- Everything after the loop does not activate if the loop isn't activated
Object Info:
- Dummy (h000): 10k mana, 1000 mana regen - has the abilities "locust", "invulnerable", "Storm Bolt".
- Blizzard (A001): 800 AoE, 900 cast range.
- Storm Bolt (A000): 0 mana cost, 0 cooldown, 0 cast time, 2000 cast range.
Any help is appreciated.
Please do not begin shouting for obvious fails -.-