Solved Script lifebar for bosses

Question that is answered or resolved.

dantedevil

Well-known member
I have a prpbelam when use an enemy first like a boss and next like a regular enemy in future stages.
Because when is a boss if use lifebarstatus, can't use again the same enemy for regular enemy. So need to create a copy of this enemy, without the lifebarstatus.

So searching info about this, I found the script lifebar for bosses in the Crime Buster mod for BloodBane.
I try to use in my mod but not work, the icon and the bar never shows.

Here the files:

The lifebar script:
Code:
// Lifebar display script
void main()
{
    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int  vAlias = getentityproperty(self, "name");
    int  iHealth = getentityproperty(self, "health");
      int  iHPMax = getentityproperty(self, "maxhealth"); // Get entity's maximum health

    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", "Lifebar"); //Set Lifebar as spawned entity.
   
    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "parent", self); //Set caller as parent.
    changeentityproperty(vSpawn, "name", vAlias); //Set name.
    changeentityproperty(vSpawn, "health", iHealth); //Set health.
      changeentityproperty(vSpawn, "maxhealth", iHPMax); // Set maxhealth.
}

The lifebar entity:
Code:
name     Lifebar
health   1
type     none
shadow     0
icon     data/chars/misc/lbaricon.png

lifebarstatus 400 8 1 1 0 -9999 -9999 -9999 -9999
iconposition -12 235
lifeposition 35 260
nameposition -9999 -9999


anim idle
@script
    void self = getlocalvar("self");
    void Parent = getentityproperty(self, "parent"); // Get parent
    int Health = getentityproperty(self, "health"); // Get entity's health

    if (Parent != NULL()){ //Have parent?
      int HParent = getentityproperty(Parent, "health"); // Get parent's health

      changeentityproperty(self, "health", HParent); // Use parent's health
    }

    if (Health <= 0){ // Health = 0?
      killentity(self); // Suicide
    }
@end_script
        loop    1
    delay    2
    offset    1 1
    frame    data/chars/misc/empty.png

anim fall
    delay    100
    offset    1 1
    frame    data/chars/misc/empty.png

And the set in spawn level:
Code:
spawn  bomberman2
spawnscript data/scripts/lifebar.c
alias  bomberman
@script
void main() {
    performattack(getlocalvar("self"), openborconstant

("ANI_follow12"));
} @end_script
2phealth 500
3phealth 600
item    bosser
coords  -150 270  0
flip  1
at     1645

There two problems here:
1 - Like said before, , the icon and the bar never shows.
2 - When use this line "spawnscript data/scripts/lifebar.c" in the spawn level,
the character not spawn using ANI_follow12. I don't understand why.
 
Last edited:
Solution
I could finally solve this and find a freat new method to use this lifebar.

Instead of use this lifebar.c
// Lifebar display script
void main()
{
void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
int  vAlias = getentityproperty(self, "name");
int  iHealth = getentityproperty(self, "health");
      int  iHPMax = getentityproperty(self, "maxhealth"); // Get entity's maximum health

clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", "Lifebar"); //Set Lifebar as spawned entity.

vSpawn = spawn(); //Spawn in entity.

changeentityproperty(vSpawn, "parent", self); //Set caller as parent.
changeentityproperty(vSpawn, "name", vAlias); //Set name...
I could finally solve this and find a freat new method to use this lifebar.

Instead of use this lifebar.c
// Lifebar display script
void main()
{
void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
int  vAlias = getentityproperty(self, "name");
int  iHealth = getentityproperty(self, "health");
      int  iHPMax = getentityproperty(self, "maxhealth"); // Get entity's maximum health

clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", "Lifebar"); //Set Lifebar as spawned entity.

vSpawn = spawn(); //Spawn in entity.

changeentityproperty(vSpawn, "parent", self); //Set caller as parent.
changeentityproperty(vSpawn, "name", vAlias); //Set name.
changeentityproperty(vSpawn, "health", iHealth); //Set health.
      changeentityproperty(vSpawn, "maxhealth", iHPMax); // Set maxhealth.
}

II decided to add this scripT to the animationscript of my enemies.
Like this:
Code:
void lifebar()
{
	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  vAlias = getentityproperty(self, "name");
	int  iHealth = getentityproperty(self, "health");
      int  iHPMax = getentityproperty(self, "maxhealth"); // Get entity's maximum health

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", "Lifebar"); //Set Lifebar as spawned entity.
	
	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "parent", self); //Set caller as parent.
	changeentityproperty(vSpawn, "name", vAlias); //Set name.
	changeentityproperty(vSpawn, "health", iHealth); //Set health.
      changeentityproperty(vSpawn, "maxhealth", iHPMax); // Set maxhealth.
}

This way you can call the boss lifebar whenever you want.
Very useful to call the lifebar after the dialogs, or spawn a hidden enemy in the background, then the enemy attack you before you can stay alert for see the bar.
Here an example, in the last frame of the animation call the lifebar.
Code:
anim follow9
	loop	0
	delay	20
	offset	82 370
	frame	data/chars/escort/rise3.png
	frame	data/chars/escort/rise4.png
	delay	1
	offset	82 177
        @cmd    move 0 0 193
	frame	data/chars/escort/rise4.png
        @cmd    stop
	delay	10
        @cmd    leaper 0 1 0
        sound   data/sounds/jump.wav
	offset	82 155
	frame	data/chars/escort/j1.png
        sound   data/chars/kitana/kat.wav
	frame	data/chars/escort/j1.png
        landframe 6
	delay	999
	frame	data/chars/escort/j2.png
	delay	20
	offset	82 177
	frame	data/chars/escort/rise4.png
	delay	10
	frame	data/chars/escort/spawn01.png
	@script
		if(frame == 8){
			void ent = spawn01("story", 0, 0, 0);
			changeentityproperty(ent, "name", "stage_5-2b");

    }
    if(frame == 9){
      void self = getlocalvar("self");
      changeentityproperty(self, "defense", openborconstant("ATK_NORMAL4"), 1);
    }
@end_script
	frame	data/chars/escort/spawn01.png
	frame	data/chars/escort/spawn01.png
        @cmd    lifebar 
	frame	data/chars/escort/spawn01.png
 
Solution
Back
Top Bottom