Một chút thắc mắc về Script Equip Summon

Zenzokuken

Youtube Master Race
Tham gia ngày
29/8/05
Bài viết
32
Reaction score
0
Em có cái script này, làm cho nó lên được rồi mà chưa biết cái dùng, ai biết giúp em với nha.
Trước hết là khuôn mặt :
#--------------------------------------------------------------------------
# Define Faces
#--------------------------------------------------------------------------
def draw_actor_face(actor, x, y)
face = RPG::Cache.character("Faces/" + actor.character_name, actor.character_hue)
fw = face.width
fh = face.height
src_rect = Rect.new(3, -1, fw, fh)
self.contents.blt(x - fw / 23, y - fh, face, src_rect)
end

Còn đây là Window skill

#==============================================================================
# ■ Window_Skill
#------------------------------------------------------------------------------
#  スキル画面、バトル画面で、使用できるスキルの一覧を衼br />¨示するウィンドウです。
#==============================================================================

class Window_Skills < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# actor : アクター
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 75, 290, 405)
@actor = actor
@column_max = 1
refresh
self.index = 0
# 戦闘中の場合はウィンドウを画面中央へ移動し、半透明にぼbr />™る
if $game_temp.in_battle
self.x = 200
self.y = 225
self.height = 256
self.width = 440
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● スキルの取得
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in [email protected]
skill = $data_skills[@actor.skills]
if skill != nil
@data.push(skill)
end
end
# 項目数が 0 でなければビットマップを作成し、全項目を描画
@item_max = @data.size
if @item_max > 0
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
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 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(skill.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, 204, 32, skill.name, 0)
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
end


#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
end

Làm 1 script mới dưới Scene skill rồi paste cái này vào

#---------------------------------------------------------------------
#Equipment for summon-------------------------------------------------
#by olamide bakre
#Scene_EquipSummon

#help window
class Window_Descri < Window_Base
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
end


def set_text(text, align = 1)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
end
#end of text box
#text box
class Window_TextSummon < Window_Selectable

def initialize
super(0, 0, 290, 76)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.draw_text(4, 0, 120,32, "Summons List")
testing = Time.now.strftime("%a %b %e %H:%M:%S %Y\n")
end
end
#Equipment list

class Window_ListSummon < Window_Skills

def initialize(actor, element_id)
@element_id = element_id
super(actor)
end

#define item max
#def summon
# return @data[self.index]
# end

def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
#loop
for i in [email protected]
skill = $data_skills[@actor.skills]
if skill != nil and skill.element_set.include?(@element_id)
@data.push(skill)
end
end
#item max is set to a value and called as a function
@item_max = @data.size
if @item_max > 0
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
draw_item(i)
end
end
end
#end of function
#beginning of object
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = normal_color
end
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 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(skill.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, 204, 32, skill.name, 0)
#self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
end
#--------------------------------------------------------------------------
# ● update help text
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
end


#end of draw object


#summon mixtured with weapon
class Window_WeaponSummon < Window_Selectable

def initialize(actor)
super(290, 0, 350, 210)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@actor = actor
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● return item index
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@data = []
@data.push($data_weapons[@actor.weapon_id])
@data.push($data_armors[@actor.armor1_id])
@data.push($data_armors[@actor.armor2_id])
@data.push($data_armors[@actor.armor3_id])
@data.push($data_armors[@actor.armor4_id])
@item_max = @data.size
self.contents.font.color = system_color
self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1)
self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4)
draw_item_name(@data[0], 92, 32 * 0)
draw_item_name(@data[1], 92, 32 * 1)
draw_item_name(@data[2], 92, 32 * 2)
draw_item_name(@data[3], 92, 32 * 3)
draw_item_name(@data[4], 92, 32 * 4)



#self.contents.draw_text(260, 5, 160, 32, "Atk up".to_s)



end
#--------------------------------------------------------------------------
# ● update help
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end

