I've just finished to make a procedural merchant. It works this way:
the first time you interact with it, it generates the group of things he'll sold, this group will last for a set time and then it will be replaced by another group of things. I'll let the code used below and a screenshots
first script:
second script
third script:
the first time you interact with it, it generates the group of things he'll sold, this group will last for a set time and then it will be replaced by another group of things. I'll let the code used below and a screenshots
first script:
var weapons = [], armors = [];
for (i=12; i<98; i++) {
if ($dataWeapons[i].price>10) {weapons.push([1,i,1,$dataWeapons[i].price*4]);}
} // genera inventario armi da vendere con prezzi personalizzati
for (i=7; i<50; i++) {
if ($dataArmors[i].price>10) {armors.push([2,i,1,$dataArmors[i].price*4]);}}
var goods = [];
for (i=1;i<16;i++) {goods.push(weapons[Math.floor(Math.random()*weapons.length)]),weapons.splice(weapons.indexOf(goods[goods.length-1]),1);}
for (i=1;i<11;i++) {goods.push(armors[Math.floor(Math.random()*armors.length)]),armors.splice(armors.indexOf(goods[goods.length-1]),1);}
SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, true);
$gameVariables.setValue(71, goods);
second script
var weapons = [], armors = [];
for (i=12; i<98; i++) {
if ($dataWeapons[i].price>10) {weapons.push([1,i,1,$dataWeapons[i].price*4]);}
} // genera inventario armi da vendere con prezzi personalizzati
for (i=7; i<50; i++) {
if ($dataArmors[i].price>10) {armors.push([2,i,1,$dataArmors[i].price*4]);}}
var goods = [];
for (i=1;i<16;i++) {goods.push(weapons[Math.floor(Math.random()*weapons.length)]);}
for (i=1;i<11;i++) {goods.push(armors[Math.floor(Math.random()*armors.length)]);}
SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, true);
$gameVariables.setValue(71, goods);
third script:
var goods = $gameVariables.value(71);
SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, true);