EST - PRICE FORMULA MZ

■ Information ╒══════════════════════════╛
EST - PRICE FORMULA MZ
Version: 1.0
By Estriole
File name: .js

■ Introduction ╒══════════════════════════╛
This script make us able to create formula for item / equip price.
for example item like seltzer from star ocean where it become more
expensive as the game time increases.

■ Features ╒══════════════════════════╛
- set price formula... global buy and sell formula
- set buy formula. buying will use that formula as priority
- set sell formula. selling will use that formula as priority
- when buying item... if the shop set the specific price of that item...
if have price formula => buy use specific price, sell use specific price
if have buy formula => buy use specific price, sell use specific price
if have sell formula => sell use sell formula.

■ Changelog ╒══════════════════════════╛
v1.0 2020.10.22 Finish the plugin

■ Plugin Download ╒══════════════════════════╛
https://www.dropbox.com/s/4yml2wbgj36mun9/EST_PRICE_FORMULA_MZ.js?dl=0

■ Screenshots ╒══════════════════════════╛
1603632505616.png


■ Demo ╒══════════════════════════╛
https://www.dropbox.com/sh/vhf1jhpydfr3vne/AACXtmj85frlI81AAmAcK50Ha?dl=0
click download to download the entire folder.

■ How to use ╒══════════════════════════╛
at item / weapon / armor database notebox add:
Spoiler
<price_formula>
specify your formula here
</price_formula>
for adding price formula. it will be used as global buy/sell formula.
if there's buy formula or sell formula... this will be overwritten.

<buy_formula>
specify your formula here
</buy_formula>
for adding buy formula... this will overwrite normal price formula.
but if there's specify price in the shop scene... this will be overwritten.

<sell_formula>
specify your formula here
</sell_formula>
for adding sell formula... this will overwrite normal price formula.
and this also overwrite specify price.

you can set your formula to return value... there's also shortcut variable
so it's easier to create formula
oprice => item original price set in database
s => $gameSwitches
=> usage: s.value(switch id);
=> or if you want to flip a switch in calculation: s.setValue(switch id, value)
v => $gameVariables
=> usage: v.value(variable id);
=> or if you want to modify variable in calculation: v.setValue(variable id, value)
p => $gameParty;
a => $gameActors;
gs = $gameSystem;
pt = $gameSystem.playtime();
bc = $gameSystem.battleCount();
sc = $gameSystem.saveCount();
inum = $gameParty.numItems(item);
WARNING: if you set your formula wrong. there's a possibility item
will be priced at Infinity Price
this usually because the formula ended with SOMETHING DIVIDED BY ZERO
thus result = Infinity.

■ Dependencies ╒══════════════════════════╛
none

■ Compatibility ╒══════════════════════════╛
MZ is new engine... so i cannot say for sure.
but it should be compatible with most things.

■ Parameters ╒══════════════════════════╛
None

■ License ╒══════════════════════════╛
Free to use in all project (except the one containing pornography)
as long as i credited (ESTRIOLE).

■ Extra Credit ╒══════════════════════════╛

■ Support ╒══════════════════════════╛
While I'm flattered and I'm glad that people have been sharing and
asking support for scripts in other RPG Maker communities, I would
like to ask that you please avoid posting my scripts outside of where
I frequent because it would make finding support and fixing bugs
difficult for both of you and me.

If you're ever looking for support, I can be reached at the following:
[ http://forums.rpgmakerweb.com/ ]
pm me : estriole

also support to compatibility with VisuStella is not possible.
because their code is obfuscated thus cannot be read by human.
if there's incompatibility... please ask VisuStella Team.

■ Donate ╒══════════════════════════╛
If you want to support my work you can donate here
https://www.makerdevs.com/profile/estriole

■ Author's Notes ╒══════════════════════════╛
None
That's really cool. So I could use:


JavaScript:
<price_formula>
oprice * v.value(variable id) / 100;
</price_formula>

To create a economy system and control the prices using a variable. If the price is 10 gold and the variable is set to 1 them the rise would be 0.01% in the price. Or 550 to rise in the price in 11%.

Thanks. I'll test it later. :3
That's really cool. So I could use:


JavaScript:
<price_formula>
oprice * v.value(variable id) / 100;
</price_formula>

To create a economy system and control the prices using a variable. If the price is 10 gold and the variable is set to 1 them the rise would be 0.01% in the price. Or 550 to rise in the price in 11%.

Thanks. I'll test it later. :3
yes you can...
Code:
oprice * v.value(variable id) / 100;
when your variable is 1 that means
Code:
oprice * 1 / 100;
the price is 1% or the original price. in your example if the price is 10 gold... it will be 0.1 gold (then math floored to 0 gold)

if you want it's 101% of the original price (raise 1% each variable)
Code:
oprice + oprice * v.value(variable id) / 100;

also all the final price is math.floor by default engine (to avoid decimal value)...
This is really cool and seems to work flawlessly with VisuStella Items & Equip Core. Thank you so much!
This plugin is good! It can add more interest to the store.
This is really cool and seems to work flawlessly with VisuStella Items & Equip Core. Thank you so much!
thank you for the compatibility information 😀. i never tested with that plugin so it's nice to know that it work flawlessly with them 😀.
Hello I really do love this plugin and will keep using it. I have a question though. I'm trying to make it so items that cost 0 don't show up in shops when selling items. Problem is, the game uses the database's price rather then the price created by your plugin to determine if the item is enabled for selling.

This is the script I'm using to try to achieve this:

Code:
Window_ShopSell.prototype.isEnabled = function(item) {
    return item && item.price > 0;
};

Window_ItemList.prototype.makeItemList = function() {
    this._data = $gameParty.allItems().filter(function(item) {
        if (SceneManager._scene instanceof Scene_Shop) {
        return this.includes(item) && this.isEnabled(item);
        } else {
        return this.includes(item);
        }
    }, this);
    if (this.includes(null)) {
        this._data.push(null);
    }
};

Spoiler: I got Scripts from here, Just wanted to give credit. Links to Forum Posts.


Any idea how I can fix this. Basically my game attached different sell costs to each shop that can also vary, and some shops refuse to buy certain goods etc. It gets annoying to see my items show up for 0 gold in selling screen when my "insert random shop owner here" doesn't want to buy my other goods.

I'm assuming I just need to reference the new price in the first scripts code, as the second script works on database items that cost 0.

Code:
Window_ShopSell.prototype.isEnabled = function(item) {
    return item && item.price > 0;
};;

Thanks again.


Update! Edited on 8.2.23

So i figured out how to do it on my own after spending 5 hours looking at java code and scripts until I got something that worked. Thought I'd update in case anyone else wondered how to do it.

1690965945693.png

It involved creating my own meta tags and referencing them to sort the list by my meta tags, and then I tell it which script to use based on the vendor variable. Anyways really cool plugin!

Original thread: https://forums.rpgmakerweb.com/threads/est-price-formula-mz.129116/