I have found a Jass Script that resurect heroes. It works great but I havent been able to figure out how to change where the hero reapear. It uses Local variables so I cant use the UI to call on the variable either. I want to change it to a Region called AllianceRez
Didnt know that you could convert normal triggers to jass in the editor. Thanks you for that. Now theres only 1 more problem. I want the countdown window to be shown only for the player that loose the hero. As it is now all players can see it. Not sure where you can edit it. From what I can tell the window is shown when you create it, would be better if you could create a countdown window for the owner of the dying unit only.
I tried what you told me but when i added it to my trigger is said that "expected end of line" so i tried to convert it to pure jass (edit/convert to custom text). It all worked but now the other players are disconnected as soon as a hero dies. My Script looks like this now:
function Trig_Alliance_Death_Conditions takes nothing returns boolean if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true ) ) then return false endif if ( not ( IsUnitAlly(GetTriggerUnit(), Player(10)) == true ) ) then return false endif return true endfunction
function Trig_Alliance_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) * 3 ) set OURTIMER = CreateTimer() call StartTimerBJ( OURTIMER, false, ( I2R(HEROWAIT) )) if(GetOwningPlayer(OURHERO) == GetLocalPlayer()) then call CreateTimerDialogBJ( OURTIMER, GetPlayerName(GetOwningPlayer(OURHERO)) ) set WINDOW = GetLastCreatedTimerDialogBJ() endif call TimerDialogDisplayForPlayerBJ( true, WINDOW, GetOwningPlayer(GetDyingUnit()) ) call PolledWait( HEROWAIT ) call ReviveHeroLoc(OURHERO, GetRectCenter(gg_rct_Alliance_Rez), true ) call PanCameraToTimedLocForPlayer( GetOwningPlayer(OURHERO), GetUnitLoc(OURHERO), 0.60 ) if(GetOwningPlayer(OURHERO) == GetLocalPlayer()) then call DestroyTimerDialog(WINDOW) endif endfunction
//=========================================================================== function InitTrig_Alliance_Death takes nothing returns nothing set gg_trg_Alliance_Death = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Alliance_Death, EVENT_PLAYER_UNIT_DEATH ) call TriggerAddCondition( gg_trg_Alliance_Death, Condition( function Trig_Alliance_Death_Conditions ) ) call TriggerAddAction( gg_trg_Alliance_Death, function Trig_Alliance_Death_Actions ) endfunction
Im not sure whats wrong, and i also tried to do a gui version with if ((owner of (triggering unit)) equals to player1(red)) then do (countdowntimer - create a timerwindow for death_timer(1) with title Resurection) else do (Do nothing)
Same thing happens with your trigger. The other players get disconnected just when the countdown-window is created and shown. When I am player 1 I dont see there window so thats working with the correct time and all. Player 2 sees his timer window but directly after that he gets disconnected. Ive tried with Battle.net and lan with the same result. Could it have something to do with that HEROWAIT is a INTERGER? Perhaps it should be a REAL. Not sure if it matters.
Ive gotten a new ide from a map ive played. Insted of showing the heros lvl in my multiboard I change that line to show the time until he ressurects, when he dies. I think I know how but if not ill ask around in a different channel. Thanks for all your help. But if you can make the jass work it would be even better.
Hmm...so the problem is definitely in the window creation? The disconnects/splits would be caused by the game going out of sync. See, everyone playing a map sort of has their own "games" playing out. Some functions generate "net traffic", or send data to the other players. Using GetLocalPlayer() is risky since you can't really tell what functions require sending data to other people, and if only half send the players send required data....you get problems(disconnects/splits).
In particular, things like timers(which must start at a certain time, and can be registered to events on triggers, etc.) are notorious for causing problems, since they obviously require communication. I don't understand why a timer *window* would generate events though or require talking through the internet. Oh well, perhaps someone with more JASS knowledge can figure it out.
Oh, and I just noticed there was a double-line typo in there. Probably nothing, but if you're totally stumped try copying it again.
Failing that, perhaps this will work? Basically, all the objects(timers, windows, etc.) will be made on ALL people's computers(which has a better chance of preserving the "sync"), but ONLY the "show" event will not be called for all people. If the below code fails....no idea.
Good luck.
Edit: Oh, hey, Player(0) is red, btw, so Player(10) would be "Player 11 - Colour". Not sure if comparing a non-existant player causes problems(10 people in a game would be players 0-9, likely), but just firing off a random thought.
function Trig_Alliance_Death_Conditions takes nothing returns boolean
if(IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO)) and (IsUnitAlly(GetTriggerUnit(), Player(10))) then
return true
endif
return false
endfunction
//===========================================================================
function Trig_Alliance_Death_Actions takes nothing returns nothing
local unit OURHERO = GetDyingUnit()
local timer OURTIMER = CreateTimer()
local timerdialog WINDOW = CreateTimerDialog(OURTIMER)
local player OwningPlayer = GetOwningPlayer(OURHERO)
local player LocalPlayer = GetLocalPlayer()
local integer HEROWAIT = GetHeroLevel(OURHERO)*3
// Start Revive Timer
call TimerStart(OURTIMER, HEROWAIT, false, null)
call TimerDialogSetTitle(WINDOW, GetPlayerName(OwningPlayer))
if(OwningPlayer == LocalPlayer) then
call TimerDialogDisplay(WINDOW, true)
endif
call TriggerSleepAction(HEROWAIT)
call ReviveHero(OURHERO, GetRectCenterX(gg_rct_Alliance_Rez), GetRectCenterY(gg_rct_Alliance_Rez), true)
if(OwningPlayer == LocalPlayer) then
call PanCameraToTimed(GetRectCenterX(gg_rct_Alliance_Rez), GetRectCenterY(gg_rct_Alliance_Rez), 0.60)
endif
// Cleanup Timer/Timer Window
call DestroyTimerDialog(WINDOW)
call DestroyTimer(OURTIMER)
// Nullify Variables
set OURHERO = null
set OURTIMER = null
set WINDOW = null
set OwningPlayer = null
set LocalPlayer = null
endfunction
//===========================================================================
function InitTrig_Alliance_Death takes nothing returns nothing
set gg_trg_Alliance_Death = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Alliance_Death, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Alliance_Death, Condition( function Trig_Alliance_Death_Conditions ) )
call TriggerAddAction( gg_trg_Alliance_Death, function Trig_Alliance_Death_Actions )
endfunction
Good news. From the testing Ive done so far it works. A really big thank you for all the time you must have put down to help me. There is 1 thing thou, I would like the window to show the text "Ressurection" instead of the player name. From what I can tell its changed in this line :
I learned something from playing around with that script. I didn't realize JASS doesn't support local machine variables. Oh well, not a terribly important limitation.
Try something like this:
call TimerDialogSetTitle(WINDOW, "Ressurection")
It likely had an extra ) on it or something, or you didn't use the right type of quotes.