Advertisement
Guest User

Super Sniper

a guest
Jul 24th, 2013
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Super Sniper
  2.  * save as SuperSniper.gml
  3.  * by iLegend
  4.  * blow up rockets and mines by shooting them.
  5.  * the true test of sniping
  6.  */
  7.  
  8. object_event_clear(Rifle, ev_other, ev_user3);
  9.  
  10. object_event_add(Rifle, ev_other, ev_user3, "
  11.     playsound(x,y,SniperSnd);
  12.     shot=true;
  13.     justShot=true;
  14.     readyToShoot = false;
  15.     alarm[0] = reloadTime + 20*owner.zoomed;
  16.    
  17.     // for drawing:
  18.     tracerAlpha = 0.8;
  19.     shotx = x;
  20.     shoty = y;
  21.    
  22.     var hit;
  23.     var x1,y1,xm,ym, len;
  24.     var hitline;
  25.     len=2000;
  26.     x1=x;
  27.     y1=y;
  28.     x2=x+lengthdir_x(len,owner.aimDirection);
  29.     y2=y+lengthdir_y(len,owner.aimDirection);
  30.    
  31.     alarm[6] = alarm[0];
  32.     while(len>1) {
  33.         xm=(x1+x2)/2;
  34.         ym=(y1+y2)/2;
  35.        
  36.         hitline = false;
  37.         with(owner) {
  38.             if (collision_line(x1,y1,xm,ym,Generator,true,true)>=0) {
  39.                 hitline = true;
  40.                 if instance_nearest(x1,y1,Generator).team == team hitline = false;
  41.             }
  42.             if(collision_line(x1,y1,xm,ym,Obstacle,true,true)>=0) {
  43.                 hitline = true;
  44.             } else if (collision_line(x1,y1,xm,ym,Character,true,true)>=0) {
  45.                 hitline = true;
  46.             } else if (collision_line(x1,y1,xm,ym,Sentry,true,false)>=0) {
  47.                 hitline = true;
  48.             } else if (collision_line(x1,y1,xm,ym,TeamGate,true,true)>=0) {
  49.                 hitline = true;
  50.             } else if (collision_line(x1,y1,xm,ym,IntelGate,true,true)>=0) {
  51.                 hitline = true;
  52.             } else if (collision_line(x1,y1,xm,ym,ControlPointSetupGate,true,true)>=0) {
  53.                 if ControlPointSetupGate.solid == true hitline = true;
  54.             } else if (collision_line(x1,y1,xm,ym,BulletWall,true,true)>=0) {
  55.                 hitline = true;
  56.             } else if (collision_line(x1,y1,xm,ym,Mine,true,true)>=0) {
  57.                 hitline = true;
  58.             } else if (collision_line(x1,y1,xm,ym,Rocket,true,true)>=0) {
  59.                 hitline = true;
  60.             }
  61.         }
  62.        
  63.         if(hitline) {
  64.             x2=xm;
  65.             y2=ym;
  66.         } else {
  67.             x1=xm;
  68.             y1=ym;
  69.         }
  70.         len/=2;
  71.     }
  72.    
  73.     with(Player) {
  74.         if(id != other.ownerPlayer and team != other.owner.team and object != -1) {
  75.             if(collision_line(other.x,other.y,other.x2,other.y2,object,true,false)>=0) && object.ubered == 0 {
  76.                 object.hp -= other.hitDamage;
  77.                 object.timeUnscathed = 0;
  78.                 if (object.lastDamageDealer != other.ownerPlayer && object.lastDamageDealer != object.player){
  79.                     object.secondToLastDamageDealer = object.lastDamageDealer;
  80.                     object.alarm[4] = object.alarm[3]
  81.                 }
  82.                 object.alarm[3] = ASSIST_TIME;
  83.                 object.lastDamageDealer = other.ownerPlayer;
  84.                 object.cloakAlpha = max(object.cloakAlpha, 0.3);
  85.                 object.cloakFlicker = true;
  86.                 object.alarm[7] = 3;
  87.                 if(global.gibLevel > 0){
  88.                     blood = instance_create(object.x,object.y,Blood);
  89.                     blood.direction = other.owner.aimDirection-180;
  90.                 }
  91.                 if (!other.owner.zoomed)
  92.                     object.lastDamageSource = WEAPON_RIFLE;
  93.                 else
  94.                     object.lastDamageSource = WEAPON_RIFLE_CHARGED;
  95.                 exit;
  96.             }
  97.         }
  98.     }
  99.    
  100.     with(Rocket) {
  101.         if(team != other.owner.team) {
  102.             if(collision_line(other.x,other.y,other.x2,other.y2,id,false,false)>=0) {
  103.                 event_user(5);
  104.             }
  105.         }
  106.     }
  107.     with(Mine) {
  108.         if(team != other.owner.team) {
  109.             if(collision_line(other.x,other.y,other.x2,other.y2,id,false,false)>=0) {
  110.                 event_user(2);
  111.             }
  112.         }
  113.     }
  114.    
  115.     with(Sentry) {
  116.         if(team != other.owner.team) {
  117.             if(collision_line(other.x,other.y,other.x2,other.y2,id,false,false)>=0) {
  118.                 hp -= other.hitDamage;
  119.                 lastDamageDealer = other.ownerPlayer;
  120.                 if (!other.owner.zoomed)
  121.                     lastDamageSource = WEAPON_RIFLE;
  122.                 else
  123.                     lastDamageSource = WEAPON_RIFLE_CHARGED;
  124.                 exit;
  125.             }
  126.         }
  127.     }
  128.    
  129.     with(Generator) {
  130.         if(team != other.owner.team) {
  131.             if(collision_line(other.x,other.y,other.x2,other.y2,id,true,false)>=0) {
  132.                 alarm[0] = regenerationBuffer;
  133.                 isShieldRegenerating = false;
  134.                 //allow overkill to be applied directly to the target
  135.                 if (other.hitDamage > shieldHp) {
  136.                     hp -= other.hitDamage - shieldHp;
  137.                     hp -= shieldHp * shieldResistance;
  138.                     shieldHp = 0;
  139.                 }
  140.                 else
  141.                 {
  142.                     hp -= other.hitDamage * shieldResistance;
  143.                     shieldHp -= other.hitDamage;
  144.                 }
  145.                 exit;
  146.             }
  147.         }
  148.     }
  149.  
  150. ");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement