SOLVED Game Object given after NPC text 4.5

Pauldalyjr

Active member
Does anyone know how to have an NPC give a game Object after the text? Like after the text box closes. I know the text drop down has an option to give magic, relic etc but I cannot find where I could make items for those. I have tried everything I can think of for code and can get the NPC to give an item before the text box, like as soon as the player touches the NPC, they can actually walk away with the item without triggering the text. I really want it after the text box closes... Any ideas?
 

mouse spirit

Well-known member
Is this 4.1.5 or 4.5? Those options are maybe left over from the creators as it is still beta, and
they made and used this program to make a game,so there are leftovers.
There is a topic somewhere on it... if i find a good npc gives item topic i will post it here. be
sure to subscribe to this post. I may even find it in a second.
 

mouse spirit

Well-known member
http://nesmakers.com/search.php?keywords="npc+gives+item"
try looking through these. If you find it let me know as if its a good tutorial,
i will link it to the wiki.Also, here's the wiki if it helps with anything.
https://nesmaker.fandom.com/wiki/NESmaker_Wiki
I am currently making the help section, but its mostly all 4.1.5 for now
as this is day one of making it.


Here's for 4.1.5.In this script i have warps after the text boxes.(dale_coop helped)
Instead of warp , you would put what you want.Don't imagine giving a physical item,
maybe just change a variable
This is at the very end of HandleTextBox.asm for 4.1.5
Code:
SetTileToChange temp3, temp2, updateTile_02
	
	LDA temp
	CLC
	ADC #$21
	STA temp2
	LDA temp1
	ADC #$00
	STA temp3
	
	SetTileToChange temp3, temp2, updateTile_03
	INC tilesToWrite
	LDA #$01
	STA updateNametable
	
	INC updateNT_H_offset
	LDA updateNT_H_offset
	CMP #BOX_1_WIDTH
	BNE dontReturnToGame
	LDA #$00
	STA updateNT_H_offset
	INC updateNT_V_offset
	LDA updateNT_V_offset
	CMP #BOX_1_HEIGHT
	BNE dontReturnToGame
	LDA #$00
	STA textboxHandler
	STA updateHUD_offset
	LDA gameHandler
	AND #%11011111
	STA gameHandler
	;ShowSprites

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; check to see if there is behavior after a text box.

;;;; THIS WOULD be where you pout code AFTER TEXTBOX.
		
;xxxx	
;xxxx
;xxxx
;xxxx
	
	; LDA #$01
	; STA activateWarpFlag
	; PlaySound #SND_ENTER
	; LDX player1_object
	; LDA Object_x_hi,x
	; STA mapPosX
	; LDA Object_y_hi,x
	; STA mapPosY
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
	
	
dontReturnToGame:

	RTS
	
	
	
isWritingTextboxAttributes:
	;; handle all four quadrants of the attribute.
	
	
	RTS
 

Pauldalyjr

Active member
I saw your update. That's awesome! I think I can make that work, thank you so much! I'll try that out later tonight and let you know.
 

Pauldalyjr

Active member
It's not working just yet, I'll need to figure out "setTileToChange" has been updated to in 4.5... once I get this figured out I'll post a solution.
 

mouse spirit

Well-known member
If youre not privy, use the </> icon in full editor & preview with you code selected
to easily post code.If you are, disregard this.
 

Pauldalyjr

Active member
So here is basically what I have, couple of issues though. If the max for the variable is more than one the item will max out as soon as the player touches the tile.

Code:
        LDA npcTrigger
	ORA #%00000001
	STA npcTrigger
	LDA screenText
	STA npc_text
	INC myItem
	UpdateHudElement #$03
	TriggerScreen screenType

So that gives a max out on the variable as soon as you touch it,then you can activate the NPC text...

So I added in something to trigger the tile and update the graphic. Now I only receive a single instance of the variable, but the NPC text will not pull up and the screen doesnt stay triggered once you leave and come back.

Code:
       LDA npcTrigger
		ORA #%00000001
		STA npcTrigger
		LDA screenText
		STA npc_text
				
	;	DrawBox #BOX_1_ORIGIN_X, #BOX_1_ORIGIN_Y, #BOX_1_WIDTH , #BOX_1_HEIGHT, #TEXT_NPC, npc_text
	;	ORA #%00000001
		INC myItem
		UpdateHudElement #$03
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;		
;;; deactivating and switching out the tile, code from lock tiles
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDY temp1
	LDA temp2
	BEQ +isEvenCt
		;; is an odd ct, so looking in collisionTable2
		LDA #$00
		STA collisionTable2,y
		JMP +doneWithTileUpdate
	+isEvenCt
		LDA #$00
		STA collisionTable,y
	+doneWithTileUpdate

;;; GET THE HIGH BYTE OF THE TILE TO CHANGE
	LDA temp2
	BEQ +isEvenNt
		;; is odd nt
		LDA #$24
		JMP +gotNt
	+isEvenNt
		;; is even nt
		LDA #$20
	+gotNt
		STA temp1
;;; GET THE LOW BYTE OF THE TILE TO CHANGE
		TYA
		STA temp
		LSR
		LSR
		LSR
		LSR
		LSR
		LSR
		clc
		ADC temp1
		STA temp2 ;;;temp16+1
		TYA
		AND #%11110000
		ASL
		ASL
		STA tempz
		TYA
		AND #%00001111
		ASL
		ORA tempz
		STA temp3 ;temp16
		
;;; SET THE TILE NUMBER TO CHANGE TO.	
	LDA #$28 ;; the tile to change.
			;;; this is in tiles, so if you wanted the second "metatile",
			;;; use 2, not 1.  If you wanted the tile in the next row, 
			;;; use #$20, not #$10.  Etc.
	STA tempA
	CLC
	ADC #$01
	STA tempB
	CLC
	ADC #$0F
	STA tempC
	CLC
	ADC #$01
	STA tempD
	LDY #$00
	LDA temp2
	STA scrollUpdateRam,y
	INY
	LDA temp3
	STA scrollUpdateRam,y
	INY
	LDA tempA
	STA scrollUpdateRam,y
	INY
	LDA temp2
	STA scrollUpdateRam,y
	INY
	LDA temp3
	CLC
	ADC #$01
	STA scrollUpdateRam,y
	INY
	LDA tempB
	STA scrollUpdateRam,y
	INY
	LDA temp3
	CLC
	ADC #$20
	STA temp3
	LDA temp2
	ADC #$00
	STA temp2
	LDA temp2
	STA scrollUpdateRam,y
	INY
	LDA temp3
	STA scrollUpdateRam,y
	INY
	LDA tempC
	STA scrollUpdateRam,y
	INY
	LDA temp2
	STA scrollUpdateRam,y
	INY
	LDA temp3
	CLC
	ADC #$01
	STA scrollUpdateRam,y
	INY
	LDA tempD
	STA scrollUpdateRam,y
	INY
	TYA
	STA maxScrollOffsetCounter	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;		
;;; done deactivating and switching out the tile, code from lock tiles
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Turn on update screen on next frame.
		LDA updateScreenData
		ORA #%0000100
		STA updateScreenData
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	TriggerScreen screenType

I think i can fix the second part by adding some additional code in postScreenLoad, but I do not know what to do about the text box.
 

Pauldalyjr

Active member
OK, I moved the INC item and that let me only have one so that part was fixed, but I could still get the item without triggering the text. So I put a check before anything happens to look for the A button to b pressed. Now this does everything I want except update the hud while Im on the screen, when I do that I get some weird text box issues. Anyways here is the code if anyone wants it...

Code:
	LDA gamepad                     ;load the controller to read the state
	AND #%00000001                  ;is the A button pressed??
	BNE runScreenOneCode            ;it is pressed jump on down a couple lines
	JMP endOfThisOne                ;its not pressed, nothing to see here, move along
	runScreenOneCode                ;ok we jumped here from 2 lines up
	INC myItem                      ;this is the item I wanted to pick up after the text plays
	LDY temp1                       ;;this is the start of the triggering the text
	LDA temp2                       ;;we need to know if we are standing on the triggering
	BEQ +isEvenCt                   ;;we need to know what colision table we are on
	LDA #$00       
	STA collisionTable2,y
	JMP +doneWithTileUpdate
	+isEvenCt
	LDA #$00
	STA collisionTable,y
	+doneWithTileUpdate             ;;figured out where we are
	LDA npcTrigger                  ;;load up the trigger
        ORA #%00000001                  ;;are we colliding with the trigger?
	STA npcTrigger                  ;;trigger the text
	DrawBox #BOX_1_ORIGIN_X, #BOX_1_ORIGIN_Y, #BOX_1_WIDTH , #BOX_1_HEIGHT, #TEXT_NPC, screenText; npc_text
	TriggerScreen screenType        ;;trigger the screen
 
Top Bottom