• 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.

Rank System

Status
Not open for further replies.
Level 6
Joined
Sep 4, 2007
Messages
157
Hey all This is a Rank System map that i made in jass.

JASS:
function Trig_exp_gain_Actions takes nothing returns nothing
    local integer array xp
    local player p = GetOwningPlayer(GetKillingUnit())
    local unit u = GetKillingUnit()
    // These are the xp you need to get for each rank
    set xp[1] = 0
    set xp[2] = 500
    set xp[3] = 1000
    set xp[4] = 2000
    set xp[5] = 4000
    set xp[6] = 6000
    set xp[7] = 8000
    set xp[8] = 10000
    set xp[9] = 20000
    set xp[10] = 30000
    set xp[11] = 40000
    set xp[12] = 50000
    set xp[13] = 60000
    set xp[14] = 70000
    set xp[15] = 80000
    set xp[16] = 90000
    set xp[17] = 100000
    set xp[18] = 200000
    set xp[19] = 300000
    set xp[20] = 400000
    set xp[21] = 500000
    set xp[22] = 600000
    set xp[23] = 700000
    // you can go to the variables menu and change how much xp is gained for each kill
    set udg_Experience[GetConvertedPlayerId(p)] = udg_Experience[GetConvertedPlayerId(p)] + udg_XP_gained
    call ConditionalTriggerExecute(gg_trg_Update1)
    if udg_Experience[GetConvertedPlayerId(p)] == xp[2] then
        call SetUnitAbilityLevel(u, 'A00N', 2)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[3] then
        call SetUnitAbilityLevel(u, 'A00N', 3)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[4] then
        call SetUnitAbilityLevel(u, 'A00N', 4)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[5] then
        call SetUnitAbilityLevel(u, 'A00N', 5)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[6] then
        call SetUnitAbilityLevel(u, 'A00N', 6)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[7] then
        call SetUnitAbilityLevel(u, 'A00N', 7)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[8] then
        call SetUnitAbilityLevel(u, 'A00N', 8)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[9] then
        call SetUnitAbilityLevel(u, 'A00N', 9)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[10] then
        call SetUnitAbilityLevel(u, 'A00N', 10)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[11] then
        call SetUnitAbilityLevel(u, 'A00N', 11)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[12] then
        call SetUnitAbilityLevel(u, 'A00N', 12)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[13] then
        call SetUnitAbilityLevel(u, 'A00N', 13)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[14] then
        call SetUnitAbilityLevel(u, 'A00N', 14)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[15] then
        call SetUnitAbilityLevel(u, 'A00N', 15)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[16] then
        call SetUnitAbilityLevel(u, 'A00N', 16)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[17] then
        call SetUnitAbilityLevel(u, 'A00N', 17)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[18] then
        call SetUnitAbilityLevel(u, 'A00N', 18)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[19] then
        call SetUnitAbilityLevel(u, 'A00N', 19)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[20] then
        call SetUnitAbilityLevel(u, 'A00N', 20)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[21] then
        call SetUnitAbilityLevel(u, 'A00N', 21)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[22] then
        call SetUnitAbilityLevel(u, 'A00N', 22)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == xp[23] then
        call SetUnitAbilityLevel(u, 'A00N', 23)
        call gain_xp()
        call DisableTrigger( GetTriggeringTrigger() )
    endif
    set p = null
    set u = null
endfunction

//===========================================================================
function InitTrig_exp_gain takes nothing returns nothing
    set gg_trg_exp_gain = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_exp_gain, Player(11), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_exp_gain, function Trig_exp_gain_Actions )
endfunction

That trigger give you the experience when you kill a unit. The experience is set very high 100 for each kill. You can change that in the variables the name of it is Xp_gained.

JASS:
function HeroRanks takes nothing returns nothing
    local string array ranks
    local string array rank_title
    local player p = GetOwningPlayer(GetLastCreatedUnit())
    local unit u = GetLastCreatedUnit()
    // you can change the names of the ranks or remove ranks or you can add more if you want to
    set ranks[1] = "Private"
    set ranks[2] = "Private First Class"
    set ranks[3] = "Specialist"
    set ranks[4] = "Corporal"
    set ranks[5] = "Sergeant"
    set ranks[6] = "Staff Sergeant"
    set ranks[7] = "Sergeant First Class"
    set ranks[8] = "Master Sergeant"
    set ranks[9] = "First Sergeant"
    set ranks[10] = "Sergeant Major"
    set ranks[11] = "Command Sergeant Major"
    set ranks[12] = "Sergeant Major of the Army"
    set ranks[13] = "Second Lieutenant"
    set ranks[14] = "First Lieutenant"
    set ranks[15] = "Captain"
    set ranks[16] = "Major"
    set ranks[17] = "Lieutenant Colonel"
    set ranks[18] = "Colonel"
    set ranks[19] = "Brigadier General"
    set ranks[20] = "Major General"
    set ranks[21] = "Lieutenant General"
    set ranks[22] = "General"
    set ranks[23] = "General of the Army"
    // these are added to your name once you get to the next rank
    set rank_title[1] = "PVT-"
    set rank_title[2] = "PFC-"
    set rank_title[3] = "SPC-"
    set rank_title[4] = "CPL-"
    set rank_title[5] = "SGT-"
    set rank_title[6] = "SSG-"
    set rank_title[7] = "SFC-"
    set rank_title[8] = "MSG-"
    set rank_title[9] = "1SG-"
    set rank_title[10] = "SGM-"
    set rank_title[11] = "CSM-"
    set rank_title[12] = "SMA-"
    set rank_title[13] = "2LT-"
    set rank_title[14] = "1LT"
    set rank_title[15] = "CPT-"
    set rank_title[16] = "MAJ-"
    set rank_title[17] = "LTC-"
    set rank_title[18] = "COL-"
    set rank_title[19] = "BG-"
    set rank_title[20] = "MG-"
    set rank_title[21] = "LTG-"
    set rank_title[22] = "GEN-"
    set rank_title[23] = "GA-"
    if GetUnitAbilityLevel(u, 'A00N') == 1 then
        call SetPlayerName( p, rank_title[1] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[1])
    elseif GetUnitAbilityLevel(u, 'A00N') == 2 then
        call SetPlayerName( p, rank_title[2] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[2])
    elseif GetUnitAbilityLevel(u, 'A00N') == 3 then
        call SetPlayerName( p, rank_title[3] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[3])
    elseif GetUnitAbilityLevel(u, 'A00N') == 4 then
        call SetPlayerName( p, rank_title[4] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[4])
    elseif GetUnitAbilityLevel(u, 'A00N') == 5 then
        call SetPlayerName( p, rank_title[5] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[5])
    elseif GetUnitAbilityLevel(u, 'A00N') == 6 then
        call SetPlayerName( p, rank_title[6] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[6])
    elseif GetUnitAbilityLevel(u, 'A00N') == 7 then
        call SetPlayerName( p, rank_title[7] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[7])
    elseif GetUnitAbilityLevel(u, 'A00N') == 8 then
        call SetPlayerName( p, rank_title[8] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[8])
    elseif GetUnitAbilityLevel(u, 'A00N') == 9 then
        call SetPlayerName( p, rank_title[9] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[9])
    elseif GetUnitAbilityLevel(u, 'A00N') == 10 then
        call SetPlayerName( p, rank_title[10] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[10])
    elseif GetUnitAbilityLevel(u, 'A00N') == 11 then
        call SetPlayerName( p, rank_title[11] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[11])
    elseif GetUnitAbilityLevel(u, 'A00N') == 12 then
        call SetPlayerName( p, rank_title[12] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[12])
    elseif GetUnitAbilityLevel(u, 'A00N') == 13 then
        call SetPlayerName( p, rank_title[13] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[13])
    elseif GetUnitAbilityLevel(u, 'A00N') == 14 then
        call SetPlayerName( p, rank_title[14] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[14])
    elseif GetUnitAbilityLevel(u, 'A00N') == 15 then
        call SetPlayerName( p, rank_title[15] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[15])
    elseif GetUnitAbilityLevel(u, 'A00N') == 16 then
        call SetPlayerName( p, rank_title[16] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[16])
    elseif GetUnitAbilityLevel(u, 'A00N') == 17 then
        call SetPlayerName( p, rank_title[17] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[17])
    elseif GetUnitAbilityLevel(u, 'A00N') == 18 then
        call SetPlayerName( p, rank_title[18] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[18])
    elseif GetUnitAbilityLevel(u, 'A00N') == 19 then
        call SetPlayerName( p, rank_title[19] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[19])
    elseif GetUnitAbilityLevel(u, 'A00N') == 20 then
        call SetPlayerName( p, rank_title[20] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[20])
    elseif GetUnitAbilityLevel(u, 'A00N') == 21 then
        call SetPlayerName( p, rank_title[21] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[21])
    elseif GetUnitAbilityLevel(u, 'A00N') == 22 then
        call SetPlayerName( p, rank_title[22] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[22])
    elseif GetUnitAbilityLevel(u, 'A00N') == 23 then
        call SetPlayerName( p, rank_title[23] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[23])
    endif
    set p = null
    set u = null
endfunction

function gain_xp takes nothing returns nothing
    local string array ranks
    local string array rank_title
    local player p = GetOwningPlayer(GetKillingUnit())
    local unit u = GetKillingUnit()
    set ranks[1] = "Private"
    set ranks[2] = "Private First Class"
    set ranks[3] = "Specialist"
    set ranks[4] = "Corporal"
    set ranks[5] = "Sergeant"
    set ranks[6] = "Staff Sergeant"
    set ranks[7] = "Sergeant First Class"
    set ranks[8] = "Master Sergeant"
    set ranks[9] = "First Sergeant"
    set ranks[10] = "Sergeant Major"
    set ranks[11] = "Command Sergeant Major"
    set ranks[12] = "Sergeant Major of the Army"
    set ranks[13] = "Second Lieutenant"
    set ranks[14] = "First Lieutenant"
    set ranks[15] = "Captain"
    set ranks[16] = "Major"
    set ranks[17] = "Lieutenant Colonel"
    set ranks[18] = "Colonel"
    set ranks[19] = "Brigadier General"
    set ranks[20] = "Major General"
    set ranks[21] = "Lieutenant General"
    set ranks[22] = "General"
    set ranks[23] = "General of the Army"
    set rank_title[1] = "PVT-"
    set rank_title[2] = "PFC-"
    set rank_title[3] = "SPC-"
    set rank_title[4] = "CPL-"
    set rank_title[5] = "SGT-"
    set rank_title[6] = "SSG-"
    set rank_title[7] = "SFC-"
    set rank_title[8] = "MSG-"
    set rank_title[9] = "1SG-"
    set rank_title[10] = "SGM-"
    set rank_title[11] = "CSM-"
    set rank_title[12] = "SMA-"
    set rank_title[13] = "2LT-"
    set rank_title[14] = "1LT"
    set rank_title[15] = "CPT-"
    set rank_title[16] = "MAJ-"
    set rank_title[17] = "LTC-"
    set rank_title[18] = "COL-"
    set rank_title[19] = "BG-"
    set rank_title[20] = "MG-"
    set rank_title[21] = "LTG-"
    set rank_title[22] = "GEN-"
    set rank_title[23] = "GA-"
    if GetUnitAbilityLevel(u, 'A00N') == 1 then
        call SetPlayerName( p, rank_title[1] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[1])
    elseif GetUnitAbilityLevel(u, 'A00N') == 2 then
        call SetPlayerName( p, rank_title[2] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[2])
    elseif GetUnitAbilityLevel(u, 'A00N') == 3 then
        call SetPlayerName( p, rank_title[3] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[3])
    elseif GetUnitAbilityLevel(u, 'A00N') == 4 then
        call SetPlayerName( p, rank_title[4] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[4])
    elseif GetUnitAbilityLevel(u, 'A00N') == 5 then
        call SetPlayerName( p, rank_title[5] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[5])
    elseif GetUnitAbilityLevel(u, 'A00N') == 6 then
        call SetPlayerName( p, rank_title[6] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[6])
    elseif GetUnitAbilityLevel(u, 'A00N') == 7 then
        call SetPlayerName( p, rank_title[7] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[7])
    elseif GetUnitAbilityLevel(u, 'A00N') == 8 then
        call SetPlayerName( p, rank_title[8] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[8])
    elseif GetUnitAbilityLevel(u, 'A00N') == 9 then
        call SetPlayerName( p, rank_title[9] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[9])
    elseif GetUnitAbilityLevel(u, 'A00N') == 10 then
        call SetPlayerName( p, rank_title[10] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[10])
    elseif GetUnitAbilityLevel(u, 'A00N') == 11 then
        call SetPlayerName( p, rank_title[11] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to" + ranks[11])
    elseif GetUnitAbilityLevel(u, 'A00N') == 12 then
        call SetPlayerName( p, rank_title[12] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[12])
    elseif GetUnitAbilityLevel(u, 'A00N') == 13 then
        call SetPlayerName( p, rank_title[13] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[13])
    elseif GetUnitAbilityLevel(u, 'A00N') == 14 then
        call SetPlayerName( p, rank_title[14] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[14])
    elseif GetUnitAbilityLevel(u, 'A00N') == 15 then
        call SetPlayerName( p, rank_title[15] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[15])
    elseif GetUnitAbilityLevel(u, 'A00N') == 16 then
        call SetPlayerName( p, rank_title[16] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[16])
    elseif GetUnitAbilityLevel(u, 'A00N') == 17 then
        call SetPlayerName( p, rank_title[17] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[17])
    elseif GetUnitAbilityLevel(u, 'A00N') == 18 then
        call SetPlayerName( p, rank_title[18] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[18])
    elseif GetUnitAbilityLevel(u, 'A00N') == 19 then
        call SetPlayerName( p, rank_title[19] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[19])
    elseif GetUnitAbilityLevel(u, 'A00N') == 20 then
        call SetPlayerName( p, rank_title[20] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[20])
    elseif GetUnitAbilityLevel(u, 'A00N') == 21 then
        call SetPlayerName( p, rank_title[21] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[21])
    elseif GetUnitAbilityLevel(u, 'A00N') == 22 then
        call SetPlayerName( p, rank_title[22] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[22])
    elseif GetUnitAbilityLevel(u, 'A00N') == 23 then
        call SetPlayerName( p, rank_title[23] + udg_PlayerName[GetConvertedPlayerId(p)])
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + ranks[23])
    endif
    set p = null
    set u = null
