Advertisement
ZoriaRPG

Leave Special Item in Goriya Room

Nov 14th, 2019
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. #include "std.zh"
  2. #include "classic.zh"
  3. ffc script goriyaItem
  4. {
  5.     void run(int iid, int paddingTicks, int reg, int bit)
  6.     {    
  7.         Waitframes(6);
  8.         paddingTicks *= 60;
  9.         while(goriyaAlive()) Waitframe();
  10.         Waitframes(paddingTicks);
  11.         if ( (Screen->D[reg] & (1<<bit)) ) Quit();
  12.        
  13.         item it = Screen->CreateItem(iid);
  14.         it->X = this->X;
  15.         it->Y = this->Y;
  16.         it->Pickup |= IP_HOLDUP;
  17.         while(it->isValid()) Waitframe(); //Wait until item is collected.
  18.         Screen->D[reg] |= (1<<bit);
  19.     }
  20.     //Returns if there are enemy NPCs alive on the current screen.
  21.     int goriyaAlive()
  22.     {
  23.         int count;
  24.         for ( int q = Screen->NumNPCs(); q > 0; --q )
  25.         {
  26.             npc n = Screen->LoadNPC(q);
  27.             if ( n->Type == NPCT_GUY && n->ID != NPC_FIRE )
  28.             {
  29.                 ++count;
  30.             }
  31.         }
  32.         return count;
  33.     }
  34. }
  35.  
  36. //this one, did not work, but I'm leaving it for the purpose of preservation
  37. ffc script guyRoomtoSpecialItem
  38. {
  39.     void run(int paddingTicks, int reg, int bit)
  40.     {    
  41.         Waitframes(6);
  42.         paddingTicks *= 60;
  43.         while(1)
  44.         {
  45.             if ( Link->PressL )
  46.             {
  47.                 char32 s[]="NumNPCs: %d\n";
  48.                 printf(s, Screen->NumNPCs());
  49.             }
  50.             if ( (Screen->D[reg] & (1<<bit)) )
  51.             {
  52.                 char32 bs[]="changing to special item room\n";
  53.                 TraceS(bs);
  54.                 Screen->RoomType = RT_SPECIALITEM;
  55.                 Screen->State[ST_SPECIALITEM] = false; 
  56.                 Quit();
  57.             }
  58.             if ( goriyaAlive() < 1 )
  59.             {
  60.                 Waitframes(paddingTicks);
  61.                 Screen->D[reg] |= (1<<bit);
  62.             }
  63.             Waitframe();
  64.         }  
  65.     }
  66.     int goriyaAlive()
  67.     {
  68.         int count;
  69.         for ( int q = Screen->NumNPCs(); q > 0; --q )
  70.         {
  71.             npc n = Screen->LoadNPC(q);
  72.             if ( n->Type == NPCT_GUY && n->ID != NPC_FIRE )
  73.             {
  74.                 ++count;
  75.             }
  76.         }
  77.         return count;
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement