www.tombraiderforums.com

Go Back   www.tombraiderforums.com > Tomb Raider Modding > Tomb Raider Level Editor > Tomb Raider Level Editor Tutorials

Closed Thread
 
Thread Tools
Old 01-09-15, 10:28   #1
AkyV
Moderator
 
Join Date: Dec 2011
Location: Hungary
Posts: 2,505
Default TRNG - Animation Command

by Paolone


This document is a short introduction to Animation command, with some study in depth of TestPosition command and ENV_ITEM_TEST_POSITION condition.


Introduction

With animation command you can create new interactive actions for Lara.

Any object, like an animating, could have new functions if you create an animation to interact with it.

The issue to perform to reach this targer are:


Create a new animation with Wad Merger
  • Type an Animation command to set the keystroke to use and the correct position about when activate your custom animation in game.
  • Add further NG AnimCommand in your custom animation to perform some special effects.
Create a new animation with Wad Merger

This operation could be difficultous, anyway you can find in internet some tutorial to learn how do it.

Try to visit Tutorials on TR Search website

In some case you could also use standard animation of tomb4 or other tomb raider adventures and then use it with other targets.

Type an Animation script command

In this document it will be described how verify the correct position and conditions to start your animation, while for general informations about Animation command you can read the html version of built-in help file you find also in NG_Center program:

Syntax: Animation=AnimIndex , KEY1_ , KEY2_ , FAN_ flags , ENV_ Environment , Distance for Env , Extra , StateId or AnimationId array (...)
Scope: to use in [Level] section
With Animation command you can perform new animation for lara when player hit some key.
(This command is suggested only for advanced level builders to add new moves for Lara.)

Other to set the number of animation and hot key used to engage in game the animation, you should set also some condition about when this new lara command will be permitted, because perform an animation, for example a kick, while lara is underwater or hanged to rope it should be weird.

AnimIndex field


Here you type the number you see in Animation Editor of Wad Merger program.

Remark:
If you type a negative number the Animation command will work in diagnostic mode.

In this situation no animation will be performed, of course, but you'll be able to see on screen an info about WHEN the animation could be performed.

Pratically you'll see a text like "Anim-1=no" or "Anim-1=YES"
This diagnostic mode is useful to test the condition you set in Animation command to verify if the animation should start in correct moment, as position or keystroke command.

Note: to see these infos on screen you have to enabled the diagnostic with command "Diagnostic=ENABLED" typed in [Options] section of script.txt.

Key1 and Key2 fields


In these fields you can set a code (or two) to identify the activation key of your new animation.

Remark: the special value KEY1_RELEASED may be added to Key1 field to invert condition about keys. When KEY1_RELEASED is present the condition is true only when the specified keys are NOT down.

You can set two kinds of value in Key fields.
Keyboard scancodes or Keyboard game commands.
Both types identify a key of keyboard but there are some differences:

- ScanCodes permit to choose any key (or almost) of keyboard, while Game commands are only the prefixed keys you see in Option screen tomb raider game.

- By other hand, the Game commands have the advantage to be activated also by joystick and if player changes the setting in Option screen of tomb4, your command will continue to work.

Another difference is the way to type the valeus in Key1 and Key2 fields.

If you use Scancodes you should copy the value from Keyboard Scancode list of Reference panel of NG Center program.

While if you want to use preformatted game commands, you can use the constant KEY1_... and KEY2_ ... you find in MNEMONIC CONSTANTS of Reference panel.

When you use game commands remember you have to place the value in Key1 field or in Key2 field in according with prefix KEY1_ and KEY2_.

Differently if you use scancodes you can assign a new key, usually non used by tomb4, for example the scancode for F8 key, or for "Q" literal.

You can also set two different scancodes, writting the first in Key1 and second in Key2. In this case the animation will be performed only when both key are hit in some moment.
For example.

Animation=500, 42, 11, ...

Since 42 = (Shift left) and 11= (Number 0), the animation will be started when player hit in same moment SHIFT + 0 (zero)

Remark: if you want to use scan codes you have to add the flag FAN_KEYS_AS_SCANCODE in FAN_ field.

Note that it's a bit different when you use KeyBoard Game Commands.

With KeyBoard Game command you can insert two or more code in same Key field, just type the sum of these valuese.
For example:

You can require two or more game command in same moment, adding the constant value KEY1_ with other KEY1_.. and KEY2 with other KEY2.

For example to have the combination of game commands Action Jump and Dash, you'll have to insert in key1 field "KEY1_JUMP+KEY1_ACTION" while in Key field the valye "KEY2_DASH".

Remark: If you don't use some of Key1/2 field you should type IGNORE to signal that it is not used.

FAN_ Flags fields


You can set one or more flags FAN_ to to set the behavior of animation command.

Read the FAN_ constant values in section _MNEMONIC CONSTANTS of Reference Panel of NG_Center to get info about FAN_ values.

ENV_ Environment field


In Environment field you can set a single very spefic condition about the environment around to Lara.

You should use this field only when your animation requires a correct environment around lara like: climbable walls, holes, walls ect.

Remarks:

* Differently by FAN_ flags you can not type the sum of any ENV_ values, you can choose only a single ENV_ condition and you can add to it only ENV_POS_.. flags or ENV_NON_TRUE flag to inverse the mean of condition.

* If you don't want set any Environment you can type IGNORE in this field.

See description of ENV_ constants in MNEMONIC CONSTANTS sectio of Reference panel for usage of ENV_ values.

Distance for Env field


If you set a value different by IGNORE in above field named Environment, you can set in this Distance field a number to specify some size or height or range about specific ENV_ condition you set in Environment field.

The common situation is Distance hosts the height/depth of wall/hole.

The units to use are 1024 for 1 sector, so 1 click = 256 and half sector is 512.

It's different the units when Distance field hosts a range, like for Environment named ENV_MONKEY_CEILING. See description of ENV_MONKEY_CEILING value about how set the Distance field in that case.

Remark: you can always type in this field IGNORE and trng engine will use a default value ideal for current ENV_ condition you chose.

Extra field


This field may host different values in according with FAN flags or ENV_ conditions.

You find what type in this field reading the descriptions of FAN_... flags or ENV_ conditions you find in Reference panel of NG_Center in section "MNEMONIC_CONSTANTS"

StateId or AnimationId array fields


After Extra field you can type one or more values to set State-ids or Animation indices to use as condition to start your special animation.

The special animation will be performed only if at least one of given state is, and one of animation indices, is currently active for Lara in game in that moment that player hit the correct keystroke.

Remark: to recognize State id from Animation indices, you have to use positive values for State-IDs, while negative values for Animation Indices.

For example: the list: "96, 112, -28, -42"

Will be read as: "Perform my animation only if state id of lara is currently = 96 or 112, and, in same moment, the current animation of Lara is 28 or 42 index.

You can use also type a constant STATE_ .. to type StateId values. You find all STATE_ values in MNEMONIC_LIST of Reference panel .

If you don't understand what is a "state-id" or Animation index you can interpret then like a number to signal what lara is doing in a more general way of specific animation.

The state-ids you type are used by engine to understand when your animation is allowed and when it's not.

Normally you'll set as state id the value "2" or "STATE_STOP" in this way your animation will be enabled only if lara is still, on land and in stand up position.

But you could create particular animation to perform only when lara is climbing a wall, in this case you should type all values for climbing:

STATE_CLIMB_UP
STATE_CLIMB_DOWN
STATE_CLIMB_END
STATE_CLIMB_LEFT
STATE_CLIMB_RIGHT
STATE_CLIMB_START_AND_STANDING

or only some of above values.


Add a NG AnimCommands to your custom animation


The NG AnimCommand are exported triggers in the form of SetPosition anim command.

You can export flipeffects and actions as NG AnimCommands, simply opening the Trigger Type window and clicking on [Export AnimCommand].

You'll be prompted to type the number of frame about when perform this animcommand and then you'll receive a text like this:

************************************************** *********
Add a SetPosition anim command with following values:

Set Position [-24556] [136] [5635]

Infos about exported trigger
-------------------------------------------------------------------------------
Exporting: TRIGGER(5635:0) for FLIPEFFECT(136)
<#> : Lara. (Physics) Vertical. Attract Lara <&>up/down with (E)speed
<&> : Down (Always, jumping/falling phase)
(E) : Speed= 22

AnimCommand: Frame=20
-------------------------------------------------------------------------------
************************************************** **********

Some infos are only for reference, the important data is this:

Set Position [-24556] [136] [5635]

Now in wad merger, open animation editor with Lara selected, and choose your custom animation.

Now click on little icon with little digits: "01010".

In new window select in combo box the type "Set Position".
Type in three white frames at right the three numbers you received from NGLE, in our example the numbers are: [-24556] [136] [5635]
and click on [Add] button.

Now save the wad: (File->Save wad)

Remark: a good trick to expand in future our animcommand in easy way, is to export as AnimCommand the flipeffect to perform a triggergroup typed in script.dat:

Exporting: TRIGGER(515:0) for FLIPEFFECT(118)
<#> : TriggerGroup. Perform <&>TriggerGroup from script.dat in (E)way
<&> : TriggerGroup= 3
(E) : Continue performing (it will be always performed until you stop it)

