HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

This could be optimized by...

07-19-2006, 12:14 PM#1
darkwulfv
Here's my trigger, yes I know it's probably the worst ever, oh well, thats why I'm here.
Trigger:
Flames
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Flame Stomp
Collapse Actions
Custom script: local effect udg_Flame1
Custom script: local effect udg_Flame2
Custom script: local effect udg_Flame3
Custom script: local effect udg_Flame4
Set Flame1 = (Create a special effect using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl at ((Position of (Triggering unit)) offset by (100.00, 0.00)))
Set Flame2 = (Create a special effect using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl at ((Position of (Triggering unit)) offset by (0.00, 100.00)))
Set Flame3 = (Create a special effect using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl at ((Position of (Triggering unit)) offset by (-100.00, 0.00)))
Set Flame4 = (Create a special effect using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl at ((Position of (Triggering unit)) offset by (0.00, -100.00)))
Wait 2.00 game-time seconds
Special Effect - Destroy Flame1
Special Effect - Destroy Flame2
Special Effect - Destroy Flame3
Special Effect - Destroy Flame4
Custom script: set udg_Flame1 = null
Custom script: set udg_Flame2 = null
Custom script: set udg_Flame3 = null
Custom script: set udg_Flame4 = null

I beleive I can optimize this by simply using 1 local variable multiple times, correct? I wasn't sure, and I don't have time to test right now. No need to do it for me, just tell me if it's possible, and I'll do the rest later today. Thank you in advance!
07-19-2006, 12:33 PM#2
Captain Griffen
That won't work. You can only have one local variable by that method.

