Snippet Set Unit Maximum HP and Mana

Tom Jones

N/A
Reaction score
437
Documentation (Can be found in the attached map as well):
General:
MUI: Depends on usesage.
GUI/JASS: This one is GUI, a JASS version can be found at wc3campaigns by BladeDK
Leaks: Nope.

Requirements:
The custom abilities Max Life Modifier (A000) and Max Mana Modifier (A001).
The GUI triggers Set Max Hp and Set Max Mana.
The variables Loop_Integer, Max_Hp, Max_Mana, Some_Unit.

Import:
Copy/Paste the abilties to your map.
Copy/Paste the triggers to your map.
Check your variables (Ctrl+x) and check if you got all the needed variables.

How to use:
Set a unit to the Some_Unit, set either Max_Hp or Max_Mana to desired value, and run the respective
trigger.

Triggers:
Code:
Set Max Hp
    Events
    Conditions
    Actions
        Set Max_Hp = (Max_Hp - (Integer((Max life of Some_Unit))))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Max_Hp Greater than 0
            Then - Actions
                Set Loop_Integer = ((Max_Hp - (Max_Hp mod 100)) / 100)
                For each (Integer A) from 1 to Loop_Integer, do (Actions)
                    Loop - Actions
                        Unit - Add Max Life Modifier  to Some_Unit
                        Unit - Set level of Max Life Modifier  for Some_Unit to 4
                        Unit - Remove Max Life Modifier  from Some_Unit
                Set Max_Hp = (Max_Hp mod 100)
                Set Loop_Integer = ((Max_Hp - (Max_Hp mod 10)) / 10)
                For each (Integer A) from 1 to Loop_Integer, do (Actions)
                    Loop - Actions
                        Unit - Add Max Life Modifier  to Some_Unit
                        Unit - Set level of Max Life Modifier  for Some_Unit to 3
                        Unit - Remove Max Life Modifier  from Some_Unit
                Set Max_Hp = (Max_Hp mod 10)
                For each (Integer A) from 1 to Max_Hp, do (Actions)
                    Loop - Actions
                        Unit - Add Max Life Modifier  to Some_Unit
                        Unit - Set level of Max Life Modifier  for Some_Unit to 2
                        Unit - Remove Max Life Modifier  from Some_Unit
            Else - Actions
                Set Max_Hp = (0 - Max_Hp)
                Set Loop_Integer = ((Max_Hp - (Max_Hp mod 100)) / 100)
                For each (Integer A) from 1 to Loop_Integer, do (Actions)
                    Loop - Actions
                        Unit - Add Max Life Modifier  to Some_Unit
                        Unit - Set level of Max Life Modifier  for Some_Unit to 7
                        Unit - Remove Max Life Modifier  from Some_Unit
                Set Max_Hp = (Max_Hp mod 100)
                Set Loop_Integer = ((Max_Hp - (Max_Hp mod 10)) / 10)
                For each (Integer A) from 1 to Loop_Integer, do (Actions)
                    Loop - Actions
                        Unit - Add Max Life Modifier  to Some_Unit
                        Unit - Set level of Max Life Modifier  for Some_Unit to 6
                        Unit - Remove Max Life Modifier  from Some_Unit
                Set Max_Hp = (Max_Hp mod 10)
                For each (Integer A) from 1 to Max_Hp, do (Actions)
                    Loop - Actions
                        Unit - Add Max Life Modifier  to Some_Unit
                        Unit - Set level of Max Life Modifier  for Some_Unit to 5
                        Unit - Remove Max Life Modifier  from Some_Unit

