| Membre royal(e) |
 |
Inscrit le: 05 Avr 2008, 00:00 Messages: 643 Niveau RPG Maker: Bon Logiciel(s) préféré(s): RMXP Point(s) Fort(s): Ruby, Scénario Sexe: Masculin Points d'aide: 8/60
Créations :
Voir ses créations
|
Sprite System part 1 - Code: Tout sélectionner
#============================================================================== # ** Animated Battlers VX ver. 2.4 (05-11-2008) # #------------------------------------------------------------------------------ # * (2) Sprite System: The Sprite Battler Class #==============================================================================
#============================================================================== # ** Sprite_Battler #------------------------------------------------------------------------------ # This sprite is used to display battlers. It observes a instance of the # Game_Battler class and automatically changes sprite conditions. #==============================================================================
class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :battler_offset # Degree of action forcing #-------------------------------------------------------------------------- # * Alias Listings #-------------------------------------------------------------------------- alias abatvx_initialize initialize alias abatvx_update update alias abatvx_update_effect update_effect #-------------------------------------------------------------------------- # * Initialize #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) # --Initialize poses @frame, @pose, @last_time, @last_move_time = 0, 0, 0, 0 # --Initialize Battler placement and pose types @battler_offset, @abatvx_skill_used, @abatvx_item_used = 0, 0, 0 # --Initialize Boolean values @s_pose, @winning, @dying, = false, true, true $game_system.abatvx_victory, $game_system.abatvx_defeat = false, false # Perform the original call abatvx_initialize(viewport, battler) # Reacess the viewport viewport.z = 99 end #-------------------------------------------------------------------------- # * Update #-------------------------------------------------------------------------- def update # Only update for battler functions return unless @battler # Reset battler if battler graphic changed if @battler.battler_name != @battler_name @started = false end # Perform the original call abatvx_update # Set Translucency if @battler.is_a?(Game_Enemy) battler_translucency(@battler, MNK_TRANSLUCENT_ENEMY) else battler_translucency(@battler, MNK_TRANSLUCENT_ACTOR) end # Start Routine unless @started # Set the pose based on battler's state @pose = state # Configure Enemy Spritesheet if @battler.is_a?(Game_Enemy) # Use spritesheet unless specified unless DEFAULT_ENEMY or DEFAULT_ENEMY_ID.include?(sprite_id) @width = @width / cell_divider(MNK_FRAMES_ENEMY, MNK_FRAMES) @height = @height / cell_divider(MNK_POSES_ENEMY, MNK_POSES) end # Or Configure Actor Spritesheet else # Use spritesheet unless specified unless DEFAULT_ACTOR or DEFAULT_ACTOR_ID.include?(sprite_id) @width = @width / cell_divider(MNK_FRAMES_ACTOR, MNK_FRAMES) @height = @height / cell_divider(MNK_POSES_ACTOR, MNK_POSES) end end # Distance the battlers @battler_offset = @width * 0.75 @display_x = @battler.screen_x @display_y = @battler.screen_y @display_z = @battler.screen_z @destination_x = @display_x @destination_y = @display_y @destination_z = @display_z @battler.abatvx_bypass_x = @display_x @battler.abatvx_bypass_y = @display_y # Hide if dead self.visible = false if @battler.dead? end # Again, ensure a pose is set @pose = state if @pose == nil # Obtain animation cell/frame from Enemy if @battler.is_a?(Game_Enemy) # Use spritesheet cell unless specified unless DEFAULT_ENEMY or DEFAULT_ENEMY_ID.include?(sprite_id) cell_obtain self.src_rect.set(@width * @frame, @height * @pose, @width, @height) else self.src_rect.set(0, 0, @width, @height) end # Or get it from an actor else # Use spritesheet cell unless specified unless DEFAULT_ACTOR or DEFAULT_ACTOR_ID.include?(sprite_id) cell_obtain self.src_rect.set(@width * @frame, @height * @pose, @width, @height) else self.src_rect.set(0, 0, @width, @height) end end # Mirror the sprites depending on surprise/ambush if @battler.is_a?(Game_Actor) mirror_pose_surprised else if MNK_MIRROR_ENEMIES mirror_pose_ambushed(true) else mirror_pose_ambushed(false) end end # Setup Frames per Pose poseframe = MNK_FRAMES_STANDARD if @battler.is_a?(Game_Actor) poseframe = cell_divider(MNK_FRAMES_ACTOR, MNK_FRAMES_STANDARD) if cell_divider(MNK_FRAMES_ACTOR, MNK_FRAMES_STANDARD) != nil else poseframe = cell_divider(MNK_FRAMES_ENEMY, MNK_FRAMES_STANDARD) if cell_divider(MNK_FRAMES_ENEMY, MNK_FRAMES_STANDARD) != nil end pose_chk = 0 pose_chk = @pose + 1 if @pose != nil poseframe = MNK_FRAMES_PER_POSE[pose_chk] if MNK_FRAMES_PER_POSE.include?(pose_chk) # Set Advanced Poses for Actors if @battler.is_a?(Game_Actor) pose_temp = [] pose_temp = MNK_POSES_FR_ACTOR[sprite_id] if MNK_POSES_FR_ACTOR.include?(sprite_id) poseframe = pose_temp[pose_chk] if pose_temp.include?(pose_chk) end # Set Advanced Poses for Enemies if @battler.is_a?(Game_Enemy) pose_temp = [] pose_temp = MNK_POSES_FR_ENEMY[sprite_id] if MNK_POSES_FR_ENEMY.include?(sprite_id) poseframe = pose_temp[pose_chk] if pose_temp.include?(pose_chk) end # Position Sprite self.x = @display_x self.y = @display_y self.z = @display_z @battler.abatvx_bypass_x = @display_x @battler.abatvx_bypass_y = @display_y self.ox = @width / 2 self.oy = @height # Make visible if returned to life unless @battler.dead? self.visible = true @freeze = false unless $game_system.abatvx_victory end # Setup Animation time = Graphics.frame_count / (Graphics.frame_rate / MNK_SPEED) if @last_time < time @frame = (@frame + 1) % poseframe if @frame == 0 or @reload if @freeze @frame = MNK_FRAMES - 1 return end @pose = state end end @last_time = time # Perform Setup routine if alive unless @battler.dead? if @s_pose == false tmp_pose = pose_obtain(MNK_POSES_SETUP, MNK_POSES_SETUP_A, MNK_POSES_SETUP_E) if tmp_pose != nil @pose = tmp_pose @s_pose = true end end # Else set dying states else if @dying == true @pose = state @dying = false end end # If Victory pose (Who's your daddy?) if @battler.is_a?(Game_Actor) && $game_system.abatvx_victory == true && @winning == true @pose = state @winning = false elsif @battler.is_a?(Game_Enemy) && $game_system.abatvx_defeat == true && @winning == true @pose = state @winning = false end # Move the sprite move if moving # Finish Up @started = true end #-------------------------------------------------------------------------- # * Update Effect #-------------------------------------------------------------------------- def update_effect @collapsed = false @collapsed = true if @effect_duration > 0 && @effect_type == COLLAPSE # Perform the original call abatvx_update_effect end #-------------------------------------------------------------------------- # * Current State #-------------------------------------------------------------------------- def state # Set Translucency if not dead unless @battler.dead? if @battler.is_a?(Game_Actor) battler_translucency(@battler, MNK_TRANSLUCENT_ACTOR) else battler_translucency(@battler, MNK_TRANSLUCENT_ENEMY) end end # Set sprite to 'Ready' pose state = pose_obtain(MNK_POSE1, MNK_APOSE1, MNK_EPOSE1) # Set sprite to 'Woozy' pose state = state_woozy if state_woozy != nil # Set sprite to 'Status Ailment' pose state = state_status if state_status != nil # Set sprite to 'Dead' pose state = state_dead if state_dead != nil # Set sprite to 'Block' pose state = pose_obtain(MNK_POSE4, MNK_APOSE4, MNK_EPOSE4) if @battler.guarding? if @battler.is_a?(Game_Actor) # Casting State if @battler.abatvx_delay_casted state = casting_pose if $game_system.abatvx_delay and @battler.sd_casting end end # Victory States if @battler.is_a?(Game_Actor) && $game_system.abatvx_victory if @winning == true state = winning_pose unless @battler.dead? && winning_pose == nil else state = victory_pose unless @battler.dead? end end # Defeat States if @battler.is_a?(Game_Enemy) && $game_system.abatvx_defeat if @winning == true state = winning_pose unless @battler.dead? && winning_pose == nil else state = victory_pose unless @battler.dead? end end # If Battler Dead if @battler.dead? # Fix Opacity if @battler.is_a?(Game_Enemy) && MNK_TRANSLUCENT_ENEMY.include?(sprite_id) set_translucency(@battler, MNK_TRANSLUCENCY) elsif @battler.is_a?(Game_Actor) && MNK_TRANSLUCENT_ACTOR.include?(sprite_id) set_translucency(@battler, MNK_TRANSLUCENCY) else set_translucency(@battler, 255) end end # Moving state state = sprite_move if sprite_move != nil # Return State return state end
_________________ "Embrace your dreams, and, whatever happends, protect your honor, AS SOLDIER ! Come and get it !" -Zack Fair -FF7 Crisis Core
|
|