function Trig_Bounce_Unitfilter_Ground takes nothing returns boolean
return IsUnitType(GetFilterUnit(),UNIT_TYPE_GROUND)
endfunction
function Trig_Bounce_Actions takes nothing returns nothing
local unit bouncer = GetTriggerUnit()
local real thisX = GetWidgetX( <reflecting thing> )
local real thisY = GetWidgetY( <reflecting thing> )
local real bouncerX = GetUnitX(bouncer)
local real bouncerY = GetUnitY(bouncer)
local real vectorX = Cos(GetUnitFacing(bouncer)) + bouncerX
local real vectorY = SquareRoot(1 - Pow(vectorX - bouncerX,2)) + bouncerY
local real lineThisBouncerX = thisX - bouncerX
local real lineThisBouncerY = thisY - bouncerY
local real angleThisBouncer = Acos(vectorX * lineThisBouncerX + vectorY * lineThisBouncerY / (SquareRoot(Pow(vectorX,2) + Pow(vectorY,2)) * SquareRoot(Pow(lineThisBouncerX,2) + Pow(lineThisBouncerY,2))))
local real aimedX = Cos(angleThisBouncer) * GetUnitMoveSpeed(bouncer) * 0.75 + thisX
local real aimedY = SquareRoot(Pow(aimedX - thisX,2) / Pow(Cos(angleThisBouncer),2) - Pow(aimedX - thisX,2))
call PauseUnit(bouncer,true)
loop
call SetUnitPosition(bouncer,bouncerX+(aimedX-bouncerX)/10,bouncerY+(aimedY-bouncerY)/10)
call TriggerSleepAction(0.005)
exitwhen SquareRoot(Pow(aimedX - GetUnitX(bouncer),2)+Pow(aimedY - GetUnitY(bouncer),2)) < 30
endloop
call PauseUnit(bouncer,false)
set bouncer = null
endfunction
function InitTrig_Bounce takes nothing returns nothing
set gg_trg_Bounce = CreateTrigger()
call TriggerRegisterUnitInRange(gg_trg_Bounce, <reflecting thing> ,30,Filter(function Trig_Bounce_Unitfilter_Ground))
call TriggerAddAction(gg_trg_Bounce,function Trig_Bounce_Actions)
endfunction