PDA

View Full Version : Can anyone make a script for me...



sonlen1414
10-25-2008, 08:54 PM
I want a ffc fairy that will follow you like in majora's mask and ocarina of time, any help is appreciated. I would make a script myself, but the scripting is a bit confusing, but I will hopefully learn someday. :D

Russ
10-25-2008, 09:30 PM
I actually have a script that does this. However, me and another person are using it for a joint quest, and since he was the one who made it, I'll have to get his permision before I can give it to you.

sonlen1414
10-25-2008, 10:58 PM
Hi russadwan, thanks, but if you can't get it it's not a problem. :) I believe you have helped me before on some kind of script too. You do visit purezc also don't you? Oh well, see ya.:)


I just accidentally found this script on my computer I found awhile back, but it says something about an itemclass is not found, could you check this for me?

import "std.zh"
ffc script followfairy{
void run(){
if(link->item[I-LEAF]){
if(epona) xspd = 1.4{
else xspd = 1;
if(fairyinit){
leaf->flags[0]=true;
leaf->flags[3]=true;
leaf->data=fairycombo+1;
leaf->cset=;
ran=rand(28)+link->x-16;
leaf->x=ran;
ran=rand(28)+link->y-16
leaf->y=ran;
}
if(screennumber1=game->getcurscreen()){
ran=rand(28)+link->x-16;
leaf->x=ran;
ran=rand(28)+link->y-16
leaf->y=ran;}
x1=leaf->x;x2=link->x2;
y1=leaf->y;y2=link->y2;
if(t==tcap){
ran=rand(5)/10+0.4;
if(rand(2)==1)ran*=-1;
leaf->vx=ran
ran=rand(5)/10+0.4;
if(rand(2)==1)ran*=-1;
leaf->vy=ran
t=0:
dircheck=true;}
if(distance(x1,y1,x2,y2)>32){
if(x1<x2){
ran=rand(5)/10+xspd;
leaf->Vx=ran;}
if(y1<y2){
ran=rand(5)/10+xspd;
leaf->Vy=ran;}
if(x1>x2){
ran=rand(5)/10+xspd;
leaf->Vx=-ran;}
if(y1>y2){
ran=rand(5)/10+xspd;
leaf->Vy=-ran;}
dircheck=true;}
if(dircheck){
if(leaf->vy<o&&(abs(leaf->vx)<0.6)){leaf->data=fairycombo;dircheck=false;}
if(leaf->vy<o&&(abs(leaf->vx)<0.6)){leaf->data=fairycombo+1;dircheck=false;}
if(leaf->vx<0&&dircheck){leaf->data=fairycombo+2;dircheck=false;}
if(leaf->vx>0&&dircheck){leaf->data=fairycombo+3;dircheck=false;}}
if(link->imputr){
if(cantalk&&!falling&&link->action!=LA_FROZEN&&link->z==0&&srpt==0){
game->playsound(leafsfx);
screen->message(leafstring0;}}
if(srpt>0)srpt--;
screennumber=game->getcurscreen();
t++;}

Joe123
10-26-2008, 05:17 AM
Heh, don't worry about that Russ.
I don't like to keep scripts hidden away; feel free to share any of them.
And what you have won't work at the moment...


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;

global script Slot_2{
void run(){
int ScreenNumber;
while(true){
//Call the Fairy functions
if(HasFairy) Fairy(ScreenNumber);
//Put any other global functions here...


ScreenNumber = Game->GetCurScreen();
Waitframe();
}

//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++;
}
}

global script Slot_3{
void run(){
if(HasFairy) FairyInit = true;
}
}

ffc script RemoveFairy{
void run(){
HasFairy = false;
ffc Fairy = Screen->LoadFFC(30);
Fairy->Data = 0;
}
}

ffc script ReturnFairy{
void run(){
HasFairy = true;
FairyInit = true;
}
}

Have a go with that one.
Put the two global scripts on the slots it says in their names, and if you place the other two scripts on an ffc on a screen, they do what the name suggests.
Make sure to set up the integer at the top to what combos you want to use for the fairy.

sonlen1414
10-26-2008, 12:35 PM
Thanks for the script, but I have a few questions about it.
So do I need to set the ffc on a screen in a certain way or does it just follow me when you start?
Also, it will follow me when I go to another screen or a dmap?
And how and where exactly do I put the combo's numbers at, it says put the first one in but then it tells me to put them in a certain order?

I have put the script in and I get this error:

Line 20: syntax error, unexpected Lparen, expecting assign, on token (
Fatal error P00: can't open or parse input file!

any idea what is wrong?

Joe123
10-26-2008, 02:44 PM
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;

global script Slot_2{
void run(){
int ScreenNumber;
while(true){
//Call the Fairy functions
if(HasFairy) Fairy(ScreenNumber);
//Put any other global functions here...


ScreenNumber = Game->GetCurScreen();
Waitframe();
}
}
//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++;
}
}

global script Slot_3{
void run(){
if(HasFairy) FairyInit = true;
}
}

ffc script RemoveFairy{
void run(){
HasFairy = false;
ffc Fairy = Screen->LoadFFC(30);
Fairy->Data = 0;
}
}

ffc script ReturnFairy{
void run(){
HasFairy = true;
FairyInit = true;
}
}
Oh, oops.
Missed an R brace.

Anyway, you put that as your global script, and then the fairy will follow you everywhere.
If you want it to go away for a bit, put the 'RemoveFairy' FFC script on a screen, then the fairy will stop following you.
If you want it to come back, put the 'ReturnFairy' FFC script on a screen.

On your combosheet you should have 4 fairy combos in a row.
The first facing up, then next down, the next left and then right.
Put the Combo ID of the first one as the integer at the top of the script.

sonlen1414
10-26-2008, 04:25 PM
The script didn't work at first so I tweaked it a little bit, I added
import"std.zh"(of course)
int FairyMovementMax; after int FairyMovementCounter
and now it works, Thanks a ton.:)

sonlen1414
10-26-2008, 06:33 PM
This doesn't require scripts but I was wondering if you could help me make a cutscene. All I want is when you enter a dungeon it says something like, It sure is creepy down here, and then you start playing again. I have the actual screen you see on layer 3 with teleports to warp you to the screen you start with. It will take me to that screen, but it won't display the text, and I have the room set to special item with the string and Abei as the "guy".Also I would like to know how you could make it a one time only thing.

lucas92
10-26-2008, 07:43 PM
bool showmessage=true;
ffc script messagecutscene
{
void run(int s,int t)
{
while(true)
{
if (showmessage==true)
{
Screen->Message(s);
Waitframes(t*60);
showmessage=false;
Quit();
}
else
{
Quit();
}
}
}
}

D0:the string you want to show
D1:the time in seconds you want it to be shown

I think it might work... I'm not even sure if you need a script for that anyway...

sonlen1414
10-26-2008, 08:31 PM
Cool, I will try it out, thanks.:)

lucas92
10-27-2008, 07:09 PM
It just cannot work... bool showmessage has to be in a global script... And I don't know how to make global scripts for now so that's the problem... :p

sonlen1414
10-27-2008, 07:41 PM
That is okay, I am trying to learn scripting, does anybody know of a really good tutorial?

lucas92
10-27-2008, 10:09 PM
ZCWiki: http://www.shardstorm.com/ZCwiki/Main_Page

Then search Zscript. The best way to learn is to try to make the most simple scripts (drawing a circle on the screen and make it grow for example), then try something else a little bit more complex, then something else... Etc.

Don't try to do something complex at first. ;)

I really liked that tutorial though: http://www.purezc.com/forums/index.php?showtopic=33916

Really helpful.

pkmnfrk
11-14-2008, 03:51 AM
Er, don't know if this is still relevant, but I would do this with a... y'know, DMap string. Which only shows up the very first time you enter a dungeon. Unless you need to change the scene in some way, this should be more than sufficient.