Changing Map/Palette on Drawsprite

maxman

Well-known member
I have a scripted icon display I created using loadsprite and drawsprite for an enemy. For that, I want have the scripted icon to display already when he spawns before he attacks or gets attacked. But the problem is I cannot remap the icon I made instead of using the regular/default icon. The enemy is in color separation. I know maps don't have effect on default icons with scripts, but I dunno for scripted icons I made. What I'm trying to do is change the palette/map similar to this:

icon data/chars/kunio/icon.png 1
palette data/chars/kunio/idle.png
alternatepal data/chars/kunio/riki.png

Look at icon here:
Code:
void main() //Enemy HP
{
	if(getplayerproperty(0, "entity") == NULL() && getplayerproperty(1, "entity") == NULL()){
/*	    void vSelf      = getlocalvar("self");                  //Caller    
    int  iETime     = openborvariant("elapsed_time");       //Current time.
    int  iMax       = openborvariant("count_entities");            //Entity count.
    int  iEntity;                                           //Loop counter.
    void vEntity;                                           //Target entity.

    for(iEntity=0; iEntity<iMax; iEntity++)
    {    
        vEntity = getentity(iEntity);                                       //Get target entity from current loop.        
        
        if (vEntity && vSelf)                                               //Both Self and Target?
        {
            changeentityproperty(vEntity, "frozen", 1);               //Toggle frozen.
            changeentityproperty(vEntity, "freezetime", 95000);    //Toggle frozen time.
        }
    }*/    
	}
	else
	{
		void self = getlocalvar("self");
//		float z = getentityproperty(self, "z");
		int HP = getentityproperty(self, "health");
		int MaxHP = getentityproperty(self, "maxhealth");
		int health = 114*HP/MaxHP;
		int P1 = getplayerproperty(0, "entity");
		int P2 = getplayerproperty(1, "entity");
		void name = getentityproperty(self, "name");
		void icon = loadsprite("data/profiles/"+ name +".png");
		int map = getentityproperty(self, "map");
		int iconmap = getentityproperty(icon, "map");
		int palette = openborvariant("current_palette");
		
		/*
		int map = getglobalvar("map");
		
		
		*/
		
		    int  iETime     = openborvariant("elapsed_time");       //Current time.
    int  iMax       = openborvariant("count_entities");            //Entity count.
    int  iEntity;                                           //Loop counter.
    void vEntity;                                           //Target entity.

/*    for(iEntity=0; iEntity<iMax; iEntity++)
    {    
        vEntity = getentity(iEntity);                                       //Get target entity from current loop.        
        
        if (vEntity && self)                                               //Both Self and Target?
        {
            changeentityproperty(vEntity, "frozen", 0);               //Toggle frozen.
  //          changeentityproperty(vEntity, "freezetime", 15000);    //Toggle frozen time.
        }
    }*/ 
		
		
		if(getentityvar(self,0)==NULL()){
		setentityvar(self,0, health);
		}
		
		if(findtarget(P1)){
			drawbox(176,6,health,2,1800,rgbcolor(255,234,41),0); 
			drawbox(176,8,health,1,1800,rgbcolor(255,226,0),0);
			drawbox(176,9,health,1,1800,rgbcolor(255,206,24),0);
			drawbox(176,10,health,1,1800,rgbcolor(246,194,0),0);
			drawbox(176,11,health,1,1800,rgbcolor(230,141,0),0);
			drawbox(176,12,health,1,1800,rgbcolor(222,92,0),0);
			drawsprite(icon,262,21,1800);
		}else if(findtarget(P2)){
			drawbox(100+(50-health),6,health,2,1800,rgbcolor(255,234,41),0); 
			drawbox(100+(50-health),8,health,1,1800,rgbcolor(255,226,0),0);
			drawbox(100+(50-health),9,health,1,1800,rgbcolor(255,206,24),0);
			drawbox(100+(50-health),10,health,1,1800,rgbcolor(246,194,0),0);
			drawbox(100+(50-health),11,health,1,1800,rgbcolor(230,141,0),0);
			drawbox(100+(50-health),12,health,1,1800,rgbcolor(222,92,0),0);
			drawsprite(icon,-56,21,1800);
		}
		
		if(health<getentityvar(self,0)){
			if(getentityvar(self,1)==NULL()){
				setentityvar(self,1,0);
			}
			setentityvar(self,1,getentityvar(self,1)+1);
			if(getentityvar(self,1) > 50){
				setentityvar(self,0,getentityvar(self,0)-1);
				setentityvar(self,1,0);
			}
		}
	}
}
 
This must be done with drawmethid, and you have to get the pointer reference to the color table itself... not a map index. Still not at a working comp (see my earlier posts today) but will post a code samples when I can.

DC
 
I was reading your tutorial about color tables. It's really nice, even it's WIP. I've not tried with colourtable before. I wonder how I can put color table in script. I see the function for colourtable is this. Is map an int? I tried putting icon in the entity part but it crashes. :P Is the value for colourtable property right?

getentityproperty(entity, "colourtable", map);

What do you think about these, DC? The last rows at the bottom are for palette(s) and alternatepals while the top are for effects. Those images with color tables are from Mugen. The first color table is from a sprite pack of CS pcx files while the others are from CS palette contributors. I tried using colourmap in setdrawmethod where drawsprite is but it don't work. Even I tried with remap in changedrawmethod too, no work at all. I know it must not be map, but color table itself which is hard for me to find/define. I can go with drawmethod but I dunno what property I could go with. I'd go with 64 colors that are from the CS icon. I'm unsure what to do.

colortable_n_remaps.png
 
maxman said:

Not exactly, but getting closer. Unfortunately I have a HUGE report due on Tuesday I forgot about, so I'm going to be out of the game until that's done. :(
 
OK. How about an entity change of it?

changeentityproperty(entity, "colourtable", map);

Honestly, I dunno what the real value for colourtable is in the entity change though. And the GEP? I know getentityproperty names don't include values, but because I looked at one post here, I was wondering about how colourtable works.

getentityproperty(entity, "colourtable");

I just tried gep without map for colourtable but it crashes.

I'll wait for ya on the solution when ya done, DC.
 
Is this correct when I have 89-90 64 slots like this? Should I rearrange each color(s) from lightest to darkest or darkest to lightest?

colortable_n_remaps_1.png
 
You don't need to rearrange colors in the pallete based on the hues. But need to take care of which position is which color.
In your exemple (3rd one),  the 5th spot is a dark color. On the entity you will apply this, if its uses a palette that the 5th is white (for example) and that color is used for a stroke or border, it will get a white border.
 
maxman said:

Like O'Ill said, and I have repeated, time and again to folks working with colors. Order has everything to do with nothing at all!

All that matters is the tables line up with each other when you want to use them in concert, and that you account for the transparent entry. That's (15, 15) for .pcx which you should never be using anyway, and (0, 0) for all others. Other than that, order them however you feel like.

 
DC, it's just that I don't know what/how to do with the color table though. :)

Anyway, I just tried using iconposition and replaced drawsprite, then it works. Normal icons always cover entities unless any entity has a very longer value of setlayer to cover them (e.g. a black screen with setlayer 280000000 for covering everything). The reason I use drawsprite is to set a z setlayer for it so characters can move around or jump around to cover their icons. drawbox for player/enemy lifebar has a z setlayer also which they can cover it just like most modern VS fighting games.

I want to go with drawmethod but dunno what type of drawmethod I could use for drawsprite. I want to go for a different method with using drawsprite. I might come up with another ondrawscript for icon.
 
Back
Top Bottom