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,462
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,462
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 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