Conflict using 2 scripts in character header

try:

ps. if it doesn't work, please fix code line space and height of the brackets before posting another code.
so because the code is very messy

Code:
void main() {
   int i, j, k;
   void spr;
   int facing, cd;
   float a, z, x;
   void ent = getlocalvar("self");
   int anim = getentityproperty(ent,"animationid");
   void map;
   int elapsed_time = openborvariant("elapsed_time");

   if(anim == openborconstant("ANI_FREESPECIAL5")){ map = getentityproperty(ent,"colourtable", 0);}
   if(anim == openborconstant("ANI_FOLLOW9")){ map = getentityproperty(ent, "colourtable", 0);}
   if(anim == openborconstant("ANI_FREESPECIAL13")){ map = getentityproperty(ent,"colourtable", 0);}
   if(anim == openborconstant("ANI_FREESPECIAL14")){ map = getentityproperty(ent,"colourtable", 0);}
   if(anim == openborconstant("ANI_FREESPECIAL16")){ map = getentityproperty(ent,"colourtable", 0);}
   setglobalvar("blahblah.map", map);


   if(elapsed_time%trailerd==0)
   {
      if((anim == openborconstant("ANI_FREESPECIAL5")) || (anim == openborconstant("ANI_FOLLOW9")) || (anim == openborconstant("ANI_FREESPECIAL13")) || (anim == openborconstant("ANI_FREESPECIAL14")) || (anim == openborconstant("ANI_FREESPECIAL16")))
      {
      spr = getentityproperty(ent, "sprite");
      x = getentityproperty(ent, "x");
      z = getentityproperty(ent, "z");
      a = getentityproperty(ent, "a");
      facing = !getentityproperty(ent,"direction");
      for(k=1; k<=trailermax; k++) //find anempty trailer slot
      {
         if(getglobalvar("trailer"+k+".s")==NULL())
         {
            setglobalvar("trailer"+k+".s", spr);
            setglobalvar("trailer"+k+".x", x);
            setglobalvar("trailer"+k+".z", z);
            setglobalvar("trailer"+k+".a", a);
            setglobalvar("trailer"+k+".f", facing);
            setglobalvar("trailer"+k+".c", trailerc*trailerd);
            break;
         }
      }
   }
   }
    int Bi; int Bz; int Bt;int Bhealth;int Boff;
    void Bpl;
   if(openborvariant("in_level")==1)
    {
        Bz = openborconstant("FRONTPANEL_Z");
        for(Bi=0; Bi<3; Bi++)
        {
            Bpl = getplayerproperty(Bi, "ent");
        if(Bpl!=NULL())
        {
                void Bself = getlocalvar("self");
            void Btarget = findtarget(Bself);
            Bhealth = getentityproperty(Btarget, "health");

         if (Bhealth<=20)// checks if the health is 20 or less and draws a red box
         {
            //drawbox(x, y, width, height, z, color, alpha)
            drawbox(Bi*160+21, 37, Bhealth, 6, Bz+1000,rgbcolor(255,0,0));//health red

           void self = getlocalvar("self");
           void target = getlocalvar("Target" + self);

           if(target==NULL())
           {
             target = getentityproperty(self, "opponent");
             setlocalvar("Target" + self, target);
           }
           if(target!=NULL())
           {
             char Tname = getentityproperty(target, "defaultname");
             char iType = getentityproperty(target, "type");

            if (iType ==openborconstant ("TYPE_OBSTACLE") || iType ==openborconstant("TYPE_ITEM"))
             {
                 changeentityproperty(self, "animation", openborconstant("ANI_FREESPECIAL15"));
             }
           }
         }
      }
     }
   }
}
 
Thanks for your quick help!

Not work, i think better a clean restart.
This script works correct :
Code:
#include "data/scripts/trailer.h"


