Hey guys, glad to be finally here. 🙂 I´m currently working on my own RPG Maker MV game and I have some "trouble" with a plugin.
I´m using a Slot Machine Plugin from TheUnproPro
You can buy chips with the ingame currency (gold) and then play on a slot machine with these chips.
Problem: You cannot exchange these chips back. It looks like these chips don´t have a variable. Also you cannot see them anywhere (for example in the inventory), only at the shop/slot.
I don´t want to necessarily exchange these chips at the same shop, I can create another "Exchange Shop" for it. But without a variable, how would I do that with an "invisible" currency?
Maybe someone can help? I´ll "spoiler" the used 2 plugins:
EDIT: Link to the plugins:
I'm grateful for any help 🙂.
I´m using a Slot Machine Plugin from TheUnproPro
You can buy chips with the ingame currency (gold) and then play on a slot machine with these chips.
Problem: You cannot exchange these chips back. It looks like these chips don´t have a variable. Also you cannot see them anywhere (for example in the inventory), only at the shop/slot.
I don´t want to necessarily exchange these chips at the same shop, I can create another "Exchange Shop" for it. But without a variable, how would I do that with an "invisible" currency?
Maybe someone can help? I´ll "spoiler" the used 2 plugins:
/*:
* @plugindesc Version: 1.00 | Core plugin for casino games!
* @Author William Ramsey (TheUnproPro)
*
* @param Chip Cost
* @desc How much Gold does it cost per chip?
* @Default 1
*
* @param Max Chips
* @desc What's the max number of Chips you can have?
* @Default 9999
*
* @param Chip Name
* @desc What are Chips called in your game?
* @Default Chips
*
* @param Gold Icon
* @desc What icon is the gold icon?
* @Default 314
*
* @param Mobile Mode
* @desc Use when exporting for touch screen devices.
* @Default false
*
* @param Block Color
* @desc Color of the dark area drawn behind the text.
* @Default 0, 0, 0, 0.5
*
* @Help
* upp_casinoCore is required for all of the casino games. This is basically
* this shop, as well as data management.
*
* There are a few plugin commands you can use.
*
* 1) - upp_setCasinoFace name id - where name is the face name (Example:
* People4) and id is the index.
*
* 2) - upp_setCasinoMsg msg - You can use the same text codes when displaying
* a normal message. You can also use \cn to display
* the name of the casino currency.
*
* 3) - upp_earnChips number - where number is how many you gain. Use -
* before the number to subtract. Example: -50
*
* 4) - upp_openCasinoShop - This opens the casino shop.
*
*/
(function() {
var empty={};
var upp_miniMapCmds = Game_Interpreter.prototype.pluginCommand
Game_Interpreter.prototype.pluginCommand = function(command, args) {
upp_miniMapCmds.apply(this, arguments);
if(command=="upp_openCasinoShop") {
SceneManager.push(Scene_ChipShop);
}
if(command=="upp_setCasinoFace") {
upp_data().casinoFace = args[0];
upp_data().casinoFaceIndex = Number(args[1]);
}
if(command=="upp_earnChips") {
upp_data().chips += Number(args[0]);
if(upp_data().chips>maxChips) {
upp_data().chips = maxChips;
}
}
if(command=="upp_setCasinoMsg") {
var str="";
for(var i=0;i<args.length;i++) {
str += args;
if(i<args.length-1) {
str += " ";
}
}
str = str.replace(/\\cn/g, chipName);
upp_data().casinoMsg = str.replace(/\\n/g, "\n");
}
}
var params = PluginManager.parameters("upp_casinoCore");
var chipName = params['Chip Name'];
var chipCost = Number(params['Chip Cost']);
var goldIcon = Number(params['Gold Icon']);
var mobileMode = (params['Mobile Mode'] == "true" || params['Mobile Mode'] == "false") ? eval(params['Mobile Mode']) : false;
var blockColor = "rgba("+params['Block Color']+")";
var maxChips = Number(params['Max Chips']);
function _upp_data() {
this.extractAlias = function(fun) {
var dmex = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
dmex.apply(this, arguments);
$gameSystem.upp_data = {};
fun.apply(this, arguments);
}
}
}
var upp_data = function() {
if($gameSystem) {
return $gameSystem.upp_data;
} else { return empty }
}
var chips = function() {
return $gameSystem.upp_data;
}
var gameSystemAlias = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
gameSystemAlias.call(this);
this.upp_data = this.upp_data || new _upp_data();
this.upp_data.mobileMode = mobileMode;
this.upp_data.casinoFace = "";
this.upp_data.casinoMsg = "";
this.upp_data.casinoFaceIndex = 0;
this.upp_data.chipName = chipName;
this.upp_data.chips=0;
}
var dmex = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
dmex.apply(this, arguments);
$gameSystem.upp_data = $gameSystem.upp_data || new _upp_data();
}
Window_ChipShop = function() {
this.initialize.apply(this, arguments);
}
Window_ChipShop.prototype = Object.create(Window_Base.prototype);
Window_ChipShop.prototype.constructor = Window_ChipShop;
Window_ChipShop.prototype.initialize = function(width, height) {
Window_Base.prototype.initialize.call(this, 0, 0, width, height);
this.chipCount=0;
this.cos=0;
this.refresh();
}
Window_ChipShop.prototype.refresh = function() {
this.contents.clear();
this.contents.fillRect(0, 0, this.contents.width, this.contents.height, blockColor);
this.contents.drawText("How many "+chipName+" do you want to buy?", 0, 0, this.contents.width, this.lineHeight());
this.contents.drawText("x"+this.chipCount, this.contents.fontSize/2, this.lineHeight(), 50, this.lineHeight(), 'center');
this.contents.drawText(this.chipCount*chipCost, -32-this.padding/2, this.lineHeight(), this.contents.width, this.lineHeight(), 'right');
this.drawIcon(goldIcon, this.contents.width-32, this.lineHeight());
this.contents.drawText("<", -Math.cos(this.cos), this.lineHeight(), 50, this.lineHeight());
this.contents.drawText(">", 50+this.contents.fontSize/2+Math.cos(this.cos), this.lineHeight(), 50, this.lineHeight());
}
Window_ChipShop.prototype.update = function() {
this.cos+=0.1;
if(Input.isRepeated("right") && $gameParty.gold()>this.chipCount*chipCost) {
this.chipCount+=1;
SoundManager.playCursor();
}
if(Input.isRepeated("pagedown") && $gameParty.gold()>this.chipCount*chipCost) {
this.chipCount+=10;
SoundManager.playCursor();
}
if(Input.isRepeated("left") && this.chipCount>0) {
this.chipCount-=1;
SoundManager.playCursor();
}
if(Input.isRepeated("pageup") && this.chipCount>0) {
this.chipCount-=10;
SoundManager.playCursor();
}
this.chipCount = Math.min(Math.max(this.chipCount, 0), $gameParty.gold()/chipCost);
this.refresh();
console.log();
}
Chip_Window = function() {
this.initialize.apply(this, arguments);
}
Chip_Window.prototype = Object.create(Window_Base.prototype);
Chip_Window.prototype.constructor = Chip_Window;
Chip_Window.prototype.initialize = function() {
Window_Base.prototype.initialize.call(this, 0, 0, 240, 256);
this.refresh();
}
Chip_Window.prototype.refresh = function() {
this.contents.clear();
this.changeTextColor(this.systemColor());
this.contents.drawText(chipName, 0, 0, this.contents.width, this.lineHeight());
this.changeTextColor(this.normalColor());
this.contents.drawText(upp_data().chips, 0, 0, this.contents.width, this .lineHeight(), 'right');
}
Chip_Window.prototype.update = function() {
this.refresh();
}
Window_ChipMsg = function() {
this.initialize.apply(this, arguments);
}
Window_ChipMsg.prototype = Object.create(Window_Base.prototype);
Window_ChipMsg.prototype.constructor = Window_ChipMsg;
Window_ChipMsg.prototype.initialize = function(height) {
Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, height);
this.refresh();
}
Window_ChipMsg.prototype.refresh = function() {
this.contents.clear();
this.drawFace(upp_data().casinoFace, upp_data().casinoFaceIndex, 0, 0, 144, 144);
this.drawTextEx(upp_data().casinoMsg, 144, 0);
}
Window_ChipMsg.prototype.update = function() {
this.refresh();
}
function Window_CasinoChoice() {
this.initialize.apply(this, arguments);
}
Window_CasinoChoice.prototype = Object.create(Window_Command.prototype);
Window_CasinoChoice.prototype.constructor = Window_CasinoChoice;
Window_CasinoChoice.prototype.initialize = function(x, y) {
Window_Command.prototype.initialize.call(this, x, y);
}
Window_CasinoChoice.prototype.windowWidth = function() {
return Graphics.boxWidth/1.5;
}
Window_CasinoChoice.prototype.makeCommandList = function() {
if(upp_data().mobileMode == true) {
this.addCommand('+1', 'p1');
this.addCommand('+10', 'p10');
this.addCommand('-1', 'm1');
this.addCommand('-10', 'm10');
}
this.addCommand('Finished', 'fin');
}
Scene_ChipShop = function() {
this.initialize.apply(this, arguments);
}
Scene_ChipShop.prototype = Object.create(Scene_MenuBase.prototype);
Scene_ChipShop.prototype.constructor = Scene_ChipShop;
Scene_ChipShop.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
}
Scene_ChipShop.prototype.start = function() {
this.createWindows();
}
Scene_ChipShop.prototype.createWindows = function() {
this.window_coinshop = new Window_ChipShop(Graphics.boxWidth/1.5, this.window_coinshopHeight());
this.window_coinshop.x=Graphics.boxWidth/2-this.window_coinshop.width/2;
this.window_coinshop.y=Window_Base.prototype.lineHeight()*5;
this.window_coinDisplay = new Chip_Window();
this.window_coinDisplay.width = 240;
this.window_coinDisplay.height = Window_Base.prototype.lineHeight()*2;
this.window_coinDisplay.y=Graphics.boxHeight-this.window_coinDisplay.height;
this.gold_window = new Window_Gold(0, this.window_coinDisplay.y);
this.gold_window.x = Graphics.boxWidth-this.gold_window.width;
this.fin_window = new Window_CasinoChoice(this.window_coinshop.x, this.window_coinshop.y + this.window_coinshop.height);
this.face_window = new Window_ChipMsg(Window_Base.prototype.lineHeight()*5);
this.fin_window.setHandler('p1', this.changeNum.bind(this, 1));
this.fin_window.setHandler('p10', this.changeNum.bind(this, 10));
this.fin_window.setHandler('m1', this.changeNum.bind(this, -1));
this.fin_window.setHandler('m10', this.changeNum.bind(this, -10));
this.fin_window.setHandler('cancel', this.popScene.bind(this));
this.fin_window.setHandler('fin', this.finishBuy.bind(this));
this.addChild(this.window_coinshop);
this.addChild(this.window_coinDisplay);
this.addChild(this.gold_window);
this.addChild(this.fin_window);
this.addChild(this.face_window);
}
Scene_ChipShop.prototype.window_coinshopHeight = function() {
return Window_Base.prototype.lineHeight()*3;
}
Scene_ChipShop.prototype.finishBuy = function() {
if(this.window_coinshop.chipCount>maxChips-upp_data().chips) { this.window_coinshop.chipCount=maxChips-upp_data().chips; }
upp_data().chips+=this.window_coinshop.chipCount;
$gameParty.loseGold(this.window_coinshop.chipCount*chipCost);
this.popScene();
}
Scene_ChipShop.prototype.changeNum = function(num) {
this.window_coinshop.chipCount+=num;
this.fin_window.activate();
}
Scene_ChipShop.prototype.update = function() {
Scene_MenuBase.prototype.update.call(this);
upp_data().chips=Math.min(Math.max(upp_data().chips, 0), maxChips);
}
})();
* @plugindesc Version: 1.00 | Core plugin for casino games!
* @Author William Ramsey (TheUnproPro)
*
* @param Chip Cost
* @desc How much Gold does it cost per chip?
* @Default 1
*
* @param Max Chips
* @desc What's the max number of Chips you can have?
* @Default 9999
*
* @param Chip Name
* @desc What are Chips called in your game?
* @Default Chips
*
* @param Gold Icon
* @desc What icon is the gold icon?
* @Default 314
*
* @param Mobile Mode
* @desc Use when exporting for touch screen devices.
* @Default false
*
* @param Block Color
* @desc Color of the dark area drawn behind the text.
* @Default 0, 0, 0, 0.5
*
* @Help
* upp_casinoCore is required for all of the casino games. This is basically
* this shop, as well as data management.
*
* There are a few plugin commands you can use.
*
* 1) - upp_setCasinoFace name id - where name is the face name (Example:
* People4) and id is the index.
*
* 2) - upp_setCasinoMsg msg - You can use the same text codes when displaying
* a normal message. You can also use \cn to display
* the name of the casino currency.
*
* 3) - upp_earnChips number - where number is how many you gain. Use -
* before the number to subtract. Example: -50
*
* 4) - upp_openCasinoShop - This opens the casino shop.
*
*/
(function() {
var empty={};
var upp_miniMapCmds = Game_Interpreter.prototype.pluginCommand
Game_Interpreter.prototype.pluginCommand = function(command, args) {
upp_miniMapCmds.apply(this, arguments);
if(command=="upp_openCasinoShop") {
SceneManager.push(Scene_ChipShop);
}
if(command=="upp_setCasinoFace") {
upp_data().casinoFace = args[0];
upp_data().casinoFaceIndex = Number(args[1]);
}
if(command=="upp_earnChips") {
upp_data().chips += Number(args[0]);
if(upp_data().chips>maxChips) {
upp_data().chips = maxChips;
}
}
if(command=="upp_setCasinoMsg") {
var str="";
for(var i=0;i<args.length;i++) {
str += args;
if(i<args.length-1) {
str += " ";
}
}
str = str.replace(/\\cn/g, chipName);
upp_data().casinoMsg = str.replace(/\\n/g, "\n");
}
}
var params = PluginManager.parameters("upp_casinoCore");
var chipName = params['Chip Name'];
var chipCost = Number(params['Chip Cost']);
var goldIcon = Number(params['Gold Icon']);
var mobileMode = (params['Mobile Mode'] == "true" || params['Mobile Mode'] == "false") ? eval(params['Mobile Mode']) : false;
var blockColor = "rgba("+params['Block Color']+")";
var maxChips = Number(params['Max Chips']);
function _upp_data() {
this.extractAlias = function(fun) {
var dmex = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
dmex.apply(this, arguments);
$gameSystem.upp_data = {};
fun.apply(this, arguments);
}
}
}
var upp_data = function() {
if($gameSystem) {
return $gameSystem.upp_data;
} else { return empty }
}
var chips = function() {
return $gameSystem.upp_data;
}
var gameSystemAlias = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
gameSystemAlias.call(this);
this.upp_data = this.upp_data || new _upp_data();
this.upp_data.mobileMode = mobileMode;
this.upp_data.casinoFace = "";
this.upp_data.casinoMsg = "";
this.upp_data.casinoFaceIndex = 0;
this.upp_data.chipName = chipName;
this.upp_data.chips=0;
}
var dmex = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
dmex.apply(this, arguments);
$gameSystem.upp_data = $gameSystem.upp_data || new _upp_data();
}
Window_ChipShop = function() {
this.initialize.apply(this, arguments);
}
Window_ChipShop.prototype = Object.create(Window_Base.prototype);
Window_ChipShop.prototype.constructor = Window_ChipShop;
Window_ChipShop.prototype.initialize = function(width, height) {
Window_Base.prototype.initialize.call(this, 0, 0, width, height);
this.chipCount=0;
this.cos=0;
this.refresh();
}
Window_ChipShop.prototype.refresh = function() {
this.contents.clear();
this.contents.fillRect(0, 0, this.contents.width, this.contents.height, blockColor);
this.contents.drawText("How many "+chipName+" do you want to buy?", 0, 0, this.contents.width, this.lineHeight());
this.contents.drawText("x"+this.chipCount, this.contents.fontSize/2, this.lineHeight(), 50, this.lineHeight(), 'center');
this.contents.drawText(this.chipCount*chipCost, -32-this.padding/2, this.lineHeight(), this.contents.width, this.lineHeight(), 'right');
this.drawIcon(goldIcon, this.contents.width-32, this.lineHeight());
this.contents.drawText("<", -Math.cos(this.cos), this.lineHeight(), 50, this.lineHeight());
this.contents.drawText(">", 50+this.contents.fontSize/2+Math.cos(this.cos), this.lineHeight(), 50, this.lineHeight());
}
Window_ChipShop.prototype.update = function() {
this.cos+=0.1;
if(Input.isRepeated("right") && $gameParty.gold()>this.chipCount*chipCost) {
this.chipCount+=1;
SoundManager.playCursor();
}
if(Input.isRepeated("pagedown") && $gameParty.gold()>this.chipCount*chipCost) {
this.chipCount+=10;
SoundManager.playCursor();
}
if(Input.isRepeated("left") && this.chipCount>0) {
this.chipCount-=1;
SoundManager.playCursor();
}
if(Input.isRepeated("pageup") && this.chipCount>0) {
this.chipCount-=10;
SoundManager.playCursor();
}
this.chipCount = Math.min(Math.max(this.chipCount, 0), $gameParty.gold()/chipCost);
this.refresh();
console.log();
}
Chip_Window = function() {
this.initialize.apply(this, arguments);
}
Chip_Window.prototype = Object.create(Window_Base.prototype);
Chip_Window.prototype.constructor = Chip_Window;
Chip_Window.prototype.initialize = function() {
Window_Base.prototype.initialize.call(this, 0, 0, 240, 256);
this.refresh();
}
Chip_Window.prototype.refresh = function() {
this.contents.clear();
this.changeTextColor(this.systemColor());
this.contents.drawText(chipName, 0, 0, this.contents.width, this.lineHeight());
this.changeTextColor(this.normalColor());
this.contents.drawText(upp_data().chips, 0, 0, this.contents.width, this .lineHeight(), 'right');
}
Chip_Window.prototype.update = function() {
this.refresh();
}
Window_ChipMsg = function() {
this.initialize.apply(this, arguments);
}
Window_ChipMsg.prototype = Object.create(Window_Base.prototype);
Window_ChipMsg.prototype.constructor = Window_ChipMsg;
Window_ChipMsg.prototype.initialize = function(height) {
Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, height);
this.refresh();
}
Window_ChipMsg.prototype.refresh = function() {
this.contents.clear();
this.drawFace(upp_data().casinoFace, upp_data().casinoFaceIndex, 0, 0, 144, 144);
this.drawTextEx(upp_data().casinoMsg, 144, 0);
}
Window_ChipMsg.prototype.update = function() {
this.refresh();
}
function Window_CasinoChoice() {
this.initialize.apply(this, arguments);
}
Window_CasinoChoice.prototype = Object.create(Window_Command.prototype);
Window_CasinoChoice.prototype.constructor = Window_CasinoChoice;
Window_CasinoChoice.prototype.initialize = function(x, y) {
Window_Command.prototype.initialize.call(this, x, y);
}
Window_CasinoChoice.prototype.windowWidth = function() {
return Graphics.boxWidth/1.5;
}
Window_CasinoChoice.prototype.makeCommandList = function() {
if(upp_data().mobileMode == true) {
this.addCommand('+1', 'p1');
this.addCommand('+10', 'p10');
this.addCommand('-1', 'm1');
this.addCommand('-10', 'm10');
}
this.addCommand('Finished', 'fin');
}
Scene_ChipShop = function() {
this.initialize.apply(this, arguments);
}
Scene_ChipShop.prototype = Object.create(Scene_MenuBase.prototype);
Scene_ChipShop.prototype.constructor = Scene_ChipShop;
Scene_ChipShop.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
}
Scene_ChipShop.prototype.start = function() {
this.createWindows();
}
Scene_ChipShop.prototype.createWindows = function() {
this.window_coinshop = new Window_ChipShop(Graphics.boxWidth/1.5, this.window_coinshopHeight());
this.window_coinshop.x=Graphics.boxWidth/2-this.window_coinshop.width/2;
this.window_coinshop.y=Window_Base.prototype.lineHeight()*5;
this.window_coinDisplay = new Chip_Window();
this.window_coinDisplay.width = 240;
this.window_coinDisplay.height = Window_Base.prototype.lineHeight()*2;
this.window_coinDisplay.y=Graphics.boxHeight-this.window_coinDisplay.height;
this.gold_window = new Window_Gold(0, this.window_coinDisplay.y);
this.gold_window.x = Graphics.boxWidth-this.gold_window.width;
this.fin_window = new Window_CasinoChoice(this.window_coinshop.x, this.window_coinshop.y + this.window_coinshop.height);
this.face_window = new Window_ChipMsg(Window_Base.prototype.lineHeight()*5);
this.fin_window.setHandler('p1', this.changeNum.bind(this, 1));
this.fin_window.setHandler('p10', this.changeNum.bind(this, 10));
this.fin_window.setHandler('m1', this.changeNum.bind(this, -1));
this.fin_window.setHandler('m10', this.changeNum.bind(this, -10));
this.fin_window.setHandler('cancel', this.popScene.bind(this));
this.fin_window.setHandler('fin', this.finishBuy.bind(this));
this.addChild(this.window_coinshop);
this.addChild(this.window_coinDisplay);
this.addChild(this.gold_window);
this.addChild(this.fin_window);
this.addChild(this.face_window);
}
Scene_ChipShop.prototype.window_coinshopHeight = function() {
return Window_Base.prototype.lineHeight()*3;
}
Scene_ChipShop.prototype.finishBuy = function() {
if(this.window_coinshop.chipCount>maxChips-upp_data().chips) { this.window_coinshop.chipCount=maxChips-upp_data().chips; }
upp_data().chips+=this.window_coinshop.chipCount;
$gameParty.loseGold(this.window_coinshop.chipCount*chipCost);
this.popScene();
}
Scene_ChipShop.prototype.changeNum = function(num) {
this.window_coinshop.chipCount+=num;
this.fin_window.activate();
}
Scene_ChipShop.prototype.update = function() {
Scene_MenuBase.prototype.update.call(this);
upp_data().chips=Math.min(Math.max(upp_data().chips, 0), maxChips);
}
})();
/*:
* @plugindesc Version: 1.00 | Slot machines! (requires upp_casinoCore)
* @Author William Ramsey (TheUnproPro)
*
* @param Slot Random Sound
* @desc Sound effect when selecting random slots.
* @Default Electrocardiogram
*
* @param Slot Random Pitch
* @desc Sound effect pitch when selecting random slots.
* @Default 100
*
* @param Slot Random Volume
* @desc Sound effect volume when selecting random slots.
* @Default 70
*
* @param Slot Selected Sound
* @desc Sound effect when selecting random slots.
* @Default Reflection
*
* @param Slot Selected Pitch
* @desc Sound effect pitch when selecting random slots.
* @Default 100
*
* @param Slot Selected Volume
* @desc Sound effect volume when selecting random slots.
* @Default 70
*
* @param Ticks
* @desc How many ticks until the slot machine decides to select something?
* @Default 10
*
* @param Speed
* @desc How many frames until it switches the slots?
* @Default 5
*
* @Help
* To increase/decrease odds, you can modify the sprite sheet called upp_slotSprites
* located in the images system folder. Remember though, it's important to make each
* sprite 144x120, just as seen in the sprite sheet. The cherries, watermelon, etc
* are 144x120 each, just lined up in a sprite sheet.
*
* Plugin commands:
* To set up a victory goal, you can use this:
* upp_setSlotsVictory 1 2 3 amount
* - where 1 2 and 3 are the order you need to get. For example, using the default
* image, 0 0 0 would be cherry cherry cherry, since 0 is the first "frame"of the
* image, the cherries. 1 1 1 would be watermelons, etc.
*
* upp_setSlotsPrice Cost
* - where Cost is how much it'll cost to play that slot machine.
*
* upp_startSlots
* - After you're done setting up all of the possible victories, you can then
* start the casino game using this command.
*
*/
(function() {
var params = PluginManager.parameters("upp_casinoSlots");
var sounds = [];
var victories = [];
var speed = Number(params['Speed']);
var ticks=Number(params['Ticks']);
sounds[0] = {
name: params['Slot Random Sound'],
pitch: Number(params['Slot Random Pitch']),
volume: Number(params['Slot Random Volume']),
pan: 0
}
sounds[1] = {
name: params['Slot Selected Sound'],
pitch: Number(params['Slot Selected Pitch']),
volume: Number(params['Slot Selected Volume']),
pan: 0
}
var empty = {};
var sblsi = Scene_Boot.loadSystemImages
Scene_Boot.loadSystemImages = function() {
sblsi.call(this);
ImageManager.loadSystem("upp_slotsFront");
ImageManager.loadSystem("upp_slotsBack");
ImageManager.loadSystem("upp_slotSprites");
}
//{ Standard UPP Settings
var upp_data = function() {
if($gameSystem) {
return $gameSystem.upp_data;
} else { return empty }
}
var Obj = function(name) {
return eval(name + ".prototype");
}
var newObj = function(name, base) {
return eval(
name + ` = function() {
this.initialize.apply(this, arguments);
}
`+name+`.prototype = Object.create(`+base+`.prototype);
`+name+`.prototype.constructor = `+name+`;`
);
}
var Fn = function(obj, name, funct) {
var str=`Obj('`+obj+`').`+name+`=function() {
funct.apply(this, arguments);
}
`;
return eval(str);
}
//}
//{ Commands
var upp_miniMapCmds = Game_Interpreter.prototype.pluginCommand
Game_Interpreter.prototype.pluginCommand = function(command, args) {
upp_miniMapCmds.apply(this, arguments);
if(command=="upp_startSlots") {
SceneManager.push(Scene_UppSlots);
}
if(command=="upp_setSlotsVictory") {
victories.push({
s1: Number(args[0]),
s2: Number(args[1]),
s3: Number(args[2]),
win: Number(args[3])
});
}
if(command=="upp_setSlotsPrice") {
slotCost = Number(args[0]);
}
}
var slotCost=0;
var slotMsg = "";
var slotWin = "";
var slotLose = "";
//}
//{Windows
newObj("Dummy_Window", "Window_Base"); //{
Fn("Dummy_Window", "initialize", function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, x, y, width, height);
});
//}
newObj("Window_SlotGraphics", "Window_Base"); //{
Fn("Window_SlotGraphics", "initialize", function() {
Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, Graphics.boxHeight);
this.opacity=0;
this.slot_id = [];
this.timer=0;
this.ticks=0;
this.started=false;
this.finished=false;
this.win=false;
this.winAmount = 0;
this.refresh();
});
Window_SlotGraphics.prototype.standardPadding = function() {
return 0;
}
Fn("Window_SlotGraphics", "refresh", function() {
this.contents.clear();
this.pad = Window_Base.prototype.standardPadding();
this.contents.blt(ImageManager.loadSystem('upp_slotsBack'), 0, 0, 816, 624, 0, 0);
this.contents.blt(ImageManager.loadSystem('upp_slotsFront'), 0, 0, 816, 624, 0, 0);
if(this.started==false) {
this.drawTextEx("Cost \\c[2]" + slotCost + " " + upp_data().chipName + "\\c[0] for 1 spin.\nDo you want to play?", this.pad, this.pad+Graphics.boxHeight-this.lineHeight()*3, this.contents.width, this.lineHeight());
}
if(this.started==true) {
this.updateSlots();
if(this.finished==true) {
if(this.win==true) {
this.drawTextEx("You won " + this.winAmount + " " + upp_data().chipName + "\n�Want to play again?", this.pad, this.pad+Graphics.boxHeight-this.lineHeight()*3, this.contents.width, this.lineHeight());
} else {
this.drawTextEx("No win... \nTry again?", this.pad, this.pad+Graphics.boxHeight-this.lineHeight()*3, this.contents.width, this.lineHeight());
}
}
}
});
Fn("Window_SlotGraphics", "update", function() {
this.refresh();
});
Fn("Window_SlotGraphics", "updateSlots", function() {
var bitmap=ImageManager.loadSystem("upp_slotSprites");
if(this.timer==speed && this.finished==false) {
if(this.ticks<ticks) {
this.slot_id[0] = Math.floor(Math.random()*(bitmap.width/144));
}
if(this.ticks<ticks*2) {
this.slot_id[1] = Math.floor(Math.random()*(bitmap.width/144));
}
if(this.ticks<ticks*3) {
this.slot_id[2] = Math.floor(Math.random()*(bitmap.width/144));
}
if(this.ticks==ticks || this.ticks==ticks*2 || this.ticks==ticks*3) {
AudioManager.playSe(sounds[1]);
}
this.timer = 0;
this.ticks+=1;
if(this.ticks<ticks*3) {
AudioManager.playSe(sounds[0]);
}
if(this.ticks>=ticks*3+1) {
this.finished=true;
for(var i=0;i<victories.length;i++) {
if(this.slot_id[0] == victories.s1 && this.slot_id[1] == victories.s2 && this.slot_id[2] == victories.s3) {
upp_data().chips+=victories.win;
this.winAmount = victories.win;
this.win=true;
}
}
}
}
this.timer+=1;
this.contents.blt(bitmap, this.slot_id[0]*144, 0, 144, 120, 132, 252);
this.contents.blt(bitmap, this.slot_id[1]*144, 0, 144, 120, 336, 252);
this.contents.blt(bitmap, this.slot_id[2]*144, 0, 144, 120, 540, 252);
});
//}
newObj("Window_SlotChoice", "Window_Command"); //{
Fn("Window_SlotChoice", "initialize", function(x, y) {
Window_Command.prototype.initialize.call(this, x, y);
this.opacity = 0;
});
Fn("Window_SlotChoice", "makeCommandList", function() {
var enabled = false;
if(upp_data().chips>=slotCost) {
enabled = true;
}
this.addCommand("Yes", 'yes', enabled);
this.addCommand("No", 'no');
});
//}
Chip_Window = function() {
this.initialize.apply(this, arguments);
}
Chip_Window.prototype = Object.create(Window_Base.prototype);
Chip_Window.prototype.constructor = Chip_Window;
Chip_Window.prototype.initialize = function() {
Window_Base.prototype.initialize.call(this, 0, 0, 240, 256);
this.refresh();
}
Chip_Window.prototype.refresh = function() {
this.contents.clear();
this.changeTextColor(this.systemColor());
this.contents.drawText(upp_data().chipName, 0, 0, this.contents.width, this.lineHeight());
this.changeTextColor(this.normalColor());
this.contents.drawText(upp_data().chips, 0, 0, this.contents.width, this .lineHeight(), 'right');
}
Chip_Window.prototype.update = function() {
this.refresh();
}
//}
//{ Scenes
Scene_UppSlots = function() {
this.initialize.apply(this, arguments);
}
Scene_UppSlots.prototype = Object.create(Scene_MenuBase.prototype);
Scene_UppSlots.prototype.constructor = Scene_UppSlots;
Scene_UppSlots.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
this.ready=false;
}
Scene_UppSlots.prototype.start = function() {
this.dummyWindow = new Dummy_Window(0, Graphics.boxHeight-(Window_Base.prototype.lineHeight()*3), Graphics.boxWidth, Window_Base.prototype.lineHeight()*3);
this.win = new Window_SlotGraphics();
this.winChoice = new Window_SlotChoice(Graphics.boxWidth-240, Graphics.boxHeight-(Window_Base.prototype.lineHeight()*3));
this.winChoice.setHandler('yes', this.yes.bind(this));
this.winChoice.setHandler('no', this.close.bind(this));
this.winChoice.setHandler('cancel', this.close.bind(this));
this.addChild(this.dummyWindow);
this.addChild(this.win);
this.addChild(this.winChoice);
this.chipWindow = new Chip_Window();
this.chipWindow.width = 240;
this.chipWindow.height = Window_Base.prototype.lineHeight()*2;
this.chipWindow.y=this.dummyWindow.y-this.chipWindow.height;
this.chipWindow.x=Graphics.boxWidth-this.chipWindow.width;
this.addChild(this.chipWindow);
}
Scene_UppSlots.prototype.close = function() {
victories.splice(0, victories.length);
this.popScene();
}
Scene_UppSlots.prototype.yes = function() {
upp_data().chips-=slotCost;
this.win.win=false;
this.win.finished=false;
this.win.ticks=0;
this.win.timer=0;
this.win.winAmount=0;
this.win.started=true;
this.winChoice.hide();
this.winChoice.deactivate();
this.dummyWindow.hide();
this.ready=true;
}
Scene_UppSlots.prototype.update = function() {
Scene_MenuBase.prototype.update.call(this);
if(this.win.finished==true) {
this.winChoice.show();
this.winChoice.activate();
this.dummyWindow.show();
this.ready=false;
}
if(upp_data().chips<slotCost) {
this.winChoice._list[0].enabled = false;
} else {
this.winChoice._list[0].enabled = true;
}
this.winChoice.refresh();
if(this.ready==false) {
this.chipWindow.y=this.dummyWindow.y-this.chipWindow.height;
} else {
this.chipWindow.y=Graphics.boxHeight-this.chipWindow.height;
}
}
//}
})();
* @plugindesc Version: 1.00 | Slot machines! (requires upp_casinoCore)
* @Author William Ramsey (TheUnproPro)
*
* @param Slot Random Sound
* @desc Sound effect when selecting random slots.
* @Default Electrocardiogram
*
* @param Slot Random Pitch
* @desc Sound effect pitch when selecting random slots.
* @Default 100
*
* @param Slot Random Volume
* @desc Sound effect volume when selecting random slots.
* @Default 70
*
* @param Slot Selected Sound
* @desc Sound effect when selecting random slots.
* @Default Reflection
*
* @param Slot Selected Pitch
* @desc Sound effect pitch when selecting random slots.
* @Default 100
*
* @param Slot Selected Volume
* @desc Sound effect volume when selecting random slots.
* @Default 70
*
* @param Ticks
* @desc How many ticks until the slot machine decides to select something?
* @Default 10
*
* @param Speed
* @desc How many frames until it switches the slots?
* @Default 5
*
* @Help
* To increase/decrease odds, you can modify the sprite sheet called upp_slotSprites
* located in the images system folder. Remember though, it's important to make each
* sprite 144x120, just as seen in the sprite sheet. The cherries, watermelon, etc
* are 144x120 each, just lined up in a sprite sheet.
*
* Plugin commands:
* To set up a victory goal, you can use this:
* upp_setSlotsVictory 1 2 3 amount
* - where 1 2 and 3 are the order you need to get. For example, using the default
* image, 0 0 0 would be cherry cherry cherry, since 0 is the first "frame"of the
* image, the cherries. 1 1 1 would be watermelons, etc.
*
* upp_setSlotsPrice Cost
* - where Cost is how much it'll cost to play that slot machine.
*
* upp_startSlots
* - After you're done setting up all of the possible victories, you can then
* start the casino game using this command.
*
*/
(function() {
var params = PluginManager.parameters("upp_casinoSlots");
var sounds = [];
var victories = [];
var speed = Number(params['Speed']);
var ticks=Number(params['Ticks']);
sounds[0] = {
name: params['Slot Random Sound'],
pitch: Number(params['Slot Random Pitch']),
volume: Number(params['Slot Random Volume']),
pan: 0
}
sounds[1] = {
name: params['Slot Selected Sound'],
pitch: Number(params['Slot Selected Pitch']),
volume: Number(params['Slot Selected Volume']),
pan: 0
}
var empty = {};
var sblsi = Scene_Boot.loadSystemImages
Scene_Boot.loadSystemImages = function() {
sblsi.call(this);
ImageManager.loadSystem("upp_slotsFront");
ImageManager.loadSystem("upp_slotsBack");
ImageManager.loadSystem("upp_slotSprites");
}
//{ Standard UPP Settings
var upp_data = function() {
if($gameSystem) {
return $gameSystem.upp_data;
} else { return empty }
}
var Obj = function(name) {
return eval(name + ".prototype");
}
var newObj = function(name, base) {
return eval(
name + ` = function() {
this.initialize.apply(this, arguments);
}
`+name+`.prototype = Object.create(`+base+`.prototype);
`+name+`.prototype.constructor = `+name+`;`
);
}
var Fn = function(obj, name, funct) {
var str=`Obj('`+obj+`').`+name+`=function() {
funct.apply(this, arguments);
}
`;
return eval(str);
}
//}
//{ Commands
var upp_miniMapCmds = Game_Interpreter.prototype.pluginCommand
Game_Interpreter.prototype.pluginCommand = function(command, args) {
upp_miniMapCmds.apply(this, arguments);
if(command=="upp_startSlots") {
SceneManager.push(Scene_UppSlots);
}
if(command=="upp_setSlotsVictory") {
victories.push({
s1: Number(args[0]),
s2: Number(args[1]),
s3: Number(args[2]),
win: Number(args[3])
});
}
if(command=="upp_setSlotsPrice") {
slotCost = Number(args[0]);
}
}
var slotCost=0;
var slotMsg = "";
var slotWin = "";
var slotLose = "";
//}
//{Windows
newObj("Dummy_Window", "Window_Base"); //{
Fn("Dummy_Window", "initialize", function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, x, y, width, height);
});
//}
newObj("Window_SlotGraphics", "Window_Base"); //{
Fn("Window_SlotGraphics", "initialize", function() {
Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, Graphics.boxHeight);
this.opacity=0;
this.slot_id = [];
this.timer=0;
this.ticks=0;
this.started=false;
this.finished=false;
this.win=false;
this.winAmount = 0;
this.refresh();
});
Window_SlotGraphics.prototype.standardPadding = function() {
return 0;
}
Fn("Window_SlotGraphics", "refresh", function() {
this.contents.clear();
this.pad = Window_Base.prototype.standardPadding();
this.contents.blt(ImageManager.loadSystem('upp_slotsBack'), 0, 0, 816, 624, 0, 0);
this.contents.blt(ImageManager.loadSystem('upp_slotsFront'), 0, 0, 816, 624, 0, 0);
if(this.started==false) {
this.drawTextEx("Cost \\c[2]" + slotCost + " " + upp_data().chipName + "\\c[0] for 1 spin.\nDo you want to play?", this.pad, this.pad+Graphics.boxHeight-this.lineHeight()*3, this.contents.width, this.lineHeight());
}
if(this.started==true) {
this.updateSlots();
if(this.finished==true) {
if(this.win==true) {
this.drawTextEx("You won " + this.winAmount + " " + upp_data().chipName + "\n�Want to play again?", this.pad, this.pad+Graphics.boxHeight-this.lineHeight()*3, this.contents.width, this.lineHeight());
} else {
this.drawTextEx("No win... \nTry again?", this.pad, this.pad+Graphics.boxHeight-this.lineHeight()*3, this.contents.width, this.lineHeight());
}
}
}
});
Fn("Window_SlotGraphics", "update", function() {
this.refresh();
});
Fn("Window_SlotGraphics", "updateSlots", function() {
var bitmap=ImageManager.loadSystem("upp_slotSprites");
if(this.timer==speed && this.finished==false) {
if(this.ticks<ticks) {
this.slot_id[0] = Math.floor(Math.random()*(bitmap.width/144));
}
if(this.ticks<ticks*2) {
this.slot_id[1] = Math.floor(Math.random()*(bitmap.width/144));
}
if(this.ticks<ticks*3) {
this.slot_id[2] = Math.floor(Math.random()*(bitmap.width/144));
}
if(this.ticks==ticks || this.ticks==ticks*2 || this.ticks==ticks*3) {
AudioManager.playSe(sounds[1]);
}
this.timer = 0;
this.ticks+=1;
if(this.ticks<ticks*3) {
AudioManager.playSe(sounds[0]);
}
if(this.ticks>=ticks*3+1) {
this.finished=true;
for(var i=0;i<victories.length;i++) {
if(this.slot_id[0] == victories.s1 && this.slot_id[1] == victories.s2 && this.slot_id[2] == victories.s3) {
upp_data().chips+=victories.win;
this.winAmount = victories.win;
this.win=true;
}
}
}
}
this.timer+=1;
this.contents.blt(bitmap, this.slot_id[0]*144, 0, 144, 120, 132, 252);
this.contents.blt(bitmap, this.slot_id[1]*144, 0, 144, 120, 336, 252);
this.contents.blt(bitmap, this.slot_id[2]*144, 0, 144, 120, 540, 252);
});
//}
newObj("Window_SlotChoice", "Window_Command"); //{
Fn("Window_SlotChoice", "initialize", function(x, y) {
Window_Command.prototype.initialize.call(this, x, y);
this.opacity = 0;
});
Fn("Window_SlotChoice", "makeCommandList", function() {
var enabled = false;
if(upp_data().chips>=slotCost) {
enabled = true;
}
this.addCommand("Yes", 'yes', enabled);
this.addCommand("No", 'no');
});
//}
Chip_Window = function() {
this.initialize.apply(this, arguments);
}
Chip_Window.prototype = Object.create(Window_Base.prototype);
Chip_Window.prototype.constructor = Chip_Window;
Chip_Window.prototype.initialize = function() {
Window_Base.prototype.initialize.call(this, 0, 0, 240, 256);
this.refresh();
}
Chip_Window.prototype.refresh = function() {
this.contents.clear();
this.changeTextColor(this.systemColor());
this.contents.drawText(upp_data().chipName, 0, 0, this.contents.width, this.lineHeight());
this.changeTextColor(this.normalColor());
this.contents.drawText(upp_data().chips, 0, 0, this.contents.width, this .lineHeight(), 'right');
}
Chip_Window.prototype.update = function() {
this.refresh();
}
//}
//{ Scenes
Scene_UppSlots = function() {
this.initialize.apply(this, arguments);
}
Scene_UppSlots.prototype = Object.create(Scene_MenuBase.prototype);
Scene_UppSlots.prototype.constructor = Scene_UppSlots;
Scene_UppSlots.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
this.ready=false;
}
Scene_UppSlots.prototype.start = function() {
this.dummyWindow = new Dummy_Window(0, Graphics.boxHeight-(Window_Base.prototype.lineHeight()*3), Graphics.boxWidth, Window_Base.prototype.lineHeight()*3);
this.win = new Window_SlotGraphics();
this.winChoice = new Window_SlotChoice(Graphics.boxWidth-240, Graphics.boxHeight-(Window_Base.prototype.lineHeight()*3));
this.winChoice.setHandler('yes', this.yes.bind(this));
this.winChoice.setHandler('no', this.close.bind(this));
this.winChoice.setHandler('cancel', this.close.bind(this));
this.addChild(this.dummyWindow);
this.addChild(this.win);
this.addChild(this.winChoice);
this.chipWindow = new Chip_Window();
this.chipWindow.width = 240;
this.chipWindow.height = Window_Base.prototype.lineHeight()*2;
this.chipWindow.y=this.dummyWindow.y-this.chipWindow.height;
this.chipWindow.x=Graphics.boxWidth-this.chipWindow.width;
this.addChild(this.chipWindow);
}
Scene_UppSlots.prototype.close = function() {
victories.splice(0, victories.length);
this.popScene();
}
Scene_UppSlots.prototype.yes = function() {
upp_data().chips-=slotCost;
this.win.win=false;
this.win.finished=false;
this.win.ticks=0;
this.win.timer=0;
this.win.winAmount=0;
this.win.started=true;
this.winChoice.hide();
this.winChoice.deactivate();
this.dummyWindow.hide();
this.ready=true;
}
Scene_UppSlots.prototype.update = function() {
Scene_MenuBase.prototype.update.call(this);
if(this.win.finished==true) {
this.winChoice.show();
this.winChoice.activate();
this.dummyWindow.show();
this.ready=false;
}
if(upp_data().chips<slotCost) {
this.winChoice._list[0].enabled = false;
} else {
this.winChoice._list[0].enabled = true;
}
this.winChoice.refresh();
if(this.ready==false) {
this.chipWindow.y=this.dummyWindow.y-this.chipWindow.height;
} else {
this.chipWindow.y=Graphics.boxHeight-this.chipWindow.height;
}
}
//}
})();
EDIT: Link to the plugins:
I'm grateful for any help 🙂.
