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,945
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
 
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.
 
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
 
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 :)
 
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 =)
 
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
 
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?
 
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
 
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
 
>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:
 
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.
 
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 The Helper:
    alternatively if you not making at least 23 an hour you could work in an Aldi warehouse
  • Varine Varine:
    Yeah I've been thinking about using AI for shit. I'm on vacation next week so I'm going to spend some time reorganizing everything and getting all my shit back in order
  • Varine Varine:
    lol I technically make less than 23 right now because I'm on salary and am there all the time, but it's a lot more than a normal wage still. I also have a meeting soon to renegotiate my pay because I want about a 25% increase to account for what I'm actually doing or a re-evaluation of our duties so that that my responsibilities are more in line with my pay. Depending on how that goes I'm prepared to give notice and move on, I don't mind taking less money so I'd have time for the rest of my life, but I'd rather they just fucking pay me enough to justify the commitment on my end. Plus right now I hold pretty much all the cards since I'm the only one actually qualified for my position.
    +1
  • Varine Varine:
    The other chef was there before me and got his position by virtue of being the only adult when the old general manager got married and didn't want to deal with the kitchen all the time, and happened to be in the position when the GM quit. New GM is fine with front of house but doesn't know enough about the kitchen side to really do anything or notice that I'm the one primarily maintaining it. Last time I left they hired like 3 people to replace me and there was still a noticeable drop in quality, so I got offered like 6 dollars an hour more and a pretty significant summer bonus to come back
  • Varine Varine:
    So honestly even if I leave I think it would last a couple of months until it's obvious that I am not exactly replaceable and then I would be in an even better position.
  • Varine Varine:
    But as of right now I have two other job offers that are reasonably close to what my hourly equivalency would be, and I would probably have more time for my other projects. The gap would be pretty easy to fill up if I had time to do my side jobs. I use to do some catering and private events, personal lessons, consultations, ect, and I charge like 120 an hour for those. But they aren't consistent enough for a full time job, too small of a town. And I'm not allowed to move for another year until my probation is over
  • Varine Varine:
    I guess I could get it transferred, but that seems like a hassle.
  • Varine Varine:
    Plus I have a storage room full of broken consoles I need to fix. I need to build a little reflow oven so I can manufacture some mod chips still, but it'll get there.
    +1
  • Varine Varine:
    I would like to get out of cooking in general at some point in the next ten years, but for the time being I can make decent money and pump that into savings. I've been taking some engineering classes online, but those aren't exactly career oriented at the moment, but I think getting into electronic or computer engineering of some sort would be ideal. I'm just going to keep taking some classes here and there until there's one that I am really into.
    +2
  • The Helper The Helper:
    There is money in fixing and reselling consoles. Problem is people know that so they are doing it
  • The Helper The Helper:
    If you can find a source of broken consoles though you can make money fixing them - sometimes some big money
  • Varine Varine:
    I was buying them on Ebay, but it's pretty competitive, so more recently I've just been telling the thrift stores to call me and I will come take all their electronics they can't sell. I've volunteered there before and people use them like a dump sometimes, and so they just have a massive amount of broken shit they throw away
  • Varine Varine:
    The local GoodWill was pretty into it, surprisingly the animal shelter store was not. The lady I talked to there seemed to think I was trying to steal stuff or something, she wasn't very nice about it. Like I'm just trying to stop you having to throw a bunch of electronics away, if you can sell it great. I'd probably pay you for the broken shit too if you wanted
  • Varine Varine:
    Then I make posts on Facebook yard sale pages sometimes saying I want your old electronics, but Facebook being Facebook people on there are also wary about why I want it, then want a bunch of money like it's going to be very worth it
  • Varine Varine:
    Sooner than later I'm going to get my archives business going a little more. I need some office space that is kind of hard to get at the moment, but without it, I have to be like "Yeah so go ahead and just leave your family heirlooms and hundred year old photographs here at my shitty apartment and give me a thousand dollars, and next month I'll give you a thumb drive. I promise I'll take care of them!"
    +1
  • Varine Varine:
    I can do some things with them at their home, but when people have thousands of slides and very delicate newspaper clippings and things, not really practical. I
  • Varine Varine:
    I would be there for days, even with my camera set up slides can take a long time, and if they want perfect captures I really need to use my scanners that are professionally made for that. My camera rig works well for what it is, but for enlargements and things it's not as good.
  • Varine Varine:
    I've only had a couple clients with that so far, though. I don't have a website or anything yet though.
  • Varine Varine:
    Console repair can be worthwhile, but it's also not a thing I can do at scale in my house. I just don't have room for the equipment. I need an office that I can segregate out for archival and then electronic restoration.
  • Varine Varine:
    But in order for that to be real, I need more time, and for more time I need to work less, and to work less I need a different job, and for a different job I need more money to fall back on so that I can make enough to just pay like, rent and utilities and use my savings to find these projects
    +1
  • Varine Varine:
    Another couple years. I just need to take it slow and it'll get there.
  • jonas jonas:
    any chance to get that stolen money back?
  • jonas jonas:
    Maybe you can do console repair just as a side thing, especially if there's so much competition business might be slow. Or do you need a lot of special equipment for that?
  • jonas jonas:
    I recently bought a used sauna and the preowner told me some component is broken, I took a look and it was just a burnt fuse, really cheap to fix. I was real proud of my self since I usually have two left hands for this kinda stuff :p
  • tom_mai78101 tom_mai78101:
    I am still playing Shapez 2. What an awful thing to happen, Varine, and hopefully everything has been sorted out soon. Always use multi-factor authentication whenever you have the opportunity to do so.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top