Advertisement
Guest User

Untitled

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