BEES! How to Create (Virtually) Unlimited Monsters

TurtleRescueNES

Active member
You're right that this code is locked in to one monster type. Your needs may be different, but I would not trust PickRandomMonster. I have NPCs and would not want them to spawn. A more likely solution is to instead create a user variable instead of user constant. Your different "beehives" could have a simple AI action that establishes a new monster ID value to the variable, then run the same code to spawn whatever monster IDs it wants.
 

Bucket Mouse

Active member
jsherman said:
You're right that this code is locked in to one monster type. Your needs may be different, but I would not trust PickRandomMonster. I have NPCs and would not want them to spawn. A more likely solution is to instead create a user variable instead of user constant. Your different "beehives" could have a simple AI action that establishes a new monster ID value to the variable, then run the same code to spawn whatever monster IDs it wants.

How would you trigger it though? My best guess is to have the player sprite load into each screen on a custom tile type that changes that value, but then you can only have so many of THOSE....

The game I'm using this for doesn't have NPCs; it would be so much easier if PickRandomMonster would work. How do I get it to work? To me, it looks like it should work. What is wrong?
 

Bucket Mouse

Active member
I still can't get Random Monster to work, but I found a way to multiply the monsters onscreen based on the Monster Group, instead of a specific monster. Good enough for now.

First go to Project Settings and establish a User Variable, MonCount.

Next find LoadMonsters.asm and search for doneWithMonsterLoop. Paste this directly below, into the space between that line and LDY PrevBank:

Code:
;;;;; ALTERATION

LDA screenFlags
AND #%01000000
BEQ noMonsterSpawn

LDA MonCount
CMP #$00
BEQ noMonsterSpawn
DEC MonCount
JMP LoadMonsters

noMonsterSpawn:

;;;;; END OF ALTERATION

Then go to your starting page (which must have monsters on it) and click the Screen Info button. Click on "Monsters Unlock Scroll." We're borrowing this flag to turn the monster multiplier on. This is intended for a Maze or an Adventure game; there is no reason to flood a sidescroller with monsters.

Now the monsters will multiply on every screen you click that flag for. The number of monsters you get depends on the number you place on the screen initially, multiplied by the value you enter into MonCount. Suffice to say you can SWARM the screen with monsters VERY quickly and yes, there WILL be slowdown and flicker, no way around it. But if you want this many mons to begin with, that's the inevitable tradeoff.
 

SubCog

New member
giphy.gif
 
dale_coop said:
Like this:
Code:
	CountObjects #%00001000, #$00 ;; count monsters.
	LDA monsterCounter
	CLC
	CMP #MON_SPAWN_MAX  
	BCS labDoNotSpawn

I'm using a monster to spawn game objects. Would the CountObjects be the same for that? The items keep spawning, not respecting the max I've set. This also goes into the Spawns Enemies AI script, or somewhere else?

EDIT: I always bug you, then find the answer :p I was trying to find MonsterCounter, but that didn't help, then found CountObjects, and it has a nice chart of which bits to flip when you want to count objects. Flipped the right one, and now it seems to be working. Success!
 

Lother

Member
Now I have a question. Let's say that in a monster group on one screen of my game, the first monster is the spawner and the second one is the monster I want to spawn regularly (the other two do not matter), what would the code be?

This way I can easily use that action to spawn different types of enemies without having to create a new spawner script for each one of these.
 

mouse spirit

Well-known member
This is great! I'm going to try it out right now.I have a question if you get a chance to answer it,it does pertain to this post.
Long question statement.I am working on a sort of music game.I want the "notes" to come from down left right or up,towards the player.What i'm trying to do is make the "notes" enemies,and so i attack in the correct direction to basically hit the "notes" as they come at me from all sides.This post looks like it can help me,so here's my question...
Do you know a way to make these enemies come out on time.So put the beehives in all four directions around my character,but they attack me in on beat or on time?.Like i want left left left up up right right right down down ect. Or do you know of a good tutorial for that sort of thing?Thanks again, this is awesome.
 

TurtleRescueNES

Active member
mouse spirit said:
This is great! I'm going to try it out right now.I have a question if you get a chance to answer it,it does pertain to this post.
Long question statement.I am working on a sort of music game.I want the "notes" to come from down left right or up,towards the player.What i'm trying to do is make the "notes" enemies,and so i attack in the correct direction to basically hit the "notes" as they come at me from all sides.This post looks like it can help me,so here's my question...
Do you know a way to make these enemies come out on time.So put the beehives in all four directions around my character,but they attack me in on beat or on time?.Like i want left left left up up right right right down down ect. Or do you know of a good tutorial for that sort of thing?Thanks again, this is awesome.

