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

Help moding Firearms to have Special Effects

NeonScorpion

New member
Hello, im new to moding and coding and i have a few questions. I'm cutting my teeth by making a Dead Island style weapon mod system using custom items and recipes. So far I have made a few flaming clubs of scalding power and effect. Here are my two questions:

First, is it possible to apply a buff such as "Burning" to a fully assembled firearm? That way any bullets fired from it have a chance to cause the fire or buff no matter the ammo being loaded? An overarching buff so to speak. Also is it possible to use a fully assembled firearm as an ingredient in a recipe and have it carry over the quality? For example can I require a recipe that needs 1 fully assembled pistol, 4 electrical components, and a rechargeable battery pack to create a pistol with the chance to cause the "shocked" effect. Or do I have to apply the recipe to a specific component of the firearm, such as the barrel. If that is the case will crafting a special barrel and combing it with the rest of the components to build a firearm carry over the buff that's attached just to the barrel so that the full firearm has the effect? Or do I have to create my own unique Ammo with the effect that causes the special effect? Because I would prefer it to be a buff on the firearm itself.

Secondly, how to I make my own recipe books? I want to make the weapon modifications spawn as books you can find, each level of power spawning only after a certain player level or each just being progressively rarer than the last. So at first you can find the book "Fire Mod" it unlocks all first level fire modification you can apply to melee weapons and firearms. But at high level you could find "Phoenix Mod" the rarest and most powerful fire effect that unlocks recipes for melee and firearms. Side note, if that is very difficult to do how can I tie the unlocks to the Blunt, Knife, and Firearm skills progression, unlocking newer more powerful recipes and Mods as you gain skill in that type of weapon? Level 10 Blunt unlocks the base level Fire Mod for all Blunt Weapons. Level 80 Firearms unlocks the highest Phoenix Fire Mod for firearms, and so on? How would I go about doing that?

Thanks for all the help everyone! So far everyone has really helped me a lot, I know I post a lot of requests and questions but you have all helped me learn so much so quickly!

 
Hello, i dont know who did this code, but works like you want.

items.xml

Code:

<item id="2004" name="gunPistolShock"><property name="CustomIcon" value="gunPistol"/> <property name="CustomIconTint" value="00C9CC"/>

<property name="Meshfile" value="Items/Weapons/Ranged/Pistol/PistolPrefab"/>

<property name="Material" value="metal"/>

<property name="RepairTools" value="repairKitS"/>

<property name="HoldType" value="1"/>

<property name="DegradationBreaksAfter" value="false"/>

<property name="SoundJammed" value="weapon_jam"/>

<property name="Attachments" value="flashlight02"/>

<property name="CrosshairOnAim" value="false"/> <!-- aimTest -->

<property name="CrosshairUpAfterShot" value="true"/> <!-- aimTest -->

<property class="Parts">

<property name="Stock" value="partsPistol_gripS"/>

<property name="Receiver" value="partsPistol_receiverS"/>

<property name="Pump" value="partsPistol_partsS"/>

<property name="Barrel" value="partsPistol_barrelS"/>

</property>

<property name="Sound_Sight_In" value="pistol_sight_in"/>

<property name="Sound_Sight_Out" value="pistol_sight_out"/>

<property class="Action0">

<!-- AttackAction -->

<property name="Class" value="Ranged"/>

<property name="Delay" value="0.2"/>

<property name="Crosshair_min_distance" value="5"/>

<!-- 5 -->

<property name="Crosshair_max_distance" value="6"/>

<!-- 6 -->

<property name="Magazine_size" value="15"/>

<property name="Magazine_items" value="9mmBullet"/>

<property name="Magazine_item_ray_counts" value="1"/>

<property name="Magazine_item_ray_spreads" value="0.85"/>

<!-- .85 -->

<property name="Reload_time" value="2"/>

<property name="Bullet_icon" value="pistol"/>

<property name="Sound_start" value="Pistol_Fire"/>

<property name="Sound_repeat" value=""/>

<property name="Sound_end" value=""/>

<property name="Sound_empty" value="weapon_empty"/>

<property name="Sound_reload" value="pistol_reload"/>

<property name="Buff" value="shockedBuff"/>

<property name="BuffChance" value="1"/>

<property name="Particles_muzzle_fire" value="nozzleflash"/>

<property name="Particles_muzzle_smoke" value="nozzlesmoke"/>

<property name="DamageBonus.head" value="6"/>

<property name="DamageBonus.wood" value="3"/>

<property name="DamageBonus.earth" value="0.4"/>

<property name="DamageBonus.glass" value="1"/>

</property>

<property class="Action1"> <!-- UseAction -->

<property name="Class" value="Zoom"/>

<property name="Zoom_max_out" value="35"/>

<property name="Zoom_max_in" value="35"/>

</property>

<property name="LightSource" value="lightSource"/> <!-- Start: Needed for the attachment flashlight -->

<property name="ActivateObject" value="Attachments/flashlight/lightSource"/>

<property name="AttachmentFlashlight" value="flashlight02"/> <!-- End: Needed for the attachment flashlight -->

<property name="Group" value="Ammo/Weapons"/>

<property name="ActionSkillGroup" value="Pistols"/>

<property name="CraftingSkillGroup" value="craftSkillGuns"/>

<property name="RepairExpMultiplier" value="10.8"/>

<property name="LightValue" value="0.45"/>

</item>
Code:

<item id="2008" name="partsPistol_gripS"><property name="CustomIcon" value="partsPistol_grip"/> <property name="CustomIconTint" value="00C9CC"/>

<property name="Extends" value="partsMaster"/>

<property name="RepairTools" value="repairKitS"/>

<property name="DescriptionKey" value="partsPistolGroupDesc"/>

<property name="PartType" value="Stock"/>

<property name="Weight" value="10"/>

<property class="Attributes">

<property name="DegradationRate" value="10,10"/>

<property name="DegradationMax" value="2000,5000"/>

</property>

<property name="EconomicValue" value="412"/>

</item>

<item id="2009" name="partsPistol_receiverS">

<property name="CustomIcon" value="partsPistol_receiver"/> <property name="CustomIconTint" value="00C9CC"/>

<property name="Extends" value="partsMaster"/>

<property name="RepairTools" value="repairKitS"/>

<property name="DescriptionKey" value="partsPistolGroupDesc"/>

<property name="PartType" value="Receiver"/>

<property name="Weight" value="20"/>

<property class="Attributes">

<property name="FalloffRange" value="22,50"/>

<property name="DegradationMax" value="2000,5000"/>

</property>

<property name="EconomicValue" value="412"/>

</item>

<item id="2010" name="partsPistol_partsS">

<property name="CustomIcon" value="partsPistol_parts"/> <property name="CustomIconTint" value="00C9CC"/>

<property name="Extends" value="partsMaster"/>

<property name="RepairTools" value="repairKitS"/>

<property name="DescriptionKey" value="partsPistolGroupDesc"/>

<property name="PartType" value="Pump"/>

<property name="Weight" value="10"/>

<property class="Attributes">

<!-- <property name="Accuracy" value="1,0.01"/> -->

<property name="DegradationMax" value="2000,5000"/>

</property>

<property name="EconomicValue" value="412"/>

</item>

<item id="2011" name="partsPistol_barrelS">

<property name="CustomIcon" value="partsPistol_barrel"/> <property name="CustomIconTint" value="00C9CC"/>

<property name="Extends" value="partsMaster"/>

<property name="RepairTools" value="repairKitS"/>

<property name="DescriptionKey" value="partsPistolGroupDesc"/>

<property name="PartType" value="Barrel"/>

<property name="Weight" value="10"/>

<property class="Attributes">

<property name="EntityDamage" value="13,19"/>

<property name="BlockDamage" value="7,13"/>

<property name="DegradationMax" value="2000,5000"/>

</property>

<property name="EconomicValue" value="412"/>

</item>
recipes.xml

Code:

<recipe name="repairKitS" count="1" craft_area="workbench"><ingredient name="diamondSteelAlloy" count="1"/>

<ingredient name="electricParts" count="5"/>

<ingredient name="electronicParts" count="5"/>

<ingredient name="repairKit" count="1"/>

</recipe>
Code:

<recipe name="partsPistol_gripS" count="1" craft_area="workbench"><ingredient name="partsPistol_grip" count="1"/>

<ingredient name="solarCell" count="1"/>

<ingredient name="diamondSteelAlloy" count="10"/>

<ingredient name="repairKitS" count="1"/>

</recipe>

<recipe name="partsPistol_receiverS" count="1" craft_area="workbench">

<ingredient name="partsPistol_receiver" count="1"/>

<ingredient name="solarCell" count="1"/>

<ingredient name="diamondSteelAlloy" count="10"/>

<ingredient name="repairKitS" count="1"/>

</recipe>

<recipe name="partsPistol_partsS" count="1" craft_area="workbench">

<ingredient name="partsPistol_parts" count="1"/>

<ingredient name="solarCell" count="1"/>

<ingredient name="diamondSteelAlloy" count="10"/>

<ingredient name="repairKitS" count="1"/>

</recipe>

<recipe name="partsPistol_barrelS" count="1" craft_area="workbench">

<ingredient name="partsPistol_barrel" count="1"/>

<ingredient name="solarCell" count="1"/>

<ingredient name="diamondSteelAlloy" count="10"/>

<ingredient name="repairKitS" count="1"/>

</recipe>
 
Alternatively, If you are looking for the regular pistol to be able to fire regular and incendiary rounds, you could add a new bullet with a fire buff to items.xml:

Code:
<item id="xxxx" name="9mmBulletINC">
<property name="Extends" value="9mmBullet" />
<property name="DescriptionKey" value="BulletINCDesc"/>
<property class="Attributes">
	<property name="GetQualityFromWeapon" value="true" />
	<property name="ApplyBuff" value="1,1" param1="burning" />
</property>
</item>
Any melee items that you want to have the burning effect, just do something similar. Extend the base club, then add a buff.

Then you want to edit the Magazine properties for gunPistol to be able to use the ammo:

