- 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 :
Thanks in advance!
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)
-
Events
-
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
-
Conditions
-
Or - Any (Conditions) are true
-
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)
-
Loop - Actions
-
Events
-
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
-
Loop - Actions
- 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
-
Loop - Actions
- 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]))
-
Loop - Actions
-
Events
-
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
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)