Jump to content

Photo

The Decimator (A Homing Weapon)


  • Please log in to reply
9 replies to this topic

#1 Zim

Zim

    Freelance Nobody

  • Members
  • Real Name:Zim
  • Location:Washington

Posted 30 April 2010 - 11:48 AM

CODE




import "std.zh"


item script Decimator
{
void run()
    {

if(UseDeci > 0) return;
UseDeci=1; //trigger for global loops

}
}

int UseDeci;        
int frames=0;
global script Slot_2    
{
    void run()
    {
    UseDeci = 0; //runs once so set to 0
    while(true)
        {
        Decimate(); //run item script
        Waitframe();
            }
    }

        }
    void Decimate() //check if used item, this function happens every frame of game
        {
        lweapon Deci=Deci();
        if(UseDeci==0) //if used item & has returned to Link, set back to 0?
            {Deci->DeadState = WDS_DEAD; return;}
        else if(UseDeci==1)
            {Throw();} //continue script
        }
    void Throw()                                    
        {
        lweapon Deci=Deci();
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=28;
        Decimator->CSet=10;
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        Decimator->X=Link->X;
        Decimator->Y=Link->Y;
        while(true)
        Hunt1();
        }
        
        
    lweapon Deci()
        {    
        lweapon a;
        for(int i=1;i<=Screen->NumLWeapons();i++)
            {
            a = Screen->LoadLWeapon(i);
        if(a->ID == LW_SCRIPT1) return a;
            a = Screen->CreateLWeapon(LW_SCRIPT1);
            a->Damage = 16;
            a->UseSprite(100);
            return a;
            }
        }                                                                                                                                                                                                                                                                                                            
    void Hunt1()
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=30;
        Decimator->CSet=10;
        lweapon Deci=Screen->CreateLWeapon(LW_SCRIPT1);
        Deci->UseSprite(100);
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        Deci->Damage=32;
        Deci->HitHeight=16;
        Deci->HitWidth=16;

        npc A=Screen->LoadNPC(1);        
            if(!A->isValid())
                {Hunt2();}
            if(Decimator->X!=A->X || Decimator->Y!=A->Y)
                {Decimator->Vx=(A->X-Decimator->X)/Distance(A->X, A->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(A->Y-Decimator->Y)/Distance(A->X, A->Y,Decimator->X, Decimator->Y)*3;}
            else if(Decimator->X==A->X && Decimator->Y==A->Y )
                                               {Hunt2();}
        Waitframe();    
        }
        }
    void Hunt2()
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=29;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        Deci->UseSprite(101);
        npc B=Screen->LoadNPC(2);
        if(!B->isValid())
            {Hunt3();}
            
            if(Decimator->X!=B->X || Decimator->Y!=B->Y)
                {Decimator->Vx=(B->X-Decimator->X)/Distance(B->X, B->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(B->Y-Decimator->Y)/Distance(B->X, B->Y,Decimator->X, Decimator->Y)*3;}

            else if(Decimator->X==B->X && Decimator->Y==B->Y)
                {Hunt3();}
        Waitframe();
        }
        
        }
    void Hunt3()    
        {
        while(true)
        {
        
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=30;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        Deci->UseSprite(102);
        npc C=Screen->LoadNPC(3);
        if(!C->isValid())
            {Hunt4();}

            if(Decimator->X!=C->X || Decimator->Y!=C->Y)
                {Decimator->Vx=(C->X-Decimator->X)/Distance(C->X, C->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(C->Y-Decimator->Y)/Distance(C->X, C->Y,Decimator->X, Decimator->Y)*3;}
            else if(Decimator->X==C->X && Decimator->Y==C->Y)
                {Hunt4();}
        Waitframe();
        }
        }
    void Hunt4()
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=28;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        Deci->UseSprite(100);
        npc D=Screen->LoadNPC(4);
        if(!D->isValid())
            {Hunt5();}
            
            if(Decimator->X!=D->X || Decimator->Y!=D->Y)
                {Decimator->Vx=(D->X-Decimator->X)/Distance(D->X, D->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(D->Y-Decimator->Y)/Distance(D->X, D->Y,Decimator->X, Decimator->Y)*3;}
            else if(Decimator->X==D->X && Decimator->Y==D->Y)
                {Hunt5();}
        Waitframe();    
        }
        }
    void Hunt5()
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=28;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        Deci->UseSprite(102);
        npc K=Screen->LoadNPC(5);
        if(!K->isValid())
            {Hunt6();}
            
            if(Decimator->X!=K->X || Decimator->Y!=K->Y)
                {Decimator->Vx=(K->X-Decimator->X)/Distance(K->X, K->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(K->Y-Decimator->Y)/Distance(K->X, K->Y,Decimator->X, Decimator->Y)*3;}
            else if(Decimator->X==K->X && Decimator->Y==K->Y)
                {Hunt6();}
        Waitframe();
        }    

        }
    void Hunt6()
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=28;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        npc F=Screen->LoadNPC(6);

        if(!F->isValid())
            {Hunt7();}
            
            if(Decimator->X!=F->X || Decimator->Y!=F->Y)
                {Decimator->Vx=(F->X-Decimator->X)/Distance(F->X, F->Y, Decimator->X, Decimator->Y)*5;
                Decimator->Vy=(F->Y-Decimator->Y)/Distance(F->X, F->Y,Decimator->X, Decimator->Y)*5;}
            else if(Decimator->X==F->X && Decimator->Y==F->Y)
                {Hunt7();}
            
        Waitframe();
        }
        }
    void Hunt7()
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=30;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        npc G=Screen->LoadNPC(7);

        if(!G->isValid())
            {Hunt8();}
            
            if(Decimator->X!=G->X || Decimator->Y!=G->Y)
                {Decimator->Vx=(G->X-Decimator->X)/Distance(G->X, G->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(G->Y-Decimator->Y)/Distance(G->X, G->Y,Decimator->X, Decimator->Y)*3;}
            else if(Decimator->X==G->X && Decimator->Y==G->Y)
                {Hunt8();}
            
        Waitframe();
        }
        }

    void Hunt8()
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=30;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        npc H=Screen->LoadNPC(8);

        if(!H->isValid())
            {Hunt9();}
            
            if(Decimator->X!=H->X || Decimator->Y!=H->Y)
                {Decimator->Vx=(H->X-Decimator->X)/Distance(H->X, H->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(H->Y-Decimator->Y)/Distance(H->X, H->Y,Decimator->X, Decimator->Y)*3;}
            else if(Decimator->X==H->X && Decimator->Y==H->Y)
                {Hunt9();}
            
        else if(!H->isValid())
            {Hunt9();}
        Waitframe();
        }
        }
    void Hunt9()
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=30;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        npc I=Screen->LoadNPC(9);
        if(!I->isValid())
            {Hunt10();}
            
            if(Decimator->X!=I->X || Decimator->Y!=I->Y)
                {Decimator->Vx=(I->X-Decimator->X)/Distance(I->X, I->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(I->Y-Decimator->Y)/Distance(I->X, I->Y,Decimator->X, Decimator->Y)*3;}
            else if(Decimator->X==I->X && Decimator->Y==I->Y)
                {Hunt10();}
            
        else if(!I->isValid())
            {Hunt10();}
        Waitframe();
        }
        }
    void Hunt10()
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=30;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        npc J=Screen->LoadNPC(10);
        if(!J->isValid())
            {Hunt11();}
            
            if(Decimator->X!=J->X || Decimator->Y!=J->Y)
                {Decimator->Vx=(J->X-Decimator->X)/Distance(J->X, J->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(J->Y-Decimator->Y)/Distance(J->X, J->Y,Decimator->X, Decimator->Y)*3;}
            else if(Decimator->X==J->X && Decimator->Y==J->Y)
                {Game->Counter[10]+=1; Hunt11();}
        Waitframe();    
        }
        }
    void Hunt11()
        {
        while(true)
        {
        if(UseDeci==0){Quit();}
        else
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=28;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
            if((Decimator->X>=Link->X && Decimator->X<Link->X+16)
                 && (Decimator->Y<=Link->Y+16 && Decimator->Y>=Link->Y))
                {UseDeci=0; Deci->DeadState=WDS_DEAD; Decimator->Data=29;}
            else if((Decimator->X>Link->X+16 || Decimator->X<Link->X)
            || (Decimator->Y>Link->Y+16 || Decimator->Y<Link->Y))
                {Decimator->Vx=(Link->X-Decimator->X)/Distance(Link->X, Link->Y, Decimator->X, Decimator->Y)*4;
                Decimator->Vy=(Link->Y-Decimator->Y)/Distance(Link->X, Link->Y, Decimator->X, Decimator->Y)*4;}
            
        Waitframe();
        }
        }
}


so basically it homes in on every enemy, one at a time, and leaves a trail behind it that also damages/kills anything that walks into it that can be hurt by that type of damage. Looks cool with a small circle combo or other thing for laser type, or like I have it in my game, a big circular-saw looking grappler leading and left behind is a smaller spinning chain link looking deal that was originally a shuriken.
If someone has time to try the script out, and/or figure out a way to get Link to catch and be able to use the item again that would be awesome. I'll continue working on it later when I get a chance but I know some of you guys already know how to do that.
A previous version of this script made it so that when the item comes back to link, it would hover around him, but not catch, and then the trail of weapons on the screen would dissapear in the order they appeared.


#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 01 May 2010 - 01:32 AM

Not really answering your question about the boomerang thing, but just pointing out that zscript can handle recursion up to a depth of about 50 or so, so you could replace all the hunt methods with a single function:
CODE

void Hunt(int recur)
        {
        while(true)
        {
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=30;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        npc J=Screen->LoadNPC(recur);
        if(!J->isValid())
            { Hunt(recur+1);}
            
            if(Decimator->X!=J->X || Decimator->Y!=J->Y)
                {Decimator->Vx=(J->X-Decimator->X)/Distance(J->X, J->Y, Decimator->X, Decimator->Y)*3;
                Decimator->Vy=(J->Y-Decimator->Y)/Distance(J->X, J->Y,Decimator->X, Decimator->Y)*3;}
            else if(Decimator->X==J->X && Decimator->Y==J->Y){
      if(recur<12)
                {Game->Counter[10]+=1; Hunt(recur+1);}
     }
    else if((Decimator->X>Link->X+16 || Decimator->X<Link->X)
            || (Decimator->Y>Link->Y+16 || Decimator->Y<Link->Y))
                {Decimator->Vx=(Link->X-Decimator->X)/Distance(Link->X, Link->Y, Decimator->X, Decimator->Y)*4;
                Decimator->Vy=(Link->Y-Decimator->Y)/Distance(Link->X, Link->Y, Decimator->X, Decimator->Y)*4;}
        Waitframe();    
        }
        }

