#=============================================================================#
# ■ BFS - FriendDefine
#-----------------------------------------------------------------------------#
# 对于队友事件、图像的核心定义
#=============================================================================#
class Friend_Sprite < Sprite_Character
attr_accessor :character
attr_accessor :friend_party_id
attr_accessor :actor_database_id
def initialize(viewport, character = nil)
super(viewport, character)
@character = character
@indicator = Sprite.new(viewport)
@indicator.opacity = 0
@indicator.bitmap = RPG::Cache.windowskin("Player2_Cursor")
@indicator.z = 5000
for i in $game_party.actors
if @character.name == i.name
@friend_party_id = (i.index - 1).to_i
break
end
end
for i in 1..$game_actors.size
if @character.name == $game_actors[i].name
@actor_database_id = $game_actors[i].id
break
end
end
@hpsprite = Sprite.new(viewport)
@hpsprite.z = 0
ox = BFS_DataBase::HP_BAR_OX[@actor_database_id]
oy = BFS_DataBase::HP_BAR_OY[@actor_database_id]
@hpsprite.bitmap = Bitmap.new(ox + 75, oy + 50)
black = Color.new(0, 0, 0)
@hpsprite.bitmap.fill_rect(ox, oy, 26, 1, black) #上
@hpsprite.bitmap.fill_rect(ox, oy + 8, 26, 1, black) #下
@hpsprite.bitmap.fill_rect(ox, oy, 1, 9, black) #左
@hpsprite.bitmap.fill_rect(ox + 25, oy, 1, 9, black) #右
@hpsprite.bitmap.fill_rect(ox, oy + 4, 26, 1, black) #中
hp = ($game_party.friends[@friend_party_id].hp).to_f
hp_w = ((hp / $game_party.friends[@friend_party_id].maxhp) * 24)
sp = ($game_party.friends[@friend_party_id].sp).to_f
sp_w = ((sp / $game_party.friends[@friend_party_id].maxsp) * 24)
@hpsprite.bitmap.fill_rect(ox + 1, oy + 1, hp_w, 3, Color.new(255, 0, 0))
@hpsprite.bitmap.fill_rect(ox + 1, oy + 5, sp_w, 3, Color.new(0, 255, 255))
end
def update
super
if @character.battler.tactics_type == 2
@indicator.opacity = 225
@indicator.x = self.x - 18
@indicator.y = self.y - 108
else
@indicator.opacity = 0
end
@hpsprite.opacity = self.opacity
self.opacity = 0 if $game_party.friends[@friend_party_id].dead?
@hpsprite.bitmap.clear
ox = BFS_DataBase::HP_BAR_OX[@actor_database_id]
oy = BFS_DataBase::HP_BAR_OY[@actor_database_id]
black = Color.new(0, 0, 0)
@hpsprite.bitmap.fill_rect(ox, oy, 26, 1, black) #上
@hpsprite.bitmap.fill_rect(ox, oy + 8, 26, 1, black) #下
@hpsprite.bitmap.fill_rect(ox, oy, 1, 9, black) #左
@hpsprite.bitmap.fill_rect(ox + 25, oy, 1, 9, black) #右
@hpsprite.bitmap.fill_rect(ox, oy + 4, 26, 1, black) #中
hp = ($game_party.friends[@friend_party_id].hp).to_f
hp_w = ((hp / $game_party.friends[@friend_party_id].maxhp) * 24)
sp = ($game_party.friends[@friend_party_id].sp).to_f
sp_w = ((sp / $game_party.friends[@friend_party_id].maxsp) * 24)
@hpsprite.bitmap.fill_rect(ox + 1, oy + 1, hp_w, 3, Color.new(255, 0, 0))
@hpsprite.bitmap.fill_rect(ox + 1, oy + 5, sp_w, 3, Color.new(0, 255, 255))
@hpsprite.x = self.x - self.ox
@hpsprite.y = self.y
end
end
class Game_Friend < Game_Event
attr_accessor :enemy_in_range
attr_accessor :aimovement_stand_by
include XRXS_BreakActs
def initialize(map_id, event)
super(map_id, event)
@last_dead = false
@max_speed = @move_speed
@aimovement_stand_by = false
@collapse_done = $game_party.actors[self.party_id].dead?
end
def controllable?
return !(moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing or
self.action != nil or @attacking)
end
def party_id
for i in $game_party.actors
if self.name == i.name
return i.index.to_i
break
end
end
end
def update
super
if @last_dead
unless self.battler.dead?
recover
end
end
@last_dead = self.battler.dead?
end
def pop_damage_text(name)
self.battler.damage = name
self.battler.damage_pop = true
end
def recover
@collapse_done = false
@through = @page.through
@character_name = @page.graphic.character_name
@opacity = 255
$game_system.friend_event_id.insert(party_id ,id)
BFS_Friends.refresh_map
$game_party.friend_party_update
self.battler_recheck
@animation_id = BFS_Setting::ANI_RECOVER
end
def update_hp_sensor
@low_hp_characters = 0
for i in $game_party.actors
@low_hp_characters += 1 if (i.hp < i.maxhp * 0.6)
end
end
def update_sensor
@enemy_in_range = nil
for i in $game_map.events.values
if i.battler != nil and i.battler.is_a?(Game_Enemy) and not
BFS_Setting::NOT_ATTACK_ID.include?(i.enemy_id)
distance = (i.x - self.x).abs + (i.y - self.y).abs
@enemy_in_range = i.id if (distance <= BFS_Setting::SENSOR_RANGE)
break
end
end
end
end
module BFS_Friends
def self.add(friend_id)
map_id = BFS_Setting::FRIEND_MAP_ID
return unless self.is_map?
map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
temp = Marshal.load(Marshal.dump(map))
if !$game_system.map_events_number
$game_system.map_events_number = {}
end
sum = $game_system.map_events_number
m_id = $game_map.map_id
sum[m_id] == nil ? sum[m_id] = 2000 : sum[m_id] += 1
new_event_id = sum[m_id]
temp.events[friend_id].id = new_event_id
temp.events[friend_id].x,temp.events[friend_id].y = $game_player.x, $game_player.y
$game_map.events[new_event_id] = Game_Friend.new(m_id,temp.events[friend_id])
$BFS_temp = $game_map.events[new_event_id]
$game_system.friend_event_id.push(new_event_id) unless $game_actors[friend_id].dead?
end
def self.get_event_to(id, x, y)
map = load_data(sprintf("Data/Map%03d.rxdata", BFS_Setting::FRIEND_MAP_ID))
temp = Marshal.load(Marshal.dump(map))
temp.events[id].x,temp.events[id].y = x,y
return temp.events[id]
end
def self.refresh_map
$scene.spriteset.dispose
$scene.spriteset = Spriteset_Map.new
end
def self.is_map?
(return true) if $scene.is_a?(Scene_Map)
return false
end
def self.prepare_for_transferring
$game_system.friend_event_id = []
return if $game_party.friends == []
for i in $game_party.friends
add(i.id)
end
$game_party.friend_party_update
end
def self.prepare_for_loading
$game_system.friend_event_id = []
return if $game_party.friends == []
for i in $game_party.friends
add(i.id)
end
$game_party.friend_party_update
m = 0
for i in $game_system.friend_event_id
c = $game_map.events[i]
x = $game_system.bfs_positions[m][0]
y = $game_system.bfs_positions[m][1]
direction = $game_system.bfs_positions[m][2]
c.moveto(x,y)
c.direction = direction
m += 1
end
end
def self.delete_all_friends
for i in $game_system.friend_event_id
$game_map.events.delete(i)
end
end
def self.friend_defeat_process(friend_battler, id)
$game_temp.ifw_text = friend_battler.name + "阵亡"
$game_temp.ifw_active = true
$game_system.friend_event_id.delete(id)
$game_party.friend_party_update
end
def self.weapon_recheck
for i in $game_party.actors
i.slash_id = XAS_SKILL::WEAPON_ID_TOOL[i.weapon_id] if XAS_SKILL::WEAPON_ID_TOOL[i.weapon_id]
end
end
end
class Game_System
attr_accessor :map_events_number
attr_accessor :map_data
end
class Scene_Map
attr_accessor :spriteset
end
class Game_Event < Game_Character
attr_reader :event
def name
return @event.name
end
end
module BFS_DataBase
MAP_ID = []
HP_BAR_OX = []
HP_BAR_OY = []
end
class Sprite_Character < RPG::Sprite
alias bfs_sp1_ini initialize
def initialize(viewport, character = nil)
bfs_sp1_ini(viewport, character)
@player = character.is_a?(Game_Player)
@indicator_step = 0
if @player
@indicator = Sprite.new(viewport)
@indicator.opacity = 0
@indicator.bitmap = RPG::Cache.windowskin("Player1_Cursor")
@indicator.x = self.x - 18
@indicator.y = self.y - 108
@indicator.z = 5000
end
end
alias bfs_sp1_update_old update
def update
bfs_sp1_update_old
if @player
if @character.indicator_setup
@character.indicator_setup = false
@indicator_step = 220
end
@indicator.x = self.x - 18
@indicator.y = self.y - 108
if @indicator_step > 0
@indicator_step -= 1
case @indicator_step
when 1..20
@indicator.opacity -= 15
when 201..219
@indicator.opacity += 15
end
end
end
end
end