import "std.zh"
ffc script Signpost2{
void run(int m,int input){
int loc = ComboAt(this->X,this->Y);
if (Screen->State[ST_SECRET]==false){
while(true){
while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
SetInput(input,false);
Screen->Message(m);
Screen->TriggerSecrets();
Screen->State[ST_SECRET]=true;
break;
Waitframe();
}
}
}
bool AgainstComboBase(int loc){
return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) <
;
}
}
//!!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;
}
const int FONT_DONATION = 0; //Font used for drawing donation values.
const int COOLDOWN_BETWEEN_PLEDGES = 60; //Cooldown between donations. Set to -1 to render consequtive donations
impossible without exiting and reentering the screen.
const int SFX_DONATION = 25;//Sound to play on successful donation.
ffc script DonationShop{
void run (int screenD, int counter, int target, int pledge, int reward,int string_offer , int
string_on_donation, int string_on_target){
int cooldown = 0;
int mincounter = 0;
if (counter == CR_LIFE) mincounter += 16;
if (Screen->D[screenD]>=target){
if (string_on_target>0)Screen->Message(string_on_target);
this->Data = 0;
Quit();
}
if (string_offer>0)Screen->Message(string_offer);
while(true){
if (cooldown>0)cooldown--;
int cost = pledge; //This variable will be drawn onto screen.
if (counter == CR_LIFE) cost /= 16; //Blood donation will be displayed measured in full hearts
if (counter == CR_MAGIC) cost /= 32; //Ditto for magic. Measured in full beakers.
int numdcm = 0; //
if ((counter == CR_LIFE)&&((pledge%16)>0)) numdcm=2;//Show partial amounts if needed.
if ((counter == CR_MAGIC)&&((pledge%32)>0)) numdcm=2;//
Screen->DrawInteger(0, ((this->X)+16), ((this->Y)+4),FONT_DONATION ,1,-1, 0, 0, cost, numdcm,
OP_OPAQUE);
if ((LinkCollision(this))&&(cooldown==0)&&(Link->PressA)){
if (Game->Counter[counter]>=(mincounter+pledge)){
Game->PlaySound(SFX_DONATION);
if (counter == CR_LIFE){ //No one likes blood donations. :-(
Game->PlaySound(SFX_OUCH);
Link->HitDir = OppositeDir(Link->Dir);
if (Link->Action==LA_SWIMMING) Link->Action=LA_GOTHURTWATER;
else Link->Action = LA_GOTHURTLAND;
}
if ((counter == CR_LIFE)||(counter == CR_MAGIC)) Game->Counter[counter]-
=pledge;
else Game->DCounter[counter] -= pledge;
Screen->D[screenD]+=pledge;
if (string_on_donation>0)Screen->Message(string_on_donation);
Waitframe();
if (Screen->D[screenD]>=target){
if (string_on_target>0)Screen->Message(string_on_target);
Waitframe();
if (reward>0){
Game->PlaySound(SFX_PICKUP);
if (Link->Action==LA_SWIMMING)Link->Action==LA_HOLD2WATER;
else Link->Action = LA_HOLD2LAND;
Link->HeldItem=reward;
Link->Item[reward]= true;
}
else if (reward == -1){
Game->PlaySound(SFX_SECRET);
Screen->TriggerSecrets();
Screen->State[ST_SECRET]=false;
}
this->Data = 0;
Quit();
}
cooldown= COOLDOWN_BETWEEN_PLEDGES;
}
}
Waitframe();
}
}
}
ffc script Shop
{
void run(int itm, int price, int input, int thanksString, int infoString, int infoInput, int counter)
{
counter++;
// Run continuously
while(true)
{
// If Link is below the FFC facing up
if(ShopCanBuy(this))
{
// If he hits the provided input button
if(ShopInput(input))
{
// Disable that input for the frame
ShopSetInput(input,false);
// If Link has enough rupees
if(Game->Counter[counter] >= price)
{
// Give Link the item
ShopItemThanks(itm, thanksString);
// Remove the rupees
ShopDeductRupees(price, counter);
}
// Else Link does not have enough rupees
else Screen->Message(S_NORUPEES);
}
// If a informational string is requested and the info button is pressed
else if(infoString > 0 && ShopInput(infoInput))
{
// Disable the input for the selected input button
ShopSetInput(infoInput, false);
// Display the info string
Screen->Message(infoString);
}
// Else Link is under the FFC but has not hit the correct button
else
{
// Do stuff here if you want something to happen when Link is under the item but hasn't hit the
input button
// Or draw some graphic to indicate to the player what button to press
}
} //! End of if(ShopCanBuy(this))
Waitframe();
} //! End of while(true)
} //! End of void run(int itm, int price, int input)
}//! End of ffc script Shop
const int S_SOLDCOMBO = 0; // Combo for the item not being available. (Transparent or a "sold out" sign.)
const int S_SOLDCSET = 0; // CSet for the item not being available. (Only if you want a "sold out" sign.)
// Alternate shop script FFC. These can be purchased only once.
// After it is sold, it shows the S_SOLDCOMBO combo for the FFC
// d0 = Item number you want to be available
// d1 = The price for the item
// d2 = Screen->D index to use for checking the combo
// d3 = The input button to press
// -1 for A, B, L, and R
// 0 for A
// 1 for B
// 2 for L
// 3 for R
// d4 = Message String after obtaining the item (if not included, default S_THANKS string is used)
// d5 = Message String to display for information (item info, item price, etc.)
// d6 = Input button to press for information (same input as above. If buy button is set the same
// as the info button or set to -1, then the information string will never activate
// d7 = The counter to use. NOTE: These are one below the CR_number in std.zh. 0 is rupees, -1 is life, 2 is
arrows, etc.
ffc script ShopSingleSaleItem
{
void run(int itm, int price, int perm, int input, int thanksString, int infoString, int infoInput, int counter)
{
counter++;
// While the item has not been purchased yet
while(Screen->D[perm] == 0)
{
// If Link is under the FFC facing up
if(ShopCanBuy(this))
{
// If he hits the selected input button
if(ShopInput(input))
{
// Disable the input for the selected input button
ShopSetInput(input,false);
// If Link has enough rupees
if(Game->Counter[counter] >= price)
{
// Give Link the item
ShopItemThanks(itm, thanksString);
// Blank out the FFC's combo and cset
this->Data = S_SOLDCOMBO;
this->CSet = S_SOLDCSET;
// Remove the rupees from Link
ShopDeductRupees(price, counter);
// Set the Screen D value to reflect that the item was purchased
Screen->D[perm]++;
}
// Else Link doesn't have enough rupees
else Screen->Message(S_NORUPEES);
}
// If a informational string is requested and the info button is pressed
else if(infoString > 0 && ShopInput(infoInput))
{
// Disable the input for the selected input button
ShopSetInput(infoInput, false);
// Display the info string
Screen->Message(infoString);
}
// Else Link is under the FFC but has not hit the correct button
else
{
// Do stuff here if you want something to happen when Link is under the item but hasn't hit the
input button
// Or draw some graphic to indicate to the player what button to press
}
} //! End of if(CanBuy(this))
Waitframe();
} //! End of while(Screen->D[perm] == 0)
// This item has been bought, so show the sold out combo
this->Data = S_SOLDCOMBO;
} //! End of void run(int itm, int price, int perm, int input)
} //! End of ffc script ShopSingleSaleItem
const int S_NORUPEES = 0; //Message saying 'Not enough rupees'
const int S_THANKS = 0; //Message saying 'Thanks for buying'
const int S_SOLDSFX = 0; //SFX when you buy an item (25 for fairy sound)
// Checks if Link is underneath the FFC facing up
bool ShopCanBuy(ffc buy)
{
return (Abs(Link->X-buy->X) < 8 && Abs(Link->Y-(buy->Y+
) < 8 && Link->Dir == DIR_UP);
}
// Gives Link the item, shows him holding it up
void ShopItemThanks(int itm, int thanksString)
{
if(S_SOLDSFX > 0)
{
Game->PlaySound(S_SOLDSFX);
WaitNoAction();
}
// Show the "thanks" string
if(thanksString > 0)
Screen->Message(thanksString);
else
Screen->Message(S_THANKS);
// Put the item underneath Link
ShopCreateItem(Link->X,Link->Y,itm);
// Force Link to hold up the item
Game->PlaySound(SFX_PICKUP);
Link->Action = LA_HOLD2LAND;
Link->HeldItem = itm;
// While Link is holding up the item, disable input
while(Link->HeldItem == itm && Link->Action == LA_HOLD2LAND)
{
// Disable all directional input of Link and Wait a frame
WaitNoAction();
}
} //! End of void ShopItemThanks(int itm)
// Function to plant an item under Link
void ShopCreateItem(int x, int y, int itm)
{
item Spawn = Screen->CreateItem(itm);
Spawn->HitWidth = 16; Spawn->HitHeight = 16;
Spawn->X = x; Spawn->Y = y;
}
// Gets if the requested input button(s) were pressed
bool ShopInput(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;
else if(input == -1)
{
return (Link->PressA || Link->PressB || Link->PressL || Link->PressR);
}
}
// Sets the requested input button(s) to the given state
void ShopSetInput(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;
else if(input == -1)
{
Link->InputA = state;
Link->InputB = state;
Link->InputL = state;
Link->InputR = state;
}
}
// This deducts rupees (or whatever counter is specified)
void ShopDeductRupees(int amount, int counter)
{
FreezeScreen();
for(int i=0;i<amount;i++)
{
Game->PlaySound(SFX_MSG);
Game->Counter[counter]--;
WaitNoAction();
}
UnFreeze();
}
// EVERYTHING UNDER HERE IS UN-EDITED FROM Joe123's VERSION
int FreezeID;
void FreezeScreen(){
FreezeID = Screen->ComboT[0];
Screen->ComboT[0] = CT_SCREENFREEZE;
}
void UnFreeze(){
Screen->ComboT[0] = FreezeID;
}
const int WSP_FALLING = 89; //Weapon/Misc. sprite for Link falling down a hole
const int WSP_LAVA = 90; //Weapon/Misc. sprite for Link drowning in lava
const int SFX_FALLING = 66; //SFX for falling down a hole
const int SFX_LAVA = 67; //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 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)) <
;
}
}
ffc script RumbleOnce{
void run(int rumbletime, int msg){
if(Screen->D[0] != 1){
for(int i = 0; i<rumbletime; i++){
Screen->Quake = 1;
WaitNoAction();
}
Screen->Message(msg);
WaitNoAction();
Screen->D[0] = 1;
}
}
}
ffc script SpriteSwap{
void run(int originalweapon, int sprite){
while(true){
for(int i=0; i<=Screen->NumEWeapons(); i++){
eweapon e=Screen->LoadEWeapon(i);
if(e->ID==originalweapon){
e->UseSprite(sprite);
}
}
Waitframe();
}
}