SHARE
TWEET

CustomArrow

a guest Jan 21st, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var arrows = [];
  3. var Arrow = Particles.registerParticleType({
  4.     texture: "arrow",
  5.     size: [1, 1],
  6.     lifetime: [1, 5],
  7.     velocity: [0, 0, 0]
  8. });
  9. var emitter = new Particles.ParticleEmitter(0, 0, 0);
  10. function CustomArrow() {
  11.     this.spawn = function (params) {
  12.         var lookAngle = Entity.getLookAngle(Player.get());
  13.         if (lookAngle.yaw == 0) { this.spawn(params); return; }
  14.         var c = Entity.getPosition(Player.get()),
  15.             v = McMath.lookDirection(lookAngle.yaw, lookAngle.pitch);
  16.         entity = Entity.spawn(c.x + (v.x * 1.2), c.y + (v.y * 0.8), c.z + (v.z * 1.2), 80);
  17.         Entity.setSkin(entity, params.skin);
  18.         Entity.setVelocity(entity, v.x * params.speed, v.y * params.speed + 0.2, v.z * params.speed);
  19.         Bows.addBullet({ "entity": entity, damage: params.damage });
  20.         this.entity = entity;
  21.         return entity;
  22.         // this.p = Entity.getPosition(this.entity);
  23.         // this.v = Entity.getVelocity(this.entity);
  24.     }
  25.  
  26.     this.tick = function () {
  27.         this.p = Entity.getPosition(this.entity);
  28.         this.v = Entity.getVelocity(this.entity);
  29.         if(this.v.y!=0){
  30.             this.animate();
  31.         }
  32.     }
  33.  
  34.     this.animate = function () {
  35.         for (let i = -0.99; i < 0.99; i += 0.33) {
  36.             var c = {
  37.                 x: this.p.x - (this.v.x * i),
  38.                 y: this.p.y - (this.v.y * i),
  39.                 z: this.p.z - (this.v.z * i)
  40.             };
  41.             emitter.emit(Arrow, 0, c.x, c.y, c.z);
  42.         }
  43.     }
  44. }
  45.  
  46. Callback.addCallback("tick", function () {
  47.     for (var i in arrows) Test(function() {
  48.         if(arrows[i].p.y!=0)
  49.             arrows[i].tick();
  50.         else
  51.         delete arrows[i];
  52.     }, 'ParticleTick')
  53. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top