Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # LM² - Crafting
- # Desenvlvido por LeonMM
- module LMM_Craft
- # Instalação:
- # Procure por:
- # $game_player = Game_Player.new
- # Adicione abaixo este código:
- # $game_craft = Game_Craft.new
- # Procure por:
- # Marshal.dump($game_player, file)
- # Adicione abaixo este código:
- # Marshal.dump($game_craft, file)
- # Procure por:
- # $game_player = Marshal.load(file)
- # Adicione abaixo este código:
- # $game_craft = Marshal.load(file)
- #(Você pode acha-los respectivamente em Scene_Title, Scene_Save
- #e Scene_Load)
- #Quantidade de receitas visíveis na tela.
- RECIPE_VIEW = 8
- #QUANTIDADE DE RECEITAS
- RECIPE_Q = 9
- # Configuração de Receitas
- # RECIPE[id] = [[it_type, it_id, item_qty],[mat_*_type, mat_*_id, mat_*_qty], ...]
- # id = id da receita, contando apartir do zero
- # it_type: Tipo de item a ser gerado. *
- # it_id: Id do item gerado no database.
- # it_qty: Quantidade do item a ser gerado.
- # mat_*_type: Tipo de item a ser usado. *
- # mat_*_id: Id do item usado no database.
- # mat_*_qty: Quantidade necessária para usar.
- # * = 0 para itens, 1 para armas, 2 para armaduras.
- # Para adicionar mais requisitos, basta adicionar uma virgula
- #após, e colocar mais um conjunto dentro de chaves, no máximo 4
- #itens podem ser usados.
- RECIPES = []
- RECIPES[0] = [[1, 1, 3], [0, 3, 2], [1, 4, 2]]
- RECIPES[1] = [[0, 10, 1], [0, 13, 2]]
- RECIPES[4] = [[0, 10, 1], [0, 13, 2], [0, 12, 2], [0, 11, 1]]
- RECIPES[8] = [[0, 1, 1], [0, 3, 2], [0, 4, 2], [0, 5, 2], [0, 6, 2]]
- # Alterar a fonte dos textos da janela de requerimentos.
- REQ_FONT = "Franklin Gothic Medium"
- REQ_SIZE = 19
- # Alterar o termo da imagem da receita
- # (Ao lado do termo deve ir o número id da receita: 0,1...)
- REC_TERM = "Recipe_"
- # As imagens devem estar na pasta Window_Craft, dentro da pasta
- #pictures do seu projeto
- # Para ativar alguma receita, deve se usar o código abaixo
- # $game_craft.recipes[id] = true
- # id = id da receita
- # (Para desativar alguma receita, basta mudar true para false)
- end
- # NÃO EDITE A PARTIR DAQUI SEM CONHECIMENTO PRÉVIO
- class Game_Craft
- attr_accessor :recipes
- def initialize
- @recipes = []
- for i in 0..LMM_Craft::RECIPE_Q - 1
- @recipes.push(false)
- end
- end
- end
- class Scene_Crafting
- include LMM_Craft
- def main
- @fundo = Spriteset_Map.new
- @black = Sprite.new
- @black.bitmap = Bitmap.new(640, 480)
- @black.bitmap.fill_rect(Rect.new(0,0,640,480), Color.new(0,0,0,75))
- @black.z = 15
- opt = []
- for i in 0..RECIPE_Q - 1
- opt.push("")
- end
- @command_window = Window_Command.new(192, opt )
- @command_window.index = 0
- @command_window.visible = false
- @BG = Sprite.new
- @BG.bitmap = RPG::Cache.picture("Window_Craft/Base_window")
- @BG.z = 16
- @Sel = Sprite.new
- @Sel.bitmap = RPG::Cache.picture("Window_Craft/Marker")
- @Sel.x = 16
- @Sel.y = 55 + (@command_window.index * 39)
- @Sel.z = 17
- @RequireWin = Require_Win.new
- @Confirm = Sprite.new
- if $game_craft.recipes[@command_window.index] == true
- if check_ing
- @Confirm.bitmap = RPG::Cache.picture("Window_Craft/ConfirmOn")
- else
- @Confirm.bitmap = RPG::Cache.picture("Window_Craft/ConfirmOff")
- end
- else
- @Confirm.bitmap = RPG::Cache.picture("Window_Craft/ConfirmNoR")
- end
- @Confirm.x = 371
- @Confirm.y = 294
- @Confirm.z = 17
- @Recipes = [Sprite.new,Sprite.new,Sprite.new,Sprite.new,Sprite.new,Sprite.new,Sprite.new,Sprite.new]
- for i in 0 .. RECIPE_VIEW - 1
- if $game_craft.recipes[i] == true
- @Recipes[i].bitmap = RPG::Cache.picture("Window_Craft/"+REC_TERM+(i).to_s)
- else
- @Recipes[i].bitmap = RPG::Cache.picture("Window_Craft/Norecipe")
- end
- @Recipes[i].x = 22
- @Recipes[i].y = 61 + (i * 39)
- @Recipes[i].z = 17
- end
- Graphics.transition
- loop do
- Graphics.update
- Input.update
- update
- if $scene != self
- break
- end
- end
- Graphics.freeze
- @command_window.dispose
- @fundo.dispose
- @black.dispose
- @BG.dispose
- @Sel.dispose
- @RequireWin.dispose
- @Confirm.dispose
- for i in 0 .. @Recipes.size - 1
- @Recipes[i].dispose
- end
- if $scene.is_a?(Scene_Title)
- Graphics.transition
- Graphics.freeze
- end
- end
- def update
- @fundo.update
- @black.update
- @BG.update
- @command_window.update
- @RequireWin.update
- if @command_window.index >= RECIPE_VIEW
- @cmw_in = RECIPE_VIEW - 1
- for i in 0 .. RECIPE_VIEW - 1
- if $game_craft.recipes[@command_window.index - (RECIPE_VIEW - 1) + i] == true
- @Recipes[i].bitmap = RPG::Cache.picture("Window_Craft/"+REC_TERM+(@command_window.index - (RECIPE_VIEW - 1) + i).to_s)
- else
- @Recipes[i].bitmap = RPG::Cache.picture("Window_Craft/Norecipe")
- end
- end
- else
- @cmw_in = @command_window.index
- for i in 0 .. RECIPE_VIEW - 1
- if $game_craft.recipes[i] == true
- @Recipes[i].bitmap = RPG::Cache.picture("Window_Craft/"+REC_TERM+(i).to_s)
- else
- @Recipes[i].bitmap = RPG::Cache.picture("Window_Craft/Norecipe")
- end
- end
- end
- @Sel.y = 55 + (@cmw_in * 39)
- if $game_craft.recipes[@command_window.index] == true
- @RequireWin.rec_id(RECIPES[@command_window.index])
- if check_ing
- update_command
- @Confirm.bitmap = RPG::Cache.picture("Window_Craft/ConfirmOn")
- else
- @Confirm.bitmap = RPG::Cache.picture("Window_Craft/ConfirmOff")
- end
- else
- @RequireWin.rec_id(nil)
- @Confirm.bitmap = RPG::Cache.picture("Window_Craft/ConfirmNoR")
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- #Altere aqui caso deseje retornar em outra cena.
- $scene = Scene_Map.new
- return
- end
- end
- def update_command
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.equip_se)
- case RECIPES[@command_window.index][0][0]
- when 0
- $game_party.gain_item(RECIPES[@command_window.index][0][1], RECIPES[@command_window.index][0][2])
- when 1
- $game_party.gain_weapon(RECIPES[@command_window.index][0][1], RECIPES[@command_window.index][0][2])
- when 2
- $game_party.gain_armor(RECIPES[@command_window.index][0][1], RECIPES[@command_window.index][0][2])
- end
- for i in 1...RECIPES[@command_window.index].size
- case RECIPES[@command_window.index][i][0]
- when 0
- $game_party.lose_item(RECIPES[@command_window.index][i][1], RECIPES[@command_window.index][i][2])
- when 1
- $game_party.lose_weapon(RECIPES[@command_window.index][i][1], RECIPES[@command_window.index][i][2])
- when 2
- $game_party.lose_armor(RECIPES[@command_window.index][i][1], RECIPES[@command_window.index][i][2])
- end
- end
- end
- end
- def check_ing
- for i in 1..RECIPES[@command_window.index].size-1
- case RECIPES[@command_window.index][i][0]
- when 0
- unless $game_party.item_number(RECIPES[@command_window.index][i][1]) >= RECIPES[@command_window.index][i][2]
- return false
- end
- when 1
- unless $game_party.weapon_number(RECIPES[@command_window.index][i][1]) >= RECIPES[@command_window.index][i][2]
- return false
- end
- when 2
- unless $game_party.armor_number(RECIPES[@command_window.index][i][1]) >= RECIPES[@command_window.index][i][2]
- return false
- end
- end
- end
- return true
- end
- end
- class Require_Win < Sprite
- include LMM_Craft
- def initialize
- super
- self.bitmap = Bitmap.new(268,253)
- self.x = 329;self.y = 38;self.z = 18
- @rec_id = nil
- self.bitmap.font.name = REQ_FONT
- self.bitmap.font.size = REQ_SIZE
- self.bitmap.font.color = Color.new(0, 0, 0, 255)
- update
- end
- def rec_id(id)
- @rec_id = id
- end
- def update
- super
- self.bitmap.clear
- if @rec_id != nil
- for i in 1..@rec_id.size-1
- case @rec_id[i][0]
- when 0
- maticon = RPG::Cache.icon($data_items[@rec_id[i][1]].icon_name)
- self.bitmap.blt(6, 97 + ((i - 1) * 42), maticon, Rect.new(0, 0, 24, 24), 255)
- text = $data_items[@rec_id[i][1]].name
- self.bitmap.draw_text(39, 100+ ((i - 1) * 42), 154, 20, text,0)
- text2 = "#{@rec_id[i][2].to_s} / #{$game_party.item_number(@rec_id[i][1])}"
- self.bitmap.draw_text(190, 99+ ((i - 1) * 42), 76, 20, text2,1)
- when 1
- maticon = RPG::Cache.icon($data_weapons[@rec_id[i][1]].icon_name)
- self.bitmap.blt(6, 97 + ((i - 1) * 42), maticon, Rect.new(0, 0, 24, 24), 255)
- text = $data_weapons[@rec_id[i][1]].name
- self.bitmap.draw_text(39, 100+ ((i - 1) * 42), 154, 20, text,0)
- text2 = "#{@rec_id[i][2].to_s} / #{$game_party.weapon_number(@rec_id[i][1])}"
- self.bitmap.draw_text(190, 99+ ((i - 1) * 42), 76, 20, text2,1)
- when 2
- maticon = RPG::Cache.icon($data_armors[@rec_id[i][1]].icon_name)
- self.bitmap.blt(6, 97 + ((i - 1) * 42), maticon, Rect.new(0, 0, 24, 24), 255)
- text = $data_armors[@rec_id[i][1]].name
- self.bitmap.draw_text(39, 100+ ((i - 1) * 42), 154, 20, text,0)
- text2 = "#{@rec_id[i][2].to_s} / #{$game_party.armor_number(@rec_id[i][1])}"
- self.bitmap.draw_text(190, 99+ ((i - 1) * 42), 76, 20, text2,1)
- end
- end
- case @rec_id[0][0]
- when 0
- resulticon = RPG::Cache.icon($data_items[@rec_id[0][1]].icon_name)
- self.bitmap.blt(13, 11, resulticon, Rect.new(0, 0, 24, 24), 255)
- desc = $data_items[@rec_id[0][1]].name
- when 1
- resulticon = RPG::Cache.icon($data_weapons[@rec_id[0][1]].icon_name)
- self.bitmap.blt(13, 11, resulticon, Rect.new(0, 0, 24, 24), 255)
- desc = $data_weapons[@rec_id[0][1]].name
- when 2
- resulticon = RPG::Cache.icon($data_armors[@rec_id[0][1]].icon_name)
- self.bitmap.blt(13, 11, resulticon, Rect.new(0, 0, 24, 24), 255)
- desc = $data_armors[@rec_id[0][1]].name
- end
- self.bitmap.draw_text(51, 12, 214,16, desc + (" X "+ @rec_id[0][2].to_s),1)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement