[4.5.9] How To Have More Than 64 Monsters

Bucket Mouse

Active member
64 monsters is a lot for an NES game, and in ordinary circumstances you wouldn't exceed that number. But there are situations where 64 isn't enough. I have a lot of sprite cutscenes in my games, and each actor in a cutscene is a separate monster. Depending on what's happening, you can blow 3 or 4 monsters in a single scene which eats into the number quickly. Foertunately, there's a way to have more than 64 monsters in the game, and without any drastic modifications.

My second row of Screen Flags is devoted to altering Action States. You just tell all Monster Action States on a specific screen to start at a different number, like Action State 2, 4 or 6. Since each Action State can have a different sprite, this allows you to make four separate monsters with just ONE monster. Great for NPCs or enemies that don't use complicated AI.

Using this method, you can store every monster in your game in the first few monsters, and then have the rest of that space free for cutscene actions. Neat!

Here's how to do it. Save an alternate doLoadScreenData.asm, and paste the following code directly under "Handle monster 1."

Code:
        ;;;;;;; MATERIAL FOR SCREEN FLAGS THAT CHANGE MONSTER ACTION STATE
            LDA ScreenFlags01
    AND #%10000000
    BEQ +
    LDA #$02
    STA monActionStep
    JMP +++
    +
    LDA ScreenFlags01
    AND #%01000000
    BEQ ++
    LDA #$04
    STA monActionStep
    JMP +++
    ++
    LDA ScreenFlags01
    AND #%00100000
    BEQ +++
    LDA #$06
    STA monActionStep
    +++
 
    ;;;;;;;;;; END OF MATERIAL

Now with the same script, hit Control-F and search for all three uses of "CreateObject." It should look like this:

CreateObject tempB, tempC, mon3_type, #$00

Note the "#$00" at the end. Delete it and replace it with monActionStep, so it looks like this, and do it for the other two:

CreateObject tempB, tempC, mon3_type, monActionStep

Not done yet. For some reason the first monster onscreen has its load data handled on a different script: LocationFinders.asm. Bring that up and scroll all the way to the bottom, where you'll see another CreateObject. Alter it the same way...

CreateObject tempB, tempC, mon1_type, monActionStep

Then rename your Screen Flags starting with the ninth one: "Start on Action Step 2," "Start on Action Step 4," and "Start On Action Step 6."

Additionally, it's not hard to modify this to make options for starting monsters at Action Steps 3, 5 or 7.
 
Last edited:

Craigery

Active member
I tried this and couldn't get it to work. I created a User Variable monActionStep. Was there something else I was supposed to do? I don't see anywhere else where monActionStep is referenced.
 

Bucket Mouse

Active member
I tried this and couldn't get it to work. I created a User Variable monActionStep. Was there something else I was supposed to do? I don't see anywhere else where monActionStep is referenced.
My bad -- I left out an entire step. The instructions above have now been revised -- try it again.
 

Craigery

Active member
Another bug: After entering a screen that has this code checked, each subsequent screen will use that code. Is that true for you as well? Could I have forgotten a step or did this wrong?
 

Bucket Mouse

Active member
Another bug: After entering a screen that has this code checked, each subsequent screen will use that code. Is that true for you as well? Could I have forgotten a step or did this wrong?
So every monster is now starting on Step 2 after commanding it for one screen? I've never had that happen, so....the issue's on your end.
Your game has a lot of custom code, I know that. Maybe something is conflicting with this.
 

Craigery

Active member
I added this right before your code so that variable will reset each time. Thanks again for this very useful code!
Less:
LDA #0
STA monActionStep
 
Top Bottom