• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

How do I set Max health/stamina to a CVar?

In this case here, for a buff:

<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="blockperc" operation="set" value="@ ? "/>

<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="blockperc" operation="divide" value="10"/>
<passive_effect name="HealthMaxBlockage" operation="base_add" value="@blockperc"/>

What should I use? I want my buff to reserve 10% of my max health.

 
<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="TotalHealth" operation="set" value="200"/>
<passive_effect name="HealthMax" operation="base_set" value="@TotalHealth"/>


I set a cvar to a number, then use that passive to set the health to that cvar, then i can do math to that cvar and it writes that final number to maxhealth. You'd have to have a health cvar, a block percent cvar, then also a block amount cvar, and do math between the two and write the final back to the health cvar.

Something like this, with each name as a it's own cvar:

Totalhealth  = 100
BlockPerc = .1
Totalhealth x BlockPerc = TotalBlock
Totalhealth - TotalBlock = FinalNumber
Totalhealth = FinalNumber

Could be another easier way, but my tired brain isn't working 100% tonight, so this is what i got. lol

 
<buff name="get_max_life" hidden="true">
<duration value="1"/>
<stack_type value="replace"/>
<effect_group>
<triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="TotalStat" operation="set" value="100"/>
<triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="TotalStat" operation="add" value="@$LastPlayerLevel">
<requirement name="PlayerLevel" operation="LTE" value="100"/></triggered_effect>
</effect_group>
<effect_group>
<triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="TotalStat" operation="set" value="200">
<requirement name="PlayerLevel" operation="GT" value="100"/></triggered_effect>
</effect_group>
</buff>


This worked. Now I can work on some life % over time buffs.

 
Back
Top