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.
  • 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
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Sticking with the desserts for now the latest recipe is Fried Apple Pies - https://www.thehelper.net/threads/recipe-fried-apple-pies.194297/
  • The Helper The Helper:
    Finally finding about some of the bots that are flooding the users online - bytespider apparently is a huge offender here - ignores robots.txt and comes in from a ton of different IPs

      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