NPC tile problem when monsters or powers on screen

Been having this issue for a while, and was wondering if anybody may have encountered it/had a solution.

We have two main ways of triggering a text box:
NPC tiles and NPC monsters.
Both activate if you are touching them and press the appropriate input button.

The problem I am having is this:
NPC monsters can be activated no matter what as long as you collide with them.
NPC tiles only seem to set the npc_collision flag if all monsters and gameobjects (like powerups) are destroyed/don't exist except for the player.

Any idea why this would be the case?
It looks like the code setting the flag is the same in both.
All the check does in the activate text box input script is check to make sure that box_collision is not zero.
 
OK!

I finally tracked down the cause of this issue. This is due to default engine behavior, so I thought I would share the fix so others could use it.

The concept:
The reason this happens, is that the tile collision script gets run for every gameobject on screen, not just the player.
So even if the player is colliding with an NPC tile, if there is a gameobject on the screen that is not, then it immediately sets the flag back to 0.

To fix, just make this change to the top of your tile collisions script:
Code:
HandleTileCollision:
    ;;;;;ASSUMES vulnerability bit 000x0000, if one, skips collision.
    ;;;;;Six collision points. 
    ;;;;;All collision points checked and registered for all objects.
    ;;;; a solid in any of the points will result in negating all others.
    
        ;;; There are 6 ram variables, collisionPoint0 - collisionPoint5.
        ;;; collisionPoint0 = top left
        ;;; collisionPoint1 = top right
        ;;; collisionPoint2 = bottom right
        ;;; collisionPoint3 = bottom left.
        ;;; collisionPoint4 = mid left
        ;;; collisionPoint5 = mid right.
    
    TXA 
    STA currentObject
    TYA
    STA tempy

    LDA currentObject ; We do not want to reset the flag if an Enemy isn't colliding with NPC while
    CMP player1_object; player is.
    BNE +
    LDA npc_collision
    AND #%00000001 ; Set TileNPC flag to zero but keep ObjectNpc flag
    ;AND #%11111101 ; original
    ;LDA #$00 ; original
    STA npc_collision
  +:
    LDA navFlag
    AND #%11111110
    STA navFlag
    ...
    ...
 
Top Bottom