Jump to content

Photo

[Global/Item] Lock-On Bomb


  • Please log in to reply
9 replies to this topic

#1 Zim

Zim

    Junior

  • Members
  • Real Name:Zim
  • Gender:Male
  • Location:Washington

Posted 08 May 2010 - 04:26 AM

CODE

const int CR_BOMLVL=16; //preferedly in another file and imported.

global script BomScript
{
void run()
    {
    while(true)
        {
        LockBoom(); //make it happen every frame.
        Waitframe();
        }
    }    
    
    void LockBoom()
    {
    npc tA=Screen->LoadNPC(npcA); //load npcs with 'n' values to be determined later in script.
    npc tB=Screen->LoadNPC(npcB);//these two npcs are given values pressing A.
    npc tC=Screen->LoadNPC(r);//this one too, but it's the third one.
    ffc T=Screen->LoadFFC(28); // The "lock-on" graphic.
    T->Data=1; // No graphic. Set this to blank combo.
    T->CSet=6; //unimportant personal information.<-optional.
    npc oot=Screen->LoadNPC(r); //another npc that will be reassigned multiple times by variable r.
    if(UseBoo>=1)
    {

    
    if(trigC==0) //Getting started...
        {
        if(Link->InputB)//Link is holding B.
            {
            if(Link->InputL)
                {
                r-=1;
                
                if(r==0)
                    {r=NumNPCs();}
                Waitframes(5);
                }
            if(Link->InputR)
                {
                r+=1;
                if(r==NumNPCs()+1)
                    {r=1;}
                Waitframes(5);    
                }
//Since Link pressed L or R, the r variable reassigns NPC "oot."
            T->Data=28; //since Link is targeting now, the target ffc is now somthing.
            T->X=oot->X; T->Y=oot->Y; //and is centered on the NPC "oot"
            if(Link->InputA && oot->isValid() && trigA==0
            && trigB==0)
                {T->CSet+=1; trigA=1; npcA=r; Waitframes(5);}
//So when Link presses A, the CSet Flashes,  NPC "tA" is assigned the value of r also, until item is used again
            if(Link->InputA && oot->isValid() && trigA==1
            && trigB==0)
                {T->CSet+=1; trigB=1; npcB=r; Waitframes(5);}
//Same story, but now NPC tB is assigned a value of "r". Link can/could still press L or R to switch NPCs.
            if(Link->InputA && oot->isValid() && trigA==1
            && trigB==1)
                {T->CSet+=1; T->X=Link->X; T->Y=Link->Y; trigA=0; trigB=0; trigC=1; Waitframes(5);}
//third NPC selection done, moving on to fun fun boom boom
            if(Link->InputA && !oot->isValid())
                {
                trigA=0; trigB=0; trigC=0; npcA=0; npcB=0; r=1;  
                UseBoo=-1; trigc=0;
                } //unless for some reason there isn't a baddie...
            }
        if(!Link->InputB)
            {UseBoo=-1; trigA=0; trigB=0; trigC=0; trigc=0;}
//if Link stopped holding B before he selected with A three times, no Boom Boom.
        }
    if(trigC==1 && triga==0)
        {//Here it is!
        trigc=0;
        if(Link->InputB)//still holding B, ready to boom boom.
            {
            T->Y=Link->Y;
            T->X=Link->X;
            T->Data=28;
//Set this to either blank or a combo that makes sense.
            T->CSet=9;
            }
        if(!Link->InputB)//let go of B.
            {
            lweapon bom2=CreateLWeaponAt(4, tA->X, tA->Y); bom2->Damage=Game->Counter[16]*4;
            lweapon bom3=CreateLWeaponAt(4, tB->X, tB->Y); bom3->Damage=Game->Counter[16]*4;
            lweapon bom4=CreateLWeaponAt(4, tC->X, tC->Y); bom4->Damage=Game->Counter[16]*4;
            UseBoo=-1; trigA=0; trigB=0; trigC=0; npcA=0; npcB=0; r=1;
                }
            //BOOM BOOM.
//Oh, and take the Damage=Game->Counter[16]*4 out if you
//like and replace it with Damage=(any multiple of 4).
//I like to use counters for upgradable damage on the
//weapons I script so the player can gain "levels" with the
//items instead of getting an item with a higher level every
//time.        

        }
    }
    if(UseBoo<=0)
    {return;}        
    }

}
item script Lock-On Bomb
{
void run()
    {
    triga=0; trigb=0; trigc=0;
    trigA=0; trigB=0; trigC=0;//reset all variables on item use.
    npcA=0; npcB=0; npcC=0;
    if(UseBoo<=0)
    {UseBoo=1; r=1;}
    }
}



