Car Drive Tutorial
| QUOTE (markbaker @ Aug 26 2009, 12:36) |
Great Tutorial!
I have a couple simple questions - how can I spawn a vehicle & have it drive forward on it's own, either in a straight line or along a specified path? Also, is it possible to spawn a vehicle that has peds driving/riding in it? |
Ok, lets start with the base: "how can I spawn a vehicle" and use the exemple script of
tutorial theme: Scripting/Writing a Thread -- Next Step/ Spawn a 3D model
Script below spawns the car Infernus in Grovestreet if player goes into red marker(sphere)
If player leave the spot the car will be released from script and the reading process jumps back into 1.Loop
| CODE |
{$CLEO .cs} :3dModels_1 03A4: name_thread 'MODL'
:3dModels_2 0001: wait 0 ms 00D6: if 0 0256: player $PLAYER_CHAR defined 004D: jump_if_false @3dModels_2 00D6: if 0 00FF: actor $PLAYER_ACTOR 1 (in-sphere)near_point_on_foot 2491.5 -1667.5 13.35 radius 1.0 1.0 1.0 004D: jump_if_false @3dModels_2
0247: request_model #INFERNUS
:Load_Model_Check 0001: wait 0 ms 00D6: if 0 0248: model #INFERNUS available 004D: jump_if_false @Load_Model_Check
00A5: 1@ = create_car #INFERNUS at 2487.5 -1660.5 13.35 0175: set_car 1@ z_angle_to 90.0 0249: release_model #INFERNUS
:3dModels_3 0001: wait 0 ms 00D6: if 0 0256: player $PLAYER_CHAR defined 004D: jump_if_false @3dModels_3 00D6: if 0 80FF: NOT actor $PLAYER_ACTOR 0 ()near_point_on_foot 2491.5 -1667.5 13.35 radius 2.0 2.0 2.0 004D: jump_if_false @3dModels_3 01C3: remove_references_to_car 1@ // Like turning a car into any random car 0002: jump @3dModels_2 |
In the next step I spawn 2 actors in the car and let the car drive to a fix coord destination
fourthermore I add an marker to can see on radar where the car is.
To spawn the actor directly in the car I use opcode 0129: for the driver and 01C8: for the passenger.
It's also possible to spawn the actors by normal placement and let then the actors enter the car. Either as driver or as passenger, also with different opcodes.
The passenger opcodes needs to set the seat number in the last parameter:
0 = front passenger seat, 1 or 2 for the back seats
To let the car drive I use a simple "drive_to opcode"
There are a lot of other variation to let a car drive and it requires allways to set the speed.
The Loop after the "drive-to commands" needs now conditions which belongs to the car drive action
Very important is to check if the car is wrecked.
We need one or more ways to let the script refresh, I mean to release the car, it's marker and the actors from our script in some cases to can beginn the script from beginning.
Such situations can be if player dies or gets arrested, if the car is wrecked or if it is far away
if or
0119: car 1@ wrecked
01F4: car 1@ flipped
8202: not actor $PLAYER_ACTOR near_car 1@ radius 500.0 500.0 flag 0
Script below spawns the car Infernus in Grovestreet with two homies inthere,
if player goes into red marker(sphere)
It drives to the next crossroad and stays there till player is far away from car (500.0 units)
| CODE |
{$CLEO .cs} :CarDrive_1 03A4: name_thread 'CDRIVE'
:CarDrive_2 0001: wait 0 ms if 0256: player $PLAYER_CHAR defined 004D: jump_if_false @CarDrive_2 if 00FF: actor $PLAYER_ACTOR 1 (in-sphere)near_point_on_foot 2491.5 -1667.5 13.35 radius 1.0 1.0 1.0 004D: jump_if_false @CarDrive_2
0247: request_model #INFERNUS 0247: request_model #fam1 0247: request_model #fam2
:CarDrive_3 0001: wait 0 ms if and 0248: model #INFERNUS available 0248: model #fam1 available 0248: model #fam2 available 004D: jump_if_false @CarDrive_3
00A5: 1@ = create_car #INFERNUS at 2487.5 -1660.5 13.35 0175: set_car 1@ z_angle_to 90.0 0129: 2@ = create_actor 8 #fam1 in_car 1@ driverseat 01C8: 3@ = create_actor 8 #fam2 in_car 1@ passenger_seat 0 0186: 4@ = create_marker_above_car 1@ 07E0: set_marker 4@ type_to 1
0249: release_model #INFERNUS 0249: release_model #fam1 0249: release_model #fam2
//////////////////// the drive-to commands --vv----
00A7: car 1@ drive_to 2353.1528 -1658.6493 13.3846//---simple drive-to command 00AD: set_car 1@ max_speed_to 20.0//---speed declaration, important!! 00AE: unknown_set_car 1@ to_ignore_traffic_lights 2//--optional, sets car to ignore red-lights and drive around traffic
//////////////////// the drive-to commands --^^----
:CarDrive_13 0001: wait 0 ms if 0256: player $PLAYER_CHAR defined 004D: jump_if_false @CarDrive_13 if or 0119: car 1@ wrecked 01F4: car 1@ flipped 8202: not actor $PLAYER_ACTOR near_car 1@ radius 500.0 500.0 flag 0 004D: jump_if_false @CarDrive_13 01C3: remove_references_to_car 1@ // Like turning a car into any random car 01C2: remove_references_to_actor 2@ // Like turning an actor into a random pedestrian 01C2: remove_references_to_actor 3@ // Like turning an actor into a random pedestrian 0164: disable_marker 4@ 0002: jump @CarDrive_2 |
As I said, there are a lot of other variation to let a car drive. The opcode 00A7: of the exemple above is the simpliest.
The car drive then
strictly along the gta paths. The paths are stored in the nodes.dat in gta3.img
These paths are the routes for the random cars in traffic.
If you place a car in an area without path like in middle of the desert and let then the car drive, it drives first to the path
and then to the destination.
The car can not reach the destination if the destination is not on a path.
A car drive script can be a very annoying work, also if the destinations are on paths.
It often won't drive that route which we want or it stucks.
----------------------------------------------------------------------------
We have several opcodes to force the car to let it do what we want
----------------------------------------------------------------------------
opcode 04e0: let the car ingnore the paths and let it drive straight ahead to the destination
04e0: car 1@ abandon_path_radius 200
replace the script part with the drive-to commands of script above with this drive-to commands:| CODE |
//////////////////// the drive-to commands --vv----
00A7: car 1@ drive_to 2431.5864 -1628.0818 13.698//---simple drive-to command 00AD: set_car 1@ max_speed_to 20.0//---speed declaration, important!! 00AE: unknown_set_car 1@ to_ignore_traffic_lights 2//--optional, sets car to ignore red-lights and drive around traffic 04e0: car 1@ abandon_path_radius 200
//////////////////// the drive-to commands --^^---- |
the destination is between the highway and grovestreet at that empty area
without 04e0: the car drives a long way on the street
opcode 04e0: works only in the given radius,
it means: by radius 200 the startpoint and the next destination may not be bigger than 200 units
more than 250 is not possible
----------------------------------------------------------------------------
the car chases the player with opcode 00AF: and 2 as last parameter
| CODE |
//////////////////// the drive-to commands --vv----
00AD: set_car 1@ max_speed_to 20.0//---speed declaration, important!! 00AE: unknown_set_car 1@ to_ignore_traffic_lights 2//--optional, sets car to ignore red-lights and drive around traffic 00AF: set_car 1@ driver_behaviour_to 2//-- 2 as last param let chase the player
//////////////////// the drive-to commands --^^---- |
four valid settings for opcode 00AF:
1 - follow road, drive back if way is blocked
2 - kill the player
4 - drive to player and stop
8 - ignore road-paths
----------------------------------------------------------------------------
the car drives automaticly along the paths with opcode 00AF: and 1 as last parameter
| CODE |
//////////////////// the drive-to commands --vv----
00AD: set_car 1@ max_speed_to 20.0//---speed declaration, important!! 00AE: unknown_set_car 1@ to_ignore_traffic_lights 2//--optional, sets car to ignore red-lights and drive around traffic 00AF: set_car 1@ driver_behaviour_to 1
//////////////////// the drive-to commands --^^---- |
----------------------------------------------------------------------------
We can use an opcode to read the coords infront of the car and let it drive to that point
| CODE |
//////////////////// the drive-to commands --vv----
0407: create_coordinate 11@ 12@ 13@ from_car 1@ offset -10.0 15.0 0.0 00A7: car 1@ drive_to 11@ 12@ 13@//---simple drive-to command 00AD: set_car 1@ max_speed_to 20.0//---speed declaration, important!! 00AE: unknown_set_car 1@ to_ignore_traffic_lights 2//--optional, sets car to ignore red-lights and drive around traffic
//////////////////// the drive-to commands --^^---- |
----------------------------------------------------------------------------
We can use an opcode to read the coords infront of the car and let it drive to that point
and give it a start boost with opcode 04BA:
| CODE |
//////////////////// the drive-to commands --vv----
0407: create_coordinate 11@ 12@ 13@ from_car 1@ offset -10.0 15.0 0.0 00A7: car 1@ drive_to 11@ 12@ 13@//---simple drive-to command 00AD: set_car 1@ max_speed_to 20.0//---speed declaration, important!! 00AE: unknown_set_car 1@ to_ignore_traffic_lights 2//--optional, sets car to ignore red-lights and drive around traffic 04BA: set_car 1@ speed_instantly 50.0
//////////////////// the drive-to commands --^^---- |
----------------------------------------------------------------------------
Let the driver do correctionsR* use in the main.scm a stuck car check, but this function don't work in Cleo
But to let the driver do corrections can be used opcode 06C7:
| CODE |
//////////////////// the drive-to commands --vv----
06C7: AS_actor 2@ driver_of_car 1@ perform_action 14 timelimit 3000 //backward circle 00A7: car 1@ drive_to 2353.1528 -1658.6493 13.3846//---simple drive-to command 00AD: set_car 1@ max_speed_to 20.0//---speed declaration, important!! 00AE: unknown_set_car 1@ to_ignore_traffic_lights 2//--optional, sets car to ignore red-lights and drive around traffic
//////////////////// the drive-to commands --^^---- |
the driver make first a backward circle for ca. 3 seconds, then the car drives to the given point
----------------------------------------------------------------------------
some different versions of opcode 06C7:
| CODE |
06C7: AS_actor 2@ driver_of_car 1@ perform_action 6 timelimit 1000 //a short stop 06C7: AS_actor 2@ driver_of_car 1@ perform_action 6 timelimit 2000000 //a long stop 06C7: AS_actor 2@ driver_of_car 1@ perform_action 3 timelimit 3000 //backwards to the right side, than straight ahead 06C7: AS_actor 2@ driver_of_car 1@ perform_action 22 timelimit 3000 //backwards to the left side, than straight ahead 06C7: AS_actor 2@ driver_of_car 1@ perform_action 14 timelimit 3000 //backward circle 06C7: AS_actor 2@ driver_of_car 1@ perform_action 9 timelimit 3000 //bump forward 06C7: AS_actor 2@ driver_of_car 1@ perform_action 7 timelimit 3000 //steer left 06C7: AS_actor 2@ driver_of_car 1@ perform_action 8 timelimit 3000 //steer right |
----------------------------------------------------------------------------
Let the driver driveOpcode 05D1: let the driver drive instead to let the car drive
This function can also ignore the paths (like using 04e0: car 1@ abandon_path_radius)
and let the driver drive the car directly to the given point
It's depending from the setting in the flags
0 0 5 let it drive on paths
2 0 5 ignore the paths
| CODE |
//////////////////// the drive-to commands --vv----
05D1: AS_actor 2@ drive_car 1@ to 2353.1528 -1658.6493 13.384 speed 20.0 0 0 5
//////////////////// the drive-to commands --^^---- |
----------------------------------------------------------------------------
Opcode 05D1: can be set more times as combo in an AS_Pack
It needs than to set -1 instead the variable name of the driver
and assign the actor 2@ after the AS_pack-setup to the defined AS_pack
| CODE |
//////////////////// the drive-to commands --vv----
0615: define_action_sequences 5@ 05D1: AS_actor -1 drive_car 1@ to 2353.1528 -1658.6493 13.384 speed 20.0 0 0 5 05D1: AS_actor -1 drive_car 1@ to 2431.7739 -1674.7444 13.6643 speed 20.0 0 0 5 05D1: AS_actor -1 drive_car 1@ to 2431.5864 -1628.0818 13.698 speed 20.0 2 0 5 0616: define_action_sequences_end 5@ 0618: assign_actor 2@ to_action_sequences 5@ 061B: remove_references_to_AS_pack 5@
//////////////////// the drive-to commands --^^---- |
----------------------------------------------------------------------------
Define a scmpath for the driverSet first opcode 05D6: to clear first a possibly created previous scmpath
Than set new coords for the scmpath and use opcode 07E7: to let the driver drive along this path
This function can also ignore the paths (like using 04e0: car 1@ abandon_path_radius)
and let the driver drive the car directly to the given point
It's depending from the setting in the flags
0 0 5 let it drive on paths
2 0 5 ignore the paths
| CODE |
//////////////////// the drive-to commands --vv----
05D6: clear_scmpath 05D7: add_point_to_scmpath 2353.1528 -1658.6493 13.384 05D7: add_point_to_scmpath 2431.7739 -1674.7444 13.6643 07E7: AS_assign_scmpath_to_actor 2@ in_car 1@ speed 20.0 flags 0 0 5
//////////////////// the drive-to commands --^^---- |
----------------------------------------------------------------------------
Car drive scripts in praxis----------------------------------------------------------------------------
In praxis to write a car drive script with a longer specific route needs a more complex script,
which checks if the car reached the destination to can submit the new destination.
Because you can not check the same destination coords which you want to submit when the car reached it,
you must use
access checksFourthermore it needs to check if the car do airborns because it looses the coord information
and we must give this information again in this case
A check if the car is fliped or wrecked makes allways sense, because it can not continue the route and the script should cancel the action in this case
R* use in the main.scm a stuck car check, but this function don't work in Cleo
a check if the car speed is smaller than 1.0 can help
----------------------------------------------------------------------------
The SF-Airport Circle version 1
The script below teleport the player to the SF airport on a motorbike and spawns an opponent driver on motorbike who drives around the airort building.
Go outside to the exterior map and press Backspace then follow the opponent driver to see what he do
Opcode 00A7: car 1@ drive_to is used and 04e0: car 1@ abandon_path_radius
The driver falls from bike sometimes and enters again his ride to continue the drive
Alternativ you can activte the opcode 08C6:
| CODE |
| //08C6: set_actor 9@ stay_on_bike 1 |
To refresh the script needs to leave the aiport, you must have a distance of 700.0 units to the startpoint
| CODE |
{$CLEO .cs} :Drive_1 03A4: name_thread 'DRIV'
:Drive_3 0001: wait 0 ms if 0256: player $PLAYER_CHAR defined jf @Drive_3 077E: 0@ = active_interior if and 0039: 0@ == 0 // integer values 0AB0: key_pressed 8//----------------------------------------Backspace jf @Drive_3 016A: fade 0 () 250 ms 0001: wait 250 ms 01B4: set_player $PLAYER_CHAR frozen_state 0 (frozen) 0362: remove_actor $PLAYER_ACTOR from_car_and_place_at -1338.5 -408.1 14.1 0173: set_actor $PLAYER_ACTOR z_angle_to 90.8 0001: wait 500 ms 0247: request_model #NRG500 0247: request_model #MAFFA
:Drive_5 0001: wait 0 ms if and 0248: model #NRG500 available 0248: model #MAFFA available jf @Drive_5 00A5: 1@ = create_car #NRG500 at -1333.5 -408.1 14.1 0175: set_car 1@ z_angle_to 280.0 0224: set_car 1@ health_to 2000 00A5: 7@ = create_car #NRG500 at -1354.5 -419.1 14.1 0175: set_car 7@ z_angle_to 280.0 0224: set_car 7@ health_to 2000 020A: set_car 7@ door_status_to 4 02AC: set_car 7@ immunities 1 1 1 1 1 01EC: make_car 7@ very_heavy 1 0129: 9@ = create_actor 24 #MAFFA in_car 7@ driverseat 0223: set_actor 9@ health_to 3000 04E4: unknown_refresh_game_renderer_at -1333.5 -408.1 03CB: set_camera -1333.5 -408.1 14.1 029B: 23@ = init_object 1655 at -1576.02 -202.34 13.76 0177: set_object 23@ z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 23@ 0382: set_object 23@ collision_detection 1 029B: 24@ = init_object 1655 at -1597.9 -506.5 21.7 0177: set_object 24@ z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 24@ 0382: set_object 24@ collision_detection 1 029B: 25@ = init_object 1655 at -1375.9 -581.5 13.69 0177: set_object 25@ z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 25@ 0382: set_object 25@ collision_detection 1 029B: 26@ = init_object 1655 at -1374.9 -585.5 13.69 0177: set_object 26@ z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 26@
0382: set_object 26@ collision_detection 1 0177: set_object 23@ z_angle_to 135.0 0177: set_object 24@ z_angle_to 225.0 0177: set_object 25@ z_angle_to 280.0 0177: set_object 26@ z_angle_to 280.0 0186: 29@ = create_marker_above_car 7@ 07E0: set_marker 29@ type_to 1
0249: release_model #NRG500 0249: release_model #MAFFA 04e0: car 7@ abandon_path_radius 200 00AD: set_car 7@ max_speed_to 100.0 04BA: set_car 7@ speed_instantly 30.0 00AF: set_car 7@ driver_behaviour_to 1 00AE: unknown_set_car 7@ to_ignore_traffic_lights 2 0001: wait 250 ms 036A: put_actor $PLAYER_ACTOR in_car 1@ 0001: wait 250 ms 016A: fade 1 () 1000 ms 0001: wait 1000 ms 0373: set_camera_directly_behind_player 02EB: restore_camera_with_jumpcut 01B4: set_player $PLAYER_CHAR frozen_state 1 (unfrozen) 0006: 15@ = 0 // integer values 0006: 16@ = 0 // integer values 0006: 20@ = 20000 // floating-point values 0006: 19@ = 0 // integer values 0007: 11@ = -1320.48 // floating-point values 0007: 12@ = -407.1 // floating-point values 0007: 13@ = 13.76 // floating-point values 00A7: car 7@ drive_to 11@ 12@ 13@ 00AD: set_car 7@ max_speed_to 1.0 04e0: car 7@ abandon_path_radius 250 //08C6: set_actor 9@ stay_on_bike 1
:Drive_7 0001: wait 0 ms if 0256: player $PLAYER_CHAR defined jf @Drive_7
0050: gosub @Drive_sub_3
if and 8119: NOT car 1@ wrecked 8119: NOT car 7@ wrecked 8118: NOT actor 9@ dead jf @Drive_7 if 00FE: actor $PLAYER_ACTOR 0 ()near_point -1333.5 -408.1 14.1 radius 650.5 650.5 50.5 jf @Drive_12 jump @Drive_7
:Drive_12 0164: disable_marker 29@ 01C3: remove_references_to_car 1@ // Like turning a car into any random car 01C3: remove_references_to_car 7@ // Like turning a car into any random car 01C2: remove_references_to_actor 9@ // Like turning an actor into a random pedestrian 0108: destroy_object 23@ 0108: destroy_object 24@ 0108: destroy_object 25@ 0108: destroy_object 26@ jump @Drive_3
:Drive_sub_3 if 8119: NOT car 7@ wrecked jf @Drive_sub_109 if 00DB: actor 9@ in_car 7@ jf @Drive_sub_99 if 0039: 19@ == 1 // integer values jf @Drive_sub_10 0006: 19@ = 0 // integer values jump @Drive_sub_100
:Drive_sub_10 if 0039: 15@ == 0 // integer values jf @Drive_sub_11 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 5.2 5.2 5.0 jf @Drive_sub_11 0006: 15@ = 1 // integer values 0007: 11@ = -1181.78 // floating-point values 0007: 12@ = -331.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 04e0: car 7@ abandon_path_radius 250 jump @Drive_sub_100
:Drive_sub_11 if 0039: 15@ == 1 // integer values jf @Drive_sub_12 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 15.2 15.2 5.0 jf @Drive_sub_12 00AD: set_car 7@ max_speed_to 10.0 0006: 15@ = 2 // integer values 0007: 11@ = -1282.1 // floating-point values 0007: 12@ = -159.3 // floating-point values 0007: 13@ = 13.76 // floating-point values 0175: set_car 7@ z_angle_to 340.0 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 04e0: car 7@ abandon_path_radius 250 jump @Drive_sub_100
:Drive_sub_12 if 0039: 15@ == 2 // integer values jf @Drive_sub_13 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 15.2 15.2 5.0 jf @Drive_sub_13 00AD: set_car 7@ max_speed_to 25.0 0006: 15@ = 3 // integer values 0007: 11@ = -1498.78 // floating-point values 0007: 12@ = -138.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 0175: set_car 7@ z_angle_to 65.0 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 04e0: car 7@ abandon_path_radius 250 jump @Drive_sub_100
:Drive_sub_13 if 0039: 15@ == 3 // integer values jf @Drive_sub_14 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 8.2 8.2 5.0 jf @Drive_sub_14 00AD: set_car 7@ max_speed_to 25.0 0006: 15@ = 4 // integer values 0007: 11@ = -1576.78 // floating-point values 0007: 12@ = -202.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 0175: set_car 7@ z_angle_to 135.0 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 04e0: car 7@ abandon_path_radius 250 jump @Drive_sub_100
:Drive_sub_14 if 0039: 15@ == 4 // integer values jf @Drive_sub_15 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 5.2 5.2 5.0 jf @Drive_sub_15 0006: 15@ = 5 // integer values 0007: 11@ = -1694.78 // floating-point values 0007: 12@ = -352.30 // floating-point values 0007: 13@ = 13.9 // floating-point values 0175: set_car 7@ z_angle_to 135.0 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 04e0: car 7@ abandon_path_radius 250 jump @Drive_sub_100
:Drive_sub_15 if 0039: 15@ == 5 // integer values jf @Drive_sub_16 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 15.2 15.2 5.0 jf @Drive_sub_16 00AD: set_car 7@ max_speed_to 10.0 0006: 15@ = 6 // integer values 0007: 11@ = -1691.78 // floating-point values 0007: 12@ = -409.30 // floating-point values 0007: 13@ = 13.9 // floating-point values 0175: set_car 7@ z_angle_to 180.0 000A: 16@ += 0 // integer values 0007: 17@ = 40.0 // floating-point values 0007: 18@ = 10.0 // floating-point values 04e0: car 7@ abandon_path_radius 250 00AE: unknown_set_car 7@ to_ignore_traffic_lights 2 jump @Drive_sub_100
:Drive_sub_16 if 0039: 15@ == 6 // integer values jf @Drive_sub_17 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 8.2 8.2 5.0 jf @Drive_sub_17 00AD: set_car 7@ max_speed_to 0.0 0006: 15@ = 7 // integer values 0007: 11@ = -1519.78 // floating-point values 0007: 12@ = -580.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 0175: set_car 7@ z_angle_to 250.0 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 0.0 // floating-point values 04e0: car 7@ abandon_path_radius 250 00AE: unknown_set_car 7@ to_ignore_traffic_lights 2 jump @Drive_sub_100
:Drive_sub_17 if 0039: 15@ == 7 // integer values jf @Drive_sub_18 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 15.2 15.2 5.0 jf @Drive_sub_18 00AD: set_car 7@ max_speed_to 5.0 01EB: set_car_density_to 0.0 0006: 15@ = 8 // integer values 0007: 11@ = -1299.78 // floating-point values 0007: 12@ = -565.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 0175: set_car 7@ z_angle_to 0.0 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 04e0: car 7@ abandon_path_radius 250 jump @Drive_sub_100
:Drive_sub_18 if 0039: 15@ == 8 // integer values jf @Drive_sub_109 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 25.2 25.2 5.0 jf @Drive_sub_109 00AD: set_car 7@ max_speed_to 0.0 0006: 15@ = 1 // integer values 000A: 16@ += 1 // integer values 0007: 11@ = -1181.78 // floating-point values 0007: 12@ = -331.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 0175: set_car 7@ z_angle_to 1.0 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 04e0: car 7@ abandon_path_radius 250 00AE: unknown_set_car 7@ to_ignore_traffic_lights 2
if 0039: 16@ == 2 // integer values jf @Drive_sub_100 00BC: text_highpriority 'BJ_LOSE' 5000 ms 1 jump @Drive_sub_100
:Drive_sub_99 if 0039: 19@ == 0 // integer values jf @Drive_sub_109 00AD: set_car 7@ max_speed_to 0.0 05CB: actor_goto_and_enter_car 9@ 7@ 5000 0006: 19@ = 1 // integer values jump @Drive_sub_109
:Drive_sub_100 00A7: car 7@ drive_to 11@ 12@ 13@ 00AD: set_car 7@ max_speed_to 17@ 03F0: text_draw_toggle 0 0006: 33@ = 0 // integer values jump @Drive_sub_109
:Drive_sub_102 if 01F3: car 7@ airborne jf @Drive_sub_103 0007: 18@ = 0.0 // floating-point values 00A7: car 7@ drive_to 11@ 12@ 13@ 04BA: set_car 7@ speed_instantly 18@ 00AD: set_car 7@ max_speed_to 17@ jump @Drive_sub_103
:Drive_sub_103 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 30.2 30.2 5.0 jf @Drive_sub_104 jump @Drive_sub_105
:Drive_sub_104 02E3: 20@ = car 7@ speed if 81F3: NOT car 7@ airborne jf @Drive_sub_106 if and 0021: 20@ > 30.0 // floating-point values 0019: 33@ > 700 // integer values jf @Drive_sub_105 04BA: set_car 7@ speed_instantly 50.0
:Drive_sub_105 if 0019: 33@ > 2000 // integer values jf @Drive_sub_109
:Drive_sub_106 0006: 33@ = 0 // integer values
:Drive_sub_109 0051: return |
----------------------------------------------------------------------------
The SF-Airport Circle version 2
Same script as above but now opcode 07E7: AS_assign_scmpath_to_actor is used
It teleports the player to the SF airport on a motorbike and spawns an opponent driver on motorbike who drives around the airort building.
Go outside to the exterior map and press Backspace then follow the opponent driver to see what he do
To refresh the script needs to leave the aiport, you must have a distance of 700.0 units to the startpoint
| CODE |
{$CLEO .cs} :scmpath_1 03A4: name_thread 'SCMP'
:scmpath_3 0001: wait 0 ms if 0256: player $PLAYER_CHAR defined jf @scmpath_3 077E: 0@ = active_interior if and 0038: 0@ == 0 // integer values 0AB0: key_pressed 8//----------------------------------------Backspace jf @scmpath_3 016A: fade 0 () 250 ms 0001: wait 250 ms 01B4: set_player $PLAYER_CHAR frozen_state 0 (frozen) 0362: remove_actor $PLAYER_ACTOR from_car_and_place_at -1338.5 -408.1 14.1 0173: set_actor $PLAYER_ACTOR z_angle_to 90.8 0001: wait 500 ms 0247: request_model #NRG500 0247: request_model #MAFFA
:scmpath_5 0001: wait 0 ms if and 0248: model #NRG500 available 0248: model #MAFFA available jf @scmpath_5 00A5: 1@ = create_car #NRG500 at -1333.5 -408.1 14.1 0175: set_car 1@ z_angle_to 280.0 0224: set_car 1@ health_to 2000 00A5: 7@ = create_car #NRG500 at -1354.5 -419.1 14.1 0175: set_car 7@ z_angle_to 280.0 0224: set_car 7@ health_to 2000 020A: set_car 7@ door_status_to 4 02AC: set_car 7@ immunities 1 1 1 1 1 01EC: make_car 7@ very_heavy 1 0129: 9@ = create_actor 24 #MAFFA in_car 7@ driverseat 0223: set_actor 9@ health_to 3000 04E4: unknown_refresh_game_renderer_at -1333.5 -408.1 03CB: set_camera -1333.5 -408.1 14.1 029B: 23@ = init_object 1655 at -1576.02 -202.34 13.76 0177: set_object 23@ z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 23@ 0382: set_object 23@ collision_detection 1 029B: 24@ = init_object 1655 at -1597.9 -506.5 21.7 0177: set_object 24@ z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 24@ 0382: set_object 24@ collision_detection 1 029B: 25@ = init_object 1655 at -1375.9 -581.5 13.69 0177: set_object 25@ z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 25@ 0382: set_object 25@ collision_detection 1 029B: 26@ = init_object 1655 at -1374.9 -585.5 13.69 0177: set_object 26@ z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 26@
0382: set_object 26@ collision_detection 1 0177: set_object 23@ z_angle_to 135.0 0177: set_object 24@ z_angle_to 225.0 0177: set_object 25@ z_angle_to 280.0 0177: set_object 26@ z_angle_to 280.0 0186: 29@ = create_marker_above_car 7@ 07E0: set_marker 29@ type_to 1
0249: release_model #NRG500 0249: release_model #MAFFA 04e0: car 7@ abandon_path_radius 200 00AD: set_car 7@ max_speed_to 100.0 04BA: set_car 7@ speed_instantly 30.0 00AF: set_car 7@ driver_behaviour_to 1 00AE: unknown_set_car 7@ to_ignore_traffic_lights 2 0001: wait 250 ms 036A: put_actor $PLAYER_ACTOR in_car 1@ 0001: wait 250 ms 016A: fade 1 () 1000 ms 0001: wait 1000 ms 0373: set_camera_directly_behind_player 02EB: restore_camera_with_jumpcut 01B4: set_player $PLAYER_CHAR frozen_state 1 (unfrozen) 0006: 15@ = 0 // integer values 0006: 16@ = 0 // integer values 0006: 20@ = 20000 // floating-point values 0006: 19@ = 0 // integer values 0007: 11@ = -1320.48 // floating-point values 0007: 12@ = -407.1 // floating-point values 0007: 13@ = 13.76 // floating-point values 00A7: car 7@ drive_to 11@ 12@ 13@ 00AD: set_car 7@ max_speed_to 1.0 04e0: car 7@ abandon_path_radius 250 08C6: set_actor 9@ stay_on_bike 1
:scmpath_7 0001: wait 0 ms if 0256: player $PLAYER_CHAR defined jf @scmpath_7
0050: gosub @scmpath_sub_3
if and 8119: NOT car 1@ wrecked 8119: NOT car 7@ wrecked 8118: NOT actor 9@ dead jf @scmpath_7 if 00FE: actor $PLAYER_ACTOR 0 ()near_point -1333.5 -408.1 14.1 radius 650.5 650.5 50.5 jf @scmpath_12 jump @scmpath_7
:scmpath_12 0164: disable_marker 29@ 01C3: remove_references_to_car 1@ // Like turning a car into any random car 01C3: remove_references_to_car 7@ // Like turning a car into any random car 01C2: remove_references_to_actor 9@ // Like turning an actor into a random pedestrian 0108: destroy_object 23@ 0108: destroy_object 24@ 0108: destroy_object 25@ 0108: destroy_object 26@ jump @scmpath_3
:scmpath_sub_3 if 8119: NOT car 7@ wrecked jf @scmpath_sub_109 if 00DB: actor 9@ in_car 7@ jf @scmpath_sub_99 if 0039: 19@ == 1 // integer values jf @scmpath_sub_10 0006: 19@ = 0 // integer values jump @scmpath_sub_100
:scmpath_sub_10 if 0039: 15@ == 0 // integer values jf @scmpath_sub_11 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 5.2 5.2 5.0 jf @scmpath_sub_11 0006: 15@ = 1 // integer values 05D6: clear_scmpath 0007: 11@ = -1181.78 // floating-point values 0007: 12@ = -331.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 05D7: add_point_to_scmpath 11@ 12@ 13@ jump @scmpath_sub_100
:scmpath_sub_11 if 0039: 15@ == 1 // integer values jf @scmpath_sub_12 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 15.2 15.2 5.0 jf @scmpath_sub_12 00AD: set_car 7@ max_speed_to 10.0 0006: 15@ = 2 // integer values 05D6: clear_scmpath 0007: 11@ = -1282.1 // floating-point values 0007: 12@ = -159.3 // floating-point values 0007: 13@ = 13.76 // floating-point values 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 05D7: add_point_to_scmpath 11@ 12@ 13@ jump @scmpath_sub_100
:scmpath_sub_12 if 0039: 15@ == 2 // integer values jf @scmpath_sub_13 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 15.2 15.2 5.0 jf @scmpath_sub_13 00AD: set_car 7@ max_speed_to 25.0 0006: 15@ = 3 // integer values 05D6: clear_scmpath 0007: 11@ = -1498.78 // floating-point values 0007: 12@ = -138.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 05D7: add_point_to_scmpath 11@ 12@ 13@ jump @scmpath_sub_100
:scmpath_sub_13 if 0039: 15@ == 3 // integer values jf @scmpath_sub_14 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 8.2 8.2 5.0 jf @scmpath_sub_14 00AD: set_car 7@ max_speed_to 25.0 0006: 15@ = 4 // integer values 05D6: clear_scmpath 0007: 11@ = -1576.78 // floating-point values 0007: 12@ = -202.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 05D7: add_point_to_scmpath 11@ 12@ 13@ jump @scmpath_sub_100
:scmpath_sub_14 if 0039: 15@ == 4 // integer values jf @scmpath_sub_15 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 5.2 5.2 5.0 jf @scmpath_sub_15 0006: 15@ = 5 // integer values 05D6: clear_scmpath 0007: 11@ = -1694.78 // floating-point values 0007: 12@ = -352.30 // floating-point values 0007: 13@ = 13.9 // floating-point values 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 05D7: add_point_to_scmpath 11@ 12@ 13@ jump @scmpath_sub_100
:scmpath_sub_15 if 0039: 15@ == 5 // integer values jf @scmpath_sub_16 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 15.2 15.2 5.0 jf @scmpath_sub_16 00AD: set_car 7@ max_speed_to 10.0 0006: 15@ = 6 // integer values 05D6: clear_scmpath 0007: 11@ = -1691.78 // floating-point values 0007: 12@ = -409.30 // floating-point values 0007: 13@ = 13.9 // floating-point values 000A: 16@ += 0 // integer values 0007: 17@ = 40.0 // floating-point values 0007: 18@ = 10.0 // floating-point values 05D7: add_point_to_scmpath 11@ 12@ 13@ 00AE: unknown_set_car 7@ to_ignore_traffic_lights 2 jump @scmpath_sub_100
:scmpath_sub_16 if 0039: 15@ == 6 // integer values jf @scmpath_sub_17 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 8.2 8.2 5.0 jf @scmpath_sub_17 00AD: set_car 7@ max_speed_to 0.0 0006: 15@ = 7 // integer values 05D6: clear_scmpath 0007: 11@ = -1519.78 // floating-point values 0007: 12@ = -580.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 0.0 // floating-point values 05D7: add_point_to_scmpath 11@ 12@ 13@ 00AE: unknown_set_car 7@ to_ignore_traffic_lights 2 jump @scmpath_sub_100
:scmpath_sub_17 if 0039: 15@ == 7 // integer values jf @scmpath_sub_18 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 15.2 15.2 5.0 jf @scmpath_sub_18 00AD: set_car 7@ max_speed_to 5.0 01EB: set_car_density_to 0.0 0006: 15@ = 8 // integer values 05D6: clear_scmpath 0007: 11@ = -1299.78 // floating-point values 0007: 12@ = -565.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 000A: 16@ += 0 // integer values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 05D7: add_point_to_scmpath 11@ 12@ 13@ jump @scmpath_sub_100
:scmpath_sub_18 if 0039: 15@ == 8 // integer values jf @scmpath_sub_109 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 25.2 25.2 5.0 jf @scmpath_sub_109 00AD: set_car 7@ max_speed_to 0.0 0006: 15@ = 1 // integer values 000A: 16@ += 1 // integer values 05D6: clear_scmpath 0007: 11@ = -1181.78 // floating-point values 0007: 12@ = -331.30 // floating-point values 0007: 13@ = 13.76 // floating-point values 0007: 17@ = 100.0 // floating-point values 0007: 18@ = 20.0 // floating-point values 05D7: add_point_to_scmpath 11@ 12@ 13@
if 0039: 16@ == 2 // integer values jf @scmpath_sub_100 00BC: text_highpriority 'BJ_LOSE' 5000 ms 1 jump @scmpath_sub_100
:scmpath_sub_99 if 0039: 19@ == 0 // integer values jf @scmpath_sub_109 00AD: set_car 7@ max_speed_to 0.0 05CB: actor_goto_and_enter_car 9@ 7@ 5000 0006: 19@ = 1 // integer values jump @scmpath_sub_109
:scmpath_sub_100 07E7: AS_assign_scmpath_to_actor 9@ in_car 7@ speed 17@ flags 2 0 3 03F0: text_draw_toggle 0 0006: 33@ = 0 // integer values jump @scmpath_sub_109
:scmpath_sub_102 if 01F3: car 7@ airborne jf @scmpath_sub_103 0007: 18@ = 0.0 // floating-point values 04BA: set_car 7@ speed_instantly 18@ 07E7: AS_assign_scmpath_to_actor 9@ in_car 7@ speed 17@ flags 2 0 3 jump @scmpath_sub_103
:scmpath_sub_103 if 01AF: car 7@ 0 ()near_point 11@ 12@ 13@ radius 30.2 30.2 5.0 jf @scmpath_sub_104 jump @scmpath_sub_105
:scmpath_sub_104 02E3: 20@ = car 7@ speed if 81F3: NOT car 7@ airborne jf @scmpath_sub_106 if and 0021: 20@ > 30.0 // floating-point values 0019: 33@ > 700 // integer values jf @scmpath_sub_105 04BA: set_car 7@ speed_instantly 50.0
:scmpath_sub_105 if 0019: 33@ > 2000 // integer values jf @scmpath_sub_109
:scmpath_sub_106 0006: 33@ = 0 // integer values
:scmpath_sub_109 0051: return |
This post has been edited by ZAZ on Saturday, Oct 3 2009, 09:38