Jump to content

Photo

Help with NPC script


  • Please log in to reply
12 replies to this topic

#1 Mibbitable

Mibbitable

    Junior

  • Members

Posted 25 July 2017 - 08:42 PM

Hello! Im back at game making, but i ran into a problem, this script wont compile at all.

 

import "std.zh"

const int RESET_NPC_LAYER_ON_ENTRY = 1; //This fix will replace all CMB_NPC_SOLID tiles with CMB_NPC_HIDDEN 
										//when entering the screen. This should prevent problems with shared
										//layers. If you don't want this fix, set it to 0.

const int LAYER_NPC = 2; //The layer NPCs use for solid combos
const int CMB_NPC_HIDDEN = 41; //Non-solid combo used for hidden NPCs
const int CMB_NPC_SOLID = 42; //Solid combo placed under visible NPCs

const int LAYER_NPC_CANTALK = 4; //The layer used for the speech bubble
const int CMB_NPC_CANTALK = 44; //The combo used for the speech bubble
const int CS_NPC_CANTALK = 8; //The CSet used for the speech bubble

const int NPCBT_NONE = 0; //Regular NPCs
const int NPCBT_FACELINK = 1; //NPCs that turn to face Link
const int NPCBT_GUARDH = 2; //NPCs that move along a horizontal path
const int NPCBT_GUARDV = 3; //NPCs that move along a vertical path