Code:
Set Max Mana
    Events
    Conditions
    Actions
        Set Max_Mana = (Max_Mana - (Integer((Max mana of Some_Unit))))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Max_Mana Greater than 0
            Then - Actions
                Set Loop_Integer = ((Max_Mana - (Max_Mana mod 100)) / 100)
                For each (Integer A) from 1 to Loop_Integer, do (Actions)
                    Loop - Actions
                        Unit - Add Max Mana Modifier  to Some_Unit
                        Unit - Set level of Max Mana Modifier  for Some_Unit to 4
                        Unit - Remove Max Mana Modifier  from Some_Unit
                Set Max_Mana = (Max_Mana mod 100)
                Set Loop_Integer = ((Max_Mana - (Max_Mana mod 10)) / 10)
                For each (Integer A) from 1 to Loop_Integer, do (Actions)
                    Loop - Actions
                        Unit - Add Max Mana Modifier  to Some_Unit
                        Unit - Set level of Max Mana Modifier  for Some_Unit to 3
                        Unit - Remove Max Mana Modifier  from Some_Unit
                Set Max_Mana = (Max_Mana mod 10)
                For each (Integer A) from 1 to Max_Mana, do (Actions)
                    Loop - Actions
                        Unit - Add Max Mana Modifier  to Some_Unit
                        Unit - Set level of Max Mana Modifier  for Some_Unit to 2
                        Unit - Remove Max Mana Modifier  from Some_Unit
            Else - Actions
                Set Max_Mana = (0 - Max_Mana)
                Set Loop_Integer = ((Max_Mana - (Max_Mana mod 100)) / 100)
                For each (Integer A) from 1 to Loop_Integer, do (Actions)
                    Loop - Actions
                        Unit - Add Max Mana Modifier  to Some_Unit
                        Unit - Set level of Max Mana Modifier  for Some_Unit to 7
                        Unit - Remove Max Mana Modifier  from Some_Unit
                Set Max_Mana = (Max_Mana mod 100)
                Set Loop_Integer = ((Max_Mana - (Max_Mana mod 10)) / 10)
                For each (Integer A) from 1 to Loop_Integer, do (Actions)
                    Loop - Actions
                        Unit - Add Max Mana Modifier  to Some_Unit
                        Unit - Set level of Max Mana Modifier  for Some_Unit to 6
                        Unit - Remove Max Mana Modifier  from Some_Unit
                Set Max_Mana = (Max_Mana mod 10)
                For each (Integer A) from 1 to Max_Mana, do (Actions)
                    Loop - Actions
                        Unit - Add Max Mana Modifier  to Some_Unit
                        Unit - Set level of Max Mana Modifier  for Some_Unit to 5
                        Unit - Remove Max Mana Modifier  from Some_Unit
Notes:
Thought I might as well upload it in one place instead of having it uploaded five different times.

Tom Jones.
 

Attachments

  • Set Unit Max hp.w3x
    19.1 KB · Views: 1,899

duyen

New Member
Reaction score
214
Mind telling us what's really good about it?

For example:

Code:
This system is good for easily manipulating <Fill in text here> and is simpler then <Fill in text here>.
You get the idea
 

Tom Jones

N/A
Reaction score
437
Mind telling us what's really good about it?

For example:

Code:
This system is good for easily manipulating <Fill in text here> and is simpler then <Fill in text here>.
You get the idea
No I don't. Seems rather pointless, since it's already described in the thread title. And I never, by principle, compare any of my work with anybody else's work.
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
Mind telling us what's really good about it?

For example:

Code:
This system is good for easily manipulating <Fill in text here> and is simpler then <Fill in text here>.
You get the idea
I think I can make an ability that add max life or max mana by percent <= this is good
 

Quauhtli

I have the right to remain silent.
Reaction score
62
I didn't know moderators used GUI :p

And I agree with Anman, I don't really see what this is supposed to do. (Perhaps if some day I actually am not lazy and look at the triggers:rolleyes:)
Set unit maximum hp and mana, does it reset the original hp and replace it with a new value? Like a footman normaly has like 120 hp and you reset it with the trigger which makes the footman now have 250 hp?

I like the idea of this, I'll probably use it to give like a non item power up for the heroes in my campaign when they do an optional quest :)
 

Somatic

You can change this now in User CP.
Reaction score
84
Its useful, espically in zombie survival maps where you can randomise the HP of the zombies, increasing and decreasing by a certain mark such that it really make all zombies look different and unique. Nice work Jones =)
 

Sil3nt

SUP?
Reaction score
134
This is pretty useful instead of setting a heroes hp which could conflict with leveling up stats or obtaining items (which is what i wouldve done cause im so dumb to think of something like this) and its in gui which makes noobs like me understand it =D
 

misterurafag

