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

Decrease mana of units [Object Editor Ability problem]

Status
Not open for further replies.
Level 14
Joined
Aug 8, 2010
Messages
1,022
Hello there, guys! I tried to make a system for my map that keeps a unit's max mana the same amount, despite everything.
So, for example, i have a unit and i want it's max mana to be 150 at all the times. And when the hero gains a level or loses/gains an item, i run a trigger that stores the units current max mana - 150 in a variable (the mana that should be removed).
I also have 4 skills. The first one sets the mana to be -1 at level 2, -2 at level 3... -9 at level 10. The first level removes 0 mana. The second one sets the mana to -10,-20...-90, the third one to -100,-200...-900, the fourth one to -1000, -2000... -9000. All the four skills have the first level removing 0 mana.
And, i convert the variable that stores the mana that should be removed to a string variable.

Let's say the mana that has to be removed is 825 - 150 = 675. I should set the first skill to be level 6 (-5), the second skill to be level 8 (-70), the third one to be level 7 (-600) and the fourth one to be level 1 (-0). You get what i want to do? At the end, the mana will be reduced by (-600) + (-70) + (-5) = -675.
To be sure that i get the right values, i make the game display those values as a game message. When the mana needs to be reduced by 675 i get this :
6
8
7
1
(i add +1 because as i stated before - level 1 reduces no mana)

And, my algorithm is right, i get the right values, but the levels don't get changed. I first tried by making them Item abilities, then Unit abilities, then Hero abilities. Nothing happened. I even tried to give the abilities to the unit trough the object editor using "Abilities - Normal". I failed again.

I am just wondering why the levels don't change.

Here are the triggers :
  • Mana decrease
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set ManaDecAbilities[1] = Mana Decrease (units)
      • Set ManaDecAbilities[2] = Mana Decrease (tens)
      • Set ManaDecAbilities[3] = Mana Decrease (hundreds)
      • Set ManaDecAbilities[4] = Mana Decrease (thousends)
  • Mana Dec Init
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Entering unit)) Equal to Electro
    • Actions
      • Unit Group - Add (Entering unit) to ManaDecGroup
      • For each (Integer IntegerLoop) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit - Add ManaDecAbilities[IntegerLoop] to (Entering unit)
  • Mana Dec
    • Events
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is in ManaDecGroup) Equal to True
    • Actions
      • Set ManaDecUnit = (Triggering unit)
      • Trigger - Run Mana Dec Default <gen> (ignoring conditions)
      • For each (Integer IntegerLoop) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit - Set level of ManaDecAbilities[IntegerLoop] for ManaDecUnit to 1
      • Set ManaDecCurrentMana = (Integer((Max mana of ManaDecUnit)))
      • Set ManaDecDecreaseNumber = (ManaDecCurrentMana - ManaDecDefault)
      • Set ManaDecString = (String(ManaDecDecreaseNumber))
      • Set ManaDecStringLength = (Length of ManaDecString)
      • For each (Integer IntegerLoop) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set ManaDecLevels[IntegerLoop] = 1
      • Set ManaDecLevels[1] = (Integer((Substring(ManaDecString, ManaDecStringLength, ManaDecStringLength))))
      • Set ManaDecLevels[2] = (Integer((Substring(ManaDecString, (ManaDecStringLength - 1), (ManaDecStringLength - 1)))))
      • Set ManaDecLevels[3] = (Integer((Substring(ManaDecString, (ManaDecStringLength - 2), (ManaDecStringLength - 2)))))
      • Set ManaDecLevels[4] = (Integer((Substring(ManaDecString, (ManaDecStringLength - 3), (ManaDecStringLength - 3)))))
      • For each (Integer IntegerLoop) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set ManaDecLevels[IntegerLoop] = (ManaDecLevels[IntegerLoop] + 1)
          • Unit - Set level of ManaDecAbilities[IntegerLoop] for ManaDecUnit to ManaDecLevels[IntegerLoop]
          • Game - Display to (All players) the text: (String(ManaDecLevels[IntegerLoop]))
  • Mana Dec Default
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of ManaDecUnit) Equal to Electro
        • Then - Actions
          • Set ManaDecDefault = 150
        • Else - Actions
Thanks in advance!
 
Level 10
Joined
Jun 6, 2007
Messages
392
There's a bug in mana and life bonus abilities. Increasing their level doesn't work, but when removing an ability, it decreases mana/life according to the current level. For example:

Mana(+1) is an ability with 0 bonus mana at level 1, and 1 bonus mana at level 2.

Add ability Mana(+1) to u
increase level of Mana(+1) for u
Remove Mana(+1) from u

That code adds 0 mana (according to level 1), but removes 1 mana (according to current level, 2). You can use this bug to your advantage to decrease mana permanently.
 
Status
Not open for further replies.
Top