• Mods are now organized as resources. Use the Mods link above to browse for or submit a mod, tool, or prefab.

    The TFP Official Modding Forum Policy establishes the rules and guidelines for mod creators and mod users.

Guidance on weapon XML creation

Alright, I touched on this topic before but got nowhere. I want to create some new weapons. I have a friend that can make the models and he has made some already. My initial plan was to extend existing weapons and tweak their rate of fire, damage, etc. I could never figure out what extending actually extended because every time I started the game it complained about something missing. My gut says extending is absolutely broken right now since nothing extends.

That said, I want to start simple for now. I want to duplicate the SMG and tweak values. Looking to make a more noob-friendly version that will not damage blocks or vehicles. One that only damages zombies. What is the proper procedure for this? Do I copy/paste the entire SMG section into a mod and then rename it?
 
Starting with a copy of the smg section would probably be the most straighforward method. Just give the gun a new name and then modify the various properties to work with your new weapon. You'll also need to add entries to recipes, progression, item_modifiers, etc. There are other mods that add weapons and you could download those and see how they do it.

"Extends" is used for about 8000 things in the game, including all the zombie variants, and almost 6000 "blocks" (pretty much anything you see in the world), so it's not absolutely broken. It just has some limitations in what it can do. Only a very few weapons in vanilla use extends.
 
Where can I find documentation on extends? I know the game isn't open-source so I can't just stroll over to Github and grab a copy (boy, I bet the cheaters would LOVE that!), but I don't know of a documentation site, and starting the game a hundred times, each time adding one line of code, is a bad way to learn. Not to mention the insanity that would surely ensue!

Okay, I'll start by copying the SMG again. I'll rename it, but what about the effects group? Assuming I should rename that also? How do I make it only damage zombies and not vehicles or blocks? I vaguely recall a property like "BlockDamage" or something from way back, but I am not sure if that is correct or current. Ideally I would set vehicle, player, and block damage to 0 or, if I cannot use 0, 1.
 
I don't know of any documentation source for extends. What I have learned has been through reading the game's xml, and looking at people's mods. When editing modlets, it is usually sufficient to just exit to the main menu and then load the save again. It can still be a lot of time waiting, but not necessarily restarting the whole game.

There are value for BlockDamage and EntityDamage for both the weapon, and the ammo used. Damage is based on ammo damage and then adjusted by weapon damage. This is an answer I wrote a couple years ago describing this more for EntityDamage. BlockDamage would be similar. The numbers may not be correct any more, but the way it works is still the same.

Damage starts with ammo damage and then is adjusted by weapon type, quality, perks, and mods.


Let's look at 9mm pistols. Regular 9mm ammo has 32 damage. A T1 pipe pistol has a damage offset of -4

<passive_effect name="EntityDamage" operation="base_add" value="-4" tags="perkGunslinger"/> <!-- damage offset -->

If you spawn in a pistol it will show it's damage as 28 which is 32 + (-4). (If you craft a pistol it may not be 28 since there is some variability in crafting.


The regular pistol has an offset of +5

<passive_effect name="EntityDamage" operation="base_add" value="5" tags="perkGunslinger"/> <!-- damage offset -->

and if you spawn in a T1 pistol it will show a damage of 37 which is 32 + (+5).


HP 9mm ammo has damage of 35, so all those pistol damage values are just increased by 3. AP ammo is 38, so bumps up damage another 3.

Weapon tier will also increase damage, I think 5% per tier. Player perks and weapon mods increase it further. In summary, base damage is set by ammo type, adjusted by weapon type, and then increased by quality, player perks and mods on the gun.

So, just changing the BlockDamage offset in the weapon effects group would probably not be enough to remove the damage. I think you'll need to also include new ammo types for it, and for those you could set a low block damage. Changing the name of the effects group is probably a good idea for clarity, although I am unsure if it is actually necessary. It would be a child node for your added weapon, separate from the smg effects group. But rename it just to be sure, there's a lot I don't know about how 7dtd uses xml.

Oh, and to limit player damage, I'm thinking you can only change that with a game setting for "Player Killing" since players would get EntityDamaqe.

If this is your first experience with modding, you haven't chosen an easy one.
 
Thanks for the information, Seven! I have eight mods since the alphas under my belt, all on Nexus. This is my first stab at weapons modding and trying to use extends. My other mods either changed values for in-game, stock items (my dew collectors mod), or added entirely new blocks (my blocks mod). Never dealt with weapons before, but I know how it works, or how it is supposed to work. I'm just used to having somewhere I can go for documentation on how the stock properties work. You should see the 100-page document I printed out back in 1998 when I was learning Unreal Engine 1!
 
I do not believe you can remove block damage completely. I think you can reduce it down to a single point of damage, but I recall discussions in the past that there were issues being able to remove all damage to blocks from weapons.
 
Hey, BFT! Good to see you! I don't think we've spoken in several years (job changes, life, not playing computer games for that time) but it is good to see you're still here!

That is fine, I won't try to set block damage to zero, just 1. I'm trying to make a noobie-friendly version of the weapons for player who cannot aim for their lives and another one with better weapons for veteran players. I did make an MP5 (SMG) with an accurate fire rate and OMG it mowed everything down, so I believe that I know why the ROF is at like, 480 in the stock SMG now.
 
Okay, let's go back to the SMG. I want to make two clones of this. One for noobs, one for vets. The base code is pasted below, right from the v2.6 items.xml file.
Code:
<item name="gunHandgunT3SMG5">
    <property name="Tags" value="weapon,ranged,holdBreathAiming,reloadPenalty,gun,shortRange,barrelAttachments,sideAttachments,smallTopAttachments,magazine,drumMagazine,firingMode,bottomAttachments,attAgility,perkGunslinger,9mmGun,attachmentsIncluded,canHaveCosmetic,handgunSkill"/>
    <property name="DisplayType" value="rangedGun"/>
    <property name="HoldType" value="6"/>
    <property name="Meshfile" value="@:Other/Items/Weapons/Ranged/SMG/smgPrefab.prefab"/>
    <property name="Material" value="MHandGunParts"/>
    <property name="TintColor" value="80, 80, 80"/>
    <property name="Weight" value="7"/>
    <property name="ScrapTimeOverride" value="10.0"/>
    <property name="RepairTools" value="resourceRepairKit"/>
    <property name="DegradationBreaksAfter" value="false"/>
    <property name="SoundJammed" value="weapon_jam"/>
    <property name="Attachments" value="meleeToolFlashlight02"/>
    <property name="CrosshairOnAim" value="true"/> <!-- aimTest -->
    <property name="CrosshairUpAfterShot" value="true"/> <!-- aimTest -->
    <property name="Sound_Sight_In" value="smg_sight_in"/>
    <property name="Sound_Sight_Out" value="smg_sight_out"/>
    <property name="Group" value="Ammo/Weapons,Ranged Weapons"/>
    <property name="RepairExpMultiplier" value="10.8"/>
    <property name="LightValue" value=".45"/>
    <property name="EconomicValue" value="5000"/>
    <property name="TraderStageTemplate" value="baseTier2"/><!-- gunHandgunT3SMG5 -->
    <property name="UnlockedBy" value="craftingHandguns"/><!-- gunHandgunT3SMG5Schematic, -->
    <property name="ShowQuality" value="true"/>
    <property name="SoundUnholster" value="weapon_unholster"/>
    <property name="SoundHolster" value="weapon_holster"/>
    <property name="SoundPickup" value="rifle_polymer_grab"/>
    <property name="SoundPlace" value="rifle_polymer_place"/>

    <property class="Action0">
        <property name="Class" value="Ranged"/>
        <property name="Delay" value=".150"/> <!-- obsolete if rounds per minute exists -->
        <property name="Magazine_items" value="ammo9mmBulletBall,ammo9mmBulletHP,ammo9mmBulletAP"/>
        <property name="Reload_time" value="4.1"/>
        <property name="Sound_start" value="smg_fire"/>
        <property name="Sound_loop" value="smg_fire"/>
        <property name="Sound_end" value="smg_fire_end"/>
        <property name="Sound_empty" value="dryfire"/>
        <property name="Sound_reload" value=""/>
        <property name="AutoReload" value="false"/>
        <property name="Particles_muzzle_fire" value="gunfire_MG_SMG"/>
        <!-- <property name="DamageBonus.head" value="4"/>
        <property name="DamageBonus.wood" value="5"/>
        <property name="DamageBonus.earth" value=".2"/> -->
        <property name="ScopeOffset" value="-.000525,.1449,-.2"/>
        <property name="SideOffset" value="0,0,0"/>
        <property name="BarrelOffset" value="-.062,.062,.16"/>
        <property name="triggerEffectTriggerPullDualsense" value="PistolTrigger"/>
        <property name="triggerEffectTriggerPullXbox" value="PistolTrigger"/>
        <property name="triggerEffectShootDualsense" value="PistolShoot"/>
        <property name="triggerEffectShootXbox" value="PistolShoot"/>
    </property>
    <property class="Action1">
        <property name="Class" value="Zoom"/>
        <property name="Zoom_max_out" value="55"/>
        <property name="Zoom_max_in" value="55"/>
        <property name="SightsCameraOffset" value="-.0003,0,-.01"/>
        <property name="zoomTriggerEffectPullDualsense" value="PistolZoom"/>
        <property name="zoomTriggerEffectPullXb" value="PistolZoom"/>
    </property>
    <effect_group name="gunHandgunT3SMG5">
        <passive_effect name="MaxRange" operation="base_set" value="65" tags="perkGunslinger,9mmGun"/>
        <passive_effect name="DamageFalloffRange" operation="base_set" value="30" tags="perkGunslinger,9mmGun"/>
        <passive_effect name="DamageFalloffRange" operation="perc_add" value="-.2,.2" tier="1,6" tags="perkGunslinger,9mmGun"/> <!-- random effective rng -->
        <passive_effect name="RoundsPerMinute" operation="base_set" value="480" tags="perkGunslinger"/>
        <passive_effect name="BurstRoundCount" operation="base_set" value="1000" tags="perkGunslinger"/>
        <passive_effect name="MagazineSize" operation="base_set" value="30" tags="perkGunslinger"/>
        <passive_effect name="ReloadSpeedMultiplier" operation="base_set" value="1" tags="perkGunslinger"/> <!-- 4s -->
        <passive_effect name="ModSlots" operation="base_set" value="3,3,3,4,4,4" tier="1,2,3,4,5,6"/>
        <passive_effect name="ModPowerBonus" operation="perc_add" value=".10" tags="EntityDamage,BlockDamage"/>
        <passive_effect name="ModPowerBonus" operation="base_add" value="300" tags="EconomicValue"/>
        <passive_effect name="EntityDamage" operation="base_add" value="18" tags="perkGunslinger"/> <!-- damage offset -->
        <passive_effect name="EntityDamage" operation="perc_add" value="-.02,.02" tags="perkGunslinger"/> <!-- random EntityDmg -->
        <passive_effect name="EntityDamage" operation="perc_add" value=".05,.25" tier="2,6" tags="perkGunslinger"/> <!-- tier bonus -->
        <passive_effect name="BlockDamage" operation="perc_add" value="-.08,.08" tags="perkGunslinger"/> <!-- random BlockDmg -->
        <passive_effect name="BlockDamage" operation="perc_add" value=".15,.75" tier="2,6" tags="perkGunslinger"/> <!-- tier bonus -->
        <!-- <passive_effect name="DegradationMax" operation="perc_add" value="-.2,.2" tier="1,6" tags="perkGunslinger"/> --> <!-- random DegMax -->
        <!-- <passive_effect name="RoundsPerMinute" operation="perc_add" value="-.05,.05" tags="perkGunslinger"/> --> <!-- random APM -->
        <!-- <passive_effect name="MagazineSize" operation="perc_add" value="-.122,.122"/> --> <!-- random MagazineSize -->
        <passive_effect name="WeaponHandling" operation="perc_add" value="-.08,.08" tags="perkGunslinger"/> <!-- random WeaponHandling -->

        <passive_effect name="SpreadDegreesVertical" operation="base_set" value="1.35" tags="perkGunslinger"/>
        <passive_effect name="SpreadDegreesHorizontal" operation="base_set" value="1.35" tags="perkGunslinger"/>
        <passive_effect name="SpreadMultiplierAiming" operation="base_set" value=".35" tags="perkGunslinger"/>
        <passive_effect name="SpreadMultiplierCrouching" operation="base_set" value=".8" tags="perkGunslinger"/>
        <passive_effect name="SpreadMultiplierWalking" operation="base_set" value="1.5" tags="perkGunslinger"/>
        <passive_effect name="SpreadMultiplierRunning" operation="base_set" value="2.2" tags="perkGunslinger"/>

        <passive_effect name="KickDegreesVerticalMin" operation="base_set" value=".5" tags="perkGunslinger"/>
        <passive_effect name="KickDegreesVerticalMax" operation="base_set" value="1" tags="perkGunslinger"/>
        <passive_effect name="KickDegreesHorizontalMin" operation="base_set" value="-.3" tags="perkGunslinger"/>
        <passive_effect name="KickDegreesHorizontalMax" operation="base_set" value=".3" tags="perkGunslinger"/>

        <passive_effect name="IncrementalSpreadMultiplier" operation="base_set" value="1.6" tags="perkGunslinger,9mmGun"/>
        <passive_effect name="WeaponHandling" operation="base_set" value=".8" tags="perkGunslinger"/>

        <passive_effect name="DegradationMax" operation="base_set" value="500,700" tier="1,6" tags="perkGunslinger,9mmGun"/>
        <passive_effect name="DegradationPerUse" operation="base_set" value="1" tags="perkGunslinger,9mmGun"/>
    </effect_group>
</item>
Some of these tags are easy to understand. Things like "SpreadDegressVertical" are very obvious. Less obvious are lines like the two below.
Code:
<passive_effect name="EntityDamage" operation="base_add" value="18" tags="perkGunslinger"/> <!-- damage offset -->
<passive_effect name="EntityDamage" operation="perc_add" value="-.02,.02" tags="perkGunslinger"/> <!-- random EntityDmg -->
I am assuming that "base_add" means the base value. A value of 18 tells me that the base damage is 18 to a zombie. Since it specifies the gunslinger perk at the end, I ASSUME this increases a bit as that skill goes up. The next line seems to just be a random spread on the amount of damage a round can do to a zombie. With the values above I assume this means that when I shoot a zombie with a level 1 SMG and basic ammo (ball, not HP/AP), I can do 17.8 to 18.2 damage to the zombie. Is this correct?

Next up is "DamageFalloffRange" which I assume is the range you get full damage, after which damage between this value and "MaxRange" gets reduced until it is zero damage beyond that max range. It also has a +/- 2% modifier so damage is a bit random. Is this correct?

To summarize, my understanding is as follows.
Code:
<passive_effect name="EntityDamage" operation="base_add" value="18" tags="perkGunslinger"/> <=-- Base damage per shot
<passive_effect name="EntityDamage" operation="perc_add" value="-.02,.02" tags="perkGunslinger"/> <=-- Add or subtract 2% damage for randomness
<passive_effect name="EntityDamage" operation="perc_add" value=".05,.25" tier="2,6" tags="perkGunslinger"/> <=-- Tier 2~5 gets 5% bonus, tier 6 gets 25%

<passive_effect name="BlockDamage" operation="perc_add" value="-.08,.08" tags="perkGunslinger"/> <=-- Add or subtract 8% damage to blocks
<passive_effect name="BlockDamage" operation="perc_add" value=".15,.75" tier="2,6" tags="perkGunslinger"/> <=-- 15% bonus damage / 75% bonus
What I do not see is where to set the base damage for blocks, only entities, which I assume are vehicles, players, and zombies. Am I missing anything?
 
Well, I tried one where I set block damage to "-.99,-.99" to reduce it as much as possible, and this. Note that I copy/pasted the in-game SMG into a blank mod in items.xml in the mod. Line 2 throws an error and I am confounded.
Code:
<append xpath="/items">
    <item name="gunDHTAMP5">
And the error is the best.
Code:
2026-05-09T13:56:55 46.815 WRN XML.Patch (/append/item, line 2 at pos 3): Patch type (item) unknown
2026-05-09T13:56:55 46.815 WRN XML patch for "items.xml" from mod "DHTA-Better-Guns" did not apply: <item name="gunDHTAMP5"  (line 2 at pos 3)
Yeah. That makes zero sense. Clearly I am missing something. I checked the entire file for errors. No open lines or anything. It just doesn't work. Every single line is identical to the stock SMG, except the name of the item and the effect group. The only other change is shown below.
Code:
            <passive_effect name="BlockDamage" operation="perc_add" value="-.99,-.99" tags="perkGunslinger"/> <!-- random BlockDmg -->
            <passive_effect name="BlockDamage" operation="perc_add" value="-.99,-.99" tier="2,6" tags="perkGunslinger"/> <!-- tier bonus -->
Am I missing something so simple I cannot see it?
 
Damage always starts with the ammo.


"base_add" ADDs to the BASE damage. Base damage is determined (with base_set) by the ammo type. If you have regular 9mm ammo loaded it is this

<passive_effect name="EntityDamage" operation="base_set" value="32" />

so doing a base_add of 18 would make EntityDamage = 50 (32+18).


The block damage is set for 9mm ammo with

<passive_effect name="BlockDamage" operation="base_set" value="6" />

and is adjusted by the perk_add's. Those should be a range of values based on tier, e.g.

value=".15,.75" tier="2,6" tags="perkGunslinger" would be .15, .30, .45, .60, .75


There can also be bonus damage to certain block types, e.g.

<property name="DamageBonus.wood" value="5"/> for the weapon, and

<passive_effect name="DamageModifier" operation="perc_add" value="2" tags="wood"/> for the ammo

So, if you want to minimize block damage, you have to start with making custom ammo types, and then adjust the weapon.


It might be helpful to have a creative game, spawn in your weapons and shoot at zombies with an HP bar enabled, or a hammer to check blocks.
 
I am an id10t. I forgot the config tag. It's been a while. Go ahead and laugh about that one. That's entirely my bad.

On a related note, I looked at my original blocks release. It was wrapped as follows.
Code:
<DHTA_Blocks>
  <config>
    <append xpath="/blocks">
      <lots of new blocks/>
    </append>
  </config>
</DHTA_Blocks>
Is that still supported? I learned it EONS ago and it always worked. Does it isolate my mod or something? I don't remember why. Several of my OLD mods are like that.
 
I don't know that it matters what is in the tag, just that you have the tag/end tag. Some people use 'config', others 'configs', others put the name of the mod. And the simple mistakes are the easiest ones to make, and hard to find. I don't know if the extra tag (DHTA_Blocks) around the config is a problem. I don't do that.

I did some quick tests.

With a stock T3 smg, no perks, no mods, and the regular 9mm ammo it'll break a wood block in about 1/2 a clip.

In my earlier post I skipped over the first damage perk_add, that does add a random amount of damage within a range like you said. If you do have that set to -.99, -.99 it will then take about 2 clips to destroy a wood block. Would that be enough? With points in perkgunslinger that is reduced, back to half a clip at top tier, but that would be more end game. Adjust the other perk_add doesn't really change it that much.

If you adjust block damage for the ammo, <passive_effect name="BlockDamage" operation="base_set" value="1" /> then at top tier gunslinger it will again take about 2 clips to break the block. With no points in the perk, even after 5 clips the block is still over half health. So, I still think you won't get enough damage reduction just by changing the weapon stats. I might be missing something though. I've done very little modding of weapons.
 
Thanks for the info. I have already worked on a mod to test things. I cloned the pistol (M9), SMG (MP5), and sniper (R11). I gave them ridiculous damage (500/1000/2500) and reduced block damage percentages on both lines as shown above (-.99). Even with those insane damage values (spawn a horde and go full auto, it's hilarious) it reduces block damage enough so a noob won't dig the Grand Canyon while spraying at a basic zed.

As for the tags, IIRC correctly it used to do something, but I believe in my update for the blocks mod I will remove those tags. No real need for them at this point AFAIK. My newest mods do not wrap like that and they work, so it's extra, unneeded code. It also means every line has an extra tab.

EDIT -

I forgot to ask. Since I cloned the stock weapons and simply renamed them and mucked around with damage values, will they show up in loot? I would prefer they did not. My goal for the REAL mod (not the one-shot everything mess I am playing with now) is to only allow blueprints to be found and force the player to build one using pistol parts and such.
 
Back
Top