[Script] Fall Animation Delay

Viper Snake

Member
The script will let an entity move off a wall or platform, but not change to an animation until it has fallen a set distance. Be sure to use on each frame of the entity RUN, IDLE, and WALK animations.

Usage: @cmd falldelay {animation} {frame} {fall distance}
Code:
void falldelay (void Ani, int Frame, int fDist)
{// Delayed animation change while falling off a platform.
 // Viper Snake - 3/5/2015
    void self = getlocalvar("self");
    int a = getentityproperty(self,"a"); //Get entity's altitude
    int b = getentityproperty(self, "base"); //Get entity's base	

     if(a > b + fDist){
	performattack(self, openborconstant(Ani)); //Change the animation
	changeentityproperty(self, "animpos", Frame);
	}
}

Example:
Code:
anim	idle
	loop	1
	delay	10
	bbox	3 0 18 88
	offset	16 87
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/idle0.png
	offset	16 86
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/idle1.png
	offset	13 87
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/idle2.png
	offset	15 88
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/idle3.png	

anim	walk
	bbox	7 0 18 88
	offset	17 88
	loop	1
	delay	10
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/walk0.png
	bbox	1 0 18 88
	offset	11 87
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/walk1.png
	bbox	7 0 18 88
	offset	17 85
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/walk2.png
	bbox	6 0 18 88
	offset	16 88
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/walk3.png
	bbox	0 0 18 88
	offset	10 87
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/walk4.png
	bbox	8 0 18 88
	offset	18 86
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/walk5.png

anim	run
	loop	1
	delay	10
	bbox	18 0 18 85
	offset	28 84
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/run1.png
	bbox	24 0 18 81
	offset	34 80
	sound	data/sounds/step1.wav
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/run2.png
	bbox	30 0 18 88
	offset	40 88
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/run3.png
	bbox	29 0 18 85
	offset	39 84
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/run4.png
	bbox	27 0 18 82
	offset	37 81
	sound	data/sounds/step1.wav
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/run5.png
	bbox	20 0 18 88
	offset	30 88
	@cmd	falldelay "ANI_JUMP" 4 25
	frame	data/chars/marianne/run0.png

anim	jump
	cancel	0 7 0 D J freespecial3
	cancel	0 7 0 A2 freespecial5
	cancel	0 7 0 F A2 freespecial8
	cancel	0 7 0 U A2 freespecial11
	cancel	0 7 0 D A2 freespecial14
	dropframe	4
	landframe 7
	bbox	14 0 18 88
	offset	25 87
	delay	10
	frame	data/chars/marianne/jump0.png
	offset	25 87
	frame	data/chars/marianne/jump1.png
	offset	25 87
	frame	data/chars/marianne/jump2.png
	bbox	17 0 18 88
	offset	28 87
	frame	data/chars/marianne/jump3.png
	bbox	27 8 18 88
	offset	38 96
	frame	data/chars/marianne/jump4.png
	bbox	27 22 18 88
	offset	38 110
	frame	data/chars/marianne/jump5.png
	bbox	27 24 18 88
	offset	38 112
	delay 9999
	frame	data/chars/marianne/jump6.png
	delay	1
	bbox	3 0 18 88
	offset	15 91
	frame	data/chars/marianne/idle3.png
 
the walkoff  animation dont work for your needs?

i use it on my projects to make smooth trasitions from platforms to the ground simulating a jump
 
rafhot said:
the walkoff  animation dont work for your needs?

i use it on my projects to make smooth trasitions from platforms to the ground simulating a jump

I edited my first post with an example. WALKOFF won't work for me unless there is a way to delay it from happening immediately.
 
This is a nasty problem, because you're running into one of OpenBOR's biggest shortcomings.

What's happening is that every time the player entity "thinks", OpenBOR notices that the player is in the air and changes the animation accordingly, overriding whatever animation you've set with script because it doesn't know about that.

That said, you can script a solution to this if you're determined.  You'll need to use a thinkscript to override the engine's animation change after every time it thinks.  Of course, it will have also destroyed the animation progress, so you'll need to keep track of the frame delays and set the right frame number in the same script if your animation has more than one frame.

