Revival only works for Player 1

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2010
Messages
312
Like the title says, the below revival trigger only works for Player 1 and only creates the window with the players name for everyone else. Am I missing something simple or is this just messed up altogether?

  • Set Revival
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set temp_point = (Position of (Triggering unit))
      • Special Effect - Create a special effect at temp_point using Abilities\Spells\Human\MarkOfChaos\MarkOfChaosTarget.mdl
      • Custom script: call RemoveLocation(udg_temp_point)
      • Set R_PlayerNumber = (Player number of (Owner of (Triggering unit)))
      • Set R_Unit[R_PlayerNumber] = (Triggering unit)
      • Set R_Wait[R_PlayerNumber] = (((Real((Hero level of (Triggering unit)))) x 2.00) + 3.00)
      • Countdown Timer - Start R_Timer[R_PlayerNumber] as a One-shot timer that will expire in R_Wait[R_PlayerNumber] seconds
      • Countdown Timer - Create a timer window for R_Timer[R_PlayerNumber] with title (Name of (Owner of (Triggering unit)))
      • Set R_Player[R_PlayerNumber] = (Last created timer window)
      • Countdown Timer - Show R_Player[R_PlayerNumber]
  • Revive
    • Events
      • Time - R_Timer[1] expires
      • Time - R_Timer[2] expires
      • Time - R_Timer[3] expires
      • Time - R_Timer[4] expires
      • Time - R_Timer[5] expires
      • Time - R_Timer[6] expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set R_MUI = (Integer A)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (R_Unit[R_MUI] is dead) Equal to True
            • Then - Actions
              • If (((Owner of R_Unit[R_MUI]) is an ally of Player 10 (Light Blue)) Equal to True) then do (Set temp_point = (Random point in Humans <gen>)) else do (Do nothing)
              • If (((Owner of R_Unit[R_MUI]) is an ally of Player 11 (Dark Green)) Equal to True) then do (Set temp_point = (Random point in Orcs <gen>)) else do (Do nothing)
              • Hero - Instantly revive R_Unit[R_MUI] at temp_point, Hide revival graphics
              • Unit - Set life of R_Unit[R_MUI] to ((Max life of R_Unit[R_MUI]) x 0.25)
              • Unit - Set mana of R_Unit[R_MUI] to ((Max mana of R_Unit[R_MUI]) x 0.25)
              • Selection - Select R_Unit[R_MUI] for (Player(R_MUI))
              • Camera - Pan camera for (Owner of R_Unit[R_MUI]) to temp_point over 0.50 seconds
              • Special Effect - Create a special effect at temp_point using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Countdown Timer - Destroy R_Player[R_MUI]
              • Custom script: call RemoveLocation(udg_temp_point)
            • Else - Actions
 
Last edited:

Deleted member 219079

D

Deleted member 219079

Can you link me the map file?

Also can you use vJass in your map?
 
The code is likely written in the wrong order. Try this instead:
  • Countdown Timer - Start R_Timer[R_PlayerNumber] as a One-shot timer that will expire in R_Wait[R_PlayerNumber] seconds
  • Countdown Timer - Create a timer window for R_Timer[R_PlayerNumber] with title (Name of (Owner of (Triggering unit)))
  • Set R_Player[R_PlayerNumber] = (Last created timer window)
  • Countdown Timer - Show R_Player[R_PlayerNumber]
You have to set R_Player[R_PlayerNumber] to the last created timer window before you try displaying it. Although, if you want the window to only be displayed for one player, you should use the other GUI function (Show timer window for player).
 
Level 9
Joined
Apr 23, 2010
Messages
312
The code is likely written in the wrong order. Try this instead:
  • Countdown Timer - Start R_Timer[R_PlayerNumber] as a One-shot timer that will expire in R_Wait[R_PlayerNumber] seconds
  • Countdown Timer - Create a timer window for R_Timer[R_PlayerNumber] with title (Name of (Owner of (Triggering unit)))
  • Set R_Player[R_PlayerNumber] = (Last created timer window)
  • Countdown Timer - Show R_Player[R_PlayerNumber]
You have to set R_Player[R_PlayerNumber] to the last created timer window before you try displaying it. Although, if you want the window to only be displayed for one player, you should use the other GUI function (Show timer window for player).

Oops didn't realize that was out of order, fixed that but it didn't help. No I want it to be displayed for everyone.
 

Deleted member 219079

D

Deleted member 219079

Make a trigger called Revive System and go to Edit > Convert to Custom Script
JASS:
function OnExpire takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer i = 0
    loop
        if t == udg_R_Timer[i] then
            if IsPlayerAlly(Player(i), Player(9)) then
                call ReviveHero(udg_R_Unit[i], GetRandomReal(GetRectMinX(gg_rct_Humans),GetRectMaxX(gg_rct_Humans)), GetRandomReal(GetRectMinY(gg_rct_Humans), GetRectMaxY(gg_rct_Humans)), false)
            else
                call ReviveHero(udg_R_Unit[i], GetRandomReal(GetRectMinX(gg_rct_Humans),GetRectMaxX(gg_rct_Humans)), GetRandomReal(GetRectMinY(gg_rct_Orcs), GetRectMaxY(gg_rct_Orcs)), false)
            endif
            call SetUnitState(udg_R_Unit[i], UNIT_STATE_LIFE, GetUnitState(udg_R_Unit[i], UNIT_STATE_MAX_LIFE)*0.25)
            call SetUnitState(udg_R_Unit[i], UNIT_STATE_MANA, GetUnitState(udg_R_Unit[i], UNIT_STATE_MAX_MANA)*0.25)
            if GetLocalPlayer() == Player(i) then
                call ClearSelection()
                call SelectUnit(udg_R_Unit[i], true)
                call PanCameraToTimed(GetUnitX(udg_R_Unit[i]), GetUnitY(udg_R_Unit[i]), 0.5)
            endif
            call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl", GetUnitX(udg_R_Unit[i]), GetUnitY(udg_R_Unit[i])))
            call DestroyTimerDialog(udg_R_Player[i])
            exitwhen true
        endif
        if i == 11 then
            call BJDebugMsg("REVIVE SYSTEM ERROR: Check system code")
            exitwhen true
        endif
        set i = i + 1
    endloop
    call DestroyTimer(t)
    set t = null
endfunction

function OnDeath takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local player p
    local integer i
    if IsUnitType(u, UNIT_TYPE_HERO) then
        set p = GetOwningPlayer(u)
        set i = GetPlayerId(p)
        set udg_R_Unit[i] = u
        set udg_R_Timer[i] = CreateTimer()
        set udg_R_Player[i] = CreateTimerDialog(udg_R_Timer[i])
        call TimerDialogSetTitle(udg_R_Player[i], udg_R_Colors[i]+GetPlayerName(p)+"|r")
        call TimerDialogDisplay(udg_R_Player[i], true)
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl", GetUnitX(u), GetUnitY(u)))
        call TimerStart(udg_R_Timer[i], GetHeroLevel(u)*2 +3, false, function OnExpire)
    endif
    set u = null
    return false
endfunction

//===========================================================================
function InitTrig_Revive_System takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddCondition(t, Condition(function OnDeath))
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
    set udg_R_Colors[0] = "|c00ff0000"
    set udg_R_Colors[1] = "|c000033ff"
    set udg_R_Colors[2] = "|c0000ffff"
    set udg_R_Colors[3] = "|c009900cc"
    set udg_R_Colors[4] = "|c00ffff00"
    set udg_R_Colors[5] = "|c00ff6600"
    set udg_R_Colors[6] = "|c0033ff00"
    set udg_R_Colors[7] = "|c00ff33ff"
    set udg_R_Colors[8] = "|c00999999"
    set udg_R_Colors[9] = "|c0099ccff"
    set udg_R_Colors[10] = "|c00023a02"
    set udg_R_Colors[11] = "|c00663300"
    set t = null
endfunction

Then remove its content and replace it with this.

It works 100% I tested it, for all the players. It even has colored player names :p

+It works with vanilla world editor.

Also if you don't want your WIP stage map to spread out I recommend you to remove the link.
 
Last edited by a moderator:
Level 27
Joined
Sep 26, 2009
Messages
2,474
Make sure you create enough timers - there are two ways to achieve this:

a) Go to variable editor, find the timer array, increase "size" to the amount you use (5 in your case)

b) At map initialization use the custom script:
  • Custom script: set udg_R_Timer[2] = CreateTimer()
The above creates timer and assigns it into the specified variable/array. Start with number 2, as the timer[1] is initialized by default, so there's no need to create it again. You'll have to use the custom script multiple times (either in sequence or via loop), because it creates the timer only for the one specified variable or array slot.


For future reference, timer array is one of the arrays that need to have correctly initialized size, else they have initialized only the first slot (slot [1]). Same thing is with unit groups I think.
 

Deleted member 219079

D

Deleted member 219079

Oh I get it :p

I see you don't like my jass solution that much.
I was once hardcore GUI user like you, I believed I could never learn jass, I even tried it multiple times, with no success. Then one hive user created a tutorial that explained those enough well (and bared my noob questions with which I harassed him for 6 months :p)
But I gotta tell you, once you've been into wc3 modding enough, you'll start getting more interested in jass, just like you start getting interest in girls irl. Then after jass starts to get too clumsy, you'll start looking for 3rd party extensions such as vJass and Wurst, just like you start getting interested in ***** in irl.

Edit:
Don't judge it, I know the triggers are all mashed together.
I didn't look at your triggers, I already removed your map from my PC. Just keep working on the map, it's promising :)
 

Deleted member 219079

D

Deleted member 219079

I harassed Daffa with questions for three days. :3

But even now when I know JASS, I still mostly prefer GUI. For some reason only known to me and my computer.
Only 3? I feel filthy now :'/

Have you tried NewGen WE? It colorizes the jass text and makes it look beautiful :p
 
Level 9
Joined
Apr 23, 2010
Messages
312
Oh I get it :p

I see you don't like my jass solution that much.
I was once hardcore GUI user like you, I believed I could never learn jass, I even tried it multiple times, with no success. Then one hive user created a tutorial that explained those enough well (and bared my noob questions with which I harassed him for 6 months :p)
But I gotta tell you, once you've been into wc3 modding enough, you'll start getting more interested in jass, just like you start getting interest in girls irl. Then after jass starts to get too clumsy, you'll start looking for 3rd party extensions such as vJass and Wurst, just like you start getting interested in ***** in irl.

Edit:

I didn't look at your triggers, I already removed your map from my PC. Just keep working on the map, it's promising :)

It's not that I don't like it, I would just rather use something I know and can modify if need be, still appreciate the help though. Besides, I've been playing and creating maps for this damn game for over 10 years now off and on >.< Might post the map in map development forums idk what else to do with it and could use suggestions.

Use RMUI instead of Int A (you set it anyway, and user defined globals are better). Also never use the one- line If/Then/Else.

Isn't that the same thing basically? Also why is single line ITE worse than the block?
 

Deleted member 219079

D

Deleted member 219079

Oh please do so, community feedback can only improve your map :)
 

Deleted member 219079

D

Deleted member 219079

Okay I'll suggest something, if you represent the map well
 
Level 9
Joined
Apr 23, 2010
Messages
312
No, not the same, Integer A is buggy in nested loops. #2; it forces you to 'Do Nothing' (it is very bad) or write a comment when you could choose not to. And you could copy paste code in multiple argument ITEs. (did I call it right?)

Ok I see your point. So this would be best?
  • For each (Integer R_MUI) from 1 to 6, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (R_Unit[R_MUI] is dead) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(R_MUI)) is an ally of Player 10 (Light Blue)) Equal to True
            • Then - Actions
              • Set temp_point = (Random point in Humans <gen>)
            • Else - Actions
              • Set temp_point = (Random point in Orcs <gen>)
          • Hero - Instantly revive R_Unit[R_MUI] at temp_point, Hide revival graphics
          • Unit - Set life of R_Unit[R_MUI] to ((Max life of R_Unit[R_MUI]) x 0.25)
          • Unit - Set mana of R_Unit[R_MUI] to ((Max mana of R_Unit[R_MUI]) x 0.25)
          • Selection - Select R_Unit[R_MUI] for (Player(R_MUI))
          • Camera - Pan camera for (Owner of R_Unit[R_MUI]) to temp_point over 0.50 seconds
          • Special Effect - Create a special effect at temp_point using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Countdown Timer - Destroy R_Player[R_MUI]
          • Custom script: call RemoveLocation(udg_temp_point)
        • Else - Actions
Yes, ITE's is right :p
 
Status
Not open for further replies.
Top