This could work, or my thought is the "Fire at Player" script that comes with the modules would be better as it projects an object (your notes) directly towards the player.

Timing would have to be done through trial and error. You do have the ability to alter the "beehive" delay between projections, but I don't think it can truly be synched to the actual song.
 

mouse spirit

Well-known member
Gotchya.Thanks for the reply.I see what you mean.I may just use like a variable that coincides with button inputs,have the inputs be visually on screen,then you press what the game tells you too type a thing.Keepin my options open.
 

BasketJames

New member
vanderblade said:
dale_coop said:
Like this:
Code:
	CountObjects #%00001000, #$00 ;; count monsters.
	LDA monsterCounter
	CLC
	CMP #MON_SPAWN_MAX  
	BCS labDoNotSpawn

Sorry for taking a while to test this. I have been very busy with my job this past week. I added this to your Handle_Monster_DC script, Dale, and received a compiler error.

This is what I have in this section:

Code:
	CountObjects #%00001000, #$00 ;; count monsters.
	LDA monsterCounter
	CLC
	CMP #MON_SPAWN_MAX
	BCS labDoNotSpawn
	BEQ doNoMoreMonsterCode
	JMP stillMonstersOnScreen_onScreenload
doNoMoreMonsterCode

I receive a compilation error myself with this code, on line 12.

I get a "branch out of range" error on this line:

BCS labDoNotSpawn

Thoughts on how to fix this? I am using Dale's Handle_CheckForMonsters_DC

I've tried multiple ways to implement a check (also tried the solution frankengraphics mentioned above) to limit the number of monsters spawning, but they all give me the "branch out of range" error, and without, my enemies all spawn until there are eight on screen, ignoring the maximum amount that I set for the spawn limit.

Thanks everyone for any thoughts on this.
 

AllDarnDavey

Active member
BasketJames said:
I receive a compilation error myself with this code, on line 12.

I get a "branch out of range" error on this line:

BCS labDoNotSpawn

Thoughts on how to fix this? I am using Dale's Handle_CheckForMonsters_DC

I've tried multiple ways to implement a check (also tried the solution frankengraphics mentioned above) to limit the number of monsters spawning, but they all give me the "branch out of range" error, and without, my enemies all spawn until there are eight on screen, ignoring the maximum amount that I set for the spawn limit.

Thanks everyone for any thoughts on this.

The trick on branch out of range errors is usually to reverse the branch check condition and do a small branch that skips a jmp statement for a fail. For example, try changing your:
Code:
BCS labDoNotSpawn

try:
Code:
BCC +
     JMP labDoNotSpawn
+

BCC is the opposite of BCS, which will now skip the jump that happens on a branch fail. It's a stupid workaround, but it usually does the trick.
 

BasketJames

New member
Thanks a lot AllDarnDavey! The solution worked, and thanks for explanation as well, it makes sense, and I will find it useful on my journey with ASM :)
 

toonyman2019

New member
Thanks for confirming. I updated my original post.
As for the limit not working, it must be a difference in how "monsterCounter" behaves in your module. I may look into it this weekend.
can you make a video tutorial? on how to implement this for the novice like me? I like to know how to spawn more monster both a unlimited amount at a set rate and a limited amount?

Also a limited amount base on a timer? for example one monster mom lays a set of eggs of her children and then she blows up or dies! but the children remain to cause harm or not and then later some of the children like the female group will do that same so the pattern repeats in this type of way. that is the nature and purpose of this monster.
 
As requested in the Facebook group, here is a quick tutorial on how to spawn (near) unlimited monsters, and why that is not a good idea. :)

In my example, which will appear in my "Turtle Rescue" game, I will use a beehive that spawns bees. You may use this for other purposes. For my tutorial, I will use "beehive" to identify the monster that spawns, and "bees" to identify the spawned monster.

Before we begin, create your beehive and bee monsters. They should be in the same monster tileset. Bees will be set up to behave as any normal monster. They are fully capable to function on their own. Your beehive is a placeholder for right now. We'll apply additional functionality to it later. Remember bounding boxes, health settings and to make them monster types!

Assign the beehive to a monster group. It is actually not required to assign the bees to the same monster group as the beehive, but for testing purposes, you should add them as well.

Create a test screen, assign your new monster group to the screen's Day Monsters. Place a bee and a beehive on the screen. For testing purposes, you should place your player on the same screen as well.

Export and test your game. Nothing special should be happening at this point, You just want to confirm your bee is behaving as expected, and your beehive just appears. It's not supposed to do anything yet.

Now we need to get down and dirty with code... well, not really. There's not all that much, really.

