Set Max HP Problem

RocKNRolL

New Member
Reaction score
0
I have used guides from this forum to learn JASS recently, and i have to say it is awesome because i understood everything!
Tho at the beggining we all know there will be some problems even newbiesh ones.

I have built a function called 'SetUnitMaxLife' which like it's name suppose to set unit max life for the newValue variable.


JASS:
function SetUnitMaxLife takes unit whichUnit, real newValue returns nothing
    call SetUnitState(whichUnit, UNIT_STATE_MAX_LIFE, newValue)
endfunction


Now the function seems quit good to me but i doesn't work - used compiler (JassCraft) and no errors, the function is working but doesnt do what it was built to do, in fact it doesn't do anything :S

I know probably this is a stupid problem, but i still doesn't know the answer :S
Thank you for all the helpers. =]
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
well maybe the problem is not in this function

show the whole code
 

RocKNRolL

New Member
Reaction score
0
Umm to tell you the truth, i do understand what it is written there (a small part :S), but this is extremly difficult!
Isn't there an easier way to increase max life??

By the way W3 didn't crash, it just did not work :S

edit:
@Dinowc:
The main aim is to have a skill that increases the max life of an hero lets say 10 levels by some points (probably depend on the skill level - the higher the bigger the amount of life raised).
But i wanted to try to build the fuction first so i created a trigger that when a hero is entering a region his life will increase by 100 points.

JASS:

function GetUnitMaxLife takes unit whichUnit returns real //working
    return GetUnitState(whichUnit, UNIT_STATE_MAX_LIFE)
endfunction

function SetUnitMaxLife takes unit whichUnit, real newValue returns nothing  //doesn't work
    call SetUnitState(whichUnit, UNIT_STATE_MAX_LIFE, newValue)
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
 local unit u = GetTriggerUnit()
 local real unitlife = GetUnitMaxLife(u)
 local real newunitlife = unitlife + 100.00
 call SetUnitMaxLife(u, newunitlife)
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Untitled_Trigger_001, gg_rct_Region_001 ) //regions name Region001
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
 

saw792

Is known to say things. That is all.
Reaction score
280
It doesn't work because... it doesn't work. You haven't done anything wrong with the code. The only way you can add to max life and max mana is through abilities.
 

Rainther

I guess I should write something of value here...
Reaction score
61
An easy way to increase max hp by a number (not increase in percent) is to steal the Item Ability Life Bonus, turn it into a regular ability and learn the unit this ability. It can have different levels for your purpose.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Use what Rainther said, Item Life Bonus Ability :D
You need to add that ability to the unit, and maybe make many levels on it, to satisfy your Max life needs ;)
 

vypur85

Hibernate
Reaction score
803
> beside that...

This is probably the 20th time I link this.

Easy to use GUI. Only 1 Item Bonus ability. Less than 15 levels. Allows you to set up to 0-99999 max hp.
 

RocKNRolL

New Member
Reaction score
0
> beside that...

This is probably the 20th time I link this.

Easy to use GUI. Only 1 Item Bonus ability. Less than 15 levels. Allows you to set up to 0-99999 max hp.

This link is really good, but i need a skill that will last and won't disappear after learning it, therefore i am tring to take the ideas now..
(ain't going well for now lol).

Edit:
I did it! XD
combined two skills one shown and the other is hidden and used with trigger.
 

Attachments

  • Hp Increase.w3x
    18.8 KB · Views: 123

Tom Jones

N/A
Reaction score
437
Firstly:
SetUnitState(...,UNIT_STATE_MAX_LIFE,...) doesn't work, as already pointed out.

We need an alternative, as already pointed out.

The alternative is to add an item ability that adds life. However these abilities acts a little funny when they have multiple levels.

On level one the ability will function properly. On level 1+n the ability messes up, it'll only add the level 1 bonus, however when removed it'll remove the bonus specified for level 1+n.

Example:
We add the ability to a unit, and set to level 1+n. The unit will only gain the bonus from level 1. We then remove the ability. The unit will lose the supposed bonus from level 1+n.

This means for a unit to gain bonus, the ability must have negative values. For the unit to lose bonus, the ability must have positive values.

Lastly note that this is the only ability to my knowlegde that acts in this way.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top