Ummmm.... hello, Im new here.
I've a Mining script from an unkown author. But its scripted very Very VERY poorly.
It allowes to create a mining scenario. You can give certain events a mining tag via names like mine2 and assign them with items that can be farmed.
When our hero mines a picture will appear that displays as a background. (line 123 bitmap = RPG::Cache.picture("MiningBackground"))
The problem is, that the background picture is only determinable once and for all, so it will be displayed for all locations. But my locations look differnt of course. LOL.
However, I want the background picture to be able to be determined several times. I want to assign different MiningBackGround locations for different locations.
If its up to me. I would bound the MiningBackGround picture to the map id of the mapss. But I dont know how
I've a Mining script from an unkown author. But its scripted very Very VERY poorly.
It allowes to create a mining scenario. You can give certain events a mining tag via names like mine2 and assign them with items that can be farmed.
When our hero mines a picture will appear that displays as a background. (line 123 bitmap = RPG::Cache.picture("MiningBackground"))
The problem is, that the background picture is only determinable once and for all, so it will be displayed for all locations. But my locations look differnt of course. LOL.
However, I want the background picture to be able to be determined several times. I want to assign different MiningBackGround locations for different locations.
If its up to me. I would bound the MiningBackGround picture to the map id of the mapss. But I dont know how
Code:
=begin
||
\/
==> INSTRUCTIONS <==
/\
||
1. Make a new attribute called pick
2. Make some weapons that are picks, and give them the attribute pick,
their attack determines their effectiveness at mining, between 50 and 250 is good.
3. Make sure your classes can use the picks
4. Make some items to be things that are mined, and go to the mining scene initialization
5. Go to the mining window initialization
6. In the tileset editor, set the terrain tags of some tiles to 1 through 7, this gives them a mining level.
Higher level mines should have better items in them.
7. In scene map, call mining has some instructions for you.
8. Import a background for your mining scene, like the one provided. (Put in pictures folder)
9. Import some pictures to the mining animations. (Put in pictures folder)
=end
#==============================================================================
# Scene_Mining
#------------------------------------------------------------------------------
# The scene with a character mining
#==============================================================================
class Scene_Mining
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize(miner, level)
@miner = miner
@level = level
#These are the id's of the items in each mining level.
@items = [[1, 1, 1, 1, 1, 2, 2, 3],
#Level one mines have a 5/8 chance of getting item id 1, 2/8 for item id 2, and 1/8 for item id 3
[149, 149, 149, 149],
#Level two mines have a 1/4 chance of getting item id 2, 2/4 for item id 3, and 1/4 for item id 3
[2, 3, 3, 3, 4],
#You get the point, change these to what you'd like. Good items should be in high level mines.
[3, 3, 4, 4, 4, 4, 4, 5, 5, 6],
[5, 5, 5, 5, 6, 6, 7],
[5, 6, 6, 7],
[6, 7, 7, 7]]
end
#--------------------------------------------------------------------------
# Main
#--------------------------------------------------------------------------
def main
@help_window = Window_Help.new
@help_window.set_text("Eine Taste drücken um abzubauen!", 1)
@mining_window = Window_Mining.new(@miner, @level)
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@mining_window.dispose
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
if Input.trigger?(Input::C)
@help_window.set_text("Am abbuen...", 1)
if @mining_window.mine
item = $data_items[@items[@level - 1][rand(@items[@level - 1].size)]]
@help_window.set_text("Du hast " + item.name + " gefunden!", 1)
@mining_window.find(item)
end
@mining_window.set_strength
@help_window.set_text("", 1)
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
@mining_window.update
end
end
#==============================================================================
# Window_Mining
#------------------------------------------------------------------------------
# The Window that has the mining stuff
#==============================================================================
class Window_Mining < Window_Base
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize(miner, level)
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
@miner = miner
@level = level
@speed = -0.012 * @miner.agi + 10.6
@strength = -1
@plus = 1
case @miner.id #What is the id of the actor mining?
when 1 #If it's actor number one,
@graphic = RPG::Cache.picture("civ4miner") #Use this picture as their graphic
when 2 #If it's actor number two,
@graphic = RPG::Cache.picture("civ4miner") #Use this picture as their graphic
else
@graphic = RPG::Cache.picture("civ4miner")#otherwise use this one! You can add more whens...
end
refresh
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
bitmap = RPG::Cache.picture("MiningBackground")
self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 608, 384))
draw_bar
bitmap = @graphic
cw = bitmap.width / 5
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(430 - cw / 2, 350 - ch, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# Mine
#--------------------------------------------------------------------------
def mine
Audio.se_play("Audio/SE/103-Attack15", 100, 250 / @speed)
for i in 0..3
self.contents.clear
bitmap = RPG::Cache.picture("MiningBackground")
self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 608, 384))
draw_bar
bitmap = @graphic
cw = bitmap.width / 5
ch = bitmap.height
src_rect = Rect.new(i * cw, 0, cw, ch)
self.contents.blt(430 - cw / 2, 350 - ch, bitmap, src_rect)
wait(@speed)
end
wait(@speed * 2)
refresh
if rand(324 + 3 * @strength - @miner.atk + @miner.str / 10) > 324 - @miner.atk + (40 * @level + 20) / 10
return true
end
return false
end
#--------------------------------------------------------------------------
# Wait
#--------------------------------------------------------------------------
def wait(time)
time = 1 if time < 1
for i in 0..time
Graphics.update
end
end
#--------------------------------------------------------------------------
# Find
#--------------------------------------------------------------------------
def find(item)
self.contents.clear
bitmap = RPG::Cache.picture("MiningBackground")
self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 608, 384))
draw_bar
bitmap = @graphic
cw = bitmap.width / 5
ch = bitmap.height
src_rect = Rect.new(4 * cw, 0, cw, ch)
self.contents.blt(430 - cw / 2, 350 - ch, bitmap, src_rect)
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(418, 328 - ch, bitmap, Rect.new(0, 0, 24, 24))
Audio.me_play("Audio/ME/Victory1")
$game_party.gain_item(item.id, 1)
wait(80)
refresh
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
super
@strength += @plus
if @strength > 27
set_strength
end
draw_bar
end
#--------------------------------------------------------------------------
# Draw Bar
#--------------------------------------------------------------------------
def draw_bar
self.contents.fill_rect(Rect.new(2, 2, 12, 380), Color.new(0, 0, 0))
height = @strength * (@strength + 1) / 2
for i in 0..height
self.contents.fill_rect(Rect.new(3, 381 - i, 10, 1), Color.new(i * 128 / (height + 1),
i * 128 / (height + 1), i * 128 / (height + 1)))
end
end
#--------------------------------------------------------------------------
# Set Strength
#--------------------------------------------------------------------------
def set_strength
@strength = 0.0
@plus = (rand(41) + 80.0) / 100.0
end
end