[SCRIPT] ShadowTrail

White Dragon

New member
draw_shadowtrail(entity, trails_num, refresh_time, min_transp, max_transp, flag,last_frame);

Parameters:
entity: entity that you want to track
trails_num: numbers of trails
refresh_time: frames to wait to generate a sprite for the trail
min_transp and max_transp: for transparency. it is the channel rgb
swap_flag: 0 or 1. sprite swapping into trail. (I prefer 0)
turnoff_flag: 0 == off, 1 == on
alpha: 1 to 6 (alpha fusion method)
color: this is the shadowtrail color. set it with function -> rgbcolor(0x00,0x00,0xFF)
map: map of shadowtrail (int)

clear_shadowtrail(entity) to clear all localvars.

TO USE IT:

1) download and copy files into data/scripts:
http://www.mediafire.com/download/k04t9plhnd2rvgq/lib_shadowtrail.zip


2) write in your character entity text file:
script  data/scripts/player_script.c

and in player_script.c write (EXAMPLE):

Code:
#import "data/scripts/shadowtrail.c"

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

  check_shadow_trail(player);

    if ( getentityproperty(player, "defaultmodel") == "CHARACTER_NAME" && getentityproperty(player, "animationid") == openborconstant("ANI_ATTACK1")
               && getentityproperty(player, "animpos") < 7 ) {
        set_shad_trail_flag(player,1);
        //draw_shadowtrail(player, 5, 15, 20, 160, 0);
    } else if ( getentityproperty(player, "defaultmodel") == "CHARACTER_NAME" && getentityproperty(player, "animationid") == openborconstant("ANI_ATTACK1")
               && getentityproperty(player, "animpos") >= 7 ) {
        set_shad_trail_flag(player,0);
        clear_shadowtrail(player);
    } else if ( getentityproperty(player, "defaultmodel") == "CHARACTER_NAME" && getentityproperty(player, "animationid") != openborconstant("ANI_ATTACK1")
               && get_shad_trail_flag(player) != 0 ) {
        set_shad_trail_flag(player,0);
        clear_shadowtrail(player);
    }
}

Now in part 2 change "CHARACTER_NAME" with your charcter name, "ANI_ATTACK1" with your  shadowtrail attack/animation and 7 with your frame where the shadowtrail stops.  ;)

 
Thanks for sharing!

How do you set this on a per animation basis?
 
for example:

    if ( getentityproperty(self, "model") == "LEONARD" && getentityproperty(self, "animationid") == openborconstant("ANI_CHARGEATTACK") && getentityproperty(player, "animpos") < 7 ) {
        draw_shadowtrail(self, 5, 15, 20, 160, 0);
    }  else if ( getentityproperty(player, "model") == "LEONARD" && getentityproperty(player, "animationid") == openborconstant("ANI_CHARGEATTACK")
              && getentityproperty(player, "animpos") >= 7 ) {
        clear_shadowtrail(player);
    }

IMPORTANT: I set 1 to stop the trail. (7 is the last frame of CHARGEATTACK animation for example)
 
Good to know you use channel feature to implement shadows with different transparency.
And tintcolor is another good choice for shadows also.
Thank you for the share.
 
Volcanic said:
Good to know you use channel feature to implement shadows with different transparency.
And tintcolor is another good choice for shadows also.
Thank you for the share.

Yes but I noticed that tintcolor doesn't work with channel transp... why?
 
Hum, this works like afterimage in Mugen
afterimage.png


Sweet, I was looking for this!
 
it keeps return error for me.

I've added all the code on my script.c that I use for all other scripts.

Then I called it:
@cmd draw_shadowtrail(getlocalvar("self"), 5, 15, 20, 160, 0);

but it returns this error:

Code:
Script error: data/chars/ironman/ironman.txt, line 13: Unknown error ',' (in production 'assignment_expr')

            draw_shadowtrail(getlocalvar("self"),(5,, 15,, 20,, 160,, 0););
                                                         ^



Script error: data/chars/ironman/ironman.txt, line 13: Unknown error ',' (in production 'assignment_expr')

            draw_shadowtrail(getlocalvar("self"),(5,, 15,, 20,, 160,, 0););
                                                              ^



