#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= # [Xp] Throw System # Version: 1.52 # Author : LiTTleDRAgo #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # # Special Thanks to Moghunter # Ripped from XAS :P # #------------------------------------------------------------------------------ # # The character can pick up and throw objects # # Any event can be thrown if is included in their name field. # Where X is the number of tiles it can be thrown. # # Extra # where X is A,B,C,D (Self switches) activated after # event is throwed # to prevent throwed event to pass through # where X is the time (in seconds) player will drop picked event # # for Blizz ABS # where X is strength of the event to damage enemy # where X is animation ID when event hit the enemy # # # You’ll need two images of your character # [ACTORNAME]_PICK and [ACTORNAME]_TRW # # #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: ($imported ||= {})[:drago_throw_system] = 1.52 #============================================================================== # ■ Game_Character #============================================================================== class Game_Character CANT_THROW_IF_BLOCKED = true TERRAIN_DISABLE_THROW = 8 #-------------------------------------------------------------------------- # Throw action #-------------------------------------------------------------------------- def throw_action(range) jump_range = range dc = $game_player.direction unless jumping? p = jump_range range.times do unless jumping? case dc when 2 then jump(0,jump_range) if throw_event?(0,jump_range,p) when 4 then jump(-jump_range,0) if throw_event?(-jump_range,0,p) when 6 then jump(jump_range,0) if throw_event?(jump_range,0,p) when 8 then jump(0,-jump_range) if throw_event?(0,-jump_range,p) end jump(0,0) if jump_range == 1 return false if jump_range == 1 && CANT_THROW_IF_BLOCKED && [@x,@y] == [$game_player.x,$game_player.y] jump_range -= 1 p -= 1 end end end end #-------------------------------------------------------------------------- # ● Reset Pickup #-------------------------------------------------------------------------- def reset_pickup return if !@pickup_lock @pickup_lock = false @pickup_lock_time = 0 $game_player.sprite_normal unless $BlizzABS $game_map.events.each_value {|event| if event.throw_active event.moveto($game_player.x, $game_player.y) event.throw_active = false event.move_speed = event.pre_move_speed event.jump(0,0) end } end #-------------------------------------------------------------------------- # ● Passable Around? #-------------------------------------------------------------------------- def passable_around?(x,y) direction = [2,4,6,8] direction_passable = [] direction.each {|i| direction_passable.push(i) if passable?(x,y,i) } return true if direction_passable != [] return false end #-------------------------------------------------------------------------- # ● Passable Here? #-------------------------------------------------------------------------- def passable_here?(x,y) return false unless $game_map.passable?(x, y, 0, self) $game_map.events.each_value {|event| if event.x == x and event.y == y return false if event.character_name != "" return false if event.through == false end } return true end #-------------------------------------------------------------------------- # ● Jump Here #-------------------------------------------------------------------------- def jump_here(x,y) return unless passable_here?(x,y) range_x = x - @x range_y = y - @y jump(range_x,range_y) end #-------------------------------------------------------------------------- # ● Jump position #-------------------------------------------------------------------------- def jump_position(x,y) if passable_here?(x,y) jump_here(x,y) else direction = [2,4,6,8] direction_passable = [] d = @direction direction.each {|i| direction_passable.push(i) if passable?(x,y,i) } if direction_passable != [] direction_passable.each {|i| if @direction == 2 && direction_passable.include?(8) @direction = 8 elsif @direction == 8 && direction_passable.include?(2) @direction = 2 elsif @direction == 4 && direction_passable.include?(6) @direction = 6 elsif @direction == 6 && direction_passable.include?(4) @direction = 4 else @direction = i end d = @direction new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) range_x = new_x - @x range_y = new_y - @y jump(range_x,range_y) } end end end #-------------------------------------------------------------------------- # Throw #-------------------------------------------------------------------------- def jump_forward(range) jump_range = range dc = @direction unless jumping? p = jump_range range.times do unless jumping? if dc == 6 jump(jump_range,0) if throw_event?(jump_range,0,p) elsif dc == 4 jump(-jump_range,0) if throw_event?(-jump_range,0,p) elsif dc == 2 jump(0,jump_range) if throw_event?(0,jump_range,p) elsif dc == 8 jump(0,-jump_range) if throw_event?(0,-jump_range,p) end jump(0,0) if jump_range == 1 jump_range -= 1 p -= 1 end end end end #-------------------------------------------------------------------------- # ● front_pos? #-------------------------------------------------------------------------- def front_pos?(x,y) d = @direction new_x = @x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_y = @y + (d == 2 ? 1 : d == 8 ? -1 : 0) return (new_x == x && new_y == y) end #-------------------------------------------------------------------------- # Throw Event? #-------------------------------------------------------------------------- def throw_event?(x_plus, y_plus,p ) dir = $game_player.direction v = 1 org_x = @x + x_plus org_y = @y + y_plus p.times do new_x2 = org_x + (dir == 6 ? -v : dir == 4 ? + v : 0) new_y2 = org_y + (dir == 2 ? -v : dir == 8 ? + v : 0) terrain_disable = $game_map.terrain_tag(new_x2,new_y2) return false if terrain_disable == TERRAIN_DISABLE_THROW $game_map.events.each_value {|event| if event.x == new_x2 && event.y == new_y2 if event.event.name =~ //i && !event.through return false end if $BlizzABS && !event.through && event.is_a?(Map_Enemy) event.animation_id = @animethrow if @animethrow if @atkpow actor = $game_party.actors[0] hp_damage = event.battler.hp atk = event.battler.attack_effect(actor) hp_damage -= event.battler.hp if @atkpow hp_damage += @atkpow.to_i event.battler.hp -= @atkpow.to_i end event.battler.hpdamage = hp_damage.to_i $BlizzABS.util.request_damage_sprite(event) if hp_damage > 0 end return false end end } v += 1 end return true end #-------------------------------------------------------------------------- # ● Passable Around Move? #-------------------------------------------------------------------------- def passable_arround_move?(x,y) direction = [2,4,6,8] direction_passable = [] direction.each {|i| direction_passable.push(i) if passable?(x,y,i) } if direction_passable != [] if direction_passable.include?(@direction) move_forward else direction_passable.each {|i| unless moving? if @direction == 2 and direction_passable.include?(8) @direction = 8 elsif @direction == 8 and direction_passable.include?(2) @direction = 2 elsif @direction == 4 and direction_passable.include?(6) @direction = 6 elsif @direction == 6 and direction_passable.include?(4) @direction = 4 else @direction = i end move_forward end } end end end attr_accessor :pre_move_speed,:pre_walk_anime,:pickup_lock,:pickup_lock_time attr_accessor :real_x,:real_y,:throw_active,:walk_anime,:character_name attr_accessor :throw_active,:throw,:x,:y,:atkpow,:animethrow attr_accessor :move_speed,:pre_move_speed,:through,:thssw,:throwed attr_accessor :step_anime,:pre_step_anime,:carrytime attr_reader :erased end #============================================================================== # ** Game_Player / BlizzABS::Controller #------------------------------------------------------------------------------ # This class handles the party leader. Its functions include event starting # determinants and map scrolling. Some input is processed instantly, # while some is converted into commands to be given to the player character #============================================================================== Klass = $BlizzABS ? BlizzABS::Controller : Game_Player #eval_text = " class Klass if $BlizzABS alias update_for_throwing update_moving alias move_for_throwing move else alias update_for_throwing update end alias pickup_check_event_trigger_there check_event_trigger_there #-------------------------------------------------------------------------- # ● Check Event Pickup #-------------------------------------------------------------------------- def check_event_trigger_there(*args) throw_event(0) pickup_event return if ($game_player.pickup_lock) return if ($game_player.pickup_lock_time || 0) > 0 pickup_check_event_trigger_there(*args) end #-------------------------------------------------------------------------- # ● Update Moving (BlizzABS) #-------------------------------------------------------------------------- def update_moving(*args) update_for_throwing(*args) update_carry_time update_throw_position end #-------------------------------------------------------------------------- # ● Update (Non BlizzABS) #-------------------------------------------------------------------------- def update update_for_throwing update_carry_time update_throw_position end #-------------------------------------------------------------------------- # ● Move (BlizzABS) #-------------------------------------------------------------------------- def move(d) return if ($game_player.pickup_lock_time || 0) > 0 move_for_throwing(d) end #-------------------------------------------------------------------------- # ● Update Carry Time #-------------------------------------------------------------------------- def update_carry_time if ($game_player.pickup_lock_time || 0) > 0 $game_player.pickup_lock_time -= 1 sprite_normal if $game_player.pickup_lock_time == 0 ## end if (@carry_time || 0) > 0 @carry_time -= 1 $game_player.reset_pickup if @carry_time == 0 end end #-------------------------------------------------------------------------- # ● Update Throw Position #-------------------------------------------------------------------------- def update_throw_position all_throw_event.each {|event| if !event.jumping? event.real_x = $game_player.real_x event.real_y = $game_player.real_y - 128 event.x = $game_player.x event.y = $game_player.y sprite_carry end } end #-------------------------------------------------------------------------- # ● Throw Event #-------------------------------------------------------------------------- def throw_event(type) return if !$game_player.pickup_lock return if ($game_player.pickup_lock_time || 0) > 0 return if $game_system.map_interpreter.running? all_throw_event.each {|event| if !event.jumping? next if !event.throw_action(type == 1 ? 1 : event.throw) sprite_throw $game_player.pickup_lock_time = 15 event.throw_active = false $game_player.pickup_lock = false event.move_speed = event.pre_move_speed event.walk_anime = event.pre_walk_anime event.throwed = true $game_player.step_anime = $game_player.pre_step_anime end } end #-------------------------------------------------------------------------- # ● Pickup Event #-------------------------------------------------------------------------- def pickup_event return if $game_player.pickup_lock return if ($game_player.pickup_lock_time || 0) > 0 return if $game_system.map_interpreter.running? $game_map.events.each_value {|event| if event.is_a?(Game_Event) if $game_player.front_pos?(event.x,event.y) next if (event.throw || 0) == 0 next if event.erased || event.through next if !sprite_throw $game_player.pickup_lock_time = 15 event.throw_active = true $game_player.pickup_lock = true event.jump(0,0) event.x = $game_player.x event.y = $game_player.y event.pre_walk_anime = event.walk_anime event.pre_move_speed = event.move_speed event.move_speed = 7 event.walk_anime = false @carry_time = (event.carrytime || 0) * 40 $game_player.pre_step_anime = $game_player.step_anime end end} end #-------------------------------------------------------------------------- # ● all_throw_event #-------------------------------------------------------------------------- def all_throw_event $game_map.events.values.select {|e| e.throw_active } end #-------------------------------------------------------------------------- # ● Sprite Throw #-------------------------------------------------------------------------- def sprite_throw name = $game_party.actors[0].character_name nama = $game_player.character_name graphic = [name,"#{name}_pick","#{name}_idl"].map {|s| s.downcase} if graphic.include?(nama.downcase) if ch_exist?(name + '_TRW') $game_player.character_name = name + '_TRW' end return true end end #-------------------------------------------------------------------------- # ● Sprite Carry #-------------------------------------------------------------------------- def sprite_carry name = $game_party.actors[0].character_name nama = $game_player.character_name graphic = [name,"#{name}_trw","#{name}_idl"].map {|s| s.downcase} if graphic.include?(nama.downcase) if ch_exist?(name + '_PICK') $game_player.character_name = name + '_PICK' end return true end end #-------------------------------------------------------------------------- # ● Normal #-------------------------------------------------------------------------- def sprite_normal name = $game_party.actors[0].character_name nama = $game_player.character_name graphic = ["#{name}_pick","#{name}_trw"].map {|s| s.downcase} if graphic.include?(nama.downcase) $game_player.character_name = name end end #-------------------------------------------------------------------------- # ● Character exist? #-------------------------------------------------------------------------- def ch_exist?(x) return RPG::Cache.character(x, 0) rescue false end end#" #============================================================================ # BlizzABS::Controls #---------------------------------------------------------------------------- # This class handles player input for battle on the map. Some input is # processed instantly, while some is converted into commands to be given to # the player character. #============================================================================ if $BlizzABS eval('class Game_System; def pixel_rate() 0 end end') class BlizzABS::Controls #-------------------------------------------------------------------------- # update # Processes the player's input. #-------------------------------------------------------------------------- alias update_for_throw update def update return if $game_player.pickup_lock update_for_throw end end #============================================================================== # Map_Battler #------------------------------------------------------------------------------ # This class serves as superclass for characters that fight on the map and # can use pixel movement. #============================================================================== class Map_Battler < Game_Character #--------------------------------------------------------------------------- # sprite_movement_animation_setup # Sets up movement sprite handling. #--------------------------------------------------------------------------- alias sprite_movement_animation_setup_throw sprite_movement_animation_setup def sprite_movement_animation_setup return if $game_player.pickup_lock sprite_movement_animation_setup_throw end end end #============================================================================== # ** Interpreter #------------------------------------------------------------------------------ # This interpreter runs event commands. This class is used within the # Game_System class and the Game_Event class. #============================================================================== class Interpreter #-------------------------------------------------------------------------- # * Transfer Player #-------------------------------------------------------------------------- alias throw_command_201 command_201 def command_201 $game_player.reset_pickup throw_command_201 end end #============================================================================== # ■ Game_Event #============================================================================== class Game_Event < Game_Character #-------------------------------------------------------------------------- # ● initialize #-------------------------------------------------------------------------- attr_reader :event alias drago_pickup_initialize initialize def initialize(map_id, event) @throw = $1.to_i if event.name =~ //i @atkpow = $1.to_i if event.name =~ //i @animethrow = $1.to_i if event.name =~ //i @carrytime = $1.to_i if event.name =~ //i @thssw = $1.to_s if event.name =~ //i drago_pickup_initialize(map_id, event) end #-------------------------------------------------------------------------- # ● Throw Action #-------------------------------------------------------------------------- alias upd_for_throw update def update upd_for_throw if @throwed && @thssw && !jumping? $game_self_switches[[$game_map.map_id,@id,@thssw]] = true $game_map.need_refresh = true @throwed = false end end #-------------------------------------------------------------------------- # ● Screen Z #-------------------------------------------------------------------------- alias screen_z_for_throw screen_z def screen_z(h=0) result = screen_z_for_throw(h) result += (2*32) if @throw_active return result end end