Druga waluta - Preyas - 16-07-16 14:13
Witam, potrzebuje do mojego projektu drugiej waluty ponieważ NPC od questa będzie przyjmował tylko taką ma ktoś coś takiego?
RE: Druga waluta - Yoroiookami - 16-07-16 15:22
Skrypt na dodatkowe waluty:
Kod:
#==============================================================================
# ** MultiCurrencies - Dodatkowe Waluty
#==============================================================================
# DerVVulfman
# Wersja 1.0
# Maj 24, 2009
# Kompatybilny z RMXP
#==============================================================================
#
# Prośba od Nathan1347
#
module MultiCurrency
# Ustawia początkowy typ waluty
Default = 1
# Ustawia ilość walut w grze
Currency_Qty = 3
# Nazwy walut
Currency_Names = [" Złoto", " Srebro", " Muszelki"]
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :currency_type # current currency in use
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias multicurrency_init initialize
def initialize
# The original call
multicurrency_init
@currency_type = MultiCurrency::Default
end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. Refer to "$game_party" for the instance of this class.
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :currency # currency array
attr_accessor :current_currency # current chosen currency
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias multicurrency_init initialize
def initialize
# The original call
multicurrency_init
# Create currency array
@currency = []
@current_currency = 1
# Run through and set currencies to 0
for i in 1..MultiCurrency::Currency_Qty
@currency[i] = 0
end
end
#--------------------------------------------------------------------------
# * Gain Currency (or lose)
# n : amount of gold
# i : currency type
#--------------------------------------------------------------------------
def gain_currency(n, i)
if i == @current_currency
gain_gold(n)
set_currency
else
@currency[i] = [[@currency[i] + n, 0].max, 9999999].min
end
end
#--------------------------------------------------------------------------
# * Lose Currency
# n : amount of gold
# i : currency type
#--------------------------------------------------------------------------
def lose_currency(n, i)
# Reverse the numerical value and call it gain_gold
# and perform a negative gain_currency.
lose_gold(n)
gain_currency(i, -n)
end
#--------------------------------------------------------------------------
# * Set Current Currency
# i : currency type
#--------------------------------------------------------------------------
def set_currency(i = nil )
# Exit if less than 1
i = @current_currency if i == nil
# Unload current currency to the currency array
@currency[@current_currency] = @gold
# Reset current currency value
@current_currency = i
# Apply the new currency to gold
@gold = @currency[@current_currency]
end
end
#==============================================================================
# ** Window_Gold
#------------------------------------------------------------------------------
# This window displays amount of gold.
#==============================================================================
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
c_name = MultiCurrency::Currency_Names[$game_party.current_currency - 1]
cx = contents.text_size(c_name).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 88-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(92-cx, 0, cx, 32, c_name, 2)
end
end
#==============================================================================
# ** Window_BattleResult
#------------------------------------------------------------------------------
# This window displays amount of gold and EXP acquired at the end of a battle.
#==============================================================================
class Window_BattleResult < Window_Base
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
x = 4
self.contents.font.color = normal_color
cx = contents.text_size(@exp.to_s).width
self.contents.draw_text(x, 0, cx, 32, @exp.to_s)
x += cx + 4
self.contents.font.color = system_color
cx = contents.text_size("EXP").width
self.contents.draw_text(x, 0, 64, 32, "EXP")
x += cx + 16
self.contents.font.color = normal_color
cx = contents.text_size(@gold.to_s).width
self.contents.draw_text(x, 0, cx, 32, @gold.to_s)
x += cx + 4
self.contents.font.color = system_color
c_name = MultiCurrency::Currency_Names[$game_party.current_currency - 1]
self.contents.draw_text(x, 0, 128, 32, c_name)
y = 32
for item in @treasures
draw_item_name(item, 4, y)
y += 32
end
end
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
# This class performs shop screen processing.
#==============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias multicurrency_main main
def main
#Set store to relate to the store's gold value
$game_party.set_currency($game_system.currency_type)
# Perform the original call
multicurrency_main
# Return gold to standard
$game_party.set_currency($game_party.current_currency)
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Start After Battle Phase
#--------------------------------------------------------------------------
alias multicurrency_start_phase5 start_phase5
def start_phase5
multicurrency_start_phase5
$game_party.set_currency($game_system.currency_type)
end
end
Menu Add-On
Kod:
#==============================================================================
# ** MultiCurrencies Main Menu Add-On - Dodatek do Main Menu
#==============================================================================
# DerVVulfman
# Wersja 1.0
# Maj 24, 2009
# Kompatybilny z RMXP
# ==Wymaga skryptu MultiCurrencies==
#==============================================================================
#
# Ten skrypt dodaje okno w którym wyświetlane są wszystkie waluty i
# przepisuje metody z Scene Menu, Scene Save oraz Scene End.
#
#==============================================================================
#==============================================================================
# ** Window_Currency
#------------------------------------------------------------------------------
# This window selects a use target for the actor on item and skill screens.
#==============================================================================
class Window_Currency < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 320, 640)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Here, I set the height of the window based on the # of currencies
self.height = 32 + (32 * MultiCurrency::Currency_Qty)
# Here, I center it vertically
self.y = (480 - self.height)/2
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.clear
for i in 1..MultiCurrency::Currency_Qty
x = 4
y = (i * 32) - 32
c_name = MultiCurrency::Currency_Names[i - 1]
c_gold = $game_party.currency[i]
cx = contents.text_size(c_name).width
self.contents.font.color = normal_color
self.contents.draw_text(4, y, 188-cx-2, 32, c_gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(192-cx, y, cx, 32, c_name, 2)
end
end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Status"
s5 = "Currency"
s6 = "Save"
s7 = "End Game"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
@command_window.index = @menu_index
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(5)
end
# Make play time window
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 288 -32
@playtime_window.height += 16
# Make steps window
@steps_window = Window_Steps.new
@steps_window.x = 0
@steps_window.y = 384 - 16
@steps_window.height += 16
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# Make currency window
@currency_window = Window_Currency.new
@currency_window.x = 160
@currency_window.z = 200
@currency_window.visible = false
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@status_window.dispose
@currency_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # currency
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@currency_window.active = true
@currency_window.visible = true
when 5 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 6 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@playtime_window.update
@steps_window.update
@status_window.update
@currency_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end
# if currency window is active: call update_currency
if @currency_window.active
update_currency
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_currency
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@currency_window.active = false
@currency_window.visible = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Make command window active
@command_window.active = true
@currency_window.active = false
@currency_window.visible = false
return
end
end
end
#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Decision Processing
#--------------------------------------------------------------------------
def on_decision(filename)
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
file = File.open(filename, "wb")
write_save_data(file)
file.close
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
$scene = Scene_Menu.new(5)
end
#--------------------------------------------------------------------------
# * Cancel Processing
#--------------------------------------------------------------------------
def on_cancel
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
$scene = Scene_Menu.new(5)
end
end
#==============================================================================
# ** Scene_End
#------------------------------------------------------------------------------
# This class performs game end screen processing.
#==============================================================================
class Scene_End
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(6)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # to title
command_to_title
when 1 # shutdown
command_shutdown
when 2 # quit
command_cancel
end
return
end
end
#--------------------------------------------------------------------------
# * Process When Choosing [Cancel] Command
#--------------------------------------------------------------------------
def command_cancel
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to menu screen
$scene = Scene_Menu.new(6)
end
end
Skrypty umieść w Edytorze Skryptów nad Main.
Zmieniasz rodzaj waluty który wymagają sprzedawcy tuż przez interakcją z nimi.
![[Obrazek: 2c95a0865a.png]](http://puu.sh/q3CDI/2c95a0865a.png)
![[Obrazek: 4b55b9554e.png]](http://puu.sh/q3CFG/4b55b9554e.png)
"$game_system.currency_type = 1"
RE: Druga waluta - Preyas - 16-07-16 15:59
Cześć, pierwszy skrypt działa pięknie nie mam z nim problemu lecz Menu ADD-ON coś się buguje mam polską wersję makera. BTW w menu ten skrypt dodaje mi Currency, Save, End Game
RE: Druga waluta - Yoroiookami - 16-07-16 18:15
W polskiej wersji makera wiele się buguje. Nic ci na to niestety nie poradzę. Nie musisz używać add-onu. Zawsze możesz poinformować gracza o tym ile czego ma przy pomocy zmiennych.
Save i End Game już powinny być w twoim menu i bez skryptu.
![[Obrazek: 312eecbf73.jpg]](http://puu.sh/q3JED/312eecbf73.jpg)
A sam Add-On powinien działać tak:
RE: Druga waluta - Preyas - 16-07-16 20:53
A czy jest możliwość podania mi linka do pobrania tego rpg makera? zależy mi na tym aby to poprawnie działało ;)
RE: Druga waluta - Yoroiookami - 16-07-16 22:45
Troszkę to nielegalne. Ale jak sam poszukasz to na pewno znajdziesz Ewentualnie można kupić na Steamie na przykład. Z tego co wiem.
RE: Druga waluta - Preyas - 16-07-16 23:07
Pobrałem triala, na nim działa wszystko pięknie czyli wina po prostu polskiego makera. Nie chcę za niego płacić, najwyżej poproszę kogoś o
przerobienie na polską wersję makera. Dzięki za pomoc ;)
RE: Druga waluta - Mateusz SSJ8 - 22-07-16 10:47
Chyba musisz całą bazę danych od nowa przepisać, bo ona jest pod TYLKO jedną walutę.
Możesz też zrobić kilka walut jako przedmioty, ale wtedy pomyślałbym nad wprowadzeniem systemu stosów. Wystarczą przedmioty, bronie i zbroje.
RE: Druga waluta - Preyas - 22-07-16 11:44
Problem już dawno rozwiązany, mam angielską wersję makera i wszystko śmiga ;)
|