Saturday, April 21, 2012

My attraction Beams are dysfuntional :)

hey guys, here is my trigger for an attractor beam:


Code:
function Trig_Attractor_Beams_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'ANcl' ) ) then
return false
endif
return true
endfunction

function Trig_Attractor_Beams_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
local real angle = AngleBetweenPoints(GetUnitLoc(target), GetUnitLoc(caster))
local lightning light
set udg_distance = DistanceBetweenPoints(GetUnitLoc(caster), GetUnitLoc(target))
call AddLightningLoc( "LEAS", GetUnitLoc(caster), GetUnitLoc(target) )
set light = GetLastCreatedLightningBJ()
loop
exitwhen udg_distance < 2
call TriggerSleepAction( 0.01 )
call SetUnitPositionLoc( target, PolarProjectionBJ(GetUnitLoc(target), 3.00, angle) )
set udg_distance = DistanceBetweenPoints(GetUnitLoc(caster), GetUnitLoc(target))
call MoveLightningLoc( light, GetUnitLoc(caster), GetUnitLoc(target) )
endloop
endfunction

//===========================================================================
function InitTrig_Attractor_Beams takes nothing returns nothing
set gg_trg_Attractor_Beams = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Attractor_Beams, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Attractor_Beams, Condition( function Trig_Attractor_Beams_Conditions ) )
call TriggerAddAction( gg_trg_Attractor_Beams, function Trig_Attractor_Beams_Actions )
endfunction

would there be a way to make udg_distance into a local? This is the first time im making maps in a number of months, so be easy on me :)

edit: it seems that whatever integer i put after "exitwhen udg_distance <" the attraction will never stop. What's the problem?|||Quote:




edit: it seems that whatever integer i put after "exitwhen udg_distance <" the attraction will never stop. What's the problem




"2" is a very small distance. Perhaps the collision size of each unit is preventing them from ever getting that close?|||Quote:






View Post

"2" is a very small distance. Perhaps the collision size of each unit is preventing them from ever getting that close?




yes, it's very small but i've tried 45, 60 and 115 aswell, same result. the unit just keeps moving until it bumps into to casting unit|||115 is still a small number. Of course, it all depends on the units involved. Try 500.|||Quote:






View Post

115 is still a small number. Of course, it all depends on the units involved. Try 500.




worked... -.- lol

thanks :p

is the trigger well written otherwise?|||Ehh, my brain's too hot to think right now. If it works and doesn't leak or lag, it's good 'nuf.|||Quote:






View Post

Ehh, my brain's too hot to think right now. If it works and doesn't leak or lag, it's good 'nuf.




kk. I guess it leaks a little but i know how to fix that, i was more concerned about unnecessary lines or functions. so, im happy :p

No comments:

Post a Comment