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

[Solved] Give item for every third level [Trigger Editor]

Status
Not open for further replies.
Level 9
Joined
Jun 13, 2010
Messages
365
Hi,
I would like to make a trigger for my RPG map.
What it is about:
Every third level my Hero gains, I wish him to gain a token of permanent bonus damage.

I have tried to make an integer that counts the amounts of levels gained.
Then I wished to divide them into 3, making it count how many tokens the Hero needs to achieve.
But the thing with integers is, if I have gained 5 levels from the same kill and I divide those into 3, I will give 1,66 = 2 integers. And by doing so, I might end up with more damage at max level, than supposed to.

Any suggestions on how to make a simple JASS trigger on how to give a Hero a permanent bonus damage token, for each third level?

It also has to be MUI. But each player has only 1 Hero, so it actually just has to be MPI tbh.
 
I'm not sure what you mean with "I have gained 5 levels from the same kill and I divide those into 3, I will give 1,66 = 2 integers," but if you just need to do something every 3 levels (3, 6, 9, 12), you can use modulo.

JASS:
function CheckLevel takes nothing returns boolean
    if (ModuloInteger(GetHeroLevel(GetTriggerUnit()), 3) == 0) then
        // hero level is 3, 6, 9, 12...
        // do stuff~
    endif
 
    return false
endfunction

//===========================================================================
function InitTrig_LevelUp takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_LEVEL)
    call TriggerAddCondition(t, Condition(function CheckLevel))
endfunction

Making it MPI will be easy. Just make the variables array with the player number as the index.
 
Level 9
Joined
Jun 13, 2010
Messages
365
I'm not sure what you mean with "I have gained 5 levels from the same kill and I divide those into 3, I will give 1,66 = 2 integers," but if you just need to do something every 3 levels (3, 6, 9, 12), you can use modulo.

JASS:
function CheckLevel takes nothing returns boolean
    if (ModuloInteger(GetHeroLevel(GetTriggerUnit()), 3) == 0) then
        // hero level is 3, 6, 9, 12...
        // do stuff~
    endif

    return false
endfunction

//===========================================================================
function InitTrig_LevelUp takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_LEVEL)
    call TriggerAddCondition(t, Condition(function CheckLevel))
endfunction

Making it MPI will be easy. Just make the variables array with the player number as the index.

What I ment was if I have a Hero in level 3 and some how gains 5 levels from killing a high level creature. I didn't want any flaws caused by the integer that evens numbers out. Hard to explain.
Also, I think I misunderstood JASS. I thought it was the basics of editor. I can't script at it will take me forever to find the commands of everything I'm afraid.
Do you have a suggestion on how to use the basics of the trigger editor? (With normal actions etc.)
But thanks for your reply though! :)
 
If you map is one Hero per Player you can save the gained Powerups by Leveling in an Integer-Array. Then at rising a Level check for the difference and create the needed amount.

Here a possible solution:

  • Hero LVL up
    • Ereignisse
      • Unit - Rise a Level
    • Bedingungen
    • Aktionen
      • Set Int = ((Hero level of (Triggering unit)) / 3)
      • Set Int = (Int - Hero_Gained_Powerups[(Player number of (Triggering player))])
      • For each (Integer A) from 1 to Int, do (Actions)
        • Schleifen - Aktionen
          • Hero - Create Foliant of DMG and give it to (Triggering unit)
          • Item - Remove (Last created item)
          • Set Hero_Gained_Powerups[(Player number of (Triggering player))] = (Hero_Gained_Powerups[(Player number of (Triggering player))] + 1)
If you have more than one Hero per Player, than the easiest way is importing a unit indexer to get the correct amount of Powerups for each hero.
 
Level 9
Joined
Jun 13, 2010
Messages
365
If you map is one Hero per Player you can save the gained Powerups by Leveling in an Integer-Array. Then at rising a Level check for the difference and create the needed amount.

Here a possible solution:

  • Hero LVL up
    • Ereignisse
      • Unit - Rise a Level
    • Bedingungen
    • Aktionen
      • Set Int = ((Hero level of (Triggering unit)) / 3)
      • Set Int = (Int - Hero_Gained_Powerups[(Player number of (Triggering player))])
      • For each (Integer A) from 1 to Int, do (Actions)
        • Schleifen - Aktionen
          • Hero - Create Foliant of DMG and give it to (Triggering unit)
          • Item - Remove (Last created item)
          • Set Hero_Gained_Powerups[(Player number of (Triggering player))] = (Hero_Gained_Powerups[(Player number of (Triggering player))] + 1)
If you have more than one Hero per Player, than the easiest way is importing a unit indexer to get the correct amount of Powerups for each hero.

I followed your instructions with the trigger. I then put my Hero on the map with some tomes of experience. When I reached level 12, I had gotten 8 tomes of damage, where I should really have had 3.
Also, the first tome should be given at level 4, but is given past that.
I'm afraid it doesn't work. :/
 
Oh, You wanted first power-up at LVL 4, a little difference (-1 to hero LVL before the /3, for calculation). Okay.
BTW Real -> Integer transformation is not rounded it is cuted (Removes any value behind the . 3.323 -> 3 ,, 3.8 -> 3)
Well the trigger i posted works for me.

I made a test map, Including an UI-Ability showing the current gained Tomes (upto 100).
hope it may help ya.

Hmm, for making this more Trigger-Crossfiring resistant increasing the gained power ups before the Tome gaining might be a good idea. Is include in the test map.

Your problem might be Trigger-Crossfiring, if you copied the trigger correct. (This can happen if we jump into another Trigger with an (for each Integer-A) loop, which i use for the powerup gain, This way the loop end-index can be bursted.
If thats the case just change the loop-Integer to something different like (for each Integer-B) or to any othervalue.
 

Attachments

  • Power up.w3x
    22.1 KB · Views: 50
Last edited:
Level 9
Joined
Jun 13, 2010
Messages
365
Oh, You wanted first power-up at LVL 4, a little difference (-1 to hero LVL before the /3, for calculation). Okay.
BTW Real -> Integer transformation is not rounded it is cuted (Removes any value behind the . 3.323 -> 3 ,, 3.8 -> 3)
Well the trigger i posted works for me.

I made a test map, Including an UI-Ability showing the current gained Tomes (upto 100).
hope it may help ya.

Hmm, for making this more Trigger-Crossfiring resistant increasing the gained power ups before the Tome gaining might be a good idea. Is include in the test map.

Your problem might be Trigger-Crossfiring, if you copied the trigger correct. (This can happen if we jump into another Trigger with an (for each Integer-A) loop, which i use for the powerup gain, This way the loop end-index can be bursted.
If thats the case just change the loop-Integer to something different like (for each Integer-B) or to any othervalue.

Oh ye, I saw an error I made in the calculation. It works. :)
Thanks for the nice help. :) +1
 
Status
Not open for further replies.
Top