#character equip with summon
class Window_CharSummon < Window_Selectable
def initialize
super(290, 210, 350, 270)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
actor = $game_party.actors[0]
draw_actor_face(actor, 189, 250 )
draw_actor_name(actor, 4, 120)
draw_actor_level(actor, 4, 140)
self.contents.draw_text(4, 170, 150, 32, "Class:")
draw_actor_class(actor, 65, 170)
self.contents.draw_text(4, 200, 150, 32, "Element:")
if $ELEMENT_VAR == 0
$ELEMENT_VAR = "none"
end
self.contents.draw_text(85, 200, 150, 32, $ELEMENT_VAR.to_s)
#define Empty
#$EQUIP_SLOT1 = 0
if $EQUIP_SLOT1 == 0
$EQUIP_SLOT1 = "-----------------------------Empty-------------------------"
$EQUIP_SLOT2 = "-----------------------------Empty-------------------------"
$EQUIP_SLOT3 = "-----------------------------Empty-------------------------"
$EQUIP_SLOT4 = "-----------------------------Empty-------------------------"
end
self.contents.font.color = system_color
self.contents.draw_text(4, 2, 600, 32, $EQUIP_SLOT1.to_s )
self.contents.draw_text(4, 35, 600, 32, $EQUIP_SLOT2.to_s)
self.contents.draw_text(4, 65, 600, 32, $EQUIP_SLOT3.to_s)
self.contents.draw_text(4, 95, 600, 32, $EQUIP_SLOT4.to_s)
#end
end
end
#end
class Scene_EquipSummon < Scene_Skill
$EQUIP_SLOT1 = 0
#initialize object
def initialize(menu_index = 0, char_index = 0)
@menu_index = menu_index
@char_index = char_index
end
def main
#selection window
s1 = "Equip"
s2 = "Class Change"
s3 = "Return"
@option = Window_Command.new(150, [s1, s2, s3])
@option.index = @menu_index
$icon
#class selection window
@select = Window_Command.new(150, ["Equip", "Remove"])
@select.index = @menu_index
@select.z = 0
@select.x = 150
@select.y = 190
@select.visible = false
@select.active = false
#class selection window ends
#confirm
@confirm_window = Window_Base.new(135, 188, 400, 64)
@confirm_window.contents = Bitmap.new(368, 32)
@confirm_window.contents.font.name = $fontface
@confirm_window.contents.font.size = $fontsize
@confirm_window.contents.draw_text(4, 0, 500, 32,"What do you want to do?")
#confirm
@item_max = $game_party.actors.size
@actor = $game_party.actors[0]
@info = Window_TextSummon.new
@list = Window_ListSummon.new(@actor, @element_id = 18)

@help_window = Window_Descri.new
@help_window.visible = false

@wepon = Window_WeaponSummon.new(@actor)
@wepon.active = false
@char = Window_CharSummon.new
@confirm_window.visible = false
@confirm_window.z = 1500
@option.visible = false
@option.active = false
@option.x = 270
@option.y = 252
@option.z = 1500
#end of window

Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@option.dispose
@confirm_window.dispose
@info.dispose
@list.dispose
@wepon.dispose
@char.dispose
@select.dispose
@help_window.dispose
end
#begin
def update
@select.update
@option.update
@info.update
@list.update
@wepon.update
@char.update
@help_window.update
if @option.active
option_update
return
end
if @list.active
list_update
return
end
if @wepon.active
wepon_update
return
end
if @char.active
char_update
return
end

if @select.active
select_update
return
end
end
#end of update
def draw_icon(x, y)
skills = @data[@list.index]
$icon = Sprite.new
$icon.bitmap = RPG::Cache.icon(skills)
$icon.z = 255
$icon.y = y
$icon.x = x
end
#define end selection
def select_update
@select.active
if Input.trigger?(Input::B)
@select.z = 0
@select.x = 145
@select.y = 150
@select.visible = false
@select.active = false
@char.active = true
end
actor = $game_party.actors[0]
if Input.trigger?(Input::C)
case @select.index
when 0
$game_system.se_play($data_system.decision_se)
if @char.index == 0
if $data_classes[1].name == "Slayer"
testing = actor.class_id = 2
end

