Banner
Views: 853,841,258
Time:
26 users online: autisticsceptile1993, Ayami, Carld923, Connnnair, containercore, Earthling, ExONightZ, JDC, kellykelster,  Lazy, Linatic, lustreflux, lx5, NewPointless, nickofzo, Para_0, PineSkyz, qantuum, RPG Hacker, Runic_Rain, Samantha, Super Wario Man, teotaylor, Ultima, Von Fahrenheit, Zareption - Guests: 103 - Bots: 68 Users: 47,115 (2,477 active)
Latest: Eber
Tip: Doors and pipes act strange near screen boundaries. See this to avoid strange issues.Not logged in.
Graphical Health bar tutorial [please close]
Forum Index - SMW Hacking - SMW Hacking Help - Tutorials - Old Tutorials - Graphical Health bar tutorial [please close]
Pages: « 1 » Thread Closed
Request from alcaro.

Download
Introduction:
Tired of having the health meter in numeral numbers or a boss that doesn't show its heath? Worry no more! This Graphical health bar displays the enemy's health in graphic rather than numbers. It should be compatible with most boss sprites and shouldn't crash.

You see health bars in Brutal Mario bosses, Super Mario Odyssey fighting the "chargen chuck" boss, and smwc production
(toadsworth final boss)
but my version is even far better than those three, because they have 1 HP per tile, so its hard to make a boss that have a lot of HP without overwriting many of the status bar tiles, mine however, uses PIXELS instead of tiles, allowing 8 HP per tile and having lots of HP without losing lots of spaces in the status bar. Not only that, you can change how long the max length/HP of the bar to your custom length. Although, if you are using this and don't want a boss to take many many hits, you need to change the damage routine when the boss gets hurt by getting stomped, hit with a thrown sprite etc. That'll reduce the number of hits the boss takes until death.

Instructions:

1) Convert to xkas. this is xkas compatibility, so open the ASM file and copy ALL the code by pressing [CTRL+A] then [CTRL+X]. Then go to this page to convert them to xkas sprite, copy that converted code then paste the code in the asm file. Then open the .CFG file, change the last number after the asm pointer from "0" to "1" (look in the cfg format) you can also use the CFG editor and check "use xkas for for assembly" near the bottom-left corner (above the "load original sprite info" and "show sprite clipping".

2) Make HP bar appear. Open the asm file and in the sprite's main routine, stick "JSR DRAW_STATUS" (without the quotes) on the top and add the code from Graphical_hp_bar.asm or Graphical_hp_bar_record.asm on the very bottom so the sprite draw its health onto the status bar (it should draw its hp every frame/time).

3) Damage routine. Skip this step to 3.5 if your sprite's HP doesn't count up when damage. Some boss sprites like the Giant Masked Koopa have their "hit points" acting like a hit counter, that is, the counter in its HP ram address counts up (rather than down) when the boss gets hurt and when it gets a certain amount (such as become equal to the compared value that calls the "death" routine), the boss dies, . Example:

Code
		JSR SUB_STOMP_PTS       ; give Mario points
		LDA #$28                ; \ sound effect
		STA $1DFC               ; /
		LDA #$A0		    ; \ Set THROW_FIRE timer
		STA $1564,x             ; /
		INC $1534,x             ; increment sprite hit counter
		LDA $1534,x             ; \ if sprite hit counter == 3
		CMP #HIT_POINTS         ;  |   

		BEQ SPRITE_DEAD		; /

Change that code into this code:
Code
!damage = $05	;\put this on the very top of the asm
!HP_ram = $1534	;/

		LDA #!damage		;\prevents the HP going to
		CMP !HP_ram,x		;|the highest value when boss
		BCC skip_kill		;|takes damage larger than its
		STZ !HP_ram,x		;|current HP.
		BRA SPRITE_DEAD		;/
skip_kill:
		LDA !HP_ram,x
		SEC : SBC #!damage
		STA !HP_ram,x             ; decrement sprite hit counter
		LDA !HP_ram,x             ; \ if sprite hit counter == 3
		BEQ SPRITE_DEAD		; /



3.5) If the boss's programming HP doesn't count up when damage (like the morton or newbie boss, subtract its HP), all you have to do is add this code in the "damage" routine (if you find "DEC" command on the HP ram, then replace that code.)
Code
!damage = $05	;\again add this on the very top
!HP_ram = $1534	;/

	LDA #!damage		;\load damage
	CMP !HP_ram,x		;|if the damage is smaller than HP..
	BCC hurt		;|then hurt the boss
	BRA kill		;/otherwise kill the boss
hurt:
	LDA !HP_ram,x
	SEC : SBC #!damage
	STA !HP_ram,x
kill:			;>add this code above the code so that it calls the death routine.


4) sets boss HP to max.
Okay, now you want the boss to start with full health when it enters the screen, keep in mind that when levels are loaded, most ram address starts at zero due to the "reset and refresh" so things are loaded correctly. So if you don't insert this code, the boss will start with 0 HP. This code will set the HP:

Code
LDA.b --*8	;\replace "--" with the number of middle tiles (the tiles where "empty" and "fill" goes into, not the end tiles)
STA !Hp_ram 	;/(replace that word with $1534 if you are using bosse like ght Giant Masked Koopa


Adding this code in the main routine isn't recommended, because it will set its HP to max every frame and unable to take damage.

5) Insert the graphics. make sure that in the options menu of Lunar magic that "use joined GFX files" is uncheck so you can replace the status bar graphic with the HP meter. After that press #lm{insgfx} to insert the gfx that should update the graphic.

