000115. Работа с грузовиками и прицепами

Работа с грузовиками и прицепами|Доброго времени суток, уважаемые пользователи сайта RU-SCRIPT.3DN.RU! Мы продолжаем изучать скриптинг GTA SA, и сегодня речь пойдёт о грузовиках и их прицепах.|wmysterio|wmysterio||||Сами прицепы в игре имеют название "trailer", а грузовики, которые могут цеплять прицеп - "cab". Так, как опкодов по ним немного, то я решил сделать Cleo-миссию на тему "Дальнобойщик". Нам дадут прицеп с грузом и нужно его доставить в целостности на маркер. Начнём с опкодов:

0893: put_trailer 0@ on_cab 1@ // Цепляет трейлер 0@ к грузовику 1@
07AC: detach_trailer 0@ from_cab 1@ // Отцепляет трейлер 0@ от грузовика 1@
07AB: trailer 0@ attached_to_cab 1@ // Проверка: "Трейлер 0@ прицеплен к грузовику 1@ ?"

Часто при работе с прицепами задают ему некую раскраску с помощью опкода:

0506: set_vehicle_model #ARTICT1 next_variation 3 3

Два последних параметра должны быть равны, так как большинство машин имеют только 1 вариант изменения ( смотрите Варианты изменения транспорта ). Перейдём к миссии. Напишем простенький стартер:

{$CLEO}
0000:

:STARTER
thread 'STARTER'
wait 0
if
player.Defined($PLAYER_CHAR)
jf @STARTER_END
03A1: show_sphere_at -2031.6582 148.4805 28.8359 radius 1.5

if AND
$ONMISSION == 0
00EC: actor $PLAYER_ACTOR 0 near_point -2031.6582 148.4805 radius 2.0 2.0
not actor.Driving($PLAYER_ACTOR)
then
jump @STARTER_1
end
jump @STARTER

:STARTER_1
wait 0
player.CanMove($PLAYER_CHAR) = false
actor.SetImmunities($PLAYER_ACTOR, 1, 1, 1, 1, 1)
0ACF: show_formatted_styled_text "~y~Run in the Cab" time 5000 style 2
fade 0 1000
wait 1000
0A94: start_custom_mission "TheCab"
wait 1000
jump @STARTER

:STARTER_END
wait 0
0A93: end_custom_thread

Код миссии будет в следующем виде:

{$CLEO .cm}

//------------- TheCab ---------------

:TheCab
thread 'TheCab'
gosub @TheCab_29_57
if
wasted_or_busted
jf @TheCab_29_46
gosub @TheCab_29_144

:TheCab_29_46
$ONMISSION = 0
mission_cleanup
end_thread

:TheCab_29_57
increment_mission_attempts
$ONMISSION = 1
model.Load(#LINERUN)
model.Load(#ARTICT1)
038B: load_requested_models

:TheCab_AA
wait 0
if AND
model.Available(#LINERUN)
model.Available(#ARTICT1)
jf @TheCab_AA
0506: set_vehicle_model #ARTICT1 next_variation 3 3
0@ = car.Create(#ARTICT1, -2039.5044, 136.4451, 28.4465)
car.Angle(0@) = 269.9084
1@ = car.Create(#LINERUN, -2025.8435, 136.9129, 28.4438)
car.Angle(1@) = 271.0394
model.Destroy(#ARTICT1)
model.Destroy(#LINERUN)
072A: put_actor $PLAYER_ACTOR into_car 1@ driverseat
041E: set_radio_station 12
0893: put_trailer 0@ on_cab 1@
camera.Restore_WithJumpCut
Camera.SetBehindPlayer
wait 1000
fade 1 1000
wait 1000
player.CanMove($PLAYER_CHAR) = true
actor.SetImmunities($PLAYER_ACTOR, 0, 0, 0, 0, 0)

:TheCab_BB
wait 0
marker.Disable(4@)
marker.Disable(5@)
018A: 2@ = create_checkpoint_at -2669.6782 1377.9211 8.0797
03BC: 3@ = create_sphere_at -2669.6782 1377.9211 8.0797 radius 2.5
0AD1: show_formatted_text_highpriority "Drive Cab inpoint!" time 4000

:TheCab_BB_1
wait 0
if OR
car.Wrecked(0@)
02BF: car 0@ sunk
car.Wrecked(1@)
02BF: car 1@ sunk
then
jump @TheCab_29_144_CAR_WRECKED
end

if AND
01AE: car 1@ sphere 0 near_point -2669.6782 1377.9211 radius 2.5 2.5 stopped
07AB: trailer 0@ attached_to_cab 1@
then
jump @TheCab_CC
end

if OR
87AB: not trailer 0@ attached_to_cab 1@
not actor.InCar($PLAYER_ACTOR, 1@)
then
jump @TheCab_BB_2
end
jump @TheCab_BB_1

:TheCab_BB_2
wait 0
marker.Disable(2@)
03BD: destroy_sphere 3@
4@ = marker.CreateAboveCar(0@)
5@ = marker.CreateAboveCar(1@)
07E0: set_marker 4@ type_to 1
07E0: set_marker 5@ type_to 1
0AD1: show_formatted_text_highpriority "Enter Cab and attach Trailer!" time 4000

:TheCab_BB_2_1
wait 0
if OR
car.Wrecked(0@)
02BF: car 0@ sunk
car.Wrecked(1@)
02BF: car 1@ sunk
then
jump @TheCab_29_144_CAR_WRECKED
end
if AND
07AB: trailer 0@ attached_to_cab 1@
actor.InCar($PLAYER_ACTOR, 1@) 
then
jump @TheCab_BB
end
jump @TheCab_BB_2_1

:TheCab_CC
wait 0
gosub @TheCab_END
player.Money($PLAYER_CHAR) += 20000
0ACF: show_formatted_styled_text "Mission passed!~n~ ~w~+%d" time 5000 style 1 20000
return

:TheCab_29_144
wait 0
gosub @TheCab_END
0ACF: show_formatted_styled_text "~r~Mission crash!" time 5000 style 1
return

:TheCab_29_144_CAR_WRECKED
wait 0
gosub @TheCab_END
0AD1: show_formatted_text_highpriority "You Cab or Trailer destroyed!" time 4000
0ACF: show_formatted_styled_text "~r~Mission crash!" time 5000 style 1
return

:TheCab_END
wait 0
if
056E: car 1@ defined
then
car.RemoveReferences(1@)
end
if
056E: car 0@ defined
then
car.RemoveReferences(0@)
end
marker.Disable(2@)
03BD: destroy_sphere 3@
marker.Disable(4@)
marker.Disable(5@)
return

Результаты:

Миссия будет считаться проваленной, если трейлер или грузовик упадёт в воду или взорвётся. Маркер будет появляться когда игрок в транспорте и трейлер прицеплен. В противном случаи над субъектами будут созданы соответствующие маркеры.

Вот такая простенькая миссия получилась :) Оставайтесь с нами!|1659|1|0|04397259png600336400224``\|11165286png600337400224``||rabota_s_gruzovikami_i_pricepami|1504504367

Last updated