1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Weave light to take you to your highest hopes - the 6th Special Effect Contest is here!
    Dismiss Notice
  4. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[General] Experienced divided in range

Discussion in 'World Editor Help Zone' started by dimitri231, Aug 5, 2014.

  1. dimitri231

    dimitri231

    Joined:
    Aug 4, 2008
    Messages:
    265
    Resources:
    0
    Resources:
    0
    So, on my map, theres a max of 8 players.
    Everyone controls one hero, thus gains exp.
    How can I make, when a unit dies near 1+ heroes, to not divide the exp by the amount of heroes, but to be the same to all of them, if they are in range?
     
  2. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,827
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    You'd need to disable EXP completely and use your own EXP system which is rather tricky.
     
  3. Mythic

    Mythic

    Media Manager

    Joined:
    Apr 24, 2012
    Messages:
    8,018
    Resources:
    125
    Models:
    108
    Icons:
    6
    Maps:
    3
    Spells:
    6
    Tutorials:
    2
    Resources:
    125
    Unit Dies

    Pick stuff in range
    Add exp
     
  4. dimitri231

    dimitri231

    Joined:
    Aug 4, 2008
    Messages:
    265
    Resources:
    0
    Resources:
    0
    yeah, i tought it would be tricky too.
    anyone has any exp system to recommend?
     
  5. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,114
    Resources:
    0
    Resources:
    0
    There is a rather simple one, I don't remember who is the creator.
     

    Attached Files:

  6. sethmachine

    sethmachine

    Joined:
    Aug 7, 2013
    Messages:
    1,318
    Resources:
    0
    Resources:
    0
    Here is an example of a custom exp system. It's in vJASS and it's not perfect, but basically it gets fired when a creep dies.

    You wouldn't be able to copy and paste it into your map, but rather you can sort of see the functions and structure your custom exp system would need.

    Basically when a creep dies, fire a function on it. Calculate how much exp each hero should gain, then loop through all players. If their hero is in X range of the dead creep, then add the appropriate amount of exp to that hero. You will have to disable normal exp gain as others have mentioned.

    Code (vJASS):

    library ExpTrig requires CreepRegionTable

    globals
        private real EXP_RANGE = 1000.0
    endglobals

    function expExec takes Monster creep returns nothing
        local integer i = 0 //loop through all the players
        local integer j = 0 //loop through party and farm monsters
        local texttag tt //show the exp gained by each monster
        local PlayerData pd
        local Monster pm
        local unit m
        local unit pc
        local unit u = creep.u
        local integer expGain = GetHeroLevel(creep.u) * 10
        loop
            exitwhen i == TOTAL_PLAYERS
            set pd = playerDatum[i]
            set pc = pd.pc.u
            if IsUnitInRange(pc, u, EXP_RANGE) then //check to see if monster master is in range
                set j = 0
                //give the player some gold for now
                call SetPlayerState(players[i], PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(players[i], PLAYER_STATE_RESOURCE_GOLD) + expGain)
                loop //loop through the party and make sure each monster is in range
                    exitwhen j == MAX_PARTY_SIZE
                    if pd.party.monsters[j] != 0 then
                        set pm = pd.party.monsters[j]
                        set m = pm.u
                        if IsUnitInRange(m, u, EXP_RANGE) and not pm.isDead() then
                            if GetHeroLevel(m) < pm.maxLvl then
                                call printl(I2S(pm.maxLvl))
                                call print(pm.toString())
                                set tt = CreateTextTag()
                                call SetTextTagText(tt, "Exp +" + I2S(R2I(expGain)), 0.02)
                                call SetTextTagVisibility(tt, false) //hide text tag
                                if players[i] == GetLocalPlayer() then //show tag only if its the owning player
                                    call SetTextTagVisibility (tt, true)
                                endif
                                call SetTextTagPosUnit(tt, m, 0)
                                call SetTextTagColor(tt, 190, 0, 255, 255)
                                call SetTextTagVelocity(tt, 0, 0.04)
                                call SetTextTagPermanent(tt, false)
                                call SetTextTagLifespan(tt, 3)
                                call SetTextTagFadepoint(tt, 2)
                                call AddHeroXP(m, expGain, true)
                                set tt = null
                            endif
                        endif
                    endif
                    set j = j + 1
                endloop
            endif
            set i = i + 1
        endloop
    endfunction

    endlibrary
     
     
  7. dimitri231

    dimitri231

    Joined:
    Aug 4, 2008
    Messages:
    265
    Resources:
    0
    Resources:
    0
    My map has over 100 units, how would I setup 100 different exp amounts?
     
  8. sethmachine

    sethmachine

    Joined:
    Aug 7, 2013
    Messages:
    1,318
    Resources:
    0
    Resources:
    0
    You could assign exp based on the level of the creep. So something like

    Code (vJASS):

    set expGain = GetUnitLevel(creep) * 10 //creeps 10 times their level for experience when killed
     


    Or you could use a hashtable / Table to store how much exp is given for each creep.

    Code (vJASS):

    set expTable['hfoo'] = 50 //50 exp for killing a footman
    set expTable['Hpal'] = 100 //100 exp for killing a human paladin
     


    So when a unit dies, you get its unit type id and then pass it as a key to the Table. It will then return the base exp for that unit. Then do whatever modifiers you want (e.g. a scroll of experience which boosts exp gain, or perhaps your heroes gain less exp the higher level they are).
     
  9. dimitri231

    dimitri231

    Joined:
    Aug 4, 2008
    Messages:
    265
    Resources:
    0
    Resources:
    0
    Im sorry, i dont understand vjass that much, how would i make the trigger recognise the dying unit, and search the hashtable for the exp value?
     
  10. Mythic

    Mythic

    Media Manager

    Joined:
    Apr 24, 2012
    Messages:
    8,018
    Resources:
    125
    Models:
    108
    Icons:
    6
    Maps:
    3
    Spells:
    6
    Tutorials:
    2
    Resources:
    125
    The first option he gave is much easier, based on level.
     
  11. sethmachine

    sethmachine

    Joined:
    Aug 7, 2013
    Messages:
    1,318
    Resources:
    0
    Resources:
    0
    Assuming you use a Unit Dies - Owned by Neutral Hostile, you can get the unit type and exp like this

    Code (vJASS):

    local unit u = GetDyingUnit()
    local integer unitType = GetUnitTypeId(u)
    local integer expGain = expTable[unitType]
     


    So if a footman died,
    unitType = 'hfoo'
    .

    But you should listen to CM and probably keep it simple for now. Just use the level of the unit to determine how much exp to dole out.
     
    Last edited: Aug 6, 2014
  12. Mythic

    Mythic

    Media Manager

    Joined:
    Apr 24, 2012
    Messages:
    8,018
    Resources:
    125
    Models:
    108
    Icons:
    6
    Maps:
    3
    Spells:
    6
    Tutorials:
    2
    Resources:
    125
    Indeed, it is what Blizzard uses anyways. If I may suggest, around 150% exp for heroes killed.