Advertisement
ZoriaRPG

Zelda 3 Follower v1.0

Apr 10th, 2019
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.83 KB | None | 0 0
  1. import "std.zh"
  2. import "classic.zh"
  3.  
  4. /////////////////////////////
  5. /// Zelda 3 Follower      ///
  6. /// v1.0                  ///
  7. /// 11th April, 2019      ///
  8. /// By: ZoriaRPG          ///
  9. /// Made for: JudasRising ///
  10. /////////////////////////////
  11. // v0.1 : Initial
  12. // v0.2 : Changed hardcoded > 3 frame cap to use FOLLOWER_MAX_FRAME in drawing loops.
  13. // v0.3 : Fix scrolling positions and positions onContinue
  14. // v0.4 : The follower's tile is now set by the combo of the ffc 'GetZelda'. (It's combo tile, -4.)
  15. //      : Added the ability for the follower to play a message, and give an item to Link, when Link
  16. //      : delivers them to their destination.
  17. //  : Added the ability to show a message when you collect the npc.
  18. // v0.5 : The follower CSet is now set by the ffc when you collect him.
  19. // v0.6 : Renamed scripts and functions, and moved global functions into local functions of ffc script Follower.
  20. // v0.7 : Moved array to be script-namespace local to ffc Follower. Used for 2.55.
  21. //      : You could use this in 2.53, but it needs the included Init script to work, as it will have bugs
  22. //      : (the array values aren't correct) on init in versions < 2.55.
  23. //  : The follower ffc now makes its data invisible on init.
  24. // v0.8 : Added support for up to 10 unique followers in a quest.
  25. // v0.9 : Set combo under follower solid when that follower is dropped off.
  26. // v1.0 : Make enemies and weapons harmless during animation.
  27. //  : Fix a flag check, and optimise statements.
  28. //  : Added a setting for solidity layer, and only do SetLayerComboD(), if this value is nonzero.
  29.  
  30. //For future versions, used in 2.55+, a specific follower *type*.
  31. //enum the_follower = { folNONE, folZELDA, folOLDMAN, folBLACKSMITH, folCHEST, folGHOST, folLAST };
  32.  
  33. //Settings
  34. const int FOLLOWER_ZELDA_MIDI_DURATION  = 300;
  35. const int FOLLOWER_ZELDA_MIDI       = 1;
  36. const int FOLLOWER_MAX_FRAME        = 3; //4-frame walking animation
  37. const int FOLLOWER_CMB_BLANK_SOLID  = 1;
  38. const int FOLLOWER_SOLIDITY_LAYER   = 1;
  39.  
  40. const int FOLLOWER_REGISTER         = 1; //Screen->D register to use on any screen where you leave a follower.
  41.  
  42. //Binary flags for Screen->D
  43. const int FOLLOWER_GAVE_ITEM        = 1b;
  44. const int FOLLOWER_SHOWED_MESSAGE   = 10b;
  45. const int FOLLOWER_DELIVERED        = 100b;
  46. const int FOLLOWER_RESCUED      = 1000b;
  47.  
  48. //Array and array indices.
  49. //int TheFollower[128] = {-1, -1};
  50. const int FOLLOWER_MIDI_TIMER   = 0;
  51. const int FOLLOWER_CUR_RESCUED  = 1;
  52. const int FOLLOWER_ACTIVE   = 2;
  53. const int FOLLOWER_ANIMATING    = 3; //Unused
  54. const int FOLLOWER_FRAME    = 4;
  55. const int FOLLOWER_SUBFRAME     = 5;
  56. const int FOLLOWER_ORIG_MIDI    = 6;
  57. const int FOLLOWER_BASE_TILE    = 7;
  58. const int FOLLOWER_CSET     = 8;
  59. const int FOLLOWER_CURRENT_ID   = 9;
  60.  
  61. //Positional data for drawing.
  62. const int FOLLOWER_X        = 10;
  63. const int FOLLOWER_X1       = 11;
  64. const int FOLLOWER_X2       = 12;
  65. const int FOLLOWER_X3       = 13;
  66. const int FOLLOWER_X4       = 14;
  67. const int FOLLOWER_X5       = 15;
  68. const int FOLLOWER_X6       = 16;
  69. const int FOLLOWER_X7       = 17;
  70. const int FOLLOWER_X8       = 19;
  71. const int FOLLOWER_X9       = 20;
  72. const int FOLLOWER_X10      = 21;
  73. const int FOLLOWER_X11      = 22;
  74. const int FOLLOWER_X12      = 23; //Highest used
  75. const int FOLLOWER_X13      = 23;
  76. const int FOLLOWER_X14      = 24;
  77. const int FOLLOWER_X15      = 26;
  78. const int FOLLOWER_X16      = 27;
  79. const int FOLLOWER_X17      = 28;
  80. const int FOLLOWER_X18      = 29;
  81. const int FOLLOWER_X19      = 30;
  82. const int FOLLOWER_X20      = 31;
  83.  
  84. const int FOLLOWER_Y        = 40;
  85. const int FOLLOWER_Y1       = 41;
  86. const int FOLLOWER_Y2       = 42;
  87. const int FOLLOWER_Y3       = 43;
  88. const int FOLLOWER_Y4       = 44;
  89. const int FOLLOWER_Y5       = 45;
  90. const int FOLLOWER_Y6       = 46;
  91. const int FOLLOWER_Y7       = 47;
  92. const int FOLLOWER_Y8       = 48;
  93. const int FOLLOWER_Y9       = 49;
  94. const int FOLLOWER_Y10      = 50;
  95. const int FOLLOWER_Y11      = 51;
  96. const int FOLLOWER_Y12      = 52; //Highest used
  97. const int FOLLOWER_Y13      = 53;
  98. const int FOLLOWER_Y14      = 54;
  99. const int FOLLOWER_Y15      = 55;
  100. const int FOLLOWER_Y16      = 56;
  101. const int FOLLOWER_Y17      = 57;
  102. const int FOLLOWER_Y18      = 58;
  103. const int FOLLOWER_Y19      = 59;
  104. const int FOLLOWER_Y20      = 60;
  105.  
  106. const int FOLLOWER_DIR      = 70;
  107. const int FOLLOWER_DIR1     = 71;
  108. const int FOLLOWER_DIR2     = 72;
  109. const int FOLLOWER_DIR3     = 73;
  110. const int FOLLOWER_DIR4     = 74;
  111. const int FOLLOWER_DIR5     = 75;
  112. const int FOLLOWER_DIR6     = 76;
  113. const int FOLLOWER_DIR7     = 77;
  114. const int FOLLOWER_DIR8     = 78;
  115. const int FOLLOWER_DIR9     = 79;
  116. const int FOLLOWER_DIR10    = 80;
  117. const int FOLLOWER_DIR11    = 81;
  118. const int FOLLOWER_DIR12    = 82; //Highest used
  119. const int FOLLOWER_DIR13    = 83;
  120. const int FOLLOWER_DIR14    = 84;
  121. const int FOLLOWER_DIR15    = 85;
  122. const int FOLLOWER_DIR16    = 86;
  123. const int FOLLOWER_DIR17    = 87;
  124. const int FOLLOWER_DIR18    = 88;
  125. const int FOLLOWER_DIR19    = 89;
  126. const int FOLLOWER_DIR20    = 90;
  127.  
  128. //Tile and CSet, supporting up to 10 unique followers in the quest.
  129. const int FOLLOWER_ID_1_TILE    = 100;
  130. const int FOLLOWER_ID_2_TILE    = 101;
  131. const int FOLLOWER_ID_3_TILE    = 102;
  132. const int FOLLOWER_ID_4_TILE    = 103;
  133. const int FOLLOWER_ID_5_TILE    = 104;
  134. const int FOLLOWER_ID_6_TILE    = 105;
  135. const int FOLLOWER_ID_7_TILE    = 106;
  136. const int FOLLOWER_ID_8_TILE    = 107;
  137. const int FOLLOWER_ID_9_TILE    = 108;
  138. const int FOLLOWER_ID_10_TILE   = 109;
  139.  
  140. const int FOLLOWER_ID_1_CSET    = 110;
  141. const int FOLLOWER_ID_2_CSET    = 111;
  142. const int FOLLOWER_ID_3_CSET    = 112;
  143. const int FOLLOWER_ID_4_CSET    = 113;
  144. const int FOLLOWER_ID_5_CSET    = 114;
  145. const int FOLLOWER_ID_6_CSET    = 115;
  146. const int FOLLOWER_ID_7_CSET    = 116;
  147. const int FOLLOWER_ID_8_CSET    = 117;
  148. const int FOLLOWER_ID_9_CSET    = 118;
  149. const int FOLLOWER_ID_10_CSET   = 119;
  150.  
  151. //Screen on which Link encountered the follower.
  152. //Used to set a remote screen flag after Link delivers them home.
  153. const int FOLLOWER_CUR_SRC_DMAP     = 120;
  154. const int FOLLOWER_CUR_SRC_SCRN     = 121;
  155.  
  156.  
  157. // When Link collides with this ffc, it triggers the follower.
  158. //
  159. // When you use this, add a second ffc on the screen with the combo of the follower, and then
  160. // set the Link property of the ffc running the script to the ffc ID of the second ffc.
  161. //
  162. // The second, linked ffc is used to draw the follower until you collect them, and it also sets
  163. // both the tiles to draw, and the CSet to use when drawing the follower.
  164. //
  165. // You can Link this to itself, but then Link will need to walk onto the follower image to 'collect' them.
  166. // Arg 'id' (D2) should be 0 to 9, for a total of 10 possible, unique followers in a quest.
  167. // NOTE: You will need to use this same ID in arg D2 (id) for the LeaveFollower ffc script, as a PAIR.
  168. ffc script Follower
  169. {
  170.     int data[128];
  171.     void run(int sfx, int msg, int id)
  172.     {
  173.         this->Data = CMB_INVISIBLE;
  174.         ffc f = Screen->LoadFFC(this->Link);
  175.        
  176.         //Follower delivered, so clear the linked ffc data.
  177.         if ((Screen->D[FOLLOWER_REGISTER]&FOLLOWER_DELIVERED))
  178.         {
  179.             f->Data = 0;
  180.             if ( FOLLOWER_SOLIDITY_LAYER ) SetLayerComboD(FOLLOWER_SOLIDITY_LAYER, ComboAt(f->X, f->Y), 0); //Clear the solid combo under the npc follower graphic.
  181.             Quit();
  182.         }
  183.         while(1)
  184.         {
  185.             if ( Collision(this) )
  186.             {
  187.                 if ( !(Screen->D[FOLLOWER_REGISTER]&FOLLOWER_DELIVERED) )
  188.                 {
  189.                     if ( !Follower.data[FOLLOWER_CURRENT_ID] )
  190.                     {
  191.                         Follower.data[FOLLOWER_CUR_RESCUED] = 2;
  192.                         Game->PlaySound(sfx);
  193.                         Follower.data[FOLLOWER_BASE_TILE] = Game->ComboTile(f->Data)-4;
  194.                         Follower.data[FOLLOWER_CSET] = f->CSet;
  195.                        
  196.                         Follower.data[FOLLOWER_ID_1_TILE+id] = Game->ComboTile(f->Data)-4;
  197.                         Follower.data[FOLLOWER_ID_1_CSET+id] = f->CSet;
  198.                         Follower.data[FOLLOWER_CURRENT_ID] = id+1;
  199.                         Follower.data[FOLLOWER_CUR_SRC_DMAP] = Game->GetCurDMap();
  200.                         Follower.data[FOLLOWER_CUR_SRC_SCRN] = Game->GetCurScreen();
  201.  
  202.                         if ( msg ) Screen->Message(msg);
  203.                         if ( FOLLOWER_SOLIDITY_LAYER ) SetLayerComboD(FOLLOWER_SOLIDITY_LAYER, ComboAt(f->X, f->Y), 0); //Clear the solid combo under the npc follower graphic.
  204.                     }
  205.                 }
  206.             } //end collision check
  207.             if ( Follower.data[FOLLOWER_ACTIVE] > 15 )
  208.             {
  209.                 if ( Follower.data[FOLLOWER_CURRENT_ID] == id+1 )
  210.                 {
  211.                     f->Data = 0;
  212.                 }
  213.             }
  214.             if ( Link->Action == LA_SCROLLING ) Follower.data[FOLLOWER_ACTIVE] = 16; //Immediately jump on scroll.
  215.            
  216.             Waitframe();
  217.         }
  218.     }
  219.     void wait(int num, int x, int y, int til, int cset, bool noaction)
  220.     {
  221.         for (; num >= 0; --num)
  222.         {
  223.             Screen->FastTile(2, x, y, til, cset, 128 );
  224.             if ( noaction ) { NoAction(); } //NoPress(true); NoInput(true); }
  225.             Waitframe();
  226.         }
  227.     }
  228.     //Returns true if the player is holding, or pressed a directional key or button.
  229.     bool pressedDPad()
  230.     {
  231.         //if ( Link->Pushing ) return false; //2.55 and above
  232.         if ( Link->InputUp ) return true;
  233.         if ( Link->InputDown ) return true;
  234.         if ( Link->InputLeft ) return true;
  235.         if ( Link->InputRight ) return true;
  236.         if ( Link->PressUp ) return true;
  237.         if ( Link->PressDown ) return true;
  238.         if ( Link->PressLeft ) return true;
  239.         if ( Link->PressRight ) return true;
  240.         if ( Link->InputAxisUp ) return true;
  241.         if ( Link->InputAxisDown ) return true;
  242.         if ( Link->InputAxisLeft ) return true;
  243.         if ( Link->InputAxisRight ) return true;
  244.         if ( Link->PressAxisUp ) return true;
  245.         if ( Link->PressAxisDown ) return true;
  246.         if ( Link->PressAxisLeft ) return true;
  247.         if ( Link->PressAxisRight ) return true;
  248.         return false;
  249.     }
  250.     //Zelda follows in Link's path with an 8 frame delay before updating
  251.     void draw()
  252.     {
  253.         if ( !Follower.data[FOLLOWER_ACTIVE] ) return;
  254.         if ( pressedDPad() )
  255.         {
  256.             ++Follower.data[FOLLOWER_ACTIVE];
  257.             if ( Follower.data[FOLLOWER_ACTIVE] > 100000 ) Follower.data[FOLLOWER_ACTIVE] = 8; //Don't roll over
  258.         }
  259.  
  260.         if ( Link->Action == LA_GOTHURTLAND )
  261.         {
  262.             //if ( Link->HitDir == DIR_UP )
  263.             //{
  264.             //  Follower.data[FOLLOWER_Y12] = Link->Y - 32;
  265.             //  Follower.data[FOLLOWER_ACTIVE] = 16;
  266.             //}
  267.             //if ( Link->HitDir == DIR_DOWN )
  268.             //{
  269.             //  Follower.data[FOLLOWER_Y12] = Link->Y + 32;
  270.             //  Follower.data[FOLLOWER_ACTIVE] = 16;
  271.             //}
  272.             //if ( Link->HitDir == DIR_LEFT )
  273.             //{
  274.             //  Follower.data[FOLLOWER_X12] = Link->X + 32;
  275.             //  Follower.data[FOLLOWER_ACTIVE] = 16;
  276.             //}
  277.             //if ( Link->HitDir == DIR_RIGHT )
  278.             //{
  279.             //  Follower.data[FOLLOWER_X12] = Link->X - 32;
  280.             //  Follower.data[FOLLOWER_ACTIVE] = 16;
  281.             //}
  282.             return; //Don't update if Link was hurt and pushed back.
  283.         }
  284.  
  285.         if ( pressedDPad() )
  286.         {
  287.             ++Follower.data[FOLLOWER_SUBFRAME];
  288.             if ( Follower.data[FOLLOWER_SUBFRAME]&1 )
  289.             {
  290.                 ++Follower.data[FOLLOWER_FRAME];
  291.                 if ( Follower.data[FOLLOWER_FRAME] > FOLLOWER_MAX_FRAME ) Follower.data[FOLLOWER_FRAME] = 0;
  292.             }
  293.            
  294.             Follower.data[FOLLOWER_X] = Link->X;
  295.             Follower.data[FOLLOWER_Y] = Link->Y;
  296.             Follower.data[FOLLOWER_DIR] = Link->Dir;
  297.             for ( int q = FOLLOWER_X12; q >= FOLLOWER_X; --q )
  298.             {
  299.                 Follower.data[q] = Follower.data[q-1];
  300.             }
  301.             for ( int q = FOLLOWER_Y12; q >= FOLLOWER_Y; --q )
  302.             {
  303.                 Follower.data[q] = Follower.data[q-1];
  304.             }
  305.             for ( int q = FOLLOWER_DIR12; q >= FOLLOWER_DIR; --q )
  306.             {
  307.                 Follower.data[q] = Follower.data[q-1];
  308.             }
  309.        
  310.         }
  311.         if ( Follower.data[FOLLOWER_ACTIVE] < 16 ) return; //Wait 8 frames to begin.
  312.         //Draw tiles
  313.         int the_tile;
  314.          
  315.         the_tile = Follower.data[FOLLOWER_BASE_TILE] + (Follower.data[FOLLOWER_DIR12]*4) + Follower.data[FOLLOWER_FRAME];
  316.         //Based on X, Y, Dir and Frame
  317.         Screen->FastTile(2, Follower.data[FOLLOWER_X12], Follower.data[FOLLOWER_Y12],
  318.                     the_tile, Follower.data[FOLLOWER_CSET], 128 );
  319.        
  320.        
  321.         //...then Update the frame
  322.        
  323.     }
  324.    
  325.    
  326.     //Called to initialise the follower.
  327.     void rescue(int follower_midi, int dur)
  328.     {
  329.         if ( Follower.data[FOLLOWER_CUR_RESCUED] < 2 ) return;
  330.        
  331.         --Follower.data[FOLLOWER_CUR_RESCUED];
  332.         if ( !dur ) dur = FOLLOWER_ZELDA_MIDI_DURATION;
  333.         if ( !follower_midi ) follower_midi = FOLLOWER_ZELDA_MIDI;
  334.         Follower.data[FOLLOWER_ACTIVE] = 1;
  335.         if ( Follower.data[FOLLOWER_MIDI_TIMER] == -1 )
  336.         {
  337.            
  338.             Follower.data[FOLLOWER_ORIG_MIDI] = Game->DMapMIDI[Game->GetCurDMap()];
  339.             Follower.data[FOLLOWER_MIDI_TIMER] = dur;
  340.             Game->PlayMIDI(follower_midi);
  341.         }
  342.         else
  343.         {
  344.             --Follower.data[FOLLOWER_MIDI_TIMER];
  345.             if ( Follower.data[FOLLOWER_MIDI_TIMER] < 1 )
  346.             {
  347.                 Game->PlayMIDI(Follower.data[FOLLOWER_ORIG_MIDI]);
  348.                 Follower.data[FOLLOWER_MIDI_TIMER] = 0;
  349.             }
  350.         }
  351.  
  352.     }  
  353.  
  354.     // Clears the follower positions if Link dies, if the playe presses F6, and so forth.
  355.     // Called in active, continue, and exit scripts.
  356.     // Use in Link's Init script if using 2.55.
  357.     void clear()
  358.     {
  359.         for ( int q = FOLLOWER_X; q <= FOLLOWER_X20; ++q )
  360.         {
  361.             Follower.data[q] = Link->X;
  362.         }
  363.         for ( int q = FOLLOWER_Y; q <= FOLLOWER_Y20; ++q )
  364.         {
  365.             Follower.data[q] = Link->Y;
  366.         }
  367.         for ( int q = FOLLOWER_DIR; q <= FOLLOWER_DIR20; ++q )
  368.         {
  369.             Follower.data[q] = Link->Dir;
  370.         }
  371.     }
  372.  
  373.     // Called in the active script during scrolling to prevent the follower from drawing at the wrong position.
  374.     void scroll()
  375.     {
  376.         if ( Link->Action != LA_SCROLLING ) return;
  377.         for ( int q = FOLLOWER_X; q <= FOLLOWER_X20; ++q )
  378.         {
  379.             Follower.data[q] = Link->X;
  380.         }
  381.         for ( int q = FOLLOWER_Y; q <= FOLLOWER_Y20; ++q )
  382.         {
  383.             Follower.data[q] = Link->Y;
  384.         }
  385.         for ( int q = FOLLOWER_DIR; q <= FOLLOWER_DIR20; ++q )
  386.         {
  387.             Follower.data[q] = Link->Dir;
  388.         }
  389.     }
  390. }
  391.  
  392.  
  393. //Place on the screen where Link is to leave the follower, at the position to which you want the
  394. //follower to move toward, and stop, on the screen.
  395. //Set this to run on screen init.
  396. ffc script LeaveFollower
  397. {
  398.     void run(int msg, int itm, int id)
  399.     {
  400.         this->Data = CMB_INVISIBLE;
  401.        
  402.         int the_tile;
  403.        
  404.         if ( (Screen->D[FOLLOWER_REGISTER] & FOLLOWER_DELIVERED) )
  405.         {
  406.             //Clear the solid combo under the npc follower graphic.
  407.             if ( FOLLOWER_SOLIDITY_LAYER ) SetLayerComboD(FOLLOWER_SOLIDITY_LAYER, ComboAt(this->X, this->Y), FOLLOWER_CMB_BLANK_SOLID);
  408.             while(1)
  409.             {
  410.                 Follower.wait(2,this->X,this->Y,Follower.data[FOLLOWER_ID_1_TILE+id]+4, Follower.data[FOLLOWER_ID_1_CSET+id],false);
  411.             }
  412.         }
  413.        
  414.         while (1)
  415.         {
  416.             if ( Follower.data[FOLLOWER_CURRENT_ID] == id+1 )
  417.             {
  418.                 //Follower.data[FOLLOWER_ANIMATING] = 1;
  419.                 //Move to the target.
  420.                 for( int q = Screen->NumNPCs(); q > 0; --q )
  421.                 {
  422.                     npc n = Screen->LoadNPC(q); n->Stun = 10;
  423.                 }
  424.                 for ( int q = Screen->NumEWeapons(); q > 0; --q )
  425.                 {
  426.                     eweapon e = Screen->LoadEWeapon(q);
  427.                     e->HitYOffset = 32768;
  428.                     e->DeadState = WDS_DEAD;
  429.                 }
  430.                 if ( Follower.data[FOLLOWER_X12] < this->X ) { ++Follower.data[FOLLOWER_X12]; Follower.data[FOLLOWER_DIR12] = DIR_RIGHT; }
  431.                 if ( Follower.data[FOLLOWER_X12] > this->X ) { --Follower.data[FOLLOWER_X12]; Follower.data[FOLLOWER_DIR12] = DIR_LEFT; }
  432.                
  433.                 if ( Follower.data[FOLLOWER_Y12] < this->Y ) { ++Follower.data[FOLLOWER_Y12]; Follower.data[FOLLOWER_DIR12] = DIR_DOWN; }
  434.                 if ( Follower.data[FOLLOWER_Y12] > this->Y ) { --Follower.data[FOLLOWER_Y12]; Follower.data[FOLLOWER_DIR12] = DIR_UP; }
  435.            
  436.                 ++Follower.data[FOLLOWER_FRAME];
  437.                 if ( Follower.data[FOLLOWER_FRAME] > FOLLOWER_MAX_FRAME ) Follower.data[FOLLOWER_FRAME] = 0;
  438.                 the_tile = Follower.data[FOLLOWER_BASE_TILE] + (Follower.data[FOLLOWER_DIR12]*4) + Follower.data[FOLLOWER_FRAME];
  439.                 //If the follower is aligned, set its final properties.
  440.                 if ( Follower.data[FOLLOWER_X12] == this->X )
  441.                 {
  442.                     if ( Follower.data[FOLLOWER_Y12] == this->Y )
  443.                     {
  444.                         Follower.data[FOLLOWER_DIR12] = DIR_DOWN;
  445.                         Follower.data[FOLLOWER_FRAME] = 0;
  446.                     }
  447.                 }
  448.                 if ( !(Screen->D[FOLLOWER_REGISTER]&FOLLOWER_DELIVERED)) Follower.wait(2,Follower.data[FOLLOWER_X12],Follower.data[FOLLOWER_Y12],the_tile, Follower.data[FOLLOWER_CSET],true);
  449.                 else Follower.wait(2,Follower.data[FOLLOWER_X12],Follower.data[FOLLOWER_Y12],the_tile, Follower.data[FOLLOWER_CSET],false);
  450.                 if ( Follower.data[FOLLOWER_X12] == this->X )
  451.                 {
  452.                     if ( Follower.data[FOLLOWER_Y12] == this->Y )
  453.                     {
  454.                         Trace(Follower.data[FOLLOWER_CUR_SRC_DMAP]);
  455.                         Trace(Follower.data[FOLLOWER_CUR_SRC_SCRN]);
  456.                         int src_d = Game->GetDMapScreenD(Follower.data[FOLLOWER_CUR_SRC_DMAP], Follower.data[FOLLOWER_CUR_SRC_SCRN], FOLLOWER_REGISTER);
  457.                         Trace(src_d);
  458.                         src_d |= FOLLOWER_DELIVERED;
  459.                         Trace(src_d);
  460.                         Game->SetDMapScreenD(Follower.data[FOLLOWER_CUR_SRC_DMAP], Follower.data[FOLLOWER_CUR_SRC_SCRN], FOLLOWER_REGISTER, src_d);
  461.                            
  462.                         if ( Follower.data[FOLLOWER_ACTIVE] )
  463.                         {
  464.                             Follower.data[FOLLOWER_ACTIVE] = 0;
  465.                             Screen->D[FOLLOWER_REGISTER] |= FOLLOWER_DELIVERED;
  466.                             Follower.data[FOLLOWER_CURRENT_ID] = 0;
  467.                            
  468.                             //Set the flags on its source screen, too.
  469.                            
  470.                         }
  471.                         if ( msg )
  472.                         {
  473.                             if ( !(Screen->D[FOLLOWER_REGISTER]&FOLLOWER_SHOWED_MESSAGE) )
  474.                             {
  475.                                 Screen->D[FOLLOWER_REGISTER] |= FOLLOWER_SHOWED_MESSAGE;
  476.                                 Screen->Message(msg);
  477.                             }
  478.                         }
  479.                         if ( itm )
  480.                         {
  481.                             if ( !(Screen->D[FOLLOWER_REGISTER]&FOLLOWER_GAVE_ITEM) )
  482.                             {
  483.                                 Screen->D[FOLLOWER_REGISTER] |= FOLLOWER_GAVE_ITEM;
  484.                                 item giveit = Screen->CreateItem(itm);
  485.                                 giveit->X = Link->X;
  486.                                 giveit->Y = Link->Y;
  487.                                 giveit->Pickup = IP_HOLDUP;
  488.                            
  489.                             }
  490.                         }
  491.                         if ( FOLLOWER_SOLIDITY_LAYER ) SetLayerComboD(FOLLOWER_SOLIDITY_LAYER, ComboAt(this->X, this->Y), FOLLOWER_CMB_BLANK_SOLID); //Set the solid combo under the npc follower graphic.
  492.                         while(1) Follower.wait(2,this->X,this->Y,Follower.data[FOLLOWER_ID_1_TILE+id]+4, Follower.data[FOLLOWER_ID_1_CSET+id],false);
  493.                     }
  494.                 }
  495.             }
  496.             else Waitframe();
  497.        
  498.         }
  499.    
  500.     }
  501. }  
  502.  
  503. //Example global script.
  504. global script FollowerActive
  505. {
  506.     void run()
  507.     {
  508.         Follower.clear();
  509.         while(1)
  510.         {
  511.             //if ( Follower.data[FOLLOWER_ANIMATING] ) { Trace(1); NoAction(); }
  512.             Follower.rescue(FOLLOWER_ZELDA_MIDI, FOLLOWER_ZELDA_MIDI_DURATION);
  513.             Follower.draw();
  514.             Follower.scroll();
  515.             Waitdraw();
  516.             Waitframe();
  517.         }
  518.     }
  519. }
  520.  
  521.  
  522.  
  523.  
  524.  
  525. global script FollowerResume
  526. {
  527.     void run()
  528.     {
  529.         Follower.clear();
  530.     }
  531. }
  532.  
  533. global script Init
  534. {
  535.     void run()
  536.     {
  537.         Follower.data[0] = -1;
  538.         Follower.data[1] = -1;
  539.     }
  540. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement