# Help with weapon fire time

**URL:** <https://discourse.cataclysmdda.org/t/help-with-weapon-fire-time/22027>\
**Category:** The Toolbox\
**Tags:** mod\
**Created:** [November 22, 2019, 2:00pm UTC](https://discourse.cataclysmdda.org/t/help-with-weapon-fire-time/22027 "2019-11-22T14:00:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheeptime](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sheeptime](https://discourse.cataclysmdda.org/u/sheeptime)\
**Post date:** [November 22, 2019, 2:00pm UTC](https://discourse.cataclysmdda.org/t/help-with-weapon-fire-time/22027/1 "2019-11-22T14:00:19Z")

</div>

Hello everyone  
I have just started a new mod project that aims to change the game’s gunplay element  
It is a mod mostly because of the player base of CDDA seems to have some disagreement around how the firearms should be balanced and handled in the vanilla base game.  
Features I planned to add are:

- more guns
- more firearm-related location (shooting range, firearm factory and SHOT Show etc.)
- A more complex firearm modification system
- A “martial arts” for firearms ( fanfire, double tap and mad minute etc.)
- more professions
- more specific skill for each type of firearms

Most of the work can be done through editing json file and is pretty easy, but I have trouble once I need to touch the hard code of the game.  
Right now I am trying to separate the rifle skill to manual action and automatic.  
I want different firearms require different action point to fire (not aiming time)  
It seems like the action point required by each type of ranged weapon is hardcoded in ranged.cpp  
Code is linked here

int time\_to\_fire( const Character &p, const itype &firing )  
{  
struct time\_info\_t {  
int min\_time; // absolute floor on the time taken to fire.  
int base; // the base or max time taken to fire.  
int reduction; // the reduction in time given per skill level.  
};

```
static const std::map<skill_id, time_info_t> map {
    {skill_id {"pistol"}, {10, 80, 10}},
    {skill_id {"shotgun"}, {70, 150, 25}},
    {skill_id {"smg"}, {20, 80, 10}},
    {skill_id {"rifle"}, {30, 150, 15}},
    {skill_id {"archery"}, {20, 220, 25}},
    {skill_id {"throw"}, {50, 220, 25}},
    {skill_id {"launcher"}, {30, 200, 20}},
    {skill_id {"melee"}, {50, 200, 20}}
};

const skill_id &skill_used = firing.gun->skill_used;
const auto it = map.find( skill_used );
// TODO: maybe JSON-ize this in some way? Probably as part of the skill class.
static const time_info_t default_info{ 50, 220, 25 };

```

I have zero experience in programming, and adding {skill\_id {“boltaction”}, {70, 400, 20}} did not work. (I have added the new skill in skill.json already)  
Can anyone provide some help with this problem?  
Thank you very much

---

<div class="post-metadata">

**Author:** ![Junknown](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@Junknown](https://discourse.cataclysmdda.org/u/Junknown)\
**Post date:** [November 22, 2019, 2:25pm UTC](https://discourse.cataclysmdda.org/t/help-with-weapon-fire-time/22027/2 "2019-11-22T14:25:28Z")

</div>

The problem is that you can’t change hardcoded C++ with a JSON mod. Doing what you want would require you to edit the source code and recompile it.

---

<div class="post-metadata">

**Author:** ![sheeptime](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sheeptime](https://discourse.cataclysmdda.org/u/sheeptime)\
**Post date:** [November 24, 2019, 1:14am UTC](https://discourse.cataclysmdda.org/t/help-with-weapon-fire-time/22027/3 "2019-11-24T01:14:13Z")

</div>

Learnt how to use basic c++ code and programs for it  
Thanks for the help
