- Joined
- Sep 26, 2005
- Messages
- 40
for the first time i've actually tried to use some jass that another person has made and it required the use of a game cache.. however i notice some computer lag after casting many times.
is there something i can do to imiprove this?
also here is the code i was experimenting with. i was looking it over to see if there are any leaks but i am unable to tell. this is the boomerang code by JonNny
-----------------------------------------------------------
function Trig_Boomerang_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == AbilityID() ) ) then
return false
endif
return true
endfunction
function BooMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local location casterloc = GetUnitLoc(I2U(get_object_iparam(t,"caster")))
local unit boo1 = I2U(get_object_iparam(t,"boo1"))
local boolean bol = get_object_bparam(t,"bol")
local location loc1 = GetUnitLoc(boo1)
local location mov1 = PolarProjectionBJ(loc1, boomspeed(), GetUnitFacing(boo1))
local location target = Location(get_object_rparam(t,"x"),get_object_rparam(t,"y"))
local real distance1 = DistanceBetweenPoints(loc1, target)
local real face1 = ( distance1/((1.00/periodictime())*boomspeed()))/1.25
call SetUnitPositionLoc( boo1, mov1 )
if bol then
else
set distance1 = ((DistanceBetweenPoints(loc1, casterloc)))
set face1 = ( distance1/((1.00/periodictime())*boomspeed()))/4.0
endif
if (distance1 < 80) then
if bol == true then
call set_object_bparam(t,"bol", false)
call TimerStart(t,periodictime(),false,function BooMove)
else
if (distance1 < 45) then
call flush_object(boo1)
call RemoveUnit( boo1 )
else
call TimerStart(t,periodictime(),false,function BooMove)
endif
endif
else
call TimerStart(t,periodictime(),false,function BooMove)
endif
if bol then
call SetUnitFacingToFaceLocTimed( boo1, target, face1 )
else
call SetUnitFacingToFaceLocTimed( boo1, casterloc, face1 )
endif
call RemoveLocation(target)
call RemoveLocation(casterloc)
call RemoveLocation(mov1)
call RemoveLocation(loc1)
endfunction
function Trig_Boomerang_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local location casterloc = GetUnitLoc(caster)
local location target = GetSpellTargetLoc()
local unit boo1
local unit boo2
local location target2
local timer t =CreateTimer()
local timer t2 =CreateTimer()
local real angle = AngleBetweenPoints(casterloc, target)
local real distance = DistanceBetweenPoints(casterloc, target)
if distance < 450 then
set target2 = PolarProjectionBJ(casterloc, 450.00, angle)
else
set target2 = target
endif
call CreateNUnitsAtLoc( 1, AxeID(), GetOwningPlayer(GetSpellAbilityUnit()), casterloc, (angle+Spreadangle()))
set boo1 = GetLastCreatedUnit()
call SetUnitAbilityLevelSwapped( DamageAbilityID(), GetLastCreatedUnit(), GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) )
call CreateNUnitsAtLoc( 1, AxeID(), GetOwningPlayer(GetSpellAbilityUnit()), casterloc, (angle-Spreadangle()))
set boo2 = GetLastCreatedUnit()
call SetUnitAbilityLevelSwapped( DamageAbilityID(), GetLastCreatedUnit(), GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) )
call TimerStart(t,periodictime(),false,function BooMove)
call set_object_iparam(t,"caster", H2I(caster))
call set_object_iparam(t,"boo1", H2I(boo1))
call set_object_bparam(t,"bol", true)
call set_object_rparam(t,"x", GetLocationX(target2))
call set_object_rparam(t,"y", GetLocationY(target2))
call TimerStart(t2,periodictime(),false,function BooMove)
call set_object_iparam(t2,"caster", H2I(caster))
call set_object_iparam(t2,"boo1", H2I(boo2))
call set_object_bparam(t2,"bol", true)
call set_object_rparam(t2,"x", GetLocationX(target2))
call set_object_rparam(t2,"y", GetLocationY(target2))
call RemoveLocation(casterloc)
call RemoveLocation(target)
call RemoveLocation(target2)
endfunction
//===========================================================================
function InitTrig_Boomerang takes nothing returns nothing
set gg_trg_Boomerang = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Boomerang, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Boomerang, Condition( function Trig_Boomerang_Conditions ) )
call TriggerAddAction( gg_trg_Boomerang, function Trig_Boomerang_Actions )
endfunction
is there something i can do to imiprove this?
also here is the code i was experimenting with. i was looking it over to see if there are any leaks but i am unable to tell. this is the boomerang code by JonNny
-----------------------------------------------------------
function Trig_Boomerang_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == AbilityID() ) ) then
return false
endif
return true
endfunction
function BooMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local location casterloc = GetUnitLoc(I2U(get_object_iparam(t,"caster")))
local unit boo1 = I2U(get_object_iparam(t,"boo1"))
local boolean bol = get_object_bparam(t,"bol")
local location loc1 = GetUnitLoc(boo1)
local location mov1 = PolarProjectionBJ(loc1, boomspeed(), GetUnitFacing(boo1))
local location target = Location(get_object_rparam(t,"x"),get_object_rparam(t,"y"))
local real distance1 = DistanceBetweenPoints(loc1, target)
local real face1 = ( distance1/((1.00/periodictime())*boomspeed()))/1.25
call SetUnitPositionLoc( boo1, mov1 )
if bol then
else
set distance1 = ((DistanceBetweenPoints(loc1, casterloc)))
set face1 = ( distance1/((1.00/periodictime())*boomspeed()))/4.0
endif
if (distance1 < 80) then
if bol == true then
call set_object_bparam(t,"bol", false)
call TimerStart(t,periodictime(),false,function BooMove)
else
if (distance1 < 45) then
call flush_object(boo1)
call RemoveUnit( boo1 )
else
call TimerStart(t,periodictime(),false,function BooMove)
endif
endif
else
call TimerStart(t,periodictime(),false,function BooMove)
endif
if bol then
call SetUnitFacingToFaceLocTimed( boo1, target, face1 )
else
call SetUnitFacingToFaceLocTimed( boo1, casterloc, face1 )
endif
call RemoveLocation(target)
call RemoveLocation(casterloc)
call RemoveLocation(mov1)
call RemoveLocation(loc1)
endfunction
function Trig_Boomerang_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local location casterloc = GetUnitLoc(caster)
local location target = GetSpellTargetLoc()
local unit boo1
local unit boo2
local location target2
local timer t =CreateTimer()
local timer t2 =CreateTimer()
local real angle = AngleBetweenPoints(casterloc, target)
local real distance = DistanceBetweenPoints(casterloc, target)
if distance < 450 then
set target2 = PolarProjectionBJ(casterloc, 450.00, angle)
else
set target2 = target
endif
call CreateNUnitsAtLoc( 1, AxeID(), GetOwningPlayer(GetSpellAbilityUnit()), casterloc, (angle+Spreadangle()))
set boo1 = GetLastCreatedUnit()
call SetUnitAbilityLevelSwapped( DamageAbilityID(), GetLastCreatedUnit(), GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) )
call CreateNUnitsAtLoc( 1, AxeID(), GetOwningPlayer(GetSpellAbilityUnit()), casterloc, (angle-Spreadangle()))
set boo2 = GetLastCreatedUnit()
call SetUnitAbilityLevelSwapped( DamageAbilityID(), GetLastCreatedUnit(), GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) )
call TimerStart(t,periodictime(),false,function BooMove)
call set_object_iparam(t,"caster", H2I(caster))
call set_object_iparam(t,"boo1", H2I(boo1))
call set_object_bparam(t,"bol", true)
call set_object_rparam(t,"x", GetLocationX(target2))
call set_object_rparam(t,"y", GetLocationY(target2))
call TimerStart(t2,periodictime(),false,function BooMove)
call set_object_iparam(t2,"caster", H2I(caster))
call set_object_iparam(t2,"boo1", H2I(boo2))
call set_object_bparam(t2,"bol", true)
call set_object_rparam(t2,"x", GetLocationX(target2))
call set_object_rparam(t2,"y", GetLocationY(target2))
call RemoveLocation(casterloc)
call RemoveLocation(target)
call RemoveLocation(target2)
endfunction
//===========================================================================
function InitTrig_Boomerang takes nothing returns nothing
set gg_trg_Boomerang = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Boomerang, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Boomerang, Condition( function Trig_Boomerang_Conditions ) )
call TriggerAddAction( gg_trg_Boomerang, function Trig_Boomerang_Actions )
endfunction