Jump to content

Passing cvar values between entities


Recommended Posts

TL;DR: How to pass cvar/make cvar global?

 

Hello all, I'm trying to implement a stacking buff based on the amount of armor shredded, here's what I had written.

<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="armorShreddedMult" operation="set" value="1"/>
<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="armorShreddedMult" operation="subtract" value="@shredPercentage"/>
<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="armorShreddedAmount" operation="set" value="@currentArmor"/>
<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="armorShreddedAmount" operation="multiply" value="@armorShreddedMult"/>
<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="armorShredded" target="selfAOE" range="10" operation="add" value="@armorShreddedAmount"/>

 

shredPercentage and currentArmor are already part of the entity already, and work fine. My problem is when trying to pass back armorShreddedAmount. What I would like it to do is calculate the amount of shredded armor (which it does) then add that back to the player entity (this buff is on an enemy). However, it seems the way this works is that when performing this line

 

<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="armorShredded" target="selfAOE" range="10" operation="add" value="@armorShreddedAmount"/>

 

it looks for the value armorShreddedAmount on the player entity, which isn't initialized so it ignored/treated as 0 and nothing changes, rather than passing the amount that was calculated above. Is there a way to declare global scope to fix this, or some other trick by which I can pass the cvar? Thanks.

 

Link to comment
Share on other sites

I tried to find my post that was asking this same thing, but couldnt find it. Probably was made before the forum change and got wiped. But pretty much you can't do it easily. You would have to have lots of checks for every possible value. EG: armorShreddedAmount = 1, so send 1 to player and set armorShredded.. then armorShreddedAmount = 2, so send 2 to player and set armorShredded.. a very tedious process.

There was a guy who did some convoluted scheme using like 3 digit numbers where he could transfer different amounts, but it still used roughly the same idea as above...

One thing you could do is stream line it a bit.. not many would notice 2 armor being taken off so do it in batches of 5 or 10 or so... That would cut the amount of possible cvar changes down a good bit.

Link to comment
Share on other sites

1 hour ago, Telric said:

I tried to find my post that was asking this same thing, but couldnt find it. Probably was made before the forum change and got wiped. But pretty much you can't do it easily. You would have to have lots of checks for every possible value. EG: armorShreddedAmount = 1, so send 1 to player and set armorShredded.. then armorShreddedAmount = 2, so send 2 to player and set armorShredded.. a very tedious process.

There was a guy who did some convoluted scheme using like 3 digit numbers where he could transfer different amounts, but it still used roughly the same idea as above...

One thing you could do is stream line it a bit.. not many would notice 2 armor being taken off so do it in batches of 5 or 10 or so... That would cut the amount of possible cvar changes down a good bit.

Yeah, the system I ended up going with utilizes a tag system tagging roughly how much armor an enemy has base, then passing back hard coded values that are approximately what you would get up to 4 stacks. A lot of legwork but I suppose it's one of the limitations of how cvars are handled.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...