Auto-play Character animation
#1
I seem to be having very poor luck with my code. ANYWAY. I want to play out the sequence of sprites in Character file, keeping the same direction, but a different file.
PHP Code:
<?php 
#==============================================================================
# ■ Jaabi Module
#==============================================================================
module Jaabi
# Weapons
SHB_WP = {
1 => {
'Id' => 1,
'Damage' => 10,
'Type' => 'Melee',
'Graphic' => '_SWD_01',

[...]

#==============================================================================
# ■ Game_Character
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# ● Alias Functions
#--------------------------------------------------------------------------
alias tayruu_shb_gamecharacter_init initialize
alias tayruu_shb_gamecharacter_update update
#--------------------------------------------------------------------------
# ● Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :knockback
attr_accessor
:defending
attr_accessor
:action_count
attr_accessor
:action_cooldown
attr_accessor
:animation_sprites
attr_accessor
:animation_file
#--------------------------------------------------------------------------
# ● Object Initialisation
#--------------------------------------------------------------------------
def initialize(*args)
tayruu_shb_gamecharacter_init(*args)
@
knockback = false
@defending = false
@move_speed = 3
@action_count = 0
@action_cooldown = 0
@animation_sprites = 0
@animation_file = ""
end
#--------------------------------------------------------------------------
# ● Frame Update
#--------------------------------------------------------------------------
def update
# Call original function
tayruu_shb_gamecharacter_update
# Additions
shb_functions
shb_anim_attack
end
#--------------------------------------------------------------------------
# ● Attack Animation
#--------------------------------------------------------------------------
def shb_anim_attack
# Return if no animation is active
return if @animation_file == ""

if Graphics.frame_count % 2 != 0
@character_name = self.character_name + @animation_file
@pattern = @animation_sprites
@animation_sprites += 1
@wait_count = 8
Graphics
.frame_reset
if @animation_sprites == 5
@animation_sprites = 0
@animation_file = ""
@character_name = self.character_name
end

end

end
end

#==============================================================================
# ■ Game_Player
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ● Alias Functions
#--------------------------------------------------------------------------
alias tayruu_shb_gameplayer_init initialize
alias tayruu_shb_gameplayer_update update
#--------------------------------------------------------------------------
# ● Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :name
attr_accessor
:mea
#--------------------------------------------------------------------------
# ● Object Initialisation
#--------------------------------------------------------------------------
def initialize(*args)
tayruu_shb_gameplayer_init(*args)
@
name = "Player Instance"
@mea = $game_party.actors[0]
@
move_speed = 3
end
#--------------------------------------------------------------------------
# ● Command Initialisation
#--------------------------------------------------------------------------
def shb_commands
return if $game_system.map_interpreter.running? or
$game_temp.message_window_showing or
(
$game_map.starting? && self.facing_enemy == false)

if
$game_system.allow_commands
if Input.trigger?(Input::C) && Input.dir8 == 0 &&
@
action_count == 0
Audio
.se_play(Jaabi::SHB_WP[@mea.weapon_id]['Sound'][0],
Jaabi::SHB_WP[@mea.weapon_id]['Sound'][1],
Jaabi::SHB_WP[@mea.weapon_id]['Sound'][2])
if
Jaabi::SHB_WP[@mea.weapon_id]['Type'] == 'Melee'
SHB.weapon_melee(@mea.weapon_id)
else
SHB.weapon_ranged(@mea.weapon_id)
end
@action_count += 1
@action_cooldown = Jaabi::SHB_WP[@mea.weapon_id]['Cooldown']
@
animation_file = Jaabi::SHB_WP[@mea.weapon_id]['Graphic']
Graphics.frame_reset
return
end

[...]

end
end
end

Here is a few segments of what I have, of particular note are @animation_file = Jaabi::SHB_WP[@mea.weapon_id]['Graphic'] and def shb_anim_attack. Giving @animation_file a value activates shb_anim_attack, which is repeatedly updated to pass through each cell of a Character. That part seems to work, the changing graphic part doesn't.

I feel such a derp, this is probably easily explained. XP
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Animation Action justpassingby 16 18,250 11-06-2017, 01:59 AM
Last Post: justpassingby
   Atoa Custom Battle System CTB animation while cast Noctis 6 10,947 01-04-2016, 03:05 PM
Last Post: Noctis
   Help editing Animation Resizer MechanicalPen 3 6,072 11-22-2012, 08:39 PM
Last Post: MechanicalPen
   Universal Message System (Edit of SE character System) stordarth 0 4,081 06-12-2010, 10:32 PM
Last Post: stordarth
   Need help on Main Character Select Screen Revolver9 0 3,526 03-21-2010, 02:09 PM
Last Post: Revolver9
   Changing the walking animation shadow040 8 11,391 01-30-2010, 04:20 PM
Last Post: shadow040



Users browsing this thread: 1 Guest(s)