Animated standing pose

Started by Igor, Sat 19/03/2011 08:46:40

Previous topic - Next topic

Igor

I'd like to have animated standing pose for main character, that would start as soon as the character would stop walking.

I figured Idle animation should do the trick, so I put this code "cChar1.SetIdleView(2,0);" (view2 is my idle animation) in "function game_start" in Global script.

Now the character animates when he stands still, but there's always a second or so pause (on frame 0 of walking animation), before the character switches to idle animation.
How could I switch to idle animation right away?

Thank you in advance.

Icey


Dualnames

I may be missing a very valid way other than this, but here it is on the top of my head.

However according to the manual, what you have should work

Code: ags

int a= Idleviewnumbergoeshere;

function repeatedly_execute_always() {

if ((!cEgo.Moving) && (cEgo.View!=a)) {
  cEgo.LockView(a);
  cEgo.Animate(cEgo.Loop,5,eRepeat,eNoBlock,eForwards);
}
if ((cEgo.Moving) && (cEgo.View==a)) cEgo.UnlockView();

}


I can't say it's the prettiest approach, but it's an approach alright.

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Igor

Thank you for your help!

Studio3: If I change  "cChar1.SetIdleView(2,0);" to "cChar1.SetIdleView(2,-1);" the idle animation doesn't appear at all.

Dualnames: As I try to run the game I get an error: "GlobalScript.asc(67): Error (line 67): Variable 'a' is already defined"
However if I skip "int a= 2;" part and just use "2" instead of "a" in the rest of the script, the character just stays in idle view and you can't move him around..

Dualnames

#4
Code: ags

int idl =idle view here;
int wview=walking view here;
int exc, fb;

function repeatedly_execute_always() {
if (!cEgo.Moving) {
if (cEgo.View!=idl)cEgo.ChangeView(idl);
if(exc!=Game.GetFrameCountForLoop(idl, cEgo.Loop)) {
ViewFrame*getidle=Game.GetViewFrame(idl, cEgo.Loop, exc);
cEgo.Frame=exc;
if (fb!=cEgo.AnimationSpeed+getidle.Speed) {
fb++;
return;
}
if (fb==cEgo.AnimationSpeed+getidle.Speed) fb=0;
exc++;
}
if(exc==Game.GetFrameCountForLoop(idl, cEgo.Loop)) exc=0;
}

if ((cEgo.Moving) && (cEgo.View==idl)) {
 cEgo.ChangeView(wview); 
 exc=0;
 fb=0;
}

}


EDIT: Using this replaces SetIdleView, so don't use that function,if you're gonna use this. If you need to set idle view for more characters let me know now.
         This works 20000000000%.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ghost

DAmn man, when did you become the waesmoe coder  ;) Works really nice!

Igor

#6
Dualnames- thank you! :)
I tried it out and so far it seems it works like a charm- I only got the error executing this line: int exc,int fb; (GlobalScript.asc(37): Error (line 37): Variable 'int' is already defined). So I took out the second int (int exc, fb) and now it seems it works.

>>If you need to set idle view for more characters let me know now.<<
I'm not sure if I understand this correctly- but I'll have only one player character in game. For other non-player characters I guess I could use normal animation functions..
Though I might find out I'll need a function for more characters later.. so, if you could let me know how to do that anyway, it would be great.
Thanks again for your help.

Dualnames

First download this module and import it.
www.xenogiagames.com/dngames/FastIdle.rar

