I've recently been writing a bomchu script, on request by Blaman.
It's now finished, and I have a nice little tutorial that should help explain to anyone who wants to use it how to set it up.
I've also got a little example quest here: bombchu.qst
How to use the Bombchu script
By Joe123
Contents- The Tiles
- Setting up the Superbombs
- The Script
- The Items
- The Subscreen
- Notes
A. The Tiles
Firstly, find yourself some nice Bombchu tiles.
They should be able to face in four directions.
The Classic tileset has some as default, and EZGBZ may have some (cause they're in the gameboy zeldas), but I haven't checked.- Rip them on to your tilepage, and arrange them in this order:
Up, Down, Left, Right. - If you want them to animate, place the animations after the first one (ie; Up1, Up2, Down1, Down2 etc.).
- Write down the number of the first tile (so the up facing one).
B. Setting up the Superbombs
Now, you won't be using superbombs in your quest if you want bombchus, so we first have to sabotage our superbomb item.- Go to Quest->Items->Superbombs.
- Change the fuse duration of your superbomb to '3'
C. The Script- Now go to the lines in the script that are noted (have '//' before them), and change the inputs to suit your needs (putting in the number you wrote down earlier for the bombchutile input).
- Make sure to set up the number of animation frames properly here, otherwise it just won't work.
- Compile the script, and put the script called 'slot_2' into global script slot 2, and write down the number of the slot you assign the item script to.
D. The Items
This is the complicated part.- Make a new custom item with a custom itemclass, give it the bombchu item pickup graphics, and set it's action script to the bombchu script (and call it 'bombchu' or something).
- Make sure to tick the 'Equipment Item' box, and then go to your subscreen editor.
- Make another custom item called 'Bombchu Ammo' (or simmilar).
- Open up the 'Bomb Ammunition' item, and copy everything about this item over into your new 'Bombchu Ammo' item.
- On the pick-up tab, change the 'counter reference' box to '6'.
- Change its graphics to be that of a bombchu, rather than a bomb.
E. The Subscreen- On the subscreen, add a space for this new itemclass (probably over the top of your superbombs, as you won't be needing them anymore).
- Change the graphics of your super-bomb counter to be that of a bombchu.
F. Notes
It is not possible to have superbombs, bombs and bombchus; only two of the three(well, currently you can't have bombchus and superbombs, but no bombs, however I could edit the script quite easily to do that).
When giving the player the bombchus in the first place, give him the first item you made (the one with the entry on the subscreen).
Then, when you want him to pick up more bombchus, place a 'bombchu ammunition' item on the screen, which will then increase Link's number of bombchus by however much you like.
Code:
import "std.zh"
const int bombchuflag = 98; //Flag the bombchu can pass through (even if solid)
bool bombchuattack;
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;
return (!(Screen->ComboS[ComboAt(x,y)]&mask)==0);
}
bool bombchucheck(int x, int y){
if((isSolid(x,y) && Screen->ComboF[ComboAt(x,y)] != bombchuflag && Screen->ComboI[ComboAt(x,y)] != bombchuflag)
|| (Screen->ComboF[ComboAt(x,y)] == 6 || Screen->ComboI[ComboAt(x,y)] == 6 ||Screen->ComboF[ComboAt(x,y)] == 11 || Screen->ComboI[ComboAt(x,y)] == 11)) return true;
}
void noaction(){
Link->InputR = false;
Link->InputL = false;
Link->InputA = false;
Link->InputB = false;
Link->InputUp = false;
Link->InputDown = false;
Link->InputRight = false;
Link->InputLeft = false;
}
global script slot_2{
void run(){
int bombchutile = 20; //Set the tile for your weapon here. Up, Down, Left, Right it should be on the tilepage.
int bombchuframes = 2; //Set the number of animation frames here.
int bombchuaspeed = 10;//Set the animation speed here
int bombchucset = 8; //Set the CSet here
int bombchudmg = 2; //Set the damage here
int bombchuspeed = 1; //Set the speed of the bombchu here
int HP;
int bdir;
int bombchux; int bombchuy;
lweapon explosion;
while(true){
if(bombchuattack){
if(Link->X > 15 && Link->X < 241 && Link->Y > 15 && Link->Y < 153){
lweapon bombchu = Screen->CreateLWeapon(31);
bdir = Link->Dir;
bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
bombchu->Tile = bombchutile+(bdir*bombchuframes);
bombchu->NumFrames = bombchuframes;
bombchu->ASpeed = bombchuaspeed;
bombchu->CSet = bombchucset;
bombchux = 0; bombchuy = 0;
if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
if(bdir<2) bombchuy = ((bdir*2)-1)*16;
bombchu->X = Link->X+bombchux;
bombchu->Y = Link->Y+bombchuy;
bombchu->Step = bombchuspeed;
Link->Action = LA_ATTACKING;
Game->Counter[6]--;
Waitframe();
while(bombchu->isValid()){
HP = Link->HP;
if(Link->InputUp) bdir = 0;
if(Link->InputDown) bdir = 1;
if(Link->InputLeft) bdir = 2;
if(Link->InputRight) bdir = 3;
if(bdir == 0 && bombchucheck(bombchu->X+8,bombchu->Y+4)
|| (bdir == 1 && bombchucheck(bombchu->X+8,bombchu->Y+12))
|| (bdir == 2 && bombchucheck(bombchu->X+4,bombchu->Y+8))
|| (bdir == 3 && bombchucheck(bombchu->X+12,bombchu->Y+8))) bombchu->DeadState = 0;
bombchu->Dir = bdir;
bombchu->Tile = bombchutile+(bdir*bombchuframes);
bombchu->OriginalTile = bombchutile+(bdir*bombchuframes);
bombchux = bombchu->X;
bombchuy = bombchu->Y;
noaction();
Waitframe();
if(Link->HP < HP) bombchu->DeadState = 0;
}
explosion = Screen->CreateLWeapon(LW_SBOMB);
explosion->Damage = bombchudmg;
explosion->X = bombchux;
explosion->Y = bombchuy;
}else{
bdir = Link->Dir;
bombchux = 0; bombchuy = 0;
if(bdir>1) bombchux = (((bdir-2)*2)-1)*16;
if(bdir<2) bombchuy = ((bdir*2)-1)*16;
explosion = Screen->CreateLWeapon(LW_SBOMB);
explosion->X = Link->X+bombchux;
explosion->Y = Link->Y+bombchuy;
explosion->Damage = bombchudmg;
}
Link->Action = 0;
bombchuattack = false;
}
Waitframe();
}
}
}
global script slot_3{
void run(){
bombchuattack = false;
}
}
item script bombchu{
void run(){
if(Game->Counter[6] > 0) bombchuattack = true;
}
}
And there we have it.
If anyone would like to have any parts of the tutorial better explained, let me know and I'll be happy to do it.
EDIT: Changed the script a little.