SHARE
TWEET

Moosh Bottles, Modified, Annotated

ZoriaRPG May 25th, 2017 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import "std.zh"
  2. import "ffcscript.zh"
  3.  
  4. //X---------------------------X
  5. //|  Screen Freeze Constants  |
  6. //X---------------------------X
  7.  
  8. const int FFC_SFA = 31; //FFC used for screen freeze A
  9. const int FFC_SFB = 32; //FFC used for screen freeze B
  10. const int CMB_SFA = 882; //Combo used for screen freeze A
  11. const int CMB_SFB = 883; //Combo used for screen freeze B
  12.  
  13.  
  14. //X--------------------------X
  15. //|  Empty Bottle Functions  |
  16. //X--------------------------X
  17.  
  18. const int BOTTLE_SETTING_NO_WATER = 0; //Set to 1 if water shouldn't be bottleable
  19.  
  20. //X--------------------------------------------------------X
  21. //|  These constants don't need to be changed.             |
  22. //|  They just define various states of the empty bottle.  |
  23. //|  BS_ constants are also used for  the potion filling   |
  24. //|  pickup item script. Look here to see what to set D2   |
  25. //|  to for that.                                          |
  26. //X--------------------------------------------------------X
  27. //                                                         |
  28. const int BS_EMPTY = 0; //                                 |
  29. const int BS_POTIONRED = 1; //                             |
  30. const int BS_POTIONGREEN = 2; //                           |
  31. const int BS_POTIONBLUE = 3; //                            |
  32. const int BS_WATER = 4; //                                 |
  33. const int BS_FAIRY = 5; //                                 |
  34. const int BS_BEE = 6; //                                   |
  35. //                                                         |
  36. const int BSI_BOTTLEUSED = 4; //                           |
  37. const int BSI_BOTTLETIMER = 5; //                          |
  38. const int BSI_OLDHP = 6; //                                |
  39. const int BSI_OLDMP = 7; //                                |
  40. const int BSI_FAIRYTIMER = 8; //                           |
  41. const int BSI_FAIRYREVIVE = 9; //                          |
  42. //                                                         |
  43. //---------------------------------------------------------
  44.  
  45. //! I believe we need to set these STATES to fill the bottles, as well, which is not in the instructions.
  46. // Moosh says:
  47. //D0 is the string to play and D1 is what type of potion it is (Red = 1, Green = 2, Blue = 3).
  48. // AND
  49. // 4 - water, 5 = faerie, 6 = bee. -Z
  50.  
  51. //D3 of the FFC must be set to 1 for __ANY__ refill item, not merely for potions.
  52.  
  53.  
  54.  
  55.  
  56.  
  57. const int REDPOTION_HEARTS = 8; //Hearts the red potion heals
  58. const int GREENPOTION_MP = 256; //MP the green potion restores
  59. const int BLUEPOTION_HEARTS = 16; //Hearts the blue potion heals
  60. const int BLUEPOTION_MP = 256; //MP the blue potion restores
  61.  
  62. const int LW_WATER = 31; //LWeapon type used for bottled water. Script 1 by default
  63. const int SPR_BOTTLEWATER = 88; //Sprite used for bottled water
  64. const int SFX_BOTTLEWATER = 55; //Sound when water is dumped out
  65.  
  66. const int FAIRY_HEARTS = 6; //Hearts healed by a fairy
  67. const int CMB_FAIRY = 889; //Fairy combo
  68. const int CS_FAIRY = 8; //Fairy cset
  69. const int SFX_FAIRY = 44; //Sound that plays when a fairy appears
  70.  
  71. const int IC_BOTTLE = 67; //Item class used for bottles. Custom 1 by default.
  72.  
  73.  
  74. const int TIL_BOTTLE = 15980; //First of the tiles used for the bottle items. Should come in four identical rows.
  75.                               //Tile order in each row should go as such:
  76.                               //Empty, Empty, Red Potion, Green Potion, Blue Potion, Water, Fairy, Bee
  77.  
  78. const int I_BOTTLE1 = 123; //Item ID for the first bottle (Level 1)
  79. const int I_BOTTLE2 = 124; //Item ID for the second bottle (Level 2)
  80. const int I_BOTTLE3 = 125; //Item ID for the second bottle (Level 3)
  81. const int I_BOTTLE4 = 126; //Item ID for the second bottle (Level 4)
  82. const int I_WATERBOTTLE = 130; //Item for bottle water pickup
  83. const int I_FAIRYBOTTLE = 131; //Item for bottle fairy pickup
  84. const int I_BEEBOTTLE = 132; //Item for bottle bee pickup
  85.  
  86. const int FREQ_HEARTREFILL = 8; //Frequency in frames at which potions/fairies restore hearts
  87. const int SFX_HEARTREFILL = 22; //Sound when potion/fairy restores a heart
  88. const int FREQ_MAGICSOUND = 8; //Frequency in frames where the magic refill sound plays
  89. const int SFX_MAGICREFILL = 49; //Magic refill sound
  90. const int SFX_ERROR = 36; //Error sound
  91.  
  92. const int TIL_BOTTLESWING = 16306; //Tile of a right facing open bottle used when trying to catch something
  93. const int CS_BOTTLESWING = 0; //CSet of the swinging bottle
  94. const int SFX_BOTTLESWING = 41; //Sound used for the bottle being swung
  95.  
  96. const int CMB_BEE = 888; //Combo used for the bee
  97. const int CS_BEE = 8; //CSet used for the bee
  98. const int SFX_BEE = 43; //SFX used for the bee
  99. const int LW_BEE = 32; //Lweapon used for the bee (Script 2 by default)
  100. const int EW_BEE = 32; //Eweapon used for the bee (Script 2 by default)
  101. const int DAMAGE_BEE = 4; //Damage the bee deals
  102. const int FFCM_BEE_SELFDESTRUCT = 0; //FFC misc used to tell the bee to disappear
  103.  
  104. const int STR_CANTAFFORD = 1; //Message for when you can't afford an item
  105. const int STR_NOBOTTLE = 2; //Message for when you don't have a bottle to store a potion in
  106.  
  107. const int C_WHITE = 0x01; //The color white
  108. const int C_BLACK = 0x0F; //The color black
  109.  
  110. //I suggest making the distance to the ffc a setting, and displaying some kind of icon when Link is close enough to buy any item. -Z
  111. //I further suggest making the ffc draw the price to a LAYER set by a CONSTANT. The price, drawn over Link, and the item, drawn UNDER
  112. //Link, is a bit, off.
  113.  
  114. const int FFC_BOTTLE_SHOP_PRICE_LAYER = 1; //Layer for drawing the price to the screen. -Z
  115. const int FFC_SHOP_DISTANCE = 14; //Distance from FFC. -Z
  116.  
  117. int BottleState[12]; //0-3: States of bottles, 4: Bottle used,
  118.                      //5: Potion timer, 6: OldHP, 7: OldMP
  119.  
  120.  
  121. //This function should be called at the beginning of your global and
  122. //refreshes the graphics for the bottles.
  123. void RefreshBottles(){
  124.     for(int i=0; i<4; i++){
  125.         CopyTile(TIL_BOTTLE+20*i+1+BottleState[i], TIL_BOTTLE+20*i);
  126.     }
  127. }
  128.  
  129.  
  130. int UsingEmptyBottle(){
  131.     if(Link->PressA){
  132.         int id = GetEquipmentA();
  133.         if(id>0){
  134.             itemdata A = Game->LoadItemData(id);
  135.             if(A->Family==IC_BOTTLE)
  136.                 return A->Level-1;
  137.         }
  138.     }
  139.     else if(Link->PressB){
  140.         int id = GetEquipmentB();
  141.         if(id>0){
  142.             itemdata B = Game->LoadItemData(id);
  143.             if(B->Family==IC_BOTTLE)
  144.                 return B->Level-1;
  145.         }
  146.     }
  147.     return -1;
  148. }
  149.  
  150.  
  151. bool CanFillBottle(){
  152.     int bottles[4] = {I_BOTTLE1, I_BOTTLE2, I_BOTTLE3, I_BOTTLE4};
  153.     for(int i=0; i<4; i++){
  154.         if(Link->Item[bottles[i]]&&BottleState[i]==BS_EMPTY)
  155.             return true;
  156.     }
  157.     return false;
  158. }
  159.  
  160. int FillBottle(int state){
  161.     int bottles[4] = {I_BOTTLE1, I_BOTTLE2, I_BOTTLE3, I_BOTTLE4};
  162.     for(int i=0; i<4; i++){
  163.         if(Link->Item[bottles[i]]&&BottleState[i]==BS_EMPTY){
  164.             BottleState[i] = state;
  165.             RefreshBottles();
  166.             return i;
  167.         }
  168.     }
  169. }
  170.  
  171. int HasFairy(){
  172.     int bottles[4] = {I_BOTTLE1, I_BOTTLE2, I_BOTTLE3, I_BOTTLE4};
  173.     for(int i=0; i<4; i++){
  174.         if(Link->Item[bottles[i]]&&BottleState[i]==BS_FAIRY)
  175.             return i;
  176.     }
  177.     return -1;
  178. }
  179.  
  180. //This function goes in the while loop of your global script before waitdraw
  181. void EmptyBottleGlobal(){
  182.     int bottle = BottleState[BSI_BOTTLEUSED];
  183.     if(BottleState[BSI_BOTTLETIMER]>0){
  184.         if(BottleState[bottle]==BS_POTIONRED){
  185.             if(BottleState[BSI_BOTTLETIMER]%FREQ_HEARTREFILL==0){
  186.                 Link->HP += 16;
  187.                 Game->PlaySound(SFX_HEARTREFILL);
  188.                 if(Link->HP>=Link->MaxHP){
  189.                     BottleState[BSI_BOTTLETIMER] = 0;
  190.                 }
  191.             }
  192.         }
  193.         else if(BottleState[bottle]==BS_POTIONGREEN){
  194.             Link->MP += 2;
  195.             if(BottleState[BSI_BOTTLETIMER]%FREQ_MAGICSOUND==0)
  196.                 Game->PlaySound(SFX_MAGICREFILL);
  197.             if(Link->MP>=Link->MaxMP){
  198.                 BottleState[BSI_BOTTLETIMER] = 0;
  199.             }
  200.         }
  201.         else if(BottleState[bottle]==BS_POTIONBLUE){
  202.             if(BottleState[BSI_BOTTLETIMER]%FREQ_HEARTREFILL==0&&Link->HP<BottleState[BSI_OLDHP]+BLUEPOTION_HEARTS*16&&Link->HP<Link->MaxHP){
  203.                 Link->HP += 16;
  204.                 Game->PlaySound(SFX_HEARTREFILL);
  205.             }
  206.             if(Link->MP<BottleState[BSI_OLDMP]+BLUEPOTION_MP&&Link->MP<Link->MaxMP){
  207.                 if(BottleState[BSI_BOTTLETIMER]%FREQ_MAGICSOUND==0)
  208.                     Game->PlaySound(SFX_MAGICREFILL);
  209.                 Link->MP += 2;
  210.             }
  211.             if(Link->HP>=Link->MaxHP&&Link->MP>=Link->MaxMP){
  212.                 BottleState[BSI_BOTTLETIMER] = 0;
  213.             }
  214.         }
  215.         else if(BottleState[bottle]==BS_FAIRY){
  216.             if(BottleState[BSI_BOTTLETIMER]<2&&BottleState[BSI_FAIRYTIMER]<120)
  217.                 BottleState[BSI_BOTTLETIMER] = 2;
  218.             BottleState[BSI_FAIRYTIMER]++;
  219.             int X = Link->X+VectorX(16*(BottleState[BSI_FAIRYTIMER]/120), BottleState[BSI_FAIRYTIMER]*8);
  220.             int Y = Link->Y+VectorY(8*(BottleState[BSI_FAIRYTIMER]/120), BottleState[BSI_FAIRYTIMER]*8)-BottleState[BSI_FAIRYTIMER]/8;
  221.             if(BottleState[BSI_FAIRYREVIVE]==1){
  222.                 if(BottleState[BSI_FAIRYTIMER]<10||BottleState[BSI_FAIRYTIMER]>110)
  223.                     Screen->Rectangle(6, 0, 0, 256, 176, C_BLACK, 1, 0, 0, 0, true, 64);
  224.                 else
  225.                     Screen->Rectangle(6, 0, 0, 256, 176, C_BLACK, 1, 0, 0, 0, true, 128);
  226.                 Screen->FastTile(6, Link->X+Link->DrawXOffset, Link->Y+Link->DrawYOffset, Link->Tile, 6, 128);
  227.             }
  228.             if(BottleState[BSI_FAIRYTIMER]<80||BottleState[BSI_FAIRYTIMER]%2==0)
  229.                 Screen->FastCombo(6, X, Y, CMB_FAIRY, CS_FAIRY, 128);
  230.             if(BottleState[BSI_BOTTLETIMER]%FREQ_HEARTREFILL==0&&Link->HP<Link->MaxHP){
  231.                 Link->HP += 16;
  232.                 Game->PlaySound(SFX_HEARTREFILL);
  233.             }
  234.         }
  235.         BottleState[BSI_BOTTLETIMER]--;
  236.         NoAction();
  237.         if(BottleState[BSI_BOTTLETIMER]<=0){
  238.             BottleState[bottle] = BS_EMPTY;
  239.             BottleState[BSI_BOTTLEUSED] = -1;
  240.             RefreshBottles();
  241.             Screen_Unfreeze();
  242.         }
  243.     }
  244.     else{
  245.         bottle = UsingEmptyBottle();
  246.         if(bottle>-1){
  247.             if(BottleState[bottle]==BS_EMPTY){
  248.                 int scriptname[] = "Bottle_Empty";
  249.                 int scriptid = Game->GetFFCScript(scriptname);
  250.                 int Args[8] = {bottle};
  251.                 RunFFCScript(scriptid, Args);
  252.             }
  253.             else if(BottleState[bottle]==BS_POTIONRED){
  254.                 if(Link->HP==Link->MaxHP){
  255.                     Game->PlaySound(SFX_ERROR);
  256.                 }
  257.                 else{
  258.                     BottleState[BSI_BOTTLEUSED] = bottle;
  259.                     BottleState[BSI_BOTTLETIMER] = FREQ_HEARTREFILL*REDPOTION_HEARTS;
  260.                     Screen_Freeze();
  261.                 }
  262.             }
  263.             else if(BottleState[bottle]==BS_POTIONGREEN){
  264.                 if(Link->MP==Link->MaxMP){
  265.                     Game->PlaySound(SFX_ERROR);
  266.                 }
  267.                 else{
  268.                     BottleState[BSI_BOTTLEUSED] = bottle;
  269.                     BottleState[BSI_BOTTLETIMER] = GREENPOTION_MP/2;
  270.                     Screen_Freeze();
  271.                 }
  272.             }
  273.             else if(BottleState[bottle]==BS_POTIONBLUE){
  274.                 if(Link->HP==Link->MaxHP&&Link->MP==Link->MaxMP){
  275.                     Game->PlaySound(SFX_ERROR);
  276.                 }
  277.                 else{
  278.                     BottleState[BSI_BOTTLEUSED] = bottle;
  279.                     BottleState[BSI_BOTTLETIMER] = FREQ_HEARTREFILL*99;
  280.                     BottleState[BSI_OLDHP] = Link->HP;
  281.                     BottleState[BSI_OLDMP] = Link->MP;
  282.                     Screen_Freeze();
  283.                 }
  284.             }
  285.             else if(BottleState[bottle]==BS_WATER){
  286.                 Link->Action = LA_ATTACKING;
  287.                 lweapon l = CreateLWeaponAt(LW_WATER, Link->X+InFrontX(Link->Dir, 0), Link->Y+InFrontY(Link->Dir, 0));
  288.                 l->UseSprite(SPR_BOTTLEWATER);
  289.                 l->DeadState = l->ASpeed*l->NumFrames;
  290.                 l->CollDetection = false;
  291.                 Game->PlaySound(SFX_BOTTLEWATER);
  292.                 BottleState[bottle] = BS_EMPTY;
  293.                 RefreshBottles();
  294.             }
  295.             else if(BottleState[bottle]==BS_FAIRY){
  296.                 if(Link->HP==Link->MaxHP){
  297.                     Game->PlaySound(SFX_ERROR);
  298.                 }
  299.                 else{
  300.                     BottleState[BSI_BOTTLEUSED] = bottle;
  301.                     BottleState[BSI_BOTTLETIMER] = FREQ_HEARTREFILL*FAIRY_HEARTS;
  302.                     BottleState[BSI_FAIRYTIMER] = 0;
  303.                     BottleState[BSI_FAIRYREVIVE] = 0;
  304.                     Game->PlaySound(SFX_FAIRY);
  305.                     Screen_Freeze();
  306.                 }
  307.             }
  308.             else if(BottleState[bottle]==BS_BEE){
  309.                 int scriptname[] = "Bottle_Bee";
  310.                 int scriptid = Game->GetFFCScript(scriptname);
  311.                 int vars[8] = {1};
  312.                 RunFFCScript(scriptid, vars);
  313.                 BottleState[bottle] = BS_EMPTY;
  314.                 RefreshBottles();
  315.             }
  316.         }
  317.         int fairy = HasFairy();
  318.         if(Link->HP<=0&&fairy>-1){
  319.             Link->HP = 1;
  320.             BottleState[BSI_BOTTLEUSED] = fairy;
  321.             BottleState[BSI_BOTTLETIMER] = FREQ_HEARTREFILL*FAIRY_HEARTS;
  322.             BottleState[BSI_FAIRYTIMER] = 0;
  323.             BottleState[BSI_FAIRYREVIVE] = 1;
  324.             Game->PlaySound(SFX_FAIRY);
  325.             Screen_Freeze();
  326.         }
  327.     }
  328. }
  329.  
  330.  
  331. ///! NOTE to viewers, I am not adding sounds to this default uest, but you should surely do that.
  332.  
  333. //X-------------------------------X
  334. //|  Empty Bottle Action Scripts  |
  335. //X-------------------------------X
  336.  
  337.  
  338.  
  339. //I'm pretty sure that the script will change the bottle tile based on the ffc arg, so why do we waste three items here,
  340. //for reg, green, and blue potions? -Z
  341.  
  342. ffc script Bottle_Empty{
  343.     void run(int bottleid){
  344.         int Angle = 0;
  345.         if(Link->Dir==DIR_UP)
  346.             Angle = -90;
  347.         else if(Link->Dir==DIR_DOWN)
  348.             Angle = 90;
  349.         else if(Link->Dir==DIR_LEFT)
  350.             Angle = 180;
  351.         Game->PlaySound(SFX_BOTTLESWING);
  352.         Link->Action = LA_ATTACKING;
  353.         int Collected = 0;
  354.         for(int i=-45; i<45; i+=10){
  355.             int X = Link->X+VectorX(12, Angle+i);
  356.             int Y = Link->Y+VectorY(12, Angle+i);
  357.             Screen->DrawTile(2, X, Y, TIL_BOTTLESWING, 1, 1, CS_BOTTLESWING, -1, -1, X, Y, Angle+i+90, 0, true, 128);
  358.             if(Collected==0||Collected==BS_WATER){
  359.                 if(OnWater(X+8, Y+8)&&Collected==0&&BOTTLE_SETTING_NO_WATER==0){
  360.                     Collected = BS_WATER;
  361.                 }
  362.                 for(int j=1; j<=Screen->NumItems(); j++){
  363.                     item itm = Screen->LoadItem(j);
  364.                     if(itm->ID==I_FAIRY||itm->ID==I_FAIRYSTILL){
  365.                         if(RectCollision(itm->X+itm->HitXOffset, itm->Y+itm->HitYOffset, itm->X+itm->HitXOffset+itm->HitWidth, itm->Y+itm->HitYOffset+itm->HitHeight, X+4, Y+4, X+11, Y+11)){
  366.                             Collected = BS_FAIRY;
  367.                             Remove(itm);
  368.                             break;
  369.                         }
  370.                     }
  371.                 }
  372.                 for(int j=1; j<=32; j++){
  373.                     ffc f = Screen->LoadFFC(j);
  374.                     int scriptname[] = "Bottle_Bee";
  375.                     int scriptid = Game->GetFFCScript(scriptname);
  376.                     if(f->Script==scriptid){
  377.                         if(RectCollision(X+4, Y+4, X+11, Y+11, f->X+4, f->Y+4, f->X+11, f->Y+11)){
  378.                             Collected = BS_BEE;
  379.                             f->Misc[FFCM_BEE_SELFDESTRUCT] = 1;
  380.                         }
  381.                     }
  382.                 }
  383.             }
  384.             WaitNoAction();
  385.         }
  386.         if(Collected==BS_WATER){
  387.             BottleState[bottleid] = BS_WATER;
  388.             RefreshBottles();
  389.             item itm = CreateItemAt(I_WATERBOTTLE, Link->X, Link->Y);
  390.             itm->Pickup = IP_HOLDUP;
  391.         }
  392.         else if(Collected==BS_FAIRY){
  393.             BottleState[bottleid] = BS_FAIRY;
  394.             RefreshBottles();
  395.             item itm = CreateItemAt(I_FAIRYBOTTLE, Link->X, Link->Y);
  396.             itm->Pickup = IP_HOLDUP;
  397.         }
  398.         else if(Collected==BS_BEE){
  399.             BottleState[bottleid] = BS_BEE;
  400.             RefreshBottles();
  401.             item itm = CreateItemAt(I_BEEBOTTLE, Link->X, Link->Y);
  402.             itm->Pickup = IP_HOLDUP;
  403.         }
  404.         WaitNoAction(10);
  405.     }
  406.     bool OnWater(int x, int y){
  407.         int ct = Screen->ComboT[ComboAt(x, y)];
  408.         if(ct==CT_WATER||ct==CT_SHALLOWWATER)
  409.             return true;
  410.         return false;
  411.     }
  412. }
  413.  
  414.  
  415.  
  416.  
  417. //! Moosh, these constants would be better ALL at the TOP of the script file. -Z
  418.  
  419. ffc script Bottle_Bee{
  420.     void run(int friendly){
  421.         this->Data = CMB_BEE;
  422.         this->CSet = CS_BEE;
  423.         if(friendly==1){
  424.             this->X = Link->X;
  425.             this->Y = Link->Y;
  426.         }
  427.         int i; int j; int k;
  428.         int X = this->X;
  429.         int Y = this->Y;
  430.         lweapon lh;
  431.         eweapon eh;
  432.         int Lifespan = Rand(900, 1200);
  433.         for(i=0; i<40; i++){
  434.             Y -= 0.5;
  435.             this->X = X;
  436.             this->Y = Y;
  437.             Waitframe();
  438.         }
  439.         while(Lifespan>0){
  440.             int Angle;
  441.             if(friendly==1){
  442.                 int Tx = -1000;
  443.                 int Ty = -1000;
  444.                 int Dist = 1000;
  445.                 for(i=1; i<=Screen->NumNPCs(); i++){
  446.                     npc n = Screen->LoadNPC(i);
  447.                     if(Distance(X+8, Y+8, CenterX(n), CenterY(n))<Dist){
  448.                         Dist = Distance(X+8, Y+8, CenterX(n), CenterY(n));
  449.                         Tx = CenterX(n)-8;
  450.                         Ty = CenterY(n)-8;
  451.                     }
  452.                 }
  453.                 Angle = Angle(X, Y, Tx, Ty);
  454.                 if(Screen->NumNPCs()==0)
  455.                     Angle = Angle(X, Y, Link->X, Link->Y);
  456.             }
  457.             else{
  458.                 if(Distance(Link->X, Link->Y, X, Y)<80&&Rand(2)==0)
  459.                     Angle = Angle(X, Y, Link->X, Link->Y);
  460.                 else
  461.                     Angle = Rand(360);
  462.             }
  463.             k = Rand(32, 48);
  464.             for(i=0; i<k; i++){
  465.                 Lifespan--;
  466.                 j = (j+1)%360;
  467.                 if(j%30==0)
  468.                     Game->PlaySound(SFX_BEE);
  469.                 X = Clamp(X+VectorX(2, Angle), -16, 256);
  470.                 Y = Clamp(Y+VectorY(2, Angle), -16, 176);
  471.                 this->X = X;
  472.                 this->Y = Y;
  473.                 if(friendly==1){
  474.                     if(lh->isValid()){
  475.                         lh->X = X;
  476.                         lh->Y = Y;
  477.                     }
  478.                     else{
  479.                         lh = CreateLWeaponAt(LW_BEE, X, Y);
  480.                         lh->HitXOffset = 4;
  481.                         lh->HitYOffset = 4;
  482.                         lh->HitWidth = 8;
  483.                         lh->HitHeight = 8;
  484.                         lh->DrawYOffset = -1000;
  485.                         lh->Dir = 8;
  486.                         lh->Damage = DAMAGE_BEE;
  487.                     }
  488.                 }
  489.                 else{
  490.                     if(eh->isValid()){
  491.                         eh->X = X;
  492.                         eh->Y = Y;
  493.                     }
  494.                     else{
  495.                         eh = CreateEWeaponAt(EW_BEE, X, Y);
  496.                         eh->HitXOffset = 4;
  497.                         eh->HitYOffset = 4;
  498.                         eh->HitWidth = 8;
  499.                         eh->HitHeight = 8;
  500.                         eh->DrawYOffset = -1000;
  501.                         eh->Dir = 8;
  502.                         eh->Damage = DAMAGE_BEE;
  503.                     }
  504.                 }
  505.                 if(this->Misc[FFCM_BEE_SELFDESTRUCT]==1){
  506.                     if(lh->isValid())
  507.                         lh->DeadState = 0;
  508.                     if(eh->isValid())
  509.                         eh->DeadState = 0;
  510.                     this->Data = 0;
  511.                     this->CSet = 0;
  512.                     Quit();
  513.                 }
  514.                 Waitframe();
  515.             }
  516.         }
  517.         if(lh->isValid())
  518.             lh->DeadState = 0;
  519.         if(eh->isValid())
  520.             eh->DeadState = 0;
  521.         this->Data = 0;
  522.         this->CSet = 0;
  523.         for(i=0; i<40; i++){
  524.             if(i%2==0)
  525.                 Screen->FastCombo(2, X, Y, CMB_BEE, CS_BEE, 128);
  526.             Waitframe();
  527.         }
  528.     }
  529. }
  530.  
  531.  
  532. //X----------------------------X
  533. //|  Other Associated Scripts  |
  534. //X----------------------------X
  535.  
  536. item script PotionFill{
  537.     void run(int str, int state){
  538.         FillBottle(state);
  539.         Screen->Message(str);
  540.     }
  541. }
  542.  
  543. //! Now, let's see if Moosh automatically set the ffc Data using any tricks.
  544. //! I am betting AGAINST this, and that you will also need to set up six combos for the items, which
  545. //! is not explained in the set-up.
  546.  
  547. //! Of course. This is why I would draw the item use din the arg to the screen. -Z
  548.  
  549. // What I do instead of forcing anyone to set up one combo per item in a shoppe, is to CREATE the item on the screen
  550. // at the coordinates of the ffc, and either set its IP_PICKUP or move its Y hit component off-screen.
  551.  
  552. // Setting up an ffc per item with a combo per item is tedious; and wasteful.
  553.  
  554. // We also need to set up a subscreen for this.
  555.  
  556. //! The shop is not selling me bees, faeries or water. Hmm.
  557.  
  558. bool ___BelowFFC(ffc n){ return Link->Y > n->Y; }
  559.  
  560. bool _______DistXY(ffc b, int distance) {
  561.     int distx; int disty;
  562.     distx = Abs(Link->X - b->X);
  563.     disty = Abs(Link->Y - b->Y);
  564.     return ( distx <= distance && disty <= distance );
  565. }
  566.  
  567.  
  568.  
  569. ffc script ItemShop{
  570.     void run(int id, int strdescription, int price, int potion){ //D3 must be the item ID for the three potion items.
  571.         itemdata ic = Game->LoadItemData(id);
  572.         while(true){
  573.             if ( _______DistXY(this, FFC_SHOP_DISTANCE) && ___BelowFFC(this) && Link->Dir == DIR_UP ) {
  574.                 if(Link->PressL){
  575.                     Screen->Message(strdescription);
  576.                     NoAction();
  577.                 }
  578.                 else if(Link->PressR){
  579.                     if(Game->Counter[CR_RUPEES]+Game->DCounter[CR_RUPEES]>=price){
  580.                         if(potion>0&&!CanFillBottle()){
  581.                             Screen->Message(STR_NOBOTTLE);
  582.                             NoAction();
  583.                         }
  584.                         else{
  585.                             item itm = CreateItemAt(id, Link->X, Link->Y);
  586.                             itm->Pickup = IP_HOLDUP;
  587.                             Game->DCounter[CR_RUPEES] -= price;
  588.                             for(int i=0; i<10; i++){
  589.                                 WaitNoAction();
  590.                             }
  591.                         }
  592.                     }
  593.                     else{
  594.                         Screen->Message(STR_CANTAFFORD);
  595.                         NoAction();
  596.                     }
  597.                 }
  598.             }
  599.             DrawPrice(this, price);
  600.             Waitframe();
  601.         }
  602.     }
  603.     void DrawPrice(ffc this, int price){
  604.         int xoff = -2;
  605.         if(price>999)
  606.             xoff = -8;
  607.         else if(price>99)
  608.             xoff = -6;
  609.         else if(price>9)
  610.             xoff = -4;
  611.         Screen->DrawInteger(FFC_BOTTLE_SHOP_PRICE_LAYER, this->X+8+xoff+1, this->Y+18+1, FONT_Z3SMALL, C_BLACK, -1, -1, -1, price, 0, 128);
  612.         Screen->DrawInteger(FFC_BOTTLE_SHOP_PRICE_LAYER, this->X+8+xoff, this->Y+18, FONT_Z3SMALL, C_WHITE, -1, -1, -1, price, 0, 128);
  613.     }
  614. }
  615.  
  616. ffc script BeeGrass{
  617.     void run(int chances){
  618.         int Combo = Screen->ComboD[ComboAt(this->X+8, this->Y+8)];
  619.         while(Screen->ComboD[ComboAt(this->X+8, this->Y+8)]==Combo){
  620.             Waitframe();
  621.         }
  622.         if(Rand(chances)==0){
  623.             int scriptname[] = "Bottle_Bee";
  624.             int scriptid = Game->GetFFCScript(scriptname);
  625.             int i = RunFFCScript(scriptid, 0);
  626.             ffc f = Screen->LoadFFC(i);
  627.             f->X = this->X;
  628.             f->Y = this->Y;
  629.         }
  630.     }
  631. }
  632.  
  633. //Bug: The script does not stop allowing a player to trigger the secrets by repeatedly pouring water over the trigger spot.  -Z
  634. //This only occurs if the player tries to trigger it multiple times without leaving the screen. -Z
  635. ffc script WaterTrigger{
  636.     void run(){
  637.         if(!Screen->State[ST_SECRET]){
  638.             while(true){
  639.                 for(int i=1; i<=Screen->NumLWeapons(); i++){
  640.                     lweapon l = Screen->LoadLWeapon(i);
  641.                     if(l->ID==LW_WATER&&Collision(this, l)){
  642.                         Screen->TriggerSecrets();
  643.                         Game->PlaySound(SFX_SECRET);
  644.                         Screen->State[ST_SECRET] = true;
  645.                         Quit();
  646.                     }
  647.                 }
  648.                 Waitframe();
  649.             }
  650.         }
  651.     }
  652. }
  653.  
  654. //X-------------------------X
  655. //|  Example Global Script  |
  656. //X-------------------------X
  657.  
  658.  
  659. global script Main2{
  660.     void run(){
  661.         RefreshBottles();
  662.         while(true){
  663.             EmptyBottleGlobal();
  664.             Waitdraw();
  665.             Waitframe();
  666.         }
  667.     }
  668. }
  669.  
  670. void Screen_Freeze(){
  671.     ffc f1 = Screen->LoadFFC(FFC_SFA);
  672.     ffc f2 = Screen->LoadFFC(FFC_SFB);
  673.     f1->Data = CMB_SFA;
  674.     f2->Data = CMB_SFB;
  675. }
  676.  
  677. void Screen_Unfreeze(){
  678.     ffc f1 = Screen->LoadFFC(FFC_SFA);
  679.     ffc f2 = Screen->LoadFFC(FFC_SFB);
  680.     f1->Data = 0;
  681.     f2->Data = 0;
  682. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top