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.
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.
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.
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.
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…
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).
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?
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.
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?
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.
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.