• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Healing bonus (gui)

Status
Not open for further replies.
Level 5
Joined
Aug 20, 2015
Messages
133
I am trying to create an ability that gives a unit 25% bonus healing
It kinda worked, if i uses an item which heals for 400 my hero gains 500 health instead
But i suppose coding can be done much better
Any suggestions?
1.26a

p.s. please ignore the fact that this system will also do 25% bonus damage to any unit that loses hitpoints, this is easy to fix

  • usil heal
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) has an item of type Blood Key) Equal to True)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • usil_heal_1st[(Custom value of (Picked unit))] Equal to 0.00
            • Then - Actions
              • Set usil_heal_1st[(Custom value of (Picked unit))] = (Life of (Picked unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • debug Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: (((Name of (Picked unit)) + ( + (String(usil_heal_1st[(Custom value of (Picked unit))])))) + 1st)
                • Else - Actions
              • Skip remaining actions
            • Else - Actions
              • Set usil_heal_2nd[(Custom value of (Picked unit))] = (Life of (Picked unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • debug Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: (((Name of (Picked unit)) + ( + (String(usil_heal_2nd[(Custom value of (Picked unit))])))) + 2nd)
                • Else - Actions
              • Set usil_heal_bonus[(Custom value of (Picked unit))] = (((usil_heal_2nd[(Custom value of (Picked unit))] - usil_heal_1st[(Custom value of (Picked unit))]) x 0.50) + 0.00)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • debug Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: (((Name of (Picked unit)) + ( + (String(usil_heal_bonus[(Custom value of (Picked unit))])))) + bonus)
                • Else - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + usil_heal_bonus[(Custom value of (Picked unit))])
              • Set usil_heal_1st[(Custom value of (Picked unit))] = 0.00
              • Set usil_heal_2nd[(Custom value of (Picked unit))] = 0.00
 
Level 23
Joined
Jun 26, 2020
Messages
1,838
First, what do you mean with "25% bonus healing"? To understand better your trigger.
Second that "Skip remaining actions" is unnecessary, because is in the end of the "if" block, and if the "if" block runs so the "else" block won't run.
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Ideally you would use a Damage Engine or something of the sort to detect a Heal event. That or create custom healing spells instead of using the default Warcraft 3 ones since you can then easily control everything through triggers.

For example, you write a simple HealUnit function in Jass and use that in all of your triggers that contain healing:
vJASS:
function HealUnit takes unit u, real heal returns nothing
    if (UnitHasItemOfTypeBJ(u, itemId)) then
        set heal = heal * 1.25
    endif
    SetWidgetLife(u, GetWidgetLife(u) + heal)
    set u = null
endfunction

Or you could make something similar to that in GUI using global variables to define the heal target/heal amount. Then you run a HealUnit trigger which would use those 2 variables in conjunction with the Item check / heal multiplier stuff to heal your unit the proper amount.
 
Level 5
Joined
Aug 20, 2015
Messages
133
First, what do you mean with "25% bonus healing"? To understand better your trigger.
Second that "Skip remaining actions" is unnecessary, because is in the end of the "if" block, and if the "if" block runs so the "else" block won't run.
hero using Health potion, whcih gives him 100hp
25% bonus heal means that he will get 125hp instead of 100hp
 
Level 5
Joined
Aug 20, 2015
Messages
133
Ideally you would use a Damage Engine or something of the sort to detect a Heal event. That or create custom healing spells instead of using the default Warcraft 3 ones since you can then easily control everything through triggers.

For example, you write a simple HealUnit function in Jass and use that in all of your triggers that contain healing:
vJASS:
function HealUnit takes unit u, real heal returns nothing
    if (UnitHasItemOfTypeBJ(u, itemId)) then
        set heal = heal * 1.25
    endif
    SetWidgetLife(u, GetWidgetLife(u) + heal)
    set u = null
endfunction

Or you could make something similar to that in GUI using global variables to define the heal target/heal amount. Then you run a HealUnit trigger which would use those 2 variables in conjunction with the Item check / heal multiplier stuff to heal your unit the proper amount.
i am total 0 in jass, not ot mention vjass cjass or pjass
aaaaaand yes, im alredy downloaded Heal event
sometimes i need t ask question and answer it myself :D
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Jass/vJass/Lua are basically the same thing, if you understand one then you'll understand all of them. You'll notice slight differences with maybe a word missing/changed here or there but at the end of the day they all use the same API, which means that they all use the same exact Events/Conditions/Actions that you use in triggers. Code isn't as scary as it first seems, you're actually coding whenever you make a trigger in the trigger editor, you're just coding using GUI-a Graphical User Interface that has buttons/icons/lists/search for text, instead of with pure text. GUI is there to make things easier to understand but it's also limiting in that it doesn't offer the full control and efficiency that pure code does.

For example, this line of code seems weird at first, but it's really just the Set Unit Life action:
JASS:
SetWidgetLife(u, GetWidgetLife(u) + heal)
  • Unit - Set life of u to ((Life of u) + heal)

Also, u and heal are local variables in the code, which are not too different from the global variables that you use in your triggers:
  • Set Variable u = some unit
  • Set Variable heal = some real amount

If you wanted to use that HealUnit code that I wrote in your triggers you would do it like this:
  • Set Variable u = some unit
  • Set Variable heal = some real amount
  • Custom script: call HealUnit(udg_u, udg_heal)
"udg_" is necessary to tell the code that you're using User Declared Global variables (ones made in the trigger editor) and not variables made in code.

Anyway, if Heal Event works then all is well :p
 
Last edited:
Status
Not open for further replies.
Top