ZoriaRPG

Dalek / BotW Guardian NPC Script for 2.55

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