Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable items with the mod manager #5993

Merged
merged 1 commit into from Feb 7, 2014
Merged

Conversation

BevapDin
Copy link
Contributor

@BevapDin BevapDin commented Feb 6, 2014

Because some items are referenced in the code directly, removing them from the json data is problematic. Similar, but much more serious for other things like skills, terrain, furniture ...

This PR add a new json type: ITEM_BLACKLIST (not the best name for it, any suggestions?)

It will remove the items from all item_groups and all recipes that have this item as result.
If the item appears as component/tool of a recipes it is removed there, too. If this leaves an empty component/tool list (which means item was required and there were no alternatives for it), the recipe is removed, too.

The item definition is not changed, the item will still spawn when the C++ code contains the item id directly (or the mapgen spawns it directly and not as part of an item group). Everything (including saves) will still have the item and the item will work like before (with the exception that it can not be used in crafting directly, but its item quality can still be used in crafting).
Same with construction.

For testing, put this in a json file that is loaded by the game (either something in data/json, or something in save/my-world/mods).

{
    "type": "ITEM_BLACKLIST",
    "items": ["veggy_wild", "rock"]
}

The rock item is in the normal field spawn list and wandering around gives fields that contain strawberries but no rocks. All the stone based tools have no recipe anymore. Recipes that allow a rock as alternatives for a hammer are still there, but with the rock as tool. Burning down a house will still give you rocks as this is coed in C++ and does not refer to a spawn list. The results of deconstruction of furniture/terrain is fixed in the code and not influenced hereby.

The blacklist is applied after loading all mods, so it applies to item groups/recipes from other mods, too. No to prevent that one can make a ITEM_WHITELIST which removes the item from the blacklist. Is this feasible?

Shall I add a similar thing for monsters?

@Zireael07
Copy link
Contributor

Woah, this is golden! A great solution to the modularization/personalization problem!

@VampyreLord
Copy link
Contributor

I guess it is appreciated if you do the same with monsters, as removing monsters from the monsters-spawns and compile it as a mod is not enough.

@kevingranade
Copy link
Member

Will look at the code tonight, but it sounds like we're half way to mod
manager mk II already!
And yes, if you're interested, a monster blacklist would be good. Ideally
we'd be able to blacklist any json entity.
Now we just need a fancy UI to generate blacklists ;)

@MisterFelixFox
Copy link
Contributor

How does this affect probability? Forgive me if it's obvious, but I don't know the spawn generation code that well.

If item A had a spawn chance of 10% of the time while items B and C each had a spawn chance of 45%, would item A still only spawn 10% of the time if B and C were blacklisted?

@BevapDin
Copy link
Contributor Author

BevapDin commented Feb 6, 2014

Item spawn chances are relative. If the item group contains an item A with chance 10 and an item B with chance 40, item B will be spawned in 4 of 5 invocations. The item removal code respects that. The number of item generated will not chance, but their number is distributed among fewer types. This is inverse to adding an item to the item groups.

Edit: wrong button.

@BevapDin BevapDin closed this Feb 6, 2014
@BevapDin BevapDin reopened this Feb 6, 2014
@MisterFelixFox
Copy link
Contributor

Okay, that makes sense. Thanks!

@KA101 KA101 self-assigned this Feb 7, 2014
@KA101
Copy link
Contributor

KA101 commented Feb 7, 2014

May as well add it for critters, too. Not a merge-blocker, though.

@KA101 KA101 merged commit d91d8cc into CleverRaven:master Feb 7, 2014
@KA101
Copy link
Contributor

KA101 commented Feb 7, 2014

It's vitally important to capitalize that blacklist name. Lowercasing it breaks things. Badly.

@BevapDin BevapDin deleted the mod-man branch February 7, 2014 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants