Sail Boat Script
#46
Posted 03 February 2008 - 05:16 AM
#47
Posted 08 February 2008 - 07:51 PM
#48
Posted 08 February 2008 - 08:07 PM
bool boatdown;
ffc script boat{
void run(int jumptil, int shadowtil, int jumpht){
ffc link2 = Screen->LoadFFC(2);
ffc water = Screen->LoadFFC(3);
bool upcheck;
Link->HP = 64;
int orig = this->Data;
int worig = water->Data;
int jumpmax = 60*5;
int yorig;
int jumptimer;
if(jumpht == 0) jumpht = 16;
else jumpht = jumpht*8;
int jumpspd = 2; //set your jumpspeed here please, 2 is default.
while(true){
upcheck = false;
if(boatjump){
Link->InputA = false; Link->InputUp = false; Link->InputDown = false;
if(this->Y >= yorig+jumpht){this->Vy = jumpspd; boatdown = true; boatjump = false;}
}
if(boatdown){
Link->InputA = false; Link->InputUp = false; Link->InputDown = false;
if(this->Y <= yorig){this->Vy = 0; boatdown = false;}
}
if(Link->InputUp){
this->Vy = -1;
link2->Vy = -1;
water->Vy = -1;
upcheck = true;
}else{
this->Vy = 0;
link2->Vy = 0;
water->Vy = 0;
}
if(Link->InputDown){
this->Vy = 1;
link2->Vy = 1;
water->Vy = 1;
}else{
if(!upcheck){
this->Vy = 0;
link2->Vy = 0;
water->Vy = 0;
}
}
if(Link->InputA){
boatjump = true;
this->Data = jumptil;
water->Data = shadowtil;
yorig = this->Y;
this->Vy = -jumpspd;
Link->InputA = false;
Waitframe();
}
if(link2->Y > 136 && this->Vy > 0){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
if(link2->Y < 32 && this->Vy < 0 && !boatjump){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
Waitframe();
}
}
}
Try that.
Edited by Joe123, 08 February 2008 - 08:09 PM.
#49
Posted 08 February 2008 - 09:29 PM
#50
Posted 09 February 2008 - 06:30 AM
//-----------------------------------//
// Global Variables //
//-----------------------------------//
bool guy1;
bool guy2;
bool guy3;
bool guy4;
int level;
bool boatjump;
// Global Constants
const int jumptil = 796;
const int shadowtil = 802;
const int blank = 3;
//-----------------------------------//
// Global Scipts //
//-----------------------------------//
//-----------------------------------//
// FFC Scipts //
//-----------------------------------//
ffc script bguys{
void run(int guy){
if(guy == 1 && !guy1){
Screen->Message(5);
guy1 = true;
}
if(guy == 2 && guy1 && !guy2){
Screen->Message(9);
guy2 = true;
}
if(guy == 3 && guy2 && !guy3 && guy4 && Link->Item[5]){
Screen->Message(10);
guy3 = true;
}
if(guy == 4 && !guy4){
Screen->Message(11);
guy4 = true;
}
}
}
ffc script mapmark{
void run(){
if(guy1) Link->Item[22] = true;
}
}
ffc script boat{
void run(){
ffc link2 = Screen->LoadFFC(2);
ffc water = Screen->LoadFFC(32);
bool upcheck;
int yorig;
int orig = this->Data;
int worig = water->Data;
int gravity = 0.1; // Acceleration due to gravity
int jumpspd = 3; // Starting speed of jump
Link->HP = 64;
while(true){
upcheck = false;
link2->Y = this->Y+28;
water->Y = this->Y+32;
if(Link->InputUp){
this->Vy = -1;
upcheck = true;
}else this->Vy = 0;
if(Link->InputDown) this->Vy = 1;
else{
if(!upcheck) this->Vy = 0;
}
if(Link->InputA){
Game->PlaySound(45);
boatjump = true;
this->Data = jumptil;
water->Data = shadowtil;
water->X += 24;
yorig = this->Y;
this->Vy = -jumpspd;
this->Ay = gravity;
Link->InputA = false;
Waitframe();
}
while(boatjump){
link2->Y = this->Y+28;
if(this->Y == yorig){
this->Vy = 0;
this->Ay = 0;
this->Data = orig; water->Data = worig;
water->X -= 24;
boatjump = false;
}
Waitframe();
}
if(this->Y+28 > 136 && this->Vy > 0) this->Vy = 0;
if(this->Y+28 < 44 && this->Vy < 0) this->Vy = 0;
Waitframe();
}
}
}
ffc script barrel{
void run(int speed){
ffc link2 = Screen->LoadFFC(2);
bool go; bool active;
int ran;
int orig = this->Data;
this->Data = blank;
ran = Rand(120);
Waitframes(ran);
this->Data = orig;
while(true){
ran = Rand(104) + 42;
this->Y = ran;
this->X = 256;
this->Vx = -speed;
go = true;
active = true;
while(go){
if(this->X < -16) go = false;
if((this->X < 65 && this->X > 47) && Abs(this->Y - link2->Y) < 16 && !boatjump && active){
Link->HP -= 16;
active = false;
Game->PlaySound(19);
}
Waitframe();
}
Waitframes(10);
}
}
}
//-----------------------------------//
// Item Scipts //
//-----------------------------------//
item script itemmessage{
void run(int msgID){
Screen->Message(msgID);
}
}
item script levelincrease{
void run(){
level += 1;
}
}
Things you'll need to do:
Copy this whole document in as your script file, and not just the two scripts.
I've used a couple of global variables, you see.
Copy the 'Water' ffc down to ffc 32 on the list, and remove it from being ffc 3.
This is so that it appears underneath barrels if Link is jumping.
Move the speeds of the barrels into D0 instead of D1.
Did you, perchance, want me to script you a cannon now?
Edited by Joe123, 09 February 2008 - 07:42 AM.
#51
Posted 09 February 2008 - 05:29 PM
AWESOME!!!!!
But... Does it have to jump so high?
Oh, and before we make the cannon, the barrels, individually of course, need to disappear and come back across the screen again when the boat is hit. Also, FFCs 1,2, & 32 should flash when hit.
#52
Posted 09 February 2008 - 07:59 PM
Don't they do that anyway?
What do you mean?
Well, that'll be really awkard to do, in terms of tiles and combos.
Can't you just have Link flash or something?
You'll have to make animated combos of all of them flashing otherwise.
Isn't the sound effect enough?
I'm glad you've got it working by the way, I had to sit down for two hours this morning with your quest file and fiddle to get it to work.
I think I'dve cried if you couldn't get it to go properly.
Edited by Joe123, 09 February 2008 - 08:00 PM.
#53
Posted 09 February 2008 - 09:29 PM
No.
When it hits the boat, the barrel will hurt Link and go to a random spot with an X of 256.
Script Update:
void run(){
ffc link2 = Screen->LoadFFC(2);
ffc water = Screen->LoadFFC(32);
bool upcheck;
int yorig;
int orig = this->Data;
int worig = water->Data;
int gravity = 0.1; // Acceleration due to gravity
int jumpspd = 3; // Starting speed of jump
Link->HP = 64;
while(true){
upcheck = false;
link2->Y = this->Y+28;
water->Y = this->Y+32;
if(Link->InputUp){
this->Vy = -1;
upcheck = true;
}else this->Vy = 0;
if(Link->InputDown) this->Vy = 1;
else{
if(!upcheck) this->Vy = 0;
}
if(Link->InputA){
Game->PlaySound(45);
boatjump = true;
this->Data = jumptil;
water->Data = shadowtil;
water->X += 24;
yorig = this->Y;
this->Vy = -jumpspd;
this->Ay = gravity;
Link->InputA = false;
Waitframe();
}
while(boatjump){
link2->Y = this->Y+28;
if(this->Y == yorig){
this->Vy = 0;
this->Ay = 0;
this->Data = orig; water->Data = worig;
water->X -= 24;
boatjump = false;
}
Waitframe();
}
if(this->Y+28 > 136 && this->Vy > 0) this->Vy = 0;
if(this->Y+28 < 44 && this->Vy < 0) this->Vy = 0;
Waitframe();
}
}
}
ffc script barrel{
void run(int speed){
ffc link2 = Screen->LoadFFC(2);
bool go; bool active;
int ran;
int orig = this->Data;
this->Data = blank;
ran = Rand(120);
Waitframes(ran);
this->Data = orig;
while(true){
ran = Rand(104) + 42;
this->Y = ran;
this->X = 256;
this->Vx = -speed;
go = true;
active = true;
while(go){
if(this->X < -16) go = false;
if((this->X < 65 && this->X > 47) && Abs(this->Y - link2->Y) < 16 && !boatjump && active){
if (Link->MaxHP <= 64 || Link->HP <= 64) {Link->HP -= 8;}
else {Link->HP -= 16;}
active = false;
Game->PlaySound(19);
this->X = 256;
}
Waitframe();
}
Waitframes(10);
}
}
}
I got the barrels to disappear when Link is hit. And Link only loses a half a heart when he has four hearts or less.
#54
Posted 09 February 2008 - 09:34 PM
That's crappy...
I spent ages scripting in that active boolean so that they'll only hurt Link once and can then pass on through him ¬_¬
EDIT:
void run(int speed){
ffc link2 = Screen->LoadFFC(2);
bool go;
int ran;
int orig = this->Data;
this->Data = blank;
ran = Rand(120);
Waitframes(ran);
this->Data = orig;
while(true){
ran = Rand(104) + 42;
this->Y = ran;
this->X = 256;
this->Vx = -speed;
go = true;
while(go){
if(this->X < -16) go = false;
if((this->X < 65 && this->X > 47) && Abs(this->Y - link2->Y) < 16 && !boatjump && active){
if(Link->HP <= 64) Link->HP -= 8;
else Link->HP -= 16;
go = false;
Game->PlaySound(19);
}
Waitframe();
}
Waitframes(10);
}
}
}
Anyway, that's all you needed to do to make the barrels dissapear after they hit Link.
I still prefered it the old way though.
Edited by Joe123, 09 February 2008 - 09:49 PM.
#55
Posted 09 February 2008 - 11:23 PM
Let's try this:
void run(int cbspeed){
ffc link2 = Screen->LoadFFC(2);
ffc water = Screen->LoadFFC(32);
ffc cannonball = Screen->LoadFFC(7);
bool upcheck;
int yorig;
int orig = this->Data;
int worig = water->Data;
int gravity = 0.1; // Acceleration due to gravity
int jumpspd = 3; // Starting speed of jump
Link->HP = 64;
while(true){
upcheck = false;
link2->Y = this->Y+28;
water->Y = this->Y+32;
if(Link->InputUp){
this->Vy = -1;
upcheck = true;
}else this->Vy = 0;
if(Link->InputDown) this->Vy = 1;
else{
if(!upcheck) this->Vy = 0;
}
if(Link->InputA){
Game->PlaySound(45);
boatjump = true;
this->Data = jumptil;
water->Data = shadowtil;
water->X += 24;
yorig = this->Y;
this->Vy = -jumpspd;
this->Ay = gravity;
Link->InputA = false;
Waitframe();
}
if(Link->InputB){
cannonball->Y = link2->Y;
cannonball->X = 64;
cannonball->Vx = cbspeed;
Waitframe();
}
while(boatjump){
link2->Y = this->Y+28;
if(this->Y == yorig){
this->Vy = 0;
this->Ay = 0;
this->Data = orig; water->Data = worig;
water->X -= 24;
boatjump = false;
}
Waitframe();
}
if(this->Y+28 > 136 && this->Vy > 0) this->Vy = 0;
if(this->Y+28 < 44 && this->Vy < 0) this->Vy = 0;
Waitframe();
}
}
}
The cannon won't fire!
#56
Posted 10 February 2008 - 05:28 AM
void run(){ // void run(){ goes on the SECOND line. NOT the first.
ffc link2 = Screen->LoadFFC(2);
ffc cball = Screen->LoadFFC(3); // I've set this to ffc 3. ffcs with a lower number are drawn above ffcs with a higher
ffc water = Screen->LoadFFC(32);// number, so this will draw your cannonball above your barrels instead of below.
bool upcheck; bool cannon;
int yorig;
int orig = this->Data;
int worig = water->Data;
int gravity = 0.1; // Acceleration due to gravity
int jumpspd = 3; // Starting speed of jump
int cbspeed = 2; // Speed of cannonball. No need to make it D0 really.
int cbcombo = 0; // Make sure to set the combo ID of your cannonball here.
Link->HP = 64;
cball->Data = blank;
while(true){
upcheck = false;
link2->Y = this->Y+28;
if(!boatjump) water->Y = this->Y+32;
if(Link->InputUp && !boatjump){
this->Vy = -1;
upcheck = true;
}else this->Vy = 0;
if(Link->InputDown && !boatjump) this->Vy = 1;
else{
if(!upcheck) this->Vy = 0;
}
if(Link->InputB && !boatjump && !cannon){
Game->PlaySound(3);
cball->Y = link2->Y; cball->X = 64;
cball->Vx = cbspeed;
cball->Data = cbcombo;
cannon = true;
Link->InputB = false;
}
if(Link->InputA && !boatjump){
Game->PlaySound(45);
boatjump = true;
this->Data = jumptil;
water->Data = shadowtil;
water->X += 24;
yorig = this->Y;
this->Vy = -jumpspd;
this->Ay = gravity;
Link->InputA = false;
Waitframe();
} // You do NOT put the end brace for if's on the same line as the functions within them.
// It confuses your script and makes it nigh on impossible to read.
// Go and read the passage on scope on page 3 again.
if(cannon){
if(cball->X >= 256){
cball->Vx = 0;
cball->Data = blank;
cannon = false;
}
}
if(boatjump){
if(this->Y == yorig){
this->Vy = 0;
this->Ay = 0;
this->Data = orig; water->Data = worig;
water->X -= 24;
boatjump = false;
}
}
if(this->Y+28 > 136 && this->Vy > 0 && !boatjump) this->Vy = 0;
if(this->Y+28 < 44 && this->Vy < 0 && !boatjump) this->Vy = 0;
Waitframe();
}
}
}
Please pay more attention to your scope, it's very important.
Make sure to set the cbspeed and cbcombo integers.
#57
Posted 10 February 2008 - 10:09 AM
When I press A, the boat, and link, go up a half a tile and never come down.
#58
Posted 10 February 2008 - 10:15 AM
It won't work if you don't do that.
actually ignore that bit, wait a second.
I had to make the jump function from a while to an if, so I probably did something a bit wrong there.
I'll check it in a bit.
void run(){ // void run(){ goes on the SECOND line. NOT the first.
ffc link2 = Screen->LoadFFC(2);
ffc cball = Screen->LoadFFC(3); // I've set this to ffc 3. ffcs with a lower number are drawn above ffcs with a higher
ffc water = Screen->LoadFFC(32);// number, so this will draw your cannonball above your barrels instead of below.
bool upcheck; bool cannon;
int yorig;
int orig = this->Data;
int worig = water->Data;
int corig = cball->Data;
int gravity = 0.1; // Acceleration due to gravity
int jumpspd = 3; // Starting speed of jump
int cbspeed = 2; // Speed of cannonball. No need to make it D0 really.
Link->HP = 64;
cball->Data = blank;
while(true){
upcheck = false;
link2->Y = this->Y+28;
if(!boatjump) water->Y = this->Y+32;
if(Link->InputUp && !boatjump){
this->Vy = -1;
upcheck = true;
}else this->Vy = 0;
if(Link->InputDown && !boatjump) this->Vy = 1;
else{
if(!upcheck) this->Vy = 0;
}
if(Link->InputB && !boatjump && !cannon){
Game->PlaySound(3);
cball->Y = link2->Y; cball->X = 64;
cball->Vx = cbspeed;
cball->Data = corig;
cannon = true;
Link->InputB = false;
}
if(Link->InputA && !boatjump){
Game->PlaySound(45);
boatjump = true;
this->Data = jumptil;
water->Data = shadowtil;
water->X += 24;
yorig = this->Y;
this->Vy = -jumpspd;
this->Ay = gravity;
Link->InputA = false;
Waitframe();
} // You do NOT put the end brace for if's on the same line as the functions within them.
// It confuses your script and makes it nigh on impossible to read.
// Go and read the passage on scope on page 3 again.
if(cannon){
if(cball->X >= 256){
cball->Vx = 0;
cball->Data = blank;
cannon = false;
}
}
if(boatjump){
if(this->Y == yorig){
this->Vy = 0;
this->Ay = 0;
this->Data = orig; water->Data = worig;
water->X -= 24;
boatjump = false;
}
}
if(this->Y+28 > 136 && this->Vy > 0 && !boatjump) this->Vy = 0;
if(this->Y+28 < 44 && this->Vy < 0 && !boatjump) this->Vy = 0;
Waitframe();
}
}
}
Try that.
Put the cannonball onto ffc 3, and set what combo it should look like for the graphic.
Edited by Joe123, 10 February 2008 - 10:17 AM.
#59
Posted 10 February 2008 - 11:21 AM
#60
Posted 10 February 2008 - 11:29 AM
I'll check it in a bit.
I wasn't planning on having to include a cannon function in the boat script, so I made the jump into a while loop.
That means the rest of the script would stop functioning while the boat jumps, which means the cannon won't work properly.
So I had to change it from a while to an if, which I obviously did slightly wrong.
And it was you that broke the barrel code, not me.
Why can't you just have the barrels continue on through the boat?
It looks much better...
Anyway, I'll have a look at that too in a bit.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users