Edited by Gleeok, 01 May 2010 - 01:33 AM.


#3 Zim

Zim

    Freelance Nobody

  • Members
  • Real Name:Zim
  • Location:Washington

Posted 01 May 2010 - 05:37 PM

Oh, I wasn't aware of that.
Thanks again Gleeok.
I'm glad to be back into Scripting for ZC.. and played your Grikirugun game yesterday too. It's pretty fun.
I managed to get a few different versions of this script to work, much more condensed..
I will post them shortly.

CODE


import "std.zh"





item script Decimator
{
void run()
    {

if(UseDeci > 0) return;
int hitcount=0;
UseDeci=1;

}
}


int hitcount;
int UseDeci;        

global script Slot_2    
{
    void run()
    {
    UseDeci = 0;
    while(true)
        {
        Decimate();
        Waitframe();
            }
    }

        }
    void Decimate()
        {
        lweapon Deci=Deci();
        if(UseDeci==0 && hitcount==0)
            {Deci->DeadState = WDS_DEAD; return;}
        else if(UseDeci==1 && hitcount==0)
            {Throw();}
        else if(UseDeci==1 && hitcount==1)
            {UseDeci=0; hitcount=0; return;}
        }
    void Throw()                                    
        {
        if(hitcount==1){return;}
        else
        lweapon Deci=Deci();
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=28;
        Decimator->CSet=10;
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        Decimator->X=Link->X;
        Decimator->Y=Link->Y;
        npc Ab=Screen->LoadNPC(1); npc Bb=Screen->LoadNPC(2); npc Cb=Screen->LoadNPC(3);
        npc Db=Screen->LoadNPC(4); npc Eb=Screen->LoadNPC(5); npc Fb=Screen->LoadNPC(6);
        npc Gb=Screen->LoadNPC(7); npc Hb=Screen->LoadNPC(8); npc Ib=Screen->LoadNPC(9);
        npc Jb=Screen->LoadNPC(10);
    if(Ab->isValid() || Bb->isValid() || Cb->isValid() || Db->isValid() || Eb->isValid()
    || Fb->isValid() || Gb->isValid() || Hb->isValid() || Ib->isValid() || Jb->isValid())    
            {Hunt1();}
    else if(!Ab->isValid() && !Bb->isValid() && !Cb->isValid() && !Db->isValid()
    && !Eb->isValid() && !Fb->isValid() && !Gb->isValid() && !Hb->isValid()
    && !Ib->isValid() && !Jb->isValid())    
             {Hunt2();}
            
        }
        
        
        
    lweapon Deci()
        {    
        lweapon a;
        for(int i=1;i<=Screen->NumLWeapons();i++)
            {
            a = Screen->LoadLWeapon(i);
        if(a->ID == LW_SCRIPT1) return a;
            a = Screen->CreateLWeapon(LW_SCRIPT1);
            a->Damage = 16;
            a->UseSprite(100);
            return a;
            }
        }                                                                                                                                                                                                                                                                                                            
    void Hunt1()
        {
        npc Ab=Screen->LoadNPC(Rand(10)); npc Bb=Screen->LoadNPC(2); npc Cb=Screen->LoadNPC(3);
        npc Db=Screen->LoadNPC(4); npc Eb=Screen->LoadNPC(5); npc Fb=Screen->LoadNPC(6);
        npc Gb=Screen->LoadNPC(7); npc Hb=Screen->LoadNPC(8); npc Ib=Screen->LoadNPC(9);
        npc Jb=Screen->LoadNPC(10);
        ffc Decimator=Screen->LoadFFC(32);

        while(true)    
            {
            if(!Ab->isValid()){return;}
                Decimator->Data=30;
                Decimator->CSet=10;
                lweapon Deci=Screen->CreateLWeapon(LW_SCRIPT1);
                Deci->UseSprite(100);
                Deci->X=Decimator->X;
                Deci->Y=Decimator->Y;
                Deci->Damage=32;
                Deci->HitHeight=16;
                Deci->HitWidth=16;
    
            if((Decimator->X!=Ab->X || Decimator->Y!=Ab->Y) && Ab->isValid())
                {
                Decimator->Vx=(Ab->X-Decimator->X)/Distance(Ab->X, Ab->Y, Decimator->X, Decimator->Y)*7;
                Decimator->Vy=(Ab->Y-Decimator->Y)/Distance(Ab->X, Ab->Y,Decimator->X, Decimator->Y)*7;
                Waitframes(4);
                }
            Waitframe();
            }    
        }
    void Hunt2()
        {
        if(UseDeci==0){Quit();}
        else
        {ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=28;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
            if((Decimator->X>=Link->X && Decimator->X<Link->X+16)
                 && (Decimator->Y<=Link->Y+16 && Decimator->Y>=Link->Y))
                {UseDeci=0; hitcount+=1; Deci->DeadState=WDS_DEAD; Decimator->Data=1; return;}
            else if((Decimator->X>Link->X+16 || Decimator->X<Link->X)
            || (Decimator->Y>Link->Y+16 || Decimator->Y<Link->Y))
                {Decimator->Vx=(Link->X-Decimator->X)/Distance(Link->X, Link->Y, Decimator->X, Decimator->Y)*4;
                Decimator->Vy=(Link->Y-Decimator->Y)/Distance(Link->X, Link->Y, Decimator->X, Decimator->Y)*4; return;}
        }
        }    
        
}

    


