• 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!
 
Back
Top