Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #strict
- local shooter;
- local Speed;
- local angle;
- local counterpart;
- local main;
- local mx,my,cx,cy,ox,oy;
- local target;
- local bonded;
- local maxdist;
- public func Launch(int iAngle, int iSpeed, object pShooter, object counterp, bM, int max)
- {
- if(pShooter)
- shooter = pShooter;
- Speed = iSpeed;
- angle=iAngle;
- counterpart=counterp;
- main=bM;
- maxdist=max;
- bonded=false;
- mx=0; my=0; cx=0; cy=0; ox=0; oy=0;
- SetXDir(+Sin(iAngle,iSpeed));
- SetYDir(-Cos(iAngle,iSpeed));
- SetAction("Travel");
- SetR(iAngle);
- SetVisibility(VIS_Owner);
- }
- private func Traveling()
- {
- if(!bonded)
- {
- if(shooter->GetAction() ne "Pray" && main)
- {
- Remove();
- }
- if(!GetXDir() && !GetYDir()) Hit();
- if(main)
- {
- if(!counterpart) Remove();
- mx=GetX();
- my=GetY();
- cx=counterpart->GetX();
- cy=counterpart->GetY();
- if(Distance(mx,my,cx,cy)>maxdist) Remove();
- DrawPseudoParticleLine(10);
- }
- }
- else
- {
- if(!target)
- {
- DrawPseudoParticleLine(32);
- for(var pEnemy in FindObjects(
- Find_OnLine(0,0,cx-mx,cy-my),
- Find_Hostile(GetOwner()),
- Find_NoContainer(),
- Find_OCF(OCF_Alive())))
- {
- target=pEnemy;
- ox=target->GetX();
- oy=target->GetY();
- SetVisibility(VIS_All);
- cx=target->GetX();
- cy=target->GetY();
- }
- }
- else
- {
- DrawPseudoParticleLine(40);
- var x=target->GetX();
- var y=target->GetY();
- if(Distance(x,y,ox,oy)>25) Remove();
- ox=x; oy=y;
- target->Jump();
- target->SetXDir(0);
- target->SetYDir(0);
- var angle=Angle(x,y,mx,my);
- if(Distance(x,y,mx,my)<15)
- {
- Remove();
- }
- target->SetPosition(x+Sin(angle,8),y-Cos(angle,8));
- if(target->Stuck())
- {
- target->SetPosition(x,y);
- Remove();
- }
- }
- }
- }
- func DrawPseudoParticleLine(size)
- {
- var angle=Angle(mx,my,cx,cy);
- var d=Random(Distance(cx,cy,mx,my));
- CreateParticle("PSpark",Sin(angle,d),-Cos(angle,d),0,0,size+Random(size),RGBa(128,200,255,Random(128)),this);
- }
- private func Remove()
- {
- if(main && !bonded)
- {
- CastParticles("PSpark",64,30,mx,my,32,64,RGBa(128,200,255,0),RGBa(128,200,255,128));
- CastParticles("PSpark",64,30,cx,cy,32,64,RGBa(128,200,255,0),RGBa(128,200,255,128));
- }
- if(counterpart && main)
- counterpart->RemoveObject();
- RemoveObject();
- }
- private func Hit()
- {
- SetXDir();
- SetYDir();
- if(!counterpart->GetXDir() && !counterpart->GetXDir())
- if(main)
- CreateBond();
- }
- func CreateBond()
- {
- if(!counterpart) Remove();
- counterpart->Remove();
- shooter->ControlUpDouble();
- bonded=true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement