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

Mod development cvar issue

anmao

New member
I added a buff to an entity. The buff is defined to increase a cvar by 1 each time it's attacked. I tested it in a single-player environment and everything worked fine, but after transferring it to the server, the cvar remains at 0 and doesn't change. Am I missing something?

Some code

```

<duration value="0"/>

<effect_group name="INIT">

<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" target="self" cvar="nwsVoidRift" operation="set" value="0"/>

<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" target="self" cvar="nwsVoidRiftCounting" operation="set" value="0"/>

<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" target="self" cvar="nwsVoidRiftSubMaxHealth" operation="set" value="1"/>

<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" target="self" cvar="nwsVoidRiftSubMaxHealthFinal" operation="set" value="@nwsVoidRiftSubMaxHealth"/>

</effect_group>

<effect_group name="Attacked by specific weapon">

                <triggered_effect trigger="onOtherAttackedSelf" action="CVarLogValue" cvar="nwsVoidRiftCounting"/> 

<requirement name="HoldingItemHasTags" target="other" tags="nwsVoidRift"/>

<requirement name="CVarCompare" cvar="nwsVoidRiftCounting" operation="LT" value="99"/>

<triggered_effect trigger="onOtherAttackedSelf" action="ModifyCVar" cvar="nwsVoidRiftCounting" operation="add" value="1"/>

<triggered_effect trigger="onOtherAttackedSelf" action="ModifyCVar" cvar="nwsVoidRiftSubMaxHealth" operation="multiply" value=".95"/>

</effect_group>

```

 
Попробуйте использовать переменную с префиксом, вот пример:
<triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" target="self" cvar=" $nwsVoidRift " operation="set" value="0"/>

I mean try putting a prefix before all your variables

 
Last edited by a moderator:
A couple of things I would try to see if I could understand the cause.

Some things that are coded in singleplayer are either not implemented or not fully implemented in multiplayer. An example of that is 'isBloodMoon'.

Is there any difference if you remove the requirements:

<requirement name="HoldingItemHasTags" target="other" tags="nwsVoidRift"/>  

and

<requirement name="CVarCompare" cvar="nwsVoidRiftCounting" operation="LT" value="99"/>

Any difference if you use onOtherDamagedSelf instead of onOtherAttackedSelf?

The target of 'self' is the default but I would also add it to the triggers as well because coding 7dtd xml for multiplayer is close to voodoo coding sometimes.

<triggered_effect trigger="onOtherDamagedSelf" action="ModifyCVar" cvar="nwsVoidRiftCounting" operation="add" value="1" target="self"/> 

<triggered_effect trigger="onOtherDamagedSelf" action="CVarLogValue" cvar="nwsVoidRiftCounting" target="self" />

I dont know if any of the above will help but it might give an idea of whats causing it.

For info on whether to use the '$' prefix look for the line

"Cvars that start with "$" are NOT networked" at the bottom of buffs.xml, there are comments there that provide some info.

cheers

 
A couple of things I would try to see if I could understand the cause.

Some things that are coded in singleplayer are either not implemented or not fully implemented in multiplayer. An example of that is 'isBloodMoon'.

Is there any difference if you remove the requirements:

<requirement name="HoldingItemHasTags" target="other" tags="nwsVoidRift"/>  

and

<requirement name="CVarCompare" cvar="nwsVoidRiftCounting" operation="LT" value="99"/>

Any difference if you use onOtherDamagedSelf instead of onOtherAttackedSelf?

The target of 'self' is the default but I would also add it to the triggers as well because coding 7dtd xml for multiplayer is close to voodoo coding sometimes.

<triggered_effect trigger="onOtherDamagedSelf" action="ModifyCVar" cvar="nwsVoidRiftCounting" operation="add" value="1" target="self"/> 

<triggered_effect trigger="onOtherDamagedSelf" action="CVarLogValue" cvar="nwsVoidRiftCounting" target="self" />

I dont know if any of the above will help but it might give an idea of whats causing it.

For info on whether to use the '$' prefix look for the line

"Cvars that start with "$" are NOT networked" at the bottom of buffs.xml, there are comments there that provide some info.

cheers
Changing to "onOtherDamagedSelf" made the function work correctly. However, I found that changes to the cvar are not synchronized to the client in real-time. Is there any way to force the client's cvar to update?

 
Not sure what timing is involved, I dont know of a way to force a push to the client. Is it a large delay? Would adding (stacking) a buff force a refresh. e.g.

<triggered_effect trigger="onOtherDamagedSelf" action="ModifyCVar" cvar="nwsVoidRiftCounting" operation="add" value="1" target="self"/>

<triggered_effect trigger="onOtherDamagedSelf" action="AddBuff" buff="some basic empty buff that stacks"  target="self"/> 

No idea if that would work - even its its just to see if you can effect an update in some way.

cheers

 
JoeSloeMoe said:
Not sure what timing is involved, I dont know of a way to force a push to the client. Is it a large delay? Would adding (stacking) a buff force a refresh. e.g.

<triggered_effect trigger="onOtherDamagedSelf" action="ModifyCVar" cvar="nwsVoidRiftCounting" operation="add" value="1" target="self"/>

<triggered_effect trigger="onOtherDamagedSelf" action="AddBuff" buff="some basic empty buff that stacks"  target="self"/> 

No idea if that would work - even its its just to see if you can effect an update in some way.

cheers
Adding a buff doesn't seem to update the cvar, so I've changed the trigger from cvar changes to triggering when a buff is present.

 
the mod doesn't seem to work properly. all of the shields are removed when entering the wasteland, the most radioactive area. why? the burnt biome buff and mod work fine, however on multiple tests, the nomad gear, well insulated, etc does literally nothing in the wasteland biome. the shields also disappear in the snow biome. I am not as familiar with buffs so I cannot figure out why the mod is essentially negated in the wasteland. No, there are no other files that would interefere.

 
Back
Top