Advertisement
ZoriaRPG

Dalek / BotW Guardian NPC Script (v0.3) for 2.55

Mar 7th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. ///////////////////////
  2. /// THE DALEKS      ///
  3. /// NPC Script      ///
  4. /// For ZC 2.55     ///
  5. /// v0.3            ///
  6. /// 7th March, 2019 ///
  7. ///////////////////////
  8.  
  9.  
  10. npc script Dalek
  11. {
  12.     const int LASER_LAYER       = 3;
  13.     const int LASER_COLOUR      = 0x04;
  14.     const int LASER_OPACITY     = 128;
  15.     const int ANGLE_VISION      = 60;
  16.     const int SHOT_STEP     = 120;
  17.     const int COODOWN       = 150;
  18.     const int WTYPE         = EW_SCRIPT1;
  19.     const int SHOT_SFX      = 70;
  20.    
  21.     void run (int angleOfVision, int shotStep, int shotCooldownTime, int weaponType, int shotSFX)
  22.     {  
  23.         //Get attributes
  24.         angleOfVision = (this->InitD[0] > 0 ) ? this->InitD[0] : ANGLE_VISION;
  25.         shotStep = (this->InitD[1]] > 0 ) ? this->InitD[1]] : SHOT_STEP;
  26.         shotCooldownTime = (this->InitD[2] > 0 ) ? this->InitD[2] : COODOWN;
  27.         weaponType = (ghost->InitD[3] > 0 ) ? ghost->InitD[3] : WTYPE;
  28.         shotSFX = (ghost->InitD[4] > 0 ) ? ghost->InitD[4]: SHOT_SFX;
  29.  
  30.         int laserStartX;
  31.         int laserStartY;
  32.  
  33.         eweapon beam;
  34.  
  35.         while(this->isValid())
  36.         {
  37.             //Shooting
  38.             if ( shotCooldownTime > 0 )
  39.                 --shotCooldownTime;
  40.             //Only one beam at a time
  41.             else if ( !beam->isValid() )
  42.             {
  43.                 //Check angle to Link against angle of vision
  44.                 //If Link is within this angle
  45.                 if ( (Abs((Angle(CenterX(this), CenterY(this), CenterLinkX(), CenterLinkY())) - (Dir4Angle(this->Dir)))) <= angleOfVision/2 )
  46.                 {
  47.                     shotCooldownTime = (this->InitD[2] > 0 ) ? this->InitD[2] : COODOWN; //can reduce down by reading InitD again -Z
  48.        
  49.                     laserStartX = CenterX(this);
  50.                     laserStartY = CenterY(this);
  51.                    
  52.                    
  53.                     beam = Screen->CreateEWeapon(weaponType);
  54.                     beam->X = laserStartX;
  55.                     beam->Y = laserStartY;
  56.                     beam->Angular = true;
  57.                     beam->Angle = ArcTan(Link->X-beam->X, Link->Y-beam->X);
  58.                     beam->Step = shotStep;
  59.                     beam->Damage = this->WeaponDamage;
  60.                     Audio->PlaySound(shotSFX);
  61.                     beam->DrawXOffset = 999; //Draw off-screen
  62.                 }
  63.             }
  64.  
  65.             //Draw laser beam
  66.             if ( beam->isValid() )
  67.             {
  68.                 Screen->Line(LASER_LAYER, laserStartX, laserStartY, CenterX(beam), CenterY(beam), LASER_COLOUR, 1, 0, 0, 0, LASER_OPACITY);
  69.             }
  70.  
  71.             Waitframe();
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement