Jump to content

Announcing our new website

To find out the latest about our new website, visit Game Dev Unlimited

- - - - -

Shop that allows for changing prices and seeing difference in current/new stuff


  • You cannot reply to this topic
12 replies to this topic

#1 Silencher

    Member

  • Member
  • 33 posts

Posted 26 September 2011 - 02:37 PM

Hey all,

I'm currently using the following script because it allows me to lower/raise prices by a certain percentage. I want this because I have an item in my game that allows for 1/2 off at all shops. This script does that just fine, but I have a pet peeve about not being able to see the difference(good or bad) in what is currently equipped on my actors and what is for sale in a shop.

I have a few other scripts installed, the most major being the AMS.

I'm looking for 1 of 2 things:

1) A brand new script that would allow me/the player to see the difference in stats and armor plus would also enable me to keep my 1/2 off item, and otherwise raise or lower my shop prices by a percentile.

2) A modification to the script below that would show the differences in current/new equipment while in the shop menu.

If you could help, that would be really great. As a side note, I'm currently learning to program Java and I would like to eventually move on to Ruby. If you are willing to help 'mentor' me as I learn Ruby, can you shoot me a PM?

thanks a bunch guys,
Silencher

Spoiler

Edited by Silencher, 27 September 2011 - 09:03 PM.


#2 Dragon324

    Extreme Member

  • Member
  • 332 posts

Posted 27 September 2011 - 06:45 PM

First of all I believe the default allows the player to see the difference. Secondly this can also possibly be evented. It largely depends on how much adjusting to prices you want, and how many coupon type things you will have in game to how long the event will be. So if your interested when I'm not busy I can probably try to whip one up for you.Again not to sound mean but kell is busy and idk when or if he could get around to it but its up to you, I'm just trying to help.

Edited by Dragon324, 27 September 2011 - 06:46 PM.


#3 Silencher

    Member

  • Member
  • 33 posts

Posted 27 September 2011 - 08:50 PM

View PostDragon324, on 27 September 2011 - 06:45 PM, said:

First of all I believe the default allows the player to see the difference. Secondly this can also possibly be evented. It largely depends on how much adjusting to prices you want, and how many coupon type things you will have in game to how long the event will be. So if your interested when I'm not busy I can probably try to whip one up for you.Again not to sound mean but kell is busy and idk when or if he could get around to it but its up to you, I'm just trying to help.


You're right, the default does allow you to see the difference. In my game I had it evented so that if the players shopped at one particular shop, it increased the prices for that shop by 50%. I thought about just raising the prices but I realized if I did that that they could still sell the items for 75% of the normal price, which while it is still a loss is a little irritating.

The other thing is just at every shop I have a conditional branch on whether or not the 1/2 off item is in the inventory, if it is, I call the script to reduce prices by 50%, then raise them back to normal after shop processing is complete.

If you could tell me how to allow both of those, I'll just go ahead and cut out the script I posted above and do it that way, it sounds like the easiest way.

So to summarize, I'd need to know how to 1) raise the price by 50%. 2) lower the price by 50%) and then 3) return the price to normal, which I can just insert after each of the raising/lowerings.

Could you help me with that? I'd appreciate it, for sure.

#4 Dragon324

    Extreme Member

  • Member
  • 332 posts

Posted 27 September 2011 - 09:08 PM

View PostSilencher, on 27 September 2011 - 08:50 PM, said:

You're right, the default does allow you to see the difference. In my game I had it evented so that if the players shopped at one particular shop, it increased the prices for that shop by 50%. I thought about just raising the prices but I realized if I did that that they could still sell the items for 75% of the normal price, which while it is still a loss is a little irritating.

The other thing is just at every shop I have a conditional branch on whether or not the 1/2 off item is in the inventory, if it is, I call the script to reduce prices by 50%, then raise them back to normal after shop processing is complete.

If you could tell me how to allow both of those, I'll just go ahead and cut out the script I posted above and do it that way, it sounds like the easiest way.

So to summarize, I'd need to know how to 1) raise the price by 50%. 2) lower the price by 50%) and then 3) return the price to normal, which I can just insert after each of the raising/lowerings.