First, create two user defined constants in Project Settings:

MON_SPAWN_MAX -- Value: 5 -- The number of monsters that will appear on the screen when the beehive stops generating bees. You can change this later.
MON_SPAWN_ID -- Value: ## -- The unique ID number of your bee monster. To determine this, go to your Monster Graphic Banks, Monsters list, and starting with 16, count the number of monsters down your list that your bee appears. For example, if your bee is the 5th monster, the ID value will be 20.

Now for the code itself!
Create a new SpawnMonsters.asm file in your AiScripts folder

Insert the following code:

Code:
;; JTS Spawn Monsters
;; In this case, spawn bees from beehive monster


    LDA monsterCounter
    CMP #MON_SPAWN_MAX 
    BCS labDoNotSpawn
   

    labSpawnBees:


    TXA
    STA tempx
   
    ;; get offset
    LDA Object_x_hi,x
    CLC
    ADC #$04 ;; arbitrário... colocaria um projeto 8x8 no centro de um objeto 16x16
    STA temp1
    CLC
    ADC #$04 ;; arbitrário... colocaria um projeto 8x8 no centro de um objeto 16x16
    Objeto LDA_y_hi,x
    STA temp2
 ;; Use um dos dois comandos abaixo com base na sua versão
 ;; CreateObject temp1, temp2, #MON_SPAWN_ID, #$00 ;Use esta linha para 4.0.X
 CreateObject temp1, temp2, #MON_SPAWN_ID, #$00, currentNametable ;Use esta linha para 4.1.X

    
    labDoNotSpawn: 
    Temperatura LDX

[/código]

Salve seu arquivo ASM.

Abra as configurações do projeto / configurações de script e atribua seu SpawnMonsters.asm a um script de ação de IA aberto.
Você também pode renomear esse script de IA na guia Rótulos do projeto e, em seguida, Tipos de ação

Agora que o script está pronto, é uma boa ideia exportar e testar seu jogo novamente. Nada terá mudado, mas como adicionamos um novo código, é um excelente momento para ter certeza de que não quebrou nosso jogo.

Agora vamos começar a fazer dessa colméia uma máquina de desova de monstros!!!

Reabra seu monstro colméia. Deve ter dois estados de ação.

O estado de ação 0 terá um temporizador. No meu caso, usei 6. Você pode usar o que quiser e mudar depois. Isso controla o ritmo em que as abelhas aparecerão. Nenhuma ação é colocada neste estado. Selecione "Avançar" para a configuração EndAction.

Em Action State 1, selecione a nova ação para refletir o novo comportamento do SpawnMonsters AI. Altere a EndAction para GoToFirst.
Isto é o que dirá à colmeia para criar uma abelha e depois repetir novamente. A abelha não aparecerá se a tela já tiver MON_SPAWN_MAX número de monstros na tela. Mate uma abelha e outra aparecerá. A única maneira de o jogador parar as abelhas é destruir a colméia.

Construa seu jogo, e tudo deve funcionar como você espera. No meu GIF abaixo, mostro que você poderia gerar muito mais do que cinco abelhas, mas seria imprudente. O NES acabará por desacelerar, e também o jogador ficará sobrecarregado. Portanto, coloque um máximo razoável para deixar todos felizes.

Boa sorte!

ATUALIZAÇÃO: Obrigado a vanderblade por ajudar a testar isso. Eu criei isso em um módulo diferente do que muitos estão usando, então sua experiência pode variar.
[/QUOTE]
amazing
 

chronogames2004

New member
Hello,
I have no idea of programming, but I really wanted to run this script in my game.
But an error appears, I only have 2 monsters the hive and the bee. My bee is the second monster.
The error that appears is this:
Routines\BASE_4_5\Game\AI_Scripts\SpawnMonsters.asm(5): Unknown label.
demo.txt written.
 

Logana

Well-known member
Hello,
I have no idea of programming, but I really wanted to run this script in my game.
But an error appears, I only have 2 monsters the hive and the bee. My bee is the second monster.
The error that appears is this:
Routines\BASE_4_5\Game\AI_Scripts\SpawnMonsters.asm(5): Unknown label.
demo.txt written.
You need to add the label, should have lives and hp already set
 

dale_coop

Moderator
Staff member
This tutorial wal made for an older version of NESmaker. I presume you are using the most recent one (5.4.9). So, it won't be compatible as it. In order to work, you will have to adapt/modify that script to work with newer versions of NESmaker.

For example, instead of the line:
Code:
LDA monsterCounter
Now I think you would need to use something like:
Code:
CountObjects #%00001000  ;; counting how many monsters on screen
 
Top Bottom