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

Ability leveling help

Status
Not open for further replies.
Level 5
Joined
Jul 17, 2013
Messages
125
Hello, i created trigger throught i can add 7 random hero abilities to hero. How can i level up this spells? Normal skill points doesnt work. How can i ''save'' added spells somewhere and when hero will gain new level, random skill will be leveled up (to max 6 level)? Also i need this get work for multiple heroes (ingame). Some help? Please
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,178
How can i level up this spells?
Either use a place holder hero ability that has no icon but levels up the ability when learnt or you will need to think of some other way to level the hero abilities up. It sounds like you choose the latter.

How can i ''save'' added spells somewhere and when hero will gain new level, random skill will be leveled up (to max 6 level)?
Integer (ability type in GUI) variables can store the ability type identifiers of all abilities learnt. An array could be used for convenience so that the 6 abilities can be accessed more easily. A 2D mapping of the array could be used so that multiple indices for different 6 abilities can be referenced.

When the hero gains a level you get his ability array index (hashtable? Maybe per player?) and then choose randomly one of the 6 abilities (random int from 0 to 5) and level it up. You could use a local array to create a set of abilities that are not level 6 or you could try the easy approach of if the random ability chosen is level 6 then choose the lowest index ability that is not level 6 and level that (not really random but you are probably struggling enough if you cannot generate a subset of the abilities that are not level 6 and choose one randomly).

Some help?
It is not that difficult. The key is arrays since a simple random integer then becomes a completely random element.
 
Level 5
Joined
Jul 17, 2013
Messages
125
Integer (ability type in GUI) variables can store the ability type identifiers of all abilities learnt. An array could be used for convenience so that the 6 abilities can be accessed more easily. A 2D mapping of the array could be used so that multiple indices for different 6 abilities can be referenced.

When the hero gains a level you get his ability array index (hashtable? Maybe per player?) and then choose randomly one of the 6 abilities (random int from 0 to 5) and level it up. You could use a local array to create a set of abilities that are not level 6 or you could try the easy approach of if the random ability chosen is level 6 then choose the lowest index ability that is not level 6 and level that (not really random but you are probably struggling enough if you cannot generate a subset of the abilities that are not level 6 and choose one randomly).

I dont get it, are you able to post here some template please? (or map)
I REALLY dont know how to use Hashtable :/
 
Last edited:

yip

yip

Level 3
Joined
Jan 15, 2014
Messages
69
I'm going to try to make something like Dr Super Good suggested so you can try and see what he means, then edit this post, hold on.

EDIT: Turns out, not being able to enumerate abilities really makes this job a LOT harder.