So, I came up with this in my quest for the perfect lock-on/homing boomerang..

The lock-on feature is the main thing I wanted to share, as this script and function can be modified for use in many other scripts for weapons, movements, etc etc.

On another note, this script, if being combined with other globals, should have the "LockBoom" function at the end of the global main body of script, because it contains Waitframes() that would stop the rest of the global from running if LockBoom() comes before other functions or body of script.
If you can combine globals, you probably already knew that. ;D

#2 Joe123

Joe123

    Retired

  • Members
  • Gender:Male

Posted 08 May 2010 - 05:51 AM

You know that 'FindMaxEnum'? There is already a way to do it, if you look in ZScript.txt there's a built in variable called 'Screen->NumNPCs()', that'll tell you how many enemies are on the screen at all times.
Also if you put Waitframe at any point in LockBoom it stops it from working properly with other global scripts, it makes no difference what order you call the functions in.

#3 Zim

Zim

    Junior

  • Members
  • Real Name:Zim
  • Gender:Male
  • Location:Washington

Posted 08 May 2010 - 04:56 PM

CODE

import "std.zh"
int UseBoo;
const int CR_BOMLVL=16;

item script LockBomb
{
void run()
    {
    triga=0; trigb=0; trigc=0;
    trigA=0; trigB=0; trigC=0;
    npcA=0; npcB=0; npcC=0; npcNum=0;
    if(UseBoo<=0)
    {UseBoo=1; r=1;}
    }
}
int triga; int trigb; int trigc;
int npcA; int npcB;
int r; int trigA; int trigB; int trigC;
int tic;
global script Slot_2    
{
    void run()
    {
    if(r==0){r=1;}
    if(Game->Counter[16]==0) {Game->Counter[16]=2;}
    ffc Power=Screen->LoadFFC(20);
    UseBoo=0;
    if(tic>0) {tic=0;}
    while(true)
        {
        LockBom();
        Waitframe();
            }
    }
    void LockBom()
    {
    if(UseBoo==-1)
    npc tA=Screen->LoadNPC(npcA);
    npc tB=Screen->LoadNPC(npcB);
    npc tC=Screen->LoadNPC(r);
    ffc T=Screen->LoadFFC(28);
    T->Data=1;
    T->CSet=6;
    ffc t4=Screen->LoadFFC(24);
    ffc t2=Screen->LoadFFC(26);
    ffc t3=Screen->LoadFFC(25);
    npc oot=Screen->LoadNPC(r);
    
    if(UseBoo>=1)
    {
    if(tic>0)
        {tic-=1; return;}
    if(trigC==0)
        {
        if(Link->InputB)
            {
            if(Link->InputL)
                {
                r-=1;
                if(r==0)                                                
                    {r=Screen->NumNPCs();}
                tic=5; return;
                }
            if(Link->InputR)
                {
                r+=1;
                if(r==Screen->NumNPCs()+1)
                    {r=1;}
                tic=5; return;
                }
            T->Data=28;
            T->X=oot->X; T->Y=oot->Y;
            if(Link->InputA && oot->isValid() && trigA==0
            && trigB==0)
                {T->CSet+=1; trigA=1; npcA=r; tic=5; return;}
            if(Link->InputA && oot->isValid() && trigA==1
            && trigB==0)
                {T->CSet+=1; trigB=1; npcB=r; tic=5; return;}
            if(Link->InputA && oot->isValid() && trigA==1
            && trigB==1)
                {T->CSet+=1; T->X=Link->X; T->Y=Link->Y; trigA=0; trigB=0; trigC=1; tic=5; return;}
            if(Link->InputA && !oot->isValid())
                {
                trigA=0; trigB=0; trigC=0; npcA=0; npcB=0; r=1;  
                UseBoo=-1; trigc=0;
                }
            }
        if(!Link->InputB)
            {UseBoo=-1; trigA=0; trigB=0; trigC=0; trigc=0;}
        }
    if(trigC==1 && triga==0)
        {
        trigc=0;
        if(Link->InputB)
            {
            t4->X=tA->X; t4->Y=tA->Y; t4->Data=60; t4->CSet+=1;
            t2->X=tB->X; t2->Y=tB->Y; t2->Data=60; t2->CSet+=1;
            t3->X=tC->X; t3->Y=tC->Y; t3->Data=60; t3->CSet+=1;
            T->X=Link->X;
            T->Y=Link->Y;
            T->Data=28;
            T->CSet=9;
            }
        if(!Link->InputB)
            {
            lweapon bom2=CreateLWeaponAt(4, tA->X, tA->Y); bom2->Damage=Game->Counter[16]*4;
            lweapon bom3=CreateLWeaponAt(4, tB->X, tB->Y); bom3->Damage=Game->Counter[16]*4;
            lweapon bom4=CreateLWeaponAt(4, tC->X, tC->Y); bom4->Damage=Game->Counter[16]*4;
            UseBoo=-1; trigA=0; trigB=0; trigC=0; npcA=0; npcB=0; r=1;
            t4->Data=0; t2->Data=0; t3->Data=0;
            }

        }
    }
    if(UseBoo<=0)
    {return;}        
    }
}