id = $data_skills[@list.index + 1].element_set[0]
$ELEMENT_VAR = $data_system.elements[id]
@char.refresh
$EQUIP_SLOT1 = @data[@list.index] + " \t \t Equipped"
$skill_equip.push(@data[@list.index])
@data[@list.index].replace(" EQUIPPED ")
@list.refresh
@list.active = true
@char.active = false
@char.index = -1
elsif @char.index == 1
if $data_classes[1].name == "Slayer"
testing = actor.class_id = 2
end
id = $data_skills[@list.index + 1].element_set[0]
$ELEMENT_VAR = $data_system.elements[id]
$EQUIP_SLOT2 = @data[@list.index] + " \t \t Equipped"
$skill_equip.push(@data[@list.index])
@data[@list.index].replace(" EQUIPPED ")
@list.refresh
@list.active = true
@char.active = false
@char.index = -1
elsif @char.index == 2
if $data_classes[1].name == "Slayer"
testing = actor.class_id = 2
end
@element_id = @list.index
id = $data_skills[@list.index + 1].element_set[0]
$ELEMENT_VAR = $data_system.elements[id]
$EQUIP_SLOT3 = @data[@list.index] + " \t \t Equipped"
$skill_equip.push(@data[@list.index])
@data[@list.index].replace(" EQUIPPED ")
@list.refresh
@list.active = true
@char.active = false
@char.index = -1
elsif @char.index == 3
if $data_classes[1].name == "Slayer"
testing = actor.class_id = 2
end
id = $data_skills[@list.index + 1].element_set[0]
$ELEMENT_VAR = $data_system.elements[id]
$EQUIP_SLOT4 = @data[@list.index] + " \t \t Equipped"
$skill_equip.push(@data[@list.index])
@data[@list.index].replace(" EQUIPPED ")
@list.refresh
@list.active = true
@char.active = false
@char.index = -1
end
@char.refresh
@select.z = 0
@select.x = 145
@select.y = 150
@select.visible = false
@select.active = false
@char.active = true
when 1
$game_system.se_play($data_system.buzzer_se)
if @char.index == 0
$ELEMENT_VAR = 0
if $EQUIP_SLOT1 == "-----------------------------Empty-------------------------"
$game_system.se_play($data_system.buzzer_se)
else
if $data_classes[2].name == "SwordMan"
testing = actor.class_id = 1
@char.refresh
end
$EQUIP_SLOT1 = "-----------------------------Empty-------------------------"
@actor.learn_skill(0)
@list.refresh
end
elsif @char.index == 1
$ELEMENT_VAR = 0
$EQUIP_SLOT2 = "-----------------------------Empty-------------------------"
@char.refresh
elsif @char.index == 2
$ELEMENT_VAR = 0
$EQUIP_SLOT3 = "-----------------------------Empty-------------------------"
@char.refresh
elsif @char.index == 3
$ELEMENT_VAR = 0
$EQUIP_SLOT4 = "-----------------------------Empty-------------------------"
@char.refresh
end
@char.refresh
@select.z = 200
@select.x = 145
@select.y = 150
@select.visible = true
@select.active = true
@char.active = false
return
end
end
end


#end of selection
#update class change
def char_update
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
#Graphics.update
@select.z = 200
@select.x = 145
@select.y = 150
@select.visible = true
@select.active = true
@char.active = false
end

if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@char.index = -1
@char.active = false
@list.active = true
end
end


#update weapon equip
def wepon_update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@wepon.active = false
@wepon.index = -1
@list.active = true
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @wepon.index
when 0
$data_weapons[$data_actors[1].weapon_id].atk += 20
@wepon.active = false
@wepon.index = -1
@list.active = true
$skill_equip.push(@data[@list.index])
@data[@list.index].replace(" EQUIPPED ")
@wepon.refresh
@list.refresh
when 1
$data_armors[$data_actors[1].armor1_id].mdef += 20
@wepon.refresh
@wepon.active = false
@wepon.index = -1
@list.active = true
$skill_equip.push(@data[@list.index])
@data[@list.index].replace(" EQUIPPED ")
when 2
$data_armors[$data_actors[1].armor2_id].pdef += 20
@wepon.refresh
@wepon.active = false
@wepon.index = -1
@list.active = true
$skill_equip.push(@data[@list.index])
@data[@list.index].replace(" EQUIPPED ")
when 3
$data_armors[$data_actors[1].armor3_id].pdef += 20
@wepon.refresh
@wepon.active = false
@wepon.index = -1
@list.active = true
$skill_equip.push(@data[@list.index])
@data[@list.index].replace(" EQUIPPED ")
end
end
end
#update skill list
def list_update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
skill_id = @actor.skills.size
if Input.trigger?(Input::C)
if $skill_equip.include?(@data[@list.index])
$game_system.se_play($data_system.buzzer_se)
else
if @actor.skill_learn?(skill_id)
$game_system.se_play($data_system.decision_se)
@confirm_window.visible = true
@confirm_window.z = 1500
@option.visible = true
@option.active = true
@option.x = 270
@option.y = 252
@option.z = 1500
@list.active = false
else
$game_system.se_play($data_system.buzzer_se)
end
end
end
end


