Pomógł: 26 razy Dołączył: 25 Wrz 2011 Posty: 236 Skąd: ty się tu wziąłeś?
Wysłany: Czw 13 Paź, 2011 16:45
SynthesisShop
SynthesisShop VX
RPG Maker: VX
Skrypt łączenia przedmiotów w sklepie VX.
Autor: Zylos,przetłumaczony przez:Vrona
Skrypt:
Spoiler:
Kod:
#==========================================================================
# Synthesis Shop (VX)
# Version: 1.0
# Autor: Zylos (rmrk.net)
# Tłumacz:Vrona
# Date: February 25, 2011
#--------------------------------------------------------------------------
# Opis:
#
# Skrypt pozwala łączyć przedmioty,bronie i pancerze ze sobą,aby uzyskać # lepszą
# lub droższą,jednak poterzebuje do tego pieniędzy.Połączenia takie
# kontrolować jednym przełącznikiem.
#----------------------------------------------------------------------
# Instrukcje:
#
# - Wklej skrypt nad Main.
# - Wybierz przełacznik włączający syntezę,wprowadzając jego #ID.Domyślne ID
# to 14.
# - Stworz polecenia syntezy,wpisując w pole note/notatki ten kod:
#
# \cost[] - koszt przedmiotu/wykonania syntezy.
# \type1[] - ID typu pierwszego wymaganego przedmiotu.Patrz #sekcję ID.
# \type2[] - To samo co wyżej,tylko dla drugiego materiału.
# \id1[] - ID w bazie danych pierwszego przedmiotu.
# \id2[] - To samo co wyżej,tyle że drugi przedmiot.
#
# Dla przykładu,jeżeli chcemy stwożycz dwóch krotkich mieczy jeden #szeroki
# za 150 goldów,wpisujemy w Note:
# \cost[150], \type1[1], \type2[1], \id1[2], and \id2[2]. Na #zasadzie tego
# wzoru stworz inne przemioty
# - To create a synthesis shop in the game, simply flip on the #synthesis
# switch that you designated earlier and set up a shop like you #normally
# would, using only the goods you have already marked for synthesis. #Be
# sure to remember to turn the switch off again afterward too.
# ~~Dopiek tłumacza~~
# Niestety nie pamiętam co to znaczy,ale powiem w skrócie:
# - Aby stworzyć sklep syntezy,zmien przełącznik odpowiadający za #syntezę na
# ON i otworz zwyczajnie sklep,używając polecenia zdarzenia "Postaw #Sklep"
# - ID 0 oznacza przedmiot,1 bron,a 2 zbroję.
#
#==========================================================================
module Synth_Switch
#==========================================================================
# UWAGA!Tutaj ustawiasz ID switha aktywującego syntezy.ustawienie go na #ON
# powoduje zmienienie wszystkich sklepów w grze na syntezowe,ustawienie #na OFF
# zmienie wszystkie sklepy na normalne.
# ID switha:
#==========================================================================
Synthesis_Switch = 14 #Swith Syntezy
#============================================================================
# Other than this bit here, you won't need to edit anything in the script
# itself. Everything else can be done in the noteboxes of the database.
#============================================================================
end
#==============================================================================
# ** Module RPG
#------------------------------------------------------------------------------
# The coding used in checking the noteboxes of the synthesizable items.
# ~~I kolejny dopisek tłumacza~~
# Sczerze nie kamam linijek od 51 do tej.Nie zostały więc stłumaczone.
#==============================================================================
module RPG
class BaseItem
def s_cost # The price of the synthesized good.
@s_cost = self.note[/\\COST\[(\d+)\]/i] != nil ? $1.to_i : 0 if @s_cost == nil
return @s_cost
end
def s_req_1_type # The object type of the first required material.
@s_req_1_type = self.note[/\\TYPE1\[(\d+)\]/i] != nil ? $1.to_i : 0 if @s_req_1_type == nil
return @s_req_1_type
end
def s_req_1_id # The ID of the first required material.
@s_req_1_id = self.note[/\\ID1\[(\d+)\]/i] != nil ? $1.to_i : 1 if @s_req_1_id == nil
return @s_req_1_id
end
def s_req_2_type # The object type of the second required material.
@s_req_2_type = self.note[/\\TYPE2\[(\d+)\]/i] != nil ? $1.to_i : 0 if @s_req_2_type == nil
return @s_req_2_type
end
def s_req_2_id # The ID of the second required material.
@s_req_2_id = self.note[/\\ID2\[(\d+)\]/i] != nil ? $1.to_i : 1 if @s_req_2_id == nil
return @s_req_2_id
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# The switch redirecting a normal shop call to a synthesis shop.
#==============================================================================
class Scene_Map < Scene_Base
def call_shop
$game_temp.next_scene = nil
if $game_switches[Synth_Switch::Synthesis_Switch]
$scene = Scene_Synthesis.new
else
$scene = Scene_Shop.new
end
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# Adding a bit to the window base to add transparency to faces.
#==============================================================================
#==============================================================================
# ** Window_SynthBuy
#------------------------------------------------------------------------------
# This window displays the synthesizable goods in the synthesis shop.
#==============================================================================
class Window_SynthBuy < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 304, 232)
@shop_goods = $game_temp.shop_goods
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Get Required Material One
#--------------------------------------------------------------------------
def req1
type1 = item.s_req_1_type
id1 = item.s_req_1_id
case type1
when 0
@req1 = $data_items[id1]
when 1
@req1 = $data_weapons[id1]
when 2
@req1 = $data_armors[id1]
end
return @req1
end
#--------------------------------------------------------------------------
# * Get Required Material Two
#--------------------------------------------------------------------------
def req2
type2 = item.s_req_2_type
id2 = item.s_req_2_id
case type2
when 0
@req2 = $data_items[id2]
when 1
@req2 = $data_weapons[id2]
when 2
@req2 = $data_armors[id2]
end
return @req2
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
number = $game_party.item_number(item)
type1 = item.s_req_1_type
id1 = item.s_req_1_id
case type1
when 0
req1 = $data_items[id1]
when 1
req1 = $data_weapons[id1]
when 2
req1 = $data_armors[id1]
end
type2 = item.s_req_2_type
id2 = item.s_req_2_id
case type2
when 0
req2 = $data_items[id2]
when 1
req2 = $data_weapons[id2]
when 2
req2 = $data_armors[id2]
end
if req1 == req2
enabled = (item.s_cost <= $game_party.gold and number < 99 and $game_party.item_number(req1) > 1)
else
enabled = (item.s_cost <= $game_party.gold and number < 99 and $game_party.item_number(req1) > 0 and $game_party.item_number(req2) > 0)
end
rect = item_rect(index)
self.contents.clear_rect(rect)
draw_item_name(item, rect.x, rect.y, enabled)
rect.width -= 4
self.contents.draw_text(rect, item.s_cost, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
end
#==============================================================================
# ** Window_SynthStatus1
#------------------------------------------------------------------------------
# This window displays the current amount of gold, the number of items
# possessed, and the number of items currently equiped.
#==============================================================================
class Window_SynthStatus1 < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 240, 116)
@item = nil
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, WLH*1.5, "Funds")
cd = contents.text_size(Vocab::gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 200-cd-2, WLH*1.5, $game_party.gold, 2)
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, WLH*1.5, Vocab::gold, 2)
number = $game_party.item_number(@item)
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 190, WLH*3.5, "Stock")
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 190, WLH*3.5, number, 2)
number2 = 0
for actor in $game_party.members
if actor.equips.include?(@item) then number2 = number2 + 1
end
end
self.contents.font.color = system_color
self.contents.font.color.alpha = @item.is_a?(RPG::Item) ? 128 : 255
self.contents.draw_text(4, 0, 190, WLH*5.5, "Equiped")
self.contents.font.color = normal_color
self.contents.font.color.alpha = @item.is_a?(RPG::Item) ? 128 : 255
self.contents.draw_text(4, 0, 190, WLH*5.5, number2, 2)
end
#--------------------------------------------------------------------------
# * Set Item
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
end
#==============================================================================
# ** Window_SynthRequire
#------------------------------------------------------------------------------
# This window displays the items necessary to synthesize.
#==============================================================================
class Window_SynthRequire < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 240, 116)
@item = nil
@req1 = nil
@req2 = nil
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @item != nil
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, WLH, "Requires")
enabled = ($game_party.item_number(@req1) > 0)
draw_item_name(@req1, 15, 25, enabled)
enabled = @req1==@req2 ? ($game_party.item_number(@req2) > 1) : ($game_party.item_number(@req2) > 0)
draw_item_name(@req2, 15, 52, enabled)
end
end
#--------------------------------------------------------------------------
# * Set Item
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
type1 = item.s_req_1_type
id1 = item.s_req_1_id
case type1
when 0
@req1 = $data_items[id1]
when 1
@req1 = $data_weapons[id1]
when 2
@req1 = $data_armors[id1]
end
type2 = item.s_req_2_type
id2 = item.s_req_2_id
case type2
when 0
@req2 = $data_items[id2]
when 1
@req2 = $data_weapons[id2]
when 2
@req2 = $data_armors[id2]
end
refresh
end
end
end
#==============================================================================
# ** Window_SynthStatus2
#------------------------------------------------------------------------------
# This displays how much of an improvement or disadvantage the equipment gives
# to the individual actors in the current party. If the selection is an item
# rather than equipment, then nothing will happen.
#==============================================================================
class Window_SynthStatus2 < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 544, 128)
@item = nil
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @item != nil
number = $game_party.item_number(@item)
for actor in $game_party.members
#--------------------------------------------------------------------
# This can be used to center the actor's pictures instead, if it looks
# awkward with more or less than four actors in a party at one time.
#--------------------------------------------------------------------
#o = $game_party.members.size
#x = ((actor.index+1)*((self.width-32)/o))-(((self.width-32)/o)/2)-48
x = actor.index*136
y = 0
draw_actor_parameter_change(actor, x, y)
end
end
end
#--------------------------------------------------------------------------
# * Draw Actor's Current Equipment and Parameters
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_parameter_change(actor, x, y)
return if @item.is_a?(RPG::Item)
enabled = actor.equippable?(@item)
draw_actor_face(actor, x, y, size = 96, opacity = enabled ? 255 : 100)
self.contents.font.color = text_color(15)
self.contents.font.color.alpha = enabled ? 180 : 60
self.contents.draw_text(x+2, y+2, 200, WLH, actor.name)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 100
self.contents.draw_text(x, y, 200, WLH, actor.name)
if @item.is_a?(RPG::Weapon)
item1 = weaker_weapon(actor)
elsif actor.two_swords_style and @item.kind == 0
item1 = nil
else
item1 = actor.equips[1 + @item.kind]
end
if enabled
if @item.is_a?(RPG::Weapon)
atk1 = item1 == nil ? 0 : item1.atk
atk2 = @item == nil ? 0 : @item.atk
change = atk2 - atk1
else
def1 = item1 == nil ? 0 : item1.def
def2 = @item == nil ? 0 : @item.def
change = def2 - def1
end
self.contents.font.color = text_color(15)
self.contents.font.color.alpha = enabled ? 180 : 60
self.contents.draw_text(x, y + 72, 96, WLH, sprintf("%+d", change), 2)
if change == 0
self.contents.font.color = normal_color
end
if change > 0
self.contents.font.color = power_up_color
end
if change < 0
self.contents.font.color = power_down_color
end
self.contents.draw_text(x, y + 70, 96, WLH, sprintf("%+d", change), 2)
end
end
#--------------------------------------------------------------------------
# * Get Weaker Weapon Equipped by the Actor (for dual wielding)
# actor : actor
#--------------------------------------------------------------------------
def weaker_weapon(actor)
if actor.two_swords_style
weapon1 = actor.weapons[0]
weapon2 = actor.weapons[1]
if weapon1 == nil or weapon2 == nil
return nil
elsif weapon1.atk < weapon2.atk
return weapon1
else
return weapon2
end
else
return actor.weapons[0]
end
end
#--------------------------------------------------------------------------
# * Set Item
# item : new item
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
end
#==============================================================================
# ** Window_SynthNumber
#------------------------------------------------------------------------------
# This window is for inputting quantity of items to synthesize on the
# synth screen.
#==============================================================================
class Window_SynthNumber < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 304, 232)
@item = nil
@max = 1
@price = 0
@number = 1
@req1 = nil
@req2 = nil
end
#--------------------------------------------------------------------------
# * Set Items, Max Quantity, and Price
#--------------------------------------------------------------------------
def set(item, max, price)
@item = item
@max = max
@price = item.s_cost
type1 = item.s_req_1_type
id1 = item.s_req_1_id
case type1
when 0
@req1 = $data_items[id1]
when 1
@req1 = $data_weapons[id1]
when 2
@req1 = $data_armors[id1]
end
type2 = item.s_req_2_type
id2 = item.s_req_2_id
case type2
when 0
@req2 = $data_items[id2]
when 1
@req2 = $data_weapons[id2]
when 2
@req2 = $data_armors[id2]
end
@number = 1
refresh
end
#--------------------------------------------------------------------------
# * Set Inputted Quantity
#--------------------------------------------------------------------------
def number
return @number
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
y = 20
self.contents.clear
draw_item_name(@item, 0, y)
self.contents.font.color = normal_color
self.contents.draw_text(212, y, 20, WLH, "×")
self.contents.draw_text(248, y, 20, WLH, @number, 2)
self.cursor_rect.set(244, y, 28, WLH)
self.contents.font.color = system_color
self.contents.draw_text(0, y + (2.5*WLH), 200, WLH, "Requires:")
self.contents.font.color = normal_color
draw_item_name(@req1, 10, y + (3.5*WLH))
self.contents.draw_text(212, y + (3.5*WLH), 20, WLH, "×")
self.contents.draw_text(248, y + (3.5*WLH), 20, WLH, @number, 2)
draw_item_name(@req2, 10, y + (4.5*WLH))
self.contents.draw_text(212, y + (4.5*WLH), 20, WLH, "×")
self.contents.draw_text(248, y + (4.5*WLH), 20, WLH, @number, 2)
draw_currency_value(@price * @number, 4, y + (6.5*WLH), 264)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if self.active
last_number = @number
if Input.repeat?(Input::RIGHT) and @number < @max
@number += 1
end
if Input.repeat?(Input::LEFT) and @number > 1
@number -= 1
end
if Input.repeat?(Input::UP) and @number < @max
@number = [@number + 10, @max].min
end
if Input.repeat?(Input::DOWN) and @number > 1
@number = [@number - 10, 1].max
end
if @number != last_number
Sound.play_cursor
refresh
end
end
end
end
#==============================================================================
# ** Scene_Synthesis
#------------------------------------------------------------------------------
# This class performs the actual synthesis, much like a shop.
#==============================================================================
class Scene_Synthesis < Scene_Base
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_menu_background
@help_window = Window_Help.new
@buy_window = Window_SynthBuy.new(0, 56)
@buy_window.active = true
@buy_window.visible = true
@buy_window.help_window = @help_window
@number_window = Window_SynthNumber.new(0, 56)
@number_window.active = false
@number_window.visible = false
@status1_window = Window_SynthStatus1.new(304, 56)
@status1_window.item = @buy_window.item
@status1_window.visible = true
@status2_window = Window_SynthStatus2.new(0, 288)
@status2_window.item = @buy_window.item
@status2_window.visible = true
@require_window = Window_SynthRequire.new(304, 172)
@require_window.visible = true
@require_window.item = @buy_window.item
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@help_window.dispose
@buy_window.dispose
@number_window.dispose
@status1_window.dispose
@status2_window.dispose
@require_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@buy_window.update
@number_window.update
@status1_window.update
@status2_window.update
@require_window.update
if @buy_window.active
update_buy_selection
elsif @number_window.active
update_number_input
end
end
#--------------------------------------------------------------------------
# * Update Buy Item Selection
#--------------------------------------------------------------------------
def update_buy_selection
@status1_window.item = @buy_window.item
@status2_window.item = @buy_window.item
@require_window.item = @buy_window.item
if Input.trigger?(Input::B)
Sound.play_decision
$scene = Scene_Map.new
end
if Input.trigger?(Input::C)
@item = @buy_window.item
@req1 = @buy_window.req1
@req2 = @buy_window.req2
if @req1 == @req2 and $game_party.item_number(@req1) <= 1
req3 = true
end
number = $game_party.item_number(@item)
if @item == nil or @item.s_cost > $game_party.gold or number == 99 or $game_party.item_number(@req1) == 0 or $game_party.item_number(@req2) == 0 or req3 == true
Sound.play_buzzer
else
Sound.play_decision
max = @item.s_cost == 0 ? 99 : $game_party.gold / @item.s_cost
if @req1 != @req2
if max > $game_party.item_number(@req1) or max > $game_party.item_number(@req2)
max = $game_party.item_number(@req1) <= $game_party.item_number(@req2) ? $game_party.item_number(@req1) : $game_party.item_number(@req2)
end
else
if max > ($game_party.item_number(@req1)/2)
max = ($game_party.item_number(@req1)/2)
end
end
max = [max, 99 - number].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.s_cost)
@number_window.active = true
@number_window.visible = true
end
end
end
#--------------------------------------------------------------------------
# * Update Number Input
#--------------------------------------------------------------------------
def update_number_input
if Input.trigger?(Input::B)
cancel_number_input
elsif Input.trigger?(Input::C)
decide_number_input
end
end
#--------------------------------------------------------------------------
# * Cancel Number Input
#--------------------------------------------------------------------------
def cancel_number_input
Sound.play_cancel
@number_window.active = false
@number_window.visible = false
@buy_window.active = true
@buy_window.visible = true
end
#--------------------------------------------------------------------------
# * Confirm Number Input
#--------------------------------------------------------------------------
def decide_number_input
Sound.play_shop
@number_window.active = false
@number_window.visible = false
$game_party.lose_gold(@number_window.number * @item.s_cost)
$game_party.gain_item(@item, @number_window.number)
$game_party.lose_item(@req1, @number_window.number)
$game_party.lose_item(@req2, @number_window.number)
@buy_window.refresh
@status1_window.refresh
@status2_window.refresh
@require_window.refresh
@buy_window.active = true
@buy_window.visible = true
end
end
Screeny:
Spoiler:
Dodatkowe informacje:
Skrypt może bugować,jeżeli zostanie zastosowany z innym skryptem zmiany sklepu.
Sklep to co innego, SynthShop to co innego. Żaden skrypt na zmianę sklepu nie powinien się z SynthShop żreć, bo nadpisuje scenę sklepu właśnie, nie scenę syntezy.
________________________
"Na trolla pewne są tylko dwie pewne metody, jedna samopowtarzalna i druga, wymagająca przeładowania ręcznego."
Pomógł: 26 razy Dołączył: 25 Wrz 2011 Posty: 236 Skąd: ty się tu wziąłeś?
Wysłany: Pon 09 Sty, 2012 19:03
Aruka21
Już ci tłumaczę.
Do silnej tarczy z żelaza potrzebujesz tarczy i żelaza i 100 zł.Żelazo ma ID w bazie danych 2,a tarcza 3.
Notatki w silnej tarczy z żelaza muszą wyglądać tak:
\cost[100] - czyli koszt naszej syntezy
\type1[2] - ID typu pierwszego przedmiotu potrzebnego do syntezy.W tym przypadku to będzie tarcza,czyli ID 2.
\type2[0] - Jak wyżej,tylko drugi przedmiot,czyli 0 - przedmiot
\id1[3] - ID bazy danych pierwszego przedmiotu potrzebnego.czyli nasza zbroja ma ID 3.
\id2[2] - Jak wyżej,tyle ze drugi przedmiot.
Jeżeli nie zrozumiesz,to wrzucę demko,ale już jutro,dzisiaj jestem padnięty.
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum