JASS Questions

lh2705

Just another Helper
Reaction score
111
Hey guys,

I've started doing some Jass spells(not really) since I couldn't do anything else when my internet was down last week.
So, I need some opinions and help.

I made a spellpack and I converted every single GUI trigger to Jass, replaced all the globals with locals and removed the unnecessary if/then/elses(that I know how to) but I still have some doubts.

Have a look at this.

JASS:
function Trig_Energize_Locals_Conditions takes nothing returns boolean
    return GetUnitAbilityLevelSwapped('A003', GetAttacker()) != 0        
endfunction

function Trig_Energize_Locals_Func003C takes nothing returns boolean
    return GetRandomInt(1, 100) <= ( 15 + ( 5 * GetUnitAbilityLevelSwapped('A003', GetAttacker()) ) )
endfunction

function Trig_Energize_Locals_Actions takes nothing returns nothing
    local unit Attacker = GetAttacker()
    local location AttackerLoc = GetUnitLoc(Attacker)
    if ( Trig_Energize_Locals_Func003C() ) then
        call CreateNUnitsAtLoc( 1, 'h002', GetOwningPlayer(GetAttacker()), AttackerLoc, bj_UNIT_FACING )
        call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )
        call UnitAddAbilityBJ( 'A000', GetLastCreatedUnit() )
        call SetUnitAbilityLevelSwapped( 'A000', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A003', Attacker) )
        call IssueTargetOrderBJ( GetLastCreatedUnit(), "bloodlust", Attacker )
    else
    endif
    call RemoveLocation (AttackerLoc)
    set Attacker = null
    set AttackerLoc = null
endfunction

//===========================================================================
function InitTrig_Energize_Locals takes nothing returns nothing
    set gg_trg_Energize_Locals = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Energize_Locals, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Energize_Locals, Condition( function Trig_Energize_Locals_Conditions ) )
    call TriggerAddAction( gg_trg_Energize_Locals, function Trig_Energize_Locals_Actions )
endfunction


This is one of the simpler ones, let me know if I did anything wrong.

Next,

JASS:
function Trig_Lightning_Blast_Locals_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A007'        
endfunction

function Trig_Lightning_Blast_Locals_Func003002003001 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Trig_Lightning_Blast_Locals_Func003002003002 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

function Trig_Lightning_Blast_Locals_Func003002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Lightning_Blast_Locals_Func003002003001(), Trig_Lightning_Blast_Locals_Func003002003002() )
endfunction

function Trig_Lightning_Blast_Locals_Func004A takes nothing returns nothing
    local location TempPoint = GetUnitLoc(GetEnumUnit())
    call CreateNUnitsAtLoc( 1, 'h002', GetOwningPlayer(GetTriggerUnit()), TempPoint, bj_UNIT_FACING )
    call UnitApplyTimedLifeBJ( 3.00, 'BTLF', GetLastCreatedUnit() )
    call UnitAddAbilityBJ( 'A005', GetLastCreatedUnit() )
    call SetUnitAbilityLevelSwapped( 'A005', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A007', GetTriggerUnit()) )
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "chainlightning", GetEnumUnit() )
    call RemoveLocation (TempPoint)
    set TempPoint = null
endfunction

function Trig_Lightning_Blast_Locals_Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location TargetPoint = GetSpellTargetLoc()
    local group TargetGroup = GetUnitsInRangeOfLocMatching(( 250.00 + ( 50.00 * I2R(GetUnitAbilityLevelSwapped('A007', Caster)) ) ), TargetPoint, Condition(function Trig_Lightning_Blast_Locals_Func003002003))
    call ForGroupBJ( TargetGroup, function Trig_Lightning_Blast_Locals_Func004A )
    call RemoveLocation (TargetPoint)
    call DestroyGroup (TargetGroup)
    set Caster = null
    set TargetPoint = null
    set TargetGroup = null
endfunction

//===========================================================================
function InitTrig_Lightning_Blast_Locals takes nothing returns nothing
    set gg_trg_Lightning_Blast_Locals = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Blast_Locals, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Lightning_Blast_Locals, Condition( function Trig_Lightning_Blast_Locals_Conditions ) )
    call TriggerAddAction( gg_trg_Lightning_Blast_Locals, function Trig_Lightning_Blast_Locals_Actions )
endfunction


There at a lot of conditions and I was wondering whether they could be simplified.

Next,

This one is the one that is weird to me,

JASS:
function Trig_Holy_Flare_Locals_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
endfunction

function Trig_Holy_Flare_Locals_Func011002003001 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Trig_Holy_Flare_Locals_Func011002003002 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

function Trig_Holy_Flare_Locals_Func011002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_Holy_Flare_Locals_Func011002003001(), Trig_Holy_Flare_Locals_Func011002003002() )
endfunction

function Trig_Holy_Flare_Locals_Func012A takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location TargetPoint = GetSpellTargetLoc()
    local location TempPoint
    call UnitDamageTargetBJ( Caster, GetEnumUnit(), ( I2R(GetUnitAbilityLevelSwapped('A003', Caster)) * 100.00 ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    set TempPoint = GetUnitLoc(GetEnumUnit())
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h002', GetOwningPlayer(Caster), TargetPoint, TempPoint )
    call UnitApplyTimedLifeBJ( 3.00, 'BTLF', GetLastCreatedUnit() )
    call UnitAddAbilityBJ( 'A004', GetLastCreatedUnit() )
    call SetUnitAbilityLevelSwapped( 'A004', GetLastCreatedUnit(), GetUnitAbilityLevelSwapped('A003', Caster) )
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "soulburn", GetEnumUnit() )
    call RemoveLocation (TempPoint)
    call RemoveLocation (TargetPoint)
    set Caster = null
    set TargetPoint = null
    set TempPoint = null
endfunction

function Trig_Holy_Flare_Locals_Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location TargetPoint = GetSpellTargetLoc()
    local real TempReal = ( 100.00 + ( 50.00 * I2R(GetUnitAbilityLevelSwapped('A003', Caster)) ) )
    local group TargetGroup
    call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(Caster), TargetPoint, bj_UNIT_FACING )
    call SetUnitScalePercent( GetLastCreatedUnit(), TempReal, TempReal, TempReal )
    call UnitApplyTimedLifeBJ( 1.50, 'BTLF', GetLastCreatedUnit() )
    call PolledWait( 0.40 )
    call CreateNUnitsAtLoc( 1, 'h004', GetOwningPlayer(Caster), TargetPoint, bj_UNIT_FACING )
    call SetUnitScalePercent( GetLastCreatedUnit(), TempReal, TempReal, TempReal )
    call UnitApplyTimedLifeBJ( 1.50, 'BTLF', GetLastCreatedUnit() )
    set TargetGroup = GetUnitsInRangeOfLocMatching(( 250.00 + ( 50.00 * I2R(GetUnitAbilityLevelSwapped('A003', Caster)) ) ), TargetPoint, Condition(function Trig_Holy_Flare_Locals_Func011002003))
    call ForGroupBJ( TargetGroup, function Trig_Holy_Flare_Locals_Func012A )
    call DestroyGroup (TargetGroup)
    call RemoveLocation (TargetPoint)
    set Caster = null
    set TargetPoint = null
    set TempReal = 0
    set TargetGroup = null
endfunction

//===========================================================================
function InitTrig_Holy_Flare_Locals takes nothing returns nothing
    set gg_trg_Holy_Flare_Locals = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Holy_Flare_Locals, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Holy_Flare_Locals, Condition( function Trig_Holy_Flare_Locals_Conditions ) )
    call TriggerAddAction( gg_trg_Holy_Flare_Locals, function Trig_Holy_Flare_Locals_Actions )
endfunction


I don't quite understand, I mean, it works fine but the variables seem very weird.
Inside the group loop, I have to set all the variables again and destroy them and null them, wouldn't that affect the variables that are outside the group loop?

Also, how can I combine one trigger with another one that runs periodically?
I know its using local timers, but how do I use them?
I wanted to combine an effect trigger with the energize trigger but I didn't know how to.

Another question, What is the difference in adding brackets?
like this

JASS:
function Trig_Holy_Flare_Locals_Func011002003002 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction


and this

JASS:
function Trig_Holy_Flare_Locals_Func011002003002 takes nothing returns boolean
    return IsUnitDeadBJ(GetFilterUnit()) == false
endfunction


And, Why do you need to add the open bracket <space> close bracket after you use GetTriggerUnit, just an example. What do they do?

One last thing, the spells are basically converted GUI and slightly simplified.
I started with that because I had no idea how to start.
Jasscraft is extremely helpful and I only used it, nothing else.
 

Arkan

Nobody rides for free
Reaction score
92
To answer some of your questions:

Why add brackets after GetAttacker(), GetTriggerUnit()..?
it's because GetAttacker(), GetTriggerUnit() are functions, all functions are called with (). Usually functions have arguments inside the brackets, but these don't.

If you want to write nice optimized jass there are some things you want to do:

1) replace locations with coordinates, using x and y. (instead of GetUnitLoc(), you use GetUnitX() and GetUnitY() and store them to two real variables)
2) replace most functions that end with BJ (double click them in JASScraft and you can see the native function that you want to use instead)
3) get rid of the GUI generated functions called func24634_7565734_673655blablablabla. Your code can often be fit in one single action function.

Good luck.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
JASS:
function Trig_Lightning_Blast_Locals_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == &#039;A007&#039;        
endfunction

function Trig_Lightning_Blast_Locals_Func003002003 takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)&gt;0
endfunction

function Trig_Lightning_Blast_Locals_Func004A takes nothing returns nothing
    local location TempPoint = GetUnitLoc(GetEnumUnit())
    local unit u = CreateNUnitsAtLoc( 1, &#039;h002&#039;, GetOwningPlayer(GetTriggerUnit()), TempPoint, 270 )
    call UnitApplyTimedLife( u,&#039;BTLF&#039;,3.)
    call UnitAddAbility(u, &#039;A005&#039;)
    call SetUnitAbilityLevel(u, &#039;A005&#039;, GetUnitAbilityLevel(GetTriggerUnit(),&#039;A007&#039;) )
    call IssueTargetOrder(u, &quot;chainlightning&quot;, GetEnumUnit() )
    call RemoveLocation (TempPoint)
    set TempPoint = null
endfunction

function Trig_Lightning_Blast_Locals_Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location TargetPoint = GetSpellTargetLoc()
    local group TargetGroup = GetUnitsInRangeOfLocMatching(( 250.00 + ( 50.00 * I2R(GetUnitAbilityLevel(Caster,&#039;A007&#039;)) ) ), TargetPoint, Condition(function Trig_Lightning_Blast_Locals_Func003002003))
    call ForGroup( TargetGroup, function Trig_Lightning_Blast_Locals_Func004A )
    call RemoveLocation (TargetPoint)
    call DestroyGroup (TargetGroup)
    set Caster = null
    set TargetPoint = null
    set TargetGroup = null
endfunction

//===========================================================================
function InitTrig_Lightning_Blast_Locals takes nothing returns nothing
    set gg_trg_Lightning_Blast_Locals = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Lightning_Blast_Locals, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Lightning_Blast_Locals, Condition( function Trig_Lightning_Blast_Locals_Conditions ) )
    call TriggerAddAction( gg_trg_Lightning_Blast_Locals, function Trig_Lightning_Blast_Locals_Actions )
endfunction

JASS:
function Trig_Holy_Flare_Locals_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == &#039;A003&#039;
endfunction

function Trig_Holy_Flare_Locals_Func011002003 takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)&gt;0
endfunction

function Trig_Holy_Flare_Locals_Func012A takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location TargetPoint = GetSpellTargetLoc()
    local location TempPoint =GetUnitLoc(GetEnumUnit())
    call UnitDamageTarget( Caster, GetEnumUnit(),  I2R(GetUnitAbilityLevel(Caster,&#039;A003&#039;) * 100.00 ),true,false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL,null ) 
    set bj_lastCreatedUnit =  CreateNUnitsAtLocFacingLocBJ( 1, &#039;h002&#039;, GetOwningPlayer(Caster), TargetPoint, TempPoint )
    call UnitApplyTimedLife(GetLastCreatedUnit(), &#039;BTLF&#039;,3.00)
    call UnitAddAbility(GetLastCreatedUnit(), &#039;A004&#039;)
    call SetUnitAbilityLevel( GetLastCreatedUnit(),&#039;A004&#039;, , GetUnitAbilityLevel(Caster,&#039;A003&#039;) )
    call IssueTargetOrder( GetLastCreatedUnit(), &quot;soulburn&quot;, GetEnumUnit() )
    call RemoveLocation (TempPoint)
    call RemoveLocation (TargetPoint)
    set Caster = null
    set TargetPoint = null
    set TempPoint = null
endfunction

function Trig_Holy_Flare_Locals_Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location TargetPoint = GetSpellTargetLoc()
    local real TempReal =  100.00 + ( 50.00 * I2R(GetUnitAbilityLevel(Caster,&#039;A003&#039;)) ) 
    local group TargetGroup
    set bj_lastCreatedUnit = CreateNUnitsAtLoc( 1, &#039;h003&#039;, GetOwningPlayer(Caster), TargetPoint, bj_UNIT_FACING )
    call SetUnitScalePercent( GetLastCreatedUnit(), TempReal, TempReal, TempReal )
    call UnitApplyTimedLife( GetLastCreatedUnit(),&#039;BTLF&#039;,1.50 )
    call PolledWait( 0.40 )
    set bj_lastCreatedUnit = CreateNUnitsAtLoc( 1, &#039;h004&#039;, GetOwningPlayer(Caster), TargetPoint, bj_UNIT_FACING )
    call SetUnitScalePercent( GetLastCreatedUnit(), TempReal, TempReal, TempReal )
    call UnitApplyTimedLife( GetLastCreatedUnit(),&#039;BTLF&#039;,1.50 )
    set TargetGroup = GetUnitsInRangeOfLocMatching(( 250.00 + ( 50.00 * I2R(GetUnitAbilityLevel( Caster,&#039;A003&#039;)) ) ), TargetPoint, Condition(function Trig_Holy_Flare_Locals_Func011002003))
    call ForGroup( TargetGroup, function Trig_Holy_Flare_Locals_Func012A )
    call DestroyGroup (TargetGroup)
    call RemoveLocation (TargetPoint)
    set Caster = null
    set TargetPoint = null
    set TargetGroup = null
endfunction

//===========================================================================
function InitTrig_Holy_Flare_Locals takes nothing returns nothing
    set gg_trg_Holy_Flare_Locals = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Holy_Flare_Locals, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Holy_Flare_Locals, Condition( function Trig_Holy_Flare_Locals_Conditions ) )
    call TriggerAddAction( gg_trg_Holy_Flare_Locals, function Trig_Holy_Flare_Locals_Actions )
endfunction

>>wouldn't that affect the variables that are outside the group loop?
Why would it effect var that outside the group loop ? They are declared at different functions.

>>Also, how can I combine one trigger with another one that runs periodically?
Use localed trigger and set their events in the same function.

>>I know its using local timers, but how do I use them?
Maybe you should use KaTTaNa's Local Handle Variables System.

>>Another question, What is the difference in adding brackets?
Brackets are refering a functions arguement, and those function at the outside...Is just useless, Delete them.

>>like this
and this

No different.

>>Why do you need to add the open bracket <space> close bracket after you use GetTriggerUnit, just an example. What do they do?
Because we are calling a function that takes nothing as arguement, we dont need to give them anything, so we put nothing inside the bracket...But we must insert the "()".
JASS:
constant native GetTriggerUnit takes nothing returns unit


>>Jasscraft is extremely helpful and I only used it, nothing else.
Use JassNewGen WorldEditor + TESH.
It is far better than JC, trust me.
 

lh2705

Just another Helper
Reaction score
111
Okay, so whats the difference in using coordinates and locs?


@Use localed trigger and set their events in the same function.
Ok, so how do I do that?

And thanks for the optimization.
 

waaaks!

Zinctified
Reaction score
255
Okay, so whats the difference in using coordinates and locs?
locs leak, while coordinates dont

@Use localed trigger and set their events in the same function.
Ok, so how do I do that?

is this what u mean?

JASS:
function HolyFlareConditions takes nothing returns boolean
 return GetSpellAbilityId() == &#039;A000&#039;
endfunction

function New_Conditions takes nothing returns boolean
 return GetSpellAbilityId() == &#039;A001&#039;
endfunction

function New_Actions takes nothing returns nothing
 call KillUnit(GetAttacker())
endfunction

function HolyFlareActions takes nothing returns nothing
 local trigger t = CreateTrigger()
 call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
 call TriggerAddCondition( t, Condition( function New_Conditions ) )
 call TriggerAddAction( t, function New_Actions )
 call KillUnit(GetTriggerUnit())
 //your actions
 call DisableTrigger(t)
 set t = null
endfunction

function InitTrig_Holy_Flare_Locals takes nothing returns nothing
    set gg_trg_Holy_Flare_Locals = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Holy_Flare_Locals, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Holy_Flare_Locals, Condition( function HolyFlareConditions ) )
    call TriggerAddAction( gg_trg_Holy_Flare_Locals, function HolyFlareActions )
endfunction


is this what u mean? two triggers in 1 trigger?
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>Okay, so whats the difference in using coordinates and locs?
The easier explaination is
  • You need to null + RemoveLocation for locs
  • You don't need to null + RemoveLocation for coordinates :p
Thats what I think.

>>Ok, so how do I do that?
Something like
JASS:
function DumTriCond takes nothing returns boolean //this is the trigger&#039;s Condition
  return GetSpellAbilityId() == &#039;A000&#039; //Rawcode of casted spell == A000
endfunction

function DumTriAct takes nothing returns nothing //this is the trigger&#039;s action
  call KillUnit(GetTriggerUnit()) //kills the caster
  call DestroyTrigger(GetTriggeringTrigger()) //Destroy this trigger, so that it only run once
endfunction

function MainFunc takes nothing returns nothing
local trigger t = CreateTrigger()
  call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
  call TriggerAddCondition(t,Condition(function DumTriCond))
  call TriggerAddAction(t,function DumTriAct)
  
  call DestroyTrigger(GetTriggeringTrigger())
set t = null
endfunction

function InitTrig_AA takes nothing returns nothing
local trigger t = CreateTrigger()
  call TriggerRegisterTimerEvent(t,1,false)
  call TriggerAddAction(t, function MainFunc)
set  t = null
endfunction
 

lh2705

Just another Helper
Reaction score
111
I wanted to combine one initializing trigger with another trigger which runs periodically
 

waaaks!

Zinctified
Reaction score
255
you can easily do that by creating timers, without a new trigger

JASS:
function MyConditions takes nothing returns nothing
 return GetSpellAbilityId() == &#039;A000&#039;
endfunction

function StartTimer takes nothing returns nothing
 local timer t = GetExpiredTimer()
 //do some actions here
endfunction

function MyAction takes nothing returns nothing
 local timer t = CreateTimer()
 call TimerStart(t, 0.04, true, function StartTimer)
endfunction

function InitTrig_Holy_Flare_Locals takes nothing returns nothing
    set gg_trg_Holy_Flare_Locals = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Holy_Flare_Locals, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Holy_Flare_Locals, Condition( function MyConditions ) )
    call TriggerAddAction( gg_trg_Holy_Flare_Locals, function MyActions )
endfunction
 

lh2705

Just another Helper
Reaction score
111
Bump

New Question.
How is the JASS triggers actually read by the editor?
Does it go from down to up? cause the events are all at the bottom..

Also, what variables are needed to null and what isn't(and how to null those that cant be nulled) << I hope I make sense.
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Answering your last question:

Well, I'm not sure. My guess would be that the triggers are orginized randomly, below the header, and then from up to down Jass reads the code once, find all functions, what they take and return etc. And then he runs the InitTrig_X functions.

I may be wrong of course, but this seems to make sense, at least for me.
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
1) How is code read? Have a look at a map with a programme that displays all the code, e.g. JassShopPro. At the bottom you see the function main which must be called as first function, since it calls other functions (at the top) to fill up the globals. So the first read is the globals block to make sure there are variables that can be filled with values, then its (unless modified) the function main, which refers to all the further functions, such as initializations for triggers, sounds, etc. Code within a function is read from top to bottom. Functions referred to need to be above the functions they're called up by.
Here's an example of how the function main looks like for my map:
JASS:

function main takes nothing returns nothing
    call SetCameraBounds(- 5504.0 + GetCameraMargin(CAMERA_MARGIN_LEFT) , - 6144.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) , 5888.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT) , 5120.0 - GetCameraMargin(CAMERA_MARGIN_TOP) , - 5504.0 + GetCameraMargin(CAMERA_MARGIN_LEFT) , 5120.0 - GetCameraMargin(CAMERA_MARGIN_TOP) , 5888.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT) , - 6144.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
    call SetDayNightModels(&quot;Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl&quot; , &quot;Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl&quot;)
    call SetTerrainFogEx(0 , 1000.0 , 15000.0 , 0.040 , 1.000 , 1.000 , 1.000)
    call SetWaterBaseColor(60 , 130 , 185 , 255)
    call NewSoundEnvironment(&quot;lake&quot;)
    call SetAmbientDaySound(&quot;SunkenRuinsDay&quot;)
    call SetAmbientNightSound(&quot;SunkenRuinsNight&quot;)
    call SetMapMusic(&quot;Music&quot; , true , 0)
    call InitSounds()
    call CreateRegions()
    call CreateCameras()
    call CreateAllItems()
    call CreateAllUnits()
    call InitBlizzard()

call ExecuteFunc(&quot;jasshelper__initstructs41964921&quot;)
call ExecuteFunc(&quot;InitCSCache&quot;)
call ExecuteFunc(&quot;CasterSystem1__InitCasterSystem&quot;)
call ExecuteFunc(&quot;Enrage5__init&quot;)
call ExecuteFunc(&quot;ABC8__InitABC&quot;)
call ExecuteFunc(&quot;InjuriInit&quot;)
call ExecuteFunc(&quot;CustomMotions3__init_cm&quot;)
call ExecuteFunc(&quot;Dialog_init&quot;)

    call InitGlobals()
    call InitCustomTriggers()
    call RunInitializationTriggers()

endfunction


2) About what to null:
Check out the post
http://www.thehelper.net/forums/showpost.php?p=458296&postcount=2
Strings*, booleans, integers and reals can't be nulled. You may null handles only, and those are the only things that need to be nulled. Also, you should null only after you have destroyed the variable.
So what's a handle then?

On handles and types in general, see:
http://jass.sourceforge.net/doc/types.shtml
>handle - a handle variable is basically a "pointer". It refers to some data structure that is internal to Warcraft III which you can not manipulate directly. All user-defined types inherit from handle. For example, a unit is a subtype of handle that points to some unit data-structure in the game. Any handle variable can be assigned the value null, which means it refers to nothing.​
Further examples for handles: players, groups, effects, locations

(*) Not quite right, Kenny; you'd know better if you'd have read the jass manual more properly: Strings can be nulled: their initial value is (null), not "";
JASS:
function StringTest takes nothing returns nothing
local string mystring
    call BJDebugMsg(mystring)
endfunction

displays (null);
that it's not necessary to null them at the end of a function is another argument​


Hope things start to become clear now
 

lh2705

Just another Helper
Reaction score
111
Okay, I sort of get it.

I wanna make sure something.
A local variable would only exist inside one particular function right?
Not throughout the whole trigger?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
The order in which codes are read:

- Global Blocks
- The map's script
- The initialization functions and triggers
- The triggers

For reading triggers:
- Global Blocks (If you use NewGen)
- InitFunc
- The function in "TriggerAddAction"
- The functions called by the actions func.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top