Jump to content

How to modify stealth damage for weapons with certain modifier


closer_ex

Recommended Posts

Hi everyone, 

 

I'm trying to make a perkbook mod, and now I'm stuck on how to determine whether a weapon is installed with certain modifier. Basically I want perk5StealthStab to increase stealth damage dealt by guns with silencer. I find that vallina perkUrbanCombatComplete does the check in item_modifiers:

 

<effect_group tiered="false" name="mod effects">
	<passive_effect name="EntityDamage" operation="perc_add" value="-.15">
		<requirement name="ProgressionLevel" progression_name="perkUrbanCombatComplete" operation="LT" value="1"/>
	</passive_effect>
	<passive_effect name="DamageFalloffRange" operation="perc_add" value="-.2"/>
	<passive_effect name="MaxRange" operation="perc_add" value="-.25"/>
</effect_group>

So I add my own item_modifiers.xml and write following code:

<?xml version="1.0" encoding="utf-8"?>
<configs>
	<append xpath="/item_modifiers/item_modifier[@name='modGunSoundSuppressorSilencer']">
		<effect_group tiered="false" name="stealth">
			<requirement name="ProgressionLevel" progression_name="perk5StealthStab" operation="Equals" value="1"/>
			<requirement name="CVarCompare" cvar="_crouching" operation="Equals" value="1"/>
			<requirement name="CVarCompare" cvar="_notAlerted" operation="GT" value="0" target="other"/>
				<passive_effect name="DamageBonus" operation="base_add" level="1" value="1"/> <!--For UI-->
				<passive_effect name="EntityDamage" operation="perc_add" level="1" value="1"/>
		</effect_group>
	</append>
</configs>

But nothing changes in game. I can't figure out what is wrong since I'm new to this modding stuff, and all the perks seems to be unlocked correctly (all other 6 books' buffs works fine).

 

Thanks in advance!

 

Btw, is there a collection of all these variables? It's really painful searching throughout all the vallina configs.

Link to comment
Share on other sites

Dump out your configs from the game, and post how the xml comes out.

 

In the console, type

exportcurrentconfigs

 

It'll dump out the configs to your appdata/roaming/7DaystoDie area.  Exact path will be show in the console so you can copy and paste to it.

 

I've found this to be a huge help in debugging if my xpath did what I thought it would do

Link to comment
Share on other sites

When I'm looking for variables there's a pretty good list in buffs.xml near the bottom.  Otherwise, yeah, just search through the xml for an item you know does something similar.  Also look in xml.txt, though.  There is a ton of good info in there, although some is outdated.

Link to comment
Share on other sites

8 hours ago, stample said:

Dump out your configs from the game, and post how the xml comes out.

 

In the console, type

exportcurrentconfigs

 

It'll dump out the configs to your appdata/roaming/7DaystoDie area.  Exact path will be show in the console so you can copy and paste to it.

 

I've found this to be a huge help in debugging if my xpath did what I thought it would do

That does help me find some other problems, but my effect_group seems to be appended correctly. I don't really understand the mechanism right now, so I'm posting the whole block as follows, mine appended at the end:

	<item_modifier name="modGunSoundSuppressorSilencer" installable_tags="gun" modifier_tags="barrelAttachment" blocked_tags="noMods,noSilencer" type="attachment">
		<property name="UnlockedBy" value="modGunSoundSuppressorSilencerSchematic" />
		<property name="Stacknumber" value="1" /> <property name="Group" value="Mods" />
		<property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab" />
		<!--Decreases sound footprint by x% -->
		<item_property_overrides name="*">
			<property name="Sound_start" value="pistol_s_fire" />
			<property name="Sound_end" value="" />
			<property name="Sound_loop" value="pistol_s_fire" />
		</item_property_overrides>

		<item_property_overrides name="gunHandgunT1Pistol">
			<property name="Sound_start" value="pistol_s_fire" />
			<property name="BarrelOffset" value="0,-.006,.127" />
			<property name="BarrelScale" value="1,1,1" />
		</item_property_overrides>

		<item_property_overrides name="gunHandgunT3SMG5">
			<property name="Sound_start" value="mp5_s_fire" />
			<property name="Sound_end" value="silencefiller" />
			<property name="Sound_loop" value="mp5_s_fire" />
			<property name="BarrelOffset" value="0,0,0" />
			<property name="BarrelScale" value="1,1,1" />
		</item_property_overrides>

		<item_property_overrides name="gunHandgunT3DesertVulture">
			<property name="Sound_start" value="pump_shotgun_s_fire" />
			<property name="Sound_loop" value="pump_shotgun_s_fire" />
			<property name="BarrelOffset" value="0,0,0" />
			<property name="BarrelScale" value="1,1,1" />
		</item_property_overrides>

		<!--<item_property_overrides name="gunHandgunT2Magnum44">
			<property name="BarrelOffset" value="0,.0418,-.0207"/>
			<property name="BarrelScale" value=".8,.8,1.5"/>
		</item_property_overrides>
		USING SNIPER RIFLE SILENCER INSTEAD OF THE MP5 ONE
		<item_property_overrides name="gunHandgunT2Magnum44">
			<property name="BarrelOffset" value="0,.0477,-.1593"/>
			<property name="BarrelScale" value="1,1,1"/>
			<property name="BarrelCameraOffset" value="0,0,0"/>
		</item_property_overrides>-->

		<item_property_overrides name="gunShotgunT1DoubleBarrel">
			<property name="Sound_start" value="pump_shotgun_s_fire" />
		</item_property_overrides>

		<item_property_overrides name="gunShotgunT2PumpShotgun">
			<property name="Sound_start" value="pump_shotgun_s_fire" />
			<property name="BarrelOffset" value="0,-.0322,.4516" />
			<property name="BarrelScale" value="1.1,1.1,1.5" />
		</item_property_overrides>

		<item_property_overrides name="gunShotgunT3AutoShotgun">
			<property name="Sound_start" value="pump_shotgun_s_fire" />
			<property name="Sound_loop" value="pump_shotgun_s_fire" />
			<property name="BarrelOffset" value="0,-.0322,.4516" />
			<property name="BarrelScale" value="1.1,1.1,1.5" />
		</item_property_overrides>

		<item_property_overrides name="gunRifleT1HuntingRifle">
			<property name="Sound_start" value="hunting_rifle_s_fire" />
			<property name="BarrelOffset" value="0,-.009,.551" />
			<property name="BarrelScale" value="1,1,1" />
		</item_property_overrides>

		<item_property_overrides name="gunRifleT2MarksmanRifle">
			<property name="Sound_start" value="sniperrifle_s_fire" />
			<property name="Sound_loop" value="sniperrifle_s_fire" />
			<property name="BarrelOffset" value="0,-.02,.2182" />
			<property name="BarrelScale" value=".88,.88,.88" />
		</item_property_overrides>

		<item_property_overrides name="gunRifleT3SniperRifle">
			<property name="Sound_start" value="sniperrifle_s_fire" />
			<property name="Sound_loop" value="sniperrifle_s_fire" />
			<property name="BarrelOffset" value="0,-.02,.2182" />
			<property name="BarrelScale" value=".88,.88,.88" />
		</item_property_overrides>

		<item_property_overrides name="gunMGT1AK47">
			<property name="Sound_start" value="ak47_s_fire" />
			<property name="Sound_end" value="silencefiller" />
			<property name="Sound_loop" value="ak47_s_fire" />
			<property name="BarrelOffset" value="-.001,-.0197,.3197" />
			<property name="BarrelScale" value="1,1,1" />
		</item_property_overrides>

		<item_property_overrides name="gunMGT2TacticalAR">
			<property name="Sound_start" value="ak47_s_fire" />
			<property name="Sound_end" value="silencefiller" />
			<property name="Sound_loop" value="ak47_s_fire" />
			<property name="BarrelOffset" value="0,.005,.275" />
			<property name="BarrelScale" value="1,1,1" />
		</item_property_overrides>

		<item_property_overrides name="gunMGT3M60">
			<property name="Sound_start" value="m60_s_fire" />
			<property name="Sound_end" value="silencefiller" />
			<property name="Sound_loop" value="m60_s_fire" />
			<property name="BarrelOffset" value="0,-.005,.31" />
		</item_property_overrides>

		<!-- visible attachment: silencer -->
		<effect_group tiered="false" name="external attachment prefab (old way)">
			<requirement name="!HoldingItemHasTags" tags="dBarrel" />
			<requirement name="!HoldingItemHasTags" tags="attachmentsIncluded" />
				<triggered_effect trigger="onSelfHoldingItemCreated" action="AttachPrefabToHeldItem" prefab="#Other/Items?Mods/Barrels/SilencerPrefab.prefab" parent_transform="Attachments/Barrel" />
		</effect_group>
		<effect_group tiered="false" name="internal attachment prefab (A19)">
			<requirement name="HoldingItemHasTags" tags="attachmentsIncluded" />
				<triggered_effect trigger="onSelfHoldingItemCreated" action="SetTransformActive" active="true" parent_transform="#HeldItemRoot" transform_path="silencer" />
		</effect_group>

		<effect_group tiered="false" name="mod effects">
			<passive_effect name="EntityDamage" operation="perc_add" value="-.15">
				<requirement name="ProgressionLevel" progression_name="perkUrbanCombatComplete" operation="LT" value="1" />
			</passive_effect>
			<passive_effect name="DamageFalloffRange" operation="perc_add" value="-.2" />
			<passive_effect name="MaxRange" operation="perc_add" value="-.25" />

			<!--<passive_effect name="MaxRange" operation="perc_add" value="-.25">
				<requirement name="RandomRoll" seed_type="Item" min_max="1,100" operation="LTE" value="80"/>
			</passive_effect>-->
		</effect_group>
		<property name="PickupJournalEntry" value="augmentGunsTip" />
	
		<item_property_overrides name="Savery"><!--Element appended by: "Snufkin Weapons Xpansion"-->
			<property name="Sound_start" value="hunting_rifle_s_fire" />
			<property name="BarrelOffset" value="0,-0.009,0.551" />
			<property name="BarrelScale" value="1,1,1" />
		</item_property_overrides>
		<item_property_overrides name="PP-19 Bizon"><!--Element appended by: "Snufkin Weapons Xpansion"-->
			<property name="Sound_start" value="mp5_s_fire" />
			<property name="Sound_end" value="silencefiller" />
			<property name="Sound_loop" value="mp5_s_fire" />
			<property name="BarrelOffset" value="0,0,-.2" />
			<property name="BarrelScale" value="1,1,1" />
		</item_property_overrides>
		<effect_group tiered="false"><!--Element appended by: "Snufkin Weapons Xpansion"-->
			<triggered_effect trigger="onSelfHoldingItemCreated" action="AttachPrefabToHeldItem" prefab="#Other/Items?Mods/Barrels/sniperrifle_silencer.fbx" local_offset="0,.02,0" parent_transform="Attachments/Barrel">
				<requirement name="HoldingItemHasTags" tags="bizon" />
			</triggered_effect>
		</effect_group>
	
		<effect_group tiered="false" name="stealth"><!--Element appended by: "Custom Perkbook"-->
			<requirement name="ProgressionLevel" progression_name="perk5StealthStab" operation="Equals" value="1" />
			<requirement name="CVarCompare" cvar="_crouching" operation="Equals" value="1" />
			<requirement name="CVarCompare" cvar="_notAlerted" operation="GT" value="0" target="other" />
				<passive_effect name="DamageBonus" operation="base_add" level="1" value="1" /> <!--For UI-->
				<passive_effect name="EntityDamage" operation="perc_add" level="1" value="1" />
		</effect_group>
	</item_modifier>

 

8 hours ago, stample said:

When I'm looking for variables there's a pretty good list in buffs.xml near the bottom.  Otherwise, yeah, just search through the xml for an item you know does something similar.  Also look in xml.txt, though.  There is a ton of good info in there, although some is outdated.

Now that's good stuff!

 

Thanks a lot!

Link to comment
Share on other sites

It's a lot cleaner to add the code to the silencer item.

Any code or checks only run if the mod is actually installed.

 

Running regular checks for [insert feature] is a last resort if nothing else works.

 

Also, doesn't that exact book already exist?

Link to comment
Share on other sites

13 minutes ago, Gazz said:

It's a lot cleaner to add the code to the silencer item.

Any code or checks only run if the mod is actually installed.

 

Running regular checks for [insert feature] is a last resort if nothing else works.

 

Also, doesn't that exact book already exist?

Hi Gazz, I don't really understand what you are referring to by that exact book, is it the Urban Combat or the Night stalker? I can't find any perkbook mod in this forum too (or maybe it's just that I don't know how to search properly? ).

 

I think I am adding the code to the silencer item, as you can see the effect_group is inserted to modGunSoundSuppressorSilencer block. Actually the idea of inserting here comes from Urban Combat, and the way I add the effect is the same as Night stalker:

 

<perk name="perkNightStalkerSlumberParty" parent="skillNightStalker" max_level="1" base_skill_point_cost="0" desc_key="perkNightStalkerSlumberPartyDesc" long_desc_key="perkNightStalkerSlumberPartyLongDesc">
  <effect_group>
    <requirement name="IsNight"/>
    <requirement name="CVarCompare" cvar="_crouching" operation="Equals" value="1"/>
    <requirement name="IsSleeping" target="other"/>
    <requirement name="CVarCompare" cvar="_notAlerted" operation="Equals" value="1" target="other"/>
      <passive_effect name="DamageBonus" operation="base_add" level="1" value=".5"/> <!--For UI-->
      <passive_effect name="EntityDamage" operation="perc_add" level="1" value=".5"/>
  </effect_group>
</perk>

But I'm not sure whether I should write like this in item_modifier... The fact is it's not working.

Link to comment
Share on other sites

2 hours ago, closer_ex said:

Hi Gazz, I don't really understand what you are referring to by that exact book, is it the Urban Combat or the Night stalker? I can't find any perkbook mod in this forum too (or maybe it's just that I don't know how to search properly? ).

 

I mean the code that is literally on the suppressor item.

Link to comment
Share on other sites

I had the same issue @Gazz, when I read his post, I thought he was checking on the individual items if a suppressor was installed, because of how he worded it.  But when you look at his code, he IS putting it on the suppressor, making the check he was asking about unnecessary.

 

I think the issue really is "Why isn't the DamageBonus and EntityBonus he added the suppressor working?" because the code block looks ok to me.

 

If I get some time today, I'll try plugging it in and playing around.  My first thought was that it was conflicting with another mod, but since he's using adds, not sets, that shouldn't be the case.

Link to comment
Share on other sites

12 hours ago, stample said:

I had the same issue @Gazz, when I read his post, I thought he was checking on the individual items if a suppressor was installed, because of how he worded it.  But when you look at his code, he IS putting it on the suppressor, making the check he was asking about unnecessary.

 

I think the issue really is "Why isn't the DamageBonus and EntityBonus he added the suppressor working?" because the code block looks ok to me.

 

If I get some time today, I'll try plugging it in and playing around.  My first thought was that it was conflicting with another mod, but since he's using adds, not sets, that shouldn't be the case.

I just realize that I can attach files😶 Now it's uploaded so you can do some testing. Thanks!

custom perkbook.zip

Link to comment
Share on other sites

Ok @closer_ex got it figured out.  Context of the code.

 

                <passive_effect name="DamageBonus" operation="base_add" value="1"/> <!--For UI-->
                <passive_effect name="EntityDamage" operation="perc_add" value="1"/>

What I did was remove

level="1"

 In the context of a <perk> tag, that tells what level of the perk scales the value.  Like normally you'd have 

level="1,5" value=".2,1"

This would tell the perk that you scale it from 20% to 100% between levels 1 and 5 of the perk.

 

In the context of an <item_modifier> level attribute is meaningless.  It has no way to know you mean the level of the perk in the requirement tag.  Because it has no level associated to the item, I suspect the null counts as level 0, resulting in it getting no bonus.  Removing that level attribute now displays 2.5x damage on the stealth attack, instead of 1.5x

 

Link to comment
Share on other sites

3 hours ago, stample said:

Ok @closer_ex got it figured out.  Context of the code.

 


                <passive_effect name="DamageBonus" operation="base_add" value="1"/> <!--For UI-->
                <passive_effect name="EntityDamage" operation="perc_add" value="1"/>

What I did was remove


level="1"

 In the context of a <perk> tag, that tells what level of the perk scales the value.  Like normally you'd have 


level="1,5" value=".2,1"

This would tell the perk that you scale it from 20% to 100% between levels 1 and 5 of the perk.

 

In the context of an <item_modifier> level attribute is meaningless.  It has no way to know you mean the level of the perk in the requirement tag.  Because it has no level associated to the item, I suspect the null counts as level 0, resulting in it getting no bonus.  Removing that level attribute now displays 2.5x damage on the stealth attack, instead of 1.5x

 

Thank you so much for the fix! After looking up in the buff.xml, I find this also mentioned under SPECIAL CASES. Nice hint!🤗

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...