Need help on item-spawning for mod

so basically i’ve been working on a mod and follows the rule of making mods and all but something makes me stuck here,

to make item spawn naturally in the world, i have to create an item group, and i’ve already made it. but then here comes the question:

  1. where does the item spawn? is it set automatically by the game or
    user-set spawn?
  2. how much spawn weight should i put for an item that is rare to be found, but not too rare?

that’s all the question i had… please let me know.

There are two methods for getting your item in the game, that I’m aware of. You can add it to a preexisting item group, which will then make it appear anywhere the mapgen places that group. If you create your own group, you wiull nbeed to make some corresponding mapgen that includes it.

edit: So if you’ve got a rare gun, add it to the ‘rare’ item group (I’m not clear on the syntax for this, I think you just create a copy of the group which only contains your item additons, these will be added to the itemgroup on load.) and give it a number corresponding to how rare you want it to be. Look at the other items in the goruip to get an idea of rarity.

owh, now that makes sense, since i made its own item group, it doesn’t spawn anywhere in the game (not even in science lab weaponry) even after playing for 2 hours.

You can use the spawn weight for diamonds if you want rare…
Or lower if you think diamonds are too easy too find.

One thing I’d absolutely recommend is a program similar to grepWin that will allow you to search all the json files quickly and easily. That makes hunting down examples of what you want to get done much easier. Notepad++ makes an excellent editor as well.

i was planning to set it to around 20-30. is it rare enough?

yes, i use notepad++, it is a perfect software for making JSON file, and also where i made the mod itself too.

{
“id”: “mansion_safe”,
“type”: “item_group”,
“subtype”: “collection”,
“items”: [
[ “diamond”, 20 ],
{ “group”: “stash_drugs”, “prob”: 5 },
[ “file”, 70 ],
{ “group”: “jewelry_front”, “prob”: 40 },
[ “money_bundle”, 50 ],
{ “group”: “mansion_guns”, “prob”: 95 },
{ “group”: “mansion_guns”, “prob”: 80 }
]
},

Back when i was trying to do a gem mod i set my gems to around… What was it 5-10 IIRC :3

Edit : Just checked it was 10.

that’s good tho, sounds like robbery safe.

Be aware of the difference between a collection and a distribution(the default). A collection will go down the list giving each item or group a chance to get called. A distribution will only spawn one item, the first item that succeeds in it’s roll. Items at the top are more likely to get a chance to roll.

1 Like

didn’t know that… Learn something new every day :smiley:

if i remember correctly, how i set my item group is :

“id”: “GT_guns_rifle”,
“type”: “item_group”,
“items”: [
[ “xvr_88”, 30 ]
]

I’m glad my hours of pounding my head against this game’s code have been helpful :wink:

@Ricky_Van That will be a distribution with a 30 percent chance to spawn the xvr_88. If you want to do some debugging, add the group to an existing item group, using the method shown in the mansion listing above. So your mods itemgroups json would include an entry like this, below the definition for the GT_guns_rifle group. This will call your group 100 percent of the time the game calls for a mansion_safe drops.
{
“id”: “mansion_safe”,
“type”: “item_group”,
“subtype”: “collection”,
“items”: [
{ “group”: “GT_guns_rifle”, “prob”: 100 }
]

1 Like

allright, i’ll put it on debug test now…

thanks for the help, will be back with the test result.

1 Like

debug test successful, yes it turns out i have to make a new mapgen for that which is not my specialty. so i have to rebuild the itemgroup from start again, now it uses default itemgroup.

That will tie it to a particular overmap special in order to get it spawning. Please set it’s freq from 0-whatever so you don’t add to the plague of ‘required’ overmap specials in the modding community. It should only have a minimum freq higher than 0 if you add missions that require that location to spawn in order to be completed.
Alternatively, I think it’s possible to make variants of existing mapgen that include your itemgroup. Like there’s a call for ‘gas station’ and the game has several different ‘gas station’ maps to choose from. I’m not sure how that’s done, maps aren’t my focus either.

me too, maps is just too difficult for me.

so i change all my itemgroups, instead of GT-weapon group, i use default group like “guns_rifle_rare” and more like that…

is it ok? and how about itemgroups for melee weapons?

Yeah, that works. Be aware you can nest collections and groups as deep as you want, which can give you amazing control over the spawns. You can also call an item_group from a monster via it’s death_drops. And when spawning guns, you can specify what ammo and whether or not to include a magazine for the entire group. The format for that is in the doc’s, can’t recall which file on the top of my head. Here’s an example from the fiasco that is the Bandit’s mod:
“type” : “item_group”,
“id” : “bandit_remington_700”,
“ammo”: 60,
“magazine”: 60,
“items”:[
[“remington_700”, 4],
[“3006”, 4]
]
}
This is a distribution(the default), has a small chance to spawn one of these rifles, and if it does theres a 60% chance of getting ammo and a 60% chance of a magazine in the rifle. I think these are being used redundantly here, one or the other probably is all that’s needed.

edit: As far as melee goes, you’ll have to go digging in the json :stuck_out_tongue:

yes i use the same format like that for the guns in my mod, and i set it so at 30 (maybe will change to 40) percent it will fully loaded with ammo and its magazine.

:smile: digging the docs again…

well…you could make a change to an existing monster by using copy-from and just including your modified death_drops entry. Or make your own monster with it’s custom deathdrops, add THAT to a monstergroup.