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,913

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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top