In above example the animcommand will perform the TriggerGroup=3 ...

In this way, we could add many triggers and conditions in our TriggerGroup in future with no need to modify furtherly the wad file or the tr4 file.

More, this way is, in some circumstance, the only way to create effects really very complex.

Last edited by AkyV; 01-09-15 at 11:39.
AkyV is online now  
Old 01-09-15, 10:39   #2
AkyV
Moderator
 
Join Date: Dec 2011
Location: Hungary
Posts: 2,505
Default

The TestPosition command

From version 1.1.9.8 there is the new TestPosition command.

Syntax: TestPosition= IdTestPosition , Flags (TPOS_...) , Slot Moveable , XDistanceMin, XDistanceMax , YDistanceMin, YDistanceMax , ZDistanceMin, ZDistanceMax , HOrientDiffMin, HOrientDiffMax , VOrientDiffMin, VOrientDiffMax , ROrientDiffMin, ROrientDiffMax
Scope: To use in [Level] section


With TestPosition you can set all data necessary to verify if lara has a correct position with respect to other item (all moveables with the given Slot)

Then you'll have to type the IdTestPosition also in DistanceForEnv field of Animation= or MultEnvConditon= script commands to transform it in an effective condition (ENV_ITEM_TEST_POSITION).

Descriptions of TestPosition fields:

IdTestPosition field

In this field you type a Identificative number to call this TestPosition command from other commands like Animation= or MultEnvConditions= (typing this id in DistanceForEnv field)

If you type many TestPosition commands in same [Level] section, each of them should have a different (progressive) Id number.

Flags (TPOS_...) field

You can type one or more TPOS_ constant values in this field to set some special features.

If you don't wish use any TPOS_ flag type IGNORE in this field.

See descriptions of TPOS_ values in Reference panel of NG_Center in MNEMONIC CONSTANTS list.

Slot Moveable field

In this field you type the slot (the number or the name) of items you mean check.

XDistanceMin and XDistanceMax fields

In these two field you have to type the min and max valid distance from X origin of lara and X origin of item to test.
To understand what is the X axis watch this image:



In light blue color you see the X axis and its orientation.
The effective difference you compare with these two field is given by X_Lara_origin - X_Item_Origin.

For this reason, normally, the range you type are always a negative value for XDistanceMin and a positive value for XDistanceMax

For exaple if you choose:

XDistanceMin = -256
XDistanceMax = +256

this means you accept a tollerance of one click (a sector is 1024 units, so a click is 256 units) of difference between lara and item on X axis.

Other example, if you set 0 for min and max X distance this means you require that lara is nose vs nose with other item (for example a ninja) and neither a pixel of difference should exist.

Anyway, choosing 0 and 0 should be very stupid, of course, because you'll have always need of some tollerance.

Last example for X difference range:

If the item to test is a coffe cup, and the cup in game give a difference on X axis of +100 , this means that the cup should be about close on left hand of lara. While if the difference was -100 the cup should be near to right hand of Lara.

When you compute the valid range for X axis (or others) you should keep in mind the concept of "Relative axis" (see next paragraph) used in TestPosition comparation.

Relative Axis

A complication, to understand the comparations of testpostion, is that the axis are relative to current orientation of lara, while usually, in 3d world we think to have fixed x,y,z coordinates.

When you compute the difference for x relative axis for example the engine fixes the origin of 3d world to origin of lara, and it will (ideally) rotate the 3d world to have facing of lara (where she is looking) in same direction of wished axis.

The image of axis explain this situation:



For above reason, if you set as Z difference (Z axis, see the picture) as 256 units and the condition is true, this means that, in front of lara, the other item will be to 1 click of distance in front, indifferently if in 3d world lara is at the left or the right (watching the game screen) of other item, because the position will be changed before performing the comparation to have lara at 0,0,0 and looking in exact axis direction, i.e. whre lara is looing it will become the new Z axis direction. The speech is complicated but using the examples of AnimationTestPosition.zip file you can understand it, and you'll discover that it works very fine.

Note: this method has been created by Eidos programmers and not by me. I'm using the specific procedure used by default tomb to test the position of items with them lara should interact.

YDistanceMin and YDistanceMax fields

This couple of values set the range for distance on Y axis.
See the image "ExTestPosition_Axis.jpg", the y axis has white color.

Many description I given to explain the X difference range are good also for Y range, anyway in this case there is further complication because while the X and Z origin of lara is always the same, at half of her body, the Y origin of lara changes in according with current animation.

I suggest to use the diagnostic to understand what is the Y origin of lara in animation from what you mean start to launch your custom animation.

Practically you should type in [Options] section of script.txt the command:

Diagnostic= ENABLED

So in game you'll see many value about lara.

Look the "Cy=..." value.

To understand better what it means, you should build a sample project where the floor is to 0 clicks, then you should extrude some sector to have 4 clicks of height, and also some hole in the floor of 4 clicks.

The targert of these test will be to see what is the Cy of lara when she is on floor. The cy should be "0" if also the floor of room is 0 click.

When lara move up a sector hight 4 click the Cy should be Cy = -1024 because upward the y axis in negative.

Differently, if lara go down in the hole deep 4 click the Cy should become +1024 because there are 4 clicks of difference than flat floor.

These experiment are enough stupid because we already know the results, anyway I made this example to explain how discover the reference of Y origin of lara for all animations.

For example if lara hangs to edge of elevated 4 click block, we have another animation (that of hanging) and we could discover that in this animation the Y origin is no more to lara's feet but now is where lara has her knees(!)

Creating a sample project (always with floor to 0 clicks) and creating also a pool room (a room with water), we could discover other Y origins for particular standard animations for example when lara is floating on water surface the Y origin of lara is the same of Y coordinate of water surface. Also while lara is floating up and down for the waves the Cy value reamins the same. So in this case the Y origin is about on the neck of lara.

So, when you create your TestPosition command you should verify as first thing what is the point of lara where there is the Y origin in animation from what you mean launch your custom animation, and build your Y range on this reference.

Now we could perform some examples using stand-up position of lara, when the Y origin is on her feet.

If the item is a little ball, and it is in front of lara, when the ball will be heigh like the head of lara, the difference will (about) + 600 while if the difference is negative, for example - 1024 this means the ball is an hole below lara than one sector.

Differently than example for X Range, when we set a range for Y distance, it's not sure we'll use same value with - and + signs, bacause when the Y pivot (origin of lara on Y axis) is in her feet, we could require different abs values for min and max.

For example, if we want that above little ball (big like head of lara and with its Y origin in the center of sphere) was (about) in front of lara's head, we should set as Y ranges somewhat like:

YDistanceMin = 550
YDistanceMax = 650

As you see, there is no negative value in above values.
This happen because lara is height about 3 clicks, so 256*3 = 768 units (exactly 800 units).

We wish that the ball was in front of head of lara, so the ball cann't be lower than neck of lara, and the neck is about to 512 units from feet (y origin) for this reason we set as min Y distance 550, because if it was less of 550 it means the ball is very close on feet of Lara.

By other hand, we neither wish to have the ball so much over the head of lara, and since the top of lara's head is 768 the max distance should less than 768 (we used 650)

Remember that we work on relative axis (see above paragrah) so it's no important if Y origin of lara or item are positive or negative, the difference will work always in correct way.

When the Y difference (in example of the ball) is 0 this means the ball is in front of feet of lara, and hence in wrong position.

Size of Lara

To understand better the size and mesh position of Lara in stand up position see this image:



In spite of some distortion
for perspective view, we could suppose following sizes for lara:

Height in stand-up position (picture A or C) = 800

Width stand-up, from hand to hand (picture A) = 320

Depth of lara by profile (picture C) = 130

Height in all fours position (picture D) = 320

Height in climb position (picture B) = 600

ZDistanceMin and ZDistanceMax fields

With these two fields you set the distance range on Z axis.
The z axis is always the direction where lara is looking.

When the Z difference (Lara.Z - Item.Z) is negative this means that item is in front of lara, while if difference is positive lara has passed over the item and now it is at her back.

HOrientDiffMin and HOrientDiffMax fields

These two fields set the acceptable range for the relation (difference) between horizontal orientation (facing) of Lara and Item.

The horizontal orientation is given by Lara.HorizonalOrient - Item.HorizontalOrient.

To understand what I mean for "Horizontal" facing you could look this picture:



The default H facing of items (lara or others) is 0 and this is the position you see in NGLE when you have just placed an item in the level map.

To understand how the difference between H orientation changes you should see the project in AnimationTestPosition.zip file.

If you set correct distance ranges (see previous fields) but you wrong the horizontal orientation difference you can get to have lara close on item (correctly) but the item is not showing the correct side to lara.

For example if you create an object like a cabinet, and you wish create an animation where lara forces the lock to open it, it's necessary that, not only lara is close on cabinet object, but also that lara has in front of her the lock, because if lara has in front the back of cabinet or some side, the distance could be correct but the animation should have no sense.

