Jump to content

Photo

Bomb Arrow Script


  • Please log in to reply
19 replies to this topic

#1 Korben

Korben

    Junior

  • Members
  • Location:USA

Posted 25 May 2021 - 10:54 AM

I was looking for a bomb arrow script and found the one Joe123 made a while ago. I don't know if there is a more recent one but this is the only one I could find. 

//Input constants
const int ArrowDamage    = 2;        //Damage for Arrow to deal. Wooden sword deals 2 damage
const int BombDamage     = 8;        //Damage for explosion to deal
const int ArrowSpeed    = 300;        //Speed arrow moves at, in hundredths of pixels per frame
const int T_BOMBARROW    = 205;        //Arrange tiles in the order 'Up,Down,Left,Right' on the tilesheet. Set up-facing bomb arrow tile here

//Variables
int UseBombArrow;
int ArrowX; int ArrowY;

//Functions
//Check inherent and regular flags at the same time
bool ComboFI(int loc,int combotype){
if(Screen->ComboF[loc] == combotype
|| Screen->ComboI[loc] == combotype) return true;
}
//Solidity Check, by Saffith
bool isSolid(int x,int y){
if(x<0 || x>255 || y<0 || y>175) return false;
int mask = 1111b;
if(x%16<8) mask &= 0011b;
else mask &= 1100b;
if(y%16<8) mask &= 0101b;
else mask &= 1010b;
int ret = Screen->ComboS[ComboAt(x,y)]&mask;
return ret != 0;
}

global script Slot_2{
    void run(){
        while(true){
            //Call bomb arrow functions
            if(UseBombArrow > 0) BombArrow();
            
        Waitframe();
        }
    }
    //bomb arrow functions
    void BombArrow(){
        if(UseBombArrow == 1){
            lweapon Arrow = Screen->CreateLWeapon(LW_ARROW);
            int x; int y;
            if(Link->Dir > 1) x = (Link->Dir-2)*16-8;
            else y = Link->Dir*16-8;
            Arrow->X = Link->X+x;
            Arrow->Y = Link->Y+y;
            Arrow->Dir = Link->Dir;
            Arrow->Tile = T_BOMBARROW;
            Arrow->Tile += Link->Dir;
            
            Arrow->Damage = ArrowDamage;
            Arrow->Step = ArrowSpeed;
            Game->PlaySound(SFX_ARROW);
            Link->Action = LA_ATTACKING;
            UseBombArrow++;
        }else{
            lweapon Arrow;
            bool Found;
            for(int i=1;i<=Screen->NumLWeapons();i++){
                Arrow = Screen->LoadLWeapon(i);
                if(Arrow->ID != LW_ARROW) continue;
                Found = true;
            }
            if(Found){
                ArrowX = Arrow->X;
                ArrowY = Arrow->Y;
                for(int j=-4;j<=4;j+=4){
                    for(int k=-4;k<=4;k+=4){
                        if(isSolid(Arrow->X+8+j,Arrow->Y+8+k)
                        || ComboFI(ComboAt(Arrow->X+8+j,Arrow->Y+8+k),CF_BOMB)) Arrow->DeadState = 0;
                    }
                }
            }else{
                lweapon Exp = Screen->CreateLWeapon(LW_BOMBBLAST);
                Exp->Damage = BombDamage;
                Exp->X = ArrowX;
                Exp->Y = ArrowY;
                UseBombArrow = 0;
            }
        }
    }
}

item script BombArrows{
    void run(){
        if(Game->Counter[CR_BOMBS] > 0 && Game->Counter[CR_ARROWS] > 0 && UseBombArrow == 0){
            UseBombArrow++;
            Game->Counter[CR_BOMBS]--;
            Game->Counter[CR_ARROWS]--;
        }
    }
}

When I try to compile it in zquest it says "Syntax Error, Unexpected Semicolon [Line 1458 Column 24 '('] - Error P000: Can't Parse The Main Buffer! Aborting"

 

I am using Moosh's global script organizer and multiple other scripts, so in the base Bomb Arrow script line 1458 is 39, the one that says "void BombArrow(){". 

 

I am using zquest version 2.55 alpha 92.



#2 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 25 May 2021 - 01:42 PM

oh, yikes, this one is really old; this was made before isSolid was internal (that's... really freaking old).

That said... huh? Wha? I don't understand why it's throwing the error. The error says it's a semicolon, but it's pointing at the '('? That's not a semicolon, that's a parenthesis...

Could you check your script file and make sure that that specific line doesn't have a semicolon or an extra character at the end? The last character should be {, but sometimes invisible characters show up.



#3 Korben

Korben

    Junior

  • Members
  • Location:USA

Posted 25 May 2021 - 01:54 PM

oh, yikes, this one is really old; this was made before isSolid was internal (that's... really freaking old).

That said... huh? Wha? I don't understand why it's throwing the error. The error says it's a semicolon, but it's pointing at the '('? That's not a semicolon, that's a parenthesis...

Could you check your script file and make sure that that specific line doesn't have a semicolon or an extra character at the end? The last character should be {, but sometimes invisible characters show up.

 

Yup the last character is "{" in my script file. That line is just "void BombArrow(){".



#4 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 25 May 2021 - 02:38 PM

Can you post an exact screenshot of the compile error? And pastebin your script file? (https://pastebin.com/)



#5 Korben

Korben

    Junior

  • Members
  • Location:USA

Posted 25 May 2021 - 02:52 PM

Can you post an exact screenshot of the compile error? And pastebin your script file? (https://pastebin.com/)

 

Sure.

 

https://imgur.com/DnkonIw

 

https://pastebin.com/Psdv5TDr

 

Thanks for taking a look.



#6 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 25 May 2021 - 03:07 PM

Ah. You are trying to declare the function 'BombArrow()' INSIDE the function 'run()'. You cannot declare a function inside another function.

 

Here, this should fix it: https://pastebin.com/gJA18Fm1



#7 Korben

Korben

    Junior

  • Members
  • Location:USA

Posted 25 May 2021 - 04:01 PM

Ah. You are trying to declare the function 'BombArrow()' INSIDE the function 'run()'. You cannot declare a function inside another function.

 

Here, this should fix it: https://pastebin.com/gJA18Fm1

 

It worked, thanks! When I was trying to get the script to work before I first tried the original version, then I tried a version altered by someone else which removed the ability for bomb arrows to blow up when they hit a solid combo. I wanted to have the original version in my quest but in the pastebin the version I gave was the version without the ability to blow up on solid combos. If it isn't too much trouble could you (or someone else) restore that function? The original version of the script with the functionality is in the first post of this thread. It is probably easy to do I just know next to nothing about scripting.


Edited by Korben, 25 May 2021 - 04:01 PM.


#8 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 25 May 2021 - 05:47 PM

.....frankly, let me just write you a better script, because this thing is fucking godawful. Just give me a few.


  • Jared likes this

#9 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 25 May 2021 - 06:34 PM

https://pastebin.com/zt7mUyjw

 

That took a bit longer than I hoped.

Setup:

Spoiler

 

Also, make sure that 'ZScript->Quest Script Settings->Objects->"Weapons Live One Extra Frame With WDS_DEAD"' is checked.

 

As an lweapon script, it now no longer needs a global script portion at all, which makes setting it up a lot easier.



#10 Korben

Korben

    Junior

  • Members
  • Location:USA

Posted 25 May 2021 - 07:44 PM

https://pastebin.com/zt7mUyjw

 

That took a bit longer than I hoped.

Setup:

Spoiler

 

Also, make sure that 'ZScript->Quest Script Settings->Objects->"Weapons Live One Extra Frame With WDS_DEAD"' is checked.

 

As an lweapon script, it now no longer needs a global script portion at all, which makes setting it up a lot easier.

 

Wow, thanks for taking the time to do that! I appreciate it. I got it working, although sometimes it blows up when nothing solid is nearby. Also sometimes the bomb counter doesn't go down when I use it, and sometimes if there is a bomb arrow in the air and you press b it will take a bomb from you without shooting a bomb arrow (because one is already on screen). I think I have everything set up correctly.



#11 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 25 May 2021 - 07:57 PM

Wow, thanks for taking the time to do that! I appreciate it. I got it working, although sometimes it blows up when nothing solid is nearby. Also sometimes the bomb counter doesn't go down when I use it, and sometimes if there is a bomb arrow in the air and you press b it will take a bomb from you without shooting a bomb arrow (because one is already on screen). I think I have everything set up correctly.

Do you still have the old item script attached to the item? If so, remove that, it shouldn't still be there.

The explosions, I copied the logic from the old script. I didn't test that the logic was sound. I'll take a look at that tomorrow.



#12 Korben

Korben

    Junior

  • Members
  • Location:USA

Posted 25 May 2021 - 08:06 PM

Do you still have the old item script attached to the item? If so, remove that, it shouldn't still be there.

The explosions, I copied the logic from the old script. I didn't test that the logic was sound. I'll take a look at that tomorrow.

 

Ah I did, after removing it the same problems are occurring. Okay sounds good, thanks!



#13 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 26 May 2021 - 03:03 AM

Ah, fun times! It seems we've stumbled into a ZC bug here, where the script item types don't charge the cost.

 

It only seems to explode when it hits something for me.



#14 Korben

Korben

    Junior

  • Members
  • Location:USA

Posted 26 May 2021 - 10:12 AM

Ah, fun times! It seems we've stumbled into a ZC bug here, where the script item types don't charge the cost.

 

It only seems to explode when it hits something for me.

 

Ah, that's too bad. Should I make a post on this on the ZC bug reports forum? Or is that not necessary? Also here is an image of it exploding when not hitting anything solid. 

 

https://i.imgur.com/bST0ILt.png

 

https://i.imgur.com/RmRCsmf.png

 

It seems to be fine when shooting vertically, but if I shoot anywhere close to the bush horizontally it explodes.



#15 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 26 May 2021 - 12:12 PM

Ah, that's too bad. Should I make a post on this on the ZC bug reports forum? Or is that not necessary? Also here is an image of it exploding when not hitting anything solid. 

 

https://i.imgur.com/bST0ILt.png

 

https://i.imgur.com/RmRCsmf.png

 

It seems to be fine when shooting vertically, but if I shoot anywhere close to the bush horizontally it explodes.

Is it hitting a bomb flag?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users