Jump to content

Any way to copy a CVAR from one entity into another?


kanaverum

Recommended Posts

But does anyone know of a way to pass/copy a CVAR value from one entity to another?

 

 

More context and tests/results below:

 

I have a CVAR on my player and I want to set the value of this same CVAR on another entity so that once the trigger completes, both entities have the same CVAR with the same Value (i.e. a copy).

 

Test 1: In this example, I'm using this block with the Trader to make things simple (won't need other humans for this testing). At this point, my player cvar was at 5 and trader was at 2.

<buff name="setTraderFromSelf">
  <duration value="1" />
  <effect_group>
    <triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="testVar" operation="set" value="@testVar" target="selfAOE" target_tags="npc" range="10" />
    
    <!-- show player current value -->
    <triggered_effect trigger="onSelfBuffStart" action="LogMessage" message="PlayerCVAR" />
    <triggered_effect trigger="onSelfBuffStart" action="CVarLogValue" cvar="testVar" />
    
    <!-- show trader current value -->
    <triggered_effect trigger="onSelfBuffStart" action="LogMessage" message="TraderCVAR" />
    <triggered_effect trigger="onSelfBuffStart" action="CVarLogValue" cvar="testVar" target="selfAOE" target_tags="npc" range="4000" />
  </effect_group>
</buff>

 

Outcome 1: Unfortunately, this didn't result in any change to the trader's CVAR (bummer).

 

 

Test 2: So I tried another approach to confirm a hunch

<buff name="addTraderFromSelf">
  <duration value="1" />
  <effect_group>
    <triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="testVar" operation="add" value="@testVar" target="selfAOE" target_tags="npc" range="10" />
    
    <!-- show player current value -->
    <triggered_effect trigger="onSelfBuffStart" action="LogMessage" message="PlayerCVAR" />
    <triggered_effect trigger="onSelfBuffStart" action="CVarLogValue" cvar="testVar" />
    
    <!-- show trader current value -->
    <triggered_effect trigger="onSelfBuffStart" action="LogMessage" message="TraderCVAR" />
    <triggered_effect trigger="onSelfBuffStart" action="CVarLogValue" cvar="testVar" target="selfAOE" target_tags="npc" range="4000" />
  </effect_group>
</buff>

Outcome 2: This results in the trader's own "testVar" cvar doubling - which makes sense, it turns out: the value reference of "@test" isn't *my* value - it's the trader's.

 

 

So this would lead me to believe that any value reference to a CVAR is going to refer to the target only and there might not be any way for a value to be copied/passed in by another entity.


Test 3: I've also tried using requirements to see if I can at least confirm if a value is out of sync and then sync it up with onSelfBuffUpdate.

I rushed this example, so it might just be incorrectly written..

 

<buff name="syncWithTrader" icon="ui_game_symbol_players" icon_color="0, 128, 255">
  <effect_group>
    <requirement name="CVarCompare" cvar="testVar" operation="LT" value="@testVar" target="other"></requirement>
    <triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="testVar" operation="add" value="1" target="selfAOE" target_tags="npc" range="10"/>
    <triggered_effect trigger="onSelfBuffUpdate" action="LogMessage" message="cvar is low" />

  </effect_group>
  <effect_group>
    <requirement name="CVarCompare" cvar="testVar" operation="GT" value="@testVar" target="other"></requirement>
    <triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="testVar" operation="subtract" value="1" target="selfAOE" target_tags="npc" range="10"/>
    <triggered_effect trigger="onSelfBuffUpdate" action="LogMessage" message="cvar is high" />
  </effect_group>
  <effect_group>
    <requirement name="CVarCompare" cvar="testVar" operation="equals" value="@testVar" target="other"></requirement>
    <triggered_effect trigger="onSelfBuffUpdate" action="LogMessage" message="cvars are synced" />
    <triggered_effect trigger="onSelfBuffUpdate" action="RemoveBuff" buff="syncWithTrader" />
  </effect_group>
</buff>


Outcome 3: this hasn't worked either, I'm sorry to say

Edited by kanaverum (see edit history)
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...