ffc script NPCScript{
	void run(int String, int ItemCheck, int Type, int Arg1, int Arg2, int NoSolid, int Script){
		//Stores the NPC's combo, hides it
		int Combo = this->Data;
		this->Data = CMB_NPC_HIDDEN;
		//Waits until the NPC should appear and shows it
		if(ItemCheck<0){
			while(!Link->Item[Abs(ItemCheck)]){
				Waitframe();
			}
			this->Data = Combo;
			if(Type==NPCBT_FACELINK){
				this->Data = Combo + Arg1;
			}
		}
		else if(ItemCheck>0){
			if(!Link->Item[Abs(ItemCheck)]){
				this->Data = Combo;
				if(Type==NPCBT_FACELINK){
					this->Data = Combo + Arg1;
				}
			}
		}
		else if(ItemCheck==0){
			this->Data = Combo;
			if(Type==NPCBT_FACELINK){
				this->Data = Combo + Arg1;
			}
		}
		//Saves the width and height of the FFC for collision checks
		int Width = 16;
		int Height = 16;
		if(this->EffectWidth!=16)
			Width = this->EffectWidth;
		else if(this->TileWidth>1)
			Width = this->TileWidth*16;
		if(this->EffectHeight!=16)
			Height = this->EffectHeight;
		else if(this->TileHeight>1)
			Height = this->TileHeight*16;
		//Wait until the screen is done scrolling to avoid a weird ZC crashing bug
		Waitframe();
		while(Link->Action==LA_SCROLLING){
			Waitframe();
		}
		//Shared Layer Fix
		if(RESET_NPC_LAYER_ON_ENTRY==1){
			if(Screen->LoadFFC(FindFFCRunning(this->Script))==this){
				for(int i=0; i<176; i++){
					if(GetLayerComboD(LAYER_NPC, i)==CMB_NPC_SOLID){
						SetLayerComboD(LAYER_NPC, i, CMB_NPC_HIDDEN);
					}
				}
			}
		}
		//Sets the space below the NPC or the space a guard NPC occupies to be solid
		if(LAYER_NPC>-1&&NoSolid==0){
			if(Type==NPCBT_GUARDH){
				for(int x=Arg1; x<=Arg2+this->TileWidth-1; x++){
					for(int y=Floor(this->Y/16); y<=Floor(this->Y/16)+this->TileHeight-1; y++){
						SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_SOLID);
					}
				}
			}
			else if(Type==NPCBT_GUARDV){
				for(int x=Floor(this->X/16); x<=Floor(this->X/16)+this->TileWidth-1; x++){
					for(int y=Arg1; y<=Arg2+this->TileHeight-1; y++){
						SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_SOLID);
					}
				}
			}
			else{
				for(int x=Floor(this->X/16); x<=Floor(this->X/16)+this->TileWidth-1; x++){
					for(int y=Floor(this->Y/16); y<=Floor(this->Y/16)+this->TileHeight-1; y++){
						SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_SOLID);
					}
				}
			}
		}
		while(true){
			//Removes NPCs if Link has the required item
			if(ItemCheck>0){
				if(Link->Item[ItemCheck]){
					this->Data = CMB_NPC_HIDDEN;
					if(LAYER_NPC>-1&&NoSolid==0){
						if(Type==NPCBT_GUARDH){
							for(int x=Arg1; x<=Arg2+this->TileWidth-1; x++){
								for(int y=Floor(this->Y/16); y<=Floor(this->Y/16)+this->TileHeight-1; y++){
									SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_HIDDEN);
								}
							}
						}
						else if(Type==NPCBT_GUARDV){
							for(int x=Floor(this->X/16); x<=Floor(this->X/16)+this->TileWidth-1; x++){
								for(int y=Arg1; y<=Arg2+this->TileHeight-1; y++){
									SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_HIDDEN);
								}
							}
						}
						else{
							for(int x=Floor(this->X/16); x<=Floor(this->X/16)+this->TileWidth-1; x++){
								for(int y=Floor(this->Y/16); y<=Floor(this->Y/16)+this->TileHeight-1; y++){
									SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_HIDDEN);
								}
							}
						}
					}
					Quit();
				}
			}
			//Handles animation for turning NPCs
			if(Type==NPCBT_FACELINK&&(Link->X>0&&Link->X<240&&Link->Y>0&&Link->Y<160)){
				if(Distance(CenterLinkX(), CenterLinkY(), CenterX(this), CenterY(this))<Arg2)
					this->Data = Combo + AngleDir4(Angle(CenterX(this), CenterY(this), CenterLinkX(), CenterLinkY()));
				else
					this->Data = Combo + Arg1;
			}
			//Handles movement for guard NPCs
			else if(Type==NPCBT_GUARDH){
				if(Link->X>16*Arg1-32&&Link->X<16*Arg2+32&&Link->Y>this->Y-32&&Link->Y<this->Y+32){
					this->X = Clamp(this->X+(-this->X + Link->X)/4, 16*Arg1, 16*Arg2);
				}
			}
			else if(Type==NPCBT_GUARDV){
				if(Link->X>this->X-32&&Link->X<this->X+32&&Link->Y>16*Arg1-32&&Link->Y<16*Arg2+32){
					this->Y = Clamp(this->Y+(-this->Y + Link->Y)/4, 16*Arg1, 16*Arg2);
				}
			}
			//Facing Up
			if(Link->Dir==DIR_UP&&Link->Y>=this->Y&&Link->Y<=this->Y+Height-8&&Link->X>=this->X-8&&Link->X<=this->X+Width-8){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						RunFFCScript(Script, 0);
					}
				}
			}
			//Facing Down
			else if(Link->Dir==DIR_DOWN&&Link->Y>=this->Y-16&&Link->Y<=this->Y+Height-16&&Link->X>=this->X-8&&Link->X<=this->X+Width-8){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						RunFFCScript(Script, 0);
					}
				}
			}
			//Facing Left
			else if(Link->Dir==DIR_LEFT&&Link->Y>=this->Y-8&&Link->Y<=this->Y+Height-8&&Link->X>=this->X&&Link->X<=this->X+Width){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						RunFFCScript(Script, 0);
					}
				}
			}
			//Facing Right
			else if(Link->Dir==DIR_RIGHT&&Link->Y>=this->Y-8&&Link->Y<=this->Y+Height-8&&Link->X>=this->X-16&&Link->X<=this->X+Width-16){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						RunFFCScript(Script, 0);
					}
				}
			}
			Waitframe();
		}
	}
}

ffc script NPCScript_Simple{
	void run(int String, int Script, int D0, int D1, int D2, int D3, int D4, int D5){
		//Saves the width and height of the FFC for collision checks
		int Width = 16;
		int Height = 16;
		if(this->EffectWidth!=16)
			Width = this->EffectWidth;
		else if(this->TileWidth>1)
			Width = this->TileWidth*16;
		if(this->EffectHeight!=16)
			Height = this->EffectHeight;
		else if(this->TileHeight>1)
			Height = this->TileHeight*16;
		while(true){
			//Facing Up
			if(Link->Dir==DIR_UP&&Link->Y>=this->Y&&Link->Y<=this->Y+Height-8&&Link->X>=this->X-8&&Link->X<=this->X+Width-8){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						int Args[8] = {D0, D1, D2, D3, D4, D5};
						RunFFCScript(Script, Args);
					}
				}
			}
			//Facing Down
			else if(Link->Dir==DIR_DOWN&&Link->Y>=this->Y-16&&Link->Y<=this->Y+Height-16&&Link->X>=this->X-8&&Link->X<=this->X+Width-8){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						int Args[8] = {D0, D1, D2, D3, D4, D5};
						RunFFCScript(Script, Args);
					}
				}
			}
			//Facing Left
			else if(Link->Dir==DIR_LEFT&&Link->Y>=this->Y-8&&Link->Y<=this->Y+Height-8&&Link->X>=this->X&&Link->X<=this->X+Width){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						int Args[8] = {D0, D1, D2, D3, D4, D5};
						RunFFCScript(Script, Args);
					}
				}
			}
			//Facing Right
			else if(Link->Dir==DIR_RIGHT&&Link->Y>=this->Y-8&&Link->Y<=this->Y+Height-8&&Link->X>=this->X-16&&Link->X<=this->X+Width-16){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						int Args[8] = {D0, D1, D2, D3, D4, D5};
						RunFFCScript(Script, Args);
					}
				}
			}
			Waitframe();
		}
	}
}

const int D_TRADE = 0; //Screen->D value used for the trade sequence state

ffc script TradeSequence{
	void run(int CheckItem, int TradeItem, int NoItemString, int HasItemString, int TradedString){
		//Check if the player has already traded
		if(Screen->D[D_TRADE]==0){
			//If player hasn't traded and has the required item, play HasItemString, give the new item, and take the old item
			if(Link->Item[CheckItem]){
				Screen->Message(HasItemString);
				WaitNoAction();
				item itm = CreateItemAt(TradeItem, Link->X, Link->Y);
				itm->Pickup = IP_HOLDUP;
				Link->Item[CheckItem] = false;
				Screen->D[D_TRADE] = 1;
				WaitNoAction();
			}
			//If player hasn't traded and doesn't have the required item, play NoItemString
			else{
				Screen->Message(NoItemString);
				WaitNoAction();
			}
		}
		//If the player has already traded, play TradedString
		else{
			Screen->Message(TradedString);
			WaitNoAction();
		}
	}

 



#2 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 25 July 2017 - 09:36 PM

You've got to be a little more specific than that. What specific error is the compiler giving you? It should have both a line number and an error message. Without that, there's really not a whole lot we can do to help.

#3 Mibbitable

Mibbitable

    Junior

  • Members

Posted 25 July 2017 - 09:55 PM

PASS 1: PARSING

PASS 2: PREPROCESSING

PASS 3: BUILDING SYMBOL TABLES

TMP, LINE 229: ERROR 510: FUNCTION RUNFFCSCRIPT IS UNDECLARED

TMP, LINE 243: ERROR 510: FUNCTION RUNFFCSCRIPT IS UNDECLARED

TMP, LINE 257: ERROR 510: FUNCTION RUNFFCSCRIPT IS UNDECLARED

TMP, LINE 271: ERROR 510: FUNCTION RUNFFCSCRIPT IS UNDECLARED

TMP, LINE 67: ERROR 510: FUNCTION FINDFFCRUNNING IS UNDECLARED

TMP, LINE 157: ERROR 510: FUNCTION RUNFFCSCRIPT IS UNDECLARED

TMP, LINE 170: ERROR 510: FUNCTION RUNFFCSCRIPT IS UNDECLARED

TMP, LINE 183: ERROR 510: FUNCTION RUNFFCSCRIPT IS UNDECLARED

TMP, LINE 196: ERROR 510: FUNCTION RUNFFCSCRIPT IS UNDECLARED



#4 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 25 July 2017 - 10:26 PM

Ah, that's it. You need to download ffcscript.zh and import at the top of your script file, right below the line where you import std.zh.
  • Mibbitable likes this

#5 Mibbitable

Mibbitable

    Junior

  • Members

Posted 25 July 2017 - 10:45 PM

:confused:

 

PASS 1: PARSING

LINE 3: SYNTAX ERROR, UNEXPECTED IDENTIFIER, EXPECTING $END, ON TOKEN FFCSCRIPT

FATAL ERROR P00: CAN'T OPEN OR PARSE INPUT FILE!



#6 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 25 July 2017 - 11:00 PM

The line needs to look like this:

import "ffcscript.zh"


#7 Mibbitable

Mibbitable

    Junior

  • Members

Posted 25 July 2017 - 11:22 PM

Now its saying the same thing, but on line 4. Maybe im doing it wrong still.

import "std.zh"

import "ffcscript.zh"
Version 1.1.1

int RunFFCScript(int scriptNum, float args[])
 * Finds an unused FFC with ID between FFCS_MIN_FFC and FFCS_MAX_FFC and
 * sets it to use FFCS_INVISIBLE_COMBO and run the given script.
 * args should be a pointer to an array of up to 8 numbers. You can also
 * pass in NULL (from std.zh), in which case no arguments will be set.
 * The return value is the number of the FFC used, or 0 if no suitable FFC
 * could be found or scriptNum is invalid.

ffc RunFFCScriptOrQuit(int scriptNum, float args[])
 * Run an FFC script as above, or call Quit() if no FFCs are available or 
 * scriptNum is invalid. Returns a pointer to the FFC running the script.

int FindFFCRunning(int scriptNum)
 * Returns the number of an FFC running the specified script or 0 if
 * no FFC is running it or scriptNum is invalid.

int FindNthFFCRunning(int scriptNum, int n)
 * Returns the number of the nth FFC running the specified script or 0 if
 * there aren't that many FFCs running it or scriptNum is invalid.

int CountFFCsRunning(int scriptNum)
 * Returns the number of FFCs running the given script.
 

const int RESET_NPC_LAYER_ON_ENTRY = 1; //This fix will replace all CMB_NPC_SOLID tiles with CMB_NPC_HIDDEN 
										//when entering the screen. This should prevent problems with shared
										//layers. If you don't want this fix, set it to 0.

const int LAYER_NPC = 2; //The layer NPCs use for solid combos
const int CMB_NPC_HIDDEN = 41; //Non-solid combo used for hidden NPCs
const int CMB_NPC_SOLID = 42; //Solid combo placed under visible NPCs

const int LAYER_NPC_CANTALK = 4; //The layer used for the speech bubble
const int CMB_NPC_CANTALK = 44; //The combo used for the speech bubble
const int CS_NPC_CANTALK = 8; //The CSet used for the speech bubble

const int NPCBT_NONE = 0; //Regular NPCs
const int NPCBT_FACELINK = 1; //NPCs that turn to face Link
const int NPCBT_GUARDH = 2; //NPCs that move along a horizontal path
const int NPCBT_GUARDV = 3; //NPCs that move along a vertical path

ffc script NPCScript{
	void run(int String, int ItemCheck, int Type, int Arg1, int Arg2, int NoSolid, int Script){
		//Stores the NPC's combo, hides it
		int Combo = this->Data;
		this->Data = CMB_NPC_HIDDEN;
		//Waits until the NPC should appear and shows it
		if(ItemCheck<0){
			while(!Link->Item[Abs(ItemCheck)]){
				Waitframe();
			}
			this->Data = Combo;
			if(Type==NPCBT_FACELINK){
				this->Data = Combo + Arg1;
			}
		}
		else if(ItemCheck>0){
			if(!Link->Item[Abs(ItemCheck)]){
				this->Data = Combo;
				if(Type==NPCBT_FACELINK){
					this->Data = Combo + Arg1;
				}
			}
		}
		else if(ItemCheck==0){
			this->Data = Combo;
			if(Type==NPCBT_FACELINK){
				this->Data = Combo + Arg1;
			}
		}
		//Saves the width and height of the FFC for collision checks
		int Width = 16;
		int Height = 16;
		if(this->EffectWidth!=16)
			Width = this->EffectWidth;
		else if(this->TileWidth>1)
			Width = this->TileWidth*16;
		if(this->EffectHeight!=16)
			Height = this->EffectHeight;
		else if(this->TileHeight>1)
			Height = this->TileHeight*16;
		//Wait until the screen is done scrolling to avoid a weird ZC crashing bug
		Waitframe();
		while(Link->Action==LA_SCROLLING){
			Waitframe();
		}
		//Shared Layer Fix
		if(RESET_NPC_LAYER_ON_ENTRY==1){
			if(Screen->LoadFFC(FindFFCRunning(this->Script))==this){
				for(int i=0; i<176; i++){
					if(GetLayerComboD(LAYER_NPC, i)==CMB_NPC_SOLID){
						SetLayerComboD(LAYER_NPC, i, CMB_NPC_HIDDEN);
					}
				}
			}
		}
		//Sets the space below the NPC or the space a guard NPC occupies to be solid
		if(LAYER_NPC>-1&&NoSolid==0){
			if(Type==NPCBT_GUARDH){
				for(int x=Arg1; x<=Arg2+this->TileWidth-1; x++){
					for(int y=Floor(this->Y/16); y<=Floor(this->Y/16)+this->TileHeight-1; y++){
						SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_SOLID);
					}
				}
			}
			else if(Type==NPCBT_GUARDV){
				for(int x=Floor(this->X/16); x<=Floor(this->X/16)+this->TileWidth-1; x++){
					for(int y=Arg1; y<=Arg2+this->TileHeight-1; y++){
						SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_SOLID);
					}
				}
			}
			else{
				for(int x=Floor(this->X/16); x<=Floor(this->X/16)+this->TileWidth-1; x++){
					for(int y=Floor(this->Y/16); y<=Floor(this->Y/16)+this->TileHeight-1; y++){
						SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_SOLID);
					}
				}
			}
		}
		while(true){
			//Removes NPCs if Link has the required item
			if(ItemCheck>0){
				if(Link->Item[ItemCheck]){
					this->Data = CMB_NPC_HIDDEN;
					if(LAYER_NPC>-1&&NoSolid==0){
						if(Type==NPCBT_GUARDH){
							for(int x=Arg1; x<=Arg2+this->TileWidth-1; x++){
								for(int y=Floor(this->Y/16); y<=Floor(this->Y/16)+this->TileHeight-1; y++){
									SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_HIDDEN);
								}
							}
						}
						else if(Type==NPCBT_GUARDV){
							for(int x=Floor(this->X/16); x<=Floor(this->X/16)+this->TileWidth-1; x++){
								for(int y=Arg1; y<=Arg2+this->TileHeight-1; y++){
									SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_HIDDEN);
								}
							}
						}
						else{
							for(int x=Floor(this->X/16); x<=Floor(this->X/16)+this->TileWidth-1; x++){
								for(int y=Floor(this->Y/16); y<=Floor(this->Y/16)+this->TileHeight-1; y++){
									SetLayerComboD(LAYER_NPC, y*16+x, CMB_NPC_HIDDEN);
								}
							}
						}
					}
					Quit();
				}
			}
			//Handles animation for turning NPCs
			if(Type==NPCBT_FACELINK&&(Link->X>0&&Link->X<240&&Link->Y>0&&Link->Y<160)){
				if(Distance(CenterLinkX(), CenterLinkY(), CenterX(this), CenterY(this))<Arg2)
					this->Data = Combo + AngleDir4(Angle(CenterX(this), CenterY(this), CenterLinkX(), CenterLinkY()));
				else
					this->Data = Combo + Arg1;
			}
			//Handles movement for guard NPCs
			else if(Type==NPCBT_GUARDH){
				if(Link->X>16*Arg1-32&&Link->X<16*Arg2+32&&Link->Y>this->Y-32&&Link->Y<this->Y+32){
					this->X = Clamp(this->X+(-this->X + Link->X)/4, 16*Arg1, 16*Arg2);
				}
			}
			else if(Type==NPCBT_GUARDV){
				if(Link->X>this->X-32&&Link->X<this->X+32&&Link->Y>16*Arg1-32&&Link->Y<16*Arg2+32){
					this->Y = Clamp(this->Y+(-this->Y + Link->Y)/4, 16*Arg1, 16*Arg2);
				}
			}
			//Facing Up
			if(Link->Dir==DIR_UP&&Link->Y>=this->Y&&Link->Y<=this->Y+Height-8&&Link->X>=this->X-8&&Link->X<=this->X+Width-8){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						RunFFCScript(Script, 0);
					}
				}
			}
			//Facing Down
			else if(Link->Dir==DIR_DOWN&&Link->Y>=this->Y-16&&Link->Y<=this->Y+Height-16&&Link->X>=this->X-8&&Link->X<=this->X+Width-8){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						RunFFCScript(Script, 0);
					}
				}
			}
			//Facing Left
			else if(Link->Dir==DIR_LEFT&&Link->Y>=this->Y-8&&Link->Y<=this->Y+Height-8&&Link->X>=this->X&&Link->X<=this->X+Width){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						RunFFCScript(Script, 0);
					}
				}
			}
			//Facing Right
			else if(Link->Dir==DIR_RIGHT&&Link->Y>=this->Y-8&&Link->Y<=this->Y+Height-8&&Link->X>=this->X-16&&Link->X<=this->X+Width-16){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						RunFFCScript(Script, 0);
					}
				}
			}
			Waitframe();
		}
	}
}