This one works. Fires from Link to towards the enemies repeatedly. If Waitframes() is set to lesser amounts, the weapon fires at a random target, goes out a few tiles, then dissapears, and Link fires again. There is a weapon left behind link as he walks that dissapears after the weapon stops firing and the player presses the item button again or goes off screen.
This version IS reasuable.

Another version of this code fired out and homed a target until it was dead, then it refires again from Link's
x,y.

The final goal was one that shoots, hits every target, and returns.
I made one that does that exact thing too, but so far haven't been able to reuse the item.

This would make an excellent weapon for a shooter style game like your Gleeok.
And you're welcome to it for all the times you've helped me learn this stuff.














QUOTE

recursion up to a depth of about 50 or so


Ok, I am trying recursion, and it looks like it should work.. But where my Hunt() function is called to start with is now saying it's not matching type signatures.. When I put Hunt(int recur) for the original call to the function, it says it's unexpected float. icon_biggrin.gif even though clearly I am intending for it to be an integer....

CODE

import "std.zh"

item script Decimator
{
void run()
    {

if(UseDeci > 0) return;
int hitcount=0;
UseDeci=1;

}
}


int throw;
int hitcount;
int UseDeci;        
global script Slot_2    
{
    void run()
    {
    UseDeci = 0;
    while(true)
        {
        Decimate();
        Waitframe();
        }
    }

    void Decimate()
        {
        lweapon Deci=Deci();
        if(UseDeci==0 && hitcount==0)
            {Deci->DeadState = WDS_DEAD; return;}
        else if(UseDeci==1 && hitcount==0)
            {Throw();}
        else if(UseDeci==1 && hitcount==1)
            {UseDeci=0; hitcount=0; return;}
        }
    void Throw()                                    
        {
        if(throw==0){throw=1;}
        if(hitcount==1){return;}
        else
        lweapon Deci=Deci();
        ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=28;
        Decimator->CSet=10;
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
        npc Ab=Screen->LoadNPC(1); npc Bb=Screen->LoadNPC(2); npc Cb=Screen->LoadNPC(3);
        npc Db=Screen->LoadNPC(4); npc Eb=Screen->LoadNPC(5); npc Fb=Screen->LoadNPC(6);
        npc Gb=Screen->LoadNPC(7); npc Hb=Screen->LoadNPC(8); npc Ib=Screen->LoadNPC(9);
        npc Jb=Screen->LoadNPC(10);
    if(throw==1 && (Ab->isValid() || Bb->isValid() || Cb->isValid() || Db->isValid() || Eb->isValid()
    || Fb->isValid() || Gb->isValid() || Hb->isValid() || Ib->isValid() || Jb->isValid()))    
            {Decimator->Y=Link->Y; Decimator->X=Link->X; Hunt1(); throw=2;}//throw <-- so ffc starts at link once
    else if(throw==1 && (!Ab->isValid() && !Bb->isValid() && !Cb->isValid() && !Db->isValid()
    && !Eb->isValid() && !Fb->isValid() && !Gb->isValid() && !Hb->isValid()
    && !Ib->isValid() && !Jb->isValid()))    
             {Hunt2();}
    if(throw==2 && (Ab->isValid() || Bb->isValid() || Cb->isValid() || Db->isValid() || Eb->isValid()
    || Fb->isValid() || Gb->isValid() || Hb->isValid() || Ib->isValid() || Jb->isValid()))    
            {Hunt1();}
    else if(throw==2 && (!Ab->isValid() && !Bb->isValid() && !Cb->isValid() && !Db->isValid()
    && !Eb->isValid() && !Fb->isValid() && !Gb->isValid() && !Hb->isValid()
    && !Ib->isValid() && !Jb->isValid()))    
             {Hunt2();}
        }
        
        
        
        
    lweapon Deci()
        {    
        lweapon a;
        for(int i=1;i<=Screen->NumLWeapons();i++)
            {
            a = Screen->LoadLWeapon(i);
        if(a->ID == LW_SCRIPT1) return a;
            a = Screen->CreateLWeapon(LW_SCRIPT1);
            a->Damage = 16;
            a->UseSprite(100);
            return a;
            }
        }                                                                                                                                                                                                                                                                                                            
    void Hunt1()
        {
        npc Ab=Screen->LoadNPC(Rand(10));
        ffc Decimator=Screen->LoadFFC(32);

        while(true)    
            {
            if(!Ab->isValid()){return;}
                Decimator->Data=30;
                Decimator->CSet=10;
                lweapon Deci=Screen->CreateLWeapon(LW_SCRIPT1);
                Deci->UseSprite(100);
                Deci->X=Decimator->X;
                Deci->Y=Decimator->Y;
                Deci->Damage=32;
                Deci->HitHeight=16;
                Deci->HitWidth=16;
    
            if((Decimator->X!=Ab->X || Decimator->Y!=Ab->Y) && Ab->isValid())
                {
                Decimator->Vx=(Ab->X-Decimator->X)/Distance(Ab->X, Ab->Y, Decimator->X, Decimator->Y)*7;
                Decimator->Vy=(Ab->Y-Decimator->Y)/Distance(Ab->X, Ab->Y,Decimator->X, Decimator->Y)*7;
                Waitframe(); //change to Waitframes(int); for delay between targeting.
                }
            Waitframe();
            }    
        }
    void Hunt2()
        {
        if(UseDeci==0){Quit();}
        else
        {ffc Decimator=Screen->LoadFFC(32);
        Decimator->Data=28;
        Decimator->CSet=10;
        lweapon Deci=Deci();
        Deci->X=Decimator->X;
        Deci->Y=Decimator->Y;
            if((Decimator->X>=Link->X && Decimator->X<Link->X+16)
                 && (Decimator->Y<=Link->Y+16 && Decimator->Y>=Link->Y))
                {throw=0; UseDeci=0; hitcount+=1; Deci->DeadState=WDS_DEAD; Decimator->Data=1; return;}
            else if((Decimator->X>Link->X+16 || Decimator->X<Link->X)
            || (Decimator->Y>Link->Y+16 || Decimator->Y<Link->Y))
                {Decimator->Vx=(Link->X-Decimator->X)/Distance(Link->X, Link->Y, Decimator->X, Decimator->Y)*4;
                Decimator->Vy=(Link->Y-Decimator->Y)/Distance(Link->X, Link->Y, Decimator->X, Decimator->Y)*4; return;}
        }
        }
}



