Advertisement
ZoriaRPG

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

Mar 7th, 2019
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.49 KB | None | 0 0
  1. ///////////////////////
  2. /// THE DALEKS      ///
  3. /// NPC Script      ///
  4. /// For ZC 2.55     ///
  5. /// v0.2            ///
  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 shotCooldown = shotCooldownTime;
  31.         int laserStartX;
  32.         int laserStartY;
  33.  
  34.         eweapon beam;
  35.  
  36.         while(this->isValid())
  37.         {
  38.             //Shooting
  39.             if ( shotCooldown > 0 )
  40.                 --shotCooldown;
  41.             //Only one beam at a time
  42.             else if ( !beam->isValid() )
  43.             {
  44.                 //Check angle to Link against angle of vision
  45.                 //int angleToLink = Angle(CenterX(this), CenterY(this), CenterLinkX(), CenterLinkY());
  46.                 //int facingAngle = Dir4Angle(this->Dir);
  47.                 //int difference = Abs(angleToLink - facingAngle);
  48.                 //int difference = Abs((Angle(CenterX(this), CenterY(this), CenterLinkX(), CenterLinkY())) - (Dir4Angle(this->Dir)));
  49.    
  50.                 //If Link is within this angle
  51.                 //if ( difference <= angleOfVision/2 )
  52.                 if ( (Abs((Angle(CenterX(this), CenterY(this), CenterLinkX(), CenterLinkY())) - (Dir4Angle(this->Dir)))) <= angleOfVision/2 )
  53.                 {
  54.                     shotCooldown = shotCooldownTime; //can reduce down by reading InitD again -Z
  55.        
  56.                     laserStartX = CenterX(this);
  57.                     laserStartY = CenterY(this);
  58.                    
  59.                    
  60.                     beam = Screen->CreateEWeapon(weaponType);
  61.                     beam->X = laserStartX;
  62.                     beam->Y = laserStartY;
  63.                     beam->Angular = true;
  64.                     beam->Angle = ArcTan(Link->X-beam->X, Link->Y-beam->X);
  65.                     beam->Step = shotStep;
  66.                     beam->Damage = this->WeaponDamage;
  67.                     Audio->PlaySound(shotSFX);
  68.                     beam->DrawXOffset = 999; //Draw off-screen
  69.                 }
  70.             }
  71.  
  72.             //Draw laser beam
  73.             if ( beam->isValid() )
  74.             {
  75.                 Screen->Line(LASER_LAYER, laserStartX, laserStartY, CenterX(beam), CenterY(beam), LASER_COLOUR, 1, 0, 0, 0, LASER_OPACITY);
  76.             }
  77.  
  78.             Waitframe();
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement