Solved Simple question

  • Thread starter Thread starter Devsman
  • Start date Start date
Question that is answered or resolved.
D

Devsman

Guest
Hi everyone, I'm new here.  I did some stuff with MUGEN a while back, and I kind of wanted to get into OpenBOR.

Anyway I've seen a lot of information about OpenBOR scripting but example code online is kind of scarce (and I work a lot better by example) so I hope nobody minds if I ask a dumb question.  :)

My problem is that I want to have a "start walk" animation for each of my characters.  Two or three frames of the character transitioning from standing still to walking, followed by the standard walk animation.  It doesn't necessarily have to be divided into two animations like that but that was the most intuitive idea to me.  So if we've got two "start walk" frames and four "walk" frames then the frame sequence would go: 1 2 3 4 5 6 3 4 5 6 3 4 5 6 3 4 5 6... until you let go of left/right/up/down or do something else.

So the question, then, is are any of these possible with OpenBOR, and if so, how would they be accomplished:
1. Creating two separate animations, the first of which changes the animation to the second (and which overrides the engine's default behavior to put your character into walk state when you're holding left/right and idling)
2. Create an animation that loops from a certain frame onward, and never goes back to frames before it (this was a very handy feature in MUGEN)
3. Creating two separate animations, the first of which changes the animation to the second but retains the behavior of the first (does that make sense?)

Also preferably, I'd like the character to be stationary for the "start walk" portion of the animation.  Should only be about a quarter of a second so I don't think that's going to be a design issue (but what do you guys think?)

Thanks, all.

EDIT: Oh, I forgot to mention something. Is it also possible to define custom animations for this purpose, so that I don't have to do something counter-intuitive and potentially confusing like using an obscure animation that I wasn't going to use for the additional animation?  Thanks again.
 
The loop setting has two additional parameters (both optional) that will allow you to do this without any need for script or complexities.

Loop {on/off} {start} {end}

So basically you would set {start} to match the first frame of the looping portion of your walking animation and you should be good to go.

Welcome to the community!
DC
 
Wow awesome.  :)  Lots of stuff in there I didn't know.

I found something else I'm stumped on that I'm sure is simple so if I may ask another dumb question...

I want my characters to be able to run only for a short amount of time.  If the player continues holding left/right after that time, they should start walking instead.

I saw a suggestion using jumpframe but I couldn't quite get it to work the way I wanted it to; I also thought about using cancel in some tricky way but I'm not sure what to put for a command sequence.  I'm sure there's a much simpler way to do this.

Thanks.
 
You'll need script for that, but it's an easy one. Here's the latest iteration of a function I wrote to do so - lots of modules make use of it.

Code:
void stop_run(void ent)
{
    /*
    stop_run
    Damon V. Caskey
    2007-11-03   
	
    Stop running. Used to create dash step from running animation.

    ent: Entity to stop.
    */

    int ani = openborconstant("ANI_IDLE");

    /* Default ent to caller. */
    if(!ent)
    {
	ent = getlocalvar("self");
    }

    changeentityproperty(vSelf, "aiflag", "running", 0);	//Turn off run flag.
    changeentityproperty(vSelf, "velocity", 0, 0, 0);		//Stop movement.
    changeentityproperty(vSelf, "animation", ani);		//Set idle animation.
}

DC
 
Oh ok I was missing the run flag and the velocity to 0,0,0.  Works like a charm, with the exchange of vSelf for ent in the calls to changeentityproperty.

It seems like you can't both define an animationscript and put in @script...@end_script elements.  Is that true?
It also seems like you can't access the frame variable to say
Code:
if (frame == /*whatever*/)
{
//do stuff
}
from within an animationscript.  Is that also true?

The way I've got it now is that I just copy/pasted it between @script...@end_script but that's kind of a waste since lots of characters are going to want to do this.  How would I modularize functions like this so lots of different characters can use them?  Is there a way I can import scripts to a character?
 
It seems like you can't both define an animationscript and put in @script...@end_script elements.  Is that true?

Not true, I've combined both couple times and no problems.

How would I modularize functions like this so lots of different characters can use them?  Is there a way I can import scripts to a character?

Are you familiar with animationscript command?
This command allows you to call functions defined in that .c file
 
Oh ok.

I think I figured out how to get what frame is currently being played too.

But actually, is there a reason I can't or shouldn't enter everything into the main() in an animationscript?

EDIT:

By "everything" I mean calls to shared functions and the logic that determines when those functions should be called.  For example,

Code:
#include "data/scripts/commonanim.c"

void main()
{
	int animnum = getlocalvar("animnum");
	int frame = getlocalvar("frame");
	if(animnum == 36)
	{
		if (frame == 13)
		{
			stop_run(getlocalvar("self"));
		}
		return;
	}
	else if (animnum==/*something else*/)
	{
		if (frame == /*something*/)
		{
			//do something
		}
	}
}
 
Back
Top Bottom