Difference between revisions of "Save pickup"

From GTAMods Wiki
Jump to navigation Jump to search
(Created page with 'This is a code snippet for a save pickup in Sanny Builder's format for Vice City and San Andreas. The code is based on the save pickups in Vice City. <source lang="s…')
 
(rewritten)
Line 1: Line 1:
This is a code snippet for a save pickup in [[Sanny Builder]]'s format for [[Vice City]] and [[San Andreas]]. The code is based on the save pickups in Vice City.
+
This is a code snippet for a '''save pickup''' in [[Sanny Builder]]'s format for [[Vice City]] and [[San Andreas]]. The code is based on the save pickup script in Vice City.
  
<source lang="scm" line>
+
{{Pre|class=sb-code|1=
:PSAVEX
+
<span class="k">const</span>
03A4: name_thread 'PSAVEX'
+
PICKUP_1_X = <span class="m">0.0</span>  <span class="c1">// set your pickup x position</span>
0007: 0@ = 0.0 // x coord pickup
+
PICKUP_1_Y = <span class="m">0.0</span>  <span class="c1">// set your pickup y position</span>
0007: 1@ = 0.0 // y coord pickup
+
PICKUP_1_Z = <span class="m">0.0</span>  <span class="c1">// set your pickup z position</span>
0007: 2@ = 0.0 // z coord pickup
+
SET_PLAYER_1_X = <span class="m">0.0</span>  <span class="c1">// set your player x position</span>
0007: 3@ = 0.0 // put player x coord
+
SET_PLAYER_1_Y = <span class="m">0.0</span>  <span class="c1">// set your player y position</span>
0007: 4@ = 0.0 // put player y coord
+
SET_PLAYER_1_Z = <span class="m">0.0</span>  <span class="c1">// set your player z position</span>
0007: 5@ = 0.0 // put player z coord
+
SET_PLAYER_1_ANGLE = <span class="m">0.0</span>  <span class="c1">// set your player angle</span>
0007: 6@ = 0.0 // put player angle
+
PICKUP_1 = <span class="nv">0@</span>
 +
PICKUP_1_CREATED = <span class="nv">1@</span>
 +
<span class="k">end</span>
  
:PSAVEX_80
+
PICKUP_1_CREATED = <span class="k">false</span>
0001: wait 250 ms
+
<span class="k">while</span> <span class="k">true</span>
00D6: if  
+
    <span class="k">wait</span> <span class="m">250</span>
0256:  player $PLAYER_CHAR defined  
+
    <span class="k">if</span>
004D: jump_if_false @PSAVEX_462
+
        [[0256]]:  player <span class="nv">$PLAYER_CHAR</span> defined
00D6: if  
+
    <span class="k">then</span>
03EE:  player $PLAYER_CHAR controllable  
+
        <span class="k">if</span>
004D: jump_if_false @PSAVEX_462
+
            [[03EE]]:  player <span class="nv">$PLAYER_CHAR</span> controllable
00D6: if  
+
        <span class="k">then</span>
0038:  $ONMISSION == 0  
+
            <span class="k">if</span>
004D: jump_if_false @PSAVEX_432
+
                <span class="nv">$ONMISSION</span> == <span class="m">0</span>
00D6: if  
+
            <span class="k">then</span>
00398@ == 0
+
                <span class="k">if</span>
004D: jump_if_false @PSAVEX_178
+
                    PICKUP_1_CREATED == <span class="k">false</span>
0213: 7@ = create_pickup #PICKUPSAVE type 3 at 0@ 1@ 2@
+
                <span class="k">then</span>
0006: 8@ = 1
+
                    [[0213]]: PICKUP_1 = create_pickup <span class="nt">#PICKUPSAVE</span> type <span class="m">3</span> at PICKUP_1_X PICKUP_1_Y PICKUP_1_Z
 +
                    PICKUP_1_CREATED = <span class="k">true</span>
 +
                <span class="k">end</span>
 +
                <span class="k">if</span>
 +
                    0214:   pickup PICKUP_1 picked_up
 +
                <span class="k">then</span>
 +
                    <span class="k">gosub</span> <span class="nl">@SAVE_BEGIN</span>
 +
                    <span class="k">if</span>
 +
                        [[0256]]player <span class="nv">$PLAYER_CHAR</span> defined
 +
                    <span class="k">then</span>
 +
                        0215: destroy_pickup PICKUP_1
 +
                        [[0213]]: PICKUP_1 = create_pickup <span class="nt">#PICKUPSAVE</span> type <span class="m">3</span> at PICKUP_1_X PICKUP_1_Y PICKUP_1_Z
 +
                        [[016A]]: <span class="k">fade</span> <span class="m">1</span> <span class="m">1000</span> ms
 +
                        0395: clear_area <span class="m">1</span> at SET_PLAYER_1_X SET_PLAYER_1_Y SET_PLAYER_1_Z radius <span class="m">1.0</span>
 +
                        [[00A1]]: put_actor <span class="nv">$PLAYER_ACTOR</span> at SET_PLAYER_1_X SET_PLAYER_1_Y SET_PLAYER_1_Z
 +
                        [[0173]]: set_actor <span class="nv">$PLAYER_ACTOR</span> z_angle_to SET_PLAYER_1_ANGLE
 +
                    <span class="k">end</span>
 +
                    <span class="k">gosub</span> <span class="nl">@SAVE_END</span>
 +
                <span class="k">end</span>
 +
            <span class="k">else</span>
 +
                <span class="k">if</span>
 +
                    PICKUP_1_CREATED == <span class="k">true</span>
 +
                <span class="k">then</span>
 +
                    0215: destroy_pickup PICKUP_1
 +
                    PICKUP_1_CREATED = <span class="k">false</span>
 +
                <span class="k">end</span>
 +
            <span class="k">end</span>
 +
        <span class="k">end</span>
 +
    <span class="k">end</span>
 +
<span class="k">end</span>
  
:PSAVEX_178
+
<span class="nl">:SAVE_BEGIN</span>
00D6: if
+
<span class="nv">$ONMISSION</span> = <span class="m">1</span>
0214:  pickup 7@ picked_up
+
[[01B4]]: set_player <span class="nv">$PLAYER_CHAR</span> frozen_state <span class="m">0</span>
004D: jump_if_false @PSAVEX_425
+
03D8: show_save_screen
0004: $ONMISSION = 1  
+
<span class="k">wait</span> <span class="m">0</span>
01B4: set_player $PLAYER_CHAR frozen_state 0  
+
<span class="k">while</span> <span class="k">if</span> 83D9:   <span class="k">not</span> save_done
03D8: show_save_screen  
+
    <span class="k">wait</span> <span class="m">0</span>
0001: wait 0 ms  
+
<span class="k">end</span>
 +
[[0169]]: set_fade_color <span class="m">0</span> <span class="m">0</span> <span class="m">0</span>
 +
[[016A]]: <span class="k">fade</span> <span class="m">0</span> <span class="m">1000</span> ms
 +
<span class="k">if</span>
 +
    [[0256]]:  player <span class="nv">$PLAYER_CHAR</span> defined
 +
<span class="k">then</span>
 +
    0222: set_player <span class="nv">$PLAYER_CHAR</span> health_to <span class="m">200</span>
 +
    [[01B4]]: set_player <span class="nv">$PLAYER_CHAR</span> frozen_state <span class="m">0</span>
 +
<span class="k">end</span>
 +
<span class="k">return</span>
  
:PSAVEX_214
+
<span class="nl">:SAVE_END</span>
00D6: if
+
<span class="k">if</span>
83D9:  not save_done
+
    [[0256]]:  player <span class="nv">$PLAYER_CHAR</span> defined
004D: jump_if_false @PSAVEX_238
+
<span class="k">then</span>
0001: wait 0 ms
+
    02EB: restore_camera_with_jumpcut
0002: jump @PSAVEX_214
+
    0373: set_camera_directly_behind_player
 
+
<span class="k">end</span>
:PSAVEX_238
+
<span class="k">wait</span> <span class="m">500</span>
0169: set_fade_color 0 0 0
+
<span class="k">if</span>
016A: fade 0 1000 ms
+
    [[0256]]:  player <span class="nv">$PLAYER_CHAR</span> defined
00D6: if  
+
<span class="k">then</span>
0256:  player $PLAYER_CHAR defined  
+
    [[01B4]]: set_player <span class="nv">$PLAYER_CHAR</span> frozen_state <span class="m">1</span>
004D: jump_if_false @PSAVEX_284
+
    <span class="nv">$ONMISSION</span> = <span class="m">0</span>
0222: set_player $PLAYER_CHAR health_to 200
+
<span class="k">end</span>
01B4: set_player $PLAYER_CHAR frozen_state 0
+
<span class="k">return</span>
 
+
}}
:PSAVEX_284
+
If you want to add this code into the [[main.scm]], read the tutorial on [[Create a script|how to create a script]].
00D6: if
 
0256:  player $PLAYER_CHAR defined
 
004D: jump_if_false @PSAVEX_370
 
0215: destroy_pickup 7@
 
0213: 7@ = create_pickup #PICKUPSAVE type 3 at 0@ 1@ 2@
 
016A: fade 1 1000 ms
 
0395: clear_area 1 at 3@ 4@ 5@ radius 1.0
 
00A1: put_actor $PLAYER_ACTOR at 3@ 4@ 5@
 
0173: set_actor $PLAYER_ACTOR z_angle_to 6@
 
 
 
:PSAVEX_370
 
00D6: if
 
0256:  player $PLAYER_CHAR defined
 
004D: jump_if_false @PSAVEX_390
 
02EB: restore_camera_with_jumpcut  
 
0373: set_camera_directly_behind_player  
 
 
 
:PSAVEX_390
 
0001: wait 500 ms
 
00D6: if  
 
0256:  player $PLAYER_CHAR defined  
 
004D: jump_if_false @PSAVEX_425
 
01B4: set_player $PLAYER_CHAR frozen_state 1  
 
0004: $ONMISSION = 0  
 
 
 
:PSAVEX_425
 
0002: jump @PSAVEX_462
 
 
 
:PSAVEX_432
 
00D6: if
 
0039:  8@ == 1
 
004D: jump_if_false @PSAVEX_462
 
0215: destroy_pickup 7@
 
0006: 8@ = 0
 
 
 
:PSAVEX_462
 
0002: jump @PSAVEX_80
 
</source>
 
  
 
[[Category:Code Snippets]]
 
[[Category:Code Snippets]]

Revision as of 01:14, 5 December 2016

This is a code snippet for a save pickup in Sanny Builder's format for Vice City and San Andreas. The code is based on the save pickup script in Vice City.

const
PICKUP_1_X = 0.0  // set your pickup x position
PICKUP_1_Y = 0.0  // set your pickup y position
PICKUP_1_Z = 0.0  // set your pickup z position
SET_PLAYER_1_X = 0.0  // set your player x position
SET_PLAYER_1_Y = 0.0  // set your player y position
SET_PLAYER_1_Z = 0.0  // set your player z position
SET_PLAYER_1_ANGLE = 0.0  // set your player angle
PICKUP_1 = 0@
PICKUP_1_CREATED = 1@
end

PICKUP_1_CREATED = false
while true
    wait 250
    if
        0256:   player $PLAYER_CHAR defined
    then
        if
            03EE:   player $PLAYER_CHAR controllable
        then
            if
                $ONMISSION == 0
            then
                if
                    PICKUP_1_CREATED == false
                then
                    0213: PICKUP_1 = create_pickup #PICKUPSAVE type 3 at PICKUP_1_X PICKUP_1_Y PICKUP_1_Z
                    PICKUP_1_CREATED = true
                end
                if
                    0214:   pickup PICKUP_1 picked_up
                then
                    gosub @SAVE_BEGIN
                    if
                        0256:   player $PLAYER_CHAR defined
                    then
                        0215: destroy_pickup PICKUP_1
                        0213: PICKUP_1 = create_pickup #PICKUPSAVE type 3 at PICKUP_1_X PICKUP_1_Y PICKUP_1_Z
                        016A: fade 1 1000 ms
                        0395: clear_area 1 at SET_PLAYER_1_X SET_PLAYER_1_Y SET_PLAYER_1_Z radius 1.0
                        00A1: put_actor $PLAYER_ACTOR at SET_PLAYER_1_X SET_PLAYER_1_Y SET_PLAYER_1_Z
                        0173: set_actor $PLAYER_ACTOR z_angle_to SET_PLAYER_1_ANGLE
                    end
                    gosub @SAVE_END
                end
            else
                if
                    PICKUP_1_CREATED == true
                then
                    0215: destroy_pickup PICKUP_1
                    PICKUP_1_CREATED = false
                end
            end
        end
    end
end

:SAVE_BEGIN
$ONMISSION = 1
01B4: set_player $PLAYER_CHAR frozen_state 0
03D8: show_save_screen
wait 0
while if 83D9:   not save_done
    wait 0
end
0169: set_fade_color 0 0 0
016A: fade 0 1000 ms
if
    0256:   player $PLAYER_CHAR defined
then
    0222: set_player $PLAYER_CHAR health_to 200
    01B4: set_player $PLAYER_CHAR frozen_state 0
end
return

:SAVE_END
if
    0256:   player $PLAYER_CHAR defined
then
    02EB: restore_camera_with_jumpcut
    0373: set_camera_directly_behind_player
end
wait 500
if
    0256:   player $PLAYER_CHAR defined
then
    01B4: set_player $PLAYER_CHAR frozen_state 1
    $ONMISSION = 0
end
return

If you want to add this code into the main.scm, read the tutorial on how to create a script.