• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] What do I need to change to make timer window display to owner of the dying unit?

Status
Not open for further replies.
Level 6
Joined
Jul 8, 2008
Messages
150
Here is my trigger: as it is right now, when a hero dies, a timer window for that hero will appear and display to all players. i want it to display to only the owner of the dying unit. How do I do that?

  • Revive
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Unit-type of (Triggering unit)) Not equal to Death Lord
    • Actions
      • Custom script: local timerdialog DeadHero_Window
      • Custom script: local integer DeadHero_Wait
      • Custom script: local timer DeadHero_Timer
      • Custom script: local unit DeadHero_Unit
      • Custom script: set DeadHero_Unit = GetDyingUnit()
      • Custom script: set DeadHero_Wait = ( ( GetHeroLevel(DeadHero_Unit) * 2 ) + 25 )
      • Custom script: set DeadHero_Timer = CreateTimer()
      • Custom script: call StartTimerBJ(DeadHero_Timer, false, ( I2R(DeadHero_Wait) ))
      • Custom script: call CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
      • Custom script: set DeadHero_Window = GetLastCreatedTimerDialogBJ()
      • Custom script: call TimerDialogDisplayForPlayerBJ( true, DeadHero_Window, GetOwningPlayer(DeadHero_Unit) )
      • Custom script: call PolledWait( DeadHero_Wait )
      • Custom script: call ReviveHeroLoc(DeadHero_Unit, GetPlayerStartLocationLoc(GetOwningPlayer(DeadHero_Unit)), true )
      • Custom script: call DestroyTimerDialog(DeadHero_Window)
 
Level 13
Joined
Mar 16, 2008
Messages
941
Why are you using gui? The entire code are custom scripts :O but ok, thats not your question. Just hide the timerwindow for all players and use this
  • Custom script: if GetLocalPlayer() == GetOwningPlayer(DeadHero_Unit) then
  • Custom script: call TimerDialogDisplayForPlayerBJ( true, DeadHero_Window, GetLocalPlayer())
  • Custom script: endif
But I'd realy recommend to write this in jass and get rid of the bjs :O
Oh, and dont write ANYTHING between the lines "if GetLocalPlayer()...." and "endif" unless you know what you're doing or your map will cause desyncs ;)
 
Level 6
Joined
Jul 8, 2008
Messages
150
It doesn't work :(

This is what I have:

  • Revive
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Unit-type of (Triggering unit)) Not equal to Death Lord
    • Actions
      • Custom script: local timerdialog DeadHero_Window
      • Custom script: local integer DeadHero_Wait
      • Custom script: local timer DeadHero_Timer
      • Custom script: local unit DeadHero_Unit
      • Custom script: set DeadHero_Unit = GetDyingUnit()
      • Custom script: set DeadHero_Wait = ( ( GetHeroLevel(DeadHero_Unit) * 2 ) + 25 )
      • Custom script: set DeadHero_Timer = CreateTimer()
      • Custom script: call StartTimerBJ(DeadHero_Timer, false, ( I2R(DeadHero_Wait) ))
      • Custom script: call CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
      • Custom script: set DeadHero_Window = GetLastCreatedTimerDialogBJ()
      • Custom script: if GetLocalPlayer() == GetOwningPlayer(DeadHero_Unit) then
      • Custom script: call TimerDialogDisplayForPlayerBJ( true, DeadHero_Window, GetLocalPlayer())
      • Custom script: endif
      • Custom script: call PolledWait( DeadHero_Wait )
      • Custom script: call ReviveHeroLoc(DeadHero_Unit, GetPlayerStartLocationLoc(GetOwningPlayer(DeadHero_Unit)), true )
      • Custom script: call DestroyTimerDialog(DeadHero_Window)
 
Level 13
Joined
Mar 16, 2008
Messages
941
because you did not all what I said :O
Just hide the timerwindow for all players and use this
And I made a mistake. I looked at the BJ, it already uses GetLocalPlayer().
Try this:
  • .
  • .
  • .
  • Custom script: call CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
  • Custom script: set DeadHero_Window = GetLastCreatedTimerDialogBJ()
  • Custom script: call TimerDialogDisplay(DeadHero_Window, false)
  • Custom script: call TimerDialogDisplayForPlayerBJ( true, DeadHero_Window, GetOwningPlayer(DeadHero_Unit))
 
That isn't the most efficient way of doing it btw - try
  • .
  • .
  • .
  • Custom script: call CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
  • Custom script: set DeadHero_Window = GetLastCreatedTimerDialogBJ()
  • Custom script: if GetLoaclPlayer()!=GetOwningPlayer(DeadHero_Unit)) then
  • Custom script: call TimerDialogDisplay( DeadHero_Window, true )
  • Custom script: endif
 
Last edited:
Level 13
Joined
Mar 16, 2008
Messages
941
Sry, but are you kidding me?
You realy cry about efficience and still write
  • Custom script: call CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
  • Custom script: set DeadHero_Window = GetLastCreatedTimerDialogBJ()
? You just changed a single BJ into the natives... if you want to help, do it with the entire trigger -.-
I just wrote a fast (not effective, but fast written :p) version that works since that was all he asked for :/
 
Sry, but are you kidding me?
You realy cry about efficience and still write
  • Custom script: call CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
  • Custom script: set DeadHero_Window = GetLastCreatedTimerDialogBJ()
? You just changed a single BJ into the natives... if you want to help, do it with the entire trigger -.-
I just wrote a fast (not effective, but fast written :p) version that works since that was all he asked for :/
The efficiency thing in this case wasn't about natives/BJs. I actually got rid of a function call in doing it that way...
 
Level 13
Joined
Mar 16, 2008
Messages
941
Did you tested it? Thats EXACTLY what he had before and it didn't worked. Afaik timer windows are instantly shown to all players, so you need to hide them before, but I could be wrong with that.
And no, less lines are most times less calls....
  • Custom script: call CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
  • Custom script: set DeadHero_Window = GetLastCreatedTimerDialogBJ()
Is the same as
  • Custom script: set DeadHero_Window = CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
  • Custom script: call CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
  • Custom script: set DeadHero_Window = GetLastCreatedTimerDialogBJ()
Is the same as
  • Custom script: set DeadHero_Window = CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )

How exactly are they the same thing?

And if you are all arguing about efficiency, then you should write it like this:

JASS:
set DeadHero_Window = CreateTimerDialog(DeadHero_Timer)
call TimerDialogSetTitle(DeadHero_Window,GetUnitName(DeadHero_Unit))

Which by the way also removes the TimerDialogDisplay call, which means you won't need to hide it from all the players.

It doesn't matter about how many lines of code you have (unless you really want to save space, but I doubt a few characters will take up much space)

Seeing as every character is one byte... nah :p
The only files which I see any reason to even think about writing in a smart way are 3d model files, which are getting bigger and bigger every year.
There are also pictures, but seeing as computers today have to so much memory, it doesn't really matter (A good example would be the OBJ 3d format which is written in a BAAAAAD way. A simple file which contains the same info can be around 30-50% file size, and when your model is, say, 100-200 mb, it matters (I made it so I know :) )).
 
Did you tested it? Thats EXACTLY what he had before and it didn't worked. Afaik timer windows are instantly shown to all players, so you need to hide them before, but I could be wrong with that.
And no, less lines are most times less calls....
  • Custom script: call CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
  • Custom script: set DeadHero_Window = GetLastCreatedTimerDialogBJ()
Is the same as
  • Custom script: set DeadHero_Window = CreateTimerDialogBJ( DeadHero_Timer, GetUnitName(DeadHero_Unit) )
More lines are NOT more calls if the lines you are expanding contain BJs... and those two codes you give - they're not the same, but did I ever say anything about them?
 
Level 9
Joined
Apr 3, 2008
Messages
700
JASS:
native CreateTimerDialog takes timer t returns timerdialog

JASS:
function CreateTimerDialogBJ takes timer t, string title returns timerdialog
    set bj_lastCreatedTimerDialog = CreateTimerDialog(t)
    call TimerDialogSetTitle(bj_lastCreatedTimerDialog, title)
    call TimerDialogDisplay(bj_lastCreatedTimerDialog, true)
    return bj_lastCreatedTimerDialog
endfunction
 
Status
Not open for further replies.
Top