Potions heal a % of heroes max life.

Extes

Cool Member
Reaction score
5
Hello theHelper!
So, Im trying to set my map up to only use two types of potions, one for mana, one for health... to do this, I want my potions recovering a % of the heroes max life. (35%)
My current trigger is set up to only go off if
Event
-Item used
Condition
-Item being used) equal to (item carried by (hero manipulating item))
Action
-(Set variable) Potion_life = (max life of (hero manipulating item))
Unit - Set life of (Max life of (hero manipulating item)) to ((percentage life of (Hero manipulating item) to (potion_life / 0.50)

Every time I pop the potion, it full heals. Ive made a dummy potion that doesn't heal for anything at all when the trigger is disabled, but when it is, it full heals... Ive tried dividing by 2.00, and that kills the hero (which is 100% counter productive) Any one have some advice on how to get this rolling? it seems simple, but I cant wrap my head around it enough to get the desired results.

------------------------------Edit
ALL RIGHT!
I kind of got it. Attached is a demo map for feedback. Please let me know if this leaks (though it is very simple, and I know the destroy unit group custom script, I do not know/am not sure of how to get rid of the variable for % of hero manipulating item. I want that part removed in case another hero uses a potion at the same time. Criticize it, pick it apart, let me know how sad it is I wasted a good chunk of time on this. Please please please return me some feedback. Just start the map, and have your units damage the hero below 50% health and pop a potion. tool tips and other cosmetics have not been implemented yet.

View attachment Potion %.w3x
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
There are plenty of items which restore a percentage of health.
You can use these potions and set the time to 0.01 to make them do their effects instantly if they were originally over time.
 

Tamisrah

Active Member
Reaction score
16
I think the problem is, that you mixed percentages and absolute values. You'd want to have

JASS:

set maxlife = GetUnitState(hero,UNIT_STATE_MAX_LIFE)
set life = GetUnitState(hero,UNIT_STATE_LIFE)+maxlife*.35
call SetUnitState(hero,UNIT_STATE_LIFE,life)


You might want to substitute the second line with:
JASS:
set life = Max(GetUnitState(hero,UNIT_STATE_LIFE)+maxlife*.35,maxlife)


Sorry for not giving you the GUI instructions but right now I don't have access to an editor.
(and the "JASS" is more pseudo code than anything for the very same reason)
 

Extes

Cool Member
Reaction score
5
Thank you for the replies!

Accname,
Id like to avoid using those items, but have been strongly considering that as an alternative to triggers. If I cannot get a way to trigger this, that will almost definitely be my resort.

Tamisrah,
I don't know JASS at all, so I unfortunately couldn't use your scripts even as reference points to correct my problem :( If I get a JASS response, Id need the entire code in JASS, I don't want to task anyone with something like that so I'm going to keep trying with the triggers. Unless you felt inclined to write a JASS code that would do this for me, though I wont ask someone to do something for me that I wont do for myself. If I finally decide I cant make this work with the triggers, Ill likely ask for someone to code it, but in the mean time, I'm gonna keep hacking away.
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
I would advice you to avoid triggering effects whenever it is possible, object editor data is much faster and saver to use in many cases. Use triggered effects only if there is no object editor solution.

However, if you need a GUI code for this:
(i havent gotten an editor at hand but there are 2 possibilities)

If you want to use a gui action to set the hitpoints as percent: (i am not sure if it exists but i think it does)
1). get the units current hitpoints in % (there is a gui action for this)
2). add 0.35 to that value
3). set the units hitpoints as percentage to the sum.

If you want to use a GUI action to set the hitpoints exact:
1). get the units current hitpoints in % (there is a gui action for this)
2). add 0.35 to the value.
3). multiply the value with the units max hitpoints.
4). set the units hitpoints to that value.
 

OMGOMGOMG

UMBWGMG (Unidentified Human Being.)
Reaction score
28
If you create a ability like: Item heal 35% then change the ability of the potion heal to 35% instead of lesser or what ever then created a new item that uses the item heal 35% then you add the ability item heal 35% onto the Item: Item heal 35%.

Try doing something like that, it may be confusing (even i don't get it) but it could just 'just' work, ok
 

Extes

Cool Member
Reaction score
5
Accname, you are the third person to suggest using object editor data whenever possible. However, after looking over the items in the object editor and the unit/hero abilities, there is no item that allows you to convert the static health to a percent. Checked Rejuvenation (night elf druid ability) as well as healing salve and like items. None of them allow you to convert over to a %. As such, I'm going to attempt to trigger this again with Accname's suggestions. Thanks in advance, and wish me luck!
 

PrisonLove

Hard Realist
Reaction score
78
Basically you need three variables

ItemType = (Item-type of (item being used))
Hero = (Hero Mainpulating Item)
HealAmnt = (Max_Life of Hero) * 0.35

Then you just do something like this:

Event
-Hero uses an item

Condition
-Item type of (Item Being Used) == ItemType

Action
-Set (Current Life) of Hero to ((Current Life) of Hero + HealAmnt)

I haven't used the editor in a long time but that's the general idea for what you're looking for. Just make sure the actual item in the game is a dummy item that is consumable and doesn't do anything.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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