Script error: data/chars/ironman/ironman.txt, line 13: Unknown error ',' (in production 'assignment_expr')

            draw_shadowtrail(getlocalvar("self"),(5,, 15,, 20,, 160,, 0););
                                                                    ^



Script error: data/chars/ironman/ironman.txt, line 13: Unknown error ')' (in production 'stmt_list2')

            draw_shadowtrail(getlocalvar("self"),(5,, 15,, 20,, 160,, 0););

**************** Done *****************

Fatal Error in load_cached_model, file: data/chars/ironman/ironman.txt, line 268, message: Error parsing function main of animation script in file '%s'!                                                                         ^

what is wrong?
 
2 errors:
1) Don't call shadow trail for a frame, call the function from a script to run it  every frame (not @cmd)
2) draw_shadowtrail(getlocalvar("self"), 5, 15, 20, 160, 0); is wrong syntax for a call with @cmd,
  Right syntax: draw_shadowtrail getlocalvar("self") 5 15 20 160 0
 
This still doesn't works for me. What I am doing wrong?

I saved as trail.c, #import "data/scripts/trail.c"  and I put it as my SCRIPT at my char header:

Code:
script  @script
void main()
{

if ( getentityproperty(self, "model") == "Black_Cat" && getentityproperty(self, "animationid") == openborconstant("ANI_FREESPECIAL3") && getentityproperty(player, "animpos") < 7 ) {
        draw_shadowtrail(self, 5, 15, 20, 160, 0);
    }  else if ( getentityproperty(player, "model") == "Black_Cat" && getentityproperty(player, "animationid") == openborconstant("ANI_FREESPECIAL3")
               && getentityproperty(player, "animpos") >= 7 ) {
        clear_shadowtrail(player);
    }

}
@end_script

the error:
Script compile error in 'updateentityscript': self line 5, column 23
 
Script error message means a function is looking for "self" variable which not declared yet.

I can't tell where exactly the error is but I can see that the script you quoted above hasn't attained "self" yet
 
Sorry for my question, but how is the way to use import?
I learn recently about @cmd scripts.
Actually use a lot of scripts  with @cmd, but i dont know how import this script.
Thanks.
 
You just add it like this to the top line of your existing script

Code:
#import  "data/scripts/nameofscript.c"
 
BeasTie said:
You just add it like this to the top line of your existing script

Code:
#import  "data/scripts/nameofscript.c"

You mean is the same like

animationscript data/scripts/nameofscript.c
 
Nah I meant add this to to the actual .C file.

For example,
if you char is already using SCRIPTONE.C
and you want to use SCRIPTTWO.C as well,
then you would add this to the top line of scriptone.c

Code:
#import  "data/scripts/scripttwo.c"

So for example you can have a script file like this that imports multiple scripts, just add the scripts you want to use.

myscript.c
Code:
#import  "data/scripts/coolscript.c"
#import  "data/scripts/script.c"
#import  "data/scripts/randomscript.c"

then in character

animation data/scripts/myscript.c
 
Bloodbane said:
Script error message means a function is looking for "self" variable which not declared yet.

I can't tell where exactly the error is but I can see that the script you quoted above hasn't attained "self" yet

Thanks.
void self = getlocalvar("self");
Then it says that can't find the "player", so I changed to "self":

script  @script
void main()
{
void self = getlocalvar("self");
if ( getentityproperty(self, "model") == "Black_Cat" && getentityproperty(self, "animationid") == openborconstant("ANI_FREESPECIAL3") && getentityproperty(self, "animpos") < 7 ) {
        draw_shadowtrail(self, 5, 15, 20, 160, 0);
    }  else if ( getentityproperty(self, "model") == "Black_Cat" && getentityproperty(self, "animationid") == openborconstant("ANI_FREESPECIAL3")
              && getentityproperty(self, "animpos") >= 7 ) {
        clear_shadowtrail(self);
    }

}
@end_script

And now the logs says:
Script compile error: can't find function 'draw_shadowtrail'

Script compile error in 'updateentityscript': draw_shadowtrail line 6, column 8

but that function is on the trail.c, I don't understand.
My animationscript file imports the trail.c, where the draw_shadowtrail function is:

animationscript data/scripts/grabscript.c

#import "data/scripts/trail.c"
 
Back
Top Bottom