ZoriaRPG

ZScript HaggleChoppah

Nov 23rd, 2016
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Swindle_Haggle.zs
  2. //Haggle Choppah by ZoriaRPG
  3. //v0.2 24-Nov-2016
  4.  
  5. const int SCREEN_D_HAGGLE = 6;
  6. int Haggle(){ return Screen->D[SCREEN_D_HAGGLE]; }
  7. void Haggle(int haggle){ Screen->D[SCREEN_D_HAGGLE] = haggle; }
  8.  
  9. const int SFX_HAGGLE_GOOD = 27;
  10. const int SFX_HAGGLE_FAIL = 28;
  11. const int SFX_HAGGLE_NORM = 24;
  12.  
  13. const int HAGGLE = 1;
  14. const int HAGGLE1 = 109;
  15. const int HAGGLE2 = 110;
  16. const int RT_HAGGLE = 10;
  17.  
  18. //Settings
  19. //Set any of these to '1' t make pressing that button in a normal ZC shop try haggling with the merchant.
  20. const int HAGGLE_BUTTON_B = 1;
  21. const int HAGGLE_BUTTON_A = 1;
  22. const int HAGGLE_BUTTON_R = 0;
  23. const int HAGGLE_BUTTON_L = 1;
  24. const int HAGGLE_BUTTON_EX1 = 0;
  25. const int HAGGLE_BUTTON_EX2 = 0;
  26. const int HAGGLE_BUTTON_EX3 = 0;
  27. const int HAGGLE_BUTTON_EX4 = 0;
  28.  
  29. void HaggleMedals(int haggle){
  30.     if ( haggle == 1 ) {
  31.         if ( Link->Item[HAGGLE1] ) Link->Item[HAGGLE1] = false;
  32.         if ( Link->Item[HAGGLE2] ) Link->Item[HAGGLE2] = false;
  33.     }
  34.     if ( haggle == 2 ) {
  35.         if ( Link->Item[HAGGLE2] ) Link->Item[HAGGLE2] = false;
  36.         if ( !Link->Item[HAGGLE1] ) Link->Item[HAGGLE1] = true;
  37.     }
  38.     if ( haggle == 3 ) {
  39.         if ( !Link->Item[HAGGLE2] ) Link->Item[HAGGLE2] = true;
  40.     }
  41. }
  42.  
  43. int HaggleMedals(){
  44.     if ( Link->Item[HAGGLE2] ) return 3;
  45.     if ( Link->Item[HAGGLE1] ) return 2;
  46.     return 1;
  47. }
  48.  
  49. //This is the haggle that you swindle before WaitHaggle()
  50. void DoHaggle(){
  51.     if ( HaggleMedals() != 2 && !CanHaggle() ) {
  52.         HaggleMedals(2);
  53.     }
  54.     if ( CanHaggle() && Haggle() ) HaggleMedals(Haggle());
  55.     TryHaggle();
  56. }
  57.  
  58. bool CanHaggle(){
  59.     return ( Screen->RoomType == RT_HAGGLE );
  60. }
  61.  
  62. void DrawHaggle() { Waitdraw(); }
  63. void WaitHaggle() { Waitframe(); }
  64.  
  65. void TryHaggle(){
  66.     bool try;
  67.     if ( HAGGLE_BUTTON_B && ( Link->PressB ) ) try = true;
  68.     if ( HAGGLE_BUTTON_A && Link->PressA ) try = true;
  69.     if ( HAGGLE_BUTTON_R && Link->PressR ) try = true;
  70.     if ( HAGGLE_BUTTON_L && Link->PressL ) try = true;
  71.     if ( HAGGLE_BUTTON_EX1 && Link->PressEx1 ) try = true;
  72.     if ( HAGGLE_BUTTON_EX2 && Link->PressEx2 ) try = true;
  73.     if ( HAGGLE_BUTTON_EX3 && Link->PressEx3 ) try = true;
  74.     if ( HAGGLE_BUTTON_EX4 && Link->PressEx4 ) try = true;
  75.     if ( try && !Haggle() && CanHaggle() ){
  76.         Haggle( Rand(3)+1 );
  77.         if ( Haggle() == 1 && SFX_HAGGLE_FAIL ) Game->PlaySound(SFX_HAGGLE_FAIL);
  78.         if ( Haggle() == 2 && SFX_HAGGLE_NORM ) Game->PlaySound(SFX_HAGGLE_NORM);
  79.         if ( Haggle() == 3 && SFX_HAGGLE_GOOD ) Game->PlaySound(SFX_HAGGLE_GOOD);
  80.         for ( int q = 0; q <= 90; q++ ) {
  81.             Link->InputUp = false; Link->PressUp = false;
  82.             Link->InputDown = false; Link->PressDown = false;
  83.             Link->InputLeft = false; Link->PressLeft = false;
  84.             Link->InputRight = false; Link->PressRight = false;
  85.             Link->InputR = false; Link->PressR = false;
  86.             Link->InputL = false; Link->PressL = false;
  87.             Link->InputA = false; Link->PressA = false;
  88.             Link->InputB = false; Link->PressB = false;
  89.             Link->InputEx1 = false; Link->PressEx1 = false;
  90.             Link->InputEx2 = false; Link->PressEx2 = false;
  91.             Link->InputEx3 = false; Link->PressEx3 = false;
  92.             Link->InputEx4 = false; Link->PressEx4 = false;
  93.             WaitHaggle();
  94.         }
  95.         HaggleMedals(Haggle());
  96.         //Prices won't swindle without warping. Ask Mister Owl.
  97.         Link->PitWarp( Game->GetCurDMap(), Game->GetCurScreen() );
  98.  
  99.     }
  100. }
  101.        
  102. global script SwindleHaggle{
  103.     void run(){
  104.         while(HAGGLE){
  105.             DoHaggle();
  106.             DrawHaggle();
  107.             WaitHaggle();
  108.         }
  109.     }
  110. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×