Greetings. I would like to ask for help. Below is the skill resembling DOTA's Venomancer first skill (maybe is called Venomous Gale, or something else), but there are some issues. First, the missile stops halfway and is not removed when casted quickly and continuously, and secondly, while the missile is stuck, next cast makes new missiles travel very fast. What is the problem in my scripting? Thank you and sorry for my inefficiency in scripting.
JASS:
globals
unit array sv_caster
unit array sv_missile
group array sv_group
group array sv_tempgroup
boolexpr sv_b
trigger array sv_loop
integer sv_i = 0
endglobals
function ShadowVenomSpellCheck takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A03A' ) ) then
return false
endif
return true
endfunction
function ShadowVenomFilter takes nothing returns boolean
return ( IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE ) == false ) and ( IsUnitType( GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE ) == false ) and ( IsUnitType( GetFilterUnit(), UNIT_TYPE_MECHANICAL ) == false ) and ( IsUnitEnemy( GetFilterUnit(), GetOwningPlayer(sv_caster[sv_i]) ) == true )
endfunction
function ShadowVenomLoop takes nothing returns nothing
local location point1 = GetUnitLoc( sv_missile[sv_i] )
local location point2
local real x = GetLocationX(point1) + 33.00 * Cos( GetUnitFacing(sv_missile[sv_i]) * bj_DEGTORAD )
local real y = GetLocationY(point1) + 33.00 * Sin( GetUnitFacing(sv_missile[sv_i]) * bj_DEGTORAD )
local unit u
local unit dummy
set point2 = Location( x, y )
call GroupEnumUnitsInRangeOfLoc( sv_group[sv_i], point1, 200.00, sv_b )
loop
set u = FirstOfGroup(sv_group[sv_i])
exitwhen(u == null)
call GroupRemoveUnit(sv_group[sv_i], u)
if ( IsUnitInGroup(u, sv_tempgroup[sv_i]) == false ) then
set dummy = CreateUnitAtLoc( GetOwningPlayer(sv_caster[sv_i]), 'n002', point1, bj_UNIT_FACING )
call UnitAddAbility( dummy, 'A03X' )
call SetUnitAbilityLevel( dummy, 'A03X', GetUnitAbilityLevel( sv_caster[sv_i], 'A03A') )
call UnitApplyTimedLife( dummy, 'BTLF', 1.00 )
call ShowUnit( dummy, false )
call IssueTargetOrder( dummy, "shadowstrike", u )
call GroupAddUnit(sv_tempgroup[sv_i], u)
endif
endloop
call SetUnitPositionLoc( sv_missile[sv_i], point2 )
call SetUnitUserData( sv_missile[sv_i], ( GetUnitUserData(sv_missile[sv_i]) - 1 ) )
call RemoveLocation(point1)
call RemoveLocation(point2)
set point1 = null
set point2 = null
set u = null
set dummy = null
if ( GetUnitUserData(sv_missile[sv_i]) <= 0 ) then
call KillUnit( sv_missile[sv_i] )
call GroupClear( sv_group[sv_i] )
call GroupClear( sv_tempgroup[sv_i] )
call DestroyGroup( sv_group[sv_i] )
call DestroyGroup( sv_tempgroup[sv_i] )
call DestroyTrigger(sv_loop[sv_i])
set sv_caster[sv_i] = null
set sv_missile[sv_i] = null
set sv_group[sv_i] = null
set sv_tempgroup[sv_i] = null
set sv_loop[sv_i] = null
endif
endfunction
function ShadowVenomAction takes nothing returns nothing
local location casloc
set sv_i = sv_i + 1
call StartSound(gg_snd_ShadowStrikeBirth1)
call Skill_TextTag("Shadow Venom")
set sv_caster[sv_i] = GetTriggerUnit()
set sv_loop[sv_i] = CreateTrigger()
call DisableTrigger(sv_loop[sv_i])
set sv_group[sv_i] = CreateGroup()
set sv_tempgroup[sv_i] = CreateGroup()
set casloc = GetUnitLoc(sv_caster[sv_i])
set sv_missile[sv_i] = CreateUnitAtLoc(GetOwningPlayer(sv_caster[sv_i]), 'n00M', casloc, GetUnitFacing(sv_caster[sv_i]))
call UnitAddAbility(sv_missile[sv_i], 'Aloc')
call SetUnitUserData(sv_missile[sv_i], R2I(750/33))
call TriggerRegisterTimerEvent( sv_loop[sv_i], 0.03, true )
call TriggerAddAction(sv_loop[sv_i], function ShadowVenomLoop)
call EnableTrigger( sv_loop[sv_i] )
call RemoveLocation(casloc)
set casloc = null
endfunction
//===========================================================================
function InitTrig_Shadow_Venom takes nothing returns nothing
local trigger ShadowVenom = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( ShadowVenom, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( ShadowVenom, Condition(function ShadowVenomSpellCheck) )
call TriggerAddAction( ShadowVenom, function ShadowVenomAction )
set sv_b = Condition(function ShadowVenomFilter)
endfunction