BEES! How to Create (Virtually) Unlimited Monsters

MistSonata

Moderator
Alternatively you could let the compiler convert it into hex for you by removing the "$" sign and writing the number in decimal. So "#48" would be the same as using "#$30".

Also, if you go into "GameEngineData/GameData/" you'll find "MonsterList.txt" which will give you the monster's number as of the last export, just add 16 to that.
 

TurtleRescueNES

Active member
vanderblade said:
The MON_SPAWN_MAX doesn't seem to limit monster creation, but everything else is working as intended. Thanks!

So at a quick glance, in your game, do you have Handle_CheckForMonsters loaded?
Within that is how MonsterCounter gets set. My script piggybacks off of that.

I suppose you could modify the spawn code to do the more direct CountObjects #%00001000, #$00 command, but that's just a theory.
 

Havok

New member
jsherman, first off, great job! This is a useful piece of code.

So useful, in fact, that I'm curious to know whether or not you would permit people to use it in commercial releases? It's a ways off for my purposes, but I may have an application for this in the game I'm planning, and I neither want to steal your code without permission, nor get far into the design process relying on a piece of code of ambiguous license status. Thank you in advance for any clarification!
 

TurtleRescueNES

Active member
Use it! Everyone here aspires to release their game in some way shape or form. We all want each other to succeed, so if this litle bit of code helps you, then please, go for it! Please share examples how you apply this to your game!
 

tornotlukin

Member
Incidentally, If you have windows 10 (probably in other windows versions too? Maybe 8?) The calculator app has a "Programmer" Calc and it gives the readouts of HEX, DEC, OCT, BIN for number, useful without any additional downloads

calc.PNG.
 

Bucket Mouse

Active member
Finally got around to trying out this code, and got stuck before I entered a single line.

jsherman said:
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.

I can't create two new user defined constants in Project Settings because it will not let me make any new ones. If I enter that stuff, it just overwrites the one that's highlighted, which will mess up my game.
 

dale_coop

Moderator
Staff member
When you click on the Add button, a new user constant is added at the end of the list, you can select the new added one and set it (name âne value)
 

vanderblade

Active member
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
 

dale_coop

Moderator
Staff member
What is exactly your error? (In the command line black window)
And could you share the whole script?
:)
 
jsherman said:
Actually, the NESMaker constants are stored in decimal format, so that is how you enter them in the Project settings. They are converted at compilation to hex.

I see the issue. My version of CreateObject wants four parameters. Your module likely wants five due to the scrolling engine.

See if this works:
CreateObject temp1, temp2, #MON_SPAWN_ID, #$00, #$00
Where does this get plugged in? I'm having the same problem.
Thanks!
 
Hello guys

From what I can see I followed the tutorial to the beat of my Zero ASM skills and this is what I'm getting any help would be awesome
 

Attachments

  • 20190208_195616.jpg
    20190208_195616.jpg
    1.6 MB · Views: 2,617

dale_coop

Moderator
Staff member
I think you didn't create the two user defined constants in Project Settings that is needed (cf the 1st post).
 

FrankenGraphics

New member
Alternately, you can forgo using constants for something this specific by specifying a literal value instead. Just be careful to comment it so the future you will remember what that magic number was for.

lda MyNumberOfCurrentActiveObjectsOrSpawns
cmp #10 ; max spawns

the pro of using constants is that you can quickly look up and edit a bunch of them in one go for balancing / resource tightening your game. Whether to make every value a constant or not is a personal judgment call.
If you think it's a set and forget after a little initial testing, a literal will probably do.
 

TurtleRescueNES

Active member
dale_coop said:
I think you didn't create the two user defined constants in Project Settings that is needed (cf the 1st post).

Agreed. The (6) and the (27) help pinpoint the actual lines in the code where the error occurs, and that is where the user defined constants are called.
So either you didn't type them out exactly right (including the # in front of them) or you didn't declare them in Project Settings.

FrankenGraphics, well said!
 

FrankenGraphics

New member
btw i seem to remember that the engine is already using a constant to define the allowed max number of objects or monsters per screen? One could use that (which will have the "beehive" spawn a dynamic number of "bees" depending how much the screen is already populated, which could be a good way to control performance).
 

Bucket Mouse

Active member
So...the main problem I have with this script is that it only generates one kind of monster, for the entire game. MON_SPAWN_ID is static, and does not change.

This evening I attempted to rewire the code to pick a random monster from the Monster Group assigned to the screen, and while I was at it, make the monster spawn in a random spot instead of right where the "generator" monster is.

There is already a routine called "DoRandomMonster" in the LoadMonsters asm, it just isn't used. So I borrowed that code, and followed the breadcrumbs to make sure it was wired correctly.

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


    LDA monsterCounter
    CMP #MON_SPAWN_MAX  
    BCS labDoNotSpawn
    

	;; first, find out which monsters to load, if it is random.
	JSR PickRandomMonster

	;;; pick a random position for this monster.
	;; first, make sure the prospective monster's position is inside the bounds.
		;;get a random position, set it to tileY
		;; get a random position, set it to tileX
		;;; so this would be:
				;; get a number 
	JSR FindFreePosition				
	
	;;;;;;;;;;;;;;;;;;;;;
	;;;;;;;;;;;;;;;;;;;;;


 ;;   Use one of the two commands below based on your version
 ;;   	CreateObject tileX, tileY, ObjectToLoad, #$00   ;Use this line for 4.0.X
 CreateObject tileX, tileY, ObjectToLoad, #$00, currentNametable    ;Use this line for 4.1.X


     
    labDoNotSpawn:  
    LDX tempx

"Find Free Position" is in the GetRandomNumber asm. "ObjectToLoad" is from PickRandomMonster which is a routine that's also found in in GetRandomNumber. The variables loaded there are called here. By all rights this should work.

But it doesn't and the screen freezes instead. What am I doing wrong?

UPDATE: Watching Joe's new "Bits and Flags" video gave me an idea...maybe instead of using a monster to generate other monsters, a flag could be modified to fill the screen with a certain number of monsters when checked. I don't know if that would make my code here suddenly work. It's bedtime for me...
 
Top Bottom