Solved Bug with shadow trails

Question that is answered or resolved.

dantedevil

Well-known member
During the final test to share the first demo of my mod, i find a new bug.
This only happend when 2 players are playing.
Never happend when play alone.

4RJkunK.png


Sometimes the shadows of super combo shows bad, like in the picture. Other times the shadows only shows with normal colors, not blue like i set.
I start to have problems when change the update.c script to create a animated menu.
CRxTRDude helpme to solve the problem.
But yesterday , I discovered while playing with my daughter, that the problem is still there. I guess with three players also malfunction.

Here the files:

updated.c:
Code:
#include "data/scripts/anititle.c"
#include "data/scripts/story/story_define.h"
#include "data/scripts/story.c"
#include "data/scripts/gettick.c"


void zoom()
{
   void vscreen = openborvariant("vscreen");
   int maxz=openborvariant("PLAYER_MAX_Z")+1000;
   int zoom_value=getglobalvar("zoomvalue");
   int zoom_x=getglobalvar("zoomx");
   int zoom_y=getglobalvar("zoomy");
   void ent=getglobalvar("zoomentity");
   int px=getentityproperty(ent,"x") +  zoom_x - openborvariant("xpos");
   int py=getentityproperty(ent,"z") + zoom_y - openborvariant("ypos") - getentityproperty(ent,"a");
   void zoom_scr = getglobalvar("zoomscreen");
   if(!zoom_scr){
      zoom_scr = allocscreen(openborvariant("hResolution"),openborvariant("vResolution"));
      setglobalvar("zoomscreen",zoom_scr);
   }
   clearscreen(zoom_scr);

   //draw what we need
   drawspriteq(zoom_scr,0,openborconstant("MIN_INT"),maxz,0,0);
   //setup drawMethod
   changedrawmethod(NULL(),"reset",1);
   changedrawmethod(NULL(),"enabled",1);
   changedrawmethod(NULL(),"scalex",zoom_value);
   changedrawmethod(NULL(),"scaley",zoom_value);
   changedrawmethod(NULL(),"centerx",px);
   changedrawmethod(NULL(),"centery",py);
   //Draw the resized customized screen to main screen.
   drawscreen(zoom_scr,px,py, maxz+1);
   changedrawmethod(NULL(),"enabled", 0);
   drawspriteq(vscreen, 0, maxz+1,maxz+1, 0, 0);
   drawspriteq(vscreen, 0, maxz+2,openborconstant("MAX_INT"), 0, 0);
   clearspriteq();
}


void main(){
   if(getglobalvar("zoomentity"))
   {
      zoom();      
   }
      mainLoop();
}

void mainLoop(){
    void scene=openborvariant("current_scene");
    if(openborvariant("in_level"))
    {
        turnWhite();
        storySystem();
    }
    if(openborvariant("in_titlescreen")){
        if (scene!="data/scenes/intro.txt"){
            inTitleLoop(1);
        }
    }
    else {
        inTitleLoop(0);   
    }
}





Here a example the trailer.c of Raiden :
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_FOLLOW8")){ map = getentityproperty(ent, "colourtable", 0);}
    if(anim == openborconstant("ANI_FOLLOW9")){ map = getentityproperty(ent, "colourtable", 0);}
    if(anim == openborconstant("ANI_FREESPECIAL14")){ map = getentityproperty(ent, "colourtable", 0);}
    setglobalvar("blahblah.map", map);


    if(elapsed_time%trailerd==0)
    {
        if((anim == openborconstant("ANI_FREESPECIAL5")) || (anim == openborconstant("ANI_FOLLOW8")) || (anim == openborconstant("ANI_FOLLOW9")) || (anim == openborconstant("ANI_FREESPECIAL14")))
        {
        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;
            }
        }
    }
    }
}

Here trailer.h:

Code:
int trailermax = 50; //total trailers the engine can handle
int trailerc = 5; // totally 5 trailer images for each character
int trailerd = 15; // delay to spawn next trailer, so trailer lasts for trailermax*trailerd


In every Level i must set:

updatescript data/scripts/traileru.c

Here the script:
Code:
#include "data/scripts/trailer.h"

void main()
{
    int i, j, k;
    void spr;
    int facing, cd;
    float a, z, x;
    float sx = 256;
    float sy = 256;
void map = getglobalvar("blahblah.map");
    for(i=1; i<=trailermax; i++)
    {
        spr = getglobalvar("trailer"+i+".s");
        if(spr)
        {
            cd = getglobalvar("trailer"+i+".c");
            if(!cd)
            {
                setglobalvar("trailer"+i+".c", NULL());
                setglobalvar("trailer"+i+".s", NULL());
                setglobalvar("trailer"+i+".x", NULL());
                setglobalvar("trailer"+i+".z", NULL());
                setglobalvar("trailer"+i+".a", NULL());
                setglobalvar("trailer"+i+".sx", NULL());
                setglobalvar("trailer"+i+".sy", NULL());
            }
            else
            {
                if(openborvariant("game_paused")==0)
                {
                    setglobalvar("trailer"+i+".c", cd-1);
                }
                x = getglobalvar("trailer"+i+".x");
                z = getglobalvar("trailer"+i+".z");
                a = getglobalvar("trailer"+i+".a");
                if ( getglobalvar("trailer"+i+".sx") != NULL()) { sx = getglobalvar("trailer"+i+".sx"); }
                if ( getglobalvar("trailer"+i+".sy") != NULL()) { sy = getglobalvar("trailer"+i+".sy"); }
                facing = getglobalvar("trailer"+i+".f");
                                //,entity ,flag ,scalex ,scaley ,flipx ,flipy ,shiftx ,alpha ,colourmap ,fillcolour ,rotate ,rotateflip ,transparencybg
                                //setdrawmethod(NULL(),1, 256,256,facing,0,0,6,0,0,0,0,0,getglobalvar("trailer"+i+".colormap"));
                                setdrawmethod(NULL(),1, sx, sy,facing,0,0,6,0,0,0,0,0,map);
                                //drawsprite(spr, x-openborvariant("xpos"), z-a-openborvariant("ypos"), z-i, 0);

                //setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 0);
                //drawsprite(sprite, int x, int y, int z, int sortid)
                drawsprite(spr, x-openborvariant("xpos"), z-a-openborvariant("ypos")-3, z-i, 0);
                                //setdrawmethod(NULL(),0, 256, 256,0,    0,0,0,0,0,0,0,0,NULL());
            }
        }
    }
}
 
Last edited:
Solution
dantedevil said:
OK, thanks.

Last question of this:
Code:
#import "data/scripts/shadowtrail.c"

void main() {
  void player = getlocalvar("self");

  check_shadow_trail(player);



    if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FREESPECIAL5")
               && getentityproperty(player, "animpos") < 7 ) {
        set_shad_trail_flag(player,1);
    } else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FREESPECIAL5")
               && getentityproperty(player, "animpos") >= 7 ) {
        set_shad_trail_flag(player,0);
    }   

    else if ( getentityproperty(player, "defaultmodel") ==...
well, to change a map see the draw_shadowtrail() function.
search the line:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, colourmap);

I use colourmap:
colourmap = getentityproperty(ent, "colourmap");

colourmap is the original character map. If you want you can change it  ;)

to add another animation the corrected code is:
Code:
    if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FREESPECIAL5")
               && getentityproperty(player, "animpos") < 7 ) {
        set_shad_trail_flag(player,1);
    } else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FREESPECIAL5")
               && getentityproperty(player, "animpos") >= 7 ) {
        set_shad_trail_flag(player,0);
    }   

    else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FOLLOW4")
               && getentityproperty(player, "animpos") < 9 ) {
        set_shad_trail_flag(player,1);
    } else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FOLLOW4")
               && getentityproperty(player, "animpos") >= 9 ) {
        set_shad_trail_flag(player,0);
    } 

    else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FOLLOW5")
               && getentityproperty(player, "animpos") < 56 ) {
        set_shad_trail_flag(player,1);
    } else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FOLLOW5")
               && getentityproperty(player, "animpos") >= 56 ) {
        set_shad_trail_flag(player,0);
    } else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") != openborconstant("ANI_FOLLOW5")
               && getentityvar(player, "shadowtrail") != 0 ) {
        set_shad_trail_flag(player,0);
    }    
 
    else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FREESPECIAL11")
               && getentityproperty(player, "animpos") < 26 ) {
        set_shad_trail_flag(player,1);
    } else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") == openborconstant("ANI_FREESPECIAL11")
               && getentityproperty(player, "animpos") >= 26 ) {
        set_shad_trail_flag(player,0);
    }

    else if ( getentityproperty(player, "defaultmodel") == "CAROLINA" && getentityproperty(player, "animationid") != openborconstant("ANI_FREESPECIAL5")
		&& getentityproperty(player, "animationid") != openborconstant("ANI_FOLLOW4") && getentityproperty(player, "animationid") != openborconstant("ANI_FOLLOW5")
		&& getentityproperty(player, "animationid") != openborconstant("ANI_FREESPECIAL11")
               && getentityvar(player, "shadowtrail") != 0 ) {
        set_shad_trail_flag(player,0);
    }

With your code there is a bug because when finish any shadowtrail animation you turn off the shadowtrail.
Instead you have to turn off the shadowtrail just when an animation is not a shadowtrail animation. See the new code  ;)
 
@WD, am I right with my changes above? I've changed the colourmap var to check a globalvar to seek the player's color table instead of using its entity, since he has his own map.png to acquire on.

He made his characters with alternate palettes and then used getentityproperty(ent, "colourtable", 0); to get the alternate colors from map.png to be its color table.

What I also quirk with this is, it replaces the global drawmethod's color table as well, but I guess doing:

                    changedrawmethod(NULL(), "enabled", 0);
                    changedrawmethod(NULL(), "reset", 1);
                    setdrawmethod(NULL(), 0);

would reset the color table of the drawmethod as well, am I right?
 
