[SOLVED] Boss drop

n8bit

Member
Not sure if I am suffering from a brain fart or just have not had enough coffee today, but hopefully someone can help me out here. I searched the forums but could not find a solution.

On my scrolling platformer I would like to have an end stage boss drop a single specific item, but I cannot seem to find the proper script or way to do it.

Any suggestions?

Thanks!
 

TurtleRescueNES

Active member
I think its possible. I don't know how to code it at the moment but in the monster drop, you can do a compare branch. If monster equals boss then destroy me and create the specific object. Else do the normal monster drop logic.
 

TurtleRescueNES

Active member
Or another thought... Create a custom AI action within the boss monster itself. Say your monster has a health setting of anything more than 1. In a special AI step, you can check if your monsters health is down to 1 (not zero because natural destroy me logic will kick in) then custom destroy me and create special object, else loop back to first.
 

dale_coop

Moderator
Staff member
Do you have your Monster Drops fixed already?
http://nesmakers.com/viewtopic.php?f=35&t=1740

If already fixed... you could modify the HandleDrops.asm script to drop a specific item, if the monster is your boss monster.

Maybe something like that (it's the idea... I didn't test myself), adding some code before the "JSR GetRandomNumber" line :
Code:
	;; we will check if it's the BOSS:
	LDA Object_type,x
	CMP #$ID_OF_YOUR_BOSS_MONSTER
	BEQ +
	;; the monster killed it the BOSS monster
	CreateObject temp, temp1, #$ID_ITEM_BOSS, #$00, temp3
	JMP donePickup
	+
	;; else continue the normal monster drop code:
	
	JSR GetRandomNumber
 

n8bit

Member
Thanks Dale!

Don't think my monster drops are fixed. Have no intention of using drops on normal enemies, so I have not messed with it previously. Will look into this method. On a little weekend getaway in Florida right now so not doing much work on my game at the moment. Although I did bring my laptop in case inspiration strikes me.
 

dale_coop

Moderator
Staff member
If you don't use the monster drops... it's almost the same, just modify the handle monster drops script and add at the beginning:
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
	
	;; we will check if it's the BOSS:
	LDA Object_type,x
	CMP #$ID_OF_YOUR_BOSS_MONSTER
	BEQ +
	;; the monster killed it the BOSS monster
	CreateObject temp, temp1, #$ID_ITEM_BOSS, #$00, temp3
	JMP donePickup
	+
	;; else, nothing:
	
	RTS
 

n8bit

Member
Hmmm... nothing dropping. Maybe I have my IDs wrong...


Boss is a 4x4 monster on the first monster tileset/sheet and the object is object 11...

here is my script...

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
	
	;; we will check if it's the BOSS:
	LDA Object_type,x
	CMP #$15
	BEQ +
	;; the monster killed it the BOSS monster
	CreateObject temp, temp1, #$0B, #$00, temp3
	JMP donePickup
	+
	;; else, nothing:
	
	RTS


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

dale_coop

Moderator
Staff member
If you count the monster in the NESMaker hierarchy (treeview)... starting from 16 (1 monster is 16, the next one is 17...).
Your boss is the number 21 ?
 

n8bit

Member
dale_coop said:
If you count the monster in the NESMaker hierarchy (treeview)... starting from 16 (1 monster is 16, the next one is 17...).
Your boss is the number 21 ?

Correct and the object is number 11, right below "PlayerVictory"
 

n8bit

Member
Hmm... that did nothing. Starting to wonder if it is an issue with my object details.

Might take a different approach. What I was trying to do was make a way for the player to warp to next level after beating boss. My thought was that I could have the boss drop an object that would cause the player to warp to screen upon touch.
 

dale_coop

Moderator
Staff member
Good idea. It should work.
Could you share a screen shots of your game objects and monster list.
AND could you share the content of your script assigned to the "Handle Monster Hurt"?
AND could you share the content of your script assigned to the "Handle Monster Drops"?

Thanks
 

n8bit

Member
dale_coop said:
Good idea. It should work.
Could you share a screen shots of your game objects and monster list.
AND could you share the content of your script assigned to the "Handle Monster Hurt"?
AND could you share the content of your script assigned to the "Handle Monster Drops"?

Thanks

as requested...

Game Objects and Monster List. Disregard some of the objects there. Have some unused ideas there and left them in for now. Also slime is still there as I was using it for testing and learning.

KbSUv5i.png


Handle Monster Hurt script:

Code:
;;; what should we do with the monster?
        ;;; monster is loaded in x
        LDA Object_vulnerability,x
        AND #%00000100 ;; is it weapon immune?
        BEQ notWeaponImmune
        ;PlaySound #SFX_MISS
        JMP skipHurtingMonsterAndSound
    notWeaponImmune:
        
        LDA Object_status,x
        AND #HURT_STATUS_MASK
        BEQ dontskipHurtingMonster
        JMP skipHurtingMonster
    dontskipHurtingMonster:
        LDA Object_status,x
        ORA #%00000001
        STA Object_status,x
        LDA #HURT_TIMER
        STA Object_timer_0,x
        ;;; assume idle is in step 0
        ChangeObjectState #$00,#$02
        ;;;; unfortunately this recoil is backwards
        LDA Object_status,x
        AND #%00000100
        BNE skipRecoilBecauseOnEdge
        LDA Object_vulnerability,x
        AND #%00001000 
        BNE skipRecoilBecauseOnEdge ;; skip recoil because bit is flipped to ignore recoil
        
        LDA selfCenterX
        STA recoil_otherX
        LDA selfCenterY
        STA recoil_otherY
        LDA otherCenterX
        STA recoil_selfX
        LDA otherCenterY
        STA recoil_selfY
        JSR DetermineRecoilDirection
    skipRecoilBecauseOnEdge:
        LDA Object_health,x
        SEC
        SBC #$01
        CMP #$01
        BCC +
		JMP notMonsterDeath
	+
DeactivateCurrentObject
;;;monster death animation
;;LDA Object_x_hi,x
;;STA temp
;;LDA Object_y_hi,x
;;STA temp1

;;DeactivateCurrentObject

;;CreateObject temp, temp1, #$09, #$00, currentNametable

;;--end monster death animation
        PlaySound #SND_SPLAT
        ;;;;;;;;;;;;;;;;;; ok, so now we also add points to score
        ;LDY Object_type,x
        ;LDA ObjectWorth,y
        ;STA temp
;       AddValue #$03, GLOBAL_Player1_Score, temp
                ;arg0 = how many places this value has.
                ;arg1 = home variable
                ;arg2 = amount to add ... places?
        ;; and this should trip the update hud flag?
        
        ;;;; 
    

	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

        JSR HandleDrops
        JSR HandleToggleScrolling
		
		CountObjects #$00001000, #$00
		BEQ +
		JMP ++
	+
		.include SCR_KILLED_LAST_MONSTER
	++
        
        JMP skipHurtingMonster
    notMonsterDeath
        STA Object_health,x
    skipHurtingMonster: 
        ;PlaySound #SFX_MONSTER_HURT
    
    skipHurtingMonsterAndSound:
        LDX tempx
        ;; what should we do with the projectile?
        DeactivateCurrentObject

Handle Drops script:

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
	
	;; we will check if it's the BOSS:
	LDA Object_type,x
	CMP #$15
	BNE +
	;; the monster killed it the BOSS monster
	CreateObject temp, temp1, #OBJ_BOSS_DROP, #$00, temp3
	JMP donePickup
	+
	;; else, nothing:
	
	RTS


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

dale_coop

Moderator
Staff member
Ok thanks.
In your handle monster hurt, try commenting out the lines
Code:
  ;;TXA
  ;;STA tempx
(Just after your animation death comments).

Else (If still no results), I will do some tests tomorrow Irh your scripts.
 

n8bit

Member
dale_coop said:
Ok thanks.
In your handle monster hurt, try commenting out the lines
Code:
  ;;TXA
  ;;STA tempx
(Just after your animation death comments).

Else (If still no results), I will do some tests tomorrow Irh your scripts.

Sorry, still no luck.
 

n8bit

Member
Was just looking at things so I could figure out where to toss the warp code after a boss death...

Could it be possible that my Jump on kills script is throwing the monster drops off?
 

dale_coop

Moderator
Staff member
Your problem might just be a wrong variable in the X register.
Do you have the drop when you kill the boss with your weapon/projectiles?
Could you also share your "Handle Object Collisions" script ?

I see that in your Handle Monster Hurt, that you comment out the createObject for animation Death. You don't want it?
 

n8bit

Member
dale_coop said:
Your problem might just be a wrong variable in the X register.
Do you have the drop when you kill the boss with your weapon/projectiles?
Could you also share your "Handle Object Collisions" script ?

I see that in your Handle Monster Hurt, that you comment out the createObject for animation Death. You don't want it?

I don't use any weapons or projectiles. Just jump on kill modified with Jump on hurt and I have the boss HP set to 3 so it requires 3 jumps to kill.

I commented out the death animations on the monster hurt script because I was testing it and we were able to get it to work in the Jump on Kills script.

I will share my Handle Object Collisions script this afternoon when I get home.
 

dale_coop

Moderator
Staff member
n8bit said:
I don't use any weapons or projectiles. Just jump on kill modified with Jump on hurt and I have the boss HP set to 3 so it requires 3 jumps to kill.

I commented out the death animations on the monster hurt script because I was testing it and we were able to get it to work in the Jump on Kills script.

I will share my Handle Object Collisions script this afternoon when I get home.

Sounds nice. I will check your script and we'll figure out how to make it work :)
 
Top Bottom