Marina Carpark mod release 3 ============================ Do-it-yourself kit for ViceBuilderv1.3 ============================ Follow the instructions below to incorporate the marina carpark mod into another scm mod. The labels mentioned in the instruction may differ from yours, due to other mods. There is no garantee that this mod will work properly together with another mod, they may interfere. Good luck, PatrickW ============================ Step 1: increase Memory claim ------------------------- Change the line DEFINE MEMORY 34329 into DEFINE MEMORY 34845 (if the original number is higher, the new number should be increased with the same amount) Step 2: increase object count ----------------------------- Change the line DEFINE OBJECTS 204 into DEFINE OBJECTS 205 (if the original number is higher, the new number should be increased with the same amount) Step 3: Add shark object ------------------------ Add below the line DEFINE OBJECT BOAT_KB2 ; Object number -204 the line DEFINE OBJECT SHARK ; Object number -204 Step 4: change position of asset pickup --------------------------------------- Replace the lines 0005: $252 = 88.5 ;; floating-point values 0005: $253 = -804.7 ;; floating-point values 0005: $254 = 11.2 ;; floating-point values with the lines 0005: $252 = -230.7 ;; floating-point values X Position of Marina Asset Marker 0005: $253 = -1300.8 ;; floating-point values Y Position of Marina Asset Marker 0005: $254 = 8.6 ;; floating-point values Z Position of Marina Asset Marker Step 5: change the price of the asset ------------------------------------- replace the line 0004: $28A = 3000 ;; integer values with the line 0004: $28A = 1000 ;; integer values Price of Marina Step 6: Thread-code for the garage handling ------------------------------------------- find the following line (the label may differ) :Label00B09E 03A4: name_thread "HOT" just before them, the following _long_ code block should be inserted ;======================START OF GARAGE-THREAD============================ ;================================= ;START OF CARPARK CODE ;by Patrick Wildenborg - The Netherlands ;To be used freely with proper credit ;================================= ;v2: unlock spawned cars ;v2: fix secondary colour ;v2: fixed save-point ;v3: remove car references define array $cp_handle 40 integer define array $cp_type 40 integer define array $cp_x 40 integer define array $cp_y 40 integer define array $cp_rz 40 integer :cp_carpark 014C: set_parked_car_generator $79E cars_to_generate_to 0 014C: set_parked_car_generator $79F cars_to_generate_to 0 014C: set_parked_car_generator $7A0 cars_to_generate_to 0 03BA: clear_cars_from_cube -200.0 -1450.0 1.0 -100.0 -1300.0 6.0 029B: $shark = init_object -204 (SHARK) at -208.065 -1391.8 13.5478 0177: set_object $shark z_angle_to 199.0 ;------------------ ; spawn gate thread ;------------------ $cp_cars_ready = 0 004F: create_thread ££cp_gate_thread ;------------------ ; init data-pool ;------------------ $cp_type_index = 0 $cp_type = -1 :cp_init_loop set_array $cp_type $cp_type_index += 1 ;; integer values if 0 $cp_type_index == 40 jump_if_false ££cp_init_loop ;----------------- ; Init status ;----------------- $cp_new_car = -1 $cp_nof_cars = 0 $cp_garage_clear = 1 10@ = 0 ; 1 => inside carpark 11@ = 0 ; 1 => Cars are present 12@ = 0 ; 1 => walking in carpark ;----------------- ; start of loop ;----------------- :cp_carpark_start 0001: wait 250 ms if 0 0256: player $PLAYER_CHAR defined jump_if_false ££cp_carpark_start if 0 0057: player $PLAYER_CHAR 0 ()in_cube -200.0 -1450.0 1.0 -100.0 -1300.0 6.0 jump_if_false ££cp_outside_carpark ;----------------------- ; PLAYER IS IN THE CARPARK ;----------------------- if 0 00E0: player $PLAYER_CHAR driving jump_if_false ££cp_carpark_walking 12@ = 0 ;; We're not walking if 0 10@ == 0 ;; we were outside last time we checked jump_if_false ££cp_carpark_end 10@ = 1 ;; remember that We're now in the carpark ;----------------------- ; ENTERING THE CARPARK IN CAR ;----------------------- $cp_type_index = 0 :cp_find_loop if 0 40 > $cp_type_index jump_if_false ££cp_carpark_full get_array $cp_type if 0 NOT $cp_type == -1 jump_if_false ££cp_carpark_store $cp_type_index += 1 jump ££cp_find_loop :cp_carpark_store 03C1: $cp_handle = player $PLAYER_CHAR car ; Code model, pcolor and scolor onto 1 variable 0441: $cp_type = car $cp_handle model integer 3@ = $cp_type $cp_type *= 65536 integer $cp_handle_index = $cp_type_index 03F3: get car $cp_handle color 1@ 2@ 1@ *= 256 integer $cp_type += 1@ integer $cp_type += 2@ set_array $cp_type set_array $cp_handle integer $cp_new_car = $cp_type_index $cp_nof_cars += 1 jump ££cp_carpark_end ;----------------------- ; PLAYER WALKS IN THE CARPARK ;----------------------- :cp_carpark_walking 10@ = 1 if 0 12@ == 0 jump_if_false ££cp_carpark_end 12@ = 1 if 0 NOT 0 > $cp_new_car jump_if_false ££cp_walk_update ;--------------------- ; CLONE CAR ;--------------------- integer $cp_handle_index = $cp_new_car integer $cp_type_index = $cp_new_car get_array $cp_type get_array $cp_handle $cp_type /= 65536 0247: request_model $cp_type 0407: create_coordinate 1@ 2@ 3@ from_car $cp_handle offset 0.0 0.0 0.0 02CE: 3@ = ground_z 1@ 2@ 3@ 0174: 4@ = car $cp_handle z_angle 03F3: get car $cp_handle color 5@ 6@ 02E3: 7@ = car $cp_handle speed :cp_clone_wait 0001: wait 0 ms if 0 0248: model $cp_type available jump_if_false ££cp_clone_wait integer $old_handle = $cp_handle 00A5: $cp_handle = create_car $cp_type at 1@ 2@ 3@ 0175: set_car $cp_handle z_angle_to 4@ 0229: set car $cp_handle color to 5@ 6@ 04BA: set car $cp_handle speed instantly 7@ 020A: set car $cp_handle door status to 1 01C3: remove references to car $old_handle 00A6: destroy_car $old_handle set_array $cp_handle $cp_new_car = -1 ;-------------------------------------- ; ITERATE ALL SLOTS AND UPDATE POSITION ;-------------------------------------- :cp_walk_update $cp_type_index = 0 :cp_walk_loop if 0 40 > $cp_type_index jump_if_false ££cp_carpark_end get_array $cp_type if 0 NOT $cp_type == -1 jump_if_false ££cp_walk_next ;-------------------------- ; SLOT IS OCCUPIED ;-------------------------- integer $cp_handle_index = $cp_type_index integer $cp_x_index = $cp_type_index integer $cp_y_index = $cp_type_index integer $cp_rz_index = $cp_type_index get_array $cp_handle 00AA: store_car $cp_handle position_to $cp_x $cp_y 3@ 0174: $cp_rz = car $cp_handle z_angle set_array $cp_x set_array $cp_y set_array $cp_rz :cp_walk_next $cp_type_index += 1 0002: jump ££cp_walk_loop ;----------------------- ; PLAYER IS OUTSIDE THE CARPARK ;----------------------- :cp_outside_carpark if 0 10@ == 1 jump_if_false ££cp_carpark_end ;----------------------- ; LEAVING THE CARPARK ;----------------------- 10@ = 0 12@ = 0 $cp_new_car = -1 if 0 00E0: player $PLAYER_CHAR driving jump_if_false ££cp_carpark_end 03C1: $cp_hdl = player $PLAYER_CHAR car $cp_type_index = 0 :cp_leave_loop if 0 40 > $cp_type_index jump_if_false ££cp_carpark_end get_array $cp_type if 0 NOT $cp_type == -1 jump_if_false ££cp_leave_next ;-------------------------- ; SLOT IS OCCUPIED ;-------------------------- integer $cp_handle_index = $cp_type_index get_array $cp_handle if 0 integer $cp_handle == $cp_hdl jump_if_false ££cp_leave_next ;----------------------- ; CAR LEFT ;----------------------- :cp_car_left $cp_type = -1 $cp_nof_cars -= 1 set_array $cp_type 01C3: remove references to car $cp_hdl jump ££cp_carpark_end :cp_leave_next $cp_type_index += 1 jump ££cp_leave_loop ;----------------------- ; ERROR: NO MORE ROOM ; player tricked the gate and deserves to loose the car ;) ;----------------------- :cp_carpark_full ; currently no further action :cp_carpark_end jump ££cp_carpark_gate ;======================== ; CHECK THE NEIGHBORHOOD OF THE GARAGE ; neighborhood is within rectangele belong level z = 9.0 ; => in front of marina ; ; Observation: After 7 or more cars exist that have been created ; with create_car, the game-engine no longer generates ; random traffic. Therefor the "neighborhood" can not be too ; big. ;======================== :cp_carpark_gate if 0 00A3: actor $PLAYER_ACTOR 0 ()in_rectangle -300.0 -1552.0 -100.0 -1310.0 jump_if_false ££cp_carpark_not_near 0054: store_player $PLAYER_CHAR position_to 1@ 2@ 3@ 02CE: 3@ = ground_z 1@ 2@ 3@ if 0 9.0 > 3@ jump_if_false ££cp_carpark_not_near ;-------------------------- ; NEAR GARAGE ;-------------------------- if 0 $cp_cars_ready == 0 jump_if_false ££cp_gate_end ;----------------------- ; CARS ARE NOT YET READY, ; RE-POPULATE GARAGE ;----------------------- $cp_garage_clear = 0 ;---------------- ; load model data ;---------------- 0247: request_model #GDB :cp_wait_for_guardmodel 0001: wait 0 ms if 0 0248: model #GDB available jump_if_false ££cp_wait_for_guardmodel 009A: $cp_guard = create_actor 4 #GDB at -207.4 -1391.788 7.306 022D: set_actor $cp_guard to_look_at_player $PLAYER_CHAR 0173: set_actor $cp_guard z_angle_to 110.0 0372: set actor $cp_guard anim 8 wait state time 60000000 ms $cp_type_index = 0 :cp_recreate_loop get_array $cp_type if 0 NOT $cp_type == -1 jump_if_false ££cp_recreate_next ;-------------------------- ; RECREATE THIS CAR ;-------------------------- ; decode model and colors from type integer $cp_temp = $cp_type $cp_temp /= 65536 integer $cp_model = $cp_temp ;; model 0247: request_model $cp_model $cp_temp *= 65536 integer $cp_type -= $cp_temp integer $cp_temp = $cp_type $cp_temp /= 256 integer $cp_pcol = $cp_temp ;; pcolor $cp_temp *= 256 integer $cp_type -= $cp_temp integer $cp_scol = $cp_type ;; scolor integer $cp_handle_index = $cp_type_index integer $cp_x_index = $cp_type_index integer $cp_y_index = $cp_type_index integer $cp_rz_index = $cp_type_index get_array $cp_x get_array $cp_y get_array $cp_rz :cp_wait_model 0001: wait 0 ms if 0 0248: model $cp_model available jump_if_false ££cp_wait_model $cp_z = 6.5 02CE: $cp_z = ground_z $cp_x $cp_y $cp_z 00A5: $cp_handle = create_car $cp_model at $cp_x $cp_y $cp_z 0175: set_car $cp_handle z_angle_to $cp_rz 0229: set car $cp_handle color to $cp_pcol $cp_scol 020A: set car $cp_handle door status to 1 set_array $cp_handle ;------------------------- ; ITERATE OVER ALL SLOTS ;------------------------- :cp_recreate_next $cp_type_index += 1 if 0 NOT 40 > $cp_type_index jump_if_false ££cp_recreate_loop ;-------------------------- ; GARAGE READY ;-------------------------- :cp_recreate_ready $cp_cars_ready = 1 jump ££cp_gate_end ;-------------------------- ; NOT NEAR GARAGE ;-------------------------- :cp_carpark_not_near if 1 $cp_cars_ready == 1 ;; integer values jump_if_false ££cp_gate_end ;-------------------------- ; PLAYER MOVED FAR AWAY FROM GARAGE, ; CLEAR GARAGE ;-------------------------- $cp_cars_ready = 0 ;-------------------------- ; RELEASE ALL CARS IN GARAGE ;-------------------------- $cp_type_index = 0 :cp_clear_loop 0001: wait 0 ms get_array $cp_type if 0 NOT $cp_type == -1 jump_if_false ££cp_clear_next ;-------------------------- ; RELEASE THIS CAR ;-------------------------- integer $cp_handle_index = $cp_type_index get_array $cp_handle 01C3: remove_references_to_car $cp_handle ;; Like turning a car into any random car ;------------------------- ; ITERATE OVER ALL SLOTS ;------------------------- :cp_clear_next $cp_type_index += 1 ;; integer values if 0 NOT 40 > $cp_type_index ;; integer values jump_if_false ££cp_clear_loop ;-------------------------- ; DELETE ALL CARS IN GARAGE ;-------------------------- :cp_clear_finish 034F: destroy_actor_with_fade $cp_guard ;; The actor fades away like a ghost 03BA: clear_cars_from_cube -200.0 -1450.0 1.0 -100.0 -1300.0 6.0 $cp_garage_clear = 1 :cp_gate_end jump ££cp_carpark_start ;===================================================== ; GATE THREAD ;===================================================== :cp_gate_thread 029B: $gate1 = init_object -33 (ELECTRICGATE) at -204.252 -1400.79 6.73 0177: set_object $gate1 z_angle_to 107.0 029B: $gate2 = init_object -33 (ELECTRICGATE) at -207.482 -1390.36 6.73 0177: set_object $gate2 z_angle_to 107.0 ;----------------------------------------------------- ; GATE THREAD LOOP ;----------------------------------------------------- :cp_gt_start 0001: wait 100 ms ;---------------------------- ; CARPARK GATE 1 ;---------------------------- if 0 00F5: player $PLAYER_CHAR 0 ()near_point -205.96 -1396.38 6.73 radius 7.5 7.5 7.5 jump_if_false ££cp_close_g1 if 21 40 > $cp_nof_cars 80E0: NOT player $PLAYER_CHAR driving jump_if_false ££cp_full_g1 if 0 $cp_cars_ready == 1 jump_if_false ££cp_wait_g1 ;------------- ; OPEN GATE 1 ;------------- 034E: unknown_move_object $gate1 to -202.118 -1407.77 6.73 unknown_angle 0.1 0.327 0.0 0 jump ££cp_gate2 :cp_full_g1 00BC: text highpriority "GA_21" 3000 ms 1 jump ££cp_close_g1 :cp_wait_g1 ; Some text must be found for here: Wait a moment or something ;------------- ; CLOSE GATE 1 ;------------- :cp_close_g1 034E: unknown_move_object $gate1 to -204.252 -1400.79 6.73 unknown_angle 0.1 0.327 0.0 0 ;---------------------------- ; CARPARK GATE 2 ;---------------------------- :cp_gate2 if 0 00F5: player $PLAYER_CHAR 0 ()near_point -208.48 -1387.05 6.73 radius 7.5 7.5 7.5 jump_if_false ££cp_close_g2 if 21 40 > $cp_nof_cars 80E0: NOT player $PLAYER_CHAR driving jump_if_false ££cp_full_g2 if 0 $cp_cars_ready == 1 jump_if_false ££cp_wait_g2 ;------------- ; OPEN GATE 2 ;------------- 034E: unknown_move_object $gate2 to -209.494 -1383.75 6.73 unknown_angle 0.1 0.327 0.0 0 jump ££cp_gt_end :cp_full_g2 00BC: text highpriority "GA_21" 3000 ms 1 jump ££cp_close_g2 :cp_wait_g2 ; Some text must be found for here: Wait a moment or something ;------------- ; CLOSE GATE 2 ;------------- :cp_close_g2 034E: unknown_move_object $gate2 to -207.482 -1390.36 6.73 unknown_angle 0.1 0.327 0.0 0 :cp_gt_end jump ££cp_gt_start ;============================================================================== ; END OF CARPARK CODE ;============================================================================= ;;======================END OF GARAGE-THREAD============================== Step 7 Change zone-check for Save4 thread ========================================= find the line 03A4: name_thread "SAVE4" eight lines down replace the line 0121: player $PLAYER_CHAR in_zone "BEACH2" with the line 0121: player $PLAYER_CHAR in_zone "BEACH1" Step 8 Insert car-cleared waitloop ========================================== seventeen lines down from the last change, just above the line (label may differ) 0050: gosub ££Label012D4C insert the following five lines :wgc_loop 0001: wait 0 ms if 0 $cp_garage_clear == 1 jf ££wgc_loop Step 9 adjust player position after save ========================================== about eight lines down from the last change, replace these three lines 0395: clear_area 1 at 90.781 -806.1213 range 10.3349 1.0 0055: put_player $PLAYER_CHAR at 90.781 -806.1213 10.3349 0171: set_player $PLAYER_CHAR z_angle_to 238.8605 with he following three lines 0395: clear_area 1 at 233.0 -1301.0 range 10.3349 1.0 0055: put_player $PLAYER_CHAR at -233.0 -1301.0 8.1 0171: set_player $PLAYER_CHAR z_angle_to 90.0 Step 10 adjust player position after buy ============================================ find the line 03A4: name_thread "WASHBUY" about 30 lines down from there replace these three lines 0395: clear_area 1 at 90.781 -806.1213 range 10.3349 1.0 0055: put_player $PLAYER_CHAR at 90.781 -806.1213 10.3349 0171: set_player $PLAYER_CHAR z_angle_to 238.8605 with the following three lines 0395: clear_area 1 at 233.0 -1301.0 range 10.3349 1.0 0055: put_player $PLAYER_CHAR at -233.0 -1301.0 8.1 0171: set_player $PLAYER_CHAR z_angle_to 90.0 Step 11 adjust camera position ============================== three lines down from the last change, replace these two lines 015F: set_camera_position 57.5999 -681.8762 10.4095 0.0 0.0 0.0 0160: point_camera 57.8653 -682.802 10.6787 2 with the following two lines 015F: set_camera_position -250.0 -1290.0 7.5 0.0 0.0 0.0 0160: point_camera -233.0 -1310.0 15.6787 2 Step 12 start carpark thread after buying the asset =================================================== about 24lines down from the last change, add just below this line 00BC: text_highpriority "BUYSAVE" 3000 ms 1 ;; ~g~You can now save your game here when not on a mission. the following five lines 004F: create_thread ££cp_carpark 0001: wait 3000 ms 015F: set_camera_position -224.544 -1421.942 18.132 0.0 0.0 0.0 0160: point_camera -214.869 -1389.704 15.132 2 00BC: text_highpriority "BUYGARG" 3000 ms 1 ;; ~g~You can also store vehicles in this garage. Step 13 Fix if statement vicebuilder complains about ==================================================== find the lines (if labels differ, just compile and the error message will lead the way) :Label0F6850 00D6: if 24 and replace this last one with 00D6: if 23 Step 14 Recompile and copy the new scm file to the data di as main.scm ======================================================================