For some reason the loops don't work in my spell.
PS: It's not complete. I was just testing it to see if it worked, but the loops didn't work.
+rep to whoever helps.
PS: It's not complete. I was just testing it to see if it worked, but the loops didn't work.
JASS:
scope Torrent initializer Init
private struct Torrent
group g
unit c
real z
real dmg
integer level
//=====================Do not touch above=====================\\
//======================Configuration=========================\\
static constant integer AbilId = 039;A000039; //The Ability Id.
static constant integer DummyId = 039;u001039; //The Dummy Id.
static constant integer DummyAbilId = 039;A001039; //The Dummy Ability Id (The Slow).
private static constant real SpellDelay = 2. //How long it takes for Torrent to actually work.
private static constant real BaseDamage = 60 //This is the base damage. Formula is BaseDamage+(DPL*AbilLevel).
private static constant real DPL = 60 //This is how much the damage increases per level.
private static constant real AoE = 225 //This is the Area of Effect of the spell.
private static constant real MaxHeight = 500 //This is how high the units go.
private static constant real DisableTime = 1.53 //This is how long the units are paused/in the air.
private static constant integer FlyAbil = 039;Amrf039; //This is the Crow Ability. Do not change unless you changed the original ability yourself.
private static constant string SFX = "Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl" // This is the Effect shown when Torrent "erupts"
//============================================================\\
//==================Do not touch past here====================\\
static method GroupCondition takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false and IsUnitType(GetFilterUnit(),UNIT_TYPE_DEAD) == false
endmethod
static method start takes unit Caster, real TargetX, real TargetY, integer Level returns nothing
local Torrent d = Torrent.create()
local unit PickedUnit
set d.c = Caster
set d.dmg = .BaseDamage + (.DPL*I2R(Level))
set d.level = Level
call GroupEnumUnitsInRange(d.g, TargetX, TargetY, .AoE, Condition(function Torrent.GroupCondition))
call DestroyEffect(AddSpecialEffectLoc(.SFX, Location(TargetX, TargetY)))
loop
set PickedUnit = FirstOfGroup(d.g)
exitwhen PickedUnit == null
call PauseUnit(PickedUnit, true)
call UnitAddAbility(PickedUnit, .FlyAbil)
call BJDebugMsg("Debug 1")
endloop
call TT_Start(function Torrent.callback, d)
endmethod
static method callback takes nothing returns boolean
local Torrent d = TT_GetData
local integer int = 0
local unit PickedUnit
local real Damage = d.dmg / 2
local real DPS = ((Damage/.MaxHeight)/.DisableTime)*TT_PERIOD
local real ZPerTick = .MaxHeight*(.DisableTime*TT_PERIOD)
local boolean EndCheck
call BJDebugMsg("Debug 2")
loop
set PickedUnit = FirstOfGroup(d.g)
exitwhen PickedUnit == null
call BJDebugMsg("Debug 3")
call SetUnitFlyHeight(PickedUnit, d.z, 0.)
call UnitDamageTarget(d.c, PickedUnit, Damage, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endloop
if d.z >= .MaxHeight then
call BJDebugMsg("Debug 4")
set d.z = d.z - ZPerTick
else
call BJDebugMsg("Debug 4")
set d.z = d.z + ZPerTick
endif
if d.z <= 0. then
call BJDebugMsg("Debug 5")
return true
endif
return false
endmethod
method onDestroy takes nothing returns nothing
local unit PickedUnit
call BJDebugMsg("Debug 6")
loop
set PickedUnit = FirstOfGroup(.g)
exitwhen PickedUnit == null
call PauseUnit(PickedUnit, false)
call CreateUnit(GetOwningPlayer(.c), .DummyId, GetUnitX(PickedUnit), GetUnitY(PickedUnit), 0.)
call UnitAddAbility(bj_lastCreatedUnit, .DummyAbilId)
call SetUnitAbilityLevel(bj_lastCreatedUnit, .DummyAbilId, .level)
call UnitApplyTimedLife(bj_lastCreatedUnit, 039;BTLF039;, 1.5)
call IssueTargetOrder(bj_lastCreatedUnit, "slow", PickedUnit)
call UnitRemoveAbility(PickedUnit, .FlyAbil)
call SetUnitFlyHeight(PickedUnit, 0., 0.)
endloop
set .c = null
call DestroyGroup(.g)
endmethod
endstruct
private function Actions takes nothing returns nothing
call Torrent.start(GetTriggerUnit(), GetLocationX(GetSpellTargetLoc()), GetLocationY(GetSpellTargetLoc()), GetUnitAbilityLevel(GetTriggerUnit(), Torrent.AbilId))
endfunction
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == Torrent.AbilId
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Cond))
call TriggerAddAction(t, function Actions)
endfunction
endscope
+rep to whoever helps.