//Prompt GFX
const int CMB_DONATION_PROMPT = 911;//Combo ID used to render prompt, when Link steps on spot.
const int CSET_DONATION_PROMPT = 11;//CSet used to render prompt, when Link steps on spot.
//Donation shop GUI
const int FONT_DONATION_SHOP = 0; //Font used for drawing donation HUD and all text in UI.
const int CSET_FONT_SHADOW_DONATION = 0x71;//Shadow for HUD font drawing (Color).
const int TILE_DONATION_FRAME = 20052;//Id of top left corner for 3x3 frame used to render UI frame.
const int CSET_DONATION_FRAME = 11;//CSet used to render UI frame.
const int C_DONATION_CANT_AFFORD = 0x81;//Color to render inner counter if input is capped by player`s funds.
const int C_DONATION_CAN_FINISH = 0x51;//Color to render inner counter if input is capped by exceeding charity demand.
// const int DONATION_DISPLAY_X_OFFSET = 0;//Coordinates of rendering counter icon displayed in the screen, input field.
// const int DONATION_DISPLAY_Y_OFFSET = -16;
const int CMB_DONATION_SELECTION = 915;//Combo used for animated selection cursor
const int CSET_DONATION_SELECTION = 7;//CSet used to render animated selection cursor
const int FONTSIZE_DONATION_SELECTION = 8;//Width of each symbol in input field, in pixels.
//Audio
const int SFX_DONATION_CONFIRM = 0;//Sound to play on successful donation.
const int SFX_DONATION_INPUT = 5;//Sound to play on operating input.
const int SFX_DONATION_CAPPED = 16;//Sound to play if unput is capped.
//Modern Donation Shop. Stand on FFC and press either A, or B, or EX1, then input amount to perform donation. Donate target total for reward.
//Place FFC at trigger position.
//D0 - Screen D to keep track charity progress.Must be unique per for each FFC in the same screen.
//D1 - Counter to be used by this charity organization. For blood donations, minimum of 1 full heart should left upon donation.
//D2 - Target total for this charity campaign.
//D3 - String to display on making donation.
//D4 - Reward for finishing charity campaign. >0 - Award item ID, -1 - Secret trigger.
//D5 - #####.____ - String to display, when starting interaction with FFC script.
// _____.#### - String to display, when charity campaign is completed.
//D6 - Combo position to render charity progress (that huge ad banner or display).
//D7 - Combo used to render counter image. CSet is FFC`s CSet.
ffc script DonationShop2{
void run (int ScreenD, int counter, int capacity, int progstr, int reward, int str, int drawpos, int cmb){
int mincounter = 0;
int intromsg = GetHighFloat(str);
int endmsg = GetLowFloat(str);
if (counter == CR_LIFE) mincounter += 16;
int linkcmb = 0;
int pos = ComboAt(CenterX(this),CenterY(this));
int State = 0;
int input = 0;
int cap = 0;
int numdigits = 4;
//int inputbuf[] = "0000";
int str1[] = "Donation";
int str2[] = "Progress:";
int str3[] = "Owned:";
int str4[] = "1 heart";
int str5[] = "must left";
int str6[] = "Ex1-Confirm";
int str7[] = "Ex2-Cancel";
int str8[] = "/";
bool secret = Screen->D[ScreenD]>=100000;
int inputcursor=0;
while(true){
if (State==0){
linkcmb = ComboAt (CenterLinkX(), CenterLinkY()-2);
if (linkcmb==pos){
Screen->FastCombo(6, Link->X,Link->Y-15,CMB_DONATION_PROMPT, CSET_DONATION_PROMPT,OP_OPAQUE);
if (Link->PressEx1){
if ((Screen->D[ScreenD]%100000)<capacity){
if (intromsg>0)Screen->Message(intromsg);
cap = Min (Game->Counter[counter]-mincounter+Game->DCounter[counter], capacity-(Screen->D[ScreenD]%100000));
input=Clamp(input, 0, cap);
State=1;
}
else Screen->Message(endmsg);
}
}
}
else if (State==1){
DrawFrame(6,TILE_DONATION_FRAME,48,16,9,9,CSET_DONATION_FRAME,OP_OPAQUE);
if (CSET_FONT_SHADOW_DONATION>0){//Donation progress
Screen->DrawString(6,81, 33, FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0, str1, OP_OPAQUE);
Screen->DrawString(6,81, 49, FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0, str2, OP_OPAQUE);
}
Screen->DrawString(6,80, 32, FONT_DONATION_SHOP, 1, -1, 0, str1, OP_OPAQUE);
Screen->DrawString(6,80, 48, FONT_DONATION_SHOP, 1, -1, 0, str2, OP_OPAQUE);
Screen->FastCombo(6, 64, 64, cmb, this->CSet, OP_OPAQUE);
if (CSET_FONT_SHADOW_DONATION>0){//Progress/target
Screen->DrawInteger(6,81, 65,FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0,0, (Screen->D[ScreenD]%100000),0, OP_OPAQUE);
Screen->DrawString(6,131, 65,FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0, str8, OP_OPAQUE);
Screen->DrawInteger(6,139, 65,FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0,0, capacity,0, OP_OPAQUE);
}
Screen->DrawInteger(6,80, 64,FONT_DONATION_SHOP, 1, -1, 0,0, (Screen->D[ScreenD]%100000),0, OP_OPAQUE);
Screen->DrawString(6,130, 64,FONT_DONATION_SHOP, 1, -1, 0, str8, OP_OPAQUE);
Screen->DrawInteger(6,138, 64,FONT_DONATION_SHOP, 1, -1, 0,0, capacity,0, OP_OPAQUE);
if (CSET_FONT_SHADOW_DONATION>0){//Owned:X
Screen->DrawString(6,81, 73,FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0, str3, OP_OPAQUE);
Screen->DrawInteger(6,139, 73,FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0,0, Game->Counter[counter],0, OP_OPAQUE);
}
Screen->DrawString(6,80, 72,FONT_DONATION_SHOP, 1, -1, 0, str3, OP_OPAQUE);
Screen->DrawInteger(6,138, 72,FONT_DONATION_SHOP, 1, -1, 0,0, Game->Counter[counter],0, OP_OPAQUE);
int inputbuf[] = "00000";
int numdigits=1;
if (input>0) numdigits = Floor(Log10(input)) + 1;
itoa(inputbuf,strlen(inputbuf) - numdigits,input);
if (CSET_FONT_SHADOW_DONATION>0){//input
Screen->DrawString(6,139, 89, FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 2, inputbuf, OP_OPAQUE);
}
Screen->DrawString(6,138, 88, FONT_DONATION_SHOP, 1, -1, 2, inputbuf, OP_OPAQUE);
Screen->FastCombo(6, 126-FONTSIZE_DONATION_SELECTION*inputcursor, 84,CMB_DONATION_SELECTION, CSET_DONATION_SELECTION, OP_OPAQUE);
if (mincounter>0){
if (CSET_FONT_SHADOW_DONATION>0){//1 heart must left
Screen->DrawString(6,81, 105, FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0, str4, OP_OPAQUE);
Screen->DrawString(6,81, 113, FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0, str5, OP_OPAQUE);
}
Screen->DrawString(6,80, 104, FONT_DONATION_SHOP, 1, -1, 0, str4, OP_OPAQUE);
Screen->DrawString(6,80, 112, FONT_DONATION_SHOP, 1, -1, 0, str5, OP_OPAQUE);
}
if (CSET_FONT_SHADOW_DONATION>0){//Ex1-Confirm, Ex2-Cancel
Screen->DrawString(6,81, 129, FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0, str6, OP_OPAQUE);
Screen->DrawString(6,81, 137, FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, 0, str7, OP_OPAQUE);
}
Screen->DrawString(6,80, 128, FONT_DONATION_SHOP, 1, -1, 0, str6, OP_OPAQUE);
Screen->DrawString(6,80, 136, FONT_DONATION_SHOP, 1, -1, 0, str7, OP_OPAQUE);
if (Link->PressLeft){
Game->PlaySound(SFX_DONATION_INPUT);
inputcursor++;
if (inputcursor>3)inputcursor=0;
}
if (Link->PressRight){
Game->PlaySound(SFX_DONATION_INPUT);
inputcursor--;
if (inputcursor<0)inputcursor=3;
}
if (Link->PressUp){
input+=Pow(10, inputcursor);
if (input>cap){
Game->PlaySound(SFX_DONATION_CAPPED);
if (cap==Game->Counter[counter]-mincounter+Game->DCounter[counter]){
Screen->DrawString(6,80, 72,FONT_DONATION_SHOP, C_DONATION_CANT_AFFORD, -1, 0, str3, OP_OPAQUE);
Screen->DrawInteger(6,138, 72,FONT_DONATION_SHOP, C_DONATION_CANT_AFFORD, -1, 0,0, Game->Counter[counter],0, OP_OPAQUE);
}
else {
Screen->DrawInteger(6,80, 64,FONT_DONATION_SHOP, C_DONATION_CAN_FINISH, -1, 0,0, (Screen->D[ScreenD]%100000),0, OP_OPAQUE);
Screen->DrawString(6,130, 64,FONT_DONATION_SHOP, C_DONATION_CAN_FINISH, -1, 0, str8, OP_OPAQUE);
Screen->DrawInteger(6,138, 64,FONT_DONATION_SHOP, C_DONATION_CAN_FINISH, -1, 0,0, capacity,0, OP_OPAQUE);
}
input=cap;
}
else Game->PlaySound(SFX_DONATION_INPUT);
}
if (Link->PressDown){
input-=Pow(10, inputcursor);
if (input<0){
Game->PlaySound(SFX_DONATION_CAPPED);
input=0;
}
else Game->PlaySound(SFX_DONATION_INPUT);
}
if (Link->PressEx2){
State=0;
}
if (Link->PressEx1 && input>0){
Game->PlaySound(SFX_DONATION_CONFIRM);
if (counter==CR_LIFE)Game->PlaySound(SFX_OUCH);
Game->DCounter[counter] -= input;
Screen->D[ScreenD] += input;
if ((Screen->D[ScreenD]%100000)>=capacity){
if (reward!=0){
Screen->Message(endmsg);
Waitframe();
if (reward<0 && !secret){
Game->PlaySound(SFX_SECRET);
Screen->TriggerSecrets();
Screen->State[ST_SECRET]=true;
secret=true;
}
if (reward>0){
Game->PlaySound(SFX_SECRET);
item it = CreateItemAt(reward, Link->X, Link->Y);
it->Pickup = 0x2;
secret=true;
}
}
Screen->D[ScreenD]=capacity+Cond(secret, 100000,0);
}
else Screen->Message(progstr);
State=0;
}
NoAction();
}
int drawx = ComboX(drawpos);
int drawy = ComboY(drawpos);
Screen->FastCombo(2, drawx, drawy, cmb, this->CSet, OP_OPAQUE);
drawx+=16;
drawy+=4;
if (CSET_FONT_SHADOW_DONATION>0)Screen->DrawInteger(2, drawx+1, drawy+1, FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, -1, -1, (Screen->D[ScreenD]%100000), 0, OP_OPAQUE);
Screen->DrawInteger(2, drawx, drawy,FONT_DONATION_SHOP, 1, -1, -1, -1, (Screen->D[ScreenD]%100000), 0, OP_OPAQUE);
int stra[]="/";
drawx+=40;
if (CSET_FONT_SHADOW_DONATION>0) Screen->DrawString(2, drawx+1, drawy+1, FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION,-1, 0, stra,OP_OPAQUE);
Screen->DrawString(2, drawx, drawy, FONT_DONATION_SHOP, 1,-1, 0, stra,OP_OPAQUE);
drawx+=8;
if (CSET_FONT_SHADOW_DONATION>0)Screen->DrawInteger(2, drawx+1, drawy+1,FONT_DONATION_SHOP, CSET_FONT_SHADOW_DONATION, -1, -1, -1, capacity, 0, OP_OPAQUE);
Screen->DrawInteger(2, drawx, drawy,FONT_DONATION_SHOP, 1, -1, -1, -1, capacity, 0, OP_OPAQUE);
Waitframe();
}
}
void DrawFrame(int layer, int tile, int posx, int posy, int sizex, int sizey, int CSet, int opacity){
int drawx = posx;
int drawy = posy;
int xoffset=0;
int yoffset=0;
for (int w=0; w<sizex; w++){
drawx = posx+16*w;
xoffset=0;
if (w>0)xoffset=1;
if (w==sizex-1) xoffset=2;
for (int h=0; h<sizey; h++){
drawy = posy+16*h;
yoffset=0;
if (h>0)yoffset=1;
if (h==sizey-1) yoffset=2;
Screen->FastTile(layer, drawx, drawy, tile +xoffset+20*yoffset, CSet, opacity);
}
}
}
}