New Member
Reaction score
0
how did you get the negitive values on your abilities? and i tried to use your method but my unit just dies heres what i put down
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        Unit_Health Equal to 3
    Then - Actions
        For each (Integer A) from 1 to Unit_Health_1, do (Actions)
            Loop - Actions
                Unit - Add Item Life Bonus (Greater) to (Triggering unit)
                Unit - Set level of Item Life Bonus (Greater) for (Triggering unit) to 4
                Unit - Remove Item Life Bonus (Greater) from (Triggering unit)
    Else - Actions
        Do nothing
what did i do wrong?
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
how did you get the negitive values on your abilities? and i tried to use your method but my unit just dies heres what i put down
what did i do wrong?

From level 2: negative values will increase life/mana and positive values will decrease life/mana
Hold Shift and press Enter or Double Click to get negative value
 

misterurafag

New Member
Reaction score
0
ok i did that and edited my trigger a little so it looks like
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        Unit_Health Equal to (7 / 2)
    Then - Actions
        Set Unit_Health_1 = (Unit_Health_1 x Unit_Health)
        For each (Integer A) from 1 to Unit_Health_1, do (Actions)
            Loop - Actions
                Unit - Add Item Life Bonus (Greater) to (Triggering unit)
                Unit - Set level of Item Life Bonus (Greater) for (Triggering unit) to 3
                Unit - Remove Item Life Bonus (Greater) from (Triggering unit)
        For each (Integer A) from 1 to (Custom value of (Triggering unit)), do (Actions)
            Loop - Actions
                Unit - Add Item Life Bonus (Greater) to (Triggering unit)
                Unit - Set level of Item Life Bonus (Greater) for (Triggering unit) to 2
                Unit - Remove Item Life Bonus (Greater) from (Triggering unit)
    Else - Actions
        Do nothing
and when i ran it the health of the unit was originaly 150 and when it comes out it has 1650 health when i want it to have 550 health also it lags a little when it happens is there anyway yo stop this?
where
Unit_Health_1 = units health (at first)
(Custom value of (Triggering unit)) = units health
level of the abilites are
1 = 0
2 = 1
3 = -1
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
>when i ran it the health of the unit was originaly 150 and when it comes out it has 1650 health
I see you have add/remove 1500 times, no doubt you got lag :eek:
>i want it to have 550 health
Check the Unit_Health_1 and the Custom Value of (Trigger Unit), you give Unit_Health_1 HP to Trigger Unit and take away Custom Value of (Trigger Unit) HP from it.
>stop the lag
You should make this ability with more levels, I recommend 9 levels:
Code:
 1 = 0
 2 = -1
 3 = -10
 4 = -100
 5 = -1000
 6 = 1
 7 = 10
 8 = 100
 9 = 1000
So, if you want to increases 1500 HP, you only need to add/remove: 1 times level 5 and 5 times level 4 => 6 times add/remove in total => it should less lag than 1500 times :thup:
 

jaybles169

New Member
Reaction score
2
First off, great trigger, does exactly what I've been looking for. Except one thing. I noticed when the trigger gets called in game the game lags just a little bit, maybe a half second; I'm making like a Hero Defense type of map, and the trigger gets call at the start of each level, so the lag definitely noticeable. If I had to guess at the reason why, it'd be the way I have it set up. It changes the health of created units in a region based on how many people are playing, (kind of like a built in difficulty setter) running the trigger for every mob created, and it gets hung up on that. So I guess I'm wondering if its possible to get this trigger working so it changes the max hp of a unit-type, that way it can be applied before creating the creeps (in a template sort of way), therefore running the trigger once instead of x amount of times. And I'm hoping for a GUI solution, as I dont think I'm commited enough for JASS quite yet. Hope my question makes sense, sorry for the long post. Thanks.

EDIT: Woops, didn't realize how old this is, I was still thinking its 2008 yet when I saw the first posts, so I thought it was recent ><
Either way, if anyone can help me out, would be cool. Thanks.
 

M4573R

New Member
Reaction score
1
I'm using this same method to set damage and health for a unit. Why does it not do anything? Is there some catch I don't know that makes these triggers fail?

I have an ability based off of Item Permanent Damage Increase. I add it to a unit, set the level, then remove it. It doesn't change the damage of the unit at all. Same goes for health.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top