Yanfly Engine Plugins is a plugin library made for RPG Maker MV, a wonderful piece of software to help you make that role playing game of your dreams. You can find out more about RPG Maker MV here.
You can grab the plugin here:
Event Copier
Self Switches & Variables
Call Event
Gab Window
Support Team Yanfly on Patreon
—
Eventing a mining system can be done a number of ways, but making the mining system efficient is a different story altogether. Here is one of the many ways you can tackle a mining system for your RPG Maker project!
You can grab the copy/paste code here:
For those who would like to get the code used for the script call, copy and paste the code here. Change the values in red to fit your game’s settings.
// This is the item ID set by variable 1. var itemId = $gameVariables.value(1); // Get the item that uses the item ID. var item = $dataItems[itemId]; // Get the total number of items mined. var total = $gameVariables.value(2); // Grant the party the total number of items. $gameParty.gainItem(item, total);
For those who would like to see how the events are structured from the video, look below!
Coal Vein – Basic Event
Page 1: Trigger > Parallel Process
◆Comment:// Determine this mineral vein's yield ◆Control Variables:#0043 Self Var Vein Yield = Random 20..25 ◆Comment:// Set a self switch to indicate this even is initialized ◆Control Self Switch:A = ON
Page 2: Conditions > Self Variable >= 0, Self Switch A; Trigger > Parallel Process
◆Comment:// If this mineral vein is empty, wait a bit before :Comment:setting its location to the corner of the map and :Comment:then erasing it. ◆Wait:60 frames ◆Set Event Location:This Event, (0,0) ◆Erase Event
Page 3: Conditions > Self Variable >= 1, Self Switch A; Trigger > Action Button
◆Comment:// Variable 1: Determine item to be received. :Comment: Insert item ID into this variable. ◆Control Variables:#0001 Temp Variable 1 = 51 ◆Comment:// Run the mining common event. ◆Common Event:Mining Prompt
Page 4: Conditions > Self Variable >= 5, Self Switch A; Trigger > Action Button
◆Comment:// Call this event's page 3 event list. ◆Plugin Command:CallEvent 1, Map 8, Page 3
Page 5: Conditions > Self Variable >= 10, Self Switch A; Trigger > Action Button
◆Comment:// Call this event's page 3 event list. ◆Plugin Command:CallEvent 1, Map 8, Page 3
And that’s it for the Coal Vein event!
Copper Vein – Basic Event
Page 1: Trigger > Parallel Process
◆Comment:// Determine this mineral vein's yield ◆Control Variables:#0043 Self Var Vein Yield = Random 15..20 ◆Comment:// Set a self switch to indicate this even is initialized ◆Control Self Switch:A = ON
Page 2: Conditions > Self Variable >= 0, Self Switch A; Trigger > Parallel Process
◆Comment:// If this mineral vein is empty, wait a bit before :Comment:setting its location to the corner of the map and :Comment:then erasing it. ◆Wait:60 frames ◆Set Event Location:This Event, (0,0) ◆Erase Event
Page 3: Conditions > Self Variable >= 1, Self Switch A; Trigger > Action Button
◆Comment:// Variable 1: Determine item to be received. :Comment: Insert item ID into this variable. ◆Control Variables:#0001 Temp Variable 1 = 52 ◆Comment:// Run the mining common event. ◆Common Event:Mining Prompt
Page 4: Conditions > Self Variable >= 5, Self Switch A; Trigger > Action Button
◆Comment:// Call this event's page 3 event list. ◆Plugin Command:CallEvent 2, Map 8, Page 3
Page 5: Conditions > Self Variable >= 10, Self Switch A; Trigger > Action Button
◆Comment:// Call this event's page 3 event list. ◆Plugin Command:CallEvent 2, Map 8, Page 3
And that’s it for the Copper Vein event!
Iron Vein – Basic Event
Page 1: Trigger > Parallel Process
◆Comment:// Determine this mineral vein's yield ◆Control Variables:#0043 Self Var Vein Yield = Random 10..15 ◆Comment:// Set a self switch to indicate this even is initialized ◆Control Self Switch:A = ON
Page 2: Conditions > Self Variable >= 0, Self Switch A; Trigger > Parallel Process
◆Comment:// If this mineral vein is empty, wait a bit before :Comment:setting its location to the corner of the map and :Comment:then erasing it. ◆Wait:60 frames ◆Set Event Location:This Event, (0,0) ◆Erase Event
Page 3: Conditions > Self Variable >= 1, Self Switch A; Trigger > Action Button
◆Comment:// Variable 1: Determine item to be received. :Comment: Insert item ID into this variable. ◆Control Variables:#0001 Temp Variable 1 = 53 ◆Comment:// Run the mining common event. ◆Common Event:Mining Prompt
Page 4: Conditions > Self Variable >= 5, Self Switch A; Trigger > Action Button
◆Comment:// Call this event's page 3 event list. ◆Plugin Command:CallEvent 3, Map 8, Page 3
Page 5: Conditions > Self Variable >= 10, Self Switch A; Trigger > Action Button
◆Comment:// Call this event's page 3 event list. ◆Plugin Command:CallEvent 3, Map 8, Page 3
And that’s it for the Iron Vein event!
Mining Prompt – Common Event
Insert this into a common event.
◆Comment:// Display a message based on variable 1's Item ID ◆Text:None, Dim, Bottom :Text: :Text:\> \<Looks like I can mine some \c[4]\ii[\v[1]]\c[0] here. ◆Show Choices:\i[90]Mine \c[4]\ii[\v[1]]\c[0], \i[91]Don't Mine (Window, Right, #1, #2) :When \i[90]Mine \c[4]\ii[\v[1]]\c[0] ◆Comment:// If Mine, run the Start Mining common event ◆Common Event:Start Mining ◆ :When \i[91]Don't Mine ◆Comment:// Do nothing ◆ :End
And that’s it for the Mining Prompt common event!
Start Mining – Common Event
Insert this into a common event.
◆Comment:\\ Variable 2: This is how much of Var1's item has been mined. :Comment: Set this value to 0 to start with. ◆Control Variables:#0002 Temp Variable 2 = 0 ◆Comment:\\ Variable 2: This is how much of Var1's item has been mined. :Comment: Set this value to 0 to start with. ◆Comment:\\ Create the loop. ◆Loop ◆Comment:\\ Increase Variable 2 by +1. :Comment: Decrease Self Variable: Vein Yield by -1. ◆Control Variables:#0002 Temp Variable 2 += 1 ◆Control Variables:#0043 Self Var Vein Yield -= 1 ◆Comment:\\ Display a Gab message indicating the amount currently mined. :Comment: Also include a message on how to cancel the mining. ◆Plugin Command:GabText Mined x\v[2] \c[4]\ii[\v[1]]\c[0] total. \}(Hold \c[6]X\c[0] to stop mining)\{ ◆Plugin Command:ForceGab ◆Comment:// Play an animation on the mineral being mined. ◆Show Animation:This Event, Pierce Effect (Wait) ◆Comment:\\ Conditional branch to check if the Cancel Button is being pressed. ◆If:Button [Cancel] is pressed down ◆Comment:\\ If it is, break the loop. ◆Break Loop ◆ :End ◆Comment:\\ Conditional branch to check if the mineral vein is empty. ◆If:Self Var Vein Yield ≤ 0 ◆Comment:\\ If it is, break the loop. ◆Break Loop ◆ :End ◆ :Repeat Above ◆Comment:\\ Run a script call to add the total mined minerals to the player's inventory. ◆Script:// This is the item ID set by variable 1. :Script:var itemId = $gameVariables.value(1); :Script: :Script:// Get the item that uses the item ID. :Script:var item = $dataItems[itemId]; :Script: :Script:// Get the total number of items mined. :Script:var total = $gameVariables.value(2); :Script: :Script:// Grant the party the total number of items. :Script:$gameParty.gainItem(item, total); ◆Comment:\\ Show a gab message indicating how much the player has acquired. ◆Plugin Command:GabText You've acquired x\v[2] \c[4]\ii[\v[1]]\c[0] from mining. ◆Plugin Command:ForceGab ◆Comment:\\ Play a sound effect, too. ◆Play SE:Item1 (90, 100, 0)
And that’s it for the Start Mining common event!
Happy RPG Making!