You should as first step find the ideal difference between H orientation and then create a range where there is at least a little tollerance.

For example with the cabinet the diffrence could be $8000 ( 32768) (face to face) and the range should have a Min a few less for example $7f00 while the max bigger than same tollerance ( +/- $100 ) i.e. $8100.

VOrientDiffMin and VOrientDiffMax fields

These two values set the range for difference of Vertical orientation.

See this image:



This range is not very important because 99 times on 100 both items (lara and other item) will have VOrientation = 0

You could set a range as Min= - 200 and Max = +200
The very seldom case where lara has a different VOrient is the run with rash, when she swimm underwater or she is diving.

Anyway you can use the sample project in AnimationTestPosition.zip file to verify this situation.

ROrientDiffMin and ROrientDiffMax fields

These two fields set the valid range for difference of Rotating Orientation between Lara and item.

Pheraps "Rotating" is not the correct term to describe this kind of facing anyway you can see how it works watching this image:



It's very seldom the value changes, it should be always 0, so also the difference between lara and item should be zero.

Anyway, this value changes a bit when lara is running with rush and she is turning at left or right.

You can type as range -200 +200 but probably you can also type 0 and 0 in most situations.

Last edited by AkyV; 01-09-15 at 20:18.
AkyV is online now  
Old 01-09-15, 11:19   #3
AkyV
Moderator
 
Join Date: Dec 2011
Location: Hungary
Posts: 2,505
Default

The project Test Lara Position

In zip file "AnimationTutorial.zip" you find all source files to create a little project.

This project has the target to explain how set the correct ENV_ conditions and TestPosition commands to verify when lara is in wished position to start our custom animation.

Before beginning with specific samples I have some suggestions.

Suggestions

  • When you want create an animation to interact with some item (moveables) it's better to use the new ENV_ITEM_TEST_POSITION condition linked with a TestPosition command, because the old env condition to detect the position of items don't allow to work on range of values but only to set a fixed distance with poor results.
    I let in NG_Center the old ENV_ITEM_EXTRA_ ... conditions only for backward compatibility but it's better don't use ever them.

  • To discover the values to type in TestPosition command you should enable the full diagnostic with following commands in [Options] section:

    Diagnostic= ENABLED
    LogItem= FLI_SHOW_DIFFERENCES, IndexItemToLog

    The Diagnostic enable the showing of infos about lara on the screen, while the new command LogItem permits to have same information also for another item. You have to type the index of this item in LogItem (IndexItemToLog)
    The flag FLI_SHOW_DIFFERENCES is very useful for our job, because it shows the ideal data to use in TestPosition command.

  • When you want create an animation to interact with a moveable, you should place this item in the level and type its index in LogItem command.
    Then, in game, you should try to reach the position where lara should be to start correctly your custom animation.
    Watching the Difference value on screen you'll get the ideal values to set in TestPosition, adding a couple of - / + values (the tollerance) to each of them, to create the tollerance range for each value.
    Well, in this operation it's necessary remember to place this item to get that, in wished position of lara, the item had original facing and lara was at left (in ngle view) of item, i.e. the DifZ should be negative or 0.
    An exception is when you want place lara on a side of item, in this case the ZDif could be also positive, just item had the original facing.
    There is this complication because the engine would like alwasys the disposition Lara.z < Item.z and Item.HOrient = 0

    If you require absolutely to have lara.z coordinate > Item.z you can read the difference value on screen inverting the sign.
    For example if you read ZDif = +400 you should use as ideal position ZDif = -400. In this case, if XDif is different than 0, you should invert also it: if XDif was -150 you should consider as ideal position XDif = +150.
    Remark: This speech doesn’t regard the YDif value, because it’s always the value you read on screen.

    This expedient is necessaery only to detect the correct values to type in testPosition command, but when you created your TestPosition command, your TestPosition command will be able to handle correctly that item with any rotation you wish use in final level.

  • Once you create your Animation and TestPosition command, it's advisable to test them in game with Animation command working in diagnostic mode.
    To do work in diagnostic mode an Animation command just you set as AnimIndex to perform (the first field of Animation command) a negative number.
    In this way no animation will be performed, of course, and you'll be able to verify if conditions and position you set in script.txt work fine.
    When the animation should be performed you see ont the screen a text like "Anim-1=YES" where that "-1" is the negative number you typed as AnimIndex.
    The reason to use this method, instead perfroming immediatly the real custom animation, is to verify in fast mode if animation could be performed in correct position and ONLY in correct position.
    If you use real animation you should everytime wait the end of custom animation and then to move back lara to previous position, while in diagnostic mode you can move lara around the critical zone to detect in precise way its zone.
    If in this check you find some bad distance, just you change the values in TestPosition command, build the script and then retry newly.
Sample A - In front of right rear wheel of Jeep

In this sample we'll try to set an animation command where is required that lara was on all fours, in front of right rear wheel of Jeep (animating6)

Pratically our ideal position is this:




The reason could be to do a custom animation where lara changes a wheel. :-)

The first step is to discover the values to type in TestPosition command.


This command accept a list of ranges for each axis and orientation (facing) type.


The values are always differences between Lara and item on what she should interact.


When we enable the diagnostic (see above
Suggestions ) we could see the difference values on screen, in right bottom corner.

Compute from ideal position to TestPosition values



The values begin with "Dif:"

In this case our ideal values for distances on axis are: DifX = 605 DifY = 0 DifZ=-579

We can use these value to build the x, y and z ranges in this way:

XDistanceMin = 605-300
XDistanceMax = 605+300

YDistanceMin = 0-128
YDistanceMax= 0+128

ZDistanceMin= -579-200
ZDistanceMax= -579+200

I added to each ideal value a tollerance value to build a range, since, requiring to have lara exactly in ideal position, it’s not possible because the player will be never able to reach in perfect way that position.

I used “300” as X tollerance, “128” as Y tollerance, and “200” as Z tollerance.


If you set value bigger, lara will result in correct position also when she is a bit far to ideal position, while if you type a littler tollerance, lara will have to go very close on ideal position.


Now we have to do same compute for difference of orientations (facing).

On screen we read:


XOrientDif=-16249 ($C087)
VOrientDif= 0 ($0000)
ROrientDif= 0 ($0000)

There is a reason to show the orientation number also in hexadecimal format (number with “$” sign in front): the facing we wish will be almost always one of these: $0000 (East in NGLE), $4000 (South), $8000 (West) or $C000 (North)
Hence, we should around the value we read because it’s a bit wrong. In this case the correct value will be $C000 because it’s the most near to value on screen ($C087).

So we’ll use $C000 as ideal value for HOrientDifMin / HOrientDifMax range.


Since $c000 in decimal is -16384, the value for H Orient range should be:


HOrientDifMin = -16384-$0800
HOrientDifMax = -16384+$0800

In this case I used as H Orient tollerance the value $0800.
It’s more easy understand the tollerance for orientation using the hexadecimal values ($) since the degrees are $4000 = 90 degrees, $2000 = 45 degrees, $1000 = 22.5 degrees, $0800 = 11.25 degrees, ect.

I used a tollerance + or - of 11 degrees, but pheraps it was better to use the standard value used in tomb4: $1000 as H Orientation Tollerance.


About the VOrient and ROrient in this case are not meaningfull, so just type a range where the ideal value is 0.

Summarizing all above computes our TestPosition command will be:

TestPosition= 1, IGNORE, ANIMATING6, 605-300, 605+300, 0-128, 0+128, -579-200, -579+200, -16384-$0800, -16384+$0800, -1000,1000,-1000,1000

While the animation command could be:

Animation= -1, IGNORE,IGNORE, IGNORE, ENV_ITEM_TEST_POSITION, 1,IGNORE, STATE_ON_ALL_FOURS_BACK, >
STATE_ON_ALL_FOURS_FORWARD, STATE_ON_ALL_FOURS_STANDING, STATE_ON_ALL_FOURS_TURN_LEFT, >
STATE_ON_ALL_FOURS_TURN_RIGHT

In this command you can notice:
the first “-1” value, to do work in diagnostic mode the command.

When the animation should be performed you see on screen “Anim-1=YES”


The “ENV_ITEM_TEST_POSITION” condition to use the TestPosition with Id = “1”

Building the script and checking in game, you can verify when the animation should be performed.

Try to change the tollerance to verify how change the esite.


Remark: in this sample I’ve not typed any keyboard command to enable our custom animation. This happens only because we are working in diagnostic mode, but when you use really a custom animation will be necessary choose some keyboard command to start the animation.

For example if we want to use the Jump command to perform the change of wheel when lara is in correct position the animation command should be:


Animation= 650, KEY1_JUMP, IGNORE, IGNORE, ENV_ITEM_TEST_POSITION, 1, IGNORE, STATE_ON_ALL_FOURS_BACK, >
STATE_ON_ALL_FOURS_FORWARD, STATE_ON_ALL_FOURS_STANDING, STATE_ON_ALL_FOURS_TURN_LEFT, >
STATE_ON_ALL_FOURS_TURN_RIGHT

Supposing that your custom animation was the 650.

Sample B - In front of the back of Jeep

