Skip to content

Instantly share code, notes, and snippets.

@surusek
Created April 16, 2021 22:26
Show Gist options
  • Save surusek/6f217f1fc5620047ff95195607a2d9e2 to your computer and use it in GitHub Desktop.
Save surusek/6f217f1fc5620047ff95195607a2d9e2 to your computer and use it in GitHub Desktop.
#==============================================================================
# Simple Sideview (Sideview - walking graphic version) ver. 1.44
# Custom version for |Eden| project
#
# Copyright (C) 2005 パラ犬 (Parainu) <http://para.j-mx.com>
# Copyright (c) 2021 surusek <surusek [at] outlook [dot] com>
#
# (This is only summary of usage terms; original text can be found at
# <http://para.j-mx.com/rgss/index.html>).
#
# * You don't have to credit author in the game itself, unless the game
# is released for contest/game jam/similar event.
# * You can't use this script for commerial purposes.
# * You can modify and redistribute this script freely, if you provide
# a instructions on how to download the original version.
#
# Link to the original: <http://para.j-mx.com/rgss/script/sdva.html>.
#==============================================================================
module SDVA
PartyPosition = [
[500, 232], # First character X/Y coordinates
[516, 248], # Second character X/Y coordinates...
[532, 256],
[548, 264],
[0, 0],
[0, 0],
[0, 0],
[0, 0]
]
# Animate (move by given amount of steps), when:
MoveOnAttack = true # attacking?
MoveOnSkill = true # using skill?
MoveOnUsingItem = false # using item?
# How many steps?
AnimSteps = 1
# How big, in pixels, step is?
PixelsPerStep = 10
# Face direction during a battle (0: Up; 1: Left; 2: Right; 3: Down)
FaceDirection = 1
# Change battle option selection window position to be near the character?
WindowNearCharacter = true
end
#==============================================================================
# * Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# Returns character's X coord
#--------------------------------------------------------------------------
def screen_x
# If it is safe to get that stuff, get it
if self.index != nil
scr_x = SDVA::PartyPosition[self.index][0]
# Apply shift (steps) if nessesary
if self.current_action.move_action == true
scr_x += @shift_x
end
return scr_x
else
return 0
end
end
#--------------------------------------------------------------------------
# Returns character's Y coord
#--------------------------------------------------------------------------
def screen_y
# If it is safe to get that stuff, get it
if self.index != nil
scr_y = SDVA::PartyPosition[self.index][1]
# Apply shift (steps) if nessesary
if self.current_action.move_action == true
scr_y += @shift_y
end
return scr_y
else
return 0
end
end
#--------------------------------------------------------------------------
# Returns character's Z coord
#--------------------------------------------------------------------------
def screen_z
if self.index != nil
return self.index
else
return 0
end
end
end
#==============================================================================
# * Game_Battler (???? 1)
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Setup readers and accessors
#--------------------------------------------------------------------------
attr_reader :pattern # ????—?
attr_reader :trans_x # X???????
attr_reader :moving # ??????
#--------------------------------------------------------------------------
# * Script initialization
#--------------------------------------------------------------------------
alias initialize_sdva initialize
def initialize
initialize_sdva
move_reset
end
#--------------------------------------------------------------------------
# 0 ??????
#--------------------------------------------------------------------------
def move
@moving = 1
if @step < SDVA::AnimSteps
# ??????????
@pattern = (@pattern + 1) % 4
@step += 1
move_step
else
# ????
@pattern = 1
@moving = 2
end
end
#--------------------------------------------------------------------------
# 0 ????
#--------------------------------------------------------------------------
def move_step
# ?—?????????????????
case SDVA::FaceDirection
when 0
@shift_y = @step * SDVA::PixelsPerStep
when 1
@shift_x = -(@step * SDVA::PixelsPerStep)
when 2
@shift_x = @step * SDVA::PixelsPerStep
when 3
@shift_y = -(@step * SDVA::PixelsPerStep)
end
end
#--------------------------------------------------------------------------
# 0 ???????
#--------------------------------------------------------------------------
def move_reset
@moving = 0
@pattern = 0
@step = 0
@shift_x = 0
@shift_y = 0
end
end
#==============================================================================
# * Game_BattleAction
#==============================================================================
class Game_BattleAction
#--------------------------------------------------------------------------
# ? ??????????
#--------------------------------------------------------------------------
attr_accessor :move_action # ??????????
#--------------------------------------------------------------------------
# ? ???
#--------------------------------------------------------------------------
alias clear_sdva clear
def clear
clear_sdva
@move_action = false
end
end
#==============================================================================
# * Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ? ??—???
#--------------------------------------------------------------------------
alias update_sdva update
def update
# ???—????—???????
if @battler.is_a?(Game_Actor)
# ????????????????????
# ??????
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue or
@battler.current_action.basic == 0 or
@battler.current_action.kind != 5
# ????????????
@character_name = @battler.character_name
@character_hue = @battler.character_hue
# ???????????
self.bitmap = RPG::Cache.character(@character_name, @character_hue)
cw = self.bitmap.width / 4
ch = self.bitmap.height / 4
@width = cw
@height = ch
if @battler.current_action.move_action == true
# ????
@battler.move
else
@battler.move_reset
end
# ?????????
sx = @battler.pattern * cw
sy = SDVA::FaceDirection * ch
self.src_rect.set(sx, sy, cw, ch)
self.ox = @width / 2
self.oy = @height
# ??????????? 0 ???
if @battler.hidden
self.opacity = 0
end
end
end
update_sdva
end
end
#==============================================================================
# * Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ? ???—????????????????
#--------------------------------------------------------------------------
alias phase3_setup_command_window_sdva phase3_setup_command_window
def phase3_setup_command_window
phase3_setup_command_window_sdva
if SDVA::WindowNearCharacter
# ???—???????????????
case SDVA::FaceDirection
when 0
x_pos = @active_battler.screen_x - (@actor_command_window.width/2)
y_pos = @active_battler.screen_y
when 1
x_pos = @active_battler.screen_x - @actor_command_window.width - 16
y_pos = @active_battler.screen_y - @actor_command_window.height
when 2
x_pos = @active_battler.screen_x + 16
y_pos = @active_battler.screen_y - @actor_command_window.height
when 3
x_pos = @active_battler.screen_x - (@actor_command_window.width/2)
y_pos = @active_battler.screen_y - @actor_command_window.height - 48
end
@actor_command_window.x = x_pos >= 0 ? x_pos : 0
@actor_command_window.x = x_pos+@actor_command_window.width <= 768 ? x_pos : 768-@actor_command_window.width
@actor_command_window.y = y_pos >= 0 ? y_pos : 0
@actor_command_window.y = y_pos+@actor_command_window.height <= 512 ? y_pos : 512-@actor_command_window.height
# ??—???????????????
@actor_command_window.z = 9999
end
end
#--------------------------------------------------------------------------
# ? ??—??? (?????—? ???? 3 : ??????—???)
#--------------------------------------------------------------------------
alias update_phase4_step3_sdva update_phase4_step3
def update_phase4_step3
if SDVA::MoveOnAttack
if @active_battler.current_action.basic == 0
@active_battler.current_action.move_action = true
end
end
if SDVA::MoveOnSkill
if @active_battler.current_action.kind == 1
@active_battler.current_action.move_action = true
end
end
if SDVA::MoveOnUsingItem
if @active_battler.current_action.kind == 2
@active_battler.current_action.move_action = true
end
end
# ???—????—?????????????
if @active_battler.is_a?(Game_Actor) and
@active_battler.current_action.move_action
# ?????
if @active_battler.moving == 2
update_phase4_step3_sdva
elsif @active_battler.moving == 0
update_phase4_step3_sdva
end
end
end
#--------------------------------------------------------------------------
# ? ??—??? (?????—? ???? 6 : ??????)
#--------------------------------------------------------------------------
alias update_phase4_step6_sdva update_phase4_step6
def update_phase4_step6
@active_battler.current_action.move_action = false
@active_battler.move_reset
update_phase4_step6_sdva
end
end
#==============================================================================
# * Spriteset_Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ? ?????????
#--------------------------------------------------------------------------
alias initialize_sdva initialize
def initialize
initialize_sdva
@viewport2.z = 1
end
end
#==============================================================================
# * Arrow_Actor
#==============================================================================
class Arrow_Actor < Arrow_Base
#--------------------------------------------------------------------------
# ? ??—???
#--------------------------------------------------------------------------
alias update_sdva update
def update
update_sdva
# ?—???
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@index += 1
@index %= $game_party.actors.size
end
# ?—???
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@index += $game_party.actors.size - 1
@index %= $game_party.actors.size
end
end
end
#==============================================================================
# * Arrow_Enemy
#==============================================================================
class Arrow_Enemy < Arrow_Base
#--------------------------------------------------------------------------
# ? ??—???
#--------------------------------------------------------------------------
alias update_sdva update
def update
update_sdva
# ?—???
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
# ?—???
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += $game_troop.enemies.size - 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment