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
- # Adicone abaixo este código:
- # $game_craft = Game_Craft.new
- # Procure por:
- # Marshal.dump($game_player, file)
- # Adicone abaixo este código:
- # Marshal.dump($game_craft, file)
- # Procure por:
- # $game_player = Marshal.load(file)
- # Adicone 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/ Máx 8.
- RECIPE_VIEW = 8
- #QUANTIDADE DE RECEITAS
- RECIPE_Q = 9
- # Configuração de Receitas
- # RECIPE[id] = [dif , [it_type, it_id, item_qty],[mat_*_type, mat_*_id, mat_*_qty], ...]
- # dif = dificuldade da receita, 0 = fácil, 1 = médio, 2 = difícil
- # 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 vigula
- #após, e colocar mais um conjunto dentro de chaves, no máximo 4
- #itens podem ser usados.
- RECIPES = []
- RECIPES[0] = [0, [1, 1, 3], [0, 3, 2], [1, 4, 2]]
- RECIPES[1] = [1, [0, 10, 1], [0, 13, 2]]
- RECIPES[4] = [2, [0, 10, 1], [0, 13, 2], [0, 12, 2], [0, 11, 1]]
- RECIPES[8] = [0, [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
- # Alterar termos da Dificuldade da Receita
- DIF_TERM = ["Fácil", "Médio", "Difícil"]
- # Nível Máximo de Crafting
- MAX_LEVEL = 10
- # Base para Cálculo da Experiência Necessária
- BASE_EXP = 25
- # Taxa de Acerto por Nível e Dificuldade
- # (Quantidade por Dificuldade = Nivel Máximo + 1)
- ACC_RATE = []
- ACC_RATE[0] = [30,35,40,45,50,65,75,80,85,95,100]
- ACC_RATE[1] = [20,25,30,35,45,50,65,70,80,90,100]
- ACC_RATE[2] = [5,15,20,25,30,35,45,55,65,75,85]
- # Exp ganha
- EXP_ERRO = 5
- EXP_ACERTO = [10, 15, 20]
- # 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
- attr_accessor :level
- attr_accessor :exp
- attr_accessor :next_exp
- def initialize
- @recipes = []
- for i in 0..LMM_Craft::RECIPE_Q - 1
- @recipes.push(false)
- end
- @level = 0
- @exp = 0
- @exp_list = Array.new(LMM_Craft::MAX_LEVEL+1)
- make_exp_list
- @next_exp = @exp_list[@level+1]
- end
- def make_exp_list
- @maxexp = 0
- @exp_list[0] = 0
- @exp_list[1] = LMM_Craft::BASE_EXP
- for i in 2..LMM_Craft::MAX_LEVEL
- if i == LMM_Craft::MAX_LEVEL
- @exp_list[i] = 0
- else
- @exp_list[i] = LMM_Craft::BASE_EXP + @exp_list[i-1] + @exp_list[i-2]
- end
- @maxexp += @exp_list[i]
- end
- end
- def add_exp(exp)
- @exp += exp
- if @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
- @level += 1
- @next_exp = @exp_list[@level+1]
- @exp = 0
- 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
- @LVL = Sprite.new
- @LVL.bitmap = Bitmap.new(20,25)
- @LVL.x = 62; @LVL.y = 377; @LVL.z = 18
- @LVL.bitmap.font.name = REQ_FONT
- @LVL.bitmap.font.size = REQ_SIZE
- @LVL.bitmap.font.color = Color.new(0, 0, 0, 255)
- @LVL.bitmap.clear
- @LVL.bitmap.draw_text(0, 0, 20, 25, $game_craft.level.to_s,1)
- @TEXT = Sprite.new
- @TEXT.bitmap = Bitmap.new(198,25)
- @TEXT.x = 362; @TEXT.y = 377; @TEXT.z = 18
- @TEXT.bitmap.font.name = REQ_FONT
- @TEXT.bitmap.font.size = REQ_SIZE
- @TEXT.bitmap.font.color = Color.new(0, 0, 0, 255)
- @TEXT.bitmap.clear
- @TEXT.bitmap.draw_text(0, 0, 198, 25, "Aguardando!",1)
- @LVLBAR = Sprite.new
- @LVLBAR.bitmap = Bitmap.new(202,9)
- @LVLBAR.x = 83; @LVLBAR.y = 385; @LVLBAR.z = 18
- @LVLBARIMG = RPG::Cache.picture("Window_Craft/Exp_Bar")
- @LVLBARRECT = Rect.new(0,0, @LVLBARIMG.width * $game_craft.exp / $game_craft.next_exp, @LVLBARIMG.height)
- @LVLBAR.bitmap.clear
- @LVLBAR.bitmap.blt(0,0, @LVLBARIMG, @LVLBARRECT)
- @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
- @LVL.dispose
- @TEXT.dispose
- @LVLBAR.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)
- @try = rand(100) + 1
- if(@try <= ACC_RATE[RECIPES[@command_window.index][0]][$game_craft.level])
- case RECIPES[@command_window.index][1][0]
- when 0
- $game_party.gain_item(RECIPES[@command_window.index][1][1], RECIPES[@command_window.index][0][2])
- when 1
- $game_party.gain_weapon(RECIPES[@command_window.index][1][1], RECIPES[@command_window.index][0][2])
- when 2
- $game_party.gain_armor(RECIPES[@command_window.index][1][1], RECIPES[@command_window.index][0][2])
- end
- $game_craft.add_exp(EXP_ACERTO[RECIPES[@command_window.index][0]])
- @TEXT.bitmap.font.color = Color.new(0, 150, 0, 255)
- @TEXT.bitmap.clear
- @TEXT.bitmap.draw_text(0, 0, 198, 25, "Item Criado!",1)
- else
- $game_craft.add_exp(EXP_ERRO)
- @TEXT.bitmap.font.color = Color.new(255, 0, 0, 255)
- @TEXT.bitmap.clear
- @TEXT.bitmap.draw_text(0, 0, 198, 25, "Falha ao criar Item!",1)
- end
- for i in 2...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
- @LVLBARRECT = Rect.new(0,0, @LVLBARIMG.width * $game_craft.exp / $game_craft.next_exp, @LVLBARIMG.height)
- @LVLBAR.bitmap.clear
- @LVLBAR.bitmap.blt(0,0, @LVLBARIMG, @LVLBARRECT)
- @LVL.bitmap.clear
- @LVL.bitmap.draw_text(0, 0, 20, 25, $game_craft.level.to_s,1)
- end
- end
- def check_ing
- for i in 2..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 2..@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 - 2) * 42), maticon, Rect.new(0, 0, 24, 24), 255)
- text = $data_items[@rec_id[i][1]].name
- self.bitmap.draw_text(39, 99 + ((i - 2) * 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 - 2) * 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 - 2) * 42), maticon, Rect.new(0, 0, 24, 24), 255)
- text = $data_weapons[@rec_id[i][1]].name
- self.bitmap.draw_text(39, 99 + ((i - 2) * 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 - 2) * 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 - 2) * 42), maticon, Rect.new(0, 0, 24, 24), 255)
- text = $data_armors[@rec_id[i][1]].name
- self.bitmap.draw_text(39, 99 + ((i - 2) * 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 - 2) * 42), 76, 20, text2,1)
- end
- end
- case @rec_id[1][0]
- when 0
- resulticon = RPG::Cache.icon($data_items[@rec_id[1][1]].icon_name)
- self.bitmap.blt(13, 11, resulticon, Rect.new(0, 0, 24, 24), 255)
- desc = $data_items[@rec_id[1][1]].name
- when 1
- resulticon = RPG::Cache.icon($data_weapons[@rec_id[1][1]].icon_name)
- self.bitmap.blt(13, 11, resulticon, Rect.new(0, 0, 24, 24), 255)
- desc = $data_weapons[@rec_id[1][1]].name
- when 2
- resulticon = RPG::Cache.icon($data_armors[@rec_id[1][1]].icon_name)
- self.bitmap.blt(13, 11, resulticon, Rect.new(0, 0, 24, 24), 255)
- desc = $data_armors[@rec_id[1][1]].name
- end
- self.bitmap.draw_text(51, 12, 214,16, desc + (" X "+ @rec_id[1][2].to_s) + (" | " + DIF_TERM[@rec_id[0]]) + (" | " +ACC_RATE[@rec_id[0]][$game_craft.level].to_s + "%"),1)
- end
- end
- end
Add Comment
Please, Sign In to add comment