Code:
<item id="40" name="gunPistol">
       ...(don't put the dots, i just omitted a bunch of lines to show you where to focus)
<property name="Magazine_items" value="9mmBullet[color="#FF0000"],9mmBulletINC[/color]" />
<property name="Magazine_item_ray_counts" value="1[color="#FF0000"],1[/color]"/>
<property name="Magazine_item_ray_spreads" value="0.85[color="#FF0000"],0.85[/color]"/>
...
</item>
Every new ammo type you add, just put a comma and the new values on those 3 lines for each type of gun you want to be able to use the ammo. Then when you hold down R in-game, you'll see the new ammo types. I use custom icons for my mods, but if you don't want to use your own icons you can always just tint the regular bullet icon red by adding these 2 lines to the new bullet you made:

Code:
<property name="CustomIcon" value="9mmBullet"/>
<property name="CustomIconTint" value="FF0000"/>
If you want to release the mod in stages based on player level, the best way to do that might be with perks. Then you can have stage one give you the recipes for xxxx and stage two give you the recipes for yyyy. In progression.xml you would do something like this:

Code:
<perk name="Incendiary Ammo" icon="gunsmithing" description_key="INCAmmoDesc" title_key="INCAmmo" max_level="2" skill_point_cost_multiplier="0" skill_point_cost_per_level="10" group="weapons">

       <requirement perk_level="1" required_skill_name="craftSkillGuns" required_skill_level="5"/>
<requirement perk_level="1" required_player_level="25"/>
<recipe name="9mmBulletINC" unlock_level="1"/>
<recipe name="xxxxxx" unlock_level="1"/>

       <requirement perk_level="2" required_skill_name="craftSkillGuns" required_skill_level="10"/>
<requirement perk_level="2" required_player_level="50"/>
<recipe name="yyyyyy" unlock_level="2"/>		
<recipe name="yyyyyy" unlock_level="2"/>
</perk>
I set it up so there are some perk requirements for level one and two, as you can see. Then each recipe won't be able to be made until the player reaches certain levels and buys this perk.

Lastly, especially if you are doing custom icons, you might as well put in descriptions of things so it looks like a finished product. You would do this in Localization.txt. Add entries for all of the items, perks, descriptions, etc.

Code:
9mmBulletINC,items,Ammo,,9mm Incendiary Bullet,,
BulletINCDesc,items,Ammo,,"These bullets have been modified to ignite the target on fire on impact.",,
INCAmmo,progression,Skill,,Incendiary Ammo,,
INCAmmoDesc,progression,Skill,,"This ammunition will burn enemies on impact",,
Of course, you also need to add recipes to recipes.xml for whatever new ammo and weapons you make.

Modding is a lot of fun, so just keep asking questions and playing around. One suggestion is to never change too much at once. Focus on one mod at a time, then test to make sure it works before trying to do another. It can be a real pain to track down errors when you've done too many things at one time.

Note: any custom icons and localization files do not get pushed from a server to the clients, so they need to be installed to your local install directory, and you need to be out of 7DTD when you do it. If you are in-game when you install the icons/localization files, you won't be able to see the changes until you completely exit.

 
Last edited by a moderator:
Thank you so much this was a huge help! The only thing is i want the shock or fire buff to not be on the Ammo, but the firearm itself. Is it as easy as just adding that property (buff) like i do with melee weapons? Or does it HAVE to be on a new form of ammunition? Thank you for your help with everything I think im starting to get it. One thing I have desperately wanted to do was add my own icons, im an artist so I was just going to hand draw them. The thing is I have no idea the steps needed to add my own icon and apply it to a weapon or item? I've already done what you said with my starter club, i found localization.txt by reading the code and realizing it was linked to nameing and descriptions, and I found the icon Tint so I use that for now. I just need to know how to apply my own Icons. Also how would I tie the recipes direcly to a skills level rather than a perk? Or is it better to make my own perks and have those unlock the new recipes as you have done? Once again you are a love saver, thanks for taking the time to answer my questions :)

 
You can definitely try what ExeBT shared, but learning to used the Extends property is your friend...really cleans up the code. Of course if you want to change the parts, the repair kit, materials, entity damage, etc., you need to include those lines. If you just want a pistol that burns, and don't want to change anything else, it can be as simple as this:

Code:
<item id="xxxx" name="gunPistolBurning">
<property name="Extends" value="gunPistol"/>		
<property class="Action0">
	<property name="Buff" value="burning"/>
	<property name="BuffChance" value="1"/>
</property>
</item>
For adding icons, I would suggest you look at something like what Valmod has done. I'd share my own icon pack, but i don't know if that's really allowed here or not. You need a Mods folder in your main 7DTD directory. Then inside of the Mods folder create a folder with the name of your mod (NeonIcons or something). Inside that folder you have an ModInfo.xml file with just the info about your mod, and an ItemIcons folder that's going to contain all of your icons. (you can put block and item icons in here, despite the name). The icons need to be 116x80 .png files. If you name them the same name as your modded item, then you don't need to do any CustomIcon line or anything, they will just work.

The ModInfo.xml should look like this:

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<xml>
<ModInfo>
	<Name value="NeonIcons" />
	<Description value="Custom icons for NeonScorpion's mods" />
	<Author value="Created by NeonScorpion" />
	<Version value="1" />
	<Website value="http://www.whatever.com" />
</ModInfo>
</xml>
As far as tying a recipe to a skill level (or a player level for that matter) the perk is the way to do it. I don't believe there is anyway to just magically unlock a recipe when a certain level is hit. Now you can make the perk only cost like 1 point if you don't want people to have to pay a lot for it in skill points.

 
Last edited by a moderator:
Awesome thank you so much you are a godsend! Exactly what I needed to know! Thanks for all the tips too, ill keep all of this in mind. :)

Real quick, just so i totally understand, what exactly does the Extends command do? Does it just tell the code to "Copy this items code but also modify it by the below added properties"? So if I want to make 5 clubs that are all really similar except for a single buff change, such as the item for each version of the barbed club but with a different level of fire mod. I could just make a base club with stats, then make a few items that extend that base club and only add the specific fire buff?

For example would it allow me to make a weapon...

ClubBarbedFireMods

Then give it a normal barbed club code.

Then add 4 items that for example just say...

Extend ClubBarbedFireMods

And add Buff Burning

Then do this with the other 3 or so possible versions? If so that would be great because I was dreading coding a new weapon version not only for each weapon in the game but for each mod it could potentially get. That would nearly quadruple the weapons because i would have to code a single of the 4 levels of club each with the 4 possible fire mods you could paply to them. And that's not even for the other buffs I want to do like Shocking. Would Extend allow me to quickly make those duplicate items for use without having to fully write out and code them each individually? I hope that makes sense.

 
Last edited by a moderator:
Sorry for the delay, I didn't check back up on this. But, yes, for the most part. Extends copies just about all of the properties of the main item, and whatever lines you include after the Extends are the ones you want to modify. There are some things that Extends doesn't copy (like an item being Dev only), but most of the basic things do Extend.

 
Back
Top