Jump to content

Photo

Buying items with another currency


  • Please log in to reply
8 replies to this topic

#1 Peteo

Peteo

    Back in Business!

  • Members
  • Real Name:Pete
  • Location:Finland

Posted 31 January 2020 - 09:46 AM

I'd like to have at least 2 different currencies in my quest: The built in "rupee" and a custom counter one. I obviously know how to set up this secondary currency, but I want the player to be able to use this custom currency in a specific shop, and only in there. There seem to be a few custom shop scripts in the database but none of them let you choose a currency.

 

Would it be hard to make a script for this? A script that enables you to have different currencies required in shops?



#2 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 31 January 2020 - 11:12 AM

It would be easy, and in fact, I have just such a shop script sitting around in my newest quest. The issue is that it mine is somewhat hard-coded. How exactly would you want this to work?



#3 Peteo

Peteo

    Back in Business!

  • Members
  • Real Name:Pete
  • Location:Finland

Posted 31 January 2020 - 11:24 AM

It would be easy, and in fact, I have just such a shop script sitting around in my newest quest. The issue is that it mine is somewhat hard-coded. How exactly would you want this to work?

 

Hmm, I'm still figuring out how I want to set up my shops in my quest. What kind of details do you need? All I really want is to replace the rupee requirement with a custom currency in some shops. I'm going to have some special items that you need a special currency to buy.



#4 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 31 January 2020 - 12:57 PM

Are the other shops in your quest the standard 3 items on the floor type? Or do you pick them up off a shelf or something like that?



#5 Mani Kanina

Mani Kanina

    Rabbits!

  • Members

Posted 31 January 2020 - 07:40 PM

If you're using a scripted shop system in the first place then it should be trivial to adapt it to use another counter instead of the rupee one to make purchases.

This one for example would be very trivial to make a second modified version of, it's even using the std variable names so it should be simple to find and replace the counter reference with another one.


Edit: made a quick edit of it that let's you set counter ID based on the FFCs D5 variable:

//D0: ID of the item
//D1: Price of the item
//D2: Message that plays when the item is bought
//D3: Message that plays when you don't have enough rupees
//D4: Input type 0=A 1=B 2=L 3=R
//D5: Counter ID


ffc script SimpleShopModified{
    void run(int itemID, int price, int m, int n, int input, int ShopCounterID){
        int loc = ComboAt(this->X,this->Y);
        while(true){
            while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
            SetInput(input,false);
            	if(Game->Counter[ShopCounterID] >= price){
	    	Game->DCounter[ShopCounterID] -= price;
	    	item shpitm = CreateItemAt(itemID, Link->X, Link->Y);
	        shpitm->Pickup = IP_HOLDUP;
            	Screen->Message(m);
		}
		else{
		Screen->Message(n);
		}		
            Waitframe();
        }
    }
    bool AgainstComboBase(int loc){
        return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8);
    }
}

//If you are already using the signpost script remove the code below
bool SelectPressInput(int input){
    if(input == 0) return Link->PressA;
    else if(input == 1) return Link->PressB;
    else if(input == 2) return Link->PressL;
    else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
    if(input == 0) Link->InputA = state;
    else if(input == 1) Link->InputB = state;
    else if(input == 2) Link->InputL = state;
    else if(input == 3) Link->InputR = state;
}

I didn't test compile it, but it's a very tiny edit so I don't imagine it causing any issues.

To know what number to put in D5 based on what counter you want:
 

//Generic counters. Use with itemclass->Counter, Game->Counter[], Game->MCounter[] and Game->DCounter[]
CR_LIFE               = 0;
CR_RUPEES             = 1;
CR_BOMBS              = 2;
CR_ARROWS             = 3;
CR_MAGIC              = 4;
CR_KEYS               = 5;
CR_SBOMBS             = 6;
CR_SCRIPT1            = 7;
CR_SCRIPT2            = 8;
CR_SCRIPT3            = 9;
CR_SCRIPT4            = 10;
R_SCRIPT5            = 11;
...etc for the rest of the script counters

Edited by Mani Kanina, 31 January 2020 - 07:48 PM.

  • Aquamentus (Facing Right) likes this

#6 Peteo

Peteo

    Back in Business!

  • Members
  • Real Name:Pete
  • Location:Finland

Posted 01 February 2020 - 03:05 AM

Russ, was planning on using a shop script to make the shops a bit better than just "pick up from the floor" style regular shops.

 

 

Mani Kanina, gonna try that if it works. Thanks. However that script doesn't have the ability to make it a one time purchase. This script https://www.purezc.n...=scripts&id=360 allows you to set the item to be purchased only once, however it is using all 8 arguments already (d0 to d7) so there's probably no way to add any more arguments for the counter ID there?


Edited by Peteo, 01 February 2020 - 03:17 AM.


#7 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 01 February 2020 - 04:59 AM

Russ, was planning on using a shop script to make the shops a bit better than just "pick up from the floor" style regular shops.

 

 

Mani Kanina, gonna try that if it works. Thanks. However that script doesn't have the ability to make it a one time purchase. This script https://www.purezc.n...=scripts&id=360 allows you to set the item to be purchased only once, however it is using all 8 arguments already (d0 to d7) so there's probably no way to add any more arguments for the counter ID there?

 

What version are you using? IIRC you were trying 2.55, so we have some example shop scripts for that. One of mine automatically converts an in-editor shop type into a Z3 style shop. Rob's 2.55 shop should easily be able to set the requisite counter ID. I used multiple currencies in LoE.

 

I wrote this one for JudasRising in May, 2017:

 

 

The last version in the video had a bug that has since been fixed, where the wrong bits were being set on purchasing some items. The shop ffcs automate their data, but I think that at this point it'd be wiser to use ffcs combined with itemsprite scripts, as itemsprite can give you extra data values, and they won't vanish during the hold-up animation as ffc draws do. The ffc would simply spawn items, set the appropriate Pickup flag, and set a shopitem itemsprite script to each, passing ffc alues to the itemsprite object, used by the script per sprite.

 

It would use D registers to set bits on what is sold out and so forth. The same door closure script would remain compatible with that transition.

 

Anyway, in the script in that video, when you buy an item, you have three options: It can be bought again, it transforms into a different item that can be bought again, or it becomes 'Sold Out'. The shop door closes when no items remain for sale. Items with a price of 0 display a price of 'Free' for their cost string.

 

Let us know what version you are using and we'll hand over the most appropriate script. I'd need to slightly update mine to the current Tango version, if you want menus; or just remove the  menus.



#8 Mani Kanina

Mani Kanina

    Rabbits!

  • Members

Posted 01 February 2020 - 07:00 AM

Mani Kanina, gonna try that if it works. Thanks. However that script doesn't have the ability to make it a one time purchase. This script https://www.purezc.n...=scripts&id=360 allows you to set the item to be purchased only once, however it is using all 8 arguments already (d0 to d7) so there's probably no way to add any more arguments for the counter ID there?

Oh I didn't realize one time only was a requirement you wanted. D variables on FFCs are not needed per se, it just makes it so you can modify things in ZQ instead of having to modify the script. Anyway, I added in another toggle option in the script edit I made, it's included below, which prevents you to purchase the item if you already have it in your inventory..., I hope it works since I didn't take the time to properly test things out. :V
 
//D0: ID of the item
//D1: Price of the item
//D2: Message that plays when the item is bought
//D3: Message that plays when you don't have enough rupees
//D4: Input type 0=A 1=B 2=L 3=R
//D5: Counter ID
//D6: Set to 1 to make shop only avalible if you don't have the item.


ffc script SimpleShopModified{
    void run(int itemID, int price, int m, int n, int input, int ShopCounterID, int HaveItem){
        int loc = ComboAt(this->X,this->Y);
		
		if(HaveItem >= 1 && Link->Item[itemID] == true){
			this->Data = 0;
			return;
		}
		else{
			
			while(true){
				
				while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
				SetInput(input,false);
					if(Game->Counter[ShopCounterID] >= price){
						Game->DCounter[ShopCounterID] -= price;
						item shpitm = CreateItemAt(itemID, Link->X, Link->Y);
						shpitm->Pickup = IP_HOLDUP;
							Screen->Message(m);
					}
					else{
						Screen->Message(n);
					}		
				Waitframe();
				
			}
			
		}
    }
    bool AgainstComboBase(int loc){
        return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8);
    }
}

//If you are already using the signpost script remove the code below
bool SelectPressInput(int input){
    if(input == 0) return Link->PressA;
    else if(input == 1) return Link->PressB;
    else if(input == 2) return Link->PressL;
    else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
    if(input == 0) Link->InputA = state;
    else if(input == 1) Link->InputB = state;
    else if(input == 2) Link->InputL = state;
    else if(input == 3) Link->InputR = state;
}


#9 Peteo

Peteo

    Back in Business!

  • Members
  • Real Name:Pete
  • Location:Finland

Posted 01 February 2020 - 03:36 PM

ZoriaRPG, using ZC 2.53 but I've been tinkering around with ZC 2.55 and will be moving there soon if there are no hiccups. And don't want to nitpick but in that video the sounds seems to be cutting/breaking quite bad at times, other than that it seems like the shops work fine and it's a nice script.

 

 

Mani Kanina, your script works perfectly, thank you. Gonna go with it for now.


Edited by Peteo, 01 February 2020 - 03:37 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users