# Adding new items and weapons

**URL:** <https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360>\
**Category:** The Toolbox\
**Created:** [May 21, 2013, 7:03pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360 "2013-05-21T19:03:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClaytonRISING](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/claytonrising/32/75_2.png) [@ClaytonRISING](https://discourse.cataclysmdda.org/u/ClaytonRISING)\
**Post date:** [May 21, 2013, 7:03pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/1 "2013-05-21T19:03:41Z")

</div>

I couldn’t find a thread for simple questions on modding/technical details, so I apologize in advance for this seemingly redundant thread. If there is a better place for it, or if it should be delete, please feel free to do so.

I have been looking through the new json files and everything seems simple enough. But my question is: say I wanted to add a new rifle, is it as simple as just making a new entry for it in the ranged.json? Or do I have to edit other files for it to show up in game and useable?

I know how to edit the files, that’s not the question haha.

---

<div class="post-metadata">

**Author:** ![drake1storm](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@drake1storm](https://discourse.cataclysmdda.org/u/drake1storm)\
**Post date:** [May 21, 2013, 7:13pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/2 "2013-05-21T19:13:35Z")

</div>

Will this rifle use an already existing type of ammo?

If you want it to spawn naturally, you will have to add it to the relevant lists in the various map files.

---

<div class="post-metadata">

**Author:** ![ClaytonRISING](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/claytonrising/32/75_2.png) [@ClaytonRISING](https://discourse.cataclysmdda.org/u/ClaytonRISING)\
**Post date:** [June 2, 2013, 9:20pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/3 "2013-06-02T21:20:32Z")

</div>

Yes, I wasn’t going to add a new ammo for it.

---

<div class="post-metadata">

**Author:** ![Soron](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/soron/32/885_2.png) [@Soron](https://discourse.cataclysmdda.org/u/Soron)\
**Post date:** [June 2, 2013, 10:42pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/4 "2013-06-02T22:42:33Z")

</div>

Yeah, you just need to add a new entry to the appropriate JSON file, then. Although, as drake1storm points out, it won’t spawn naturally without editing the actual source code, because the spawn lists haven’t been pushed out to data files yet.

---

<div class="post-metadata">

**Author:** ![ClaytonRISING](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/claytonrising/32/75_2.png) [@ClaytonRISING](https://discourse.cataclysmdda.org/u/ClaytonRISING)\
**Post date:** [June 2, 2013, 10:47pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/5 "2013-06-02T22:47:11Z")

</div>

Roger that, capt’. I appreciate the responses, thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/cataclysmdda/original/1X/21b5d044e8473b25d0bf905d60477e25f6fbe0cf.png) [@system](https://discourse.cataclysmdda.org/u/system)\
**Post date:** [June 3, 2013, 1:20am UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/6 "2013-06-03T01:20:54Z")

</div>

Modify an existing rifle, keep the world gen name. Change everything else.

---

<div class="post-metadata">

**Author:** ![ClaytonRISING](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/claytonrising/32/75_2.png) [@ClaytonRISING](https://discourse.cataclysmdda.org/u/ClaytonRISING)\
**Post date:** [June 3, 2013, 1:24am UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/7 "2013-06-03T01:24:41Z")

</div>

> [@gtaguy](#):
>
> Modify an existing rifle, keep the world gen name. Change everything else.

Ah, good idea. I didn’t even think about that. But would the ID of the new weapon have to be registered in another file?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/cataclysmdda/original/1X/21b5d044e8473b25d0bf905d60477e25f6fbe0cf.png) [@system](https://discourse.cataclysmdda.org/u/system)\
**Post date:** [June 3, 2013, 1:28am UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/8 "2013-06-03T01:28:27Z")

</div>

Basically if it has the name of something else that works everything should be fine. It should spawn and be awesome. The crafting recipes will be different I think as the In-game name and the crafting menu names are different.

---

<div class="post-metadata">

**Author:** ![KA101](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@KA101](https://discourse.cataclysmdda.org/u/KA101)\
**Post date:** [June 3, 2013, 2:29am UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/9 "2013-06-03T02:29:25Z")

</div>

Now, I take it that renaming an existing gun takes that existing gun out of the game. Obvious, but worth checking.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/cataclysmdda/original/1X/21b5d044e8473b25d0bf905d60477e25f6fbe0cf.png) [@system](https://discourse.cataclysmdda.org/u/system)\
**Post date:** [June 3, 2013, 5:25am UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/10 "2013-06-03T05:25:58Z")

</div>

Yes, having two entires with the same name causes errors.

---

<div class="post-metadata">

**Author:** ![halberdsturgeon](https://avatars.discourse-cdn.com/v4/letter/h/7ab992/32.png) [@halberdsturgeon](https://discourse.cataclysmdda.org/u/halberdsturgeon)\
**Post date:** [June 6, 2013, 10:09am UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/11 "2013-06-06T10:09:20Z")

</div>

If you’re interested in actually creating a completely new item, and want to brave the source code, I believe the only file you’d need to modify to add the item to the game’s spawn lists is mapitemsdef.cpp.

---

<div class="post-metadata">

**Author:** ![Wayfarer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/wayfarer/32/76_2.png) [@Wayfarer](https://discourse.cataclysmdda.org/u/Wayfarer)\
**Post date:** [June 7, 2013, 2:27am UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/12 "2013-06-07T02:27:33Z")

</div>

Has anyone ever made a shield? In the code I noticed the technique wblock\_3 which the comment describes as a good block - shield. Got to thinking it could be cool to have shields, perhaps craftable even. Not a medieval game I know, but there’s some medieval weapons already…perhaps your survivor was into medieval reenactments heh. But I don’t know how that’d be handled by the equipment/wielding system.

On another note, a nice addition to the sci-fi side of the game might be melee weapons that were modified with attached power sources to inflict shocking damage on successful strikes, at the cost of a finite charge number, which could be recharged by replacing or recharging the power source. Likewise I don’t know how to code that…

---

<div class="post-metadata">

**Author:** ![i2amroy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/i2amroy/32/909_2.png) [@i2amroy](https://discourse.cataclysmdda.org/u/i2amroy)\
**Post date:** [June 7, 2013, 7:58am UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/13 "2013-06-07T07:58:46Z")

</div>

For the shield I believe you can wield manhole covers as shields right now (though you can’t also wield a weapon at the same time). Sadly shields probably won’t be too much addressed until we manage to get dual-wielding in, at which point they would become more useful (though there is always the chance someone could add one in earlier).

As for lightning weapons, that might not be too bad of an idea. We’ve already got electroshock batons in real life, so I could certainly see at least adding those in (and being able to craft your own, they aren’t exactly complex devices :P).

---

<div class="post-metadata">

**Author:** ![Soron](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/soron/32/885_2.png) [@Soron](https://discourse.cataclysmdda.org/u/Soron)\
**Post date:** [June 7, 2013, 8:05am UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/14 "2013-06-07T08:05:28Z")

</div>

An electrified weapon would be really nifty, and we’ve got the ability to add flags to items post-creation. It would be entirely possible to modify weapons on the fly, if someone wrote up the code for it.

It could probably be done via an Electronics craft, with either Mechanics or Melee as a secondary skill?

---

<div class="post-metadata">

**Author:** ![kevin.granade](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/kevin.granade/32/1316_2.png) [@kevin.granade](https://discourse.cataclysmdda.org/u/kevin.granade)\
**Post date:** [June 7, 2013, 5:54pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/15 "2013-06-07T17:54:16Z")

</div>

I think the item spawn lists will be one of the next targets for JSON-ification, also we definitely need to put together a serious modding guide.

---

<div class="post-metadata">

**Author:** ![Slax](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/slax/32/5385_2.png) [@Slax](https://discourse.cataclysmdda.org/u/Slax)\
**Post date:** [June 7, 2013, 11:30pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/16 "2013-06-07T23:30:31Z")

</div>

Just popping in for a visit.  
Another electronics craft could be a laser sight. Perhaps just a conference demonstration pen with some duct tape on it or a complete craft in itself. Good for a short range to-hit bonus. Rendered mute with actual firearms/weapon skill. Probably more effective in darkness.

---

<div class="post-metadata">

**Author:** ![Isylwin](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@Isylwin](https://discourse.cataclysmdda.org/u/Isylwin)\
**Post date:** [June 8, 2013, 9:23pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/17 "2013-06-08T21:23:59Z")

</div>

Hi,

I was looking through the source code because I was interested in adding some (flavour) items and I came across code\_doc/EDITING and it stated there that I should add this and that in itype.h and itypedef.cpp and mapitemsdef.cpp and doesn’t mention the JSON files mentioned here.  
From this forum I’ve percieved that you can add items to the game by adding them to the corresponding .JSON file (but that it doesn’t gen the new item?).  
So my question: If I want to add an item and make it spawn in the corresponding area’s within the game where should I add stuff and codes and stuff?

Many thanks in advance,  
Isy

---

<div class="post-metadata">

**Author:** ![Soron](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/soron/32/885_2.png) [@Soron](https://discourse.cataclysmdda.org/u/Soron)\
**Post date:** [June 8, 2013, 10:29pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/18 "2013-06-08T22:29:42Z")

</div>

Yeah, that EDITING file is out of date now.

To add the items to the game, edit the appropriate JSON file in data/raw/items/, and add a new entry. Take note of the “id” field - it has to be unique, free of spaces, and it will be needed later.

To actually get it to spawn, you need to edit mapitemsdef.cpp, and add the item ID from before to the appropriate lists.

---

<div class="post-metadata">

**Author:** ![Isylwin](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@Isylwin](https://discourse.cataclysmdda.org/u/Isylwin)\
**Post date:** [June 9, 2013, 12:49pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/19 "2013-06-09T12:49:50Z")

</div>

K, thanks 🙂 another little question though, if I want to check flags or add flags, for instance the str req for a bow how would I be able to do that?

---

<div class="post-metadata">

**Author:** ![DinoCat](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/dinocat/32/837_2.png) [@DinoCat](https://discourse.cataclysmdda.org/u/DinoCat)\
**Post date:** [June 9, 2013, 1:20pm UTC](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360/20 "2013-06-09T13:20:45Z")

</div>

You can add the flag in the JSON entry, but for it to take effect, you also need to code in its effect in game.cpp (game::plfire) and item.cpp (item::range). Search for STR8\_DRAW in the files to see how they are used.

[Next page](https://discourse.cataclysmdda.org/t/adding-new-items-and-weapons/1360.md?page=2)
