Skip to content

Instantly share code, notes, and snippets.

@kl
Created December 26, 2011 15:04
Show Gist options
  • Save kl/1521342 to your computer and use it in GitHub Desktop.
Save kl/1521342 to your computer and use it in GitHub Desktop.
Port of IEX(Icy Engine Xelion) - Party Shift to VX Ace
#==============================================================================#
# ** IEX(Icy Engine Xelion) - Party Shift (VX Ace)
#------------------------------------------------------------------------------#
# ** Created by : IceDragon ([url="http://www.rpgmakervx.net/"]http://www.rpgmakervx.net/[/url])
# ** Script-Status : Addon
# ** Date Created : 10/19/2010
# ** Date Modified : 11/10/2010
# ** VX Ace port by : Kal
# ** Date Modified : 12/26/2011
# ** Version : 1.1
#------------------------------------------------------------------------------#
#==============================================================================#
# ** INTRODUCTION
#------------------------------------------------------------------------------#
# >.> This is a pretty nice script, perfect for dungeon crawling.
# Anyway, this was orignally made for use with Yggdrasil, it adds the
# ability to shift the party while on map.
# There is also a party recovery feature.
# While on map the parties hp and or mp will recover at a rate you set.
#
#------------------------------------------------------------------------------#
#==============================================================================#
# ** COMPATABLITIES
#------------------------------------------------------------------------------#
#
# IEX - Yggdrasil (Reccommended for)
#
#------------------------------------------------------------------------------#
#==============================================================================#
# ** CHANGE LOG
#------------------------------------------------------------------------------#
#
# 10/20/2010 - V1.0 Finished Script
# 11/10/2010 - V1.0 Fixed up Header
#
#------------------------------------------------------------------------------#
#==============================================================================#
# ** KNOWN ISSUES
#------------------------------------------------------------------------------#
# This script will not work with YEZ - Party System.
# YEZ - Party System LOCKS the party order.
#
#------------------------------------------------------------------------------#
$imported ||= {}
$imported["IEX_Party_Shift"] = true
#==============================================================================#
# ** IEX::PARTY_SHIFT
#------------------------------------------------------------------------------#
#==============================================================================#
module IEX
module PARTY_SHIFT
#==============================================================================
# Start Customization
#------------------------------------------------------------------------------
#==============================================================================
SHIFT_ANIMATION_ID = 81 # Animation played when shifting, set to nil or false if unused
SHIFT_WAIT = 120 # Time between party shifts in frames (60f = 1s)
SHIFT_IF_DEAD = true # If first member is dead, should a shift occur
SKIP_DEAD = true # If shifting and a dead member is set, should it skip?
MOVE_ON_SHIFT = true # Should the player move when shifting, if true a step is down
MOVE_DISTANCE = 0.5 # The distance the player should move when shifting
RECOVER_SHIFT = true # Should members of the party recover slowly
RECOVER_ACTIVE = true # Should the first member recover also
RECOVER_HP = true # Should Hp Be recovered
RECOVER_MP = true # Should Mp Be recovered
RECOVER_DEAD = false # If dead, should they recover, this is not reccommended for ABS
NO_RECOVER_MOVE = true # If moving, the party will not recover
RECOVER_PERCENT = 1 # Percentage to recover each time
RECOVER_TIME = 20 # In frames
SHIFT_BUTTON_L = Input::L
SHIFT_BUTTON_R = Input::R
#==============================================================================
# End Customization
#------------------------------------------------------------------------------
#==============================================================================
end
end
#==============================================================================#
# ** Game_System
#------------------------------------------------------------------------------#
#==============================================================================#
class Game_System
attr_accessor :shift_recover_time
alias iex_party_shift_gs_initialize initialize
def initialize(*args)
iex_party_shift_gs_initialize(*args)
@shift_recover_time = 0
end
end
#==============================================================================#
# ** Game_Party
#------------------------------------------------------------------------------#
#==============================================================================#
class Game_Party < Game_Unit
def iex_party_shift
@actors.push(@actors.shift)
end
def iex_party_unshift
@actors.unshift(@actors.pop)
end
def iex_party_shift_party_recover_percent(active_rec = true,
percent = 0,
hp_recover = true,
mp_recover = false,
dead_recover = true)
members.each do |actor|
unless (actor == members.first && !active_rec) ||
(actor.dead? && !dead_recover)
actor.hp += [(percent * actor.mhp / 100).to_i, 1].max if hp_recover
actor.mp += [(percent * actor.mmp / 100).to_i, 1].max if mp_recover
end
end
end
end
#==============================================================================#
# ** Game_Player
#------------------------------------------------------------------------------#
#==============================================================================#
class Game_Player < Game_Character
attr_accessor :iex_shift_wait
alias iex_party_shift_initialize initialize
def initialize(*args)
iex_party_shift_initialize(*args)
@iex_shift_wait = 0
end
def can_perform_shift?
if $game_map.interpreter.running? || $game_message.visible
false
else
true
end
end
alias iex_party_shift_update update
def update(*args)
iex_party_shift_update(*args)
if can_perform_shift? && $game_party.members.first != nil
iex_perform_shift
if $game_party.members.first.dead?
if IEX::PARTY_SHIFT::SHIFT_IF_DEAD && !$game_party.all_dead?
iex_check_shift_input
end
else
iex_check_shift_input
end
end
end
def iex_perform_shift
if key = @shift_button_pressed
key == :r ? iex_party_shift : iex_party_unshift
iex_reset_shift_wait
@shift_button_pressed = false
end
end
def iex_check_shift_input
if @iex_shift_wait <= 0
if Input.trigger?(IEX::PARTY_SHIFT::SHIFT_BUTTON_R)
iex_half_backward if IEX::PARTY_SHIFT::MOVE_ON_SHIFT
@shift_button_pressed = :r
elsif Input.trigger?(IEX::PARTY_SHIFT::SHIFT_BUTTON_L)
iex_half_backward if IEX::PARTY_SHIFT::MOVE_ON_SHIFT
@shift_button_pressed = :l
end
else
@iex_shift_wait -= 1
end
end
def iex_reset_shift_wait
@iex_shift_wait = IEX::PARTY_SHIFT::SHIFT_WAIT
end
def iex_party_shift
iex_party_shift_base(:shift)
end
def iex_party_unshift
iex_party_shift_base(:unshift)
end
def iex_party_shift_base(method)
Sound.play_cursor
if IEX::PARTY_SHIFT::SHIFT_ANIMATION_ID
@animation_id = IEX::PARTY_SHIFT::SHIFT_ANIMATION_ID
end
$game_party.send("iex_party_#{method}")
refresh
end
#--------------------------------------------------------------------------
# * Half Down
#--------------------------------------------------------------------------
def iex_half_down(turn_ok = true)
iex_half_base(2, turn_ok)
end
#--------------------------------------------------------------------------
# * Half Left
#--------------------------------------------------------------------------
def iex_half_left(turn_ok = true)
iex_half_base(4, turn_ok)
end
#--------------------------------------------------------------------------
# * Half Right
#--------------------------------------------------------------------------
def iex_half_right(turn_ok = true)
iex_half_base(6, turn_ok)
end
#--------------------------------------------------------------------------
# * Half Up
#--------------------------------------------------------------------------
def iex_half_up(turn_ok = true)
iex_half_base(8, turn_ok)
end
def iex_half_base(direction, turn_ok)
set_direction(direction) if turn_ok
case direction
when 2
@real_y += IEX::PARTY_SHIFT::MOVE_DISTANCE
when 8
@real_y -= IEX::PARTY_SHIFT::MOVE_DISTANCE
when 4
@real_x -= IEX::PARTY_SHIFT::MOVE_DISTANCE
when 6
@real_x += IEX::PARTY_SHIFT::MOVE_DISTANCE
end
@move_failed = false
end
#--------------------------------------------------------------------------
# * Half Backward
#--------------------------------------------------------------------------
def iex_half_backward
last_direction_fix = @direction_fix
@direction_fix = true
case @direction
when 2; iex_half_up
when 4; iex_half_right
when 6; iex_half_left
when 8; iex_half_down
end
@direction_fix = last_direction_fix
end
end
#==============================================================================#
# ** Scene_Map
#------------------------------------------------------------------------------#
#==============================================================================#
class Scene_Map < Scene_Base
alias iex_party_shift_anim_scm_update update
def update(*args)
iex_party_shift_anim_scm_update(*args)
if IEX::PARTY_SHIFT::RECOVER_SHIFT
unless $game_system.shift_recover_time == 0
$game_system.shift_recover_time -= 1
else
unless $game_message.visible
unless $game_player.moving? && IEX::PARTY_SHIFT::NO_RECOVER_MOVE
$game_party.iex_party_shift_party_recover_percent(
IEX::PARTY_SHIFT::RECOVER_ACTIVE,
IEX::PARTY_SHIFT::RECOVER_PERCENT,
IEX::PARTY_SHIFT::RECOVER_HP,
IEX::PARTY_SHIFT::RECOVER_MP,
IEX::PARTY_SHIFT::RECOVER_DEAD)
$game_system.shift_recover_time = IEX::PARTY_SHIFT::RECOVER_TIME
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment