Krótki opis:
Skrypt dodaje nową opcję do Menu - użycie określonego przedmiotu.
Autor:
Przemusiek25
Kompatybilność:
RPG Maker VX
Skrypt:
Spoiler:
Kod:
#==============================================================================
# ** Konfiguracja
#------------------------------------------------------------------------------
# Poniżej należy wpisać tylko Id przedmiotu w bazie oraz jego nazwę w Menu
# Skrypt zalecam umieścić poniżej Materials ale powyżej wszystkimi skryptami
#==============================================================================
module Przedmiot
ID = 2 # ID przedmiotu
MENUNAZWA = "Użyj Potiona" # Nazwa przedmiotu w menu, należy podać w cudzysłowiu
JESTMENU = false # Jeśli true powyżej wpisana nazwa pokaże się w menu.
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================
class Scene_Menu < Scene_Base
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_menu_background
create_command_window
@PrzedmiotID = $data_items[Przedmiot::ID]
@gold_window = Window_Gold.new(0, 360)
@scene_item = Scene_Item.new
@przedmiot_window = Window_Przedmiot.new(0, 304)
@status_window = Window_MenuStatus.new(160, 0)
@target_window = Window_MenuStatus.new(160, 0)
@ILOSCPRZEDMIOTOW = 0
hide_target_window
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@command_window.dispose
@gold_window.dispose
@przedmiot_window.dispose
@status_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
update_menu_background
@command_window.update
@gold_window.update
@przedmiot_window.update
@status_window.update
@target_window.update
if @command_window.active
update_command_selection
elsif @status_window.active
update_actor_selection
elsif @target_window.active
update_target_selection
end
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::status
s5 = Vocab::save
s6 = Vocab::game_end
s7 = Przedmiot::MENUNAZWA
if Przedmiot::JESTMENU == true
@command_window = Window_Command.new(160, [s7, s1, s2, s3, s4, s5, s6])
else
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
end
@command_window.index = @menu_index
if Przedmiot::JESTMENU == true
if $game_party.members.size == 0 # If number of party members is 0
@command_window.draw_item(1, false) # Disable item
@command_window.draw_item(2, false) # Disable skill
@command_window.draw_item(3, false) # Disable equipment
@command_window.draw_item(4, false) # Disable status
end
if $game_system.save_disabled # If save is forbidden
@command_window.draw_item(5, false) # Disable save
end
if $game_party.item_number($data_items[Przedmiot::ID]) == 0
@command_window.draw_item(0, false)
end
else
if $game_party.members.size == 0 # If number of party members is 0
@command_window.draw_item(0, false) # Disable item
@command_window.draw_item(1, false) # Disable skill
@command_window.draw_item(2, false) # Disable equipment
@command_window.draw_item(3, false) # Disable status
end
if $game_system.save_disabled # If save is forbidden
@command_window.draw_item(4, false) # Disable save
end
end
end
#--------------------------------------------------------------------------
# * Update Command Selection
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
if Przedmiot::JESTMENU == true
if $game_party.members.size == 0 and @command_window.index < 5 and @command_window.index > 1
Sound.play_buzzer
return
elsif $game_system.save_disabled and @command_window.index == 5
Sound.play_buzzer
return
elsif $game_party.item_number($data_items[Przedmiot::ID]) == 0 and @command_window.index == 0
Sound.play_buzzer
return
end
Sound.play_decision
case @command_window.index
when 0 # Item
@item = $data_items[Przedmiot::ID]
if $game_party.item_can_use?(@item)
Sound.play_decision
determine_item
else
Sound.play_buzzer
end
#~ $game_party.gain_item(@PrzedmiotID, -1)
@przedmiot_window.refresh
if $game_party.item_number($data_items[Przedmiot::ID]) == 0
@command_window.draw_item(0, false)
end
# $game_party.gain_item($data_items[Przedmiot::ID], -1)
when 1 # Item
$scene = Scene_Item.new
when 2,3,4 # Skill, equipment, status
start_actor_selection
when 5 # Save
$scene = Scene_File.new(true, false, false)
when 6 # End Game
$scene = Scene_End.new
end
else
if $game_party.members.size == 0 and @command_window.index < 4
Sound.play_buzzer
return
elsif $game_system.save_disabled and @command_window.index == 4
Sound.play_buzzer
return
end
Sound.play_decision
case @command_window.index
when 0 # Item
$scene = Scene_Item.new
when 1,2,3 # Skill, equipment, status
start_actor_selection
when 4 # Save
$scene = Scene_File.new(true, false, false)
when 5 # End Game
$scene = Scene_End.new
end
end
end
end
#--------------------------------------------------------------------------
# * Start Actor Selection
#--------------------------------------------------------------------------
def start_actor_selection
@command_window.active = false
@status_window.active = true
if $game_party.last_actor_index < @status_window.item_max
@status_window.index = $game_party.last_actor_index
else
@status_window.index = 0
end
end
#--------------------------------------------------------------------------
# * End Actor Selection
#--------------------------------------------------------------------------
def end_actor_selection
@command_window.active = true
@status_window.active = false
@status_window.index = -1
end
#--------------------------------------------------------------------------
# * Update Actor Selection
#--------------------------------------------------------------------------
def update_actor_selection
if Input.trigger?(Input::B)
Sound.play_cancel
end_actor_selection
elsif Input.trigger?(Input::C)
$game_party.last_actor_index = @status_window.index
Sound.play_decision
if Przedmiot::JESTMENU == true
case @command_window.index
when 2 # skill
$scene = Scene_Skill.new(@status_window.index)
when 3 # equipment
$scene = Scene_Equip.new(@status_window.index)
when 4 # status
$scene = Scene_Status.new(@status_window.index)
end
else
case @command_window.index
when 1 # skill
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
$scene = Scene_Status.new(@status_window.index)
end
end
end
end
#--------------------------------------------------------------------------
# * Używanie przedmiotu
#--------------------------------------------------------------------------
def determine_item
if @item.for_friend?
show_target_window
if @item.for_all?
@target_window.index = 99
else
if $game_party.last_target_index < @target_window.item_max
@target_window.index = $game_party.last_target_index
else
@target_window.index = 0
end
end
else
use_item_nontarget
end
end
def update_target_selection
if Input.trigger?(Input::B)
Sound.play_cancel
# if $game_party.item_number(@item) == 0 # If item is used up
# @item_window.refresh # Recreate the window contents
# end
hide_target_window
elsif Input.trigger?(Input::C)
if not $game_party.item_can_use?(@item)
Sound.play_buzzer
else
determine_target
end
end
end
def determine_target
used = false
if @item.for_all?
for target in $game_party.members
target.item_effect(target, @item)
used = true unless target.skipped
end
else
$game_party.last_target_index = @target_window.index
target = $game_party.members[@target_window.index]
target.item_effect(target, @item)
used = true unless target.skipped
end
if used
use_item_nontarget
else
Sound.play_buzzer
end
# @przedmiot_window.refresh
end
def show_target_window#(right)
@command_window.active = false
width_remain = 544 - @target_window.width
# @target_window.x = right ? width_remain : 0
@target_window.visible = true
@target_window.active = true
#~ if right
#~ @viewport.rect.set(0, 0, width_remain, 416)
#~ @viewport.ox = 0
#~ else
#~ @viewport.rect.set(@target_window.width, 0, width_remain, 416)
#~ @viewport.ox = @target_window.width
#~ end
end
def use_item_nontarget
Sound.play_use_item
$game_party.consume_item(@item)
#~ @item_window.draw_item(@item_window.index)
@target_window.refresh
@status_window.refresh
@przedmiot_window.refresh
if $game_party.all_dead?
$scene = Scene_Gameover.new
elsif @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$scene = Scene_Map.new
end
end
end
#==============================================================================
# ** Window_Przedmiot
#------------------------------------------------------------------------------
# This window displays the amount of item.
#==============================================================================
class Window_Przedmiot < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 160, WLH + 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
@ilosc = $game_party.item_number($data_items[Przedmiot::ID])
@ILOSCPRZEDMIOTOW = @ilosc
draw_icon($data_items[Przedmiot::ID].icon_index, 106, 0, true)
self.contents.draw_text(4, 0, 100, 32, @ILOSCPRZEDMIOTOW, 2)
# draw_currency_value(@IloscPrzedmiotuID, 4, 0, 120)
end
end
Screeny:
Spoiler:
Dodatkowe informacje:
Stworzony na prośbę jednego z użytkowników.
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