Advertisement
ZoriaRPG

AutoGhost Item Thief NPCs

Nov 19th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. const int NPC_MISC_HOLDING_ITEM = 12;
  2. const int GHOST_STEALITEM_HOLDING_ITEM = 3;
  3. const int GHOST_STEALITEM_STEAL_SFX = 43;
  4. const float GHOST_STEALITEM_DRAGDUR = 1.5;
  5.  
  6. ffc script AutoghostBasicThief{
  7.     void run(int enemyid){
  8.         npc ghost = Ghost_InitAutoGhost(this, enemyid);
  9.         item i; itemdata it;
  10.         int a[4];
  11.         int itemlist[]={ IC_RUPEE, IC_HEART, IC_ARROWAMMO, IC_MAGIC, IC_BOMBAMMO };
  12.         while(true){
  13.             for ( a[0] = 1; a[0] <= Screen->NumItems(); a[0]++){
  14.                 if ( !a[GHOST_STEALITEM_HOLDING_ITEM] ) {
  15.                     i = Screen->LoadItem( a[0] );
  16.                     it = Game->LoadItemData(i->ID);
  17.                     for ( a[1] = 0; a[1] < SizeOfArray(itemlist); a[1]++){
  18.                         if ( it->Family == itemlist[ a[1] ] ) {
  19.                             if ( __DistX(ghost,i,4) && __DistY(ghost,i,4) ){
  20.                                 a[GHOST_STEALITEM_HOLDING_ITEM] = 1;
  21.                                 for ( a[2] = 0; a[2] < (GHOST_STEALITEM_DRAGDUR * 60); a[2]++ ) {
  22.                                     i->X = ghost->X;
  23.                                     i->Y = ghost->Y;
  24.                                     Ghost_Waitframe2(this,ghost);
  25.                                 }
  26.                                 Game->PlaySound(GHOST_STEALITEM_STEAL_SFX);
  27.                                 Remove(i);
  28.                                 a[GHOST_STEALITEM_HOLDING_ITEM] = 0;
  29.                             }
  30.                         }
  31.                     }
  32.                 }
  33.             }
  34.             Ghost_Waitframe2(this,ghost);
  35.         }
  36.     }
  37.     bool __DistX(npc a, item b, int distance) {
  38.         int dist;
  39.         if ( a->X > b->X ) dist = a->X - b->X;
  40.         else dist = b->X - a->X;
  41.         return ( dist <= distance );
  42.     }
  43.     bool __DistY(npc a, item b, int distance) {
  44.         int dist;
  45.         if ( a->Y > b->Y ) dist = a->Y - b->Y;
  46.         else dist = b->Y - a->Y;
  47.         return ( dist <= distance );
  48.     }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement