Dialog Box

Genemos

New Member
Reaction score
3
So, I decided to make a system for my dungeons, that when a player types "-out" and are not within some certain areas. They are teleported to the townsquare, their hero is paused for a set amount of time and a dialog box is shown counting down until the hero should be unpaused and being able to resume play. There is just one problem, everything works fine until the time has run out, and play is supposed to be resumed. There is 2 problems.

1. The Countdown box will not dissapear.
2. The hero will not be unpaused.

The trigger is based upon my hero revival system, that is in many ways like this one. It works perfectly fine without any problems.

The "-out" system.

JASS:
function Trig_Untitled_Trigger_001_Func009Func001C takes nothing returns boolean
    if ( not ( RectContainsUnit(gg_rct_Bandit_C_Entrance, GetEnumUnit()) != true ) ) then
        return false
    endif
    if ( not ( RectContainsUnit(gg_rct_Bandit_W_Entrance, GetEnumUnit()) != true ) ) then
        return false
    endif
    if ( not ( RectContainsUnit(gg_rct_Murloc_Entrance, GetEnumUnit()) != true ) ) then
        return false
    endif
    if ( not ( RectContainsUnit(gg_rct_Dungeon, GetEnumUnit()) == true ) ) then
        return false
    endif
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Untitled_Trigger_001_Func009A takes nothing returns nothing
        local timerdialog WINDOW
        local integer HEROWAIT
        local timer OURTIMER
        local unit OURHERO
    if ( Trig_Untitled_Trigger_001_Func009Func001C() ) then
        set OURHERO = GetEnumUnit()
        set HEROWAIT = ( GetHeroLevel(OURHERO) * 1 )
        set OURTIMER = CreateTimer()
        call SetUnitPositionLoc( GetEnumUnit(), GetRectCenter(gg_rct_High_Spawn) )
        call PanCameraToTimedLocForPlayer( GetTriggerPlayer(), GetRectCenter(gg_rct_High_Spawn), 0 )
        call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "Your hero has been frozen for a few seconds" )
        call PauseUnitBJ( true, GetEnumUnit() )
        call StartTimerBJ( OURTIMER, false, ( I2R(HEROWAIT)) )
        call CreateTimerDialogBJ( OURTIMER, GetPlayerName(GetOwningPlayer(OURHERO)))
        set WINDOW = GetLastCreatedTimerDialogBJ()
        call TimerDialogDisplayForPlayerBJ( true, WINDOW, GetOwningPlayer(OURHERO))
        call PolledWait ( HEROWAIT )
        call DestroyTimerDialog(WINDOW)
        call PauseUnitBJ( false, GetEnumUnit() )
    else
    endif
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing

    call ForGroupBJ( GetUnitsInRectOfPlayer(GetPlayableMapRect(), GetTriggerPlayer()), function Trig_Untitled_Trigger_001_Func009A )
endfunction

//===========================================================================
function InitTrig_TP_Out_not_in_exit_zone takes nothing returns nothing
    set gg_trg_TP_Out_not_in_exit_zone = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_TP_Out_not_in_exit_zone, Player(0), "-out", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_TP_Out_not_in_exit_zone, Player(1), "-out", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_TP_Out_not_in_exit_zone, Player(2), "-out", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_TP_Out_not_in_exit_zone, Player(3), "-out", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_TP_Out_not_in_exit_zone, Player(4), "-out", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_TP_Out_not_in_exit_zone, Player(5), "-out", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_TP_Out_not_in_exit_zone, Player(6), "-out", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_TP_Out_not_in_exit_zone, Player(7), "-out", true )
    call TriggerAddAction( gg_trg_TP_Out_not_in_exit_zone, function Trig_Untitled_Trigger_001_Actions )
endfunction


The hero revival system

