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

Hero icons not fading when training

Status
Not open for further replies.
Level 6
Joined
Oct 25, 2010
Messages
203
I've been trying to figure this out but I find this all very confusing. When I train a hero my new hero icons do not fade away. I have made a video to explain it better.

Please see video for details:

You can also see the triggers I am using at the end of the video. I have new Random Hero icons labeled under the constants>techtree and when I train a Random Hero the game knows to disabled the regular heros, but it does not disabled the Random Hero icons allowing players to build an extra hero.

I have also uploaded my map here:
 

Attachments

  • (4)TwistedMeadowsRH2 (1).w3x
    215.4 KB · Views: 46
Level 6
Joined
Oct 25, 2010
Messages
203
@Dr Super Good - when you say game play constants, are you referring to something different than the constants>techtree I mentioned already? In the video I posted at 0:38 you can see my gameplay constants displayed and my heros are already present in my gameplay constants under the techtree, unless I am missing something and you are talking about a different constants than the one I posted about in my OP
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
Why don't you try my approach and then tell me i'm wrong?
Because that stops him training the same hero twice, which is needed. It does not stop him from training the hero due to insufficient town hall development level. The number of heroes you can train in melee is based on town hall tier. Tier 1 = 1 hero, Tier 2 = 2 heroes, Tier 3 = 3 heroes, there is no Tier 4 or above. Heroes that cannot be trained as a result of this show shaded icons in the alter. The problem he is having is that the tier requirement is not working, he can still train the hero even though he has maxed out on heroes for his tier.

Make sure the random hero dummy units are configured like real heroes. It is possible that the hero mechanics only work for training hero units.
 
Level 6
Joined
Oct 25, 2010
Messages
203
Dr super good you are not accurate, the new hero icon will go away when the AM finishes training
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
unfortunately this won't help
JASS:
function ReducePlayerTechMaxAllowed takes player whichPlayer,integer techId,integer limit returns nothing
    local integer oldMax = GetPlayerTechMaxAllowed(whichPlayer, techId)
    if (oldMax < 0 or oldMax > limit) then
        call SetPlayerTechMaxAllowed(whichPlayer, techId, limit)
    endif
endfunction
 
Level 18
Joined
Nov 21, 2012
Messages
835
this is a mini-system I made for you for random hero train
it uses 3 researches to mimic random hero training
to configure: create (or copy from demo map) 3 researches
copy whole "HeroRandomizer" category,
in trigger "CreateRandomHero" you can see your actions to create hero/give scroll of portal/etc
this part can be edited.

  • HeroRandomizerSettings
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set RandomHeroUpgr[1] = Random Hero (tier1)
      • Set RandomHeroUpgr[2] = Random Hero (tier2)
      • Set RandomHeroUpgr[3] = Random Hero (tier3)
      • -------- -------------------- --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Set the max research level of RandomHeroUpgr[1] to 1 for (Player((Integer A)))
          • Player - Set the max research level of RandomHeroUpgr[2] to 0 for (Player((Integer A)))
          • Player - Set the max research level of RandomHeroUpgr[3] to 0 for (Player((Integer A)))
          • -------- -------------------- --------
          • Set WorkingAltar[((Integer A) - 1)] = No unit
      • -------- -------------------- --------
      • -------- -------------------- --------
JASS:
//-----------------------------------------------------------------------------------
function HeroRandomizer_SetActiveUpgrade takes player pla returns nothing
    local integer heroCount = GetPlayerTechCount(pla, 'HERO', true)
    //set active upgrade (random hero) begins
    if heroCount==0 then
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[1], 1)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[2], 0)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[3], 0)
    elseif heroCount==1 then
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[1], 0)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[2], 1)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[3], 0)
    elseif heroCount==2 then
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[1], 0)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[2], 0)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[3], 1)
    else
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[1], 0)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[2], 0)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[3], 0)
    endif
endfunction
//-----------------------------------------------------------------------------------
//-------------------------------RESEARCH TRIGGERS-----------------------------
//-----------------------------------------------------------------------------------
function HeroRandomizer_StartResearch takes nothing returns boolean
    local integer r = GetResearched()
    local player pla = GetOwningPlayer(GetResearchingUnit())
    if r==udg_RandomHeroUpgr[1] or r==udg_RandomHeroUpgr[2] or r==udg_RandomHeroUpgr[3] then
        //check food (5):
        if GetPlayerState(pla, PLAYER_STATE_RESOURCE_FOOD_CAP) - GetPlayerState(pla, PLAYER_STATE_RESOURCE_FOOD_USED) < 5 then
            call IssueImmediateOrderById(GetResearchingUnit(), 851976) // cancel
            call DisplayTextToPlayer(pla, 0, 0, "Not enough food.")
        else
            set udg_WorkingAltar[GetPlayerId(pla)] = GetResearchingUnit() //remember altar
            call SetPlayerTechMaxAllowed(pla, 'HERO', 0) // temporary block training heroes
        endif
    endif
    set pla=null
    return false
