[4.1] Magic Projectile Goes Through Enemies

TurtleRescueNES

Active member
Maybe this is an easy oversight, or maybe this is how the 4.1 engine works by default. Whenever I fire my projectile at enemies, it harms them, but continues straight through them until it hits the edge of the screen or hits a solid object. Any ideas how to destroy the projectile upon impact with monsters?

My guess is to add a DeactivateCurrentObject command in one of the collision detection scripts, or maybe HandleMonsterHurt?
 

dale_coop

Moderator
Staff member
Strange, this should already happen... what module are you using?
Hacve you checked that your projectile object is set as "player weapon" and your monsters as "monster"?

update: just did a rapid test, and you're right... projectiles are not destroyed..? weird. It should be in the HandleHurtMonster.asm script... I will check the code.
 

dale_coop

Moderator
Staff member
Yeah, looks like the "HandleHurtMonster.asm" has some mistakes...
I think it rewrites tempx with other object (the monster or the monsterDeath object maybe)... but tempx was containing the projectile object in that script.

Maybe we could try to odify the "HandleHurtMonster.asm" script, replacing the "tempx" with "tempy" at line 64 and line 75.
Before:
Code:
	TXA
	STA tempx

	AddValue #$08, myScore, #$01, #$00

	;STA hudElementTilesToLoad
	;	LDA #$00
	;	STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	LDX tempx
After:
Code:
	TXA
	STA tempy

	AddValue #$08, myScore, #$01, #$00

	;STA hudElementTilesToLoad
	;	LDA #$00
	;	STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	LDX tempy

Don't know yet if it will cause issues with other parts of the collision scripts (need tests).
 

LordFred

New member
Putting this code into my project ( it works!! ) I realised that there are some problems when enemies dies... It doesn't drop anything. Into HandleDrops the first line is a "RTS", so, the entire script is not procesed. You can comment that line and ir will work... unless the screen is scrolling... in that case, I don't know why but the "y" coordinate is incorrect... I tried this code and the drop fails and always is painted in the first row of the screen...

Code:
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	LDA Object_scroll,x
	STA temp3    
    
	CreateObject temp, temp1, #$09, #$00, temp3    ;My object number 9 is an effect to use when player, monster, etc dies
 

dale_coop

Moderator
Staff member
Thanks for the feedback...
The issue of monsters not dropping items might be because of the modification I suggested.
Will need to do more tests to have a better fix.
 

dale_coop

Moderator
Staff member
A really quick fix for the "HandleDrops.asm" script would be something like that:
Code:
	;RTS ;; skip drops
;;; monster objects drop at random.
	LDA otherCenterX
	SBC #$08
	STA temp
	LDA otherCenterY
	SBC #$08
	STA temp1
	
	LDA Object_scroll,x
	SBC #$00
	STA temp3

	JSR GetRandomNumber
	AND #%00000111 ;; now, we have a number between 0 and 7
	BNE notPickup0 ;; 
	;; zero case here;
	;;; here, we'll create health
	CreateObject temp, temp1, #$04, #$00, temp3
	JMP donePickup
notPickup0:
	CMP #$01
	BNE notPickup1
	;; one case here;
;;; here, we'll create currency
	CreateObject temp, temp1, #$07, #$00, temp3
	JMP donePickup
notPickup1:
	CMP #$02
	BNE notPickup2
	;; two case here;
	;;; here, we'll create currency
	CreateObject temp, temp1, #$07, #$00, temp3
	JMP donePickup
notPickup2:
	;;;; do the same for each case.
	;;;; blank cases will simply return 'nothing'.
	
	
	
	
donePickup:	
	;;; ALL cases create a "pow"
	CreateObject temp, temp1, #$09, #$00, currentNametable
 

TurtleRescueNES

Active member
Thanks, Dale! The tempx/tempy fix worked for making projectiles disappear!

I'll have to look into restoring the monster drops as well.
 

vanderblade

Active member
It's frustrating that a lot of functionality was stripped out of the latest version.

My enemies don't drop anything. My sword is a god weapon. The monster lock no longer operates correctly.

I know this can all be fixed by manipulating code, but the whole appeal of NESmaker was that I wouldn't have to do this kind of stuff.