In this sample we want create an animation when lara is in front of the back of jeep (animating6):



The ideal position, looking in diagnostic mode could be:



The ideal position is:

DifX = 0 DifY = 0 DifZ = -981 OrienHDiff = 0

and will be converted in following TestPosition command:

TestPosition= 2, IGNORE, ANIMATING6, 0-400, 0+400, 0-127, 0+127, -981-200, -981+200, 0-$1000, 0+$1000,-1000,1000,-1000,1000

See Compute of ideal position for details about the compute of conversion between ideal position and final data to type in TestPosition command.

In this B Sample there is a news in animation command :

Animation= -2,KEY1_ACTION,IGNORE, FAN_ALIGN_TO_ENV_POS, ENV_ITEM_TEST_POSITION, 2, IGNORE, STATE_STOP

Where we used the FAN_ALIGN_TO_ENV_POS flag to enable the self-aligment of lara in ideal position.

Self-Alignment feature

We already know the self-aligment feature to have seen it many times in old tomb4. For example when lara goes in front of pushable object, when the player hit the action key, lara will move byself to reach a precise position (ideal position) and only after this adjustment the push/pull animation will be started.


Now also with our custom animation we can have same feature.

The advantage of this feature is to reach in same moment two targets:
  • Permit to Lara to have a wide zone to interact with some object (like the pushable), since also when lara is far from ideal position she will be able to interact with pushable object.
  • To have the sureness that the custom animation will be started from a very precise (and always the same) ideal position, avoiding an incoherent movement between animation and object.
To enable the self-adjustment just to add in FAN_ flags of Animation command the FAN_ALIGN_TO_ENV_POS flag.

This flag works only when you use also a TestPosition to verify the correct position of lara with the ENV_ITEM_TEST_POSITION condition.

The reason is that, the self-alignment will use own the data in TestPosition to discover the exact target (ideal) position to reach with self-alignment.

The engine will perform an inverse compute to get, from the ranges in TestPosition, the ideal position to reach.


The formula used is simple: (MaxRange + MinRange) / 2

In this way for each X, Y, Z and H Orient will be found the orientation and position to do reach to lara.

Remarks:

- When you use self-alignment you should always set some keyboard command for Animation= command, because otherwise lara will move byself in unpredicatble way.


- The self-adjustament should work fine when Lara (at start) is in stand-up position or she is swimming underwater or floating on water, but in many other positions, like hanging position (climb, monkey) or special position like “on all fours” it could fail.

- If in game Lara moves byself endless, this means you mistaked somewhat to compute the ideal position, in fact you set an ideal position where lara is not able to go, probably because the collision box of item stops her.

In this case you have to modify the ideal value for Z or X in according with what axis is the distance between lara and the item.


Sample C - In front of King Throne

In this sample we want reach this position:



As you can see in this sample we requires also another conditon: lara has to hold a flare in the hand.

About the ideal position it could be this:




Using the ideal position you see in above image we can build the TestPosition as showed in Compute of ideal position in above paragraph.

The interesting thing in this sample is we wish verify also antoher ENV condition (other the usual ENV_ITEM_TEST_POSITION condition).

We want that lara hold also a flare to start our custom animation.


To use multiple ENV conditions

Since we can directly set only one ENV_ condition in Animation= command, to pass over this limit we have to use a MultEnvCondition command where store our two conditions (but it could be also a big number of conditions), while in Animation command we’ll use the ENV_MULT_CONDITION conditon and in DistanceForEnv field, we’ll type the ID of MultEnvCondition with our conditions to test.

Using this method we can perform a lot of ENV condition for each Animation command.

The MultEnvCommand has the first field for its ID, and following fields are triple values serie. Each triple group has following fields:

EnvCondition
DistanceForEnv
Extra field

The names of above field are the same of Animation command, and we can use them in same way.

So, to have a Multiple condition where we want check for conditon “lara holds flare” and “Lara is in TestPosition” we’ll type following commands:

;The test position:
TestPosition= 3, IGNORE, ANIMATING7, 0-512, 0+512, 0-127, 0+127, -860-300, -860+300, 0-$1000, 0+$1000, 0,0,0,0

;The multenv condition
MultEnvCondition= 1, ENV_HOLD_EXTRA_ITEM_IN_HANDS, IGNORE, HOLD_FLARE, > ;First condition: lara holds the flare
ENV_ITEM_TEST_POSITION, 3, IGNORE ;Second condition: the testposition 3

;and finally the Animation command (in diagnostic mode)
Animation= -3, KEY1_ACTION, IGNORE, FAN_ALIGN_TO_ENV_POS, ENV_MULT_CONDITION, 1 , IGNORE , STATE_STOP

Sample D - In front of Metal Gate

In this case we want lara in front of metal gate:



The data with ideal position is:



Animation= -4, KEY1_ACTION, IGNORE, FAN_ALIGN_TO_ENV_POS, ENV_ITEM_TEST_POSITION, 4, IGNORE, STATE_STOP

Using the ideal position you see in above image we can build the TestPosition as showed in Compute of ideal position in above paragraph.

Double facing with TestPosition

In this D sample we used the flag TPOS_DOUBLE_HORIENT in TestPosition command.

This flag permits to do work the correct position also in opposite side of the object.

If you try in game you see that it’s possible start animation from both sides of the gate.


This flag works fine only when the pivot (origin x,y,z) of object is really at center of the visible meshes. Unfortunately in some circustances the pivot is in a corner of sector where the item will be placed, and in this case the double horient will get poor results.

Move the origin of Objects using MetaSequoia

If you need to move the pivot of some object you should to use MetaSequoia program and StrPix program.

With StrPix program you find the mesh of your object and then export in DXF format this mesh.

Then import the .dxf file in MetaSequoia importing the object with these settings:



Now in metasquoia each sector is 1/4 of tomb4 sector.

The gate I used has been moved to have its origin in center of tomb4 sector.

You can see how it appears in metasequoia:



The red point is where is in tomb4 the center of sector. Try to use the colored line of three axis as reference.

The tomb4 sector in above picture has been highlighted with white color.

One time you moved your object in center of tomb4 sector, you export it in dxf formato using following parameters:



Then you’ll import in StrPix the modified .dxf file in same mesh of object.

After this operation you should also to use the program FexAnim to fix the collision and visibility box of your object, because moving the mesh with metasequoia we have let the collision box in previous position and in game this should be a problem.

With FexAnim you can work only on tr4 file, so you should:
  1. Build the level to have a tr4 file
  2. Load this tr4 file with FexAnim
  3. Select in left frame your object
  4. Clik on item "Show [x]"
  5. Now you should click on [Automatic Bound] button for each animation of your object. You can see in top left corner of FexAnim window the list of animations.
  6. When you completed all animations, choose from menu "Save as ..." and choose newly the same .tr4 file
  7. Now, to have your correct object in wad file, you should use wad merger to move the object from .tr4 file to .wad file
Sample E - Lara in front to the cube

We want get lara in front of cube for each side:



Facing for all sides

In this sample we had used the flag TPOS_FOUR_HORIENT in TestPosition to do work our TestPosition for each side of cube.

This flag works fine only when the origin of object is exactly at center of sector and also when the object has a regular shape for each side.

TestPosition= 5, TPOS_FOUR_HORIENT, ANIMATING3, 0-512, 0+512, 0-127, 0+127, -680-200, -680+200, 0-$1000, 0+$1000,0,0,0,0

Animation= -5, KEY1_ACTION, IGNORE, FAN_ALIGN_TO_ENV_POS, ENV_ITEM_TEST_POSITION, 5, IGNORE, STATE_STOP

Sample F - Lara punchs a Baddy (Full working example)

In all previous examples we have set only testposition to verify the position but the custom animation to do work those examples was always missing.

The reason is simple: I'm not able to create custom animation with Animation editor so I can only to do script commands to verify position for further custom animations.


However in this Sample F I create a full working example using an animation I found in tomb5 chronicles.


The animation should be with Lara punchs but in the reality is not own so good that animation for our target.


If you are able to build new animations you could enhance this example using a real fighting animations set, while in this example I'll exaplain how create the script commands to handle it.


Compute Ideal Position for Item in motion

The method to compute the ideal position for Lara with some item in motion is theorically the same we saw in this tutorial, but in this case there is the complication about the continue going of moveable.

To solve this problem we can perform a simple trick: the position of moveable is present in diagnosic also when the moveable has not yet been triggered in game, so we can try to read the ideal position on screen working on the point where the moveable should be, hence he is not yet visibile.



We can help us, placing a special texture where is the moveable, like in above picture.

The white circle on red texture, show the x,z position where we placed the baddy, and the little black arrow shows where he is looking, i.e. his facing.


Now, we can detect the ideal position working on that texture, both on moving baddy.


We type its index in LogItem command:


LogItem= FLI_SHOW_DIFFERENCES, 14

We play the game, and we move lara in correct position:



So, reading and rounding the data on screen:

DifX = -25 Y=0 Z=-469 HOrientDif = 757 ($02f5)

We can get these ideal position:

DifX = 0 Y=0 Z= -400 HOrientDif = 0 ($0000)