endfunction
//-----------------------------------------------------------------------------------
function HeroRandomizer_CancelResearch takes nothing returns boolean
    local integer r = GetResearched()
    local player pla = GetOwningPlayer(GetResearchingUnit())
    if r==udg_RandomHeroUpgr[1] or r==udg_RandomHeroUpgr[2] or r==udg_RandomHeroUpgr[3] then
        set udg_WorkingAltar[GetPlayerId(pla)] = null //null altar
        call SetPlayerTechMaxAllowed(pla, 'HERO', 3) // allow training heroes
    endif
    set pla=null
    return false
endfunction
//-----------------------------------------------------------------------------------
//-------------------------------TRAINING TRIGGERS-----------------------------
//-----------------------------------------------------------------------------------
function HeroRandomizer_StartTrain takes nothing returns boolean
    local player pla = GetOwningPlayer(GetTriggerUnit())
    if IsHeroUnitId(GetTrainedUnitType()) then
        set udg_WorkingAltar[GetPlayerId(pla)] = GetTriggerUnit()
        // block researches and next heroes training (allowed one training at the time only)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[1], 0)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[2], 0)
        call SetPlayerTechMaxAllowed(pla, udg_RandomHeroUpgr[3], 0)
        call SetPlayerTechMaxAllowed(pla, 'HERO', 0) // temporary block training heroes
    endif
    set pla=null
    return false
endfunction
//-----------------------------------------------------------------------------------
function HeroRandomizer_CancelTrain takes nothing returns boolean
    local player pla = GetOwningPlayer(GetTriggerUnit())
    if IsHeroUnitId(GetTrainedUnitType()) then
        set udg_WorkingAltar[GetPlayerId(pla)] = null
        call SetPlayerTechMaxAllowed(pla, 'HERO', 3) // allow training heroes
        call HeroRandomizer_SetActiveUpgrade(pla)
    endif
    set pla=null
    return false
endfunction
//-----------------------------------------------------------------------------------
function HeroRandomizer_FinishTrain takes nothing returns boolean
    local player pla = GetOwningPlayer(GetTrainedUnit())
    if IsUnitType(GetTrainedUnit(), UNIT_TYPE_HERO) then
        set udg_WorkingAltar[GetPlayerId(pla)] = null
        call SetPlayerTechMaxAllowed(pla, 'HERO', 3) // allow training heroes
        call HeroRandomizer_SetActiveUpgrade(pla)    
    endif
    set pla=null
    return false
endfunction
//-----------------------------------------------------------------------------------
function HeroRandomizer_AltarDies takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local integer i=0    
    loop // check if it is altar:
        exitwhen i==bj_MAX_PLAYERS
        if u==udg_WorkingAltar[i] then
            call SetPlayerTechMaxAllowed(GetOwningPlayer(u), 'HERO', 3)
            call HeroRandomizer_SetActiveUpgrade(GetOwningPlayer(u))
            exitwhen true
        endif
        set i=i+1
    endloop
    set u=null
    return false
endfunction
//=======================================================
//=======================================================
function InitTrig_HeroRandomizer takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_RESEARCH_START)
    call TriggerAddCondition(t, Condition(function HeroRandomizer_StartResearch))
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_RESEARCH_CANCEL)
    call TriggerAddCondition(t, Condition(function HeroRandomizer_CancelResearch))
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_TRAIN_START)
    call TriggerAddCondition(t, Condition(function HeroRandomizer_StartTrain))
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_TRAIN_CANCEL)
    call TriggerAddCondition(t, Condition(function HeroRandomizer_CancelTrain))
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_TRAIN_FINISH)
    call TriggerAddCondition(t, Condition( function HeroRandomizer_FinishTrain))
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(t, Condition( function HeroRandomizer_AltarDies))
    set t=null
endfunction

  • CreateRandomHero
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Researched tech-type) Equal to RandomHeroUpgr[1]
          • (Researched tech-type) Equal to RandomHeroUpgr[2]
          • (Researched tech-type) Equal to RandomHeroUpgr[3]
    • Actions
      • -------- ------------------------------- --------
      • -------- your "create random hero" actions here : --------
      • Set x = (Random integer number between 1 and 24)
      • Unit - Create 1 Heros[x] for (Owner of (Researching unit)) at (Position of (Researching unit)) facing Default building facing degrees
      • Hero - Create Scroll of Town Portal and give it to (Last created unit)
      • Unit - Order (Last created unit) to Move To (Rally-Point of (Researching unit) as a point)
      • Set HeroIndex[i] = x
      • Sound - Play Sounds[x] at 100.00% volume, attached to (Last created unit)
      • -------- ------------------------------- --------
      • -------- ++++++++++++++++ --------
      • -------- please do NOT change anything below --------
      • Set WorkingAltar[((Player number of (Owner of (Researching unit))) - 1)] = No unit
      • Player - Limit training of Heroes to 3 for (Owner of (Researching unit))
      • Custom script: call HeroRandomizer_SetActiveUpgrade(GetOwningPlayer(GetResearchingUnit()))
      • Player - Set (Owner of (Researching unit)) Available free Heroes to 0
      • -------- ++++++++++++++++ --------
 

Attachments

  • HeroRandomizer1.00.w3x
    216.5 KB · Views: 35
Level 6
Joined
Oct 25, 2010
Messages
203
Thank you so much for your help! this is a very tricksy little problem I am having lol

I have been testing your trigger setup for the past hour, and there is a small flaw which is not too big of a deal but... say I train my first hero and then reach tier 2, but my first hero dies. When I revive my first hero and then click to train a second random hero while still queuing the 1st one, it allows me to then queue up 3 heros which will allow me to have an extra hero at tier 2. Then if I cancel the training of my 2nd hero, the random hero icon will vanish and not return

I guess your trick will not fully work because you're using normal units as heroes
I dont think that the problem is about whether or not we are using custom units, heros, or upgrades. I have actually tested all 3 now. I originally thought that was the problem too, and tried both custom units and custom heros. But the problem is in the fact that I can not add the "random heros" to the constants>techtree tab and also set it as a custom hero because then it counts the hero as 2 for some reason, and prevents training a 2nd hero.

Your setup is still better than mine though, at least its sort of usable now, so thank you!


I also found another issue. When training a random hero, the food supply does not increase until after the hero is finished training, so say my food is 5/10 and I train a hero, my food stays 5/10 while the hero is training, which then lets me train more units, so that when my hero finishes training I can then have 15/10 food.
 
Last edited:
Level 18
Joined
Nov 21, 2012
Messages
835
it counts the hero as 2 for some reason, and prevents training a 2nd hero.
after training if you replace unit (it removes hero interally) game still treats this 1st hero as yours and tier requirement goes up by 1. So you cannot train real hero and then replace it. It wont work.

I made 2nd version of hero randomizer system for you, check it out ;)

  • HRsettings
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set HRcanceledUnit = No unit
      • Set HRdummy[1] = Random Hero (tier1)
      • Set HRdummy[2] = Random Hero (tier2)
      • Set HRdummy[3] = Random Hero (tier3)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Limit training of Random Hero (tier1) to 1 for (Player((Integer A)))
          • Player - Limit training of Random Hero (tier2) to 0 for (Player((Integer A)))
          • Player - Limit training of Random Hero (tier3) to 0 for (Player((Integer A)))
          • -------- -------------------- --------
          • Set HRheroCount[((Integer A) - 1)] = 0
          • Set HRreviveCount[((Integer A) - 1)] = 0
          • Set HRrevivedByTavern[((Integer A) - 1)] = No unit
          • Set HRreviveInProgress[((Integer A) - 1)] = False
          • Set HRrevivingHero[((Integer A) - 1)] = No unit
          • Set HRtrainInProgress[((Integer A) - 1)] = False
          • Set HRworkingAltar[((Integer A) - 1)] = No unit
  • CreateRandomHero
    • Events
    • Conditions
    • Actions
      • Set x = (Random integer number between 1 and 24)
      • Unit - Create 1 Heros[x] for HRTempPlayer at HRTempPoint facing 0.00 degrees
      • Hero - Create Scroll of Town Portal and give it to (Last created unit)
      • Unit - Order (Last created unit) to Move To HRTempPointRally
      • -------- ---------- --------
      • Sound - Play Sounds[x] at 100.00% volume, attached to (Last created unit)
JASS:
//-------------------------------------------------------------------------------------
function IsUnitAlive takes unit u returns boolean
    return not (GetUnitTypeId(u) == 0 or IsUnitType(u, UNIT_TYPE_DEAD))
endfunction
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
function HeroRandomizer_Block takes player pla returns nothing
    call SetPlayerTechMaxAllowed(pla, 'HERO', 0) // temporary block training heroes
    call SetPlayerTechMaxAllowed(pla, udg_HRdummy[1], 0) //block
    call SetPlayerTechMaxAllowed(pla, udg_HRdummy[2], 0) //block
    call SetPlayerTechMaxAllowed(pla, udg_HRdummy[3], 0) //block
endfunction
//-------------------------------------------------------------------------------------
function HeroRandomizer_Allow takes player pla returns nothing
    //local integer heroCount = GetPlayerTechCount(pla, 'HERO', true) // counts only alive heroes!
    local integer heroCount = udg_HRheroCount[GetPlayerId(pla)]
    if heroCount==0 then
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[1], 1) //allow training
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[2], 0) //block training
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[3], 0) //block
    elseif heroCount==1 then
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[1], 0) //block
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[2], 1) //allow
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[3], 0) //block
    elseif heroCount==2 then
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[1], 0) //block
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[2], 0) //block
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[3], 1) //allow
    else
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[1], 0) //block
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[2], 0) //block
        call SetPlayerTechMaxAllowed(pla, udg_HRdummy[3], 0) //block
    endif
    call SetPlayerTechMaxAllowed(pla, 'HERO', 3) // allow training 3 heroes
endfunction
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
function HR_TrainStart takes nothing returns boolean
    local integer id = GetTrainedUnitType()
    local player pla = GetOwningPlayer(GetTriggerUnit())
    local integer i = GetPlayerId(pla)
    if IsHeroUnitId(id) or id==udg_HRdummy[1] or id==udg_HRdummy[2] or id==udg_HRdummy[3] then
        call HeroRandomizer_Block(pla)
        set udg_HRtrainInProgress[i] = true
        set udg_HRworkingAltar[i] = GetTriggerUnit()
    endif   
    set pla=null
    return false
endfunction
//-------------------------------------------------------------------------------------
function HR_TrainCancel takes nothing returns boolean
    local integer id = GetTrainedUnitType()
    local player pla = GetOwningPlayer(GetTriggerUnit())
    local integer i = GetPlayerId(pla)
    if IsHeroUnitId(id) or id==udg_HRdummy[1] or id==udg_HRdummy[2] or id==udg_HRdummy[3] then
        set udg_HRtrainInProgress[i] = false
        set udg_HRworkingAltar[i] = null
        call HeroRandomizer_Allow(pla)
    endif
    set pla=null
    return false
endfunction
//-------------------------------------------------------------------------------------
function HR_TrainFinish takes nothing returns boolean
    local unit u = GetTrainedUnit()
    local integer id = GetUnitTypeId(u)
    local player pla = GetOwningPlayer(u)
    local integer i = GetPlayerId(pla)
    if IsUnitType(u, UNIT_TYPE_HERO) or id==udg_HRdummy[1] or id==udg_HRdummy[2] or id==udg_HRdummy[3] then
        set udg_HRtrainInProgress[i] = false
        set udg_HRworkingAltar[i] = null
        set udg_HRheroCount[i] = udg_HRheroCount[i] + 1
        call HeroRandomizer_Allow(pla)       
        call SetPlayerState(pla, PLAYER_STATE_RESOURCE_HERO_TOKENS, 0)
    endif
    if id==udg_HRdummy[1] or id==udg_HRdummy[2] or id==udg_HRdummy[3] then
        call KillUnit(u)
        //create random hero actions
        set udg_HRTempPlayer = pla
        set udg_HRTempPoint = GetUnitLoc(u)
        set udg_HRTempPointRally = GetUnitRallyPoint(GetTriggerUnit())       
        call TriggerExecute(gg_trg_CreateRandomHero)
       
    endif
    set u=null
    set pla=null
    return false
endfunction
//-------------------------------------------------------------------------------------
function HR_HeroSold takes nothing returns boolean
    local integer i = GetPlayerId(GetOwningPlayer(GetSoldUnit()))
    if IsUnitType(GetSoldUnit(), UNIT_TYPE_HERO) then
        set udg_HRheroCount[i] = udg_HRheroCount[i] + 1
        call HeroRandomizer_Allow(Player(i))
    endif
    return false