Do share if either of you figure out how to fix any of the above issues.

Is Joe aware of all this?
 

dale_coop

Moderator
Staff member
vanderblade said:
It's frustrating that a lot of functionality was stripped out of the latest version.

My enemies don't drop anything. My sword is a god weapon. The monster lock no longer operates correctly.

I know this can all be fixed by manipulating code, but the whole appeal of NESmaker was that I wouldn't have to do this kind of stuff.

Do share if either of you figure out how to fix any of the above issues.

Is Joel aware of all this?

I am not thinking completly like you on that...
I think there 's something you missed, here... THIS is the code of the "Basic" module. The intended behavior of this module (no monster drops, god sword, ...).
If/when Joe or someone else would released another project module, the behavior can be completely different.
For exemple, we could "fix" all these issues (I repeat, most of them are not issues, because it is made that way) and make a module from that, and share that module here, with all fixed :p

NESMaker is definitely a VERY versatile tool !
 

vanderblade

Active member
I see what you're saying, but I imported the Adventure Module, not the basic module.

I would argue the Adventure Module should come equipped with all of these features as basic functions. I know everything is possible with code, but the appeal of NESMaker is not having to deal with all that.

But you are a super dude for helping out on these forums.
 

dale_coop

Moderator
Staff member
vanderblade said:
I see what you're saying, but I imported the Adventure Module, not the basic module.

I would argue the Adventure Module should come equipped with all of these features as basic functions. I know everything is possible with code, but the appeal of NESMaker is not having to deal with all that.

But you are a super dude for helping out on these forums.

I understand... it's just a point of vue.
I can see yours and Joe's.
But very glad it's so customizable... we can do OUR module ;)
 

TurtleRescueNES

Active member
Vanderblade, I feel your pain. A lot of what I've been doing is restoring stuff that was available in 4.0.6. It can feel frustrating, but I have been using this as a great opportunity to understand the underlying code, and tweak it even more.
 

nroflmao

New member
I agree with you vanderblade....i'm combing the forums trying to figure out why all the things that worked for me in 4.0.11 are broken in 4.1.x and it seems most of the comments on fb group are "start learning asm"....ummmm that was why i wanted to use Nesmaker so i don't have to learn ASM. Tempted to go back to 4.0.11 to be honest.