void main()
{
	int i, j, k;
	void spr;
	int facing, cd;
	float a, z, x;
	
	void ent = getlocalvar("self");
	int anim = getentityproperty(ent, "animationid");
	void map;
	int elapsed_time = openborvariant("elapsed_time");

	if(anim == openborconstant("ANI_FREESPECIAL5")){ map = getentityproperty(ent, "colourtable", 0);}
	if(anim == openborconstant("ANI_FOLLOW9")){ map = getentityproperty(ent, "colourtable", 0);}
	if(anim == openborconstant("ANI_FREESPECIAL13")){ map = getentityproperty(ent, "colourtable", 0);}
	if(anim == openborconstant("ANI_FREESPECIAL14")){ map = getentityproperty(ent, "colourtable", 0);}
	if(anim == openborconstant("ANI_FREESPECIAL16")){ map = getentityproperty(ent, "colourtable", 0);}
	setglobalvar("blahblah.map", map);


	if(elapsed_time%trailerd==0)
	{
		if((anim == openborconstant("ANI_FREESPECIAL5")) || (anim == openborconstant("ANI_FOLLOW9")) || (anim == openborconstant("ANI_FREESPECIAL13")) || (anim == openborconstant("ANI_FREESPECIAL14")) || (anim == openborconstant("ANI_FREESPECIAL16")))
		{
		spr = getentityproperty(ent, "sprite");
		x = getentityproperty(ent, "x");
		z = getentityproperty(ent, "z");
		a = getentityproperty(ent, "a");
		facing = !getentityproperty(ent, "direction");
		for(k=1; k<=trailermax; k++) //find an empty trailer slot
		{
			if(getglobalvar("trailer"+k+".s")==NULL())
			{
				setglobalvar("trailer"+k+".s", spr);
				setglobalvar("trailer"+k+".x", x);
				setglobalvar("trailer"+k+".z", z);
				setglobalvar("trailer"+k+".a", a);
				setglobalvar("trailer"+k+".f", facing);
				setglobalvar("trailer"+k+".c", trailerc*trailerd);
				break;
			}
		}
	}
	}
    int Bi; int Bz; int Bt;int Bhealth;int Boff;
    void Bpl;
   if(openborvariant("in_level")==1)
    {
        Bz = openborconstant("FRONTPANEL_Z");
        for(Bi=0; Bi<3; Bi++)
        {
            Bpl = getplayerproperty(Bi, "ent");
            if(Bpl!=NULL())
            {
                void Bself = getlocalvar("self");
            void Btarget = findtarget(Bself);
            Bhealth = getentityproperty(Btarget, "health");
            
         
         if (Bhealth<=20)// checks if the health is 20 or less and draws a red box
         {
            //drawbox(x, y, width, height, z, color, alpha)      
            drawbox(Bi*160+21, 37, Bhealth, 6, Bz+1000, rgbcolor(255,0,0));//health red

            
      }
            }
        }
    }
}
The only problem is the red bar appear with items (with no life 1).
Need a exception to work only with enemies.
I'm right?

 
ah, try this:
Code:
#include "data/scripts/trailer.h"


void main()
{
	int i, j, k;
	void spr;
	int facing, cd;
	float a, z, x;
	
	void ent = getlocalvar("self");
	int anim = getentityproperty(ent, "animationid");
	void map;
	int elapsed_time = openborvariant("elapsed_time");

	if(anim == openborconstant("ANI_FREESPECIAL5")){ map = getentityproperty(ent, "colourtable", 0);}
	if(anim == openborconstant("ANI_FOLLOW9")){ map = getentityproperty(ent, "colourtable", 0);}
	if(anim == openborconstant("ANI_FREESPECIAL13")){ map = getentityproperty(ent, "colourtable", 0);}
	if(anim == openborconstant("ANI_FREESPECIAL14")){ map = getentityproperty(ent, "colourtable", 0);}
	if(anim == openborconstant("ANI_FREESPECIAL16")){ map = getentityproperty(ent, "colourtable", 0);}
	setglobalvar("blahblah.map", map);


	if(elapsed_time%trailerd==0)
	{
		if((anim == openborconstant("ANI_FREESPECIAL5")) || (anim == openborconstant("ANI_FOLLOW9")) || (anim == openborconstant("ANI_FREESPECIAL13")) || (anim == openborconstant("ANI_FREESPECIAL14")) || (anim == openborconstant("ANI_FREESPECIAL16")))
		{
		spr = getentityproperty(ent, "sprite");
		x = getentityproperty(ent, "x");
		z = getentityproperty(ent, "z");
		a = getentityproperty(ent, "a");
		facing = !getentityproperty(ent, "direction");
		for(k=1; k<=trailermax; k++) //find an empty trailer slot
		{
			if(getglobalvar("trailer"+k+".s")==NULL())
			{
				setglobalvar("trailer"+k+".s", spr);
				setglobalvar("trailer"+k+".x", x);
				setglobalvar("trailer"+k+".z", z);
				setglobalvar("trailer"+k+".a", a);
				setglobalvar("trailer"+k+".f", facing);
				setglobalvar("trailer"+k+".c", trailerc*trailerd);
				break;
			}
		}
	}
	}
    int Bi; int Bz; int Bt;int Bhealth;int Boff;
    void Bpl;
   if(openborvariant("in_level")==1)
    {
        Bz = openborconstant("FRONTPANEL_Z");
        for(Bi=0; Bi<3; Bi++)
        {
            Bpl = getplayerproperty(Bi, "ent");
            if(Bpl!=NULL())
            {
            void Bself = getlocalvar("self");
            void Btarget = findtarget(Bself);
            Bhealth = getentityproperty(Btarget, "health");
            
         if (Btarget!=openborconstant("TYPE_ITEM") || Btarget!=openborconstant("TYPE_OBSTACLE"))
		 {
			if (Bhealth<=20)// checks if the health is 20 or less and draws a red box
			{
				//drawbox(x, y, width, height, z, color, alpha)      
			drawbox(Bi*160+21, 37, Bhealth, 6, Bz+1000, rgbcolor(255,0,0));//health red
			}
		 }		
            }
        }
    }
}
 
Well finally i think this is last try.
All works perfect,  but after the kill a enemy, the red bar still showing in the screen.
Only leaves when a new enemy  comes.
 
Back
Top Bottom