endfunction
//-------------------------------------------------------------------------------------
function HR_WorkingAltarDies takes nothing returns boolean
    local integer i=0   
    loop // check if it is working altar:
        exitwhen i==bj_MAX_PLAYERS
        if GetTriggerUnit()==udg_HRworkingAltar[i] then
            // found:
            set udg_HRtrainInProgress[i] = false
            set udg_HRworkingAltar[i] = null
            set udg_HRreviveInProgress[i] = false       
            set udg_HRrevivingHero[i] = null
            call HeroRandomizer_Allow(Player(i))
            exitwhen true
        endif
        set i=i+1
    endloop
    return false
endfunction
//-------------------------------------------------------------------------------------
//-------------------------------REVIVE TRIGGERS----------------------------------
//-------------------------------------------------------------------------------------
function HR_CheckForQueueCancelRev takes nothing returns nothing
    local integer i = 0
    loop //find playerId:
        exitwhen i==bj_MAX_PLAYERS
        if GetExpiredTimer() == udg_HRtimerRevCanceled[i] then
            exitwhen true
        endif
        set i=i+1
    endloop

    if (not IsUnitAlive(udg_HRworkingAltar[i])) or IsUnitAlive(udg_HRrevivingHero[i]) then // actions in "altar dies" / "finishes reviving"
        call PauseTimer(GetExpiredTimer())
    endif

    if IssueTargetOrder(udg_HRworkingAltar[i], "revive", udg_HRrevivingHero[i]) then
        call IssueImmediateOrderById(udg_HRworkingAltar[i], 851976) // cancel id
        call PauseTimer(GetExpiredTimer())
        // --> here cancel event fires :
        if udg_HRreviveInProgress[i] then
            set udg_HRreviveCount[i] = udg_HRreviveCount[i] - 1
        endif
        if udg_HRreviveCount[i]==0 then
            set udg_HRreviveInProgress[i] = false
        endif
       
        if udg_HRtrainInProgress[i] == false and udg_HRreviveInProgress[i]==false then           
            set udg_HRworkingAltar[i] = null
            set udg_HRrevivingHero[i] = null
            call HeroRandomizer_Allow(Player(i))
        endif
        // --> here cancel event fires : end
    endif           
endfunction
//===========================================
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
function HR_CancelOrder takes nothing returns nothing
    call IssueImmediateOrderById(udg_HRcanceledUnit, 851976)
endfunction
//-------------------------------------------------------------------------
function HR_ReviveStartOrd_Cond takes nothing returns boolean
    local integer ord = GetIssuedOrderId()
    return ord==852027 or ord==852028 or ord==852029 // means "Begin-revive-hero" order given to ALTAR
endfunction
//-------------------------------------------------------------------------
function HR_ReviveStartOrd_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetOwningPlayer(GetOrderTargetUnit())) // hero owner's id
    set udg_HRreviveCount[i] = udg_HRreviveCount[i] + 1
   
    if udg_HRtrainInProgress[i] then //cancel this revive action:
        set udg_HRreviveCount[i] = udg_HRreviveCount[i] - 1
        set udg_HRcanceledUnit = GetOrderedUnit() //altar
        call TimerStart(udg_HRtimerCancel, 0.00, false, function HR_CancelOrder)   
    elseif udg_HRreviveInProgress[i] then //cancel this revive action:
        set udg_HRcanceledUnit = GetOrderedUnit() //altar
        call TimerStart(udg_HRtimerCancel, 0.00, false, function HR_CancelOrder)
    else
        call HeroRandomizer_Block(Player(i))
        set udg_HRreviveInProgress[i] = true
        set udg_HRworkingAltar[i] = GetOrderedUnit()
        set udg_HRrevivingHero[i] = GetOrderTargetUnit()
        set udg_HRrevivedByTavern[i] = null
        //run periodic timer to catch queue revive cancel event
        call TimerStart(udg_HRtimerRevCanceled[i], 1.00, true, function HR_CheckForQueueCancelRev)
    endif
endfunction
//-------------------------------------------------------------------------------------
function HR_RevieveCancel takes nothing returns nothing
    local integer i = GetPlayerId(GetOwningPlayer(GetTriggerUnit())) // hero's owner
   
    if udg_HRreviveInProgress[i] then
        set udg_HRreviveCount[i] = udg_HRreviveCount[i] - 1
    endif
    if udg_HRreviveCount[i]==0 then
        set udg_HRreviveInProgress[i] = false
    endif
   
    if udg_HRtrainInProgress[i] == false and udg_HRreviveInProgress[i]==false then           
        set udg_HRworkingAltar[i] = null
        set udg_HRrevivingHero[i] = null
        call HeroRandomizer_Allow(Player(i))
    endif
endfunction
//-------------------------------------------------------------------------------------
function HR_ReviveFinish takes nothing returns nothing
    local integer i = GetPlayerId(GetOwningPlayer(GetRevivingUnit()))
   
    if udg_HRreviveInProgress[i] and udg_HRrevivedByTavern[i] != GetRevivingUnit() then
        set udg_HRreviveCount[i] = udg_HRreviveCount[i] - 1

        set udg_HRreviveInProgress[i] = false
        set udg_HRworkingAltar[i] = null
        set udg_HRrevivingHero[i] = null
        call HeroRandomizer_Allow(Player(i))
    endif
endfunction
//-------------------------------------------------------------------------------------

function HR_ReviveFromTavern takes nothing returns boolean
    local integer ord = GetIssuedOrderId()
    if ord==852463 or ord==852464 or ord==852465 then // means "instant-revive-hero" order given to TAVERN
        set udg_HRrevivedByTavern[GetPlayerId(GetOwningPlayer(GetOrderTargetUnit()))] = GetOrderTargetUnit()
    endif
    return false
endfunction
//-------------------------------------------------------------------------------------

//==================================================================
function InitTrig_HRSystem takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_TRAIN_START)
    call TriggerAddCondition(t, Condition(function HR_TrainStart))
    set t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_TRAIN_CANCEL)
    call TriggerAddCondition(t, Condition(function HR_TrainCancel))
    set t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_TRAIN_FINISH)
    call TriggerAddCondition(t, Condition(function HR_TrainFinish))
    set t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SELL)
    call TriggerAddCondition(t, Condition( function HR_HeroSold))
    set t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(t, Condition(function HR_WorkingAltarDies))
   
    set t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerAddCondition(t, Condition(function HR_ReviveStartOrd_Cond))
    call TriggerAddAction(t, function HR_ReviveStartOrd_Actions)
    set t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_REVIVE_CANCEL)
    call TriggerAddAction(t, function HR_RevieveCancel)
    set t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_REVIVE_FINISH)
    call TriggerAddAction(t, function HR_ReviveFinish)
    set t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(t, Condition( function HR_ReviveFromTavern))
   
    set t=null
endfunction
 

Attachments

  • HeroRandomizer2.00.w3x
    219.2 KB · Views: 32
Level 6
Joined
Oct 25, 2010
Messages
203
Dude you did it!!!!! Thank you so much! If I could I would donate you some cash, because that must have taken you quite some time. Thanks again!

I've already showed my new map that I'm working on to a few friends and I think that what I am working on could be quite popular. The RH triggers are just one aspect of this new map I am working on, but it was very frustrating trying to work on and test my map for balancing when the RH triggers were broken. Now I can finally get to balancing my map, and hopefully release it to the world soon!!!


Oh I have on last question though, is it possible to give each RH unit a different item, so that only the first hero has a TP? I was able to give each hero different items with my previous triggers, but I can't figure out why it wont work now. I tried adding separate triggers for each hero using "give item to last REPLACED unit" but no luck
 
Level 18
Joined
Nov 21, 2012
Messages
835
Good to hear its working fine for you ;)
  • CreateRandomHero
    • Events
    • Conditions
    • Actions
      • Set x = (Random integer number between 1 and 24)
      • Unit - Create 1 Heros[x] for HRTempPlayer at HRTempPoint facing 0.00 degrees
      • Unit - Order (Last created unit) to Move To HRTempPointRally
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HRheroCount[((Player number of HRTempPlayer) - 1)] Equal to 1
        • Then - Actions
          • -------- iem for 1st hero --------
          • Hero - Create Scroll of Town Portal and give it to (Last created unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HRheroCount[((Player number of HRTempPlayer) - 1)] Equal to 2
            • Then - Actions
              • -------- iem for 2nd hero --------
            • Else - Actions
              • -------- iem for 3rd hero --------
      • -------- ---------- --------
      • Sound - Play Sounds[x] at 100.00% volume, attached to (Last created unit)
its possible to differentiate between 1st, 2nd and third hero like I show you above
good luck with map ;)
 
Level 6
Joined
Oct 25, 2010
Messages
203
awesome man thanks again! Ill be sure to post my map here soon when its a bit more balanced :)
 

Attachments

  • HR triggers.wtg
    13 KB · Views: 49
Last edited:
Status
Not open for further replies.
Top