ffc script NPCScript_Simple{
	void run(int String, int Script, int D0, int D1, int D2, int D3, int D4, int D5){
		//Saves the width and height of the FFC for collision checks
		int Width = 16;
		int Height = 16;
		if(this->EffectWidth!=16)
			Width = this->EffectWidth;
		else if(this->TileWidth>1)
			Width = this->TileWidth*16;
		if(this->EffectHeight!=16)
			Height = this->EffectHeight;
		else if(this->TileHeight>1)
			Height = this->TileHeight*16;
		while(true){
			//Facing Up
			if(Link->Dir==DIR_UP&&Link->Y>=this->Y&&Link->Y<=this->Y+Height-8&&Link->X>=this->X-8&&Link->X<=this->X+Width-8){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						int Args[8] = {D0, D1, D2, D3, D4, D5};
						RunFFCScript(Script, Args);
					}
				}
			}
			//Facing Down
			else if(Link->Dir==DIR_DOWN&&Link->Y>=this->Y-16&&Link->Y<=this->Y+Height-16&&Link->X>=this->X-8&&Link->X<=this->X+Width-8){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						int Args[8] = {D0, D1, D2, D3, D4, D5};
						RunFFCScript(Script, Args);
					}
				}
			}
			//Facing Left
			else if(Link->Dir==DIR_LEFT&&Link->Y>=this->Y-8&&Link->Y<=this->Y+Height-8&&Link->X>=this->X&&Link->X<=this->X+Width){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						int Args[8] = {D0, D1, D2, D3, D4, D5};
						RunFFCScript(Script, Args);
					}
				}
			}
			//Facing Right
			else if(Link->Dir==DIR_RIGHT&&Link->Y>=this->Y-8&&Link->Y<=this->Y+Height-8&&Link->X>=this->X-16&&Link->X<=this->X+Width-16){
				if(CMB_NPC_CANTALK>0)
					Screen->FastCombo(LAYER_NPC_CANTALK, Link->X, Link->Y-16, CMB_NPC_CANTALK, CS_NPC_CANTALK, 128);
				if(Link->PressA){
					Link->InputA = false;
					Link->PressA = false;
					Screen->Message(String);
					if(Script>0){
						int Args[8] = {D0, D1, D2, D3, D4, D5};
						RunFFCScript(Script, Args);
					}
				}
			}
			Waitframe();
		}
	}
}

const int D_TRADE = 0; //Screen->D value used for the trade sequence state

ffc script TradeSequence{
	void run(int CheckItem, int TradeItem, int NoItemString, int HasItemString, int TradedString){
		//Check if the player has already traded
		if(Screen->D[D_TRADE]==0){
			//If player hasn't traded and has the required item, play HasItemString, give the new item, and take the old item
			if(Link->Item[CheckItem]){
				Screen->Message(HasItemString);
				WaitNoAction();
				item itm = CreateItemAt(TradeItem, Link->X, Link->Y);
				itm->Pickup = IP_HOLDUP;
				Link->Item[CheckItem] = false;
				Screen->D[D_TRADE] = 1;
				WaitNoAction();
			}
			//If player hasn't traded and doesn't have the required item, play NoItemString
			else{
				Screen->Message(NoItemString);
				WaitNoAction();
			}
		}
		//If the player has already traded, play TradedString
		else{
			Screen->Message(TradedString);
			WaitNoAction();
		}
	}
}


#8 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 25 July 2017 - 11:24 PM

No no no no no, you don't put the entire header in your script file. You put ONLY the line I pasted above and nothing else.

#9 Mibbitable

Mibbitable

    Junior

  • Members

Posted 25 July 2017 - 11:33 PM

So it would be like this? 

import "std.zh"

import "ffcscript.zh"

const int RESET_NPC_LAYER_ON_ENTRY = 1; //This fix will replace all CMB_NPC_SOLID tiles with CMB_NPC_HIDDEN 
										//when entering the screen. This should prevent problems with shared
										//layers. If you don't want this fix, set it to 0.

const int LAYER_NPC = 2; //The layer NPCs use for solid combos
const int CMB_NPC_HIDDEN = 41; //Non-solid combo used for hidden NPCs
const int CMB_NPC_SOLID = 42; //Solid combo placed under visible NPCs

const int LAYER_NPC_CANTALK = 4; //The layer used for the speech bubble
const int CMB_NPC_CANTALK = 44; //The combo used for the speech bubble
const int CS_NPC_CANTALK = 8; //The CSet used for the speech bubble

const int NPCBT_NONE = 0; //Regular NPCs
const int NPCBT_FACELINK = 1; //NPCs that turn to face Link
const int NPCBT_GUARDH = 2; //NPCs that move along a horizontal path
const int NPCBT_GUARDV = 3; //NPCs that move along a vertical path

ffc script NPCScript{
	void run(int String, int ItemCheck, int Type, int Arg1, int Arg2, int NoSolid, int Script){
		//Stores the NPC's combo, hides it
		int Combo = this->Data;
		this->Data = CMB_NPC_HIDDEN;
		//Waits until the NPC should appear and shows it
		if(ItemCheck<0){
			while(!Link->Item[Abs(ItemCheck)]){
				Waitframe();
			}
			this->Data = Combo;
			if(Type==NPCBT_FACELINK){
Blah blah blah rest of code


#10 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 26 July 2017 - 12:09 AM

Yes, like that. That should compile without any issues.

#11 Mibbitable

Mibbitable

    Junior

  • Members

Posted 26 July 2017 - 01:19 AM

Im really confused.

 

PASS 1: PARSING

PASS 2: PREPROCESSING

CAN'T OPEN INPUT FILE

TMP, LINE 3: ERROR P01 : FAILURE TO PARSE IMPORTED FILE FFCSCRIPT.ZH


Edited by Mibbitable, 26 July 2017 - 01:19 AM.


#12 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 26 July 2017 - 01:47 AM

... do you actually have ffcscript.zh in the folder with ZC?

#13 Mibbitable

Mibbitable

    Junior

  • Members

Posted 26 July 2017 - 09:43 AM

:doh: No! It works perfectly fine now. Thank you so much!


  • Russ likes this


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users