def option_update
#input
if Input.trigger?(Input::B)
then
$game_system.se_play($data_system.cancel_se)
@confirm_window.visible = false
@confirm_window.z = 1500
@option.visible = false
@option.active = false
@option.x = 270
@option.y = 252
@option.z = 1500
@list.active = true
return
end
if Input.trigger?(Input::C)
#begin
$game_system.se_play($data_system.decision_se)
case @option.index
when 0#Equip
$game_system.se_play($data_system.decision_se)
@wepon.active = true
@wepon.index = 0
@confirm_window.visible = false
@confirm_window.z = 0
@option.visible = false
@option.active = false
@option.z = 0
@option.update
when 1#class change
@confirm_window.visible = false
@confirm_window.z = 0
@option.visible = false
@option.active = false
@option.z = 0
@option.update
@char.active = true
@char.index = @char_index
when 2#return
$game_system.se_play($data_system.decision_se)
@confirm_window.visible = false
@confirm_window.z = 0
@option.visible = false
@option.active = false
@option.z = 0
@option.update
@list.active = true
return
end
#end
end
end
end
#end of code

#update function, alias
class Scene_EquipSummon

def skill
return @data[@list.index]
end
#equipped skills
$skill_equip = []
#aliasing begin reference to class method ^-^
alias new_list_update list_update
#skill list
def list_update
new_list_update
@list.refresh
@data = []
for i in [email protected]
skill = $data_skills[@actor.skills].name
if skill != nil
@data.push(skill)
end
end
end


alias new_wepon_update wepon_update
#weapon list
def wepon_update
new_wepon_update
@list.refresh
@data = []
for i in [email protected]
skill = $data_skills[@actor.skills].name
if skill != nil
@data.push(skill)
end
end
end

alias new_select_update select_update
#select command
def select_update
new_select_update
@list.refresh
@data = []
for i in [email protected]
skill = $data_skills[@actor.skills].name
if skill != nil
@data.push(skill)
end
end
end

end
#update function, alias

Để kích hoạt nó dùng lệnh sau

$scene = Scene_EquipSummon.new
 
Tại sao chẳng bác nào giúp em với cả thế? Em lập cái này có phải để câu bài đâu cơ chứ. Ai biết vào hướng dẫn em dùng cái script này cái, Em làm được hết rồi mà chưa biết cách dùng.
 
Bó tay với ông này. Ai đủ thời gian mà đọc cái script này mà trả lời cơ chứ. Nhìn đã hoa mắt chóng mặt rùi.
 
Tui ko biết về phần này nhưng phải công nhận Squall$Rinoa nói vô trách nhiệm thật đó có ai đời như vậy không thế admin đâu quản lý đâu chết hết rồi hả hay bận chuyện đại sự mất đi ăn đám giỗ rồi nên không giúp được anh em , qua là vô trách nhiệm quá đi
 
U giỏi thì vào giúp người ta một tay đi. Viết code đã khó đọc code người khác viết thì lại càng khó hơn nữa code gì mà chả có chú thích gì cả(hình như có chữ tàu) đọc hoa cả mắt.
 
sorry mọi người lần sau post bài tui sẽ suy nghĩ trước. XIN LỖI TẤT CẢ MỌI NGƯỜI MONG ĐƯỢC BỎ QUA CHO THẰNG EM NÀY
 
Mấy bác ơi, tui đâu có đòi hỏi gì cao xa, chỉ nhờ mấy bác giúp em cách xài Script này thôi mà, hay là để em post nguyên bản gốc của nó lên cho các bác nghiên cứu nhé. Thấy tụi nó bảo cái scirpt này giúp người chơi equip được các phép thuật vào vũ khí đố. Nếu các bác muốn nghiên cứu thì bảo em một tiếng nhé.
 
Back
Top