Release 0.0.1.8.8.7
This commit is contained in:
1 parent
3c8a17aa78
commit
c7beab414c
16283 files changed
+768761
-2
No files matched your search
@@ -0,0 +1,87 @@
|
||||
#==============================================================================
|
||||
# LonaCraft - 40_Mining.rb
|
||||
# What it does:
|
||||
# * Each time a mining node yields its ore (Crystal Ore, Saltpeter or
|
||||
# Phosphorus), two independent rolls drop raw materials on the same tile:
|
||||
# 60% Rough Stone (cut into Stone Block at the pot, 30_Process.rb)
|
||||
# 35% Iron Ore (smelted into Iron Ingot at the pot)
|
||||
# Stone Block itself is no longer dropped by mining.
|
||||
# * No map or script file is edited. Two hooks:
|
||||
# - Game_Interpreter#load_script override: marks "mining in progress" while
|
||||
# a Mining_*.rb script runs (vanilla Data/HCGframes/event/Mining_*.rb and
|
||||
# the RolePlayS copies; they yield with EvLib.sum("ItemX",x,y)).
|
||||
# - Game_Map#reserve_summon_event alias: when an ore is summoned while
|
||||
# mining, also roll the by-products. The vanilla prison mine (Map050
|
||||
# node events) has no script file; it summons
|
||||
# reserve_summon_event("ItemMineral",x,y,<player id>), which no other
|
||||
# call does, so that call is recognised directly.
|
||||
# * Ore dropped by NPCs, thrown or summoned any other way gives nothing extra.
|
||||
#==============================================================================
|
||||
module LonaCraft
|
||||
MINING_ORES = ["ItemMineral", "ItemSaltpeter", "ItemPhosphorus"]
|
||||
# [item_name, percent per ore yield]; each row is rolled on its own
|
||||
MINING_BYPRODUCTS = [
|
||||
["ItemLonaCraftRoughStone", 60],
|
||||
["ItemLonaCraftIronOre", 35]
|
||||
]
|
||||
|
||||
def self.mining_depth
|
||||
@mining_depth || 0
|
||||
end
|
||||
|
||||
def self.mining_depth=(value)
|
||||
@mining_depth = value
|
||||
end
|
||||
|
||||
# args = the arguments of reserve_summon_event(event_name, x, y, id, data)
|
||||
def self.mining_yield?(args)
|
||||
name = args[0]
|
||||
return false unless MINING_ORES.include?(name)
|
||||
return true if mining_depth > 0
|
||||
return true if name == "ItemMineral" && $game_player && !args[3].nil? && args[3] == $game_player.id
|
||||
false
|
||||
end
|
||||
|
||||
# Item names to drop next to one ore yield
|
||||
def self.roll_mining_byproducts
|
||||
out = []
|
||||
MINING_BYPRODUCTS.each{|item_name, pct|
|
||||
next unless $data_EventLib[item_name]
|
||||
out << item_name if rand(100) < pct
|
||||
}
|
||||
out
|
||||
end
|
||||
end
|
||||
|
||||
class Game_Interpreter
|
||||
def load_script(path)
|
||||
mining = path.to_s.include?("/Mining_")
|
||||
LonaCraft.mining_depth = LonaCraft.mining_depth + 1 if mining
|
||||
begin
|
||||
super
|
||||
ensure
|
||||
LonaCraft.mining_depth = LonaCraft.mining_depth - 1 if mining
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Game_Map
|
||||
unless method_defined?(:reserve_summon_event_lonacraft)
|
||||
alias_method :reserve_summon_event_lonacraft, :reserve_summon_event
|
||||
def reserve_summon_event(*args)
|
||||
result = reserve_summon_event_lonacraft(*args)
|
||||
begin
|
||||
if LonaCraft.mining_yield?(args)
|
||||
tmpX = args[1].nil? ? $game_player.x : args[1]
|
||||
tmpY = args[2].nil? ? $game_player.y : args[2]
|
||||
LonaCraft.roll_mining_byproducts.each{|item_name|
|
||||
reserve_summon_event_lonacraft(item_name, tmpX, tmpY)
|
||||
}
|
||||
end
|
||||
rescue => e
|
||||
p "LonaCraft mining drop error #{e.message}"
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user