Alright, although I did get a few versions with the recursion method that worked out..
this one I like best because it targets randomly though. Leaves a damage sprite at every target, and clears them all out when they're gone. Would be great for big amounts of spawning enemies maybe...

#4 Drewby3

Drewby3

    veteran member

  • Members

Posted 05 May 2010 - 05:07 PM

Zim can you do some scripting for me I am currently trying to learn it but until I do learn it can you do a few things for me? also if you don't mind can one of you help me on a quest

#5 Zim

Zim

    Freelance Nobody

  • Members
  • Real Name:Zim
  • Location:Washington

Posted 05 May 2010 - 07:32 PM

Sure Drewby, I'd be glad to help. But it depends on the task and what you need scripted.
Although my scripting skill and knowledge grows every day I put in some effort, it is still limited to some degree.
For example, although a Sword type weapon "isn't possible" to script, I scripted out a weapon that attacks almost exactly like the sword, except fort that it's faster, 2 frames, and my character just lunges forward, punches directly in front of him, and jumps back to the original position, and the attack happens so fast there isn't any turning mid-attack like one can with the sword.
PM or reply here with details about what you have in mind though Drewby. icon_smile.gif
If you are asking for simple script s I can bust them out for you real quick.. If they are complex and a big task, I'll do them when I have time or if they interest me enough.


#6 Drewby3

Drewby3

    veteran member

  • Members

Posted 05 May 2010 - 08:53 PM

ok thanks well since you can't do complex scripts then I will just list the simple ones that I have asked, the things I would like are a script that allows link to pick up a white rock and boulder for the level 1 bracelet, and a black rock and boulder for level 2 bracelet Like in ALTTP. the second item is a grappling that allows you to steal an item from an enemy. the third thing is a fan that creates a whirlwind that multiplies a sword beam, or wand fire rod or ice rod beam and it sends it in all directions, it will also toss a bomb to a random location if you toss in a regular bomb, and it does the same with an arrow send it in a random location. and my final item idea is a homing boomerang that the level 1 item homes in on and stuns 1 enemy and level 2 homes in on and stuns 3 enemies.

#7 Zim

Zim

    Freelance Nobody

  • Members
  • Real Name:Zim
  • Location:Washington

Posted 06 May 2010 - 06:18 PM

Well, I have the boomerang almost done, and the hookshot should be easy enough...

The boomerang will have a lock-on system kindof like the Gale Boomerang, i.e. you hold down the B button, a cursor goes over the enemys, L&R cycle targets, A inputs targets, after 3 targets selected, the boomerang goes out and hits the enemies and then returns.

Just hammering out some kinks before I submit it.

