Sign in to follow this  
Followers 0
Fegarur

Script de Miner?a II

19 posts in this topic

Descripción:
Otro sistema de Minería, con una realización bastante más realista que el anterior. Se verá al chara cavando y mostrando el objeto conseguido. La forma de conseguir los objetos también es diferente.

Screens:[spoiler]
user posted image Cavando:
user posted image

user posted image Hemos encontrado algo:
user posted image[/spoiler]

Demo:
Descarga del Demo (Descarga Directa)

Script:
CODE
=begin

                 ||
                 \/
==> INSTRUCCIONES <==
                 /\
                 ||

1. Crea un atributo nuevo llamado pick
2. Crea algunas armas que serán los picos, y ponles el atributo pick.
   Su ataque determinará su efectividad en la minería; entre 50 y 250 está bien.
3. Asegúrate de que tus clases pueden usar los picos.
4. Crea algunos objetos que sean cosas para encontrarlas, y ve a la "mining scene initialization"
5. Ve a "mining window initialization"
6. En el Editor de Tileset, coloca el nivel del terreno de algunos tiles de 1 a 7. Esto el nivel de minería.
   Cuanto mayor sea el nivel, mejores objetos debería haber allí.
7. En Scene_Map, hay instrucciones para llamar a la escena de minería.
8. Importa un background para tu escena de minería. (Puonlo en la carpeta Pictures)
9. Importa algunos dibujos para las animaciones. (Ponlos en la carpeta Pictures)

=end

#==============================================================================
#     Scene_Mining
#------------------------------------------------------------------------------
#     The scene with a character mining
#==============================================================================

class Scene_Mining
 #--------------------------------------------------------------------------
 #    Initialize
 #--------------------------------------------------------------------------
 def initialize(miner, level)
   @miner = miner
   @level = level
   #Estas son las ID de los objetos en cada nivel de minería.
   @items = [[1, 1, 1, 1, 1, 2, 2, 3],
                   #Terreno de nivel 1 tiene 5/8 de probabilidad de conseguir el objeto con ID 1, 2/8 para la ID 2, y 1/8 para la ID 3
                   [1, 2, 2, 3],
                   #Terreno de nivel 2 tiene 1/4 de probabilidad de conseguir el objeto con ID 2, 2/4 para la ID 3, y 1/4 para la ID 4
                   [2, 3, 3, 3, 4],
                   #Cambia todo esto a tu gusto. Los mejores objetos deberían conseguirse en los mayores niveles.
                   [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("¡Presiona el botón de acción para cavar!", 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("Cavando...", 1)
     if @mining_window.mine
       item = $data_items[@items[@level - 1][rand(@items[@level - 1].size)]]
       @help_window.set_text("¡Encontraste " + item.name + "!", 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 #La ID del personaje que cava.
   when 1 #Si es el personaje 1:
     @graphic = RPG::Cache.picture("civ4miner") # Usa esto como su gráfico
   when 2 #Si es el personaje 2:
     @graphic = RPG::Cache.picture("civ4miner") # Usa esto como su gráfico...
   else
     @graphic = RPG::Cache.picture("civ4miner") # ¡O utiliza este otro! Puedes añadir más 'whens'...
   end
   refresh
 end
 #--------------------------------------------------------------------------
 #    Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   bitmap = RPG::Cache.picture("MiningBackground") # El background que se va a usar
   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))
   $game_system.me_play($game_system.battle_end_me)
   $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


Instrucciones:
user posted image Coloca el script sobre Main.
user posted image en Scene_Map, añade en la línea 131:
CODE
if Input.trigger?(Input::A)
     call_mining                      
   end

Y añade en la línea 157 (después del cambio anterior)
CODE
#--------------------------------------------------------------------------
 #      Mining
 #--------------------------------------------------------------------------
 def call_mining
   character = $game_player
   case character.direction
   when 2
     lookingx = character.x
     lookingy = character.y + 1
  when 4
     lookingx = character.x - 1
     lookingy = character.y
   when 6
     lookingx = character.x + 1
     lookingy = character.y
   when 8
     lookingx = character.x
     lookingy = character.y - 1
   end
   for i in 0..$game_party.actors.size
     actor = $game_party.actors[i]
     if $data_weapons[actor.weapon_id] != nil and
         $data_weapons[actor.weapon_id].element_set.include?(17) #¡¡Cambia el 17 por la ID del atributo Pick!!
       miner = actor
       break
     end
   end
   level = $game_map.terrain_tag(lookingx,lookingy)
   for i in 1..$game_map.events.size
     if  $game_map.events[i] != nil
       name = load_data(sprintf("Data/Map%03d.rxdata", $game_map.map_id)).events[i].name
       if $game_map.events[i].x == lookingx and $game_map.events[i].y == lookingy and
             name[0..3] == "mine" and name.length == 5
         level = [[name[4] - 48, 1].max, 7].min
         break
       end
     end
   end
   if miner != nil and level > 0
     $scene = Scene_Mining.new(miner, level)
   end
 end


Te quedará:
CODE
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  マップ画面の処理を行うクラスです。
#==============================================================================

class Scene_Map
 #--------------------------------------------------------------------------
 # ● メイン処理
 #--------------------------------------------------------------------------
 def main
   # スプライトセットを作成
   @spriteset = Spriteset_Map.new
   # メッセージウィンドウを作成
   @message_window = Window_Message.new
   # トランジション実行
   Graphics.transition
   # メインループ
   loop do
     # ゲーム画面を更新
     Graphics.update
     # 入力情報を更新
     Input.update
     # フレーム更新
     update
     # 画面が切り替わったらループを中断
     if $scene != self
       break
     end
   end
   # トランジション準備
   Graphics.freeze
   # スプライトセットを解放
   @spriteset.dispose
   # メッセージウィンドウを解放
   @message_window.dispose
   # タイトル画面に切り替え中の場合
   if $scene.is_a?(Scene_Title)
     # 画面をフェードアウト
     Graphics.transition
     Graphics.freeze
   end
 end
 #--------------------------------------------------------------------------
 # ● フレーム更新
 #--------------------------------------------------------------------------
 def update
   # ループ
   loop do
     # マップ、インタプリタ、プレイヤーの順に更新
     # (この更新順序は、イベントを実行する条件が満たされているときに
     #  プレイヤーに一瞬移動する機会を与えないなどの理由で重要)
     $game_map.update
     $game_system.map_interpreter.update
     $game_player.update
     # システム (タイマー)、画面を更新
     $game_system.update
     $game_screen.update
     # プレイヤーの場所移動中でなければループを中断
     unless $game_temp.player_transferring
       break
     end
     # 場所移動を実行
     transfer_player
     # トランジション処理中の場合、ループを中断
     if $game_temp.transition_processing
       break
     end
   end
   # スプライトセットを更新
   @spriteset.update
   # メッセージウィンドウを更新
   @message_window.update
   # ゲームオーバーの場合
   if $game_temp.gameover
     # ゲームオーバー画面に切り替え
     $scene = Scene_Gameover.new
     return
   end
   # タイトル画面に戻す場合
   if $game_temp.to_title
     # タイトル画面に切り替え
     $scene = Scene_Title.new
     return
   end
   # トランジション処理中の場合
   if $game_temp.transition_processing
     # トランジション処理中フラグをクリア
     $game_temp.transition_processing = false
     # トランジション実行
     if $game_temp.transition_name == ""
       Graphics.transition(20)
     else
       Graphics.transition(40, "Graphics/Transitions/" +
         $game_temp.transition_name)
     end
   end
   # メッセージウィンドウ表示中の場合
   if $game_temp.message_window_showing
     return
   end
   # エンカウント カウントが 0 で、エンカウントリストが空ではない場合
   if $game_player.encounter_count == 0 and $game_map.encounter_list != []
     # イベント実行中かエンカウント禁止中でなければ
     unless $game_system.map_interpreter.running? or
            $game_system.encounter_disabled
       # トループを決定
       n = rand($game_map.encounter_list.size)
       troop_id = $game_map.encounter_list[n]
       # トループが有効なら
       if $data_troops[troop_id] != nil
         # バトル呼び出しフラグをセット
         $game_temp.battle_calling = true
         $game_temp.battle_troop_id = troop_id
         $game_temp.battle_can_escape = true
         $game_temp.battle_can_lose = false
         $game_temp.battle_proc = nil
       end
     end
   end
   # B ボタンが押された場合
   if Input.trigger?(Input::B)
     # イベント実行中かメニュー禁止中でなければ
     unless $game_system.map_interpreter.running? or
            $game_system.menu_disabled
       # メニュー呼び出しフラグと SE 演奏フラグをセット
       $game_temp.menu_calling = true
       $game_temp.menu_beep = true
     end
   end
   if Input.trigger?(Input::A)
     call_mining                      
   end
   # デバッグモードが ON かつ F9 キーが押されている場合
   if $DEBUG and Input.press?(Input::F9)
     # デバッグ呼び出しフラグをセット
     $game_temp.debug_calling = true
   end
   # プレイヤーの移動中ではない場合
   unless $game_player.moving?
     # 各種画面の呼び出しを実行
     if $game_temp.battle_calling
       call_battle
     elsif $game_temp.shop_calling
       call_shop
     elsif $game_temp.name_calling
       call_name
     elsif $game_temp.menu_calling
       call_menu
     elsif $game_temp.save_calling
       call_save
     elsif $game_temp.debug_calling
       call_debug
     end
   end
 end
 #--------------------------------------------------------------------------
 #      Mining
 #--------------------------------------------------------------------------
 def call_mining
   character = $game_player
   case character.direction
   when 2
     lookingx = character.x
     lookingy = character.y + 1
  when 4
     lookingx = character.x - 1
     lookingy = character.y
   when 6
     lookingx = character.x + 1
     lookingy = character.y
   when 8
     lookingx = character.x
     lookingy = character.y - 1
   end
   for i in 0..$game_party.actors.size
     actor = $game_party.actors[i]
     if $data_weapons[actor.weapon_id] != nil and
         $data_weapons[actor.weapon_id].element_set.include?(17) #¡¡Cambia el 17 por la ID del atributo Pick!!
       miner = actor
       break
     end
   end
   level = $game_map.terrain_tag(lookingx,lookingy)
   for i in 1..$game_map.events.size
     if  $game_map.events[i] != nil
       name = load_data(sprintf("Data/Map%03d.rxdata", $game_map.map_id)).events[i].name
       if $game_map.events[i].x == lookingx and $game_map.events[i].y == lookingy and
             name[0..3] == "mine" and name.length == 5
         level = [[name[4] - 48, 1].max, 7].min
         break
       end
     end
   end
   if miner != nil and level > 0
     $scene = Scene_Mining.new(miner, level)
   end
 end
 #--------------------------------------------------------------------------
 # ● バトルの呼び出し
 #--------------------------------------------------------------------------
 def call_battle
   # バトル呼び出しフラグをクリア
   $game_temp.battle_calling = false
   # メニュー呼び出しフラグをクリア
   $game_temp.menu_calling = false
   $game_temp.menu_beep = false
   # エンカウント カウントを作成
   $game_player.make_encounter_count
   # マップ BGM を記憶し、BGM を停止
   $game_temp.map_bgm = $game_system.playing_bgm
   $game_system.bgm_stop
   # バトル開始 SE を演奏
   $game_system.se_play($data_system.battle_start_se)
   # バトル BGM を演奏
   $game_system.bgm_play($game_system.battle_bgm)
   # プレイヤーの姿勢を矯正
   $game_player.straighten
   # バトル画面に切り替え
   $scene = Scene_Battle.new
 end
 #--------------------------------------------------------------------------
 # ● ショップの呼び出し
 #--------------------------------------------------------------------------
 def call_shop
   # ショップ呼び出しフラグをクリア
   $game_temp.shop_calling = false
   # プレイヤーの姿勢を矯正
   $game_player.straighten
   # ショップ画面に切り替え
   $scene = Scene_Shop.new
 end
 #--------------------------------------------------------------------------
 # ● 名前入力の呼び出し
 #--------------------------------------------------------------------------
 def call_name
   # 名前入力呼び出しフラグをクリア
   $game_temp.name_calling = false
   # プレイヤーの姿勢を矯正
   $game_player.straighten
   # 名前入力画面に切り替え
   $scene = Scene_Name.new
 end
 #--------------------------------------------------------------------------
 # ● メニューの呼び出し
 #--------------------------------------------------------------------------
 def call_menu
   # メニュー呼び出しフラグをクリア
   $game_temp.menu_calling = false
   # メニュー SE 演奏フラグがセットされている場合
   if $game_temp.menu_beep
     # 決定 SE を演奏
     $game_system.se_play($data_system.decision_se)
     # メニュー SE 演奏フラグをクリア
     $game_temp.menu_beep = false
   end
   # プレイヤーの姿勢を矯正
   $game_player.straighten
   # メニュー画面に切り替え
   $scene = Scene_Menu.new
 end
 #--------------------------------------------------------------------------
 # ● セーブの呼び出し
 #--------------------------------------------------------------------------
 def call_save
   # プレイヤーの姿勢を矯正
   $game_player.straighten
   # セーブ画面に切り替え
   $scene = Scene_Save.new
 end
 #--------------------------------------------------------------------------
 # ● デバッグの呼び出し
 #--------------------------------------------------------------------------
 def call_debug
   # デバッグ呼び出しフラグをクリア
   $game_temp.debug_calling = false
   # 決定 SE を演奏
   $game_system.se_play($data_system.decision_se)
   # プレイヤーの姿勢を矯正
   $game_player.straighten
   # デバッグ画面に切り替え
   $scene = Scene_Debug.new
 end
 #--------------------------------------------------------------------------
 # ● プレイヤーの場所移動
 #--------------------------------------------------------------------------
 def transfer_player
   # プレイヤー場所移動フラグをクリア
   $game_temp.player_transferring = false
   # 移動先が現在のマップと異なる場合
   if $game_map.map_id != $game_temp.player_new_map_id
     # 新しいマップをセットアップ
     $game_map.setup($game_temp.player_new_map_id)
   end
   # プレイヤーの位置を設定
   $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
   # プレイヤーの向きを設定
   case $game_temp.player_new_direction
   when 2  # 下
     $game_player.turn_down
   when 4  # 左
     $game_player.turn_left
   when 6  # 右
     $game_player.turn_right
   when 8  # 上
     $game_player.turn_up
   end
   # プレイヤーの姿勢を矯正
   $game_player.straighten
   # マップを更新 (並列イベント実行)
   $game_map.update
   # スプライトセットを再作成
   @spriteset.dispose
   @spriteset = Spriteset_Map.new
   # トランジション処理中の場合
   if $game_temp.transition_processing
     # トランジション処理中フラグをクリア
     $game_temp.transition_processing = false
     # トランジション実行
     Graphics.transition(20)
   end
   # マップに設定されている BGM と BGS の自動切り替えを実行
   $game_map.autoplay
   # フレームリセット
   Graphics.frame_reset
   # 入力情報を更新
   Input.update
 end
end

user posted image El resto de instrucciones están en el script, en la parte superior.

Funcionamiento:
Al lado de una roca en la que se pueda excavar, pulsa Z (en realidad, es A, por si lo habeis cambiado) y pasarás al background. Una barra a la derecha de la pantalla indicará la fuerza del golpe. Golpea hasta que encuentres algo.

Crédito:
Script creado por: Tiberius
0

Share this post


Link to post
Share on other sites
Veo que lo encontraste, jeje. Me bajo la demo y edito

Adeus! medieval.gif

*Edit:

Sinceramente, nolo entiendo xD.png Que tengo que hacer en la cueva? Edited by Zamaroht
0

Share this post


Link to post
Share on other sites
wtf??? q script mas raro como en el ff9 xD.png mola!!
0

Share this post


Link to post
Share on other sites
Zamaroht, mira en el post la parte de Funcionamiento. Pulsa Z enfrente de una roca. icon13.gif
Creo que pondré los recursos que se pueden necesitar...
0

Share this post


Link to post
Share on other sites
Ah! Es que vi la palabra demo y me lo baje sin leer xD.png. Gracias Feg

Adeus! medieval.gif
0

Share this post


Link to post
Share on other sites
Jeje, en realidad a mí me pasó algo parecido. No ponía qué había que pulsar y no tenía ganas de leer el script, así que probé con todas... menos la Z. Luego se lo comenté a Drako y me lo dijo. xD.png
Así que... ¡Gracias, Drako! happy.gif
0

Share this post


Link to post
Share on other sites
Me hace recordar al Harvest Moon
Muy bueno y puede q lo use para mi proyecto ya que necesito material para forjar armas, y que el jugador lo consiga es una wena idea..
Lo había visto antes, pero nunca lo probé y ahora q lo veo, es muy bueno icon13.gif
0

Share this post


Link to post
Share on other sites
Jajaja, si. Este script mola mucho. Aunque no le veo el uso de que puedas cavar el mismo sitio una y otra vez y el mineral nunca se acaba... me parece algo raro. o_O

@Fegarur: De nada. xD.png
0

Share this post


Link to post
Share on other sites
No entendi como hacer para llamar al evento, ¿Me lo explicarias porfa? es q no se como hacer para q aparesca la pantalla donde se va a cargar la barra.

Gracias verguenza.gif
0

Share this post


Link to post
Share on other sites
Mira. En el demo, simplemente acércate a una roca de las que están a la derecha del personaje. Pulsa Z y ya entrarás a la pantalla para cavar. Para cavar, pulsa el botón de acción (por ejemplo Intro) y pararás la barra. icon13.gif
0

Share this post


Link to post
Share on other sites
No, pero yo digo para activarlo en otro juego, osea como llamar al script en otro juego laugh.gif
0

Share this post


Link to post
Share on other sites
Wow! nose para que sirva en mi juego.
Pero esta muy bueno icon13.gif icon13.gif
0

Share this post


Link to post
Share on other sites
QUOTE(Nailuj @ Dec 6 2006, 02:17 PM)
No, pero yo digo para activarlo en otro juego, osea como llamar al script en otro juego  laugh.gif
[right][snapback]18147[/snapback][/right]


Perdón, no te entendí. Prueba a usar esto:
QUOTE
$scene = Scene_Mining.new(miner, level)

Edita quién cavará y el nivel de los objetos. icon13.gif Edited by Fegarur
0

Share this post


Link to post
Share on other sites
Me tira error del script en la parte de "agi".

Puse esto de llamado de script, ¿Esta bien?
$scene = Scene_Mining.new(2, 1)

Perdon por ser tan molestp cheesy.gif
0

Share this post


Link to post
Share on other sites
Vaya... que lío me monté. xD.png
A ver, en las rocas excavables, tienes que poner como nombre de evento "mineX".
La X es el número del nivel de la roca, del 1 al 7. Se escribe sin comillas. icon13.gif
También lo puedes hacer así: En la base de datos, a lo excavable le pones elegir terreno. De nuevo, es del 1 al 7.

No se si me he explicado bien... pero es tarde para aclararlo mejor...
0

Share this post


Link to post
Share on other sites
Esta muy bueno. interesante, para un juego muy largo. Exelente aporte.
Muy bien explicado ademas.
0

Share this post


Link to post
Share on other sites
No hagas ni caso a lo de llamarlo con $scene = Scene_Mining.new, se me fue la pinza. xD.png
Creo que funciona automáticamente siempre que hayas hecho lo que puse en el post anterior. happy.gif
0

Share this post


Link to post
Share on other sites
Hooo impresionado.gif , el script parece estar muy bueno laugh.gif , me bajo el
script y luego la demo icon13.gif
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0