• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Revive Hero

Status
Not open for further replies.
Level 10
Joined
Feb 20, 2008
Messages
448
Thats my first try to make a hero revive.....unit type of hero are set within the int!

when a hero die team 1-6 go to 1 spot and 6-12 but atm wanted at least to be able to revive a unit @_@ and i failed this!!!

plz apologize my noob skill and help me hihi lol


JASS:
function Trig_Revive_hero takes nothing returns boolean
    local unit u = GetTriggerUnit()
    // player 0 = player 1 in game & player 6 = player 7 in game 
    // Note player start from 0 to 16 in jass!! 
    //in GUI converted text(jass) you will see player 1in gui  was 1 in jass its 0
    //Here i use preset hero becuz in some map hero can unally other hero 
    //if not you can use Boolean Player as condition :)
    local boolean ok = IsUnitType(u,UNIT_TYPE_HERO) and (GetUnitTypeId(u) == udg_temp_UnitTypes[1]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[2]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[3]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[4]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[5]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[6])
    set u = null
    return ok
endfunction

function Trig_Revive_hero_Actions takes nothing returns nothing
    // here is good hero revive for spell template
    local unit Tunit = GetTriggerUnit()
    // since the point of revive is mostly static i used a premade region
    // i think it would be useless to create a region than destroy it!
    // if you feel confident you can try :P
    local location Loc = GetRectCenter(gg_rct_ReviveRegion)
    local real Time = 10
    // Here we will Loop a Global variable premade in the initialization
    // Please take on look on it so you can understand more the reason of my Loop
    // its way faster and its econimize some line
    // p.s you can correct my comments if they arent true!!
    call PolledWait(Time)
    call ReviveHeroLoc(Tunit, Loc, true)
    set Tunit = null
    call RemoveLocation(Loc)
endfunction

//===========================================================================
function InitTrig_Revive_hero takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( t, function Trig_Revive_hero_Actions )
endfunction
 
Last edited:
ehm.....
1. the location is not removed and leaks.
2. why use global integer var if you can use locals? you should change the udg_Revive_Int to locals.
3. you should change the Trig_Revive_Hero to something like this:
JASS:
function Trig_Revive_Hero takes nothing returns boolean
    if (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[1]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[2]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[3]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[4]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[5]) or (GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[6]) then
        return true
    endif
    return false
endfunction
4. I don't understand one thing, you loop 6 times, checking the same unit in every loop, this will cause the same hero to be revived 6 times.
 
a function stops when you return something...

This never runs:
JASS:
return ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[2] )
return ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[3] )
return ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[4] )
return ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[5] )
return ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[6] )
 
JASS:
return  ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[1] )
return  ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[2] )
return  ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[3] )
return  ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[4] )
return  ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[5] )
return  ( GetUnitTypeId(GetTriggerUnit()) == udg_temp_UnitTypes[6] )

this can't work because the first one returns true or false and skips the rest.
 
Cant you check if the dying you was a hero and owned by a player?

JASS:
function Trig_Revive_hero takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local boolean ok = IsUnitType(u,UNIT_TYPE_HERO) and (IsPlayerAlly(Player(0),GetOwningPlayer(u)) or IsPlayerAlly(Player(6),GetOwningPlayer(u))
    set u = null
    return ok
endfunction

Player(0) and Player(6) is Computer allys for the teams (this just works for 2 teams add more if you have)

M_Vegeta, why dont you use JNGP? you dont have too use the OOP part but the initializer and globals would help you alot
 
Cant you check if the dying you was a hero and owned by a player?

JASS:
function Trig_Revive_hero takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local boolean ok = IsUnitType(u,UNIT_TYPE_HERO) and (IsPlayerAlly(Player(0),GetOwningPlayer(u)) or IsPlayerAlly(Player(6),GetOwningPlayer(u))
    set u = null
    return ok
endfunction

Player(0) and Player(6) is Computer allys for the teams (this just works for 2 teams add more if you have)

M_Vegeta, why dont you use JNGP? you dont have too use the OOP part but the initializer and globals would help you alot

i do use jngp but my jass knowledge isnt complete at all >.> atm i learn fast when i saw an example!! i will try tips i had here i will post feedback in this post!!(sorry for didnt answer topics before i was very busy 2d)

so u mean i dont have to use the LOOP part but i didnt learn about private function & initializer & what u mean by global ?global vars ?


edit : i did remade my trigger so now its look more clean its work now but now im thinking polledwait probly suck!!would it be better if i make any hero have his own timer instead of used polledwait ?

p.s. i suck into making timer any exemple would greatly help me
 
Last edited:
Status
Not open for further replies.
Back
Top