#8 Drewby3

Drewby3

    veteran member

  • Members

Posted 11 May 2010 - 11:21 PM

is it done yet? and if you post them in the scripting database can you give me credit for the ideas?

Edited by Drewby3, 11 May 2010 - 11:23 PM.


#9 Zim

Zim

    Freelance Nobody

  • Members
  • Real Name:Zim
  • Location:Washington

Posted 12 May 2010 - 01:04 PM

Well in all actuality the homing boomerang you asked for is already done, and is the topic of this thread...
I'll adjust it for you and make it lock on to only one enemy at a time though, and then three...
Give me awhile.
I just finished a hookshot that script, can change radius with L and R to retract or extend the length of the chain, with a grapple hook on the end, that can grapple onto Hookshot Only combo type combos and pull link in towards them.
Pretty shnazzy. icon_smile.gif


Ok, about the hookshot stealing the items.. This is totally doable, except for that it would help me to know how you want it set up, and it won't be like a conventional hookshot, more like a yo-yo, or like my grapple hook is, a rotating deal. Scripting hookshots is otherwise "not allowed."
The editor won't allow for a hookshot type weapon to be called into the game.
So instead, I used the call to a combotype, freeze the weapon on the target, use an ffc to carry link to the target. Same effect as a hookshot, but can be used in more than just straight-lines.
Anyway, you'd have to either have the enemy with the item you want to steal always be a certain one on the list, or I could make an ffc script with an argument that sets which npc that is for each screen with a stealable item, which could also set the item that would be stolen...
All I would have to do is set a script so that when the collision happens between the hook and the enemy, the item appears, and stays with the hook, until you pull it in. (Which, btw, my grapple hook doesn't pull in by itself, you have to either hold L to shorten the rope, or hold L and R together to zip it back in instantly.
I think I am going to try and script another feature so that it doesn't automatically pull the player to the hooks, or latchable items, etc... but can also attempt to pull things to the player, or pull the player towards the grappled target if not pullable, and even swing in the air when not on the ground.
It's all doable, it will just take some time.


#10 Mitchfork

Mitchfork

    no fun. not ever.

  • Members
  • Real Name:Mitch
  • Location:Alabama

Posted 13 May 2010 - 12:10 PM

Drewby3, please remember: keep discussions on-topic. You can very easily communicate with Zim through PM.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users