Advertisement
ZoriaRPG

Random Encounter Template v0.1

Feb 7th, 2018
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.21 KB | None | 0 0
  1.  
  2. void RandomEncounter()
  3. {
  4.     mapdata m = Game->LoadMapDat(Game->GetCurMap(), Game->GetCurScreen());
  5.     npcdata e = Game->LoadNPCData(m-Enemy[Rand(10]l
  6.     ffc f = Screen->LoadFFC(32);
  7.     f->Script = Game->GetFFCScript("Battle");
  8.     f->InitD[0] = e;
  9.     f->InitD[1] = m; //for drawing backdrops
  10. }
  11.  
  12.  
  13. ffc script Battle
  14. {
  15.    void run(npcdata e, mapdata m)
  16.    {
  17.         bool waiting; int mode; int action;
  18.     while(1)
  19.     {
  20.         // Draw background using 'm'
  21.                 // draw npc using 'e'
  22.             // determine e's attacks using it's attributes;
  23.             // draw menus
  24.             // determine who goes first
  25.             mode = Rand(1); //if 1, enemy goes first
  26.             while(mode)
  27.             {
  28.                 //do enemy actions
  29.                 //Waitframe();
  30.             }
  31.             while(!mode)
  32.             {
  33.                 //player actions
  34.             waiting = true;
  35.             while(waiting)
  36.             {
  37.                 //do_menus();
  38.                 action = BattleMenu();
  39.                     Waitframe();
  40.                 }
  41.            
  42.                 //resolve stuff this round
  43.             Waitframe();
  44.         }
  45.     }
  46. }
  47.  
  48.  
  49. // There are certainly other ways to handle these...
  50. // Vars used by the Tango menu.
  51. int menuCommand;
  52. int menuArg;
  53.  
  54. //Tango Menu Init
  55. void SetUpWindow(int slot, int style, int x, int y, int size)
  56. {
  57.     SetStyleSize(style, size);
  58.     Tango_ClearSlot(slot);
  59.     Tango_SetSlotStyle(slot, style);
  60.     Tango_SetSlotPosition(slot, x, y);
  61. }
  62.  
  63. //Quick way to drop a string into a Tango dialogue box.
  64. void ShowString(int string, int slot, int style, int x, int y)
  65. {
  66.     SetUpWindow(slot, style, x, y, SIZE_LARGE);
  67.     Tango_LoadString(slot, string);
  68.     Tango_ActivateSlot(slot);
  69.     while(Tango_SlotIsActive(slot))  
  70.         Waitframe();
  71. }
  72.  
  73.  
  74. //The 'yes/no' menu called by the ffc.
  75. int BattleMenu() {
  76.  
  77.     int lineBreak[]="@26";
  78.     int line1[]="@choice(1)Attack@tab(40)@choice(2)Spell@26";
  79.     int line2[]="@choice(3)Item@tab(40)@choice(4)Item@domenu(1)@suspend()";
  80.    
  81.    
  82.     SetUpWindow(WINDOW_SLOT_1, WINDOW_STYLE_3, 32, 32, SIZE_LARGE);
  83.         Tango_LoadString(WINDOW_SLOT_1, line1);
  84.     Tango_AppendString(WINDOW_SLOT_1, line2);
  85.         Tango_ActivateSlot(WINDOW_SLOT_1);
  86.  
  87.    
  88.     while(!Tango_MenuIsActive()){
  89.        
  90.         Waitframe();
  91.     }
  92.    
  93.     // Save the state again...
  94.     int slotState[278];
  95.     int menuState[960];
  96.     int cursorPos;
  97.     Tango_SaveSlotState(WINDOW_SLOT_1, slotState);
  98.     Tango_SaveMenuState(menuState);
  99.    
  100.     int done = 0;
  101.     int choice;
  102.     while(true){
  103.    
  104.         while( Tango_MenuIsActive() ) {
  105.             cursorPos=Tango_GetMenuCursorPosition();
  106.             Waitframe();
  107.         }
  108.        
  109.         choice = Tango_GetLastMenuChoice();
  110.         if ( choice == 1 ) { // Item Info
  111.             int text[256];
  112.             Game->GetMessage(msg,text); //Load msg into the buffer.
  113.             ShowString(text, WINDOW_SLOT_2, WINDOW_STYLE_3, 48, 48);
  114.         }
  115.         else if ( choice == 2 ) { //Buy
  116.             done = choice;
  117.             menuArg = choice;
  118.         }
  119.        
  120.         else if ( choice == 3 ) { //Cancel
  121.             done = choice;
  122.         }
  123.        
  124.         else if ( Link->PressEx1 ) {
  125.             done = 1;
  126.         }
  127.         else done = 3;
  128.  
  129.         if ( done ) {
  130.             break;
  131.         //  return choice;
  132.         }
  133.         else {
  134.             Tango_RestoreSlotState(WINDOW_SLOT_1, slotState);
  135.             Tango_RestoreMenuState(menuState);
  136.             Tango_SetMenuCursorPosition(cursorPos);
  137.         }
  138.     }
  139.    
  140.     Tango_ClearSlot(WINDOW_SLOT_1);
  141.     return done;
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement