import "std.zh" ffc script real_npcV2 { void run(int m, int gmitem, int f, int d, int def_dir, int npcissolid, int gm_min, int gm_max) { int d_x; int d_y; int a_x; int a_y; int ir; int tho=(this->TileHeight*16-16); int orig_d = this->Data; int Apressed2; int Appr2; int onscreenedge; if(d == 0) d = 48; while(true) { //This detects if link is on the edge of the screen if (Link->X<8 || Link->Y<8 || Link->X>232 || Link->Y>152){onscreenedge=1;} else {onscreenedge=0;} //This checks if you're above or below the NPC to create an overhead effect if (Link->YY-8+tho && onscreenedge==0){this->Flags[FFCF_OVERLAY] = true;} else {this->Flags[FFCF_OVERLAY] = false;} //This detects if A was pressed, allowing you to exit messages with the A button if (Link->InputA) { if (Apressed2==1){Apressed2=0;} else { if (Appr2==0){Apressed2=1; Appr2=1;}} } else { Apressed2=0; Appr2=0; } d_x = this->X - Link->X; d_y = this->Y+(this->TileHeight*16-16) - Link->Y; a_x = Abs(d_x); a_y = Abs(d_y); if(f != 0) { if(a_x < d && a_y < d) { if(a_x <= a_y) { if(d_y >= 0) { this->Data = orig_d + DIR_DOWN; } else { this->Data = orig_d + DIR_UP; } } else { if(d_x >= 0) { this->Data = orig_d + DIR_LEFT; } else { this->Data = orig_d + DIR_RIGHT; } } } else { this->Data = orig_d + def_dir; } } //This checks if you have item D1, and makes the NPC disappear if you do. if (Link->Item[gmitem] == true){this->X=-256; this->Y=-256;} else { //This enables horizontal guard mode. if (gm_max>0) { if (Link->X>gm_min-32 && Link->XY>this->Y+tho-32 && Link->YY+tho+32) {ir=1;} else {ir=0;} if (Link->XX-2 && this->X>gm_min && ir==1) { if (Link->X>gm_min){this->Vx= (- this->X + Link->X)/4;} else{this->Vx= (- this->X + gm_min)/4;} } if (Link->X>this->X+2 && this->XXVx= (Link->X - this->X)/4;} else{this->Vx= (gm_max - this->X)/4;} } if (Link->XX+2 && Link->X>this->X-2){this->Vx=0;} if (ir==0){this->Vx=0;} if (this->XVx<0) this->Vx=0; this->X=gm_min; } if (this->X>gm_max-1){ if (this->Vx>0) this->Vx=0; this->X=gm_max; } } //This enables vertical guard mode. if (gm_max<0) { if (Link->Y>-gm_min-32 && Link->Y<-gm_max+32 && Link->X>this->X-32 && Link->XX+32) {ir=1;} else {ir=0;} if (Link->YY-2+tho && this->Y+tho>-gm_min && ir==1) { if (Link->Y>-gm_min){this->Vy= (- this->Y-tho + Link->Y)/4;} else {this->Vy= (- this->Y-tho + -gm_min)/4;} } if (Link->Y>this->Y+2+tho && this->Y+tho<-gm_max && ir==1) { if (Link->Y<-gm_max){this->Vy= (Link->Y - this->Y-tho)/4;} else {this->Vy= (-gm_max - this->Y-tho)/4;} } if (Link->YY+2+tho && Link->Y>this->Y-2+tho){this->Vy=0;} if (ir==0){this->Vy=0;} if (this->Y+tho<-gm_min+1){ if (this->Vy<0)this->Vy=0; this->Y=-gm_min-tho; } if (this->Y+tho>-gm_max-1){ if (this->Vy>0)this->Vy=0; this->Y=-gm_max-tho; } } } if (this->Vy>0)this->Data = orig_d + DIR_UP; if (this->Vy<0)this->Data = orig_d + DIR_DOWN; if (this->Vx>0)this->Data = orig_d + DIR_RIGHT; if (this->Vx<0)this->Data = orig_d + DIR_LEFT; if(Apressed2==1 && a_x < 24 && a_y < 24) { //This is all checking if Link is facing the NPC while to the left, to the right, above, or below the NPC if (Link->XX-8 && Link->Y>this->Y+tho-12 && Link->YY+tho+8 && Link->Dir == DIR_RIGHT || Link->X>this->X+8 && Link->Y>this->Y+tho-12 && Link->YY+tho+8 && Link->Dir == DIR_LEFT || Link->YY+tho-8 && Link->X>this->X-8 && Link->XX+8 && Link->Dir == DIR_DOWN || Link->Y>this->Y+tho+8 && Link->X>this->X-8 && Link->XX+8 && Link->Dir == DIR_UP){ Apressed2=0; Screen->Message(m); Link->InputA = false; } } //This enables the NPC to be solid without having to lay a solid combo under it. if (npcissolid>0){ if ((Abs(Link->X - this->X) < 10) && (Link->Y <= this->Y+tho + 12) && (Link->Y > this->Y+tho+8)){Link->Y = this->Y+tho+12;} if ((Abs(Link->Y - this->Y-tho) < 10) && (Link->X >= this->X - 12) && (Link->X < this->X-8)){Link->X = this->X-12;} if ((Abs(Link->X - this->X) < 10) && (Link->Y >= this->Y+tho - 12) && (Link->Y < this->Y+tho-8)){Link->Y = this->Y+tho-12;} if ((Abs(Link->Y - this->Y-tho) < 10) && (Link->X <= this->X + 12) && (Link->X > this->X+8)){Link->X = this->X+12;} } Waitframe(); } } } //D0: ID of the item //D1: Price of the item //D2: Message that plays when the item is bought //D3: Message that plays when you don't have enough rupees //D4: Input type 0=A 1=B 2=L 3=R ffc script SimpleShop{ void run(int itemID, int price, int m, int n, int input){ int loc = ComboAt(this->X,this->Y); while(true){ while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe(); SetInput(input,false); if(Game->Counter[CR_RUPEES] >= price){ Game->DCounter[CR_RUPEES] -= price; item shpitm = CreateItemAt(itemID, Link->X, Link->Y); shpitm->Pickup = IP_HOLDUP; Screen->Message(m); } else{ Screen->Message(n); } Waitframe(); } } bool AgainstComboBase(int loc){ return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8); } } //If you are already using the signpost script remove the code below 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; } //Permanent Tiered Secrets Script //D0: The Screen->D (0-7) to use to store the number of triggered secrets on the screen //D1: If you want to use a layered combo to detect secrets being triggered, set this to the layer number //D2: In an infinite looping tiered secret, set this to the number of states the secret can have ffc script PermanentTieredSecrets{ void run(int D, int Layer, int NumStates){ //Triggers the number of screen secrets stored in Screen->D when you enter the screen if(Screen->D[D]>0){ for(int i=0; iD[D]; i++){ Screen->TriggerSecrets(); } } //Saves the combo position and combo under the FFC int ComboPos = ComboAt(this->X+8, this->Y+8); int Combo; if(Layer>0) Combo = GetLayerComboD(Layer, ComboPos); else if(Layer==0) Combo = Screen->ComboD[ComboPos]; while(true){ //Detects if the combo under the FFC changes and increases Screen->D if(Layer>0&&GetLayerComboD(Layer, ComboPos)!=Combo){ Combo = GetLayerComboD(Layer, ComboPos); Screen->D[D]++; } else if(Layer==0&&Screen->ComboD[ComboPos]!=Combo){ Combo = Screen->ComboD[ComboPos]; Screen->D[D]++; } //Wraps Screen->D if NumStates is set, otherwise caps Screen->D at 100 if(NumStates>0&&Screen->D[D]>=NumStates) Screen->D[D] -= NumStates; else if(NumStates==0&&Screen->D[D]>100){ Screen->D[D] = 100; } Waitframe(); } } } //D0: ID of the item //D1: Price of the item //D2: Message that plays when the item is bought //D3: Message that plays when you don't have enough rupees //D4: Input type 0=A 1=B 2=L 3=R ffc script SimpleShop{ void run(int itemID, int price, int m, int n, int input){ int loc = ComboAt(this->X,this->Y); while(true){ while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe(); SetInput(input,false); if(Game->Counter[CR_RUPEES] >= price){ Game->DCounter[CR_RUPEES] -= price; item shpitm = CreateItemAt(itemID, Link->X, Link->Y); shpitm->Pickup = IP_HOLDUP; Screen->Message(m); } else{ Screen->Message(n); } Waitframe(); } } bool AgainstComboBase(int loc){ return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8); } } //If you are already using the signpost script remove the code below 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; }