Fleebop123
New Member
- Reaction score
- 0
some reason my dummy units only spawn in one direction..
also can some one maybe make my code look better?
+rep
also can some one maybe make my code look better?
+rep
JASS:
scope Earthbind initializer init
globals
private constant integer abilID = 039;A000039;
private constant integer dummyID = 039;h001039;
private constant integer effectID = 039;h000039;
private constant integer ensnareID = 039;A001039;
private constant integer stunID = 039;A002039;
private constant integer lifeID = 039;BTLF039;
endglobals
private function Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == abilID )
endfunction
private function PickUnit takes nothing returns boolean
return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true ) and ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false )
endfunction
private function Immobile takes nothing returns nothing
local unit e = GetEnumUnit()
local unit d
local real x = GetUnitX(e)
local real y = GetUnitY(e)
set d = CreateUnit( GetOwningPlayer(GetTriggerUnit()), dummyID, x, y, bj_UNIT_FACING )
call UnitApplyTimedLife( d, lifeID, 2.00 )
call UnitAddAbility( d, ensnareID )
call SetUnitAbilityLevel( d, ensnareID, GetUnitAbilityLevel(GetTriggerUnit(), abilID) )
call IssueTargetOrder( d, "ensnare", e )
set e=null
set d=null
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit e
local unit d
local player p = GetOwningPlayer(u)
local integer index
local integer end
local real t = 0.00
local location up = GetUnitLoc(u)
local location tp = GetSpellTargetLoc()
set index = 1
set end = ( R2I(DistanceBetweenPoints(tp, up)) / 20 )
loop
exitwhen index > end
set t = ( t + 100.00 )
if ( t < DistanceBetweenPoints(tp, up) ) then
set e = CreateUnitAtLoc( p, effectID, OffsetLocation(up, t, AngleBetweenPoints(tp, up)), bj_UNIT_FACING )
call ForGroupBJ( GetUnitsInRangeOfLocMatching(200.00, GetUnitLoc(e), Condition(function PickUnit)), function Immobile )
call UnitApplyTimedLife( e, lifeID, 1.50 )
call TriggerSleepAction( 0.01 )
else
call TriggerSleepAction( 1.00 )
set d = CreateUnitAtLoc( p, dummyID, tp, bj_UNIT_FACING )
call UnitAddAbility( d, stunID )
call SetUnitAbilityLevel( d, stunID, GetUnitAbilityLevel( u, abilID) )
call IssueImmediateOrder( d, "stomp" )
return
endif
set index = index + 1
endloop
call RemoveLocation( up )
call RemoveLocation( tp )
set u=null
set e=null
set d=null
set p=null
set up=null
set tp=null
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( trig, Condition( function Conditions ) )
call TriggerAddAction( trig, function Actions )
set trig=null
endfunction
endscope