• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

emove buttons from victory/defeat condition

Status
Not open for further replies.
Level 26
Joined
Aug 18, 2009
Messages
4,097
That's part of the bj functions, which assemble an interactive dialog. So that brings no new native functionality. Just make your own dialog.

You can refer to the below structure and apply the localized strings.

JASS:
function MeleeVictoryDialogBJ takes player whichPlayer, boolean leftGame returns nothing
    local trigger t = CreateTrigger()
    local dialog  d = DialogCreate()
    local string formatString

    // Display "player was victorious" or "player has left the game" message
    if (leftGame) then
        set formatString = GetLocalizedString( "PLAYER_LEFT_GAME" )
    else
        set formatString = GetLocalizedString( "PLAYER_VICTORIOUS" )
    endif

    call DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, formatString)

    call DialogSetMessage( d, GetLocalizedString( "GAMEOVER_VICTORY_MSG" ) )
    call DialogAddButton( d, GetLocalizedString( "GAMEOVER_CONTINUE_GAME" ), GetLocalizedHotkey("GAMEOVER_CONTINUE_GAME") )

    set t = CreateTrigger()
    call TriggerRegisterDialogButtonEvent( t, DialogAddQuitButton( d, true, GetLocalizedString( "GAMEOVER_QUIT_GAME" ), GetLocalizedHotkey("GAMEOVER_QUIT_GAME") ) )

    call DialogDisplay( whichPlayer, d, true )
    call StartSoundForPlayerBJ( whichPlayer, bj_victoryDialogSound )
endfunction

//===========================================================================
function MeleeDefeatDialogBJ takes player whichPlayer, boolean leftGame returns nothing
    local trigger t = CreateTrigger()
    local dialog  d = DialogCreate()
    local string formatString

    // Display "player was defeated" or "player has left the game" message
    if (leftGame) then
        set formatString = GetLocalizedString( "PLAYER_LEFT_GAME" )
    else
        set formatString = GetLocalizedString( "PLAYER_DEFEATED" )
    endif

    call DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, formatString)

    call DialogSetMessage( d, GetLocalizedString( "GAMEOVER_DEFEAT_MSG" ) )

    // Only show the continue button if the game is not over and observers on death are allowed
    if (not bj_meleeGameOver and IsMapFlagSet(MAP_OBSERVERS_ON_DEATH)) then
        call DialogAddButton( d, GetLocalizedString( "GAMEOVER_CONTINUE_OBSERVING" ), GetLocalizedHotkey("GAMEOVER_CONTINUE_OBSERVING") )
    endif

    set t = CreateTrigger()
    call TriggerRegisterDialogButtonEvent( t, DialogAddQuitButton( d, true, GetLocalizedString( "GAMEOVER_QUIT_GAME" ), GetLocalizedHotkey("GAMEOVER_QUIT_GAME") ) )

    call DialogDisplay( whichPlayer, d, true )
    call StartSoundForPlayerBJ( whichPlayer, bj_defeatDialogSound )
endfunction
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
This is a very simple script but you can also do it via GUI yes. The only functionality I see you may not have an equivalent for is the DialogAddQuitButton, which is a variant of normal buttons, it just runs

native EndGame takes boolean doScoreScreen returns nothing

when pressed, which is not directly available in GUI either. But it's very simple. Just insert

  • Custom script: if (GetLocalPlayer() == udg_Player) then
  • Custom script: call EndGame(udg_ShowScores)
  • Custom script: endif
where Player is a variable containing the player you want to kick (global variables you create in GUI are invisibly prefixed by udg_). And ShowScores is a boolean variable determining if to show the scoreboard afterwards.
 
OK, you two gave me an idea to just create the dialogs for victory and defeat with triggers... I made the two variables victory and defeat and their dialog button values... no complicated stuff :D
I'll do it like

define buttons
  • Events
  • Map initialization
  • Actions
  • Dialog - change title of Victory to Victory!
  • Dialog - change title of Defeat to Defeat!
trigger victory
  • Events
  • whatever
  • Conditions
  • Whatever
  • Actions
  • Dialog - Show Victory for player 1
  • Dialog - create Dialog button for Victory labeled Quit Game
  • Custom script: call EndGame()
