Actor Animations and Animation Paths
Introduction You can assign all kind of animations to actors, just to make the mission more amusing. You have to know two things about the animations: the name of the animation and the name of de IFP-file that contains the animation. You can find a list of it here. The bold and large words are the names of the IFP-file, then the animation names inside that IFP-file will follow. For example, if you want that your actor dances, you have to look in the list and you will find the IFP-file "DANCING". That file contains all kind of animations, in this tutorial we will use "dnceMa". Of course you can give the actor also other animations, but please note: I can't guarantee that all of these animations will work!
First we will create an actor, which has to perform the animation. When you worked through the other tutorials of this topic, this won't need any explanation. If you don't understand it, please go back to the tutorial about actors. CODE
0247: loadmodel #BFYST 038B: loadrequested_models
:MODELLOAD if 8248: not model #BFYST available elsejump @MODELSPAWN wait 0 ms jump @MODELLOAD
:MODEL_SPAWN 10@ = Actor.Create(CIVFEMALE, #BFYST, 2491.3635, -1661.4694, 13.3359) Actor.Angle(10@) = 182.9651
0249: release_model #BFYST
We will first have to load the IFP file, then we have to check if the animation is loaded. After that you have to give her an animation. You can do this with the following opcodes: CODE
04ED: load_animation "DANCING"
repeat wait 0 until 04EE: animation "DANCING" loaded
0605: actor 10@ performanimationsequence "DNCEMA" IFP_file "DANCING" 10.0 loop 1 0 0 0 time -1 // versionA
Sometimes you don't have to load the animation, but I have to admit that I don't know when. I've seen many bugged scripts because they didn't load the animation, so my advice is to load it always. What do you have to lose? Better a few lines to much, than a bugged script! Opcode 0605 is exactly the same as opcode 0A1A and 0812. So it doesn't matter which opcode you choose. I will only explain the most important parts of this opcode. Feel free to experiment by changing the other parameters. First you have to say which actor you will give an animation, in our case that will be 10@, which we just created. The first integer number, the only 1 in the opcode above, will indicate how many times the animation has to repeat itself. When you make it a 0, the animation will only be done once. When you make it a 1, it will repeated. After time you will see "-1". This means that the actor will perform the animation until there is an opcode that says that it has to stop. You can change it into a number like 4000, which means that the animation had to continue for 4 seconds.
There is also a variant on the opcode: CODE
0829: actor 10@ performanimation "DNCEMA" IFPfile "DANCING" 4.0 time 4000 and_dies
In my opinion this is a bit stupid, but you can give it a try. After the actor performed it for 4 seconds, it will die. But it doesn't die like you would espect, it only freezes. There will be blood on the ground, but the actor is still standing, frozen. You can walk through it, and only if you kick the actor it will lay down. Funny to see, though.
0804: ASactor 10@ walkto 2498.1187 -1671.9563 13.3427 angle 0.0 radius 0.2 animation "GRLFRDKISS03" IFPfile "BDFIRE" 4.0 LA 0 LX 0 LY 0 LF 0 LT -1 0804: ASactor 10@ walkto 2498.1187 -1671.9563 13.3427 angle 0.0 radius 0.2 animation "DNCEMA" IFP_file "DANCING" 4.0 LA 0 LX 0 LY 0 LF 0 LT -1
Two examples of one opcode, try it to see the result (you can edit it into the code at the end, if you find it difficult to create something from a stripped file). The actor walks to the supplied coordinates, and then perform the animation. In the first the actor will walk to the point and then give a kiss. To nobody in this case, but of course, you can add another actor next to it. The second will let the actor dance when he is at the location.
0611: actor 2@ performinganimation "LRGIRLIDLETOL0" 8611: not actor 2@ performinganimation "LRGIRLBDBNCE"
This opcode is a condition, so you have to use with for example an if-structure. This can be handy if you want to check if the animation is stopped, or if the actor is doing an animation. Here is an example of a code that checks if the animation is stopped: CODE
0605: actor 10@ performanimationsequence "DNCEMA" IFPfile "DANCING" 10.0 loop 1 0 0 0 time 3000 // versionA repeat wait 0 until 8611: not actor 10@ performinganimation "DNCEMA"
Yet another opcode for an animation: CODE
0612: setactor 10@ animation "DNCEM_A" paused 1
With this code you can pause an animation. 1 means that it has to start, 0 means that it has to pause. For example we will make an actor with an animation, that has to do it for 1 second, then has to stop for 1 second, and then has to continue. CODE
0605: actor 10@ performanimationsequence "DNCEMA" IFPfile "DANCING" 10.0 loop 1 0 0 0 time -1 wait 1000 0612: setactor 10@ animation "DNCEMA" paused 0 wait 1000 0612: setactor 10@ animation "DNCEM_A" paused 1
0605: actor 10@ performanimationsequence "DNCEMA" IFPfile "DANCING" 10.0 loop 1 0 0 0 time -1 wait 3000 0614: setactor 10@ animation "DNCEMA" progress_to 0.5 // 0.0 to 1.0
This is another opcode, of course we are talking about the 0614 opcode. You can split up every animation. The whole animation is 1.0, it starts at 0.0. So you can say: I want that the actor perform the animation for 3 seconds, and then it has to start over from 0.5. Of course you can also say it has to start from the beginning after some time, then you have to write 0.0.
Release animation Of course you have to release the animation when you loaded it: CODE
04EF: release_animation "DANCING"
Animation Paths CODE
0754: definenewanimationpath 0755: addanimationpath3Dcoord 2496.5234 -1671.363 13.3359 animation "ROADCROSS" IFPfile "PED" 0755: addanimationpath3Dcoord 2499.4873 -1661.1962 13.3587 animation "ROADCROSS" IFPfile "PED" 0755: addanimationpath3Dcoord 2490.1294 -1661.246 13.3359 animation "ROADCROSS" IFPfile "PED"
You first have to define the animation path. You have to start with define new animation path. Then you have to add coordinates. In this example, we will add three coordinates. The Animation and the IFP-file is just like the animations explained at the beginning of the tutorial. You can also use "NONE" instead of "ROADCROSS" and "PED", but then they won't do an animation. The animation will be performed at the coord, so it won't be during the time that the actor walks to the coord.
Then you have to add an actor to the animation path: CODE
0817: assignactor 10@ toanimationpathwithwalkmode 4 route_mode 3
You can just expriment with this opcode. The route-mode: 0-normal order of waypoints, once (ABCD) 1-normal order of waypoints and reverse, once (ABCDCBA) 2-normal order of waypoints plus reversed, looped (ABCDDCBAABCD...) 3-normal order of waypoints, looped (ABCDABCDABCD...) (Source: this topic)
Finally I will give you the code of a stripped file with an actor that performs an animation: click.