About the HOrientDif, we give a big tollerance for rotation in west direction both to east direction and this to compensate the fact that lara punchs using the right arm.

So the testposition command could be:

TestPosition= 6, TPOS_FOUR_HORIENT, BADDY_1, 0-200,0+200, 0-127, 0+127, -400-256, -400+256, 0-$1000 ,0+$1800 ,0,0,0,0

We used the TPOS_FOUR_HORIENT flag to do work above position on all four sides, but this is only a choice, we could also set to work only on single orientation and pherap it was more realistic.

The necessary to add new skills to Lara

To add some new skills to Lara it's necessary to have:
  • A custom animation to show the new moves for Lara.

  • Type an Animation script command, with further TestPosition command, to detetect when there are all conditions to perform our custom animation

  • Create some NG AnimCommand to insert in our custom animation to perform some change in game: the actions performed by this NG AnimCommand will be the new skill for Lara
The Custom Animation

We'll use this animation, it's not perfect (only the good girls fight in this way) but it's the best I found.



To avoid that lara try to punch when she hold crossbow, pistols or other, we have to add also the ENV_FREE_HANDS condition to verify if she has free hands.

MultEnvCondition= 2, ENV_FREE_HANDS, IGNORE, IGNORE, > ;lara has free hands
ENV_ITEM_TEST_POSITION, 6, IGNORE ;test position for lara close on baddy

Animation= 445, KEY1_ACTION, IGNORE, FAN_KEEP_NEXT_STATEID, ENV_MULT_CONDITION, 2, IGNORE, STATE_STOP

How set a NG AnimCommand

A NG AnimCommand is a special anim command that will be performed when our custom aimation will be played.

We can get the data for NG Anim Command click on [Export AnimCommand] in Set Trigger Type window.


See also Add a NG AnimCommands to your custom animation. (above)

Now we have to decide what skill to give to lara and the how we could transform it in a triggergroup.

The skill is to punch an enemy (a baddy1) and our AnimCommand should remove HP (vitality) to enemy and set some movement for baddy to get visible he has been hit.

Our trigger group contains two triggers:

First exported trigger reduces the vitality for enemy:

; Exporting: TRIGGER(2086:0) for ACTION(14)
; <#> : BADDY_1 ID:14 in sector (4,4) of Room4 (This will be replaced by any Baddy found by testposition)
; <&> : Enemy. Hurth <#>enemy removing (E)Vitality points
; (E) : Vitality Points= 8
; Values to add in script command: $5000, 14, $826

While second trigger force a falling down animation for baddy:

; Exporting: TRIGGER(783:0) for ACTION(14)
; <#> : BADDY_1 ID:14 in sector (4,4) of Room4
; <&> : Force (E) animation (0-31) for <#>object
; (E) : 3 Animation
; Values to add in script command: $5000, 14, $30F

The data to type in TriggerGroup command are always the three values for each exported trigger, so our TriggerGroup becomes:

TriggerGroup= 1, $5000+TGROUP_USE_FOUND_ITEM_INDEX, 14, $826, > ; Hurt enemy removing 8 hp
$5000+TGROUP_USE_FOUND_ITEM_INDEX, 14, $30F ;force anim to thow down the baddy

Remarks:
We used the TGROUP_USE_FOUND_ITEM_INDEX flag to replace the original item index typed in exported trigger, with (any) item index that TestPosition command will detect in correct position.

For this reason, hence our trigger in TriggerGroup are refered to a specific moveable with index = 14, our skill will be able to work with all baddy1 in the level.

In the sample I place another baddy1 with different index, lara is able to trigger him going on heigh floor sector, and you see that our skill works also with this new different baddy1 item.


The animation forced for baddy is a duplicate of another animation, in fact it's always a good rule, don't change any default animation but always duplicate the wished animation in an empty animation slot, and then change it in this new position.

I used the animation used to kill baddy, but I used it only to do fall him, and then I set as NextAnim (in my duplicated animation) another default animation to do the baddy stands up newly.


Now we can in NGLE export a flipeffect trigger to do perform the TriggerGroup =1:



Clicking on [Export AnimCommand] button, we'll be prompted for frame number when perform this animcommand, I chose the number 12

Remark: when there is a frame rate different than 1 in animation editor, you have to consider the effective frame number that you see in above bar and not that in the bottom of screen with single frames.

We get this text:

--------------------------------------------------------------------------------------------------
Add a SetPosition anim command with following values:

Set Position [-24564] [118] [1]

Infos about exported trigger
-------------------------------------------------------------------------------
Exporting: TRIGGER(1:0) for FLIPEFFECT(118)
<#> : TriggerGroup. Perform <&>TriggerGroup from script.dat in (E)way
<&> : TriggerGroup= 1
(E) : Mutiple performing (to use when in TriggerGroup there is some condition)

AnimCommand: Frame=12
--------------------------------------------------------------------------------------------------

Now we can open wadmerger, select lara and cick on Animation Editor to place above anim command in animation 445.

The data to add are:

Set Position [-24564] [118] [1]

See Add a NG AnimCommands to your custom animation

How enhance the fighting sample

If you try in game our sample you see it works, but not very fine.

If you have time and the ability to create new animations with animation editor you can give to lara a large set of new fantastic skills.

Different fighting animations

You could create two or more animations with different fighting mode: punch, kicks ect

Set for each custom animation a different group of testposition and animation and, furtherly, keyboard command to enable.

For each different type of animation you should force a different lost of vitality for enemy and a different enemy animation to show his hurting.


Create new non-shooting weapon.

You could permits to lara to fight using a knife.
There is some problem to solve because all weapon management is strongly hardcoded.

I suggest to use this method:
  • Modify the mesh of BURNING_TORCH_ITEM to give the look of knife (or sword)
  • Modify the hand mesh of TORCH_ANIM slot to give same look of above knife
  • Create TestPosition and Animation command like in example of punching the baddy but in MultEnvCondition add also the condition ENV_HOLD_EXTRA_ITEM_IN_HANDS with (in extra field) the value HOLD_ANY_TORCH.
    In this way the animation will be started only if lara holds the torch/knife
  • Create a custom animation where lara hits using the knife
    This animation should be placed in Slot 0 of default Lara and not in slot of TORCH_ANIM because these extra slots are not reachable by custom animation.
  • In the Animation command, that you use to perform this animation, add to FAN flags also the flag FAN_SET_FREE_HANDS_TEMP.
    This flag is necessary to perform custom animations (full working) while lara is holding somewhat in her hands (weapons or torch)

Following above suggestions I believe the knife should work fine.

Theorically you could add other features very comples, like to add some effect to enemy after in its hurting animation. You could realize this target exporting an action trigger to add blood effect as animcommand and insert it in hurting animation of the enemy.

About the chance to have a common inventory item as knife it's a bit difficultous and now I can only give a general way to follow.

You should modify an inventory item like a PickupItem to give the look of knife.


In script.txt type a customize command like this:

Customize= CUST_SET_INV_ITEM, PICKUP_ITEM4

Supposing that our knife was the Pickup4

Above command it's necessary to preserve always the item in inventory like a weapon (when lara extract the pistols, they remain in inventory)


Then you should create a globaltrigger command with GT_USED_INVENTORY_ITEM and slot of your Pickup4.
This globaltrigger (when the condition is true) will perform a triggergroup where you have exported the trigger:
"Lara. (Mesh) Torch. <&>Give/Remove Torch to/from hand of Lara"

Setting to "Give" the torch, of course

In this way, we realize first part of our new weapon:

Lara can find and pick up the knife
It goes in inventory
Lara is able to use this knife
And it appears in the hand of lara
Our custom animation allows to Lara to fight using it and kill the enemies.

There is yet a single problem.
What happens when lara extract other weapon? Our knife/torch will be thrown out, but this is not the behavior ideal for our skill.
To solve this problem it's necessary set also another GlobalTrigger command, like this:

GlobalTrigger= (ID GlobalTrigger), FGT_REMOVE_INPUT, GT_GAME_KEY1_COMMAND, KEY1_DRAW_WEAPON, ... ....

Above global trigger intercepts the game command to extract weapons.

Adding the FGT_REMOVE_INPUT flag the DrawWeapon command will be removed but only when the condition in IdConditionTriggerGroup is true, otherwise the game command DRAW_WEAPON will be perfomed normally.


For this reason we have to create two triggergroup called by above GlobalTrigger:

- A TriggerGroup working as Conditional triggergroup, to verify if currently lara hold the torch.


The trigger to export in this triggergroup will be: "Lara. (Holds) Lara is holding/driving the <#>item" with item "Holding_Any_Torch"


Then we'll type the Id of above TriggerGroup in field "IdConditionTriggerGroup" of GlobalTrigger command.


- A TriggerGroup used to solve our problem: what could we do when lara has the torch/knife but the player chose to throw out the knife and to use another weapon?

An easy but poor solution, is to type in this triggergroup only the flipeffect trigger "Lara. (Mesh) Torch. <&>Give/Remove Torch to/from hand of Lara" setting "Remove"

In this case it's not necessary to use the FGT_REMOVE_INPUT flag in global trigger.

When player hit SPACE to laod the guns, the knife will disappear from lara's hand and the command to extract the pistols will work in normal way.
But this disappearing of knife is a bit weird.

A more difficultous solution but more effective, is to create another custom animation where lara move the her right hand on body bag to take off the knife, and we could place a NG AnimCommand in correct frame of this animation to remove the mesh of knife.

The trigger is the same showed above "Lara. (Mesh) Torch. <&>Give/Remove Torch to/from hand of Lara" setting "Remove"


In this case, in our triggergroup we'll type only the flipeffect trigger to perform our custom animation to take off the knife and the animcommand within it, will do the necessary operation.


Remark: using this solution it's necessary let in GlobalTrigger the FGT_REMOVE_INPUT flag, because if this flag is missing, our "take-off" animation could be replaced by default animation to throw out the torch/knife, since the game command to draw weapon has been left to pass.


Differently, with FGT_REMOVE_INPUT flag, the first draw weapon command has been catched and destroyed by our globaltrigger, and used to put off the knife.


After this operation, player could hit newly the space bar to extract the pistols, and when our custom animation will be completed, the global trigger will be not activared because lara has no more the torch in the hand.


I've not the time to create all this method, anyway I presume it should work.


Sample G - Conditions to test Room Geometry

In G Sample there are a list of Animation commands in diagnostic mode to detect some shapes of room geometry respect to Lara.

Since, many conditions have a clear mean, I'll describe only the most particular environment conditions.


Remark: many of this samples require to have lara still in stand up position and to hit the ACTION (ctrl) key to perform the conditon.


Inner and Outside Corners

In some condition there is the definition of "inner" corner, reduced with "IN_CORNER" or outside corner , reduced in OUT_CORNER.

These condition work about the chance for lara to turn a corner, at her left or right in climb mode or hang mode.
Here there are some image to understand the concept of "inner" or "outside" corners.

G1 - Inner Corner



In above picture you can see what I mean for inner (right) corner.

Animation= -6, KEY1_ACTION, IGNORE, IGNORE, ENV_CLIMB_RIGHT_IN_CORNER, IGNORE, IGNORE, STATE_CLIMB_DOWN, >
STATE_CLIMB_LEFT, STATE_CLIMB_RIGHT, STATE_CLIMB_UP, STATE_CLIMB_START_AND_STANDING

The condition used is ENV_CLIMB_RIGHT_IN_CORNER and it'is true when lara, other to be in climb mode, has an inner climbable wall at right.

You can see the text "Anim=6=YES" to show the position when the condition is true.

If you try to move lara at left you'll see the diagnostic change in "Anim-6=no" because lara will be too far from inner right corner.


Anyway you can also change the DistanceForEnv field to increase the acceptable distance from right wall.


The default value (used if you type IGNORE in DistanceForEnv) is 140. If you type a bigger value the condition will be true also when Lara is more far from right wall.


G2 - Outside Corner



In above picture you can see an outside corner.

Animation= -7, KEY1_ACTION, IGNORE, IGNORE, ENV_CLIMB_LEFT_OUT_CORNER, IGNORE,IGNORE, STATE_CLIMB_DOWN, >
STATE_CLIMB_LEFT, STATE_CLIMB_RIGHT, STATE_CLIMB_UP, STATE_CLIMB_START_AND_STANDING

The condition used is ENV_CLIMB_LEFT_OUT_CORNER, set in Animation= -7 script command.

You can see the diagnostic mexage "Anim-7=YES" because Lara is enough close on left outside corner to turn it.


G3 - Height of Monkey Ceiling



The condition ENV_MONKEY_CEILING check for distance of ceiling from lara Y position.

Animation= -8, KEY1_ACTION, IGNORE, IGNORE, ENV_MONKEY_CEILING, $0705, IGNORE,STATE_STOP

This condition is true only when Lara is on monkey sector and the distance in height from ceiling is in range set in DistanceForEnv.

Differently by other env condition, the DistanceForEnv requires two values added whereby a simple formula:


MaxClickHeight * 256 + MinClickHeight

For example in our example we checked for an height enclosed in range 5 (minheight) and 7 (maxheight)

When DistanceForEnv requires a range (like in this case) it's better type the value in hexadecimal format because it's more readable, in fact in hexadecimal the value is $0705 where you can see the Max ("07") and the Min (05) clicks for height distance.

While using decimal format the number should be 1797, more difficultous to understand simply reading it.


Remark:
Please don't confuse you, only in this condition and few other in DistanceForEnv you type a range with clicks values. In the most of ENV conditions the distance will have an absolute value, where one sector = 1024 and a click requires to type 256 in DistanceForEnv.

G4 - An HandHold in Front Wall



The condition used is ENV_SUPPORT_IN_FRONT_WALL to verify if in the wall in front of lara there is an handhold with correct Y distance and with wished height of space.

Animation= -9, KEY1_ACTION, IGNORE, IGNORE, ENV_SUPPORT_IN_FRONT_WALL+ >
ENV_POS_STRIP_1+ENV_POS_HORTOGONAL, $0274, IGNORE, STATE_STOP

In this animation command we have used also the ENV_POS_STRIP_1 flag to require that lara was in forwardest side of sector (strip 1) and the
flag ENV_POS_HORTOGONAL to require lara had correct orientation.

You can try (hitting CTRL) to verify in game when the condition is "no" if you change orientation or side of sector where lara is.


For this condition the DistanceForEnv field is a bit complex becuase it requires three values: the Min height of handhold (lower side), the max acceptable height for handhold (lower side) but also the height of space over the handhold.

If we use this condition only to discover where lara is able to hang, the height of space just to be of one click "1", but if we want create an animation to jump in fast way in an hole over the wall, where lara enters in on all fours position, it should be necessary to have at least 2 clicks of height for the space.

In above Animation command I set:

The minimum Y distance for lower side : 4 clicks
The maximum Y distance for lower side: 7 clicks
The minimum height for space over the handhold: 2 clicks

The formula to compact these three values in DistanceForEnv field is:

MinLowerSize + MaxLowerSide * 16 + HeightSpace * 256

Also in this case it's more easy understand this number in hexadecimal formato: it becomes $0274

Remark:
If you want use this condition to verify when lara has over her an hole in the wall, while she is climbing this wall, the values to type in DistanceForEnv could be different since the Y pivot of lara is different while she is climbing.

To find the correct values in situation like this, the diagnostic mode is very useful: you type an animation command like above (but you have to change the "2" at end because the climbing state id are differents), and then you move lara up and down to see when the conditon is true (YES). Then you can underatand the better values and change the script command until you find the exact distance values to use.


G5 - Lara monkey has over her a climb wall



Above picture show the positive esite for ENV_HOLE_IN_FRONT_CEILING_CLIMB condition

Animation= -10, KEY1_ACTION, IGNORE, IGNORE, ENV_HOLE_IN_FRONT_CEILING_CLIMB + >
ENV_POS_STRIP_1+ENV_POS_HORTOGONAL, IGNORE, IGNORE, >
STATE_MONKEY_STILL_OR_HANG_SWING

I used also the ENV_POS_STRIP_1 flag to have lara on border and the ENV_POS_HORTOGONAL flag to have her parallel to border.

G6 - Lara monkey has over and back her a climb wall



Above picture show the positive esite for ENV_HOLE_BACK_CEILING_CLIMB condition.

Animation= -11, KEY1_ACTION, IGNORE, IGNORE, ENV_HOLE_BACK_CEILING_CLIMB + >
ENV_POS_STRIP_3+ENV_POS_HORTOGONAL, IGNORE, IGNORE, >
STATE_MONKEY_STILL_OR_HANG_SWING

Please, note that in above Animation command I used the ENV_POS_STRIP_3 instead of ENV_POS_STRIP_1, because lara has to have at her back the climb wall so to have her close on border I had to use ENV_POS_STRIP_3.

G7 - Lara hanged on height wall



Above picture shows the positive esite for ENV_HANG_WITH_FEET condition.

Animation= -12, KEY1_ACTION, IGNORE, IGNORE, ENV_HANG_WITH_FEET, $250, IGNORE, STATE_HANG, >
STATE_HANG_LEFT, STATE_HANG_RIGHT

This condition could be used to permit a custom animation to jump in fast way over the upper floor. If lara is able to place her feet on the wall she could to push to jump over the up floor, while if she is swinging she will be not able to do.



While in this other picture the condition is false because the feet are over the wall and they point in the empty.

Really above images are not very clear, anyways if you play in that room you can see how the condition becomes YES or NO in according with height of wall where lara is hanged.

Last edited by AkyV; 22-10-17 at 12:24.
AkyV is online now  
Old 01-09-15, 11:36   #4
AkyV
Moderator
 
Join Date: Dec 2011
Location: Hungary
Posts: 2,505
Default

Trouble shooting

You could type an Animation command with correct ENV condition to start your custom animation but it didn't performe in the wished way.

This situation could happen for different reasons: a wrong state id set in you custom animation in Animation Editor program, a missing FAN_ flags to prepare the execution of the animation or some collision problem.