Is this how it should be? Correct me if I am wrong
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The create button should go to init, you do not need to create it over and over again. Then you need a trigger that detects the dialog being clicked. Since that event refers to the dialog and you have only one button, you do not need to save the button in a variable/check for it. This trigger should finally get the EndGame lines. And no, the way you have written this is wrong. EndGame takes a boolean parameter and you won't want to defeat all players at once I suppose. Just copy the lines from me, create the variables as described and set them before those three lines via Set Variable action.
 
(global variables you create in GUI are invisibly prefixed by udg_). And ShowScores is a boolean variable determining if to show the scoreboard afterwards.

then for defeat how do i script it?
  • Events
  • Dialog - a dialog button is clicked for Defeat
  • Actions
  • Custom script: call Endgame(udg_showscores)
?
So you say that the custom script will defeat all players?
this mean i have to make a player group variable or a player variable? What is the syntax of the text inside the brackets? playerVariable_showscores?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
No, if you want to target multiple players, put it in a loop. But the normal victory/defeat dialog does not do this either. Do not misunderstand. You can show the same dialog to multiple players individually and use that same code for each player. You would just want to specifically kick the player that has clicked the dialog at a time.
 
create
  • events
  • Map initialization
  • Actions
  • Dialog - change title of Victory to Victory!
  • Dialog - change title of Defeat to Defeat!
  • Dialog - create button for victory labeled Quit Game
  • Dialog - create button for defeat labeled Quit Game
clicked victory
  • Events
  • Dialog - a dialog button is clicked for victory
  • Actions
  • Game - victory player 1(skip dialogs,show scores)
clicked defeat
  • Events
  • Dialog - a dialog button is clicked for Defeat
  • Actions
  • Custom script: if (GetLocalPlayer() == udg_Player1) then
  • Custom script: call EndGame(udg_ShowScores)
  • Custom script: endif
Nothing changes actually. I expected to create a dialog with one button but nothing changes. wtf?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Do not set up the dialog at map init. Wc3 cannot deal with that. But it's still enough to do it only once.
In the click trigger, ofc you have to set the player variable before the if block to the triggering player in order to get the one that clicked the dialog.

Instead of literally titling the dialog with english identifiers, you can pick the localized variants by using the function Conversion - Convert Externalized String

  • Dialog - Change the title of Defeat to (Externalized string(GAMEOVER_DEFEAT_MSG))
  • Dialog - Create a dialog button for Defeat labelled (Externalized string(GAMEOVER_QUIT_GAME))
You do not have to manually transcribe your triggers in this thread. Right-click on the trigger root (name) on the right side and >Copy as text.
 
u mean
  • (Triggering player) Equal to Player 1 (Red)
?

btw, I know you know what I ask for, but I want to present my idea visually
Game Dialogs. Is anything chanegd in these ddialogs. o_O?
735120.jpg
735121.jpg


Wanted Dialog

735122.jpg
 
  • create
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Dialog - Change the title of victory to Victory!
      • Dialog - Change the title of Defeat to Defeat!
      • Dialog - Create a dialog button for Defeat labelled (Externalized string(GAMEOVER_DEFEAT_MSG))
      • Dialog - Create a dialog button for victory labelled (Externalized string( GAMEOVER_QUIT_GAME))
  • clicked defeat
    • Events
      • Dialog - A dialog button is clicked for Defeat
    • Conditions
    • Actions
      • Set player1 = (Triggering player)
      • Custom script: if (GetLocalPlayer() == udg_player1) then
      • Custom script: call EndGame(udg_ShowScores)
      • Custom script: endif
  • Ship die alliance
    • Events
      • Unit - Alliance Ship 0029 <gen> Dies
    • Conditions
    • Actions
      • Dialog - Show Defeat for Player 1 (Red)
ha-ha! the game pauses but no dialog is shown! ;D
 
Take a 0 game time elapsed event or anything before you actually want to show the dialog but not map init.
  • buttons
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Dialog - Create a dialog button for Defeat labelled (Externalized string(GAMEOVER_DEFEAT_MSG))
      • Dialog - Create a dialog button for victory labelled (Externalized string( GAMEOVER_QUIT_GAME))
I did but it's the same. Are you sure the buttons should be externalized strings?
 
The point of your last post was to change init to something other like I did - 0.05 sec.

Now this worked!

about the externalzied strings - the string makes the button text "you failed to achieve victory!" so I went back to my label. Now this is what I wanted! Thank you for the patience :) Also is there a way to create a subtext(text beneath title) as a final detail?
 
Status
Not open for further replies.
Top