CRxTRDude said:
What I also quirk with this is, it replaces the global drawmethod's color table as well, but I guess doing:

                    changedrawmethod(NULL(), "enabled", 0);
                    changedrawmethod(NULL(), "reset", 1);
                    setdrawmethod(NULL(), 0);

would reset the color table of the drawmethod as well, am I right?

Yeah, my shadowtrail script doesnt waste globalvars and it works in local to not touch anything to not affect other future parts of the code (modular programming).
Yes:
changedrawmethod(NULL(), "enabled", 0);
changedrawmethod(NULL(), "reset", 1);
setdrawmethod(NULL(), 0);

reset all previous drawmethods after changedrawmethod(NULL(), "enabled", 1);

You have to change the params into the draw_shadowtrail() func  ;)

If you want you can add:
changedrawmethod(NULL(), "tintmode", 1);
changedrawmethod(NULL(), "tintcolor", 0xFF00FF);
 
White Dragon said:
Yeah, my shadowtrail script doesnt waste globalvars and it works in local to not touch anything to not affect other future parts of the code (modular programming).

Yeah, forgot what you wanted to achieve there. I'm just curious on how to get the color palette from alternatepal, since that's where his map.png was placed.

E.g. on how Dante used this:

palette     data/chars/person/idle0.png
alternatepal data/chars/person/map.png
alternatepal data/chars/person/mapf.png

The two alternate pals are maps for the shadow trail.
 
Thanks my friend!

I understood your correcion perfectly.

About this:
`well, to change a map see the draw_shadowtrail() function.
search the line:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, colourmap);

I use colourmap:
colourmap = getentityproperty(ent, "colourmap");

colourmap is the original character map. If you want you can change it  ;)

I find the line:
Code:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, colourmap); // map: -1 = Use entity's colormap.

But I do not understand exactly how to replace.
Try changing the "map: -1" for 2 (my remap) but not working.
 
CRxTRDude said:
White Dragon said:
Yeah, my shadowtrail script doesnt waste globalvars and it works in local to not touch anything to not affect other future parts of the code (modular programming).

Yeah, forgot what you wanted to achieve there. I'm just curious on how to get the color palette from alternatepal, since that's where his map.png was placed.

E.g. on how Dante used this:

palette     data/chars/person/idle0.png
alternatepal data/chars/person/map.png
alternatepal data/chars/person/mapf.png

The two alternate pals are maps for the shadow trail.

mmm....
1) you can set the new colourtable
2) get colourmap
3) draw sprites
4) re-set old colourtable

BTW I suggest you to use:
                    changedrawmethod(NULL(), "tintmode", 1);
                    changedrawmethod(NULL(), "tintcolor", rgbcolor(0xFF,0xE4,0x54));
 
dantedevil said:
Thanks my friend!

I understood your correcion perfectly.

About this:
`well, to change a map see the draw_shadowtrail() function.
search the line:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, colourmap);

I use colourmap:
colourmap = getentityproperty(ent, "colourmap");

colourmap is the original character map. If you want you can change it  ;)

I find the line:
Code:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, colourmap); // map: -1 = Use entity's colormap.

But I do not understand exactly how to replace.
Try changing the "map: -1" for 2 (my remap) but not working.

See:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, colourmap);

You have to change colourmap that is the map of your player.
0,1,2 etc..
example
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, 1);
or
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, 2);
 
Was about to answer similar to that, but you beat me to it WD  :)

@Dante: What WD suggested with tinting is way better though for your purpose, but it's all up to you.
 
Well, if iset like this:
Code:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, 2);

OpenBor crash with this in the log:

Code:
There's an exception while executing script 'updateentityscript' data/chars/caro/caro.txt


Only with this works (without remap):
Code:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, colourmap)
 
dantedevil said:
Well, if iset like this:
Code:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, 2);

OpenBor crash with this in the log:

Code:
There's an exception while executing script 'updateentityscript' data/chars/caro/caro.txt


Only with this works (without remap):
Code:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, colourmap)

ok, in your entity not use alternatepal but remap
 
You mean this Ilusionista says:
Quote
changedrawmethod(NULL(), "tintmode", 1);
changedrawmethod(NULL(), "tintcolor", 0xFF00FF);
This will give the afterimage (the technical name for "shadow trail") a purple-ish color

So i need change the script?
 
dantedevil said:
You mean this Ilusionista says:
Quote
changedrawmethod(NULL(), "tintmode", 1);
changedrawmethod(NULL(), "tintcolor", 0xFF00FF);
This will give the afterimage (the technical name for "shadow trail") a purple-ish color

So i need change the script?

just uncomment that lines.
use changedrawmethod(NULL(), "tintcolor", rgbcolor(0xFF,0x00,0xFF));
instead of
changedrawmethod(NULL(), "tintcolor", 0xFF00FF);
 
Ok my friend,  i made the line change.
But now if i set the alternatepal here like this:
Code:
setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, 2);

Openbor crash again with the log:

Code:
There's an exception while executing script 'updateentityscript' data/chars/caro/caro.txt

If no set the alternatepal, all works ok, without change change the colors of shadows.
 
Back
Top Bottom