In this chapter I'll try to give some suggestion about most common problems.

Issue about State IDs

In some circumstances you could have some trouble to perform your animation because of a wrong state-id set in your animation
.
For each State-Id number there is a different portion of code performed in tomb4 engine.

If you choose a wrong state id, this code could disturb or forbid your animation, pheraps because it could violate some physics rule.

The most common problems

In according with trouble type, we could find a correct solution.
We presume you set the correct ENV_ conditions and (further) TestPosition command, and they works fine.

So, the problem should be while the custom animation should be performed.

You could have the following problems:
  • In a jump animation, Lara is not able to cling to climb walls or wall edges.
    This happens when you forgot to use in Animation command the FAN flag FAN_SET_FREE_HANDS or FAN_SET_FREE_HANDS_TEMP.
    You can solve the problem also typing an animcommand directly in your animation: the [Command3].
    The [Command3] is the animcommand to free the hands of lara.
    If lara holds somewhat, weapons or also a vehicle or a climb wall, an handhold on the edge ect., she is not able to cling to other surface.
    When you perfom a "free hands" command, you say to engine: "I know that lara a moment ago was climing/hanging a wall, but now, with this my animation, she has newly the free hands"
    This command don't remove really the hand's meshes, but simply it assigns to lara the skill to cling newly to somewhat.
  • The custom animation starts but immediatly it has been interrupted by other default animation.
    This is the most command situation where the problem is own the state-id.
    You should try to type in State-Id field of Animation Editor, another state-id for your custom animation.
    You can try with state-id 69: full neutral.
    It doesn't disturb your custom animation, but neither it helps her in any way.
    To use this neutral state id you can also use simply the FAN flag named: FAN_SET_NEUTRAL_STATE_ID in Animation command.
    This method works for "static" animations, i.e. animations where lara move her arms or hands, but she reamins in same position of the level.
    When your animation moves lara, jumping, falling or running, this method cann't work fine, at least to use a (standard) SetPosition animCommand to perform the translation (moving of lara position) of Lara in the animation and at end force the new target coordinates with setposition command.
    If you need to have some help from State id procedures, you can use the state id 89.
    It performs some default computes to manage lara, set byself the "free hands" command, and change the camera mode to watch lara.

    Anoter chance is to use the state id 95 or 96, to have default collision and basic management but with very little bans.

    As last chance you could select an effective well-known state id, choosing it in according with your custom animation.
    For example if your animation perform a jump, you could use your custom animation only for begin of jump, while for jumping phase you could use a stateid specific for jumps, like:

    25 STATE_BACK_JUMP
    3 STATE_FORWARD_JUMP
    27 STATE_LEFT_JUMP
    28 STATE_UP_JUMP

    Ect.
    While if your animation is swimming underwater, you could try to set as state id a compatible state id, like:

    17 STATE_SWIM

    Use [Find] button in Reference panel to find fastly the wished state id. For example for state ids with jumps, you can perform a search with search mask "state jump", or read the State IDs List at bottom of this tutorial.
  • In a jump or falling animation, lara remain still in midair.
    Probably you need to set the FAN flag.
    FAN_ENABLE_GRAVITY in Animation command, to enable the compute for gravity simulation and intertial horizzontal movement.
    If neither with this flag you solve the problem, then it's a state id issue, too.
    Try to use a state id about jump or falling.
  • Lara performs correctly your custom animation, but at end, she comes back to starting position.
    You created an animation where Lara move herself in the space with translation but you forgot to add a SetPosition command to update her position in game.

    You can create a static animation, where lara move her legs but she is alwsys in same point of Animation Editor. Then you type a value in [Speed] field of Animation Editor, or you choose a state id for your animation where the engine will move lara for you.

    Differently, another method, it's when you move really the dummy of Lara in the animation editor, in this case you translated her position, and to have a correct execution in game, you have to type a standard animcommand for this animation: you type a (standard) SetPosition command, to move the position of lara from its starting position to final position.
    For example if lara in your animation move her for a single sector in forward direction, the setposition command should be:
    SetPosition [0] [0] [1024]
    And you should read above values in this way:
    At end of animation the origin of lara has to be changed from current position (because lara in the reality had not been moved during your animation but only her meshes had been) to a new position adding to her origin: +0 to X Pivot, +0 to Y pivot and +1024 (one sector forward) to Z pivot.
    I.e. the syntax is:

    Set Position [+x] [+y] [+z]

    Or, said in extended mode:

    Set Position [+Right/-Left displacemente] [-Up/+down displacement] [+Forward/-backward displacement]

    Give a look to standard animation 42 of lara. It's when she move up a block. You can see the to move up her [-768] (the negative Y move up), and move a bit forward her [128].
  • At end of your animation the position of Lara is correct but her facing is wrong.
    This happen when your animation should translate the position of lara but also it tries to change her orientaton (facing). I.e. when she in animation rotate herself to look in other diredtion.
    In this case the problem is a missing of SetPosition command: it doesn't permit to change the facing of lara.
    For this reason I added a new flipeffect to change the facing of lara and you should add this ng animcommand to your custom animation.
    The flipeffect is:

    "AnimCommand. Turn (facing) current object of <&>degrees in (E)way"

    You set above flipeffect in Set Trigger window, and the click on [Export AnimCommand].
    Type the SetPosition values in your animation and save newly the wad.
  • I typed the SetPosition for translation and another for turning of facing but yet somewhat doesn't work.
    This situation could happen when lara was in hang position at start of your custom animation.
    For technical reason it's possible that the engine store yet the original position of lara (at start of your animation) and then, at end, it restores it newly.
    To solve this problem you should add another ng animcommand to your animation:

    "AnimCommand. Update also original Lara position. (after a SetPosition)"

    Export in it as AnimCommand, and type the data in your custom animation.
  • All works fine except the starting or ending of animation where lara has a rough movement.
    This happen when the starting or ending frame of your animation are not compatible with previous or following default animation of lara.

    To solve the problem you should try to reach this target in your animation:
    The first frame of your animarion should have lara in (almost) same position of last frame of previous animation, from what your animation will be started.
    The last frame of your animation should have lara in same position of first frame of next animation, that will be peformed at end of your custom animation and you type in NextAnim field of Animation Editor.

    You should open two instances of WadMerger/Animation editor program, and , while with first Animation editor you build your animation, with other Animation editor you should look the frame of some standard animation that will be used first or after your custom animation to normalize the start and final frame with it.
  • My animation is performed only once while it should be performed continuosly or vice versa.
    This problem regards the loop (or less) mode of your animation.
    Some animations have been created to work in loop mode, i.e. until player hits some key lara will perform continuosly that animation.
    For example the running animation is a looped mode animation.
    Differently other animation work in single-shot mode, like the animation to throw out a flare or to engages a switch.
    Technically the loop or singleshot mode are set from NextAnimation field in AnimationEditor (if nextanim is the same number of current animation it should be a looped animation), and from state id procedure that manages this animation.

    About state id it's important the value of NextStateId for lara.
    You cann't set the next state it in animation editor but you can change it dynamically using an exported flipeffect like:

    "Lara. (Animation) Force <&>StateID and (E)next StateID for Lara"

    or using some FAN flag in Animation script command to force a wished state id or next state id:

    FAN_SET_NEUTRAL_STATE_ID (if you don't want that engine disturbes your animation) But this regard the current state id and you can get same target type the wished value in StateId field in Animation Editor

    FAN_KEEP_NEXT_STATEID (if you want that your custom animation was performed only once and then lara comes back to her original animation and state id.)

    Remark: if you omit to use FAN_KEEP_NEXT_STATEID the next state id used by lara will be the same you placed in State-Id field of Animation editor for your custom animation.
    Differently, if you use FAN_KEEP_NEXT_STATEID flag, the next state id will be the same foreseen for animation played before starting your custom animation.

    If you use FAN_KEEP_NEXT_STATEID in a continuos animation (where NextAnim is the same of current animation) you should add also some Change State id value in your custom animation, using the animation editor.
    A "Change State Id" is a record with values like these:

    [StateId] [LowFrame] [HighFrame] [Next Anim] [NextFrame]

    The engine when it finds a "Change state id" record in your animation, it uses it in following way:

    * Check if the NextStateId of Lara is the same of [StateId] field of "Change State id" record
    * If it is the same, it checks if current frame number of current animation is enclosed in frame range [LowFrame] - [HighRange]
    *If the frame is in the range, the engine will perform the animation [Next Anim] of "Change State Id" record, and this nex anim animation will be started from [Next Frame] frame. Usually it should be 0 (the first frame) but it could be happen that the first frame is different and own to use a more alike frame from previous animation and this [Next Anim] animation.

    If you set the FAN_KEEP_NEXT_STATEID and your custom animation start when lara was in StateId = 2 i.e. STATE_STOP, you should type your record using as [StateId] the value 2, because it will be "2" in NextStateId field of lara while your custom animation was performing, then you should set other value to call in correct frame [Low] - [High] a new animation [NextAnim] to start from [NextFrame] frame where lara moves from the current frame of your custom animation until to reach the to stop stand up position, typical of StateId= 2 STATE_STOP.
    You can add more "Change State id" record in your animation, to permits in different frame range or for different nextstateid values to pass to other default animations.
State IDs List

This is the full list of state id in default tomb4 exe of The Last Revelation

Remarks:

* The Management procedure is the code used to filter the input game command and to apply many changes of states or animations in according with what lara is doing, and what there is around her (the environment around her).

* The CollisionProcedure theorically should check only for collisions to apply when lara is in that StateId, anyway in many circustances the most of computes happen own in collision procedure.

* The NULL value are missing procedure, pratically the engine doesn't do anything of particular to support that state id type.

* The LARA DEFAULT COL is the default collision procedure. It doesn't perform special checks but only the default verifications to avoid that lara enters in the walls, floors or ceilings.

* The CONTROLLED procedure, verify if lara is performing some specific hardcoded animation and executes furtherly extra operations in according with animation number

* CONTROLLED LET procedure, works like above "COONTROLLED" procedure but in this case it seems works with animation where lara will be translated in other position (with SetPosition standard animcommand).
There are two CONTROLLED LET state id: 95 (with a limited check for collisions) and 96 with no check for collisions.

* SPECIAL procedure forces only a new camera mode, looking lara from a different position or distance.

* COMPRESS it is simply the preparation phase of some jumps, where lara compress her like a spring and then jump in some direction.

StateId ManagementProcedure CollisionProcedure
----------------------------------------------------------------
0 ($00) : WALK COLLISION WALK
1 ($01) : RUN COLLISION RUN
2 ($02) : STOP COLLISION STOP
3 ($03) : FORWARD JUMP COLLISION FORWARD JUMP
4 ($04) : NULL COLLISION FAST TURN
5 ($05) : FAST BACK COLLISION FAST BACK
6 ($06) : TURN RIGHT COLLISION TURN RIGHT
7 ($07) : TURN LEFT COLLISION TURN LEFT
8 ($08) : DEATH COLLISION DEATH
9 ($09) : FAST FALL COLLISION FAST FALL
10 ($0A) : HANG COLLISION HANG
11 ($0B) : REACH COLLISION REACH
12 ($0C) : SPLAT COLLISION SPLAT
13 ($0D) : TREAD COLLISION TREAD
14 ($0E) : NULL COLLISION FAST TURN
15 ($0F) : COMPRESS COLLISION COMPRESS
16 ($10) : BACK COLLISION BACK
17 ($11) : SWIM COLLISION SWIM
18 ($12) : GLIDE COLLISION GLIDE
19 ($13) : NULL COLLISION NULL
20 ($14) : FAST TURN COLLISION FAST TURN
21 ($15) : STEP RIGHT COLLISION STEP RIGHT
22 ($16) : STEP LEFT COLLISION STEP LEFT
23 ($17) : NULL COLLISION ROLL2
24 ($18) : SLIDE COLLISION SLIDE
25 ($19) : BACK JUMP COLLISION BACK JUMP
26 ($1A) : RIGHT JUMP COLLISION RIGHT JUMP
27 ($1B) : LEFT JUMP COLLISION LEFT JUMP
28 ($1C) : UP JUMP COLLISION UP JUMP
29 ($1D) : FALL BACK COLLISION FALL BACK
30 ($1E) : HANG LEFT COLLISION HANG LEFT
31 ($1F) : HANG RIGHT COLLISION HANG RIGHT
32 ($20) : SLIDE BACK COLLISION SLIDE BACK
33 ($21) : SURF TREAD COLLISION SURF TREAD
34 ($22) : SURF SWIM COLLISION SURF SWIM
35 ($23) : DIVE COLLISION DIVE
36 ($24) : PUSH BLOCK COLLISION NULL
37 ($25) : PULL BLOCK COLLISION NULL
38 ($26) : PUSH PULL READY COLLISION NULL
39 ($27) : PICK UP COLLISION NULL
40 ($28) : SWITCH ON COLLISION NULL
41 ($29) : SWITCH ON COLLISION NULL
42 ($2A) : USE KEY COLLISION NULL
43 ($2B) : USE PUZZLE COLLISION NULL
44 ($2C) : UNDERWATER DEATH COLLISION UNDERWATER DEATH
45 ($2D) : NULL COLLISION ROLL
46 ($2E) : SPECIAL NULL
47 ($2F) : SURF BACK COLLISION SURF BACK
48 ($30) : SURF LEFT COLLISION SURF LEFT
49 ($31) : SURF RIGHT COLLISION SURF RIGHT
50 ($32) : NULL NULL
51 ($33) : NULL NULL
52 ($34) : SWAN DIVE COLLISION SWAN DIVE
53 ($35) : FAST DIVE COLLISION FAST DIVE
54 ($36) : NULL COLLISION NULL
55 ($37) : WATER OUT COLLISION NULL
56 ($38) : CLIMB START_AND_STANDING COLLISION CLIMB START AND STANDING
57 ($39) : CLIMB UP COLLISION CLIMB UP
58 ($3A) : CLIMB LEFT COLLISION CLIMB LEFT
59 ($3B) : CLIMB END NULL
60 ($3C) : CLIMB RIGHT COLLISION CLIMB RIGHT
61 ($3D) : CLIMB DOWN COLLISION CLIMB DOWN
62 ($3E) : NULL NULL
63 ($3F) : NULL NULL
64 ($40) : NULL NULL
65 ($41) : WADE COLLISION WADE
66 ($42) : WATER ROLL COLLISION WATER ROLL
67 ($43) : PICK UP FLARE COLLISION NULL
68 ($44) : NULL NULL
69 ($45) : NULL NULL
70 ($46) : DEATH SLIDE NULL
71 ($47) : DUCK COLLISION DUCK
72 ($48) : DUCK COLLISION DUCK
73 ($49) : DASH COLLISION DASH
74 ($4A) : DASH DIVE COLLISION DASH DIVE
75 ($4B) : MONKEY_STILL_OR_HANG_SWING COLLISION MONKEY_STILL_OR_HANG_SWING
76 ($4C) : MONKEY SWING COLLISION MONKEY SWING
77 ($4D) : MONKEY LEFT COLLISION MONKEY LEFT
78 ($4E) : MONKEY RIGHT COLLISION MONKEY RIGHT
79 ($4F) : MONKEY 180 COLLISION MONKEY 180
80 ($50) : ON ALL FOURS STANDING COLLISION ON ALL FOURS STANDING
81 ($51) : ON ALL FOURS FORWARD COLLISION ON ALL FOURS FORWARD
82 ($52) : HANG TURN LEFT COLLISION HANG TURN LEFT RIGHT
83 ($53) : HANG TURN RIGHT COLLISION HANG TURN LEFT RIGHT
84 ($54) : ON ALL FOURS TURN LEFT COLLISION ON ALL FOURS TURN LEFT RIGHT
85 ($55) : ON ALL FOURS TURN RIGHT COLLISION ON ALL FOURS TURN LEFT RIGHT
86 ($56) : ON ALL FOURS BACK COLLISION ON ALL FOURS TURN LEFT RIGHT BACK
87 ($57) : NULL NULL
88 ($58) : NULL COLLISION ON ALL FOURS TURN LEFT RIGHT TO HANG
89 ($59) : CONTROLLED LARA DEFAULT COL
90 ($5A) : ROPE LEFT NULL
91 ($5B) : ROPE RIGHT NULL
92 ($5C) : CONTROLLED LARA DEFAULT COL
93 ($5D) : CONTROLLED NULL
94 ($5E) : CONTROLLED NULL
95 ($5F) : CONTROLLED LET COLLISION TURN SWITCH
96 ($60) : CONTROLLED LET NULL
97 ($61) : CONTROLLED NULL
98 ($62) : PICK UP COLLISION NULL
99 ($63) : NULL COLLISION POLE STATIC
100 ($64) : NULL COLLISION POLE UP
101 ($65) : NULL COLLISION POLE DOWN
102 ($66) : POLE LEFT NULL
103 ($67) : POLE RIGHT NULL
104 ($68) : PULLEY LARA DEFAULT COL
105 ($69) : DUCK LEFT COLLISION DUCK LEFT RIGHT
106 ($6A) : DUCK RIGHT COLLISION DUCK LEFT RIGHT
107 ($6B) : EXTERNAL CORNER LEFT LARA DEFAULT COL
108 ($6C) : EXTERNAL CORNER RIGHT LARA DEFAULT COL
109 ($6D) : INTERNAL CORNER LEFT LARA DEFAULT COL
110 ($6E) : INTERNAL CORNER RIGHT LARA DEFAULT COL
111 ($6F) : ROPE COLLISION ROPE
112 ($70) : ROPE CLIMB UP NULL
113 ($71) : ROPE CLIMB DOWN NULL
114 ($72) : ROPE COLLISION ROPE FORWARD
115 ($73) : ROPE COLLISION ROPE FORWARD
116 ($74) : NULL NULL
117 ($75) : CONTROLLED NULL
----------------------------------------------------------------

Last edited by AkyV; 02-09-15 at 09:04.
AkyV is online now  
Closed Thread

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 22:01.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.