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 09-10-15, 15:19   #1
Titak
Moderator
 
Titak's Avatar
 
Join Date: Jul 2003
Location: Drenthe, The Netherlands
Posts: 29,593
Default TRNG - Quad Bike

TRNG - Quad bike

In TR3 we can drive a couple of quadbikes.
Since the arrival of the TRLE, people have been trying to get the quadbike to work with it.
It works, but there are some flaws due to some hardcoded stuff which is attached to the motorbike slot.

This tutorial shows you how to get rid of the flaws, using some extra animations in both the MOTORBIKE and VEHICLE-EXTRA objects, and some TRNG scripting.
With this, we now have a fully working TR3 Quadbike!!!

All credits for figuring it all out, the scripting and extra animations go to Krystian!


Okay, first we need a quadbike and the corresponding vehicle-extra.
We used the TR3 Lost Artefact Slinc Quadbike, made by EssGee, as a base.
It is used in the MOTORBIKE slot.

As said, it's been modified a bit, so you can download the modified version here:

TRNG-quad.zip


Krystian has now added:
• mounting on the left side
• dismounting to the left
• driving backwards
• steering while driving backwards


The second post in this thread is about adding some additional sounds to the quad.




Mounting on the left side
The motorbike only allows mounting on the right side of the bike, on account of the sidecar being on the left.

To make this possible for the quad, there's TestPosition 1 for the motorbike and you'll notice there is no moveable slot in the testposition, but the index of the motorbike. This is to fix a certain bug in which Lara wouldn't mount the bike on room connections, where Lara and the bike would be in different rooms (this is a limitation of the testposition, which doesn't occur when using a moveable index instead of a slot).
The Animation= script doesn't really perform an animation, but a triggergroup, as indicated by the FAN_PERFORM_TRIGGER_GROUP flag.

TriggerGroup11, performed by the Animation script, does the following. Copy the X, Y, Z position and Horizontal, Vertical, Rotational facing of the motorbike one by one to the Local Long Alpha variable, and paste these values correspondingly to Lara (this avoids a glitch where Lara would momentarilly appear in a different location, it didn't cause serious bugs but it looked ugly, so it's more a matter of aesthetics), after which it gets the index of the found motorbike and passes it into the "current operated vehicle index" memory zone, and finally forces the left mounting anim in the VEHICLE_EXTRA.




Script:
Code:
Animation= 11, KEY1_ACTION, IGNORE, FAN_PERFORM_TRIGGER_GROUP, ENV_MULT_CONDITION, 1, IGNORE, -103, -11, -0, -1

MultEnvCondition= 1, ENV_ITEM_TEST_POSITION, 1, IGNORE, ENV_FREE_HANDS, IGNORE, IGNORE

TestPosition= 1, TPOS_TEST_ITEM_INDEX, Motorbike NGLE index, -396-64, -396, -256, 256, -128, 128, $2000, $6000, -4096, 4096, -4096, 4096

TriggerGroup= 11, $5000 + TGROUP_USE_FOUND_ITEM_INDEX, 1, $36, $2000, 256, $1970, $5000, Lara NGLE index, $36, $2000, 257, $1970, >
$5000 + TGROUP_USE_FOUND_ITEM_INDEX, 1, $36, $2000, 256, $1A70, $5000, Lara NGLE index, $36, $2000, 257, $1A70, >
$5000 + TGROUP_USE_FOUND_ITEM_INDEX, 1, $36, $2000, 256, $1B70, $5000, Lara NGLE index, $36, $2000, 257, $1B70, >
$5000 + TGROUP_USE_FOUND_ITEM_INDEX, 1, $36, $2000, 256, $1C70, $5000, Lara NGLE index, $36, $2000, 257, $1C70, >
$5000 + TGROUP_USE_FOUND_ITEM_INDEX, 1, $36, $2000, 256, $1D70, $5000, Lara NGLE index, $36, $2000, 257, $1D70, >
$5000 + TGROUP_USE_FOUND_ITEM_INDEX, 1, $36, $2000, 256, $1E70, $5000, Lara NGLE index, $36, $2000, 257, $1E70, >
$2000, 244, $FF, $2000, 278, $17, $2000, 77, $2117; set found index as selected item, copy X position to LLA,
;set Lara as selected item, paste X position from Local Long Alpha (LLA) variable, set found item, copy Y position, set Lara, paste Y position,
;set found item, copy Z pos, set Lara, paste Z pos, set found item, copy horizontal facing, set Lara,
;paste facing, set found item, copy vertical facing, set Lara, paste facing, set found item, copy rotation facing,
;set Lara, paste facing, copy index of found item to Current Value, paste Current Value to index of vehicle used by Lara,
;force mounting anim (23) in vehicle_extra

NOTE 1:
Lara NGLE index and Motorbike NGLE index are the indexes of the placed LARA and placed MOTORBIKE in your level.
So go into the editor, find the objects and see which number they have by clicking on them. The ID number is in the yellow box that appears.
Type that number in these fields.

NOTE 2:
If TriggerGroup11 is already used for something else in your level-script, change it and also change it accordingly in the Animation= line, replacing the first 11 with the number your TG11 now has.







Dismounting to the left

The left side dismounting relies on the the "forced state change" trick. In animation 18 ("standing still" animation) there's a state change of stateID 24 to the dismounting animation (animation 24). Normally, if you press the jump and left keys, nothing happens.
But animation 18 now has a little secret. There is a NGLE anim command added to the animation, that plays in each frame. It performs TriggerGroup 10 from the level-script.

It's a bit elaborate, but here's what it basically does. It copies Lara's vertical orientation into the Local Long Alfa variable and compares the absolute value to the number in PARAM_BIG_NUMBERS at index 0 (2650). After that there are two more conditions, that both the left and jump keys are pressed. If all these conditions are met (Lara's orientation is smaller than 2650 and the keys are pressed), a flipeffect sets Lara's "next stateID" to 24. This in turn forces the state change of animation 18 in the vehicle extra, and she dismounts.

Code:
Parameters= PARAM_BIG_NUMBERS, 2650

TriggerGroup= 10, $5000, Lara NGLE index, $36, $2000, 256, $1C70, $8000, 112, $2A, $2000, 284, $70, $8000, 112, $27, >
$8000, 7, $30D, $8000, 2, $30D, $2000, 78, $180F, $8000 + TGROUP_ELSE, 112, $29, $8000, 112, $27, >
$8000, 7, $30D, $8000, 2, $30D, $2000, 78, $180F; set LARA as selected item, copy vertical facing to Local Long Alfa,
;if LLA is < 0, invert sign of LLA (- becomes +), LLA is < than index 0 of PARAM_BIG_NUMBERS, JUMP key is pressed,
;LEFT key is pressed, set next stateID to 24, else if LLA is >= 0, LLA is < than index 0 of PARAM_BIG_NUMBER,
;JUMP key is pressed, LEFT key is pressed, set next stateID to 24
NOTE 1:
Lara NGLE index is the index of the placed LARA and in your level.
So go into the editor, find the object and see which number it has by clicking on it. The ID number is in the yellow box that appears.
Type that number in this field.

NOTE 2 :
If you need to change the ID of TriggerGroup 10 (because there already is a TG10 in your script somewhere else), remember that you also must change this ID in the set position anim command of anim 18 in the VEHICLE_EXTRA. It is the third field of the setposition animcommand.





Driving backwards
There are two additional animations in the vehicle_extra, the first one is a "Lara turns back and starts driving backwards" (the last frame is played in a loop), the second one is "Lara stops and turns forwards". The motorbike itself needs the two correlated animations of the same length, but these are simply the same frame copied over.

It requires no scripting, however the setup is a bit complicated.

As mentioned, it depends on 2 animations in the VEHICLE_EXTRA.
The first animation ("start backing up"), with stateID 3, has a sort of strange construction. The first 10 frames aren't played, it begins from the 11th frame. This is due to a state change in animation 18, (in the original TR4 bike, this used to be the state change to the "push bike backwards" animation).
The purpose of this is the following: animations of stateID 3 have a hardcoded movement at frame 24. Now here comes the part that makes the "driving back" work. There's a state change (of stateID 4) at frames 24-25 of the "backing up" anim that leads back to frame 24 of the same animation. Originally, it used to lead to the "continue pushing back" animation in the TR4 bike, i.e. it occured if the player held the down key pressed. In other words, this state change will endlessly loop back to frame 24 (the moving frame) as long as the down key is held down. If it's released, the animation will change to the "stop driving back" animation, via the "next animation" field.

To change the camera when Lara is driving backwards, a NGLE flipeffect has been added to the backing up animation for a PARAM_SET_CAMERA. It looks back when Lara's backing up

This is the script for the camera, so also paste this into your level-script:
Code:
Parameters= PARAM_SET_CAMERA, 1, IGNORE, IGNORE, -4096, $9800, 12 ;set camera for driving backwards

Steering while driving backwards

Steering while driving backwards is possible, but there's a little bug with it.
The steering is not included in the quad-bike download, but it is easy to add if you want to test it.
I am using the steering despite the bug.
Why? Because I think it is important to be able to steer while backing up. It makes it easier to get out of corners and the bug will not get you stuck permanently.

When the rear-end of the quad is touching the wall while backing up, and you try to steer, it sometimes happens that the bike will nose-dive forward and get stuck briefly. If you stop backing up, the quad can get launched forward at a great speed. This looks odd...
This doesn't occur when steering is not enabled.


(This is the most extreme nosedive I've been able to pull off. It was a lot less in most cases and in less cramped quarters.)

Here's the script :
Code:
TriggerGroup= 12, $8000, 2, $30D, $2000, 277, $17, $2000, 245, $2FF, $2000, 258, $7F1D, $2000, 258, $601D, >
$8000 + TGROUP_ELSE, 3, $30D, $2000, 277, $17, $2000, 245, $2FF, $2000, 256, $1DFF, $2000, 233, $7FFF, >
$2000, 233, $60FF, $2000, 257, $1DFF; if left key is pressed, copy operated vehicle index to CurrentValue,
;set CurrentValue as selected item, add 127 to horizontal facing, add 96 to horizontal facing,
;else if right key is pressed, copy vehicle index to CV, set CV as selected item, copy horizontal facing to CV,
;subtract 127 from CV, subtract 96 from CV, copy CV to horizontal facing
You must also add a setposition to animation 29 (backing up) with the following numbers: -24552, 372, 12.
This is an animcommand flipeffect, performing TriggerGroup 12 at frame 24 of animation 29.

NOTE :
If you need to change the ID of TriggerGroup 12 (because there already is a TG12 in your script somewhere else), remember that you also must change this ID in the set position anim command of anim 29 in the VEHICLE_EXTRA. It is the third field of the setposition animcommand.
__________________
If it walks like a duck and if it quacks like a duck, it is a duck.

Last edited by Titak; 09-10-15 at 15:21.
Titak is offline  
Old 09-10-15, 15:20   #2
Titak
Moderator
 
Titak's Avatar
 
Join Date: Jul 2003
Location: Drenthe, The Netherlands
Posts: 29,593
Default

Additional sounds

I've noticed that there are few sounds assigned to the quad animations.
For example, there are not even footsteps sounds when Lara steps onto the ground when dismounting.
Well, I've added the footsteps sounds to the TRNG-quad.zip, so no worries there, but no other sounds.

You can however add additional sounds to the quad.
So far I have added suspension sounds when Lara mounts and dismounts the quad. They make the quad creak a bit when Lara mounts/dismounts.

You can download the sounds here:

quad-additionalsounds.zip

The sounds are taken from the TRU game and are used for the motorcycle in that game.

Since there are no "motorbike" soundslots for these, I've put them in slots 149 and 151, which are not otherwise used in my level. You can ofcourse put them in other slots if these are already used in your level.

It looks like this in the sounds.txt:
Code:
149 RUMBLE_NEXTDOOR:          quad_susp3                        VOL12                            RAD10  #CM

151 CHAINS_LIBRARY:           quad_susp2                        VOL12                            RAD10  #CM
CM are the letters I'm using for my level, so you should change them to whatever letters your level uses.
(I use TRLE Sound Editor for editing and converting the sounds.txt)
Also make sure that you assign the rest of the motorbike sounds when they are not yet assigned in the sounds.txt.

Next thing to do is to assigned them to the VEHICLE-EXTRA animations, like this:

Code:
Animation 9: Play Sound. Frame 32, Sound:151
Animation 10: Play Sound. Frame 28, Sound: 149 

Animation 23: Play Sound. Frame 32, Sound:151
Animation 24: Play Sound. Frame 28, Sound: 149
NOTE
I've noticed that sometimes the sounds revert back to the ones that were originally assigned to the slots. To fix this, simply reconvert the sounds.txt and replace the .sam and .sfx files again.
__________________
If it walks like a duck and if it quacks like a duck, it is a duck.
Titak is offline  
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 17:49.


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