Shadow Trails Demo

Exhibition Shadow Trails 2017 - tech demo 3.0

No permission to download
Projects meant as a technical demonstrator or instructional tutorial.

msmalik681

OpenBOR Developer
Staff member
Just made a new example demo for using shadow trails re-wrote OX's script using local variables but some global variables had to be used to pull data from a animation script. in the demo walk and jump animation have different colour trails.

2 files needed are in scripts folder and need to be declared for each character.



Code:
animationscript data/scripts/shadow.c
ondrawscript data/scripts/shadowon.c


the animation script should use a forwarder see the demo for example.


to use the script on any character animation that you want shadows just add this line before the first frame.


Code:
#{max shadows} {delay between shadows} {shadow timeout} {alpha} {tintmode} {red} {green} {blue}
@cmd shadow 5 20 120 6 2 155 0 0


anyone who wants to be lazy i set some default values so you could use.


Code:
@cmd shadow

Download Shadow Trails - Version 3.0 - fixed issue with shadows not showing alternate maps.
 
Last edited:
Double post.

I've tried your script, and it works. But It always get the same color in afterimage - with no tint over it
Avengers_-_0008.png


I've tried both versions - with and without parameters.

plus, it ignores the direction too
Avengers_-_0010.png
 
If you are using drawsprite in your mod it will conflict not sure yet but i might be able to fix it but can you confirm if you have any active drawsprites within your mod ?
 
I've tested it on a char where I don't use any ondrawscript.

I've copy and pasted your shadow.c codes to my own animation script
Code:
//// ---------------------------------- SHADOWTRAIL
void shadow(int max, int delay, int timeout, int alpha, int tintm, int r, int g, int b)
{//animation script for shadow trails
	void self = getlocalvar("self"); //Get calling entity.
	int anim = getentityproperty(self, "animationid");//Get calling animation id.
	//if any values null set defaults
	if(max==NULL()){max=5;}
	if(delay==NULL()){delay=20;}
	if(timeout==NULL()){timeout=120;}
	if(alpha==NULL()){alpha=6;}
	if(tintm==NULL()){tintm=2;}
	if(r==NULL()){r=0;}
	if(g==NULL()){g=0;}
	if(b==NULL()){b=255;}
	//store all recorded data into entity variables.
	setentityvar(self,"shadow.anim", anim);
	setentityvar(self,"shadow.max", max);
	setentityvar(self,"shadow.delay", delay);
	setentityvar(self,"shadow.timeout", timeout);
	setentityvar(self,"shadow.alpha", alpha);
	setentityvar(self,"shadow.tintm", tintm);
	setentityvar(self,"shadow.r", r);
	setentityvar(self,"shadow.g", g);
	setentityvar(self,"shadow.b", b);

}

Then called the ondrawscript
Code:
ondrawscript data/scripts/shadowon.c

And I am calling the script in my anitmation:
Code:
	@cmd	shadow 5 10 30 6 2 155 0 0

I've tried your demo and it works perfectly there. I even tried to use the same OpenBOR you are using, but nothing changed.
 
But do you draw any sprites to screen ?

If you set "drawmethod(null ()" anywhere in your mod this will change the way shadows are displayed on screen)
 
I've checked my updated.c and I don't use any drawsprite (for that character)
I only use "drawspriteq" from uTunnels' Zoom Code.
 
Thanks! you can get it here: https://gamejolt.com/games/avengers-united-battle-force/14591
I was trying the code in Namor, because some characters like Brand do have a ondrawscript.
 
Good news the shadow trails work perfectly on your mod (see attached image)


Bad news your zoom script conflicts with the shadows your have to work out a way they don't run at the same time !


try my method: http://www.mediafire.com/file/59727v4l9sucn1e/3rd_Strike_Zoom_Effect.rar if I remeber right I summon a entity on the player and that entity zooms into itself and back out use the special to test it.


here is what I did to get the shadow trails working just commented out your changedrawmethod scripts.


Code:
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();

[attachment deleted by admin]
 
Thanks man!
I will need to take a look, because my zoom code is tied to many entities. But it seams that, with your method, a bug I was having don't occurs anymore (some frames can get stuck).

Edit: I tried your version, and it works exactly on the same way of the code I use (the code is identical, the only exception is the "//- getentityproperty(ent,"a");" line). Plus, as I use the code in a text type entity, it doesn't have the bug your code has (if she hits an entity while zooming, you will notice a jump on the screen scroll).

Have you tried to mix both codes? Because If I comment the lines you said, the overall zoom doesn't works.

 
UHU I found it!

Just add this line to your shadowon.c:

Code:
changedrawmethod(NULL(),"reset",1);

