Plecak, walka i opcja wczytaj - Athanor - 29-01-14 17:39
Witam znów.
1. Azaliż zaczynając jest problem z skryptem Kategoryzacji Przedmiotów XP Ayene. Otóż skrypt ten podczas próby odpalenia go w walce, wywala z grę z błędem.
Błąd:
![[Obrazek: 25sswo5.jpg]](http://i57.tinypic.com/25sswo5.jpg)
Skrypt:
Kod:
#==============================================================================
# Kategoryzacja przedmiotów [XP]
# by Ayene
# 05.05.2012 ver 1.0
# www.ultimateam.pl
#==============================================================================
# Opis:
# Skrypt umożliwia grupowanie przedmiotów w Plecaku w dowolne kategorie, np.
# bronie, mapy, przedmioty leczące, klucze itd. W tym celu wystarczy
# odpowiednio skonfigurować linijki poniżej (sekcja Konfiguracja).
#==============================================================================
# Konfiguracja:
#==============================================================================
module AYE
module ITEM_CAT
# Poszczególne kategorie przedmiotów wymienione po przecinku.
# Muszą być zadeklarowane w CATEGORY_NAME i CATEGORY_ITEMS
ITEM_CATEGORIES = [:item, :battle, :weapon, :armor,
:acc, :quest, :all]
# Nazwy ketegorii
CATEGORY_NAME = { # <- nie usuwać
# :symbol => ["Komenda", "Opis", "Ikona"],
:item => ["Mikstury", "Ukazuje wszelkie mikstury.", "HPSrednia"],
:battle => ["Przedmioty", "Ukazuje Przedmioty waleczne i rozne.", "040-Item09"],
:weapon => ["Orez", "Ukazuje wszystkie bronie.", "Miecz3"],
:armor => ["Uzbrojenie", "Ukazuje pancerze.", "Zciezka3"],
:acc => ["Akcesoria", "Ukazuje akcesoria.", "Rekawica1"],
:quest => ["Misje", "Ukazuje przedmioty kluczowe dla fabuły.", "List"],
:all => ["Wszystkie przedmioty", "Wyświetla wszystkie przedmioty.", "034-Item03"],
} # <- nie usuwać
# Przedmioty przypisane do kategorii
CATEGORY_ITEMS = { # <- nie usuwać
# :symbol => ["Typ" , [ID, ID, ID, ...],
# gdzie: Typ w bazie danych - Item (przedmiot), Weapon (broń), Armor (pancerz),
# :all - wszystkie kategorie
:item => ["Item", [1, 2, 3]],
:battle => ["Item", [4, 5, 6]],
:weapon => ["Weapon", :all],
:armor => ["Armor", [1, 2, 3]],
:acc => ["Armor", [11, 12, 13]],
:quest => ["Item", [23, 24, 25]],
:all => [:all, :all]
} # <- nie usuwać
end
end
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :item_menu
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias aye_itemcat_gmtemp_ini initialize
def initialize
aye_itemcat_gmtemp_ini
@item_menu = false
end
end
#==============================================================================
# ** Game_Party
#==============================================================================
class Game_Party
def all_item_number(item)
case item
when RPG::Weapon
return @weapons.include?(item.id) ? @weapons[item.id] : 0
when RPG::Armor
return @armors.include?(item.id) ? @armors[item.id] : 0
else
return @items.include?(item.id) ? @items[item.id] : 0
end
end
end
class Window_Help < Window_Base
include AYE::ITEM_CAT
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
if $game_temp.item_menu
self.y = 480 - height
end
end
end
#==============================================================================
# ** Window_ItemHelp
#==============================================================================
class Window_ItemHelp < Window_Base
include AYE::ITEM_CAT
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
cw = 32 + ITEM_CATEGORIES.size * 32
super(cw, 0, 640-cw, 64)
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# * Set Text
#--------------------------------------------------------------------------
def set_text(index)
if index != @index
self.contents.clear
self.contents.font.color = normal_color
text = CATEGORY_NAME[ITEM_CATEGORIES[index]][0]
self.contents.draw_text(4, 0, self.width - 40, 32, text, 1)
@index = index
end
end
end
#==============================================================================
# ** Window_ItemCategory
#==============================================================================
class Window_ItemCategory < Window_Selectable
include AYE::ITEM_CAT
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
cw = 32 + ITEM_CATEGORIES.size * 32
super(0, 0, cw, 64)
@commands = ITEM_CATEGORIES
@item_max = @commands.size
@column_max = @item_max
self.contents = Bitmap.new(cw - 32, height - 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@commands.each_with_index {|com, i|draw_item(com, i)}
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text character color
#--------------------------------------------------------------------------
def draw_item(command, index)
rect = Rect.new(0, 0, 24, 24)
bitmap = RPG::Cache.icon(CATEGORY_NAME[command][2])
self.contents.blt(4 + 32 * index, 4, bitmap, rect)
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(@index * 32, 0, 32, 32)
end
end
#==============================================================================
# ** Window_Item
#==============================================================================
class Window_Item < Window_Selectable
include AYE::ITEM_CAT
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 352)
@column_max = 2
unless $game_temp.in_battle
category(0)
self.active = false
end
refresh
self.index = 0
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# * Category
#--------------------------------------------------------------------------
def category(index)
self.index = 0
@items = []
@category = ITEM_CATEGORIES[index]
@itemtype = CATEGORY_ITEMS[@category][0]
if @category != :all
@items = CATEGORY_ITEMS[@category][1]
end
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
if $game_temp.in_battle
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
else
@all_item = []
case @itemtype
when "Item"
@all_item = $data_items
when "Weapon"
@all_item = $data_weapons
when "Armor"
@all_item = $data_armors
else
@all_item = $data_items + $data_weapons + $data_armors
end
@all_item.each{|item|
unless item == nil
if $game_party.all_item_number(item) > 0
if @category != :all and @items != :all
if @items.include?(item.id)
@data.push(item)
end
else
@data.push(item)
end
end
end
}
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
end
#==============================================================================
# ** Scene_Item
#==============================================================================
class Scene_Item
include AYE::ITEM_CAT
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
alias aye_itemcat_scitem_main main
def main
$game_temp.item_menu = true
@category_window = Window_ItemCategory.new
@catname_window = Window_ItemHelp.new
@catname_window.set_text(@category_window.index)
aye_itemcat_scitem_main
$game_temp.item_menu = false
@category_window.dispose
@catname_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias aye_itemcat_scitem_update update
def update
@category_window.update
@catname_window.update
if @category_window.active
update_category
return
end
aye_itemcat_scitem_update
end
#--------------------------------------------------------------------------
# * Frame Update (when category window is active)
#--------------------------------------------------------------------------
def update_category
@help_window.set_text(CATEGORY_NAME[ITEM_CATEGORIES[@category_window.index]][1])
@item_window.category(@category_window.index)
if Input.repeat?(Input::RIGHT) || Input.repeat?(Input::LEFT)
@item_window.refresh
@catname_window.set_text(@category_window.index)
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(0)
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@item_window.active = true
@category_window.active = false
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
alias aye_itemcat_scitem_update_item update_item
def update_item
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@item_window.active = false
@category_window.active = true
return
else
aye_itemcat_scitem_update_item
return
end
end
end
2. I jeszcze jedno, czy wie ktoś jak zrobić walkę i ucieczkę jak w Parallel Worlds lub innych grach. Gdy potwór nas zobaczy do nas biegnie, gdy odejdziemy on po prostu chodzi. I ucieczka że cofamy się pole do tyłu albo po prostu zanikamy na sekundę jak w PW.
3. Kłamałem, jeszcze jedno. Skrypt na ekran tytułowy z obrazkami. Opcja "Wczytaj" Nie działa. Wejście do gry działa jak powinno, nawet z jakimś zapisem nie działa
Skrypt:
Kod:
#=====================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#=========================================================
class Scene_Title
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# If battle test
if $BTEST
battle_test
return
end
# Load database
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
# Make system object
$game_system = Game_System.new
# Make title graphic
@sprite = Sprite.new
# NEW CODE
@back_sprite = Sprite.new
@back_sprite.z = @sprite.z - 10
# transition between images, set to 0 if none
@transition_frames = 10
@delta = 255 / @transition_frames
@wait = 0
#END NEW CODE
# Continue enabled determinant
# Check if at least one save file exists
# If enabled, make @continue_enabled true; if disabled, make it false
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
# If continue is enabled, move cursor to "Continue"
# NEW CODE
if @continue_enabled
@sprite.bitmap = RPG::Cache.title("2")
@back_sprite.bitmap = RPG::Cache.title("2")
@index = 2
else
@sprite.bitmap = RPG::Cache.title("1")
@back_sprite.bitmap = RPG::Cache.title("1")
@index = 1
end
# END NEW CODE
# Play title BGM
$game_system.bgm_play($data_system.title_bgm)
# Stop playing ME and BGS
Audio.me_stop
Audio.bgs_stop
# 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 title graphic
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# NEW CODE
if @wait >= 0
if @wait == 0
@sprite.bitmap = RPG::Cache.title(@index.to_s)
@sprite.opacity = 255
else
@sprite.opacity -= @delta
end
@wait -= 1
return
end
# if directional buttons are pressed
if Input.trigger?(Input::LEFT) or Input.trigger?(Input::UP)
$game_system.se_play($data_system.cursor_se)
if @index == 1
@index = 3
else
@index -= 1
end
@wait = @transition_frames
@back_sprite.bitmap = RPG::Cache.title(@index.to_s)
end
if Input.trigger?(Input::RIGHT) or Input.trigger?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
if @index == 3
@index = 1
else
@index += 1
end
@wait = @transition_frames
@back_sprite.bitmap = RPG::Cache.title(@index.to_s)
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by index
case @index
when 1 # New game
command_new_game
when 2 # Continue
command_continue
when 3 # Shutdown
command_shutdown
end
end
# END NEW CODE
end
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Command: Continue
#--------------------------------------------------------------------------
def command_continue
# If continue is disabled
unless @continue_enabled
# 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 load screen
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# * Command: Shutdown
#--------------------------------------------------------------------------
def command_shutdown
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Shutdown
$scene = nil
end
#--------------------------------------------------------------------------
# * Battle Test
#--------------------------------------------------------------------------
def battle_test
# Load database (for battle test)
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up party for battle test
$game_party.setup_battle_test_members
# Set troop ID, can escape flag, and battleback
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
# Switch to battle screen
$scene = Scene_Battle.new
end
end
Z góry dziękuję za pomoc 
(o ile ją dostanę)
RE: Plecak, walka i opcja wczytaj - Ayene - 29-01-14 17:58
Musiałbyś przesłać mi swój projekt na PW. Albo chociażby plik Scripts z folderu Data. Widocznie masz problem kompatybilności.
Co do drugiego, gdy ustawiasz Battle processing możesz włączyć opcję Can Escape, wówczas dodaje się Tobie warunek If Escape. Wystarczy ustawić, że bohater odchodzi do tyłu na jeden krok. Tylko mała rada - ustaw, że krok do tyłu powinien być ignorowany, jeśli jest niemożliwy, bo w przeciwnym razie gra się zawiesi, jeśli postać będzie stała w samym rogu ekranu i nie będzie mogła zrobić kroku w tył.
|