Essential, increase maximum Health!!

CGdfc

New member
I have been looking for information about this but I have not found it, I do not know if someone has created a tutorial.

One of the most important elements of any game are its mechanics, in an RPG or adventure game, the improvements of your character are important or the game becomes boring.

In the legend oz zelda we can find hearts to increase our Health.
we started with 3 but little by little we increased to 20.
NES_01.gif

zelda-nes-gameplay.png


My idea is that you take an object or touch a tile, this disappears and increases a maximum number of Health. Of course "triggered" the screen hehehe
in the HUD I have verified that it can only have a maximum of 8 (in my opinion it's fine)

Does anyone know how this can be done? It is very useful and it is possible that many people are interested.
 

dale_coop

Moderator
Staff member
It should not be to difficult...
1/ Set your hud element max display to "8"
2/ Add a user variable "HealthMax" with an inital value of "3" (for your containers, that you will be able to increase until "8").
3/ Modify your powerup increasehealth script to check that container limit (HealthMax) when collecting a heart... it's the first lines of the script... modify to someting like:
Code:
	LDA myHealth
	CLC
	;ADC #$01
	;;CMP #$04
	CMP HealthMax	;; check against the container (hearts) limit
	BCS skipGettingHealth
4/ make a new power up script to increase the "HealthMax" value (adding a new heart container). You can collect on the screen. The script would be something like:
Code:
	;; check how is the max :
	LDA HealthMax
	CLC
	CMP #$08	;;; the max limit (same value than your HUD health element max)
	BCC +
	JMP ++
+:

	;; increment the Health MAX variable
	LDA HealthMax	
	CLC
	ADC #$01
	STA HealthMax
	
	;; uncomment if you want to give full health (HealthMax value) to the player:
	; STA myHealth
	; LDX player1_object
	; STA Object_health,x

	;;; Update the health HUD :
	LDA myHealth
	STA hudElementTilesToLoad
	LDA #$00
	STA hudElementTilesMax
	UpdateHud HUD_myHealth
	
	;; trigger the current screen :
	TriggerScreen screenType
 

dale_coop

Moderator
Staff member
Oh, also, you need to fix some current issues in NESmaker about the health HUD...
When the game starts it always shows hud MAX (eveen if the health is lower)...

To fix that issue:
1) modify the "HandleUpdateObjects.asm" script (in the "Basic\System\" folder), around line 193, locate those lines:
Code:
			LDA #HUD_LOAD	
			AND #%01000000
			BEQ +
			STA hudElementTilesToLoad
And modify like this (adding a line of code):
Code:
			LDA #HUD_LOAD	
			AND #%01000000
			BEQ +
			LDA myHealth	;;HERE <-------- fix to start with the correct hud health
			STA hudElementTilesToLoad

1) modify the script assgined to the "Hud Element 0" element in your "Project Settings > Script Settings" (it should be the HUD_Element_Var_Image.asm script), , around line 12, locate those lines:
Code:
DoScreenOffHudUpdate:
	LDX player1_object
	LDA Object_health,x
	STA myHealth
And modify like this :
Code:
DoScreenOffHudUpdate:
	; LDX player1_object 	;; commented out !
	; LDA Object_health,x	;; commented out !
  	; STA myHealth	;; commented out !
	LDA myHealth	;;dale_coop: fix to start with the correct hud health
Now it should display the right health value in the HUD.
 

CGdfc

New member
nesmaker gives error in a script line powerup_increasehealth :( unknow label.
line :
BCS skipGettingHealth

if I add ";" to that line I have verified that the "powerup_increasehealth_MAX" object that adds an extra health works.

but the powerup_increasehealth does not work and it adds triggered screen.
 

CGdfc

New member
I just checked that the piece of code xD wrong
Now it works perfectly. I added ... I do not know why ... the code of the object max health to that of increase health .... but now work good.

I noticed that the empty tile, used to show on the HUD that that point of heart you do not have (damaged by an enemy) is shown on the HUD from the beginning.

if your maximum halth is 8, it will show 8.

HaTBKwe.png


empty_tile in HUD
 

dale_coop

Moderator
Staff member
Yes, this will be way more complicated...
For now, I'd suggest to use completely blanks for the empty tiles.
 

CGdfc

New member
Thanks dale_coop !!, this was one of the very necessary things for my project and it helped me a lot.
for now I will use the black tile (same as in the original zelda)
 

SpiderDave

New member
To keep it simple, use two separate hud elements using varTiles. One will be drawn over the other one. The first one for max hit points (which you can still change since it's a separate variable), and the second for your current hit points. You still need to adjust some code but using two hud elements like that should make it easier if you have trouble.

EDIT: Actually, no this doesn't work. I did kludge together things with two varTiles side by side using blanks for empty, but it's a mess.
 

dale_coop

Moderator
Staff member
Or maybe...
just try to modify the HUD_Element_Var_Image.asm script assigned to the "Hud Element 0" element in your "Project Settings > Script Settings", adding this block of code at the beginning of the script:

Code:
	;; here, we replace the max tiles (max health) to draw:
	LDA DrawHudBytes
	AND #HUD_myHealth
	BEQ +
	LDA HealthMax
	STA hudElementTilesFull
	+

Now, the max should be displayed correclty on the hud (even if you are using empty tiles that are NOT blank).
 

CGdfc

New member
dale_coop said:
Or maybe...
just try to modify the HUD_Element_Var_Image.asm script assigned to the "Hud Element 0" element in your "Project Settings > Script Settings", adding this block of code at the beginning of the script:

Code:
	;; here, we replace the max tiles (max health) to draw:
	LDA DrawHudBytes
	AND #HUD_myHealth1
	BEQ +
	LDA HealthMax
	STA hudElementTilesFull
	+

Now, the max should be displayed correclty on the hud (even if you are using empty tiles that are NOT blank).

Hello, I checked that it works more or less, but the problem is that the upper HUD, cover the lower HUD, I explain.
In the hud, the black is not transparent, it is a color that is above the hud that shows the empty health.
it only appears if I place the hud in a place where I do not have any other hud element occupied.
 

CGdfc

New member
OK, it works!! it was not necessary to use the old var myHealth of the hud, just put HUD_myHealth1.
I got confused because the hud is not updated, you must go to the screen to see the changes of the hud.
if you receive damage, you will only know the damage it received if you change the screen.

Any solution to this?
 

CGdfc

New member
dale_coop said:
When you increase the max?

in any changes to the health hud, when take an object to heal or when the player receives damage. ( need to change the screen to see the changes)
it is the hud that does not update the changes, but it only happens with the life of the var HUD_myHealth1.
 

dale_coop

Moderator
Staff member
ok... if you are using the "BASE_" ones, it means you need to use HUD_myHealth and myHeath constant/variable (not health1 ones, those are for the twoPlayers module).
 

CGdfc

New member
OK,this work now perfect!!
Code:
	LDA DrawHudBytes
	AND #HUD_myHealth
	BEQ +
	LDA HealthMax
	STA hudElementTilesFull
	+
and again use the myHeath variable in the HUD.

Thanks dale!!
 
Top Bottom