• 🏆 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!

How to "MUI" this trigger ?

Status
Not open for further replies.

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
  • Timer Count Start
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Set ReviveHero = (Dying unit)
      • Countdown Timer - Start ReviveTimerArray[1] as a One-shot timer that will expire in 3.00 seconds
      • Countdown Timer - Create a timer window for ReviveTimerArray[1] with title Reviverá em...
      • Countdown Timer - Show (Last created timer window)
      • Set ReviveTimerWindowArray[1] = (Last created timer window)
  • Timer Destroy
    • Events
      • Time - ReviveTimerArray[1] expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy ReviveTimerWindowArray[1]
      • Set HRL = (Random point in Region 000 <gen>)
      • Hero - Instantly revive ReviveHero at HRL, Show revival graphics
      • Set HRLC = (Position of (Reviving Hero))
      • Camera - Pan camera for (Owner of (Reviving Hero)) to HRLC over 0.00 seconds
      • Selection - Select (Reviving Hero) for (Owner of (Reviving Hero))
      • Custom script: call RemoveLocation(udg_HRL)
      • Custom script: call RemoveLocation(udg_HRLC)
This trigger often bugs if two units dies. I think that if it was MUI it would work for both. How can I ?
 

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
Okay, so how can I make a revive hero system with timer and MUI ? Can anyone help ? I can't find none in War3 Spells.
 
Level 4
Joined
Feb 28, 2014
Messages
70
The problem is, that you're using the same Countdown with all units. If each player can only control 1 hero, use Player Number as index, if they can have multiple heroes, set an HeroID for each hero.

Or in other words:



  • Timer Count Start
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Set ReviveHero[Player Number of Dying unit] = (Dying unit)
      • Countdown Timer - Start ReviveTimerArray[Player Number of ReviveHero] as a One-shot timer that will expire in 3.00 seconds
      • Countdown Timer - Create a timer window for ReviveTimerArray[Player Number of ReviveHero] with title Reviverá em...
      • Countdown Timer - Show (Last created timer window)
      • Set ReviveTimerWindowArray[Player Number of ReviveHero] = (Last created timer window)
  • Timer Destroy
    • Events
      • Time - ReviveTimerArray[1] expires
      • Time - ReviveTimerArray[2] expires
      • Time - ReviveTimerArray[3] expires
      • Time - ReviveTimerArray[4] expires
      • Time - ReviveTimerArray[5] expires
      • Time - ReviveTimerArray[6] expires
      • Time - ReviveTimerArray[7] expires
      • Time - ReviveTimerArray[8] expires
      • Time - ReviveTimerArray[9] expires
      • Time - ReviveTimerArray[10] expires
      • Time - ReviveTimerArray[11] expires
      • Time - ReviveTimerArray[12] expires
    • Conditions
    • Actions
      • For each (Integer Variable) from 1 to 12, do (Actions)
        • Loop - Actions
          • If then else
            • If - conditions
              • Remaining time of ReviveTimerArray[Integer Variable] equal to 0
              • ReviveHero[Integer Variable] is Dead Equal to True
            • Then - Actions
              • Countdown Timer - Destroy ReviveTimerWindowArray[Integer Variable]
              • Custom script: set udg_ReviveTimerWindowArray[Integer Variable] = null
              • Set HRL = (Random point in Region 000 <gen>)
              • Hero - Instantly revive ReviveHero[IntegerVariable] at HRL, Show revival graphics
              • Camera - Pan camera for (Owner of (Reviving Hero)) to HRL over 0.00 seconds
              • Selection - Select (Reviving Hero) for (Owner of (Reviving Hero))
              • Custom script: call RemoveLocation(udg_HRL)
              • Custom script: set udg_HRL = null




  • Timer Count Start
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • If then else
        • If - Conditions
          • (Dying unit custom value) Equal to 0
        • Then - Actions
          • Set UnitID = UnitID + 1
          • Unit - Set the custom value of (Dying unit) to UnitID
          • Set ReviveHero[UnitID] = (Dying unit)
          • Countdown Timer - Start ReviveTimerArray[UnitID] as a One-shot timer that will expire in 3.00 seconds
          • Countdown Timer - Create a timer window for ReviveTimerArray[UnitID] with title (Hero Name of Dying Unit) + ReviverÃi em...
          • Countdown Timer - Show (Last created timer window)
          • Set ReviveTimerWindowArray[UnitID] = (Last created timer window)
          • Trigger - Add event to Timer Destroy (ReviveTimerArray[UnitID] expires)
        • Else - Actions
          • Set UnitTempID = Custom Value of Dying Unit
          • Set ReviveHero[UnitTempID] = (Dying unit)
          • Countdown Timer - Start ReviveTimerArray[UnitTempID] as a One-shot timer that will expire in 3.00 seconds
          • Countdown Timer - Create a timer window for ReviveTimerArray[UnitTempID] with title (Hero Name of Dying Unit) + ReviverÃi em...
          • Countdown Timer - Show (Last created timer window)
          • Set ReviveTimerWindowArray[UnitTempID] = (Last created timer window)
  • Timer Destroy
    • Events
    • Conditions
    • Actions
      • For each (Integer Variable) from 1 to UnitID, do (Actions)
        • Loop - Actions
          • If then else
            • If - conditions
              • Remaining time of ReviveTimerArray[Integer Variable] equal to 0
              • ReviveHero[Integer Variable] is Dead Equal to True
            • Then - Actions
              • Countdown Timer - Destroy ReviveTimerWindowArray[Integer Variable]
              • Custom script: set udg_ReviveTimerWindowArray[Integer Variable] = null
              • Set HRL = (Random point in Region 000 <gen>)
              • Hero - Instantly revive ReviveHero[IntegerVariable] at HRL, Show revival graphics
              • Camera - Pan camera for (Owner of (Reviving Hero)) to HRL over 0.00 seconds
              • Selection - Select (Reviving Hero) for (Owner of (Reviving Hero))
              • Custom script: call RemoveLocation(udg_HRL)
              • Custom script: set udg_HRL = null
 
Last edited:
  • Like
Reactions: hdm
Level 18
Joined
May 11, 2012
Messages
2,103
The problem is, that you're using the same Countdown with all units. If each player can only control 1 hero, use Player Number as index, if they can have multiple heroes, set an HeroID for each hero.

Or in other words:

If each player can only control 1 Hero

  • Timer Count Start
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Set ReviveHero[Player Number of Dying unit] = (Dying unit)
      • Countdown Timer - Start ReviveTimerArray[Player Number of ReviveHero] as a One-shot timer that will expire in 3.00 seconds
      • Countdown Timer - Create a timer window for ReviveTimerArray[Player Number of ReviveHero] with title Reviverá em...
      • Countdown Timer - Show (Last created timer window)
      • Set ReviveTimerWindowArray[Player Number of ReviveHero] = (Last created timer window)
  • Timer Destroy
    • Events
      • Time - ReviveTimerArray[1] expires
      • Time - ReviveTimerArray[2] expires
      • Time - ReviveTimerArray[3] expires
      • Time - ReviveTimerArray[4] expires
      • Time - ReviveTimerArray[5] expires
      • Time - ReviveTimerArray[6] expires
      • Time - ReviveTimerArray[7] expires
      • Time - ReviveTimerArray[8] expires
      • Time - ReviveTimerArray[9] expires
      • Time - ReviveTimerArray[10] expires
      • Time - ReviveTimerArray[11] expires
      • Time - ReviveTimerArray[12] expires
    • Conditions
    • Actions
      • For each (Integer Variable) from 1 to 12, do (Actions)
        • Loop - Actions
          • If then else
            • If - conditions
              • Remaining time of ReviveTimerArray[Integer Variable] equal to 0
            • Then - Actions
              • Countdown Timer - Destroy ReviveTimerWindowArray[Integer Variable]
              • Custom script: set udg_ReviveTimerWindowArray[Integer Variable] = null
            • Else - Actions
      • Set HRL = (Random point in Region 000 <gen>)
      • Hero - Instantly revive ReviveHero at HRL, Show revival graphics
      • Camera - Pan camera for (Owner of (Reviving Hero)) to HRL over 0.00 seconds
      • Selection - Select (Reviving Hero) for (Owner of (Reviving Hero))
      • Custom script: call RemoveLocation(udg_HRL)
      • Custom script: set udg_HRL = null

That's MPI, but not MUI.
What is a player has multiple heroes? It will bug out.
Although, if a player can have 1 hero only, then you're good to go.
 
JASS Solution

Here is a solution that will handle multiple heroes per player. It is written in JASS however; I don't know if that's what you want.
JASS:
function RevivePlayerCallback takes nothing returns nothing
    local timer Callback=GetExpiredTimer()
    local integer CallbackId=GetHandleId(Callback)
    local unit Hero=LoadUnitHandle(udg_Hashtable,CallbackId,0)
    local timerdialog Window=LoadTimerDialogHandle(udg_Hashtable,CallbackId,1)
    local real X=GetRandomReal(GetRectMinX(gg_rct_Region_000),GetRectMaxX(gg_rct_Region_000))
    local real Y=GetRandomReal(GetRectMinY(gg_rct_Region_000),GetRectMaxY(gg_rct_Region_000))
    call ReviveHero(Hero,X,Y,true)
    if(GetLocalPlayer()==GetOwningPlayer(Hero))then
        call PanCameraTo(X,Y)
        call ClearSelection()
        call SelectUnit(Hero,true)
    endif
    set Hero=null
    call DestroyTimer(Callback)
    call DestroyTimerDialog(Window)
    set Callback=null
    set Window=null
    call FlushChildHashtable(udg_Hashtable,CallbackId)
endfunction

function RevivePlayer takes nothing returns nothing
    local unit Hero=GetTriggerUnit()
    local timer Timer
    local timerdialog Window
    local integer TimerId
    if(IsUnitType(Hero,UNIT_TYPE_HERO))then
        set Timer=CreateTimer()
        set TimerId=GetHandleId(Timer)
        set Window=CreateTimerDialog(Timer)
        call TimerStart(Timer,3.0,false,function RevivePlayerCallback)
        call TimerDialogSetTitle(Window,"Revive")
        call TimerDialogDisplay(Window,true)
        call SaveUnitHandle(udg_Hashtable,TimerId,0,Hero)
        call SaveTimerDialogHandle(udg_Hashtable,TimerId,1,Window)
        set Timer=null
        set Window=null
    endif
    set Hero=null
endfunction
 
Level 4
Joined
Feb 28, 2014
Messages
70
That's MPI, but not MUI.
What is a player has multiple heroes? It will bug out.
Although, if a player can have 1 hero only, then you're good to go.

I never wrote that it's MUI, but for what OP is describing, he wants a MPI trigger and that's what I posted. Anyway I don't think OP knows Jass so setting a UnitID to each hero instead of using Player Number as index will make this trigger MUI. So the different is hardly significant.

Here is a solution that will handle multiple heroes per player. It is written in JASS however; I don't know if that's what you want.
JASS:
function RevivePlayerCallback takes nothing returns nothing
    local timer Callback=GetExpiredTimer()
    local integer CallbackId=GetHandleId(Callback)
    local unit Hero=LoadUnitHandle(udg_Hashtable,CallbackId,0)
    local timerdialog Window=LoadTimerDialogHandle(udg_Hashtable,CallbackId,1)
    local real X=GetRandomReal(GetRectMinX(gg_rct_Region_000),GetRectMaxX(gg_rct_Region_000))
    local real Y=GetRandomReal(GetRectMinY(gg_rct_Region_000),GetRectMaxY(gg_rct_Region_000))
    call ReviveHero(Hero,X,Y,true)
    if(GetLocalPlayer()==GetOwningPlayer(Hero))then
        call PanCameraTo(X,Y)
        call ClearSelection()
        call SelectUnit(Hero,true)
    endif
    set Hero=null
    call DestroyTimer(Callback)
    call DestroyTimerDialog(Window)
    set Callback=null
    set Window=null
    call FlushChildHashtable(udg_Hashtable,CallbackId)
endfunction

function RevivePlayer takes nothing returns nothing
    local unit Hero=GetTriggerUnit()
    local timer Timer
    local timerdialog Window
    local integer TimerId
    if(IsUnitType(Hero,UNIT_TYPE_HERO))then
        set Timer=CreateTimer()
        set TimerId=GetHandleId(Timer)
        set Window=CreateTimerDialog(Timer)
        call TimerStart(Timer,3.0,false,function RevivePlayerCallback)
        call TimerDialogSetTitle(Window,"Revive")
        call TimerDialogDisplay(Window,true)
        call SaveUnitHandle(udg_Hashtable,TimerId,0,Hero)
        call SaveTimerDialogHandle(udg_Hashtable,TimerId,1,Window)
        set Timer=null
        set Window=null
    endif
    set Hero=null
endfunction

I guess that OP has the default WE (I'm 99% he doesn't know there's NewJassGenPack) so you're system won't work with him :p
 
Actually my code will work in the default editor. Just copy the two functions to the map header and create the global variable 'Hashtable' with the type being a hashtable. Don't forget to create the hashtable with InitHashtable. You'll have to use custom script to add the event with RevivePlayer as the function. If you want I can make this easier to use.
 
Level 4
Joined
Feb 28, 2014
Messages
70
Actually my code will work in the default editor. Just copy the two functions to the map header and create the global variable 'Hashtable' with the type being a hashtable. Don't forget to create the hashtable with InitHashtable. You'll have to use custom script to add the event with RevivePlayer as the function. If you want I can make this easier to use.

Oh yea, my bad. It works :p
 
Status
Not open for further replies.
Top