I also can't get my monster drops to work in adventure module. I used Dale's modification to get the game object weapon to work, but now the monster death "poofs" don't work. if i switch back to the sprite weapon they do work so something about the game object weapon is blocking the poofs. i've spent more time on 4.1.0 just trying to get the exact things working i already had working without much effort in 4.0.11. seems like 4.1.0 is focused on trying to cover more game genres at the expense of breaking the existing ones :-(
 

Mugi

Member
maybe your object weapon is missing the code for "the poofs"
if you mean the monster death animation, the issue is that the new code uses a variable #MONSTER_DEATH_OBJ for spawning the monster death object, but the old code had it hard coded into an object number (i believe it was #$09)

as far as the whole thing with modifications go, modifications in general are good. I highly recommend that you grit your teeth and attempt to use 4.1.0 instead of reverting to the old version, the engine is so much more robust now.
if you intend to use nesmaker for longer, you will regret your choice of going back to the old engine really fast.

i have to agree with you though on the whole "i dont have to learn assembly" part. I think it was a big mistake on the dev's part to use this as a slogan for nesmaker. Nesmaker is REALLY good in making learning in easier and more fun (because you can see results immediately instead of struggling weeks if not months in attempting to code physics engines by hand and trying to figure out memory management and creating graphics banks without a visual IDE to work with) but you WILL have to dig into the code sooner or later if you want to achieve results you imagined in your head. What nesmaker provides is simply some basics you can use and modify.
 

nroflmao

New member
Thanks Mugi for the feedback and encouragement. I did find an OBJ_MONSTER_DEATH which i have set to 9, the game object slot where my monster death poof is and still doesn't seem to be working. I should say the poofs work about 20% of the time, and then sometimes they show up in the HUD...not sure whats going on there...

I have not been able to get monsters to drop powerups..using the sprite or game object weapon mod. I tried using the custom Handle Drop from Dale as well, to no luck and also commented out the RTS at top of default Handle Drops didn't work.

Also if i have 4 monsters or even worse 4 shooting monsters on a screen the game slows down quite a bit, no longer realtime speed. The exact same screen works perfect no slowdown in 4.0.11.

I agree with you that i probably will regret going back to 4.0.11 at some point, but i feel that 4.1.1 is a functional degradation out of the box for the adventure game i was working on. All of the issues above worked fine in 4.0.11, and now i'm spending all my time just getting back to that. I didn't really have any "show stopping" issues with 4.0.11 and was actually spending my time developing the game not troubleshooting ASM. The only reason i stopped was because of all the hype for what was coming in 4.1.0. After seeing whats here, i think i am better just using 4.0.11 until a 4.2 or 4.3 or a more robust adventure module is released. I think the major benefits of 4.1.x are probably for those not using adventure module and for those that are heavily into modifying the ASM as it seems like its more modular for updating and handling different game genre's, and seems like some significant improvements for platformers with sprite 0, etc.

Actually one of my fave parts of 4.1.0 the "Path tiles" actually i went back to 4.0.11 and they work in that version as well i just had never seen a tutorial for how to do it!
Likewise, i thought the SFX mapping screen under sound, which when i went back to 4.0.11 i realized it was already there too! Also the "q" "w" "e" "r" functionality to change palette, there in 4.0.11.
So far the only functions i will miss are the collision view for overworld and the ability to hold down the mouse button and drag to create tiles on the overworld instead of having to click each time....but i guess i can always sketch out my overworld in 4.1 and export /import back to 4.0.11.
 

dale_coop

Moderator
Staff member
nroflmao, if you have an issue with one my scripts, just tell me, or make a post about it, I will be happy trying to fix it
Sorry guys, I am not aware of all the issues that people have, depends if wich module used, wich scripts used which which settings. Now almost each game is different.

If the monster drops don’t work, of course I can make it back. Will do my best.
 

dale_coop

Moderator
Staff member
For the Monster Drops issues, have you try that fix:
http://nesmakers.com/viewtopic.php?p=10689#p10689

And check your HandleHurtMonster script, it needs to be fixed like this:
http://nesmakers.com/viewtopic.php?f=23&t=1726

And in fact, if you keep using the sprite-based weapon (that comes with the 4.1), you will never have monster drops as the routine is not executed.
So you would have to modify the HandleSpriteWeapon.asm:
http://nesmakers.com/viewtopic.php?f=3&t=1738

And also modifying the HandleObjectCollision.asm around line 270, replacing :
Code:
isLethalInvincible:
	LDX tempx
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #OBJ_MONSTER_DEATH, #$00, currentNametable ;; create "splat"
	LDX tempx
	
	;;; ordinarily we'll want to destroy the instance.
	 DeactivateCurrentObject
	;; incrase score, you killed a monster
	PlaySound #SND_SPLAT
	TXA
	STA tempy
	AddValue #$08, myScore, #$01, #$00

	;;; we also need to set up the routine to update the HUD
	;; for this to work right, health must be a "blank-then-draw" type element.
	;STA hudElementTilesToLoad
	;	LDA #$00
	;	STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	LDX tempx
By:
Code:
isLethalInvincible:
	LDX tempx
	;LDA Object_x_hi,x
	;STA temp
	;LDA Object_y_hi,x
	;STA temp1
	;;;;;;;;CreateObject temp, temp1, #OBJ_MONSTER_DEATH, #$00, currentNametable ;; create "splat"
	;LDX tempx
	
	;;; ordinarily we'll want to destroy the instance.
	 DeactivateCurrentObject
	;; incrase score, you killed a monster
	PlaySound #SND_SPLAT
	TXA
	STA temps
	AddValue #$08, myScore, #$01, #$00

	;;; we also need to set up the routine to update the HUD
	;; for this to work right, health must be a "blank-then-draw" type element.
	;STA hudElementTilesToLoad
	;	LDA #$00
	;	STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	LDX tempx
	JSR HandleDrops
 

nroflmao

New member
Thanks Dale, I will give this a try and let you know how it goes. I am very grateful for your help and your scripts already and feel bad asking for more from you, as you are a great community resource and i don't want to ask too much from you.
 
Top Bottom