Snippet Set Unit Maximum HP and Mana

Discussion in 'Systems and Snippets' started by Tom Jones, Jan 24, 2008.

  1. Tom Jones

    Tom Jones N/A

    Ratings:
    +435 / 0 / -0
    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.
     

    Attached Files:

    • Like Like x 6
  2. Insane!

    Insane! Shh I didn't edit this, go away.

    Ratings:
    +121 / 0 / -0
    Yeah can you post the code
    >.<
     
  3. Tom Jones

    Tom Jones N/A

    Ratings:
    +435 / 0 / -0
    Knew I forgot something.
     
  4. duyen

    duyen New Member

    Ratings:
    +214 / 0 / -0
    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
     
  5. Tom Jones

    Tom Jones N/A

    Ratings:
    +435 / 0 / -0
    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.
     
  6. Tom_Kazansky

    Tom_Kazansky --- wraith it ! ---

    Ratings:
    +157 / 0 / -0
    I think I can make an ability that add max life or max mana by percent <= this is good
     
  7. TheDamien

    TheDamien _

    Ratings:
    +332 / 0 / -0
    Maybe instead of:

    I think the link would be helpful for people looking for a Jass version.
     
    • Like Like x 1
  8. Quauhtli

    Quauhtli I have the right to remain silent.

    Ratings:
    +62 / 0 / -0
    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 :)
     
  9. Somatic

    Somatic You can change this now in User CP.

    Ratings:
    +84 / 0 / -1
    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 =)
     
  10. Sil3nt

    Sil3nt SUP?

    Ratings:
    +136 / 0 / -0
    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
     
  11. Sim

    Sim Forum Administrator Staff Member

    Ratings:
    +531 / 0 / -0
    Approved.
     
  12. misterurafag

    misterurafag New Member

    Ratings:
    +0 / 0 / -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?
     
  13. Tom_Kazansky

    Tom_Kazansky --- wraith it ! ---

    Ratings:
    +157 / 0 / -0
    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
     
    • Like Like x 1
  14. misterurafag

    misterurafag New Member

    Ratings:
    +0 / 0 / -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
     
  15. Tom_Kazansky

    Tom_Kazansky --- wraith it ! ---

    Ratings:
    +157 / 0 / -0
    >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:
     
  16. jaybles169

    jaybles169 New Member

    Ratings:
    +2 / 0 / -0
    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.
     
  17. IDF_ALLAH

    IDF_ALLAH New Member

    Ratings:
    +1 / 0 / -0
    Does this work in Percentage as in like a 0.95xhp or like 1.2xhp? or only add/subtract?
     
  18. M4573R

    M4573R New Member

    Ratings:
    +1 / 0 / -0
    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.
     
  19. Jesus4Lyf

    Jesus4Lyf Good Idea™

    Ratings:
    +394 / 0 / -0
    It doesn't work because this method is based off a bug to start with. That bug only applies to max life, max mana and I think it may apply to unit sight range. Go use Bonus instead for other stuff, or something.
     
  20. M4573R

    M4573R New Member

    Ratings:
    +1 / 0 / -0
    Is there something I can do completely within world editor? (no addons)
     

Share This Page