import "std.zh""
ffc script FFCJumpCliff{
void run(int verticalmovement, int horizontalmovement, int directiontopress) {
int directiontopressmoreleft;
int directiontopressmoreright;
int LinkHmovementdone = 0;
bool ffcsentlinkjumping = false;
if (directiontopress==DIR_DOWN) {
directiontopressmoreleft = DIR_RIGHTDOWN;
directiontopressmoreright = DIR_LEFTDOWN;
}
else {
if (directiontopress==DIR_UP) {
directiontopressmoreleft = DIR_LEFTUP;
directiontopressmoreright = DIR_RIGHTUP;
}
else {
if (directiontopress==DIR_LEFT) {
directiontopressmoreleft = DIR_LEFTDOWN;
directiontopressmoreright = DIR_LEFTUP;
}
else {
if (directiontopress==DIR_RIGHT) {
directiontopressmoreleft = DIR_RIGHTUP;
directiontopressmoreright = DIR_RIGHTDOWN;
}
else {
if (directiontopress==DIR_LEFTDOWN) {
directiontopressmoreleft = DIR_DOWN;
directiontopressmoreright = DIR_LEFT;
}
else {
if (directiontopress==DIR_RIGHTDOWN) {
directiontopressmoreleft = DIR_RIGHT;
directiontopressmoreright = DIR_DOWN;
}
else {
if (directiontopress==DIR_LEFTUP) {
directiontopressmoreleft = DIR_LEFT;
directiontopressmoreright = DIR_UP;
}
else {
if (directiontopress==DIR_RIGHTUP) {
directiontopressmoreleft = DIR_UP;
directiontopressmoreright = DIR_RIGHT;
}
}
}
}
}
}
}
}
while (true){
if (Link->Z==0) {
LinkHmovementdone=0;
ffcsentlinkjumping = false;
}
if ( (ffcsentlinkjumping)&&(LinkHmovementdone<Abs(horizontalmovement)) ) {
if (horizontalmovement<0) {Link->X--;}
if (horizontalmovement>0) {Link->X++;}
LinkHmovementdone++;
}
if ( (LinkCollision(this))
&& ( (Link->Dir==directiontopress)
||(Link->Dir==directiontopressmoreleft)
||(Link->Dir==directiontopressmoreright) ) ) {
if (Link->Z==0) Game->PlaySound(SFX_JUMP);
ffcsentlinkjumping=true;
Link->Y=Link->Y+verticalmovement;
Link->Z=Link->Z+verticalmovement;
}
Waitframe();
}
}
}
ffc script RealNPC{
void run(int m, int sfx, int defdir, int d, int ffcnumber, int input){
ffc NPC = this;
if(ffcnumber != 0) Screen->LoadFFC(ffcnumber);
NPC->Misc[0] = NPC->Data;
if(d == 0) d = 40;
while(true){
SetGraphic(NPC,defdir,d);
if(CanTalk(NPC,input)){
SetInput(input,false);
if(sfx != 0) Game->PlaySound(sfx);
Screen->Message(m);
}
Waitframe();
}
}
bool CanTalk(ffc NPC,int input){
return (SelectPressInput(input) && Abs(NPC->X-Link->X) < 24 && Abs(NPC->Y-Link->Y) < 24 && Link->Z == 0);
}
void SetGraphic(ffc NPC, int defdir, int d){
int dx = NPC->X-Link->X; int ax = Abs(dx);
int dy = NPC->Y-Link->Y; int ay = Abs(dy);
if(defdir != 0){
if(ax < d && ay < d){
if(ax <= ay){
if(dy >= 0) NPC->Data = NPC->Misc[0]+DIR_UP;
else NPC->Data = NPC->Misc[0]+DIR_DOWN;
}else{
if(dx >= 0) NPC->Data = NPC->Misc[0]+DIR_LEFT;
else NPC->Data = NPC->Misc[0]+DIR_RIGHT;
}
}else NPC->Data = NPC->Misc[0]+(defdir-1);
}
}
}
//Only include these two functions once in your script file
bool SelectPressInput(int input){
if(input == 0) return Link->PressA;
else if(input == 1) return Link->PressB;
else if(input == 2) return Link->PressL;
else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
if(input == 0) Link->InputA = state;
else if(input == 1) Link->InputB = state;
else if(input == 2) Link->InputL = state;
else if(input == 3) Link->InputR = state;
}
item script Message{
void run(int m){
Screen->Message(m);
}
}
ffc script Signpost{
void run(int m,int input){
int loc = ComboAt(this->X,this->Y);
while(true){
while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
SetInput(input,false);
Screen->Message(m);
Waitframe();
}
}
bool AgainstComboBase(int loc){
return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8);
}
}
//These functions should only be included in your script file once
bool SelectPressInput(int input){
if(input == 0) return Link->PressA;
else if(input == 1) return Link->PressB;
else if(input == 2) return Link->PressL;
else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
if(input == 0) Link->InputA = state;
else if(input == 1) Link->InputB = state;
else if(input == 2) Link->InputL = state;
else if(input == 3) Link->InputR = state;
}
ugh im sorry i dont know how to get it posted corectly...