Advertisement
ZoriaRPG

Enemy Laser EWeapon Script

Oct 23rd, 2019
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.36 KB | None | 0 0
  1. namespace std
  2. {
  3.     namespace weapons
  4.     {
  5.         namespace laser
  6.         {
  7.             // Set the weapon's direction based on its angle;
  8.             // Can also makes weapons unblockable
  9.             void Aim(eweapon wpn)
  10.             {
  11.                 float angle=wpn->Angle%6.2832;
  12.                 int dir;
  13.                
  14.                 if(angle<0)
  15.                 angle+=6.2832;
  16.                
  17.                 if(angle<0.3927 || angle>5.8905)
  18.                 dir=DIR_RIGHT;
  19.                 else if(angle<1.1781)
  20.                 dir=DIR_RIGHTDOWN;
  21.                 else if(angle<1.9635)
  22.                 dir=DIR_DOWN;
  23.                 else if(angle<2.7489)
  24.                 dir=DIR_LEFTDOWN;
  25.                 else if(angle<3.5343)
  26.                 dir=DIR_LEFT;
  27.                 else if(angle<4.3197)
  28.                 dir=DIR_LEFTUP;
  29.                 else if(angle<5.1051)
  30.                 dir=DIR_UP;
  31.                 else
  32.                 dir=DIR_RIGHTUP;
  33.                 wpn->Dir=dir;
  34.             }
  35.  
  36.  
  37.             eweapon Fire(int weaponID, int x, int y, float angle, int step, int damage)
  38.             {
  39.                 eweapon wpn=Screen->CreateEWeapon(weaponID);
  40.                 wpn->X=x;
  41.                 wpn->Y=y;
  42.                 wpn->Step=step;
  43.                 wpn->Damage=damage;
  44.                 wpn->Angular=true;
  45.                 wpn->Angle=ArcTan(Link->X-x, Link->Y-y)+angle;
  46.  
  47.  
  48.                 Aim(wpn);
  49.                
  50.                 return wpn;
  51.             }
  52.             //DEFAULT VALUES
  53.             const int LAYER     = 3;
  54.             const int COLOUR    = 0x04;
  55.             const int OPACITY   = 128;
  56.             const int ANGLE_VISION  = 60;
  57.             const int SPEED     = 120;
  58.             const int COOLDOWN  = 150;
  59.             const int WEAPONID  = EW_SCRIPT1;
  60.             const int SOUND     = 70;
  61.            
  62.         }
  63.     }
  64. }
  65.  
  66. eweapon script laz
  67. {
  68.     void run(int speed, int colour, int layer, int fizzlesfx, int fizzlesprite)
  69.     {
  70.         int startX = this->X; //light bending if Parent->X
  71.         Audio->PlaySound(shotsfx); //because enemy editor shot sound isn't variable yet
  72.         this->Angular = true;
  73.         this->Angle = ArcTan(Link->X-this->X, Link->Y-this->Y);
  74.         this->Step = speed;
  75.         //this->Damage = Game->LoadNPCData(this->Parent)->WeaponDamage; //should get bthis from the enemy editor
  76.         this->DrawYOffset = -32768; //make wpn sprite invisible
  77.         while(1)
  78.         {
  79.             if (Screen->isSolid(CenterX(this), CenterY(this))
  80.             {
  81.                 this->DeadState = WDS_DEAD;
  82.                 Audio->PlaySound(fizzlesfx);
  83.                 if(fizzlesprite)
  84.                 {
  85.                    
  86.                     lweapon fiz = Screen->CreateLWeapon(LW_SPARKLE);
  87.                     fiz->UseSprite(fizzlesprite);
  88.                     fiz->CollDetection = false;
  89.                     fiz->X = this->X;
  90.                     fiz->Y = this->Y;
  91.                 }
  92.             }
  93.             else
  94.             {
  95.                 Screen->Line(layer, startX, this->Y, CenterX(this), CenterY(this), colour, 1, 0, 0, 0, 128);
  96.             }
  97.             Waitframe();
  98.         }
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement