User Tag List

Results 1 to 10 of 10

Thread: MSU's Individual Item Shop Script

  1. #1
    クールな男
    SE Developer
    MasterSwordUltima's Avatar
    Join Date
    Jul 2001
    Location
    Keystonia
    Age
    29
    Posts
    5,560
    Mentioned
    16 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    8,290
    Level
    27
    vBActivity - Bars
    Lv. Percent
    53.52%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    2.83%

    MSU's Individual Item Shop Script

    So I'm sure this has been done before in various ways - this is just my method. There is definitely room for improvement, but I don't see anything listed here on AGN specifically, so here goes.

    [UPDATE]: Added option for buying ammo types, which you can keep buying without leaving the screen.

    Code:
     ffc script MSUShop {
      void run(int M_BUY, int I_ITEM, int I_COST, int M_BROKE, int M_SOLDOUT, int I_TYPE) {
    // D0 - M_BUY = the message when you make the buy
    // D1 - I_ITEM = the item number
    // D2 - I_COST = the amount of rupees item costs
    // D3 - M_BROKE = the message that plays if you haven't enough cash!    
    // D4 - M_SOLDOUT = the message that plays if you already have that item
    // D5 - I_TYPE = 0 for reg item, 1 for keys, 2 for arrows, 3 for bombs
    
    	while(true) {
          while(Link->X < this->X - 8 || Link->X > this->X + 24 || Link->Y < this->Y || Link->Y > this->Y + 24 || 
    
    Link->Dir != DIR_UP || !Link->InputA) {
            Waitframe();
          }      
    
    	Link->InputA = false;
    	
    
    	if(Link->Item[I_ITEM] && I_TYPE == 0)
    		{
    		Screen->Rectangle(1, 26, 9, 232, 22, 0, 1, 0, 0, 0, 1, OP_OPAQUE);
    		Screen->Message(M_SOLDOUT);
    		}
    		else if(Game->Counter[CR_RUPEES]<I_COST && !Link->Item[I_ITEM] == 1)	
    		{
    		Screen->Rectangle(1, 26, 9, 232, 22, 0, 1, 0, 0, 0, 1, OP_OPAQUE);
    		Screen->Message(M_BROKE);		
    		}
    	else if(Game->Counter[CR_RUPEES]>=I_COST && (!Link->Item[I_ITEM] || I_TYPE != 0))
    		{
    		Screen->Rectangle(1, 26, 9, 232, 22, 0, 1, 0, 0, 0, 1, OP_OPAQUE);
    		Screen->Message(M_BUY);
    			if(I_TYPE != 0){
    				if(I_TYPE == 1){Game->Counter[CR_KEYS]++;}
    				if(I_TYPE == 2){Game->Counter[CR_ARROWS]++;}
    				if(I_TYPE == 3){Game->Counter[CR_BOMBS]++;}
    				   }
    			else if(I_TYPE == 0){	
    					Link->Item[I_ITEM] = true;
    					this->Data = 0;
    					}
    		Game->PlaySound(20);
    		Game->Counter[CR_RUPEES] = Game->Counter[CR_RUPEES] - I_COST;		
    		}      	
    
    
    
          while(Link->X >= this->X - 8 && Link->X <= this->X + 24 && Link->Y >= this->Y && Link->Y <= this->Y + 24 && 
    
    Link->Dir == DIR_UP) {
            Waitframe();
          }
          
          Screen->Message(0);	
          Link->InputA = true;
    	}
    	     
        
      }
    }
    As explained in the code itself;

    D0 = the string that will show when you successfully buy the item
    D1 = the item number itself
    D2 = the cost of the item (in rupees)
    D3 = the string that will show if you don't have enough rupees
    D4 = the string that will show if you already have the item
    D5 = determines if the item is an ammo type. 0 = regular item. 1 = keys. 2 = arrows. 3 = bombs. 4 = superbombs.

    I've also used font SS3, with a Y axis of 4 for this to line up properly. I should probably add a sound in there, but haven't brushed up on the particulars of those variables. All feedback is welcome.
    Last edited by MasterSwordUltima; 02-02-2014 at 12:45 PM.

    -----

  2. #2
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    31
    Posts
    4,430
    Mentioned
    149 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,308
    Level
    30
    vBActivity - Bars
    Lv. Percent
    20.84%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    2.83%
    Looks good. There are a couple things I don't like. I wish your variables were more desciptive. r, m, i, etc. are not very readable. Also, "Link->Item[i] == 1".

  3. #3
    クールな男
    SE Developer
    MasterSwordUltima's Avatar
    Join Date
    Jul 2001
    Location
    Keystonia
    Age
    29
    Posts
    5,560
    Mentioned
    16 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    8,290
    Level
    27
    vBActivity - Bars
    Lv. Percent
    53.52%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    2.83%
    Would "!Link->Item[i] != 1" be a better logic flow?

    [edit] OH, now I see what you meant. Is there any real difference between using 0/1 as opposed to false/true? They both accomplish the same thing, correct?[/edit]
    Last edited by MasterSwordUltima; 02-02-2014 at 11:21 AM.

    -----

  4. #4
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    34
    Posts
    3,329
    Mentioned
    152 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    5,965
    Level
    23
    vBActivity - Bars
    Lv. Percent
    91.56%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    2.83%
    Link->Item[x] is already a bool, so there's no need to compare it against anything.

    if(Link->Item[I_ITEM] && I_TYPE == 0)

    Functionally, there's no difference between comparing a bool against true/false or 1/0; it's just more logical to compare two data of the same type.
    [téknolŕiz]

    ffcscript.zh 1.1.1 - Updated 2014-08-19
    ghost.zh 2.8.1 - Updated 2016-09-16
    tango.zh 1.2.0 - Updated 2016-09-16

  5. #5
    クールな男
    SE Developer
    MasterSwordUltima's Avatar
    Join Date
    Jul 2001
    Location
    Keystonia
    Age
    29
    Posts
    5,560
    Mentioned
    16 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    8,290
    Level
    27
    vBActivity - Bars
    Lv. Percent
    53.52%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    2.83%
    *nod* Redundancy department of redundancy.

    -----

  6. #6
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    31
    Posts
    4,430
    Mentioned
    149 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,308
    Level
    30
    vBActivity - Bars
    Lv. Percent
    20.84%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    2.83%
    Quote Originally Posted by Saffith View Post
    Link->Item[x] is already a bool, so there's no need to compare it against anything.

    if(Link->Item[I_ITEM] && I_TYPE == 0)

    Functionally, there's no difference between comparing a bool against true/false or 1/0; it's just more logical to compare two data of the same type.
    Yes, this is what I was talking about. The redundancy only bothers me a little, but compairing a bool to 0 or 1 could be confusing to people and if you are sharing a script the less confusing and easier it is to read the better. I do prefer letting a bool stand on it's own. I mean, you did it with Link->Input but not Link->Item? Be consistant.

  7. #7
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    31
    Posts
    4,430
    Mentioned
    149 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,308
    Level
    30
    vBActivity - Bars
    Lv. Percent
    20.84%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    2.83%
    @MasterSwordUltima , I noticed when you purchase the items you are setting the item to true or increasing the counter. You could alternatively create the item right on top of Link that way(if the item is set up for it) Link will hold it above his head and the "Got something" SFX will play. Also if the item has a pickup script it will run.

  8. #8
    Gel
    Join Date
    Dec 2015
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    169
    Level
    4
    vBActivity - Bars
    Lv. Percent
    80.66%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    2.83%
    Quote Originally Posted by MasterSwordUltima View Post
    So I'm sure this has been done before in various ways - this is just my method. There is definitely room for improvement, but I don't see anything listed here on AGN specifically, so here goes.

    [UPDATE]: Added option for buying ammo types, which you can keep buying without leaving the screen.

    Code:
     ffc script MSUShop {
      void run(int M_BUY, int I_ITEM, int I_COST, int M_BROKE, int M_SOLDOUT, int I_TYPE) {
    // D0 - M_BUY = the message when you make the buy
    // D1 - I_ITEM = the item number
    // D2 - I_COST = the amount of rupees item costs
    // D3 - M_BROKE = the message that plays if you haven't enough cash!    
    // D4 - M_SOLDOUT = the message that plays if you already have that item
    // D5 - I_TYPE = 0 for reg item, 1 for keys, 2 for arrows, 3 for bombs
    
    	while(true) {
          while(Link->X < this->X - 8 || Link->X > this->X + 24 || Link->Y < this->Y || Link->Y > this->Y + 24 || 
    
    Link->Dir != DIR_UP || !Link->InputA) {
            Waitframe();
          }      
    
    	Link->InputA = false;
    	
    
    	if(Link->Item[I_ITEM] && I_TYPE == 0)
    		{
    		Screen->Rectangle(1, 26, 9, 232, 22, 0, 1, 0, 0, 0, 1, OP_OPAQUE);
    		Screen->Message(M_SOLDOUT);
    		}
    		else if(Game->Counter[CR_RUPEES]<I_COST && !Link->Item[I_ITEM] == 1)	
    		{
    		Screen->Rectangle(1, 26, 9, 232, 22, 0, 1, 0, 0, 0, 1, OP_OPAQUE);
    		Screen->Message(M_BROKE);		
    		}
    	else if(Game->Counter[CR_RUPEES]>=I_COST && (!Link->Item[I_ITEM] || I_TYPE != 0))
    		{
    		Screen->Rectangle(1, 26, 9, 232, 22, 0, 1, 0, 0, 0, 1, OP_OPAQUE);
    		Screen->Message(M_BUY);
    			if(I_TYPE != 0){
    				if(I_TYPE == 1){Game->Counter[CR_KEYS]++;}
    				if(I_TYPE == 2){Game->Counter[CR_ARROWS]++;}
    				if(I_TYPE == 3){Game->Counter[CR_BOMBS]++;}
    				   }
    			else if(I_TYPE == 0){	
    					Link->Item[I_ITEM] = true;
    					this->Data = 0;
    					}
    		Game->PlaySound(20);
    		Game->Counter[CR_RUPEES] = Game->Counter[CR_RUPEES] - I_COST;		
    		}      	
    
    
    
          while(Link->X >= this->X - 8 && Link->X <= this->X + 24 && Link->Y >= this->Y && Link->Y <= this->Y + 24 && 
    
    Link->Dir == DIR_UP) {
            Waitframe();
          }
          
          Screen->Message(0);	
          Link->InputA = true;
    	}
    	     
        
      }
    }
    As explained in the code itself;

    D0 = the string that will show when you successfully buy the item
    D1 = the item number itself
    D2 = the cost of the item (in rupees)
    D3 = the string that will show if you don't have enough rupees
    D4 = the string that will show if you already have the item
    D5 = determines if the item is an ammo type. 0 = regular item. 1 = keys. 2 = arrows. 3 = bombs. 4 = superbombs.

    I've also used font SS3, with a Y axis of 4 for this to line up properly. I should probably add a sound in there, but haven't brushed up on the particulars of those variables. All feedback is welcome.
    is this a gameboy styled shop?
    it could be made into one by creating a npc ffc and allowing the option to make players have to pick up the item and talk to the shop keeper

  9. #9
    クールな男
    SE Developer
    MasterSwordUltima's Avatar
    Join Date
    Jul 2001
    Location
    Keystonia
    Age
    29
    Posts
    5,560
    Mentioned
    16 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    8,290
    Level
    27
    vBActivity - Bars
    Lv. Percent
    53.52%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    2.83%
    Uh, kinda sorta. You don't pick up the item and carry it to a cashier. It's basically you stand underneath it and press A to purchase it if you have enough cash.

    -----

  10. #10
    Gibdo Tim's Avatar
    Join Date
    Apr 2004
    Age
    29
    Posts
    577
    Mentioned
    27 Post(s)
    Tagged
    8 Thread(s)
    vBActivity - Stats
    Points
    2,723
    Level
    17
    vBActivity - Bars
    Lv. Percent
    1.16%
    Daily Activity
    0%
    Weekly Activity
    1.63%
    Monthly Activity
    5.29%
    Sounds more like LttP.

    Sweet

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social