Unless there's some way I don't know about to temporarily disable the engine's player AI.  And even if there is, it would have the side effect of disabling input, so the player wouldn't be able to control the player character whatsoever until the character lands.
 
The closest I was able to get to a workaround was having a cancel on the same frame this script changes too. The freespecial the cancel changes too actually does play the full animation. Is there a way to make a cancel happen automatically without any kind of input command?
 
Plombo said:
...Unless there's some way I don't know about to temporarily disable the engine's player AI.  And even if there is, it would have the side effect of disabling input, so the player wouldn't be able to control the player character whatsoever until the character lands....

There is actually, though reading this I'm not sure if it's necessary. In any case I don't remember the name of the command, but Utunnels uses it for cut scenes in Golden Axe Remake. I'd suggest giving that a look.

DC
 
I can't seem to get a player to play more than one frame of the animation it changes too

Why would you want that?

I have @cmd falldelay "ANI_PAIN10" 0 25 declared on each frame of the player's RUN, IDLE, and WALK animations.

Since you're using this function in those animations, why not use performattack function instead?
 
Bloodbane said:
Why would you want that?
Most of my player entities have 4 to 9 frames of animation when falling to the ground from a jump. Having only one frame of that animation played for this 'delayed walkoff' looks odd.

Since you're using this function in those animations, why not use performattack function instead?

I'll try it out when I get the time.
 
Just posting to say using performattack solved all the animation problems of this script, thank you Bloodbane! I've updated the first post with the new version.
 
Cool script,

I'm trying to just prevent an enemy from playing walkoff so they turn around instead and will always stay on the platform.
 
There's a way to do that with script. I've tried it with Blood Skeleton and I managed to force it to stay on platform with script
However, it's still using anti gravity setting to prevent it from falling. I need to update the script so it won't need that setting
 
I had tried it too, I wasn't sure if antigravity would prevent walkoff from playing or not.

Did you use this script or another?

Like there could be invisible entities to force them to move but it's probably a waste for a simple thing.

I have tried invisible entities next to my walls (which are actually platforms) to force enemies to crawl up and down the walls and ceilings.  I got that part working, but I'm still working on making them navigate around platforms that are above/below them.  I wanted to see it working before I tried to script it.
 
Well, Blood Skeleton has no WALKOFF animation (it's not meant to walk off anyways) so there's no problem with antigravity

As for script no, it's different script
The script is similar to script based walkoff except that instead of changing animation, it changes facing direction and velocity

Actually, there's a function which can acquire platform but unfortunately, I don't know how to acquire it's width :(.

Hmmm... one workaround is to set the width with health command and use this value to measure range to see if entity has reached of edge platform or not
Let me give this a try
 
Hmmm... this is the script from that Blood Skeleton:

anim follow1
@script
    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "a");
    int b = getentityproperty(self, "base");
    int Vx = getentityproperty(self, "xdir");

    if(y > b){
      changeentityproperty(self, "velocity", -Vx);
      if(Dir == 0){
        changeentityproperty(self, "position", x+5);
        changeentityproperty(self, "direction", 1);
      } else {
        changeentityproperty(self, "position", x-5);
        changeentityproperty(self, "direction", 0);
      }
    }
@end_script
loop 1
delay 5
offset  19 50
jumpframe 0 0 0.5 0
bbox 12 3 15 48
attack 12 3 15 48 5 1 1
frame data/chars/blodskel/walk1.png
frame data/chars/blodskel/walk1.png
frame data/chars/blodskel/walk1.png
frame data/chars/blodskel/walk1.png
frame data/chars/blodskel/walk2.png
frame data/chars/blodskel/walk2.png
frame data/chars/blodskel/walk2.png
frame data/chars/blodskel/walk2.png
frame data/chars/blodskel/walk3.png
frame data/chars/blodskel/walk3.png
frame data/chars/blodskel/walk3.png
frame data/chars/blodskel/walk3.png
frame data/chars/blodskel/walk2.png
frame data/chars/blodskel/walk2.png
frame data/chars/blodskel/walk2.png
attack 0
frame data/chars/blodskel/walk2.png

I forced Blood Skeleton to play this animation in SPAWN to prevent it from playing IDLE
Works well so far
 
Back
Top Bottom