Instruction for the Newbie boss.
1) convert the ASM. again, use this page, copy the converted code, paste them in the ASM, then change the last bit in the CFG.

2) Use a different ASM code. Because the Ram address HP for the newbie boss isn't a miscellaneous sprite table, you have to use Newbie_boss_Graphical_HP.asm or Newbie_boss_record_effect.asm instead. so stick "JSR DRAW_STATUS" in the top of the main routine, and add the HP bar code from Newbie_boss_Graphical_HP.asm or Newbie_boss_record_effect.asm and paste them in the very bottom of the newbie boss asm file.

3) damage. Skip this if you want the boss to take the smallest unit of damage (takes 1 point of pixel of HP in the meter) which nobody want that on a really long HP bar. so go to line 272 (by pressing CTRL+G in notepad) and you should find this:
Code
LDA $7F8888
DEC A
STA $7F8888

change that into:
Code
!damage	=	$--	;>put this on the very top.

LDA #!damage	;\
CMP $7F8888	;|if damage larger than HP
BCS dead	;/then kill
LDA $7F8888
SEC : SBC #!damage
STA $7F8888

4) set the HP to max. Super easy, because of the easy customizable defines on the top, just do the math:
Hitpoints = [number of middle tiles] times [8].
The default is #$07, so its max HP is #$38

5) Insert the graphics. make sure that in the options menu of Lunar magic that "use joined GFX files" is uncheck so you can replace the status bar graphic with the HP meter. After that press #lm{insgfx} to insert the gfx that should update the graphic.

MISC:
1)If you want a longer HP bar on the status bar (HUD), there are two steps you must do:
change "!middle_tile" to any number of how many tiles long long plus 2 end tiles, Example: I want it 9 tiles long, so replace $07 with $09 in that define.

2)In the "cleaning area" just above the where it says: "do not change anything under here!!" edit this:
Code
	LDA #!empty_tile			;>don't change this.
	STA !position+$01			;|empty tiles, change this if you change 
	STA !position+$02			;|"!middle_tile" by adding a new
	STA !position+$03			;|"STA !position+X" where x is the position
	STA !position+$04			;|of each empty tile. Do not skip position
	STA !position+$05			;|numbers.
	STA !position+$06			;|
	STA !position+$07			;/
;add another "STA !position+$**" here if you change !middle tile (must be in order)

add another "STA !position+$--" where "--" is the number of middle tiles (where it says; "add another "STA !position+$**" here if you change !middle tile (must be in order)"). The !position of empty tiles must be in order and must not skip, so don't do this:
Code
	LDA #!empty_tile				;>don't change this.
	STA !position+$01				;\empty tiles, change this if you change 
	STA !position+$02				;|"!middle_tile" by adding a new
	STA !position+$03				;|"STA !position+X" where "X" is the position
	STA !position+$04				;|of each empty tile. Do not skip position
	STA !position+$05				;|numbers.
	STA !position+$06				;|
	STA !position+$07				;/
	STA !position+$09

instead, you have to list ALL the empty tiles:
Code
	LDA #!empty_tile				;>don't change this.
	STA !position+$01				;\empty tiles, change this if you change 
	STA !position+$02				;|"!middle_tile" by adding a new
	STA !position+$03				;|"STA !position+X" where "X" is the position
	STA !position+$04				;|of each empty tile. Do not skip position
	STA !position+$05				;|numbers.
	STA !position+$06				;|
	STA !position+$07				;/
	STA !position+$08
	STA !position+$09

And finally you are done. If you have any question, please PM me or any asm knowledge people. TIP: to find the code to replace, you can press [CTRL+F] and type a phrase that is likely be in the asm file, for example: "HIT_POINTS" and I found the damage routine.

Q: what is a record effect?
A: a record effect is when the boss appears, the HP bar starts empty and begins to fill, and when the boss gets hurt, the subtract HP does't instantly goes down to a certain amount (depending on which damage), rather subtract 1 by 1 each frame until it reaches a certain amount.

--------------------
Give thanks to RPG hacker for working on Asar.
This is nice, but, how to make something like Mario's Health Bar in Brutal Mario, where Mario could take damage without losing his power-up and allowing him to take more than 3 hits?



-Aki
In pseudocode, you could do something like this every frame for a very simple version of what you ask:

Code
if Mario is small:
 	if remaining hits > 0:
		decrease number of remaining hits
		make Mario big (or whatever other status you like)
	else:
		kill Mario
write number of remaining hits to the status bar

Although I'm not sure why you're asking in this thread, since it's not really related to the sprite the tutorial is for at all.

Also closing the thread on request of the original poster.

--------------------
My YouTube channel
Get the official ASMT resource pack here!

Pages: « 1 » Thread Closed
Forum Index - SMW Hacking - SMW Hacking Help - Tutorials - Old Tutorials - Graphical Health bar tutorial [please close]

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2020 - SMW Central
Legal Information - Privacy Policy - Link To Us


Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Super Mario Bros. X Community
  • ROMhacking.net
  • Mario Fan Games Galaxy