HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to make this trigger less lag?

01-22-2006, 05:16 PM#1
JeffreyQ
How to make the below trigger less lag when cast? I tried using loop, but it lags more than the below trigger. I want it to work when the caster cast the spell, 5 dummy units will be created around the caster and it will cast shockwave towards their facing direction. If JASS is needed to make it less lag, hope someone can help me out. I am quite new to JASS. Maybe some examples will help.
Trigger:
Battle Slam
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Battle Slam (Defender)
Collapse Actions
Set BattleSlam_Caster = (Casting unit)
Unit - Create 1 Battle Slam Dummy for (Owner of BattleSlam_Caster) at ((Position of BattleSlam_Caster) offset by 100.00 towards 0.00 degrees) facing 0.00 degrees
Unit - Order (Last created unit) to Orc Tauren Chieftain - Shockwave ((Position of (Last created unit)) offset by 100.00 towards 0.00 degrees)
Unit - Create 1 Battle Slam Dummy for (Owner of BattleSlam_Caster) at ((Position of BattleSlam_Caster) offset by 100.00 towards 72.00 degrees) facing 72.00 degrees
Unit - Order (Last created unit) to Orc Tauren Chieftain - Shockwave ((Position of (Last created unit)) offset by 100.00 towards 72.00 degrees)
Unit - Create 1 Battle Slam Dummy for (Owner of BattleSlam_Caster) at ((Position of BattleSlam_Caster) offset by 100.00 towards 144.00 degrees) facing 144.00 degrees
Unit - Order (Last created unit) to Orc Tauren Chieftain - Shockwave ((Position of (Last created unit)) offset by 100.00 towards 144.00 degrees)
Unit - Create 1 Battle Slam Dummy for (Owner of BattleSlam_Caster) at ((Position of BattleSlam_Caster) offset by 100.00 towards 216.00 degrees) facing 216.00 degrees
Unit - Order (Last created unit) to Orc Tauren Chieftain - Shockwave ((Position of (Last created unit)) offset by 100.00 towards 216.00 degrees)
Unit - Create 1 Battle Slam Dummy for (Owner of BattleSlam_Caster) at ((Position of BattleSlam_Caster) offset by 100.00 towards 288.00 degrees) facing 288.00 degrees
Unit - Order (Last created unit) to Orc Tauren Chieftain - Shockwave ((Position of (Last created unit)) offset by 100.00 towards 288.00 degrees)
Unit Group - Pick every unit in (Units owned by (Owner of BattleSlam_Caster) of type Battle Slam Dummy) and do (Unit - Add a 1.00 second Generic expiration timer to (Picked unit))
01-22-2006, 05:24 PM#2
Thunder_Eye
clean the leaks.
use 2 variables, tempPoint (point) ,tempPoint2 (point) and tempGroup (UnitGroup)
then in the beginning of the trigger make
Set tempPoint = ((Position of BattleSlam_Caster) offset by 100.00 towards **.** degrees)
Set tempPoint2 = ((Position of (Last created unit)) offset by 100.00 towards **.** degrees)
Set tempGroup = (Units owned by (Owner of BattleSlam_Caster) of type BattleSlam_Dummy)

and in the end add
Custom Script: call RemoveLocation(udg_tempPoint)
Custom Script: call RemoveLocation(udg_tempPoint2)
and,
Unit Group - Clear tempGroup
01-22-2006, 05:33 PM#3
JeffreyQ
Hm, do i need to use "temp" in a var to make it actually work in custom script? Or can i put any name for the var?
So what u said above is asking me to do a loop?
01-22-2006, 05:34 PM#4
Chuckle_Brother
I don't think that alone is going to do it....I've had loads of lag issues when ordering dummies to cast shockwaves, even with just a single unit sometimes.

Anyway the best thing you can do is remove leaks and maybe try some preloading of the abilities and such.
01-22-2006, 05:35 PM#5
Peekaboo
you can use any name, using temp just reminds you that it is a temporary variable
01-22-2006, 05:40 PM#6
JeffreyQ
Quote:
Originally Posted by Chuckle_Brother
I don't think that alone is going to do it....I've had loads of lag issues when ordering dummies to cast shockwaves, even with just a single unit sometimes.

Anyway the best thing you can do is remove leaks and maybe try some preloading of the abilities and such.
Yeah, preload works fine. How do we actually know where it leaks??

Quote:
Originally Posted by Peekaboo
you can use any name, using temp just reminds you that it is a temporary variable
thanks!
01-22-2006, 05:44 PM#7
Thunder_Eye
Anywhere where you create a point, like (Position of Unit) for example. It creates a object at the position and then uses it, If you dont attach it to a variable and destroy it it will get lost and cause "memory leak"

the things that you have to worry most about is:
Points
Unit Groups
Player Groups

dont remember if there were anymore
01-22-2006, 05:50 PM#8
Azazel_
Collapse JASS:
function BattleSlam takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local location l = GetUnitLoc(u)
    local location t
    local player p = GetOwningPlayer(u)
    local real x = GetLocationX(l)
    local real y = GetLocationY(l)
    local real r = 0.0
    loop
        exitwhen r > 288
        set u = CreateUnit( p, DummyUnitId, x, y, angle )
        set t = Location(x + 150.00 * Cos(r * bj_DEGTORAD), y + 150.00 * Sin(r * bj_DEGTORAD))
        call IssuePointOrderLoc( u, "shockwave", t )
        call TriggerSleepAction(0)
        call UnitApplyTimedLife( u, 'Bhwd', 3.00 )
        call RemoveLocation(t)
        set r = r + 72.0
    endloop
    set u = null
    call RemoveLocation(l)
    set l = null
    set t = null
endfunction
Collapse JASS:
function BattleSlam_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == BattleSlamSpellId )
endfunction

function BattleSlamInit takes unit u returns nothing //u is the specific hero that is going to use this spell
    local trigger t = CreateTrigger(  )
    call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_SPELL_CAST )
    call TriggerAddCondition( t, Condition( function BattleSlam_Conditions ) )
    call TriggerAddAction( t, function BattleSlam )
    call UnitAddAbility(u, BattleSlamSpellId) //Preload Spell
    call UnitRemoveAbility(u, BattleSlamSpellId)
    set t = null
endfunction

- You can literally copy-paste this entire thing inside, but I urge you to understand it first.
- Create a new trigger, Edit --> Convert to Custom Text (easier to manage rather than placing it in the main custom script area)
- Figure out your preferred method of passing in unit u into the initialisation function.
- This method solves the memory leaks and duplication of effort. There are many ways to build this spell, and this is my preferred method.
- The initialisation deals with first cast lag.
- The use of natives as far as possible reduces resource usage, however marginal.