• 🏆 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!

How to adjust unit property?

Status
Not open for further replies.
Level 31
Joined
Jun 27, 2008
Messages
2,556
Hello.

1. How to, for example, set unit's life and mana to the amount that is equal to another unit's life and mana? I tried to Set Value, but it didn't help.

2. How to set unit's attack base damage, for example, that is equal to 10% of hero's hit points.

Thanks.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Both can be done by implementing Bonus Mod and SetUnitMaxState.

1) use the lines
call SetUnitMaxState( unit1, UNIT_STATE_MAX_LIFE, GetUnitState( unit2, UNIT_STATE_MAX_LIFE ) )
call SetUnitMaxState( unit1, UNIT_STATE_MAX_MANA, GetUnitState( unit2, UNIT_STATE_MAX_MANA ) )
This will change "unit1"s HP/Mana to be equal to that of "unit2".

2) use the line
call UnitSetBonus( unit, BONUS_DAMAGE, R2I( GetUnitState( hero, UNIT_STATE_MAX_LIFE ) * .1) )
Of course, this is bonus damage, so the base damage has to be 1-1 (and then just subtract 1 from the bonus damage).


Of course, you will need JNGP for that (those systems can be made with GUI if necessary, but if using vJass isn't a problem for you, then this would be easier).
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
And did you implement the libraries I linked to (see top of previous post)? Because the functions I gave work with those.
You also need to setup the libraries. If you follow the instructions in the link ("Implementation Instructions"), it will give you all the required information. If you still have any questions, ask away.
 
Level 31
Joined
Jun 27, 2008
Messages
2,556
Ah, alright. Yes, only those. So how to do it with GUI?

Edit: I managed to deal with hit and mana points. I used a GUI system made by Snippet, it works concerning hp and mana. If someone would be willing to help me out with damage issue, I would appreciate it, even though I could be fine absent it.

Edit: Nevermind. Solved it all. Thanks for the help, ap0.
 
Last edited:
Status
Not open for further replies.
Top