Globals And Certain Triggers Breaking Map

WolfieeifloW

WEHZ Helper
Reaction score
372
I have six triggers that use [ljass]globals[/ljass], and quite a few of the same ones.
I'm trying to make a trigger with a globals block so they can all call from the same one.
Now, when I try to use this global [ljass]globals[/ljass] block, 3/6 of my triggers make the map not load, and instead just go to the main screen when I try to test map.

I'm going to show all my triggers so people can see, and hopefully help.


Globals (Contains all the globals; When I try to use globals from here, the first three triggers make the map not work):
JASS:
globals
    //Presence IDs
    constant integer f = 'A000'
    constant integer u = 'A001'
    constant integer fd = 'A003'
    constant integer ud = 'A002'
        
    //Frost IDs
    constant integer Ob = 'A006'
    constant integer IT = 'A008'
    constant integer CI = 'A005'
        
    //Unholy IDs
    constant integer PS = 'A009'
    constant integer DC = 'A007'
    constant integer UF = 'A00A'
    
    constant integer SB = 'A004'
endglobals

FULearn (Breaks when trying to use [ljass]globals[/ljass] from 'Globals':
JASS:
scope FULearn initializer FULearnInit
    
    //globals
        //private constant integer SB = 'A004'
        //private constant integer f = 'A000'
        //private constant integer u = 'A001'
        //private constant integer fd = 'A003'
    //endglobals

    private function FUL takes unit t returns nothing
        call UnitAddAbility(t, SB)
        call SetPlayerAbilityAvailable(GetOwningPlayer(t), u, false)
        call SetUnitAbilityLevel(t, f, 1)
        call SetPlayerAbilityAvailable(GetOwningPlayer(t), SB, false)
    endfunction

    private function Conditions takes nothing returns boolean
        if GetLearnedSkill() == fd then
            call FUL(GetLearningUnit())
        endif
        return false
    endfunction

    private function FULearnInit takes nothing returns nothing
        local integer index = 0
        local trigger tr = CreateTrigger()
        loop
            call TriggerRegisterPlayerUnitEvent(tr, Player(index), EVENT_PLAYER_HERO_SKILL, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(tr, Condition(function Conditions))
    endfunction
    
endscope

DKLevel (Breaks when trying to use [ljass]globals[/ljass] from 'Globals':
JASS:
scope DKLevel initializer DKLevelInit

    //globals
        //private constant integer f = 'A000'
        //private constant integer u = 'A001'
        //private constant integer fd = 'A003'
        //private constant integer ud = 'A002'
        //private constant integer Ob = 'A006'
        //private constant integer IT = 'A008'
        //private constant integer CI = 'A005'
        //private constant integer PS = 'A009'
        //private constant integer DC = 'A007'
        //private constant integer UF = 'A00A'
    //endglobals

    private function DKL takes unit t returns nothing
        local integer l = GetUnitAbilityLevel(t, u)
        
        call SetPlayerAbilityAvailable(GetOwningPlayer(t), u, false)
        call SetPlayerAbilityAvailable(GetOwningPlayer(t), f, true)
        call UnitRemoveAbility(t, ud)
        call UnitAddAbility(t, fd)
        call SetUnitAbilityLevel(t, fd, l)
        call SetUnitAbilityLevel(t, f, l)
        
        //Ability 1
        if (GetUnitAbilityLevel(t, PS) >=1) then
            set l = GetUnitAbilityLevel(t, PS)
            call SetPlayerAbilityAvailable(GetOwningPlayer(t), PS, false)
            call SetPlayerAbilityAvailable(GetOwningPlayer(t), Ob, true)
            call SetUnitAbilityLevel(t, Ob, l)
        endif
        //Ability 2
        if (GetUnitAbilityLevel(t, DC) >=1) then
            set l = GetUnitAbilityLevel(t, DC)
            call SetPlayerAbilityAvailable(GetOwningPlayer(t), DC, false)
            call SetPlayerAbilityAvailable(GetOwningPlayer(t), IT, true)
            call SetUnitAbilityLevel(t, IT, l)
        endif
        //Ability 3
        if (GetUnitAbilityLevel(t, UF) >= 1) then
            set l = GetUnitAbilityLevel(t, UF)
            call SetPlayerAbilityAvailable(GetOwningPlayer(t), UF, false)
            call SetPlayerAbilityAvailable(GetOwningPlayer(t), CI, true)
            call SetUnitAbilityLevel(t, CI, l)
        endif
    endfunction

    private function Conditions takes nothing returns boolean
        if GetUnitTypeId(GetLevelingUnit()) == 'U000' and GetUnitAbilityLevel(GetLevelingUnit(), u) >= 1 then
            call DKL(GetLevelingUnit())
        endif
        return false
    endfunction

    private function DKLevelInit takes nothing returns nothing
        local integer index = 0
        local trigger tr = CreateTrigger()
        loop
            call TriggerRegisterPlayerUnitEvent(tr, Player(index), EVENT_PLAYER_HERO_LEVEL, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(tr, Condition(function Conditions))
    endfunction

endscope

FUPresence (Breaks when trying to use [ljass]globals[/ljass] from 'Globals':
JASS:
scope FUPresence initializer FUPresenceInit

    //globals
        ////Presence IDs
        //private constant integer f = 'A000'
        //private constant integer u = 'A001'
        //private constant integer fd = 'A003'
        //private constant integer ud = 'A002'
        
        ////Frost IDs
        //private constant integer Ob = 'A006'
        //private constant integer IT = 'A008'
        //private constant integer CI = 'A005'
        ////private constant integer MF =  ''
        
        ////Unholy IDs
        //private constant integer PS = 'A009'
        //private constant integer DC = 'A007'
        //private constant integer UF = 'A00A'
        ////private constant integer DG = ''
    //endglobals
    
    private function FU takes unit t, integer a, integer b, integer ab, integer bb returns nothing
        local integer l
        
        //Switch the presences
        set l = GetUnitAbilityLevel(t, ab)
        call SetPlayerAbilityAvailable(GetOwningPlayer(t), a, false)
        call SetPlayerAbilityAvailable(GetOwningPlayer(t), b, true)
        call UnitRemoveAbility(t, ab)
        call UnitAddAbility(t, bb)
        call SetUnitAbilityLevel(t, bb, l)
        call SetUnitAbilityLevel(t, b, l)
        
        if (ab == fd) then //F2U
            //Ability 1
            if (GetUnitAbilityLevel(t, Ob) >= 1) then
                set l = GetUnitAbilityLevel(t, Ob)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), Ob, false)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), PS, true)
                call SetUnitAbilityLevel(t, PS, l)
            endif
            //Ability 2
            if (GetUnitAbilityLevel(t, IT) >=1) then
                set l = GetUnitAbilityLevel(t, IT)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), IT, false)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), DC, true)
                call SetUnitAbilityLevel(t, DC, l)
            endif
            //Ability 3
            if (GetUnitAbilityLevel(t, CI) >= 1) then
                set l = GetUnitAbilityLevel(t, CI)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), CI, false)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), UF, true)
                call SetUnitAbilityLevel(t, UF, l)
            endif
            //Ability 4
            //if (GetUnitAbilityLevel(t, ) >=1) then
            //endif
        elseif (ab == ud) then //U2F
            //Ability 1
            if (GetUnitAbilityLevel(t, PS) >=1) then
                set l = GetUnitAbilityLevel(t, PS)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), PS, false)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), Ob, true)
                call SetUnitAbilityLevel(t, Ob, l)
            endif
            //Ability 2
            if (GetUnitAbilityLevel(t, DC) >=1) then
                set l = GetUnitAbilityLevel(t, DC)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), DC, false)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), IT, true)
                call SetUnitAbilityLevel(t, IT, l)
            endif
            //Ability 3
            if (GetUnitAbilityLevel(t, UF) >= 1) then
                set l = GetUnitAbilityLevel(t, UF)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), UF, false)
                call SetPlayerAbilityAvailable(GetOwningPlayer(t), CI, true)
                call SetUnitAbilityLevel(t, CI, l)
            endif
            //Ability 4
            //if (GetUnitAbilityLevel(t, ) >=1) then
            //endif
        endif
    endfunction
    
    private function Conditions takes nothing returns boolean
        if GetSpellAbilityId() == fd then
            call FU(GetTriggerUnit(), f, u, fd, ud)
        elseif GetSpellAbilityId() == ud then
            call FU(GetTriggerUnit(), u, f, ud, fd)
        endif
        return false
    endfunction
    
    private function FUPresenceInit takes nothing returns nothing
        local integer index = 0
        local trigger tr = CreateTrigger()
        loop
            call TriggerRegisterPlayerUnitEvent(tr, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(tr, Condition(function Conditions))
    endfunction

endscope

DKS1 (Works when trying to use [ljass]globals[/ljass] from 'Globals':
JASS:
scope DKS1 initializer DKS1Init
    
    //globals
        //private constant integer Ob = 'A006'
        //private constant integer PS = 'A009'
    //endglobals
    
    private function S1 takes unit t returns nothing
        call UnitAddAbility(t, PS)
        call SetPlayerAbilityAvailable(GetOwningPlayer(t), PS, false)
    endfunction
    
    private function Conditions takes nothing returns boolean
        if GetLearnedSkill() == Ob then
            call S1(GetLearningUnit())
        endif
        return false
    endfunction
    
    private function DKS1Init takes nothing returns nothing
        local integer index = 0
        local trigger tr = CreateTrigger()
        loop
            call TriggerRegisterPlayerUnitEvent(tr, Player(index), EVENT_PLAYER_HERO_SKILL, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(tr, Condition(function Conditions))
    endfunction

endscope

DKS2 (Works when trying to use [ljass]globals[/ljass] from 'Globals':
JASS:
scope DKS2 initializer DKS2Init
    
    //globals
        //private constant integer DC = 'A007'
        //private constant integer IT = 'A008'
    //endglobals
    
    private function S2 takes unit t returns nothing
        call UnitAddAbility(t, DC)
        call SetPlayerAbilityAvailable(GetOwningPlayer(t), DC, false)
    endfunction
    
    private function Conditions takes nothing returns boolean
        if GetLearnedSkill() == IT then
            call S2(GetLearningUnit())
        endif
        return false
    endfunction
    
    private function DKS2Init takes nothing returns nothing
        local integer index = 0
        local trigger tr = CreateTrigger()
        loop
            call TriggerRegisterPlayerUnitEvent(tr, Player(index), EVENT_PLAYER_HERO_SKILL, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(tr, Condition(function Conditions))
    endfunction

endscope

DKS3 (Works when trying to use [ljass]globals[/ljass] from 'Globals':
JASS:
scope DKS3 initializer DKS3Init
    
    //globals
        //constant integer UF = 'A00A'
        //constant integer CI = 'A005'
    //endglobals
    
    private function S3 takes unit t returns nothing
        call UnitAddAbility(t, UF)
        call SetPlayerAbilityAvailable(GetOwningPlayer(t), UF, false)
    endfunction
    
    private function Conditions takes nothing returns boolean
        if GetLearnedSkill() == CI then
            call S3(GetLearningUnit())
        endif
        return false
    endfunction
    
    private function DKS3Init takes nothing returns nothing
        local integer index = 0
        local trigger tr = CreateTrigger()
        loop
            call TriggerRegisterPlayerUnitEvent(tr, Player(index), EVENT_PLAYER_HERO_SKILL, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(tr, Condition(function Conditions))
    endfunction

endscope


I tested this by turning off all of the triggers at once; The map loads fine.
Globals, and DKS3 on; Loads.
Globals, DKS3, and DKS2; Loads.
Globals, DKS3, DKS2, and DKS1; Loads.
Globals, DKS3, DKS2, DKS1, and any of the other three; Fails.
Globals, and FULearn or DKLevel or FUPresence; Fails.

Why are those three making the map 'crash'..?


If any more information is needed or something, please let me know..
I don't want each trigger to have to have it's own globals block.
 

Romek

Super Moderator
Reaction score
964
That code tag makes the post horrible to read. I'd rather a long post to that. :p

Are you saving the map before testing it?
Does it work if the 'broken' scripts (alone, and together) and the globals are enabled, and everything else disabled?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Yepp, it's just subconscious to always hit CTRL+S before testing :p
I took out the code tags too.

With all three scripts together, it doesn't work.
Just 'FULearn' doesn't work.
Just 'DKLevel' doesn't work.
And whoa, what the heck..
Apparently with just 'FUPresence' enabled, the game actually critically errors before even showing the loading screen.

Maybe that last clue will help :p ?
 

Romek

Super Moderator
Reaction score
964
> Are you sure that the globals is going before the others?
Yes

Do the triggers work if you're using the globals from within the scopes?
If so, do you have any triggers/structs that have the same names as those globals?

The triggers themselves look fine to me. I'm positive there's another problem elsewhere. With global names such as 'u' or 'f', it's quite likely that they're being referenced somewhere where there's a local of the same name in scope, causing problems of some sort.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
If I disable the script 'Globals', and un-comment all the globals within each script, everything works fine.
These are the only six scripts in my map so far.
And there's no overlapping names.
All those global names are unique (Although I'm going to change them later, to be more specific).
 

Romek

Super Moderator
Reaction score
964
Could you upload your map or the 'inputwar3map.j' file found in the /logs folder?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I don't want my map left up for long, so if you could just let me know via PM or something when you've got it downloaded, so I can detach it please.


EDIT: Thank you.
 

Romek

Super Moderator
Reaction score
964
I'm unable to replicate your problem. I commented the globals in the scripts, enabled the globals trigger, and took it in turns enabling/disabling different combinations of the triggers.
Everything saved and loaded perfectly.

Have you updated WC3 recently (ever)?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Warcraft 3 is whatever the newest version is.
I go on b.net often.

I just enabled Globals, and commented all the other globals out.
Still going to the main screen.

Let me upload the map, as is right now, in it's not working state.

Again, please let me know when you have it.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Warcraft 3 is whatever the newest version is.
I go on b.net often.

I just enabled Globals, and commented all the other globals out.
Still going to the main screen.

Let me upload the map, as is right now, in it's not working state.

Again, please let me know when you have it.

You do have the newest JASSHelper, right? I downloaded it, and it works fine for me.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Yes, I do.
The only thing that's different, besides newest NewGen, WC3, and JassHelper, is Romek's wehack.lua.
 

Romek

Super Moderator
Reaction score
964
Do any other maps with public constant globals work?
Could you upload your 'outputwar3map.j'?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
One of my other maps have globals, but they're not constant.
And I can't upload .j to the forums, so [del]here's[/del] a mediafire link.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Well then..
I guess that's all it takes.

Although we'll never know the real cause now! muahahahaha.
:nuts:


EDIT: Just by the way.
I did have the newest NewGen and JASSHelper before.
So I don't know what caused it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top