Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: RickJ on Sat 01/03/2003 04:07:51

Title: Animation Engine Functions
Post by: RickJ on Sat 01/03/2003 04:07:51
In this thread the functions that comprise the animation engine will be discussed in detail.  This discussion is being conducted here for the benefit of the community and to allow opportunities for making input in the process.  A design spec as well as other documents are available in plain text form from the urls below. Checkout Juncmodule's disscussion of AI/Mood system.  

Execution Control Functions
Here are the functions curently defined that control the execution of animation engine threads.  

  // Start and stop execution of the specified thread
  AeRun(thread)
  AePause(thread)
  AeStop(thread)
  AeToggle(thread)

  // Debug GUI - Next and previous line in the specified thread,
  // Similar to single step function in traditional debugers
  AeNext(thread)
  AePrev(thread)

  // Debug GUI - Switch gui to another thread
  AeNextThread()
  AePrevThread()
  AeGotoThread(thread)

  // Get current execution state of specified thread
  AeState(thread)

Thread Creation, Branching, and Looping
These functions can be nested upto aeNMAX levels deep.  aeNMAX is a constant and can be set to any number of desoired levels.

What convention should be used to name constants?  Use aeNAME, AENAME, AE_NAME or some other variation?

  // Create thread, threads are bounded by these functions
  aeInit(thread)
     :
  aeEnd()

  // Expressions
  // An expresion consists of two values and one of the
  // following operators: (eq, ne, gt, lt, ge, le, and, or)

  // Conditional branching
  aeIf(value1, operator, value2);
     :
  aeIfElse();
     :
  aeElse();
     :
  aeEnd();

  // Conditional looping
  aeWhile(value1, operator, value2);
     :
  aeEnd();

  // Unconditional looping - loop fixed number of times
  aeLoop(value); or aeRepeat(value);
     :
  aeEnd();

which name is preferrable aeRepeat() or aeLoop()? aeRepeat is currently implemented to repeat the entire thread and simply jumps back to the beginning the specified number of times.   What should I do about this?

  // Unconditional branching
  aeDoCase(case);  
     :                        
  aeCase(case);      
     :
  aeDefaultCase();
     :
  aeEnd();

Statements immediately following the DoCase() will always be executed.  When the first Case() is encountered a jump to the specified case will occur.

  // Unconditional branching
  aeDoRandomCase(case, random);  
     :                        
  aeCase(case);      
     :
  aeDefaultCase();
     :
  aeEnd();

Similiar to DoCase() except actual case is calculated by case=case+Random(random).

Ok so let's review these first, then we will go on to the next group.  Let me know what you think, questions comments, suggestions, pitfalls, etc..  ;D
Title: Re:Animation Engine Functions
Post by: Scorpiorus on Sun 02/03/2003 23:43:47
Oh, I have found the thread. bump up.

QuoteWhat convention should be used to name constants? Use aeNAME, AENAME, AE_NAME or some other variation?
aeNAME seems fine for me.

Quotewhich name is preferrable aeRepeat() or aeLoop()? aeRepeat is currently implemented to repeat the entire thread and simply jumps back to the beginning the specified number of times. What should I do about this?
I'm voting for aeLoop then.



After reviewing the first version of global move command I optimized it's code. The new version adds separate raw move command as well as global move command:

