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

fix: shopkeepers properly generate shopkeeper_item_group if different from carry_override, generic arsonist NPCs no longer overloaded with loot #4637

Merged
merged 3 commits into from May 15, 2024

Conversation

chaosvolt
Copy link
Member

@chaosvolt chaosvolt commented May 12, 2024

Purpose of change

A while back I noticed that NPC arsonists spawned with an absolute fuckload of stuff, because I'd been adamant about letting the arsonist NPC class be usable by both the unique refugee center shopkeep and random NPCs.

What was going to be a nice simple lil JSON fix turned into a giant pain in the dick as I found I needed to change some codeto actually fix NPC shopkeepers being able to have different itemgroups in shopkeeper_item_group and carry_override.

This should as a side effect fix cases like the chemist NPC where the NPC class has only shopkeeper_item_group defined potentially failing to generate starting inventory too.

Describe the solution

C++ changes:

  1. In npc.cpp, updated npc::load_npc_template so that any NPC set to count as a shopkeeper checks fort he presence of shopkeeper_item_group and, if found, clears out their starting items and properly fills it with the full contents of that group. Currently doesn't respect faction value stuff and other behaviors in npc::shop_restock but I kinda really would like to fuck with that in a follow up PR and fix any potential jank in it.
  2. In npctrade.cpp, set npc_trading::trade so that shop_restock is only called by NPCs set to count as shopkeepers, preventing any potential case of a non-shopkeeper NPC whose class has shopkeeper_item_group defined from magically devouring every item in their inventory and regenerating fresh ones from thin air.

JSON changes:

  1. Greatly expanded the variety of stuff and added variation in quantity to NC_ARSONIST_STOCK, with most of the stuff broken up into specific distributions to roll for. Less huge stacks of stuff overall but now can be a good source of components to make their explosives, various scrap metals, and a slightly wider range of books. Lot less molotovs and pipe bombs but more of the components to make your own, and more salvage.
  2. Defined itemgroup NC_ARSONIST_carry_misc. It's basically NC_ARSONIST_STOCK but minus the Merch and with much lower amounts of stuff, since carried by plain NPCs without magical shopkeeper powers.
  3. Deleted the arsonist NPC class' carry_override, separate from shopkeeper_item_group. Idea is that generic arsonists that spawn in the wild will make use of the previously de-facto obsolete NC_ARSONIST_misc while Makayla sells more stuff overall.
  4. Updated contents of NC_ARSONIST_misc to have a different range of weights, removed excess clothing and an obsoleted weapon from it, added calls to NC_ARSONIST_STOCK_crafting_supplies and NC_ARSONIST_STOCK_scrap.

Describe alternatives you've considered

  1. Making the arsonist NPC class no longer available as a generic NPC class, like DDA does. That would've been so much easier but doing it thisway forces me to confront and fix some lingering jank in the hardcode anyway.
  2. Making the refugee center's arsonist use the same itemgroup as generic ones and instead spawning a bunch of extra loot in a faction-owned shopping cart. Problems are those items won't naturally restock like shopkeeper inventory, plus Makayla is set to "no faction" currently.

Testing

  1. Checked affected JSON files for syntax and lint errors.
  2. Spawned in evac shelter until I got an arsonist NPC, traded with them to confirm their inventory looked tolerable.
  3. Started anew in the refugee center and traded with the arsonist NPC there. Her inventory starts off full of stuff as finally expected.
  4. Checked affected C++ files for astyle.

Generic arsonist:
image

Refugee center arsonist:
image

Sometimes she doesn't spawn with their grenades stacked properly and I dunno why the game does that.

Additional context

Checklist

…nt from `carry_override`, generic arsonist NPCs no longer overloaded with loot
@github-actions github-actions bot added src PR changes related to source code. data PRs related to datas. Won't crash game (probably) labels May 12, 2024
@chaosvolt
Copy link
Member Author

Oh yeah, using the hardcoded method of defining an itemgroup called NC_ARSONIST_misc is also an option instead of carry override, maybe?

@Lamandus
Copy link
Contributor

grafik
...

Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, hardcoded exception cases, my favorite

@chaosvolt chaosvolt merged commit ec979f5 into cataclysmbnteam:main May 15, 2024
13 checks passed
@chaosvolt chaosvolt deleted the arsonist-carry-tweak branch May 15, 2024 18:05
@Ignaramico
Copy link

grafik ...

to beat the enemy, you need to know it xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data PRs related to datas. Won't crash game (probably) src PR changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants