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: Molotov Fix/Rework, make turn_per_charge less inconsistent. #5480

Merged
merged 11 commits into from
Oct 2, 2024

Conversation

KheirFerrum
Copy link
Collaborator

@KheirFerrum KheirFerrum commented Oct 1, 2024

Checklist

Required

Purpose of change

Describe the solution

  • Molotov behaviour is now changed in the following ways

    • Base molotov has no charges, instead it transforms into the lit molotov that has 1 charge.
      • Lit molotovs last 5 turns before extinguishing themselves and converting back into the uncharged molotov.
      • If a molotov is extinguished by water or rain, it will not stack with the other molotovs because internally it's considered to have 1 charge, even if its otherwise identical to the player.
    • Dropping a molotov no longer causes it to explode, and instead of exploding with no warning when you activate a lit molotov, it asks you if you really want to set yourself and the squares around you on fire.
  • Tool items with turns_per_charge now keep track of how long they have been active via turns_active variable.

    • If turns_active exceeds turns_per_charge the item consumes it's per use charges and resets turns_active.
    • Modified the foodperson helmet to keep track of this as well when telling you how much time is left on your shift.

Describe alternatives you've considered

  • Reworking the entire molotov iuse to make it more versatile for impact explosives.
    • I don't have time for this right now, so this will last as a stopgap measure that restores functionality until I have time to make it better than it was.

Testing

  • Molotovs can be activated, and extinguish after 5 turns or if they are exposed to rain/water
    • Molotovs explode when thrown, not when dropped, not when left on the floor, and not in your inventory.
    • Activating a lit molotov asks for confirmation before exploding all over you with sticky warm goo.
  • Foodperson helmet doesn't bug out when viewing shift.

Additional context

Fixes molotovs burning out too quickly due to my changes to charge handling.

Makes it so that active items will now keep track of the turns they've been active if they use turns_per_charge.

Molotovs now consume their own charges and burn out if left alone too long, they are reloaded with rags, one charge of which lasts about 5 turns.
@github-actions github-actions bot added src changes related to source code. JSON related to game datas in JSON format. labels Oct 1, 2024
@github-actions github-actions bot added the mods PR changes related to mods. label Oct 1, 2024
Copy link
Member

@chaosvolt chaosvolt left a comment

Choose a reason for hiding this comment

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

  1. Compiled and load-tested.
  2. Spawned in and activated a molotov.
  3. Tossed it, it go fwoosh yaaay.
  4. Spawned in rags and tested to make sure that changing them to ammo doesn't screw up their use actions.
  5. Crafted a molotov. It still consumes a rag as a component in the recipe, but produces a molotov with 0/1 ammo in it so you need to waste a second rag loading it.

@KheirFerrum
Copy link
Collaborator Author

KheirFerrum commented Oct 1, 2024

  1. Compiled and load-tested.
  2. Spawned in and activated a molotov.
  3. Tossed it, it go fwoosh yaaay.
  4. Spawned in rags and tested to make sure that changing them to ammo doesn't screw up their use actions.
  5. Crafted a molotov. It still consumes a rag as a component in the recipe, but produces a molotov with 0/1 ammo in it so you need to waste a second rag loading it.

Looks like setting it to use tangible ammo makes it not be created with initial charges, will remove rags from the recipe, as I don't see any way to make recipes force the initial charge.

Setting it to use rags as ammo makes it not spawn with default charges.
@chaosvolt
Copy link
Member

Specifying initial_charges in the item wouldn't work?

@KheirFerrum
Copy link
Collaborator Author

Specifying initial_charges in the item wouldn't work?

It already has it to begin with. It just doesn't apply outside of debug spawning it it seems.

@chaosvolt
Copy link
Member

Ah right, damn. Guess that works but it feels real hacky having to load the rag manually after filling it, hmm. This is technically only mandated by it having turns_per_charge defined, right? Though I suppose without it, and combined with it no longer going off when dropped, the player could exploit an infinitely-burning molotov for light, bleh. :/

@KheirFerrum
Copy link
Collaborator Author

Ah right, damn. Guess that works but it feels real hacky having to load the rag manually after filling it, hmm. This is technically only mandated by it having turns_per_charge defined, right? Though I suppose without it, and combined with it no longer going off when dropped, the player could exploit an infinitely-burning molotov for light, bleh. :/

It's technically mandated by me making them reloadable with rags. If we went by the old behaviour, every time it went out it would refill it's charges and you could light it again.

@chaosvolt
Copy link
Member

Fair, I was wondering whether that'd technically be okay on the basis of the rag serving as a wick, but this would technically make the fuel infinite-use instead. This would only really matter if the player repeatedly lights a molotov and lets it burn out again and again until they start questioning why it hasn't run out of fuel by then, but that'd be a bit of a wacky scenario to begin with.

@KheirFerrum
Copy link
Collaborator Author

KheirFerrum commented Oct 1, 2024

Fair, I was wondering whether that'd technically be okay on the basis of the rag serving as a wick, but this would technically make the fuel infinite-use instead. This would only really matter if the player repeatedly lights a molotov and lets it burn out again and again until they start questioning why it hasn't run out of fuel by then, but that'd be a bit of a wacky scenario to begin with.

To be fair another way we could do it is have it never burn out and only be "extinguished" by rain and water

@RoyalFox2140
Copy link
Collaborator

image
Huh.

RoyalFox2140
RoyalFox2140 previously approved these changes Oct 1, 2024
@chaosvolt
Copy link
Member

I think it just burning out after a bit but being able to be re-lit without having to provide a fresh rag is probably acceptable, compared to having to manually stuff the rag in before use each time after making it. Like I said, it would only look weird if the player lights and extinguishes it multiple times, whereas the rag thing will look weird every time one's crafted.

@KheirFerrum
Copy link
Collaborator Author

KheirFerrum commented Oct 1, 2024

I think it just burning out after a bit but being able to be re-lit without having to provide a fresh rag is probably acceptable, compared to having to manually stuff the rag in before use each time after making it. Like I said, it would only look weird if the player lights and extinguishes it multiple times, whereas the rag thing will look weird every time one's crafted.

I feel like the latter makes more sense than the former, though like... we could also just make it burn forever and have the activation effect allow you to manually extinguish it. I just feel that the behaviour where you can wait it out and relight it is very odd, and codewise looks kind of weird.

@chaosvolt
Copy link
Member

That would work I guess too? I just find it really weird having to craft a molotov and then basically "fuze" it manually afterward. It stands out as kinda weird when every other grenade-type item in the game is crafted as an all-in-one deal.

@KheirFerrum
Copy link
Collaborator Author

KheirFerrum commented Oct 1, 2024

That would work I guess too? I just find it really weird having to craft a molotov and then basically "fuze" it manually afterward. It stands out as kinda weird when every other grenade-type item in the game is crafted as an all-in-one deal.

Okay. I also recalled that WATER_EXTINGUISH won't proc this charge renewal, which would have been a problem for the original setup.

@scarf005
Copy link
Member

scarf005 commented Oct 1, 2024

maybe we could make molotov use oil as charge?

@KheirFerrum
Copy link
Collaborator Author

KheirFerrum commented Oct 1, 2024

maybe we could make molotov use oil as charge?

Pretty sure it having an ammo type at all is what's causing it to spawn with no charges, so changing that won't change the problem.

@scarf005
Copy link
Member

scarf005 commented Oct 1, 2024

Pretty sure it having an ammo type at all is what's causing it to spawn with no charges, so changing that won't change the problem.

oh, i meant as a balance change.

@chaosvolt
Copy link
Member

Oh, I see now. Fair enough in that case, we can keep that for now and add an option to manually extinguish it in a later PR then.

Copy link
Member

@chaosvolt chaosvolt left a comment

Choose a reason for hiding this comment

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

These should be all the changes needed to make it do the "return to a lightable molotov if it goes out" thing, lemme know if I missed anything.

data/json/items/ammo_types.json Outdated Show resolved Hide resolved
data/json/items/generic.json Outdated Show resolved Hide resolved
data/json/items/generic.json Outdated Show resolved Hide resolved
data/json/items/tool/explosives.json Outdated Show resolved Hide resolved
data/json/items/tool/explosives.json Outdated Show resolved Hide resolved
data/json/items/tool/explosives.json Outdated Show resolved Hide resolved
data/json/items/tool/explosives.json Outdated Show resolved Hide resolved
data/json/items/tool/explosives.json Outdated Show resolved Hide resolved
data/json/recipes/weapon/explosive.json Outdated Show resolved Hide resolved
data/mods/Item_Category_Overhaul/overwrite_scrap.json Outdated Show resolved Hide resolved
@KheirFerrum
Copy link
Collaborator Author

KheirFerrum commented Oct 1, 2024

These should be all the changes needed to make it do the "return to a lightable molotov if it goes out" thing, lemme know if I missed anything.

There's still iuse code that needs to be done to make it revert properly when running out of charges and water_extinguish code so it actually reverts properly. This just reverts it to the prior broken state. Give me a few minutes.

@chaosvolt
Copy link
Member

Ah, no worries then. I'm currently out and about on wifi so won't be able to compile-test the new changes until I get home, so take your time if needed. ^^

@github-actions github-actions bot removed the mods PR changes related to mods. label Oct 1, 2024
@RoyalFox2140
Copy link
Collaborator

RoyalFox2140 commented Oct 1, 2024

So to be fair, I only tested spawning it, not crafting it. Why it spawns as 0/1 when crafted is beyond me.

@KheirFerrum
Copy link
Collaborator Author

So to be fair, I only tested spawning it, not crafting it. Why it spawns as 0/1 when crafted is beyond me.

Because it's been given an ammo type, there's no code to make it spawn with specific ammo and count, and it defaults against that in case you're making magazines and the like. Anyway, code's rewritten, updating the original PR. I'm annoyed, but hey, it works about right now

Copy link
Collaborator

@RoyalFox2140 RoyalFox2140 left a comment

Choose a reason for hiding this comment

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

image
I can't in good faith accept an infinite light source exploit by holding lit molotovs in my inventory indefinitely. Someone else can feel free to accept the PR if they don't see it as a big deal.

@RoyalFox2140
Copy link
Collaborator

image

God has granted us unlimited light.

@chaosvolt
Copy link
Member

Hmm. I thought the idea was they'd burn out and revert back to an unlit molotov if you don't throw them quickly enough?

@KheirFerrum KheirFerrum marked this pull request as draft October 1, 2024 19:54
@KheirFerrum
Copy link
Collaborator Author

KheirFerrum commented Oct 1, 2024

Hmm. I thought the idea was they'd burn out and revert back to an unlit molotov if you don't throw them quickly enough?

All three implementations have issues, some are under the hood, and some are overt.

Original (intended) implementation

  • Behaviour: Item reverts after several turns, refilling it's charges to full again to allow reignition.
  • Drawbacks: Code needs special handling as revert() preserves current charges, so both the iuse code and WATER_EXTINGUISH code must restore charges, and WATER_EXTINGUISH code must specifically target only items with iuse::molotov_lit or we get cigarettes that replenish themselves to full as long as you douse them in water before they are depleted.

Rag implementation

  • Behaviour: Item reverts after several turns, consuming a rag to fuel it.
  • Drawbacks: Recipe cannot produce molotov with charges, so players must manually reload them on craft.

New implementation

  • Behaviour: Item doesn't revert unless in water or player extinguished, can essentially be toggled between both.
  • Drawbacks: Infinite light source.

I don't like the first implementation because it's a lot of special case code handling for 1 specific iuse that needs to be careful about not treading on anything else's toes. And I can't just revert it to the original implementation and expect it to be fine because the original code as is doesn't revert at all when WATER_EXTINGUISH procs, invoking a non-existent transform that fails and leaves an inactive lit molotov. Adding revert means that it will revert into a molotov that has no charges. So I have to intentionally screw the code.

Putting this in draft while I think of a better stopgap that compromises between them and is acceptable to all of us.

Base molotov has no charges, instead, it transforms into a lit molotov that has charges, that over time depletes it's charges and turns back.

Disallow extinguishing it manually, as this produces molotovs with no max charge but a charge. They don't stack in the UI with other molotovs This issue will still occur if it gets extinguished by water.
@github-actions github-actions bot added the mods PR changes related to mods. label Oct 1, 2024
@KheirFerrum KheirFerrum marked this pull request as ready for review October 1, 2024 20:21
@github-actions github-actions bot removed the mods PR changes related to mods. label Oct 1, 2024
@RoyalFox2140
Copy link
Collaborator

image

Copy link
Collaborator

@RoyalFox2140 RoyalFox2140 left a comment

Choose a reason for hiding this comment

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

I mean, It works as intended and works under our old system of being relightable forever. It's not ideal but it's what we have right now.

Copy link
Member

@chaosvolt chaosvolt left a comment

Choose a reason for hiding this comment

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

Hopefully is fine then, still out and about so can't compile-test weh

@chaosvolt
Copy link
Member

  1. Compiled and load-tested.
  2. Crafted a molotov.
  3. Lit it, let it burn out, no odd behavior and I can re-light it without issue.
  4. Lit it, tossed it, it go fwoosh. :D

@chaosvolt chaosvolt merged commit 9081fe7 into cataclysmbnteam:main Oct 2, 2024
12 checks passed
@KheirFerrum KheirFerrum deleted the Molotov-Fix branch October 2, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSON related to game datas in JSON format. src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lighting a molotov cocktail causes it to disappear
4 participants