Could you help me with that? I'd appreciate it, for sure.
Ok I think I get you the last thing I need to know is why the prices raise, such as the player has bought to many, or is it just at certain times prices are higher. Preferably the second one imo would be easier but the first would not be impossible but I will tell you this might get pretty lengthy. If you respond to that if I have time I'll start on it 2 nite when I get home if not I should be able to do it Wednesday.

#5 Silencher

    Member

  • Member
  • 33 posts

Posted 27 September 2011 - 09:39 PM

View PostDragon324, on 27 September 2011 - 09:08 PM, said:

Ok I think I get you the last thing I need to know is why the prices raise, such as the player has bought to many, or is it just at certain times prices are higher. Preferably the second one imo would be easier but the first would not be impossible but I will tell you this might get pretty lengthy. If you respond to that if I have time I'll start on it 2 nite when I get home if not I should be able to do it Wednesday.

The price just raises at one particular shop because it's the 'black market' so I wanted the prices to be higher. Basically it's a shop for getting mid-game eq at near the beginning of the game. The increase in price is just to mitigate that basically. So it affects the entire shops' prices and is independent of certain times or if the player buys too many items or anything like that.

#6 kellessdee

    mrrow ~!

  • Moderator
  • 902 posts

Posted 28 September 2011 - 01:58 PM

You guys may or may not be over-complicating this...
(being a scripter gives me an unfair advantage i guess)

Use this with the default shop system.
Change the price modification through a script call:
$game_party.price_modifier = mod
mod is a percentage represented as a decimal number.
100% = 1.0
50% = 0.5
so to make all the items in a shop cost 50% price rate
$game_party.price_modifier = 0.5

There's the modification, then if you use the default shop, it will display the difference in changing equipment.
This only affects buy price, did you need a mod on sale price as well?

put above main as per usual

class Game_Party
  attr_accessor :price_modifier
  
  alias :new_init_item_price :initialize unless method_defined?(:new_init_item_price)
  
  def initialize
    new_init_item_price
    @price_modifier = 1.0
  end
  
end

class Window_ShopBuy < Window_Selectable
  
  alias :new_draw_item_price :draw_item unless method_defined?(:new_draw_item_price)
  
  def draw_item(index)
    new_draw_item_price(index)
    price = (@data[index].price * $game_party.price_modifier).to_i
    x, y = 4, index * 32
    self.contents.fill_rect(x + 240, y, 88, 32, Color.new(0,0,0,0))
    self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  end
  
  def item
    item = @data[self.index].dup
    item.price = (item.price * $game_party.price_modifier).to_i
    return item
  end

end


#7 Silencher

    Member

  • Member
  • 33 posts

Posted 28 September 2011 - 02:20 PM

This seems to work fine so long as I put in the call script everytime. But after putting in the full script after main, if I go to a shop where I don't call the script it gives me an error message: Script 'PriceModifier' line20: TypeError occurred. nil can't be coerced into Fixnum.

The line it references seems to be this one, so I'm not sure what the issue is.
 price = (@data[index].price * $game_party.price_modifier).to_i


#8 kellessdee

    mrrow ~!

  • Moderator
  • 902 posts

Posted 28 September 2011 - 02:46 PM

Hmm that's weird. That means either @data[index].price or $game_party.price_modifier is nil when the shop is being called.... which it shouldn't be.
Do you change the price_modification after a shop is finished processing?

I will try to recreate this error in like 5-10mins. I have to boot back to windows to try it out. BRB LOL

EDIT: I hate to say things like this, but I can't recreate the error... You *MAY* be doing something funny with the $game_party.price_modifier value.......? (or it could be a compatibility issue...but I HIGHLY doubt that...you are using the default shop with this right?)

If you could upload some pics of the event editor on the shop events that you tested to get this error; I may be able to figure out what's going on.

#9 Silencher

    Member

  • Member
  • 33 posts

Posted 28 September 2011 - 03:00 PM

View Postkellessdee, on 28 September 2011 - 02:46 PM, said:

Hmm that's weird. That means either @data[index].price or $game_party.price_modifier is nil when the shop is being called.... which it shouldn't be.
Do you change the price_modification after a shop is finished processing?

I will try to recreate this error in like 5-10mins. I have to boot back to windows to try it out. BRB LOL

EDIT: I hate to say things like this, but I can't recreate the error... You *MAY* be doing something funny with the $game_party.price_modifier value.......? (or it could be a compatibility issue...but I HIGHLY doubt that...you are using the default shop with this right?)

If you could upload some pics of the event editor on the shop events that you tested to get this error; I may be able to figure out what's going on.


As far as I know I'm not doing anything, but to be on the safe side I just used a call script to set the price mod to 1 when the game first starts, that seems to fix it no problem, so thanks a lot =)

#10 kellessdee

    mrrow ~!

  • Moderator
  • 902 posts

Posted 28 September 2011 - 03:07 PM

AROOO????

Well that means I found the issue, for some reason on your end the script isn't initializing the price_modifier...

Did you include this part of the script?
class Game_Party
  attr_accessor :price_modifier
  
  alias :new_init_item_price :initialize unless method_defined?(:new_init_item_price)
  
  def initialize
    new_init_item_price
    @price_modifier = 1.0
  end
  
end

If you did, then there somehow must be some interference of scripts somewhere xD

Eitherway, if it all works now then I guess it's all good, and I am glad :alright:

ALSO, I forgot to mention: I am a total nerd and love talking all things computers/scripts/programming/etc. Also, java was my *technically* first language (i did briefly learn visual basic, but never really took it that far), so if you are looking to learn ruby as well, and have any questions feel free to drop me a PM

EDIT: somehow i left my message in the code tags LOL fixed haha

#11 Silencher

    Member

  • Member
  • 33 posts

Posted 28 September 2011 - 03:22 PM

I did, I'll try re-copying and pasting it to see if that fixes it and yeah, definitely, I'll drop you a PM as stuff comes up. I'm actually trying to do a warp spell, I have it working fine with eventing, but the issue is that it could potentially spoil upcoming towns. I'll include it here if you want to take a look and maybe guide me through how I could fix it. Ideally I'd like the menu to be longer, and for the warp point names to be either blank or ???? until the town has been visited. It would also be nice to know how to gray out 'warp' when it isn't available, such as when I'm inside of dungeons, I turn off the enablewarp switch.

Basically the 'warp' spell calls a common event that first checks via conditional branch(hearafter referred to as CB) if warp is enabled. If not, then the event spits out a message and cancels. If so, it brings up a text box and choices list: Choose a town to warp to (Choice box: Town1, Town2,Town3,next). Anytime they choose a town, it pulls up CB:Is(X)townfound? if so: CB:Is (X) town accessible? if either of those are false, it tells them they haven't found or can't warp to that town. If both CBs are true, it teleports them to that town via a Transfer Player event.

So yeah, the drawbacks to this are that first of all they might waste precious MP trying to use it when they can't, for whatever reason; the event way of doing it doesn't look particularly nice/professional; it could potentially spoil what future towns there are(although I suppose I could just make more CBs to only display certain towns at certain times but it would require a lot of reworking of both the common event and the project itself, like adding switches, etc.)

#12 kellessdee

    mrrow ~!

  • Moderator
  • 902 posts

Posted 28 September 2011 - 03:38 PM

Weird, I am wondering if maybe you are using a script that modifies the Game_Party class, but doesn't alias initialize and just overwrites it...Although, if my script is below that script, it still shouldn't be an issue. Did you place my script DIRECTLY above main? that may fix the issue (if you didn't put it DIRECTLY above main anyways...)

As for the warp issue, to make it work the way YOU want it to, without extensive eventing/pictures/etc. It would need to be a script. Otherwise, to make the menu longer: you would need to use pictures for the names/menu/cursor/etc. then you would need to use loops/conditional branching to determine what's available, etc.

I can go into more detail if you'd like.
Although, this seems like a useful system I could make..but if I did, I would make it a public release..so if you are cool with me using your idea-I would make a script like this.

#13 Silencher

    Member

  • Member
  • 33 posts

Posted 28 September 2011 - 03:43 PM

Yeah I'd be cool with you making it public release, I'd just love to see get it to work, and I have your script above main and AMS, it's below everything else. I also sent you a PM about a probably less complicated script too.





0 user(s) are reading this topic

members, guests, anonymous users