Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. #strict
  2.  
  3. local shooter;
  4. local Speed;
  5. local angle;
  6. local counterpart;
  7. local main;
  8. local mx,my,cx,cy,ox,oy;
  9. local target;
  10. local bonded;
  11. local maxdist;
  12.  
  13.  
  14. public func Launch(int iAngle, int iSpeed, object pShooter, object counterp, bM, int max)
  15. {
  16.  
  17. if(pShooter)
  18. shooter = pShooter;
  19. Speed = iSpeed;
  20. angle=iAngle;
  21. counterpart=counterp;
  22. main=bM;
  23. maxdist=max;
  24. bonded=false;
  25. mx=0; my=0; cx=0; cy=0; ox=0; oy=0;
  26. SetXDir(+Sin(iAngle,iSpeed));
  27. SetYDir(-Cos(iAngle,iSpeed));
  28. SetAction("Travel");
  29. SetR(iAngle);
  30. SetVisibility(VIS_Owner);
  31. }
  32.  
  33.  
  34. private func Traveling()
  35. {
  36.  
  37. if(!bonded)
  38. {
  39.  
  40. if(shooter->GetAction() ne "Pray" && main)
  41. {
  42. Remove();
  43. }
  44. if(!GetXDir() && !GetYDir()) Hit();
  45. if(main)
  46. {
  47. if(!counterpart) Remove();
  48. mx=GetX();
  49. my=GetY();
  50. cx=counterpart->GetX();
  51. cy=counterpart->GetY();
  52. if(Distance(mx,my,cx,cy)>maxdist) Remove();
  53. DrawPseudoParticleLine(10);
  54. }
  55. }
  56. else
  57. {
  58. if(!target)
  59. {
  60. DrawPseudoParticleLine(32);
  61. for(var pEnemy in FindObjects(
  62. Find_OnLine(0,0,cx-mx,cy-my),
  63. Find_Hostile(GetOwner()),
  64. Find_NoContainer(),
  65. Find_OCF(OCF_Alive())))
  66. {
  67. target=pEnemy;
  68. ox=target->GetX();
  69. oy=target->GetY();
  70. SetVisibility(VIS_All);
  71. cx=target->GetX();
  72. cy=target->GetY();
  73. }
  74. }
  75. else
  76. {
  77. DrawPseudoParticleLine(40);
  78. var x=target->GetX();
  79. var y=target->GetY();
  80. if(Distance(x,y,ox,oy)>25) Remove();
  81. ox=x; oy=y;
  82. target->Jump();
  83. target->SetXDir(0);
  84. target->SetYDir(0);
  85. var angle=Angle(x,y,mx,my);
  86. if(Distance(x,y,mx,my)<15)
  87. {
  88. Remove();
  89. }
  90. target->SetPosition(x+Sin(angle,8),y-Cos(angle,8));
  91. if(target->Stuck())
  92. {
  93. target->SetPosition(x,y);
  94. Remove();
  95. }
  96.  
  97. }
  98. }
  99.  
  100. }
  101.  
  102. func DrawPseudoParticleLine(size)
  103. {
  104. var angle=Angle(mx,my,cx,cy);
  105. var d=Random(Distance(cx,cy,mx,my));
  106. CreateParticle("PSpark",Sin(angle,d),-Cos(angle,d),0,0,size+Random(size),RGBa(128,200,255,Random(128)),this);
  107. }
  108.  
  109. private func Remove()
  110. {
  111. if(main && !bonded)
  112. {
  113. CastParticles("PSpark",64,30,mx,my,32,64,RGBa(128,200,255,0),RGBa(128,200,255,128));
  114. CastParticles("PSpark",64,30,cx,cy,32,64,RGBa(128,200,255,0),RGBa(128,200,255,128));
  115. }
  116. if(counterpart && main)
  117. counterpart->RemoveObject();
  118. RemoveObject();
  119. }
  120.  
  121.  
  122. private func Hit()
  123. {
  124.  
  125. SetXDir();
  126. SetYDir();
  127. if(!counterpart->GetXDir() && !counterpart->GetXDir())
  128. if(main)
  129. CreateBond();
  130.  
  131.  
  132. }
  133.  
  134. func CreateBond()
  135. {
  136. if(!counterpart) Remove();
  137. counterpart->Remove();
  138. shooter->ControlUpDouble();
  139. bonded=true;
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement