Advertisement
ZoriaRPG

Klop Request

May 27th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. ffc script klop_request //Not sure what else to call it this time.
  2. {
  3.      void run(int target_enemy_id, int split, int num_splits, int msg)
  4.      //There had better only be one enemy of this type on the screen!
  5.      {
  6.           int teloc[3]; //target enemy location
  7.           npc n; teloc[1] = -1; teloc[2] = -1;
  8.           while(1)
  9.           {
  10.                teloc[0] = 0; //wipe every frame
  11.                for ( int q = Screen->NumNPCs(); q > 0; --q; )
  12.                {
  13.                     n = Screen->LoadNPC(q);
  14.                     if ( n->ID == target_npc_id )
  15.                     {
  16.                          teloc[0] = q; teloc[1] = n->X; teloc[2] = n->Y;
  17.                     }
  18.                }
  19.                if ( !teloc[0] ) //no target npc, but we preserve its last coordinates.
  20.                {
  21.                     break;
  22.                }
  23.                Waitframe();
  24.           } //infinite loop ends here.
  25.           if ( split )
  26.           {
  27.                if ( teloc[1] > -1 ) //only if there was a valid target with good coordinates.
  28.                {
  29.                     if ( teloc[2] > -1 )
  30.                     {
  31.                          for ( ; num_splits > 0; --num_splits )
  32.                          {
  33.                               n = Screen->CreateNPC(split_into);
  34.                               n->X = teloc[1];
  35.                               n->Y = teloc[2];
  36.                          }
  37.                     }
  38.                }
  39.           }
  40.           if ( msg )
  41.           {
  42.                Screen->Message(msg);
  43.           }
  44.      }
  45.      this->Data = 0; Quit();
  46. } //runs out of scope
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement