07-21-2005, 01:00 PM
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
I'm really new to scripting. (And by really new, I mean really new. I just started last week.) And this is the first useful thing that I've managed to produce.
When you're choosing an item to equip, instead of showing how it alters Attack Power, Physical Def, and Magic Def, it shows how it alters all character stats.
Replace Window_EquipLeft with this:
Code:
#==============================================================================
# –� Window_EquipLeft
#------------------------------------------------------------------------------
#  装備画���アクター�パラメータ変化を表示�るウィンドウ��。
#==============================================================================
class Window_EquipLeft < Window_Base
#--------------------------------------------------------------------------
# —? オブジェクトåˆ?期化
# actor : アクター
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 64, 272, 415)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# —? リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_level(@actor, 4, 32)
draw_actor_parameter(@actor, 4, 64, 0)
draw_actor_parameter(@actor, 4, 96, 1)
draw_actor_parameter(@actor, 4, 128, 2)
draw_actor_parameter(@actor, 4, 160, 3)
draw_actor_parameter(@actor, 4, 192, 4)
draw_actor_parameter(@actor, 4, 222, 5)
draw_actor_parameter(@actor, 4, 255, 6)
if @new_atk != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 64, 40, 32, " ’", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 64, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 96, 40, 32, " ’", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 96, 36, 32, @new_pdef.to_s, 2)
end
if @new_mdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 128, 40, 32, " ’", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 128, 36, 32, @new_mdef.to_s, 2)
end
if @new_str != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 160, 40, 32, " ’", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 160, 36, 32, @new_str.to_s, 2)
end
if @new_dex != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 192, 40, 32, " ’", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 192, 36, 32, @new_dex.to_s, 2)
end
if @new_agi != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 222, 40, 32, " ’", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 222, 36, 32, @new_agi.to_s, 2)
end
if @new_int != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 255, 40, 32, " ’", 1)
self.contents.font.color = normal_color
self.contents.draw_text(200, 255, 36, 32, @new_int.to_s, 2)
end
end
#--------------------------------------------------------------------------
# —? 装備変更後ã?®ãƒ‘ラメータè¨å®š
# new_atk : 装備変更後ã?®æ”»æ’ƒå� ›
# new_pdef : 装備変更後�物� 防御
# new_mdef : 装備変更後ã?®é”法防御
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef or @new_str != new_str or @new_dex != new_dex or @new_agi != new_agi or @new_int != new_int
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
@new_str = new_str
@new_dex = new_dex
@new_agi = new_agi
@new_int = new_int
refresh
end
end
end
Replace Window_EquipItem with this:
Code:
#==============================================================================
# –� Window_EquipItem
#------------------------------------------------------------------------------
#  装備画���装備変更�候補��るアイ� � �一覧を表示�るウィンドウ��。
#==============================================================================
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
# —? オブジェクトåˆ?期化
# actor : アクター
# equip_type : 装備部� (0~3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(272, 256, 368, 224)
@actor = actor
@equip_type = equip_type
@column_max = 1
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# —? アイãƒ� ãƒ� ã?®å?–å¾—
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# —? リフレッシュ
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 装備å?¯èƒ½ã?ªæ¦å™¨ã‚’追å� �
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
# 装備å?¯èƒ½ã?ªé˜²å…·ã‚’追å� �
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
# 空白を追å� �
@data.push(nil)
# ビットマップを作æˆ?ã?—ã€?å…¨é� …目をæ??ç”»
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
for i in 0...@item_max-1
draw_item(i)
end
end
#--------------------------------------------------------------------------
# —? é� …ç›®ã?®æ??ç”»
# index : é� …目番å?·
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 1 * (288 + 32)
y = index * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.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.item == nil ? "" : self.item.description)
end
end
And finally replace Scene_Equip with this:
Code:
#==============================================================================
# –� Scene_Equip
#------------------------------------------------------------------------------
#  装備画��処� を行� クラス��。
#==============================================================================
class Scene_Equip
#--------------------------------------------------------------------------
# —? オブジェクトåˆ?期化
# actor_index : アクターインデックス
# equip_index : 装備インデックス
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
@equip_index = equip_index
end
#--------------------------------------------------------------------------
# —? メイン処ç?�
#--------------------------------------------------------------------------
def main
# アクターを�得
@actor = $game_party.actors[@actor_index]
# ウィンドウを作�
@help_window = Window_Help.new
@left_window = Window_EquipLeft.new(@actor)
@right_window = Window_EquipRight.new(@actor)
@item_window1 = Window_EquipItem.new(@actor, 0)
@item_window2 = Window_EquipItem.new(@actor, 1)
@item_window3 = Window_EquipItem.new(@actor, 2)
@item_window4 = Window_EquipItem.new(@actor, 3)
@item_window5 = Window_EquipItem.new(@actor, 4)
# ヘルプウィンドウを関連付�
@right_window.help_window = @help_window
@item_window1.help_window = @help_window
@item_window2.help_window = @help_window
@item_window3.help_window = @help_window
@item_window4.help_window = @help_window
@item_window5.help_window = @help_window
# カーソルä½?置をè¨å®š
@right_window.index = @equip_index
refresh
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲー� 画�を更新
Graphics.update
# å…¥å� ›æƒ…å� ±ã‚’æ›´æ–°
Input.update
# フレー� 更新
update
# ç”»é?¢ã?Œåˆ‡ã‚� 替ã‚?ã?£ã?Ÿã‚‰ãƒ«ãƒ¼ãƒ—ã‚’ä¸æ–
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@help_window.dispose
@left_window.dispose
@right_window.dispose
@item_window1.dispose
@item_window2.dispose
@item_window3.dispose
@item_window4.dispose
@item_window5.dispose
end
#--------------------------------------------------------------------------
# —? リフレッシュ
#--------------------------------------------------------------------------
def refresh
# アイãƒ� ãƒ� ウィンドウã?®å?¯è¦–ç� ¶æ…‹è¨å®š
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
# ç?¾åœ¨è£…å‚™ä¸ã?®ã‚¢ã‚¤ãƒ� ãƒ� ã‚’å?–å¾—
item1 = @right_window.item
# ç?¾åœ¨ã?®ã‚¢ã‚¤ãƒ� ãƒ� ウィンドウを @item_window ã?«è¨å®š
case @right_window.index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
# ライトウィンドウã?Œã‚¢ã‚¯ãƒ� ィブã?®å� ´å?ˆ
if @right_window.active
# 装備変更後�パラメータを消去
@left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil)
end
# アイãƒ� ãƒ� ウィンドウã?Œã‚¢ã‚¯ãƒ� ィブã?®å� ´å?ˆ
if @item_window.active
# ç?¾åœ¨é?¸æ� žä¸ã?®ã‚¢ã‚¤ãƒ� ãƒ� ã‚’å?–å¾—
item2 = @item_window.item
# 装備を変更
last_hp = @actor.hp
last_sp = @actor.sp
@actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
# 装備変更後�パラメータを�得
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
new_str = @actor.str
new_dex = @actor.dex
new_agi = @actor.agi
new_int = @actor.int
# 装備を戻�
@actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
@actor.hp = last_hp
@actor.sp = last_sp
# レフトウィンドウã?«æ??ç”»
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int)
end
end
#--------------------------------------------------------------------------
# —? フレーãƒ� æ›´æ–°
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@left_window.update
@right_window.update
@item_window.update
refresh
# ライトウィンドウã?Œã‚¢ã‚¯ãƒ� ィブã?®å� ´å?ˆ: update_right を呼ã?¶
if @right_window.active
update_right
return
end
# アイãƒ� ãƒ� ウィンドウã?Œã‚¢ã‚¯ãƒ� ィブã?®å� ´å?ˆ: update_item を呼ã?¶
if @item_window.active
update_item
return
end
end
#--------------------------------------------------------------------------
# —? フレーãƒ� æ›´æ–° (ライトウィンドウã?Œã‚¢ã‚¯ãƒ� ィブã?®å� ´å?ˆ)
#--------------------------------------------------------------------------
def update_right
# B ボタンã?Œæ� ¼ã?•ã‚Œã?Ÿå� ´å?ˆ
if Input.trigger?(Input::B)
# ã‚ャンセル SE ã‚’æ¼”å¥?
$game_system.se_play($data_system.cancel_se)
# メニュー画��切� 替�
$scene = Scene_Menu.new(2)
return
end
# C ボタンã?Œæ� ¼ã?•ã‚Œã?Ÿå� ´å?ˆ
if Input.trigger?(Input::C)
# 装備固定ã?®å� ´å?ˆ
if @actor.equip_fix?(@right_window.index)
# ブザー SE を演�
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演�
$game_system.se_play($data_system.decision_se)
# アイ� � ウィンドウをアク� ィブ化
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
# R ボタンã?Œæ� ¼ã?•ã‚Œã?Ÿå� ´å?ˆ
if Input.trigger?(Input::R)
# カーソル SE を演�
$game_system.se_play($data_system.cursor_se)
# 次�アクター�
@actor_index += 1
@actor_index %= $game_party.actors.size
# 別�装備画��切� 替�
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
# L ボタンã?Œæ� ¼ã?•ã‚Œã?Ÿå� ´å?ˆ
if Input.trigger?(Input::L)
# カーソル SE を演�
$game_system.se_play($data_system.cursor_se)
# ��アクター�
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 別�装備画��切� 替�
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
end
#--------------------------------------------------------------------------
# —? フレーãƒ� æ›´æ–° (アイãƒ� ãƒ� ウィンドウã?Œã‚¢ã‚¯ãƒ� ィブã?®å� ´å?ˆ)
#--------------------------------------------------------------------------
def update_item
# B ボタンã?Œæ� ¼ã?•ã‚Œã?Ÿå� ´å?ˆ
if Input.trigger?(Input::B)
# ã‚ャンセル SE ã‚’æ¼”å¥?
$game_system.se_play($data_system.cancel_se)
# ライトウィンドウをアク� ィブ化
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
# C ボタンã?Œæ� ¼ã?•ã‚Œã?Ÿå� ´å?ˆ
if Input.trigger?(Input::C)
# 装備 SE を演�
$game_system.se_play($data_system.equip_se)
# アイãƒ� ãƒ� ウィンドウã?§ç?¾åœ¨é?¸æ� žã?•ã‚Œã?¦ã?„るデータをå?–å¾—
item = @item_window.item
# 装備を変更
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
# ライトウィンドウをアク� ィブ化
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# ライトウィンドウã€?アイãƒ� ãƒ� ウィンドウã?®å� …容をå� ?作æˆ?
@right_window.refresh
@item_window.refresh
return
end
end
end
I know this is a very minor acomplishment. I'm just really glad that this is starting to make sense to me.