CandyNim
Tiller
Intended behavior: When you reach 2 hearts with an npc, you gain the ability to enter their bedroom. Doing so grants you the doorUnlocked[npc] flag, which means that even if you go back under 2 hearts, you permanently have gained access to their room. With a 2-npc bedroom, having friendship with either of the two npcs is enough to gain access to the room. Thus, you'd expect having either doorUnlocked flags to also gain access.
Buggy behavior: If you have enough friendship with both owners, you only gain doorUnlocked for the first owner. If you have no friendship with either owner, the game only cares about if you have doorUnlocked for the second owner. (Additional buggy behavior: with the doorUnlocked flag, you halt in place for a moment when entering)
Code Analysis:
The relevant code all lives inside of
i=1:
fails, because i = 1 not 2. Also, should the order be switched for incredibly minor performance improvement for short circuiting?
succeeds if you're friends with the first npc
if you're friends with the first npc, gives the doorUnlock flag and breaks [ensuring i = 2 never runs].
if you're not friends with first npc, we get
i = 2:
succeeds, assuming not friends.
It always makes the player briefly halt in place.
For a 2-npc door, above if statement translates to
Suggested fix:
The (~p | ~q ) & ~q check should be replaced with a ~p & ~q check; I think full on just deleting
Additionally, the fact that only one of the two doorUnlocked flags can be fixed by duplicating the
Finally, to fix the random halt if you enter without friendship but with doorunlocked, you can move the player halting code to only happen in the if block with
Attached are two save files; OneDoor and TwoDoor. Both are set up to have both relevant npcs at 500 friendship, and you can note that for Vincent's door you can open it, sleep, and then still go through [but have the weird halting movement]. For Robin/Demetrius, you can note that when you opening it, sleep, and try to get through you are blocked.
Buggy behavior: If you have enough friendship with both owners, you only gain doorUnlocked for the first owner. If you have no friendship with either owner, the game only cares about if you have doorUnlocked for the second owner. (Additional buggy behavior: with the doorUnlocked flag, you halt in place for a moment when entering)
Code Analysis:
The relevant code all lives inside of
GameLocation.performTouchAction (under the case of Doors). Let's imagine a door is owned by NPC1 and NPC2. The game iterates first through i = 1 and then i = 2.i=1:
if (Game1.player.getFriendshipHeartLevelForNPC(action[i]) < 2 && i == action.Length - 1)fails, because i = 1 not 2. Also, should the order be switched for incredibly minor performance improvement for short circuiting?
if (i != action.Length - 1 && Game1.player.getFriendshipHeartLevelForNPC(action[i]) >= 2)succeeds if you're friends with the first npc
if you're friends with the first npc, gives the doorUnlock flag and breaks [ensuring i = 2 never runs].
if you're not friends with first npc, we get
i = 2:
if (Game1.player.getFriendshipHeartLevelForNPC(action[i]) < 2 && i == action.Length - 1)succeeds, assuming not friends.
It always makes the player briefly halt in place.
if ((!Game1.player.mailReceived.Contains("doorUnlock" + action[1]) || (action.Length != 2 && !Game1.player.mailReceived.Contains("doorUnlock" + action[2]))) && (action.Length != 3 || !Game1.player.mailReceived.Contains("doorUnlock" + action[2]))): lock the doorFor a 2-npc door, above if statement translates to
((!door1 || !door2) && (!door2)). If you have door 2, it opens. If you don't have door 2, it becomes ((!door1 || True) && (True)), ensuring the door is locked even with door 1 access.Suggested fix:
The (~p | ~q ) & ~q check should be replaced with a ~p & ~q check; I think full on just deleting
|| (action.Length != 2 && !Game1.player.mailReceived.Contains("doorUnlock" + action[2])) would fix the bug? That should just make it ~p & ~q, which makes sense as you should only be blocked if you (don't have) both. Additionally, the fact that only one of the two doorUnlocked flags can be fixed by duplicating the
if (i == action.Length - 1 && Game1.player.getFriendshipHeartLevelForNPC(action[i]) >= 2) {
Game1.player.mailReceived.Add("doorUnlock" + action[i]);}if block inside the (if i != action.Length - 1 blah blah) so as to avoid the early exit in the code.Finally, to fix the random halt if you enter without friendship but with doorunlocked, you can move the player halting code to only happen in the if block with
ShowLockedDoorMessage .Attached are two save files; OneDoor and TwoDoor. Both are set up to have both relevant npcs at 500 friendship, and you can note that for Vincent's door you can open it, sleep, and then still go through [but have the weird halting movement]. For Robin/Demetrius, you can note that when you opening it, sleep, and try to get through you are blocked.
Attachments
-
199.4 KB Views: 8
-
103 KB Views: 12