Difference between revisions of "Save pickup"
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 | + | 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. |
− | < | + | {{Pre|class=sb-code|1= |
− | + | <span class="k">const</span> | |
− | + | PICKUP_1_X = <span class="m">0.0</span> <span class="c1">// set your pickup x position</span> | |
− | + | PICKUP_1_Y = <span class="m">0.0</span> <span class="c1">// set your pickup y position</span> | |
− | + | PICKUP_1_Z = <span class="m">0.0</span> <span class="c1">// set your pickup z position</span> | |
− | + | SET_PLAYER_1_X = <span class="m">0.0</span> <span class="c1">// set your player x position</span> | |
− | + | SET_PLAYER_1_Y = <span class="m">0.0</span> <span class="c1">// set your player y position</span> | |
− | + | SET_PLAYER_1_Z = <span class="m">0.0</span> <span class="c1">// set your player z position</span> | |
− | + | SET_PLAYER_1_ANGLE = <span class="m">0.0</span> <span class="c1">// set your player angle</span> | |
− | + | PICKUP_1 = <span class="nv">0@</span> | |
+ | PICKUP_1_CREATED = <span class="nv">1@</span> | ||
+ | <span class="k">end</span> | ||
− | + | PICKUP_1_CREATED = <span class="k">false</span> | |
− | + | <span class="k">while</span> <span class="k">true</span> | |
− | + | <span class="k">wait</span> <span class="m">250</span> | |
− | 0256: player $PLAYER_CHAR defined | + | <span class="k">if</span> |
− | + | [[0256]]: player <span class="nv">$PLAYER_CHAR</span> defined | |
− | + | <span class="k">then</span> | |
− | 03EE: player $PLAYER_CHAR controllable | + | <span class="k">if</span> |
− | + | [[03EE]]: player <span class="nv">$PLAYER_CHAR</span> controllable | |
− | + | <span class="k">then</span> | |
− | + | <span class="k">if</span> | |
− | + | <span class="nv">$ONMISSION</span> == <span class="m">0</span> | |
− | + | <span class="k">then</span> | |
− | + | <span class="k">if</span> | |
− | + | PICKUP_1_CREATED == <span class="k">false</span> | |
− | 0213: | + | <span class="k">then</span> |
− | + | [[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> | ||
− | : | + | <span class="nl">:SAVE_BEGIN</span> |
− | + | <span class="nv">$ONMISSION</span> = <span class="m">1</span> | |
− | + | [[01B4]]: set_player <span class="nv">$PLAYER_CHAR</span> frozen_state <span class="m">0</span> | |
− | + | 03D8: show_save_screen | |
− | + | <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> |
− | + | <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> | ||
− | : | + | <span class="nl">:SAVE_END</span> |
− | + | <span class="k">if</span> | |
− | + | [[0256]]: player <span class="nv">$PLAYER_CHAR</span> defined | |
− | + | <span class="k">then</span> | |
− | + | 02EB: restore_camera_with_jumpcut | |
− | + | 0373: set_camera_directly_behind_player | |
− | + | <span class="k">end</span> | |
− | + | <span class="k">wait</span> <span class="m">500</span> | |
− | + | <span class="k">if</span> | |
− | + | [[0256]]: player <span class="nv">$PLAYER_CHAR</span> defined | |
− | + | <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> |
− | + | <span class="nv">$ONMISSION</span> = <span class="m">0</span> | |
− | + | <span class="k">end</span> | |
− | + | <span class="k">return</span> | |
− | + | }} | |
− | + | If you want to add this code into the [[main.scm]], read the tutorial on [[Create a script|how to create a script]]. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | 02EB: restore_camera_with_jumpcut | ||
− | 0373: set_camera_directly_behind_player | ||
− | |||
− | |||
− | |||
− | |||
− | 0256: player $PLAYER_CHAR defined | ||
− | |||
− | 01B4: set_player $PLAYER_CHAR frozen_state 1 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | </ | ||
[[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.