Now just find a repeatedly_execute_always() {

and do this:
Code: ags

function repeatedly_execute_always() {
cEgo.FastIdle(3,6);//this will run view 3 as idle view and 6 as walking.
}


idl is idle view and wview is walking view
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Igor

Wonderful, can't thank you enough for this! :)

Igor

#9
I'm having another problem..
It seems, now that I'm using "FastIdle" code, I can't animate my character. Walking and idle animations are working perfectly, but as I try to asigne new animation to character it doesn't work.

An example:
At the start of the game/room I'd like to play a special character animation, so I scripted:

function room_AfterFadeIn()
{
cChar1.LockView(3);
cChar1.Animate(0, 1, 0, eBlock, eForwards);
cChar1.UnlockView();
}

It doesn't work. However if I delete the "fastidle" script, animation works (but of course, then the ide animation problem occures again)..

Dualnames

Quote from: Igor on Wed 23/03/2011 09:06:53
I'm having another problem..
It seems, now that I'm using "FastIdle" code, I can't animate my character. Walking and idle animations are working perfectly, but as I try to asigne new animation to character it doesn't work.

An example:
At the start of the game/room I'd like to play a special character animation, so I scripted:

function room_AfterFadeIn()
{
cChar1.LockView(3);
cChar1.Animate(0, 1, 0, eBlock, eForwards);
cChar1.UnlockView();
}

It doesn't work. However if I delete the "fastidle" script, animation works (but of course, then the ide animation problem occures again)..

You see the fast idle takes over the animation.
Okay there are several ways out of this, but here's one.

Creating a global variable called whatever you like. I'm going with
Name:Dualnamesisthebest.
Initial value: false
Type: Boolean


Now, every time you lock or want to change the view and not have it play the idle. You set Dualnamesisthebest to true.
Code: ags

function room_AfterFadeIn(){
Dualnamesisthebest=true;
cChar1.LockView(3);
cChar1.Animate(0, 1, 0, eBlock, eForwards);
cChar1.UnlockView();
Dualnamesisthebest=false;
}


On the repeatedly_execute_always:
Code: ags

function repeatedly_execute_always() {
if (Dualnamesisthebest==false) {
//what you already got goes here
cEgo.FastIdle(3,6);//this will run view 3 as idle view and 6 as walking.
//ecc
}
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Igor

Hm, I still can't make it work..
Custom animation still doesn't play.

As you said, I created "idleonoff" global variable (type: bool, initial value: false).

This is a code for Room:

function room_AfterFadeIn()
{
idleonoff=true;
cChar1.LockView(3);
cChar1.Animate(0, 1, 0, eBlock, eForwards);
cChar1.UnlockView();
idleonoff=false;
}


And for global script:

function repeatedly_execute_always() {
 if (idleonoff == false){
cChar1.FastIdle(2,1);
}
}

What could be wrong?
(ps. I'm of course using your Fastidle module)

Dualnames

First it works on me. And also you seem to have set the delay quite fast. Meaning the animation plays as fast as possible. So you may not see it. But I assure you what you got works.

In the meantime, I noticed something occuring on lucas-art styled speech

So module script should be:
Code: ags

int fb[], exc[];

function FastIdle(this Character*, int idl, int wview) {
if (!this.Speaking) {
if (!this.Moving) {
if (this.View!=idl)this.ChangeView(idl);
if(exc[this.ID]!=Game.GetFrameCountForLoop(idl, this.Loop)) {
ViewFrame*getidle=Game.GetViewFrame(idl, this.Loop, exc[this.ID]);
this.Frame=exc[this.ID];
if (fb[this.ID]!=this.AnimationSpeed+getidle.Speed) {
fb[this.ID]++;
return;
}
if (fb[this.ID]==this.AnimationSpeed+getidle.Speed) fb[this.ID]=0;
exc[this.ID]++;
}
if(exc[this.ID]==Game.GetFrameCountForLoop(idl, this.Loop)) exc[this.ID]=0;
}
if ((this.Moving) && (this.View==idl)) {
this.ChangeView(wview);
exc[this.ID]=0;
fb[this.ID]=0;
}
}
}
function game_start() {
fb = new int[Game.CharacterCount];
exc = new int[Game.CharacterCount];
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Igor

#13
Hm, that's strange.. it seems it just doesn't register this part in Room script:

function room_AfterFadeIn()
{
idleonoff=true;
...

I tried to just turn idleonoff "true" (and not turn it "false" after) and it didn't register that at all (character was on his idle animation from the start).
I also did a test- I changed conditions in Global script to this: if (idleonoff == true){
cChar1.FastIdle(2,1);
}
}

it did register that the idleonoff is set on off by default and it didn't play idle animation (even though it should be set on "true" after room fade in..).

Dualnames

I think this requires a closer look to the game files, at least that's how I usually go by. So pm me the files, I'll take a look.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Igor

Ah, I found the problem- your script was perfect, but I shouldn't have used "AfterFadeIn()" for what I was trying to do. I used diferent event and now it works as it should.
Thanks for your help and patience Dualnames :)

Dualnames

Quote from: Igor on Wed 23/03/2011 14:58:40
Ah, I found the problem- your script was perfect, but I shouldn't have used "AfterFadeIn()" for what I was trying to do. I used diferent event and now it works as it should.
Thanks for your help and patience Dualnames :)

Great. Let me know if anything happens again.  ;)
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk