This is the first time I ever requested help on scripting, about two years ago I didn't know the first thing about scripting when I started using RMXP. So is anyone kind enough to show me the errors in this edited script by Moghunter? I've been trying to edit the Item menu so that I can select whether I want to open up Armors, Items or Weapons inventories, It's all been edited to work, except for one little small detail. Everytime I leave the item part and go to another and come back to item. The target window pops up.. I've tried everything.. The last thing I want to do is change the button that enters the menu, I wanna keep using C. So if anyone could be so kind as to show me where I fail :crazy: I'll love you forever. :angel:
Code:
#_______________________________________________________________________________
# MOG_Scene_Item V1.3
#_______________________________________________________________________________
# By Moghunter
# [url=http://www.atelier-rgss.com]http://www.atelier-rgss.com[/url]
#_______________________________________________________________________________
module MOG
#Transition Time.
MNIT = 10
#Transition Type(Name).
MNITT = "004-Blind04"
end
$mogscript = {} if $mogscript == nil
$mogscript["MOG_Scene_Item"] = true
###############
# Window_Base #
###############
class Window_Base < Window
def nada
face = RPG::Cache.picture("")
end
def drw_face5(actor,x,y)
face = RPG::Cache.picture(actor.name + "_fc5") rescue nada
cw = face.width
ch = face.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x , y - ch, face, src_rect)
end
def drw_charback(x,y)
face = RPG::Cache.picture("CharSelectBackground") rescue nada
cw = face.width
ch = face.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x , y, face, src_rect)
end
def draw_maphp3(actor, x, y)
back = RPG::Cache.picture("BAR0")
cw = back.width
ch = back.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 65, y - ch + 30, back, src_rect)
meter = RPG::Cache.picture("HP_Bar")
cw = meter.width * actor.hp / actor.maxhp
ch = meter.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 65, y - ch + 30, meter, src_rect)
text = RPG::Cache.picture("HP_Tx")
cw = text.width
ch = text.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 35, y - ch + 30, text, src_rect)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x + 81, y - 1, 48, 32, actor.hp.to_s, 2)
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(x + 80, y - 2, 48, 32, actor.hp.to_s, 2)
end
def draw_mapsp3(actor, x, y)
back = RPG::Cache.picture("BAR0")
cw = back.width
ch = back.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 65, y - ch + 30, back, src_rect)
meter = RPG::Cache.picture("SP_Bar")
cw = meter.width * actor.sp / actor.maxsp
ch = meter.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 65, y - ch + 30, meter, src_rect)
text = RPG::Cache.picture("SP_Tx")
cw = text.width
ch = text.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 35, y - ch + 30, text, src_rect)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x + 81, y - 1, 48, 32, actor.sp.to_s, 2)
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(x + 80, y - 2, 48, 32, actor.sp.to_s, 2)
end
def draw_mexp_it(actor, x, y)
lv_tx = RPG::Cache.picture("LV_tx")
cw = lv_tx.width
ch = lv_tx.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x + 60 , y - ch + 32, lv_tx, src_rect)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x + 101, y + 5, 24, 32, actor.level.to_s, 1)
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(x + 100, y + 4, 24, 32, actor.level.to_s, 1)
end
def draw_actor_state_it(actor, x, y, width = 80)
text = make_battler_state_text(actor, width, true)
self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
self.contents.draw_text(x, y, width, 32, text,1)
end
end
######################
# Window_Target_Item #
######################
class Window_Target_Item < Window_Selectable
def initialize
super(0, 130, 290, 300)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "BorisBlackBloxx"
self.windowskin = RPG::Cache.windowskin("Mywindowskin_deep")
self.z += 20
@item_max = $game_party.actors.size
refresh
end
def refresh
self.contents.clear
drw_charback(0,0)
for i in 0...$game_party.actors.size
x = 4
y = i * 65
actor = $game_party.actors[i]
drw_face5(actor,x,y + 55)
if $mogscript["TP_System"] == true
draw_actor_tp(actor, x + 168, y + 27 ,4)
else
draw_mexp_it(actor, x + 110, y + 25 )
end
draw_actor_state_it(actor, x + 165, y )
draw_maphp3(actor, x + 20, y + 0)
draw_mapsp3(actor, x + 20, y + 32)
end
end
def update_cursor_rect
if @index <= -2
self.cursor_rect.set(-5, (@index + 10) * 65, self.width - 32, 60)
elsif @index == -1
self.cursor_rect.set(-5, 0, self.width - 32, @item_max * 64 )
else
self.cursor_rect.set(-5, @index * 65, self.width - 32, 60)
end
end
end
################
# Window_Blank #
################
class Window_StartSel01 < Window_Selectable
def initialize
super(0, 0, 120, 800)
self.contents = Bitmap.new(width - 32, height - 32)
self.windowskin = RPG::Cache.windowskin("Mywindowskin_deep")
self.opacity = 25
self.z = 255
self.active = false
self.index = -1
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, 0, self.width - 32, 62)
end
end
end
############
# Type_Sel #
############
class Type_Sel < Window_Base
attr_reader :index
attr_reader :help_window
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 1
@index = -1
end
def index=(index)
@index = index
end
def row_max
return (@item_max + @column_max - 1) / @column_max
end
def top_row
return self.oy / 32
end
def top_row=(row)
if row < 0
row = 0
end
if row > row_max - 1
row = row_max - 1
end
self.oy = row * 32
end
def page_row_max
return (self.height - 32) / 32
end
def page_item_max
return page_row_max * @column_max
end
end
###############
# Window_Type #
###############
class Window_Type < Type_Sel
def initialize
super(0, 0, 0, 0)
@item_max = 3
self.index = 0
end
end
#################
# Window_Weapon #
#################
class Window_Weapon < Window_Selectable
def initialize
super(0, 68, 640, 346)
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
def weapon
return @data[self.index]
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
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_weapon(i)
end
end
end
def draw_weapon(index)
weapon = @data[index]
case weapon
when RPG::Weapon
number = $game_party.weapon_number(weapon.id)
end
self.contents.font.color = disabled_color
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 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(weapon.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, weapon.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.weapon == nil ? "" : self.weapon.description)
end
end
################
# Window_Armor #
################
class Window_Armor < Window_Selectable
def initialize
super(0, 68, 640, 346)
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
def armor
return @data[self.index]
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
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_armor(i)
end
end
end
def draw_armor(index)
armor = @data[index]
case armor
when RPG::Armor
number = $game_party.armor_number(armor.id)
end
self.contents.font.color = disabled_color
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 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(armor.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, armor.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
def update_help
@help_window.set_text(self.armor == nil ? "" : self.armor.description)
end
end
##############
# Scene_Item #
##############
class Scene_Item
def main
@holycastle = 0
@spriteset = Spriteset_Map.new
@item_lay = Sprite.new
@item_lay.bitmap = RPG::Cache.picture("Item_lay")
@item_lay.z = 100
@item_com = Sprite.new
@item_com.bitmap = RPG::Cache.picture("Item_com00")
@item_com.z = 100
@type = Window_Type.new
@type.opacity = 0
@type.visible = false
@help_window = Window_Help.new
@help_window.y = 405
@item_window = Window_Item.new
@item_window.visible = false
@item_window.active = false
@window_startsel01 = Window_StartSel01.new
@window_startsel01.x = 332
@window_startsel01.y = 5
@window_startsel01.opacity = 255
@window_startsel01.index = 0
@WindowsActive = 0
@item_window.help_window = @help_window
@weapon_window = Window_Weapon.new
@weapon_window.help_window = @help_window
@weapon_window.visible = false
@weapon_window.active = false
@armor_window = Window_Armor.new
@armor_window.help_window = @help_window
@armor_window.visible = false
@armor_window.active = false
@target_window = Window_Target_Item.new
@target_window.x = -300
@target_window.active = false
@help_window.opacity = 0
@help_window.x = -200
@help_window.contents_opacity = 0
@item_window.opacity = 0
@weapon_window.opacity = 0
@armor_window.opacity = 0
@target_window.opacity = 0
@weapon_window.x = 40
@armor_window.x = 40
@item_window.x = 40
@weapon_window.contents_opacity = 0
@armor_window.contents_opacity = 0
@item_window.contents_opacity = 0
Graphics.transition(MOG::MNIT, "Graphics/Transitions/" + MOG::MNITT)
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
for i in 0..10
@weapon_window.x += 5
@armor_window.x += 5
@item_window.x += 5
@weapon_window.contents_opacity -= 25
@armor_window.contents_opacity -= 25
@item_window.contents_opacity -= 25
@item_lay.zoom_x += 0.2
@item_lay.opacity -= 25
@item_com.zoom_y += 0.2
@item_com.opacity -= 25
@target_window.x -= 25
@help_window.contents_opacity -= 25
@window_startsel01.x += 35
@window_startsel01.opacity -= 25
Graphics.update
end
Graphics.freeze
@window_startsel01.dispose
@spriteset.dispose
@help_window.dispose
@item_window.dispose
@weapon_window.dispose
@armor_window.dispose
@target_window.dispose
@item_lay.dispose
@item_com.dispose
end
def update
if @target_window.active == false
update_menu
end
if @item_window.active == false
update_item
end
if @WindowsActive == 0 and Input.trigger?(Input::B)
update_leave
end
if @target_window.active == true
@target_window.visible = true
if @target_window.x < 0
@target_window.x += 30
elsif @target_window.x >= 0
@target_window.x = 0
end
else
if @target_window.x > -300
@target_window.x -= 30
elsif @target_window.x >= -300
@target_window.x = -300
@target_window.visible = false
end
end
if @help_window.x < 0 and @WindowsActive == 1
@help_window.x += 15
@help_window.contents_opacity += 20
elsif @help_window.x >= 0
@help_window.x = 0
end
if @item_window.x > 250
@weapon_window.x -= 30
@armor_window.x -= 30
@item_window.x -= 30
@weapon_window.contents_opacity += 20
@armor_window.contents_opacity += 20
@item_window.contents_opacity += 20
elsif @item_window.x <= 250
@weapon_window.x = 0
@armor_window.x = 0
@item_window.x = 0
@weapon_window.contents_opacity = 250
@armor_window.contents_opacity = 250
@item_window.contents_opacity = 250
end
if @target_window.active == false
if Input.trigger?(Input.dir4) or Input.trigger?(Input.dir4) or
Input.trigger?(Input::L) or Input.trigger?(Input::R)
@help_window.x = -200
@help_window.contents_opacity = 0
end
if Input.trigger?(Input::RIGHT) and @WindowsActive == 0
if @window_startsel01.index == 2
@window_startsel01.index = 0
else
@window_startsel01.index += 1
end
end
if Input.trigger?(Input::LEFT) and @WindowsActive == 0
if @window_startsel01.index == 0
@window_startsel01.index = 2
else
@window_startsel01.index -= 1
end
end
end
@help_window.update
@item_window.update
@weapon_window.update
@armor_window.update
@target_window.update
case @window_startsel01.index
when 0
@WindowStartSel = 0
@window_startsel01.x = 332
@window_startsel01.y = 5
when 1
@WindowStartSel = 1
@window_startsel01.x = 422
@window_startsel01.y = 5
when 2
@WindowStartSel = 2
@window_startsel01.x = 515
@window_startsel01.y = 5
end
if @type == 0
@item_com.bitmap = RPG::Cache.picture("Item_com00")
@item_window.active = false
@weapon_window.active = false
@armor_window.active = false
@item_window.visible = false
@weapon_window.visible = false
@armor_window.visible = false
end
if @type == 1
@item_com.bitmap = RPG::Cache.picture("Item_com01")
if @target_window.active == true
update_target2
@item_window.active = false
return
else
@item_window.active = true
end
@weapon_window.active = false
@armor_window.active = false
@item_window.visible = true
@weapon_window.visible = false
@armor_window.visible = false
end
if @type == 2
@item_com.bitmap = RPG::Cache.picture("Item_com02")
@target_window.active = false
@item_window.active = false
@weapon_window.active = true
@armor_window.active = false
@item_window.visible = false
@weapon_window.visible = true
@armor_window.visible = false
end
if @type == 3
@item_com.bitmap = RPG::Cache.picture("Item_com03")
@target_window.active = false
@item_window.active = false
@weapon_window.active = false
@armor_window.active = true
@item_window.visible = false
@weapon_window.visible = false
@armor_window.visible = true
end
if @item_window.active
update_item
return
end
if @armor_window.active
update_armor
return
end
if @weapon_window.active
update_weapon
return
end
end
def update_item
if Input.press?(Input::B) and @WindowsActive == 0 and @item_window.active == true
$game_system.se_play($data_system.cancel_se)
@holyshit = 0
@holycastle = 1
if $game_variables[499] == 0
$scene = Scene_Menu.new(0)
else
$scene = Scene_Map.new
end
elsif Input.trigger?(Input::B) and @WindowsActive == 1 and @item_window.active == true
$game_system.se_play($data_system.cancel_se)
@type = 0
@window_startsel01.index = 0
@help_window.contents_opacity = 0
@WindowsActive = 0
@holyshit = 0
@holycastle = 1
end
if Input.trigger?(Input::C) and @WindowStartSel == 0 and @WindowsActive == 0
$game_system.se_play($data_system.cursor_se)
@type = 1
@WindowsActive = 1
@target_window.active = false
@holyshit = 2
anew
elsif Input.trigger?(Input::C) and @WindowsActive == 1 and @holyshit == 1
if @holycastle == 1
anew
else
######################
# Get currently selected data on the item window
@item = @item_window.item
# If not a use item
unless @item.is_a?(RPG::Item)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If it can't be used
unless $game_party.item_can_use?(@item.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# If effect scope is an ally
if @item.scope >= 3
# Activate target window
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# Set cursor position to effect scope (single / all)
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# If effect scope is other than an ally
else
# If command event ID is valid
if @item.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @item.common_event_id
# Play item use SE
$game_system.se_play(@item.menu_se)
# If consumable
if @item.consumable
# Decrease used items by 1
$game_party.lose_item(@item.id, 1)
# Draw item window item
@item_window.draw_item(@item_window.index)
end
# Switch to map screen
$scene = Scene_Map.new
return
end
end
return
end
end
end
def update_menu
###############################################3
if (@WindowStartSel == 1 and Input.trigger?(Input::C))
$game_system.se_play($data_system.cursor_se)
@type = 2
@WindowsActive = 1
return
end
if (@WindowStartSel == 2 and Input.trigger?(Input::C))
$game_system.se_play($data_system.cursor_se)
@type = 3
@WindowsActive = 1
return
end
end
def update_weapon
if Input.trigger?(Input::B) and @WindowsActive == 0 and @weapon_window.active == true
$game_system.se_play($data_system.cancel_se)
if $game_variables[499] == 0
$scene = Scene_Menu.new(0)
else
$scene = Scene_Map.new
end
elsif Input.trigger?(Input::B) and @WindowsActive == 1 and @weapon_window.active == true
$game_system.se_play($data_system.cancel_se)
@type = 0
@window_startsel01.index = 1
@help_window.contents_opacity = 0
@WindowsActive = 0
@holycastle = 1
end
end
def update_armor
if Input.trigger?(Input::B) and @WindowsActive == 0 and @armor_window.active == true
$game_system.se_play($data_system.cancel_se)
if $game_variables[499] == 0
$scene = Scene_Menu.new(0)
else
$scene = Scene_Map.new
end
elsif Input.trigger?(Input::B) and @WindowsActive == 1 and @armor_window.active == true
$game_system.se_play($data_system.cancel_se)
@help_window.contents_opacity = 0
@type = 0
@window_startsel01.index = 2
@WindowsActive = 0
@holycastle = 1
end
end
def update_leave
if Input.press?(Input::B) and @WindowsActive == 0
$game_system.se_play($data_system.cancel_se)
if $game_variables[499] == 0
$scene = Scene_Menu.new(0)
else
$scene = Scene_Map.new
end
end
end
def update_target2
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If unable to use because items ran out
unless $game_party.item_can_use?(@item.id)
# Remake item window contents
@item_window.refresh
end
# Erase target window
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C) and holycastle = 0
# If items are used up
if $game_party.item_number(@item.id) == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If target is all
if @target_window.index == -1
# Apply item effects to entire party
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# If single target
if @target_window.index >= 0
# Apply item use effects to target actor
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# If an item was used
if used
# Play item use SE
$game_system.se_play(@item.menu_se)
# If consumable
if @item.consumable
# Decrease used items by 1
$game_party.lose_item(@item.id, 1)
# Redraw item window item
@item_window.draw_item(@item_window.index)
end
# Remake target window contents
@target_window.refresh
# If all party members are dead
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If common event ID is valid
if @item.common_event_id > 0
# Common event call reservation
$game_temp.common_event_id = @item.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If item wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#################################
def anew
@item_window.refresh
@item_window.active = true
@target_window.visible = false
@target_window.active = false
@holyshit = 1
@holycastle = 0
return
end