Here is my code:
const int WSP_FALLING = 90; //Weapon/Misc. sprite for Link falling down a hole
const int WSP_LAVA = 91; //Weapon/Misc. sprite for Link drowning in lava
const int SFX_FALLING = 61; //SFX for falling down a hole
const int SFX_LAVA = 61; //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)
bool Falling;
ffc script HoleLava{
void run(int lava, int warpto, int warptype, int damage){
int graphic = WSP_FALLING; int sfx = SFX_FALLING;
if(lava){ graphic = WSP_LAVA; sfx = SFX_LAVA; }
if(this->X == 0 && this->Y == 0){
Waitframes(5);
this->X = Link->X; this->Y = Link->Y;
}
if(damage == 0) damage = 8;
while(true){
while(!OnPitCombo()) Waitframe();
int pitclk = 0;
while(OnPitCombo() && pitclk++ < 4) WaitCancelFeather();
if(pitclk >= 5) Fall(this,sfx,graphic,damage,warpto,warptype);
}
}
void Fall(ffc pos, int sfx, int graphic, int damage, int warpto, int warptype){
Falling = true;
Game->PlaySound(sfx);
for(int i=1;i<=Screen->NumLWeapons();i++){
lweapon l = Screen->LoadLWeapon(i);
if(l->ID == LW_SWORD) l->DeadState = WDS_DEAD;
}
int wait = CreateGraphic(graphic);
Link->CollDetection = false; Link->Invisible = true;
for(int i=0;i<30;i++) WaitNoAction();
Link->CollDetection = true; Link->Invisible = false;
if(warpto) Warp(pos, warptype);
Link->X = pos->X; Link->Y = pos->Y;
Link->HP -= damage;
Game->PlaySound(SFX_OUCH);
Falling = false;
}
void Warp(ffc Warp, int warptype){
int orig = Warp->Data;
Warp->Data = CMB_AUTOWARP+warptype;
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 WaitCancelFeather(){
if(GetEquipmentA() == I_ROCSFEATHER && Link->InputA) Link->InputA = false;
if(GetEquipmentB() == I_ROCSFEATHER && Link->InputB) Link->InputB = false;
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;
}
ffc script SecretSFX
{
void run(int playsound)
{
Game->PlaySound(playsound);
}
}
ffc script Shop{
void run(int itm, int price,int input){
while(true){
if(CanBuy(this,input)){
SetInput(input,false);
if(Game->Counter[CR_RUPEES] >= price){
ShopItemThanks(itm);
DeductRupees(price);
}else Screen->Message(S_NORUPEES);
}
Waitframe();
}
}
}
const int S_NORUPEES = 0; //Message saying 'Not enough rupees'
const int S_THANKS = 0; //Message saying 'Thanks for buying'
bool CanBuy(ffc buy,int input){
return (Abs(Link->X-buy->X) < 8 && Abs(Link->Y-(buy->Y+8)) < 8 && SelectPressInput(input) && Link->Dir == DIR_UP);
}
void ShopItemThanks(int itm){
Screen->Message(S_THANKS);
Game->PlaySound(SFX_SCALE);
WaitNoAction();
CreatePickupItem(Link->X,Link->Y,itm);
Game->PlaySound(SFX_PICKUP);
WaitNoAction();
}
void CreatePickupItem(int x, int y, int itm){
item Spawn = Screen->CreateItem(itm);
Spawn->Pickup |= (IP_TIMEOUT|IP_HOLDUP);
Spawn->HitWidth = 16; Spawn->HitHeight = 16;
Spawn->X = x; Spawn->Y = y;
}
void DeductRupees(int amount){
FreezeScreen();
for(int i=0;i<amount;i++){
Game->PlaySound(SFX_MSG);
Game->Counter[CR_RUPEES]--;
Waitframe();
}
UnFreeze();
}
int FreezeID;
void FreezeScreen(){
FreezeID = Screen->ComboT[0];
Screen->ComboT[0] = CT_SCREENFREEZE;
}
void UnFreeze(){
Screen->ComboT[0] = FreezeID;
}
//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;
}
It works fine other than the GB Shop script.
Can someone help me get it to work?