CODE
//Bombchu
const int bombchuflag = 98; //Flag the bombchu can pass through (even if solid)
const int bombchutile = 21752; //Set the tile for your weapon here. Up, Down, Left, Right it should be on the tilepage.
const int bombchuframes = 2; //Set the number of animation frames here.
const int bombchuaspeed = 10;//Set the animation speed here
const int bombchucset = 7; //Set the CSet here
const int bombchudmg = 2; //Set the damage here
const int bombchuspeed = 1; //Set the speed of the bombchu here
int bombchuattack = 0;
int bombchux = 0;
int bombchuy = 0;
int bdir = 0;
//Rolling
const int DustTile = 0; //Tile for dust-kickup
const int DustCset = 0; //Cset
const int RollSFX = 0; //SFX to play when rolling
const int F_NOROLL = 98;//Flag Link can't roll onto
bool NoRoll;
int RollX[5];
int RollY[5];
int RollCounter;
int DustFrame;
//Fairy
const int CMB_FAIRY = 0; // Set here the first of the 4 Fairy combos, in the order Up, Down, Left, Right
bool HasFairy = true;
bool FairyInit = true;
int FairyMovementCounter;
int FairyMovementMax = 30;
//Climbing
const int F_LADDER = 98; //ladder flag
//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;
}
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;
}
//Checks for both placed and inherent flags on a location, to reduce checks
bool ComboFI(int x,int y,int combotype){
if(Screen->ComboF[ComboAt(x,y)] == combotype
|| Screen->ComboI[ComboAt(x,y)] == combotype) return true;
}
global script slot_2{
void run(){
bool lastL;
int ScreenNumber;
while(true){
//Call bombchu functions
if(bombchuattack == 2) run_bombchu();
if(bombchuattack == 1) start_bombchu();
//Call Roll functions
if(Link->InputL && !lastL && Link->Action == LA_WALKING && Link->Z == 0 && !NoRoll && !Epona && !Falling) Roll();
//Call the Fairy functions
if(HasFairy) Fairy(ScreenNumber);
ScreenNumber = Game->GetCurScreen();
lastL = Link->InputL;
Waitframe();
}
}
void run_bombchu() {
lweapon bombchu;
lweapon explosion;
int HP = 0;
bool found = false;
for(int i = 1; i <= Screen->NumLWeapons(); i+= 1) {
bombchu = Screen->LoadLWeapon(i);
if(bombchu->ID == LW_SCRIPT1) {
found = true;
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();
if(Link->HP < HP) bombchu->DeadState = 0;
break;
}
}
if(found == false) {
explosion = Screen->CreateLWeapon(LW_SBOMB);
explosion->Damage = bombchudmg;
explosion->X = bombchux;
explosion->Y = bombchuy;
Link->Action = 0;
bombchuattack = 0;
}
}
void start_bombchu() {
if(Link->X > 15 && Link->X < 241 && Link->Y > 15 && Link->Y < 153){
lweapon bombchu = Screen->CreateLWeapon(LW_SCRIPT1);
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]--;
bombchuattack = 2;
}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;
lweapon explosion = Screen->CreateLWeapon(LW_SBOMB);
explosion->X = Link->X+bombchux;
explosion->Y = Link->Y+bombchuy;
explosion->Damage = bombchudmg;
Link->Action = 0;
bombchuattack = 0;
}
}
//Fairy functions
void Fairy(int ScreenNumber){
ffc Fairy = Screen->LoadFFC(32);
bool ChangeDir;
if(FairyInit){
Fairy->Flags[0] = true;
Fairy->Flags[3] = true;
Fairy->Data = CMB_FAIRY+1;
FairyInit = false;
Fairy->X = Rand(28) + Link->X-16;
Fairy->Y = Rand(28) + Link->Y-16;
}
if(ScreenNumber != Game->GetCurScreen()){
Fairy->X = Rand(28) + Link->X-16;
Fairy->Y = Rand(28) + Link->Y-16;
}
if(FairyMovementCounter == FairyMovementMax){
Fairy->Vx = (Rand(5)/10+0.4)*(Rand(2)*2-1);
Fairy->Vy = (Rand(5)/10+0.4)*(Rand(2)*2-1);
ChangeDir = true;
FairyMovementCounter = 0;
}
if(Distance(Fairy->X,Fairy->Y,Link->X,Link->Y) > 32){
if(Fairy->X < Link->X) Fairy->Vx = (Rand(5)/10+1);
else Fairy->Vx = -(Rand(5)/10+1);
if(Fairy->Y < Link->Y) Fairy->Vy = (Rand(5)/10+1);
else Fairy->Vy = -(Rand(5)/10+1);
ChangeDir = true;
}
if(ChangeDir){
if(Fairy->Vy < 0 && (Abs(Fairy->Vx) < 0.6)) Fairy->Data = CMB_FAIRY;
else if(Fairy->Vy > 0 && (Abs(Fairy->Vx) < 0.6)) Fairy->Data = CMB_FAIRY+1;
else if(Fairy->Vx < 0) Fairy->Data = CMB_FAIRY+2;
else if(Fairy->Vx > 0) Fairy->Data = CMB_FAIRY+3;
ChangeDir = false;
}
FairyMovementCounter++;
}
//Beefster's Roll functions
void Roll(){
int i;
Link->Jump = 2;
RollCounter = 20;
DustFrame = 1;
for(i=0;i<5;i++){
RollX[i] = -1;
RollY[i] = -1;
}
Game->PlaySound(RollSFX);
while(RollCounter > 0){
Link->Z = 0;
NoAction();
if(RollCounter%2 == 0){
if(Link->Dir < 2) RollX[0] = Link->X+2;
else if(Link->Dir < 3) RollX[0] = Link->X;
else RollX[0] = Link->X+4;
RollY[0] = Link->Y;
for(i=4;i>0;i--){
RollX[i] = RollX[i-1];
RollY[i] = RollY[i-1];
}
if(DustFrame >= 5){
RollX[0] = -1;
RollY[0] = -1;
}
DustFrame++;
}
for(i=0;i<5;i++) if(RollX[i] != -1 && RollY[i] != -1) Screen->DrawTile(2,RollX[i],RollY[i],DustTile+i,1,1,DustCSet,1,0,0,0,0,true,128);
if(Link->Dir < 1){if(RollCheck(Link->X+8,Link->Y+6,Vertical)) Link->Y -= 2;}
else if(Link->Dir < 2){if(RollCheck(Link->X+8,Link->Y+18,Vertical)) Link->Y += 2;}
else if(Link->Dir < 3){if(RollCheck(Link->X,Link->Y+12,Horizontal)) Link->X -= 2;}
else if(Link->Dir < 4){if(RollCheck(Link->X+16,Link->Y+12,Horizontal)) Link->X += 2;}
RollCounter--;
Waitframe();
}
Link->Jump = 0;
}
//Check whether Link can roll onto a tile
bool RollCheck(int x, int y, bool xy){
int xoffset; int yoffset;
if(xy) xoffset = 4;
else yoffset = 3;
if(!isSolid(x-xoffset,y-yoffset) && !isSolid(x+xoffset,y+yoffset)
&& !ComboFI(x-xoffset,y-yoffset,F_NOROLL)
&& !ComboFI(x+xoffset,y+yoffset,F_NOROLL)) return true;
}
//Climbing functions
void Climbing(bool before){
if(before){
if(OnLadder()){
Link->InputA = false;
Link->InputB = false;
Link->InputL = false;
}
}else{
if(OnLadder()) Link->Dir = 0;
}
}
//Check whether Link is on a ladder combo
bool OnLadder(){
if(ComboFI(Link->X+8,Link->Y+8,F_LADDER) && Link->Z == 0) return true;
}
}
global script slot_3{
void run(){
bombchuattack = 0;
}
}
item script bombchu{
void run(){
if(Game->Counter[6] > 0) bombchuattack = 1;
}
}
Looking back at these bottle scripts, I've just realised again quite how complicated they are.
I'm afraid, to that end, I'm not going to put them in the script for you.
You'll have to either sort it out yourself, or get someone else to do it.
It really is just more complicated than I can be bothered with, sorry.
CODE
//Checks whether Link has an empty bottle or not when given a potion
void RunPotion(int set1, int set2, int set3, int m){
if(Link->Item[I_BTTL1]){
Link->Item[set1] = true;
Link->Item[I_BTTL1] = false;
}else if(Link->Item[I_BTTL2]){
Link->Item[set2] = true;
Link->Item[I_BTTL2] = false;
}else if(Link->Item[I_BTTL3]){
Link->Item[set3] = true;
Link->Item[I_BTTL3] = false;
}else Screen->Message(m);
}
//within global script
//Call the Potion functions
if(UsePotion >= 0) PotionEffect();
if(SwordTimer >= 0) PowerPotion();
if(RingTimer >= 0) DefencePotion();
//after void run of global script
//Functions for the 'sparkle' effect when Link uses a Potion
void PotionEffect(){
Link->Action = LA_FROZEN;
if(UsePotion == 50) Game->PlaySound(SFX_POTION);
else if(UsePotion <= 25) Screen->DrawTile(3,Link->X,Link->Y,T_POTION+5-Floor(UsePotion/5),1,1,11,1,0,0,0,0,true,128);
if(UsePotion == 0) Link->Action = 0;
UsePotion--;
}
//Power Potion functions
void PowerPotion(){
if(SwordTimer == 0){
Link->Item[I_RING2] = false;
Link->Item[I_RING3] = false;
if(Link->Item[I_SWORD4]) Link->Item[I_SWORD4] = false;
else Link->Item[I_SWORD2] = false;
}
SwordTimer--;
}
//Defence Potion functions
void DefencePotion(){
if(RingTimer == 0){
Link->Item[I_RING1] = false;
Link->Item[I_RING3] = false;
}
RingTimer --;
}
//item scripts
//These item scripts are the pickup scripts for the potions
item script LifePotionPickup{
void run(int m){
Screen->Message(m);
RunPotion(I_LPTN1,I_LPTN2,I_LPTN3,1);
}
}
item script MagicPotionPickup{
void run(int m){
Screen->Message(m);
RunPotion(I_MPTN1,I_MPTN2,I_MPTN3,1);
}
}
item script AttackPotionPickup{
void run(int m){
Screen->Message(m);
RunPotion(I_APTN1,I_APTN2,I_APTN3,1);
}
}
item script DefencePotionPickup{
void run(int m){
Screen->Message(m);
RunPotion(I_DPTN1,I_DPTN2,I_DPTN3,1);
}
}
item script EmptyBottlePickup{
void run(int m, int n){
if(Link->Item[I_BTTL2]){Link->Item[I_BTTL3] = true; Screen->Message(m);}
else if(Link->Item[I_BTTL1]){Link->Item[I_BTTL2] = true; Screen->Message(m);}
else{Link->Item[I_BTTL1] = true; Screen->Message(n);}
}
}
//These item scripts are the action scripts for the potions
item script LifePotionAction{
void run(int foo, int place){
Link->HP += 128;
if(Link->HP > Link->MaxHP) Link->HP = Link->MaxHP;
if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_LPTN1] = false;}
else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_LPTN2] = false;}
else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_LPTN3] = false;}
UsePotion = 50;
}
}
item script MagicPotionAction{
void run(int foo, int place){
Link->MP = 256;
if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_MPTN1] = false;}
else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_MPTN2] = false;}
else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_MPTN3] = false;}
UsePotion = 50;
}
}
item script AttackPotionAction{
void run(int foo, int place){
if(!Link->Item[I_RING1]) Link->Item[I_RING2] = true;
else Link->Item[I_RING3] = true;
if(Link->Item[I_SWORD3]) Link->Item[I_SWORD4] = true;
else Link->Item[I_SWORD2] = true;
if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_APTN1] = false;}
else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_APTN2] = false;}
else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_APTN3] = false;}
SwordTimer = (Minute*3)/4;
UsePotion = 50;
}
}
item script DefencePotionAction{
void run(int foo, int place){
if(!Link->Item[I_RING2]) Link->Item[I_RING1] = true;
else Link->Item[I_RING3] = true;
if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_DPTN1] = false;}
else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_DPTN2] = false;}
else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_DPTN3] = false;}
RingTimer = (Minute*3)/4;
UsePotion = 50;
}
}
You'll need to declare a load of integers for that bit too.