Custom Lifebars & Weapons

Zox

New member
Is it possible to create a custom Lifebar and a Heart system weapons like in regular Castlevania?

2njzx35.png
 
Now I'm curious about getting points of hearts after grabbing any weapon. In Castlevania games, you can see that the player grabs small or big hearts for amount of "ammos" in throwing out weapons like holy water, knives, kunai, axes, etc. For example, if you have 15 hearts with you as points, you throw out an axe and it could reduce to 3 points which will have 12 hearts remaining until they're out so you wouldn't use 'em till you get some more hearts.
 
It's not really that hard, thou I can't teach a proper methods, my own scripts need some work, I still use old methods (using update.c )

Basically with script, we check the current health etc.  and display sprites accordingly.

A heart system will be slightly different to what I've made before. The rest of the script will depend on what exactly you want to make.

Hide all the default GUI offscreen.

Load the sprites for the HP/hearts (in level.c for example).

Code:
setglobalvar("heart", loadsprite("data/gui/heart.png"));  //HEART SPRITE
setglobalvar("hp1", loadsprite("data/gui/hp1.png"));  //SINGLE HP BLOCK FULL
setglobalvar("hp2", loadsprite("data/gui/hp2.png"));  //SINGLE HP BLOCK EMPTY

ALTERNATE, COMBINED IMAGES

Code:
setglobalvar("hp1", loadsprite("data/gui/hp100.png"));  //HP FULL
setglobalvar("hp2", loadsprite("data/gui/hp90.png"));  //HP BLOCK 1 EMPTY

ETC.


Then the script to display the GUI

"check player HP, drawsprite's accordingly"
Code:
void main()
{  
void p1 = getplayerproperty(0, "entity");


if(getentityproperty(p1, "exists")) {

if(blahblah == x) { drawsprite(getglobalvar("hp1"), 0, 0, 91001001000, 0);

}

91001001000 - This is layer order for this sprite, a number this high will make it display over everything.



Anyhow that's the basic idea.
 
Phew, I've implemented the lifebar in Castlevania Collab demo as you can see in attachments below

(look at image posted by Zox)

Eh? you have 2 bars there but you also have heart counter. Are you going to use MP bar and hearts together?

[attachment deleted by admin]
 
Wow.. well yea i will use MP, with that he will have some special moves, like flame whip, whip upper and some more moves.. but send me the code seperated one with and without MP.

 
I don't have the code for dual lifebar as it will require coding new system for hearts

The heart number you see in both shots are actually MP bar converted into number (with little modification)

Also, I don't know about subweapons you're planning to have so the code will need to be adjusted for them. The system shown by these shots are for Castlevania Collab who has (currently) 12 subweapons

I'll post the code to create this but I'll omit subweapons part for now
Oh last but not least, the lifebar you see is drawn by script instead of using icon. That's why I don't need to edit playables text :)
 
Alright, here's the script but first of all you need to download and put the attached images in data/sprites folder.
Second, you need an update.c placed in data/scripts folder. The update.c is shown below:

Code:
void main()
{// Update script for displaying current HP from player 1 with colored bar
// Also displays current MP with numbers
    void P1 = getplayerproperty(0, "entity");
    void Bar = getglobalvar("Bar");

    if(openborvariant("in_level")==1){
      if(P1){
        int HP1 = getentityproperty(P1, "health");
        int MP1 = getentityproperty(P1, "mp");
        drawsprite(Bar, 3, 3, 1000);

	if(MP1>=100){
	  MP1 = 99;
	}

	drawstring(15,29,4, MP1);
	drawbox(7,104-HP1,3,HP1,1500,rgbcolor(255,0,0),0);
	drawbox(8,104-HP1,1,HP1,1800,rgbcolor(255,104,104),0);
	drawbox(10,104-HP1,1,HP1,1500,rgbcolor(178,0,0),0);
      }
    }
}

void oncreate()
{
    void Bar;

    Bar = loadsprite("data/sprites/lifebar.png");
    setglobalvar("Bar", Bar);
}

void ondestroy(){
    void Bar = getglobalvar("Bar");

    free(Bar);
    setglobalvar("Bar", NULL());
}

Third, you need to modify your HUD yourself like placing default lifebar and mpbar offscreen, move icon to fit the lifebar and move name & score

HTH

[attachment deleted by admin]
 
Thanks Bloodbane! :) I can take care of the scripts.

EDIT: I'm wondering if there's a possible way to have 2 MPs while we have one health bar.
 
I told you before that you need to create new system for the 2nd MP bar
It's doable but you need to use variable for it (global variable or indexed variable) then set script to fill that variable when hearts or anything is taken. That's just to name a few
 
Back
Top Bottom