Coding error

Hey all, so I’ve been trying to make a custom weapon in my game but everytime I make it it was something that says Item error. I can change specs of any weapon I want, but it seems if I change the name it glitches out. Now I’m just changing the code in the RAW file… am I doing something wrong? Cause I can change it seems everything but the item name if I do it says the item doesn’t exist or some kind of error :confused:

What kind of custom weapon are you making? If it’s just a simple item with no use function then it’s simple to edit json files. other wise hard coding is needed.

post it here so we check what’s wrong.

So here is the code I want to use.

{
“id”: “shoota”,
“type”: “GUN”,
“symbol”: “(”,
“color”: “grey”,
“name”: “shoota”,
“description”: “One of the most recognizable assault rifles ever made, the AK-47 is renowned for its durability even under the worst conditions.”,
“rarity”: 5,
“price”: 100,
“material”: [“iron”, “wood”],
“flags”: “MODE_BURST”,
“skill”: “rifle”,
“ammo”: “7.62x39mm”,
“weight”: 20,
“volume”: 12,
“bashing”: 14,
“cutting”: 0,
“to_hit”: 2,
“ranged_damage”: 0,
“range”: 0,
“accuracy”: 4,
“recoil”: 8,
“durability”: 9,
“burst”: 3,
“clip_size”: 30,
“reload”: 250
},

And the recipie

{
“result”: “shoota”,
“category”: “CC_WEAPON”,
“skill_pri”: “mechanics”,
“skill_sec”: “gun”,
“difficulty”: 2,
“time”: 4000,
“reversible”: true,
“autolearn”: true,
“tools”: [
[
[“rock”, -1],
[“toolset”, -1]
],
[
[“screwdriver”, -1],
[“toolset”, -1]
]
],
“components”: [
[
[“pipe”, 1]
],
[
[“2x4”, 1]
]
]
},

All I did was simply change the name of a gun in the system that was already there, change some specs around, and I am getting silly errors :confused:

well instead of changing an existing item you should add the item separately into the list instead as the original item would still be in mapitemsdef.cpp for spawning and giving you that error because it’s not in the game due to the original item being edited out.

Simply restore the AK-47 back add your new item to the list and it should be working fine.

Oh wow! Thank you so much it works now, I feel like such an idiot haha.

Now I am having another issue, I made custom ammo for the shoota but when I try and reload it says it doesnt reload normally… what causes this error?

no problem people here are happy to help, don’t be afraid to ask questions and yeah sometimes it’s just the problem of missing a symbol like , ; } { "

also if you want items to spawn you can edit mapitemsdef.cpp and place them in appropriate locations before the null with their ID.


Custom ammo eh? well that requires the addition of custom ammo to be hard coded post me the custom ammo description, anyway if it’s in the game you can just change it’s ammo type “ammo”: “9mm”, like this

Thanks for all the help :smiley:

The ammo is:
{ “type” : “AMMO”,
“id” : “bolt_shot”,
“rarity” : 2,
“price” : 100,
“name” : “bolt shot”,
“symbol” : “=”,
“color” : “red”,
“description” : “A heavy metal slug used with shootas.”,
“material” : “plastic”,
“volume” : 2,
“weight” : 34,
“bashing” : 1,
“cutting” : 0,
“to_hit” : 0,
“ammo_type” : “boltshot”,
“damage” : 50,
“pierce” : 5,
“range” : 16,
“accuracy” : 5,
“recoil” : 28,
“count” : 25,
“effects” : [“COOKOFF”]
},

The recipie is:

{
“result”: “bolt_shot”,
“category”: “CC_AMMO”,
“skill_pri”: “gun”,
“skill_sec”: “mechanics”,
“difficulty”: 1,
“time”: 2500,
“reversible”: false,
“autolearn”: true,
“tools”: [
[
[“rock”, -1]
],
[
[“fire”, -1],
[“toolset”, 1],
[“press”, 2]
]
],
“components”: [
[
[“rock”, 1]
],
[
[“pipe”, 1]
],
[
[“rock”, 1]
],
[
[“rock”, 1]
]
]
},

I’m not sure if I did anything wrong, or maybe I should just use ammo in game already?

Well for bolt_shot to be added to the game it needs some hard coding and on the recipe instead of putting multiple rock 1 as requirements just increase their number as it can crash your game.

I’m assuming bolt_shot=bolts? if not then It’s gonna need some hard coding which can be done by adding them. It’s gonna take a bit to make it work but I can show where to edit those and help fixing it.

I wasn’t planning on having those rocks in the actual list, I just put them to try it out and see if it works, since there are a lot of rocks laying around the home evac station.

I tried switching the ammo for the gun and that worked perfectly :smiley: I may just use other ammo as to avoid hard coding, cause I’ll be honest, I’m terrible with computers haha, I may just have it use the same ammo as ak-47s do, seems a lot easier than making something new out of thin air.

But actually bolt shots are small missile like bullets, if you have ever played Warhammer 40,000? The gun is practically a rapid fire mini grenade launcher, but is really a machine gun. Fun stuff it is.

well changing it’s ammo type to grenade should give it that equivalent effect. probably not that accurate though.