-  Global move script file v1.01 (http://invis.free.anonymizer.com/http://www.geocities.com/scorpiorus82/globalmove.txt)
-  A little test game demonstrates global move in action [25kb] (http://invis.free.anonymizer.com/http://www.geocities.com/scorpiorus82/gmove101.zip)

Well, Rick, this way move command should work fine for AE. There is AGS_CHARACTERS_MAX constant which determines maximum number of characters. You may want to decrease it (originally it's 150) to see single NPC's footprints.

As you already know global move (new move) uses both raw move and AGS move function but there is a problem....
Although raw move command uses the same walking speed as AGS MoveCharacter() it doesn't work properly if there is anti-glide mode turned on. I just can't solve the problem of recalculating walkspeed as it depends on frame skipping speed.

-Cheers

Title: Re:Animation Engine Functions
Post by: RickJ on Mon 03/03/2003 15:54:22
Ok.  aeNAME, aeLoop() it is.

I had a look at your global.txt.  Cool.  I need to look more, maybe try it when I find some time.   I will use this method for character movements.  I would also like to add the generic math functions to BlueGui.  I also found your sting array stuff on another thread, very good stuff.  Thanks for everything.

I have added DoCase() and DoRandomCase() functions.  See my previous post or the text document.

 
Title: Re:Animation Engine Functions
Post by: Scorpiorus on Tue 04/03/2003 21:57:17
Quote from: RickJ on Mon 03/03/2003 15:54:22
Thanks for everything.
you are welcome. :)
The global move command works another way that the one from CCS where I used only AGS movecharacter function and hiding NPCs. The only disadvantage, as I said above, is speed calculatings.

QuoteI have added DoCase() and DoRandomCase() functions.  See my previous post or the text document.
oh, yes that's would be handy statements. Good work!

Another suggestion has just occured to me is (for future) is some sort of export import functions:
aeLoadThread(int ThreadId, string filename);
aeSaveThread(int ThreadId, string filename);
AeLoadThread(int ThreadId, string filename);
AeSaveThread(int ThreadId, string filename);

With these commands it would be possible to change code inside already compiled game. That might be useful. But that's not priority for now.

-Cheers
Title: Re:Animation Engine Functions
Post by: Neole on Wed 05/03/2003 19:08:41
I'm confused - what is this, a plugin?
Title: Re:Animation Engine Functions
Post by: RickJ on Wed 05/03/2003 22:43:57
Neole:  It's open source script.   Anyone can downloade it and include it in their own creations.  

Scorp:  I'm working on  specifications for the base engine and for extensions that support the autonomous character control system I have been discussing with Juncmodule.  I plan top begin implementation next wednesday.

Oh! and the Load and Save thread idea is cool.  With that you would be able to select personality profiles for your characters.  Let the player do it or automatically like Dr. Jekyll & Mr. Hyde.

 
Title: Re:Animation Engine Functions
Post by: Neole on Thu 06/03/2003 09:22:10
Open source script for AGS? What is it supposed to do exactly?
Title: Re:Animation Engine Functions
Post by: RickJ on Thu 06/03/2003 15:23:52
It makes it easy to make multiple, simultaneous character and object animations....
Title: Re:Animation Engine Functions
Post by: RickJ on Sat 08/03/2003 15:32:08
Spec documents have been updated.  See links in first post.
Title: Re:Animation Engine Functions
Post by: Scorpiorus on Sun 06/04/2003 00:43:02
I was experimeting with bold character[]. variables  ;D and here is a simple global animation command:

=> newAnimationCharacter function [global script source] (http://invis.free.anonymizer.com/http://www.geocities.com/scorpiorus82/globalanim.txt) (ver0.2)


Well it's just a basic implementation and it has some bugs due to the lack of get-view(loop/frame)-data functions.

-Cheers
Title: Re:Animation Engine Functions
Post by: a-v-o on Sun 06/04/2003 19:38:31
Quote from: RickJ on Sat 01/03/2003 04:07:51
  • Scorp's string array solution (http://www.agsforums.com/yabb/index.php?board=2;action=display;threadid=3806;start=0)
CJ has already implemented 50 GlobalStrings. See help file SetGlobalString and GetGlobalString
Title: Re:Animation Engine Functions
Post by: Helm on Mon 23/06/2003 10:13:33
RickJ are you still pursuing this?
Title: Re:Animation Engine Functions
Post by: RickJ on Thu 26/06/2003 05:07:51
Helm,

Yes this is still on my todo list.  When will you need it?
Title: Re:Animation Engine Functions
Post by: juncmodule on Thu 26/06/2003 17:44:04
I posted a little in your "My Absence" thread about this...

I have abandoned my previous project that would have used this system. I had decided to go back and start it again but, after taking a good look at it I realized that it was WAY too ambitious :P.

As a sort of test game/demo of my AI system and perhaps even AE I have started another game which is a bit more simple.

It will contain one city and about 26 people. A lot of work, but much better than the 20 cities and 60 people that Smuggler had. Of the 26 characters initially I intend to only have 5 exhibit "intelligence". I will slowly build up from there adding "intelligence" to other characters as I become more comfortable (and get all of the bugs worked out) with the system.

I am currently still in the artwork stages which I intend on taking a lot of time with. This will be my first game with 100% orginal artwork ;D.

So, when I need this will be some time off still. Just to let you know though, I am still greatly interested in seeing it completed ;).

later,
-junc
Title: Re:Animation Engine Functions
Post by: RickJ on Thu 26/06/2003 17:54:15
Junc:  

Great!  Knowing that folks are interested in using it gives me incentive to get busy.  I think your timing will work out just fine for me.  
Title: Re:Animation Engine Functions
Post by: TerranRich on Fri 27/06/2003 00:45:24
Boy, I must be stupid. :P I'm very interested, but also very confused. I've read all the threads, all the documents, and I still don't quite get any of it. Perhaps some kind of dumbed-down tutorial could be made in the future? ;)
Title: Re:Animation Engine Functions
Post by: juncmodule on Fri 27/06/2003 02:02:13
It is actually extremely simple. That is what makes it so confusing :P.

Truthfully though, it is.

It is a very complex way to be able to do something very simple. Since AGS doesn't allow controlling of characters across rooms there needs to be a way to do this.

Currently if you have a character you can control him in one room, but, if you want to use him in another room you have to import him there and THEN move him around. Some commands are blocking and some execute all at once. This all makes it very difficult to control non-player characters (NPC's).

RickJ's Animation Engine (AE) solves these problems by allowing global animation and movement commands. So, in your global script under repeatedly execute you can put a set of commands to control EVERY character in the game, in every room.

Currently Scorpiorus' CCS plug-in does just that. But, it can be a little confusing, doesn't recognize walkable areas, and a few other things. The work between Scorpious and RickJ was to combine their efforts and make it so you didn't need a plug-in. (Thus allowing portability to Linux).

My project which mirrored another portion of RickJ's AE system was meant to create Artificial Intelligence(AI) within AGS. While of course not TRUE AI, it was something that could at least emulate it.

It would allow two characters, NPC's, to walk up to each other, have a conversation, and then walk away in a different "mood". Then, the next time they had a conversation their initial mood would affect that conversation.

Of course this is how I saw all of these things coming together. I think Scorpiorus and RickJ may have been taking a slightly different approach. Hopefully that kind of explains it a little better. My apologies if anything sounds a little "too" dumbed down in here. My intention is not to insult, just to be as clear as possible without adding more confusion. ::)

later,
-junc
Title: Re:Animation Engine Functions
Post by: TerranRich on Sat 28/06/2003 01:16:11
Don't worry about it! I prefer dumbed-down explanations. :P

This sounds very interesting actually. I'd imagine having moods in that aspect (affecting conversations, etc.) would be VERy complicated to implement. I mean, altering moods is one thing. But deciding what to say based on a set of moods is another altogether.

:o
Title: Re:Animation Engine Functions
Post by: RickJ on Sat 28/06/2003 03:34:54
Rich, you are the one that got all this started ;) when you asked about having characters randomly walk across the screen in the background.  Maybe it will make more sense when I get it done and thetre is a demo available.
Title: Re:Animation Engine Functions
Post by: Scorpiorus on Sat 28/06/2003 21:30:23
QuoteAs a sort of test game/demo of my AI system and perhaps even AE I have started another game which is a bit more simple.

It will contain one city and about 26 people. A lot of work, but much better than the 20 cities and 60 people that Smuggler had. Of the 26 characters initially I intend to only have 5 exhibit "intelligence". I will slowly build up from there adding "intelligence" to other characters as I become more comfortable (and get all of the bugs worked out) with the system.
Right approach, junc. Also I think it is the way the future mood-packs will be created. So we have several characters living in a small world. Then we can extend it, add new ones, adjust their attributes, etc.

QuoteCurrently Scorpiorus' CCS plug-in does just that. But, it can be a little confusing, doesn't recognize walkable areas, and a few other things.
Walkables is a general problem. AGS holds only one room at time so that means we can't get access to the walkable in any other room. The reason I made it MoveDirect is because otherwise it could de-synch game process a lot more as in that case characters moving in the current room would walk around the obstacles (set by walkables) while in other rooms they'd go direct. Yet one important note, even if it were possible to use all rooms' walkables imagine how it could slowdown a game when there is a pathfinder run for several characters. :P


Rick, glad to see you. :) I had think about AE implementation and another idea come to my mind. What about simulating multiple scripts running at time? Not just threads but having fully(basically)-equiped script launguage: functions, variables (scope), stack (recursive calls). And all these with parallel processes support. And maybe implement the ability to use some object oriented approach. :P No, I'm not talking about entire OOP thingy but some sort of class struct would be handy. So all related projects like Autonomous CCS could rely on that basement (example: we could have a class with all character's attributes defined in + some methods incapsulated as well). It would make unnecessary to add segments thing we were talking about. Instead there are two different methods processing simultaneously: character.walk() and character.think(). Though I see the speed to be the main issue. I know you are working on important project so that's just a suggestion for future  requiring a detailed discussion I think.

-Cheers
Title: Re:Animation Engine Functions
Post by: TerranRich on Sun 29/06/2003 02:00:44
Quote from: RickJ on Sat 28/06/2003 03:34:54
Rich, you are the one that got all this started ;) when you asked about having characters randomly walk across the screen in the background.  Maybe it will make more sense when I get it done and thetre is a demo available.

Eek! I noticed the link to that thread. :P All I was asking for was a simple script that would let random characters walk across the screen...randomly. I'm considering implementing this AI/AE stuff into By the Sword 2, where I can have realistic characters, etc. And yeah, maybe when a demo comes out, I can understand it more by analyzing the source code and stuff. :)