JASS:
function Trig_Death_Conditions takes nothing returns boolean

    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Death_Actions takes nothing returns nothing
    local timerdialog WINDOW
    local integer HEROWAIT
    local timer OURTIMER
    local unit OURHERO
    set OURHERO = GetDyingUnit()
    set HEROWAIT = ( GetHeroLevel(OURHERO) * 5 )
    set OURTIMER = CreateTimer()
    call StartTimerBJ( OURTIMER, false, ( I2R(HEROWAIT) ))
    call CreateTimerDialogBJ( OURTIMER, GetPlayerName(GetOwningPlayer(OURHERO)))
    set WINDOW = GetLastCreatedTimerDialogBJ()
    call TimerDialogDisplayForPlayerBJ( true, WINDOW, GetOwningPlayer(OURHERO))
    call PolledWait ( HEROWAIT )
    call ReviveHeroLoc(OURHERO, GetRectCenter(gg_rct_High_Spawn), true )
    call PanCameraToTimedLocForPlayer( GetOwningPlayer(OURHERO), GetUnitLoc(OURHERO), 0.60)
    call DestroyTimerDialog(WINDOW)
endfunction

//===========================================================================
function InitTrig_Death takes nothing returns nothing
    set gg_trg_Death = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Death, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Death, Condition( function Trig_Death_Conditions ) )
    call TriggerAddAction( gg_trg_Death, function Trig_Death_Actions )
endfunction


Would be happy for any response, and how do I hide the code using spoilers?

Also, how do I do to include the timer "HEROWAIT" in the string below?

JASS:
call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "Your hero has been frozen for a few seconds" )


EDIT: Might have figured out how to display the time in the message.
 

Rommel

New Member
Reaction score
13
You have only one Hero per player or more?

You should setup a Hero variable for each player for later use so that you do not need such many conditions each time you need to do something with your hero.
Your code looks not efficient but answer me before i could help.
 

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
call PolledWait ( HEROWAIT )

You cannot use [LJASS]TriggerSleepAction[/LJASS] from within a ForGroup call.
And [LJASS]PolledWait[/LJASS] is a wrapper for [LJASS]TriggerSleepAction[/LJASS], with some extra stuff (like leaking a handle).

It will cause the thread to end. :)
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
I never got what PolledWait was.
My World Editor doesn't seem to acknowledge PolledWait as a native.
It doesn't ackowledge IsUnitAlive (Or something like that) as a native, too.
 

Genemos

New Member
Reaction score
3
You have only one Hero per player or more?

You should setup a Hero variable for each player for later use so that you do not need such many conditions each time you need to do something with your hero.
Your code looks not efficient but answer me before i could help.

Only 1 hero per player, yes.

And no, it is most likely not the most efficient way to do it, but it is my first try, and most of the time I am just happy it works, not saying efficiency should be ignored thou.

Could you perhaps help me with making it more efficient? Aswell :p
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
I never got what PolledWait was.
My World Editor doesn't seem to acknowledge PolledWait as a native.
It doesn't ackowledge IsUnitAlive (Or something like that) as a native, too.

PolledWait is a BJ and UnitAlive is from the common.ai. (Which means you must declare it [ljass]native UnitAlive takes unit id returns boolean[/ljass])

PolledWait is simply a "less random" tool for TriggerSleepAction. It incorporates a timer and loops a wait. The reason for it being less random is that it uses TimerGetRemaining() to check when the duration has expired. This way, if things happen to be random it'll usually end up waiting somewhere around the duration it is supposed to. However, the lowest wait time for using the PolledWait BJ is about 0.250 seconds. (For TSA, it varies and can get as low as 0.7825 or something along those lines)
 

Genemos

New Member
Reaction score
3
JASS:
call PolledWait ( HEROWAIT )

You cannot use [LJASS]TriggerSleepAction[/LJASS] from within a ForGroup call.
And [LJASS]PolledWait[/LJASS] is a wrapper for [LJASS]TriggerSleepAction[/LJASS], with some extra stuff (like leaking a handle).

It will cause the thread to end. :)

Ok, I think I understand, if I get it right it is the fact that I use
instead of


This causes the entire thread (trigger?) to stop going.

You're also mentioning that the PolledWait is just a wrapper, that leaks o_O
How do I solve the problem?
Since I can't figure out a way to do it without the


Grateful for all the help!
 

Bribe

vJass errors are legion
Reaction score
67
First Trigger:

JASS:

function Trig_Untitled_Trigger_001_Func009B takes nothing returns nothing
    local timer t=CreateTimer()
    local timerdialog w=CreateTimerDialogBJ(t,GetPlayerName(bj_groupEnumOwningPlayer))
//*
//* The function must memorize the hero-unit, and that is by setting it as a local unit.
    local unit u=bj_meleeNearestMine
//*
//* Memorize the coordinates of the center of High Spawn.
    local real x=GetRectCenterX(gg_rct_High_Spawn)
    local real y=GetRectCenterY(gg_rct_High_Spawn)
//*
//* A GetLocalPlayer() comparison means that the actions within the if/then/else block will ONLY
//* be done for *this person's computer*.  Avoid doing crazy things here, as that causes big problems
//* in multiplayer games (usually players drop).
//*
    if GetLocalPlayer()==bj_groupEnumOwningPlayer then
        call TimerDialogDisplay(w,true)
        call PanCameraToTimed(x,y,0.)
    endif
//*
//* Move unit to memorized coordinates.
    call SetUnitPosition(u,x,y)
    call PauseUnit(u,true)
    call DisplayTextToPlayer(bj_groupEnumOwningPlayer,0.,0.,"Your hero has been frozen for a few seconds" )
//*
//* Start the timer; "polled wait" the timer's duration.
    call TimerStart(t,bj_meleeNearestMineDist,false,null)
    call PolledWait(bj_meleeNearestMineDist)
    
    call PauseUnit(u,false)
//*
//* Clear memory leaks:
    call DestroyTimer(t)
    call DestroyTimerDialog(w)
    set t=null
    set u=null
    set w=null
endfunction
    
function Trig_Untitled_Trigger_001_Func009A takes nothing returns boolean
//*
//* Since this is a filter instead of a "For Group" call, refer to the "picked unit" as "filter unit".
    local unit u=GetFilterUnit()
    local real x=GetWidgetX(u)
    local real y=GetWidgetY(u)
    if IsUnitType(u,UNIT_TYPE_HERO) and not RectContainsCoords(gg_rct_Bandit_C_Entrance,x,y) and not RectContainsCoords(gg_rct_Bandit_W_Entrance,x,y) and not RectContainsCoords(gg_rct_Murloc_Entrance,x,y) and RectContainsCoords(gg_rct_Dungeon,x,y) then
//*
//* meleeNearestMineDist is a global real value, so you don't need to create a new one.  Same with
//* meleeNearestMine.
//*
        set bj_meleeNearestMineDist=I2R(GetHeroLevel(u))
        set bj_meleeNearestMine=u
//*
//* ExecuteFunc is very sweet as it creates a new thread, enabling you to use &quot;polled wait&quot; <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />
        call ExecuteFunc(&quot;Trig_Untitled_Trigger_001_Func009B&quot;)
    endif
    set u=null
    return false //return &quot;False&quot; so no units are ever added to the group <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />
endfunction
    
function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
//*
//* Memorize the triggering player with this preset global.
    set bj_groupEnumOwningPlayer=GetTriggerPlayer()
//*
//* Evaluate every unit owned by that player with the above function:
    call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup,bj_groupEnumOwningPlayer,Filter(function Trig_Untitled_Trigger_001_Func009A))
    return false
endfunction
    
//===========================================================================
function InitTrig_TP_Out_not_in_exit_zone takes nothing returns nothing
    local trigger t=CreateTrigger()
    local integer i=0
    call TriggerAddCondition(t,Condition(function Trig_Untitled_Trigger_001_Conditions))
    loop
        call TriggerRegisterPlayerChatEvent( t, Player(i), &quot;-out&quot;, true )
        exitwhen i==7
        set i=i+1
    endif
endfunction


Second Trigger:

JASS:

    
function Trig_Death_Actions takes nothing returns nothing
//*
//* These first 4 locals have handles.  Usually, you need to set them to null when the function
//* no longer needs them. The things you don&#039;t have to null are things that will never be
//* destroyed or killed (if the map ends if a specific unit dies, you never have to null that
//* unit.  Players, don&#039;t null. Triggers created in an &quot;Init&quot; function almost never need a null.
//*
    local unit u=GetTriggerUnit()
    local timer t=CreateTimer()
    local player p=GetTriggerPlayer()   //when responding to &quot;player unit&quot; event, &quot;triggering player&quot;
                                        //returns the owner of the &quot;triggering unit&quot; (you don&#039;t need
                                        //GetOwningPlayer(GetTriggerUnit())).
    local timerdialog w=CreateTimerDialogBJ(t,GetPlayerName(p))
    
    local real d=GetHeroLevel(u)*5.
    local real x=GetRectCenterX(gg_rct_High_Spawn)
    local real y=GetRectCenterY(gg_rct_High_Spawn)
    
    call TimerStart(t,d,false,null)
    call TimerDialogDisplayForPlayerBJ(true,w,p) //show the dialog only for the specified player.
    call PolledWait(d) //wait the duration of the timer.
    
    call ReviveHero(u,x,y,true)
    call PanCameraToTimedForPlayer(p,x,y,0.6)
//*
//* Clean up memory leaks:
    call DestroyTimer(t)
    call DestroyTimerDialog(w)
    set t=null
    set u=null
    set w=null
endfunction
    
function Trig_Death_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO)
endfunction
    
//===========================================================================
function InitTrig_Death takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(t,Condition(function Trig_Death_Conditions))
    call TriggerAddAction(t,function Trig_Death_Actions)
endfunction
 

Genemos

New Member
Reaction score
3
First trigger:

JASS:
function Trig_Untitled_Trigger_001_Func009B takes nothing returns nothing
    local timer t=CreateTimer()
    local timerdialog w=CreateTimerDialog(t)
    local unit u=bj_meleeNearestMine
    local real x=GetRectCenterX(gg_rct_High_Spawn)
    local real y=GetRectCenterY(gg_rct_High_Spawn)
    if GetLocalPlayer()==bj_groupEnumOwningPlayer then
        call TimerDialogDisplay(w,true)
        call PanCameraToTimed(x,y,0.)
    endif
    call SetUnitPosition(u,x,y)
    call PauseUnit(u,true)
    call DisplayTextToPlayer(bj_groupEnumOwningPlayer,0.,0.,&quot;Your hero has been frozen for a few seconds&quot; )
    call TimerStart(t,bj_meleeNearestMineDist,false,null)
    call PolledWait(bj_meleeNearestMineDist)
    call PauseUnit(u,false)
    call DestroyTimer(t)
    call DestroyTimerDialog(w)
    set t=null
    set u=null
    set w=null
endfunction
    
function Trig_Untitled_Trigger_001_Func009A takes nothing returns boolean
    local unit u=GetFilterUnit()
    local real x=GetWidgetX(u)
    local real y=GetWidgetY(u)
    if IsUnitType(u,UNIT_TYPE_HERO) and not RectContainsCoords(gg_rct_Bandit_C_Entrance,x,y) and not RectContainsCoords(gg_rct_Bandit_W_Entrance,x,y) and not RectContainsCoords(gg_rct_Murloc_Entrance,x,y) and RectContainsCoords(gg_rct_Dungeon,x,y) then
        set bj_meleeNearestMineDist=I2R(GetHeroLevel(u))
        set bj_meleeNearestMine=u
        call ExecuteFunc(&quot;Trig_Untitled_Trigger_001_Func009B&quot;)
    endif
    set u=null
    return false
endfunction
    
