[4.1] Quick fix for the monster drops issue

dale_coop

Moderator
Staff member
A quick fix for the Monster Drops issue.

1/ Modify the "HandleDrops.asm" script (in the "Routines\Basic\ModuleScripts\HurtWinLoseDeath" folder) , replacing with this code:

Code:
;;; 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, #OBJ_MONSTER_DEATH, #$00, temp3


2/ And you have to fix the "HandleHurtMonster.asm" (in the "GameEngineData\Routines\Basic\ModuleScripts\HurtWinLoseDeath") folder, replacing the "tempx" by "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


3/ If you are using the sprite-based sword weapon (that comes by default with the 4.1), you also have to modify the HandleSpriteWeapon.asm:
http://nesmakers.com/viewtopic.php?f=3&t=1738


4/ And also have to modify the HandleObjectCollision.asm around line 200, 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 tempx
	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 tempx
	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

Updates:
2019-01-21 fixed a typo in the 4/ (the f**** auto-correction of macOS or Safari... don't know which one)
2019-01-20 added the HandleHurtMonster modifications.
 

dale_coop

Moderator
Staff member
Updated the script (the last line has an issue with the "Pow" (monster death) creation!
 

nroflmao

New member
Is Step 4 only for sprite based weapon? It wasn't clear to me. Also I get an error when compiling with Step 4 as it doesn't recognize "temps" (right after play sound splat in the new code) is this a typo or is temps the correct word? Seems like maybe should be tempx or tempy?
 

dale_coop

Moderator
Staff member
Yes, only if you're using the sprite-based weapon.
And you right, looks like my Mac made auto-correct when I was typing.
I will fix that right, now...
 

nroflmao

New member
ok thanks, i am using the game object weapon so i will revert back step 4. But it looks like the monster drops are working now even with step 4 for my adventure module!
 

dale_coop

Moderator
Staff member
FIXED, thank you nroflmoa
The step 4 is needed when your player kills a monster from his back (your in attacking state and a monster arrives behind you, the monster will be killed automatically... but will not drops, until you fixed that with the step 4/ )
 

WillElm

New member
EDIT The fix for this seems to be that I told the object to get destroyed with edge collision. I have no idea why this helped, but I tested it. when I turn destroy of edge contact I can no longer collect it!

I've tried to implement this fix but I get the same results that I got when I simply commented out the RTS in the default script.

My monsters are creating their death animation (I changed it to the object number by the way) and they create the drop object, but I can't pick them up most of the time. The weird thing is, I can pick them up some of the time. The object itself is fine, if I place it manually, it works normally.

To clarify, by "can't pick up", I mean that my player just goes straight through it and the object remains.

Code:
;;; 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, #$04, #$00, temp3
	JMP donePickup
notPickup1:
	CMP #$02
	BNE notPickup2
	;; two case here;
	;;; here, we'll create currency
	CreateObject temp, temp1, #$04, #$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, temp3
 

dale_coop

Moderator
Staff member
It's quit edifficult to explain, but basically, with the Basic (scroll) core, there is not only one screen displayed... But 2 at teh same time on the screen (half screenleft and half screen right)
So I'd suggest to never set an object to "DestroyMe" for edge reaction, else it would disapear on screen (or just ghost, like the pickups in the scrolling tutorial demo) ...
If you want it to be removed, you should use "extend screen" reaction (that means if the object is no more displayed on screen, it will be destroyed).
 

WillElm

New member
dale_coop said:
It's quit edifficult to explain, but basically, with the Basic (scroll) core, there is not only one screen displayed... But 2 at teh same time on the screen (half screenleft and half screen right)
So I'd suggest to never set an object to "DestroyMe" for edge reaction, else it would disapear on screen (or just ghost, like the pickups in the scrolling tutorial demo) ...
If you want it to be removed, you should use "extend screen" reaction (that means if the object is no more displayed on screen, it will be destroyed).

Oh great thanks! I thought that meant that the object would remain.
 
Top Bottom