Hello, long time no see, right? Anyway, I found a way to store tiles in an array struct to form the fossil rocks and the fossils inside for my RPG Maker MZ Love letter to the Fossil Fighters series, Dragon Bones. All I need to know is how you draw them from an array struct using a JS Draw Code. I plan to do it similarly to how the CCG Plugin was programmed. In this case, I plan to use notes created directly from my plugin.
Below is the code I'm currently using for the plugin, credit goes to ct_bolt for giving me the template to help me get started.
Below is a sample image of a fossil Rock I created in Krita if you need an example to work from:
Plus the fossil tiles:
You will need to create certain folders in the img folder: fossils and rocks respectively.
Thank you in advance.
Below is the code I'm currently using for the plugin, credit goes to ct_bolt for giving me the template to help me get started.
JavaScript:
//=============================================================================
// RPG Maker MZ - GreenTree Studios' Fossil Cleaning Core Plugin
//=============================================================================
/*~struct~BGM:
* @param name
* @text Filename
* @type file
* @dir audio/bgm/
* @default
*
* @param volume
* @text Volume
* @type number
* @default 90
*
* @param pitch
* @text Pitch
* @type number
* @default 100
*
* @param pan
* @text Pan
* @type number
* @default 0
*
*/
/*~struct~RockTemplate:
* @param rockImages
* @text Rock Graphics
* @default
*
* @param Layer1
* @text Top Layer
* @parent rockImages
* @type file
* @dir img/rocks
* @desc Tileset for the top layer of the fossil rock
*
* @param Layer2
* @text Middle Layer
* @parent rockImages
* @type file
* @dir img/rocks
* @desc Tileset for the middle layer of the fossil rock
*
* @param Layer3
* @text Bottom Layer
* @parent rockImages
* @type file
* @dir img/rocks
* @desc Tileset for the bottom layer of the fossil rock
*
* @param RockDrawCode:func
* @text JS: Rock Draw Code
* @type note
* @desc Code used to draw coordinates on the rock tiles.
*/
/*:
* @target MZ
* @plugindesc [RPG Maker MZ] [Tier 1] [Version 1.00] [GT_Studios - Fossil Cleaning Core]
* @author GT_Studios
* @url https://greentree-studios.itch.io/
*
* @param RockTemplates:ArrayStruct
* @text Rock Shapes
* @type struct<RockTemplate>[]
* @desc A list of the templates used for the rock layers and how they are visibly drawn.
*
* @param Templates:ArrayStruct
* @text Fossil Templates
* @type struct<FossilTemplate>[]
* @desc A list of the templates used for the fossils and how they are visibly drawn.
*
* @param BGM
* @text Default BGM
* @type struct<BGM>
* @desc Default BGM (Optional)
* @default
*
* @param HoleMaskTile
* @text Hole Mask Tileset
* @type file
* @dir img/layers/
* @desc the tileset used to mask out the layers, thus making holes.
*
* @param TimeAmount
* @text Timer
* @type number
* @desc The Time Limit (in seconds)
* @default 120
*
* @param cleaningBackground
* @text Cleaning Background
* @type file
* @dir img/cleaningbackground/
* @desc The background graphic for the cleaning scene.
* @default Cleaning_BKG
*/
/*~struct~FossilTemplate:
* @param Name:str
* @text Name
* @desc The name of this template. Used in code, too.
* @default None
*
* @param FossilTiles
* @text Fossil Graphics
*
* @param HeadFossilTiles:str
* @text Head
* @parent FossilTiles
* @type file
* @dir img/fossils
* @desc Tileset file for the head fossil
* @default
*
* @param HeadRockID:num
* @text Rock Shape
* @parent HeadFossilTiles:str
* @type number
* @desc Fossil Rock Shape ID (Head)
* @default 1
*
* @param FossilHeadDamageLayer:str
* @text Damage Layer (Head)
* @parent HeadFossilTiles:str
* @type file
* @dir img/fossils
* @desc Fossil Damage Layer (Head)
* @default
*
* @param BodyFossilTiles:str
* @text Body
* @parent FossilTiles
* @type file
* @dir img/fossils
* @desc Tileset file for the body fossil
* @default
*
* @param BodyRockID:num
* @text Rock Shape
* @parent BodyFossilTiles:str
* @type number
* @desc Fossil Rock Shape ID (Body)
* @default 1
*
* @param FossilBodyDamageLayer:str
* @text Damage Layer (Body)
* @parent BodyFossilTiles:str
* @type file
* @dir img/fossils
* @desc Fossil Damage Layer (Body)
* @default
*
* @param ArmsFossilTiles:str
* @text Arms
* @parent FossilTiles
* @type file
* @dir img/fossils
* @desc Tileset file for the arm fossils
* @default
*
* @param ArmsRockID:num
* @text Rock Shape
* @parent ArmsFossilTiles:str
* @type number
* @desc Fossil Rock Shape ID (Arms)
* @default 1
*
* @param LegsFossilTiles:str
* @text Legs
* @parent FossilTiles
* @type file
* @dir img/fossils
* @desc Tileset file for the leg fossils
* @default
*
* @param LegsRockID:num
* @text Rock Shape
* @parent LegsFossilTiles:str
* @type number
* @desc Fossil Rock Shape ID (Legs)
* @default 1
*
* @param TailFossilTiles:str
* @text Tail
* @parent FossilTiles
* @type file
* @dir img/fossils
* @desc Tileset file for the tail fossil
* @default
*
* @param TailRockID:num
* @text Rock Shape
* @parent TailFossilTiles:str
* @type number
* @desc Fossil Rock Shape ID (Tail)
* @default 1
*
* @param FullBodyFossilTiles:str
* @text Full Body
* @parent FossilTiles
* @type file
* @dir img/fossils
* @desc Tileset file for the full body fossil
* @default
*
* @param FullBodyRockID:num
* @text Rock Shape
* @parent FullBodyFossilTiles:str
* @type number
* @desc Fossil Rock Shape ID (Full Body)
* @default 1
*
* @param FossilDrawCode:func
* @text JS: Fossil Draw Code
* @type note
* @desc Code used to draw coordinates on the fossil rock tiles.
*/
var GTS = GTS || {}; GTS.FossilCleaning = GTS.FossilCleaning || {};
var Imported = Imported || {}; Imported["GreenTreeStudios_FossilCleaning"] = 1.00;
(($_$) => {
const NAMESPACE = 'FossilCleaning';
const PLUGIN_NAME = 'GTS_' + NAMESPACE;
function getPluginParameters() {var a = document.currentScript || (function() { var b = document.getElementsByTagName('script'); return b[b.length - 1]; })(); return PluginManager.parameters(a.src.substring((a.src.lastIndexOf('/') + 1), a.src.indexOf('.js')));} $_$.params = getPluginParameters();
['BGM'].forEach(function(v){
$_$.params[v] = $_$.params[v] || '""';
$_$.params[v] = JSON.parse($_$.params[v]);
});
$_$.bgm = $_$.params['BGM'];
$_$.fossilRock = $_$.params['RockTemplates:ArrayStruct'];
$_$.rockDrawCode = $_$.params['RockDrawCode:func'];
$_$.fossil = $_$.params['Templates:ArrayStruct'];
$_$.fossilDrawCode = $_$.params['FossilDrawCode:func'];
$_$.holeTiles = $_$.params['HoleMaskTile'];
$_$.cleaningIMG = $_$.params['cleaningBackground'];
//-----------------------------------------------------------------------------
// FossilCleaningManager
//
// The static class that assists with the Slot Game progress.
function FossilCleaningManager() {
throw new Error("This is a static class");
}
FossilCleaningManager.setup = function() {
};
FossilCleaningManager.saveBgmAndBgs = function() {
this._mapBgm = AudioManager.saveBgm();
this._mapBgs = AudioManager.saveBgs();
};
FossilCleaningManager.replayBgmAndBgs = function() {
if (this._mapBgm) {
AudioManager.replayBgm(this._mapBgm);
} else {
AudioManager.stopBgm();
}
if (this._mapBgs) {
AudioManager.replayBgs(this._mapBgs);
}
};
FossilCleaningManager.playBgm = function(audio) {
audio = audio || $_$.bgm || {};
console.log(audio);
AudioManager.playBgm(audio);
AudioManager.stopBgs();
};
FossilCleaningManager.stopAudioOnStart = function(audio) {
audio = audio || GTS.FossilCleaning.bgm || {};
if (!AudioManager.isCurrentBgm(audio)) {
AudioManager.stopBgm();
};
AudioManager.stopBgs();
AudioManager.stopMe();
AudioManager.stopSe();
};
//-----------------------------------------------------------------------------
// FossilDamageSprite
//
function FossilDamageSprite() {
this.initialize.apply(this, arguments);
}
FossilDamageSprite.prototype = Object.create(Sprite.prototype);
FossilDamageSprite.prototype.constructor = FossilDamageSprite;
FossilDamageSprite.prototype.initialize = function (bitmap) {
Sprite.prototype.initialize.call(this, bitmap);
};
//-----------------------------------------------------------------------------
// CleaningBackgroundSprite
//
function CleaningBackgroundSprite() {
this.initialize.apply(this, arguments);
}
CleaningBackgroundSprite.prototype = Object.create(Sprite.prototype);
CleaningBackgroundSprite.prototype.constructor = CleaningBackgroundSprite;
CleaningBackgroundSprite.prototype.initialize = function (bitmap) {
Sprite.prototype.initialize.call(this, bitmap);
};
//-----------------------------------------------------------------------------
// FossilSprite
//
function FossilSprite() {
this.initialize.apply(this, arguments);
}
FossilSprite.prototype = Object.create(Sprite.prototype);
FossilSprite.prototype.constructor = FossilSprite;
FossilSprite.prototype.initialize = function (bitmap) {
Sprite.prototype.initialize.call(this, bitmap);
};
//-----------------------------------------------------------------------------
// RockSprite
//
function RockSprite() {
this.initialize.apply(this, arguments);
}
RockSprite.prototype = Object.create(Sprite.prototype);
RockSprite.prototype.constructor = RockSprite;
RockSprite.prototype.initialize = function (bitmap) {
Sprite.prototype.initialize.call(this, bitmap);
};
//------------------------------------------------------------------------------
// Scene FossilCleaning
//
function Scene_FossilCleaning() {
this.initialize(...arguments);
}
Scene_FossilCleaning.prototype = Object.create(Scene_MenuBase.prototype);
Scene_FossilCleaning.prototype.constructor = Scene_FossilCleaning;
$_$['Scene_FossilCleaning.prototype.isReady'] = Scene_FossilCleaning.prototype.isReady;
Scene_FossilCleaning.prototype.isReady = function() {
return $_$['Scene_FossilCleaning.prototype.isReady'].apply(this, arguments) && this._imagesLoaded >= this._imagesLoadCount;
};
Scene_FossilCleaning.prototype.imageLoaded = function () {
this._imagesLoaded++;
};
Scene_FossilCleaning.prototype.initialize = function () {
this._imagesLoaded = 0;
this._imagesLoadCount = 2;
$_$._cleaningBackgroundBitmap = ImageManager.loadBitmap($_$.cleaningIMG);
$_$._cleaningBackgroundBitmap.addLoadListener(this.imageLoaded.bind(this));
$_$._fossilBitmap = ImageManager.loadBitmap();
$_$._fossilBitmap.addLoadListener(this.imageLoaded.bind(this));
$_$._rockBitmap = ImageManager.loadBitmap();
$_$._rockBitmap.addLoadListener(this.imageLoaded.bind(this));
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_FossilCleaning.prototype.create = function () {
this.createBackground();
this.createFossil();
this.createRock();
};
Scene_FossilCleaning.prototype.createBackground = function () {
this._backgroundSprite = new CleaningBackgroundSprite($_$._cleaningBackgroundBitmap);
this.addChild(this._backgroundSprite);
};
Scene_FossilCleaning.prototype.createFossil = function() {
this._fossilPieces = [];
// sprite settings
const cellSize = 24;
const cols = $_$._fossilBitmap.width / cellSize;
const rows = $_$._fossilBitmap.height / cellSize;
for (var i = 0; i < cols*rows; i++) {
var row = Math.floor(i / cols);
var col = i % cols;
this._fossilPieces[i] = new FossilSprite($_$._fossilBitmap);
this._fossilPieces[i].setFrame(col*cellSize, row*cellSize, cellSize, cellSize);
this._fossilPieces[i].x = col * cellSize;
this._fossilPieces[i].y = row * cellSize;
this._fossilPieces[i].visible = false;
this.addChild(this._fossilPieces[i]);
};
}
Scene_FossilCleaning.prototype.createRock = function() {
this._rockPieces = [];
// sprite settings
const cellSize = 24;
const cols = $_$._rockBitmap.width / cellSize;
const rows = $_$._rockBitmap.height / cellSize;
for (var i = 0; i < cols*rows; i++) {
var row = Math.floor(i / cols);
var col = i % cols;
this._rockPieces[i] = new RockSprite($_$._rockBitmap);
this._rockPieces[i].setFrame(col*cellSize, row*cellSize, cellSize, cellSize);
this._rockPieces[i].x = col * cellSize;
this._rockPieces[i].y = row * cellSize;
this._rockPieces[i].visible = false;
this.addChild(this._rockPieces[i]);
}
};
//-----------------------------------------------------------------------------
// GTS.FossilsMZ
//-----------------------------------------------------------------------------
GTS.FossilCleaning.Play = function(){
FossilCleaningManager.saveBgmAndBgs();
FossilCleaningManager.stopAudioOnStart();
SceneManager.push(Scene_FossilCleaning);
};
})(GTS.FossilCleaning, this);
Below is a sample image of a fossil Rock I created in Krita if you need an example to work from:
Plus the fossil tiles:
You will need to create certain folders in the img folder: fossils and rocks respectively.
Thank you in advance.