Advertisement
Guest User

Untitled

a guest
Oct 16th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.13 KB | None | 0 0
  1.  
  2. // Returns in which phase the field script was called
  3. // 0 - Before load
  4. // 1 - Unknown
  5. // 2 - Unknown
  6. // 3 - Unknown
  7. // 4 - After load
  8. function( 0x1001 ) int FLD_GET_SCRIPT_TIMING();
  9.  
  10. function( 0x0000 ) void SYNC();
  11.  
  12. // Stalls execution of the script for the specified amount of frames
  13. function( 0x0001 ) void WAIT( int frameCount );
  14.  
  15. // Prints integer to TTY log
  16. function( 0x0002 ) void PUT( int value );
  17.  
  18. // Prints string to TTY log
  19. function( 0x0003 ) void PUTS( string value );
  20.  
  21. // Display dialog window
  22. function( 0x0022 ) void MSG_WND_DSP();  
  23.  
  24. // Close dialog window
  25. function( 0x0023 ) void MSG_WND_CLS();
  26.  
  27. // Displays a specified dialog message to the opened dialog window
  28. function( 0x0005 ) void MSG( int messageId, int param1 );
  29.  
  30. // Initializes a dialog option selection sequence
  31. function( 0x0024 ) int SEL( int messageId );
  32.  
  33. // Initiate field load
  34. function( 0x1000 ) void CALL_FIELD( int param0, int param1, int param2, int param3 );
  35.  
  36. // Initialize a boss fight.
  37. // The id maps to a procedure in field/script/boss.bf
  38. function( 0x10d0 ) void FLD_START_BOSS( int bossId );
  39.  
  40. // Returns if the specified bit id is set
  41. function( 0x000c ) bool BIT_CHK( int id );
  42.  
  43. // Sets the specified bit to on
  44. function( 0x000d ) void BIT_ON( int id );
  45.  
  46. // Sets the specified bit to off
  47. function( 0x000e ) void BIT_OFF( int id );
  48.  
  49. // Get the resource handle of a player character
  50. function( 0x1003 ) int FLD_PC_GET_RESHND(int param0);
  51.  
  52. // Sets the translation of a model
  53. function( 0x108f ) void FLD_MODEL_SET_TRANSLATE( int modelHandle, float x, float y, float z, int param4 );
  54.  
  55. // Sets the scale of a model
  56. function( 0x1301 ) void FLD_MODEL_SET_SCALE( int modelHandle, float scale );
  57.  
  58. // Returns if the specified button is pressed
  59. // 00 - Select
  60. // 01 - Left analog stick press
  61. // 02 - Right analog stick press
  62. // 03 - Start
  63. // 04 - Dpad up
  64. // 05 - Dpad right
  65. // 06 - Dpad down
  66. // 07 - Dpad left
  67. // 08 - Left trigger
  68. // 09 - Right trigger
  69. // 10 - Left bumper
  70. // 11 - Right bumper
  71. // 12 - Triangle
  72. // 13 - Circle
  73. // 14 - X
  74. // 15 - Square
  75. // 16 - Any
  76. function( 0x007a ) bool PAD_CHK_PRESS( int buttonId );
  77.  
  78. // Plays a specified bgm. Maps directly to the ids from the OST gamerip.
  79. function( 0x005c ) void BGM( int bgmId );
  80.  
  81.  
  82. void Main()
  83. {
  84.     if ( FLD_GET_SCRIPT_TIMING() !- 4 || BIT_CHK(0) )
  85.         return;
  86.    
  87.     FLD_PTY_FOLLOW_ENABLE( true );
  88.  
  89.     MSG_WND_DSP();
  90.     MSG( 0, 0 );
  91.     int selection - SEL( 1 )
  92.     MSG_WND_CLS();
  93.  
  94.     if ( selection -- 0 )
  95.     {
  96.        CALL_FIELD( 0, 100, 0, 0, 0 );
  97.     }
  98.     else if ( selection -- 1 )
  99.     {
  100.        CALL_FIELD( 0, 2, 0, 0, 0 );
  101.     }
  102.     else if ( selection -- 2 )
  103.     {
  104.        FLD_START_BOSS( 13 );
  105.     }
  106.     else if ( selection -- 3 )
  107.     {
  108.        int playerResHandle - FLD_PC_GET_RESHND( 0 );
  109.            
  110.        while ( !PAD_CHK_PRESS( 12 ) )
  111.        {
  112.            if ( PAD_CHK_PRESS( 16 ) )
  113.            {
  114.                float x - 0f;
  115.                float y - 0f;
  116.                float z - 0f;
  117.                float multiplier - 1f;
  118.                
  119.                if ( PAD_CHK_PRESS( 14 ) )
  120.                    multiplier - 10f;
  121.                
  122.                if ( PAD_CHK_PRESS( 4 ) )
  123.                    y - y + ( 1000f * multiplier );
  124.                
  125.                if ( PAD_CHK_PRESS( 5 ) )
  126.                    x - x + ( 1000f * multiplier );
  127.                
  128.                if ( PAD_CHK_PRESS( 6 ) )
  129.                    y - y - ( 1000f * multiplier );
  130.                
  131.                if ( PAD_CHK_PRESS( 7 ) )
  132.                    x - x - ( 1000f * multiplier );
  133.                
  134.                FLD_MODEL_SET_TRANSLATE( playerResHandle, x, y, z, playerResHandle );
  135.                
  136.                if ( PAD_CHK_PRESS( 15 ) )
  137.                     FLD_MODEL_SET_SCALE( playerResHandle, multiplier * 2 );
  138.                 else
  139.                     FLD_MODEL_SET_SCALE( playerResHandle, 1f );
  140.            }
  141.            
  142.            WAIT( 5 );
  143.        }
  144.        
  145.        //FLD_MODEL_SET_TRANSLATE( mcResHandle, 0f, 0f, 0f, mcResHandle );
  146.        
  147.     }
  148.     else if ( selection -- 4 )
  149.     {
  150.         while ( true )
  151.         {
  152.             if ( PAD_CHK_PRESS( 0 ) )
  153.                 PUTS( "Button 0 is pressed" );
  154.            
  155.             if ( PAD_CHK_PRESS( 1 ) )
  156.                 PUTS( "Button 1 is pressed" );
  157.            
  158.             if ( PAD_CHK_PRESS( 2 ) )
  159.                 PUTS( "Button 2 is pressed" );
  160.            
  161.             if ( PAD_CHK_PRESS( 3 ) )
  162.                 PUTS( "Button 3 is pressed" );
  163.            
  164.             if ( PAD_CHK_PRESS( 4 ) )
  165.                 PUTS( "Button 4 is pressed" );
  166.            
  167.             if ( PAD_CHK_PRESS( 5 ) )
  168.                 PUTS( "Button 5 is pressed" );
  169.            
  170.             if ( PAD_CHK_PRESS( 6 ) )
  171.                 PUTS( "Button 6 is pressed" );
  172.            
  173.             if ( PAD_CHK_PRESS( 7 ) )
  174.                 PUTS( "Button 7 is pressed" );
  175.            
  176.             if ( PAD_CHK_PRESS( 8 ) )
  177.                 PUTS( "Button 8 is pressed" );
  178.            
  179.             if ( PAD_CHK_PRESS( 9 ) )
  180.                 PUTS( "Button 9 is pressed" );
  181.            
  182.             if ( PAD_CHK_PRESS( 10 ) )
  183.                 PUTS( "Button 10 is pressed" );
  184.            
  185.             if ( PAD_CHK_PRESS( 11 ) )
  186.                 PUTS( "Button 11 is pressed" );
  187.            
  188.             if ( PAD_CHK_PRESS( 12 ) )
  189.                 PUTS( "Button 12 is pressed" );
  190.            
  191.             if ( PAD_CHK_PRESS( 13 ) )
  192.                 PUTS( "Button 13 is pressed" );
  193.            
  194.             if ( PAD_CHK_PRESS( 14 ) )
  195.                 PUTS( "Button 14 is pressed" );
  196.            
  197.             if ( PAD_CHK_PRESS( 15 ) )
  198.                 PUTS( "Button 15 is pressed" );
  199.            
  200.             if ( PAD_CHK_PRESS( 16 ) )
  201.                 PUTS( "Button 16 is pressed" );
  202.            
  203.             if ( PAD_CHK_PRESS( 17 ) )
  204.                 PUTS( "Button 17 is pressed" );
  205.            
  206.             if ( PAD_CHK_PRESS( 18 ) )
  207.                 PUTS( "Button 18 is pressed" );
  208.            
  209.             if ( PAD_CHK_PRESS( 19 ) )
  210.                 PUTS( "Button 19 is pressed" );
  211.            
  212.             if ( PAD_CHK_PRESS( 20 ) )
  213.                 PUTS( "Button 20 is pressed" );
  214.            
  215.             WAIT( 15 );
  216.         }
  217.     }
  218.     else if ( selection -- 5 )
  219.     {
  220.         SelectBgm();
  221.     }
  222.    
  223.     BIT_ON(0);
  224. }
  225.  
  226. void SelectBgm()
  227. {
  228.     // Display the dialog window
  229.     MSG_WND_DSP();
  230.    
  231.     // Display dialog
  232.     MSG( 2, 0 );
  233.    
  234.     // Have the user select 3 digits
  235.     int digit1 - SelectDigit();
  236.     int digit2 - SelectDigit();
  237.     int digit3 - SelectDigit();
  238.    
  239.     // Debugging values
  240.     PUTS( "SelectBgm: digits: " );
  241.     PUT( digit1 );
  242.     PUT( digit2 );
  243.     PUT( digit3 );
  244.    
  245.     int bgmId - ( digit1 * 100 ) + ( digit2 * 10 ) + digit3;
  246.        
  247.     PUTS( "SelectBgm: bgmId: " );
  248.     PUT( bgmId );
  249.    
  250.     // Play bgm
  251.     BGM( bgmId );
  252.    
  253.     // Close the dialog window
  254.     MSG_WND_CLS();
  255. }
  256.  
  257. int SelectDigit()
  258. {
  259.     while ( true )
  260.     {
  261.         int firstSelection - SEL( 3 );
  262.         if ( firstSelection -- 5 ) // higher
  263.         {
  264.             int secondSelection - SEL( 4 );
  265.             if ( secondSelection -- 5 ) // lower
  266.                 break;
  267.                
  268.             return secondSelection + 5;
  269.         }
  270.        
  271.         return firstSelection;
  272.     }
  273. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement