Icedmetal57
Member
Icedmetal57's Mining
Version: 1.0
Introduction
My reasons for making this were, a)to make a mining system easier for me to set up for my game, and b)well pretty much just a.
This is a mining script that allows for experience and levels, if you wish, along with changing probability for mining a certain ore. It's not hard to set up either.
Features
Screen Shots
Sorry guys, no screen shots.
Demo
I didn't feel like making a demo for this, mainly because I made this for my own game and just didn't have time to make a demo, and because it's a simple setup.
Script
Instructions
Change the few variables at the top of the script, below the comments. All you need to do is add the following comments to an event to allow you to mine from it.
For example if you wanted to be able to mine item 71 or 12, then this how you'd set it up, if you wanted to have just one item.
You have to have the brackets and the number inside it is the item id from the database.
FAQ
None so far.
Compatibility
Requires SDK version 2.2, parts 1 and 3.
Credits and Thanks
Credits go to myself, Icedmetal57, and Near Fantastica for a couple methods, also the SDK team for allowing me to make this easily compatible for many of you.
Terms and Conditions
If you intend to use this in your game, please credit both Icedmetal57 and Near Fantastica, and if you intend to use this in a commercial release, please let me know ahead of time, also give credit to both Icedmetal57 and Near Fantastica.
Version: 1.0
Introduction
My reasons for making this were, a)to make a mining system easier for me to set up for my game, and b)well pretty much just a.
This is a mining script that allows for experience and levels, if you wish, along with changing probability for mining a certain ore. It's not hard to set up either.
Features
- Set up easily
- Allow for mining skill level and experience
- Allow for more than one 'ore' to be mined from any rock
- Allow for having a chance of not finding something and have it based off your mining skill level, if enabled
Screen Shots
Sorry guys, no screen shots.
Demo
I didn't feel like making a demo for this, mainly because I made this for my own game and just didn't have time to make a demo, and because it's a simple setup.
Script
Code:
#===============================================================================
# ** Icedmetal57's Mining
#-------------------------------------------------------------------------------
# Author Icedmetal57
# Version 1.0
# Date July 3rd, 2007
#===============================================================================
#
# Description
#-------------------
# A mining script that allows for experience and levels, if you wish, along with
# changing probability for mining a certain ore.
#
# Instructions
#-------------------
# Go to the section EDIT HERE and edit the things according to what you wish. To
# set up an event so you can mine an ore from it, add the following comments...
#
# Comment: Mine_Ore
# Comment: Ore [n1,n2]
#
# This script will choose 1 item randomly from the Ore array in the comments,
# so change the n's to the item ids you wish to choose randomly from.
#
# Example:
#
# Comment: Mine_Ore
# Comment: Ore [71,12]
#
# In your mining attempt for this example, it will choose either 71 or 12
#
# Compatability
#-------------------
# Requires SDK version 2.2 parts 1 and 3.
#
# Script Changes
#-------------------
# â–¼ This script aliases:
# - Scene_Map > main_window
# - Scene_Map > update
#
# â–¼ This script adds methods:
# - Scene_Map > set_ore
# - Scene_Map > mine
# - Scene_Map > in_direction? Credit to Near_Fantastica for this one
# - Scene_Map > in_range? Credit to Near_Fantastica for this one
#
#==============================================================================
#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log("Icedmetal57's Mining", "Icedmetal57", 1.0, "July 3rd, 2007")
#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.enabled?("Icedmetal57's Mining") == true
# EDIT HERE
#--------------------------------------------------------------------------
Mine_Animation = 109 # Animation ID displayed when mining.
Mining_Level_Up_Animation = 1 # Animation ID displayed when mining levels up.
Mine_Wait = 7 # Delay between each mining attempt, in seconds.
Mine_Activate_Key = Input::A # Key you have to press to mine.
# If true, Mining_Pick is a weapon id and you must have it equipped.
Mining_Pick_Weapon = true
Mining_Pick = 202 # Item ID or Weapon ID of Pick Axe which is required to mine.
Mine_Level_Enabled = true # Set true if you'd like to have levels for your mining.
# Probability that you'll get that ore.
# Ore_Probability = {Ore_ID => percent chance to get it, Ore_ID => percent...
Ore_Probability = {515 => 50, 515 => 50
}
# If Ore_Probability does not contain a certain Ore ID, then it'll refer to the
# default probability.
Default_Probability = 50
# Determines if you gain exact amount of exp, or not, otherwise you'll gain exp
# based off your level. The formula for the exp that way, is (exp/level) * 2
Exact_Ore_Exp_Gain = false
# Probability that you'll get that ore.
# Ore_Exp = {Ore_ID => exp, Ore_ID => percent...
Ore_Exp = {514 => 3, 515 => 3
}
# If Ore_Exp does not contain a certain Ore ID, then it'll refer to the
# default probability.
Default_Exp = 3
#--------------------------------------------------------------------------
# DO NOT EDIT BELOW, UNLESS YOU KNOW WHAT YOU ARE DOING
class Scene_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :mining_scene_map_update, :update
alias_method :mining_scene_map_main_window, :main_window
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main_window
@mine_button_mash = 0
mining_scene_map_main_window
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
mining_scene_map_update
@mine_button_mash -= 1 if @mine_button_mash > 0
pick = $game_party.actors[0].weapon_id
if (Mining_Pick_Weapon and Mining_Pick == pick) or (Mining_Pick_Weapon != true and $game_party.item_number(Mining_Pick) > 0)
if Input.trigger?(Mine_Activate_Key) and @mine_button_mash <= 0
for e in $game_map.events.values
#Skip the enemy if its not close by or not facing
next if !in_direction?($game_player, e) or !in_range?($game_player, e, 1)
ore = set_ore(e)
return if ore == 0 or ore == nil or ore < 0
@mine_button_mash = Mine_Wait * 10
e.animation_id = Mine_Animation
mine(ore)
end
end
end
end
#--------------------------------------------------------------------------
# * Set Ore(Event)
#--------------------------------------------------------------------------
def set_ore(event)
#Get the parameters
parameters = SDK.event_comment_input(event, 1, "Mine_Ore")
#Skip if the paramete is NIL
return 0 if parameters.nil?
#Set Ore
o = parameters[0].split
ore = eval(o[1])
ore2 = ore[rand(ore.size)]
return ore2
end
#--------------------------------------------------------------------------
# * Mine(Ore Item ID)
#--------------------------------------------------------------------------
def mine(ore)
r = rand(100)
prob = Ore_Probability.has_key?(ore) ? Ore_Probability[ore] : Default_Probability
mining_level = Mine_Level_Enabled ? $game_party.actors[0].mining_level : prob
receive_ore = mining_level + prob / 2
if r <= receive_ore.to_i
$game_party.gain_item(ore,1)
if Mine_Level_Enabled
exp = Ore_Exp.has_key?(ore) ? Ore_Exp[ore] : Default_Exp
$game_party.actors[0].gain_mining_exp(exp, Exact_Ore_Exp_Gain)
end
$scene = Scene_Mine_Item.new(ore)
end
end
#--------------------------------------------------------------------------
# * In Range?(Element, Object, Range) - Near Fantastica
#--------------------------------------------------------------------------
def in_range?(element, object, range)
x = (element.x - object.x) * (element.x - object.x)
y = (element.y - object.y) * (element.y - object.y)
r = x + y
return true if r <= (range * range)
return false
end
#--------------------------------------------------------------------------
# * In Direction?(Element, Object) - Near Fantastica
#--------------------------------------------------------------------------
def in_direction?(subject, object)
return true if subject.direction == 2 and object.y >= subject.y and object.x == subject.x
return true if subject.direction == 4 and object.x <= subject.x and object.y == subject.y
return true if subject.direction == 6 and object.x >= subject.x and object.y == subject.y
return true if subject.direction == 8 and object.y <= subject.y and object.x == subject.x
return false
end
end
#==============================================================================
# ** Window_Mine_Item
#------------------------------------------------------------------------------
# This window displays the item you received from mining.
#==============================================================================
class Window_Mine_Item < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(ore)
super(208, 0, 224, 96)
self.contents = Bitmap.new(width - 32, height - 32)
@ore = ore
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 14
item = $data_items[@ore]
self.contents.font.color = system_color
self.contents.draw_text(0, 0, self.width-32, 32, 'You Mined...',1)
self.contents.font.color = normal_color
draw_item_name(item, 0, 32)
end
end
class Scene_Mine_Item
#--------------------------------------------------------------------------
# * Object Initialization
# ore_id : item ID of ore
#--------------------------------------------------------------------------
def initialize(ore)
@ore = ore
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
@mine_item = Window_Mine_Item.new(@ore)
@mine_item.y = 320 if $game_player.screen_y < 240
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@spriteset.dispose
@mine_item.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@spriteset.update
@mine_item.update
# If B button was pressed
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Map.new
return
end
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Aliasing Objects
#--------------------------------------------------------------------------
alias_method :mining_game_actor_setup, :setup
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :mining_level, :mining_exp
#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
def setup(actor_id)
mining_game_actor_setup(actor_id)
@mining_level = 1
@mining_exp = 0
end
#--------------------------------------------------------------------------
# * Gain Mining Level (or lose)
# level : increase amount of Mining level
#--------------------------------------------------------------------------
def gain_mining_level(level=1)
@mining_level = [[@mining_level + level, 1].max, 100].min
end
#--------------------------------------------------------------------------
# * Lose Mining Level
# level : decrease amount of Mining level
#--------------------------------------------------------------------------
def lose_mining_level(level=1)
gain_mining_level(-level)
end
#--------------------------------------------------------------------------
# * Change EXP of mastery skill
# exp : amount of exp change
# exact : determines if you want to gain the exact amount of exp, or not
#--------------------------------------------------------------------------
def gain_mining_exp(exp, exact=false)
if @mining_level < 100
result = exact ? exp : (exp/@mining_level.to_f) * 2.00
@mining_exp += result if @mining_level < 100
if @mining_exp >= 100 and @mining_level < 100
self.damage = "~Mining Leveled Up~"
$game_player.animation_id = Mining_Level_Up_Animation
gain_mining_level
@mining_exp -= 100
@mining_exp = 100 if @mining_level == 100
end
else
@mining_exp = 100 if @mining_level == 100
end
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
Instructions
Change the few variables at the top of the script, below the comments. All you need to do is add the following comments to an event to allow you to mine from it.
Code:
Comment: Mine_Ore
Comment: Ore [71,12]
For example if you wanted to be able to mine item 71 or 12, then this how you'd set it up, if you wanted to have just one item.
Code:
Comment: Mine_Ore
Comment: Ore [81]
You have to have the brackets and the number inside it is the item id from the database.
FAQ
None so far.
Compatibility
Requires SDK version 2.2, parts 1 and 3.
Credits and Thanks
Credits go to myself, Icedmetal57, and Near Fantastica for a couple methods, also the SDK team for allowing me to make this easily compatible for many of you.
Terms and Conditions
If you intend to use this in your game, please credit both Icedmetal57 and Near Fantastica, and if you intend to use this in a commercial release, please let me know ahead of time, also give credit to both Icedmetal57 and Near Fantastica.