How to prevent projectile and "medusa head" slowdowns

vanderblade

Active member
You have to code the behaviour for each one yourself, then select which ones you want for each of the object's action steps. You can check each flag for an object in x by loading Object_vulnerability,x and ANDing it. So if you wanted to set up the invincible one, you'd put this in your monster hurt script:

Code:
LDA Object_vulnerability,x
AND #%00000001 ;; first flag
BEQ +hurtThisMonster
   ;;invincible flag is on
   JMP +doSkipHurtingThisMonster
+hurtThisMonster

For collisions you can put something similar in doHandleObjectCollisions I think it was.

For the editor you can rename each one in the project settings.
Thanks for sharing this. Did you see noticeable improvement in your slow down?
 

JamesNES

Well-known member
Thanks for sharing this. Did you see noticeable improvement in your slow down?
Sure did, I was using an object on my HUD as a weapon selector thing so this stopped it checking collisions for it every time. Before, if I had more than 3 enemies on the screen it'd slow right down, now I'm good.

Since, I've used it for when an enemy flies up into the air and zooms around before coming back down. Being able to set it for individual action steps is really useful.
 

vanderblade

Active member
Sure did, I was using an object on my HUD as a weapon selector thing so this stopped it checking collisions for it every time. Before, if I had more than 3 enemies on the screen it'd slow right down, now I'm good.

Since, I've used it for when an enemy flies up into the air and zooms around before coming back down. Being able to set it for individual action steps is really useful.
@JamesNES So, I get the how to use this in the monsterhurt script for an invincible state. But where do I add a similar check in the tilecollisions code to prevent checks on certain objects? I'm using the PlatformBase tile collisions script.
 

JamesNES

Well-known member
@JamesNES So, I get the how to use this in the monsterhurt script for an invincible state. But where do I add a similar check in the tilecollisions code to prevent checks on certain objects? I'm using the PlatformBase tile collisions script.
I jammed it in here, in bank 18, near the top:

Code:
doTileObservationLogic:

;;start added code
    LDA Object_vulnerability,x    ;;see if the object observes tile collision for this action step
    AND #%00000100
    BEQ +doTileCollisions
        JMP ObjectDoesNotObserveTiles
    +doTileCollisions
;;end added code

    LDA Object_status,x
....
 

vanderblade

Active member
I jammed it in here, in bank 18, near the top:

Code:
doTileObservationLogic:

;;start added code
    LDA Object_vulnerability,x    ;;see if the object observes tile collision for this action step
    AND #%00000100
    BEQ +doTileCollisions
        JMP ObjectDoesNotObserveTiles
    +doTileCollisions
;;end added code

    LDA Object_status,x
....
Just thought I would update this by saying that, for some reason, when this code is implemented, the skip collision flag checked, and the monster has a solid reaction to stop, the player's stop on solid code messes with the object. For instance, if an enemy fires a projectile that has the above characteristics, and I run into a solid or jump into a solid, the projectile will disappear in mid flight.

It's bizarre! I'm not sure what systems are interfering with each other at this point. I just know that unchecking the skip collisions flag fixes the issue. If I know more or find a fix, I'll update this post.
 
Last edited:

vanderblade

Active member
I jammed it in here, in bank 18, near the top:

Code:
doTileObservationLogic:

;;start added code
    LDA Object_vulnerability,x    ;;see if the object observes tile collision for this action step
    AND #%00000100
    BEQ +doTileCollisions
        JMP ObjectDoesNotObserveTiles
    +doTileCollisions
;;end added code

    LDA Object_status,x
....
I think I narrowed down the problem to the implementation of this bit of code. Everything works as intended when I don't have this code in place and the flag checked on the monster object/projectile. When I do, the monster's solid reaction activates when the player collides with a solid. The game is treating them as one unit for some reason. Any ideas how to avoid this? Changes to where to place the skip tile collisions code?
 

vanderblade

Active member
I think I narrowed down the problem to the implementation of this bit of code. Everything works as intended when I don't have this code in place and the flag checked on the monster object/projectile. When I do, the monster's solid reaction activates when the player collides with a solid. The game is treating them as one unit for some reason. Any ideas how to avoid this? Changes to where to place the skip tile collisions code?
I had to end up moving the "skip collision" code back to HandleObjectsWithinCamera just before the bankswitch to Bank 18. So, basically, if the object has the "skip collision" flag checked, it won't even bother going to Bank 18 to check tile stuff. This solved the bug -- just in case anybody else runs into this.

Edit: Well, that actually didn't fix the problem at all. So, here's the current deal: The is issue is that the player running into a solid tile triggers a solid reaction in some monsters or monster weapons ONLY WHEN the “ignore collision” flag is checked and ONLY WHEN the object is created on screen by another object. I also discovered that the player projectiles hitting solids can also trigger monster objects/weapons to perform their solid reactions. It all boils down to this technique for skipping tile collisions, but I just can't understand why it's resulting in this particular bug.

@JamesNES, any ideas?
 
Last edited:

timefor

New member
when I try this on the adventure base module 4.5.9 I get an unknown label error.
Code:
Routines\BASE_4_5\Game\Subroutines\doHandleTileCollisions.asm(5): Unknown label.
Routines\BASE_4_5\Game\Subroutines\doHandleTileCollisions.asm(6): Unknown label.

Placed the code from first post at the top of the file doHandleTileCollisions.asm
Code:
;hack from https://www.nesmakers.com/index.php?threads/how-to-prevent-projectile-and-medusa-head-slowdowns.2527/
LDA Object_type,x
    cmp #06 ; cash object
    BNE +
        JSR updateHorizontalPosition
        JSR updateVerticalPosition
        RTS
        +

I'm trying to make it rain with cash objects and after six of them on screen, the player, and nothing else the game is chugging
 
Top Bottom