Skyrim Alchemy Script V 1.03
Skyrim Alchemy Script V 1.03By Michael
Introduction
Took a request from this thread.
http://forums.rpgmakerweb.com/index.php?/topic/22006-skyrim-alchemy-script/
Features
What this thread asked
http://forums.rpgmakerweb.com/index.php?/topic/22006-skyrim-alchemy-script/
Screenshots
Screenshot source: chigoo's recipe.
How to Use
Instruction inside, feel free to ask questions if confused.
You can edit the success rate on this line (ignore the game interpreter lol)
#==============================================================================# Success Rate## - Edit as you see fit# - True means the alchemy succeed# - False means the alchemy hasn't succeed# - Default is 100% success rate##==============================================================================class Game_Interpreterattr_accessor :map_id, :event_id, :list, :index, :fiberend#==============================================================================# SCENARIO 1#==============================================================================#WHEN SUCCEES, CALL Suc_EVENT_ID (common event)#WHEN FAIL, CALL Fail_EVENT_ID (common event)Variables_ID = nil #Change variable ID if u're using variable #Change nil to 1 if you're using variable ID 1 #Change nil to 500 if you're using variable ID 500Suc_EVENT_ID = nil #Change to Event ID for Success #Use Common Event ID or something weird will happenFai_EVENT_ID = nil #Change to Event ID for Failure #Use Common Event ID or something weird will happenclass Scene_Alchemy < Scene_MenuBasedef success_rate if rand(100) <= ((Variables_ID) ? $game_variables : 100) ce = $data_common_events unless Suc_EVENT_ID.nil? if ce c = Game_Interpreter.new c.clear c.map_id = $game_map.map_id c.event_id = 0 c.list = ce.list c.create_fiber c.wait_for_message while c.list do c.execute_command c.index += 1 end c.fiber = nil end return true else ce = $data_common_events unless Fai_EVENT_ID.nil? if ce c = Game_Interpreter.new c.clear c.map_id = $game_map.map_id c.event_id = 0 c.list = ce.list c.create_fiber c.wait_for_message while c.list do c.execute_command c.index += 1 end c.fiber = nil end return false endendend#==============================================================================# SCENARIO 2#==============================================================================#Remove "=begin" and "=end" to use=begin #remove this line to use scenario 2, don't forget the "=end" also#WHEN SUCCEES, turn SWITCD_ID on, CALL EVENT_ID (common event)#WHEN FAIL, turn SWITCD_ID off, CALL EVENT_ID (common event)Variables_ID = nil #Change variable ID if u're using variable #Change nil to 1 if you're using variable ID 1 #Change nil to 500 if you're using variable ID 500SWITCH_ID = 999 #Change to SWITCH IDEVENT_ID = nil #Change to Event ID #Use Common Event ID or something weird will happenclass Scene_Alchemy < Scene_MenuBasedef success_rate $game_switches = rand(100) <= ((Variables_ID) ? $game_variables : 100) ce = $data_common_events unless EVENT_ID.nil? if ce c = Game_Interpreter.new c.clear c.map_id = $game_map.map_id c.event_id = 0 c.list = ce.list c.create_fiber c.wait_for_message while c.list do c.execute_command c.index += 1 end c.fiber = nil end $game_switchesendend=end #remove this line to use scenario 2Demo
N/A
Script
Spoiler#==============================================================================## Michael Skyrym Alchemy + Extended# Last Updated: 2014.02.27# V 1.03# Requirement: RPG Maker VX Ace# -Knowledge of 'how to use script and notetag'##==============================================================================# Description#==============================================================================# This script is to do alchemy like in Skyrym GUI but with more dynamic settings##==============================================================================# Compatibility#==============================================================================# - DataManager is the only overloaded class, so compatibility# is pretty high.##==============================================================================# Installation#==============================================================================# - Place anywhere under material section but above main##==============================================================================# How to Use:# - Call Scene by using Script Call# Script: SceneManager.call(Scene_Alchemy)## - use notetag to specify ingredient and product# Notetag for ingredient => <key># #add key(s) here# </key>## For ex: <key># Stone# </key># This item is an inggredient for crafting item(s)# that requires 'stone'.## For ex: <key># Wood# Iron# </key># This item is an inggredient for crafting item(s)# that requires 'wood'.# This item is an inggredient for crafting item(s)# that requires 'iron'.### Notetag for product => <Ingr># key: (IV,IA)# </Ingr># IT = # of Ingredient Variety# IA = # of Ingredient Amount# For ex: <Ingr># stone: (1,2)# </Ingr># This item requires 1 variety of 'stone' key# This item requires 2 each of 'stone' key variety# For ex: <Ingr># stone: (1,2)# wood: (5,12)# </Ingr># This item requires 1 variety of 'stone' key# This item requires 2 each of 'stone' key variety# This item requires 5 variety of 'wood' key# This item requires 12 each of 'wood' key variety##==============================================================================#==============================================================================#Nickname - If you don't like the names of your 'keys', you can set nicknames#==============================================================================Keys_Nickname = {"Example_Key" => "Example_Nickname","ASDkeyQWE" => "ASDNicknameQWE","Dont forget" => "To put comma","Last nick" => "No need comma"}#==============================================================================# Success Rate## - Edit as you see fit# - True means the alchemy succeed# - False means the alchemy hasn't succeed# - Default is 100% success rate##==============================================================================class Game_Interpreter #Ignoreattr_accessor :map_id, :event_id, :list, :index, :fiber #Ignoreend #Ignore#==============================================================================# SCENARIO 1#==============================================================================#WHEN SUCCEES, CALL Suc_EVENT_ID (common event)#WHEN FAIL, CALL Fail_EVENT_ID (common event)Variables_ID = nil #Change variable ID if u're using variable #Change nil to 1 if you're using variable ID 1 #Change nil to 500 if you're using variable ID 500Suc_EVENT_ID = nil #Change to Event ID for Success #Use Common Event ID or something weird will happenFai_EVENT_ID = nil #Change to Event ID for Failure #Use Common Event ID or something weird will happenclass Scene_Alchemy < Scene_MenuBasedef success_rate if rand(100) <= ((Variables_ID) ? $game_variables : 100) ce = $data_common_events unless Suc_EVENT_ID.nil? if ce c = Game_Interpreter.new c.clear c.map_id = $game_map.map_id c.event_id = 0 c.list = ce.list c.create_fiber c.wait_for_message while c.list do c.execute_command c.index += 1 end c.fiber = nil end return true else ce = $data_common_events unless Fai_EVENT_ID.nil? if ce c = Game_Interpreter.new c.clear c.map_id = $game_map.map_id c.event_id = 0 c.list = ce.list c.create_fiber c.wait_for_message while c.list do c.execute_command c.index += 1 end c.fiber = nil end return false endendend#==============================================================================# SCENARIO 2#==============================================================================#Remove "=begin" and "=end" to use=begin #remove this line to use scenario 2, don't forget the "=end" also#WHEN SUCCEES, turn SWITCD_ID on, CALL EVENT_ID (common event)#WHEN FAIL, turn SWITCD_ID off, CALL EVENT_ID (common event)Variables_ID = nil #Change variable ID if u're using variable #Change nil to 1 if you're using variable ID 1 #Change nil to 500 if you're using variable ID 500SWITCH_ID = 999 #Change to SWITCH IDEVENT_ID = nil #Change to Event ID #Use Common Event ID or something weird will happenclass Scene_Alchemy < Scene_MenuBasedef success_rate $game_switches = rand(100) <= ((Variables_ID) ? $game_variables : 100) ce = $data_common_events unless EVENT_ID.nil? if ce c = Game_Interpreter.new c.clear c.map_id = $game_map.map_id c.event_id = 0 c.list = ce.list c.create_fiber c.wait_for_message while c.list do c.execute_command c.index += 1 end c.fiber = nil end $game_switchesendend=end #remove this line to use scenario 2#==============================================================================# More Customization~#- Edit As You See Fit#==============================================================================Success_Message = "Gratz, Ya Dawg"Fail_Message = " stole Yo Item"Cannot_Make = "Not Enough Ingredient"#==============================================================================##REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER#- check spelling before reporting error### #=================================== End ===================================###Have Fun!##==============================================================================#==============================================================================# Bio#==============================================================================## 2014.02.27 - V 1.03GUI Update# Custom Message Upon Success / Fail / N/A is initialized# Cut Down Performance Cost# 2014.02.25 - V 1.02Cut Down Performance Cost# Fixed Custom SaveScript Compatibility# 2014.02.24 - V 1.01Minor event call fix and script trimmed down# 2014.02.23 - V 1.00Script is released and up for bug testing# 2014.02.23 - V 0.14Implementing Alchemy Algoritm# 2014.02.22 - V 0.13GUI is finished# 2014.02.10 - V 0.12Notetag reader is implemented# 2014.02.09 - V 0.11Game_Alchemy is made# 2014.02.08 - V 0.1 Script is initailized##==============================================================================class SkyAlcattr_accessor :id, :name, :icon_index, :description, :noteattr_accessor :cmake, :ingr, :keys, :usedattr_accessor :itypedef initialize(item) @id = item.id @name = item.name @icon_index = item.icon_index @description = item.description @note = item.note @itype = 0 if item.is_a?(RPG::Item) @itype = 1 if item.is_a?(RPG::Weapon) @itype = 2 if item.is_a?(RPG::Armor) @cmake = falseenddef cb case @itype when 0; return $data_items[@id] when 1; return $data_weapons[@id] when 2; return $data_armors[@id] endenddef get_ingr(string) @ingr = Hash.new {|h,k| h=[]} if @ingr.nil? @refrigerator = Hash.new {|h,k| h=[]} if @refrigerator.nil? @ingr)/i]] << string[/(?<=[(]).*?(?=[,])/].to_i << string[/(?<=[,]).*?(?=[)])/].to_i @refrigerator)/i]] << string[/(?<=[(]).*?(?=[,])/].to_i << string[/(?<=[,]).*?(?=[)])/].to_ienddef get_keys(string) @used = Hash.new if @used.nil? @used = falseenddef nf(string); @ingr != 0 enddef cF; @ingr.each_key do |k|; return false if nf(k) end; return true enddef reset_ingr(key); @ingr = @refrigerator.dup endend#==============================================================================# DataManager#==============================================================================module DataManagerclass << self; alias mcgo create_game_objects enddef self.create_game_objects; mcgo; $ga = Game_Alchemy.new endend#==============================================================================# Game_Alchemy#==============================================================================class Game_Alchemyattr_accessor
r, :keysdef initialize @pr = Array.new @keys = Hash.new {|h,k| h=[]} [$data_items, $data_weapons, $data_armors].each { |array| array.each { |i| @just_once = true i.note.split(/[\r\n]+/).each { |nt| case nt when /<(?:ingr?)>/i; @gi = true when /<\/(?:ingr?)>/i; @gi = false when /<(?:key?)>/i; @gk = true when /<\/(?:key?)>/i; @gk = false else if @gi (@just_once = false; @pr << SkyAlc.new(i)) if @just_once; @pr.last.get_ingr(nt) end if @gk @keys << SkyAlc.new(i); @keys.last.get_keys(nt) end end if i.note.match(/<(?:ingr?)>/i) || i.note.match(/<(?:key?)>/i) } unless i.nil? } } @pr.each { |item| checkCanMake?(item) }enddef checkCanMake?(item) getPair(item) lss = item.ingr.size sp = Hash.new item.ingr.each_pair { |k, v| lsr = v @keys.each { |t| ((@p.include?(t.name)) ? sp ||= 0 : lsr -= 1) if $game_party.item_number(t.cb) >= v (sp += v; lsr -= 1 if $game_party.item_number(t.cb) >= sp) if sp && lsr > 0 } lss -= 1 if lsr <= 0 } item.cmake = (lss <= 0); @p = nil; sp = nilenddef getPair(item) b = Array.new; @p = Array.new item.ingr.each_key { |k| @keys.each { |i| (b.include?(i.name)) ? @p << i.name : b << i.name} }enddef rU(i); @pr.ingr.each_key { |k| @keys.each { |item| item.used = false } } enddef rR(i); @pr.ingr.each_key { |k| @pr.reset_ingr(k)} endend#==============================================================================# Scene_Alchemy#==============================================================================class Scene_Alchemy < Scene_MenuBasedef start super create_help_window; create_product_window create_ingredient_window; create_confirm_window @help_window.x = 0; @help_window.y = 344 @help_window.width = 544; @help_window.height = 72enddef create_product_window @pw = Window_Product.new(0,0) @pw.set_handler
product,method
selectIngredient)) @pw.set_handler
cancel, method
return_scene)) @pw.help_window = @help_window @pw.activate @pw.refreshenddef selectIngredient if $ga.pr[@pw.in].cmake @pw.deactivate; @iw.activate @iw.sl; @sui = Array.new else cs; @pw.activate endenddef create_ingredient_window @iw = Window_Ingredient.new(48,0) @iw.sh
ok, method
ingredientSelect)) @iw.sh
cancel, method
returnProduct)) @iw.hw = @help_window @pw.iw = @iw @iw.deactivateenddef ingredientSelect(i) @usedIngr = i; @sui << i @iw.deactivate; @cw.activate @cw.show; @cw.openenddef returnProduct $ga.rU(@pw.in); $ga.rR(@pw.in) @pw.update; @iw.refresh; @iw.sl; @iw.deactivate; @pw.activate; enddef create_confirm_window @cw = Window_Confirm.new(172, 208) @cw.width = 200 @cw.set_handler
Confirm, method
confirm)) @cw.set_handler
Cancel, method
cancel)) @cw.set_handler
cancel, method
cancel)) @cw.z = 200; @cw.deactivate @cw.hide; @cw.closeenddef confirm @iw.data[@usedIngr].used[@iw.ika[@usedIngr]] = true $ga.pr[@pw.in].ingr[@iw.ika[@usedIngr]] -= 1 @cw.deactivate; @cw.hide; @cw.close if $ga.pr[@pw.in].cF confirm_alchemy $ga.rU(@pw.in); $ga.rR(@pw.in) @iw.refresh; @pw.update; if $ga.pr[@pw.in].cmake @iw.activate; @iw.sl else @pw.activate end else @iw.refresh; @iw.activate; @iw.sl endenddef confirm_alchemy @sui.each do |i| $game_party.gain_item(@iw.data.cb, -$ga.pr[@pw.in].ingr[@iw.ika]) end (success_rate) ? ($game_party.gain_item($ga.pr[@pw.in].cb,1); sm) : fmenddef cancel @iw.activate; @iw.sl; @cw.deactivate; @cw.hide; @cw.closeenddef cs w = Window_Message.new; Sound.play_buzzer; b = Bitmap.new(w.text_size(Cannot_Make).width + 2,60) b.draw_text(0, 20,w.text_size(Cannot_Make).width + 2, 40, Cannot_Make); w.contents = b w.width = w.text_size(Cannot_Make).width + 32; w.height = 100; w.visible = true; w.openness = 255 w.x = 100; w.y = 180; w.back_opacity = 255; w.opacity = 255 w.update; Graphics.wait(70); b.dispose; w.disposeenddef sm w = Window_Message.new; Sound.play_buzzer; b = Bitmap.new(w.text_size(Success_Message).width + 2,60) b.draw_text(0, 20,w.text_size(Success_Message).width + 2, 40, Success_Message); w.contents = b w.width = w.text_size(Success_Message).width + 32; w.height = 100; w.visible = true; w.openness = 255 w.x = 100; w.y = 180; w.back_opacity = 255; w.opacity = 255 w.update; Graphics.wait(70); b.dispose; w.disposeenddef fm w = Window_Message.new; Sound.play_buzzer; b = Bitmap.new(w.text_size(Fail_Message).width + 2,60) b.draw_text(0, 20,w.text_size(Fail_Message).width + 2, 40, Fail_Message); w.contents = b w.width = w.text_size(Fail_Message).width + 32; w.height = 100; w.visible = true; w.openness = 255 w.x = 100; w.y = 180; w.back_opacity = 255; w.opacity = 255 w.update; Graphics.wait(70); b.dispose; w.disposeendend#==============================================================================# Window_Product#==============================================================================class Window_Product < Window_Commandattr_accessor :iw #Ingredient Windowattr_accessor :in #Index Numberdef make_command_list; $ga.pr.each do |i| add_command(i.name,
roduct) end enddef window_width; 48 enddef window_height; 344 enddef item; $ga.pr && index >= 0 ? $ga.pr : nil enddef select_last; select(0) enddef update; super; @iw.c = $ga.pr if @iw; @in = index; refresh enddef iw=(iw); @iw = iw; update enddef update_help; @help_window.set_item(item) enddef refresh; super; checkEnable enddef checkEnable(k = nil) $ga.pr.each do |i| $ga.checkCanMake?(i) end enddef draw_icon(i, x, y, enabled = true) bitmap = Cache.system("Iconset") rect = Rect.new(i % 16 * 24, i / 16 * 24, 24, 24) contents.blt(x, y, bitmap, rect, enabled ? 255 : 100)enddef item_rect(i) rect = Rect.new; rect.width = rect.height = 24 rect.x = 0; rect.y = i * 24; rectenddef draw_item(index) rect = item_rect(index) rect.x += 4; rect.width -= 8 icon_index = $ga.pr.icon_index self.contents.clear_rect(rect) if !icon_index.nil? rect.x -= 4 draw_icon(icon_index, rect.x, rect.y, $ga.pr.cmake) rect.x += 26; rect.width -= 20 end self.contents.clear_rect(rect)endend#==============================================================================# Window_Confirm#==============================================================================class Window_Confirm < Window_Commanddef make_command_list; add_command('Confirm', :Confirm); add_command('Cancel',:Cancel) endend#==============================================================================# Window_Ingredient#==============================================================================class Window_Ingredient < Window_Baseattr_reader :index, :hw, :data, :ika def initialize(x, y, width = 496, height = 344) super @index = -1; @h = {}; self.padding_bottom = 20; deactivate; refresh; select(1); activate; @c = nil; @data = []enddef in; @data.index($game_party.last_item.object) end #index numberdef contents_height; (item_max + 2) * 24 enddef active=(active); super; uc; cuh enddef index=(index); @index = index; @index = 1 if @index == 0; uc; cuh enddef select(index); self.index = index if index enddef unselect; self.index = -1 enddef hw=(hw); @hw = hw; cuh enddef sl; select(1) enddef sh(s, method); @h = method enddef ch(s, i = nil); (i) ? @h.call(i) : @h.call enddef cm; active && open? && item_max > 0 enddef cd(wrap = false) ((@data.is_a?(String)) ? select((index + 2) % item_max) : select((index + 1) % item_max)) if index < item_max - 1 || (wrap)enddef cu(wrap = false) ((@data.is_a?(String)) ? select((index - 2 + item_max) % item_max) : select((index - 1 + item_max) % item_max)) if (index >= 2 || (wrap) || top_row > 0)enddef cpd if top_row + 11 < item_max self.top_row += 11 (@index + 11 > item_max - 1) ? select(item_max - 1) : ((@data[@index + 11].class.is_a?(String)) ? (self.top_row += 1; select(@index + 12)) : select(@index + 11)) endenddef cpu if top_row > 0 self.top_row -= 11 (@index - 11 < 0) ? select(@data) : ((@data[@index - 11].is_a?(String)) ? select(@index - 10) : select(@index - 11)) endenddef update; super; pcm; ph enddef pcm return unless cm li = @index cd(Input.trigger?
DOWN))if Input.repeat?
DOWN) cu(Input.trigger?
UP)) if Input.repeat?
UP) cpd if Input.trigger?
R) cpu if Input.trigger?
L) Sound.play_cursor if @index != lienddef ph return unless open? && active return poif oe && Input.trigger?
C) return pcif ce && Input.trigger?
return ppd if Input.trigger?
R) return ppu if Input.trigger?
L)enddef ce; true enddef po (cie(@ika)) ? (Sound.play_ok; Input.update; deactivate; coh(index)) : Sound.play_buzzerenddef pc; Sound.play_cancel; Input.update; deactivate; cch enddef cch; ch
cancel) enddef ppu; Sound.play_cursor; Input.update; deactivate; ch
pageup) enddef ppd; Sound.play_cursor; Input.update; deactivate; ch
pagedown) enddef uc; (@index < 0) ? cursor_rect.empty : (ecv; cursor_rect.set(item_rect(@index))) enddef top_row; oy/24 enddef top_row=(index) index = 0 if index < 0 index = item_max - 1 if index > item_max - 1 self.oy = index * 24enddef ecv self.top_row = index if index < top_row self.top_row = index - 10 if index > top_row + 10 self.top_row = 0 if index == 1enddef cuh; uh if active && @hw enddef oe; true enddef coh(i); ch
ok, i) enddef c=(p); return if @c == p; @c = p; refresh enddef item_max; @data ? @data.size : 1 enddef item; @data && index >= 0 ? @data : nil enddef cie(ik); enable?(@data, ik) enddef item_rect(i) rect = Rect.new; rect.width = 472; rect.height = 24 rect.x = 0; rect.y = (i + 2) * 24; rectenddef di return if @c.nil? draw_title @data.size.times { |i| if @data.is_a?(String) draw_text(24, 0, 350, 48, "#{@c.name}") @ik = @data; @ika << @ik change_color(text_color(0), @c.nf(@ik)) draw_text(24, (i + 2) * 24, 350, 24, "#{(Keys_Nickname[@data] ||= @data)}" + ": Select " + "(%2d)" % @c.ingr[@data]) else; (draw_item(i, @ik); @ika << @ik) end }enddef draw_titleenddef he(item, ik); $game_party.item_number(item.cb) >= @c.ingr enddef enable?(item, ik); he(item, ik) && !item.used && @c.nf(ik) enddef mil return if @c.nil? @c.ingr.each_key { |k| @data << k; (0...$ga.keys.size).each { |i| @data << $ga.keys } }enddef draw_item(index, ik) return if @data.nil? item = @data if item rect = item_rect(index); rect.width -= 4 draw_item_name(item, rect.x, rect.y, enable?(item, ik)) din(rect, item); dir(rect, item, ik) endenddef din(rect, item) draw_text(270, rect.y, 100, 24, "%2d" % $game_party.item_number(item.cb)) enddef dir(rect, item, ik) draw_text(290, rect.y, 120, 24, "(%2d)" % @c.ingr) enddef uh; @hw.set_item(item) enddef refresh; @ika = Array.new; @data = []; mil; create_contents; di endend
Term of Use:
Use however you want it.
You can burn, make slave, whatever.
Credit is also optional, though use Michael instead Mike if you would like to credit me. : x
本贴来自国际rpgmaker官方论坛作者:Mike处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/skyrim-alchemy-script-v-1-03.24077/
页:
[1]