Skrypty [VX] - Szybkie pokazanie przedmiotów, po ich zdobyciu.
bionicl - Czw 31 Gru, 2009 13:04 Temat postu: Szybkie pokazanie przedmiotów, po ich zdobyciu.Witajcie! To jest pierwszy skrypt, który tutaj zamieszczam. Nie jestem jego autorem, ale troszkę go prze tłumaczyłem...
Zastosowania:
Gdy zdobędziesz jakiś przedmiot (złoto, zbroje itp.) to wyskoczy małe okienko z informacją o tym i z ikonką przedmioty (patrzcie na screeny)
class Game_System
#--------------------------------------------------------------------------
# Public Instance Variables (Added)
#--------------------------------------------------------------------------
attr_accessor :battle_pop # holds items to popup after battle
attr_accessor :battle_pop_gold # holds gold to popup after battle
#--------------------------------------------------------------------------
# Initialize (Mod)
#--------------------------------------------------------------------------
alias chest_pop_gs_initialize initialize unless $@
def initialize
chest_pop_gs_initialize
@battle_pop = nil
@battle_pop_gold = 0
end
#--------------------------------------------------------------------------
# Get Battle Pop (New)
#--------------------------------------------------------------------------
def battle_pop
return @battle_pop
end
#--------------------------------------------------------------------------
# Set Battle Pop (New)
#--------------------------------------------------------------------------
def battle_pop=(items)
@battle_pop = items
end
#--------------------------------------------------------------------------
# Get Battle Pop Gold (New)
#--------------------------------------------------------------------------
def battle_pop_gold
return @battle_pop_gold
end
#--------------------------------------------------------------------------
# Set Battle Pop Gold (New)
#--------------------------------------------------------------------------
def battle_pop_gold=(gold)
@battle_pop_gold = gold
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# Display Gained Experience and Gold (Rewrite)
#--------------------------------------------------------------------------
def display_exp_and_gold
# Save gold to popup after battle
$game_system.battle_pop_gold = $game_troop.gold_total if BATTLE_POP # added
exp = $game_troop.exp_total
gold = BATTLE_POP ? 0 : $game_troop.gold_total # changed
$game_party.gain_gold(gold) unless BATTLE_POP # changed
text = sprintf(Vocab::Victory, $game_party.name)
$game_message.texts.push('\|' + text)
if exp > 0
text = sprintf(Vocab::ObtainExp, exp)
$game_message.texts.push('\.' + text)
end
if gold > 0
text = sprintf(Vocab::ObtainGold, gold, Vocab::gold)
$game_message.texts.push('\.' + text)
end
wait_for_message
end
#--------------------------------------------------------------------------
# Display Gained Drop Items (Mod)
#--------------------------------------------------------------------------
alias chest_pop_display_drop_items display_drop_items unless $@
def display_drop_items
# Save items to popup after battle
$game_system.battle_pop = $game_troop.make_drop_items if BATTLE_POP
return if BATTLE_POP
chest_pop_display_drop_items
end
end
class Chest_Popup < Scene_Base
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize(type, amount, index, add = false, x = nil, y = nil)
x = $game_player.screen_x if x == nil
y = $game_player.screen_y if y == nil
$game_switches[POPUP_SWITCH] = !AUTO_POPUP
$scene.disable_blur = true
@x, @y, @amount = x, y, amount
@gold = @no_desc = false
case type
when 0 # Gold
$game_party.gain_gold(amount) if add
@icon = GOLD_ICON
@desc_amount = ''
@desc = @amount.to_s
@amount = 1
@gold = true
when 1 # Items
$game_party.gain_item($data_items[index], amount) if add
@icon = $data_items[index].icon_index
@desc_amount = @amount.to_s + ' x'
@desc_amount = '' if @amount == 1
@no_desc = true if @amount == 1
@desc = $data_items[index].name
@amount = 1 if ONLY_SHOW_ONE
when 2 # Weapons
$game_party.gain_item($data_weapons[index], amount) if add
@icon = $data_weapons[index].icon_index
@desc_amount = @amount.to_s + ' x'
@desc_amount = '' if @amount == 1
@no_desc = true if @amount == 1
@desc = $data_weapons[index].name
@amount = 1 if ONLY_SHOW_ONE
when 3 # Armors
$game_party.gain_item($data_armors[index], amount) if add
@icon = $data_armors[index].icon_index
@desc_amount = @amount.to_s + ' x'
@desc_amount = '' if @amount == 1
@no_desc = true if @amount == 1
@desc = $data_armors[index].name
@amount = 1 if ONLY_SHOW_ONE
end
# Set index
@index = @desc_amount
# Add description to text
if @gold
@desc = @desc + ' '
else
if SHOW_POPUP_TEXT_ICON
@desc = @desc_amount + ' ' + @desc
else
@desc = @desc_amount + ' ' + @desc if @desc_amount != ''
end
end
# If battle reward
item_check = $game_system.battle_pop
gold_check = $game_system.battle_pop_gold
if BATTLE_POP and (item_check != nil or gold_check > 0)
@desc = BATTLE_REWARD + @desc
end
end
#--------------------------------------------------------------------------
# Start
#--------------------------------------------------------------------------
def start
create_background
# Create pop-up window
@popup_window = Item_Popup_Window.new(@x, @y)
end
#--------------------------------------------------------------------------
# Terminate
#--------------------------------------------------------------------------
def terminate
# Dispose windows
@popup_window.dispose
@menuback_sprite.dispose
@name_window.dispose if SHOW_POPUP_TEXT
end
#--------------------------------------------------------------------------
# Return Scene
#--------------------------------------------------------------------------
def return_scene
# Turn off blur and pop-up switch
$scene.disable_blur = false
$game_switches[POPUP_SWITCH] = false
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
super
# Update pop-up window
@popup_window.update
@menuback_sprite.update
# Do the actual popping-up
do_popup
end
#--------------------------------------------------------------------------
# Update Basic
#--------------------------------------------------------------------------
def update_basic
Graphics.update
Input.update
end
#--------------------------------------------------------------------------
# Wait
#--------------------------------------------------------------------------
def wait(duration)
# Wait for DURATION frames
for i in 0..duration
update_basic
end
end
#--------------------------------------------------------------------------
# Wait for close
#--------------------------------------------------------------------------
def wait_for_close
count = 0
loop do
update_basic
count += 1
# Close if button 1 pressed
break if Input.trigger?(BUTTON_TO_WAIT_FOR1) and WAIT_FOR_BUTTON
# Close if button 2 pressed
break if Input.trigger?(BUTTON_TO_WAIT_FOR2) and WAIT_FOR_BUTTON
# Close if time elapsed
break if count >= WAIT_FOR_TIME and !WAIT_FOR_BUTTON
end
end
#--------------------------------------------------------------------------
# Create Background
#--------------------------------------------------------------------------
def create_background
# Create modified background
@menuback_sprite = Sprite.new
@menuback_sprite.bitmap = $game_temp.background_bitmap
@menuback_sprite.update
end
#--------------------------------------------------------------------------
# Show Name
#--------------------------------------------------------------------------
def show_name
x = 272
y = TEXT_WINDOW_Y
py = $game_player.screen_y - 32
cy = (py - y).abs
# Offset Y if text box is above player's position
if cy < 128 and TEXT_WINDOW_MOVE
y = py < y ? y + (y / 2) : y - (y / 2)
end
# Create Window
@name_window = Name_Window.new(x, y, @desc, @no_desc, @index, @gold, @icon)
# Wait for button(s) or time
wait_for_close
# Play sound
Audio.se_play(C_SND, C_SND_V, C_SND_P) if WAIT_FOR_BUTTON and PLAY_C_SND
end
#--------------------------------------------------------------------------
# Do Pop-Up
#--------------------------------------------------------------------------
def do_popup
# Pop-up icon(s)
for i in 1..@amount
Audio.se_play(P_SND, P_SND_V, P_SND_P) if PLAY_P_SND
for i in 0..4
@popup_window.pop_up(@icon, 0, i * -4)
@popup_window.update
wait(2)
end
wait(5) if i != @amount and !ONLY_SHOW_ONE
end
wait(5)
# Pop-up text
show_name if SHOW_POPUP_TEXT
# Exit
return_scene
end
end
adek16 - Czw 31 Gru, 2009 15:57 a masz tego skrypta do xpmjack1234 - Sob 03 Kwi, 2010 13:06 Mam pytanko.Kiedy zdobywam dany przedmiot to pierwsza lub pierwsze dwie litery nazwy przedmiotu znajdują się na ikonie przedmiotu tak samo jak zdobywam złoto po walce.Czy można to naprawić i sprawić żeby ikona i tekst pojawiał się trochę dalej?Ayene - Sob 03 Kwi, 2010 13:28 Znajdź w powyższym skrypcie linijkę:
Kod:
tx = gold ? 4 : 0
i zmień:
Kod:
tx = gold ? 0 : 24
a następnie znajdź:
Kod:
draw_icon(GOLD_ICON, width - 24, 0, true) if gold
i zamień na:
Kod:
draw_icon(GOLD_ICON, width, 0, true) if gold
mjack1234 - Sob 03 Kwi, 2010 14:14 Zmieniałem te linijki ale kiedy próbuje zabrać złoto to wyskakuje mi błąd:
Window_Base linijka 159
A gdy zabieram potiona to pokazuje mi się ikonka tak jak chciałem lecz nie widać całej nazwy Potiona :
(ikonka potiona)PotAyene - Sob 03 Kwi, 2010 14:19 No to coś musiałeś źle zrobić...
Zamień cały skrypt z pierwszego posta na poniższy:
Spoiler:
Kod:
#=====================================================
# Chest Item Pop-Up
#=========================================================
# Autor : OriginalWij
# wersja : 3.0
# "pół" tłumaczenie : bionicl
# Dla: : www.ultimateam.pl
#=========================================================
#
# Automatyczny "popup mode"
# (true = Zawsze "popup" wyskakuje ,false = "popup" nigdy nie wyskakuje)
AUTO_POPUP = true
# Switch do włączania/wyłączenia "popup"
# (aktywuje jeżeli AUTO_POPUP = false) (dezaktywuje jeżeli AUTO_POPUP = true)
POPUP_SWITCH = 10
# ikona złota (bo zawsze jest taka sama)
GOLD_ICON = 205
# grupowanie przedmiotów. true = np. dostałeś 4 takie same zbroje pokazuje:
# dostałeś zbroje, dostałeś zbroje, dostałeś zbroje, dostałeś zbroje
# false = dostałeś 4 zbroje
ONLY_SHOW_ONE = true
# Pokazuje wyniki walki. pokazuje "popup" po walce, gdy coś dostałeś
BATTLE_POP = true
# co pisze (tylko gdy BATTLE_POP = true ) jako "wyniki bitwy.
# np. po walce gdy wygrałeś 5 zł: "xxx 5 zł" ( xxx to właśnie ta nazwa)
BATTLE_REWARD = 'Nagroda po walce: '
# Zagrać dzwięk gdy jest "popup"?
PLAY_P_SND = true
#############################################################
# 3 opcje odnośnie dźwięku (Tylko jeżeli PLAY_P_SND = true) #
#############################################################
# po kolei: jaki dźwięk, głośność (0-100), nastrój (0-300)
P_SND = 'Audio/SE/Chime2'
P_SND_V = 100
P_SND_P = 150 # (standardowo)
class Game_System
#--------------------------------------------------------------------------
# Public Instance Variables (Added)
#--------------------------------------------------------------------------
attr_accessor :battle_pop # holds items to popup after battle
attr_accessor :battle_pop_gold # holds gold to popup after battle
#--------------------------------------------------------------------------
# Initialize (Mod)
#--------------------------------------------------------------------------
alias chest_pop_gs_initialize initialize unless $@
def initialize
chest_pop_gs_initialize
@battle_pop = nil
@battle_pop_gold = 0
end
#--------------------------------------------------------------------------
# Get Battle Pop (New)
#--------------------------------------------------------------------------
def battle_pop
return @battle_pop
end
#--------------------------------------------------------------------------
# Set Battle Pop (New)
#--------------------------------------------------------------------------
def battle_pop=(items)
@battle_pop = items
end
#--------------------------------------------------------------------------
# Get Battle Pop Gold (New)
#--------------------------------------------------------------------------
def battle_pop_gold
return @battle_pop_gold
end
#--------------------------------------------------------------------------
# Set Battle Pop Gold (New)
#--------------------------------------------------------------------------
def battle_pop_gold=(gold)
@battle_pop_gold = gold
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# Display Gained Experience and Gold (Rewrite)
#--------------------------------------------------------------------------
def display_exp_and_gold
# Save gold to popup after battle
$game_system.battle_pop_gold = $game_troop.gold_total if BATTLE_POP # added
exp = $game_troop.exp_total
gold = BATTLE_POP ? 0 : $game_troop.gold_total # changed
$game_party.gain_gold(gold) unless BATTLE_POP # changed
text = sprintf(Vocab::Victory, $game_party.name)
$game_message.texts.push('\|' + text)
if exp > 0
text = sprintf(Vocab::ObtainExp, exp)
$game_message.texts.push('\.' + text)
end
if gold > 0
text = sprintf(Vocab::ObtainGold, gold, Vocab::gold)
$game_message.texts.push('\.' + text)
end
wait_for_message
end
#--------------------------------------------------------------------------
# Display Gained Drop Items (Mod)
#--------------------------------------------------------------------------
alias chest_pop_display_drop_items display_drop_items unless $@
def display_drop_items
# Save items to popup after battle
$game_system.battle_pop = $game_troop.make_drop_items if BATTLE_POP
return if BATTLE_POP
chest_pop_display_drop_items
end
end
class Chest_Popup < Scene_Base
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize(type, amount, index, add = false, x = nil, y = nil)
x = $game_player.screen_x if x == nil
y = $game_player.screen_y if y == nil
$game_switches[POPUP_SWITCH] = !AUTO_POPUP
$scene.disable_blur = true
@x, @y, @amount = x, y, amount
@gold = @no_desc = false
case type
when 0 # Gold
$game_party.gain_gold(amount) if add
@icon = GOLD_ICON
@desc_amount = ''
@desc = @amount.to_s
@amount = 1
@gold = true
when 1 # Items
$game_party.gain_item($data_items[index], amount) if add
@icon = $data_items[index].icon_index
@desc_amount = @amount.to_s + ' x'
@desc_amount = '' if @amount == 1
@no_desc = true if @amount == 1
@desc = $data_items[index].name
@amount = 1 if ONLY_SHOW_ONE
when 2 # Weapons
$game_party.gain_item($data_weapons[index], amount) if add
@icon = $data_weapons[index].icon_index
@desc_amount = @amount.to_s + ' x'
@desc_amount = '' if @amount == 1
@no_desc = true if @amount == 1
@desc = $data_weapons[index].name
@amount = 1 if ONLY_SHOW_ONE
when 3 # Armors
$game_party.gain_item($data_armors[index], amount) if add
@icon = $data_armors[index].icon_index
@desc_amount = @amount.to_s + ' x'
@desc_amount = '' if @amount == 1
@no_desc = true if @amount == 1
@desc = $data_armors[index].name
@amount = 1 if ONLY_SHOW_ONE
end
# Set index
@index = @desc_amount
# Add description to text
if @gold
@desc = @desc + ' '
else
if SHOW_POPUP_TEXT_ICON
@desc = @desc_amount + ' ' + @desc
else
@desc = @desc_amount + ' ' + @desc if @desc_amount != ''
end
end
# If battle reward
item_check = $game_system.battle_pop
gold_check = $game_system.battle_pop_gold
if BATTLE_POP and (item_check != nil or gold_check > 0)
@desc = BATTLE_REWARD + @desc
end
end
#--------------------------------------------------------------------------
# Start
#--------------------------------------------------------------------------
def start
create_background
# Create pop-up window
@popup_window = Item_Popup_Window.new(@x, @y)
end
#--------------------------------------------------------------------------
# Terminate
#--------------------------------------------------------------------------
def terminate
# Dispose windows
@popup_window.dispose
@menuback_sprite.dispose
@name_window.dispose if SHOW_POPUP_TEXT
end
#--------------------------------------------------------------------------
# Return Scene
#--------------------------------------------------------------------------
def return_scene
# Turn off blur and pop-up switch
$scene.disable_blur = false
$game_switches[POPUP_SWITCH] = false
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
super
# Update pop-up window
@popup_window.update
@menuback_sprite.update
# Do the actual popping-up
do_popup
end
#--------------------------------------------------------------------------
# Update Basic
#--------------------------------------------------------------------------
def update_basic
Graphics.update
Input.update
end
#--------------------------------------------------------------------------
# Wait
#--------------------------------------------------------------------------
def wait(duration)
# Wait for DURATION frames
for i in 0..duration
update_basic
end
end
#--------------------------------------------------------------------------
# Wait for close
#--------------------------------------------------------------------------
def wait_for_close
count = 0
loop do
update_basic
count += 1
# Close if button 1 pressed
break if Input.trigger?(BUTTON_TO_WAIT_FOR1) and WAIT_FOR_BUTTON
# Close if button 2 pressed
break if Input.trigger?(BUTTON_TO_WAIT_FOR2) and WAIT_FOR_BUTTON
# Close if time elapsed
break if count >= WAIT_FOR_TIME and !WAIT_FOR_BUTTON
end
end
#--------------------------------------------------------------------------
# Create Background
#--------------------------------------------------------------------------
def create_background
# Create modified background
@menuback_sprite = Sprite.new
@menuback_sprite.bitmap = $game_temp.background_bitmap
@menuback_sprite.update
end
#--------------------------------------------------------------------------
# Show Name
#--------------------------------------------------------------------------
def show_name
x = 272
y = TEXT_WINDOW_Y
py = $game_player.screen_y - 32
cy = (py - y).abs
# Offset Y if text box is above player's position
if cy < 128 and TEXT_WINDOW_MOVE
y = py < y ? y + (y / 2) : y - (y / 2)
end
# Create Window
@name_window = Name_Window.new(x, y, @desc, @no_desc, @index, @gold, @icon)
# Wait for button(s) or time
wait_for_close
# Play sound
Audio.se_play(C_SND, C_SND_V, C_SND_P) if WAIT_FOR_BUTTON and PLAY_C_SND
end
#--------------------------------------------------------------------------
# Do Pop-Up
#--------------------------------------------------------------------------
def do_popup
# Pop-up icon(s)
for i in 1..@amount
Audio.se_play(P_SND, P_SND_V, P_SND_P) if PLAY_P_SND
for i in 0..4
@popup_window.pop_up(@icon, 0, i * -4)
@popup_window.update
wait(2)
end
wait(5) if i != @amount and !ONLY_SHOW_ONE
end
wait(5)
# Pop-up text
show_name if SHOW_POPUP_TEXT
# Exit
return_scene
end
end
mjack1234 - Sob 03 Kwi, 2010 14:24 Działa Świetnie !!!
Wielkie dzięki Ayene !!
PS.Może moja wina ale nic przy skrypcie nie grzebałem.Teraz Działa jak należy i jak chciałem Asantos - Sob 03 Kwi, 2010 16:59 Skrypt ma dużą wadę - pokazuję tylko jeden przedmiot, który dostajemy.mjack1234 - Sob 03 Kwi, 2010 22:24 Niestety to prawda,lecz jest świetny.Moim zdaniem jeżeli ktoś zauważy 100 skrzynek w każdej po 1 przedmiocie zamiast 50 skrzynek w których jest po 2 przedmioty to sprawi większe wrażenie Kiniaq - Sob 16 Paź, 2010 19:40 Asantos, znalazłem rozwiązanie tego problemu. Wystarczy pomiędzy wymienianymi przedmiotami dać komendę "Czekaj". Ja daję zawsze 1 klatkę i wystarcza Ayene - Pią 28 Paź, 2011 12:53 Niestety link do dema nie działa. Ktoś może zaktualizować? tracersgta - Pon 31 Paź, 2011 15:17 @Ayenehttp://www.mediafire.com/?kyommm0tzo2