Well, here it is, works even if heroes level up and enter region 000 (which would be, uh, your arena? well, you can replace that event with whenever you want your heroes to get their 7 random abilities, just make sure it isn't triggered twice for the same hero) at the same time.

I have to say though, this is definitely not the cleanest or best method by any means, I'm sure someone more experienced can make something better and wipe it in my face. Maybe in Jass with hashtables, both of which I know nothing about, and I assume neither do you.

In any case, here are the triggers, for the 7 ability randomizer:

  • Ability Randomizer Switch
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
      • ((Triggering unit) is in HeroesGroup) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HeroCount Less than 100
        • Then - Actions
          • Set HeroCount = (HeroCount + 1)
        • Else - Actions
          • Set HeroCount = 0
      • Set Hero[HeroCount] = (Triggering unit)
      • Trigger - Run Ability Randomizer <gen> (ignoring conditions)
  • Ability Randomizer
    • Events
    • Conditions
    • Actions
      • Set RandomLearningInteger = (Random integer number between 1 and NumberOfSpellsAvailable)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomLearningInteger Equal to 1
          • AbilitiesLearnedSoFar Less than 7
          • (Level of Acid Bomb for Hero[HeroCount]) Less than 1
        • Then - Actions
          • Unit - Add Acid Bomb to Hero[HeroCount]
          • Set AbilitiesLearnedSoFar = (AbilitiesLearnedSoFar + 1)
          • Set HeroAbility[(AbilityCount[HeroCount] + 1)] = Acid Bomb
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomLearningInteger Equal to 2
          • AbilitiesLearnedSoFar Less than 7
          • (Level of Animate Dead for Hero[HeroCount]) Less than 1
        • Then - Actions
          • Unit - Add Animate Dead to Hero[HeroCount]
          • Set AbilitiesLearnedSoFar = (AbilitiesLearnedSoFar + 1)
          • Set HeroAbility[(AbilityCount[HeroCount] + 1)] = Animate Dead
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomLearningInteger Equal to 3
          • AbilitiesLearnedSoFar Less than 7
          • (Level of Attribute Bonus for Hero[HeroCount]) Less than 1
        • Then - Actions
          • Unit - Add Attribute Bonus to Hero[HeroCount]
          • Set AbilitiesLearnedSoFar = (AbilitiesLearnedSoFar + 1)
          • Set HeroAbility[(AbilityCount[HeroCount] + 1)] = Attribute Bonus
        • Else - Actions
      • -------- So on and so forth for ALL spells available. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AbilitiesLearnedSoFar Equal to 7
        • Then - Actions
          • Set AbilitiesLearnedSoFar = 0
        • Else - Actions
          • Trigger - Run (This trigger) (ignoring conditions)
And for the random ability level up...

  • Ability Level Up Switch
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is in HeroesGroup) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LevellingHeroCount Less than 100
        • Then - Actions
          • Set LevellingHeroCount = (LevellingHeroCount + 1)
        • Else - Actions
          • Set LevellingHeroCount = 0
      • Set LevellingHero[LevellingHeroCount] = (Triggering unit)
      • Trigger - Run Ability Level Up <gen> (ignoring conditions)
  • Ability Level Up
    • Events
    • Conditions
    • Actions
      • Set RandomLevellingInteger = (Random integer number between 1 and 7)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of HeroAbility[RandomLevellingInteger] for LevellingHero[LevellingHeroCount]) Less than 6
        • Then - Actions
          • Unit - Set level of HeroAbility[RandomLearningInteger] for LevellingHero[LevellingHeroCount] to ((Level of HeroAbility[RandomLevellingInteger] for LevellingHero[LevellingHeroCount]) + 1)
        • Else - Actions
          • Trigger - Run (This trigger) (ignoring conditions)
If you want, I can embed the map or try to explain something better. It gets a little convoluted storing an ability integer for an ability of the hero integer of the hero. Heugh. Cracked my head a bit.

Variable List - Variable Type:

AbilitiesLearnedSoFar - Integer
Hero - Unit Array
HeroCount - Integer
HeroAbility - Ability Array
AbilityCount - Integer Array
Levelling Hero - Unit Array
Levelling Hero Count - Integer
RandomLearningInteger - Integer
RandomLevellingInteger - Integer

EDIT2: Now that I think about it and reread Super Good's post, yeah, this would be a lot simpler if you used ability IDs (available with JASS and/or hashtables.)... Oh well. Sucks not having an ability type variable. Integer Arrays are really overkill.
 
Last edited:
Level 5
Joined
Jul 17, 2013
Messages
125
I'm going to try to make something like Dr Super Good suggested so you can try and see what he means, then edit this post, hold on.

EDIT: Turns out, not being able to enumerate abilities really makes this job a LOT harder.

Well, here it is, works even if heroes level up and enter region 000 (which would be, uh, your arena? well, you can replace that event with whenever you want your heroes to get their 7 random abilities, just make sure it isn't triggered twice for the same hero) at the same time.

I have to say though, this is definitely not the cleanest or best method by any means, I'm sure someone more experienced can make something better and wipe it in my face. Maybe in Jass with hashtables, both of which I know nothing about, and I assume neither do you.

In any case, here are the triggers, for the 7 ability randomizer:

  • Ability Randomizer Switch
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
      • ((Triggering unit) is in HeroesGroup) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HeroCount Less than 100
        • Then - Actions
          • Set HeroCount = (HeroCount + 1)
        • Else - Actions
          • Set HeroCount = 0
      • Set Hero[HeroCount] = (Triggering unit)
      • Trigger - Run Ability Randomizer <gen> (ignoring conditions)
  • Ability Randomizer
    • Events
    • Conditions
    • Actions
      • Set RandomLearningInteger = (Random integer number between 1 and NumberOfSpellsAvailable)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomLearningInteger Equal to 1
          • AbilitiesLearnedSoFar Less than 7
          • (Level of Acid Bomb for Hero[HeroCount]) Less than 1
        • Then - Actions
          • Unit - Add Acid Bomb to Hero[HeroCount]
          • Set AbilitiesLearnedSoFar = (AbilitiesLearnedSoFar + 1)
          • Set HeroAbility[(AbilityCount[HeroCount] + 1)] = Acid Bomb
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomLearningInteger Equal to 2
          • AbilitiesLearnedSoFar Less than 7
          • (Level of Animate Dead for Hero[HeroCount]) Less than 1
        • Then - Actions
          • Unit - Add Animate Dead to Hero[HeroCount]
          • Set AbilitiesLearnedSoFar = (AbilitiesLearnedSoFar + 1)
          • Set HeroAbility[(AbilityCount[HeroCount] + 1)] = Animate Dead
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RandomLearningInteger Equal to 3
          • AbilitiesLearnedSoFar Less than 7
          • (Level of Attribute Bonus for Hero[HeroCount]) Less than 1
        • Then - Actions
          • Unit - Add Attribute Bonus to Hero[HeroCount]
          • Set AbilitiesLearnedSoFar = (AbilitiesLearnedSoFar + 1)
          • Set HeroAbility[(AbilityCount[HeroCount] + 1)] = Attribute Bonus
        • Else - Actions
      • -------- So on and so forth for ALL spells available. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AbilitiesLearnedSoFar Equal to 7
        • Then - Actions
          • Set AbilitiesLearnedSoFar = 0
        • Else - Actions
          • Trigger - Run (This trigger) (ignoring conditions)
And for the random ability level up...

  • Ability Level Up Switch
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is in HeroesGroup) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LevellingHeroCount Less than 100
        • Then - Actions
          • Set LevellingHeroCount = (LevellingHeroCount + 1)
        • Else - Actions
          • Set LevellingHeroCount = 0
      • Set LevellingHero[LevellingHeroCount] = (Triggering unit)
      • Trigger - Run Ability Level Up <gen> (ignoring conditions)
  • Ability Level Up
    • Events
    • Conditions
    • Actions
      • Set RandomLevellingInteger = (Random integer number between 1 and 7)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of HeroAbility[RandomLevellingInteger] for LevellingHero[LevellingHeroCount]) Less than 6
        • Then - Actions
          • Unit - Set level of HeroAbility[RandomLearningInteger] for LevellingHero[LevellingHeroCount] to ((Level of HeroAbility[RandomLevellingInteger] for LevellingHero[LevellingHeroCount]) + 1)
        • Else - Actions
          • Trigger - Run (This trigger) (ignoring conditions)
If you want, I can embed the map or try to explain something better. It gets a little convoluted storing an ability integer for an ability of the hero integer of the hero. Heugh. Cracked my head a bit.

Variable List - Variable Type:

AbilitiesLearnedSoFar - Integer
Hero - Unit Array
HeroCount - Integer
HeroAbility - Ability Array
AbilityCount - Integer Array
Levelling Hero - Unit Array
Levelling Hero Count - Integer
RandomLearningInteger - Integer
RandomLevellingInteger - Integer

EDIT2: Now that I think about it and reread Super Good's post, yeah, this would be a lot simpler if you used ability IDs (available with JASS and/or hashtables.)... Oh well. Sucks not having an ability type variable. Integer Arrays are really overkill.

Can you please send me map? please please
 

yip

yip

Level 3
Joined
Jan 15, 2014
Messages
69
Here, though I didn't build the map around it so you can't test it. Those are just the bare triggers.
 

Attachments

  • AbilityRandomizerSystem.w3x
    18.2 KB · Views: 83

yip

yip

Level 3
Joined
Jan 15, 2014
Messages
69
No problem, though you should probably consider looking up hashtables because i'm pretty sure this would be a little easier if you stored ability IDs and used those. Glad to have helped!
 
Status
Not open for further replies.
Top