Tears Unlimited
Member
Hi everyone on RMXP! This is actualy the first time I even post on the forums, feels kind of odd though i've been a member for some time now. I were just hoppeing some one more talented then me, could help me out from the kind of heart. The person would become my hero, ish.
Im using a modification of ccoas CBS. But it seams like its missing a function from ccoas orignial work. The one function were you could have the characters holding diffrent type of weapons in battle depending on which one he or she has equiped. So i tought maybe some kind soul could help me out. The skript posted belove (sorry for not puting it in "thingy" you have to click to open, don't know how to make them.) is the "spirte_battler" from the CBS I use. And the script belove that, is the code i would like to work with mine...
Please would someone help me?
And this is the code I would like to work with the one above... if it is possible.
The code belove is simply the a part of the code form ccoas CBS "spirte_battler".
Just so you all know, all of you here on RMXP ROCKS! ;D
Kisses
Susanna
Im using a modification of ccoas CBS. But it seams like its missing a function from ccoas orignial work. The one function were you could have the characters holding diffrent type of weapons in battle depending on which one he or she has equiped. So i tought maybe some kind soul could help me out. The skript posted belove (sorry for not puting it in "thingy" you have to click to open, don't know how to make them.) is the "spirte_battler" from the CBS I use. And the script belove that, is the code i would like to work with mine...
Please would someone help me?
Code:
[COLOR=green]class Sprite_Battler < RPG::Sprite
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
@frame_num = 0
@victory = false
@update_speed = 5 # the higher this number, the slower the animation
@move_speed = 8 # the higher this number, the faster the battler moves
@stop_anime = false
@count = Graphics.frame_count
@initialized = false
@move_x = 0
@move_y = 0
end
def update
super
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
if @battler.dead? or @battler.hidden
self.opacity = 0
end
end
if @battler.damage == nil and
@battler.state_animation_id != @state_animation_id
@state_animation_id = @battler.state_animation_id
loop_animation($data_animations[@state_animation_id])
end
if !@initialized
setup
end
if @battler_visible and @battler.animated
# update the animation every nth update
if Graphics.frame_count - @count >= @update_speed
@count = Graphics.frame_count
if !@stop_anime
src_rect.set(@frame_num * @frame_size, 0, @frame_size,
@frame_size)
else
src_rect.set(self.bitmap.width - @frame_size, 0, @frame_size,
@frame_size)
end
@frame_num += 1
if @victory and @frame_num == @num_frames - 1
@stop_anime = true
end
if @frame_num == @num_frames and !@victory
@frame_num = 0
@reload = true
if @attacking
@battler.moving = true
@battler.target_x = @battler.screen_x
@battler.target_y = @battler.screen_y
end
end
end
# ???????????????????????
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
if @reload == false
@reload = @battler.move_init || @battler.attack || @battler.skill || @battler.item
end
if !@victory and @battler.animated and @reload
@reload = false
if @battler.move_init
@battler.move_init = false
weapon = $data_weapons[@battler.weapon_id]
if weapon != nil and weapon.element_set.include?($RANGED_ELEMENT)
@battler.moving = false
@battler.attack = true
@battler.target.attack_effect(@battler)
else
if self.x < @battler.target_x
@battler.target_x -= @frame_size / 2
else
@battler.target_x += @frame_size / 2
end
slope = (@battler.target_y.to_f - @battler.actual_y.to_f) / (@battler.target_x.to_f - @battler.actual_x.to_f)
if slope < 0
slope = -slope
end
@move_x = Math.sqrt((@move_speed * @move_speed) / (slope * slope + 1))
@move_y = slope * @move_x
end
end
# ***ccoa*** Victory? Guarding? Attacking? Using a skill?
if @battler_dead
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_dead",
@battler_hue)
elsif @battler.victory
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_victory",
@battler_hue)
@battler.victory = false
@update_speed += 2
@frame_size = self.bitmap.height
@num_frames = self.bitmap.width / @frame_size
@frame_num = 0
@victory = true
elsif @battler.guarding?
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_guard",
@battler_hue)
elsif @battler.moving
if @attacking
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_movefrom",
@battler_hue)
else
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_moveto",
@battler_hue)
end
elsif @battler.attack
if @game_actor
# if the battler is armed, use that weapon's attack animation
weapon = $data_weapons[@battler.weapon_id]
if (weapon != nil)
# battler is armed
picture_name = @battler.battler_name + "_attack_" +
weapon.name.gsub(' ', '_')
if !File.exists?("Graphics/Battlers/" + picture_name + ".png")
# no animation for this weapon, use the default
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_attack_default",
@battler_hue)
else
self.bitmap = RPG::Cache.battler(picture_name, @battler_hue)
end
else
# battler is unarmed
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_attack",
@battler_hue)
end
else
# battler is an enemy
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_attack",
@battler_hue)
end
@battler.attack = false
@attacking = true
$scene.external_wait = true
elsif @battler.skill
if @game_actor
# If we're using individual animations for skills
if $USING_INDIV_SKILL_ANIM
skill = $data_skills[@battler.current_action.skill_id]
picture_name = @battler.battler_name + "_skill_" + skill.name.gsub(" ", "_")
# does an animation for this skill exist?
if !File.exists?("Graphics/Battlers/" + picture_name + ".png")
# If not, see if one for the skill type exists
picture_name = @battler.battler_name + "_skill_" + @battler.skill_kind.gsub(" ", "_")
if !File.exists?("Graphics/Battlers/" + picture_name + ".png")
# Neither exists, use the default
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_skill_default",
@battler_hue)
else
# skill type
self.bitmap = RPG::Cache.battler(picture_name, @battler_hue)
end
else
# individual skill animation
self.bitmap = RPG::Cache.battler(picture_name, @battler_hue)
end
else # using animation by skill type
picture_name = @battler.battler_name + "_skill_" + @battler.skill_kind
if !File.exists?("Graphics/Battlers/" + picture_name + ".png")
# use the default, no animation for this skill
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_skill_default",
@battler_hue)
else
# skill type
self.bitmap = RPG::Cache.battler(picture_name, @battler_hue)
end
end
else # battler is an enemy
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_skill",
@battler_hue)
end
@battler.skill = false
elsif @battler.item and @game_actor # using an item
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_item",
@battler_hue)
@battler.item = false
elsif @game_actor and @battler.low_hp? # low hp animation
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_lowhp",
@battler_hue)
else # ready animation
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_ready",
@battler_hue)
end
if !@stop_anime
@frame_num = 0
@frame_size = self.bitmap.height
@num_frames = self.bitmap.width / @frame_size
src_rect.set(@frame_num * @frame_size, 0, @frame_size,
@frame_size)
end
end
if @battler.blink
blink_on
else
blink_off
end
# ??????
unless @battler_visible
# ??
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@battler_visible = true
@battler_dead = false
end
end
# ?????
if @battler_visible
# ??
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
# ***ccoa***
# hit and miss animations
if @battler.damage != nil and @battler.animated
if !(@battler.damage.is_a?(String) or @battler.damage == "Miss") and
@battler.damage > 0
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_hit",
@battler_hue)
@reload = true
@frame_num = 0
@frame_size = self.bitmap.height
@num_frames = self.bitmap.width / @frame_size
if !@stop_anime
src_rect.set(@frame_num * @frame_size, 0, @frame_size,
@frame_size)
end
elsif @battler.damage.is_a?(String) and @battler.damage == "Miss" and
@game_actor
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_miss",
@battler_hue)
@reload = true
@frame_num = 0
@frame_size = self.bitmap.height
@num_frames = self.bitmap.width / @frame_size
if !@stop_anime
src_rect.set(@frame_num * @frame_size, 0, @frame_size,
@frame_size)
end
end
@battler.animation_hit = false
end
if @battler.white_flash
whiten
@battler.white_flash = false
end
# ???????
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
animation(animation, @battler.animation_hit)
@battler.animation_id = 0
end
# ????
if @battler.damage_pop
damage(@battler.damage, @battler.critical)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# ????
if @battler.damage == nil and @battler.dead?
if !@game_actor
$game_system.se_play($data_system.enemy_collapse_se)
collapse
@battler_visible = false
else
if @battler_dead == false
@battler_dead = true
$game_system.se_play($data_system.actor_collapse_se)
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_dead",
@battler_hue)
@frame_num = 0
@frame_size = self.bitmap.height
@num_frames = self.bitmap.width / @frame_size
end
end
end
end
if @battler.moving
if !@battler.animated
@battler.moving = false
@battler.target.attack_effect(@battler)
$scene.external_wait = false
else
if @battler.actual_x < @battler.target_x
#battler is to the left of the target
@battler.actual_x += @move_x
if @battler.actual_x > @battler.target_x
@battler.actual_x = @battler.target_x
end
else
# battler is to the right of the target
@battler.actual_x -= @move_x
if @battler.actual_x < @battler.target_x
@battler.actual_x = @battler.target_x
end
end
if @battler.actual_y < @battler.target_y
# battler is above the target
@battler.actual_y += @move_y
if @battler.actual_y > @battler.target_y
@battler.actual_y = @battler.target_y
end
else
# battler is below the target
@battler.actual_y -= @move_y
if @battler.actual_y < @battler.target_y
@battler.actual_y = @battler.target_y
end
end
self.x = @battler.actual_x
self.y = @battler.actual_y
if self.x == @battler.target_x and self.y == @battler.target_y
@battler.moving = false
$scene.external_wait = false
if @attacking
@attacking = false
@reload = true
else
@battler.attack = true
@reload = true
@battler.target.attack_effect(@battler)
end
end
end
else
self.x = @battler.actual_x
self.y = @battler.actual_y
end
end
def setup
if @battler != nil
if @battler.animated
self.bitmap = RPG::Cache.battler(@battler.battler_name + "_ready",
@battler_hue)
else
self.bitmap = RPG::Cache.battler(@battler.battler_name, @battler_hue)
end
@frame_size = self.bitmap.height
@num_frames = self.bitmap.width / @frame_size
@game_actor = @battler.is_a?(Game_Actor)
@battler.actual_x = @battler.screen_x
@battler.actual_y = @battler.screen_y
@initialized = true
end
end
end[/COLOR]
And this is the code I would like to work with the one above... if it is possible.
The code belove is simply the a part of the code form ccoas CBS "spirte_battler".
Code:
[COLOR=green]# If we're using visible weapons, better get that, too
if $USING_VISIBLE_WEAPONS and weapon != nil
weapon_poses = []
weapon_name = weapon.name.sub(" ", "_")
for string in @pose_names
weapon_poses.push("_" + weapon_name + string)
end
end
else # the battler is an enemy. Much simpler.
if !@battler.animated
return
end
@pose_names = ["_ready", "_guard", "_hit", "_miss", "_skill", "_attack",
"_lowhp", "_moveto", "_movefrom"]
end
bitmaps = []
height = width = 0
@frame_height = 0
@frames = []
weapon_bitmaps = []
dummy_image = Bitmap.new(1, 1)
for i in 0...@pose_names.size
begin
RPG::Cache.battler(@battler.battler_name + @pose_names[i], @battler.battler_hue)
bitmaps[i] = RPG::Cache.battler(@battler.battler_name + @pose_names[i], @battler.battler_hue)
height += bitmaps[i].height
width = [width, bitmaps[i].width].max
@frames[i] = bitmaps[i].width / bitmaps[i].height
@frame_height = bitmaps[i].height
if $USING_VISIBLE_WEAPONS and @game_actor
begin
weapon_bitmaps[i] = RPG::Cache.battler(@battler.battler_name + weapon_poses[i], @battler.battler_hue)
rescue
weapon_bitmaps[i] = dummy_image
end
end
if @pose_names[i].include?("attack")
@battler.attack_frames = @frames[i]
end
rescue
bitmaps[i] = nil
height += @frame_height
@frames[i] = 0
end
end
@sprite_sheet = Bitmap.new(width, height)
mark = 0
for i in 0..bitmaps.size
if bitmaps[i] != nil
if $USING_VISIBLE_WEAPONS and @game_actor
@sprite_sheet.blt(0, mark, bitmaps[i], bitmaps[i].rect)
@sprite_sheet.blt(0, mark, weapon_bitmaps[i], weapon_bitmaps[i].rect)
else
@sprite_sheet.blt(0, mark, bitmaps[i], bitmaps[i].rect)
end
end
mark += @frame_height
end
end
end[/COLOR]
Just so you all know, all of you here on RMXP ROCKS! ;D
Kisses
Susanna