Swindle Haggle

SubmittedDecember 14, 2016

0.0 rating

Featured Screenshot

Author

ZoriaRPG

Download Script Package

SwindleHaggle.zip

Description

This script allows you to permit a player to risk raising shop prices, in order to lower them. Once per shop, the player may press a button (set by script preferences) to attempt to 'haggle' with the shopkeep. This will result in one of three events, each with a 1/3 chance:

Prices lower.
Prices remain the same.
Prices increase.

The shop uses the 'Wealth Medal' items to accomplish its effects, and quests using this should balance shop prices around the player having 'Wealth Medal 1'.

The script only uses the first two level of Wealth medals, and you may edit the price discount, or price hike, by adjusting the values in the Item Editor for Wealth Medals level 1 and level 2.

Failing a 'haggle' attempt results in taking away the wealth medals 9for that shoppe).

You may still award the Level 3 Wealth Medal, if you so choose. This will override all 'haggle' shop pricing.

Script Setup Details

Compile the script, and assign the global script 'SwindleHaggle' to slow 2 (active).

If you already have a global script, place the following function 'DoHaggle()' before Waitdraw(), and the script will function normally.

This doesn't even require std.zh. 😀

Note: I purposefully wrote the identifiers in this to be hilarious, which may also make it slightly confusing. Don't fear: The proper mixture of insomnia and alcohol, cures all woes.

Script Contents

//Swindle_Haggle.zs
//Haggle Choppah by ZoriaRPG
//v0.2 24-Nov-2016

const int SCREEN_D_HAGGLE = 6;
int Haggle(){ return Screen->D[SCREEN_D_HAGGLE]; }
void Haggle(int haggle){ Screen->D[SCREEN_D_HAGGLE] = haggle; }

const int SFX_HAGGLE_GOOD = 27;
const int SFX_HAGGLE_FAIL = 28;
const int SFX_HAGGLE_NORM = 24;

const int HAGGLE = 1;
const int HAGGLE1 = 109;
const int HAGGLE2 = 110;
const int RT_HAGGLE = 10;

//Settings
//Set any of these to '1' t make pressing that button in a normal ZC shop try haggling with the merchant.
const int HAGGLE_BUTTON_B = 1;
const int HAGGLE_BUTTON_A = 1;
const int HAGGLE_BUTTON_R = 0;
const int HAGGLE_BUTTON_L = 1;
const int HAGGLE_BUTTON_EX1 = 0;
const int HAGGLE_BUTTON_EX2 = 0;
const int HAGGLE_BUTTON_EX3 = 0;
const int HAGGLE_BUTTON_EX4 = 0;

void HaggleMedals(int haggle){
if ( haggle == 1 ) {
if ( Link->Item[HAGGLE1] ) Link->Item[HAGGLE1] = false;
if ( Link->Item[HAGGLE2] ) Link->Item[HAGGLE2] = false;
}
if ( haggle == 2 ) {
if ( Link->Item[HAGGLE2] ) Link->Item[HAGGLE2] = false;
if ( !Link->Item[HAGGLE1] ) Link->Item[HAGGLE1] = true;
}
if ( haggle == 3 ) {
if ( !Link->Item[HAGGLE2] ) Link->Item[HAGGLE2] = true;
}
}

int HaggleMedals(){
if ( Link->Item[HAGGLE2] ) return 3;
if ( Link->Item[HAGGLE1] ) return 2;
return 1;
}

//This is the haggle that you swindle before WaitHaggle()
void DoHaggle(){
if ( HaggleMedals() != 2 && !CanHaggle() ) {
HaggleMedals(2);
}
if ( CanHaggle() && Haggle() ) HaggleMedals(Haggle());
TryHaggle();
}

bool CanHaggle(){
return ( Screen->RoomType == RT_HAGGLE );
}

void DrawHaggle() { Waitdraw(); }
void WaitHaggle() { Waitframe(); }

void TryHaggle(){
bool try;
if ( HAGGLE_BUTTON_B && ( Link->PressB ) ) try = true;
if ( HAGGLE_BUTTON_A && Link->PressA ) try = true;
if ( HAGGLE_BUTTON_R && Link->PressR ) try = true;
if ( HAGGLE_BUTTON_L && Link->PressL ) try = true;
if ( HAGGLE_BUTTON_EX1 && Link->PressEx1 ) try = true;
if ( HAGGLE_BUTTON_EX2 && Link->PressEx2 ) try = true;
if ( HAGGLE_BUTTON_EX3 && Link->PressEx3 ) try = true;
if ( HAGGLE_BUTTON_EX4 && Link->PressEx4 ) try = true;
if ( try && !Haggle() && CanHaggle() ){
Haggle( Rand(3)+1 );
if ( Haggle() == 1 && SFX_HAGGLE_FAIL ) Game->PlaySound(SFX_HAGGLE_FAIL);
if ( Haggle() == 2 && SFX_HAGGLE_NORM ) Game->PlaySound(SFX_HAGGLE_NORM);
if ( Haggle() == 3 && SFX_HAGGLE_GOOD ) Game->PlaySound(SFX_HAGGLE_GOOD);
for ( int q = 0; q InputUp = false; Link->PressUp = false;
Link->InputDown = false; Link->PressDown = false;
Link->InputLeft = false; Link->PressLeft = false;
Link->InputRight = false; Link->PressRight = false;
Link->InputR = false; Link->PressR = false;
Link->InputL = false; Link->PressL = false;
Link->InputA = false; Link->PressA = false;
Link->InputB = false; Link->PressB = false;
Link->InputEx1 = false; Link->PressEx1 = false;
Link->InputEx2 = false; Link->PressEx2 = false;
Link->InputEx3 = false; Link->PressEx3 = false;
Link->InputEx4 = false; Link->PressEx4 = false;
WaitHaggle();
}
HaggleMedals(Haggle());
//Prices won't swindle without warping. Ask Mister Owl.
Link->PitWarp( Game->GetCurDMap(), Game->GetCurScreen() );

}
}

global script SwindleHaggle{
void run(){
while(HAGGLE){
DoHaggle();
DrawHaggle();
WaitHaggle();
}
}
}

This entry has no reviews.

Recent Resources