Basically, you'll need JASS.
07-19-2006, 12:39 PM#3
darkwulfv
It won't? Wait wait what won't? What I have now, or what I wanted to do?
This won't cause leaking, I've nulled it all. SO if this works fine the way it is, I won't mind. jsut wanted to find something a little neater.
07-19-2006, 01:05 PM#4
Captain Griffen
local [type] udg_[name] only works for one variable per trigger.
07-19-2006, 01:09 PM#5
darkwulfv
So I can't make 4 local variables? Or can I make 4 and only use them once per trigger? guess I'm not understanding exactly what your saying.
07-19-2006, 01:55 PM#6
Mezzer
Just hit Convert to custom text and erase all the udg_ prefixes from your variables and it'll work fine
07-19-2006, 02:04 PM#7
darkwulfv
Hm. Ok, that seems simple enough. I wanted to use little JASS, but this is ok, since its so simple. :D
07-19-2006, 02:43 PM#8
The)TideHunter(
Captain was saying you cant use the "local VARTYPE udg_VAR" more than once.

You can use as many local's as you want, and as many globals, but not a "global local" if you know what i mean.

Like:

Collapse JASS:
local integer udg_MyInt = 0

Would work

Collapse JASS:
local integer udg_MyInt = 0
local integer udg_MyOtherInt = 0

Wouldent work, you cant use 2+ locals that have udg_
07-19-2006, 06:54 PM#9
Vexorian
Trigger:
Flames
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Flame Stomp
Collapse Actions
Custom script: local effect array udg_Flame
Set TempPoint1=(Position of (Triggering unit))
Set TempPoint2=(TempPoint1 offset (TempPoint1) by (100.00, 0.00))
Set Flame[1] = (Create a special effect using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl at TempPoint2)
Custom script: call RemoveLocation(udg_TempPoint2)
Set TempPoint2=(TempPoint1 offset (TempPoint1) by (0.00, 100.00))
Set Flame[2] = (Create a special effect using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl at TempPoint2)
Custom script: call RemoveLocation(udg_TempPoint2)
Set TempPoint2=(TempPoint1 offset (TempPoint1) by (-100.00, 0.00))
Set Flame[3] = (Create a special effect using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl at TempPoint2)
Custom script: call RemoveLocation(udg_TempPoint2)
Set TempPoint2=(TempPoint1 offset (TempPoint1) by (0.00, -100.00))
Set Flame[4] = (Create a special effect using Doodads\Cinematic\TownBurningFireEmitter\TownBurningFireEmitter.mdl at TempPoint2)
Custom script: call RemoveLocation(udg_TempPoint2)
Custom script: call RemoveLocation(udg_TempPoint1)
Wait 2.00 game-time seconds
Special Effect - Destroy Flame[1]
Special Effect - Destroy Flame[2]
Special Effect - Destroy Flame[3]
Special Effect - Destroy Flame[4]
-- last time we checked there was no need to set arrays to null --
07-19-2006, 08:36 PM#10
darkwulfv
Oooook... Uh thanks Vex (I think) Your trigger actually looks harder to read than mine... :P Will this work ok?
Collapse JASS:
function Trig_Flames_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A00E' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Flames_Actions takes nothing returns nothing
    local effect Flame1
    local effect Flame2
    local effect Flame3
    local effect Flame4
    set Flame1 = AddSpecialEffectLoc("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", OffsetLocation(GetUnitLoc(GetTriggerUnit()), 100.00, 0))
    set Flame2 = AddSpecialEffectLoc("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", OffsetLocation(GetUnitLoc(GetTriggerUnit()), 0, 100.00))
    set Flame3 = AddSpecialEffectLoc("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", OffsetLocation(GetUnitLoc(GetTriggerUnit()), -100.00, 0))
    set Flame4 = AddSpecialEffectLoc("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", OffsetLocation(GetUnitLoc(GetTriggerUnit()), 0, -100.00))
    call PolledWait( 2 )
    call DestroyEffectBJ( Flame1 )
    call DestroyEffectBJ( Flame2 )
    call DestroyEffectBJ( Flame3 )
    call DestroyEffectBJ( Flame4 )
    set Flame1 = null
    set Flame2 = null
    set Flame3 = null
    set Flame4 = null
endfunction
Please do me a favor, and DON'T tell me how sloppy this is or how this could be fit into one native or whatever. I just want to know that it will work. Sorry if I sound harsh right now, but I just learned my braces are on for another month or two (again) so I'm kinda angry...
07-19-2006, 08:41 PM#11
Vexorian
Quote:
Your trigger actually looks harder to read than mine...
It is GUI's fault

that jass script still has leaks:
Collapse JASS:
function Trig_Flames_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A00E' )
endfunction

function Trig_Flames_Actions takes nothing returns nothing
    local effect Flame1
    local effect Flame2
    local effect Flame3
    local effect Flame4
    local real x=GetUnitX(GetTriggerUnit())
    local real y=GetUnitY(GetTriggerUnit())
    set Flame1 = AddSpecialEffect("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", x+100, y+0)
    set Flame2 = AddSpecialEffect("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", x, y+100)
    set Flame3 = AddSpecialEffect("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", x-100, y+0)
    set Flame4 = AddSpecialEffect("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", x, y-100)
    call PolledWait( 2 )
    call DestroyEffect( Flame1 )
    call DestroyEffect( Flame2 )
    call DestroyEffect( Flame3 )
    call DestroyEffect( Flame4 )
    set Flame1 = null
    set Flame2 = null
    set Flame3 = null
    set Flame4 = null
endfunction
07-20-2006, 12:37 AM#12
darkwulfv
the unit postitons? ah well. Thanks man. I'll put it right in. Thanks all.
07-20-2006, 06:40 AM#13
Jazradel
And they could go on the same line:
Collapse JASS:
    local real x=GetUnitX(GetTriggerUnit())
    local real y=GetUnitY(GetTriggerUnit())
    local effect Flame1 = AddSpecialEffect("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", x+100, y+0)
etc
07-20-2006, 02:45 PM#14
The)TideHunter(
Vex, if you dont mind me asking, why, in the reals, did you put:

y+0

What effect does it have?
Or dosent it do anything?
07-20-2006, 02:50 PM#15
Captain Griffen
y + 0 == y.

CnP + laziness -> y + 0