function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
    set bj_groupEnumOwningPlayer=GetTriggerPlayer()
    call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup,bj_groupEnumOwningPlayer,Filter(function Trig_Untitled_Trigger_001_Func009A))
    return false
endfunction
    
//===========================================================================
function InitTrig_TP_Out_not_in_exit_zone takes nothing returns nothing
    local trigger t=CreateTrigger()
    local integer i=0
    call TriggerAddCondition(t,Condition(function Trig_Untitled_Trigger_001_Conditions))
    loop
        call TriggerRegisterPlayerChatEvent( t, Player(i), &quot;-out&quot;, true )
        exitwhen i==7
        set i=i+1
    endif
endfunction


Second trigger:
JASS:
function Trig_Death_Actions takes nothing returns nothing
    local unit u=GetTriggerUnit()
    local timer t=CreateTimer()
    local player p=GetTriggerPlayer()
    local timerdialog w=CreateTimerDialogBJ(t,GetPlayerName(p))
    
    local real d=GetHeroLevel(u)*5.
    local real x=GetRectCenterX(gg_rct_High_Spawn)
    local real y=GetRectCenterY(gg_rct_High_Spawn)
    
    call TimerStart(t,d,false,null)
    call TimerDialogDisplayForPlayerBJ(true,w,p)
    call PolledWait(d)
    
    call ReviveHero(u,x,y,true)
    call PanCameraToTimedForPlayer(p,x,y,0.6)
    call DestroyTimer(t)
    call DestroyTimerDialog(w)
endfunction
    
function Trig_Death_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO)
endfunction
    
//===========================================================================
function InitTrig_Death takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(t,Condition(function Trig_Death_Conditions))
    call TriggerAddAction(t,function Trig_Death_Actions)
endfunction

This looks simply amazing, with my untrained eyes it is a bit of a mess thou, I will try my best to understand it but it would help me a lot if you could perhaps put some comments in.

I understand that it will work, but I also want to understand HOW, or I will not learn ^^

Thanks a lot, will give it another try to see what it does when I am clearer in the head.
 

Genemos

New Member
Reaction score
3
JASS:
call TriggerRegisterPlayerChatEvent( t, Player(i), &quot;-out&quot;, true )
        exitwhen i==7
        set i=i+1


If I read this right, this is sort of a loop that runs 7 times? This is probably way wrong, but it is the only idea I have as of why you have the "exitwhen" and "set" functions, can you explain the logic behind it?



Simply judging by the way it looks, this sets the unit as "u" what exactly does these two "bj" do?

JASS:
    
local real x=GetRectCenterX(gg_rct_High_Spawn)
local real y=GetRectCenterY(gg_rct_High_Spawn)


What's the logic behind this? Being able to call the coordinates easily when moving the unit and the camera?



This checks the owned of the picked units(or should it be filtered unit?) What happens if there is units belonging to multiple amount of players?


Lots of questions, but then I have not really done any Jass programing myself, I go with the idea that all questions are good questions. If there is some sort of dictionary over the "bj" functions I have not been able to find it, or my knowledge is just not enough. Either way, thanks for the help.
 

Bribe

vJass errors are legion
Reaction score
67
If I read this right, this is sort of a loop that runs 7 times?
-- It runs 8 times, from player 0 through player 7. Players are identified by the value Player(i) so since i increases by one each loop, it's a new player each time.

what exactly does these two "bj" do?
-- They are explained in that code, the "mine" is a unit global, the "mineDist" is a real global.

What's the logic behind this? Being able to call the coordinates easily when moving the unit and the camera?
-- Yep.

This checks the owned of the picked units(or should it be filtered unit?) What happens if there is units belonging to multiple amount of players?
-- Your function was only picking units owned by the triggering player, so... that's what i did.


If there is some sort of dictionary over the "bj" functions I have not been able to find it.
-- Just click on any function on this web site and it has a link to its useage (that's very clever btw of thehelper staff to include that).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top