• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Does using a Game Cache Cause Slowdown?

Status
Not open for further replies.
Level 4
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
 
Level 4
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
 
Level 15
Joined
Jan 31, 2007
Messages
502
:grin: hehe i know this spell ;) and i actually i guess ( and hope ) that its leaksfree
Maybe i forgot to destroy the created time but im not sure ...

I think Game Caches do not really leak if you use "call FlushStoredMission" to clean it up if u dont need values anymore.

Anyway , you can check this out to get sth to know about leaks http://www.hiveworkshop.com/forums/showthread.php?t=35124

btw - Please use tags ( [.Jass][./Jass] , withou the "." )
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
First of all, USE JASS TAGS!!! ([.jass]........[./jass] without '.')

Game cache is slow, that's why we (well, some people) use structs from JassNewGenPack on wc3campaigns, but I think it's a little advanced to someone who has just started JASS

There are no leaks, as far as I can tell (and I'm good in finding leaks :D). But this is missing some functions and it uses some kind of a system or something, I've seen this before, but I can't remember what it was.......

As for lagging, use coordinates (http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=28217) instead of locations, believe me, that will improve the performance a whole lot more :)

EDIT: Sry I had some problems posting this, so the first line is already said :D
 
Status
Not open for further replies.
Top