Hey guys, my spell is called Landslide and what it does when my hero (the Earthfather) casts the spell on a target it creates dust effects up until it reaches the target however at the moment it just goes in a straight line and if the target is moving i think the line gets messed up. Anyway heres my code, i tried to remove leaks, replace BJs and comment my code as much as possible before i submitted it:
What i would be really greatful for is if anyone could help me make the dust kinda chase the enemy during the loop but only so it goes to a distance of 880-900 (Hence the loop)
JASS:
function Landslide_C takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A009' ) ) then
return false
endif
return true
endfunction
function Landslide_A takes nothing returns nothing
local unit l_caster = GetSpellAbilityUnit()
local unit l_target = GetSpellTargetUnit()
local location l_rockLoc
local location l_casterLoc = GetUnitLoc(l_caster)
local location l_targetLoc = GetUnitLoc(l_target)
local real l_casterFacing
local real l_loop = 0.00
local real l_distance = DistanceBetweenPoints(l_casterLoc, l_targetLoc)
local real l_result = 23.32
// Simple wait for unit to face target
call TriggerSleepAction(0.6)
// We set the facing now rather then instantly
set l_casterFacing = GetUnitFacing(l_caster)
loop
// Max distance is 880
exitwhen l_loop == 880
// Check if we are close enough to the target to damage
if (l_loop > l_distance) then
// Check if the distance is REALLY close
set l_result = l_distance / l_loop
endif
if (l_result < 1) then
// Effect has reached target
// --
// Make sure our loop doesn't run after this
set l_loop = 880
// Create our dust effect at target and make a Rock shoot out of the ground
call CreateNUnitsAtLoc( 1, 'A011', Player(9), l_targetLoc, bj_UNIT_FACING )
call UnitApplyTimedLife(GetLastCreatedUnit(), 'BTLF', 0.25)
call CreateNUnitsAtLoc( 1, 'A010', Player(9), l_targetLoc, bj_UNIT_FACING )
call UnitApplyTimedLife(GetLastCreatedUnit(), 'BTLF', 1.75)
call SetUnitFlyHeight(GetLastCreatedUnit(), 0, 1000)
else
// Effect has yet to reach target
// --
// Set a gap between the effects so they dont appear instantly
call TriggerSleepAction(0.01)
// Establish our location and create an effect at it for a really short time
set l_rockLoc = PolarProjectionBJ(l_casterLoc, l_loop, l_casterFacing)
call CreateNUnitsAtLoc( 1, 'A011', Player(9), l_rockLoc, GetRandomReal(0, 360) )
call UnitApplyTimedLife(GetLastCreatedUnit(), 'BTLF', 0.05 )
// Set our loop so the effect advances forward
set l_loop = l_loop + 80
endif
endloop
// Remove our variables until next time
call RemoveLocation(l_rockLoc)
call RemoveLocation(l_casterLoc)
call RemoveLocation(l_targetLoc)
set l_casterFacing = 0.00
set l_caster = null
set l_target = null
set l_result = 23.32
set l_loop = 0.00
set l_distance = 0.00
endfunction
//===========================================================================
function InitTrig_LandslideL takes nothing returns nothing
local trigger Landslide = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Landslide, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( Landslide, Condition( function Landslide_C ) )
call TriggerAddAction( Landslide, function Landslide_A )
endfunction
What i would be really greatful for is if anyone could help me make the dust kinda chase the enemy during the loop but only so it goes to a distance of 880-900 (Hence the loop)