Okay, I remodeled the script to not have waitframes, and to use Screen->NumNPCs() instead,
as it makes much more sense to do that.
Also, after lock-on to three targets, the target appears over all three targets while the bombs are armed,
and flashes until the player releases B.

Assign item script to item, put in inventory.
!!!ONLY WORKS WHEN ASSIGNED TO B!!!
Player holds B, a cursor comes up, when player presses A, selection occurs. L and R move cursor to
different NPC.
Player selects three NPCS, Targets appear while still holding B.
Player releases B, Bombs appear on the three targets.

icon_heh.gif

Edited by Zim, 08 May 2010 - 04:57 PM.


#4 Drewby3

Drewby3

    Junior

  • Members

Posted 12 May 2010 - 11:35 AM

Zim I would appreciate it if you at least give me credit for my ideas. I had thought of that plus a couple of other ideas Joe123 if only I knew how to script

Edited by Drewby3, 12 May 2010 - 11:36 AM.


#5 Zim

Zim

    Junior

  • Members
  • Real Name:Zim
  • Gender:Male
  • Location:Washington

Posted 15 May 2010 - 04:47 PM

I'll give you credit for the idea of a hookshot that steals, if and when I have the time to script that into my game, and loan you the script.
Other than that, I was already working on the homing/lock on boomerang before I started conversing with you, and the grapple hook I made is my idea also, aside from that it would steal. (which it does not yet.)
Although, it does drag NPCs with hookshot defense enabled, and ffcs with the solid flag equalling true, when the ex2 button is held.
So it is now capable of retracting/extending with L and R, it can latch onto enemies with hookshot defense enabled, and ffcs with the solid flag, and combotypes Hookshot Only, and pull the player towards the enemy or ffc, or if Ex2 is held also, it pulls the enemy or ffc, but not combotype Hookshot Only, with it in it's movement.
Will make for some cool puzzles, and some enemies that can only die if you latch them and swing them into a pit or spikes or whatnot.

This deserves it's own topic, but I am going to wait a few more days to publish a demo along with the thread, to display some possibilities of it's capability.

#6 Joe123

Joe123

    Retired

  • Members
  • Gender:Male

Posted 26 May 2010 - 02:02 AM

When I try to compile I'm getting an error, apparently 'npcC' and 'npcNum' are undeclared in the 'LockBomb' script.

#7 Zim

Zim

    Junior

  • Members
  • Real Name:Zim
  • Gender:Male
  • Location:Washington

Posted 18 June 2010 - 12:00 PM

CODE
int UseBoo;
const int CR_BOMLVL=16;

item script LockBomb
{
void run()
    {
    triga=0; trigb=0; trigc=0; trigA=0; trigB=0; trigC=0;  npcA=0; npcB=0;
     if(UseBoo<=0)
    {UseBoo=1; r=1;}
    }
}
int triga; int trigb; int trigc;
int npcA; int npcB;
int r; int trigA; int trigB; int trigC;
int tic;
global script Slot_2    
{
    void run()
    {
    if(r==0){r=1;}
    if(Game->Counter[16]==0) {Game->Counter[16]=2;}
    ffc Power=Screen->LoadFFC(20);
    UseBoo=0;
    if(tic>0) {tic=0;}
    while(true)
        {
        LockBom();
        Waitframe();
            }
    }
    void LockBom()
    {
    if(UseBoo==-1)
    npc tA=Screen->LoadNPC(npcA);
    npc tB=Screen->LoadNPC(npcB);
    npc tC=Screen->LoadNPC(r);
    ffc T=Screen->LoadFFC(28);
    T->Data=1;
    T->CSet=6;
    ffc t4=Screen->LoadFFC(24);
    ffc t2=Screen->LoadFFC(26);
    ffc t3=Screen->LoadFFC(25);
    npc oot=Screen->LoadNPC(r);
    
    if(UseBoo>=1)
    {
    if(tic>0)
        {tic-=1; return;}
    if(trigC==0)
        {
        if(Link->InputB)
            {
            if(Link->InputL)
                {
                r-=1;
                if(r==0)                                                
                    {r=Screen->NumNPCs();}
                tic=5; return;
                }
            if(Link->InputR)
                {
                r+=1;
                if(r==Screen->NumNPCs()+1)
                    {r=1;}
                tic=5; return;
                }
            T->Data=28;
            T->X=oot->X; T->Y=oot->Y;
            if(Link->InputA && oot->isValid() && trigA==0
            && trigB==0)
                {T->CSet+=1; trigA=1; npcA=r; tic=5; return;}
            if(Link->InputA && oot->isValid() && trigA==1
            && trigB==0)
                {T->CSet+=1; trigB=1; npcB=r; tic=5; return;}
            if(Link->InputA && oot->isValid() && trigA==1
            && trigB==1)
                {T->CSet+=1; T->X=Link->X; T->Y=Link->Y; trigA=0; trigB=0; trigC=1; tic=5; return;}
            if(Link->InputA && !oot->isValid())
                {
                trigA=0; trigB=0; trigC=0; npcA=0; npcB=0; r=1;  
                UseBoo=-1; trigc=0;
                }
            }
        if(!Link->InputB)
            {UseBoo=-1; trigA=0; trigB=0; trigC=0; trigc=0;}
        }
    if(trigC==1 && triga==0)
        {
        trigc=0;
        if(Link->InputB)
            {
            t4->X=tA->X; t4->Y=tA->Y; t4->Data=60; t4->CSet+=1;
            t2->X=tB->X; t2->Y=tB->Y; t2->Data=60; t2->CSet+=1;
            t3->X=tC->X; t3->Y=tC->Y; t3->Data=60; t3->CSet+=1;
            T->X=Link->X; T->Y=Link->Y; T->Data=28;  T->CSet=9;
            }
        if(!Link->InputB)
            {
            lweapon bom2=CreateLWeaponAt(4, tA->X, tA->Y); bom2->Damage=Game->Counter[16]*4;
            lweapon bom3=CreateLWeaponAt(4, tB->X, tB->Y); bom3->Damage=Game->Counter[16]*4;
            lweapon bom4=CreateLWeaponAt(4, tC->X, tC->Y); bom4->Damage=Game->Counter[16]*4;
            UseBoo=-1; trigA=0; trigB=0; trigC=0; npcA=0; npcB=0; r=1;
            t4->Data=0; t2->Data=0; t3->Data=0;
            }

        }
    }
    if(UseBoo<=0)
    {return;}        
    }
}


Oh, my mistake. those were necisarry for a rough draft and I forgot to take them out for this version of the script. This version should work. I'll test it and repost again if it doesn't. Thanks.

#8 Joe123

Joe123

    Retired

  • Members
  • Gender:Male

Posted 28 June 2010 - 02:51 PM

I ran it through the compiler this time but I can't seem to get any functionality out of it. I tried to have a look and see how it works but your brace/indentation scheme's a bit inconsistent and it's confusing me.

#9 Zim

Zim

    Junior

  • Members
  • Real Name:Zim
  • Gender:Male
  • Location:Washington

Posted 06 October 2010 - 12:08 PM

I don't know why it wouldn't work.... It works fine here.

Setup is standard place item script on items, set combo for ffc for the cursor...

Also, it's set up so that the player has to hold the B button, and make 3 target selections, switching targets with Ex1 and Ex2, then when all three targets are selected with the A button, when the B button is released they all go kablooey.

I left my flash drive at a friend's house with all my demos and scripts on it... I intend to get back into beta testing and scripting this winter...
When I get it back I'll post up a demo showing the function.

#10 SpacemanDan

SpacemanDan

    Hrm

  • Global Moderators
  • Real Name:Daniel
  • Gender:Male
  • Location:Canada
  • Past Nicks:Blaman

Posted 20 July 2011 - 07:38 PM

I can't get any functionality of it either. I imported it as is, and tested with no results. Using RC 1 though.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users