Inn price per member

iCed

Villager
Member
Joined
May 10, 2020
Messages
15
Reaction score
6
First Language
French
Primarily Uses
RMMV
Hi there !

I just wrote my first (newbie) script to calculate the price of an inn depending on the number of members in a party, and wanted to share it, to read from you about improvements that could be made.

Basically, I created an event somewhere in the map, in Parallel mode, with the following script in the 28th variable (the base Inn price is at the 30th) :
JavaScript:
$gameParty.members().length*$gameVariables.value(30)
Then I tested all the variables in the innkeeper conversation, and it works like a charm, as you can see below.
My goal is to use the same script all game long, with a factor >1 to increase the price in the inns of the game.

My question is : is there a way to optimize it, or improve it (no plugin necessary I guess in this case) ?
Could I have done better, in your opinion ? Any suggestion highly appreciated !
 

Attachments

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
The snippet looks good! You could have another variable represent the "inflation factor" used to increase the price of inns throughout the game, and multiply your snippet by that. So, if that variable is Variable 32, it would be
$gameParty.members().length*$gameVariables.value(30)*$gameVariables.value(32)
You may need to use a Math.round() function around the entire snippet to avoid decimal values.

However, you should avoid handling this using a Parallel Event on the map. It's unnecessary (it forces the variable to recalculate up to 60 times per second!) and it's going to absolutely tank your game's performance on slower computers. Instead, just set Variable 28 to this snippet as the first event command in your Inn Shopkeeper event. Therefore, it will always be set right before you need it.

I'm also moving this thread to the Learning JavaScript board. It's usually the best place to get tips on writing custom code. The Plugin Support board is for asking for help using other peoples' plugins correctly.
 

iCed

Villager
Member
Joined
May 10, 2020
Messages
15
Reaction score
6
First Language
French
Primarily Uses
RMMV
Thank you Wavelength for your tips and recommendations.
I will edit it right away !
And ok for next time, I'll put my explorations on the Learning JS section !
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,892
Reaction score
1,026
First Language
Dutch
Primarily Uses
RMMV
for inn's it is indeed usefull to pay for each member instead of full price like 100 G
for a single actor or 4, but I also wonder, If you can do this trick on the INN Kepper person
alone on top, instead of parallel process, so you just change the base price.

I love your idea, and hopefulyl many people make use of it if they use party bigger than 2 :)
good job.
 

iCed

Villager
Member
Joined
May 10, 2020
Messages
15
Reaction score
6
First Language
French
Primarily Uses
RMMV
but I also wonder, If you can do this trick on the INN Kepper person
alone on top, instead of parallel process, so you just change the base price.

I love your idea, and hopefulyl many people make use of it if they use party bigger than 2 :)
good job.
@ShadowDragon thanks a lot !
As you can see in my screenshot below, I edited it after @Wavelength's tip, and it works indeed pretty well. I didn't understand the exact purpose of parallel and other modes, but now it's clear to me : it's useless to make a cycle parallel process running all the time, for sure.
Learning everyday !
Here's my final snippet to calculate the price, according to the numbers of variables I declared in the pic :
Code:
Math.round($gameParty.members().length*$gameVariables.value(30)*$gameVariables.value(26))
 

Attachments

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,892
Reaction score
1,026
First Language
Dutch
Primarily Uses
RMMV
im not sure what inflation exacly does, while I think for me its easier (if I use it) to change
the base price alone, but you do a nice job.

Hope you improve,
 

iCed

Villager
Member
Joined
May 10, 2020
Messages
15
Reaction score
6
First Language
French
Primarily Uses
RMMV
I may have another use to increase the prices of items, armors and weapons based on this inflation factor variable too, not sure how far I will use it yet, but I thought it would be useful later : fancy towns may sell at higher price than small villages, like in real life (unfortunately :wink:!)
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
As you can see in my screenshot below, I edited it after @Wavelength's tip, and it works indeed pretty well. I didn't understand the exact purpose of parallel and other modes, but now it's clear to me : it's useless to make a cycle parallel process running all the time, for sure.
Learning everyday !
Glad that the new approach is working better for you!

There are multiple different, creative ways that you can use the different modes, but in their basic form, Action Button/Player Touch/Event Touch are pretty self explanatory, "Autorun" is something you'll want to use when you want an event to immediately process when you enter a map (or immediately after something else changes) and temporarily take control away from the player while the event runs, and "Parallel Process" is something you'll want to use when you need an event to continuously run while allowing the player to keep doing what they're doing.

For example, if I had a weather system and I wanted the weather to update itself every 15 seconds and show the appropriate visual weather effects, I'd put that in a Parallel Process Event, and I'd put a 900-frame Wait (15 seconds * 60 frames per second = 900 frames) at the end of the Event. This would only create a very slight performance loss because of the long Wait time - while the Event is in a Wait status, it doesn't need to run any code or check any conditions - and since I need the event to keep running every 15 seconds regardless of what the player is doing, it makes sense to use the Parallel Process here. In contrast, since you only need to calculate the price of the Inn directly before showing the price to the player, there was no need for a Parallel Process in that instance. :)

im not sure what inflation exacly does, while I think for me its easier (if I use it) to change
the base price alone, but you do a nice job.
I could see the case for using an Inflation mechanic in certain games. For example, if the player can easily jump between towns, and the designer doesn't want the player to keep jumping to the first town to use the cheapest possible Inn, Inflation could be used to increase the price of Inns throughout the game (to keep up with accelerating Gold drops from enemies), while avoiding the "first inn abuse case".

It's not something that would be a smart mechanic to use in every game, but in some games it might be a smart addition.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,892
Reaction score
1,026
First Language
Dutch
Primarily Uses
RMMV
wouldn't be smart to use the base price, but in a conditional brance?

if player level >= 10
base price is 10

if player level >= 30
base price is 45

etc? (I know it might be more work), but in a common event for all towns inn's
and for fancy towns, a different one?

I have no use for it, but I try to learn how to use variables in many ways or combining them
nicely.
but how do you increase the base price base and inflation rate for different town if
those variables are callled at the inn keeper npc alone and set the base price and
inflation rate?
 

iCed

Villager
Member
Joined
May 10, 2020
Messages
15
Reaction score
6
First Language
French
Primarily Uses
RMMV
but how do you increase the base price base and inflation rate for different town if
those variables are callled at the inn keeper npc alone and set the base price and
inflation rate?
Actually, the base price would stay the same, only the inflation rate would increase, depending on where or when you are in the game. But your idea of linking the member's level of experience to this factor is pretty cool too, maybe not in a conditional branch but as a variable itself, why not ? I'll make some tests.
Or maybe, I'll find it easier to find a math function with the member's level instead of this inflation factor (such as a logarithmic function, to avoid a linear progression of the prices - but not sure if I can use advanced math in JS?... ). I'll keep investigating !

About your ideas @Wavelength I didn't think about the "first inn abuse case" at first, but it's a good way to avoid it, indeed ! And thanks for the precise description of these modes. I just used now a parallel mode to make an area freezing cold, causing damage to the party unless they have a special equipment. Works well !
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top