Can you now post your entire .z file here?
const int CMB_BLANK = 0; //Set this to the ID of a transparent combo
const int CMB_NULL = 0; //Leave this as 0!
ffc script ShopSingleSaleItem{
void run(int itm, int price, int perm, int input){
while(Screen->D[perm] == 0){
if(CanBuy(this,input)){
SetInput(input,false);
if(Game->Counter[CR_RUPEES] >= price){
ShopItemThanks(itm);
this->Data = CMB_BLANK;
DeductRupees(price);
Screen->D[perm]++;
}else Screen->Message(S_NORUPEES);
}
Waitframe();
}
this->Data = CMB_NULL;
}
}
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;
}
const int WSP_FALLING = 100; //Weapon/Misc. sprite for Link falling down a hole
const int WSP_LAVA = 101; //Weapon/Misc. sprite for Link drowning in lava
const int SFX_FALLING = 38; //SFX for falling down a hole
const int SFX_LAVA = 55; //SFX for drowning in lava
const int CMB_AUTOWARP = 7; //Combo ID of a transparent AutoWarp A combotype
const int CT_HOLELAVA = 11; //Combotype to give hole functionality to (default is Left Statue)
ffc script HoleLava{
void run(int lava, int warpto, int damage){
this->Misc[0] = WSP_FALLING; this->Misc[1] = SFX_FALLING; //Set up correct graphic and sound effect
if(lava){
this->Misc[0] = WSP_LAVA;
this->Misc[1] = SFX_LAVA;
}
//Find return point when falling in lava. (this->X,this->Y) used if ffc is not at (0,0)
if((this->X == 0 && this->Y == 0) || this->Flags[FFCF_CHANGER]){
Waitframes(5);
this->X = Link->X; this->Y = Link->Y;
}
this->Misc[2] = warpto;
if(damage) this->Misc[3] = damage;
else this->Misc[3] = 8;
while(true){
while(!OnPitCombo()) Waitframe(); //Idle while not on pit
int pitclk = 0;
while(OnPitCombo() && pitclk++ < 4) Waitframe(); //Wait for four frames whilst on pit
if(pitclk >= 5) Fall(this); //Fall
}
}
void Fall(ffc Info){
Screen->ClearSprites(SL_LWPNS);
Game->PlaySound(Info->Misc[1]);
int wait = CreateGraphic(Info->Misc[0]);
Link->Invisible = true; Link->CollDetection = true;
for(int i=0;i<wait+30;i++) WaitNoAction();
Link->Invisible = false; Link->CollDetection = false;
if(Info->Misc[2]) Warp(Info);
Link->X = Info->X; Link->Y = Info->Y;
Link->HP -= Info->Misc[3];
Game->PlaySound(SFX_OUCH);
}
void Warp(ffc Warp){
int orig = Warp->Data;
Warp->Data = CMB_AUTOWARP;
Warp->Flags[FFCF_CARRYOVER] = true;
Waitframe();
Warp->Data = orig;
Warp->Flags[FFCF_CARRYOVER] = false;
Link->Z = Link->Y;
Quit();
}
bool OnPitCombo(){
return (Screen->ComboT[ComboAt(Link->X+8,Link->Y+8)] == CT_HOLELAVA && Link->Z <= 0 && Link->Action != LA_FROZEN);
}
int CreateGraphic(int sprite){
lweapon l = Screen->CreateLWeapon(LW_SCRIPT1);
l->HitXOffset = 500;
l->UseSprite(sprite);
l->DeadState = l->NumFrames*l->ASpeed;
l->X = Link->X; l->Y = Link->Y;
return l->DeadState;
}
void WaitNoAction(){
Link->InputUp = false; Link->InputDown = false;
Link->InputLeft = false; Link->InputRight = false;
Link->InputR = false; Link->InputMap = false;
Link->InputA = false; Link->InputB = false;
Waitframe();
}
}
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);
Link->Action=LA_HOPPING;
}
ffcsentlinkjumping=true;
Link->Y=Link->Y+verticalmovement;
Link->Z=Link->Z+verticalmovement;
}
Waitframe();
}
}
}
ffc script OrbReact
{
void run(int a,int b,int c, int m)
{
if(Link->Item[a] && Link->Item[b] && Link->Item[c])
{
Screen->TriggerSecrets();
}
else
{
Screen->Message(m);
}
}
}
item script Give
{
void run(int i)
{
Link->Item[i] = true;
}
}
item script Message{
void run(int m){
Screen->Message(m);
}
}