endfunction

That part should be pasted in the Custom script part in your triggers

I have 23 ranks set in this you can add or remove ranks or you can change them to names that you want. Also you might want to change how much experience you need for each rank
those are set kinda high.

Any problems you can post it here or private message me
 
Level 4
Joined
Aug 15, 2007
Messages
42
No offense, but this code looks VERY inefficient:

Problem - In every function, you are making the ranks into a local variable, but more than that, you are declaring them EVERY time the function is run. Not only does this mean you are slowing down your functions and the game, but also that if someone wants to edit the ranks, they have to do so in EVERY function.

Solution: Create a trigger that runs on map initialization and then destroys itself, and have a GLOBAL variable (udg) called XP, Ranks, and RankTitle. Declare them the way you had it so that the user can easily edit the code, but delete all of the local variables with XP, Ranks, and RankTitle from the functions.

---

Problem - In "HeroRanks", you are using a super huge if then statement to detect which rank they have attained.

Solution - Get rid of the if/then statements and do:

JASS:
local integer lvl = GetUnitAbilityLevel(u, 'A00N')
        call SetPlayerName( p, rank_title[lvl] + GetPlayerName(p))
        set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
        call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + ranks[lvl])

Then, whichever level it is, it will find it based on the level of your "ability" and display it and set the player's name accordingly.

--

There are a few other problems, but let me see if I can clean it up for you and test it to make sure it still works. Maybe I'm completely wrong, it has been a while since I've done this.
 
Level 6
Joined
Sep 4, 2007
Messages
157
Ok thanks for your input i fixed all those things and heres what i have now 2 triggers

JASS:
function Trig_RankInt_Actions takes nothing returns nothing
    set udg_ranks[1] = "Private"
    set udg_ranks[2] = "Private First Class"
    set udg_ranks[3] = "Specialist"
    set udg_ranks[4] = "Corporal"
    set udg_ranks[5] = "Sergeant"
    set udg_ranks[6] = "Staff Sergeant"
    set udg_ranks[7] = "Sergeant First Class"
    set udg_ranks[8] = "Master Sergeant"
    set udg_ranks[9] = "First Sergeant"
    set udg_ranks[10] = "Sergeant Major"
    set udg_ranks[11] = "Command Sergeant Major"
    set udg_ranks[12] = "Sergeant Major of the Army"
    set udg_ranks[13] = "Second Lieutenant"
    set udg_ranks[14] = "First Lieutenant"
    set udg_ranks[15] = "Captain"
    set udg_ranks[16] = "Major"
    set udg_ranks[17] = "Lieutenant Colonel"
    set udg_ranks[18] = "Colonel"
    set udg_ranks[19] = "Brigadier General"
    set udg_ranks[20] = "Major General"
    set udg_ranks[21] = "Lieutenant General"
    set udg_ranks[22] = "General"
    set udg_ranks[23] = "General of the Army"
    set udg_rank_title[1] = "PVT-"
    set udg_rank_title[2] = "PFC-"
    set udg_rank_title[3] = "SPC-"
    set udg_rank_title[4] = "CPL-"
    set udg_rank_title[5] = "SGT-"
    set udg_rank_title[6] = "SSG-"
    set udg_rank_title[7] = "SFC-"
    set udg_rank_title[8] = "MSG-"
    set udg_rank_title[9] = "1SG-"
    set udg_rank_title[10] = "SGM-"
    set udg_rank_title[11] = "CSM-"
    set udg_rank_title[12] = "SMA-"
    set udg_rank_title[13] = "2LT-"
    set udg_rank_title[14] = "1LT"
    set udg_rank_title[15] = "CPT-"
    set udg_rank_title[16] = "MAJ-"
    set udg_rank_title[17] = "LTC-"
    set udg_rank_title[18] = "COL-"
    set udg_rank_title[19] = "BG-"
    set udg_rank_title[20] = "MG-"
    set udg_rank_title[21] = "LTG-"
    set udg_rank_title[22] = "GEN-"
    set udg_rank_title[23] = "GA-"
    set udg_xp[1] = 0
    set udg_xp[2] = 500
    set udg_xp[3] = 1000
    set udg_xp[4] = 2000
    set udg_xp[5] = 4000
    set udg_xp[6] = 6000
    set udg_xp[7] = 8000
    set udg_xp[8] = 10000
    set udg_xp[9] = 20000
    set udg_xp[10] = 30000
    set udg_xp[11] = 40000
    set udg_xp[12] = 50000
    set udg_xp[13] = 60000
    set udg_xp[14] = 70000
    set udg_xp[15] = 80000
    set udg_xp[16] = 90000
    set udg_xp[17] = 100000
    set udg_xp[18] = 200000
    set udg_xp[19] = 300000
    set udg_xp[20] = 400000
    set udg_xp[21] = 500000
    set udg_xp[22] = 600000
    set udg_xp[23] = 700000
    call DestroyTrigger( gg_trg_RankInt)
endfunction

//===========================================================================
function InitTrig_RankInt takes nothing returns nothing
    set gg_trg_RankInt = CreateTrigger(  )
    call TriggerAddAction( gg_trg_RankInt, function Trig_RankInt_Actions )
endfunction

JASS:
function Trig_exp_gain_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) != 'h007'
endfunction

function HeroRanks takes nothing returns nothing
    local player p = GetTriggerPlayer()
    local unit u = GetSoldUnit()
    local integer lvl = GetUnitAbilityLevel(u, 'A00N')
    call SetPlayerName( p, udg_rank_title[lvl] + GetPlayerName(p))
    set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
    call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "Welcome " + udg_ranks[lvl])
    set p = null
    set u = null
endfunction

function gain_xp takes nothing returns nothing
    local player p = GetOwningPlayer(GetKillingUnit())
    local unit u = GetKillingUnit()
    local integer lvl = GetUnitAbilityLevel(u, 'A00N')
    call SetPlayerName( p, udg_rank_title[lvl] + GetPlayerName(p))
    set udg_Player_Name[GetConvertedPlayerId(p)] = GetPlayerName(p)
    call DisplayTimedTextToPlayer(p, 0, 0, 20.00, "You have been Promoted to " + udg_ranks[lvl])
    set p = null
    set u = null
endfunction

function Trig_exp_gain_Actions takes nothing returns nothing
    local player p = GetOwningPlayer(GetKillingUnit())
    local unit u = GetKillingUnit()
    set udg_Experience[GetConvertedPlayerId(p)] = udg_Experience[GetConvertedPlayerId(p)] + udg_XP_gained
    call ConditionalTriggerExecute(gg_trg_Update1)
    if udg_Experience[GetConvertedPlayerId(p)] == udg_xp[2] then
        call SetUnitAbilityLevel(u, 'A00N', 2)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[3] then
        call SetUnitAbilityLevel(u, 'A00N', 3)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[4] then
        call SetUnitAbilityLevel(u, 'A00N', 4)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[5] then
        call SetUnitAbilityLevel(u, 'A00N', 5)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[6] then
        call SetUnitAbilityLevel(u, 'A00N', 6)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[7] then
        call SetUnitAbilityLevel(u, 'A00N', 7)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[8] then
        call SetUnitAbilityLevel(u, 'A00N', 8)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[9] then
        call SetUnitAbilityLevel(u, 'A00N', 9)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[10] then
        call SetUnitAbilityLevel(u, 'A00N', 10)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[11] then
        call SetUnitAbilityLevel(u, 'A00N', 11)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[12] then
        call SetUnitAbilityLevel(u, 'A00N', 12)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[13] then
        call SetUnitAbilityLevel(u, 'A00N', 13)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[14] then
        call SetUnitAbilityLevel(u, 'A00N', 14)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[15] then
        call SetUnitAbilityLevel(u, 'A00N', 15)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[16] then
        call SetUnitAbilityLevel(u, 'A00N', 16)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[17] then
        call SetUnitAbilityLevel(u, 'A00N', 17)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[18] then
        call SetUnitAbilityLevel(u, 'A00N', 18)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[19] then
        call SetUnitAbilityLevel(u, 'A00N', 19)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[20] then
        call SetUnitAbilityLevel(u, 'A00N', 20)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[21] then
        call SetUnitAbilityLevel(u, 'A00N', 21)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[22] then
        call SetUnitAbilityLevel(u, 'A00N', 22)
        call gain_xp()
    elseif udg_Experience[GetConvertedPlayerId(p)] == udg_xp[23] then
        call SetUnitAbilityLevel(u, 'A00N', 23)
        call gain_xp()
        call DisableTrigger( GetTriggeringTrigger() )
    endif
    set p = null
    set u = null
endfunction

//===========================================================================
function InitTrig_exp_gain takes nothing returns nothing
    set gg_trg_exp_gain = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_exp_gain, Player(11), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_exp_gain, Condition( function Trig_exp_gain_Conditions ) )
    call TriggerAddAction( gg_trg_exp_gain, function Trig_exp_gain_Actions )
endfunction

ok as you can tell the first trigger sets all the globals and the 2nd sets everything when you start and gain levels

The ability i used is made from "Sphere". The variables Experience is a real array and xp_gained is a real and for the other variables you can check the top triggers for them.
 
Last edited:
Status
Not open for further replies.
Top