Project1
标题: 【腳本】敵我攻擊以顏色區分的判斷要加在哪個部分? [打印本页]
作者: 燕征 时间: 2016-3-22 02:38
标题: 【腳本】敵我攻擊以顏色區分的判斷要加在哪個部分?
本帖最后由 燕征 于 2016-3-22 16:56 编辑
關於攻擊數據的圖形的顯示都是在這個腳本(片段)
#==============================================================================
# ■class Sprite
#==============================================================================
class Sprite < ::Sprite
#-------------------------------------------------------------------
# ● 執行損傷
#---------------------------------------------------------------------
def damage(value,critical,sp_damage=nil)
dispose_damage
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if sp_damage != nil
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 16-1, 160, 36, sp_damage.to_s, 1)
bitmap.draw_text(+1, 16-1, 160, 36, sp_damage.to_s, 1)
bitmap.draw_text(-1, 16+1, 160, 36, sp_damage.to_s, 1)
bitmap.draw_text(+1, 16+1, 160, 36, sp_damage.to_s, 1)
bitmap.font.color.set(0, 255, 255)
bitmap.draw_text(0, 16, 160, 36, sp_damage.to_s, 1)
end
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end
#==============================================================================
# ■class Sprite
#==============================================================================
class Sprite < ::Sprite
#-------------------------------------------------------------------
# ● 執行損傷
#---------------------------------------------------------------------
def damage(value,critical,sp_damage=nil)
dispose_damage
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if sp_damage != nil
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 16-1, 160, 36, sp_damage.to_s, 1)
bitmap.draw_text(+1, 16-1, 160, 36, sp_damage.to_s, 1)
bitmap.draw_text(-1, 16+1, 160, 36, sp_damage.to_s, 1)
bitmap.draw_text(+1, 16+1, 160, 36, sp_damage.to_s, 1)
bitmap.font.color.set(0, 255, 255)
bitmap.draw_text(0, 16, 160, 36, sp_damage.to_s, 1)
end
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end
然而判斷主角或者怪物挨揍的腳本(片段)會去掉用上面的顯示(# 寫入動畫與執行延遲 我不知道是不是相關的)
# 決定損傷目標
if self.is_a?(Game_Actor)
s_event = $game_player
else
s_event = event
end
# 設置事件損傷
if self.damage != nil
s_event.damage = self.damage
s_event.critical = self.critical
s_event.damage_pop = true
self.damage = nil
self.critical = false
end
# 攻速計算
attack_speed = Integer(10 - attacker.agi/999.00*20)
# 寫入動畫與執行延遲
ani_id = attacker.animation2_id
if $data_animations[ani_id] != nil
a = [$data_animations[ani_id].frame_max * 2 + attack_speed,2].max
if attacker.is_a?(Game_Actor)
event.actor_count = a
event.animation_id = ani_id
else
event.delay_count = a
if self.is_a?(Game_Actor)
$game_player.animation_id = ani_id
else
event.animation_id = ani_id
end
end
end
# 決定損傷目標
if self.is_a?(Game_Actor)
s_event = $game_player
else
s_event = event
end
# 設置事件損傷
if self.damage != nil
s_event.damage = self.damage
s_event.critical = self.critical
s_event.damage_pop = true
self.damage = nil
self.critical = false
end
# 攻速計算
attack_speed = Integer(10 - attacker.agi/999.00*20)
# 寫入動畫與執行延遲
ani_id = attacker.animation2_id
if $data_animations[ani_id] != nil
a = [$data_animations[ani_id].frame_max * 2 + attack_speed,2].max
if attacker.is_a?(Game_Actor)
event.actor_count = a
event.animation_id = ani_id
else
event.delay_count = a
if self.is_a?(Game_Actor)
$game_player.animation_id = ani_id
else
event.animation_id = ani_id
end
end
end
我覺得在第二部分的腳本已經判斷好誰受傷了,不知道是不是可以在這邊直接竄改第一部份用來顯示顏色的那句bitmap.font.color.set(0, 0, 0)
可以的話是怎麼使用呢?
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |