Skip to content

[lua] Fix CoP 5-2 and Container:isVarBitsSet bug - #11001

Open
Nobutadas wants to merge 1 commit into
LandSandBoat:basefrom
Nobutadas:fix-is-vars-bits
Open

[lua] Fix CoP 5-2 and Container:isVarBitsSet bug#11001
Nobutadas wants to merge 1 commit into
LandSandBoat:basefrom
Nobutadas:fix-is-vars-bits

Conversation

@Nobutadas

@Nobutadas Nobutadas commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

I affirm:

  • I understand that if I do not agree to the following points by completing the checkboxes my PR will be ignored.
  • I understand I should leave resolving conversations to the LandSandBoat team so that reviewers won't miss what was said.
  • I have read and understood the Contributing Guide and the Code of Conduct.
  • I have tested my code and the things my code has changed since the last commit in the PR and will test after any later commits.

What does this pull request do?

Fixes CoP 5-2 as well as a bug in Container:isVarBitsSet.

CoP 5-2:

  • You could enter Spire of Vahzl if you never fought an NM (Status == 0). This fixes that.
  • You could trigger an event if the NM was alive. This fixes that.
  • Container:isVarBitsSet should be doing an exact match. Fixing this function corrects quests/bastok/Stamp_hunt.lua and quests/ahtUrhgan/Arts_and_Crafts.lua. CoP 5-2 was doing an odd check later on to correct for the bug in isVarBitsSet.

Steps to test these changes

Run through CoP 5-2 as well as Stamp Hunt and Arts and Crafts.

@WinterSolstice8

Copy link
Copy Markdown
Contributor

Container:isVarBitsSet is OR'ing the bits instead of AND'ing the bits.

no, it is ANDing the bits, its just that any non-zero bit from any AND sets a non-zero value and the result is based on a partial match of bits (~= 0) and not an exact match (== sum)

@Nobutadas

Nobutadas commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Container:isVarBitsSet is OR'ing the bits instead of AND'ing the bits.

no, it is ANDing the bits, its just that any non-zero bit from any AND sets a non-zero value and the result is based on a partial match of bits (~= 0) and not an exact match (== sum)

The final check is effectively an OR, right? The for loop ANDs all the bits, but then the function does final check incorrectly? Or am I just misunderstanding bit math?

Edit: It's probably my phrasing is wrong but the fix is right?

@Nobutadas

Nobutadas commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Ignore my previous comment. I see it now based on what Winter said. I completely brainfarted and my fix was luckily correct.

I for some reason thought the for loop was ORing the variable. I don't know why I thought this as the variable isn't anywhere except in bit.band.

I'll go ahead and update the PR description.

@Nobutadas
Nobutadas marked this pull request as draft August 5, 2026 18:23
@Nobutadas Nobutadas changed the title [lua] Fix Container:isVarBitsSet bug [lua] Fix CoP 5-2 and Container:isVarBitsSet bug Aug 5, 2026
@Nobutadas

Nobutadas commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

I was correcting CoP 5-2 when I realized the code had a weird work-around for the isVarBitsSet bug. I noticed I needed to combine the CoP 5-2 fix with this. I checked the other 2 quests and they are coded correctly.

I've updated the PR name and description.

@Nobutadas
Nobutadas marked this pull request as ready for review August 5, 2026 18:47
@github-actions

Copy link
Copy Markdown

This PR has been automatically marked as stale because
it has not had recent activity. It will be closed if no
further activity occurs.

@github-actions github-actions Bot added the stale label Aug 20, 2026
@Nobutadas

Nobutadas commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Please let me know what you'd like me to change.

Right now on LSB, you don't have to kill any of the 3 NMs to trigger the door events for CoP 5-2

@github-actions github-actions Bot removed the stale label Aug 21, 2026
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.

2 participants