Region Bug?

DuelPlayer

Member
Reaction score
21
Hmm here is my code for..

JASS:
globals
region array Station_Turret_Rect 
endglobals


function Trig_Station_Turrets_Condition takes nothing returns boolean
    if IsUnitAliveBJ(udg_Station) == true then
    if ( ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_ANCIENT) == true ) ) then
        return true
    endif
    if ( ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_SAPPER) == true ) ) then
        return true
    endif
    if ( ( GetTriggerUnit() == udg_AIMain ) ) then
        return true
    endif
    endif
    return false
endfunction


function Trig_Station_Turret_Actions takes nothing returns nothing
    local integer i = 0
    local location l
    loop
    exitwhen i == 4
    set i = i + 1
    if GetTriggeringRegion() == Station_Turret_Rect<i> and udg_Station_Turret_Using<i> == Player(PLAYER_NEUTRAL_PASSIVE) and udg_StationLanded == false then
    call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()),0,0,&quot;|cFF00FF00Now controlling the turret on station, to fire the turret, issue a move order and when you want to stop using it, walk off the circle .|r&quot;)
    set l = GetUnitLoc(udg_Station)
    set udg_Station_Turret_Using<i> = GetOwningPlayer(GetTriggerUnit())
    call SetUnitOwner( udg_Station_Turret<i>, GetOwningPlayer(GetTriggerUnit()), true )
    call ShowUnit(udg_Station_Turret<i>, true)
    call SelectUnitForPlayerSingle( udg_Station_Turret<i>, GetOwningPlayer(GetTriggerUnit()) )
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(GetTriggerUnit()), l, 0 )
    call RemoveLocation(l)
    else
    endif
    endloop
endfunction


function Trig_Station_Turret_Actions2 takes nothing returns nothing
    local integer i = 0
    loop
    exitwhen i == 4
    set i = i + 1
    if GetTriggeringRegion() == Station_Turret_Rect<i> and udg_Station_Turret_Using<i> == GetOwningPlayer(GetTriggerUnit()) then
    call DisplayTextToPlayer(GetOwningPlayer(GetTriggerUnit()),0,0,&quot;|cFF00FF00You have stopped using the turret on staton&quot;)
    set udg_Station_Turret_Using<i> = Player(PLAYER_NEUTRAL_PASSIVE)
    call SetUnitOwner( udg_Station_Turret<i>, Player(PLAYER_NEUTRAL_PASSIVE), true )
    call ShowUnit(udg_Station_Turret<i>, false)
    else
    endif
    endloop
endfunction

//===========================================================================
function InitTrig_Station_Turret takes nothing returns nothing
    local trigger t = CreateTrigger()
    local trigger t2 = CreateTrigger()
    local integer i = 0
    set Station_Turret_Rect[1] = CreateRegion()
    set Station_Turret_Rect[2] = CreateRegion()
    set Station_Turret_Rect[3] = CreateRegion()
    set Station_Turret_Rect[4] = CreateRegion()
    call RegionAddRect(Station_Turret_Rect[1],gg_rct_Station_Turret_1)
    call RegionAddRect(Station_Turret_Rect[2],gg_rct_Station_Turret_2)
    call RegionAddRect(Station_Turret_Rect[3],gg_rct_Station_Turret_3)
    call RegionAddRect(Station_Turret_Rect[4],gg_rct_Station_Turret_4)    
    loop
    exitwhen i == 4
    set i = i + 1
    call TriggerRegisterEnterRegion(t, Station_Turret_Rect<i>, null)
    call TriggerRegisterLeaveRegion(t2, Station_Turret_Rect<i>, null)
    endloop
    call TriggerAddCondition(t, Condition(function Trig_Station_Turrets_Condition))
    call TriggerAddCondition(t2, Condition(function Trig_Station_Turrets_Condition))
    call TriggerAddAction(t, function Trig_Station_Turret_Actions )
    call TriggerAddAction(t2, function Trig_Station_Turret_Actions2 )
endfunction

</i></i></i></i></i></i></i></i></i></i></i></i></i>


yeah and the problem is that there is no message shown when i goes into the region
Please highlight any mistakes I made

Thanks in advance
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Are the conditions passed to execute the actions? To check, just add a message outside of the loop in both "actions" functions.

If that message shows, then you know that it is a problem with the line:
[ljass]if GetTriggeringRegion() == Station....[/ljass]
If it does not show, then that means that there is a problem with your conditions.

Also, you can use the [noparse]
JASS:
[/noparse] tags to highlight the code for it to be easier to read. =)
 

DuelPlayer

Member
Reaction score
21
Are the conditions passed to execute the actions? To check, just add a message outside of the loop in both "actions" functions.

If that message shows, then you know that it is a problem with the line:
[ljass]if GetTriggeringRegion() == Station....[/ljass]
If it does not show, then that means that there is a problem with your conditions.

Also, you can use the [noparse]
JASS:
[/noparse] tags to highlight the code for it to be easier to read. =)
JASS:
I tried. But it is still not working <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown    :(" loading="lazy" data-shortname=":(" />
And thanks for the reminder for [noparse]<div class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code"><div class="bbCodeBlock-title">JASS:</div><div class="bbCodeBlock-content"><pre class="bbCodeCode"><code class="jass"><span class="symbol">[</span><span class="symbol">/</span><span>noparse</span><span class="symbol">]</span> <span>tags</span></code></pre></div></div>
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
You never set the nor increment the [ljass]local integer i[/ljass] in [ljass]Trig_Station_Turret_Actions[/ljass] or [ljass]Trig_Station_Turret_Actions2[/ljass]. Check how you did in [ljass]InitTrig_Station_Turret[/ljass]. Also, do you initialize [ljass]udg_Station_Turret_Using[1..4][/ljass] with [ljass]Player(PLAYER_NEUTRAL_PASSIVE)[/ljass]?
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
also in your loops, i never gets higher so how does it ever hit 4?
it starts with no value so you cant use it in code where it uses i other than conditions or it will crash the thread (i = ???, so set i = i + 1 = ??? + 1, the computer gives up and shuts that trigger down, you have to set it to 0 for it to be initialized correctly) so you are using it to refer to an array, so the computer goes [ljass]Station_Turret_Rect[???] = ???[/ljass] it doesnt actually reference everything and stops the thread

also, at the end of your loop, add the line:
[ljass]set i = i + 1[/ljass] so i gets higher, then when it becomes 4 it will exit the loop, till then it will be endlessely looping and cause the computer to hit its op limit and crash wc3

PS.

please indent right, IE:

JASS:
function something takes something returns nothing
    loop
        exitwhen Something
        do stuff
        if this then
            do more stuff
        elseif this then
            do other more stuff
        else
            do other more stuff
        endif
    endloop
endfunction


every layer of encapsulation is another indent (makes it a LOT easier to read)

PPS:

instead of [ljass]call TriggerAddAction(trigger, function Actions)[/ljass] do [ljass]call TriggerAddCondition(trigger, Filter(function Actions))[/ljass] because actions leak, but you can use your actions as a condition, make them return boolean, and false at the end, and they will work the same way, just like an action but with no leak

PPPS:

you leak a lot of things
locals must be nulled if they are not a real number, integer, or struct variable
so just do:

[ljass]set localvariable = null[/ljass]

to clear those leaks
the exception is groups, which are cleared via: [ljass]call DestroyGroup(variable)[/ljass]
 

DuelPlayer

Member
Reaction score
21
also in your loops, i never gets higher so how does it ever hit 4?
it starts with no value so you cant use it in code where it uses i other than conditions or it will crash the thread (i = ???, so set i = i + 1 = ??? + 1, the computer gives up and shuts that trigger down, you have to set it to 0 for it to be initialized correctly) so you are using it to refer to an array, so the computer goes [ljass]Station_Turret_Rect[???] = ???[/ljass] it doesnt actually reference everything and stops the thread

also, at the end of your loop, add the line:
[ljass]set i = i + 1[/ljass] so i gets higher, then when it becomes 4 it will exit the loop, till then it will be endlessely looping and cause the computer to hit its op limit and crash wc3

PS.

please indent right, IE:

JASS:
function something takes something returns nothing
    loop
        exitwhen Something
        do stuff
        if this then
            do more stuff
        elseif this then
            do other more stuff
        else
            do other more stuff
        endif
    endloop
endfunction


every layer of encapsulation is another indent (makes it a LOT easier to read)

PPS:

instead of [ljass]call TriggerAddAction(trigger, function Actions)[/ljass] do [ljass]call TriggerAddCondition(trigger, Filter(function Actions))[/ljass] because actions leak, but you can use your actions as a condition, make them return boolean, and false at the end, and they will work the same way, just like an action but with no leak

PPPS:

you leak a lot of things
locals must be nulled if they are not a real number, integer, or struct variable
so just do:

[ljass]set localvariable = null[/ljass]

to clear those leaks
the exception is groups, which are cleared via: [ljass]call DestroyGroup(variable)[/ljass]

Thanks for your help...
I did realised I forgot to increase, silly me
but even after I changed, it still don't work....
I got a feeling that it is not related to those loop instead because even without the increment, the warcraft still did not crashed
PS: I only do indentation for very complicated script
If i null the trigger, wouldn't they stop working.....

You never set the nor increment the [ljass]local integer i[/ljass] in [ljass]Trig_Station_Turret_Actions[/ljass] or [ljass]Trig_Station_Turret_Actions2[/ljass]. Check how you did in [ljass]InitTrig_Station_Turret[/ljass]. Also, do you initialize [ljass]udg_Station_Turret_Using[1..4][/ljass] with [ljass]Player(PLAYER_NEUTRAL_PASSIVE)[/ljass]?

Thanks for your help...
Yeah I did not notice it... thanks for reminder
And I did initialize it in another trigger
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
when u null the trigger it sets the variable to null, but does nothing to the actual trigger except erase it's handle and recycle it, basically because you saved the reference to that trigger it is keeping that reference until it is nulled, but if you null the variable it erases that reference and the trigger is no longer referenced at all so you can erase the "ID" for the trigger or handle for it...
its kinda complex, but setting variables to null does nothing to what is inside the variable except prevent leaks

JASS:
function InitTrig_Station_Turret takes nothing returns nothing
    local trigger t = CreateTrigger()
    local trigger t2 = CreateTrigger()
    local integer i = 0
    set Station_Turret_Rect[1] = CreateRegion()
    set Station_Turret_Rect[2] = CreateRegion()
    set Station_Turret_Rect[3] = CreateRegion()
    set Station_Turret_Rect[4] = CreateRegion()
    call RegionAddRect(Station_Turret_Rect[1],gg_rct_Station_Turret_1)
    call RegionAddRect(Station_Turret_Rect[2],gg_rct_Station_Turret_2)
    call RegionAddRect(Station_Turret_Rect[3],gg_rct_Station_Turret_3)
    call RegionAddRect(Station_Turret_Rect[4],gg_rct_Station_Turret_4)    
    loop
    exitwhen i == 4
    set i = i + 1
    call TriggerRegisterEnterRegion(t, Station_Turret_Rect<i>, null)
    call TriggerRegisterLeaveRegion(t2, Station_Turret_Rect<i>, null)
    endloop
    call TriggerAddCondition(t, Condition(function Trig_Station_Turrets_Condition))
    call TriggerAddCondition(t2, Condition(function Trig_Station_Turrets_Condition))
    call TriggerAddAction(t, function Trig_Station_Turret_Actions )
    call TriggerAddAction(t2, function Trig_Station_Turret_Actions2 )
endfunction

//================================================================
//---------------------&gt;

function InitTrig_Station_Turret takes nothing returns nothing
    local trigger t = CreateTrigger()
    local trigger t2 = CreateTrigger()
    local integer i = 0
    set Station_Turret_Rect[1] = CreateRegion()
    set Station_Turret_Rect[2] = CreateRegion()
    set Station_Turret_Rect[3] = CreateRegion()
    set Station_Turret_Rect[4] = CreateRegion()
    call RegionAddRect(Station_Turret_Rect[1], Station_Turret_Rect[1])
    call RegionAddRect(Station_Turret_Rect[2], Station_Turret_Rect[2])
    call RegionAddRect(Station_Turret_Rect[3], Station_Turret_Rect[3])
    call RegionAddRect(Station_Turret_Rect[4], Station_Turret_Rect[4])    //its here, i believe these variables were referenced incorrectly in your code
    loop
    exitwhen i == 4
    set i = i + 1
    call TriggerRegisterEnterRegion(t, Station_Turret_Rect<i>, null)
    call TriggerRegisterLeaveRegion(t2, Station_Turret_Rect<i>, null)
    endloop
    call TriggerAddCondition(t, Condition(function Trig_Station_Turrets_Condition))
    call TriggerAddCondition(t2, Condition(function Trig_Station_Turrets_Condition))
    call TriggerAddAction(t, function Trig_Station_Turret_Actions )
    call TriggerAddAction(t2, function Trig_Station_Turret_Actions2 )
endfunction</i></i></i></i>
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top