05-30-2012, 11:56 AM
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