So it will be:

} else {
changedrawmethod(NULL(),"reset",1); // ADDED LINE
changedrawmethod(NULL(),"flipx",getlocalvar("shadow."+self+"."+j+".f")); //face same as caller
changedrawmethod(NULL(),"alpha",alpha); //apply tint effect
changedrawmethod(NULL(),"tintmode",tintm); //apply tint effect
changedrawmethod(NULL(),"tintcolor",rgbcolor(r,g,b)); //set a tint
drawsprite(getlocalvar("shadow."+self+"."+j+".s"),getlocalvar("shadow."+self+"."+j+".x")-openborvariant("xpos"),getlocalvar("shadow."+self+"."+j+".z")-getlocalvar("shadow."+self+"."+j+".y")-openborvariant("ypos")-4,getlocalvar("shadow."+self+"."+j+".z")-j);
}
 
Sorry for the tripple post, but its needed so it will be easier to understand.
Both scripts will try to affect each one. If you add the line I said ealier:
Code:
changedrawmethod(NULL(),"reset",1);
To your code, it will work. But the tintcolor of your code will affect the zoom code too.

So, we need to nullify it in the zoom code, adding this line:

Code:
   setdrawmethod(NULL(), 0); // ADDED - Nullify the trail effect

So the whole zoom code will be:

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
  setdrawmethod(NULL(), 0); // ADDED - Nullify the trail effect
  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();
}

Really thanks. I will be making some tests, but it looks perfect.

PS: I would like to documment all the options for CHANGEDRAWMETHOD. Do you have any info?
 
Yeah I remember that topic (I've saved it long time ago). But it misses some options, like "reset", "enabled", etc

msmalik681 said:
so are you saying your mod is working fine now ?

90%. The trail code works, the zoom code works. But if you call the zoom code while the trail is in action, the trail will get affected.
I tried to nullify the effect, but no good. Take a look:

Using the trail
G61wl3i.png


After we call the zoom
glgQzeN.png


It looks like the colors get inverted. Maybe I will need to check for the global zoom variable and not trigger it.
I will work more on this.


Edit: This is all changedrawmethod properties:
  alpha,
    amplitude,
    beginsize,
    centerx,
    centery,
    channelb,
    channelg,
    channelr,
    clip,
    cliph,
    clipw,
    clipx,
    clipy,
    enabled,
    endsize,
    fillcolor,
    flag,
    fliprotate,
    flipx,
    flipy,
    perspective,
    remap,
    reset,
    rotate,
    scalex,
    scaley,
    shiftx,
    table,
    tintcolor,
    tintmode,
    transbg,
    watermode,
    wavelength,
    wavespeed,
    wavetime,
    xrepeat,
    xspan,
    yrepeat,
    yspan,
    the_end,
 
Sprites can have id's if only there was a way to apply draw method to set sprites it would avoid conflicts like this.
 
hey Ilu I have found a fix  for your problem try wrapping the draw methods codes in "reset", 1 like this:


Code:
   //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);
   changedrawmethod(NULL(),"reset",1);
   clearspriteq();


and mine:


Code:
changedrawmethod(NULL(),"reset",1);
changedrawmethod(NULL(),"flipx",getlocalvar("shadow."+self+"."+j+".f")); //face same as caller
changedrawmethod(NULL(),"alpha",getlocalvar("shadow."+self+"."+j+".a")); //apply alpha effect 
changedrawmethod(NULL(),"tintmode",getlocalvar("shadow."+self+"."+j+".tm")); //apply tint effect 
changedrawmethod(NULL(),"tintcolor",rgbcolor(getlocalvar("shadow."+self+"."+j+".r"),getlocalvar("shadow."+self+"."+j+".g"),getlocalvar("shadow."+self+"."+j+".b"))); //set a tint 
drawsprite(getlocalvar("shadow."+self+"."+j+".s"),getlocalvar("shadow."+self+"."+j+".x")-openborvariant("xpos"),getlocalvar("shadow."+self+"."+j+".z")-getlocalvar("shadow."+self+"."+j+".y")-openborvariant("ypos")-4,getlocalvar("shadow."+self+"."+j+".z")-j);
changedrawmethod(NULL(),"reset",1);


tried this and it worked on my zoom demo also I have made a fix for the shadow trails not to conflict with player 2.  Right now the 2 shadows don't conflict in colour but the trails do have gaps when 2 players are in play so I will update my demo from the first post when I fix this.
 
Thanks. I tried your solution, but the trail is still been affected by the zoom:
Uc8kkn7.png


Doing more tests, it likes like the trail get wrong only in the end of the code, take a look:
08tzRvY.png

b0KGN7p.png

(if you put the same value for the R G B properties, you can simulate the same sprite from the caller. I've used 50 50 50 on the example above)
 
Just updated download link on the first post with v2.0 bug fixed that caused player 1 and 2 shadows to conflict and change each others colour and direction and delay. I have not tested with more then 2 players so please report if there are any issues.  Last thing to fix is the issue using current map of the player using the shadow but DC is working on a fix for this.
 
msmalik681 said:
Last thing to fix is the issue using current map of the player using the shadow but DC is working on a fix for this.

Getting after images to use the entity's active color set is actually super easy. The hard part is if you want them to use a color set that isn't active. Like if you wanted to the after images to always display with a blue color set the way Capcom does. The much better and far simpler solution would be to employ tinting, but I know some folks just have to have their static color sets, so I'm working on including it as an option.

DC
 
Back
Top Bottom