Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # LM² - Forge
- # Data 29/08/17
- # Criado por LeonMM
- # 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.
- module LMM_Forge
- WTITLE = "Forja"
- CREATE = "Forjar"
- RECIPES = []
- RECIPES[0] = [[1, 1, 3], [0, 3, 2], [1, 4, 2]]
- RECIPES[1] = [[0, 5, 1], [0, 4, 3]]
- RECIPES[2] = [[0, 13, 1], [0, 13, 2], [0, 12, 2], [0, 11, 1]]
- RECIPES[3] = [[0, 25, 1], [0, 25, 2], [0, 25, 2], [0, 25, 1], [0, 25, 2]]
- RECIPES[4] = [[0, 2, 1], [0, 1, 3]]
- RECIPES[5] = [[0, 7, 1], [0, 1, 3], [0, 4, 3]]
- RECIPES[6] = [[0, 2, 1], [0, 1, 3]]
- MAT_X_POS = [7,7,82,82]
- MAT_Y_POS = [55,91,55,91]
- NCOLOR = Color.new(195,0,0)
- PCOLOR = Color.new(0,195,0)
- end
- # Janela de Forja
- class Forge_Window < Window_Base
- include LMM_Forge
- def initialize
- super(480, 125, 182, 152)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.visible = self.active = false
- draw_title(WTITLE)
- draw_help
- @create_bt = Button.new(self, 102, 25, CREATE) { create }
- #self.contents.font.size = 10
- @bg = RPG::Cache.picture('Crafting')
- @dragable = true
- @closable = true
- end
- def trigger
- super
- $windows[:forge_list].trigger
- end
- def on_close
- super
- $windows[:forge_list].on_close
- end
- def refresh
- self.contents.clear
- recipe = RECIPES[$windows[:forge_list].recipeS]
- self.contents.font.color = normal_color
- self.contents.blt(0, 0, @bg, Rect.new(0, 0, @bg.width, @bg.height))
- recicon = RPG::Cache.icon(help_return(recipe,0).icon_name)
- self.contents.blt(7,7, recicon, Rect.new(0, 0, 24, 24), 255)
- desc = help_return(recipe,0).name
- self.contents.draw_text(34, 12, 150,16, " X "+ recipe[0][2].to_s)
- self.contents.draw_text(7, 32, 150,16, desc)
- self.contents.font.color = check_ing ? PCOLOR : NCOLOR
- check_ing ? @create_bt.show : @create_bt.hide
- for i in 1..recipe.size-1
- recicon = RPG::Cache.icon(help_return(recipe,i).icon_name)
- self.contents.blt(MAT_X_POS[i-1],MAT_Y_POS[i-1], recicon, Rect.new(0, 0, 24, 24), 255)
- text = "#{number_return(recipe,i)} / #{recipe[i][2].to_s} "
- self.contents.draw_text(MAT_X_POS[i-1]+26,MAT_Y_POS[i-1], 48, 20, text,1)
- end
- end
- def update
- super
- create_help if in_area?(0,16)
- end
- def create_help
- recipel = RECIPES[$windows[:forge_list].recipeS]
- if in_area?(21, 21, 26, 26) and $mouse.object == nil
- show_help(help_return(recipel,0))
- elsif in_area?(21, 70, 26, 26) and recipel.size > 1 and $mouse.object == nil
- show_help(help_return(recipel,1))
- elsif in_area?(21, 107, 26, 26) and recipel.size > 2 and $mouse.object == nil
- show_help(help_return(recipel,2))
- elsif in_area?(97, 70, 26, 26) and recipel.size > 3 and $mouse.object == nil
- show_help(help_return(recipel,3))
- elsif in_area?(97, 107, 26, 26) and recipel.size > 4 and $mouse.object == nil
- show_help(help_return(recipel,4))
- else
- hide_help
- end
- end
- def create
- recipe = RECIPES[$windows[:forge_list].recipeS]
- case recipe[0][0]
- when 0
- $game_party.gain_item(recipe[0][1], recipe[0][2])
- when 1
- $game_party.gain_weapon(recipe[0][1], recipe[0][2])
- when 2
- $game_party.gain_armor(recipe[0][1], recipe[0][2])
- end
- for i in 1...recipe.size
- case recipe[i][0]
- when 0
- $game_party.lose_item(recipe[i][1], recipe[i][2])
- when 1
- $game_party.lose_weapon(recipe[i][1], recipe[i][2])
- when 2
- $game_party.lose_armor(recipe[i][1], recipe[i][2])
- end
- end
- refresh
- $windows[:forge_list].refresh
- end
- def help_return(recipe,pos)
- case recipe[pos][0]
- when 0
- return $data_items[recipe[pos][1]]
- when 1
- return $data_weapons[recipe[pos][1]]
- when 2
- return $data_armors[recipe[pos][1]]
- end
- end
- def number_return(recipe,pos)
- case recipe[pos][0]
- when 0
- return $game_party.item_number(recipe[pos][1])
- when 1
- return $game_party.weapon_number(recipe[pos][1])
- when 2
- return $game_party.armor_number(recipe[pos][1])
- end
- end
- def check_ing
- recipe = RECIPES[$windows[:forge_list].recipeS]
- for i in 1..recipe.size-1
- case recipe[i][0]
- when 0
- unless $game_party.item_number(recipe[i][1]) >= recipe[i][2]
- return false
- end
- when 1
- unless $game_party.weapon_number(recipe[i][1]) >= recipe[i][2]
- return false
- end
- when 2
- unless $game_party.armor_number(recipe[i][1]) >= recipe[i][2]
- return false
- end
- end
- end
- return true
- end
- end
Add Comment
Please, Sign In to add comment