Advertisement
ZoriaRPG

Basic NPC Scripts, v1

Dec 25th, 2018
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.80 KB | None | 0 0
  1. //Flying enemym with hardcoded sprite and animations
  2. npc script floater
  3. {
  4.     void run()
  5.     {
  6.         int attack_clk;
  7.         TraceS("Running npc script 'test'"); TraceNL();
  8.         this->Dir = Rand(0,3);
  9.         switch(this->Dir)
  10.         {
  11.             case DIR_UP: this->ScriptTile = 862; break;
  12.             case DIR_DOWN: this->ScriptTile = 861; break;
  13.             case DIR_LEFT: this->ScriptTile = 882; break;
  14.             case DIR_RIGHT: this->ScriptTile = 881; break;
  15.             default: break;
  16.         }
  17.  
  18.         this->ScriptTile = this->Tile;
  19.         while(this->isValid())
  20.         {
  21.             switch(this->Dir)
  22.             {
  23.                 case DIR_UP: this->ScriptTile = 862; break;
  24.                 case DIR_DOWN: this->ScriptTile = 861; break;
  25.                 case DIR_LEFT: this->ScriptTile = 882; break;
  26.                 case DIR_RIGHT: this->ScriptTile = 881; break;
  27.                 default: break;
  28.             }
  29.             //this->ScriptTile;
  30.             //if ( this->CanMove(this->Dir) )
  31.             //{
  32.                 this->FloatingWalk({10,200,2});
  33.             //}
  34.             if ( this->LinedUp(60,true) )
  35.             {
  36.                 if ( this->LinkInRange(60) )
  37.                 {
  38.                     if (!attack_clk)
  39.                     {
  40.                         attack_clk = 100;
  41.                         this->Attack();
  42.                     }
  43.                 }
  44.             }
  45.             if (attack_clk) --attack_clk;
  46.             Waitframe();
  47.         }
  48.     }
  49. }
  50.  
  51. //Hard codes a walking enemy sprite
  52. npc script walker
  53. {
  54.     void run()
  55.     {
  56.         int attack_clk;
  57.         TraceS("Running npc script 'test'"); TraceNL();
  58.         this->Dir = Rand(0,3);
  59.         switch(this->Dir)
  60.         {
  61.             case DIR_UP: this->ScriptTile = 862; break;
  62.             case DIR_DOWN: this->ScriptTile = 861; break;
  63.             case DIR_LEFT: this->ScriptTile = 882; break;
  64.             case DIR_RIGHT: this->ScriptTile = 881; break;
  65.             default: break;
  66.         }
  67.  
  68.         this->ScriptTile = this->Tile;
  69.         while(this->isValid())
  70.         {
  71.             switch(this->Dir)
  72.             {
  73.                 case DIR_UP: this->ScriptTile = 862; break;
  74.                 case DIR_DOWN: this->ScriptTile = 861; break;
  75.                 case DIR_LEFT: this->ScriptTile = 882; break;
  76.                 case DIR_RIGHT: this->ScriptTile = 881; break;
  77.                 default: break;
  78.             }
  79.             //this->ScriptTile;
  80.             //if ( this->CanMove(this->Dir) )
  81.             //{
  82.                 this->HaltingWalk({10,1,0,50,2});
  83.             //}
  84.             if ( this->LinedUp(60,true) )
  85.             {
  86.                 if ( this->LinkInRange(60) )
  87.                 {
  88.                     if (!attack_clk)
  89.                     {
  90.                         attack_clk = 100;
  91.                         this->Attack();
  92.                     }
  93.                 }
  94.             }
  95.             if (attack_clk) --attack_clk;
  96.             Waitframe();
  97.         }
  98.     }
  99. }
  100.  
  101.  
  102. //Uses the Enemy Editor to draw the sprite and do its animation
  103. npc script walker2
  104. {
  105.     void run()
  106.     {
  107.         int attack_clk;
  108.         //TraceS("Running npc script 'test'"); TraceNL();
  109.         this->Dir = Rand(0,3);
  110.        
  111.         while(this->isValid())
  112.         {
  113.             //if ( this->CanMove(this->Dir) )
  114.             //{
  115.                 this->HaltingWalk({10,1,0,50,2});
  116.             //}
  117.             if ( this->LinedUp(20,false) > -1 )
  118.             {
  119.                 if ( this->LinkInRange(60) )
  120.                 {
  121.                     if (!attack_clk)
  122.                     {
  123.                         attack_clk = 100;
  124.                         this->Attack();
  125.                     }
  126.                 }
  127.             }
  128.             if (attack_clk) --attack_clk;
  129.             if ( Input->ReadKey[KEY_0] ) this->Attack();
  130.             Waitframe();
  131.         }
  132.     }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement