|
|||||||
![]() |
|
|
Herramientas | Desplegado |
|
|||
|
Gracias pero hay otro problema Me salta demasiados errores hasta que me pide borrar el Main que hago?
|
|
|
||||
|
||||
|
Aportes de Scripts RPG-Maker
|
|
||||
|
[aqui va uno, pero no se que le pasa que a mi no me va, que alguien lo mire, pofa
tren de charas
Spoiler
#--------------------------------------------------------------------------
# Script de Seguimiento de Personajes #-------------------------------------------------------------------------- class Game_Map def in_range?(object) screne_x = $game_map.display_x screne_x -= 256 screne_y = $game_map.display_y screne_y -= 256 screne_width = $game_map.display_x screne_width += 2816 screne_height = $game_map.display_y screne_height += 2176 return false if object.real_x <= screne_x return false if object.real_x >= screne_width return false if object.real_y <= screne_y return false if object.real_y >= screne_height return true end def update if $game_map.need_refresh refresh end if @scroll_rest > 0 distance = 2 ** @scroll_speed case @scroll_direction when 2 scroll_down(distance) when 4 scroll_left(distance) when 6 scroll_right(distance) when 8 scroll_up(distance) end @scroll_rest -= distance end for event in @events.values if in_range?(event) or event.trigger == 3 or event.trigger == 4 event.update end end for common_event in @common_events.values common_event.update end @fog_ox -= @fog_sx / 8.0 @fog_oy -= @fog_sy / 8.0 if @fog_tone_duration >= 1 d = @fog_tone_duration target = @fog_tone_target @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d @fog_tone_duration -= 1 end if @fog_opacity_duration >= 1 d = @fog_opacity_duration @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d @fog_opacity_duration -= 1 end end end class Spriteset_Map def in_range?(object) screne_x = $game_map.display_x screne_x -= 256 screne_y = $game_map.display_y screne_y -= 256 screne_width = $game_map.display_x screne_width += 2816 screne_height = $game_map.display_y screne_height += 2176 return false if object.real_x <= screne_x return false if object.real_x >= screne_width return false if object.real_y <= screne_y return false if object.real_y >= screne_height return true end def update if @panorama_name != $game_map.panorama_name or @panorama_hue != $game_map.panorama_hue @panorama_name = $game_map.panorama_name @panorama_hue = $game_map.panorama_hue if @panorama.bitmap != nil @panorama.bitmap.dispose @panorama.bitmap = nil end if @panorama_name != "" @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue) end Graphics.frame_reset end if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue @fog_name = $game_map.fog_name @fog_hue = $game_map.fog_hue if @fog.bitmap != nil @fog.bitmap.dispose @fog.bitmap = nil end if @fog_name != "" @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue) end Graphics.frame_reset end @tilemap.ox = $game_map.display_x / 4 @tilemap.oy = $game_map.display_y / 4 @tilemap.update @panorama.ox = $game_map.display_x / 8 @panorama.oy = $game_map.display_y / 8 @fog.zoom_x = $game_map.fog_zoom / 100.0 @fog.zoom_y = $game_map.fog_zoom / 100.0 @fog.opacity = $game_map.fog_opacity @fog.blend_type = $game_map.fog_blend_type @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy @fog.tone = $game_map.fog_tone i=0 for sprite in @character_sprites if sprite.character.is_a?(Game_Event) if in_range?(sprite.character) or sprite.character.trigger == 3 or sprite.character.trigger == 4 sprite.update i+=1 end else sprite.update i+=1 end end #p i @weather.type = $game_screen.weather_type @weather.max = $game_screen.weather_max @weather.ox = $game_map.display_x / 4 @weather.oy = $game_map.display_y / 4 @weather.update for sprite in @picture_sprites sprite.update end @timer_sprite.update @viewport1.tone = $game_screen.tone @viewport1.ox = $game_screen.shake @viewport3.color = $game_screen.flash_color @viewport1.update @viewport3.update end end |
|
||||
|
Cita:
Saludos |
|
||||
|
esto se aregla en un pim-pam. la verdad es que es culpa mia, me equivoque por error, pero ahora si que pongo el tren de charas
Spoiler
#--------------------------------------------
# Train_Actor # Script de Seguimiento de Grupo # fukuyama@alles.or.jp # http://www4.big.or.jp/~fukuyama/ # Edición por Makerhack # http://www.rpgmakerxp.com # TRAIN_ACTOR_TRANSPARENT_SWITCH = false TRAIN_ACTOR_TRANSPARENT_SWITCH = true TRAIN_ACTOR_TRANSPARENT_SWITCHES_INDEX = 20 #Input: OWN = 2#Input::LEFT = 4 #Input::RIGHT = 6 #Input::UP = 8 DOWN_LEFT = 1 DOWN_RIGHT = 3 UP_LEFT = 7 UP_RIGHT = 9 JUMP = 5 class Game_Party_Actor < Game_Character def initialize super() @through = true end def setup(actor) if actor != nil @character_name = actor.character_name @character_hue = actor.character_hue else @character_name = "" @character_hue = 0 end @opacity = 255 @blend_type = 0 end def screen_z(height = 0) if $game_player.x == @x and $game_player.y == @y return $game_player.screen_z(height) - 1 end super(height) end #-------------------------------------------------------------------------- def move_down(turn_enabled = true) if turn_enabled turn_down end if passable?(@x, @y, Input: OWN)turn_down @y += 1 end end #-------------------------------------------------------------------------- def move_left(turn_enabled = true) if turn_enabled turn_left end if passable?(@x, @y, Input::LEFT) turn_left @x -= 1 end end #-------------------------------------------------------------------------- def move_right(turn_enabled = true) if turn_enabled turn_right end if passable?(@x, @y, Input::RIGHT) turn_right @x += 1 end end #-------------------------------------------------------------------------- def move_up(turn_enabled = true) if turn_enabled turn_up end if passable?(@x, @y, Input::UP) turn_up @y -= 1 end end #-------------------------------------------------------------------------- def move_lower_left unless @direction_fix @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input: OWN : @direction)end if (passable?(@x, @y, Input: OWN) and passable?(@x, @y + 1, Input::LEFT)) or(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input: OWN))@x -= 1 @y += 1 end end #-------------------------------------------------------------------------- def move_lower_right unless @direction_fix @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input: OWN : @direction)end if (passable?(@x, @y, Input: OWN) and passable?(@x, @y + 1, Input::RIGHT)) or(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input: OWN))@x += 1 @y += 1 end end #-------------------------------------------------------------------------- def move_upper_left unless @direction_fix @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input: OWN ? Input::UP : @direction)end if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP)) @x -= 1 @y -= 1 end end #-------------------------------------------------------------------------- def move_upper_right unless @direction_fix @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input: OWN ? Input::UP : @direction)end if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP)) @x += 1 @y -= 1 end end def set_move_speed(move_speed) @move_speed = move_speed end end class Spriteset_Map def setup_actor_character_sprites? return @setup_actor_character_sprites_flag != nil end def setup_actor_character_sprites(characters) if !setup_actor_character_sprites? index_game_player = 0 @character_sprites.each_index do |i| if @character_sprites[i].character.instance_of?(Game_Player) index_game_player = i break end end for character in characters.reverse @character_sprites.unshift( Sprite_Character.new(@viewport1, character) ) end @setup_actor_character_sprites_flag = true end end end class Scene_Map def setup_actor_character_sprites(characters) @spriteset.setup_actor_character_sprites(character s) end end class Game_Party def set_transparent_actors(transparent) @transparent = transparent end def setup_actor_character_sprites if @characters == nil @characters = [] for i in 1 .. 4 @characters.push(Game_Party_Actor.new) end end if @actors_chach == nil @actors_chach = [] end if @actors_chach != @actors @actors_chach = @actors.clone for i in 1 .. 4 @characters[i - 1].setup(actors[i]) end end if $scene.instance_of?(Scene_Map) $scene.setup_actor_character_sprites(@characters) end end def update_party_actors setup_actor_character_sprites transparent = $game_player.transparent if transparent == false if TRAIN_ACTOR_TRANSPARENT_SWITCH transparent = $game_switches[TRAIN_ACTOR_TRANSPARENT_SWITCHES_INDEX] else transparent = $game_player.transparent end end for character in @characters character.transparent = transparent character.set_move_speed($game_player.get_move_spe ed) character.update end end def moveto_party_actors( x, y ) setup_actor_character_sprites for character in @characters character.moveto( x, y ) end if @move_list == nil @move_list = [] end for i in 0 .. 10 @move_list[i] = nil end end def move_party_actors if @move_list == nil @move_list = [] for i in 0 .. 10 @move_list[i] = nil end end @move_list.each_index do |i| if @characters[i] != nil case @move_list[i].type when Input: OWN@characters[i].move_down(@move_list[i].args[0]) when Input::LEFT @characters[i].move_left(@move_list[i].args[0]) when Input::RIGHT @characters[i].move_right(@move_list[i].args[0]) when Input::UP @characters[i].move_up(@move_list[i].args[0]) when DOWN_LEFT @characters[i].move_lower_left when DOWN_RIGHT @characters[i].move_lower_right when UP_LEFT @characters[i].move_upper_left when UP_RIGHT @characters[i].move_upper_right when JUMP @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1]) end end end end class Move_List_Element def initialize(type,args) @type = type @args = args end def type() return @type end def args() return @args end end def add_move_list(type,*args) @move_list.unshift(Move_List_Element.new(type,args )).pop end def move_down_party_actors(turn_enabled = true) move_party_actors add_move_list(Input: OWN,turn_enabled)end def move_left_party_actors(turn_enabled = true) move_party_actors add_move_list(Input::LEFT,turn_enabled) end def move_right_party_actors(turn_enabled = true) move_party_actors add_move_list(Input::RIGHT,turn_enabled) end def move_up_party_actors(turn_enabled = true) move_party_actors add_move_list(Input::UP,turn_enabled) end def move_lower_left_party_actors move_party_actors add_move_list(DOWN_LEFT) end def move_lower_right_party_actors move_party_actors add_move_list(DOWN_RIGHT) end def move_upper_left_party_actors move_party_actors add_move_list(UP_LEFT) end def move_upper_right_party_actors move_party_actors add_move_list(UP_RIGHT) end def jump_party_actors(x_plus, y_plus) move_party_actors add_move_list(JUMP,x_plus, y_plus) end end module Game_Player_Module def update $game_party.update_party_actors super end def moveto( x, y ) super $game_party.moveto_party_actors( x, y ) end def move_down(turn_enabled = true) if passable?(@x, @y, Input: OWN)$game_party.move_down_party_actors(turn_enabled) end super(turn_enabled) end def move_left(turn_enabled = true) if passable?(@x, @y, Input::LEFT) $game_party.move_left_party_actors(turn_enabled) end super(turn_enabled) end def move_right(turn_enabled = true) if passable?(@x, @y, Input::RIGHT) $game_party.move_right_party_actors(turn_enabled) end super(turn_enabled) end def move_up(turn_enabled = true) if passable?(@x, @y, Input::UP) $game_party.move_up_party_actors(turn_enabled) end super(turn_enabled) end def move_lower_left if (passable?(@x, @y, Input: OWN) and passable?(@x, @y + 1, Input::LEFT)) or(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input: OWN))$game_party.move_lower_left_party_actors end super end def move_lower_right if (passable?(@x, @y, Input: OWN) and passable?(@x, @y + 1, Input::RIGHT)) or(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input: OWN))$game_party.move_lower_right_party_actors end super end def move_upper_left if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP)) $game_party.move_upper_left_party_actors end super end def move_upper_right if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP)) $game_party.move_upper_right_party_actors end super end def jump(x_plus, y_plus) new_x = @x + x_plus new_y = @y + y_plus if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0) $game_party.jump_party_actors(x_plus, y_plus) end super(x_plus, y_plus) end # ----------------------------------------------- def get_move_speed return @move_speed end end class Game_Player include Game_Player_Module end a parte, pongo este que no se que le passa, si alguien sabe el error que avise.
Spoiler
def refresh self.contents.clear if $game_temp.shop_type == 0 for i in 0...@item_max draw_item(i) end end if $game_temp.shop_type == 1 self.contents.draw_text(4, 0, 324, 32, "You can only buy at this shop.") self.index = -1 update_cursor_rect end if $game_temp.shop_type == 2 self.contents.draw_text(4, 0, 324, 32, "You can only sell at this shop.") self.index = -1 update_cursor_rect end end def draw_item(index) x = 4 + index * 160 self.contents.draw_text(x, 0, 128, 32, @commands[index]) end def update_cursor_rect if $game_temp.shop_type == 0 super end if $game_temp.shop_type == 1 || $game_temp.shop_type == 2 self.cursor_rect.empty end end end #================================================= ============================= class Window_ShopBuyBG < Window_Base def initialize super(0, 128, 320, 352) self.contents = Bitmap.new(width - 32, height - 32) refresh end def refresh self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, 128, 32, 'Item Name') self.contents.draw_text(4, 0, 284, 32, 'Marked Price', 2) end end #================================================= ============================= class Window_ShopBuy < Window_Selectable def initialize(shop_goods) super(0, 160, 320, 320) @shop_goods = shop_goods refresh self.index = 0 self.opacity = 0 end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @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 # If item count is not 0, make a bit map and draw all items @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 def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) + $game_temp.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) + $game_temp.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) + $game_temp.armor_number(item.id) end price = [[item.price * $game_temp.buy_rate / 100, 9999999].min, 0].max if number >= 99 self.contents.font.color = disabled_color else self.contents.font.color = normal_color end x = 4 y = index * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 192, y, 88, 32, price.to_s, 2) end end #================================================= ============================= class Window_ShopNumber < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 128, 320, 352) self.contents = Bitmap.new(width - 32, height - 32) @item = nil @max = 1 @price = 0 @number = 1 end #-------------------------------------------------------------------------- # * Set Items, Max Quantity, and Price #-------------------------------------------------------------------------- def set(item, max, price) @item = item @max = max @price = price @number = 1 refresh end #-------------------------------------------------------------------------- # * Set Inputted Quantity #-------------------------------------------------------------------------- def number return @number end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear draw_item_name(@item, 4, 96) self.contents.font.color = normal_color self.contents.draw_text(236, 96, 32, 32, "×") self.contents.draw_text(248, 96, 24, 32, @number.to_s, 2) self.cursor_rect.set(304, 96, 32, 32) # Draw total price and currency units domination = $data_system.words.gold cx = contents.text_size(domination).width total_price = @price * @number self.contents.font.color = normal_color self.contents.draw_text(0, 160, 288-cx-4, 32, total_price.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(288-cx, 160, cx, 32, domination, 2) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if self.active # Cursor right (+1) if Input.repeat?(Input::RIGHT) and @number < @max $game_system.se_play($data_system.cursor_se) @number += 1 refresh end # Cursor left (-1) if Input.repeat?(Input::LEFT) and @number > 1 $game_system.se_play($data_system.cursor_se) @number -= 1 refresh end # Cursor up (+10) if Input.repeat?(Input::UP) and @number < @max $game_system.se_play($data_system.cursor_se) @number = [@number + 10, @max].min refresh end # Cursor down (-10) if Input.repeat?(Input: OWN) and @number > 1$game_system.se_play($data_system.cursor_se) @number = [@number - 10, 1].max refresh end end end end #================================================= ============================= class Window_ShopNumber2 < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 128, 320, 352) self.contents = Bitmap.new(width - 32, height - 32) @item = nil @max = 1 @number = 1 end #-------------------------------------------------------------------------- # * Set Items, Max Quantity, and Price #-------------------------------------------------------------------------- def set(item) @item = item @number = 1 refresh end #-------------------------------------------------------------------------- # * Set Inputted Quantity #-------------------------------------------------------------------------- def number return @number end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear draw_item_name(@item, 4, 96) case @item when RPG::Item @max = $game_temp.item_number(@item.id) when RPG::Weapon @max = $game_temp.weapon_number(@item.id) when RPG::Armor @max = $game_temp.armor_number(@item.id) end self.contents.font.color = normal_color self.contents.draw_text(236, 96, 32, 32, "×") self.contents.draw_text(248, 96, 24, 32, @number.to_s, 2) self.cursor_rect.set(304, 96, 32, 32) self.contents.draw_text(248, 128, 24, 32, "#{@max - @number}", 2) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if self.active # Cursor right (+1) if Input.repeat?(Input::RIGHT) and @number < @max $game_system.se_play($data_system.cursor_se) @number += 1 refresh end # Cursor left (-1) if Input.repeat?(Input::LEFT) and @number > 1 $game_system.se_play($data_system.cursor_se) @number -= 1 refresh end # Cursor up (+10) if Input.repeat?(Input::UP) and @number < @max $game_system.se_play($data_system.cursor_se) @number = [@number + 10, @max].min refresh end # Cursor down (-10) if Input.repeat?(Input: OWN) and @number > 1$game_system.se_play($data_system.cursor_se) @number = [@number - 10, 1].max refresh end end end end #================================================= ============================= class Window_ShopFinalize < Window_Selectable attr_reader :final_price def initialize super(0, 128, 320, 352) self.contents = Bitmap.new(width - 32, height - 32) self.index = 0 self.active = false @item_max = 2 @final_price = 0 refresh end def refresh @final_price = 0 base_price = 0 for i in 1..$data_items.size if $game_temp.item_number(i) > 0 price = $game_temp.item_number(i) * $data_items[i].price base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max end end for i in 1..$data_weapons.size if $game_temp.weapon_number(i) > 0 price = $game_temp.weapon_number(i) * $data_weapons[i].price base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max end end for i in 1..$data_armors.size if $game_temp.armor_number(i) > 0 price = $game_temp.armor_number(i) * $data_armors[i].price base_price += [[price * $game_temp.buy_rate / 100, 9999999].min, 0].max end end total_price = base_price discount = 0 if $game_temp.discount != 0 discount = [[total_price * $game_temp.discount / 100, 9999999].min, 0].max total_price = total_price - discount end tax = 0 if $game_temp.tax != 0 tax = [[total_price * $game_temp.tax / 100, 9999999].min, 0].max end total_price = total_price + tax self.contents.clear word = $data_system.words.gold cx = contents.text_size(word).width self.contents.font.color = system_color self.contents.draw_text(4, 0, 288, 32, 'Finalize this purchase?', 1) self.contents.draw_text(4, 64, 128, 32, 'Price of Items:') self.contents.draw_text(4, 96, 128, 32, 'Sales Discount:') self.contents.draw_text(4, 128, 128, 32, 'Tax Added:') self.contents.fill_rect(4, 160, 280, 1, normal_color) self.contents.draw_text(4, 160, 128, 32, 'Grand Total:') self.contents.draw_text(0, 64, 288, 32, word, 2) self.contents.draw_text(0, 96, 288, 32, word, 2) self.contents.draw_text(0, 128, 288, 32, word, 2) self.contents.draw_text(0, 160, 288, 32, word, 2) self.contents.font.color = normal_color self.contents.draw_text(0, 64, 288-cx-2, 32, base_price.to_s, 2) self.contents.draw_text(0, 96, 288-cx-2, 32, discount.to_s, 2) self.contents.draw_text(0, 128, 288-cx-2, 32, tax.to_s, 2) self.contents.draw_text(0, 160, 288-cx-2, 32, total_price.to_s, 2) self.contents.draw_text(0, 256, 288, 32, 'No', 1) if total_price > $game_party.gold self.contents.font.color = disabled_color end self.contents.draw_text(0, 224, 288, 32, 'Yes', 1) @final_price = total_price end def update_cursor_rect if self.index == 0 cursor_rect.set(0, 224, 288, 32) else cursor_rect.set(0, 256, 288, 32) end end end #================================================= ============================= #================================================= ============================= # ** Window_ShopStatus #------------------------------------------------------------------------------ # This window displays number of items in possession and the actor's equipment # on the shop screen. #================================================= ============================= class Window_ShopStatus < Window_Selectable attr_reader :data #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(320, 128, 320, 352) refresh self.index = 0 self.active = false @data = [] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # Add item for i in 1...$data_items.size if $game_temp.item_number(i) > 0 @data.push($data_items[i]) end end # Also add weapons and items if outside of battle for i in 1...$data_weapons.size if $game_temp.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if $game_temp.armor_number(i) > 0 @data.push($data_armors[i]) end end # If item count is not 0, make a bit map and draw all items @item_max = @data.size + 1 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 #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] if item != nil case item when RPG::Item number = $game_temp.item_number(item.id) when RPG::Weapon number = $game_temp.weapon_number(item.id) when RPG::Armor number = $game_temp.armor_number(item.id) end x = 4 y = index * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, "x", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) else x = 4 y = index * 32 self.contents.font.color = @data == [] ? disabled_color : normal_color self.contents.draw_text(x, y, 288, 32, 'Finalize Purchase', 1) end end def item return @data[self.index] end def update_help if item != nil @help_window.set_text(item.description) else @help_window.set_text('Purchase all the goods in your cart.') end end end #================================================= ============================= # ** Scene_Shop #------------------------------------------------------------------------------ # This class performs shop screen processing. #================================================= ============================= class Scene_Shop #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # Make help window @help_window = Window_Help.new # Make command window @command_window = Window_ShopCommand.new # Make gold window @gold_window = Window_Gold.new @gold_window.x = 480 @gold_window.y = 64 # Make dummy window @dummy_window = Window_Base.new(0, 128, 640, 352) # Make buy window @buy_window = Window_ShopBuy.new($game_temp.shop_goods) @buy_window.active = false @buy_window.visible = false @buy_window.help_window = @help_window @buyBG = Window_ShopBuyBG.new @buyBG.visible = false # Make sell window @sell_window = Window_ShopSell.new @sell_window.active = false @sell_window.visible = false @sell_window.help_window = @help_window # Make quantity input window @number_window = Window_ShopNumber.new @number_window.active = false @number_window.visible = false @number_window2 = Window_ShopNumber2.new @number_window2.active = false @number_window2.visible = false # Make status window @status_window = Window_ShopStatus.new @status_window.visible = false @status_window.help_window = @help_window @finalize_window = Window_ShopFinalize.new @finalize_window.visible = false if $game_temp.shop_type == 1 @command_window.index = 0 @command_window.active = false @dummy_window.visible = false @buy_window.active = true @buy_window.visible = true @buyBG.visible = true @buy_window.refresh @status_window.visible = true end if $game_temp.shop_type == 2 @command_window.index = 1 @command_window.active = false @dummy_window.visible = false @sell_window.active = true @sell_window.visible = true @sell_window.refresh end # 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 @help_window.dispose @command_window.dispose @gold_window.dispose @dummy_window.dispose @buy_window.dispose @buyBG.dispose @sell_window.dispose @number_window.dispose @number_window2.dispose @status_window.dispose @finalize_window.dispose $game_temp.clear_cart $game_temp.buy_rate = 100 $game_temp.sell_rate = 50 $game_temp.discount = 0 $game_temp.shop_type = 0 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update windows @help_window.update @command_window.update @gold_window.update @dummy_window.update @buy_window.update @buyBG.update @sell_window.update @number_window.update @number_window2.update @status_window.update @finalize_window.update # If command window is active: call update_command if @command_window.active update_command return # If buy window is active: call update_buy elsif @buy_window.active update_buy return # If sell window is active: call update_sell elsif @sell_window.active update_sell return # If quantity input window is active: call update_number elsif @number_window.active update_number return elsif @status_window.active update_status elsif @finalize_window.active update_finalize elsif @number_window2.active update_number2 end 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) # Branch by command window cursor position case @command_window.index when 0 # buy # Play decision SE $game_system.se_play($data_system.decision_se) # Change windows to buy mode @command_window.active = false @dummy_window.visible = false @buy_window.active = true @buy_window.visible = true @buy_window.refresh @buyBG.visible = true @status_window.visible = true when 1 # sell # Play decision SE $game_system.se_play($data_system.decision_se) # Change windows to sell mode @command_window.active = false @dummy_window.visible = false @sell_window.active = true @sell_window.visible = true @sell_window.refresh when 2 # quit # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to map screen $scene = Scene_Map.new end return end end #-------------------------------------------------------------------------- # * Frame Update (when buy window is active) #-------------------------------------------------------------------------- def update_buy # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) if $game_temp.shop_type == 1 $scene = Scene_Map.new return end # Change windows to initial mode @command_window.active = true @dummy_window.visible = true @buy_window.active = false @buy_window.visible = false @buyBG.visible = false @status_window.visible = false # Erase help text @help_window.set_text("") return end # If C button was pressed if Input.trigger?(Input::C) # Get item @item = @buy_window.item # Get items in possession count case @item when RPG::Item number = $game_party.item_number(@item.id) number2 = $game_temp.item_number(@item.id) when RPG::Weapon number = $game_party.weapon_number(@item.id) number2 = $game_temp.weapon_number(@item.id) when RPG::Armor number = $game_party.armor_number(@item.id) number2 = $game_temp.armor_number(@item.id) end # If 99 items are already in possession if number + number2 >= 99 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Calculate maximum amount possible to buy max = [99, 99 - number - number2].min # Change windows to quantity input mode @buy_window.active = false @buy_window.visible = false @buyBG.visible = false price = [[@item.price * $game_temp.buy_rate / 100, 9999999].min, 0].max @number_window.set(@item, max, price) @number_window.active = true @number_window.visible = true end # If RIGHT was pressed if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT) $game_system.se_play($data_system.decision_se) @buy_window.active = false @status_window.active = true end end #-------------------------------------------------------------------------- # * Frame Update (when sell window is active) #-------------------------------------------------------------------------- def update_sell # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) if $game_temp.shop_type == 2 $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end # Change windows to initial mode @command_window.active = true @dummy_window.visible = true @sell_window.active = false @sell_window.visible = false # Erase help text @help_window.set_text("") return end # If C button was pressed if Input.trigger?(Input::C) # Get item @item = @sell_window.item # If item is invalid, or item price is 0 (unable to sell) if @item == nil or @item.price == 0 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Get items in possession count case @item when RPG::Item number = $game_party.item_number(@item.id) when RPG::Weapon number = $game_party.weapon_number(@item.id) when RPG::Armor number = $game_party.armor_number(@item.id) end # Maximum quanitity to sell = number of items in possession max = number price = [[@item.price * $game_temp.sell_rate / 100, 9999999].min, 1].max # Change windows to quantity input mode @sell_window.active = false @sell_window.visible = false @number_window.set(@item, max, price) @number_window.active = true @number_window.visible = true @status_window.visible = true end end #-------------------------------------------------------------------------- # * Frame Update (when quantity input window is active) #-------------------------------------------------------------------------- def update_number # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Set quantity input window to inactive / invisible @number_window.active = false @number_window.visible = false # Branch by command window cursor position case @command_window.index when 0 # buy # Change windows to buy mode @buy_window.active = true @buy_window.visible = true @buyBG.visible = true when 1 # sell # Change windows to sell mode @sell_window.active = true @sell_window.visible = true @status_window.visible = false end return end # If C button was pressed if Input.trigger?(Input::C) # Set quantity input window to inactive / invisible @number_window.active = false @number_window.visible = false # Branch by command window cursor position case @command_window.index when 0 # buy $game_system.se_play($data_system.equip_se) case @item when RPG::Item $game_temp.gain_item(@item.id, @number_window.number) when RPG::Weapon $game_temp.gain_weapon(@item.id, @number_window.number) when RPG::Armor $game_temp.gain_armor(@item.id, @number_window.number) end # Refresh each window @gold_window.refresh @buy_window.refresh @status_window.refresh # Change windows to buy mode @buy_window.active = true @buy_window.visible = true @buyBG.visible = true when 1 # sell $game_system.se_play($data_system.shop_se) # Sell process price = [[@item.price * $game_temp.sell_rate / 100, 9999999].min, 1].max $game_party.gain_gold(@number_window.number * (price)) case @item when RPG::Item $game_party.lose_item(@item.id, @number_window.number) when RPG::Weapon $game_party.lose_weapon(@item.id, @number_window.number) when RPG::Armor $game_party.lose_armor(@item.id, @number_window.number) end # Refresh each window @gold_window.refresh @sell_window.refresh @status_window.refresh # Change windows to sell mode @sell_window.active = true @sell_window.visible = true @status_window.visible = false end return end end def update_status if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT) $game_system.se_play($data_system.decision_se) @buy_window.active = true @status_window.active = false end if Input.trigger?(Input::C) if @status_window.item == nil if @status_window.data != [] $game_system.se_play($data_system.decision_se) @buy_window.visible = false @buyBG.visible = false @finalize_window.visible = true @finalize_window.index = 0 @finalize_window.refresh @finalize_window.active = true @status_window.active = false return else $game_system.se_play($data_system.buzzer_se) return end else $game_system.se_play($data_system.decision_se) @status_window.active = false @buy_window.visible = false @buyBG.visible = false @number_window2.set(@status_window.item) @number_window2.visible = true @number_window2.active = true end end if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) if $game_temp.shop_type == 1 $scene = Scene_Map.new return end # Change windows to initial mode @command_window.active = true @dummy_window.visible = true @buy_window.visible = false @buyBG.visible = false @status_window.visible = false @status_window.active = false # Erase help text @help_window.set_text("") return end end def update_finalize if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) @buy_window.visible = true @buy_window.active = false @buyBG.visible = true @finalize_window.visible = false @finalize_window.active = false @status_window.active = true @buy_window.refresh end if Input.trigger?(Input::C) if @finalize_window.index == 0 if @finalize_window.final_price > $game_party.gold $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.shop_se) $game_party.lose_gold(@finalize_window.final_price ) $game_temp.gain_items @gold_window.refresh @buy_window.visible = true @buy_window.active = true @buyBG.visible = true @finalize_window.visible = false @finalize_window.act |
















