Torchmodders
Modding => Modding Questions => Topic started by: Haxley on August 02, 2016, 07:25:46 am
-
I've been trying to get a mechanic to work and I just can't seem to get it to register any type of hp?
Basically, I want this weapon to fire a projectile at 100% life, and not otherwise. I used the rifle as a reference and created my item, the skill, the particle, the missile, yadda yadda.
End result, I cannot seem to get a statwatcher to work for HP, Max HP, or HP PCT
Is there a way to get it to actually watch hp percentage?
-
The stat you want is "HP %"
Make sure to declare the stat as a predefined int before you use it, since it's not included in vanilla TL2.
-
Worked a beauty, thanks mate!
Are there any other really useful stats like this that I should know about, and is there a way I could explore them on my own?
Again, thanks a bunch! :D
-
The stat you want is "HP %"
Make sure to declare the stat as a predefined int before you use it, since it's not included in vanilla TL2.
Mind me asking why there's a need to do that? The HP % stat is a static stat already in the game, you can evaluate it with a stat evaluator?
-
Pretty sure it's not defined in vanilla TL2. At least it's not in my MEDIA/STATS/ directory.
-
Are there any other really useful stats like this that I should know about, and is there a way I could explore them on my own?
http://docs.runicgames.com/wiki/Static_Stats
-
Well I'll be damned, never realised the need to (re)declare static stats already known by the game. This could explain why I never got perks to trigger with the PLAYERSTAT task... I always suspected there was a connection between perks and stat watchers.
-
Yep, you need a declaration in MEDIA/STATS/ to associate a hardcoded variable in the executable with a stat object in the statwatcher system. Vanilla TL2 only declares a fraction of the accessible hardcoded variables (list (http://docs.runicgames.com/wiki/Static_Stats)), so you need to declare the others if you want to use them.
Three more notes that may be of interest:
1. The connection between a hardcoded variable and a stat object is one-way. You can read the hardcoded variable via the stat object, but you cannot change its value.
2. The a stat object is, in C parlance, volatile. Its value can change nonprogrammatically, in the middle of a function. If you need a guarantee that the value will be consistent over multiple reads, then you need to copy the value to a custom stat once at the start of your function and read from that.
3. Some of the issues with floats not working well with statwatchers can be overcome by declaring the stat object as a predefined int. The program seems to handle casting the float to int just fine in this context.