What would be the best way to make heroes learn skills?

Evan1993

Ultra Cool Member
Reaction score
30
Would making a function like this be the best way or is there another better way?
Code:
function randomskill takes integer rawcode returns integer
    local integer ran = GetRandomInt(1,5)
    if rawcode == 'hpal' then
        if ran == 1 then
            return 'AUav'
        elseif ran == 2 then
            return 'ANms'
        elseif ran == 3 then
            return 'AOsh'
        elseif ran == 4 then
            return 'AHbh'
        elseif ran == 5 then
            return 0
        endif
    endif
    return 0
endfunction

Code:
function Trig_LearnSkill_Actions takes nothing returns nothing
    call SelectHeroSkill( GetLevelingUnit(), randomskill(GetUnitTypeId(GetLevelingUnit())))
endfunction

//===========================================================================
function InitTrig_LearnSkill takes nothing returns nothing
    set gg_trg_LearnSkill = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_LearnSkill, EVENT_PLAYER_HERO_LEVEL )
    call TriggerAddAction( gg_trg_LearnSkill, function Trig_LearnSkill_Actions )
endfunction
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
It's a bit too random.

It could mean that some Hero never learns one particular spell.
It could mean the function returns a spell the Hero can't learn yet for level requirements or not yet again because of the two levels difference to learn the same spell.

Assuming that still applies to your map...


Event:
- A unit gains a level
Conditions:
- Unit-type of (Triggering unit) equal to <...>
Actions:
- Hero - Learn skill: <ultimate>
- Hero - Learn skill: <most important skill>
- Hero - Learn skill: <not that important skill>
- Hero - Learn skill: <whatever else he has>
- Hero - Learn skill: <filler>

That's as basic as it gets.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top